@microsoft/fast-element 1.7.1 → 1.9.0

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 (56) hide show
  1. package/.eslintrc.json +30 -0
  2. package/CHANGELOG.json +73 -1
  3. package/CHANGELOG.md +26 -2
  4. package/dist/dts/components/attributes.d.ts +1 -1
  5. package/dist/dts/components/controller.d.ts +6 -6
  6. package/dist/dts/components/fast-definitions.d.ts +5 -5
  7. package/dist/dts/components/fast-element.d.ts +2 -2
  8. package/dist/dts/dom.d.ts +4 -4
  9. package/dist/dts/index.d.ts +26 -26
  10. package/dist/dts/observation/behavior.d.ts +1 -1
  11. package/dist/dts/observation/observable.d.ts +51 -50
  12. package/dist/dts/platform.d.ts +37 -0
  13. package/dist/dts/styles/css-directive.d.ts +2 -2
  14. package/dist/dts/styles/css.d.ts +2 -2
  15. package/dist/dts/styles/element-styles.d.ts +1 -1
  16. package/dist/dts/templating/binding.d.ts +3 -3
  17. package/dist/dts/templating/children.d.ts +2 -2
  18. package/dist/dts/templating/compiler.d.ts +1 -1
  19. package/dist/dts/templating/html-directive.d.ts +1 -1
  20. package/dist/dts/templating/node-observation.d.ts +1 -1
  21. package/dist/dts/templating/ref.d.ts +2 -2
  22. package/dist/dts/templating/repeat.d.ts +6 -6
  23. package/dist/dts/templating/slotted.d.ts +2 -2
  24. package/dist/dts/templating/template.d.ts +3 -3
  25. package/dist/dts/templating/view.d.ts +2 -2
  26. package/dist/dts/templating/when.d.ts +2 -2
  27. package/dist/esm/components/attributes.js +2 -2
  28. package/dist/esm/components/controller.js +4 -4
  29. package/dist/esm/components/fast-definitions.js +31 -14
  30. package/dist/esm/components/fast-element.js +2 -2
  31. package/dist/esm/dom.js +55 -50
  32. package/dist/esm/index.js +23 -23
  33. package/dist/esm/observation/array-change-records.js +1 -1
  34. package/dist/esm/observation/array-observer.js +12 -6
  35. package/dist/esm/observation/observable.js +244 -236
  36. package/dist/esm/platform.js +23 -0
  37. package/dist/esm/styles/css.js +2 -2
  38. package/dist/esm/styles/element-styles.js +1 -1
  39. package/dist/esm/templating/binding.js +5 -5
  40. package/dist/esm/templating/children.js +2 -2
  41. package/dist/esm/templating/compiler.js +2 -2
  42. package/dist/esm/templating/html-directive.js +1 -1
  43. package/dist/esm/templating/node-observation.js +2 -2
  44. package/dist/esm/templating/ref.js +1 -1
  45. package/dist/esm/templating/repeat.js +6 -6
  46. package/dist/esm/templating/slotted.js +2 -2
  47. package/dist/esm/templating/template.js +6 -6
  48. package/dist/fast-element.api.json +43 -48
  49. package/dist/fast-element.d.ts +53 -13
  50. package/dist/fast-element.js +428 -344
  51. package/dist/fast-element.min.js +1 -1
  52. package/docs/api-report.md +39 -12
  53. package/docs/guide/observables-and-state.md +10 -8
  54. package/docs/guide/using-directives.md +1 -1
  55. package/karma.conf.cjs +152 -0
  56. package/package.json +11 -10
@@ -1535,6 +1535,10 @@
1535
1535
  "text": "ExecutionContext",
1536
1536
  "canonicalReference": "@microsoft/fast-element!ExecutionContext:class"
1537
1537
  },
1538
+ {
1539
+ "kind": "Content",
1540
+ "text": "<TParent>"
1541
+ },
1538
1542
  {
1539
1543
  "kind": "Content",
1540
1544
  "text": "): "
@@ -1549,8 +1553,8 @@
1549
1553
  }
1550
1554
  ],
1551
1555
  "returnTypeTokenRange": {
1552
- "startIndex": 5,
1553
- "endIndex": 6
1556
+ "startIndex": 6,
1557
+ "endIndex": 7
1554
1558
  },
