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
package/dist/bobe.esm.js
CHANGED
|
@@ -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
|
|
|
@@ -1908,16 +1908,20 @@ class Interpreter {
|
|
|
1908
1908
|
}
|
|
1909
1909
|
onePropParsed(data, node, key, value, valueIsMapKey, isFn, hookI) {
|
|
1910
1910
|
if (isFn) {
|
|
1911
|
-
|
|
1911
|
+
new Scope(() => {
|
|
1912
|
+
return this.setProp(node, key, value, hookI);
|
|
1913
|
+
}).get();
|
|
1912
1914
|
} else if (typeof value === 'function') {
|
|
1913
1915
|
new Effect(() => {
|
|
1914
|
-
const res = value();
|
|
1915
|
-
this.setProp(node, key, res, hookI);
|
|
1916
|
+
const res = value(data);
|
|
1917
|
+
const dispose = this.setProp(node, key, res, hookI);
|
|
1918
|
+
return dispose;
|
|
1916
1919
|
});
|
|
1917
1920
|
} else if (valueIsMapKey) {
|
|
1918
1921
|
new Effect(() => {
|
|
1919
1922
|
const res = data[value];
|
|
1920
|
-
this.setProp(node, key, res, hookI);
|
|
1923
|
+
const dispose = this.setProp(node, key, res, hookI);
|
|
1924
|
+
return dispose;
|
|
1921
1925
|
});
|
|
1922
1926
|
} else {
|
|
1923
1927
|
this.setProp(node, key, value, hookI);
|
|
@@ -1942,7 +1946,7 @@ class Interpreter {
|
|
|
1942
1946
|
realBefore: null,
|
|
1943
1947
|
realAfter: null,
|
|
1944
1948
|
data: child,
|
|
1945
|
-
tokenizer: render ? render(true) : child
|
|
1949
|
+
tokenizer: render ? render(true) : child.ui(true)
|
|
1946
1950
|
};
|
|
1947
1951
|
this.onePropParsed = (data, _, key, value, valueIsMapKey, isFn, hookI) => {
|
|
1948
1952
|
if (isFn) {
|
|
@@ -1953,7 +1957,7 @@ class Interpreter {
|
|
|
1953
1957
|
const meta = child[Keys.Meta];
|
|
1954
1958
|
const cells = meta.cells;
|
|
1955
1959
|
if (typeof value === 'function') {
|
|
1956
|
-
const computed = new Computed(value);
|
|
1960
|
+
const computed = new Computed(() => value(data));
|
|
1957
1961
|
cells.set(key, computed);
|
|
1958
1962
|
child[Keys.Raw][key] = undefined;
|
|
1959
1963
|
} else {
|
|
@@ -1970,6 +1974,10 @@ class Interpreter {
|
|
|
1970
1974
|
getFn(data, expression) {
|
|
1971
1975
|
return new Function('data', `let v;with(data){v=${expression}};return v;`).bind(undefined, data);
|
|
1972
1976
|
}
|
|
1977
|
+
getAssignFn(data, expression) {
|
|
1978
|
+
const valueId = `value_bobe_${date32()}`;
|
|
1979
|
+
return new Function('data', valueId, `with(data){${expression}=${valueId}};`).bind(undefined, data);
|
|
1980
|
+
}
|
|
1973
1981
|
condDeclaration(ctx) {
|
|
1974
1982
|
const prevSibling = ctx.prevSibling;
|
|
1975
1983
|
const keyWord = this.tokenizer.token;
|
|
@@ -2123,7 +2131,27 @@ class Interpreter {
|
|
|
2123
2131
|
hookI = _this$tokenizer$_hook4[2];
|
|
2124
2132
|
const rawVal = data[Keys.Raw][value];
|
|
2125
2133
|
const isFn = typeof rawVal === 'function';
|
|
2126
|
-
if (
|
|
2134
|
+
if (key === 'ref') {
|
|
2135
|
+
const valueIsMapKey = Reflect.has(data[Keys.Raw], value);
|
|
2136
|
+
let refValue = _node;
|
|
2137
|
+
if (_node.__logicType === FakeType.Component) {
|
|
2138
|
+
refValue = _node.data;
|
|
2139
|
+
} else {
|
|
2140
|
+
refValue[Keys.ProxyFreeObject] = true;
|
|
2141
|
+
}
|
|
2142
|
+
if (valueIsMapKey) {
|
|
2143
|
+
data[value] = refValue;
|
|
2144
|
+
new Scope(() => () => {
|
|
2145
|
+
data[value] = null;
|
|
2146
|
+
}).get();
|
|
2147
|
+
} else {
|
|
2148
|
+
const fn = this.getAssignFn(data, value);
|
|
2149
|
+
fn(refValue);
|
|
2150
|
+
new Scope(() => () => {
|
|
2151
|
+
fn(null);
|
|
2152
|
+
}).get();
|
|
2153
|
+
}
|
|
2154
|
+
} else if (hookType === 'dynamic') {
|
|
2127
2155
|
const valueIsMapKey = Reflect.has(data[Keys.Raw], value);
|
|
2128
2156
|
const fn = isFn ? rawVal : valueIsMapKey ? value : this.getFn(data, value);
|
|
2129
2157
|
this.onePropParsed(data, _node, key, fn, valueIsMapKey, isFn, hookI);
|
|
@@ -2208,7 +2236,7 @@ function bobe(fragments, ...values) {
|
|
|
2208
2236
|
function customRender(option) {
|
|
2209
2237
|
return function render(Ctor, root) {
|
|
2210
2238
|
const store = Ctor.new();
|
|
2211
|
-
const tokenizer = store
|
|
2239
|
+
const tokenizer = store.ui(false);
|
|
2212
2240
|
const terp = new Interpreter(tokenizer);
|
|
2213
2241
|
terp.config(option);
|
|
2214
2242
|
const componentNode = {
|