@ibyar/core 0.5.6 → 0.6.1

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 (80) hide show
  1. package/annotation/decorators.d.ts +121 -0
  2. package/annotation/decorators.js.map +1 -1
  3. package/binding/binding.expressions.d.ts +9 -4
  4. package/binding/binding.expressions.js +10 -15
  5. package/binding/binding.expressions.js.map +1 -1
  6. package/component/component.d.ts +3 -0
  7. package/component/component.js +1 -0
  8. package/component/component.js.map +1 -1
  9. package/component/custom-element.d.ts +48 -4
  10. package/component/custom-element.js.map +1 -1
  11. package/component/events.js +2 -6
  12. package/component/events.js.map +1 -1
  13. package/context/stack.js +4 -0
  14. package/context/stack.js.map +1 -1
  15. package/directive/directive.d.ts +9 -0
  16. package/directive/directive.js +9 -0
  17. package/directive/directive.js.map +1 -1
  18. package/directive/parser.d.ts +4 -0
  19. package/directive/parser.js +19 -0
  20. package/directive/parser.js.map +1 -1
  21. package/directive/providers.js +3 -3
  22. package/directive/providers.js.map +1 -1
  23. package/html/expression.d.ts +5 -0
  24. package/html/expression.js +13 -1
  25. package/html/expression.js.map +1 -1
  26. package/index.d.ts +4 -0
  27. package/index.js +4 -0
  28. package/index.js.map +1 -1
  29. package/linker/change-detector-ref.d.ts +25 -2
  30. package/linker/change-detector-ref.js +30 -18
  31. package/linker/change-detector-ref.js.map +1 -1
  32. package/linker/template-ref.d.ts +17 -5
  33. package/linker/template-ref.js +23 -20
  34. package/linker/template-ref.js.map +1 -1
  35. package/linker/view-container-ref.d.ts +140 -8
  36. package/linker/view-container-ref.js +82 -31
  37. package/linker/view-container-ref.js.map +1 -1
  38. package/linker/view-ref.d.ts +49 -5
  39. package/linker/view-ref.js +23 -9
  40. package/linker/view-ref.js.map +1 -1
  41. package/package.json +9 -5
  42. package/pipe/pipe.d.ts +7 -0
  43. package/pipe/pipe.js +4 -4
  44. package/pipe/pipe.js.map +1 -1
  45. package/providers/injector.js +1 -0
  46. package/providers/injector.js.map +1 -1
  47. package/render/host-listener.handler.d.ts +17 -0
  48. package/render/host-listener.handler.js +20 -3
  49. package/render/host-listener.handler.js.map +1 -1
  50. package/render/render-handler.d.ts +6 -0
  51. package/utils/typeof.d.ts +3 -0
  52. package/utils/utils.js +1 -0
  53. package/utils/utils.js.map +1 -1
  54. package/view/base-view.js +56 -19
  55. package/view/base-view.js.map +1 -1
  56. package/view/form-view.js +21 -0
  57. package/view/form-view.js.map +1 -1
  58. package/view/mutation.js +1 -0
  59. package/view/mutation.js.map +1 -1
  60. package/view/render.d.ts +9 -9
  61. package/view/render.js +38 -29
  62. package/view/render.js.map +1 -1
  63. package/view/view.d.ts +5 -0
  64. package/view/view.js +7 -0
  65. package/view/view.js.map +1 -1
  66. package/zone/bootstrap.d.ts +21 -0
  67. package/zone/bootstrap.js +35 -0
  68. package/zone/bootstrap.js.map +1 -0
  69. package/zone/proxy.d.ts +15 -0
  70. package/zone/proxy.js +41 -0
  71. package/zone/proxy.js.map +1 -0
  72. package/zone/task.d.ts +61 -0
  73. package/zone/task.js +109 -0
  74. package/zone/task.js.map +1 -0
  75. package/zone/zone.d.ts +51 -0
  76. package/zone/zone.js +193 -0
  77. package/zone/zone.js.map +1 -0
  78. package/component/provider.d.ts +0 -10
  79. package/component/provider.js +0 -17
  80. package/component/provider.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/core/component/events.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAY;IAExB,YAAoB,YAA6B;QAA7B,iBAAY,GAAZ,YAAY,CAAiB;IAAI,CAAC;IACtD,GAAG,CAAC,YAA+B;QAClC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC7B,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;SAC7B;QACD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IACD,WAAW;QACV,IAAI,CAAC,YAAY,CAA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,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;CACD","sourcesContent":["export class Subscription<T> {\n\tprivate othersSubscription: Subscription<any>[];\n\tconstructor(private eventEmitter: EventEmitter<T>) { }\n\tadd(subscription: Subscription<any>) {\n\t\tif (!this.othersSubscription) {\n\t\t\tthis.othersSubscription = [];\n\t\t}\n\t\tthis.othersSubscription.push(subscription);\n\t}\n\tunsubscribe(): void {\n\t\tthis.eventEmitter.remove(this);\n\t\tif (this.othersSubscription) {\n\t\t\tthis.othersSubscription.forEach((subscription) => {\n\t\t\t\tsubscription.unsubscribe();\n\t\t\t});\n\t\t}\n\t}\n}\n\ninterface Subscribe {\n\tnext?: any;\n\terror?: any;\n\tcomplete?: any;\n}\n\nexport class EventEmitter<T> {\n\tprivate subscribers: Map<Subscription<T>, Subscribe> = new Map();\n\tconstructor() { }\n\temit(value?: T): void {\n\t\tthis.subscribers.forEach((subscribe) => {\n\t\t\ttry {\n\t\t\t\tsubscribe.next(value);\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tif (subscribe.error) {\n\t\t\t\t\t\tsubscribe.error(error);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('error: handling event', error);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tif (subscribe.complete) {\n\t\t\t\t\t\tsubscribe.complete();\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('error: handling event', error);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\tsubscribe(next?: any, error?: any, complete?: any): Subscription<T> {\n\t\tconst subscription: Subscription<T> = new Subscription(this);\n\t\tthis.subscribers.set(subscription, { next, error, complete });\n\t\treturn subscription;\n\t}\n\n\tremove(subscription: Subscription<T>) {\n\t\tthis.subscribers.delete(subscription);\n\t}\n}\n"]}
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../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SAAS,CAAC,IAAU,EAAE,KAAW,EAAE,QAAc;QAChD,MAAM,YAAY,GAAoB,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9D,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,YAA6B;QACnC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;CACD","sourcesContent":["export class Subscription<T> {\n\tprivate othersSubscription: Subscription<any>[];\n\tconstructor(private eventEmitter: EventEmitter<T>) { }\n\tadd(subscription: Subscription<any>) {\n\t\tif (!this.othersSubscription) {\n\t\t\tthis.othersSubscription = [];\n\t\t}\n\t\tthis.othersSubscription.push(subscription);\n\t}\n\tunsubscribe(): void {\n\t\tthis.eventEmitter.remove(this);\n\t\tif (this.othersSubscription) {\n\t\t\tthis.othersSubscription.forEach((subscription) => {\n\t\t\t\tsubscription.unsubscribe();\n\t\t\t});\n\t\t}\n\t}\n}\n\ninterface Subscribe {\n\tnext?: any;\n\terror?: any;\n\tcomplete?: any;\n}\n\nexport class EventEmitter<T> {\n\tprivate subscribers: Map<Subscription<T>, Subscribe> = new Map();\n\tconstructor() { }\n\temit(value?: T): void {\n\t\tthis.subscribers.forEach((subscribe) => {\n\t\t\ttry {\n\t\t\t\tsubscribe.next(value);\n\t\t\t} catch (error) {\n\t\t\t\ttry {\n\t\t\t\t\tsubscribe.error?.(error);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('error: handling event', error);\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\ttry {\n\t\t\t\t\tsubscribe.complete?.();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconsole.error('error: handling event', error);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\tsubscribe(next?: any, error?: any, complete?: any): Subscription<T> {\n\t\tconst subscription: Subscription<T> = new Subscription(this);\n\t\tthis.subscribers.set(subscription, { next, error, complete });\n\t\treturn subscription;\n\t}\n\n\tremove(subscription: Subscription<T>) {\n\t\tthis.subscribers.delete(subscription);\n\t}\n}\n"]}
package/context/stack.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ReadOnlyScope, Stack } from '@ibyar/expressions';
2
2
  import { PipeProvider, AsyncPipeProvider } from '../pipe/pipe.js';
3
3
  const Constant = {
4
+ // math
4
5
  Math: {
5
6
  E: Math.E,
6
7
  LN10: Math.LN10,
@@ -46,13 +47,16 @@ const Constant = {
46
47
  fround: Math.fround,
47
48
  cbrt: Math.cbrt,
48
49
  },
50
+ // object
49
51
  Object,
52
+ // number
50
53
  parseFloat,
51
54
  parseInt,
52
55
  Infinity,
53
56
  NaN,
54
57
  isNaN,
55
58
  isFinite,
59
+ // array
56
60
  Array: {
57
61
  isArray: Array.isArray,
58
62
  },
@@ -1 +1 @@
1
- {"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../src/core/context/stack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,QAAQ,GAAyB;IAEtC,IAAI,EAAE;QACL,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,KAAK,EAAE,IAAI,CAAC,KAAK;QAEjB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;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AE;QACN,OAAO,EAAE,KAAK,CAAC,OAAO;KACtB;IACD,MAAM;IACN,MAAM;IACN,MAAM;CACN,CAAC;AAEF,MAAM,cAAc,GAAG,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC;AACnD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,KAAK,CACrC;IACC,cAAc;IACd,IAAI,YAAY,EAAE;IAClB,IAAI,iBAAiB,EAAE;CACvB,CACD,CAAC","sourcesContent":["import { ReadOnlyScope, Scope, Stack } from '@ibyar/expressions';\nimport { PipeProvider, AsyncPipeProvider } from '../pipe/pipe.js';\n\nconst Constant: { [k: string]: any } = {\n\t// math\n\tMath: {\n\t\tE: Math.E,\n\t\tLN10: Math.LN10,\n\t\tLN2: Math.LN2,\n\t\tLOG10E: Math.LOG10E,\n\t\tLOG2E: Math.LOG2E,\n\t\tPI: Math.PI,\n\t\tSQRT1_2: Math.SQRT1_2,\n\t\tSQRT2: Math.SQRT2,\n\n\t\tabs: Math.abs,\n\t\tacos: Math.acos,\n\t\tasin: Math.asin,\n\t\tatan: Math.atan,\n\t\tatan2: Math.atan2,\n\t\tceil: Math.ceil,\n\t\tcos: Math.cos,\n\t\texp: Math.exp,\n\t\tfloor: Math.floor,\n\t\tlog: Math.log,\n\t\tmax: Math.max,\n\t\tmin: Math.min,\n\t\tpow: Math.pow,\n\t\trandom: Math.random,\n\t\tround: Math.round,\n\t\tsin: Math.sin,\n\t\tsqrt: Math.sqrt,\n\t\ttan: Math.tan,\n\t\tclz32: Math.clz32,\n\t\timul: Math.imul,\n\t\tsign: Math.sign,\n\t\tlog10: Math.log10,\n\t\tlog2: Math.log2,\n\t\tlog1p: Math.log1p,\n\t\texpm1: Math.expm1,\n\t\tcosh: Math.cosh,\n\t\tsinh: Math.sinh,\n\t\ttanh: Math.tanh,\n\t\tacosh: Math.acosh,\n\t\tasinh: Math.asinh,\n\t\tatanh: Math.atanh,\n\t\thypot: Math.hypot,\n\t\ttrunc: Math.trunc,\n\t\tfround: Math.fround,\n\t\tcbrt: Math.cbrt,\n\t},\n\t// object\n\tObject,\n\t// number\n\tparseFloat,\n\tparseInt,\n\tInfinity,\n\tNaN,\n\tisNaN,\n\tisFinite,\n\t// array\n\tArray: {\n\t\tisArray: Array.isArray,\n\t},\n\tSymbol,\n\tString,\n\tNumber,\n};\n\nconst CONSTANT_SCOPE = new ReadOnlyScope(Constant);\nexport const documentStack = new Stack(\n\t[\n\t\tCONSTANT_SCOPE,\n\t\tnew PipeProvider(),\n\t\tnew AsyncPipeProvider()\n\t]\n);\n"]}
1
+ {"version":3,"file":"stack.js","sourceRoot":"","sources":["../../../src/core/context/stack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,QAAQ,GAAyB;IACtC,OAAO;IACP,IAAI,EAAE;QACL,CAAC,EAAE,IAAI,CAAC,CAAC;QACT,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,KAAK,EAAE,IAAI,CAAC,KAAK;QAEjB,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,GAAG,EAAE,IAAI,CAAC,GAAG;QACb,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,EAAE,IAAI,CAAC,G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AAc;IACd,IAAI,YAAY,EAAE;IAClB,IAAI,iBAAiB,EAAE;CACvB,CACD,CAAC","sourcesContent":["import { ReadOnlyScope, Scope, Stack } from '@ibyar/expressions';\nimport { PipeProvider, AsyncPipeProvider } from '../pipe/pipe.js';\n\nconst Constant: { [k: string]: any } = {\n\t// math\n\tMath: {\n\t\tE: Math.E,\n\t\tLN10: Math.LN10,\n\t\tLN2: Math.LN2,\n\t\tLOG10E: Math.LOG10E,\n\t\tLOG2E: Math.LOG2E,\n\t\tPI: Math.PI,\n\t\tSQRT1_2: Math.SQRT1_2,\n\t\tSQRT2: Math.SQRT2,\n\n\t\tabs: Math.abs,\n\t\tacos: Math.acos,\n\t\tasin: Math.asin,\n\t\tatan: Math.atan,\n\t\tatan2: Math.atan2,\n\t\tceil: Math.ceil,\n\t\tcos: Math.cos,\n\t\texp: Math.exp,\n\t\tfloor: Math.floor,\n\t\tlog: Math.log,\n\t\tmax: Math.max,\n\t\tmin: Math.min,\n\t\tpow: Math.pow,\n\t\trandom: Math.random,\n\t\tround: Math.round,\n\t\tsin: Math.sin,\n\t\tsqrt: Math.sqrt,\n\t\ttan: Math.tan,\n\t\tclz32: Math.clz32,\n\t\timul: Math.imul,\n\t\tsign: Math.sign,\n\t\tlog10: Math.log10,\n\t\tlog2: Math.log2,\n\t\tlog1p: Math.log1p,\n\t\texpm1: Math.expm1,\n\t\tcosh: Math.cosh,\n\t\tsinh: Math.sinh,\n\t\ttanh: Math.tanh,\n\t\tacosh: Math.acosh,\n\t\tasinh: Math.asinh,\n\t\tatanh: Math.atanh,\n\t\thypot: Math.hypot,\n\t\ttrunc: Math.trunc,\n\t\tfround: Math.fround,\n\t\tcbrt: Math.cbrt,\n\t},\n\t// object\n\tObject,\n\t// number\n\tparseFloat,\n\tparseInt,\n\tInfinity,\n\tNaN,\n\tisNaN,\n\tisFinite,\n\t// array\n\tArray: {\n\t\tisArray: Array.isArray,\n\t},\n\tSymbol,\n\tString,\n\tNumber,\n};\n\nconst CONSTANT_SCOPE = new ReadOnlyScope(Constant);\nexport const documentStack = new Stack(\n\t[\n\t\tCONSTANT_SCOPE,\n\t\tnew PipeProvider(),\n\t\tnew AsyncPipeProvider()\n\t]\n);\n"]}
@@ -1,16 +1,25 @@
1
1
  import { HTMLComponent } from '../component/custom-element.js';
2
2
  import { TemplateRef } from '../linker/template-ref.js';
3
3
  import { ViewContainerRef } from '../linker/view-container-ref.js';
4
+ /**
5
+ * A structural directive selector as '*if' '*for'
6
+ */
4
7
  export declare class StructuralDirective {
5
8
  protected templateRef: TemplateRef;
6
9
  protected viewContainerRef: ViewContainerRef;
7
10
  protected host: HTMLComponent<any> | StructuralDirective;
8
11
  constructor(templateRef: TemplateRef, viewContainerRef: ViewContainerRef, host: HTMLComponent<any> | StructuralDirective);
9
12
  }
13
+ /**
14
+ * An attributes directive selector as '[class] [style]'
15
+ */
10
16
  export declare class AttributeDirective {
11
17
  protected el: HTMLElement;
12
18
  constructor(el: HTMLElement);
13
19
  }
20
+ /**
21
+ * An attributes directive on structural directive
22
+ */
14
23
  export declare class AttributeOnStructuralDirective {
15
24
  protected directive: StructuralDirective;
16
25
  constructor(directive: StructuralDirective);
@@ -1,3 +1,6 @@
1
+ /**
2
+ * A structural directive selector as '*if' '*for'
3
+ */
1
4
  export class StructuralDirective {
2
5
  constructor(templateRef, viewContainerRef, host) {
3
6
  this.templateRef = templateRef;
@@ -5,11 +8,17 @@ export class StructuralDirective {
5
8
  this.host = host;
6
9
  }
7
10
  }
11
+ /**
12
+ * An attributes directive selector as '[class] [style]'
13
+ */
8
14
  export class AttributeDirective {
9
15
  constructor(el) {
10
16
  this.el = el;
11
17
  }
12
18
  }
19
+ /**
20
+ * An attributes directive on structural directive
21
+ */
13
22
  export class AttributeOnStructuralDirective {
14
23
  constructor(directive) {
15
24
  this.directive = directive;
@@ -1 +1 @@
1
- {"version":3,"file":"directive.js","sourceRoot":"","sources":["../../../src/core/directive/directive.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,mBAAmB;IAC/B,YACW,WAAwB,EACxB,gBAAkC,EAClC,IAA8C;QAF9C,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,SAAI,GAAJ,IAAI,CAA0C;IACrD,CAAC;CACL;AAKD,MAAM,OAAO,kBAAkB;IAC9B,YAAsB,EAAe;QAAf,OAAE,GAAF,EAAE,CAAa;IAAI,CAAC;CAC1C;AAKD,MAAM,OAAO,8BAA8B;IAC1C,YAAsB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAI,CAAC;CACzD","sourcesContent":["\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { TemplateRef } from '../linker/template-ref.js';\nimport { ViewContainerRef } from '../linker/view-container-ref.js';\n\n/**\n * A structural directive selector as '*if' '*for'\n */\nexport class StructuralDirective {\n\tconstructor(\n\t\tprotected templateRef: TemplateRef,\n\t\tprotected viewContainerRef: ViewContainerRef,\n\t\tprotected host: HTMLComponent<any> | StructuralDirective,\n\t) { }\n}\n\n/**\n * An attributes directive selector as '[class] [style]'\n */\nexport class AttributeDirective {\n\tconstructor(protected el: HTMLElement) { }\n}\n\n/**\n * An attributes directive on structural directive\n */\nexport class AttributeOnStructuralDirective {\n\tconstructor(protected directive: StructuralDirective) { }\n}\n"]}
1
+ {"version":3,"file":"directive.js","sourceRoot":"","sources":["../../../src/core/directive/directive.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAC/B,YACW,WAAwB,EACxB,gBAAkC,EAClC,IAA8C;QAF9C,gBAAW,GAAX,WAAW,CAAa;QACxB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,SAAI,GAAJ,IAAI,CAA0C;IACrD,CAAC;CACL;AAED;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC9B,YAAsB,EAAe;QAAf,OAAE,GAAF,EAAE,CAAa;IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,OAAO,8BAA8B;IAC1C,YAAsB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAI,CAAC;CACzD","sourcesContent":["\nimport { HTMLComponent } from '../component/custom-element.js';\nimport { TemplateRef } from '../linker/template-ref.js';\nimport { ViewContainerRef } from '../linker/view-container-ref.js';\n\n/**\n * A structural directive selector as '*if' '*for'\n */\nexport class StructuralDirective {\n\tconstructor(\n\t\tprotected templateRef: TemplateRef,\n\t\tprotected viewContainerRef: ViewContainerRef,\n\t\tprotected host: HTMLComponent<any> | StructuralDirective,\n\t) { }\n}\n\n/**\n * An attributes directive selector as '[class] [style]'\n */\nexport class AttributeDirective {\n\tconstructor(protected el: HTMLElement) { }\n}\n\n/**\n * An attributes directive on structural directive\n */\nexport class AttributeOnStructuralDirective {\n\tconstructor(protected directive: StructuralDirective) { }\n}\n"]}
@@ -25,6 +25,10 @@ export declare class DirectiveExpressionParser {
25
25
  protected consumeSemicolonOrComma(): void;
26
26
  protected parseTemplateInput(): boolean;
27
27
  protected parseExpression(inputName: string): void;
28
+ /**
29
+ * check if the first is
30
+ * @returns `boolean`
31
+ */
28
32
  protected parseDirectiveAndTemplateInputs(): void;
29
33
  private mapTokenToString;
30
34
  }
@@ -31,16 +31,19 @@ export class DirectiveExpressionParser {
31
31
  };
32
32
  }
33
33
  scan() {
34
+ // parse 'let/const/var' if found, or switch to expression mode.
34
35
  if (this.isDeclareKeyword()) {
35
36
  this.parseTemplateInput();
36
37
  }
37
38
  else {
39
+ // parse expression, possible ends is semicolon, comma, let and 'EOS'
38
40
  this.parseExpression(this.directiveName);
39
41
  }
40
42
  if (this.stream.peek().isType(Token.EOS)) {
41
43
  return;
42
44
  }
43
45
  this.consumeSemicolonOrComma();
46
+ // parse let and parseDirectiveAndTemplateInputs
44
47
  while (this.stream.peek().isNotType(Token.EOS)) {
45
48
  this.parseTemplateInput() || this.parseDirectiveAndTemplateInputs();
46
49
  this.consumeSemicolonOrComma();
@@ -103,12 +106,14 @@ export class DirectiveExpressionParser {
103
106
  }
104
107
  }
105
108
  parseTemplateInput() {
109
+ // let = "let" :local "=" :export ";"?
106
110
  if (this.isDeclareKeyword()) {
107
111
  let peek = this.stream.peek();
108
112
  const list = [peek];
109
113
  this.consume(peek.token);
110
114
  peek = this.stream.peek();
111
115
  if (Token.isOpenPair(peek.token) && peek.isNotType(Token.LPAREN)) {
116
+ // object and array pattern, destructing
112
117
  this.stream.readTill(Token.closeOf(peek.token), list);
113
118
  }
114
119
  else if (peek.isType(Token.IDENTIFIER)) {
@@ -133,6 +138,10 @@ export class DirectiveExpressionParser {
133
138
  this.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);
134
139
  this.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));
135
140
  }
141
+ /**
142
+ * check if the first is
143
+ * @returns `boolean`
144
+ */
136
145
  parseDirectiveAndTemplateInputs() {
137
146
  if (this.stream.peek().isType(Token.EOS)) {
138
147
  return;
@@ -146,8 +155,13 @@ export class DirectiveExpressionParser {
146
155
  const identifierName = inputToken.token.getName();
147
156
  inputToken = new TokenExpression(Token.IDENTIFIER, new Identifier(identifierName));
148
157
  }
158
+ // only template input
159
+ // mapping from directive scope(context) to template scope
149
160
  if (this.isAsKeyword()) {
161
+ // as = :export "as" :local ";"?
150
162
  this.consumeAsKeyword();
163
+ // rewrite `input as alias`
164
+ // ==> in template -> alias = input
151
165
  const aliasToken = this.stream.next();
152
166
  const aliasList = [];
153
167
  aliasList.push(aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);
@@ -156,9 +170,14 @@ export class DirectiveExpressionParser {
156
170
  }
157
171
  this.check(Token.ASSIGN) || this.check(Token.COLON);
158
172
  const list = [];
173
+ // keyExp = :key ":"? :expression ("as" :local)? ";"?
159
174
  this.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);
175
+ // mix for directive input and template input
160
176
  if (this.isAsKeyword()) {
161
177
  this.consumeAsKeyword();
178
+ // rewrite `input {x: 7, y: 9} as alias`
179
+ // ==> in directive ->`input = {x: 7, y: 9}`
180
+ // ==> or in template -> let alias = input
162
181
  const aliasToken = this.stream.next();
163
182
  const aliasList = [];
164
183
  aliasList.push(TokenConstant.LET, aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);
@@ -1 +1 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/core/directive/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOrF,MAAM,aAAa;;AACX,iBAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACrC,mBAAK,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACzC,oBAAM,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC3C,sBAAQ,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;AAC9E,iBAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAG7C,MAAM,OAAO,yBAAyB;IAiBrC,YAAsB,aAAqB,EAAY,MAAmB;QAApD,kBAAa,GAAb,aAAa,CAAQ;QAAY,WAAM,GAAN,MAAM,CAAa;QAHhE,wBAAmB,GAAG,IAAI,KAAK,EAAqB,CAAC;QACrD,oBAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEwB,CAAC;IAdxE,MAAM,CAAC,KAAK,CAAC,aAAqB,EAAE,UAAkB;QAC5D,MAAM,MAAM,GAAG,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,IAAI,yBAAyB,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACpE,IAAI;YACH,MAAM,CAAC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AC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAGrH,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;YACvB,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAIxB,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACtC,MAAM,SAAS,GAAsB,EAAE,CAAC;YACxC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,UAAU,EAAE,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;YACnG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACzC;QACD,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,EAAc,CAAC,OAAO,EAAY,CAAC;QACxE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEhF,CAAC;IAEO,gBAAgB,CAAC,KAAsB;QAC9C,IAAI,KAAK,CAAC,KAAK,EAAE;YAChB,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;SAC9B;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CAED","sourcesContent":["import { Identifier, Token, TokenExpression, TokenStream } from '@ibyar/expressions';\n\nexport type DirectiveExpressionType = {\n\ttemplateExpressions: Array<TokenExpression[]>;\n\tdirectiveInputs: Map<string, string>;\n};\n\nclass TokenConstant {\n\tstatic LET = new TokenExpression(Token.LET);\n\tstatic COMMA = new TokenExpression(Token.COMMA);\n\tstatic ASSIGN = new TokenExpression(Token.ASSIGN);\n\tstatic IMPLICIT = new TokenExpression(Token.IDENTIFIER, new Identifier('$implicit'));\n\tstatic EOS = new TokenExpression(Token.EOS);\n}\n\nexport class DirectiveExpressionParser {\n\n\n\tpublic static parse(directiveName: string, expression: string): DirectiveExpressionType {\n\t\tconst stream = TokenStream.getTokenStream(expression);\n\t\tconst parser = new DirectiveExpressionParser(directiveName, stream);\n\t\ttry {\n\t\t\tparser.scan();\n\t\t} catch (error) {\n\t\t\tconsole.error('error parsing template expression', expression, parser, error);\n\t\t}\n\t\treturn parser.getDirectiveExpressionType();\n\t}\n\n\tprotected templateExpressions = new Array<TokenExpression[]>();\n\tprotected directiveInputs = new Map<string, string>();\n\n\tconstructor(protected directiveName: string, protected stream: TokenStream) { }\n\n\tgetDirectiveExpressionType(): DirectiveExpressionType {\n\t\treturn {\n\t\t\ttemplateExpressions: this.templateExpressions,\n\t\t\tdirectiveInputs: this.directiveInputs\n\t\t};\n\t}\n\tscan(): void {\n\t\t// parse 'let/const/var' if found, or switch to expression mode.\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tthis.parseTemplateInput();\n\t\t} else {\n\t\t\t// parse expression, possible ends is semicolon, comma, let and 'EOS'\n\t\t\tthis.parseExpression(this.directiveName);\n\t\t}\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.consumeSemicolonOrComma();\n\n\t\t// parse let and parseDirectiveAndTemplateInputs\n\t\twhile (this.stream.peek().isNotType(Token.EOS)) {\n\t\t\tthis.parseTemplateInput() || this.parseDirectiveAndTemplateInputs();\n\t\t\tthis.consumeSemicolonOrComma();\n\t\t}\n\t}\n\tprotected consume(token: Token) {\n\t\tif (this.stream.next().isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t}\n\tprotected check(token: Token): boolean {\n\t\tconst peek = this.stream.peek();\n\t\tif (peek.isType(token)) {\n\t\t\tthis.stream.next();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tprotected consumeToList(token: Token, list: TokenExpression[]) {\n\t\tconst next = this.stream.next();\n\t\tif (next.isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t\tlist.push(next);\n\t}\n\n\tprotected consumeIfToken(token: Token, list: TokenExpression[]): boolean {\n\t\tconst next = this.stream.peek();\n\t\tif (next.isNotType(token)) {\n\t\t\treturn false;\n\t\t}\n\t\tlist.push(next);\n\t\tthis.stream.next();\n\t\treturn true;\n\t}\n\n\tprotected isDeclareKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.LET) || peek.isType(Token.CONST) || peek.isType(Token.VAR);\n\t}\n\n\tprotected isIdentifier(): boolean {\n\t\treturn this.stream.peek().isType(Token.IDENTIFIER);\n\t}\n\n\tprotected isAsKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.IDENTIFIER) && (peek.getValue<Identifier>().getName() == 'as');\n\t}\n\n\tprotected consumeAsKeyword() {\n\t\tthis.consume(Token.IDENTIFIER);\n\t}\n\tprotected isSemicolon() {\n\t\treturn this.stream.peek().isType(Token.SEMICOLON);\n\t}\n\tprotected isComma() {\n\t\treturn this.stream.peek().isType(Token.COMMA);\n\t}\n\tprotected consumeSemicolonOrComma() {\n\t\tlet peek = this.stream.peek();\n\t\tif (peek.isType(Token.SEMICOLON) || peek.isType(Token.COMMA)) {\n\t\t\tthis.stream.next();\n\t\t\treturn;\n\t\t}\n\t}\n\tprotected parseTemplateInput() {\n\t\t// let = \"let\" :local \"=\" :export \";\"?\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tlet peek = this.stream.peek();\n\t\t\tconst list: TokenExpression[] = [peek];\n\t\t\tthis.consume(peek.token);\n\t\t\tpeek = this.stream.peek();\n\t\t\tif (Token.isOpenPair(peek.token) && peek.isNotType(Token.LPAREN)) {\n\t\t\t\t// object and array pattern, destructing\n\t\t\t\tthis.stream.readTill(Token.closeOf(peek.token), list);\n\t\t\t} else if (peek.isType(Token.IDENTIFIER)) {\n\t\t\t\tthis.consumeToList(Token.IDENTIFIER, list);\n\t\t\t} else {\n\t\t\t\tthrow new Error(this.stream.createError(`Can't parse let/const/var {IDENTIFIER/ObjectPattern}`));\n\t\t\t}\n\t\t\tif (this.consumeIfToken(Token.ASSIGN, list)) {\n\t\t\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\t\t\t} else {\n\t\t\t\tlist.push(TokenConstant.ASSIGN, TokenConstant.IMPLICIT);\n\t\t\t}\n\t\t\tthis.templateExpressions.push(list);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected parseExpression(inputName: string) {\n\t\tconst list: TokenExpression[] = [];\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\t}\n\n\t/**\n\t * check if the first is\n\t * @returns `boolean`\n\t */\n\tprotected parseDirectiveAndTemplateInputs() {\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tlet inputToken: TokenExpression;\n\t\tif (this.isIdentifier()) {\n\t\t\tinputToken = this.stream.next();\n\t\t} else {\n\t\t\tinputToken = this.stream.next();\n\t\t\tconst identifierName = inputToken.token.getName();\n\t\t\tinputToken = new TokenExpression(Token.IDENTIFIER, new Identifier(identifierName));\n\t\t}\n\n\t\t// only template input\n\t\t// mapping from directive scope(context) to template scope\n\t\tif (this.isAsKeyword()) {\n\t\t\t// as = :export \"as\" :local \";\"?\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input as alias`\n\t\t\t// ==> in template -> alias = input\n\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.check(Token.ASSIGN) || this.check(Token.COLON);\n\n\t\tconst list: TokenExpression[] = [];\n\t\t// keyExp = :key \":\"? :expression (\"as\" :local)? \";\"?\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\n\t\t// mix for directive input and template input\n\t\tif (this.isAsKeyword()) {\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input {x: 7, y: 9} as alias` \n\t\t\t// ==> in directive ->`input = {x: 7, y: 9}`\n\t\t\t// ==> or in template -> let alias = input\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(TokenConstant.LET, aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t}\n\t\tconst inputName = inputToken.getValue<Identifier>().getName() as string;\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\n\t}\n\n\tprivate mapTokenToString(token: TokenExpression): String {\n\t\tif (token.value) {\n\t\t\treturn token.value.toString();\n\t\t}\n\t\treturn token.token.getName();\n\t}\n\n}\n\n"]}
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/core/directive/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOrF,MAAM,aAAa;;AACX,iBAAG,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACrC,mBAAK,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACzC,oBAAM,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC3C,sBAAQ,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;AAC9E,iBAAG,GA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AAC;QACxE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAEhF,CAAC;IAEO,gBAAgB,CAAC,KAAsB;QAC9C,IAAI,KAAK,CAAC,KAAK,EAAE;YAChB,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;SAC9B;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IAC9B,CAAC;CAED","sourcesContent":["import { Identifier, Token, TokenExpression, TokenStream } from '@ibyar/expressions';\n\nexport type DirectiveExpressionType = {\n\ttemplateExpressions: Array<TokenExpression[]>;\n\tdirectiveInputs: Map<string, string>;\n};\n\nclass TokenConstant {\n\tstatic LET = new TokenExpression(Token.LET);\n\tstatic COMMA = new TokenExpression(Token.COMMA);\n\tstatic ASSIGN = new TokenExpression(Token.ASSIGN);\n\tstatic IMPLICIT = new TokenExpression(Token.IDENTIFIER, new Identifier('$implicit'));\n\tstatic EOS = new TokenExpression(Token.EOS);\n}\n\nexport class DirectiveExpressionParser {\n\n\n\tpublic static parse(directiveName: string, expression: string): DirectiveExpressionType {\n\t\tconst stream = TokenStream.getTokenStream(expression);\n\t\tconst parser = new DirectiveExpressionParser(directiveName, stream);\n\t\ttry {\n\t\t\tparser.scan();\n\t\t} catch (error) {\n\t\t\tconsole.error('error parsing template expression', expression, parser, error);\n\t\t}\n\t\treturn parser.getDirectiveExpressionType();\n\t}\n\n\tprotected templateExpressions = new Array<TokenExpression[]>();\n\tprotected directiveInputs = new Map<string, string>();\n\n\tconstructor(protected directiveName: string, protected stream: TokenStream) { }\n\n\tgetDirectiveExpressionType(): DirectiveExpressionType {\n\t\treturn {\n\t\t\ttemplateExpressions: this.templateExpressions,\n\t\t\tdirectiveInputs: this.directiveInputs\n\t\t};\n\t}\n\tscan(): void {\n\t\t// parse 'let/const/var' if found, or switch to expression mode.\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tthis.parseTemplateInput();\n\t\t} else {\n\t\t\t// parse expression, possible ends is semicolon, comma, let and 'EOS'\n\t\t\tthis.parseExpression(this.directiveName);\n\t\t}\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tthis.consumeSemicolonOrComma();\n\n\t\t// parse let and parseDirectiveAndTemplateInputs\n\t\twhile (this.stream.peek().isNotType(Token.EOS)) {\n\t\t\tthis.parseTemplateInput() || this.parseDirectiveAndTemplateInputs();\n\t\t\tthis.consumeSemicolonOrComma();\n\t\t}\n\t}\n\tprotected consume(token: Token) {\n\t\tif (this.stream.next().isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t}\n\tprotected check(token: Token): boolean {\n\t\tconst peek = this.stream.peek();\n\t\tif (peek.isType(token)) {\n\t\t\tthis.stream.next();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tprotected consumeToList(token: Token, list: TokenExpression[]) {\n\t\tconst next = this.stream.next();\n\t\tif (next.isNotType(token)) {\n\t\t\tthrow new Error(this.stream.createError(`Parsing ${JSON.stringify(token)}`));\n\t\t}\n\t\tlist.push(next);\n\t}\n\n\tprotected consumeIfToken(token: Token, list: TokenExpression[]): boolean {\n\t\tconst next = this.stream.peek();\n\t\tif (next.isNotType(token)) {\n\t\t\treturn false;\n\t\t}\n\t\tlist.push(next);\n\t\tthis.stream.next();\n\t\treturn true;\n\t}\n\n\tprotected isDeclareKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.LET) || peek.isType(Token.CONST) || peek.isType(Token.VAR);\n\t}\n\n\tprotected isIdentifier(): boolean {\n\t\treturn this.stream.peek().isType(Token.IDENTIFIER);\n\t}\n\n\tprotected isAsKeyword(): boolean {\n\t\tconst peek = this.stream.peek();\n\t\treturn peek.isType(Token.IDENTIFIER) && (peek.getValue<Identifier>().getName() == 'as');\n\t}\n\n\tprotected consumeAsKeyword() {\n\t\tthis.consume(Token.IDENTIFIER);\n\t}\n\tprotected isSemicolon() {\n\t\treturn this.stream.peek().isType(Token.SEMICOLON);\n\t}\n\tprotected isComma() {\n\t\treturn this.stream.peek().isType(Token.COMMA);\n\t}\n\tprotected consumeSemicolonOrComma() {\n\t\tlet peek = this.stream.peek();\n\t\tif (peek.isType(Token.SEMICOLON) || peek.isType(Token.COMMA)) {\n\t\t\tthis.stream.next();\n\t\t\treturn;\n\t\t}\n\t}\n\tprotected parseTemplateInput() {\n\t\t// let = \"let\" :local \"=\" :export \";\"?\n\t\tif (this.isDeclareKeyword()) {\n\t\t\tlet peek = this.stream.peek();\n\t\t\tconst list: TokenExpression[] = [peek];\n\t\t\tthis.consume(peek.token);\n\t\t\tpeek = this.stream.peek();\n\t\t\tif (Token.isOpenPair(peek.token) && peek.isNotType(Token.LPAREN)) {\n\t\t\t\t// object and array pattern, destructing\n\t\t\t\tthis.stream.readTill(Token.closeOf(peek.token), list);\n\t\t\t} else if (peek.isType(Token.IDENTIFIER)) {\n\t\t\t\tthis.consumeToList(Token.IDENTIFIER, list);\n\t\t\t} else {\n\t\t\t\tthrow new Error(this.stream.createError(`Can't parse let/const/var {IDENTIFIER/ObjectPattern}`));\n\t\t\t}\n\t\t\tif (this.consumeIfToken(Token.ASSIGN, list)) {\n\t\t\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\t\t\t} else {\n\t\t\t\tlist.push(TokenConstant.ASSIGN, TokenConstant.IMPLICIT);\n\t\t\t}\n\t\t\tthis.templateExpressions.push(list);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected parseExpression(inputName: string) {\n\t\tconst list: TokenExpression[] = [];\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.EOS);\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\t}\n\n\t/**\n\t * check if the first is\n\t * @returns `boolean`\n\t */\n\tprotected parseDirectiveAndTemplateInputs() {\n\t\tif (this.stream.peek().isType(Token.EOS)) {\n\t\t\treturn;\n\t\t}\n\t\tlet inputToken: TokenExpression;\n\t\tif (this.isIdentifier()) {\n\t\t\tinputToken = this.stream.next();\n\t\t} else {\n\t\t\tinputToken = this.stream.next();\n\t\t\tconst identifierName = inputToken.token.getName();\n\t\t\tinputToken = new TokenExpression(Token.IDENTIFIER, new Identifier(identifierName));\n\t\t}\n\n\t\t// only template input\n\t\t// mapping from directive scope(context) to template scope\n\t\tif (this.isAsKeyword()) {\n\t\t\t// as = :export \"as\" :local \";\"?\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input as alias`\n\t\t\t// ==> in template -> alias = input\n\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.check(Token.ASSIGN) || this.check(Token.COLON);\n\n\t\tconst list: TokenExpression[] = [];\n\t\t// keyExp = :key \":\"? :expression (\"as\" :local)? \";\"?\n\t\tthis.stream.readTokensConsiderPair(list, Token.SEMICOLON, Token.COMMA, Token.LET, Token.CONST, Token.VAR, Token.EOS);\n\n\t\t// mix for directive input and template input\n\t\tif (this.isAsKeyword()) {\n\t\t\tthis.consumeAsKeyword();\n\t\t\t// rewrite `input {x: 7, y: 9} as alias` \n\t\t\t// ==> in directive ->`input = {x: 7, y: 9}`\n\t\t\t// ==> or in template -> let alias = input\n\t\t\tconst aliasToken = this.stream.next();\n\t\t\tconst aliasList: TokenExpression[] = [];\n\t\t\taliasList.push(TokenConstant.LET, aliasToken, TokenConstant.ASSIGN, inputToken, TokenConstant.EOS);\n\t\t\tthis.templateExpressions.push(aliasList);\n\t\t}\n\t\tconst inputName = inputToken.getValue<Identifier>().getName() as string;\n\t\tthis.directiveInputs.set(inputName, list.map(this.mapTokenToString).join(' '));\n\n\t}\n\n\tprivate mapTokenToString(token: TokenExpression): String {\n\t\tif (token.value) {\n\t\t\treturn token.value.toString();\n\t\t}\n\t\treturn token.token.getName();\n\t}\n\n}\n\n"]}
@@ -7,7 +7,7 @@ export class ElementReactiveScope extends ReactiveScope {
7
7
  super({});
8
8
  this.el = el;
9
9
  this.directiveMap = new Map();
10
- this.context.this = el;
10
+ this._ctx.this = el;
11
11
  }
12
12
  getElement() {
13
13
  return this.el;
@@ -32,7 +32,7 @@ export class ElementReactiveScope extends ReactiveScope {
32
32
  if (directiveRef && directiveRef.modelClass instanceof AttributeDirective) {
33
33
  const directive = new directiveRef.modelClass(this.el);
34
34
  this.directiveMap.set(propertyKey, directive);
35
- this.context[propertyKey] = directive;
35
+ this._ctx[propertyKey] = directive;
36
36
  if (isOnInit(directive)) {
37
37
  directive.onInit();
38
38
  }
@@ -66,7 +66,7 @@ export class ElementReactiveScope extends ReactiveScope {
66
66
  return false;
67
67
  }
68
68
  has(propertyKey) {
69
- if (propertyKey in this.context) {
69
+ if (propertyKey in this._ctx) {
70
70
  return true;
71
71
  }
72
72
  if (this.directiveMap.has(propertyKey)) {
@@ -1 +1 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/core/directive/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgB,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,OAAO,oBAAqB,SAAQ,aAA6B;IAEtE,YAAoB,EAAe;QAClC,KAAK,CAAC,EAAoB,CAAC,CAAC;QADT,OAAE,GAAF,EAAE,C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AI,IAAI,CAAC,OAAO,EAAE;YAChC,OAAO,IAAI,CAAC;SACZ;QACD,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YACvC,OAAO,IAAI,CAAC;SACZ;QACD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE;YACnD,IAAI,WAAW,IAAI,SAAS,EAAE;gBAC7B,OAAO,IAAI,CAAC;aACZ;SACD;QACD,IAAI,qBAAqB,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE;YACpD,OAAO,IAAI,CAAC;SACZ;QACD,IAAI,qBAAqB,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE;YACzD,OAAO,IAAI,CAAC;SACZ;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,QAAQ;QACP,OAAO,oBAAoB,CAAC;IAC7B,CAAC;CACD","sourcesContent":["import { ReactiveScope, ScopeContext } from '@ibyar/expressions';\nimport { TypeOf } from '@ibyar/expressions/api/utils';\nimport { isOnInit } from '../component/lifecycle.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective } from './directive.js';\n\nexport type ElementContext = { this: HTMLElement } & { [key: string]: AttributeDirective | undefined; };\nexport class ElementReactiveScope extends ReactiveScope<ElementContext> {\n\tprivate directiveMap: Map<string, AttributeDirective> = new Map();\n\tconstructor(private el: HTMLElement) {\n\t\tsuper({} as ElementContext);\n\t\tthis.context.this = el;\n\t}\n\tgetElement() {\n\t\treturn this.el;\n\t}\n\tgetDirectives() {\n\t\treturn this.directiveMap;\n\t}\n\tget(propertyKey: PropertyKey): any {\n\t\tif (propertyKey === 'this') {\n\t\t\treturn this.el;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn directive;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.get(directive, propertyKey);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tthis.context[propertyKey as string] = directive;\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn Reflect.get(directive, propertyKey as string);\n\t\t}\n\t\treturn void 0;\n\t}\n\tset(propertyKey: PropertyKey, value: any, receiver?: any): boolean {\n\t\tif (propertyKey in this.el) {\n\t\t\treturn Reflect.set(this.el, propertyKey, value);\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass.prototype instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tconst result = Reflect.set(directive, propertyKey, value);\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\treturn false;\n\t}\n\thas(propertyKey: string): boolean {\n\t\tif (propertyKey in this.context) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tif (ClassRegistryProvider.hasDirective(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (ClassRegistryProvider.directiveHasInput(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tgetClass(): TypeOf<ElementReactiveScope> {\n\t\treturn ElementReactiveScope;\n\t}\n}\n"]}
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../../src/core/directive/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,MAAM,OAAO,oBAAqB,SAAQ,aAA6B;IAEtE,YAAoB,EAAe;QAClC,KAAK,CAAC,EAAoB,CAAC,CAAC;QADT,OAAE,GAAF,EAAE,CAAa;QAD3B,iBAAY,GAAoC,IAAI,GAAG,EAAE,CAAC;QAGjE,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IACrB,CAAC;IACD,UAAU;QACT,OAAO,IAAI,CAAC,EAAE,CAAC;IAChB,CAAC;IACD,aAAa;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IACD,GAAG,CAAC,WAAwB;QAC3B,IAAI,WAAW,KAAK,MAAM,EAAE;YAC3B,OAAO,IAAI,CAAC,EAAE,CAAC;SACf;QACD,IAAI,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAqB,CAAC,EAAE;YACjD,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAqB,CAAE,CAAC;YAChE,OAAO,SAAS,CAAC;SACjB;QACD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,EAAE;YACnD,IAAI,WAAW,IAAI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f } from '@ibyar/expressions/api/utils';\nimport { isOnInit } from '../component/lifecycle.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\nimport { AttributeDirective } from './directive.js';\n\nexport type ElementContext = { this: HTMLElement } & { [key: string]: AttributeDirective | undefined; };\nexport class ElementReactiveScope extends ReactiveScope<ElementContext> {\n\tprivate directiveMap: Map<string, AttributeDirective> = new Map();\n\tconstructor(private el: HTMLElement) {\n\t\tsuper({} as ElementContext);\n\t\tthis._ctx.this = el;\n\t}\n\tgetElement() {\n\t\treturn this.el;\n\t}\n\tgetDirectives() {\n\t\treturn this.directiveMap;\n\t}\n\tget(propertyKey: PropertyKey): any {\n\t\tif (propertyKey === 'this') {\n\t\t\treturn this.el;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn directive;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.get(directive, propertyKey);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tthis._ctx[propertyKey as string] = directive;\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn Reflect.get(directive, propertyKey as string);\n\t\t}\n\t\treturn void 0;\n\t}\n\tset(propertyKey: PropertyKey, value: any, receiver?: any): boolean {\n\t\tif (propertyKey in this.el) {\n\t\t\treturn Reflect.set(this.el, propertyKey, value);\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey as string)) {\n\t\t\tconst directive = this.directiveMap.get(propertyKey as string)!;\n\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn Reflect.set(directive, propertyKey, value);\n\t\t\t}\n\t\t}\n\t\tconst directiveRef = ClassRegistryProvider.getDirectiveRef<any>(propertyKey as string);\n\t\tif (directiveRef && directiveRef.modelClass.prototype instanceof AttributeDirective) {\n\t\t\tconst directive = new directiveRef.modelClass(this.el) as AttributeDirective;\n\t\t\tthis.directiveMap.set(propertyKey as string, directive);\n\t\t\tconst result = Reflect.set(directive, propertyKey, value);\n\t\t\tif (isOnInit(directive)) {\n\t\t\t\tdirective.onInit();\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\treturn false;\n\t}\n\thas(propertyKey: string): boolean {\n\t\tif (propertyKey in this._ctx) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.directiveMap.has(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tfor (const directive of this.directiveMap.values()) {\n\t\t\tif (propertyKey in directive) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tif (ClassRegistryProvider.hasDirective(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\tif (ClassRegistryProvider.directiveHasInput(propertyKey)) {\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tgetClass(): TypeOf<ElementReactiveScope> {\n\t\treturn ElementReactiveScope;\n\t}\n}\n"]}
@@ -14,6 +14,11 @@ declare module '@ibyar/elements' {
14
14
  pipelineNames?: string[];
15
15
  }
16
16
  interface DomStructuralDirectiveNodeUpgrade extends DomStructuralDirectiveNode {
17
+ /**
18
+ * create a new scope for a template and bind the new variables to the directive scope.
19
+ *
20
+ * execution for let-i="index".
21
+ */
17
22
  templateExpressions: ExpressionNode[];
18
23
  }
19
24
  interface DomAttributeDirectiveNodeUpgrade extends DomAttributeDirectiveNode {
@@ -5,7 +5,7 @@ import { DirectiveExpressionParser } from '../directive/parser.js';
5
5
  import { ClassRegistryProvider } from '../providers/provider.js';
6
6
  const ThisTextContent = JavaScriptParser.parseScript('this.textContent');
7
7
  function parseLiveText(text) {
8
- const textExpression = JavaScriptParser.parse(text.value);
8
+ const textExpression = JavaScriptParser.parseScript(text.value);
9
9
  text.expression = new OneWayAssignmentExpression(ThisTextContent, textExpression);
10
10
  text.pipelineNames = getPipelineNames(textExpression);
11
11
  }
@@ -16,6 +16,13 @@ function convertToMemberAccessStyle(source) {
16
16
  }
17
17
  return dashSplits[0] + dashSplits.splice(1).map(s => (s[0].toUpperCase() + s.substring(1))).join('');
18
18
  }
19
+ /**
20
+ * warp js code with `()` if necessary
21
+ *
22
+ * `{name: 'alex'}` will be `({name: 'alex'})`
23
+ *
24
+ * @param params
25
+ */
19
26
  function checkAndValidateObjectSyntax(source) {
20
27
  if (source.startsWith('{')) {
21
28
  return `(${source})`;
@@ -76,6 +83,7 @@ function parseBaseNode(base) {
76
83
  }
77
84
  function parseChild(child) {
78
85
  if (child instanceof DomElementNode) {
86
+ // DomElementNode
79
87
  parseBaseNode(child);
80
88
  parseDomParentNode(child);
81
89
  }
@@ -83,8 +91,10 @@ function parseChild(child) {
83
91
  let expressions = [];
84
92
  child.templateExpressions = expressions;
85
93
  if (child.value) {
94
+ // use shorthand syntax, possible mixed with input and outputs
86
95
  const info = DirectiveExpressionParser.parse(child.name.substring(1), child.value);
87
96
  expressions.push(...info.templateExpressions.map(template => JavaScriptParser.parseScript(template)));
97
+ // <div let-i="index">{{item}}</div>
88
98
  searchForLetAttributes(child, expressions);
89
99
  if (info.directiveInputs.size > 0) {
90
100
  const ref = ClassRegistryProvider.getDirectiveRef(child.name);
@@ -102,6 +112,8 @@ function parseChild(child) {
102
112
  else {
103
113
  searchForLetAttributes(child, expressions);
104
114
  }
115
+ // DomDirectiveNode
116
+ // in case if add input/output support need to handle that here.
105
117
  parseChild(child.node);
106
118
  parseBaseNode(child);
107
119
  }
@@ -1 +1 @@
1
- {"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EAC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AC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACrG,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAqB;IAChD,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAa;IACjD,IAAI,IAAI,YAAY,eAAe,EAAE;QACpC,kBAAkB,CAAC,IAAI,CAAC,CAAC;KACzB;SAAM;QACN,UAAU,CAAC,IAAI,CAAC,CAAC;KACjB;AACF,CAAC","sourcesContent":["import {\n\tBaseNode, createLiveAttribute,\n\tDomStructuralDirectiveNode, DomElementNode, DomNode,\n\tDomFragmentNode, DomParentNode, ElementAttribute,\n\tisLiveTextContent, LiveAttribute, LiveTextContent,\n\tDomStructuralDirectiveNodeUpgrade, DomAttributeDirectiveNode\n} from '@ibyar/elements';\nimport {\n\tExpressionNode, expressionVisitor, Identifier,\n\tJavaScriptParser, LanguageMode, MemberExpression, PipelineExpression\n} from '@ibyar/expressions';\nimport {\n\tBindingAssignment,\n\tOneWayAssignmentExpression,\n\tTwoWayAssignmentExpression\n} from '../binding/binding.expressions.js';\nimport { DirectiveExpressionParser } from '../directive/parser.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\n\ndeclare module '@ibyar/elements' {\n\texport interface ElementAttribute<N, V> {\n\t\texpression: ExpressionNode;\n\t}\n\n\texport interface LiveAttribute {\n\t\texpression: BindingAssignment;\n\t\tpipelineNames?: string[];\n\t}\n\n\texport interface LiveTextContent {\n\t\texpression: OneWayAssignmentExpression;\n\t\tpipelineNames?: string[];\n\t}\n\texport interface DomStructuralDirectiveNodeUpgrade extends DomStructuralDirectiveNode {\n\t\t/**\n\t\t * create a new scope for a template and bind the new variables to the directive scope.\n\t\t * \n\t\t * execution for let-i=\"index\".\n\t\t */\n\t\ttemplateExpressions: ExpressionNode[];\n\t}\n\n\texport interface DomAttributeDirectiveNodeUpgrade extends DomAttributeDirectiveNode {\n\n\t}\n}\n\nconst ThisTextContent = JavaScriptParser.parseScript('this.textContent') as MemberExpression;\nfunction parseLiveText(text: LiveTextContent) {\n\tconst textExpression = JavaScriptParser.parse(text.value);\n\ttext.expression = new OneWayAssignmentExpression(ThisTextContent, textExpression);\n\ttext.pipelineNames = getPipelineNames(textExpression);\n}\n\nfunction convertToMemberAccessStyle(source: string | string[]) {\n\tconst dashSplits = Array.isArray(source) ? source : source.split('-');\n\tif (dashSplits.length === 1) {\n\t\treturn source;\n\t}\n\treturn dashSplits[0] + dashSplits.splice(1).map(s => (s[0].toUpperCase() + s.substring(1))).join('');\n}\n\n/**\n * warp js code with `()` if necessary\n * \n * `{name: 'alex'}` will be `({name: 'alex'})`\n * \n * @param params \n */\nfunction checkAndValidateObjectSyntax(source: string) {\n\tif (source.startsWith('{')) {\n\t\treturn `(${source})`;\n\t}\n\treturn source;\n}\nfunction parseLiveAttribute(attr: LiveAttribute) {\n\tconst elementSource = `this.${convertToMemberAccessStyle(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parseScript(elementSource);\n\tconst modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression\n\t\t&& (modelExpression instanceof MemberExpression || modelExpression instanceof Identifier)) {\n\t\tattr.expression = new TwoWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`${attr.name}=\"${attr.value}\"\" is not a valid MemberExpression or Identifier 'x.y.z'`);\n\t}\n\n}\n\nfunction getPipelineNames(modelExpression: ExpressionNode): string[] | undefined {\n\tconst pipelineNames: string[] = [];\n\texpressionVisitor.visit(modelExpression, (expression, type, control) => {\n\t\tif (type === 'PipelineExpression') {\n\t\t\tconst pipelineName = (expression as PipelineExpression).getRight();\n\t\t\tif (pipelineName instanceof Identifier) {\n\t\t\t\tpipelineNames.push(pipelineName.getName() as string);\n\t\t\t}\n\t\t}\n\t});\n\treturn pipelineNames.length ? pipelineNames : undefined;\n}\n\nfunction parseLiveAttributeUpdateElement(attr: LiveAttribute) {\n\tconst elementSource = `this.${convertToMemberAccessStyle(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parseScript(elementSource);\n\tconst modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression) {\n\t\tattr.expression = new OneWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`${attr.name} is not a valid MemberExpression 'x.y.z'`);\n\t}\n\tattr.pipelineNames = getPipelineNames(modelExpression);\n}\n\nfunction parseOutputExpression(attr: ElementAttribute<string, string>) {\n\tattr.expression = JavaScriptParser.parseScript(attr.value);\n}\n\nfunction parseAttributeDirectives(directive: DomAttributeDirectiveNode) {\n\tdirective.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tdirective.outputs?.forEach(parseOutputExpression);\n\tdirective.twoWayBinding?.forEach(parseLiveAttribute);\n\tdirective.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n}\n\nfunction parseBaseNode(base: BaseNode) {\n\tbase.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.outputs?.forEach(parseOutputExpression);\n\tbase.twoWayBinding?.forEach(parseLiveAttribute);\n\tbase.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.attributeDirectives?.forEach(parseAttributeDirectives);\n}\n\nfunction parseChild(child: DomNode) {\n\tif (child instanceof DomElementNode) {\n\t\t// DomElementNode\n\t\tparseBaseNode(child);\n\t\tparseDomParentNode(child);\n\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\tlet expressions: ExpressionNode[] = [];\n\t\t(child as DomStructuralDirectiveNodeUpgrade).templateExpressions = expressions;\n\t\tif (child.value) {\n\t\t\t// use shorthand syntax, possible mixed with input and outputs\n\t\t\tconst info = DirectiveExpressionParser.parse(child.name.substring(1), child.value);\n\t\t\texpressions.push(...info.templateExpressions.map(template => JavaScriptParser.parseScript(template)));\n\t\t\t// <div let-i=\"index\">{{item}}</div>\n\n\t\t\tsearchForLetAttributes(child, expressions);\n\n\t\t\tif (info.directiveInputs.size > 0) {\n\t\t\t\tconst ref = ClassRegistryProvider.getDirectiveRef(child.name);\n\t\t\t\tif (!ref?.inputs?.length) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tchild.inputs ??= [];\n\t\t\t\tinfo.directiveInputs.forEach((expression, input) => {\n\t\t\t\t\tconst modelName = ref?.inputs.find(i => i.viewAttribute === input)?.modelProperty ?? input;\n\t\t\t\t\tconst attr: LiveAttribute = createLiveAttribute(modelName, expression);\n\t\t\t\t\t(child.inputs ??= []).push(attr);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tsearchForLetAttributes(child, expressions);\n\t\t}\n\t\t// DomDirectiveNode\n\t\t// in case if add input/output support need to handle that here.\n\t\tparseChild(child.node);\n\t\tparseBaseNode(child);\n\t} else if (isLiveTextContent(child)) {\n\t\tparseLiveText(child);\n\t} else if (child instanceof DomFragmentNode) {\n\t\tparseDomParentNode(child);\n\t}\n}\n\nfunction searchForLetAttributes(child: DomStructuralDirectiveNode, expressions: ExpressionNode[]) {\n\tconst templateExpressionsFromInput = child.attributes?.filter(attr => attr.name.startsWith('let-'));\n\ttemplateExpressionsFromInput?.forEach(attr => {\n\t\tchild.attributes!.splice(child.attributes!.indexOf(attr), 1);\n\t\tconst attrName = convertToMemberAccessStyle(attr.name.split('-').slice(1));\n\t\tconst expression = `let ${attrName} = ${(typeof attr.value == 'string') ? attr.value : '$implicit'}`;\n\t\texpressions.push(JavaScriptParser.parseScript(expression));\n\t});\n}\n\nfunction parseDomParentNode(parent: DomParentNode) {\n\tparent.children?.forEach(parseChild);\n}\n\nexport function buildExpressionNodes(node: DomNode) {\n\tif (node instanceof DomFragmentNode) {\n\t\tparseDomParentNode(node);\n\t} else {\n\t\tparseChild(node);\n\t}\n}\n"]}
1
+ {"version":3,"file":"expression.js","sourceRoot":"","sources":["../../../src/core/html/expression.ts"],"names":[],"mappings":"AAAA,OAAO,EACI,mBAAmB,EAC7B,0BAA0B,EAAE,cAAc,EAC1C,eAAe,EACf,iBAAiB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACU,iBAAiB,EAAE,UAAU,EAC7C,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEN,0BAA0B,EAC1B,0BAA0B,EAC1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AA8BjE,MAAM,eAAe,GAAG,gBAAgB,CAAC,WAAW,CAAC,kBAAkB,CAAqB,CAAC;AAC7F,SAAS,aAAa,CAAC,IAAqB;IAC3C,MAAM,cAAc,GAAG,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChE,IAAI,CAAC,UAAU,GAAG,IAAI,0BAA0B,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IAClF,IAAI,CAAC,aAAa,GAAG,gBAAgB,CAAC,cAAc,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,0BAA0B,CAAC,MAAyB;IAC5D,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;QAC5B,OAAO,MAAgB,CAAC;KACxB;IACD,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,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AAC;QAC7D,MAAM,QAAQ,GAAG,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3E,MAAM,UAAU,GAAG,OAAO,QAAQ,MAAM,CAAC,OAAO,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACrG,WAAW,CAAC,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAqB;IAChD,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,IAAa;IACjD,IAAI,IAAI,YAAY,eAAe,EAAE;QACpC,kBAAkB,CAAC,IAAI,CAAC,CAAC;KACzB;SAAM;QACN,UAAU,CAAC,IAAI,CAAC,CAAC;KACjB;AACF,CAAC","sourcesContent":["import {\n\tBaseNode, createLiveAttribute,\n\tDomStructuralDirectiveNode, DomElementNode, DomNode,\n\tDomFragmentNode, DomParentNode, ElementAttribute,\n\tisLiveTextContent, LiveAttribute, LiveTextContent,\n\tDomStructuralDirectiveNodeUpgrade, DomAttributeDirectiveNode\n} from '@ibyar/elements';\nimport {\n\tExpressionNode, expressionVisitor, Identifier,\n\tJavaScriptParser, MemberExpression, PipelineExpression\n} from '@ibyar/expressions';\nimport {\n\tBindingAssignment,\n\tOneWayAssignmentExpression,\n\tTwoWayAssignmentExpression\n} from '../binding/binding.expressions.js';\nimport { DirectiveExpressionParser } from '../directive/parser.js';\nimport { ClassRegistryProvider } from '../providers/provider.js';\n\ndeclare module '@ibyar/elements' {\n\texport interface ElementAttribute<N, V> {\n\t\texpression: ExpressionNode;\n\t}\n\n\texport interface LiveAttribute {\n\t\texpression: BindingAssignment;\n\t\tpipelineNames?: string[];\n\t}\n\n\texport interface LiveTextContent {\n\t\texpression: OneWayAssignmentExpression;\n\t\tpipelineNames?: string[];\n\t}\n\texport interface DomStructuralDirectiveNodeUpgrade extends DomStructuralDirectiveNode {\n\t\t/**\n\t\t * create a new scope for a template and bind the new variables to the directive scope.\n\t\t * \n\t\t * execution for let-i=\"index\".\n\t\t */\n\t\ttemplateExpressions: ExpressionNode[];\n\t}\n\n\texport interface DomAttributeDirectiveNodeUpgrade extends DomAttributeDirectiveNode {\n\n\t}\n}\n\nconst ThisTextContent = JavaScriptParser.parseScript('this.textContent') as MemberExpression;\nfunction parseLiveText(text: LiveTextContent) {\n\tconst textExpression = JavaScriptParser.parseScript(text.value);\n\ttext.expression = new OneWayAssignmentExpression(ThisTextContent, textExpression);\n\ttext.pipelineNames = getPipelineNames(textExpression);\n}\n\nfunction convertToMemberAccessStyle(source: string | string[]): string {\n\tconst dashSplits = Array.isArray(source) ? source : source.split('-');\n\tif (dashSplits.length === 1) {\n\t\treturn source as string;\n\t}\n\treturn dashSplits[0] + dashSplits.splice(1).map(s => (s[0].toUpperCase() + s.substring(1))).join('');\n}\n\n/**\n * warp js code with `()` if necessary\n * \n * `{name: 'alex'}` will be `({name: 'alex'})`\n * \n * @param params \n */\nfunction checkAndValidateObjectSyntax(source: string) {\n\tif (source.startsWith('{')) {\n\t\treturn `(${source})`;\n\t}\n\treturn source;\n}\nfunction parseLiveAttribute(attr: LiveAttribute) {\n\tconst elementSource = `this.${convertToMemberAccessStyle(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parseScript(elementSource);\n\tconst modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression\n\t\t&& (modelExpression instanceof MemberExpression || modelExpression instanceof Identifier)) {\n\t\tattr.expression = new TwoWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`${attr.name}=\"${attr.value}\"\" is not a valid MemberExpression or Identifier 'x.y.z'`);\n\t}\n\n}\n\nfunction getPipelineNames(modelExpression: ExpressionNode): string[] | undefined {\n\tconst pipelineNames: string[] = [];\n\texpressionVisitor.visit(modelExpression, (expression, type, control) => {\n\t\tif (type === 'PipelineExpression') {\n\t\t\tconst pipelineName = (expression as PipelineExpression).getRight();\n\t\t\tif (pipelineName instanceof Identifier) {\n\t\t\t\tpipelineNames.push(pipelineName.getName() as string);\n\t\t\t}\n\t\t}\n\t});\n\treturn pipelineNames.length ? pipelineNames : undefined;\n}\n\nfunction parseLiveAttributeUpdateElement(attr: LiveAttribute) {\n\tconst elementSource = `this.${convertToMemberAccessStyle(attr.name)}`;\n\tconst elementExpression = JavaScriptParser.parseScript(elementSource);\n\tconst modelExpression = JavaScriptParser.parseScript(checkAndValidateObjectSyntax(attr.value));\n\tif (elementExpression instanceof MemberExpression) {\n\t\tattr.expression = new OneWayAssignmentExpression(elementExpression, modelExpression);\n\t} else {\n\t\tconsole.error(`${attr.name} is not a valid MemberExpression 'x.y.z'`);\n\t}\n\tattr.pipelineNames = getPipelineNames(modelExpression);\n}\n\nfunction parseOutputExpression(attr: ElementAttribute<string, string>) {\n\tattr.expression = JavaScriptParser.parseScript(attr.value);\n}\n\nfunction parseAttributeDirectives(directive: DomAttributeDirectiveNode) {\n\tdirective.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tdirective.outputs?.forEach(parseOutputExpression);\n\tdirective.twoWayBinding?.forEach(parseLiveAttribute);\n\tdirective.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n}\n\nfunction parseBaseNode(base: BaseNode) {\n\tbase.inputs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.outputs?.forEach(parseOutputExpression);\n\tbase.twoWayBinding?.forEach(parseLiveAttribute);\n\tbase.templateAttrs?.forEach(parseLiveAttributeUpdateElement);\n\tbase.attributeDirectives?.forEach(parseAttributeDirectives);\n}\n\nfunction parseChild(child: DomNode) {\n\tif (child instanceof DomElementNode) {\n\t\t// DomElementNode\n\t\tparseBaseNode(child);\n\t\tparseDomParentNode(child);\n\t} else if (child instanceof DomStructuralDirectiveNode) {\n\t\tlet expressions: ExpressionNode[] = [];\n\t\t(child as DomStructuralDirectiveNodeUpgrade).templateExpressions = expressions;\n\t\tif (child.value) {\n\t\t\t// use shorthand syntax, possible mixed with input and outputs\n\t\t\tconst info = DirectiveExpressionParser.parse(child.name.substring(1), child.value);\n\t\t\texpressions.push(...info.templateExpressions.map(template => JavaScriptParser.parseScript(template)));\n\t\t\t// <div let-i=\"index\">{{item}}</div>\n\n\t\t\tsearchForLetAttributes(child, expressions);\n\n\t\t\tif (info.directiveInputs.size > 0) {\n\t\t\t\tconst ref = ClassRegistryProvider.getDirectiveRef(child.name);\n\t\t\t\tif (!ref?.inputs?.length) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tchild.inputs ??= [];\n\t\t\t\tinfo.directiveInputs.forEach((expression, input) => {\n\t\t\t\t\tconst modelName = ref?.inputs.find(i => i.viewAttribute === input)?.modelProperty ?? input;\n\t\t\t\t\tconst attr: LiveAttribute = createLiveAttribute(modelName, expression);\n\t\t\t\t\t(child.inputs ??= []).push(attr);\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tsearchForLetAttributes(child, expressions);\n\t\t}\n\t\t// DomDirectiveNode\n\t\t// in case if add input/output support need to handle that here.\n\t\tparseChild(child.node);\n\t\tparseBaseNode(child);\n\t} else if (isLiveTextContent(child)) {\n\t\tparseLiveText(child);\n\t} else if (child instanceof DomFragmentNode) {\n\t\tparseDomParentNode(child);\n\t}\n}\n\nfunction searchForLetAttributes(child: DomStructuralDirectiveNode, expressions: ExpressionNode[]) {\n\tconst templateExpressionsFromInput = child.attributes?.filter(attr => attr.name.startsWith('let-'));\n\ttemplateExpressionsFromInput?.forEach(attr => {\n\t\tchild.attributes!.splice(child.attributes!.indexOf(attr), 1);\n\t\tconst attrName = convertToMemberAccessStyle(attr.name.split('-').slice(1));\n\t\tconst expression = `let ${attrName} = ${(typeof attr.value == 'string') ? attr.value : '$implicit'}`;\n\t\texpressions.push(JavaScriptParser.parseScript(expression));\n\t});\n}\n\nfunction parseDomParentNode(parent: DomParentNode) {\n\tparent.children?.forEach(parseChild);\n}\n\nexport function buildExpressionNodes(node: DomNode) {\n\tif (node instanceof DomFragmentNode) {\n\t\tparseDomParentNode(node);\n\t} else {\n\t\tparseChild(node);\n\t}\n}\n"]}
package/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from './context/stack.js';
8
8
  export * from './linker/view-ref.js';
9
9
  export * from './linker/template-ref.js';
10
10
  export * from './linker/view-container-ref.js';
11
+ export * from './linker/change-detector-ref.js';
11
12
  export * from './directive/directive.js';
12
13
  export * from './pipe/pipe.js';
13
14
  export * from './providers/injector.js';
@@ -19,3 +20,6 @@ export * from './utils/utils.js';
19
20
  export * from './view/mutation.js';
20
21
  export * from './view/render.js';
21
22
  export * from './view/view.js';
23
+ export * from './zone/bootstrap.js';
24
+ export * from './zone/task.js';
25
+ export * from './zone/zone.js';
package/index.js CHANGED
@@ -8,6 +8,7 @@ export * from './context/stack.js';
8
8
  export * from './linker/view-ref.js';
9
9
  export * from './linker/template-ref.js';
10
10
  export * from './linker/view-container-ref.js';
11
+ export * from './linker/change-detector-ref.js';
11
12
  export * from './directive/directive.js';
12
13
  export * from './pipe/pipe.js';
13
14
  export * from './providers/injector.js';
@@ -19,4 +20,7 @@ export * from './utils/utils.js';
19
20
  export * from './view/mutation.js';
20
21
  export * from './view/render.js';
21
22
  export * from './view/view.js';
23
+ export * from './zone/bootstrap.js';
24
+ export * from './zone/task.js';
25
+ export * from './zone/zone.js';
22
26
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,4BAA4B,CAAC;AAE3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAE/C,cAAc,0BAA0B,CAAC;AAEzC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AAExC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC","sourcesContent":["import 'reflect-metadata';\n\nexport * from './annotation/decorators.js';\n\nexport * from './component/component.js';\nexport * from './component/custom-element.js';\nexport * from './component/events.js';\nexport * from './component/lifecycle.js';\n\nexport * from './context/stack.js';\n\nexport * from './linker/view-ref.js';\nexport * from './linker/template-ref.js';\nexport * from './linker/view-container-ref.js';\n\nexport * from './directive/directive.js';\n\nexport * from './pipe/pipe.js';\n\nexport * from './providers/injector.js';\nexport * from './providers/provider.js';\n\nexport * from './utils/elements-util.js';\nexport * from './utils/path.js';\nexport * from './utils/typeof.js';\nexport * from './utils/utils.js';\n\nexport * from './view/mutation.js';\nexport * from './view/render.js';\nexport * from './view/view.js';\n\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,cAAc,4BAA4B,CAAC;AAE3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,0BAA0B,CAAC;AAEzC,cAAc,gBAAgB,CAAC;AAE/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AAExC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC","sourcesContent":["import 'reflect-metadata';\n\nexport * from './annotation/decorators.js';\n\nexport * from './component/component.js';\nexport * from './component/custom-element.js';\nexport * from './component/events.js';\nexport * from './component/lifecycle.js';\n\nexport * from './context/stack.js';\n\nexport * from './linker/view-ref.js';\nexport * from './linker/template-ref.js';\nexport * from './linker/view-container-ref.js';\nexport * from './linker/change-detector-ref.js';\n\nexport * from './directive/directive.js';\n\nexport * from './pipe/pipe.js';\n\nexport * from './providers/injector.js';\nexport * from './providers/provider.js';\n\nexport * from './utils/elements-util.js';\nexport * from './utils/path.js';\nexport * from './utils/typeof.js';\nexport * from './utils/utils.js';\n\nexport * from './view/mutation.js';\nexport * from './view/render.js';\nexport * from './view/view.js';\n\n\nexport * from './zone/bootstrap.js';\nexport * from './zone/task.js';\nexport * from './zone/zone.js';\n"]}
@@ -1,7 +1,30 @@
1
- import { ReactiveScopeControl, ScopeContext } from '@ibyar/expressions';
1
+ import { ReactiveScopeControl, Context } from '@ibyar/expressions';
2
2
  export declare abstract class ChangeDetectorRef {
3
+ /**
4
+ * used when want to update ui-view like, you want to replace an array with another
5
+ * without reflect changes on view until reattached again.
6
+ */
3
7
  abstract detach(): void;
8
+ /**
9
+ * apply all the not emitted changes, and continue emit changes now.
10
+ */
4
11
  abstract reattach(): void;
12
+ /**
13
+ * apply changes now,
14
+ * will not effect the state of the detector wither if attached ot not.
15
+ */
5
16
  abstract markForCheck(): void;
17
+ /**
18
+ * apply change detection
19
+ */
20
+ abstract detectChanges(): void;
21
+ /**
22
+ * throw error if any changes has been made
23
+ */
24
+ abstract checkNoChanges(): void;
6
25
  }
7
- export declare function createChangeDetectorRef(scope: ReactiveScopeControl<ScopeContext>, propertyKey: keyof ScopeContext): ChangeDetectorRef;
26
+ /**
27
+ * create a change Detector Reference by property key.
28
+ */
29
+ export declare function createChangeDetectorRef(scope: ReactiveScopeControl<any>, propertyKey: keyof Context): ChangeDetectorRef;
30
+ export declare function createModelChangeDetectorRef(resolver: () => ReactiveScopeControl<any>): ChangeDetectorRef;
@@ -1,22 +1,10 @@
1
1
  export class ChangeDetectorRef {
2
2
  }
3
- class ChangeDetectorRefImpl extends ChangeDetectorRef {
4
- constructor(changeDetectorRef) {
5
- super();
6
- this.changeDetectorRef = changeDetectorRef;
7
- }
8
- detach() {
9
- this.changeDetectorRef.detach();
10
- }
11
- reattach() {
12
- this.changeDetectorRef.reattach();
13
- }
14
- markForCheck() {
15
- this.changeDetectorRef.markForCheck();
16
- }
17
- }
3
+ /**
4
+ * create a change Detector Reference by property key.
5
+ */
18
6
  export function createChangeDetectorRef(scope, propertyKey) {
19
- const changeDetectorRef = {
7
+ return {
20
8
  detach() {
21
9
  scope.detach();
22
10
  },
@@ -25,8 +13,32 @@ export function createChangeDetectorRef(scope, propertyKey) {
25
13
  },
26
14
  markForCheck() {
27
15
  scope.emitChanges(propertyKey, scope.get(propertyKey));
28
- }
16
+ },
17
+ detectChanges() {
18
+ scope.detectChanges();
19
+ },
20
+ checkNoChanges() {
21
+ scope.checkNoChanges();
22
+ },
23
+ };
24
+ }
25
+ export function createModelChangeDetectorRef(resolver) {
26
+ return {
27
+ detach() {
28
+ resolver().detach();
29
+ },
30
+ reattach() {
31
+ resolver().reattach();
32
+ },
33
+ markForCheck() {
34
+ resolver().detectChanges();
35
+ },
36
+ detectChanges() {
37
+ resolver().detectChanges();
38
+ },
39
+ checkNoChanges() {
40
+ resolver().checkNoChanges();
41
+ },
29
42
  };
30
- return new ChangeDetectorRefImpl(changeDetectorRef);
31
43
  }
32
44
  //# sourceMappingURL=change-detector-ref.js.map