@microsoft/fast-element 2.10.4 → 3.0.0-rc.2

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 (211) hide show
  1. package/CHANGELOG.md +52 -2
  2. package/README.md +244 -1
  3. package/dist/arrays/arrays.api.json +2621 -0
  4. package/dist/context/context.api.json +13 -13
  5. package/dist/declarative/declarative.api.json +8483 -0
  6. package/dist/di/di.api.json +16 -16
  7. package/dist/dts/__test__/helpers.d.ts +6 -0
  8. package/dist/dts/array-observer.d.ts +2 -0
  9. package/dist/dts/arrays.d.ts +2 -0
  10. package/dist/dts/attr.d.ts +1 -0
  11. package/dist/dts/binding/binding.d.ts +15 -5
  12. package/dist/dts/binding/one-time.d.ts +1 -1
  13. package/dist/dts/binding/one-way.d.ts +1 -1
  14. package/dist/dts/binding/signal.d.ts +6 -6
  15. package/dist/dts/binding/two-way.d.ts +2 -1
  16. package/dist/dts/binding.d.ts +7 -0
  17. package/dist/dts/components/attributes.d.ts +1 -4
  18. package/dist/dts/components/definition-schema-transforms.d.ts +9 -0
  19. package/dist/dts/components/element-controller.d.ts +80 -114
  20. package/dist/dts/components/element-hydration.d.ts +1 -1
  21. package/dist/dts/components/enable-hydration.d.ts +54 -0
  22. package/dist/dts/components/fast-definitions.d.ts +98 -46
  23. package/dist/dts/components/fast-element.d.ts +43 -16
  24. package/dist/dts/components/hydration-tracker.d.ts +83 -0
  25. package/dist/dts/components/hydration.d.ts +23 -53
  26. package/dist/dts/components/schema.d.ts +205 -0
  27. package/dist/dts/context.d.ts +13 -13
  28. package/dist/dts/css.d.ts +3 -0
  29. package/dist/dts/debug.d.ts +5 -1
  30. package/dist/dts/declarative/attribute-map.d.ts +58 -0
  31. package/dist/dts/declarative/debug.d.ts +4 -0
  32. package/dist/dts/declarative/index.d.ts +14 -0
  33. package/dist/dts/declarative/interfaces.d.ts +8 -0
  34. package/dist/dts/declarative/observer-map-utilities.d.ts +58 -0
  35. package/dist/dts/declarative/observer-map.d.ts +89 -0
  36. package/dist/dts/declarative/runtime.d.ts +5 -0
  37. package/dist/dts/declarative/syntax.d.ts +21 -0
  38. package/dist/dts/declarative/template-bridge.d.ts +33 -0
  39. package/dist/dts/declarative/template-parser.d.ts +98 -0
  40. package/dist/dts/declarative/template.d.ts +10 -0
  41. package/dist/dts/declarative/utilities.d.ts +358 -0
  42. package/dist/dts/di/di.d.ts +7 -7
  43. package/dist/dts/directives/children.d.ts +2 -0
  44. package/dist/dts/directives/node-observation.d.ts +2 -0
  45. package/dist/dts/directives/ref.d.ts +2 -0
  46. package/dist/dts/directives/repeat.d.ts +4 -0
  47. package/dist/dts/directives/slotted.d.ts +2 -0
  48. package/dist/dts/directives/when.d.ts +3 -0
  49. package/dist/dts/dom-policy.d.ts +23 -5
  50. package/dist/dts/dom.d.ts +4 -16
  51. package/dist/dts/html.d.ts +5 -0
  52. package/dist/dts/hydration/diagnostics.d.ts +93 -0
  53. package/dist/dts/hydration/hydration-debugger.d.ts +35 -0
  54. package/dist/dts/hydration/messages.d.ts +62 -0
  55. package/dist/dts/hydration/runtime.d.ts +7 -0
  56. package/dist/dts/hydration/target-builder.d.ts +40 -12
  57. package/dist/dts/hydration.d.ts +18 -0
  58. package/dist/dts/index.d.ts +42 -42
  59. package/dist/dts/index.debug.d.ts +0 -1
  60. package/dist/dts/index.rollup.debug.d.ts +0 -1
  61. package/dist/dts/interfaces.d.ts +2 -49
  62. package/dist/dts/observable.d.ts +3 -6
  63. package/dist/dts/observation/arrays.d.ts +1 -1
  64. package/dist/dts/observation/observable.d.ts +3 -3
  65. package/dist/dts/observation/update-queue.d.ts +1 -1
  66. package/dist/dts/platform.d.ts +45 -8
  67. package/dist/dts/registry.d.ts +1 -0
  68. package/dist/dts/render.d.ts +7 -0
  69. package/dist/dts/schema.d.ts +1 -0
  70. package/dist/dts/state/exports.d.ts +1 -1
  71. package/dist/dts/state/state.d.ts +2 -2
  72. package/dist/dts/styles/css-directive.d.ts +5 -12
  73. package/dist/dts/styles/css.d.ts +5 -7
  74. package/dist/dts/styles/element-styles.d.ts +0 -10
  75. package/dist/dts/styles.d.ts +6 -0
  76. package/dist/dts/templating/compiler.d.ts +1 -1
  77. package/dist/dts/templating/html-binding-directive.d.ts +10 -2
  78. package/dist/dts/templating/html-directive.d.ts +19 -1
  79. package/dist/dts/templating/hydration-view.d.ts +130 -0
  80. package/dist/dts/templating/render.d.ts +1 -1
  81. package/dist/dts/templating/repeat.d.ts +1 -1
  82. package/dist/dts/templating/template.d.ts +15 -7
  83. package/dist/dts/templating/view.d.ts +25 -102
  84. package/dist/dts/templating.d.ts +10 -0
  85. package/dist/dts/testing/exports.d.ts +2 -2
  86. package/dist/dts/testing/fakes.d.ts +4 -4
  87. package/dist/dts/updates.d.ts +1 -0
  88. package/dist/dts/volatile.d.ts +2 -0
  89. package/dist/esm/__test__/helpers.js +22 -0
  90. package/dist/esm/__test__/setup-node.js +18 -0
  91. package/dist/esm/array-observer.js +1 -0
  92. package/dist/esm/arrays.js +1 -0
  93. package/dist/esm/attr.js +1 -0
  94. package/dist/esm/binding/normalize.js +1 -1
  95. package/dist/esm/binding/signal.js +4 -4
  96. package/dist/esm/binding/two-way.js +3 -3
  97. package/dist/esm/binding.js +4 -0
  98. package/dist/esm/components/attributes.js +18 -11
  99. package/dist/esm/components/definition-schema-transforms.js +23 -0
  100. package/dist/esm/components/element-controller.js +206 -270
  101. package/dist/esm/components/element-hydration.js +1 -1
  102. package/dist/esm/components/enable-hydration.js +124 -0
  103. package/dist/esm/components/fast-definitions.js +219 -56
  104. package/dist/esm/components/fast-element.js +18 -27
  105. package/dist/esm/components/hydration-tracker.js +122 -0
  106. package/dist/esm/components/hydration.js +137 -140
  107. package/dist/esm/components/schema.js +253 -0
  108. package/dist/esm/context.js +6 -6
  109. package/dist/esm/css.js +3 -0
  110. package/dist/esm/debug.js +27 -26
  111. package/dist/esm/declarative/attribute-map.js +122 -0
  112. package/dist/esm/declarative/debug.js +4 -0
  113. package/dist/esm/declarative/index.js +4 -0
  114. package/dist/esm/declarative/interfaces.js +9 -0
  115. package/dist/esm/declarative/observer-map-utilities.js +565 -0
  116. package/dist/esm/declarative/observer-map.js +216 -0
  117. package/dist/esm/declarative/runtime.js +14 -0
  118. package/dist/esm/declarative/syntax.js +36 -0
  119. package/dist/esm/declarative/template-bridge.js +160 -0
  120. package/dist/esm/declarative/template-parser.js +306 -0
  121. package/dist/esm/declarative/template.js +143 -0
  122. package/dist/esm/declarative/utilities.js +1069 -0
  123. package/dist/esm/di/di.js +8 -9
  124. package/dist/esm/directives/children.js +1 -0
  125. package/dist/esm/directives/node-observation.js +1 -0
  126. package/dist/esm/directives/ref.js +1 -0
  127. package/dist/esm/directives/repeat.js +1 -0
  128. package/dist/esm/directives/slotted.js +1 -0
  129. package/dist/esm/directives/when.js +1 -0
  130. package/dist/esm/dom-policy.js +35 -6
  131. package/dist/esm/dom.js +1 -1
  132. package/dist/esm/html.js +2 -0
  133. package/dist/esm/hydration/diagnostics.js +50 -0
  134. package/dist/esm/hydration/hydration-debugger.js +112 -0
  135. package/dist/esm/hydration/messages.js +84 -0
  136. package/dist/esm/hydration/runtime.js +33 -0
  137. package/dist/esm/hydration/target-builder.js +144 -91
  138. package/dist/esm/hydration.js +6 -0
  139. package/dist/esm/index.debug.js +2 -1
  140. package/dist/esm/index.js +38 -29
  141. package/dist/esm/index.rollup.debug.js +3 -2
  142. package/dist/esm/index.rollup.js +1 -1
  143. package/dist/esm/interfaces.js +2 -45
  144. package/dist/esm/metadata.js +2 -8
  145. package/dist/esm/observable.js +1 -4
  146. package/dist/esm/observation/arrays.js +1 -1
  147. package/dist/esm/observation/notifier.js +2 -4
  148. package/dist/esm/observation/observable.js +5 -5
  149. package/dist/esm/observation/update-queue.js +47 -58
  150. package/dist/esm/platform.js +31 -30
  151. package/dist/esm/registry.js +1 -0
  152. package/dist/esm/render.js +1 -0
  153. package/dist/esm/schema.js +1 -0
  154. package/dist/esm/state/exports.js +1 -1
  155. package/dist/esm/styles/css-directive.js +1 -2
  156. package/dist/esm/styles/css.js +15 -56
  157. package/dist/esm/styles/element-styles.js +69 -15
  158. package/dist/esm/styles.js +2 -0
  159. package/dist/esm/templating/html-binding-directive.js +11 -9
  160. package/dist/esm/templating/hydration-view.js +228 -0
  161. package/dist/esm/templating/render.js +39 -18
  162. package/dist/esm/templating/repeat.js +69 -33
  163. package/dist/esm/templating/template.js +7 -7
  164. package/dist/esm/templating/view.js +25 -234
  165. package/dist/esm/templating.js +7 -0
  166. package/dist/esm/testing/exports.js +2 -2
  167. package/dist/esm/testing/fixture.js +2 -2
  168. package/dist/esm/testing/timeout.js +2 -2
  169. package/dist/esm/updates.js +1 -0
  170. package/dist/esm/volatile.js +1 -0
  171. package/dist/fast-element.api.json +14389 -11138
  172. package/dist/fast-element.d.ts +3651 -809
  173. package/dist/fast-element.debug.js +5666 -4722
  174. package/dist/fast-element.debug.min.js +2 -2
  175. package/dist/fast-element.js +5394 -4381
  176. package/dist/fast-element.min.js +2 -2
  177. package/dist/fast-element.untrimmed.d.ts +923 -472
  178. package/dist/hydration/hydration.api.json +6460 -0
  179. package/dist/styles/styles.api.json +2672 -0
  180. package/package.json +165 -45
  181. package/ARCHITECTURE_FASTELEMENT.md +0 -63
  182. package/ARCHITECTURE_HTML_TAGGED_TEMPLATE_LITERAL.md +0 -36
  183. package/ARCHITECTURE_INTRO.md +0 -10
  184. package/ARCHITECTURE_OVERVIEW.md +0 -52
  185. package/ARCHITECTURE_UPDATES.md +0 -11
  186. package/CHANGELOG.json +0 -2275
  187. package/DESIGN.md +0 -510
  188. package/api-extractor.context.json +0 -14
  189. package/api-extractor.di.json +0 -14
  190. package/biome.json +0 -4
  191. package/dist/dts/components/install-hydration.d.ts +0 -1
  192. package/dist/dts/pending-task.d.ts +0 -32
  193. package/dist/dts/styles/css-binding-directive.d.ts +0 -60
  194. package/dist/dts/templating/install-hydratable-view-templates.d.ts +0 -1
  195. package/dist/esm/components/install-hydration.js +0 -3
  196. package/dist/esm/pending-task.js +0 -28
  197. package/dist/esm/polyfills.js +0 -60
  198. package/dist/esm/styles/css-binding-directive.js +0 -76
  199. package/dist/esm/templating/install-hydratable-view-templates.js +0 -23
  200. package/docs/ACKNOWLEDGEMENTS.md +0 -12
  201. package/docs/api-report.api.md +0 -1122
  202. package/docs/context/api-report.api.md +0 -69
  203. package/docs/di/api-report.api.md +0 -315
  204. package/docs/fast-element-2-changes.md +0 -15
  205. package/playwright.config.ts +0 -26
  206. package/scripts/run-api-extractor.js +0 -51
  207. package/test/index.html +0 -11
  208. package/test/main.ts +0 -104
  209. package/test/vite.config.ts +0 -19
  210. package/tsconfig.api-extractor.json +0 -6
  211. /package/dist/dts/{polyfills.d.ts → __test__/setup-node.d.ts} +0 -0
