@microsoft/fast-element 2.0.0-beta.17 → 2.0.0-beta.19

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 (59) hide show
  1. package/CHANGELOG.json +36 -0
  2. package/CHANGELOG.md +18 -1
  3. package/dist/dts/dom-policy.d.ts +68 -0
  4. package/dist/dts/dom.d.ts +116 -0
  5. package/dist/dts/index.d.ts +3 -2
  6. package/dist/dts/index.rollup.d.ts +0 -1
  7. package/dist/dts/index.rollup.debug.d.ts +0 -1
  8. package/dist/dts/interfaces.d.ts +24 -31
  9. package/dist/dts/polyfills.d.ts +0 -1
  10. package/dist/dts/templating/binding-signal.d.ts +3 -1
  11. package/dist/dts/templating/binding-two-way.d.ts +3 -1
  12. package/dist/dts/templating/binding.d.ts +16 -5
  13. package/dist/dts/templating/compiler.d.ts +11 -13
  14. package/dist/dts/templating/dangerous-html.d.ts +18 -0
  15. package/dist/dts/templating/html-directive.d.ts +50 -119
  16. package/dist/dts/templating/node-observation.d.ts +11 -1
  17. package/dist/dts/templating/ref.d.ts +4 -0
  18. package/dist/dts/templating/render.d.ts +30 -6
  19. package/dist/dts/templating/repeat.d.ts +1 -5
  20. package/dist/dts/templating/template.d.ts +39 -13
  21. package/dist/dts/templating/view.d.ts +2 -2
  22. package/dist/dts/utilities.d.ts +39 -0
  23. package/dist/esm/components/attributes.js +1 -1
  24. package/dist/esm/components/fast-definitions.js +2 -2
  25. package/dist/esm/debug.js +4 -1
  26. package/dist/esm/dom-policy.js +337 -0
  27. package/dist/esm/dom.js +117 -0
  28. package/dist/esm/index.js +2 -1
  29. package/dist/esm/index.rollup.debug.js +3 -1
  30. package/dist/esm/index.rollup.js +3 -1
  31. package/dist/esm/interfaces.js +45 -0
  32. package/dist/esm/observation/observable.js +3 -3
  33. package/dist/esm/observation/update-queue.js +2 -2
  34. package/dist/esm/platform.js +1 -1
  35. package/dist/esm/polyfills.js +3 -7
  36. package/dist/esm/templating/binding-signal.js +3 -2
  37. package/dist/esm/templating/binding-two-way.js +3 -2
  38. package/dist/esm/templating/binding.js +31 -54
  39. package/dist/esm/templating/compiler.js +31 -38
  40. package/dist/esm/templating/dangerous-html.js +23 -0
  41. package/dist/esm/templating/html-directive.js +38 -135
  42. package/dist/esm/templating/node-observation.js +14 -8
  43. package/dist/esm/templating/ref.js +1 -1
  44. package/dist/esm/templating/render.js +17 -6
  45. package/dist/esm/templating/repeat.js +2 -6
  46. package/dist/esm/templating/template.js +81 -56
  47. package/dist/esm/testing/fixture.js +1 -1
  48. package/dist/esm/utilities.js +68 -0
  49. package/dist/fast-element.api.json +1088 -608
  50. package/dist/fast-element.d.ts +190 -147
  51. package/dist/fast-element.debug.js +756 -388
  52. package/dist/fast-element.debug.min.js +1 -1
  53. package/dist/fast-element.js +727 -362
  54. package/dist/fast-element.min.js +1 -1
  55. package/dist/fast-element.untrimmed.d.ts +190 -147
  56. package/docs/api-report.md +66 -56
  57. package/package.json +5 -1
  58. package/dist/dts/templating/dom.d.ts +0 -41
  59. package/dist/esm/templating/dom.js +0 -49
@@ -1,7 +1,7 @@
1
- import type { HostBehavior } from "../index.js";
1
+ import { DOMAspect, DOMPolicy } from "../dom.js";
2
2
  import { Constructable } from "../interfaces.js";
