@ibyar/core 0.4.1 → 0.5.2

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.
Files changed (77) hide show
  1. package/README.md +1 -0
  2. package/annotation/decorators.d.ts +2 -2
  3. package/annotation/decorators.js.map +1 -1
  4. package/binding/binding.expressions.d.ts +32 -0
  5. package/binding/binding.expressions.js +100 -0
  6. package/binding/binding.expressions.js.map +1 -0
  7. package/component/component.d.ts +2 -2
  8. package/component/component.js +5 -7
  9. package/component/component.js.map +1 -1
  10. package/component/custom-element.d.ts +12 -16
  11. package/component/custom-element.js.map +1 -1
  12. package/component/provider.d.ts +2 -4
  13. package/component/provider.js +3 -16
  14. package/component/provider.js.map +1 -1
  15. package/context/subscription.d.ts +2 -0
  16. package/context/subscription.js +14 -0
  17. package/context/subscription.js.map +1 -0
  18. package/directive/directive.d.ts +11 -11
  19. package/directive/directive.js +9 -10
  20. package/directive/directive.js.map +1 -1
  21. package/directive/parser.d.ts +30 -0
  22. package/directive/parser.js +174 -0
  23. package/directive/parser.js.map +1 -0
  24. package/html/expression.d.ts +13 -10
  25. package/html/expression.js +78 -21
  26. package/html/expression.js.map +1 -1
  27. package/index.d.ts +4 -1
  28. package/index.js +4 -1
  29. package/index.js.map +1 -1
  30. package/linker/change-detector-ref.d.ts +7 -0
  31. package/linker/change-detector-ref.js +32 -0
  32. package/linker/change-detector-ref.js.map +1 -0
  33. package/linker/template-ref.d.ts +22 -0
  34. package/linker/template-ref.js +57 -0
  35. package/linker/template-ref.js.map +1 -0
  36. package/linker/view-container-ref.d.ts +41 -0
  37. package/linker/view-container-ref.js +82 -0
  38. package/linker/view-container-ref.js.map +1 -0
  39. package/linker/view-ref.d.ts +38 -0
  40. package/linker/view-ref.js +78 -0
  41. package/linker/view-ref.js.map +1 -0
  42. package/package.json +5 -5
  43. package/pipe/pipe.d.ts +23 -3
  44. package/pipe/pipe.js +37 -5
  45. package/pipe/pipe.js.map +1 -1
  46. package/providers/provider.d.ts +2 -2
  47. package/providers/provider.js +6 -3
  48. package/providers/provider.js.map +1 -1
  49. package/utils/elements-util.js +4 -1
  50. package/utils/elements-util.js.map +1 -1
  51. package/view/base-view.d.ts +1 -1
  52. package/view/base-view.js +27 -56
  53. package/view/base-view.js.map +1 -1
  54. package/view/render.d.ts +25 -24
  55. package/view/render.js +154 -151
  56. package/view/render.js.map +1 -1
  57. package/view/view.d.ts +2 -2
  58. package/view/view.js +12 -10
  59. package/view/view.js.map +1 -1
  60. package/html/update.d.ts +0 -12
  61. package/html/update.js +0 -24
  62. package/html/update.js.map +0 -1
  63. package/linker/template_ref.d.ts +0 -5
  64. package/linker/template_ref.js +0 -3
  65. package/linker/template_ref.js.map +0 -1
  66. package/linker/view_container_ref.d.ts +0 -20
  67. package/linker/view_container_ref.js +0 -3
  68. package/linker/view_container_ref.js.map +0 -1
  69. package/linker/view_ref.d.ts +0 -9
  70. package/linker/view_ref.js +0 -5
  71. package/linker/view_ref.js.map +0 -1
  72. package/model/change-detection.d.ts +0 -13
  73. package/model/change-detection.js +0 -100
  74. package/model/change-detection.js.map +0 -1
  75. package/view/events.d.ts +0 -2
  76. package/view/events.js +0 -25
  77. package/view/events.js.map +0 -1
package/view/view.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isFormElement } from '@ibyar/elements';
1
+ import { getAllAttributes, isFormElement } from '@ibyar/elements';
2
2
  import { ToCamelCase } from '../utils/utils.js';
3
3
  import { baseFactoryView } from './base-view.js';
4
4
  import { baseFormFactoryView } from './form-view.js';
@@ -18,14 +18,12 @@ export function initCustomElementView(modelClass, componentRef) {
18
18
  }
19
19
  })[htmlViewClassName];
20
20
  componentRef.inputs.forEach((input) => {
21
- const parentProperty = Object.getOwnPropertyDescriptor(htmlParent.prototype, input.viewAttribute);
22
21
  Object.defineProperty(viewClass.prototype, input.viewAttribute, {
23
22
  get() {
24
- return this._proxyModel[input.modelProperty] || parentProperty?.get?.call(this);
23
+ return this._modelScope.get(input.modelProperty);
25
24
  },
26
25
  set(value) {
27
26
  this._modelScope.set(input.modelProperty, value);
28
- parentProperty?.set?.call(this, value);
29
27
  },
30
28
  enumerable: true,
31
29
  });
@@ -62,11 +60,15 @@ export function initCustomElementView(modelClass, componentRef) {
62
60
  enumerable: true
63
61
  });
64
62
  });
