@microsoft/fast-element 2.0.0-beta.9 → 2.0.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 (142) hide show
  1. package/.eslintrc.json +1 -1
  2. package/CHANGELOG.json +518 -0
  3. package/CHANGELOG.md +181 -1
  4. package/README.md +1 -9
  5. package/api-extractor.context.json +14 -0
  6. package/api-extractor.di.json +14 -0
  7. package/dist/context/context.api.json +1068 -0
  8. package/dist/di/di.api.json +4929 -0
  9. package/dist/dts/binding/binding.d.ts +49 -0
  10. package/dist/dts/binding/normalize.d.ts +9 -0
  11. package/dist/dts/binding/one-time.d.ts +11 -0
  12. package/dist/dts/binding/one-way.d.ts +20 -0
  13. package/dist/dts/{templating/binding-signal.d.ts → binding/signal.d.ts} +19 -4
  14. package/dist/dts/{templating/binding-two-way.d.ts → binding/two-way.d.ts} +9 -5
  15. package/dist/dts/components/attributes.d.ts +7 -1
  16. package/dist/dts/components/element-controller.d.ts +104 -8
  17. package/dist/dts/components/element-hydration.d.ts +2 -0
  18. package/dist/dts/components/fast-definitions.d.ts +6 -0
  19. package/dist/dts/components/hydration.d.ts +56 -0
  20. package/dist/dts/components/install-hydration.d.ts +1 -0
  21. package/dist/dts/context.d.ts +29 -15
  22. package/dist/dts/di/di.d.ts +0 -5
  23. package/dist/dts/dom-policy.d.ts +83 -0
  24. package/dist/dts/dom.d.ts +100 -0
  25. package/dist/dts/hydration/target-builder.d.ts +63 -0
  26. package/dist/dts/index.d.ts +33 -26
  27. package/dist/dts/index.rollup.d.ts +0 -1
  28. package/dist/dts/index.rollup.debug.d.ts +0 -1
  29. package/dist/dts/interfaces.d.ts +32 -82
  30. package/dist/dts/metadata.d.ts +6 -5
  31. package/dist/dts/observation/arrays.d.ts +1 -1
  32. package/dist/dts/observation/observable.bench.d.ts +18 -0
  33. package/dist/dts/observation/observable.d.ts +5 -5
  34. package/dist/dts/pending-task.d.ts +19 -7
  35. package/dist/dts/platform.d.ts +11 -2
  36. package/dist/dts/polyfills.d.ts +0 -8
  37. package/dist/dts/styles/css-binding-directive.d.ts +60 -0
  38. package/dist/dts/styles/css.d.ts +9 -7
  39. package/dist/dts/styles/element-styles.d.ts +1 -14
  40. package/dist/dts/styles/host.d.ts +2 -5
  41. package/dist/dts/styles/style-strategy.d.ts +42 -0
  42. package/dist/dts/templating/compiler.d.ts +11 -13
  43. package/dist/dts/templating/{binding.d.ts → html-binding-directive.d.ts} +21 -41
  44. package/dist/dts/templating/html-directive.d.ts +44 -140
  45. package/dist/dts/templating/install-hydratable-view-templates.d.ts +1 -0
  46. package/dist/dts/templating/node-observation.d.ts +11 -1
  47. package/dist/dts/templating/ref.d.ts +4 -0
  48. package/dist/dts/templating/render.bench.d.ts +3 -0
  49. package/dist/dts/templating/render.d.ts +49 -9
  50. package/dist/dts/templating/repeat-basic-reverse.bench.d.ts +3 -0
  51. package/dist/dts/templating/repeat-basic-shift.bench.d.ts +3 -0
  52. package/dist/dts/templating/repeat.d.ts +31 -9
  53. package/dist/dts/templating/template.d.ts +97 -12
  54. package/dist/dts/templating/view.d.ts +146 -29
  55. package/dist/dts/templating/when-basic.bench.d.ts +3 -0
  56. package/dist/dts/templating/when-conditional.bench.d.ts +3 -0
  57. package/dist/dts/templating/when-switch.bench.d.ts +3 -0
  58. package/dist/dts/templating/when.d.ts +3 -1
  59. package/dist/dts/testing/fakes.d.ts +12 -1
  60. package/dist/dts/tsdoc-metadata.json +1 -1
  61. package/dist/dts/utilities.d.ts +55 -1
  62. package/dist/esm/binding/binding.js +18 -0
  63. package/dist/esm/binding/normalize.js +17 -0
  64. package/dist/esm/binding/one-time.js +21 -0
  65. package/dist/esm/binding/one-way.js +30 -0
  66. package/dist/esm/{templating/binding-signal.js → binding/signal.js} +22 -6
  67. package/dist/esm/{templating/binding-two-way.js → binding/two-way.js} +18 -12
  68. package/dist/esm/components/attributes.js +19 -6
  69. package/dist/esm/components/element-controller.js +319 -49
  70. package/dist/esm/components/element-hydration.js +2 -0
  71. package/dist/esm/components/fast-definitions.js +12 -4
  72. package/dist/esm/components/fast-element.js +3 -1
  73. package/dist/esm/components/hydration.js +104 -0
  74. package/dist/esm/components/install-hydration.js +3 -0
  75. package/dist/esm/context.js +26 -4
  76. package/dist/esm/debug.js +8 -2
  77. package/dist/esm/di/di.js +9 -12
  78. package/dist/esm/dom-policy.js +345 -0
  79. package/dist/esm/dom.js +101 -0
  80. package/dist/esm/hydration/target-builder.js +175 -0
  81. package/dist/esm/index.js +34 -25
  82. package/dist/esm/index.rollup.debug.js +3 -1
  83. package/dist/esm/index.rollup.js +3 -1
  84. package/dist/esm/interfaces.js +51 -3
  85. package/dist/esm/metadata.js +11 -8
  86. package/dist/esm/observation/arrays.js +1 -1
  87. package/dist/esm/observation/observable.bench.js +79 -0
  88. package/dist/esm/observation/observable.js +20 -15
  89. package/dist/esm/observation/update-queue.js +2 -2
  90. package/dist/esm/pending-task.js +13 -1
  91. package/dist/esm/platform.js +12 -2
  92. package/dist/esm/polyfills.js +3 -61
  93. package/dist/esm/styles/css-binding-directive.js +76 -0
  94. package/dist/esm/styles/css.js +14 -7
  95. package/dist/esm/styles/element-styles.js +0 -33
  96. package/dist/esm/styles/style-strategy.js +1 -0
  97. package/dist/esm/templating/children.js +8 -4
  98. package/dist/esm/templating/compiler.js +37 -44
  99. package/dist/esm/templating/html-binding-directive.js +218 -0
  100. package/dist/esm/templating/html-directive.js +25 -152
  101. package/dist/esm/templating/install-hydratable-view-templates.js +17 -0
  102. package/dist/esm/templating/node-observation.js +14 -8
  103. package/dist/esm/templating/ref.js +1 -1
  104. package/dist/esm/templating/render.bench.js +56 -0
  105. package/dist/esm/templating/render.js +74 -30
  106. package/dist/esm/templating/repeat-basic-reverse.bench.js +43 -0
  107. package/dist/esm/templating/repeat-basic-shift.bench.js +43 -0
  108. package/dist/esm/templating/repeat.js +116 -17
  109. package/dist/esm/templating/template.js +135 -60
  110. package/dist/esm/templating/view.js +254 -34
  111. package/dist/esm/templating/when-basic.bench.js +36 -0
  112. package/dist/esm/templating/when-conditional.bench.js +39 -0
  113. package/dist/esm/templating/when-switch.bench.js +68 -0
  114. package/dist/esm/templating/when.js +12 -5
  115. package/dist/esm/testing/fakes.js +32 -1
  116. package/dist/esm/testing/fixture.js +1 -1
  117. package/dist/esm/utilities.js +97 -1
  118. package/dist/fast-element.api.json +9789 -5667
  119. package/dist/fast-element.d.ts +813 -2392
  120. package/dist/fast-element.debug.js +2788 -974
  121. package/dist/fast-element.debug.min.js +3 -1
  122. package/dist/fast-element.js +2641 -833
  123. package/dist/fast-element.min.js +3 -1
  124. package/dist/fast-element.untrimmed.d.ts +662 -314
  125. package/docs/{api-report.md → api-report.api.md} +238 -151
  126. package/docs/context/api-report.api.md +69 -0
  127. package/docs/di/api-report.api.md +315 -0
  128. package/karma.conf.cjs +2 -1
  129. package/package.json +59 -47
  130. package/scripts/run-api-extractor.js +51 -0
  131. package/scripts/run-benchmarks.js +46 -0
  132. package/tensile.config.js +12 -0
  133. package/dist/dts/templating/dom.d.ts +0 -41
  134. package/dist/esm/templating/binding.js +0 -282
  135. package/dist/esm/templating/dom.js +0 -49
  136. package/docs/guide/declaring-templates.md +0 -230
  137. package/docs/guide/defining-elements.md +0 -214
  138. package/docs/guide/leveraging-css.md +0 -253
  139. package/docs/guide/next-steps.md +0 -13
  140. package/docs/guide/observables-and-state.md +0 -213
  141. package/docs/guide/using-directives.md +0 -576
  142. package/docs/guide/working-with-shadow-dom.md +0 -296