3
3
  import type { Subscriber } from "../observation/notifier.js";
4
- import { Expression, ExpressionController, ExpressionObserver } from "../observation/observable.js";
4
+ import type { Expression, ExpressionController, ExpressionObserver } 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,6 +142,14 @@ 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;
145
+ /**
146
+ *
147
+ * @param directive - The directive to assign the aspect to.
148
+ * @param value - The value to base the aspect determination on.
149
+ * @remarks
150
+ * If a falsy value is provided, then the content aspect will be assigned.
151
+ */
152
+ assignAspect(directive: Aspected, value?: string): void;
147
153
  }>;
148
154
  /**
149
155
  * Decorator: Defines an HTMLDirective.
@@ -158,6 +164,7 @@ export declare function htmlDirective(options?: PartialHTMLDirectiveDefinition):
158
164
  */
159
165
  export declare abstract class Binding<TSource = any, TReturn = any, TParent = any> {
160
166
  evaluate: Expression<TSource, TReturn, TParent>;
167
+ policy?: DOMPolicy | undefined;
161
168
  isVolatile: boolean;
162
169
  /**
163
170
  * Options associated with the binding.
@@ -166,9 +173,10 @@ export declare abstract class Binding<TSource = any, TReturn = any, TParent = an
166
173
  /**
167
174
  * Creates a binding.
168
175
  * @param evaluate - Evaluates the binding.
176
+ * @param policy - The security policy to associate with this binding.
169
177
  * @param isVolatile - Indicates whether the binding is volatile.
170
178
  */
171
- constructor(evaluate: Expression<TSource, TReturn, TParent>, isVolatile?: boolean);
179
+ constructor(evaluate: Expression<TSource, TReturn, TParent>, policy?: DOMPolicy | undefined, isVolatile?: boolean);
172
180
  /**
173
181
  * Creates an observer capable of notifying a subscriber when the output of a binding changes.
174
182
  * @param directive - The HTML Directive to create the observer for.
@@ -176,89 +184,12 @@ export declare abstract class Binding<TSource = any, TReturn = any, TParent = an
176
184
  */
177
185
  abstract createObserver(directive: HTMLDirective, subscriber: Subscriber): ExpressionObserver<TSource, TReturn, TParent>;
178
186
  }
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
- /**
213
- *
214
- * @param directive - The directive to assign the aspect to.
215
- * @param value - The value to base the aspect determination on.
216
- * @remarks
217
- * If a falsy value is provided, then the content aspect will be assigned.
218
- */
219
- readonly assign: (directive: Aspected, value?: string) => void;
220
- }>;
221
- /**
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.
228
- * @public
229
- */
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
- }
248
187
  /**
249
188
  * A base class used for attribute directives that don't need internal state.
250
189
  * @public
251
190
  */
