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/index.d.ts CHANGED
@@ -49,6 +49,7 @@ declare class Interpreter {
49
49
  oneRealPropParsed: Interpreter['onePropParsed'];
50
50
  componentOrFragmentDeclaration(ComponentOrRender: BobeUI | typeof Store, ctx: ProgramCtx): ComponentNode$1;
51
51
  getFn(data: any, expression: string | number): any;
52
+ getAssignFn(data: any, expression: string | number): any;
52
53
  condDeclaration(ctx: ProgramCtx): IfNode;
53
54
  removeLogicNode(node: LogicNode): void;
54
55
  /**
@@ -89,7 +90,7 @@ declare class Interpreter {
89
90
  defaultInsert(parent: any, node: any, prev: any): void;
90
91
  remove(node: any, parent?: any, prev?: any): void;
91
92
  defaultRemove(node: any, parent: any, prevSibling: any): void;
92
- setProp(node: any, key: string, value: any, hookI?: number): void;
93
+ setProp(node: any, key: string, value: any, hookI?: number): void | undefined | (() => void);
93
94
  }
94
95
 
95
96
  interface StackNode<T> {
package/dist/index.umd.js CHANGED
@@ -1910,16 +1910,20 @@
1910
1910
  }
1911
1911
  onePropParsed(data, node, key, value, valueIsMapKey, isFn, hookI) {
1912
1912
  if (isFn) {
1913
- this.setProp(node, key, value, hookI);
1913
+ new aoye.Scope(() => {
1914
+ return this.setProp(node, key, value, hookI);
1915
+ }).get();
1914
1916
  } else if (typeof value === 'function') {
1915
1917
  new aoye.Effect(() => {
1916
- const res = value();
1917
- this.setProp(node, key, res, hookI);
1918
+ const res = value(data);
1919
+ const dispose = this.setProp(node, key, res, hookI);
1920
+ return dispose;
1918
1921
  });
1919
1922
  } else if (valueIsMapKey) {
1920
1923
  new aoye.Effect(() => {
1921
1924
  const res = data[value];
1922
- this.setProp(node, key, res, hookI);
1925
+ const dispose = this.setProp(node, key, res, hookI);
1926
+ return dispose;
1923
1927
  });
1924
1928
  } else {
1925
1929
  this.setProp(node, key, value, hookI);
@@ -1944,7 +1948,7 @@
1944
1948
  realBefore: null,
1945
1949
  realAfter: null,
1946
1950
  data: child,
1947
- tokenizer: render ? render(true) : child['ui'](true)
1951
+ tokenizer: render ? render(true) : child.ui(true)
1948
1952
  };
1949
1953
  this.onePropParsed = (data, _, key, value, valueIsMapKey, isFn, hookI) => {
1950
1954
  if (isFn) {
@@ -1955,7 +1959,7 @@
1955
1959
  const meta = child[aoye.Keys.Meta];
1956
1960
  const cells = meta.cells;
1957
1961
  if (typeof value === 'function') {
1958
- const computed = new aoye.Computed(value);
1962
+ const computed = new aoye.Computed(() => value(data));
1959
1963
  cells.set(key, computed);
1960
1964
  child[aoye.Keys.Raw][key] = undefined;
1961
1965
  } else {
@@ -1972,6 +1976,10 @@
1972
1976
  getFn(data, expression) {
1973
1977
  return new Function('data', `let v;with(data){v=${expression}};return v;`).bind(undefined, data);
1974
1978
  }
1979
+ getAssignFn(data, expression) {
1980
+ const valueId = `value_bobe_${bobeShared.date32()}`;
1981
+ return new Function('data', valueId, `with(data){${expression}=${valueId}};`).bind(undefined, data);
1982
+ }
1975
1983
  condDeclaration(ctx) {
1976
1984
  const prevSibling = ctx.prevSibling;
1977
1985
  const keyWord = this.tokenizer.token;
@@ -2125,7 +2133,27 @@
2125
2133
  hookI = _this$tokenizer$_hook4[2];
2126
2134
  const rawVal = data[aoye.Keys.Raw][value];
2127
2135
  const isFn = typeof rawVal === 'function';
2128
- if (hookType === 'dynamic') {
2136
+ if (key === 'ref') {
2137
+ const valueIsMapKey = Reflect.has(data[aoye.Keys.Raw], value);
2138
+ let refValue = _node;
2139
+ if (_node.__logicType === FakeType.Component) {
2140
+ refValue = _node.data;
2141
+ } else {
2142
+ refValue[aoye.Keys.ProxyFreeObject] = true;
2143
+ }
2144
+ if (valueIsMapKey) {
2145
+ data[value] = refValue;
2146
+ new aoye.Scope(() => () => {
2147
+ data[value] = null;
2148
+ }).get();
2149
+ } else {
2150
+ const fn = this.getAssignFn(data, value);
2151
+ fn(refValue);
2152
+ new aoye.Scope(() => () => {
2153
+ fn(null);
2154
+ }).get();
2155
+ }
2156
+ } else if (hookType === 'dynamic') {
2129
2157
  const valueIsMapKey = Reflect.has(data[aoye.Keys.Raw], value);
2130
2158
  const fn = isFn ? rawVal : valueIsMapKey ? value : this.getFn(data, value);
2131
2159
  this.onePropParsed(data, _node, key, fn, valueIsMapKey, isFn, hookI);
@@ -2210,7 +2238,7 @@
2210
2238
  function customRender(option) {
2211
2239
  return function render(Ctor, root) {
2212
2240
  const store = Ctor.new();
2213
- const tokenizer = store['ui'](false);
2241
+ const tokenizer = store.ui(false);
2214
2242
  const terp = new Interpreter(tokenizer);
2215
2243
  terp.config(option);
2216
2244
  const componentNode = {