@ibyar/core 0.5.4 → 0.6.0

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 (81) hide show
  1. package/LICENSE +1 -1
  2. package/annotation/decorators.d.ts +121 -0
  3. package/annotation/decorators.js.map +1 -1
  4. package/binding/binding.expressions.d.ts +9 -4
  5. package/binding/binding.expressions.js +26 -20
  6. package/binding/binding.expressions.js.map +1 -1
  7. package/component/component.d.ts +3 -0
  8. package/component/component.js +1 -0
  9. package/component/component.js.map +1 -1
  10. package/component/custom-element.d.ts +48 -4
  11. package/component/custom-element.js.map +1 -1
  12. package/component/events.js +2 -6
  13. package/component/events.js.map +1 -1
  14. package/context/stack.js +4 -0
  15. package/context/stack.js.map +1 -1
  16. package/directive/directive.d.ts +9 -0
  17. package/directive/directive.js +9 -0
  18. package/directive/directive.js.map +1 -1
  19. package/directive/parser.d.ts +4 -0
  20. package/directive/parser.js +20 -1
  21. package/directive/parser.js.map +1 -1
  22. package/directive/providers.js +3 -3
  23. package/directive/providers.js.map +1 -1
  24. package/html/expression.d.ts +5 -0
  25. package/html/expression.js +21 -9
  26. package/html/expression.js.map +1 -1
  27. package/index.d.ts +4 -0
  28. package/index.js +4 -0
  29. package/index.js.map +1 -1
  30. package/linker/change-detector-ref.d.ts +25 -2
  31. package/linker/change-detector-ref.js +30 -18
  32. package/linker/change-detector-ref.js.map +1 -1
  33. package/linker/template-ref.d.ts +17 -5
  34. package/linker/template-ref.js +23 -20
  35. package/linker/template-ref.js.map +1 -1
  36. package/linker/view-container-ref.d.ts +140 -8
  37. package/linker/view-container-ref.js +82 -31
  38. package/linker/view-container-ref.js.map +1 -1
  39. package/linker/view-ref.d.ts +49 -5
  40. package/linker/view-ref.js +23 -9
  41. package/linker/view-ref.js.map +1 -1
  42. package/package.json +10 -6
  43. package/pipe/pipe.d.ts +7 -0
  44. package/pipe/pipe.js +4 -4
  45. package/pipe/pipe.js.map +1 -1
  46. package/providers/injector.js +1 -0
  47. package/providers/injector.js.map +1 -1
  48. package/render/host-listener.handler.d.ts +17 -0
  49. package/render/host-listener.handler.js +21 -4
  50. package/render/host-listener.handler.js.map +1 -1
  51. package/render/render-handler.d.ts +6 -0
  52. package/utils/typeof.d.ts +3 -0
  53. package/utils/utils.js +1 -0
  54. package/utils/utils.js.map +1 -1
  55. package/view/base-view.js +51 -19
  56. package/view/base-view.js.map +1 -1
  57. package/view/form-view.js +21 -0
  58. package/view/form-view.js.map +1 -1
  59. package/view/mutation.js +1 -0
  60. package/view/mutation.js.map +1 -1
  61. package/view/render.d.ts +9 -9
  62. package/view/render.js +38 -29
  63. package/view/render.js.map +1 -1
  64. package/view/view.d.ts +5 -0
  65. package/view/view.js +7 -0
  66. package/view/view.js.map +1 -1
  67. package/zone/bootstrap.d.ts +21 -0
  68. package/zone/bootstrap.js +35 -0
  69. package/zone/bootstrap.js.map +1 -0
  70. package/zone/proxy.d.ts +15 -0
  71. package/zone/proxy.js +32 -0
  72. package/zone/proxy.js.map +1 -0
  73. package/zone/task.d.ts +61 -0
  74. package/zone/task.js +109 -0
  75. package/zone/task.js.map +1 -0
  76. package/zone/zone.d.ts +49 -0
  77. package/zone/zone.js +198 -0
  78. package/zone/zone.js.map +1 -0
  79. package/component/provider.d.ts +0 -10
  80. package/component/provider.js +0 -17
  81. package/component/provider.js.map +0 -1
package/view/render.js CHANGED
@@ -41,10 +41,10 @@ export class ComponentRender {
41
41
  }
42
42
  let rootRef;