252
191
  export declare abstract class StatelessAttachedAttributeDirective<TOptions> implements HTMLDirective, ViewBehaviorFactory, ViewBehavior {
253
192
  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
193
  /**
263
194
  * Opts out of JSON stringification.
264
195
  * @internal
@@ -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 controllerProperty;
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.
@@ -1,4 +1,5 @@
1
1
  import type { FASTElement } from "../components/fast-element.js";
2
+ import type { DOMPolicy } from "../dom.js";
2
3
  import { Constructable } from "../interfaces.js";
3
4
  import type { Subscriber } from "../observation/notifier.js";
4
5
  import type { ExecutionContext, Expression, ExpressionObserver } from "../observation/observable.js";
@@ -45,14 +46,10 @@ export declare class RenderDirective<TSource = any> implements HTMLDirective, Vi
45
46
  readonly dataBinding: Binding<TSource>;
46
47
  readonly templateBinding: Binding<TSource, ContentTemplate>;
47
48
  readonly templateBindingDependsOnData: boolean;
48
- /**
49
- * The unique id of the factory.
50
- */
51
- id: string;
52
49
  /**
53
50
  * The structural id of the DOM node to which the created behavior will apply.
54
51
  */
55
- nodeId: string;
52
+ targetNodeId: string;
56
53
  /**
57
54
  * Creates an instance of RenderDirective.
58
55
  * @param dataBinding - A binding expression that returns the data to render.
@@ -123,12 +120,28 @@ export declare type TemplateRenderOptions = CommonRenderOptions & {
123
120
  export declare type BaseElementRenderOptions<TSource = any, TParent = any> = CommonRenderOptions & {
124
121
  /**
125
122
  * Attributes to use when creating the element template.
123
+ * @remarks
124
+ * This API should be used with caution. When providing attributes, if not done properly,
125
+ * you can open up the application to XSS attacks. When using this API, provide a strong
126
+ * DOMPolicy that can properly sanitize and also be sure to manually sanitize attribute
127
+ * values particularly if they can come from user input.
126
128
  */
127
129
  attributes?: Record<string, string | TemplateValue<TSource, TParent>>;
128
130
  /**
129
131
  * Content to use when creating the element template.
132
+ * @remarks
133
+ * This API should be used with caution. When providing content, if not done properly,
134
+ * you can open up the application to XSS attacks. When using this API, provide a strong
135
+ * DOMPolicy that can properly sanitize and also be sure to manually sanitize content
136
+ * particularly if it can come from user input. Prefer passing a template
137
+ * created by the the html tag helper rather than passing a raw string, as that will
138
+ * enable the JS runtime to help secure the static strings.
130
139
  */
131
140
  content?: string | SyntheticViewTemplate;
141
+ /**
142
+ * The DOMPolicy to create the render instruction with.
143
+ */
144
+ policy?: DOMPolicy;
132
145
  };
133
146
  /**
134
147
  * Render options used to specify an element.
@@ -150,7 +163,7 @@ export declare type TagNameRenderOptions<TSource = any, TParent = any> = BaseEle
150
163
  */
151
164
  tagName: string;
152
165
  };
153
- declare function createElementTemplate<TSource = any, TParent = any>(tagName: string, attributes?: Record<string, string | TemplateValue<TSource, TParent>>, content?: string | ContentTemplate): ViewTemplate<TSource, TParent>;
166
+ declare function createElementTemplate<TSource = any, TParent = any>(tagName: string, attributes?: Record<string, string | TemplateValue<TSource, TParent>>, content?: string | ContentTemplate, policy?: DOMPolicy): ViewTemplate<TSource, TParent>;
154
167
  declare function create(options: TagNameRenderOptions): RenderInstruction;
155
168
  declare function create(options: ElementConstructorRenderOptions): RenderInstruction;
156
169
  declare function create(options: TemplateRenderOptions): RenderInstruction;