@@ -1,5 +1,12 @@
1
+ import type { Expression } from "../observation/observable.js";
2
+ import { Binding } from "../binding/binding.js";
1
3
  import { CSSDirective } from "./css-directive.js";
2
4
  import { ComposableStyles, ElementStyles } from "./element-styles.js";
5
+ /**
6
+ * Represents the types of values that can be interpolated into a template.
7
+ * @public
8
+ */
9
+ export declare type CSSValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | ComposableStyles | CSSDirective;
3
10
  /**
4
11
  * Transforms a template literal string into styles.
5
12
  * @param strings - The string fragments that are interpolated with the values.
@@ -9,14 +16,14 @@ import { ComposableStyles, ElementStyles } from "./element-styles.js";
9
16
  * Use the .partial method to create partial CSS fragments.
10
17
  * @public
11
18
  */
12
- export declare type CSSTemplateTag = ((strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]) => ElementStyles) & {
19
+ export declare type CSSTemplateTag = (<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: CSSValue<TSource, TParent>[]) => ElementStyles) & {
13
20
  /**
14
21
  * Transforms a template literal string into partial CSS.
15
22
  * @param strings - The string fragments that are interpolated with the values.
16
23
  * @param values - The values that are interpolated with the string fragments.
17
24
  * @public
18
25
  */
19
- partial(strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]): CSSDirective;
26
+ partial<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: CSSValue<TSource, TParent>[]): CSSDirective;
20
27
  };
