mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-30 10:30:08 +00:00
bugfix...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
3d3b76d914
commit
0f7be9d6b8
@ -44,6 +44,8 @@ module.store = {
|
|||||||
}
|
}
|
||||||
//*/
|
//*/
|
||||||
|
|
||||||
|
console.log('---', page.Config)
|
||||||
|
|
||||||
module.setup =
|
module.setup =
|
||||||
Promise.all([
|
Promise.all([
|
||||||
// static stores...
|
// static stores...
|
||||||
|
|||||||
@ -541,40 +541,46 @@ module.BaseParser = {
|
|||||||
ast = typeof(ast) != 'object' ?
|
ast = typeof(ast) != 'object' ?
|
||||||
this.expand(page, ast, state)
|
this.expand(page, ast, state)
|
||||||
: ast
|
: ast
|
||||||
// XXX .awaitOrRun(..) will check inside the array for promises, do
|
// XXX .awaitOrRun(..) will check inside the input array for promises, do
|
||||||
// we need to do this???
|
// we need to do this???
|
||||||
ast = Promise.awaitOrRun(
|
ast = Promise.awaitOrRun(
|
||||||
ast,
|
ast,
|
||||||
function(ast){
|
function(ast){
|
||||||
|
var async_content = false
|
||||||
return ast
|
return ast
|
||||||
// XXX in case of @filter(..) can be a function that
|
|
||||||
// returns a promise...
|
|
||||||
// ...on a sync action this promise does not get a
|
|
||||||
// chance to resolve, and thus its value is lost...
|
|
||||||
// ...should this be fixed here or in filter???
|
|
||||||
// fixing it here -- mark and wrap ast in
|
|
||||||
// Promise's .all(..), .iter(..) or .seqiter(..)
|
|
||||||
// ...I'm leaning to fixing this in @filter(..)
|
|
||||||
.map(function(e){
|
.map(function(e){
|
||||||
// expand delayed sections...
|
// expand delayed sections...
|
||||||
e = typeof(e) == 'function' ?
|
e = typeof(e) == 'function' ?
|
||||||
e.call(page, state)
|
e.call(page, state)
|
||||||
: e
|
: e
|
||||||
|
// promise...
|
||||||
|
if(e instanceof Promise){
|
||||||
|
async_content = true
|
||||||
|
return e
|
||||||
// expand arrays...
|
// expand arrays...
|
||||||
if(e instanceof Array
|
} else if(e instanceof Array
|
||||||
|| e instanceof types.Generator){
|
|| e instanceof types.Generator){
|
||||||
return that.resolve(page, e, state)
|
return that.resolve(page, e, state)
|
||||||
// data -- unwrap content...
|
// data -- unwrap content...
|
||||||
} else if(e instanceof Object && 'data' in e){
|
} else if(e instanceof Object && 'data' in e){
|
||||||
return Promise.awaitOrRun(
|
var res = Promise.awaitOrRun(
|
||||||
that.resolve(page, e.data, state),
|
that.resolve(page, e.data, state),
|
||||||
function(e){
|
function(e){
|
||||||
return { data: e } })
|
return { data: e } })
|
||||||
|
res instanceof Promise
|
||||||
|
&& (async_content = true)
|
||||||
|
return res
|
||||||
// skipped items...
|
// skipped items...
|
||||||
} else if(e instanceof Object && e.skip){
|
} else if(e instanceof Object && e.skip){
|
||||||
return []
|
return []
|
||||||
} else {
|
} else {
|
||||||
return [e] } })
|
return [e] } })
|
||||||
|
// NOTE: if we still have promises in the ast, wrap the
|
||||||
|
// whole thing in a promise...
|
||||||
|
.run(function(){
|
||||||
|
return async_content ?
|
||||||
|
Promise.iter(this)
|
||||||
|
: this })
|
||||||
.flat() })
|
.flat() })
|
||||||
return ast instanceof Promise ?
|
return ast instanceof Promise ?
|
||||||
// keep the API consistently array-like...
|
// keep the API consistently array-like...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user