1555
1559
  "releaseTag": "Public",
1556
1560
  "overloadIndex": 1,
@@ -1566,7 +1570,7 @@
1566
1570
  "parameterName": "context",
1567
1571
  "parameterTypeTokenRange": {
1568
1572
  "startIndex": 3,
1569
- "endIndex": 4
1573
+ "endIndex": 5
1570
1574
  }
1571
1575
  }
1572
1576
  ],
@@ -3527,7 +3531,7 @@
3527
3531
  },
3528
3532
  {
3529
3533
  "kind": "Content",
3530
- "text": "): number;\n createInterpolationPlaceholder(index: number): string;\n createCustomAttributePlaceholder(attributeName: string, index: number): string;\n createBlockPlaceholder(index: number): string;\n queueUpdate(callable: "
3534
+ "text": "): number;\n createInterpolationPlaceholder(index: number): string;\n createCustomAttributePlaceholder(attributeName: string, index: number): string;\n createBlockPlaceholder(index: number): string;\n queueUpdate: (callable: "
3531
3535
  },
3532
3536
  {
3533
3537
  "kind": "Reference",
@@ -3536,7 +3540,7 @@
3536
3540
  },
3537
3541
  {
3538
3542
  "kind": "Content",
3539
- "text": "): void;\n processUpdates(): void;\n nextUpdate(): "
3543
+ "text": ") => void;\n processUpdates: () => void;\n nextUpdate(): "
3540
3544
  },
3541
3545
  {
3542
3546
  "kind": "Reference",
@@ -4987,13 +4991,17 @@
4987
4991
  "isStatic": false
4988
4992
  },
4989
4993
  {
4990
- "kind": "Method",
4991
- "canonicalReference": "@microsoft/fast-element!FASTElementDefinition.forType:member(1)",
4994
+ "kind": "Property",
4995
+ "canonicalReference": "@microsoft/fast-element!FASTElementDefinition.forType:member",
4992
4996
  "docComment": "/**\n * Gets the element definition associated with the specified type.\n *\n * @param type - The custom element type to retrieve the definition for.\n */\n",
4993
4997
  "excerptTokens": [
4994
4998
  {
4995
4999
  "kind": "Content",
4996
- "text": "static forType<TType extends "
5000
+ "text": "static readonly forType: "
5001
+ },
5002
+ {
5003
+ "kind": "Content",
5004
+ "text": "<TType_1 extends "
4997
5005
  },
4998
5006
  {
4999
5007
  "kind": "Reference",
@@ -5002,60 +5010,38 @@
5002
5010
  },
5003
5011
  {
5004
5012
  "kind": "Content",
5005
- "text": ">(type: "
5013
+ "text": ">(key: TType_1) => "
5006
5014
  },
5007
5015
  {
5008
- "kind": "Content",
5009
- "text": "TType"
5016
+ "kind": "Reference",
5017
+ "text": "FASTElementDefinition",
5018
+ "canonicalReference": "@microsoft/fast-element!FASTElementDefinition:class"
5010
5019
  },
5011
5020
  {
5012
5021
  "kind": "Content",
5013
- "text": "): "
5022
+ "text": "<"
5014
5023
  },
5015
5024
  {
5016
5025
  "kind": "Reference",
5017
- "text": "FASTElementDefinition",
5018
- "canonicalReference": "@microsoft/fast-element!FASTElementDefinition:class"
5026
+ "text": "Function",
5027
+ "canonicalReference": "!Function:interface"
5019
5028
  },
5020
5029
  {
5021
5030
  "kind": "Content",
5022
- "text": " | undefined"
5031
+ "text": "> | undefined"
5023
5032
  },
5024
5033
  {
5025
5034
  "kind": "Content",
5026
5035
  "text": ";"
5027
5036
  }
5028
5037
  ],
5029
- "isStatic": true,
5030
- "returnTypeTokenRange": {
5031
- "startIndex": 5,
5032
- "endIndex": 7
5033
- },
5034
5038
  "releaseTag": "Public",
5035
- "overloadIndex": 1,
5036
- "parameters": [
5037
- {
5038
- "parameterName": "type",
5039
- "parameterTypeTokenRange": {
5040
- "startIndex": 3,
5041
- "endIndex": 4
5042
- }
5043
- }
5044
- ],
5045
- "typeParameters": [
5046
- {
5047
- "typeParameterName": "TType",
5048
- "constraintTokenRange": {
5049
- "startIndex": 1,
5050
- "endIndex": 2
5051
- },
5052
- "defaultTypeTokenRange": {
5053
- "startIndex": 0,
5054
- "endIndex": 0
5055
- }
5056
- }
5057
- ],
5058
- "name": "forType"
5039
+ "name": "forType",
5040
+ "propertyTypeTokenRange": {
5041
+ "startIndex": 1,
5042
+ "endIndex": 8
5043
+ },
5044
+ "isStatic": true
5059
5045
  },