21
28
  /**
22
29
  * Transforms a template literal string into styles.
@@ -27,8 +34,3 @@ export declare type CSSTemplateTag = ((strings: TemplateStringsArray, ...values:
27
34
  * @public
28
35
  */
29
36
  export declare const css: CSSTemplateTag;
30
- /**
31
- * @deprecated Use css.partial instead.
32
- * @public
33
- */
34
- export declare const cssPartial: (strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]) => CSSDirective;
@@ -1,4 +1,4 @@
1
- import { StyleStrategy, StyleTarget } from "../interfaces.js";
1
+ import type { StyleStrategy, StyleTarget } from "./style-strategy.js";
2
2
  import type { HostBehavior } from "./host.js";
3
3
  /**
4
4
  * Represents styles that can be composed into the ShadowDOM of a custom element.
@@ -69,16 +69,3 @@ export declare class ElementStyles {
69
69
  */
70
70
  static readonly supportsAdoptedStyleSheets: boolean;
71
71
  }
72
- /**
73
- * https://wicg.github.io/construct-stylesheets/
74
- * https://developers.google.com/web/updates/2019/02/constructable-stylesheets
75
- *
76
- * @internal
77
- */
78
- export declare class AdoptedStyleSheetsStrategy implements StyleStrategy {
79
- /** @internal */
80
- readonly sheets: CSSStyleSheet[];
81
- constructor(styles: (string | CSSStyleSheet)[]);
82
- addStylesTo(target: StyleTarget): void;
83
- removeStylesFrom(target: StyleTarget): void;
84
- }
@@ -1,14 +1,11 @@
1
+ import type { ExpressionController } from "../observation/observable.js";
1
2
  import type { ElementStyles } from "./element-styles.js";
