@lushly-dev/fast-element 3.0.1-preview.0 → 3.0.1-preview.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 (250) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/command/command.api.json +7857 -0
  3. package/dist/context/context.api.json +1084 -0
  4. package/dist/declarative/declarative.api.json +8130 -0
  5. package/dist/definition-schema/definition-schema.api.json +2689 -0
  6. package/dist/di/di.api.json +4945 -0
  7. package/dist/dts/arrays.d.ts +2 -0
  8. package/dist/dts/binding/binding.d.ts +59 -0
  9. package/dist/dts/binding/exports.d.ts +9 -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/binding/signal.d.ts +36 -0
  14. package/dist/dts/binding/two-way.d.ts +44 -0
  15. package/dist/dts/command/behavior.d.ts +94 -0
  16. package/dist/dts/command/behaviors/confirm-behavior.d.ts +139 -0
  17. package/dist/dts/command/behaviors/undo-behavior.d.ts +178 -0
  18. package/dist/dts/command/command.d.ts +79 -0
  19. package/dist/dts/command/component-registry.d.ts +50 -0
  20. package/dist/dts/command/components/confirm-dialog.d.ts +117 -0
  21. package/dist/dts/command/index.d.ts +21 -0
  22. package/dist/dts/command/registry.d.ts +201 -0
  23. package/dist/dts/command/schema-validation.d.ts +45 -0
  24. package/dist/dts/command/types.d.ts +332 -0
  25. package/dist/dts/command/validation.d.ts +116 -0
  26. package/dist/dts/command/weak-ref.d.ts +11 -0
  27. package/dist/dts/components/attributes.d.ts +153 -0
  28. package/dist/dts/components/definition-schema-transforms.d.ts +9 -0
  29. package/dist/dts/components/element-controller.d.ts +349 -0
  30. package/dist/dts/components/element-hydration.d.ts +2 -0
  31. package/dist/dts/components/enable-hydration.d.ts +66 -0
  32. package/dist/dts/components/fast-definitions.d.ts +211 -0
  33. package/dist/dts/components/fast-element-registry.d.ts +23 -0
  34. package/dist/dts/components/fast-element.d.ts +91 -0
  35. package/dist/dts/components/hydration-tracker.d.ts +110 -0
  36. package/dist/dts/components/hydration.d.ts +52 -0
  37. package/dist/dts/components/schema.d.ts +205 -0
  38. package/dist/dts/context.d.ts +171 -0
  39. package/dist/dts/debug.d.ts +5 -0
  40. package/dist/dts/declarative/attribute-map.d.ts +58 -0
  41. package/dist/dts/declarative/debug.d.ts +4 -0
  42. package/dist/dts/declarative/index.d.ts +14 -0
  43. package/dist/dts/declarative/interfaces.d.ts +8 -0
  44. package/dist/dts/declarative/observer-map-utilities.d.ts +58 -0
  45. package/dist/dts/declarative/observer-map.d.ts +89 -0
  46. package/dist/dts/declarative/runtime.d.ts +5 -0
  47. package/dist/dts/declarative/syntax.d.ts +21 -0
  48. package/dist/dts/declarative/template-bridge.d.ts +33 -0
  49. package/dist/dts/declarative/template-parser.d.ts +98 -0
  50. package/dist/dts/declarative/template.d.ts +9 -0
  51. package/dist/dts/declarative/utilities.d.ts +358 -0
  52. package/dist/dts/definition-schema/api.d.ts +42 -0
  53. package/dist/dts/definition-schema/cem.d.ts +78 -0
  54. package/dist/dts/definition-schema/extension.d.ts +18 -0
  55. package/dist/dts/definition-schema/extract.d.ts +38 -0
  56. package/dist/dts/definition-schema/index.d.ts +9 -0
  57. package/dist/dts/definition-schema/storage.d.ts +35 -0
  58. package/dist/dts/definition-schema/types.d.ts +176 -0
  59. package/dist/dts/dev-mode.d.ts +13 -0
  60. package/dist/dts/di/di.d.ts +894 -0
  61. package/dist/dts/dom-policy.d.ts +101 -0
  62. package/dist/dts/dom.d.ts +88 -0
  63. package/dist/dts/hydration/diagnostics.d.ts +93 -0
  64. package/dist/dts/hydration/exports.d.ts +18 -0
  65. package/dist/dts/hydration/hydration-debugger.d.ts +35 -0
  66. package/dist/dts/hydration/messages.d.ts +62 -0
  67. package/dist/dts/hydration/runtime.d.ts +7 -0
  68. package/dist/dts/hydration/target-builder.d.ts +107 -0
  69. package/dist/dts/index.d.ts +51 -0
  70. package/dist/dts/index.debug.d.ts +1 -0
  71. package/dist/dts/index.rollup.d.ts +1 -0
  72. package/dist/dts/index.rollup.debug.d.ts +1 -0
  73. package/dist/dts/interfaces.d.ts +106 -0
  74. package/dist/dts/metadata.d.ts +26 -0
  75. package/dist/dts/observation/arrays.d.ts +248 -0
  76. package/dist/dts/observation/notifier.d.ts +127 -0
  77. package/dist/dts/observation/observable.d.ts +276 -0
  78. package/dist/dts/observation/update-queue.d.ts +40 -0
  79. package/dist/dts/observation/volatile.d.ts +9 -0
  80. package/dist/dts/platform.d.ts +87 -0
  81. package/dist/dts/registry.d.ts +2 -0
  82. package/dist/dts/render.d.ts +7 -0
  83. package/dist/dts/schema.d.ts +1 -0
  84. package/dist/dts/scoped/detection.d.ts +55 -0
  85. package/dist/dts/scoped/index.d.ts +68 -0
  86. package/dist/dts/scoped/mixin.d.ts +118 -0
  87. package/dist/dts/scoped/registry.d.ts +76 -0
  88. package/dist/dts/scoped/types.d.ts +48 -0
  89. package/dist/dts/state/exports.d.ts +3 -0
  90. package/dist/dts/state/reactive.d.ts +8 -0
  91. package/dist/dts/state/state.d.ts +141 -0
  92. package/dist/dts/state/visitor.d.ts +6 -0
  93. package/dist/dts/state/watch.d.ts +10 -0
  94. package/dist/dts/styles/css-directive.d.ts +50 -0
  95. package/dist/dts/styles/css.d.ts +34 -0
  96. package/dist/dts/styles/element-styles.d.ts +61 -0
  97. package/dist/dts/styles/host.d.ts +65 -0
  98. package/dist/dts/styles/style-strategy.d.ts +42 -0
  99. package/dist/dts/templating/children.d.ts +62 -0
  100. package/dist/dts/templating/compiler.d.ts +54 -0
  101. package/dist/dts/templating/html-binding-directive.d.ts +155 -0
  102. package/dist/dts/templating/html-directive.d.ts +218 -0
  103. package/dist/dts/templating/html.d.ts +1 -0
  104. package/dist/dts/templating/hydration-view.d.ts +130 -0
  105. package/dist/dts/templating/markup.d.ts +48 -0
  106. package/dist/dts/templating/node-observation.d.ts +99 -0
  107. package/dist/dts/templating/ref.d.ts +23 -0
  108. package/dist/dts/templating/render.d.ts +318 -0
  109. package/dist/dts/templating/repeat.d.ts +131 -0
  110. package/dist/dts/templating/slotted.d.ts +38 -0
  111. package/dist/dts/templating/template.d.ts +221 -0
  112. package/dist/dts/templating/view.d.ts +268 -0
  113. package/dist/dts/templating/when.d.ts +12 -0
  114. package/dist/dts/testing/exports.d.ts +3 -0
  115. package/dist/dts/testing/fakes.d.ts +16 -0
  116. package/dist/dts/testing/fixture.d.ts +84 -0
  117. package/dist/dts/testing/models.d.ts +20 -0
  118. package/dist/dts/testing/timeout.d.ts +7 -0
  119. package/dist/dts/trust/index.d.ts +8 -0
  120. package/dist/dts/trust/types.d.ts +48 -0
  121. package/dist/dts/trust/utils.d.ts +26 -0
  122. package/dist/dts/tsdoc-metadata.json +11 -0
  123. package/dist/dts/utilities.d.ts +76 -0
  124. package/dist/esm/arrays.js +1 -0
  125. package/dist/esm/binding/binding.js +18 -0
  126. package/dist/esm/binding/exports.js +6 -0
  127. package/dist/esm/binding/normalize.js +17 -0
  128. package/dist/esm/binding/one-time.js +21 -0
  129. package/dist/esm/binding/one-way.js +30 -0
  130. package/dist/esm/binding/signal.js +99 -0
  131. package/dist/esm/binding/two-way.js +109 -0
  132. package/dist/esm/command/behavior.js +155 -0
  133. package/dist/esm/command/behaviors/confirm-behavior.js +225 -0
  134. package/dist/esm/command/behaviors/undo-behavior.js +313 -0
  135. package/dist/esm/command/command.js +104 -0
  136. package/dist/esm/command/component-registry.js +107 -0
  137. package/dist/esm/command/components/confirm-dialog.js +370 -0
  138. package/dist/esm/command/index.js +22 -0
  139. package/dist/esm/command/registry.js +755 -0
  140. package/dist/esm/command/schema-validation.js +194 -0
  141. package/dist/esm/command/types.js +86 -0
  142. package/dist/esm/command/validation.js +508 -0
  143. package/dist/esm/command/weak-ref.js +5 -0
  144. package/dist/esm/components/attributes.js +219 -0
  145. package/dist/esm/components/definition-schema-transforms.js +23 -0
  146. package/dist/esm/components/element-controller.js +840 -0
  147. package/dist/esm/components/element-hydration.js +2 -0
  148. package/dist/esm/components/enable-hydration.js +123 -0
  149. package/dist/esm/components/fast-definitions.js +294 -0
  150. package/dist/esm/components/fast-element-registry.js +67 -0
  151. package/dist/esm/components/fast-element.js +82 -0
  152. package/dist/esm/components/hydration-tracker.js +211 -0
  153. package/dist/esm/components/hydration.js +187 -0
  154. package/dist/esm/components/schema.js +253 -0
  155. package/dist/esm/context.js +185 -0
  156. package/dist/esm/debug.js +71 -0
  157. package/dist/esm/declarative/attribute-map.js +122 -0
  158. package/dist/esm/declarative/debug.js +4 -0
  159. package/dist/esm/declarative/index.js +10 -0
  160. package/dist/esm/declarative/interfaces.js +9 -0
  161. package/dist/esm/declarative/observer-map-utilities.js +565 -0
  162. package/dist/esm/declarative/observer-map.js +216 -0
  163. package/dist/esm/declarative/runtime.js +14 -0
  164. package/dist/esm/declarative/syntax.js +36 -0
  165. package/dist/esm/declarative/template-bridge.js +160 -0
  166. package/dist/esm/declarative/template-parser.js +306 -0
  167. package/dist/esm/declarative/template.js +116 -0
  168. package/dist/esm/declarative/utilities.js +1069 -0
  169. package/dist/esm/definition-schema/api.js +129 -0
  170. package/dist/esm/definition-schema/cem.js +89 -0
  171. package/dist/esm/definition-schema/extension.js +53 -0
  172. package/dist/esm/definition-schema/extract.js +167 -0
  173. package/dist/esm/definition-schema/index.js +8 -0
  174. package/dist/esm/definition-schema/storage.js +58 -0
  175. package/dist/esm/definition-schema/types.js +8 -0
  176. package/dist/esm/dev-mode.js +22 -0
  177. package/dist/esm/di/di.js +1441 -0
  178. package/dist/esm/dom-policy.js +374 -0
  179. package/dist/esm/dom.js +101 -0
  180. package/dist/esm/hydration/diagnostics.js +50 -0
  181. package/dist/esm/hydration/exports.js +6 -0
  182. package/dist/esm/hydration/hydration-debugger.js +112 -0
  183. package/dist/esm/hydration/messages.js +84 -0
  184. package/dist/esm/hydration/runtime.js +33 -0
  185. package/dist/esm/hydration/target-builder.js +264 -0
  186. package/dist/esm/index.debug.js +3 -0
  187. package/dist/esm/index.js +49 -0
  188. package/dist/esm/index.rollup.debug.js +6 -0
  189. package/dist/esm/index.rollup.js +4 -0
  190. package/dist/esm/interfaces.js +55 -0
  191. package/dist/esm/metadata.js +57 -0
  192. package/dist/esm/observation/arrays.js +661 -0
  193. package/dist/esm/observation/notifier.js +162 -0
  194. package/dist/esm/observation/observable.js +324 -0
  195. package/dist/esm/observation/update-queue.js +56 -0
  196. package/dist/esm/observation/volatile.js +16 -0
  197. package/dist/esm/platform.js +98 -0
  198. package/dist/esm/registry.js +2 -0
  199. package/dist/esm/render.js +1 -0
  200. package/dist/esm/schema.js +1 -0
  201. package/dist/esm/scoped/detection.js +102 -0
  202. package/dist/esm/scoped/index.js +69 -0
  203. package/dist/esm/scoped/mixin.js +127 -0
  204. package/dist/esm/scoped/registry.js +125 -0
  205. package/dist/esm/scoped/types.js +4 -0
  206. package/dist/esm/state/exports.js +3 -0
  207. package/dist/esm/state/reactive.js +34 -0
  208. package/dist/esm/state/state.js +148 -0
  209. package/dist/esm/state/visitor.js +28 -0
  210. package/dist/esm/state/watch.js +36 -0
  211. package/dist/esm/styles/css-directive.js +36 -0
  212. package/dist/esm/styles/css.js +56 -0
  213. package/dist/esm/styles/element-styles.js +144 -0
  214. package/dist/esm/styles/host.js +1 -0
  215. package/dist/esm/styles/style-strategy.js +1 -0
  216. package/dist/esm/templating/children.js +67 -0
  217. package/dist/esm/templating/compiler.js +359 -0
  218. package/dist/esm/templating/html-binding-directive.js +288 -0
  219. package/dist/esm/templating/html-directive.js +113 -0
  220. package/dist/esm/templating/html.js +1 -0
  221. package/dist/esm/templating/hydration-view.js +228 -0
  222. package/dist/esm/templating/markup.js +83 -0
  223. package/dist/esm/templating/node-observation.js +84 -0
  224. package/dist/esm/templating/ref.js +21 -0
  225. package/dist/esm/templating/render.js +468 -0
  226. package/dist/esm/templating/repeat.js +434 -0
  227. package/dist/esm/templating/slotted.js +49 -0
  228. package/dist/esm/templating/template.js +206 -0
  229. package/dist/esm/templating/view.js +298 -0
  230. package/dist/esm/templating/when.js +22 -0
  231. package/dist/esm/testing/exports.js +3 -0
  232. package/dist/esm/testing/fakes.js +107 -0
  233. package/dist/esm/testing/fixture.js +86 -0
  234. package/dist/esm/testing/models.js +58 -0
  235. package/dist/esm/testing/timeout.js +24 -0
  236. package/dist/esm/trust/index.js +7 -0
  237. package/dist/esm/trust/types.js +6 -0
  238. package/dist/esm/trust/utils.js +126 -0
  239. package/dist/esm/utilities.js +140 -0
  240. package/dist/fast-element.api.json +26798 -0
  241. package/dist/fast-element.d.ts +3985 -0
  242. package/dist/fast-element.debug.js +7604 -0
  243. package/dist/fast-element.debug.min.js +3 -0
  244. package/dist/fast-element.js +7603 -0
  245. package/dist/fast-element.min.js +3 -0
  246. package/dist/fast-element.untrimmed.d.ts +4103 -0
  247. package/dist/observation/arrays/arrays.api.json +2621 -0
  248. package/dist/scoped/scoped.api.json +891 -0
  249. package/dist/trust/trust.api.json +629 -0
  250. package/package.json +21 -23
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Represents a callable type such as a function or an object with a "call" method.
3
+ * @public
4
+ */
5
+ export type Callable = typeof Function.prototype.call | {
6
+ call(): void;
7
+ };
8
+ /**
9
+ * Represents a type which can be constructed with the new operator.
10
+ *
11
+ * @public
12
+ */
13
+ export type Constructable<T = {}> = {
14
+ new (...args: any[]): T;
15
+ };
16
+ /**
17
+ * Represents a constructable class with a prototype.
18
+ * @public
19
+ */
20
+ export type Class<T, C = {}> = C & Constructable<T> & {
21
+ /**
22
+ * The class's prototype;
23
+ */
24
+ readonly prototype: T;
25
+ };
26
+ /**
27
+ * Provides a mechanism for releasing resources.
28
+ * @public
29
+ */
30
+ export interface Disposable {
31
+ /**
32
+ * Disposes the resources.
33
+ */
34
+ dispose(): void;
35
+ }
36
+ /**
37
+ * A policy for use with the standard trustedTypes platform API.
38
+ * @public
39
+ */
40
+ export type TrustedTypesPolicy = {
41
+ /**
42
+ * Creates trusted HTML.
43
+ * @param html - The HTML to clear as trustworthy.
44
+ */
45
+ createHTML(html: string): string;
46
+ };
47
+ /**
48
+ * Reverses all readonly members, making them mutable.
49
+ * @public
50
+ */
51
+ export type Mutable<T> = {
52
+ -readonly [P in keyof T]: T[P];
53
+ };
54
+ /**
55
+ * A temporary type as a workaround for the TS compiler's erroneous built-in ParameterDecorator type.
56
+ * @public
57
+ */
58
+ export type ParameterDecorator = (target: Object, propertyKey: string | undefined, parameterIndex: number) => void;
59
+ /**
60
+ * Warning and error messages.
61
+ * @internal
62
+ */
63
+ export declare const enum Message {
64
+ needsArrayObservation = 1101,
65
+ onlySetDOMPolicyOnce = 1201,
66
+ bindingInnerHTMLRequiresTrustedTypes = 1202,
67
+ twoWayBindingRequiresObservables = 1203,
68
+ hostBindingWithoutHost = 1204,
69
+ unsupportedBindingBehavior = 1205,
70
+ directCallToHTMLTagNotAllowed = 1206,
71
+ onlySetTemplatePolicyOnce = 1207,
72
+ cannotSetTemplatePolicyAfterCompilation = 1208,
73
+ blockedByDOMPolicy = 1209,
74
+ invalidHydrationAttributeMarker = 1210,
75
+ duplicateRenderInstruction = 1211,
76
+ missingElementDefinition = 1401,
77
+ noRegistrationForContext = 1501,
78
+ noFactoryForResolver = 1502,
79
+ invalidResolverStrategy = 1503,
80
+ cannotAutoregisterDependency = 1504,
81
+ cannotResolveKey = 1505,
82
+ cannotConstructNativeFunction = 1506,
83
+ cannotJITRegisterNonConstructor = 1507,
84
+ cannotJITRegisterIntrinsic = 1508,
85
+ cannotJITRegisterInterface = 1509,
86
+ invalidResolver = 1510,
87
+ invalidKey = 1511,
88
+ noDefaultResolver = 1512,
89
+ cyclicDependency = 1513,
90
+ connectUpdateRequiresController = 1514
91
+ }
92
+ /**
93
+ * Determines whether or not an object is a function.
94
+ * @public
95
+ */
96
+ export declare const isFunction: (object: any) => object is Function;
97
+ /**
98
+ * Determines whether or not an object is a string.
99
+ * @public
100
+ */
101
+ export declare const isString: (object: any) => object is string;
102
+ /**
103
+ * A function which does nothing.
104
+ * @public
105
+ */
106
+ export declare const noop: () => undefined;
@@ -0,0 +1,26 @@
1
+ import type { Constructable } from "./interfaces.js";
2
+ /**
3
+ * Provides basic metadata capabilities used by Context and Dependency Injection.
4
+ * @public
5
+ */
6
+ export declare const Metadata: Readonly<{
7
+ /**
8
+ * Gets the "design:paramtypes" metadata for the specified type.
9
+ * @param Type - The type to get the metadata for.
10
+ * @returns The metadata array or a frozen empty array if no metadata is found.
11
+ */
12
+ getDesignParamTypes: (Type: Constructable) => readonly any[];
13
+ /**
14
+ * Gets the "annotation:paramtypes" metadata for the specified type.
15
+ * @param Type - The type to get the metadata for.
16
+ * @returns The metadata array or a frozen empty array if no metadata is found.
17
+ */
18
+ getAnnotationParamTypes: (Type: Constructable) => readonly any[];
19
+ /**
20
+ * Gets the "annotation:paramtypes" metadata for the specified type. If none is found,
21
+ * an empty, mutable metadata array is created and added.
22
+ * @param Type - The type to get or create the metadata for.
23
+ * @returns A mutable metadata array.
24
+ */
25
+ getOrCreateAnnotationParamTypes(Type: Constructable): any[];
26
+ }>;
@@ -0,0 +1,248 @@
1
+ import { type Subscriber, SubscriberSet } from "./notifier.js";
2
+ /**
3
+ * A splice map is a representation of how a previous array of items
4
+ * was transformed into a new array of items. Conceptually it is a list of
5
+ * tuples of
6
+ *
7
+ * (index, removed, addedCount)
8
+ *
9
+ * which are kept in ascending index order of. The tuple represents that at
10
+ * the |index|, |removed| sequence of items were removed, and counting forward
11
+ * from |index|, |addedCount| items were added.
12
+ * @public
13
+ */
14
+ export declare class Splice {
15
+ index: number;
16
+ removed: any[];
17
+ addedCount: number;
18
+ /**
19
+ * Indicates that this splice represents a complete array reset.
20
+ */
21
+ reset?: boolean;
22
+ /**
23
+ * Creates a splice.
24
+ * @param index - The index that the splice occurs at.
25
+ * @param removed - The items that were removed.
26
+ * @param addedCount - The number of items that were added.
27
+ */
28
+ constructor(index: number, removed: any[], addedCount: number);
29
+ /**
30
+ * Adjusts the splice index based on the provided array.
31
+ * @param array - The array to adjust to.
32
+ * @returns The same splice, mutated based on the reference array.
33
+ */
34
+ adjustTo(array: any[]): this;
35
+ }
36
+ /**
37
+ * A sort array indicates new index positions of array items.
38
+ * @public
39
+ */
40
+ export declare class Sort {
41
+ sorted?: number[] | undefined;
42
+ /**
43
+ * Creates a sort update.
44
+ * @param sorted - The updated index of sorted items.
45
+ */
46
+ constructor(sorted?: number[] | undefined);
47
+ }
48
+ /**
49
+ * Indicates what level of feature support the splice
50
+ * strategy provides.
51
+ * @public
52
+ */
53
+ export declare const SpliceStrategySupport: Readonly<{
54
+ /**
55
+ * Only supports resets.
56
+ */
57
+ readonly reset: 1;
58
+ /**
59
+ * Supports tracking splices and resets.
60
+ */
61
+ readonly splice: 2;
62
+ /**
63
+ * Supports tracking splices and resets, while applying some form
64
+ * of optimization, such as merging, to the splices.
65
+ */
66
+ readonly optimized: 3;
67
+ }>;
68
+ /**
69
+ * The available values for SpliceStrategySupport.
70
+ * @public
71
+ */
72
+ export type SpliceStrategySupport = (typeof SpliceStrategySupport)[keyof typeof SpliceStrategySupport];
73
+ /**
74
+ * An approach to tracking changes in an array.
75
+ * @public
76
+ */
77
+ export interface SpliceStrategy {
78
+ /**
79
+ * The level of feature support the splice strategy provides.
80
+ */
81
+ readonly support: SpliceStrategySupport;
82
+ /**
83
+ * Normalizes the splices before delivery to array change subscribers.
84
+ * @param previous - The previous version of the array if a reset has taken place.
85
+ * @param current - The current version of the array.
86
+ * @param changes - The set of changes tracked against the array.
87
+ */
88
+ normalize(previous: unknown[] | undefined, current: unknown[], changes: Splice[] | undefined): readonly Splice[];
89
+ /**
90
+ * Performs and tracks a pop operation on an array.
91
+ * @param array - The array to track the change for.
92
+ * @param observer - The observer to register the change with.
93
+ * @param pop - The operation to perform.
94
+ * @param args - The arguments for the operation.
95
+ */
96
+ pop(array: any[], observer: ArrayObserver, pop: typeof Array.prototype.pop, args: any[]): any;
97
+ /**
98
+ * Performs and tracks a push operation on an array.
99
+ * @param array - The array to track the change for.
100
+ * @param observer - The observer to register the change with.
101
+ * @param push - The operation to perform.
102
+ * @param args - The arguments for the operation.
103
+ */
104
+ push(array: any[], observer: ArrayObserver, push: typeof Array.prototype.push, args: any[]): any;
105
+ /**
106
+ * Performs and tracks a reverse operation on an array.
107
+ * @param array - The array to track the change for.
108
+ * @param observer - The observer to register the change with.
109
+ * @param reverse - The operation to perform.
110
+ * @param args - The arguments for the operation.
111
+ */
112
+ reverse(array: any[], observer: ArrayObserver, reverse: typeof Array.prototype.reverse, args: any[]): any;
113
+ /**
114
+ * Performs and tracks a shift operation on an array.
115
+ * @param array - The array to track the change for.
116
+ * @param observer - The observer to register the change with.
117
+ * @param shift - The operation to perform.
118
+ * @param args - The arguments for the operation.
119
+ */
120
+ shift(array: any[], observer: ArrayObserver, shift: typeof Array.prototype.shift, args: any[]): any;
121
+ /**
122
+ * Performs and tracks a sort operation on an array.
123
+ * @param array - The array to track the change for.
124
+ * @param observer - The observer to register the change with.
125
+ * @param sort - The operation to perform.
126
+ * @param args - The arguments for the operation.
127
+ */
128
+ sort(array: any[], observer: ArrayObserver, sort: typeof Array.prototype.sort, args: any[]): any[];
129
+ /**
130
+ * Performs and tracks a splice operation on an array.
131
+ * @param array - The array to track the change for.
132
+ * @param observer - The observer to register the change with.
133
+ * @param splice - The operation to perform.
134
+ * @param args - The arguments for the operation.
135
+ */
136
+ splice(array: any[], observer: ArrayObserver, splice: typeof Array.prototype.splice, args: any[]): any;
137
+ /**
138
+ * Performs and tracks an unshift operation on an array.
139
+ * @param array - The array to track the change for.
140
+ * @param observer - The observer to register the change with.
141
+ * @param unshift - The operation to perform.
142
+ * @param args - The arguments for the operation.
143
+ */
144
+ unshift(array: any[], observer: ArrayObserver, unshift: typeof Array.prototype.unshift, args: any[]): any[];
145
+ }
146
+ /**
147
+ * Functionality related to tracking changes in arrays.
148
+ * @public
149
+ */
150
+ export declare const SpliceStrategy: Readonly<{
151
+ /**
152
+ * A set of changes that represent a full array reset.
153
+ */
154
+ readonly reset: Splice[];
155
+ /**
156
+ * Sets the default strategy to use for array observers.
157
+ * @param strategy - The splice strategy to use.
158
+ */
159
+ readonly setDefaultStrategy: (strategy: SpliceStrategy) => void;
160
+ }>;
161
+ /**
162
+ * Observes array lengths.
163
+ * @public
164
+ */
165
+ export interface LengthObserver extends Subscriber {
166
+ /**
167
+ * The length of the observed array.
168
+ */
169
+ length: number;
170
+ }
171
+ /**
172
+ * Observes array sort.
173
+ * @public
174
+ */
175
+ export interface SortObserver extends Subscriber {
176
+ /**
177
+ * The sorted times on the observed array, this should be incremented every time
178
+ * an item in the array changes location.
179
+ */
180
+ sorted: number;
181
+ }
182
+ /**
183
+ * An observer for arrays.
184
+ * @public
185
+ */
186
+ export interface ArrayObserver extends SubscriberSet {
187
+ /**
188
+ * The strategy to use for tracking changes.
189
+ */
190
+ strategy: SpliceStrategy | null;
191
+ /**
192
+ * The length observer for the array.
193
+ */
194
+ readonly lengthObserver: LengthObserver;
195
+ /**
196
+ * The sort observer for the array.
197
+ */
198
+ readonly sortObserver: SortObserver;
199
+ /**
200
+ * Adds a splice to the list of changes.
201
+ * @param splice - The splice to add.
202
+ */
203
+ addSplice(splice: Splice): void;
204
+ /**
205
+ * Adds a sort to the list of changes.
206
+ * @param sort - The sort to add.
207
+ */
208
+ addSort(sort: Sort): void;
209
+ /**
210
+ * Indicates that a reset change has occurred.
211
+ * @param oldCollection - The collection as it was before the reset.
212
+ */
213
+ reset(oldCollection: any[] | undefined): void;
214
+ /**
215
+ * Flushes the changes to subscribers.
216
+ */
217
+ flush(): void;
218
+ }
219
+ /**
220
+ * An observer for arrays.
221
+ * @public
222
+ */
223
+ export declare const ArrayObserver: Readonly<{
224
+ readonly sorted: 0;
225
+ /**
226
+ * Enables the array observation mechanism.
227
+ * @remarks
228
+ * Array observation is enabled automatically when using the
229
+ * `RepeatDirective`, so calling this API manually is
230
+ * not typically necessary.
231
+ */
232
+ readonly enable: () => void;
233
+ }>;
234
+ /**
235
+ * Enables observing the length of an array.
236
+ * @param array - The array to observe the length of.
237
+ * @returns The length of the array.
238
+ * @public
239
+ */
240
+ export declare function lengthOf<T>(array: readonly T[]): number;
241
+ /**
242
+ * Enables observing the sorted property of an array.
243
+ * @param array - The array to observe the sorted property of.
244
+ * @returns The sorted property.
245
+ * @public
246
+ */
247
+ export declare function sortedCount<T>(array: readonly T[]): number;
248
+ export { type Notifier, type Subscriber, SubscriberSet } from "./notifier.js";
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Implemented by objects that are interested in change notifications.
3
+ * @public
4
+ */
5
+ export interface Subscriber {
6
+ /**
7
+ * Called when a subject this instance has subscribed to changes.
8
+ * @param subject - The subject of the change.
9
+ * @param args - The event args detailing the change that occurred.
10
+ */
11
+ handleChange(subject: any, args: any): void;
12
+ }
13
+ /**
14
+ * Provides change notifications for an observed subject.
15
+ * @public
16
+ */
17
+ export interface Notifier {
18
+ /**
19
+ * The object that subscribers will receive notifications for.
20
+ */
21
+ readonly subject: any;
22
+ /**
23
+ * Notifies all subscribers, based on the args.
24
+ * @param args - Data passed along to subscribers during notification.
25
+ * @remarks
26
+ * In some implementations, the args may be used to target specific subscribers.
27
+ * This is usually in the case where a propertyName was passed during subscription.
28
+ */
29
+ notify(args: any): void;
30
+ /**
31
+ * Subscribes to notification of changes in an object's state.
32
+ * @param subscriber - The object that is subscribing for change notification.
33
+ * @param propertyToWatch - The name of the property that the subscriber is interested in watching for changes.
34
+ * @remarks
35
+ * Some implementation may or may not require the propertyToWatch.
36
+ */
37
+ subscribe(subscriber: Subscriber, propertyToWatch?: any): void;
38
+ /**
39
+ * Unsubscribes from notification of changes in an object's state.
40
+ * @param subscriber - The object that is unsubscribing from change notification.
41
+ * @param propertyToUnwatch - The name of the property that the subscriber is no longer interested in watching.
42
+ * @remarks
43
+ * Some implementation may or may not require the propertyToUnwatch.
44
+ */
45
+ unsubscribe(subscriber: Subscriber, propertyToUnwatch?: any): void;
46
+ }
47
+ /**
48
+ * An implementation of {@link Notifier} that efficiently keeps track of
49
+ * subscribers interested in a specific change notification on an
50
+ * observable subject.
51
+ *
52
+ * @remarks
53
+ * This set is optimized for the most common scenario of 1 or 2 subscribers.
54
+ * With this in mind, it can store a subscriber in an internal field, allowing it to avoid Array#push operations.
55
+ * If the set ever exceeds two subscribers, it upgrades to an array automatically.
56
+ * @public
57
+ */
58
+ export declare class SubscriberSet implements Notifier {
59
+ private sub1;
60
+ private sub2;
61
+ private spillover;
62
+ /**
63
+ * The object that subscribers will receive notifications for.
64
+ */
65
+ readonly subject: any;
66
+ /**
67
+ * Creates an instance of SubscriberSet for the specified subject.
68
+ * @param subject - The subject that subscribers will receive notifications from.
69
+ * @param initialSubscriber - An initial subscriber to changes.
70
+ */
71
+ constructor(subject: any, initialSubscriber?: Subscriber);
72
+ /**
73
+ * Checks whether the provided subscriber has been added to this set.
74
+ * @param subscriber - The subscriber to test for inclusion in this set.
75
+ */
76
+ has(subscriber: Subscriber): boolean;
77
+ /**
78
+ * Subscribes to notification of changes in an object's state.
79
+ * @param subscriber - The object that is subscribing for change notification.
80
+ */
81
+ subscribe(subscriber: Subscriber): void;
82
+ /**
83
+ * Unsubscribes from notification of changes in an object's state.
84
+ * @param subscriber - The object that is unsubscribing from change notification.
85
+ */
86
+ unsubscribe(subscriber: Subscriber): void;
87
+ /**
88
+ * Notifies all subscribers.
89
+ * @param args - Data passed along to subscribers during notification.
90
+ */
91
+ notify(args: any): void;
92
+ }
93
+ /**
94
+ * An implementation of Notifier that allows subscribers to be notified
95
+ * of individual property changes on an object.
96
+ * @public
97
+ */
98
+ export declare class PropertyChangeNotifier implements Notifier {
99
+ private subscribers;
100
+ private subjectSubscribers;
101
+ /**
102
+ * The subject that property changes are being notified for.
103
+ */
104
+ readonly subject: any;
105
+ /**
106
+ * Creates an instance of PropertyChangeNotifier for the specified subject.
107
+ * @param subject - The object that subscribers will receive notifications for.
108
+ */
109
+ constructor(subject: any);
110
+ /**
111
+ * Notifies all subscribers, based on the specified property.
112
+ * @param propertyName - The property name, passed along to subscribers during notification.
113
+ */
114
+ notify(propertyName: string): void;
115
+ /**
116
+ * Subscribes to notification of changes in an object's state.
117
+ * @param subscriber - The object that is subscribing for change notification.
118
+ * @param propertyToWatch - The name of the property that the subscriber is interested in watching for changes.
119
+ */
120
+ subscribe(subscriber: Subscriber, propertyToWatch?: string): void;
121
+ /**
122
+ * Unsubscribes from notification of changes in an object's state.
123
+ * @param subscriber - The object that is unsubscribing from change notification.
124
+ * @param propertyToUnwatch - The name of the property that the subscriber is no longer interested in watching.
125
+ */
126
+ unsubscribe(subscriber: Subscriber, propertyToUnwatch?: string): void;
127
+ }