@ibyar/core 0.5.2 → 0.5.62

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 (64) hide show
  1. package/LICENSE +1 -1
  2. package/annotation/decorators.d.ts +97 -0
  3. package/binding/binding.expressions.d.ts +8 -2
  4. package/binding/binding.expressions.js +48 -15
  5. package/binding/binding.expressions.js.map +1 -1
  6. package/component/component.js +9 -8
  7. package/component/component.js.map +1 -1
  8. package/component/custom-element.d.ts +42 -0
  9. package/component/provider.d.ts +4 -7
  10. package/component/provider.js +5 -17
  11. package/component/provider.js.map +1 -1
  12. package/context/stack.js +5 -1
  13. package/context/stack.js.map +1 -1
  14. package/directive/directive.d.ts +9 -0
  15. package/directive/directive.js +9 -0
  16. package/directive/directive.js.map +1 -1
  17. package/directive/parser.d.ts +5 -1
  18. package/directive/parser.js +33 -11
  19. package/directive/parser.js.map +1 -1
  20. package/directive/providers.d.ts +2 -0
  21. package/directive/providers.js +4 -1
  22. package/directive/providers.js.map +1 -1
  23. package/html/expression.d.ts +5 -0
  24. package/html/expression.js +22 -10
  25. package/html/expression.js.map +1 -1
  26. package/linker/change-detector-ref.d.ts +14 -0
  27. package/linker/change-detector-ref.js +3 -0
  28. package/linker/change-detector-ref.js.map +1 -1
  29. package/linker/template-ref.d.ts +12 -0
  30. package/linker/template-ref.js +4 -2
  31. package/linker/template-ref.js.map +1 -1
  32. package/linker/view-container-ref.d.ts +78 -0
  33. package/linker/view-container-ref.js +4 -3
  34. package/linker/view-container-ref.js.map +1 -1
  35. package/linker/view-ref.d.ts +39 -0
  36. package/package.json +6 -6
  37. package/pipe/pipe.d.ts +10 -0
  38. package/pipe/pipe.js +14 -4
  39. package/pipe/pipe.js.map +1 -1
  40. package/providers/injector.js +1 -0
  41. package/providers/injector.js.map +1 -1
  42. package/providers/provider.js +2 -0
  43. package/providers/provider.js.map +1 -1
  44. package/render/host-listener.handler.d.ts +43 -0
  45. package/render/host-listener.handler.js +86 -0
  46. package/render/host-listener.handler.js.map +1 -0
  47. package/render/render-handler.d.ts +11 -0
  48. package/render/render-handler.js +2 -0
  49. package/render/render-handler.js.map +1 -0
  50. package/utils/typeof.d.ts +3 -0
  51. package/utils/utils.js +1 -0
  52. package/utils/utils.js.map +1 -1
  53. package/view/base-view.js +15 -9
  54. package/view/base-view.js.map +1 -1
  55. package/view/form-view.js +21 -0
  56. package/view/form-view.js.map +1 -1
  57. package/view/mutation.js +1 -0
  58. package/view/mutation.js.map +1 -1
  59. package/view/render.d.ts +1 -2
  60. package/view/render.js +59 -53
  61. package/view/render.js.map +1 -1
  62. package/view/view.d.ts +5 -0
  63. package/view/view.js +7 -0
  64. package/view/view.js.map +1 -1
package/view/render.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { ReactiveScope } from '@ibyar/expressions';
1
2
  import { CommentNode, DomStructuralDirectiveNode, DomElementNode, DomFragmentNode, isLiveTextContent, isTagNameNative, isValidCustomElementName, TextContent } from '@ibyar/elements';
2
3
  import { isHTMLComponent } from '../component/custom-element.js';
3
4
  import { documentStack } from '../context/stack.js';
@@ -8,6 +9,7 @@ import { AttributeDirective, AttributeOnStructuralDirective } from '../directive
8
9
  import { TemplateRefImpl } from '../linker/template-ref.js';
9
10
  import { ViewContainerRefImpl } from '../linker/view-container-ref.js';
10
11
  import { createSubscriptionDestroyer } from '../context/subscription.js';
