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.
@@ -1950,16 +1950,20 @@ class Interpreter {
1950
1950
  }
1951
1951
  onePropParsed(data, node, key, value, valueIsMapKey, isFn, hookI) {
1952
1952
  if (isFn) {
1953
- this.setProp(node, key, value, hookI);
1953
+ new aoye.Scope(() => {
1954
+ return this.setProp(node, key, value, hookI);
1955
+ }).get();
1954
1956
  } else if (typeof value === 'function') {
1955
1957
  new aoye.Effect(() => {
1956
- const res = value();
1957
- this.setProp(node, key, res, hookI);
1958
+ const res = value(data);
1959
+ const dispose = this.setProp(node, key, res, hookI);
1960
+ return dispose;
1958
1961
  });
1959
1962
  } else if (valueIsMapKey) {
1960
1963
  new aoye.Effect(() => {
1961
1964
  const res = data[value];
1962
- this.setProp(node, key, res, hookI);
1965
+ const dispose = this.setProp(node, key, res, hookI);
1966
+ return dispose;
1963
1967
  });
1964
1968
  } else {
1965
1969
  this.setProp(node, key, value, hookI);
@@ -1984,7 +1988,7 @@ class Interpreter {
1984
1988
  realBefore: null,
1985
1989
  realAfter: null,
1986
1990
  data: child,
1987
- tokenizer: render ? render(true) : child['ui'](true)
1991
+ tokenizer: render ? render(true) : child.ui(true)
1988
1992
  };
1989
1993
  this.onePropParsed = (data, _, key, value, valueIsMapKey, isFn, hookI) => {
1990
1994
  if (isFn) {
@@ -1995,7 +1999,7 @@ class Interpreter {
1995
1999
  const meta = child[aoye.Keys.Meta];
1996
2000
  const cells = meta.cells;
1997
2001
  if (typeof value === 'function') {
1998
- const computed = new aoye.Computed(value);
2002
+ const computed = new aoye.Computed(() => value(data));
1999
2003
  cells.set(key, computed);
2000
2004
  child[aoye.Keys.Raw][key] = undefined;
2001
2005
  } else {
@@ -2012,6 +2016,10 @@ class Interpreter {
2012
2016
  getFn(data, expression) {
2013
2017
  return new Function('data', `let v;with(data){v=${expression}};return v;`).bind(undefined, data);
2014
2018
  }
2019
+ getAssignFn(data, expression) {
2020
+ const valueId = `value_bobe_${bobeShared.date32()}`;
2021
+ return new Function('data', valueId, `with(data){${expression}=${valueId}};`).bind(undefined, data);
2022
+ }
2015
2023
  condDeclaration(ctx) {
2016
2024
  const prevSibling = ctx.prevSibling;
2017
2025
  const keyWord = this.tokenizer.token;
@@ -2165,7 +2173,27 @@ class Interpreter {
2165
2173
  hookI = _this$tokenizer$_hook4[2];
2166
2174
  const rawVal = data[aoye.Keys.Raw][value];
2167
2175
  const isFn = typeof rawVal === 'function';
2168
- if (hookType === 'dynamic') {
2176
+ if (key === 'ref') {
2177
+ const valueIsMapKey = Reflect.has(data[aoye.Keys.Raw], value);
2178
+ let refValue = _node;
2179
+ if (_node.__logicType === FakeType.Component) {
2180
+ refValue = _node.data;
2181
+ } else {
2182
+ refValue[aoye.Keys.ProxyFreeObject] = true;
2183
+ }
2184
+ if (valueIsMapKey) {
2185
+ data[value] = refValue;
2186
+ new aoye.Scope(() => () => {
2187
+ data[value] = null;
2188
+ }).get();
2189
+ } else {
2190
+ const fn = this.getAssignFn(data, value);
2191
+ fn(refValue);
2192
+ new aoye.Scope(() => () => {
2193
+ fn(null);
2194
+ }).get();
2195
+ }
2196
+ } else if (hookType === 'dynamic') {
2169
2197
  const valueIsMapKey = Reflect.has(data[aoye.Keys.Raw], value);
2170
2198
  const fn = isFn ? rawVal : valueIsMapKey ? value : this.getFn(data, value);
2171
2199
  this.onePropParsed(data, _node, key, fn, valueIsMapKey, isFn, hookI);
@@ -2250,7 +2278,7 @@ function bobe(fragments, ...values) {
2250
2278
  function customRender(option) {
2251
2279
  return function render(Ctor, root) {
2252
2280
  const store = Ctor.new();
2253
- const tokenizer = store['ui'](false);
2281
+ const tokenizer = store.ui(false);
2254
2282
  const terp = new Interpreter(tokenizer);
2255
2283
  terp.config(option);
2256
2284
  const componentNode = {