@@ -175,6 +188,11 @@ export declare const RenderInstruction: Readonly<{
175
188
  /**
176
189
  * Creates a RenderInstruction for a set of options.
177
190
  * @param options - The options to use when creating the RenderInstruction.
191
+ * @remarks
192
+ * This API should be used with caution. When providing attributes or content,
193
+ * if not done properly, you can open up the application to XSS attacks. When using this API,
194
+ * provide a strong DOMPolicy that can properly sanitize and also be sure to manually sanitize
195
+ * content and attribute values particularly if they can come from user input.
178
196
  */
179
197
  create: typeof create;
180
198
  /**
@@ -182,7 +200,13 @@ export declare const RenderInstruction: Readonly<{
182
200
  * @param tagName - The tag name to use when creating the template.
183
201
  * @param attributes - The attributes to apply to the element.
184
202
  * @param content - The content to insert into the element.
203
+ * @param policy - The DOMPolicy to create the template with.
185
204
  * @returns A template based on the provided specifications.
205
+ * @remarks
206
+ * This API should be used with caution. When providing attributes or content,
207
+ * if not done properly, you can open up the application to XSS attacks. When using this API,
208
+ * provide a strong DOMPolicy that can properly sanitize and also be sure to manually sanitize
209
+ * content and attribute values particularly if they can come from user input.
186
210
  */
187
211
  createElementTemplate: typeof createElementTemplate;
188
212
  /**
@@ -72,14 +72,10 @@ export declare class RepeatDirective<TSource = any> implements HTMLDirective, Vi
72
72
  readonly dataBinding: Binding<TSource>;
73
73
  readonly templateBinding: Binding<TSource, SyntheticViewTemplate>;
74
74
  readonly options: RepeatOptions;
75
- /**
76
- * The unique id of the factory.
77
- */
78
- id: string;
79
75
  /**
80
76
  * The structural id of the DOM node to which the created behavior will apply.
81
77
  */
82
- nodeId: string;
78
+ targetNodeId: string;
83
79
  /**
84
80
  * Creates a placeholder string based on the directive's index within the template.
85
81
  * @param index - The index of the directive within the template.
@@ -1,3 +1,4 @@
1
+ import type { DOMPolicy } from "../dom.js";
1
2
  import type { Expression } from "../observation/observable.js";
2
3
  import { Binding, HTMLDirective, ViewBehaviorFactory } from "./html-directive.js";
3
4
  import type { ElementView, HTMLView, SyntheticView } from "./view.js";
@@ -41,11 +42,24 @@ export interface HTMLTemplateCompilationResult<TSource = any, TParent = any> {
41
42
  */
42
43
  createView(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
43
44
  }
45
+ /**
46
+ * A marker interface used to capture types when interpolating Directive helpers
47
+ * into templates.
48
+ * @public
49
+ */
50
+ export interface CaptureType<TSource, TParent> {
51
+ }
52
+ /**
53
+ * Represents the types of values that can be interpolated into a template.
54
+ * @public
55
+ */
56
+ export declare type TemplateValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | HTMLDirective | CaptureType<TSource, TParent>;
44
57
  /**
45
58
  * A template capable of creating HTMLView instances or rendering directly to DOM.
46
59
  * @public
47
60
  */
48
61
  export declare class ViewTemplate<TSource = any, TParent = any> implements ElementViewTemplate<TSource, TParent>, SyntheticViewTemplate<TSource, TParent> {
62
+ private policy?;
49
63
  private result;
50
64
  /**
51
65
  * The html representing what this template will
@@ -60,13 +74,23 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
60
74
  * Creates an instance of ViewTemplate.
61
75
  * @param html - The html representing what this template will instantiate, including placeholders for directives.
62
76
  * @param factories - The directives that will be connected to placeholders in the html.
77
+ * @param policy - The security policy to use when compiling this template.
63
78
  */
64
- constructor(html: string | HTMLTemplateElement, factories: Record<string, ViewBehaviorFactory>);
79
+ constructor(html: string | HTMLTemplateElement, factories?: Record<string, ViewBehaviorFactory>, policy?: DOMPolicy | undefined);
65
80
  /**
66
81
  * Creates an HTMLView instance based on this template definition.
67
82
  * @param hostBindingTarget - The element that host behaviors will be bound to.
68
83
  */
69
84
  create(hostBindingTarget?: Element): HTMLView<TSource, TParent>;
85
+ /**
86
+ * Sets the DOMPolicy for this template.
87
+ * @param policy - The policy to associated with this template.
88
+ * @returns The modified template instance.
89
+ * @remarks
90
+ * The DOMPolicy can only be set once for a template and cannot be
91
+ * set after the template is compiled.
92
+ */
93
+ withPolicy(policy: DOMPolicy): this;
70
94
  /**
71
95
  * Creates an HTMLView from this template, binds it to the source, and then appends it to the host.
72
96
  * @param source - The data source to bind the template to.
@@ -80,19 +104,21 @@ export declare class ViewTemplate<TSource = any, TParent = any> implements Eleme
80
104
  * @internal
81
105
  */
82
106
  toJSON: () => undefined;
107
+ /**
108
+ * Creates a template based on a set of static strings and dynamic values.
109
+ * @param strings - The static strings to create the template with.
110
+ * @param values - The dynamic values to create the template with.
111
+ * @param policy - The DOMPolicy to associated with the template.
112
+ * @returns A ViewTemplate.
113
+ * @remarks
114
+ * This API should not be used directly under normal circumstances because constructing
115
+ * a template in this way, if not done properly, can open up the application to XSS
116
+ * attacks. When using this API, provide a strong DOMPolicy that can properly sanitize
117
+ * and also be sure to manually sanitize all static strings particularly if they can
118
+ * come from user input.
119
+ */
120
+ static create<TSource = any, TParent = any>(strings: string[], values: TemplateValue<TSource, TParent>[], policy?: DOMPolicy): ViewTemplate<TSource, TParent>;
83
121
  }
84
- /**
85
- * A marker interface used to capture types when interpolating Directive helpers
86
- * into templates.
87
- * @public
88
- */
89
- export interface CaptureType<TSource, TParent> {
90
- }
91
- /**
92
- * Represents the types of values that can be interpolated into a template.
93
- * @public
94
- */
95
- export declare type TemplateValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | HTMLDirective | CaptureType<TSource, TParent>;
96
122
  /**
97
123
  * Transforms a template literal string into a ViewTemplate.
98
124
  * @param strings - The string fragments that are interpolated with the values.
@@ -1,6 +1,6 @@
1
1
  import { Disposable } from "../interfaces.js";
2
2
  import { ExecutionContext, SourceLifetime } from "../observation/observable.js";
3
- import type { ViewBehaviorFactory, ViewBehaviorTargets, ViewController } from "./html-directive.js";
3
+ import type { CompiledViewBehaviorFactory, ViewBehaviorTargets, ViewController } from "./html-directive.js";
4
4
  /**
5
5
  * Represents a collection of DOM nodes which can be bound to a data source.
6
6
  * @public
@@ -151,7 +151,7 @@ export declare class HTMLView<TSource = any, TParent = any> implements ElementVi
151
151
  * @param fragment - The html fragment that contains the nodes for this view.
152
152
  * @param behaviors - The behaviors to be applied to this view.
153
153
  */
154
- constructor(fragment: DocumentFragment, factories: ReadonlyArray<ViewBehaviorFactory>, targets: ViewBehaviorTargets);
154
+ constructor(fragment: DocumentFragment, factories: ReadonlyArray<CompiledViewBehaviorFactory>, targets: ViewBehaviorTargets);
155
155
  /**
156
156
  * Appends the view's DOM nodes to the referenced node.
157
157
  * @param node - The parent node to append the view's DOM nodes to.
@@ -1,3 +1,5 @@
1
+ import type { HostBehavior } from "./styles/host.js";
2
+ import type { ViewBehavior, ViewBehaviorFactory, ViewController } from "./templating/html-directive.js";
1
3
  /**
2
4
  * Retrieves the "composed parent" element of a node, ignoring DOM tree boundaries.
3
5
  * When the parent of a node is a shadow-root, it will return the host
@@ -34,3 +36,40 @@ export declare class UnobservableMutationObserver extends MutationObserver {
34
36
  observe(target: Node, options?: MutationObserverInit | undefined): void;
35
37
  unobserve(target: Node): void;
36
38
  }
39
+ /**
40
+ * Bridges between ViewBehaviors and HostBehaviors, enabling a host to
41
+ * control ViewBehaviors.
42
+ * @public
43
+ */
44
+ export interface ViewBehaviorOrchestrator<TSource = any, TParent = any> extends ViewController<TSource, TParent>, HostBehavior<TSource> {
45
+ /**
46
+ *
47
+ * @param nodeId - The structural id of the DOM node to which a behavior will apply.
48
+ * @param target - The DOM node associated with the id.
49
+ */
50
+ addTarget(nodeId: string, target: Node): void;
51
+ /**
52
+ * Adds a behavior.
53
+ * @param behavior - The behavior to add.
54
+ */
55
+ addBehavior(behavior: ViewBehavior): void;
56
+ /**
57
+ * Adds a behavior factory.
58
+ * @param factory - The behavior factory to add.
59
+ * @param target - The target the factory will create behaviors for.
60
+ */
61
+ addBehaviorFactory(factory: ViewBehaviorFactory, target: Node): void;
62
+ }
63
+ /**
64
+ * Bridges between ViewBehaviors and HostBehaviors, enabling a host to
65
+ * control ViewBehaviors.
66
+ * @public
67
+ */
68
+ export declare const ViewBehaviorOrchestrator: Readonly<{
69
+ /**
70
+ * Creates a ViewBehaviorOrchestrator.
71
+ * @param source - The source to to associate behaviors with.
72
+ * @returns A ViewBehaviorOrchestrator.
73
+ */
74
+ create<TSource = any, TParent = any>(source: TSource): ViewBehaviorOrchestrator<TSource, TParent>;
75
+ }>;
@@ -1,7 +1,7 @@
1
1
  import { Observable } from "../observation/observable.js";
2
2
  import { isString } from "../interfaces.js";
3
3
  import { Updates } from "../observation/update-queue.js";
4
- import { DOM } from "../templating/dom.js";
4
+ import { DOM } from "../dom.js";
5
5
  import { createMetadataLocator } from "../platform.js";
6
6
  const booleanMode = "boolean";
7
7
  const reflectMode = "reflect";
@@ -1,4 +1,4 @@
1
- import { isString } from "../interfaces.js";
1
+ import { isString, KernelServiceId } from "../interfaces.js";
2
2
  import { Observable } from "../observation/observable.js";
3
3
  import { createTypeRegistry, FAST } from "../platform.js";
4
4
  import { ElementStyles } from "../styles/element-styles.js";
@@ -6,7 +6,7 @@ import { AttributeDefinition } from "./attributes.js";
6
6
  const defaultShadowOptions = { mode: "open" };
7
7
  const defaultElementOptions = {};
8
8
  const fastElementBaseTypes = new Set();
9
- const fastElementRegistry = FAST.getById(4 /* KernelServiceId.elementRegistry */, () => createTypeRegistry());
9
+ const fastElementRegistry = FAST.getById(KernelServiceId.elementRegistry, () => createTypeRegistry());
10
10
  /**
11
11
  * Defines metadata for a FASTElement.
12
12
  * @public
package/dist/esm/debug.js CHANGED
@@ -9,11 +9,14 @@ if (globalThis.FAST === void 0) {
9
9
  const FAST = globalThis.FAST;
10
10
  const debugMessages = {
11
11
  [1101 /* needsArrayObservation */]: "Must call enableArrayObservation before observing arrays.",
