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