5060
5046
  {
5061
5047
  "kind": "Property",
@@ -5064,7 +5050,7 @@
5064
5050
  "excerptTokens": [
5065
5051
  {
5066
5052
  "kind": "Content",
5067
- "text": "readonly isDefined: "
5053
+ "text": "get isDefined(): "
5068
5054
  },
5069
5055
  {
5070
5056
  "kind": "Content",
@@ -5286,6 +5272,15 @@
5286
5272
  "text": "TrustedTypes",
5287
5273
  "canonicalReference": "@microsoft/fast-element!TrustedTypes:type"
5288
5274
  },
5275
+ {
5276
+ "kind": "Content",
5277
+ "text": ";\n readonly FAST: "
5278
+ },
5279
+ {
5280
+ "kind": "Reference",
5281
+ "text": "FASTGlobal",
5282
+ "canonicalReference": "@microsoft/fast-element!FASTGlobal:interface"
5283
+ },
5289
5284
  {
5290
5285
  "kind": "Content",
5291
5286
  "text": ";\n}"
@@ -5299,7 +5294,7 @@
5299
5294
  "name": "Global",
5300
5295
  "typeTokenRange": {
5301
5296
  "startIndex": 1,
5302
- "endIndex": 6
5297
+ "endIndex": 8
5303
5298
  }
5304
5299
  },
5305
5300
  {
@@ -6722,7 +6717,7 @@
6722
6717
  },
6723
6718
  {
6724
6719
  "kind": "Content",
6725
- "text": "): void;\n getNotifier(source: any): "
6720
+ "text": "): void;\n getNotifier: (source: any) => "
6726
6721
  },
6727
6722
  {
6728
6723
  "kind": "Reference",
@@ -6740,7 +6735,7 @@
6740
6735
  },
6741
6736
  {
6742
6737
  "kind": "Content",
6743
- "text": "): void;\n getAccessors(target: {}): "
6738
+ "text": "): void;\n getAccessors: (target: {}) => "
6744
6739
  },
6745
6740
  {
6746
6741
  "kind": "Reference",
@@ -262,7 +262,7 @@ export declare interface BindingObserver<TSource = any, TReturn = any, TParent =
262
262
  * @param context - The execution context to execute the binding within.
263
263
  * @returns The value of the binding.
264
264
  */
265
- observe(source: TSource, context: ExecutionContext): TReturn;
265
+ observe(source: TSource, context: ExecutionContext<TParent>): TReturn;
266
266
  /**
267
267
  * Unsubscribe from all dependent observables of the binding.
268
268
  */
@@ -639,7 +639,7 @@ export declare const DOM: Readonly<{
639
639
  * Schedules DOM update work in the next async batch.
640
640
  * @param callable - The callable function or object to queue.
641
641
  */
642
- queueUpdate(callable: Callable): void;
642
+ queueUpdate: (callable: Callable) => void;
643
643
  /**
644
644
  * Immediately processes all work previously scheduled
645
645
  * through queueUpdate.
@@ -647,7 +647,7 @@ export declare const DOM: Readonly<{
647
647
  * This also forces nextUpdate promises
648
648
  * to resolve.
649
649
  */
650
- processUpdates(): void;
650
+ processUpdates: () => void;
651
651
  /**
652
652
  * Resolves with the next DOM update.
653
653
  */
@@ -831,8 +831,20 @@ export declare class ExecutionContext<TParent = any, TGrandparent = any> {
831
831
  * is the last item in the collection.
832
832
  */
833
833
  get isLast(): boolean;
834
+ /**
835
+ * Sets the event for the current execution context.
836
+ * @param event - The event to set.
837
+ * @internal
838
+ */
839
+ static setEvent(event: Event | null): void;
834
840
  }
835
841
 
842
+ /**
843
+ * The FAST global.
844
+ * @internal
845
+ */
846
+ export declare const FAST: FASTGlobal;
847
+
836
848
  /**
837
849
  * Represents a custom element based on the FASTElement infrastructure.
838
850
  * @public
@@ -915,7 +927,7 @@ export declare class FASTElementDefinition<TType extends Function = Function> {
915
927
  /**
916
928
  * Indicates if this element has been defined in at least one registry.
917
929
  */
918
- readonly isDefined: boolean;
930
+ get isDefined(): boolean;
919
931
  /**
920
932
  * The name of the custom element.
921
933
  */
@@ -964,7 +976,25 @@ export declare class FASTElementDefinition<TType extends Function = Function> {
964
976
  * Gets the element definition associated with the specified type.
965
977
  * @param type - The custom element type to retrieve the definition for.
966
978
  */
967
- static forType<TType extends Function>(type: TType): FASTElementDefinition | undefined;
979
+ static readonly forType: <TType_1 extends Function>(key: TType_1) => FASTElementDefinition<Function> | undefined;
980
+ }
981
+
982
+ /**
983
+ * The FAST global.
984
+ * @internal
985
+ */
986
+ export declare interface FASTGlobal {
987
+ /**
988
+ * The list of loaded versions.
989
+ */
990
+ readonly versions: string[];
991
+ /**
992
+ * Gets a kernel value.
993
+ * @param id - The id to get the value for.
994
+ * @param initialize - Creates the initial value for the id if not already existing.
995
+ */
996
+ getById<T>(id: string | number): T | null;
997
+ getById<T>(id: string | number, initialize: () => T): T;
968
998
  }
969
999
 
970
1000
  /**
@@ -976,6 +1006,11 @@ export declare type Global = typeof globalThis & {
976
1006
  * Enables working with trusted types.
977
1007
  */
978
1008
  trustedTypes: TrustedTypes;
1009
+ /**
1010
+ * The FAST global.
1011
+ * @internal
1012
+ */
1013
+ readonly FAST: FASTGlobal;
979
1014
  };
980
1015
 
981
1016
  /**
@@ -1112,6 +1147,17 @@ export declare class HTMLView implements ElementView, SyntheticView {
1112
1147
  static disposeContiguousBatch(views: SyntheticView[]): void;
1113
1148
  }
1114
1149
 
1150
+ /**
1151
+ * Core services shared across FAST instances.
1152
+ * @internal
1153
+ */
1154
+ export declare const enum KernelServiceId {
1155
+ updateQueue = 1,
1156
+ observable = 2,
1157
+ contextEvent = 3,
1158
+ elementRegistry = 4
1159
+ }
1160
+
1115
1161
  /**
1116
1162
  * Reverses all readonly members, making them mutable.
1117
1163
  * @internal
@@ -1262,7 +1308,7 @@ export declare const Observable: Readonly<{
1262
1308
  * Gets a notifier for an object or Array.
1263
1309
  * @param source - The object or Array to get the notifier for.
1264
1310
  */
1265
- getNotifier(source: any): Notifier;
1311
+ getNotifier: (source: any) => Notifier;
1266
1312
  /**
1267
1313
  * Records a property change for a source object.
1268
1314
  * @param source - The object to record the change against.
@@ -1292,7 +1338,7 @@ export declare const Observable: Readonly<{
1292
1338
  * including its prototype chain.
1293
1339
  * @param target - The target object to search for accessor on.
1294
1340
  */
1295
- getAccessors(target: {}): Accessor[];
1341
+ getAccessors: (target: {}) => Accessor[];
1296
1342
  /**
1297
1343
  * Creates a {@link BindingObserver} that can watch the
1298
1344
  * provided {@link Binding} for changes.
@@ -1534,12 +1580,6 @@ export declare interface RepeatOptions {
1534
1580
  recycle?: boolean;
1535
1581
  }
1536
1582
 
1537
- /**
1538
- * @param event - The event to set as current for the context.
1539
- * @internal
1540
- */
1541
- export declare function setCurrentEvent(event: Event | null): void;
1542
-
1543
1583
  /**
1544
1584
  * A directive that observes the `assignedNodes()` of a slot and updates a property
1545
1585
  * whenever they change.