43
43
  if (this.componentRef.isShadowDom) {
44
- if (this.view.shadowRoot) {
44
+ if (this.view.shadowRoot /* OPEN MODE */) {
45
45
  rootRef = this.view.shadowRoot;
46
46
  }
47
- else {
47
+ else /* CLOSED MODE*/ {
48
48
  rootRef = Reflect.get(this.view, '_shadowRoot');
49
49
  Reflect.deleteProperty(this.view, '_shadowRoot');
50
50
  }
@@ -94,7 +94,7 @@ export class ComponentRender {
94
94
  }
95
95
  addNativeEventListener(source, eventName, funcCallback) {
96
96
  source.addEventListener(eventName, (event) => {
97
- funcCallback.call(this.view._proxyModel, event);
97
+ this.view._zone.run(funcCallback, this.view._model);
98
98
  });
99
99
  }
100
100
  getElementByName(name) {
@@ -106,10 +106,12 @@ export class ComponentRender {
106
106
  const stack = directiveStack.copyStack();
107
107
  const templateRef = new TemplateRefImpl(this, directive.node, stack, directive.templateExpressions ?? []);
108
108
  const viewContainerRef = new ViewContainerRefImpl(parentNode, comment);
109
+ // structural directive selector
109
110
  const StructuralDirectiveClass = directiveRef.modelClass;
110
111
  const structural = new StructuralDirectiveClass(templateRef, viewContainerRef, host);
111
112
  templateRef.host = structural;
112
- stack.pushReactiveScopeFor({ 'this': structural });
113
+ const scope = ReactiveScope.readOnlyScopeForThis(structural);
114
+ stack.pushScope(scope);
113
115
  const dSubs = this.initStructuralDirective(structural, directive, stack);
114
116
  subscriptions.push(...dSubs);
115
117
  if (isOnInit(structural)) {
@@ -123,6 +125,8 @@ export class ComponentRender {
123
125
  }
124
126
  }
125
127
  else {
128
+ // didn't find directive or it is not define yet.
129
+ // class registry should have 'when defined' callback
126
130
  }
127
131
  }
128
132
  createComment(node) {
@@ -137,9 +141,7 @@ export class ComponentRender {
137
141
  contextStack.pushBlockScopeFor({ this: liveText });
138
142
  const textSubscriptions = textNode.expression.subscribe(contextStack, textNode.pipelineNames);
139
143
  subscriptions.push(...textSubscriptions);
140
- contextStack.detach();
141
144
  textNode.expression.get(contextStack);
142
- contextStack.reattach();
143
145
  return liveText;
144
146
  }
145
147
  createDocumentFragment(node, contextStack, parentNode, subscriptions, host) {
@@ -151,6 +153,11 @@ export class ComponentRender {
151
153
  if (child instanceof DomElementNode) {
152
154
  if (this.isTemplateRefName(child)) {
153
155
  const templateRefName = child.templateRefName;
156
+ // const oldRef = this.templateNameScope.get(templateRefName.name);
157
+ // if (oldRef) {
158
+ // return;
159
+ // }
160
+ // TODO: extract template expression
154
161
  const templateRef = new TemplateRefImpl(this, new DomFragmentNode(child.children), contextStack.copyStack(), []);
155
162
  this.templateNameScope.set(templateRefName.name, templateRef);
156
163
  return;
@@ -193,9 +200,11 @@ export class ComponentRender {
193
200
  }
194
201
  }
195
202
  else if (isTagNameNative(node.tagName)) {
203
+ // native tags // and custom tags can be used her
196
204
  element = document.createElement(node.tagName, node.is ? { is: node.is } : undefined);
197
205
  }
198
206
  else {
207
+ // html unknown element
199
208
  element = document.createElement(node.tagName);
200
209
  }
201
210
  if (isHTMLComponent(element)) {
@@ -206,15 +215,16 @@ export class ComponentRender {
206
215
  createElement(node, contextStack, subscriptions, parentNode, host) {
207
216
  const element = this.createElementByTagName(node);
208
217
  const elementStack = contextStack.copyStack();
209
- const elementScope = isHTMLComponent(element) ? element._viewScope : elementStack.pushReactiveScopeFor({ 'this': element });
218
+ const elementScope = isHTMLComponent(element)
219
+ ? element._viewScope
220
+ : ReactiveScope.readOnlyScopeForThis(element);
210
221
  elementStack.pushScope(elementScope);
211
222
  const attributesSubscriptions = this.initAttribute(element, node, elementStack);
212
223
  subscriptions.push(...attributesSubscriptions);
213
224
  const eventName = getInputEventName(element);
214
- let listener;
215
225
  if (eventName) {
216
- const inputScope = elementScope.getScopeOrCreat('this');
217
- listener = (event) => inputScope.emit('value', element.value);
226
+ const inputScope = elementScope.getInnerScope('this');
227
+ const listener = (event) => inputScope.emit('value', element.value);
218
228
  element.addEventListener(eventName, listener);
219
229
  }
220
230
  const templateRefName = node.templateRefName;
@@ -260,6 +270,9 @@ export class ComponentRender {
260
270
  const subscriptions = [];
261
271
  if (node.attributes?.length) {
262
272
  node.attributes.forEach(attr => {
273
+ /**
274
+ * <input id="23" name="person-name" />
275
+ */
263
276
  const isAttr = hasAttr(element, attr.name);
264
277
  if (isAttr) {
265
278
  if (attr.value === false) {
@@ -281,33 +294,37 @@ export class ComponentRender {
281
294
  node.twoWayBinding.forEach(attr => {
282
295
  const sub = attr.expression.subscribe(contextStack);
283
296
  subscriptions.push(...sub);
284
- contextStack.detach();
285
297
  attr.expression.get(contextStack);
286
- contextStack.reattach();
287
298
  });
288
299
  }
289
300
  if (node.inputs?.length) {
290
301
  node.inputs.forEach(attr => {
291
302
  const sub = attr.expression.subscribe(contextStack, attr.pipelineNames);
292
303
  subscriptions.push(...sub);
293
- contextStack.detach();
294
304
  attr.expression.get(contextStack);
295
- contextStack.reattach();
296
305
  });
297
306
  }
298
307
  if (node.outputs?.length) {
299
308
  node.outputs.forEach(event => {
300
309
  let listener;
310
+ /**
311
+ * <a (click)="onLinkClick($event)"></a>
312
+ * <a @click="onLinkClick($event)"></a>
313
+ * <input [(value)]="person.name" />
314
+ * <input (value)="person.name" />
315
+ * <!-- <input (value)="person.name = $event" /> -->
316
+ *
317
+ * TODO: diff of event listener and back-way data binding
318
+ */
301
319
  if (typeof event.value === 'string') {
302
320
  listener = ($event) => {
303
321
  const stack = contextStack.copyStack();
304
322
  stack.pushBlockScopeFor({ $event });
305
- stack.detach();
306
- event.expression.get(stack);
307
- stack.reattach();
323
+ this.view._zone.run(event.expression.get, event.expression, [stack]);
308
324
  };
309
325
  }
310
- else {
326
+ else /* if (typeof event.sourceHandler === 'function')*/ {
327
+ // let eventName: keyof HTMLElementEventMap = event.eventName;
311
328
  listener = event.value;
312
329
  }
313
330
  element.addEventListener(event.name, listener);
@@ -317,9 +334,7 @@ export class ComponentRender {
317
334
  node.templateAttrs.forEach(attr => {
318
335
  const sub = attr.expression.subscribe(contextStack);
319
336
  subscriptions.push(...sub);
320
- contextStack.detach();
321
337
  attr.expression.get(contextStack);
322
- contextStack.reattach();
323
338
  });
324
339
  }
325
340
  return subscriptions;
@@ -333,18 +348,14 @@ export class ComponentRender {
333
348
  node.twoWayBinding.forEach(attr => {
334
349
  const sub = attr.expression.subscribe(contextStack);
335
350
  subscriptions.push(...sub);
336
- contextStack.detach();
337
351
  attr.expression.get(contextStack);
338
- contextStack.reattach();
339
352
  });
340
353
  }
341
354
  if (node.inputs?.length) {
342
355
  node.inputs.forEach(attr => {
343
356
  const sub = attr.expression.subscribe(contextStack, attr.pipelineNames);
344
357
  subscriptions.push(...sub);
345
- contextStack.detach();
346
358
  attr.expression.get(contextStack);
347
- contextStack.reattach();
348
359
  });
349
360
  }
350
361
  if (node.outputs?.length) {
@@ -352,9 +363,7 @@ export class ComponentRender {
352
363
  const listener = ($event) => {
353
364
  const stack = contextStack.copyStack();
354
365
  stack.pushBlockScopeFor({ $event });
355
- stack.detach();
356
- event.expression.get(stack);
357
- stack.reattach();
366
+ this.view._zone.run(event.expression.get, event.expression, [stack]);
358
367
  };
359
368
  directive[event.name].subscribe(listener);
360
369
  });
@@ -363,11 +372,11 @@ export class ComponentRender {
363
372
  node.templateAttrs.forEach(attr => {
364
373
  const sub = attr.expression.subscribe(contextStack);
365
374
  subscriptions.push(...sub);
366
- contextStack.detach();
367
375
  attr.expression.get(contextStack);
368
- contextStack.reattach();
369
376
  });
370
377
  }
378
+ // TODO:
379
+ // check host binding
371
380
  return subscriptions;
372
381
  }
373
382
  }
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/view/render.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,WAAW,EAAE,0BAA0B,EACvC,cAAc,EAAE,eAAe,EAAW,iBAAiB,EAC3D,eAAe,EAAE,wBAAwB,EACzC,WAAW,EACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAiB,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,8BAA8B,EAAuB,MAAM,2BAA2B,CAAC;AACpH,OAAO,EAAe,eAAe,EAAE,MAAM,2BAA2B,CAAC;A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CAAC,CAAC;gBAClC,YAAY,CAAC,QAAQ,EAAE,CAAC;YACzB,CAAC,CAAC,CAAC;SACH;QACD,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE;YACzB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBAC5B,MAAM,QAAQ,GAAG,CAAC,MAAa,EAAE,EAAE;oBAClC,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,EAAE,CAAC;oBACvC,KAAK,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;oBACpC,KAAK,CAAC,MAAM,EAAE,CAAC;oBACf,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;oBAC5B,KAAK,CAAC,QAAQ,EAAE,CAAC;gBAClB,CAAC,CAAC;gBACK,SAAU,CAAC,KAAK,CAAC,IAAI,CAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;SACH;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE;YAC/B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACjC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBACpD,aAAa,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBAC3B,YAAY,CAAC,MAAM,EAAE,CAAC;gBACtB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;gBAClC,YAAY,CAAC,QAAQ,EAAE,CAAC;YACzB,CAAC,CAAC,CAAC;SACH;QAGD,OAAO,aAAa,CAAC;IACtB,CAAC;CAED","sourcesContent":["import {\n\tReactiveScope, ScopeContext, ScopeSubscription, Stack\n} from '@ibyar/expressions';\nimport {\n\tCommentNode, DomStructuralDirectiveNode, DomStructuralDirectiveNodeUpgrade,\n\tDomElementNode, DomFragmentNode, DomNode, isLiveTextContent,\n\tisTagNameNative, isValidCustomElementName, LiveTextContent,\n\tTextContent, DomAttributeDirectiveNode\n} from '@ibyar/elements';\nimport { ComponentRef } from '../component/component.js';\nimport { HTMLComponent, isHTMLComponent } from '../component/custom-element.js';\nimport { documentStack } from '../context/stack.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { isOnDestroy, isOnInit } from '../component/lifecycle.js';\nimport { hasAttr } from '../utils/elements-util.js';\nimport { AttributeDirective, AttributeOnStructuralDirective, StructuralDirective } from '../directive/directive.js';\nimport { TemplateRef, TemplateRefImpl } from '../linker/template-ref.js';\nimport { ViewContainerRefImpl } from '../linker/view-container-ref.js';\nimport { createSubscriptionDestroyer } from '../context/subscription.js';\nimport { HostListenerHandler } from '../render/host-listener.handler.js';\n\ntype ViewScopeContext = { [element: string]: HTMLElement };\n\nfunction getInputEventName(element: HTMLElement): 'input' | 'change' | undefined {\n\tswitch (true) {\n\t\tcase element instanceof HTMLInputElement:\n\t\t\treturn 'input';\n\t\tcase element instanceof HTMLTextAreaElement:\n\t\tcase element instanceof HTMLSelectElement:\n\t\t\treturn 'change';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\nexport class ComponentRender<T extends object> {\n\tprivate componentRef: ComponentRef<T>;\n\tprivate template: DomNode;\n\tprivate contextStack: Stack;\n\tprivate templateNameScope: ReactiveScope<{ [templateName: string]: TemplateRef }>;\n\tprivate viewScope: ReactiveScope<ViewScopeContext> = new ReactiveScope({});\n\n\tconstructor(public view: HTMLComponent<T>, private subscriptions: ScopeSubscription<ScopeContext>[]) {\n\t\tthis.componentRef = this.view.getComponentRef();\n\t\tthis.contextStack = documentStack.copyStack();\n\t\tthis.contextStack.pushScope<ScopeContext>(this.view._modelScope);\n\t\tthis.templateNameScope = this.contextStack.pushReactiveScope();\n\t}\n\tinitView(): void {\n\t\tif (this.componentRef.template) {\n\t\t\tif (typeof this.componentRef.template === 'function') {\n\t\t\t\tthis.template = this.componentRef.template(this.view._model);\n\t\t\t} else {\n\t\t\t\tthis.template = this.componentRef.template;\n\t\t\t}\n\n\t\t\tlet rootRef: HTMLElement | ShadowRoot;\n\t\t\tif (this.componentRef.isShadowDom) {\n\t\t\t\tif (this.view.shadowRoot /* OPEN MODE */) {\n\t\t\t\t\trootRef = this.view.shadowRoot;\n\t\t\t\t} else /* CLOSED MODE*/ {\n\t\t\t\t\trootRef = Reflect.get(this.view, '_shadowRoot') as ShadowRoot;\n\t\t\t\t\tReflect.deleteProperty(this.view, '_shadowRoot');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trootRef = this.view;\n\t\t\t}\n\t\t\tthis.initTemplateRefMap(this.template);\n\t\t\tlet rootFragment: DocumentFragment;\n\t\t\tif (this.template instanceof DomFragmentNode) {\n\t\t\t\trootFragment = this.createDocumentFragment(this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t\t} else {\n\t\t\t\trootFragment = document.createDocumentFragment();\n\t\t\t\tthis.appendChildToParent(rootFragment, this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t\t}\n\t\t\trootRef.append(rootFragment);\n\t\t}\n\t}\n\tisTemplateRefName(template: DomNode): template is DomElementNode {\n\t\tif (template instanceof DomElementNode) {\n\t\t\tif (template.tagName === 'template' && template.templateRefName) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tinitTemplateRefMap(domNode: DomNode) {\n\t\tif (domNode instanceof DomElementNode || domNode instanceof DomFragmentNode) {\n\t\t\tif (domNode.children) {\n\t\t\t\tfor (let index = 0; index < domNode.children.length; index++) {\n\t\t\t\t\tconst child = domNode.children[index];\n\t\t\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\t\t\tthis.templateNameScope.set(child.templateRefName!.name, undefined);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.initTemplateRefMap(child);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tinitHostListener(): void {\n\t\tconst handlers = this.componentRef.hostListeners.map(listenerRef => new HostListenerHandler(listenerRef, this.view, this.viewScope));\n\t\thandlers.forEach(handler => handler.onInit());\n\t\thandlers.forEach(handler => this.subscriptions.push(createSubscriptionDestroyer(\n\t\t\t() => handler.onDestroy(),\n\t\t\t() => handler.onDisconnect(),\n\t\t\t() => handler.onConnect(),\n\t\t)));\n\t}\n\taddNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function) {\n\t\tsource.addEventListener(eventName, (event: Event) => {\n\t\t\tfuncCallback.call(this.view._proxyModel, event);\n\t\t});\n\t}\n\tgetElementByName(name: string) {\n\t\treturn Reflect.get(this.view, name);\n\t}\n\tcreateStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<ScopeContext>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void {\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<T>(directive.name);\n\t\tif (directiveRef) {\n\t\t\tconst stack = directiveStack.copyStack();\n\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\tthis,\n\t\t\t\tdirective.node,\n\t\t\t\tstack,\n\t\t\t\t(directive as DomStructuralDirectiveNodeUpgrade).templateExpressions ?? [],\n\t\t\t);\n\t\t\tconst viewContainerRef = new ViewContainerRefImpl(parentNode as Element, comment);\n\n\t\t\t// structural directive selector\n\t\t\tconst StructuralDirectiveClass = directiveRef.modelClass as typeof StructuralDirective;\n\t\t\tconst structural = new StructuralDirectiveClass(\n\t\t\t\ttemplateRef,\n\t\t\t\tviewContainerRef,\n\t\t\t\thost\n\t\t\t);\n\t\t\ttemplateRef.host = structural;\n\t\t\tstack.pushReactiveScopeFor({ 'this': structural });\n\t\t\tconst dSubs = this.initStructuralDirective(structural, directive, stack);\n\t\t\tsubscriptions.push(...dSubs);\n\t\t\tif (isOnInit(structural)) {\n\t\t\t\tstructural.onInit();\n\t\t\t}\n\t\t\tif (directive.attributeDirectives?.length) {\n\t\t\t\tthis.initAttributeDirectives(directive.attributeDirectives, structural, stack, subscriptions);\n\t\t\t}\n\t\t\tif (isOnDestroy(structural)) {\n\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => structural.onDestroy()));\n\t\t\t}\n\t\t} else {\n\t\t\t// didn't find directive or it is not define yet.\n\t\t\t// class registry should have 'when defined' callback\n\t\t}\n\t}\n\tcreateComment(node: CommentNode): Comment {\n\t\treturn document.createComment(`${node.comment}`);\n\t}\n\tcreateText(node: TextContent): Text {\n\t\treturn new Text(node.value);\n\t}\n\tcreateLiveText(textNode: LiveTextContent, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[]): Text {\n\t\tconst liveText = new Text('');\n\t\tcontextStack = contextStack.copyStack();\n\t\tcontextStack.pushBlockScopeFor({ this: liveText });\n\t\tconst textSubscriptions = textNode.expression.subscribe(contextStack, textNode.pipelineNames);\n\t\tsubscriptions.push(...textSubscriptions);\n\t\tcontextStack.detach();\n\t\ttextNode.expression.get(contextStack);\n\t\tcontextStack.reattach();\n\t\treturn liveText;\n\t}\n\tcreateDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[], host: HTMLComponent<any> | StructuralDirective): DocumentFragment {\n\t\tconst fragment = document.createDocumentFragment();\n\t\tnode.children?.forEach(child => this.appendChildToParent(fragment, child, contextStack, parentNode, subscriptions, host));\n\t\treturn fragment;\n\t}\n\tappendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<ScopeContext>[], host: HTMLComponent<any> | StructuralDirective) {\n\t\tif (child instanceof DomElementNode) {\n\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\tconst templateRefName = child.templateRefName!;\n\t\t\t\t// const oldRef = this.templateNameScope.get(templateRefName.name);\n\t\t\t\t// if (oldRef) {\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\t// TODO: extract template expression\n\t\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\t\tthis,\n\t\t\t\t\tnew DomFragmentNode(child.children),\n\t\t\t\t\tcontextStack.copyStack(),\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tthis.templateNameScope.set(templateRefName.name, templateRef);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfragmentParent.append(this.createElement(child, contextStack, subscriptions, parentNode, host));\n\t\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\t\tconst commentText = child.name + (typeof child.value == 'string' ? (' = ' + child.value) : '');\n\t\t\tconst comment = document.createComment(`start ${commentText}`);\n\t\t\tfragmentParent.append(comment);\n\t\t\tconst lastComment = document.createComment(`end ${commentText}`);\n\t\t\tcomment.after(lastComment);\n\t\t\tthis.createStructuralDirective(child, comment, contextStack, subscriptions, parentNode, host);\n\t\t} else if (isLiveTextContent(child)) {\n\t\t\tfragmentParent.append(this.createLiveText(child, contextStack, parentNode, subscriptions));\n\t\t} else if (child instanceof TextContent) {\n\t\t\tfragmentParent.append(this.createText(child));\n\t\t} else if (child instanceof CommentNode) {\n\t\t\tfragmentParent.append(this.createComment(child));\n\t\t} else if (child instanceof DomFragmentNode) {\n\t\t\tfragmentParent.append(this.createDocumentFragment(child, contextStack, parentNode, subscriptions, host));\n\t\t}\n\t}\n\tcreateElementByTagName(node: { tagName: string, is?: string }): HTMLElement {\n\t\tlet element: HTMLElement;\n\t\tif (isValidCustomElementName(node.tagName)) {\n\t\t\tconst ViewClass = customElements.get(node.tagName) as ((new () => HTMLElement) | undefined);\n\t\t\tif (ViewClass) {\n\t\t\t\telement = new ViewClass();\n\t\t\t} else {\n\t\t\t\telement = document.createElement(node.tagName);\n\t\t\t\tif (element.constructor.name === 'HTMLElement') {\n\t\t\t\t\tcustomElements.whenDefined(node.tagName).then(() => customElements.upgrade(element));\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isTagNameNative(node.tagName)) {\n\t\t\t// native tags // and custom tags can be used her\n\t\t\telement = document.createElement(node.tagName, node.is ? { is: node.is } : undefined);\n\t\t} else {\n\t\t\t// html unknown element\n\t\t\telement = document.createElement(node.tagName);\n\t\t}\n\t\tif (isHTMLComponent(element)) {\n\t\t\telement.setParentComponent(this.view);\n\t\t}\n\t\treturn element;\n\t}\n\tcreateElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<ScopeContext>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): HTMLElement {\n\t\tconst element = this.createElementByTagName(node);\n\t\tconst elementStack = contextStack.copyStack();\n\t\tconst elementScope = isHTMLComponent(element) ? element._viewScope : elementStack.pushReactiveScopeFor({ 'this': element });\n\t\telementStack.pushScope<ScopeContext>(elementScope);\n\t\tconst attributesSubscriptions = this.initAttribute(element, node, elementStack);\n\t\tsubscriptions.push(...attributesSubscriptions);\n\t\tconst eventName = getInputEventName(element);\n\t\tlet listener: ((event: HTMLElementEventMap['input' | 'change']) => any) | undefined;\n\t\tif (eventName) {\n\t\t\tconst inputScope = elementScope.getScopeOrCreat('this');\n\t\t\tlistener = (event) => inputScope.emit('value', (element as HTMLInputElement).value);\n\t\t\telement.addEventListener(eventName, listener);\n\t\t}\n\n\t\tconst templateRefName = node.templateRefName;\n\t\tif (templateRefName) {\n\t\t\tReflect.set(this.view, templateRefName.name, element);\n\t\t\tthis.viewScope.set(templateRefName.name, element);\n\t\t\tconst view = this.componentRef.viewChild.find(child => child.selector === templateRefName.name);\n\t\t\tif (view) {\n\t\t\t\tReflect.set(this.view._model, view.modelName, element);\n\t\t\t}\n\t\t}\n\t\tif (node.children) {\n\t\t\tfor (const child of node.children) {\n\t\t\t\tthis.appendChildToParent(element, child, elementStack, element, subscriptions, host);\n\t\t\t}\n\t\t}\n\t\tif (node.attributeDirectives?.length) {\n\t\t\tthis.initAttributeDirectives(node.attributeDirectives, element, contextStack, subscriptions);\n\t\t}\n\t\treturn element;\n\t}\n\tprivate initAttributeDirectives(\n\t\tattributeDirectives: DomAttributeDirectiveNode[],\n\t\telement: HTMLElement | StructuralDirective,\n\t\tcontextStack: Stack, subscriptions: ScopeSubscription<ScopeContext>[]) {\n\t\tattributeDirectives?.forEach(directiveNode => {\n\t\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(directiveNode.name);\n\t\t\tif (directiveRef &&\n\t\t\t\t(directiveRef.modelClass.prototype instanceof AttributeDirective\n\t\t\t\t\t|| directiveRef.modelClass.prototype instanceof AttributeOnStructuralDirective\n\t\t\t\t)) {\n\t\t\t\tconst directive = new directiveRef.modelClass(element) as AttributeDirective | AttributeOnStructuralDirective;\n\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\tstack.pushReactiveScopeFor({ 'this': directive });\n\t\t\t\tconst directiveSubscriptions = this.initStructuralDirective(directive, directiveNode, stack);\n\t\t\t\tsubscriptions.push(...directiveSubscriptions);\n\t\t\t\tif (isOnInit(directive)) {\n\t\t\t\t\tdirective.onInit();\n\t\t\t\t}\n\t\t\t\tif (isOnDestroy(directive)) {\n\t\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => directive.onDestroy()));\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tinitAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<ScopeContext>[] {\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => {\n\t\t\t\t/**\n\t\t\t\t * <input id=\"23\" name=\"person-name\" />\n\t\t\t\t */\n\t\t\t\tconst isAttr = hasAttr(element, attr.name);\n\t\t\t\tif (isAttr) {\n\t\t\t\t\tif (attr.value === false) {\n\t\t\t\t\t\telement.removeAttribute(attr.name);\n\t\t\t\t\t} else if (attr.value === true) {\n\t\t\t\t\t\telement.setAttribute(attr.name, '');\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.setAttribute(attr.name, attr.value as string);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tReflect.set(element, attr.name, attr.value);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tcontextStack.detach();\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t\tcontextStack.reattach();\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tcontextStack.detach();\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t\tcontextStack.reattach();\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tlet listener: Function;\n\t\t\t\t/**\n\t\t\t\t * <a (click)=\"onLinkClick($event)\"></a>\n\t\t\t\t * <a @click=\"onLinkClick($event)\"></a>\n\t\t\t\t * <input [(value)]=\"person.name\" />\n\t\t\t\t * <input (value)=\"person.name\" />\n\t\t\t\t * <!-- <input (value)=\"person.name = $event\" /> -->\n\t\t\t\t * \n\t\t\t\t * TODO: diff of event listener and back-way data binding\n\t\t\t\t */\n\t\t\t\tif (typeof event.value === 'string') {\n\t\t\t\t\tlistener = ($event: Event) => {\n\t\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\t\tstack.detach();\n\t\t\t\t\t\tevent.expression.get(stack);\n\t\t\t\t\t\tstack.reattach();\n\t\t\t\t\t};\n\t\t\t\t} else /* if (typeof event.sourceHandler === 'function')*/ {\n\t\t\t\t\t// let eventName: keyof HTMLElementEventMap = event.eventName;\n\t\t\t\t\tlistener = event.value;\n\t\t\t\t}\n\t\t\t\telement.addEventListener(event.name as any, listener as any);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tcontextStack.detach();\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t\tcontextStack.reattach();\n\t\t\t});\n\t\t}\n\t\treturn subscriptions;\n\t}\n\n\tinitStructuralDirective(\n\t\tdirective: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective,\n\t\tnode: DomStructuralDirectiveNode | DomAttributeDirectiveNode,\n\t\tcontextStack: Stack): ScopeSubscription<ScopeContext>[] {\n\t\tconst subscriptions: ScopeSubscription<ScopeContext>[] = [];\n\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => Reflect.set(directive, attr.name, attr.value));\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tcontextStack.detach();\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t\tcontextStack.reattach();\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tcontextStack.detach();\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t\tcontextStack.reattach();\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tconst listener = ($event: Event) => {\n\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\tstack.detach();\n\t\t\t\t\tevent.expression.get(stack);\n\t\t\t\t\tstack.reattach();\n\t\t\t\t};\n\t\t\t\t((<any>directive)[event.name] as any).subscribe(listener);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tcontextStack.detach();\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t\tcontextStack.reattach();\n\t\t\t});\n\t\t}\n\t\t// TODO: \n\t\t// check host binding\n\t\treturn subscriptions;\n\t}\n\n}\n"]}
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/view/render.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,WAAW,EAAE,0BAA0B,EACvC,cAAc,EAAE,eAAe,EAAW,iBAAiB,EAC3D,eAAe,EAAE,wBAAwB,EACzC,WAAW,EACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAiB,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,8BAA8B,EAAuB,MAAM,2BAA2B,CAAC;AACpH,OAAO,EAAe,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAIzE,SAAS,iBAAiB,CAAC,OAAoB;IAC9C,QAAQ,IAAI,EAAE;QACb,KAAK,OAAO,YAAY,gBAAgB;YACvC,OAAO,OAAO,CAAC;QAChB,KAAK,OAAO,YAAY,mBAAmB,CAAC;QA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C;gBACtE,CAAC,CAAC;gBACK,SAAU,CAAC,KAAK,CAAC,IAAI,CAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAC;SACH;QACD,IAAI,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE;YAC/B,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACjC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBACpD,aAAa,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBAC3B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;SACH;QACD,SAAS;QACT,qBAAqB;QACrB,OAAO,aAAa,CAAC;IACtB,CAAC;CAED","sourcesContent":["import {\n\tReactiveScope, Context, ScopeSubscription, Stack\n} from '@ibyar/expressions';\nimport {\n\tCommentNode, DomStructuralDirectiveNode, DomStructuralDirectiveNodeUpgrade,\n\tDomElementNode, DomFragmentNode, DomNode, isLiveTextContent,\n\tisTagNameNative, isValidCustomElementName, LiveTextContent,\n\tTextContent, DomAttributeDirectiveNode\n} from '@ibyar/elements';\nimport { ComponentRef } from '../component/component.js';\nimport { HTMLComponent, isHTMLComponent } from '../component/custom-element.js';\nimport { documentStack } from '../context/stack.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { isOnDestroy, isOnInit } from '../component/lifecycle.js';\nimport { hasAttr } from '../utils/elements-util.js';\nimport { AttributeDirective, AttributeOnStructuralDirective, StructuralDirective } from '../directive/directive.js';\nimport { TemplateRef, TemplateRefImpl } from '../linker/template-ref.js';\nimport { ViewContainerRefImpl } from '../linker/view-container-ref.js';\nimport { createSubscriptionDestroyer } from '../context/subscription.js';\nimport { HostListenerHandler } from '../render/host-listener.handler.js';\n\ntype ViewContext = { [element: string]: HTMLElement };\n\nfunction getInputEventName(element: HTMLElement): 'input' | 'change' | undefined {\n\tswitch (true) {\n\t\tcase element instanceof HTMLInputElement:\n\t\t\treturn 'input';\n\t\tcase element instanceof HTMLTextAreaElement:\n\t\tcase element instanceof HTMLSelectElement:\n\t\t\treturn 'change';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\nexport class ComponentRender<T extends object> {\n\tprivate componentRef: ComponentRef<T>;\n\tprivate template: DomNode;\n\tprivate contextStack: Stack;\n\tprivate templateNameScope: ReactiveScope<{ [templateName: string]: TemplateRef }>;\n\tprivate viewScope: ReactiveScope<ViewContext> = new ReactiveScope({});\n\n\tconstructor(public view: HTMLComponent<T>, private subscriptions: ScopeSubscription<Context>[]) {\n\t\tthis.componentRef = this.view.getComponentRef();\n\t\tthis.contextStack = documentStack.copyStack();\n\t\tthis.contextStack.pushScope<Context>(this.view._modelScope);\n\t\tthis.templateNameScope = this.contextStack.pushReactiveScope();\n\t}\n\tinitView(): void {\n\t\tif (this.componentRef.template) {\n\t\t\tif (typeof this.componentRef.template === 'function') {\n\t\t\t\tthis.template = this.componentRef.template(this.view._model);\n\t\t\t} else {\n\t\t\t\tthis.template = this.componentRef.template;\n\t\t\t}\n\n\t\t\tlet rootRef: HTMLElement | ShadowRoot;\n\t\t\tif (this.componentRef.isShadowDom) {\n\t\t\t\tif (this.view.shadowRoot /* OPEN MODE */) {\n\t\t\t\t\trootRef = this.view.shadowRoot;\n\t\t\t\t} else /* CLOSED MODE*/ {\n\t\t\t\t\trootRef = Reflect.get(this.view, '_shadowRoot') as ShadowRoot;\n\t\t\t\t\tReflect.deleteProperty(this.view, '_shadowRoot');\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trootRef = this.view;\n\t\t\t}\n\t\t\tthis.initTemplateRefMap(this.template);\n\t\t\tlet rootFragment: DocumentFragment;\n\t\t\tif (this.template instanceof DomFragmentNode) {\n\t\t\t\trootFragment = this.createDocumentFragment(this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t\t} else {\n\t\t\t\trootFragment = document.createDocumentFragment();\n\t\t\t\tthis.appendChildToParent(rootFragment, this.template, this.contextStack, rootRef, this.subscriptions, this.view);\n\t\t\t}\n\t\t\trootRef.append(rootFragment);\n\t\t}\n\t}\n\tisTemplateRefName(template: DomNode): template is DomElementNode {\n\t\tif (template instanceof DomElementNode) {\n\t\t\tif (template.tagName === 'template' && template.templateRefName) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tinitTemplateRefMap(domNode: DomNode) {\n\t\tif (domNode instanceof DomElementNode || domNode instanceof DomFragmentNode) {\n\t\t\tif (domNode.children) {\n\t\t\t\tfor (let index = 0; index < domNode.children.length; index++) {\n\t\t\t\t\tconst child = domNode.children[index];\n\t\t\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\t\t\tthis.templateNameScope.set(child.templateRefName!.name, undefined);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.initTemplateRefMap(child);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tinitHostListener(): void {\n\t\tconst handlers = this.componentRef.hostListeners.map(listenerRef => new HostListenerHandler(listenerRef, this.view, this.viewScope));\n\t\thandlers.forEach(handler => handler.onInit());\n\t\thandlers.forEach(handler => this.subscriptions.push(createSubscriptionDestroyer(\n\t\t\t() => handler.onDestroy(),\n\t\t\t() => handler.onDisconnect(),\n\t\t\t() => handler.onConnect(),\n\t\t)));\n\t}\n\taddNativeEventListener(source: HTMLElement | Window, eventName: string, funcCallback: Function) {\n\t\tsource.addEventListener(eventName, (event: Event) => {\n\t\t\tthis.view._zone.run(funcCallback as () => void, this.view._model);\n\t\t});\n\t}\n\tgetElementByName(name: string) {\n\t\treturn Reflect.get(this.view, name);\n\t}\n\tcreateStructuralDirective(directive: DomStructuralDirectiveNode, comment: Comment, directiveStack: Stack, subscriptions: ScopeSubscription<Context>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): void {\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<T>(directive.name);\n\t\tif (directiveRef) {\n\t\t\tconst stack = directiveStack.copyStack();\n\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\tthis,\n\t\t\t\tdirective.node,\n\t\t\t\tstack,\n\t\t\t\t(directive as DomStructuralDirectiveNodeUpgrade).templateExpressions ?? [],\n\t\t\t);\n\t\t\tconst viewContainerRef = new ViewContainerRefImpl(parentNode as Element, comment);\n\n\t\t\t// structural directive selector\n\t\t\tconst StructuralDirectiveClass = directiveRef.modelClass as typeof StructuralDirective;\n\t\t\tconst structural = new StructuralDirectiveClass(\n\t\t\t\ttemplateRef,\n\t\t\t\tviewContainerRef,\n\t\t\t\thost\n\t\t\t);\n\t\t\ttemplateRef.host = structural;\n\t\t\tconst scope = ReactiveScope.readOnlyScopeForThis(structural);\n\t\t\tstack.pushScope(scope);\n\n\t\t\tconst dSubs = this.initStructuralDirective(structural, directive, stack);\n\t\t\tsubscriptions.push(...dSubs);\n\t\t\tif (isOnInit(structural)) {\n\t\t\t\tstructural.onInit();\n\t\t\t}\n\t\t\tif (directive.attributeDirectives?.length) {\n\t\t\t\tthis.initAttributeDirectives(directive.attributeDirectives, structural, stack, subscriptions);\n\t\t\t}\n\t\t\tif (isOnDestroy(structural)) {\n\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => structural.onDestroy()));\n\t\t\t}\n\t\t} else {\n\t\t\t// didn't find directive or it is not define yet.\n\t\t\t// class registry should have 'when defined' callback\n\t\t}\n\t}\n\tcreateComment(node: CommentNode): Comment {\n\t\treturn document.createComment(`${node.comment}`);\n\t}\n\tcreateText(node: TextContent): Text {\n\t\treturn new Text(node.value);\n\t}\n\tcreateLiveText(textNode: LiveTextContent, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[]): Text {\n\t\tconst liveText = new Text('');\n\t\tcontextStack = contextStack.copyStack();\n\t\tcontextStack.pushBlockScopeFor({ this: liveText });\n\t\tconst textSubscriptions = textNode.expression.subscribe(contextStack, textNode.pipelineNames);\n\t\tsubscriptions.push(...textSubscriptions);\n\t\ttextNode.expression.get(contextStack);\n\t\treturn liveText;\n\t}\n\tcreateDocumentFragment(node: DomFragmentNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective): DocumentFragment {\n\t\tconst fragment = document.createDocumentFragment();\n\t\tnode.children?.forEach(child => this.appendChildToParent(fragment, child, contextStack, parentNode, subscriptions, host));\n\t\treturn fragment;\n\t}\n\tappendChildToParent(fragmentParent: HTMLElement | DocumentFragment, child: DomNode, contextStack: Stack, parentNode: Node, subscriptions: ScopeSubscription<Context>[], host: HTMLComponent<any> | StructuralDirective) {\n\t\tif (child instanceof DomElementNode) {\n\t\t\tif (this.isTemplateRefName(child)) {\n\t\t\t\tconst templateRefName = child.templateRefName!;\n\t\t\t\t// const oldRef = this.templateNameScope.get(templateRefName.name);\n\t\t\t\t// if (oldRef) {\n\t\t\t\t// \treturn;\n\t\t\t\t// }\n\t\t\t\t// TODO: extract template expression\n\t\t\t\tconst templateRef = new TemplateRefImpl(\n\t\t\t\t\tthis,\n\t\t\t\t\tnew DomFragmentNode(child.children),\n\t\t\t\t\tcontextStack.copyStack(),\n\t\t\t\t\t[]\n\t\t\t\t);\n\t\t\t\tthis.templateNameScope.set(templateRefName.name, templateRef);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfragmentParent.append(this.createElement(child, contextStack, subscriptions, parentNode, host));\n\t\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\t\tconst commentText = child.name + (typeof child.value == 'string' ? (' = ' + child.value) : '');\n\t\t\tconst comment = document.createComment(`start ${commentText}`);\n\t\t\tfragmentParent.append(comment);\n\t\t\tconst lastComment = document.createComment(`end ${commentText}`);\n\t\t\tcomment.after(lastComment);\n\t\t\tthis.createStructuralDirective(child, comment, contextStack, subscriptions, parentNode, host);\n\t\t} else if (isLiveTextContent(child)) {\n\t\t\tfragmentParent.append(this.createLiveText(child, contextStack, parentNode, subscriptions));\n\t\t} else if (child instanceof TextContent) {\n\t\t\tfragmentParent.append(this.createText(child));\n\t\t} else if (child instanceof CommentNode) {\n\t\t\tfragmentParent.append(this.createComment(child));\n\t\t} else if (child instanceof DomFragmentNode) {\n\t\t\tfragmentParent.append(this.createDocumentFragment(child, contextStack, parentNode, subscriptions, host));\n\t\t}\n\t}\n\tcreateElementByTagName(node: { tagName: string, is?: string }): HTMLElement {\n\t\tlet element: HTMLElement;\n\t\tif (isValidCustomElementName(node.tagName)) {\n\t\t\tconst ViewClass = customElements.get(node.tagName) as ((new () => HTMLElement) | undefined);\n\t\t\tif (ViewClass) {\n\t\t\t\telement = new ViewClass();\n\t\t\t} else {\n\t\t\t\telement = document.createElement(node.tagName);\n\t\t\t\tif (element.constructor.name === 'HTMLElement') {\n\t\t\t\t\tcustomElements.whenDefined(node.tagName).then(() => customElements.upgrade(element));\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (isTagNameNative(node.tagName)) {\n\t\t\t// native tags // and custom tags can be used her\n\t\t\telement = document.createElement(node.tagName, node.is ? { is: node.is } : undefined);\n\t\t} else {\n\t\t\t// html unknown element\n\t\t\telement = document.createElement(node.tagName);\n\t\t}\n\t\tif (isHTMLComponent(element)) {\n\t\t\telement.setParentComponent(this.view);\n\t\t}\n\t\treturn element;\n\t}\n\tcreateElement(node: DomElementNode, contextStack: Stack, subscriptions: ScopeSubscription<Context>[], parentNode: Node, host: HTMLComponent<any> | StructuralDirective): HTMLElement {\n\t\tconst element = this.createElementByTagName(node);\n\t\tconst elementStack = contextStack.copyStack();\n\t\tconst elementScope = isHTMLComponent(element)\n\t\t\t? element._viewScope\n\t\t\t: ReactiveScope.readOnlyScopeForThis(element);\n\t\telementStack.pushScope<Context>(elementScope);\n\t\tconst attributesSubscriptions = this.initAttribute(element, node, elementStack);\n\t\tsubscriptions.push(...attributesSubscriptions);\n\t\tconst eventName = getInputEventName(element);\n\t\tif (eventName) {\n\t\t\tconst inputScope = elementScope.getInnerScope<ReactiveScope<HTMLInputElement>>('this')!;\n\t\t\tconst listener = (event: HTMLElementEventMap['input' | 'change']) => inputScope.emit('value', (element as HTMLInputElement).value);\n\t\t\telement.addEventListener(eventName, listener);\n\t\t}\n\n\t\tconst templateRefName = node.templateRefName;\n\t\tif (templateRefName) {\n\t\t\tReflect.set(this.view, templateRefName.name, element);\n\t\t\tthis.viewScope.set(templateRefName.name, element);\n\t\t\tconst view = this.componentRef.viewChild.find(child => child.selector === templateRefName.name);\n\t\t\tif (view) {\n\t\t\t\tReflect.set(this.view._model, view.modelName, element);\n\t\t\t}\n\t\t}\n\t\tif (node.children) {\n\t\t\tfor (const child of node.children) {\n\t\t\t\tthis.appendChildToParent(element, child, elementStack, element, subscriptions, host);\n\t\t\t}\n\t\t}\n\t\tif (node.attributeDirectives?.length) {\n\t\t\tthis.initAttributeDirectives(node.attributeDirectives, element, contextStack, subscriptions);\n\t\t}\n\t\treturn element;\n\t}\n\tprivate initAttributeDirectives(\n\t\tattributeDirectives: DomAttributeDirectiveNode[],\n\t\telement: HTMLElement | StructuralDirective,\n\t\tcontextStack: Stack, subscriptions: ScopeSubscription<Context>[]) {\n\t\tattributeDirectives?.forEach(directiveNode => {\n\t\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(directiveNode.name);\n\t\t\tif (directiveRef &&\n\t\t\t\t(directiveRef.modelClass.prototype instanceof AttributeDirective\n\t\t\t\t\t|| directiveRef.modelClass.prototype instanceof AttributeOnStructuralDirective\n\t\t\t\t)) {\n\t\t\t\tconst directive = new directiveRef.modelClass(element) as AttributeDirective | AttributeOnStructuralDirective;\n\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\tstack.pushReactiveScopeFor({ 'this': directive });\n\n\t\t\t\tconst directiveSubscriptions = this.initStructuralDirective(directive, directiveNode, stack);\n\t\t\t\tsubscriptions.push(...directiveSubscriptions);\n\t\t\t\tif (isOnInit(directive)) {\n\t\t\t\t\tdirective.onInit();\n\t\t\t\t}\n\t\t\t\tif (isOnDestroy(directive)) {\n\t\t\t\t\tsubscriptions.push(createSubscriptionDestroyer(() => directive.onDestroy()));\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tinitAttribute(element: HTMLElement, node: DomElementNode, contextStack: Stack): ScopeSubscription<Context>[] {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => {\n\t\t\t\t/**\n\t\t\t\t * <input id=\"23\" name=\"person-name\" />\n\t\t\t\t */\n\t\t\t\tconst isAttr = hasAttr(element, attr.name);\n\t\t\t\tif (isAttr) {\n\t\t\t\t\tif (attr.value === false) {\n\t\t\t\t\t\telement.removeAttribute(attr.name);\n\t\t\t\t\t} else if (attr.value === true) {\n\t\t\t\t\t\telement.setAttribute(attr.name, '');\n\t\t\t\t\t} else {\n\t\t\t\t\t\telement.setAttribute(attr.name, attr.value as string);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tReflect.set(element, attr.name, attr.value);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tlet listener: Function;\n\t\t\t\t/**\n\t\t\t\t * <a (click)=\"onLinkClick($event)\"></a>\n\t\t\t\t * <a @click=\"onLinkClick($event)\"></a>\n\t\t\t\t * <input [(value)]=\"person.name\" />\n\t\t\t\t * <input (value)=\"person.name\" />\n\t\t\t\t * <!-- <input (value)=\"person.name = $event\" /> -->\n\t\t\t\t * \n\t\t\t\t * TODO: diff of event listener and back-way data binding\n\t\t\t\t */\n\t\t\t\tif (typeof event.value === 'string') {\n\t\t\t\t\tlistener = ($event: Event) => {\n\t\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\t\tthis.view._zone.run(event.expression.get, event.expression, [stack]);\n\t\t\t\t\t};\n\t\t\t\t} else /* if (typeof event.sourceHandler === 'function')*/ {\n\t\t\t\t\t// let eventName: keyof HTMLElementEventMap = event.eventName;\n\t\t\t\t\tlistener = event.value;\n\t\t\t\t}\n\t\t\t\telement.addEventListener(event.name as any, listener as any);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\treturn subscriptions;\n\t}\n\tinitStructuralDirective(\n\t\tdirective: StructuralDirective | AttributeDirective | AttributeOnStructuralDirective,\n\t\tnode: DomStructuralDirectiveNode | DomAttributeDirectiveNode,\n\t\tcontextStack: Stack): ScopeSubscription<Context>[] {\n\t\tconst subscriptions: ScopeSubscription<Context>[] = [];\n\n\t\tif (node.attributes?.length) {\n\t\t\tnode.attributes.forEach(attr => Reflect.set(directive, attr.name, attr.value));\n\t\t}\n\t\tif (node.twoWayBinding?.length) {\n\t\t\tnode.twoWayBinding.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.inputs?.length) {\n\t\t\tnode.inputs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack, attr.pipelineNames);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\tif (node.outputs?.length) {\n\t\t\tnode.outputs.forEach(event => {\n\t\t\t\tconst listener = ($event: Event) => {\n\t\t\t\t\tconst stack = contextStack.copyStack();\n\t\t\t\t\tstack.pushBlockScopeFor({ $event });\n\t\t\t\t\tthis.view._zone.run(event.expression.get, event.expression, [stack]);\n\t\t\t\t};\n\t\t\t\t((<any>directive)[event.name] as any).subscribe(listener);\n\t\t\t});\n\t\t}\n\t\tif (node.templateAttrs?.length) {\n\t\t\tnode.templateAttrs.forEach(attr => {\n\t\t\t\tconst sub = attr.expression.subscribe(contextStack);\n\t\t\t\tsubscriptions.push(...sub);\n\t\t\t\tattr.expression.get(contextStack);\n\t\t\t});\n\t\t}\n\t\t// TODO: \n\t\t// check host binding\n\t\treturn subscriptions;\n\t}\n\n}\n"]}
package/view/view.d.ts CHANGED
@@ -2,6 +2,11 @@ import type { TypeOf } from '../utils/typeof.js';
2
2
  import { ComponentRef } from '../component/component.js';
3
3
  import { HTMLComponent } from '../component/custom-element.js';
4
4
  import { Constructable } from '../providers/injector.js';
5
+ /**
6
+ *
7
+ * @param modelClass
8
+ * @param componentRef
9
+ */
5
10
  export declare function initCustomElementView<T extends Object>(modelClass: TypeOf<T>, componentRef: ComponentRef<T>): TypeOf<HTMLComponent<T>>;
6
11
  export declare type ComponentModelClass = Constructable & {
7
12
  [key: string]: string;
package/view/view.js CHANGED
@@ -2,6 +2,11 @@ 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';
5
+ /**
6
+ *
7
+ * @param modelClass
8
+ * @param componentRef
9
+ */
5
10
  export function initCustomElementView(modelClass, componentRef) {
6
11
  const htmlParent = componentRef.extend.classRef;
7
12
  let viewClass;
@@ -64,11 +69,13 @@ export function initCustomElementView(modelClass, componentRef) {
64
69
  .concat(componentRef.outputs.map(output => output.modelProperty))
65
70
  .concat(componentRef.hostBindings.map(host => host.hostPropertyName))
66
71
  .concat(componentRef.viewChild.map(child => child.modelName))
72
+ .filter(modelName => !(modelName in modelClass.prototype))
67
73
  .forEach(modelName => modelClass.prototype[modelName] = undefined);
68
74
  const defaultAttributes = getAllAttributes(componentRef.extend.name);
69
75
  const observedAttributes = componentRef.inputs.map(input => input.viewAttribute);
70
76
  Reflect.set(viewClass, 'observedAttributes', observedAttributes);
71
77
  Reflect.set(viewClass, 'allAttributes', defaultAttributes.concat(observedAttributes));
78
+ // https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example
72
79
  if (false) {
73
80
  Object.defineProperty(viewClass, 'formAssociated', {
74
81
  get() {
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,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;Y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C,QAAQ,CAAC,GAAG,iBAAiB,CAAC;KACnD;AACF,CAAC;AAED,MAAM,UAAU,8BAA8B,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,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;IACD,OAAO;AACR,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\treturn;\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;AAErD;;;;GAIG;AACH,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,CA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W,EAAE,EAAE,CAAC,CAAC;KACzC;IAED,IAAI,qBAAqB,CAAC,UAAU,CAAC,EAAE;QACtC,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,iBAAiB,CAAC;KACnD;AACF,CAAC;AAED,MAAM,UAAU,8BAA8B,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,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;IACD,OAAO;AACR,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.filter(modelName => !(modelName in modelClass.prototype))\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\treturn;\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import { AuroraZone, ManualAuroraZone, ProxyAuroraZone } from './zone.js';
2
+ export declare type ZoneType =
3
+ /**
4
+ * used when zone.js is disabled, no change detection will applied
5
+ */
6
+ 'manual'
7
+ /***
8
+ * used when zone.js is disabled, try to detection changes using ES6 proxy handler.
9
+ */
10
+ | 'proxy'
11
+ /***
12
+ * use when zone.js is active and loaded throw a polyfills file.
13
+ *
14
+ * active change detection
15
+ */
16
+ | 'aurora';
17
+ /**
18
+ * call once to init the aurora zone, for the platform
19
+ */
20
+ export declare function bootstrapZone(type?: ZoneType): void;
21
+ export declare function getCurrentZone(type?: ZoneType): AuroraZone | ManualAuroraZone | ProxyAuroraZone;
@@ -0,0 +1,35 @@
1
+ import { AuroraZone, ManualAuroraZone, ProxyAuroraZone } from './zone.js';
2
+ const manualAuroraZone = new ManualAuroraZone();
3
+ let proxyAuroraZone;
4
+ let auroraZone;
5
+ /**
6
+ * call once to init the aurora zone, for the platform
7
+ */
8
+ export function bootstrapZone(type) {
9
+ if (auroraZone) {
10
+ return;
11
+ }
12
+ if ('aurora' === type?.toLowerCase()) {
13
+ auroraZone = new AuroraZone();
14
+ }
15
+ else if ('proxy' === type?.toLowerCase()) {
16
+ auroraZone = proxyAuroraZone = new ProxyAuroraZone();
17
+ }
18
+ else {
19
+ auroraZone = manualAuroraZone;
20
+ }
21
+ }
22
+ export function getCurrentZone(type) {
23
+ if (type) {
24
+ switch (type.toLowerCase()) {
25
+ case 'aurora':
26
+ return auroraZone ?? (auroraZone = new AuroraZone());
27
+ case 'proxy':
28
+ return proxyAuroraZone ?? (proxyAuroraZone = new ProxyAuroraZone());
29
+ default:
30
+ case 'manual': return manualAuroraZone;
31
+ }
32
+ }
33
+ return auroraZone ?? manualAuroraZone;
34
+ }
35
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../../src/core/zone/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAqB1E,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAChD,IAAI,eAAgC,CAAC;AACrC,IAAI,UAAsB,CAAC;AAE3B;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAAe;IAC5C,IAAI,UAAU,EAAE;QACf,OAAO;KACP;IACD,IAAI,QAAQ,KAAK,IAAI,EAAE,WAAW,EAAE,EAAE;QACrC,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;KAC9B;SAAM,IAAI,OAAO,KAAK,IAAI,EAAE,WAAW,EAAE,EAAE;QAC3C,UAAU,GAAG,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;KACrD;SAAM;QACN,UAAU,GAAG,gBAAgB,CAAC;KAC9B;AACF,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAe;IAC7C,IAAI,IAAI,EAAE;QACT,QAAQ,IAAI,CAAC,WAAW,EAAE,EAAE;YAC3B,KAAK,QAAQ;gBACZ,OAAO,UAAU,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC,CAAC;YACtD,KAAK,OAAO;gBACX,OAAO,eAAe,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC,CAAC;YACrE,QAAQ;YACR,KAAK,QAAQ,CAAC,CAAC,OAAO,gBAAgB,CAAC;SACvC;KACD;IACD,OAAO,UAAU,IAAI,gBAAgB,CAAC;AACvC,CAAC","sourcesContent":["import { AuroraZone, ManualAuroraZone, ProxyAuroraZone } from './zone.js';\n\nexport type ZoneType =\n\t/**\n\t * used when zone.js is disabled, no change detection will applied\n\t */\n\t| 'manual'\n\n\t/***\n\t * used when zone.js is disabled, try to detection changes using ES6 proxy handler.\n\t */\n\t| 'proxy'\n\n\t/***\n\t * use when zone.js is active and loaded throw a polyfills file.\n\t * \n\t * active change detection\n\t */\n\t| 'aurora'\n\t;\n\nconst manualAuroraZone = new ManualAuroraZone();\nlet proxyAuroraZone: ProxyAuroraZone;\nlet auroraZone: AuroraZone;\n\n/**\n * call once to init the aurora zone, for the platform\n */\nexport function bootstrapZone(type?: ZoneType) {\n\tif (auroraZone) {\n\t\treturn;\n\t}\n\tif ('aurora' === type?.toLowerCase()) {\n\t\tauroraZone = new AuroraZone();\n\t} else if ('proxy' === type?.toLowerCase()) {\n\t\tauroraZone = proxyAuroraZone = new ProxyAuroraZone();\n\t} else {\n\t\tauroraZone = manualAuroraZone;\n\t}\n}\n\nexport function getCurrentZone(type?: ZoneType) {\n\tif (type) {\n\t\tswitch (type.toLowerCase()) {\n\t\t\tcase 'aurora':\n\t\t\t\treturn auroraZone ?? (auroraZone = new AuroraZone());\n\t\t\tcase 'proxy':\n\t\t\t\treturn proxyAuroraZone ?? (proxyAuroraZone = new ProxyAuroraZone());\n\t\t\tdefault:\n\t\t\tcase 'manual': return manualAuroraZone;\n\t\t}\n\t}\n\treturn auroraZone ?? manualAuroraZone;\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { RevocableProxy } from '@ibyar/expressions';
2
+ import { AuroraZone } from './zone.js';
3
+ /**
4
+ * crete new proxy handler for object
5
+ */
6
+ export declare class ZoneProxyHandler<T extends object> implements ProxyHandler<T> {
7
+ private _zone;
8
+ constructor(_zone: AuroraZone);
9
+ defineProperty(target: T, p: string | symbol, attributes: PropertyDescriptor): boolean;
10
+ deleteProperty(target: T, p: string | symbol): boolean;
11
+ get(target: T, p: string | symbol, receiver: any): any;
12
+ set(target: T, p: string | symbol, value: any, receiver: any): boolean;
13
+ }
14
+ export declare function createRevocableZoneProxyHandler<T extends object>(model: T, zone: AuroraZone): RevocableProxy<T>;
15
+ export declare function createZoneProxyHandler<T extends object>(model: T, zone: AuroraZone): T;
package/zone/proxy.js ADDED
@@ -0,0 +1,32 @@
1
+ import { hasBindingHook } from '@ibyar/expressions';
2
+ /**
3
+ * crete new proxy handler for object
4
+ */
5
+ export class ZoneProxyHandler {
6
+ constructor(_zone) {
7
+ this._zone = _zone;
8
+ }
9
+ defineProperty(target, p, attributes) {
10
+ return this._zone.run(Reflect.defineProperty, target, [target, p, attributes]);
11
+ }
12
+ deleteProperty(target, p) {
13
+ return this._zone.run(Reflect.deleteProperty, target, [target, p]);
14
+ }
15
+ get(target, p, receiver) {
16
+ const value = Reflect.get(target, p, receiver);
17
+ if (!(value && typeof value === 'object') || hasBindingHook(value)) {
18
+ return value;
19
+ }
20
+ return createZoneProxyHandler(value, this._zone);
21
+ }
22
+ set(target, p, value, receiver) {
23
+ return this._zone.run(Reflect.set, target, [target, p, value, receiver]);
24
+ }
25
+ }
26
+ export function createRevocableZoneProxyHandler(model, zone) {
27
+ return Proxy.revocable(model, new ZoneProxyHandler(zone));
28
+ }
29
+ export function createZoneProxyHandler(model, zone) {
30
+ return new Proxy(model, new ZoneProxyHandler(zone));
31
+ }
32
+ //# sourceMappingURL=proxy.js.map
@@ -0,0 +1 @@
1
+ {"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,IAAgB;IAC3F,OAAO,KAAK,CAAC,SAAS,CAAI,KAAK,EAAE,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAmB,KAAQ,EAAE,IAAgB;IAClF,OAAO,IAAI,KAAK,CAAI,KAAK,EAAE,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import { hasBindingHook, RevocableProxy } from '@ibyar/expressions';\nimport { AuroraZone } from './zone.js';\n\n/**\n * crete new proxy handler for object\n */\nexport class ZoneProxyHandler<T extends object> implements ProxyHandler<T> {\n\tconstructor(private _zone: AuroraZone) { }\n\tdefineProperty(target: T, p: string | symbol, attributes: PropertyDescriptor): boolean {\n\t\treturn this._zone.run(Reflect.defineProperty, target, [target, p, attributes]);\n\t}\n\tdeleteProperty(target: T, p: string | symbol): boolean {\n\t\treturn this._zone.run(Reflect.deleteProperty, target, [target, p]);\n\t}\n\tget(target: T, p: string | symbol, receiver: any): any {\n\t\tconst value = Reflect.get(target, p, receiver);\n\t\tif (!(value && typeof value === 'object') || hasBindingHook(value)) {\n\t\t\treturn value;\n\t\t}\n\t\treturn createZoneProxyHandler(value, this._zone);\n\t}\n\tset(target: T, p: string | symbol, value: any, receiver: any): boolean {\n\t\treturn this._zone.run(Reflect.set, target, [target, p, value, receiver]);\n\t}\n}\n\nexport function createRevocableZoneProxyHandler<T extends object>(model: T, zone: AuroraZone): RevocableProxy<T> {\n\treturn Proxy.revocable<T>(model, new ZoneProxyHandler(zone));\n}\n\nexport function createZoneProxyHandler<T extends object>(model: T, zone: AuroraZone): T {\n\treturn new Proxy<T>(model, new ZoneProxyHandler(zone));\n}\n"]}