@@ -0,0 +1,98 @@
1
+ import type { Schema } from "../components/schema.js";
2
+ import { ViewTemplate } from "../templating/template.js";
3
+ /**
4
+ * The return type for {@link TemplateParser.parse}.
5
+ * @public
6
+ */
7
+ export interface ResolvedStringsAndValues {
8
+ strings: Array<string>;
9
+ values: Array<any>;
10
+ }
11
+ /**
12
+ * Converts declarative HTML template markup into the `strings` and `values`
13
+ * arrays that `ViewTemplate.create()` consumes.
14
+ *
15
+ * This class is intentionally stateless across invocations — all mutable
16
+ * parsing state lives on the call stack or in the `TemplateResolutionContext`.
17
+ *
18
+ * The parsing pipeline is fully synchronous — no promises are allocated
19
+ * during template resolution.
20
+ * @public
21
+ */
22
+ export declare class TemplateParser {
23
+ /**
24
+ * Parse declarative HTML into strings and values for ViewTemplate creation.
25
+ * @param innerHTML - The transformed innerHTML to parse.
26
+ * @param schema - The Schema instance for property tracking.
27
+ * @returns The resolved strings and values.
28
+ */
29
+ parse(innerHTML: string, schema: Schema): ResolvedStringsAndValues;
30
+ /**
31
+ * Create a ViewTemplate from resolved strings and values.
32
+ * @param strings - The strings array.
33
+ * @param values - The interpreted values.
34
+ */
35
+ createTemplate(strings: Array<string>, values: Array<any>): ViewTemplate<any, any>;
36
+ /**
37
+ * Resolve strings and values from an innerHTML string.
38
+ * @param rootPropertyName - The root property name for schema registration.
39
+ * @param innerHTML - The innerHTML.
40
+ * @param context - The template resolution context.
41
+ */
42
+ private resolveStringsAndValues;
43
+ /**
44
+ * Resolve a template directive (when/repeat).
45
+ * @param rootPropertyName - The root property name for schema registration.
46
+ * @param behaviorConfig - The directive behavior configuration object.
47
+ * @param externalValues - The interpreted values from the parent.
48
+ * @param innerHTML - The innerHTML.
49
+ * @param context - The template resolution context.
50
+ */
51
+ private resolveTemplateDirective;
52
+ /**
53
+ * Resolve an attribute directive (children/slotted/ref).
54
+ * @param name - The name of the directive.
55
+ * @param propName - The property name to pass to the directive.
56
+ * @param externalValues - The interpreted values from the parent.
57
+ */
58
+ private resolveAttributeDirective;
59
+ /**
60
+ * Resolve an access binding — shared by content bindings, boolean-attribute
61
+ * fallback, and default attribute bindings.
62
+ * @returns An object with the resolved binding function and the updated rootPropertyName.
63
+ */
64
+ private resolveAccessBinding;
65
+ /**
66
+ * Resolve an event binding (the "\@" aspect).
67
+ * @returns An object with the event binding function and the updated rootPropertyName.
68
+ */
69
+ private resolveEventBinding;
70
+ /**
71
+ * Resolve a content data binding (`{{expression}}` in text content).
72
+ */
73
+ private resolveContentBinding;
74
+ /**
75
+ * Resolve an attribute data binding (`{{expression}}` in an HTML attribute).
76
+ * Dispatches to event, expression, or access binding handlers based on aspect.
77
+ */
78
+ private resolveAttributeBinding;
79
+ /**
80
+ * Resolve an attribute directive binding (`f-children`, `f-slotted`, `f-ref`).
81
+ */
82
+ private resolveAttributeDirectiveBinding;
83
+ /**
84
+ * Dispatcher for data binding resolution. Routes to the appropriate handler
85
+ * based on the binding subtype.
86
+ */
87
+ private resolveDataBinding;
88
+ /**
89
+ * Resolver of the innerHTML string. Finds the next binding or directive
90
+ * in the HTML and dispatches to the appropriate handler.
91
+ * @param rootPropertyName - The root property name for schema registration.
92
+ * @param innerHTML - The innerHTML to parse.
93
+ * @param strings - Accumulator for literal HTML segments and running previous-string.
94
+ * @param values - The values array (accumulates binding functions and directives).
95
+ * @param context - The template resolution context.
96
+ */
97
+ private resolveInnerHTML;
98
+ }
@@ -0,0 +1,10 @@
1
+ import type { FASTElementTemplateResolver, TemplateLifecycleCallbacks } from "../components/fast-definitions.js";
2
+ import type { Constructable } from "../interfaces.js";
3
+ /**
4
+ * Returns a declarative template resolver that waits for the matching
5
+ * `<f-template>` element and resolves it into a concrete `ViewTemplate`.
6
+ *
7
+ * @param callbacks - Optional per-element lifecycle callbacks.
8
+ * @public
9
+ */
10
+ export declare function declarativeTemplate<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(callbacks?: TemplateLifecycleCallbacks): FASTElementTemplateResolver<TType>;
@@ -0,0 +1,358 @@
1
+ import { type JSONSchema, type Schema } from "../components/schema.js";
2
+ import { attributeDirectivePrefix, clientSideCloseExpression, clientSideOpenExpression, closeExpression, eventArgAccessor, executionContextAccessor, openExpression } from "./syntax.js";
3
+ export { assignObservables, assignProxy, deepEqual, deepMerge, findDef, isPlainObject, } from "./observer-map-utilities.js";
4
+ /**
5
+ * Declarative behavior type.
6
+ * @public
7
+ */
8
+ export type BehaviorType = "dataBinding" | "templateDirective";
9
+ /**
10
+ * Declarative attribute directive names.
11
+ * @public
12
+ */
13
+ export type AttributeDirective = "children" | "slotted" | "ref";
14
+ /**
15
+ * Declarative data binding marker type.
16
+ * @public
17
+ */
18
+ export type DataBindingBindingType = "client" | "default" | "unescaped";
19
+ /**
20
+ * Base behavior configuration.
21
+ * @public
22
+ */
23
+ export interface BehaviorConfig {
24
+ type: BehaviorType;
25
+ }
26
+ /**
27
+ * Declarative schema path type.
28
+ * @public
29
+ */
30
+ export type PathType = "access" | "default" | "event" | "repeat";
31
+ /**
32
+ * Content binding behavior configuration.
33
+ * @public
34
+ */
35
+ export interface ContentDataBindingBehaviorConfig extends BaseDataBindingBehaviorConfig {
36
+ subtype: "content";
37
+ }
38
+ /**
39
+ * Attribute binding behavior configuration.
40
+ * @public
41
+ */
42
+ export interface AttributeDataBindingBehaviorConfig extends BaseDataBindingBehaviorConfig {
43
+ subtype: "attribute";
44
+ aspect: "@" | ":" | "?" | null;
45
+ }
46
+ /**
47
+ * Attribute directive binding behavior configuration.
48
+ * @public
49
+ */
50
+ export interface AttributeDirectiveBindingBehaviorConfig extends BaseDataBindingBehaviorConfig {
51
+ subtype: "attributeDirective";
52
+ name: AttributeDirective;
53
+ }
54
+ /**
55
+ * Declarative data binding behavior configuration.
56
+ * @public
57
+ */
58
+ export type DataBindingBehaviorConfig = ContentDataBindingBehaviorConfig | AttributeDataBindingBehaviorConfig | AttributeDirectiveBindingBehaviorConfig;
59
+ /**
60
+ * Base data binding behavior configuration.
61
+ * @public
62
+ */
63
+ export interface BaseDataBindingBehaviorConfig extends BehaviorConfig {
64
+ type: "dataBinding";
65
+ bindingType: DataBindingBindingType;
66
+ openingStartIndex: number;
67
+ openingEndIndex: number;
68
+ closingStartIndex: number;
69
+ closingEndIndex: number;
70
+ }
71
+ /**
72
+ * Declarative template directive names.
73
+ * @public
74
+ */
75
+ export type TemplateDirective = "when" | "repeat";
76
+ /**
77
+ * Template directive behavior configuration.
78
+ * @public
79
+ */
80
+ export interface TemplateDirectiveBehaviorConfig extends BehaviorConfig {
81
+ type: "templateDirective";
82
+ name: TemplateDirective;
83
+ value: string;
84
+ openingTagStartIndex: number;
85
+ openingTagEndIndex: number;
86
+ closingTagStartIndex: number;
87
+ closingTagEndIndex: number;
88
+ }
89
+ /**
90
+ * Map between child component attribute references and custom element names.
91
+ * @public
92
+ */
93
+ export interface ChildrenMap {
94
+ customElementName: string;
95
+ attributeName: string;
96
+ }
97
+ /**
98
+ * Prefix used for execution context paths.
99
+ * @public
100
+ */
101
+ export declare const contextPrefixDot: string;
102
+ export { attributeDirectivePrefix, clientSideCloseExpression, clientSideOpenExpression, closeExpression, eventArgAccessor, executionContextAccessor, openExpression, };
103
+ /**
104
+ * The type of a parsed event handler argument.
105
+ * @public
106
+ */
107
+ export type EventArgType = "event" | "context" | "binding";
108
+ /**
109
+ * A parsed event handler argument descriptor.
110
+ * @public
111
+ */
112
+ export interface ParsedEventArg {
113
+ type: EventArgType;
114
+ /** The raw argument string, present only when `type` is `"binding"`. */
115
+ rawArg?: string;
116
+ }
117
+ /**
118
+ * Parses the arguments string of an event handler binding into an array of
119
+ * typed argument descriptors. Unrecognised tokens are returned as `"binding"`
120
+ * type with their raw string preserved.
121
+ *
122
+ * Special arguments:
123
+ * - `$e` — resolves to the DOM event object
124
+ * - `$c` — resolves to the full execution context object
125
+ *
126
+ * Any other token is treated as a binding path and resolved against the current
127
+ * data source.
128
+ *
129
+ * @param argsString - The raw arguments string from between the parentheses,
130
+ * e.g. `""`, `"$e"`, `"$c"`, or `"$e, $c"`.
131
+ * @returns An array of {@link ParsedEventArg} descriptors.
132
+ * @public
133
+ */
134
+ export declare function parseEventArgs(argsString: string): ParsedEventArg[];
135
+ /**
136
+ * Logical operator tokens.
137
+ * @public
138
+ */
139
+ export declare const LogicalOperator: {
140
+ readonly AND: "&&";
141
+ readonly OR: "||";
142
+ };
143
+ /**
144
+ * Logical operator token.
145
+ * @public
146
+ */
147
+ export type LogicalOperator = (typeof LogicalOperator)[keyof typeof LogicalOperator];
148
+ /**
149
+ * Comparison operator tokens.
150
+ * @public
151
+ */
152
+ export declare const ComparisonOperator: {
153
+ readonly ACCESS: "access";
154
+ readonly EQUALS: "==";
155
+ readonly GREATER_THAN: ">";
156
+ readonly GREATER_THAN_OR_EQUALS: ">=";
157
+ readonly LESS_THAN: "<";
158
+ readonly LESS_THAN_OR_EQUALS: "<=";
159
+ readonly NOT: "!";
160
+ readonly NOT_EQUALS: "!=";
161
+ };
162
+ /**
163
+ * Comparison operator token.
164
+ * @public
165
+ */
166
+ export type ComparisonOperator = (typeof ComparisonOperator)[keyof typeof ComparisonOperator];
167
+ /**
168
+ * Declarative expression operator tokens.
169
+ * @public
170
+ */
171
+ export declare const Operator: {
172
+ readonly AND: "&&";
173
+ readonly OR: "||";
174
+ readonly ACCESS: "access";
175
+ readonly EQUALS: "==";
176
+ readonly GREATER_THAN: ">";
177
+ readonly GREATER_THAN_OR_EQUALS: ">=";
178
+ readonly LESS_THAN: "<";
179
+ readonly LESS_THAN_OR_EQUALS: "<=";
180
+ readonly NOT: "!";
181
+ readonly NOT_EQUALS: "!=";
182
+ };
183
+ /**
184
+ * Declarative expression operator token.
185
+ * @public
186
+ */
187
+ export type Operator = (typeof Operator)[keyof typeof Operator];
188
+ /**
189
+ * Get the index of the next matching tag
190
+ * @param openingTagStartSlice - The slice starting from the opening tag
191
+ * @param openingTag - The opening tag string
192
+ * @param closingTag - The closing tag
193
+ * @param openingTagStartIndex - The opening tag start index derived from the innerHTML
194
+ * @returns index
195
+ * @public
196
+ */
197
+ export declare function getIndexOfNextMatchingTag(openingTagStartSlice: string, openingTag: string, closingTag: string, openingTagStartIndex: number): number;
198
+ /**
199
+ * Get the next behavior
200
+ * @param innerHTML - The innerHTML string to evaluate
201
+ * @param offset - The current offset in the original string.
202
+ * @returns DataBindingBehaviorConfig | DirectiveBehaviorConfig | null - A configuration object or null
203
+ * @public
204
+ */
205
+ export declare function getNextBehavior(innerHTML: string, offset?: number): DataBindingBehaviorConfig | TemplateDirectiveBehaviorConfig | null;
206
+ /**
207
+ * Create a function to resolve a value from an object using a path with dot syntax.
208
+ * e.g. "foo.bar"
209
+ * @param path - The dot syntax path to an objects property.
210
+ * @param contextPath - The current repeat context path.
211
+ * @param level - The current repeat nesting level.
212
+ * @param rootSchema - The root schema for resolving context paths.
213
+ * @returns A function to access the value from a given path.
214
+ * @public
215
+ */
216
+ export declare function pathResolver(path: string, contextPath: string | null, level: number, rootSchema: JSONSchema): (accessibleObject: any, context: any) => any;
217
+ /**
218
+ * Creates a binding resolver and records the binding path in the schema.
219
+ * @param previousString - The previous literal string before the binding.
220
+ * @param rootPropertyName - The current root property name.
221
+ * @param path - The binding path to resolve.
222
+ * @param parentContext - The parent repeat context.
223
+ * @param type - The schema path type.
224
+ * @param schema - The schema to record paths in.
225
+ * @param currentContext - The current repeat context.
226
+ * @param level - The current repeat nesting level.
227
+ * @returns A function that resolves the binding path.
228
+ * @public
229
+ */
230
+ export declare function bindingResolver(previousString: string | null, rootPropertyName: string | null, path: string, parentContext: string | null, type: PathType, schema: Schema, currentContext: string | null, level: number): (accessibleObject: any, context: any) => any;
231
+ /**
232
+ * Creates a resolver for a chained expression and records its paths in the schema.
233
+ * @param rootPropertyName - The current root property name.
234
+ * @param expression - The expression to resolve.
235
+ * @param parentContext - The parent repeat context.
236
+ * @param level - The current repeat nesting level.
237
+ * @param schema - The schema to record paths in.
238
+ * @returns A function that resolves the expression.
239
+ * @public
240
+ */
241
+ export declare function expressionResolver(rootPropertyName: string | null, expression: ChainedExpression, parentContext: string | null, level: number, schema: Schema): (accessibleObject: any, context: any) => any;
242
+ /**
243
+ * Extracts all paths from a ChainedExpression, including nested expressions
244
+ * @param chainedExpression - The chained expression to extract paths from
245
+ * @returns A Set containing all unique paths found in the expression chain
246
+ * @public
247
+ */
248
+ export declare function extractPathsFromChainedExpression(chainedExpression: ChainedExpression): Set<string>;
249
+ /**
250
+ * Declarative expression descriptor.
251
+ * @public
252
+ */
253
+ export interface DeclarativeExpression {
254
+ operator: Operator;
255
+ left: string;
256
+ leftIsValue: boolean | null;
257
+ right: string | boolean | number | null;
258
+ rightIsValue: boolean | null;
259
+ }
260
+ /**
261
+ * Declarative chained expression descriptor.
262
+ * @public
263
+ */
264
+ export interface ChainedExpression {
265
+ operator?: LogicalOperator;
266
+ expression: DeclarativeExpression;
267
+ next?: ChainedExpression;
268
+ }
269
+ /**
270
+ * Gets the expression chain as a configuration object
271
+ * @param value - The binding string value
272
+ * @returns - A configuration object containing information about the expression
273
+ * @public
274
+ */
275
+ export declare function getExpressionChain(value: string): ChainedExpression | void;
276
+ /**
277
+ * This is the transform utility for rationalizing declarative HTML syntax
278
+ * with bindings in the ViewTemplate
279
+ * @param innerHTML - The innerHTML to transform.
280
+ * @param index - The index to start the current slice of HTML to evaluate.
281
+ * @public
282
+ */
283
+ export declare function transformInnerHTML(innerHTML: string, index?: number): string;
284
+ /**
285
+ * Tag name of the HTML element whose contents are auto-escaped to render
286
+ * code samples literally. Inside this element FAST binding delimiters
287
+ * (`{{...}}`, `{{{...}}}`, `{...}`) are neutralised by replacing each
288
+ * `{` / `}` with the HTML numeric character reference `&#123;` /
289
+ * `&#125;` so the literal text is rendered instead of a binding.
290
+ *
291
+ * The escape behaviour is split between the server-side renderer
292
+ * (`escape_code_sample_elements` in `microsoft-fast-build`) and the
293
+ * client-side `<f-template>` parser (`escapeBracesInCodeElements`
294
+ * below):
295
+ *
296
+ * - Curly-brace escape runs in **both** server and client because
297
+ * `&#123;` / `&#125;` are decoded to literal `{` / `}` in the DOM
298
+ * and the `.innerHTML` serializer does not re-encode them — so the
299
+ * server-side escape would otherwise be undone on the client.
300
+ * - Angle brackets of FAST directive tags (`<f-when>`, `</f-when>`,
301
+ * `<f-repeat>`, `</f-repeat>`, case-insensitive) inside this element
302
+ * are escaped on the **server only**. The DOM serializer
303
+ * re-encodes `<` / `>` in text content automatically, so the client
304
+ * never sees raw directive tags inside `<code>` regardless of what
305
+ * the page source contained.
306
+ * - Real HTML elements (`<button>`) and custom elements (`<my-widget>`)
307
+ * inside this element keep their angle brackets and continue to
308
+ * render as live DOM elements; only the brace-binding syntax inside
309
+ * their text and attribute values is neutralised.
310
+ * @public
311
+ */
312
+ export declare const codeElementName = "code";
313
+ /**
314
+ * Preprocess an HTML string by escaping FAST brace characters inside every
315
+ * `<code>` element. Mirrors part of the brace/angle-bracket escaping
316
+ * behaviour of Microsoft WebUI's `webui-press` markdown renderer so that
317
+ * example template snippets inside `<code>` render literally instead of
318
+ * being interpreted as bindings.
319
+ *
320
+ * Nested `<code>` elements are handled via depth tracking. The pass is
321
+ * idempotent because `{` / `}` inside an already-processed `<code>` have
322
+ * been replaced with entities, so a second pass finds nothing to escape.
323
+ *
324
+ * This is the client-side half of a two-stage escape — see the JSDoc on
325
+ * {@link codeElementName} for why only braces are handled here and
326
+ * `<` / `>` are exclusively handled on the server.
327
+ * @public
328
+ */
329
+ export declare function escapeBracesInCodeElements(innerHTML: string): string;
330
+ /**
331
+ * Resolves boolean logic
332
+ * used for f-when and boolean attributes
333
+ * @param rootPropertyName - The current root property name.
334
+ * @param expression - The chained expression to resolve.
335
+ * @param parentContext - The parent repeat context.
336
+ * @param level - The current repeat nesting level.
337
+ * @param schema - The schema to record paths in.
338
+ * @returns - A binding that resolves the chained expression logic
339
+ * @public
340
+ */
341
+ export declare function getBooleanBinding(rootPropertyName: string | null, expression: ChainedExpression, parentContext: string | null, level: number, schema: Schema): (x: boolean, c: any) => any;
342
+ /**
343
+ * Get the root property name
344
+ * @param rootPropertyName - The root property
345
+ * @param path - The dot syntax path
346
+ * @param context - The context created by a repeat
347
+ * @param type - The type of path binding
348
+ * @returns
349
+ * @public
350
+ */
351
+ export declare function getRootPropertyName(rootPropertyName: string | null, path: string, context: null | string, type: PathType): string | null;
352
+ /**
353
+ * Get details of bindings to the attributes of child custom elements
354
+ * @param previousString - The previous string before the binding
355
+ * @returns null, or a custom element name and attribute name
356
+ * @public
357
+ */
358
+ export declare function getChildrenMap(previousString: string | null): ChildrenMap | null;
@@ -390,7 +390,7 @@ export interface InterfaceConfiguration {
390
390
  friendlyName?: string;
391
391
  /**
392
392
  * When true, the dependency will be re-resolved when FASTElement connection changes.
393
- * If the resolved value changes due to connection change, a {@link @microsoft/fast-element#Observable | notification }
393
+ * If the resolved value changes due to connection change, an observable notification
394
394
  * will be emitted for the property, with the previous and next values provided to any subscriber.
395
395
  */
396
396
  respectConnection?: boolean;
@@ -537,7 +537,7 @@ export declare const DI: Readonly<{
537
537
  *
538
538
  * @public
539
539
  */
540
- singleton<T_1 extends Constructable>(target: T_1 & Partial<RegisterSelf<T_1>>, options?: SingletonOptions): T_1 & RegisterSelf<T_1>;
540
+ singleton<T extends Constructable>(target: T & Partial<RegisterSelf<T>>, options?: SingletonOptions): T & RegisterSelf<T>;
541
541
  }>;
542
542
  /**
543
543
  * The key that resolves the dependency injection Container itself.
@@ -827,7 +827,7 @@ export declare const Registration: Readonly<{
827
827
  * @param key - The key to register the singleton under.
828
828
  * @param value - The class to instantiate as a singleton when first requested.
829
829
  */
830
- singleton<T_1 extends Constructable>(key: Key, value: T_1): Registration<InstanceType<T_1>>;
830
+ singleton<T extends Constructable>(key: Key, value: T): Registration<InstanceType<T>>;
831
831
  /**
832
832
  * Creates an instance from a class.
833
833
  * Every time you request this {@link Key} you will get a new instance.
@@ -840,7 +840,7 @@ export declare const Registration: Readonly<{
840
840
  * @param key - The key to register the instance type under.
841
841
  * @param value - The class to instantiate each time the key is requested.
842
842
  */
843
- transient<T_2 extends Constructable>(key: Key, value: T_2): Registration<InstanceType<T_2>>;
843
+ transient<T extends Constructable>(key: Key, value: T): Registration<InstanceType<T>>;
844
844
  /**
845
845
  * Delegates to a callback function to provide the dependency.
846
846
  * Every time you request this {@link Key} the callback will be invoked to provide
@@ -855,7 +855,7 @@ export declare const Registration: Readonly<{
855
855
  * @param key - The key to register the callback for.
856
856
  * @param callback - The function that is expected to return the dependency.
857
857
  */
858
- callback<T_3>(key: Key, callback: ResolveCallback<T_3>): Registration<Resolved<T_3>>;
858
+ callback<T>(key: Key, callback: ResolveCallback<T>): Registration<Resolved<T>>;
859
859
  /**
860
860
  * Delegates to a callback function to provide the dependency and then caches the
861
861
  * dependency for future requests.
@@ -872,7 +872,7 @@ export declare const Registration: Readonly<{
872
872
  * If you pass the same Registration to another container, the same cached value will be used.
873
873
  * Should all references to the resolver returned be removed, the cache will expire.
874
874
  */
875
- cachedCallback<T_4>(key: Key, callback: ResolveCallback<T_4>): Registration<Resolved<T_4>>;
875
+ cachedCallback<T>(key: Key, callback: ResolveCallback<T>): Registration<Resolved<T>>;
876
876
  /**
877
877
  * Creates an alternate {@link Key} to retrieve an instance by.
878
878
  *
@@ -887,7 +887,7 @@ export declare const Registration: Readonly<{
887
887
  * @param originalKey - The original key that has been registered.
888
888
  * @param aliasKey - The alias to the original key.
889
889
  */
890
- aliasTo<T_5>(originalKey: T_5, aliasKey: Key): Registration<Resolved<T_5>>;
890
+ aliasTo<T>(originalKey: T, aliasKey: Key): Registration<Resolved<T>>;
891
891
  }>;