2
3
  /**
3
4
  * Controls the lifecycle and context of behaviors and styles
4
5
  * associated with a component host.
5
6
  * @public
6
7
  */
7
- export interface HostController<TSource = any> {
8
- /**
9
- * The component source.
10
- */
11
- readonly source: TSource;
8
+ export interface HostController<TSource = any> extends ExpressionController<TSource> {
12
9
  /**
13
10
  * Indicates whether the host is connected or not.
14
11
  */
@@ -0,0 +1,42 @@
1
+ /**
2
+ * A node that can be targeted by styles.
3
+ * @public
4
+ */
5
+ export interface StyleTarget extends Pick<Node, "getRootNode"> {
6
+ /**
7
+ * Stylesheets to be adopted by the node.
8
+ */
9
+ adoptedStyleSheets?: CSSStyleSheet[];
10
+ /**
11
+ * Adds styles to the target by appending the styles.
12
+ * @param styles - The styles element to add.
13
+ */
14
+ append(styles: HTMLStyleElement): void;
15
+ /**
16
+ * Removes styles from the target.
17
+ * @param styles - The styles element to remove.
18
+ */
19
+ removeChild(styles: HTMLStyleElement): void;
20
+ /**
21
+ * Returns all element descendants of node that match selectors.
22
+ * @param selectors - The CSS selector to use for the query.
23
+ */
24
+ querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
25
+ }
26
+ /**
27
+ * Implemented to provide specific behavior when adding/removing styles
28
+ * for elements.
29
+ * @public
30
+ */
31
+ export interface StyleStrategy {
32
+ /**
33
+ * Adds styles to the target.
34
+ * @param target - The target to add the styles to.
35
+ */
36
+ addStylesTo(target: StyleTarget): void;
37
+ /**
38
+ * Removes styles from the target.
39
+ * @param target - The target to remove the styles from.
40
+ */
41
+ removeStylesFrom(target: StyleTarget): void;
42
+ }
@@ -1,4 +1,4 @@
1
- import { TrustedTypesPolicy } from "../interfaces.js";
1
+ import { DOMPolicy } from "../dom.js";
2
2
  import { ViewBehaviorFactory } from "./html-directive.js";
3
3
  import type { HTMLTemplateCompilationResult as TemplateCompilationResult } from "./template.js";
4
4
  /**
@@ -14,32 +14,29 @@ html: string | HTMLTemplateElement,
14
14
  /**
15
15
  * The behavior factories used within the html that is being compiled.
16
16
  */
17
- factories: Record<string, ViewBehaviorFactory>) => TemplateCompilationResult;
17
+ factories: Record<string, ViewBehaviorFactory>,
18
+ /**
19
+ * The security policy to compile the html with.
20
+ */
21
+ policy: DOMPolicy) => TemplateCompilationResult;
18
22
  /**
19
23
  * Common APIs related to compilation.
20
24
  * @public
21
25
  */
