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
package/dist/bobe.cjs.js
CHANGED
|
@@ -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;
|
|
@@ -1664,7 +1665,7 @@ class Interpreter {
|
|
|
1664
1665
|
_forNode$snapshot.isFirstToken;
|
|
1665
1666
|
const snapshotForUpdate = _objectWithoutProperties(_forNode$snapshot, _excluded);
|
|
1666
1667
|
let isFirstRender = true;
|
|
1667
|
-
forNode.effect = new
|
|
1668
|
+
forNode.effect = new this.Effect(() => {
|
|
1668
1669
|
let arr = arrSignal.get();
|
|
1669
1670
|
arr[aoye.Keys.Iterator];
|
|
1670
1671
|
const prevCtx = aoye.getPulling();
|
|
@@ -1835,7 +1836,7 @@ class Interpreter {
|
|
|
1835
1836
|
}
|
|
1836
1837
|
}
|
|
1837
1838
|
};
|
|
1838
|
-
});
|
|
1839
|
+
}, aoye.ScheduleType.Render);
|
|
1839
1840
|
return forNode.children[0] || forNode;
|
|
1840
1841
|
}
|
|
1841
1842
|
insertForItem(forNode, i, parentData, newChildren, before, snapshotForUpdate) {
|
|
@@ -1941,17 +1942,17 @@ class Interpreter {
|
|
|
1941
1942
|
return this.setProp(node, key, value, hookI);
|
|
1942
1943
|
}).get();
|
|
1943
1944
|
} else if (typeof value === 'function') {
|
|
1944
|
-
new
|
|
1945
|
+
new this.Effect(() => {
|
|
1945
1946
|
const res = value(data);
|
|
1946
1947
|
const dispose = this.setProp(node, key, res, hookI);
|
|
1947
1948
|
return dispose;
|
|
1948
|
-
});
|
|
1949
|
+
}, aoye.ScheduleType.Render);
|
|
1949
1950
|
} else if (valueIsMapKey) {
|
|
1950
|
-
new
|
|
1951
|
+
new this.Effect(() => {
|
|
1951
1952
|
const res = data[value];
|
|
1952
1953
|
const dispose = this.setProp(node, key, res, hookI);
|
|
1953
1954
|
return dispose;
|
|
1954
|
-
});
|
|
1955
|
+
}, aoye.ScheduleType.Render);
|
|
1955
1956
|
} else {
|
|
1956
1957
|
this.setProp(node, key, value, hookI);
|
|
1957
1958
|
}
|
|
@@ -2074,7 +2075,7 @@ class Interpreter {
|
|
|
2074
2075
|
}
|
|
2075
2076
|
ifNode.condition = signal;
|
|
2076
2077
|
ifNode.realAfter = this.insertAfterAnchor(`${keyWord.value}-after`);
|
|
2077
|
-
const ef =
|
|
2078
|
+
const ef = this.effect(({
|
|
2078
2079
|
val
|
|
2079
2080
|
}) => {
|
|
2080
2081
|
if (val) {
|
|
@@ -2095,7 +2096,9 @@ class Interpreter {
|
|
|
2095
2096
|
}
|
|
2096
2097
|
}
|
|
2097
2098
|
ifNode.isFirstRender = false;
|
|
2098
|
-
}, [signal]
|
|
2099
|
+
}, [signal], {
|
|
2100
|
+
type: 'render'
|
|
2101
|
+
});
|
|
2099
2102
|
ifNode.effect = ef;
|
|
2100
2103
|
return ifNode;
|
|
2101
2104
|
}
|
|
@@ -2181,6 +2184,10 @@ class Interpreter {
|
|
|
2181
2184
|
config(opt) {
|
|
2182
2185
|
Object.assign(this, opt);
|
|
2183
2186
|
this.opt = opt;
|
|
2187
|
+
if (opt.noopEffect) {
|
|
2188
|
+
this.effect = aoye.noopEffect;
|
|
2189
|
+
this.Effect = aoye.NoopEffect;
|
|
2190
|
+
}
|
|
2184
2191
|
}
|
|
2185
2192
|
createNode(name) {
|
|
2186
2193
|
return {
|
|
@@ -2230,6 +2237,8 @@ class Interpreter {
|
|
|
2230
2237
|
setProp(node, key, value, hookI) {
|
|
2231
2238
|
node.props[key] = value;
|
|
2232
2239
|
}
|
|
2240
|
+
Effect = aoye.Effect;
|
|
2241
|
+
effect = aoye.effect;
|
|
2233
2242
|
}
|
|
2234
2243
|
function createStoreOnePropParsed(child) {
|
|
2235
2244
|
const onePropParsed = (data, _, key, value, valueIsMapKey, isFn, hookI) => {
|
|
@@ -2300,6 +2309,34 @@ const context = name => {
|
|
|
2300
2309
|
return context;
|
|
2301
2310
|
};
|
|
2302
2311
|
|
|
2312
|
+
const depTokenizer = new Tokenizer(() => '', false);
|
|
2313
|
+
const effect = (callback, depOrOpt, opt) => {
|
|
2314
|
+
const isArray = Array.isArray(depOrOpt);
|
|
2315
|
+
const isSingleDep = isDep(depOrOpt);
|
|
2316
|
+
const deps = isArray ? depOrOpt : isSingleDep ? [depOrOpt] : [];
|
|
2317
|
+
const option = isArray || isSingleDep ? opt : depOrOpt;
|
|
2318
|
+
const newDeps = [];
|
|
2319
|
+
for (let i = 0; i < deps.length; i++) {
|
|
2320
|
+
const dep = deps[i];
|
|
2321
|
+
if (typeof dep === 'string') {
|
|
2322
|
+
depTokenizer.code = dep.trim() + '\n';
|
|
2323
|
+
let exp;
|
|
2324
|
+
while (depTokenizer.i < depTokenizer.code.length) {
|
|
2325
|
+
exp = depTokenizer.jsExp().value;
|
|
2326
|
+
depTokenizer.nextToken();
|
|
2327
|
+
newDeps.push(new Function('data', `let v;with(data){v=${exp};}return v;`).bind(undefined, aoye.Store.Current));
|
|
2328
|
+
}
|
|
2329
|
+
} else {
|
|
2330
|
+
newDeps.push(dep);
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
return aoye.effect(callback, newDeps, option);
|
|
2334
|
+
};
|
|
2335
|
+
|
|
2336
|
+
Object.defineProperty(exports, "Store", {
|
|
2337
|
+
enumerable: true,
|
|
2338
|
+
get: function () { return aoye.Store; }
|
|
2339
|
+
});
|
|
2303
2340
|
exports.Compiler = Compiler;
|
|
2304
2341
|
exports.NodeType = NodeType;
|
|
2305
2342
|
exports.ParseSyntaxError = ParseSyntaxError;
|
|
@@ -2307,10 +2344,5 @@ exports.Tokenizer = Tokenizer;
|
|
|
2307
2344
|
exports.bobe = bobe;
|
|
2308
2345
|
exports.context = context;
|
|
2309
2346
|
exports.customRender = customRender;
|
|
2310
|
-
|
|
2311
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
2312
|
-
enumerable: true,
|
|
2313
|
-
get: function () { return aoye[k]; }
|
|
2314
|
-
});
|
|
2315
|
-
});
|
|
2347
|
+
exports.effect = effect;
|
|
2316
2348
|
//# sourceMappingURL=bobe.cjs.js.map
|