12
+ import { HostListenerHandler } from '../render/host-listener.handler.js';
11
13
  function getInputEventName(element) {
12
14
  switch (true) {
13
15
  case element instanceof HTMLInputElement:
@@ -23,10 +25,11 @@ export class ComponentRender {
23
25
  constructor(view, subscriptions) {
24
26
  this.view = view;
25
27
  this.subscriptions = subscriptions;
28
+ this.viewScope = new ReactiveScope({});
26
29
  this.componentRef = this.view.getComponentRef();
27
30
  this.contextStack = documentStack.copyStack();
28
31
  this.contextStack.pushScope(this.view._modelScope);
29
- this.templateNameScope = this.contextStack.pushBlockReactiveScope();
32
+ this.templateNameScope = this.contextStack.pushReactiveScope();
30
33
  }
31
34
  initView() {
32
35
  if (this.componentRef.template) {
@@ -38,10 +41,10 @@ export class ComponentRender {
38
41
  }
39
42
  let rootRef;
40
43
  if (this.componentRef.isShadowDom) {
41
- if (this.view.shadowRoot) {
44
+ if (this.view.shadowRoot /* OPEN MODE */) {
42
45
  rootRef = this.view.shadowRoot;
43
46
  }
44
- else {
47
+ else /* CLOSED MODE*/ {
45
48
  rootRef = Reflect.get(this.view, '_shadowRoot');
46
49
  Reflect.deleteProperty(this.view, '_shadowRoot');
47
50
  }
@@ -85,50 +88,9 @@ export class ComponentRender {
85
88
  }
86
89
  }
87
90
  initHostListener() {
88
- this.componentRef.hostListeners?.forEach(listener => this.handelHostListener(listener));
89
- }
90
- handelHostListener(listener) {
91
- let eventName = listener.eventName, source;
92
- if (listener.eventName.includes(':')) {
93
- const eventSource = eventName.substring(0, eventName.indexOf(':'));
94
- eventName = eventName.substring(eventName.indexOf(':') + 1);
95
- if ('window' === eventSource.toLowerCase()) {
96
- source = window;
97
- this.addNativeEventListener(source, eventName, (event) => {
98
- this.view._model[listener.modelCallbackName].call(this.view._proxyModel, event);
99
- });
100
- return;
101
- }
102
- else if (eventSource in this.view) {
103
- source = Reflect.get(this.view, eventSource);
104
- if (!Reflect.has(source, '_model')) {
105
- this.addNativeEventListener(source, eventName, (event) => {
106
- this.view._model[listener.modelCallbackName].call(this.view._proxyModel, event);
107
- });
108
- return;
109
- }
110
- }
111
- else {
112
- source = this.view;
113
- }
114
- }
115
- else {
116
- source = this.view;
117
- }
118
- const sourceModel = Reflect.get(source, '_model');
119
- const output = ClassRegistryProvider.hasOutput(sourceModel, eventName);
120
- if (output) {
121
- sourceModel[output.modelProperty].subscribe((value) => {
122
- this.view._model[listener.modelCallbackName].call(this.view._proxyModel, value);
123
- });
124
- }
125
- else if (Reflect.has(source, 'on' + eventName)) {
126
- this.addNativeEventListener(source, eventName, (event) => {
127
- this.view._model[listener.modelCallbackName].call(this.view._proxyModel, event);
128
- });
129
- }
130
- else {
131
- }
91
+ const handlers = this.componentRef.hostListeners.map(listenerRef => new HostListenerHandler(listenerRef, this.view, this.viewScope));
92
+ handlers.forEach(handler => handler.onInit());
93
+ handlers.forEach(handler => this.subscriptions.push(createSubscriptionDestroyer(() => handler.onDestroy(), () => handler.onDisconnect(), () => handler.onConnect())));
132
94
  }
133
95
  addNativeEventListener(source, eventName, funcCallback) {
134
96
  source.addEventListener(eventName, (event) => {
@@ -144,10 +106,11 @@ export class ComponentRender {
144
106
  const stack = directiveStack.copyStack();
145
107
  const templateRef = new TemplateRefImpl(this, directive.node, stack, directive.templateExpressions ?? []);
146
108
  const viewContainerRef = new ViewContainerRefImpl(parentNode, comment);
109
+ // structural directive selector
147
110
  const StructuralDirectiveClass = directiveRef.modelClass;
148
111
  const structural = new StructuralDirectiveClass(templateRef, viewContainerRef, host);
149
112
  templateRef.host = structural;
150
- stack.pushBlockReactiveScopeFor({ 'this': structural });
113
+ stack.pushReactiveScopeFor({ 'this': structural });
151
114
  const dSubs = this.initStructuralDirective(structural, directive, stack);
152
115
  subscriptions.push(...dSubs);
153
116
  if (isOnInit(structural)) {
@@ -161,6 +124,8 @@ export class ComponentRender {
161
124
  }
162
125
  }
163
126
  else {
127
+ // didn't find directive or it is not define yet.
128
+ // class registry should have 'when defined' callback
164
129
  }
165
130
  }
166
131
  createComment(node) {
@@ -175,7 +140,9 @@ export class ComponentRender {
175
140
  contextStack.pushBlockScopeFor({ this: liveText });
176
141
  const textSubscriptions = textNode.expression.subscribe(contextStack, textNode.pipelineNames);
177
142
  subscriptions.push(...textSubscriptions);
143
+ contextStack.detach();
178
144
  textNode.expression.get(contextStack);
145
+ contextStack.reattach();
179
146
  return liveText;
180
147
  }
181
148
  createDocumentFragment(node, contextStack, parentNode, subscriptions, host) {
@@ -187,6 +154,11 @@ export class ComponentRender {
187
154
  if (child instanceof DomElementNode) {
188
155
  if (this.isTemplateRefName(child)) {
189
156
  const templateRefName = child.templateRefName;
157
+ // const oldRef = this.templateNameScope.get(templateRefName.name);
158
+ // if (oldRef) {
159
+ // return;
160
+ // }
161
+ // TODO: extract template expression
190
162
  const templateRef = new TemplateRefImpl(this, new DomFragmentNode(child.children), contextStack.copyStack(), []);
191
163
  this.templateNameScope.set(templateRefName.name, templateRef);
192
164
  return;
@@ -229,9 +201,11 @@ export class ComponentRender {
229
201
  }
230
202
  }
231
203
  else if (isTagNameNative(node.tagName)) {
204
+ // native tags // and custom tags can be used her
232
205
  element = document.createElement(node.tagName, node.is ? { is: node.is } : undefined);
233
206
  }
234
207
  else {
208
+ // html unknown element
235
209
  element = document.createElement(node.tagName);
236
210
  }
237
211
  if (isHTMLComponent(element)) {
@@ -242,7 +216,7 @@ export class ComponentRender {
242
216
  createElement(node, contextStack, subscriptions, parentNode, host) {
243
217
  const element = this.createElementByTagName(node);
244
218
  const elementStack = contextStack.copyStack();
245
- const elementScope = isHTMLComponent(element) ? element._viewScope : elementStack.pushBlockReactiveScopeFor({ 'this': element });
219
+ const elementScope = isHTMLComponent(element) ? element._viewScope : elementStack.pushReactiveScopeFor({ 'this': element });
246
220
  elementStack.pushScope(elementScope);
247
221
  const attributesSubscriptions = this.initAttribute(element, node, elementStack);
248
222
  subscriptions.push(...attributesSubscriptions);
@@ -256,6 +230,7 @@ export class ComponentRender {
256
230
  const templateRefName = node.templateRefName;
257
231
  if (templateRefName) {
258
232
  Reflect.set(this.view, templateRefName.name, element);
233
+ this.viewScope.set(templateRefName.name, element);
259
234
  const view = this.componentRef.viewChild.find(child => child.selector === templateRefName.name);
260
235
  if (view) {
261
236
  Reflect.set(this.view._model, view.modelName, element);
@@ -279,7 +254,7 @@ export class ComponentRender {
279
254
  || directiveRef.modelClass.prototype instanceof AttributeOnStructuralDirective)) {
280
255
  const directive = new directiveRef.modelClass(element);
281
256
  const stack = contextStack.copyStack();
282
- stack.pushBlockReactiveScopeFor({ 'this': directive });
257
+ stack.pushReactiveScopeFor({ 'this': directive });
283
258
  const directiveSubscriptions = this.initStructuralDirective(directive, directiveNode, stack);
284
259
  subscriptions.push(...directiveSubscriptions);
285
260
  if (isOnInit(directive)) {
@@ -295,6 +270,9 @@ export class ComponentRender {
295
270
  const subscriptions = [];
296
271
  if (node.attributes?.length) {
297
272
  node.attributes.forEach(attr => {
273
+ /**
274
+ * <input id="23" name="person-name" />
275
+ */
298
276
  const isAttr = hasAttr(element, attr.name);
299
277
  if (isAttr) {
300
278
  if (attr.value === false) {
@@ -316,27 +294,43 @@ export class ComponentRender {
316
294
  node.twoWayBinding.forEach(attr => {
317
295
  const sub = attr.expression.subscribe(contextStack);
318
296
  subscriptions.push(...sub);
297
+ contextStack.detach();
319
298
  attr.expression.get(contextStack);
299
+ contextStack.reattach();
320
300
  });
321
301
  }
322
302
  if (node.inputs?.length) {
323
303
  node.inputs.forEach(attr => {
324
304
  const sub = attr.expression.subscribe(contextStack, attr.pipelineNames);
325
305
  subscriptions.push(...sub);
306
+ contextStack.detach();
326
307
  attr.expression.get(contextStack);
308
+ contextStack.reattach();
327
309
  });
328
310
  }
329
311
  if (node.outputs?.length) {
330
312
  node.outputs.forEach(event => {
331
313
  let listener;
314
+ /**
315
+ * <a (click)="onLinkClick($event)"></a>
316
+ * <a @click="onLinkClick($event)"></a>
317
+ * <input [(value)]="person.name" />
318
+ * <input (value)="person.name" />
319
+ * <!-- <input (value)="person.name = $event" /> -->
320
+ *
321
+ * TODO: diff of event listener and back-way data binding
322
+ */
332
323
  if (typeof event.value === 'string') {
333
324
  listener = ($event) => {
334
325
  const stack = contextStack.copyStack();
335
326
  stack.pushBlockScopeFor({ $event });
336
- event.expression.get(stack, this.view._proxyModel);
327
+ stack.detach();
328
+ event.expression.get(stack);
329
+ stack.reattach();
337
330
  };
338
331
  }
339
- else {
332
+ else /* if (typeof event.sourceHandler === 'function')*/ {
333
+ // let eventName: keyof HTMLElementEventMap = event.eventName;
340
334
  listener = event.value;
341
335
  }
342
336
  element.addEventListener(event.name, listener);
@@ -346,7 +340,9 @@ export class ComponentRender {
346
340
  node.templateAttrs.forEach(attr => {
347
341
  const sub = attr.expression.subscribe(contextStack);
348
342
  subscriptions.push(...sub);
343
+ contextStack.detach();
349
344
  attr.expression.get(contextStack);
345
+ contextStack.reattach();
350
346
  });
351
347
  }
352
348
  return subscriptions;
@@ -360,14 +356,18 @@ export class ComponentRender {
360
356
  node.twoWayBinding.forEach(attr => {
361
357
  const sub = attr.expression.subscribe(contextStack);
362
358
  subscriptions.push(...sub);
359
+ contextStack.detach();
363
360
  attr.expression.get(contextStack);
361
+ contextStack.reattach();
364
362
  });
365
363
  }
366
364
  if (node.inputs?.length) {
367
365
  node.inputs.forEach(attr => {
368
366
  const sub = attr.expression.subscribe(contextStack, attr.pipelineNames);
369
367
  subscriptions.push(...sub);
368
+ contextStack.detach();
370
369
  attr.expression.get(contextStack);
370
+ contextStack.reattach();
371
371
  });
372
372
  }
373
373
  if (node.outputs?.length) {
@@ -375,7 +375,9 @@ export class ComponentRender {
375
375
  const listener = ($event) => {
376
376
  const stack = contextStack.copyStack();
377
377
  stack.pushBlockScopeFor({ $event });
378
- event.expression.get(stack, this.view._proxyModel);
378
+ stack.detach();
379
+ event.expression.get(stack);
380
+ stack.reattach();
379
381
  };
380
382
  directive[event.name].subscribe(listener);
381
383
  });
@@ -384,9 +386,13 @@ export class ComponentRender {
384
386
  node.templateAttrs.forEach(attr => {
385
387
  const sub = attr.expression.subscribe(contextStack);
386
388
  subscriptions.push(...sub);
389
+ contextStack.detach();
387
390
  attr.expression.get(contextStack);
391
+ contextStack.reattach();
388
392
  });
389
393
  }
394
+ // TODO:
395
+ // check host binding
390
396
  return subscriptions;
391
397
  }
392
398
  }
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/view/render.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,WAAW,EAAE,0BAA0B,EACvC,cAAc,EAAE,eAAe,EAAW,iBAAiB,EAC3D,eAAe,EAAE,wBAAwB,EACzC,WAAW,EACX,MAAM,iBAAiB,CAAC;AAEzB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C1B,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;gBACxE,aAAa,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;gBAC3B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACnC,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,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACpD,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;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, ListenerRef } 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 { EventEmitter } from '../component/events.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';\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\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.pushBlockReactiveScope();\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\tthis.componentRef.hostListeners?.forEach(\n\t\t\tlistener => this.handelHostListener(listener)\n\t\t);\n\t}\n\thandelHostListener(listener: ListenerRef) {\n\t\tlet eventName: string = listener.eventName, source: HTMLElement | Window;\n\t\tif (listener.eventName.includes(':')) {\n\t\t\tconst eventSource = eventName.substring(0, eventName.indexOf(':'));\n\t\t\teventName = eventName.substring(eventName.indexOf(':') + 1);\n\t\t\tif ('window' === eventSource.toLowerCase()) {\n\t\t\t\tsource = window;\n\t\t\t\tthis.addNativeEventListener(source, eventName, (event: any) => {\n\t\t\t\t\t(this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel, event);\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t} else if (eventSource in this.view) {\n\t\t\t\tsource = Reflect.get(this.view, eventSource);\n\t\t\t\tif (!Reflect.has(source, '_model')) {\n\t\t\t\t\tthis.addNativeEventListener(source, eventName, (event: any) => {\n\t\t\t\t\t\t(this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel, event);\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsource = this.view;\n\t\t\t}\n\t\t} else {\n\t\t\tsource = this.view;\n\t\t}\n\t\tconst sourceModel = Reflect.get(source, '_model') as { [key: string]: EventEmitter<any> };\n\t\tconst output = ClassRegistryProvider.hasOutput(sourceModel, eventName);\n\t\tif (output) {\n\t\t\tsourceModel[output.modelProperty].subscribe((value: any) => {\n\t\t\t\t(this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel, value);\n\t\t\t});\n\t\t}\n\t\telse if (Reflect.has(source, 'on' + eventName)) {\n\t\t\tthis.addNativeEventListener(source, eventName, (event: any) => {\n\t\t\t\t(this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel, event);\n\t\t\t});\n\t\t}\n\t\t// else if (this.componentRef.encapsulation === 'template' && !this.view.hasParentComponent()) {\n\t\t// \tthis.addNativeEventListener(this.view, eventName, eventCallback);\n\t\t// }\n\t\telse {\n\t\t\t// listen to internal changes\n\t\t\t// TODO: need to resolve parameter\n\t\t\t// addChangeListener(sourceModel, eventName, () => (this.view._model[listener.modelCallbackName] as Function).call(this.view._proxyModel));\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.pushBlockReactiveScopeFor({ '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\ttextNode.expression.get(contextStack);\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.pushBlockReactiveScopeFor({ '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\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.pushBlockReactiveScopeFor({ '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\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\tevent.expression.get(stack, this.view._proxyModel);\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\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\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\tevent.expression.get(stack, this.view._proxyModel);\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"]}
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;AA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AC;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;QACD,SAAS;QACT,qBAAqB;QACrB,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"]}
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;
@@ -69,6 +74,7 @@ export function initCustomElementView(modelClass, componentRef) {
69
74
  const observedAttributes = componentRef.inputs.map(input => input.viewAttribute);
70
75
  Reflect.set(viewClass, 'observedAttributes', observedAttributes);
71
76
  Reflect.set(viewClass, 'allAttributes', defaultAttributes.concat(observedAttributes));
77
+ // https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example
72
78
  if (false) {
73
79
  Object.defineProperty(viewClass, 'formAssociated', {
74
80
  get() {
@@ -114,5 +120,6 @@ export function getComponentView(modelClass, selector) {
114
120
  }
115
121
  return Reflect.get(modelClass, viewClassName);
116
122
  }
123
+ return;
117
124
  }
118
125
  //# sourceMappingURL=view.js.map
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,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BAAiB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAE3E,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE;QACvC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,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;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"]}
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,C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,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAE3E,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE;QACvC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,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.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"]}