22
26
  export declare const Compiler: {
23
- /**
24
- * Sets the HTML trusted types policy used by the compiler.
25
- * @param policy - The policy to set for HTML.
26
- * @remarks
27
- * This API can only be called once, for security reasons. It should be
28
- * called by the application developer at the start of their program.
29
- */
30
- setHTMLPolicy(policy: TrustedTypesPolicy): void;
31
27
  /**
32
28
  * Compiles a template and associated directives into a compilation
33
29
  * result which can be used to create views.
34
30
  * @param html - The html string or template element to compile.
35
- * @param directives - The directives referenced by the template.
31
+ * @param factories - The behavior factories referenced by the template.
32
+ * @param policy - The security policy to compile the html with.
36
33
  * @remarks
37
34
  * The template that is provided for compilation is altered in-place
38
35
  * and cannot be compiled again. If the original template must be preserved,
39
36
  * it is recommended that you clone the original and pass the clone to this API.
40
37
  * @public
41
38
  */
42
- compile<TSource = any, TParent = any>(html: string | HTMLTemplateElement, directives: Record<string, ViewBehaviorFactory>): TemplateCompilationResult<TSource, TParent>;
39
+ compile<TSource = any, TParent = any>(html: string | HTMLTemplateElement, factories: Record<string, ViewBehaviorFactory>, policy?: DOMPolicy): TemplateCompilationResult<TSource, TParent>;
43
40
  /**
44
41
  * Sets the default compilation strategy that will be used by the ViewTemplate whenever
45
42
  * it needs to compile a view preprocessed with the html template function.
@@ -50,7 +47,8 @@ export declare const Compiler: {
50
47
  * Aggregates an array of strings and directives into a single directive.
51
48
  * @param parts - A heterogeneous array of static strings interspersed with
52
49
  * directives.
50
+ * @param policy - The security policy to use with the aggregated bindings.
53
51
  * @returns A single inline directive that aggregates the behavior of all the parts.
54
52
  */
55
- aggregate(parts: (string | ViewBehaviorFactory)[]): ViewBehaviorFactory;
53
+ aggregate(parts: (string | ViewBehaviorFactory)[], policy?: DOMPolicy): ViewBehaviorFactory;
56
54
  };
