bobe 0.0.46 → 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Queue, isNum, matchIdStart2, matchId, escapeMap, jsVarRegexp, date32 } from 'bobe-shared';
|
|
2
|
-
import { getPulling, setPulling, Keys, deepSignal,
|
|
3
|
-
export
|
|
2
|
+
import { Signal, Computed, getPulling, setPulling, Keys, deepSignal, toRaw, ScheduleType, runWithPulling, Scope, Store, noopEffect, NoopEffect, Effect, effect as effect$1, shareSignal } from 'aoye';
|
|
3
|
+
export { Store } from 'aoye';
|
|
4
4
|
|
|
5
5
|
let TokenType = function (TokenType) {
|
|
6
6
|
TokenType[TokenType["NewLine"] = 1] = "NewLine";
|
|
@@ -80,6 +80,7 @@ class ParseSyntaxError extends SyntaxError {
|
|
|
80
80
|
this.loc = loc;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
const isDep = target => target && (target instanceof Signal || target instanceof Computed || typeof target === 'function' || typeof target === 'string');
|
|
83
84
|
|
|
84
85
|
class Tokenizer {
|
|
85
86
|
TabSize = 2;
|
|
@@ -1704,7 +1705,7 @@ class Interpreter {
|
|
|
1704
1705
|
_forNode$snapshot.isFirstToken;
|
|
1705
1706
|
const snapshotForUpdate = _objectWithoutProperties(_forNode$snapshot, _excluded);
|
|
1706
1707
|
let isFirstRender = true;
|
|
1707
|
-
forNode.effect = new Effect(() => {
|
|
1708
|
+
forNode.effect = new this.Effect(() => {
|
|
1708
1709
|
let arr = arrSignal.get();
|
|
1709
1710
|
arr[Keys.Iterator];
|
|
1710
1711
|
const prevCtx = getPulling();
|
|
@@ -1875,7 +1876,7 @@ class Interpreter {
|
|
|
1875
1876
|
}
|
|
1876
1877
|
}
|
|
1877
1878
|
};
|
|
1878
|
-
});
|
|
1879
|
+
}, ScheduleType.Render);
|
|
1879
1880
|
return forNode.children[0] || forNode;
|
|
1880
1881
|
}
|
|
1881
1882
|
insertForItem(forNode, i, parentData, newChildren, before, snapshotForUpdate) {
|
|
@@ -1981,17 +1982,17 @@ class Interpreter {
|
|
|
1981
1982
|
return this.setProp(node, key, value, hookI);
|
|
1982
1983
|
}).get();
|
|
1983
1984
|
} else if (typeof value === 'function') {
|
|
1984
|
-
new Effect(() => {
|
|
1985
|
+
new this.Effect(() => {
|
|
1985
1986
|
const res = value(data);
|
|
1986
1987
|
const dispose = this.setProp(node, key, res, hookI);
|
|
1987
1988
|
return dispose;
|
|
1988
|
-
});
|
|
1989
|
+
}, ScheduleType.Render);
|
|
1989
1990
|
} else if (valueIsMapKey) {
|
|
1990
|
-
new Effect(() => {
|
|
1991
|
+
new this.Effect(() => {
|
|
1991
1992
|
const res = data[value];
|
|
1992
1993
|
const dispose = this.setProp(node, key, res, hookI);
|
|
1993
1994
|
return dispose;
|
|
1994
|
-
});
|
|
1995
|
+
}, ScheduleType.Render);
|
|
1995
1996
|
} else {
|
|
1996
1997
|
this.setProp(node, key, value, hookI);
|
|
1997
1998
|
}
|
|
@@ -2114,7 +2115,7 @@ class Interpreter {
|
|
|
2114
2115
|
}
|
|
2115
2116
|
ifNode.condition = signal;
|
|
2116
2117
|
ifNode.realAfter = this.insertAfterAnchor(`${keyWord.value}-after`);
|
|
2117
|
-
const ef = effect(({
|
|
2118
|
+
const ef = this.effect(({
|
|
2118
2119
|
val
|
|
2119
2120
|
}) => {
|
|
2120
2121
|
if (val) {
|
|
@@ -2135,7 +2136,9 @@ class Interpreter {
|
|
|
2135
2136
|
}
|
|
2136
2137
|
}
|
|
2137
2138
|
ifNode.isFirstRender = false;
|
|
2138
|
-
}, [signal]
|
|
2139
|
+
}, [signal], {
|
|
2140
|
+
type: 'render'
|
|
2141
|
+
});
|
|
2139
2142
|
ifNode.effect = ef;
|
|
2140
2143
|
return ifNode;
|
|
2141
2144
|
}
|
|
@@ -2221,6 +2224,10 @@ class Interpreter {
|
|
|
2221
2224
|
config(opt) {
|
|
2222
2225
|
Object.assign(this, opt);
|
|
2223
2226
|
this.opt = opt;
|
|
2227
|
+
if (opt.noopEffect) {
|
|
2228
|
+
this.effect = noopEffect;
|
|
2229
|
+
this.Effect = NoopEffect;
|
|
2230
|
+
}
|
|
2224
2231
|
}
|
|
2225
2232
|
createNode(name) {
|
|
2226
2233
|
return {
|
|
@@ -2270,6 +2277,8 @@ class Interpreter {
|
|
|
2270
2277
|
setProp(node, key, value, hookI) {
|
|
2271
2278
|
node.props[key] = value;
|
|
2272
2279
|
}
|
|
2280
|
+
Effect = Effect;
|
|
2281
|
+
effect = effect$1;
|
|
2273
2282
|
}
|
|
2274
2283
|
function createStoreOnePropParsed(child) {
|
|
2275
2284
|
const onePropParsed = (data, _, key, value, valueIsMapKey, isFn, hookI) => {
|
|
@@ -2340,5 +2349,29 @@ const context = name => {
|
|
|
2340
2349
|
return context;
|
|
2341
2350
|
};
|
|
2342
2351
|
|
|
2343
|
-
|
|
2352
|
+
const depTokenizer = new Tokenizer(() => '', false);
|
|
2353
|
+
const effect = (callback, depOrOpt, opt) => {
|
|
2354
|
+
const isArray = Array.isArray(depOrOpt);
|
|
2355
|
+
const isSingleDep = isDep(depOrOpt);
|
|
2356
|
+
const deps = isArray ? depOrOpt : isSingleDep ? [depOrOpt] : [];
|
|
2357
|
+
const option = isArray || isSingleDep ? opt : depOrOpt;
|
|
2358
|
+
const newDeps = [];
|
|
2359
|
+
for (let i = 0; i < deps.length; i++) {
|
|
2360
|
+
const dep = deps[i];
|
|
2361
|
+
if (typeof dep === 'string') {
|
|
2362
|
+
depTokenizer.code = dep.trim() + '\n';
|
|
2363
|
+
let exp;
|
|
2364
|
+
while (depTokenizer.i < depTokenizer.code.length) {
|
|
2365
|
+
exp = depTokenizer.jsExp().value;
|
|
2366
|
+
depTokenizer.nextToken();
|
|
2367
|
+
newDeps.push(new Function('data', `let v;with(data){v=${exp};}return v;`).bind(undefined, Store.Current));
|
|
2368
|
+
}
|
|
2369
|
+
} else {
|
|
2370
|
+
newDeps.push(dep);
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
return effect$1(callback, newDeps, option);
|
|
2374
|
+
};
|
|
2375
|
+
|
|
2376
|
+
export { Compiler, NodeType, ParseSyntaxError, Tokenizer, bobe, context, customRender, effect };
|
|
2344
2377
|
//# sourceMappingURL=bobe.compiler.esm.js.map
|