bobe 0.0.42 → 0.0.43
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 +36 -8
- package/dist/bobe.cjs.js.map +1 -1
- package/dist/bobe.compiler.cjs.js +36 -8
- package/dist/bobe.compiler.cjs.js.map +1 -1
- package/dist/bobe.compiler.esm.js +37 -9
- package/dist/bobe.compiler.esm.js.map +1 -1
- package/dist/bobe.esm.js +37 -9
- package/dist/bobe.esm.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.umd.js +36 -8
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Queue, isNum, matchIdStart2, matchId, escapeMap, jsVarRegexp } from 'bobe-shared';
|
|
1
|
+
import { Queue, isNum, matchIdStart2, matchId, escapeMap, jsVarRegexp, date32 } from 'bobe-shared';
|
|
2
2
|
import { getPulling, setPulling, Keys, Computed, Effect, toRaw, runWithPulling, Scope, deepSignal, Store, shareSignal, effect } from 'aoye';
|
|
3
3
|
export * from 'aoye';
|
|
4
4
|
|
|
@@ -1949,16 +1949,20 @@ class Interpreter {
|
|
|
1949
1949
|
}
|
|
1950
1950
|
onePropParsed(data, node, key, value, valueIsMapKey, isFn, hookI) {
|
|
1951
1951
|
if (isFn) {
|
|
1952
|
-
|
|
1952
|
+
new Scope(() => {
|
|
1953
|
+
return this.setProp(node, key, value, hookI);
|
|
1954
|
+
}).get();
|
|
1953
1955
|
} else if (typeof value === 'function') {
|
|
1954
1956
|
new Effect(() => {
|
|
1955
|
-
const res = value();
|
|
1956
|
-
this.setProp(node, key, res, hookI);
|
|
1957
|
+
const res = value(data);
|
|
1958
|
+
const dispose = this.setProp(node, key, res, hookI);
|
|
1959
|
+
return dispose;
|
|
1957
1960
|
});
|
|
1958
1961
|
} else if (valueIsMapKey) {
|
|
1959
1962
|
new Effect(() => {
|
|
1960
1963
|
const res = data[value];
|
|
1961
|
-
this.setProp(node, key, res, hookI);
|
|
1964
|
+
const dispose = this.setProp(node, key, res, hookI);
|
|
1965
|
+
return dispose;
|
|
1962
1966
|
});
|
|
1963
1967
|
} else {
|
|
1964
1968
|
this.setProp(node, key, value, hookI);
|
|
@@ -1983,7 +1987,7 @@ class Interpreter {
|
|
|
1983
1987
|
realBefore: null,
|
|
1984
1988
|
realAfter: null,
|
|
1985
1989
|
data: child,
|
|
1986
|
-
tokenizer: render ? render(true) : child
|
|
1990
|
+
tokenizer: render ? render(true) : child.ui(true)
|
|
1987
1991
|
};
|
|
1988
1992
|
this.onePropParsed = (data, _, key, value, valueIsMapKey, isFn, hookI) => {
|
|
1989
1993
|
if (isFn) {
|
|
@@ -1994,7 +1998,7 @@ class Interpreter {
|
|
|
1994
1998
|
const meta = child[Keys.Meta];
|
|
1995
1999
|
const cells = meta.cells;
|
|
1996
2000
|
if (typeof value === 'function') {
|
|
1997
|
-
const computed = new Computed(value);
|
|
2001
|
+
const computed = new Computed(() => value(data));
|
|
1998
2002
|
cells.set(key, computed);
|
|
1999
2003
|
child[Keys.Raw][key] = undefined;
|
|
2000
2004
|
} else {
|
|
@@ -2011,6 +2015,10 @@ class Interpreter {
|
|
|
2011
2015
|
getFn(data, expression) {
|
|
2012
2016
|
return new Function('data', `let v;with(data){v=${expression}};return v;`).bind(undefined, data);
|
|
2013
2017
|
}
|
|
2018
|
+
getAssignFn(data, expression) {
|
|
2019
|
+
const valueId = `value_bobe_${date32()}`;
|
|
2020
|
+
return new Function('data', valueId, `with(data){${expression}=${valueId}};`).bind(undefined, data);
|
|
2021
|
+
}
|
|
2014
2022
|
condDeclaration(ctx) {
|
|
2015
2023
|
const prevSibling = ctx.prevSibling;
|
|
2016
2024
|
const keyWord = this.tokenizer.token;
|
|
@@ -2164,7 +2172,27 @@ class Interpreter {
|
|
|
2164
2172
|
hookI = _this$tokenizer$_hook4[2];
|
|
2165
2173
|
const rawVal = data[Keys.Raw][value];
|
|
2166
2174
|
const isFn = typeof rawVal === 'function';
|
|
2167
|
-
if (
|
|
2175
|
+
if (key === 'ref') {
|
|
2176
|
+
const valueIsMapKey = Reflect.has(data[Keys.Raw], value);
|
|
2177
|
+
let refValue = _node;
|
|
2178
|
+
if (_node.__logicType === FakeType.Component) {
|
|
2179
|
+
refValue = _node.data;
|
|
2180
|
+
} else {
|
|
2181
|
+
refValue[Keys.ProxyFreeObject] = true;
|
|
2182
|
+
}
|
|
2183
|
+
if (valueIsMapKey) {
|
|
2184
|
+
data[value] = refValue;
|
|
2185
|
+
new Scope(() => () => {
|
|
2186
|
+
data[value] = null;
|
|
2187
|
+
}).get();
|
|
2188
|
+
} else {
|
|
2189
|
+
const fn = this.getAssignFn(data, value);
|
|
2190
|
+
fn(refValue);
|
|
2191
|
+
new Scope(() => () => {
|
|
2192
|
+
fn(null);
|
|
2193
|
+
}).get();
|
|
2194
|
+
}
|
|
2195
|
+
} else if (hookType === 'dynamic') {
|
|
2168
2196
|
const valueIsMapKey = Reflect.has(data[Keys.Raw], value);
|
|
2169
2197
|
const fn = isFn ? rawVal : valueIsMapKey ? value : this.getFn(data, value);
|
|
2170
2198
|
this.onePropParsed(data, _node, key, fn, valueIsMapKey, isFn, hookI);
|
|
@@ -2249,7 +2277,7 @@ function bobe(fragments, ...values) {
|
|
|
2249
2277
|
function customRender(option) {
|
|
2250
2278
|
return function render(Ctor, root) {
|
|
2251
2279
|
const store = Ctor.new();
|
|
2252
|
-
const tokenizer = store
|
|
2280
|
+
const tokenizer = store.ui(false);
|
|
2253
2281
|
const terp = new Interpreter(tokenizer);
|
|
2254
2282
|
terp.config(option);
|
|
2255
2283
|
const componentNode = {
|