@@ -1,5 +1,7 @@
1
+ import { DOMAspect, DOMPolicy } from "../dom.js";
1
2
  import { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
2
- import { AddViewBehaviorFactory, Aspect, Aspected, Binding, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
3
+ import type { Binding, BindingDirective } from "../binding/binding.js";
4
+ import { AddViewBehaviorFactory, Aspected, HTMLDirective, ViewBehavior, ViewBehaviorFactory, ViewController } from "./html-directive.js";
3
5
  /**
4
6
  * A simple View that can be interpolated into HTML content.
5
7
  * @public
@@ -37,11 +39,17 @@ export interface ContentTemplate {
37
39
  */
38
40
  create(): ContentView;
39
41
  }
42
+ export interface HydratableContentTemplate extends ContentTemplate {
43
+ /**
44
+ * Hydrates a content view from first/last nodes.
45
+ */
46
+ hydrate(first: Node, last: Node): ContentView;
47
+ }
40
48
  /**
41
49
  * A directive that applies bindings.
42
50
  * @public
43
51
  */
44
- export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected {
52
+ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected, BindingDirective {
45
53
  dataBinding: Binding;
46
54
  private data;
47
55
  private updateTarget;
@@ -52,7 +60,15 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
52
60
  /**
53
61
  * The structural id of the DOM node to which the created behavior will apply.
54
62
  */
55
- nodeId: string;
63
+ targetNodeId: string;
64
+ /**
65
+ * The tagname associated with the target node.
66
+ */
67
+ targetTagName: string | null;
68
+ /**
69
+ * The policy that the created behavior must run under.
70
+ */
71
+ policy: DOMPolicy;
56
72
  /**
57
73
  * The original source aspect exactly as represented in markup.
58
74
  */
@@ -64,7 +80,7 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
64
80
  /**
65
81
  * The type of aspect to target.
66
82
  */
67
- aspectType: Aspect;
83
+ aspectType: DOMAspect;
68
84
  /**
69
85
  * Creates an instance of HTMLBindingDirective.
70
86
  * @param dataBinding - The binding configuration to apply.
@@ -80,13 +96,7 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
80
96
  */
81
97
  createBehavior(): ViewBehavior;
82
98
  /** @internal */
83
- bindDefault(controller: ViewController): void;
84
- /** @internal */
85
- bind: (controller: ViewController) => void;
86
- /** @internal */
87
- bindContent(controller: ViewController): void;
88
- /** @internal */
89
- bindEvent(controller: ViewController): void;
99
+ bind(controller: ViewController): void;
90
100
  /** @internal */
91
101
  unbind(controller: ViewController): void;
92
102
  /** @internal */
@@ -94,33 +104,3 @@ export declare class HTMLBindingDirective implements HTMLDirective, ViewBehavior
94
104
  /** @internal */
95
105
  handleChange(binding: Expression, observer: ExpressionObserver): void;
96
106
  }
97
- /**
98
- * Creates an standard binding.
99
- * @param binding - The binding to refresh when changed.
100
- * @param isVolatile - Indicates whether the binding is volatile or not.
101
- * @returns A binding configuration.
102
- * @public
103
- */
104
- export declare function bind<T = any>(binding: Expression<T>, isVolatile?: boolean): Binding<T>;
105
- /**
106
- * Creates a one time binding
107
- * @param binding - The binding to refresh when signaled.
108
- * @returns A binding configuration.
109
- * @public
110
- */
111
- export declare function oneTime<T = any>(binding: Expression<T>): Binding<T>;
112
- /**
113
- * Creates an event listener binding.
114
- * @param binding - The binding to invoke when the event is raised.
115
- * @param options - Event listener options.
116
- * @returns A binding configuration.
117
- * @public
118
- */
119
- export declare function listener<T = any>(binding: Expression<T>, options?: AddEventListenerOptions): Binding<T>;
120
- /**
121
- * Normalizes the input value into a binding.
122
- * @param value - The value to create the default binding for.
123
- * @returns A binding configuration for the provided value.
124
- * @public
125
- */
126
- export declare function normalizeBinding<TSource = any, TReturn = any, TParent = any>(value: Expression<TSource, TReturn, TParent> | Binding<TSource, TReturn, TParent> | {}): Binding<TSource, TReturn, TParent>;
@@ -1,7 +1,7 @@
1
- import type { HostBehavior } from "../index.js";
1
+ import { DOMAspect, DOMPolicy } from "../dom.js";
2
2
  import type { Constructable } from "../interfaces.js";
3
- import type { Subscriber } from "../observation/notifier.js";
4
- import { Expression, ExpressionController, ExpressionObserver } from "../observation/observable.js";
3
+ import type { Binding } from "../binding/binding.js";
4
+ import type { ExpressionController } from "../observation/observable.js";
5
5
  /**
6
6
  * The target nodes available to a behavior.
7
7
  * @public
@@ -19,43 +19,6 @@ export interface ViewController<TSource = any, TParent = any> extends Expression
19
19
  */
20
20
  readonly targets: ViewBehaviorTargets;
21
21
  }
22
- /**
23
- * Bridges between ViewBehaviors and HostBehaviors, enabling a host to
24
- * control ViewBehaviors.
25
- * @public
26
- */
27
- export interface ViewBehaviorOrchestrator<TSource = any, TParent = any> extends ViewController<TSource, TParent>, HostBehavior<TSource> {
28
- /**
29
- *
30
- * @param nodeId - The structural id of the DOM node to which a behavior will apply.
31
- * @param target - The DOM node associated with the id.
32
- */
33
- addTarget(nodeId: string, target: Node): void;
34
- /**
35
- * Adds a behavior.
36
- * @param behavior - The behavior to add.
37
- */
38
- addBehavior(behavior: ViewBehavior): void;
39
- /**
40
- * Adds a behavior factory.
41
- * @param factory - The behavior factory to add.
42
- * @param target - The target the factory will create behaviors for.
43
- */
44
- addBehaviorFactory(factory: ViewBehaviorFactory, target: Node): void;
45
- }
46
- /**
47
- * Bridges between ViewBehaviors and HostBehaviors, enabling a host to
48
- * control ViewBehaviors.
49
- * @public
50
- */
51
- export declare const ViewBehaviorOrchestrator: Readonly<{
52
- /**
53
- * Creates a ViewBehaviorOrchestrator.
54
- * @param source - The source to to associate behaviors with.
55
- * @returns A ViewBehaviorOrchestrator.
56
- */
57
- create<TSource = any, TParent = any>(source: TSource): ViewBehaviorOrchestrator<TSource, TParent>;
58
- }>;
59
22
  /**
60
23
  * Represents an object that can contribute behavior to a view.
61
24
  * @public
@@ -76,16 +39,29 @@ export interface ViewBehaviorFactory {
76
39
  /**
77
40
  * The unique id of the factory.
78
41
  */
79
- id: string;
42
+ id?: string;
80
43
  /**
81
44
  * The structural id of the DOM node to which the created behavior will apply.
82
45
  */
83
- nodeId: string;
46
+ targetNodeId?: string;
47
+ /**
48
+ * The tag name of the DOM node to which the created behavior will apply.
49
+ */
50
+ targetTagName?: string | null;
51
+ /**
52
+ * The policy that the created behavior must run under.
53
+ */
54
+ policy?: DOMPolicy;
84
55
  /**
85
56
  * Creates a behavior.
86
57
  */
87
58
  createBehavior(): ViewBehavior;
88
59
  }