12
- [1201 /* onlySetHTMLPolicyOnce */]: "The HTML policy can only be set once.",
12
+ [1201 /* onlySetDOMPolicyOnce */]: "The DOM Policy can only be set once.",
13
13
  [1202 /* bindingInnerHTMLRequiresTrustedTypes */]: "To bind innerHTML, you must use a TrustedTypesPolicy.",
14
14
  [1203 /* twoWayBindingRequiresObservables */]: "View=>Model update skipped. To use twoWay binding, the target property must be observable.",
15
15
  [1204 /* hostBindingWithoutHost */]: "No host element is present. Cannot bind host with ${name}.",
16
16
  [1205 /* unsupportedBindingBehavior */]: "The requested binding behavior is not supported by the binding engine.",
17
+ [1206 /* directCallToHTMLTagNotAllowed */]: "Calling html`` as a normal function invalidates the security guarantees provided by FAST.",
18
+ [1207 /* onlySetTemplatePolicyOnce */]: "The DOM Policy for an HTML template can only be set once.",
19
+ [1208 /* cannotSetTemplatePolicyAfterCompilation */]: "The DOM Policy cannot be set after a template is compiled.",
17
20
  [1401 /* missingElementDefinition */]: "Missing FASTElement definition.",
18
21
  [1501 /* noRegistrationForContext */]: "No registration for Context/Interface '${name}'.",
19
22
  [1502 /* noFactoryForResolver */]: "Dependency injection resolver for '${key}' returned a null factory.",