892
892
  /** @internal */
893
893
  export declare function validateKey(key: any): void;
@@ -0,0 +1,2 @@
1
+ export { type ChildListDirectiveOptions, ChildrenDirective, type ChildrenDirectiveOptions, children, type SubtreeDirectiveOptions, } from "../templating/children.js";
2
+ export type { CaptureType } from "../templating/template.js";
@@ -0,0 +1,2 @@
1
+ export { type ElementsFilter, elements, type NodeBehaviorOptions, NodeObservationDirective, } from "../templating/node-observation.js";
2
+ export type { CaptureType } from "../templating/template.js";
@@ -0,0 +1,2 @@
1
+ export { RefDirective, ref } from "../templating/ref.js";
2
+ export type { CaptureType } from "../templating/template.js";
@@ -0,0 +1,4 @@
1
+ export type { Binding } from "../binding/binding.js";
2
+ export type { Expression } from "../observation/observable.js";
3
+ export { RepeatBehavior, RepeatDirective, type RepeatOptions, repeat, } from "../templating/repeat.js";
4
+ export type { CaptureType, ViewTemplate } from "../templating/template.js";
@@ -0,0 +1,2 @@
1
+ export { SlottedDirective, type SlottedDirectiveOptions, slotted, } from "../templating/slotted.js";
2
+ export type { CaptureType } from "../templating/template.js";
@@ -0,0 +1,3 @@
1
+ export type { ExecutionContext, Expression } from "../observation/observable.js";
2
+ export type { CaptureType, SyntheticViewTemplate } from "../templating/template.js";
3
+ export { when } from "../templating/when.js";
@@ -1,5 +1,24 @@
1
- import { DOMAspect, type DOMSink, type DOMPolicy as IDOMPolicy } from "./dom.js";
1
+ import { DOMAspect, type DOMSink } from "./dom.js";
2
2
  import { type TrustedTypesPolicy } from "./interfaces.js";