60
+ /**
61
+ * Represents a ViewBehaviorFactory after the compilation process has completed.
62
+ * @public
63
+ */
64
+ export declare type CompiledViewBehaviorFactory = Required<ViewBehaviorFactory>;
89
65
  /**
90
66
  * Used to add behavior factories when constructing templates.
91
67
  * @public
@@ -102,6 +78,28 @@ export interface HTMLDirective {
102
78
  */
103
79
  createHTML(add: AddViewBehaviorFactory): string;
104
80
  }
81
+ /**
82
+ * Represents something that applies to a specific aspect of the DOM.
83
+ * @public
84
+ */
85
+ export interface Aspected {
86
+ /**
87
+ * The original source aspect exactly as represented in markup.
88
+ */
89
+ sourceAspect: string;
90
+ /**
91
+ * The evaluated target aspect, determined after processing the source.
92
+ */
93
+ targetAspect: string;
94
+ /**
95
+ * The type of aspect to target.
96
+ */
97
+ aspectType: DOMAspect;
98
+ /**
99
+ * A binding if one is associated with the aspect.
100
+ */
101
+ dataBinding?: Binding;
102
+ }
105
103
  /**
106
104
  * Represents metadata configuration for an HTMLDirective.
107
105
  * @public
@@ -144,71 +142,6 @@ export declare const HTMLDirective: Readonly<{
144
142
  * @param options - Options that specify the directive's application.
145
143
  */
146
144
  define<TType extends Constructable<HTMLDirective>>(type: TType, options?: PartialHTMLDirectiveDefinition): TType;
147
- }>;
148
- /**
149
- * Decorator: Defines an HTMLDirective.
150
- * @param options - Provides options that specify the directive's application.
151
- * @public
152
- */
153
- export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition): (type: Constructable<HTMLDirective>) => void;
154
- /**
155
- * Captures a binding expression along with related information and capabilities.
156
- *
157
- * @public
158
- */
159
- export declare abstract class Binding<TSource = any, TReturn = any, TParent = any> {
160
- evaluate: Expression<TSource, TReturn, TParent>;
161
- isVolatile: boolean;
162
- /**
163
- * Options associated with the binding.
164
- */
165
- options?: any;
166
- /**
167
- * Creates a binding.
168
- * @param evaluate - Evaluates the binding.
169
- * @param isVolatile - Indicates whether the binding is volatile.
170
- */
171
- constructor(evaluate: Expression<TSource, TReturn, TParent>, isVolatile?: boolean);
172
- /**
173
- * Creates an observer capable of notifying a subscriber when the output of a binding changes.
174
- * @param directive - The HTML Directive to create the observer for.
175
- * @param subscriber - The subscriber to changes in the binding.
176
- */
177
- abstract createObserver(directive: HTMLDirective, subscriber: Subscriber): ExpressionObserver<TSource, TReturn, TParent>;
178
- }
179
- /**
180
- * The type of HTML aspect to target.
181
- * @public
182
- */
183
- export declare const Aspect: Readonly<{
184
- /**
185
- * Not aspected.
186
- */
187
- readonly none: 0;
188
- /**
189
- * An attribute.
190
- */
191
- readonly attribute: 1;
192
- /**
193
- * A boolean attribute.
194
- */
195
- readonly booleanAttribute: 2;
196
- /**
197
- * A property.
198
- */
199
- readonly property: 3;
200
- /**
201
- * Content
202
- */
203
- readonly content: 4;
204
- /**
205
- * A token list.
206
- */
207
- readonly tokenList: 5;
208
- /**
209
- * An event.
210
- */
211
- readonly event: 6;
212
145
  /**
213
146
  *
214
147
  * @param directive - The directive to assign the aspect to.
@@ -216,49 +149,20 @@ export declare const Aspect: Readonly<{
216
149
  * @remarks
217
150
  * If a falsy value is provided, then the content aspect will be assigned.
218
151
  */
219
- readonly assign: (directive: Aspected, value?: string) => void;
152
+ assignAspect(directive: Aspected, value?: string): void;
220
153
  }>;
