bobe 0.0.47 → 0.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bobe.cjs.js +46 -14
- package/dist/bobe.cjs.js.map +1 -1
- package/dist/bobe.compiler.cjs.js +46 -14
- package/dist/bobe.compiler.cjs.js.map +1 -1
- package/dist/bobe.compiler.esm.js +44 -11
- package/dist/bobe.compiler.esm.js.map +1 -1
- package/dist/bobe.esm.js +44 -11
- package/dist/bobe.esm.js.map +1 -1
- package/dist/index.d.ts +13 -5
- package/dist/index.umd.js +46 -14
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
|
@@ -81,6 +81,7 @@ class ParseSyntaxError extends SyntaxError {
|
|
|
81
81
|
this.loc = loc;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
+
const isDep = target => target && (target instanceof aoye.Signal || target instanceof aoye.Computed || typeof target === 'function' || typeof target === 'string');
|
|
84
85
|
|
|
85
86
|
class Tokenizer {
|
|
86
87
|
TabSize = 2;
|
|
@@ -1705,7 +1706,7 @@ class Interpreter {
|
|
|
1705
1706
|
_forNode$snapshot.isFirstToken;
|
|
1706
1707
|
const snapshotForUpdate = _objectWithoutProperties(_forNode$snapshot, _excluded);
|
|
1707
1708
|
let isFirstRender = true;
|
|
1708
|
-
forNode.effect = new
|
|
1709
|
+
forNode.effect = new this.Effect(() => {
|
|
1709
1710
|
let arr = arrSignal.get();
|
|
1710
1711
|
arr[aoye.Keys.Iterator];
|
|
1711
1712
|
const prevCtx = aoye.getPulling();
|
|
@@ -1876,7 +1877,7 @@ class Interpreter {
|
|
|
1876
1877
|
}
|
|
1877
1878
|
}
|
|
1878
1879
|
};
|
|
1879
|
-
});
|
|
1880
|
+
}, aoye.ScheduleType.Render);
|
|
1880
1881
|
return forNode.children[0] || forNode;
|
|
1881
1882
|
}
|
|
1882
1883
|
insertForItem(forNode, i, parentData, newChildren, before, snapshotForUpdate) {
|
|
@@ -1982,17 +1983,17 @@ class Interpreter {
|
|
|
1982
1983
|
return this.setProp(node, key, value, hookI);
|
|
1983
1984
|
}).get();
|
|
1984
1985
|
} else if (typeof value === 'function') {
|
|
1985
|
-
new
|
|
1986
|
+
new this.Effect(() => {
|
|
1986
1987
|
const res = value(data);
|
|
1987
1988
|
const dispose = this.setProp(node, key, res, hookI);
|
|
1988
1989
|
return dispose;
|
|
1989
|
-
});
|
|
1990
|
+
}, aoye.ScheduleType.Render);
|
|
1990
1991
|
} else if (valueIsMapKey) {
|
|
1991
|
-
new
|
|
1992
|
+
new this.Effect(() => {
|
|
1992
1993
|
const res = data[value];
|
|
1993
1994
|
const dispose = this.setProp(node, key, res, hookI);
|
|
1994
1995
|
return dispose;
|
|
1995
|
-
});
|
|
1996
|
+
}, aoye.ScheduleType.Render);
|
|
1996
1997
|
} else {
|
|
1997
1998
|
this.setProp(node, key, value, hookI);
|
|
1998
1999
|
}
|
|
@@ -2115,7 +2116,7 @@ class Interpreter {
|
|
|
2115
2116
|
}
|
|
2116
2117
|
ifNode.condition = signal;
|
|
2117
2118
|
ifNode.realAfter = this.insertAfterAnchor(`${keyWord.value}-after`);
|
|
2118
|
-
const ef =
|
|
2119
|
+
const ef = this.effect(({
|
|
2119
2120
|
val
|
|
2120
2121
|
}) => {
|
|
2121
2122
|
if (val) {
|
|
@@ -2136,7 +2137,9 @@ class Interpreter {
|
|
|
2136
2137
|
}
|
|
2137
2138
|
}
|
|
2138
2139
|
ifNode.isFirstRender = false;
|
|
2139
|
-
}, [signal]
|
|
2140
|
+
}, [signal], {
|
|
2141
|
+
type: 'render'
|
|
2142
|
+
});
|
|
2140
2143
|
ifNode.effect = ef;
|
|
2141
2144
|
return ifNode;
|
|
2142
2145
|
}
|
|
@@ -2222,6 +2225,10 @@ class Interpreter {
|
|
|
2222
2225
|
config(opt) {
|
|
2223
2226
|
Object.assign(this, opt);
|
|
2224
2227
|
this.opt = opt;
|
|
2228
|
+
if (opt.noopEffect) {
|
|
2229
|
+
this.effect = aoye.noopEffect;
|
|
2230
|
+
this.Effect = aoye.NoopEffect;
|
|
2231
|
+
}
|
|
2225
2232
|
}
|
|
2226
2233
|
createNode(name) {
|
|
2227
2234
|
return {
|
|
@@ -2271,6 +2278,8 @@ class Interpreter {
|
|
|
2271
2278
|
setProp(node, key, value, hookI) {
|
|
2272
2279
|
node.props[key] = value;
|
|
2273
2280
|
}
|
|
2281
|
+
Effect = aoye.Effect;
|
|
2282
|
+
effect = aoye.effect;
|
|
2274
2283
|
}
|
|
2275
2284
|
function createStoreOnePropParsed(child) {
|
|
2276
2285
|
const onePropParsed = (data, _, key, value, valueIsMapKey, isFn, hookI) => {
|
|
@@ -2341,6 +2350,34 @@ const context = name => {
|
|
|
2341
2350
|
return context;
|
|
2342
2351
|
};
|
|
2343
2352
|
|
|
2353
|
+
const depTokenizer = new Tokenizer(() => '', false);
|
|
2354
|
+
const effect = (callback, depOrOpt, opt) => {
|
|
2355
|
+
const isArray = Array.isArray(depOrOpt);
|
|
2356
|
+
const isSingleDep = isDep(depOrOpt);
|
|
2357
|
+
const deps = isArray ? depOrOpt : isSingleDep ? [depOrOpt] : [];
|
|
2358
|
+
const option = isArray || isSingleDep ? opt : depOrOpt;
|
|
2359
|
+
const newDeps = [];
|
|
2360
|
+
for (let i = 0; i < deps.length; i++) {
|
|
2361
|
+
const dep = deps[i];
|
|
2362
|
+
if (typeof dep === 'string') {
|
|
2363
|
+
depTokenizer.code = dep.trim() + '\n';
|
|
2364
|
+
let exp;
|
|
2365
|
+
while (depTokenizer.i < depTokenizer.code.length) {
|
|
2366
|
+
exp = depTokenizer.jsExp().value;
|
|
2367
|
+
depTokenizer.nextToken();
|
|
2368
|
+
newDeps.push(new Function('data', `let v;with(data){v=${exp};}return v;`).bind(undefined, aoye.Store.Current));
|
|
2369
|
+
}
|
|
2370
|
+
} else {
|
|
2371
|
+
newDeps.push(dep);
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
return aoye.effect(callback, newDeps, option);
|
|
2375
|
+
};
|
|
2376
|
+
|
|
2377
|
+
Object.defineProperty(exports, "Store", {
|
|
2378
|
+
enumerable: true,
|
|
2379
|
+
get: function () { return aoye.Store; }
|
|
2380
|
+
});
|
|
2344
2381
|
exports.Compiler = Compiler;
|
|
2345
2382
|
exports.NodeType = NodeType;
|
|
2346
2383
|
exports.ParseSyntaxError = ParseSyntaxError;
|
|
@@ -2348,10 +2385,5 @@ exports.Tokenizer = Tokenizer;
|
|
|
2348
2385
|
exports.bobe = bobe;
|
|
2349
2386
|
exports.context = context;
|
|
2350
2387
|
exports.customRender = customRender;
|
|
2351
|
-
|
|
2352
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
2353
|
-
enumerable: true,
|
|
2354
|
-
get: function () { return aoye[k]; }
|
|
2355
|
-
});
|
|
2356
|
-
});
|
|
2388
|
+
exports.effect = effect;
|
|
2357
2389
|
//# sourceMappingURL=bobe.compiler.cjs.js.map
|