3
+ /**
4
+ * A policy that controls whether values can be written to DOM sinks.
5
+ * @public
6
+ */
7
+ export interface DOMPolicy {
8
+ /**
9
+ * Creates safe HTML from the provided value.
10
+ * @param value - The source to convert to safe HTML.
11
+ */
12
+ createHTML(value: string): string;
13
+ /**
14
+ * Protects a DOM sink that intends to write to the DOM.
15
+ * @param tagName - The tag name for the element to write to.
16
+ * @param aspect - The aspect of the DOM to write to.
17
+ * @param aspectName - The name of the aspect to write to.
18
+ * @param sink - The sink that is used to write to the DOM.
19
+ */
20
+ protect(tagName: string | null, aspect: DOMAspect, aspectName: string, sink: DOMSink): DOMSink;
21
+ }
3
22
  /**
4
23
  * A specific DOM sink guard for a node aspect.
5
24
  * @public
@@ -72,12 +91,11 @@ export type DOMPolicyOptions = {
72
91
  * A helper for creating DOM policies.
73
92
  * @public
74
93
  */
75
- declare const DOMPolicy: Readonly<{
94
+ export declare const DOMPolicy: Readonly<{
76
95
  /**
77
96
  * Creates a new DOM Policy object.
78
- * @param options The options to use in creating the policy.
97
+ * @param options - The options to use in creating the policy.
79
98
  * @returns The newly created DOMPolicy.
80
99
  */
81
- create(options?: DOMPolicyOptions): Readonly<IDOMPolicy>;
100
+ create(options?: DOMPolicyOptions): Readonly<DOMPolicy>;
82
101
  }>;
83
- export { DOMPolicy };
package/dist/dts/dom.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { DOMPolicy as DOMPolicyDefinition } from "./dom-policy.js";
1
2
  /**
2
3
  * The type of HTML aspect to target.
3
4
  * @public
@@ -46,20 +47,7 @@ export type DOMSink = (target: Node, aspectName: string, value: any, ...args: an
46
47
  * A security policy that FAST can use to interact with the DOM.
47
48
  * @public
48
49
  */
49
- export interface DOMPolicy {
50
- /**
51
- * Creates safe HTML from the provided value.
52
- * @param value - The source to convert to safe HTML.
53
- */
54
- createHTML(value: string): string;
55
- /**
56
- * Protects a DOM sink that intends to write to the DOM.
57
- * @param tagName - The tag name for the element to write to.
58
- * @param aspect - The aspect of the DOM to write to.
59
- * @param aspectName - The name of the aspect to write to.
60
- * @param sink - The sink that is used to write to the DOM.
61
- */
62
- protect(tagName: string | null, aspect: DOMAspect, aspectName: string, sink: DOMSink): DOMSink;
50
+ export interface DOMPolicy extends DOMPolicyDefinition {
63
51
  }
64
52
  /**
65
53
  * Common DOM APIs.
@@ -69,7 +57,7 @@ export declare const DOM: Readonly<{
69
57
  /**
70
58
  * Gets the dom policy used by the templating system.
71
59
  */
72
- readonly policy: DOMPolicy;
60
+ readonly policy: DOMPolicyDefinition;
73
61
  /**
74
62
  * Sets the dom policy used by the templating system.
75
63
  * @param policy - The policy to set.
@@ -77,7 +65,7 @@ export declare const DOM: Readonly<{
77
65
  * This API can only be called once, for security reasons. It should be
78
66
  * called by the application developer at the start of their program.
79
67
  */
80
- setPolicy(value: DOMPolicy): void;
68
+ setPolicy(value: DOMPolicyDefinition): void;
81
69
  /**
82
70
  * Sets an attribute value on an element.
83
71
  * @param element - The element to set the attribute value on.
@@ -0,0 +1,5 @@
1
+ export type { Binding } from "./binding/binding.js";
2
+ export type { DOMPolicy } from "./dom.js";
3
+ export type { Expression } from "./observation/observable.js";
4
+ export { type ElementViewTemplate, type HTMLTemplateCompilationResult, type HTMLTemplateTag, html, InlineTemplateDirective, type SyntheticViewTemplate, type TemplateValue, ViewTemplate, } from "./templating/template.js";
5
+ export { type ElementView, HTMLView, type SyntheticView } from "./templating/view.js";