221
154
  /**
222
- * The type of HTML aspect to target.
223
- * @public
224
- */
225
- export declare type Aspect = typeof Aspect[Exclude<keyof typeof Aspect, "assign" | "none">];
226
- /**
227
- * Represents something that applies to a specific aspect of the DOM.
155
+ * Decorator: Defines an HTMLDirective.
156
+ * @param options - Provides options that specify the directive's application.
228
157
  * @public
229
158
  */
230
- export interface Aspected {
231
- /**
232
- * The original source aspect exactly as represented in markup.
233
- */
234
- sourceAspect: string;
235
- /**
236
- * The evaluated target aspect, determined after processing the source.
237
- */
238
- targetAspect: string;
239
- /**
240
- * The type of aspect to target.
241
- */
242
- aspectType: Aspect;
243
- /**
244
- * A binding if one is associated with the aspect.
245
- */
246
- dataBinding?: Binding;
247
- }
159
+ export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition): (type: Constructable<HTMLDirective>) => void;
248
160
  /**
249
161
  * A base class used for attribute directives that don't need internal state.
250
162
  * @public
251
163
  */
252
164
  export declare abstract class StatelessAttachedAttributeDirective<TOptions> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
253
165
  protected options: TOptions;
254
- /**
255
- * The unique id of the factory.
256
- */
257
- id: string;
258
- /**
259
- * The structural id of the DOM node to which the created behavior will apply.
260
- */
261
- nodeId: string;
262
166
  /**
263
167
  * Creates an instance of RefDirective.
264
168
  * @param options - The options to use in configuring the directive.
@@ -36,7 +36,17 @@ export declare const elements: (selector?: string) => ElementsFilter;
36
36
  * Internally used by the SlottedDirective and the ChildrenDirective.
37
37
  */
38
38
  export declare abstract class NodeObservationDirective<T extends NodeBehaviorOptions> extends StatelessAttachedAttributeDirective<T> {
39
- private sourceProperty;
39
+ private _id;
40
+ private _controllerProperty;
41
+ /**
42
+ * The unique id of the factory.
43
+ */
44
+ get id(): string;
45
+ set id(value: string);
46
+ /**
47
+ * The structural id of the DOM node to which the created behavior will apply.
48
+ */
49
+ targetNodeId: string;
40
50
  /**
41
51
  * Bind this behavior to the source.
42
52
  * @param source - The source to bind to.
@@ -5,6 +5,10 @@ import type { CaptureType } from "./template.js";
5
5
  * @public
6
6
  */
7
7
  export declare class RefDirective extends StatelessAttachedAttributeDirective<string> {
8
+ /**
9
+ * The structural id of the DOM node to which the created behavior will apply.
10
+ */
11
+ targetNodeId: string;
8
12
  /**
9
13
  * Bind this behavior.
10
14
  * @param controller - The view controller that manages the lifecycle of this behavior.
@@ -0,0 +1,3 @@
1
+ declare const itemRenderer: () => HTMLElement;
2
+ export default itemRenderer;
3
+ export { tests } from "@tensile-perf/web-components";