65
- Object.defineProperty(viewClass, 'observedAttributes', {
66
- get() {
67
- return componentRef.inputs.map(input => input.viewAttribute);
68
- }
69
- });
63
+ componentRef.inputs.map(input => input.modelProperty)
64
+ .concat(componentRef.outputs.map(output => output.modelProperty))
65
+ .concat(componentRef.hostBindings.map(host => host.hostPropertyName))
66
+ .concat(componentRef.viewChild.map(child => child.modelName))
67
+ .forEach(modelName => modelClass.prototype[modelName] = undefined);
68
+ const defaultAttributes = getAllAttributes(componentRef.extend.name);
69
+ const observedAttributes = componentRef.inputs.map(input => input.viewAttribute);
70
+ Reflect.set(viewClass, 'observedAttributes', observedAttributes);
71
+ Reflect.set(viewClass, 'allAttributes', defaultAttributes.concat(observedAttributes));
70
72
  if (false) {
71
73
  Object.defineProperty(viewClass, 'formAssociated', {
72
74
  get() {
@@ -98,7 +100,7 @@ export function buildViewClassNameFromSelector(selector) {
98
100
  .map(name => name.replace(/^\w/, char => char.toUpperCase()))
99
101
  .join('');
100
102
  }
101
- export function ComponentView(modelClass, selector) {
103
+ export function getComponentView(modelClass, selector) {
102
104
  if (isComponentModelClass(modelClass)) {
103
105
  let viewClassName;
104
106
  if (selector) {
package/view/view.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/core/view/view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAOrD,MAAM,UAAU,qBAAq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8B,CAAC,QAAgB;IAC9D,OAAO,QAAQ;SACb,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;SAC5D,IAAI,CAAC,EAAE,CAAC,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,aAAa,CAAI,UAAqB,EAAE,QAAiB;IACxE,IAAI,qBAAqB,CAAC,UAAU,CAAC,EAAE;QACtC,IAAI,aAAqB,CAAC;QAC1B,IAAI,QAAQ,EAAE;YACb,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAC/C,IAAI,CAAC,aAAa,EAAE;gBACnB,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,CAAC,IAAI,iBAAiB,QAAQ,UAAU,CAAC,CAAC;aACvE;SACD;aAAM;YACN,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;SACrD;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;KAC9C;AACF,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { isFormElement } from '@ibyar/elements';\nimport { ComponentRef } from '../component/component.js';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { EventEmitter, Subscription } from '../component/events.js';\nimport { ToCamelCase } from '../utils/utils.js';\nimport { Constructable } from '../providers/injector.js';\nimport { baseFactoryView } from './base-view.js';\nimport { baseFormFactoryView } from './form-view.js';\n\n/**\n * \n * @param modelClass \n * @param componentRef \n */\nexport function initCustomElementView<T extends Object>(modelClass: TypeOf<T>, componentRef: ComponentRef<T>): TypeOf<HTMLComponent<T>> {\n\tconst htmlParent = componentRef.extend.classRef as TypeOf<HTMLElement>;\n\tlet viewClass: TypeOf<HTMLComponent<T>>;\n\tconst viewClassName = buildViewClassNameFromSelector(componentRef.selector);\n\tconst htmlViewClassName = `HTML${viewClassName}Element`;\n\tconst parentClass = componentRef.extend.name\n\t\t? (isFormElement(componentRef.extend.name)\n\t\t\t? baseFormFactoryView<T>(htmlParent)\n\t\t\t: baseFactoryView<T>(htmlParent)\n\t\t)\n\t\t: baseFactoryView<T>(HTMLElement);\n\tviewClass = ({\n\t\t[htmlViewClassName]: class extends parentClass { constructor() { super(componentRef, modelClass); } }\n\t})[htmlViewClassName];\n\n\tcomponentRef.inputs.forEach((input) => {\n\t\tconst parentProperty = Object.getOwnPropertyDescriptor(\n\t\t\thtmlParent.prototype,\n\t\t\tinput.viewAttribute\n\t\t);\n\t\tObject.defineProperty(viewClass.prototype, input.viewAttribute, {\n\t\t\tget(this: HTMLComponent<T>): any {\n\t\t\t\treturn this._proxyModel[input.modelProperty] || parentProperty?.get?.call(this);\n\t\t\t},\n\t\t\tset(this: HTMLComponent<{ [key: string]: any; }>, value: any) {\n\t\t\t\tthis._modelScope.set(input.modelProperty, value);\n\t\t\t\t// this._model[input.modelProperty] = value;\n\t\t\t\t// this._proxyModel[input.modelProperty] = value;\n\t\t\t\tparentProperty?.set?.call(this, value);\n\t\t\t},\n\t\t\tenumerable: true,\n\t\t});\n\t});\n\n\tcomponentRef.outputs.forEach(output => {\n\t\tObject.defineProperty(viewClass.prototype, output.viewAttribute, {\n\t\t\tget(): EventEmitter<any> {\n\t\t\t\treturn this._model[output.modelProperty];\n\t\t\t},\n\t\t\tenumerable: true\n\t\t});\n\t\tlet eventListener: Function | undefined;\n\t\tlet subscription: Subscription<any>;\n\t\tObject.defineProperty(viewClass.prototype, 'on' + ToCamelCase(output.viewAttribute), {\n\t\t\t// get(): EventEmitter<any> {\n\t\t\t// \t// return this._model[output.modelProperty];\n\t\t\t// },\n\t\t\tget(): Function | undefined {\n\t\t\t\t// return this._model[output.modelProperty];\n\t\t\t\treturn eventListener;\n\t\t\t},\n\t\t\tset(this: HTMLComponent<T>, event: string | Function): void {\n\t\t\t\tif (!event) {\n\t\t\t\t\tif (subscription) {\n\t\t\t\t\t\tsubscription.unsubscribe();\n\t\t\t\t\t\teventListener = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof event === 'string') {\n\t\t\t\t\tif (event.endsWith('()')) {\n\t\t\t\t\t\tevent = event.substring(0, event.length - 2);\n\t\t\t\t\t}\n\t\t\t\t\tevent = Reflect.get(window, event);\n\t\t\t\t}\n\t\t\t\teventListener = event as Function;\n\t\t\t\tsubscription = (this._model[output.modelProperty] as EventEmitter<any>).subscribe(event);\n\t\t\t},\n\t\t\tenumerable: true\n\t\t});\n\t});\n\tObject.defineProperty(viewClass, 'observedAttributes', {\n\t\tget() {\n\t\t\treturn componentRef.inputs.map(input => input.viewAttribute);\n\t\t}\n\t});\n\t// https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example\n\tif (false) {\n\t\tObject.defineProperty(viewClass, 'formAssociated', {\n\t\t\tget() {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t});\n\t}\n\taddViewToModelClass<T>(modelClass, componentRef.selector, viewClass, htmlViewClassName);\n\tif (!Reflect.has(window, htmlViewClassName)) {\n\t\tReflect.set(window, htmlViewClassName, viewClass);\n\t}\n\treturn viewClass;\n}\n\nexport type ComponentModelClass = Constructable & { [key: string]: string } & { component: { [key: string]: string } };\n\nexport function isComponentModelClass(target: Constructable): target is ComponentModelClass {\n\treturn Reflect.has(target, 'component');\n}\n\nexport function addViewToModelClass<T>(modelClass: TypeOf<T>, selector: string, viewClass: TypeOf<HTMLComponent<T>>, htmlViewClassName: string) {\n\tObject.defineProperty(modelClass, htmlViewClassName, { value: viewClass });\n\n\tif (!isComponentModelClass(modelClass)) {\n\t\tReflect.set(modelClass, 'component', {});\n\t}\n\n\tif (isComponentModelClass(modelClass)) {\n\t\tmodelClass.component[selector] = htmlViewClassName;\n\t}\n}\n\nexport function buildViewClassNameFromSelector(selector: string) {\n\treturn selector\n\t\t.split('-')\n\t\t.map(name => name.replace(/^\\w/, char => char.toUpperCase()))\n\t\t.join('');\n}\n\nexport function ComponentView<T>(modelClass: TypeOf<T>, selector?: string): TypeOf<HTMLComponent<T>> | undefined {\n\tif (isComponentModelClass(modelClass)) {\n\t\tlet viewClassName: string;\n\t\tif (selector) {\n\t\t\tviewClassName = modelClass.component[selector];\n\t\t\tif (!viewClassName) {\n\t\t\t\tthrow new Error(`${modelClass.name} doesn't have ${selector} as view`);\n\t\t\t}\n\t\t} else {\n\t\t\tviewClassName = Object.keys(modelClass.component)[0];\n\t\t}\n\t\treturn Reflect.get(modelClass, viewClassName);\n\t}\n}\n"]}
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/core/view/view.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIlE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAOrD,MAAM,UAAU,qBAAqB,CAAmB,UAAqB,EAAE,YAA6B;IAC3G,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,QAA+B,CAAC;IACvE,IAAI,SAAmC,CAAC;IACxC,MAAM,aAAa,GAAG,8BAA8B,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC5E,MAAM,iBAAiB,GAAG,OAAO,aAAa,SAAS,CAAC;IACxD,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI;QAC3C,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC;YACzC,CAAC,CAAC,mBAAmB,CAAI,UAAU,CAAC;YACpC,CAAC,CAAC,eAAe,CAAI,UAAU,CAAC,CAChC;QACD,CAAC,CAAC,eAAe,CAAI,WAAW,CAAC,CAAC;IACn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,OAAO,QAAQ;SACb,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;SAC5D,IAAI,CAAC,EAAE,CAAC,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAmB,UAAqB,EAAE,QAAiB;IAC1F,IAAI,qBAAqB,CAAC,UAAU,CAAC,EAAE;QACtC,IAAI,aAAqB,CAAC;QAC1B,IAAI,QAAQ,EAAE;YACb,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAC/C,IAAI,CAAC,aAAa,EAAE;gBACnB,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,CAAC,IAAI,iBAAiB,QAAQ,UAAU,CAAC,CAAC;aACvE;SACD;aAAM;YACN,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;SACrD;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;KAC9C;AACF,CAAC","sourcesContent":["import type { TypeOf } from '../utils/typeof.js';\nimport { getAllAttributes, isFormElement } from '@ibyar/elements';\nimport { ComponentRef } from '../component/component.js';\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { EventEmitter, Subscription } from '../component/events.js';\nimport { ToCamelCase } from '../utils/utils.js';\nimport { Constructable } from '../providers/injector.js';\nimport { baseFactoryView } from './base-view.js';\nimport { baseFormFactoryView } from './form-view.js';\n\n/**\n * \n * @param modelClass \n * @param componentRef \n */\nexport function initCustomElementView<T extends Object>(modelClass: TypeOf<T>, componentRef: ComponentRef<T>): TypeOf<HTMLComponent<T>> {\n\tconst htmlParent = componentRef.extend.classRef as TypeOf<HTMLElement>;\n\tlet viewClass: TypeOf<HTMLComponent<T>>;\n\tconst viewClassName = buildViewClassNameFromSelector(componentRef.selector);\n\tconst htmlViewClassName = `HTML${viewClassName}Element`;\n\tconst parentClass = componentRef.extend.name\n\t\t? (isFormElement(componentRef.extend.name)\n\t\t\t? baseFormFactoryView<T>(htmlParent)\n\t\t\t: baseFactoryView<T>(htmlParent)\n\t\t)\n\t\t: baseFactoryView<T>(HTMLElement);\n\tviewClass = ({\n\t\t[htmlViewClassName]: class extends parentClass { constructor() { super(componentRef, modelClass); } }\n\t})[htmlViewClassName];\n\n\tcomponentRef.inputs.forEach((input) => {\n\t\tObject.defineProperty(viewClass.prototype, input.viewAttribute, {\n\t\t\tget(this: HTMLComponent<T>): any {\n\t\t\t\treturn this._modelScope.get(input.modelProperty);\n\t\t\t},\n\t\t\tset(this: HTMLComponent<{ [key: string]: any; }>, value: any) {\n\t\t\t\tthis._modelScope.set(input.modelProperty, value);\n\t\t\t},\n\t\t\tenumerable: true,\n\t\t});\n\t});\n\n\tcomponentRef.outputs.forEach(output => {\n\t\tObject.defineProperty(viewClass.prototype, output.viewAttribute, {\n\t\t\tget(): EventEmitter<any> {\n\t\t\t\treturn this._model[output.modelProperty];\n\t\t\t},\n\t\t\tenumerable: true\n\t\t});\n\t\tlet eventListener: Function | undefined;\n\t\tlet subscription: Subscription<any>;\n\t\tObject.defineProperty(viewClass.prototype, 'on' + ToCamelCase(output.viewAttribute), {\n\t\t\tget(): Function | undefined {\n\t\t\t\treturn eventListener;\n\t\t\t},\n\t\t\tset(this: HTMLComponent<T>, event: string | Function): void {\n\t\t\t\tif (!event) {\n\t\t\t\t\tif (subscription) {\n\t\t\t\t\t\tsubscription.unsubscribe();\n\t\t\t\t\t\teventListener = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (typeof event === 'string') {\n\t\t\t\t\tif (event.endsWith('()')) {\n\t\t\t\t\t\tevent = event.substring(0, event.length - 2);\n\t\t\t\t\t}\n\t\t\t\t\tevent = Reflect.get(window, event);\n\t\t\t\t}\n\t\t\t\teventListener = event as Function;\n\t\t\t\tsubscription = (this._model[output.modelProperty] as EventEmitter<any>).subscribe(event);\n\t\t\t},\n\t\t\tenumerable: true\n\t\t});\n\t});\n\n\tcomponentRef.inputs.map(input => input.modelProperty)\n\t\t.concat(componentRef.outputs.map(output => output.modelProperty))\n\t\t.concat(componentRef.hostBindings.map(host => host.hostPropertyName))\n\t\t.concat(componentRef.viewChild.map(child => child.modelName))\n\t\t.forEach(modelName => modelClass.prototype[modelName] = undefined);\n\n\tconst defaultAttributes = getAllAttributes(componentRef.extend.name);\n\tconst observedAttributes = componentRef.inputs.map(input => input.viewAttribute)\n\tReflect.set(viewClass, 'observedAttributes', observedAttributes);\n\tReflect.set(viewClass, 'allAttributes', defaultAttributes.concat(observedAttributes));\n\t// https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example\n\tif (false) {\n\t\tObject.defineProperty(viewClass, 'formAssociated', {\n\t\t\tget() {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t});\n\t}\n\taddViewToModelClass<T>(modelClass, componentRef.selector, viewClass, htmlViewClassName);\n\tif (!Reflect.has(window, htmlViewClassName)) {\n\t\tReflect.set(window, htmlViewClassName, viewClass);\n\t}\n\treturn viewClass;\n}\n\nexport type ComponentModelClass = Constructable & { [key: string]: string } & { component: { [key: string]: string } };\n\nexport function isComponentModelClass(target: Constructable): target is ComponentModelClass {\n\treturn Reflect.has(target, 'component');\n}\n\nexport function addViewToModelClass<T extends object>(modelClass: TypeOf<T>, selector: string, viewClass: TypeOf<HTMLComponent<T>>, htmlViewClassName: string) {\n\tObject.defineProperty(modelClass, htmlViewClassName, { value: viewClass });\n\n\tif (!isComponentModelClass(modelClass)) {\n\t\tReflect.set(modelClass, 'component', {});\n\t}\n\n\tif (isComponentModelClass(modelClass)) {\n\t\tmodelClass.component[selector] = htmlViewClassName;\n\t}\n}\n\nexport function buildViewClassNameFromSelector(selector: string) {\n\treturn selector\n\t\t.split('-')\n\t\t.map(name => name.replace(/^\\w/, char => char.toUpperCase()))\n\t\t.join('');\n}\n\nexport function getComponentView<T extends object>(modelClass: TypeOf<T>, selector?: string): TypeOf<HTMLComponent<T>> | undefined {\n\tif (isComponentModelClass(modelClass)) {\n\t\tlet viewClassName: string;\n\t\tif (selector) {\n\t\t\tviewClassName = modelClass.component[selector];\n\t\t\tif (!viewClassName) {\n\t\t\t\tthrow new Error(`${modelClass.name} doesn't have ${selector} as view`);\n\t\t\t}\n\t\t} else {\n\t\t\tviewClassName = Object.keys(modelClass.component)[0];\n\t\t}\n\t\treturn Reflect.get(modelClass, viewClassName);\n\t}\n}\n"]}
package/html/update.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import { ExpressionNode, InfixExpressionNode, Stack } from '@ibyar/expressions';
2
- export declare class NodeAssignmentExpression extends InfixExpressionNode<':='> {
3
- constructor(left: ExpressionNode, right: ExpressionNode);
4
- set(stack: Stack, value: any): any;
5
- get(stack: Stack): any;
6
- }
7
- export declare class TextNodeAssignmentExpression extends NodeAssignmentExpression {
8
- }
9
- export declare class HTMLNodeAssignmentExpression extends NodeAssignmentExpression {
10
- }
11
- export declare class DirectiveNodeAssignmentExpression extends NodeAssignmentExpression {
12
- }
package/html/update.js DELETED
@@ -1,24 +0,0 @@
1
- import { InfixExpressionNode } from '@ibyar/expressions';
2
- export class NodeAssignmentExpression extends InfixExpressionNode {
3
- constructor(left, right) {
4
- super(':=', left, right);
5
- }
6
- set(stack, value) {
7
- return this.left.set(stack, value);
8
- }
9
- get(stack) {
10
- const lv = this.left.get(stack);
11
- const rv = this.right.get(stack);
12
- if (lv !== rv) {
13
- this.set(stack, rv);
14
- }
15
- return rv;
16
- }
17
- }
18
- export class TextNodeAssignmentExpression extends NodeAssignmentExpression {
19
- }
20
- export class HTMLNodeAssignmentExpression extends NodeAssignmentExpression {
21
- }
22
- export class DirectiveNodeAssignmentExpression extends NodeAssignmentExpression {
23
- }
24
- //# sourceMappingURL=update.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/core/html/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,mBAAmB,EAAS,MAAM,oBAAoB,CAAC;AAEhF,MAAM,OAAO,wBAAyB,SAAQ,mBAAyB;IACtE,YAAY,IAAoB,EAAE,KAAqB;QACtD,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1B,CAAC;IACD,GAAG,CAAC,KAAY,EAAE,KAAU;QAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IACD,GAAG,CAAC,KAAY;QACf,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,EAAE,KAAK,EAAE,EAAE;YACd,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;SACpB;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD;AAED,MAAM,OAAO,4BAA6B,SAAQ,wBAAwB;CAEzE;AAED,MAAM,OAAO,4BAA6B,SAAQ,wBAAwB;CAEzE;AAED,MAAM,OAAO,iCAAkC,SAAQ,wBAAwB;CAE9E","sourcesContent":["import { ExpressionNode, InfixExpressionNode, Stack } from '@ibyar/expressions';\n\nexport class NodeAssignmentExpression extends InfixExpressionNode<':='> {\n\tconstructor(left: ExpressionNode, right: ExpressionNode) {\n\t\tsuper(':=', left, right);\n\t}\n\tset(stack: Stack, value: any) {\n\t\treturn this.left.set(stack, value);\n\t}\n\tget(stack: Stack): any {\n\t\tconst lv = this.left.get(stack);\n\t\tconst rv = this.right.get(stack);\n\t\tif (lv !== rv) {\n\t\t\tthis.set(stack, rv);\n\t\t}\n\t\treturn rv;\n\t}\n}\n\nexport class TextNodeAssignmentExpression extends NodeAssignmentExpression {\n\n}\n\nexport class HTMLNodeAssignmentExpression extends NodeAssignmentExpression {\n\n}\n\nexport class DirectiveNodeAssignmentExpression extends NodeAssignmentExpression {\n\n}\n\n"]}
@@ -1,5 +0,0 @@
1
- import { EmbeddedViewRef } from './view_ref.js';
2
- export declare abstract class TemplateRef<C> {
3
- abstract get anchorRef(): Element;
4
- abstract createEmbeddedView(context: C): EmbeddedViewRef<C>;
5
- }
@@ -1,3 +0,0 @@
1
- export class TemplateRef {
2
- }
3
- //# sourceMappingURL=template_ref.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"template_ref.js","sourceRoot":"","sources":["../../../src/core/linker/template_ref.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,WAAW;CAuBhC","sourcesContent":["import { EmbeddedViewRef } from './view_ref.js';\n\nexport abstract class TemplateRef<C> {\n\n\t/**\n\t * The anchor element in the parent view for this embedded view.\n\t *\n\t * The data-binding and injection contexts of embedded views created from this `TemplateRef`\n\t * inherit from the contexts of this location.\n\t *\n\t * Typically new embedded views are attached to the view container of this location, but in\n\t * advanced use-cases, the view can be attached to a different container while keeping the\n\t * data-binding and injection context from the original location.\n\t *\n\t */\n\tabstract get anchorRef(): Element;\n\n\t/**\n\t * Instantiates an embedded view based on this template,\n\t * and attaches it to the view container.\n\t * @param context The data-binding context of the embedded view, as declared\n\t * in the `<ng-template>` usage.\n\t * @returns The new embedded view object.\n\t */\n\tabstract createEmbeddedView(context: C): EmbeddedViewRef<C>;\n}\n"]}
@@ -1,20 +0,0 @@
1
- import { HTMLComponent } from '../index.js';
2
- import { TypeOf } from '../utils/typeof.js';
3
- import { TemplateRef } from './template_ref.js';
4
- import { EmbeddedViewRef, ViewRef } from './view_ref.js';
5
- export declare abstract class ViewContainerRef {
6
- abstract get anchorElement(): Element;
7
- abstract clear(): void;
8
- abstract get(index: number): ViewRef | null;
9
- abstract get length(): number;
10
- abstract createEmbeddedView<C>(templateRef: TemplateRef<C>, context?: C, index?: number): EmbeddedViewRef<C>;
11
- abstract createComponent<C>(componentType: TypeOf<C>, options: {
12
- index?: number;
13
- selector?: string;
14
- }): HTMLComponent<C>;
15
- abstract insert(viewRef: ViewRef, index?: number): ViewRef;
16
- abstract move(viewRef: ViewRef, currentIndex: number): ViewRef;
17
- abstract indexOf(viewRef: ViewRef): number;
18
- abstract remove(index?: number): void;
19
- abstract detach(index?: number): ViewRef | null;
20
- }
@@ -1,3 +0,0 @@
1
- export class ViewContainerRef {
2
- }
3
- //# sourceMappingURL=view_container_ref.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"view_container_ref.js","sourceRoot":"","sources":["../../../src/core/linker/view_container_ref.ts"],"names":[],"mappings":"AAKA,MAAM,OAAgB,gBAAgB;CAwGrC","sourcesContent":["import { HTMLComponent } from '../index.js';\nimport { TypeOf } from '../utils/typeof.js';\nimport { TemplateRef } from './template_ref.js';\nimport { EmbeddedViewRef, ViewRef } from './view_ref.js';\n\nexport abstract class ViewContainerRef {\n\n\t/**\n\t * Anchor element that specifies the location of this container in the containing view.\n\t * Each view container can have only one anchor element, and each anchor element\n\t * can have only a single view container.\n\t * \n\t * Root elements of views attached to this container become siblings of the anchor element in\n\t * the rendered view.\n\t *\n\t * Access the `ViewContainerRef` of an element by placing a `Directive` injected\n\t * with `ViewContainerRef` on the element, or use a `ViewChild` query.\n\t *\n\t */\n\tabstract get anchorElement(): Element;\n\n\t/**\n\t * Destroys all views in this container.\n\t */\n\tabstract clear(): void;\n\n\t/**\n\t * Retrieves a view from this container.\n\t * @param index The 0-based index of the view to retrieve.\n\t * @returns The `ViewRef` instance, or null if the index is out of range.\n\t */\n\tabstract get(index: number): ViewRef | null;\n\n\t/**\n\t * Reports how many views are currently attached to this container.\n\t * @returns The number of views.\n\t */\n\tabstract get length(): number;\n\n\t/**\n\t * Instantiates an embedded view and inserts it\n\t * into this container.\n\t * @param templateRef The HTML template that defines the view.\n\t * @param context The data-binding context of the embedded view, as declared\n\t * in the `<ng-template>` usage.\n\t * @param index The 0-based index at which to insert the new view into this container.\n\t * If not specified, appends the new view as the last entry.\n\t *\n\t * @returns The `ViewRef` instance for the newly created view.\n\t */\n\tabstract createEmbeddedView<C>(templateRef: TemplateRef<C>, context?: C, index?: number): EmbeddedViewRef<C>;\n\n\t/**\n * Instantiates a single component and inserts its host view into this container.\n *\n * @param componentType Component Type to use.\n * @param options An object that contains extra parameters:\n * * index: the index at which to insert the new component's host view into this container.\n * If not specified, appends the new view as the last entry.\n * * selector: the tag name of the new create component that attached with this model class.\n * \t\t\tAny Model class can have many views with different selectors. \n *\n * @returns The new `HTMLComponent` which contains the component instance and the host view.\n */\n\tabstract createComponent<C>(componentType: TypeOf<C>, options: {\n\t\tindex?: number,\n\t\tselector?: string\n\t}): HTMLComponent<C>;\n\n\t/**\n\t * Inserts a view into this container.\n\t * @param viewRef The view to insert.\n\t * @param index The 0-based index at which to insert the view.\n\t * If not specified, appends the new view as the last entry.\n\t * @returns The inserted `ViewRef` instance.\n\t *\n\t */\n\tabstract insert(viewRef: ViewRef, index?: number): ViewRef;\n\n\t/**\n\t * Moves a view to a new location in this container.\n\t * @param viewRef The view to move.\n\t * @param index The 0-based index of the new location.\n\t * @returns The moved `ViewRef` instance.\n\t */\n\tabstract move(viewRef: ViewRef, currentIndex: number): ViewRef;\n\n\t/**\n\t * Returns the index of a view within the current container.\n\t * @param viewRef The view to query.\n\t * @returns The 0-based index of the view's position in this container,\n\t * or `-1` if this container doesn't contain the view.\n\t */\n\tabstract indexOf(viewRef: ViewRef): number;\n\n\t/**\n\t * Destroys a view attached to this container\n\t * @param index The 0-based index of the view to destroy.\n\t * If not specified, the last view in the container is removed.\n\t */\n\tabstract remove(index?: number): void;\n\n\t/**\n\t * Detaches a view from this container without destroying it.\n\t * Use along with `insert()` to move a view within the current container.\n\t * @param index The 0-based index of the view to detach.\n\t * If not specified, the last view in the container is detached.\n\t */\n\tabstract detach(index?: number): ViewRef | null;\n}\n"]}
@@ -1,9 +0,0 @@
1
- export declare abstract class ViewRef {
2
- abstract destroy(): void;
3
- abstract get destroyed(): boolean;
4
- abstract onDestroy(callback: Function): any;
5
- }
6
- export declare abstract class EmbeddedViewRef<C> extends ViewRef {
7
- abstract context: C;
8
- abstract get rootNodes(): any[];
9
- }
@@ -1,5 +0,0 @@
1
- export class ViewRef {
2
- }
3
- export class EmbeddedViewRef extends ViewRef {
4
- }
5
- //# sourceMappingURL=view_ref.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"view_ref.js","sourceRoot":"","sources":["../../../src/core/linker/view_ref.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,OAAO;CAmB5B;AAGD,MAAM,OAAgB,eAAmB,SAAQ,OAAO;CAUvD","sourcesContent":["\n\nexport abstract class ViewRef {\n\t/**\n\t * Destroys this view and all of the data structures associated with it.\n\t */\n\tabstract destroy(): void;\n\n\t/**\n\t * Reports whether this view has been destroyed.\n\t * @returns True after the `destroy()` method has been called, false otherwise.\n\t */\n\tabstract get destroyed(): boolean;\n\n\t/**\n\t * A lifecycle hook that provides additional developer-defined cleanup\n\t * functionality for views.\n\t * @param callback A handler function that cleans up developer-defined data\n\t * associated with a view. Called when the `destroy()` method is invoked.\n\t */\n\tabstract onDestroy(callback: Function): any /** TODO #9100 */;\n}\n\n\nexport abstract class EmbeddedViewRef<C> extends ViewRef {\n\t/**\n\t * The context for this view, inherited from the anchor element.\n\t */\n\tabstract context: C;\n\n\t/**\n\t * The root nodes for this embedded view.\n\t */\n\tabstract get rootNodes(): any[];\n}\n"]}
@@ -1,13 +0,0 @@
1
- export declare type SourceFollowerCallback = (stack: any[]) => void;
2
- export interface Model {
3
- __observable: {
4
- [key: string]: Function[];
5
- };
6
- subscribeModel(eventName: string, callback: SourceFollowerCallback): void;
7
- emitChangeModel(eventName: string, source?: any[]): void;
8
- }
9
- export declare function isModel(object: any): object is Model;
10
- export declare function defineModel<T>(object: T): Model & T;
11
- export declare function subscribe1way(obj1: {}, obj1PropName: string, callback: SourceFollowerCallback, obj2?: {}, obj2PropName?: string): void;
12
- export declare function addChangeListener(observableModel: {}, propertyName: string, callback: () => void): void;
13
- export declare function subscribe2way(obj1: {}, obj1PropName: string, callback1: SourceFollowerCallback, obj2: {}, obj2PropName: string, callback2: SourceFollowerCallback): void;
@@ -1,100 +0,0 @@
1
- import { isHTMLComponent } from '../component/custom-element.js';
2
- export function isModel(object) {
3
- return object.__observable
4
- && object.subscribeModel
5
- && object.emitChangeModel;
6
- }
7
- export function defineModel(object) {
8
- if (typeof object !== 'object') {
9
- throw new Error(`typeof ${typeof object} can't be a subscription model`);
10
- }
11
- if (isModel(object)) {
12
- return object;
13
- }
14
- const observable = {};
15
- Object.defineProperty(object, '__observable', { value: observable });
16
- Object.defineProperty(object, 'subscribeModel', {
17
- value: (eventName, callback) => {
18
- if (typeof callback !== 'function') {
19
- return;
20
- }
21
- observable[eventName] = observable[eventName] || [];
22
- observable[eventName].push(callback);
23
- }
24
- });
25
- Object.defineProperty(object, 'emitChangeModel', {
26
- value: (eventName, source) => {
27
- if (!source) {
28
- source = [object];
29
- }
30
- else {
31
- source.push(object);
32
- }
33
- let calls = Object.keys(observable)
34
- .filter(key => key.startsWith(eventName) || eventName.startsWith(key));
35
- calls.forEach(key => {
36
- observable[key].forEach(callback => callback.call(object, source));
37
- });
38
- }
39
- });
40
- return object;
41
- }
42
- export function subscribe1way(obj1, obj1PropName, callback, obj2, obj2PropName) {
43
- const subject1 = defineModel(isHTMLComponent(obj1) ? obj1._model : obj1);
44
- const subject1Callback = (source) => {
45
- callback(source);
46
- if (obj2 && obj2PropName) {
47
- let subject2 = defineModel(isHTMLComponent(obj2) ? obj2._model : obj2);
48
- if (obj2PropName && !source.includes(subject2)) {
49
- subject2.emitChangeModel(obj2PropName, source);
50
- }
51
- }
52
- };
53
- const subject1DestroyCallback = (source) => {
54
- const subIndex = subject1.__observable[obj1PropName].indexOf(subject1Callback);
55
- subject1.__observable[obj1PropName].splice(subIndex, 1);
56
- };
57
- subject1.subscribeModel(obj1PropName, subject1Callback);
58
- subject1.subscribeModel('destroy', subject1DestroyCallback);
59
- }
60
- export function addChangeListener(observableModel, propertyName, callback) {
61
- const subject1 = defineModel(isHTMLComponent(observableModel) ? observableModel._model : observableModel);
62
- const subject1Callback = (source) => {
63
- callback();
64
- };
65
- const subject1DestroyCallback = (source) => {
66
- const subIndex = subject1.__observable[propertyName].indexOf(subject1Callback);
67
- subject1.__observable[propertyName].splice(subIndex, 1);
68
- };
69
- subject1.subscribeModel(propertyName, subject1Callback);
70
- subject1.subscribeModel('destroy', subject1DestroyCallback);
71
- }
72
- export function subscribe2way(obj1, obj1PropName, callback1, obj2, obj2PropName, callback2) {
73
- const subject1 = defineModel(isHTMLComponent(obj1) ? obj1._model : obj1);
74
- const subject2 = defineModel(isHTMLComponent(obj2) ? obj2._model : obj2);
75
- const subject1Callback = (source) => {
76
- callback1(source);
77
- if (!source.includes(subject2)) {
78
- subject2.emitChangeModel(obj2PropName, source);
79
- }
80
- };
81
- const subject1DestroyCallback = (source) => {
82
- const subIndex = subject1.__observable[obj1PropName].indexOf(subject1Callback);
83
- subject1.__observable[obj1PropName].splice(subIndex, 1);
84
- };
85
- subject1.subscribeModel(obj1PropName, subject1Callback);
86
- subject1.subscribeModel('destroy', subject1DestroyCallback);
87
- const subject2Callback = (source) => {
88
- callback2(source);
89
- if (!source.includes(subject1)) {
90
- subject1.emitChangeModel(obj1PropName, source);
91
- }
92
- };
93
- const subject2DestroyCallback = (source) => {
94
- const subIndex = subject2.__observable[obj2PropName].indexOf(subject1Callback);
95
- subject2.__observable[obj2PropName].splice(subIndex, 1);
96
- };
97
- subject2.subscribeModel(obj2PropName, subject2Callback);
98
- subject2.subscribeModel('destroy', subject2DestroyCallback);
99
- }
100
- //# sourceMappingURL=change-detection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"change-detection.js","sourceRoot":"","sources":["../../../src/core/model/change-detection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AASjE,MAAM,UAAU,OAAO,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ent":["import { isHTMLComponent } from '../component/custom-element.js';\n\nexport type SourceFollowerCallback = (stack: any[]) => void;\nexport interface Model {\n\t__observable: { [key: string]: Function[] };\n\tsubscribeModel(eventName: string, callback: SourceFollowerCallback): void;\n\temitChangeModel(eventName: string, source?: any[]): void;\n}\n\nexport function isModel(object: any): object is Model {\n\treturn object.__observable\n\t\t&& object.subscribeModel\n\t\t&& object.emitChangeModel;\n}\n\nexport function defineModel<T>(object: T): Model & T {\n\tif (typeof object !== 'object') {\n\t\tthrow new Error(`typeof ${typeof object} can't be a subscription model`);\n\t}\n\tif (isModel(object)) {\n\t\treturn object;\n\t}\n\tconst observable: { [key: string]: Function[] } = {};\n\tObject.defineProperty(object, '__observable', { value: observable });\n\tObject.defineProperty(object, 'subscribeModel', {\n\t\tvalue: (eventName: string, callback: Function) => {\n\t\t\tif (typeof callback !== 'function') {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tobservable[eventName] = observable[eventName] || [];\n\t\t\tobservable[eventName].push(callback);\n\t\t}\n\t});\n\tObject.defineProperty(object, 'emitChangeModel', {\n\t\tvalue: (eventName: string, source?: any[]) => {\n\t\t\tif (!source) {\n\t\t\t\tsource = [object];\n\t\t\t} else {\n\t\t\t\tsource.push(object);\n\t\t\t}\n\t\t\tlet calls = Object.keys(observable)\n\t\t\t\t.filter(key => key.startsWith(eventName) || eventName.startsWith(key));\n\t\t\tcalls.forEach(key => {\n\t\t\t\tobservable[key].forEach(callback => callback.call(object, source));\n\t\t\t});\n\t\t}\n\t});\n\treturn object as Model & T;\n}\n\nexport function subscribe1way(obj1: {}, obj1PropName: string, callback: SourceFollowerCallback, obj2?: {}, obj2PropName?: string) {\n\tconst subject1 = defineModel<object>(isHTMLComponent(obj1) ? obj1._model : obj1);\n\tconst subject1Callback = (source: any[]) => {\n\t\tcallback(source);\n\t\tif (obj2 && obj2PropName) {\n\t\t\tlet subject2 = defineModel<object>(isHTMLComponent(obj2) ? obj2._model : obj2);\n\t\t\tif (obj2PropName && !source.includes(subject2)) {\n\t\t\t\tsubject2.emitChangeModel(obj2PropName, source);\n\t\t\t}\n\t\t}\n\t};\n\tconst subject1DestroyCallback = (source: any[]) => {\n\t\tconst subIndex = subject1.__observable[obj1PropName].indexOf(subject1Callback);\n\t\tsubject1.__observable[obj1PropName].splice(subIndex, 1);\n\t};\n\n\tsubject1.subscribeModel(obj1PropName, subject1Callback);\n\tsubject1.subscribeModel('destroy', subject1DestroyCallback);\n}\n\nexport function addChangeListener(observableModel: {}, propertyName: string, callback: () => void) {\n\tconst subject1 = defineModel<object>(isHTMLComponent(observableModel) ? observableModel._model : observableModel);\n\n\tconst subject1Callback = (source: any[]) => {\n\t\tcallback();\n\t};\n\tconst subject1DestroyCallback = (source: any[]) => {\n\t\tconst subIndex = subject1.__observable[propertyName].indexOf(subject1Callback);\n\t\tsubject1.__observable[propertyName].splice(subIndex, 1);\n\t};\n\n\tsubject1.subscribeModel(propertyName, subject1Callback);\n\tsubject1.subscribeModel('destroy', subject1DestroyCallback);\n}\n\nexport function subscribe2way(obj1: {}, obj1PropName: string, callback1: SourceFollowerCallback, obj2: {}, obj2PropName: string, callback2: SourceFollowerCallback) {\n\tconst subject1: Model = defineModel(isHTMLComponent(obj1) ? obj1._model : obj1);\n\tconst subject2: Model = defineModel(isHTMLComponent(obj2) ? obj2._model : obj2);\n\n\tconst subject1Callback = (source: any[]) => {\n\t\tcallback1(source);\n\t\tif (!source.includes(subject2)) {\n\t\t\tsubject2.emitChangeModel(obj2PropName, source);\n\t\t}\n\t};\n\tconst subject1DestroyCallback = (source: any[]) => {\n\t\tconst subIndex = subject1.__observable[obj1PropName].indexOf(subject1Callback);\n\t\tsubject1.__observable[obj1PropName].splice(subIndex, 1);\n\t};\n\n\tsubject1.subscribeModel(obj1PropName, subject1Callback);\n\tsubject1.subscribeModel('destroy', subject1DestroyCallback);\n\n\tconst subject2Callback = (source: any[]) => {\n\t\tcallback2(source);\n\t\tif (!source.includes(subject1)) {\n\t\t\tsubject1.emitChangeModel(obj1PropName, source);\n\t\t}\n\t};\n\tconst subject2DestroyCallback = (source: any[]) => {\n\t\tconst subIndex = subject2.__observable[obj2PropName].indexOf(subject1Callback);\n\t\tsubject2.__observable[obj2PropName].splice(subIndex, 1);\n\t};\n\n\tsubject2.subscribeModel(obj2PropName, subject2Callback);\n\tsubject2.subscribeModel('destroy', subject2DestroyCallback);\n}\n"]}
package/view/events.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { ExpressionEventMap, Scope, Stack } from '@ibyar/expressions';
2
- export declare function findScopeMap(events: ExpressionEventMap, stack: Stack): Map<string, Scope<object>>;
package/view/events.js DELETED
@@ -1,25 +0,0 @@
1
- function visitInnerEvents(events, scope, rootName, scopeMap) {
2
- const innerEventNames = Object.keys(events);
3
- innerEventNames.forEach(eventName => {
4
- if (eventName.startsWith(':')) {
5
- return;
6
- }
7
- const innerScope = scope.getScope(eventName);
8
- if (innerScope) {
9
- const innerEventName = `${rootName}.${eventName}`;
10
- scopeMap.set(innerEventName, innerScope);
11
- visitInnerEvents(events[eventName], innerScope, innerEventName, scopeMap);
12
- }
13
- });
14
- }
15
- export function findScopeMap(events, stack) {
16
- const scopeMap = new Map();
17
- const rootEventNames = Object.keys(events);
18
- rootEventNames.forEach(eventName => {
19
- const scope = stack.findScope(eventName);
20
- scopeMap.set(eventName, scope);
21
- visitInnerEvents(events[eventName], scope, eventName, scopeMap);
22
- });
23
- return scopeMap;
24
- }
25
- //# sourceMappingURL=events.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/core/view/events.ts"],"names":[],"mappings":"AAEA,SAAS,gBAAgB,CAAC,MAA0B,EAAE,KAA0B,EAAE,QAAgB,EAAE,QAAoC;IACvI,MAAM,eAAe,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5C,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QACnC,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC9B,OAAO;SACP;QACD,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAe,SAAS,CAAC,CAAC;QAC3D,IAAI,UAAU,EAAE;YACf,MAAM,cAAc,GAAG,GAAG,QAAQ,IAAI,SAAS,EAAE,CAAC;YAClD,QAAQ,CAAC,GAAG,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;YACzC,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;SAC1E;IACF,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAA0B,EAAE,KAAY;IACpE,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAClD,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3C,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;QAClC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACzC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC/B,gBAAgB,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["import type { ExpressionEventMap, Scope, ScopeContext, Stack } from '@ibyar/expressions';\n\nfunction visitInnerEvents(events: ExpressionEventMap, scope: Scope<ScopeContext>, rootName: string, scopeMap: Map<string, Scope<object>>) {\n\tconst innerEventNames = Object.keys(events);\n\tinnerEventNames.forEach(eventName => {\n\t\tif (eventName.startsWith(':')) {\n\t\t\treturn;\n\t\t}\n\t\tconst innerScope = scope.getScope<ScopeContext>(eventName);\n\t\tif (innerScope) {\n\t\t\tconst innerEventName = `${rootName}.${eventName}`;\n\t\t\tscopeMap.set(innerEventName, innerScope);\n\t\t\tvisitInnerEvents(events[eventName], innerScope, innerEventName, scopeMap);\n\t\t}\n\t});\n}\n\nexport function findScopeMap(events: ExpressionEventMap, stack: Stack) {\n\tconst scopeMap = new Map<string, Scope<object>>();\n\tconst rootEventNames = Object.keys(events);\n\trootEventNames.forEach(eventName => {\n\t\tconst scope = stack.findScope(eventName);\n\t\tscopeMap.set(eventName, scope);\n\t\tvisitInnerEvents(events[eventName], scope, eventName, scopeMap);\n\t});\n\treturn scopeMap;\n}\n"]}