@microsoft/fast-element 2.0.0-beta.20 → 2.0.0-beta.21

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.
@@ -6806,6 +6806,28 @@
6806
6806
  ],
6807
6807
  "extendsTokenRanges": []
6808
6808
  },
6809
+ {
6810
+ "kind": "Variable",
6811
+ "canonicalReference": "@microsoft/fast-element!FAST:var",
6812
+ "docComment": "/**\n * The FAST global.\n *\n * @public\n */\n",
6813
+ "excerptTokens": [
6814
+ {
6815
+ "kind": "Content",
6816
+ "text": "FAST: "
6817
+ },
6818
+ {
6819
+ "kind": "Reference",
6820
+ "text": "FASTGlobal",
6821
+ "canonicalReference": "@microsoft/fast-element!FASTGlobal:interface"
6822
+ }
6823
+ ],
6824
+ "releaseTag": "Public",
6825
+ "name": "FAST",
6826
+ "variableTypeTokenRange": {
6827
+ "startIndex": 1,
6828
+ "endIndex": 2
6829
+ }
6830
+ },
6809
6831
  {
6810
6832
  "kind": "Interface",
6811
6833
  "canonicalReference": "@microsoft/fast-element!FASTElement:interface",
@@ -7854,6 +7876,363 @@
7854
7876
  ],
7855
7877
  "implementsTokenRanges": []
7856
7878
  },
7879
+ {
7880
+ "kind": "Interface",
7881
+ "canonicalReference": "@microsoft/fast-element!FASTGlobal:interface",
7882
+ "docComment": "/**\n * The FAST global.\n *\n * @public\n */\n",
7883
+ "excerptTokens": [
7884
+ {
7885
+ "kind": "Content",
7886
+ "text": "export interface FASTGlobal "
7887
+ }
7888
+ ],
7889
+ "releaseTag": "Public",
7890
+ "name": "FASTGlobal",
7891
+ "members": [
7892
+ {
7893
+ "kind": "MethodSignature",
7894
+ "canonicalReference": "@microsoft/fast-element!FASTGlobal#addMessages:member(1)",
7895
+ "docComment": "/**\n * Adds debug messages for errors and warnings.\n *\n * @remarks\n *\n * Message can include placeholders like $\\{name\\} which can be replaced by values passed at runtime.\n *\n * @param messages - The message dictionary to add.\n */\n",
7896
+ "excerptTokens": [
7897
+ {
7898
+ "kind": "Content",
7899
+ "text": "addMessages(messages: "
7900
+ },
7901
+ {
7902
+ "kind": "Reference",
7903
+ "text": "Record",
7904
+ "canonicalReference": "!Record:type"
7905
+ },
7906
+ {
7907
+ "kind": "Content",
7908
+ "text": "<number, string>"
7909
+ },
7910
+ {
7911
+ "kind": "Content",
7912
+ "text": "): "
7913
+ },
7914
+ {
7915
+ "kind": "Content",
7916
+ "text": "void"
7917
+ },
7918
+ {
7919
+ "kind": "Content",
7920
+ "text": ";"
7921
+ }
7922
+ ],
7923
+ "isOptional": false,
7924
+ "returnTypeTokenRange": {
7925
+ "startIndex": 4,
7926
+ "endIndex": 5
7927
+ },
7928
+ "releaseTag": "Public",
7929
+ "overloadIndex": 1,
7930
+ "parameters": [
7931
+ {
7932
+ "parameterName": "messages",
7933
+ "parameterTypeTokenRange": {
7934
+ "startIndex": 1,
7935
+ "endIndex": 3
7936
+ },
7937
+ "isOptional": false
7938
+ }
7939
+ ],
7940
+ "name": "addMessages"
7941
+ },
7942
+ {
7943
+ "kind": "MethodSignature",
7944
+ "canonicalReference": "@microsoft/fast-element!FASTGlobal#error:member(1)",
7945
+ "docComment": "/**\n * Creates an error.\n *\n * @param code - The error code to send.\n *\n * @param values - Values relevant for the error message.\n */\n",
7946
+ "excerptTokens": [
7947
+ {
7948
+ "kind": "Content",
7949
+ "text": "error(code: "
7950
+ },
7951
+ {
7952
+ "kind": "Content",
7953
+ "text": "number"
7954
+ },
7955
+ {
7956
+ "kind": "Content",
7957
+ "text": ", values?: "
7958
+ },
7959
+ {
7960
+ "kind": "Reference",
7961
+ "text": "Record",
7962
+ "canonicalReference": "!Record:type"
7963
+ },
7964
+ {
7965
+ "kind": "Content",
7966
+ "text": "<string, any>"
7967
+ },
7968
+ {
7969
+ "kind": "Content",
7970
+ "text": "): "
7971
+ },
7972
+ {
7973
+ "kind": "Reference",
7974
+ "text": "Error",
7975
+ "canonicalReference": "!Error:interface"
7976
+ },
7977
+ {
7978
+ "kind": "Content",
7979
+ "text": ";"
7980
+ }
7981
+ ],
7982
+ "isOptional": false,
7983
+ "returnTypeTokenRange": {
7984
+ "startIndex": 6,
7985
+ "endIndex": 7
7986
+ },
7987
+ "releaseTag": "Public",
7988
+ "overloadIndex": 1,
7989
+ "parameters": [
7990
+ {
7991
+ "parameterName": "code",
7992
+ "parameterTypeTokenRange": {
7993
+ "startIndex": 1,
7994
+ "endIndex": 2
7995
+ },
7996
+ "isOptional": false
7997
+ },
7998
+ {
7999
+ "parameterName": "values",
8000
+ "parameterTypeTokenRange": {
8001
+ "startIndex": 3,
8002
+ "endIndex": 5
8003
+ },
8004
+ "isOptional": true
8005
+ }
8006
+ ],
8007
+ "name": "error"
8008
+ },
8009
+ {
8010
+ "kind": "MethodSignature",
8011
+ "canonicalReference": "@microsoft/fast-element!FASTGlobal#getById:member(1)",
8012
+ "docComment": "/**\n * Gets a kernel value.\n *\n * @param id - The id to get the value for.\n *\n * @param initialize - Creates the initial value for the id if not already existing.\n */\n",
8013
+ "excerptTokens": [
8014
+ {
8015
+ "kind": "Content",
8016
+ "text": "getById<T>(id: "
8017
+ },
8018
+ {
8019
+ "kind": "Content",
8020
+ "text": "string | number"
8021
+ },
8022
+ {
8023
+ "kind": "Content",
8024
+ "text": "): "
8025
+ },
8026
+ {
8027
+ "kind": "Content",
8028
+ "text": "T | null"
8029
+ },
8030
+ {
8031
+ "kind": "Content",
8032
+ "text": ";"
8033
+ }
8034
+ ],
8035
+ "isOptional": false,
8036
+ "returnTypeTokenRange": {
8037
+ "startIndex": 3,
8038
+ "endIndex": 4
8039
+ },
8040
+ "releaseTag": "Public",
8041
+ "overloadIndex": 1,
8042
+ "parameters": [
8043
+ {
8044
+ "parameterName": "id",
8045
+ "parameterTypeTokenRange": {
8046
+ "startIndex": 1,
8047
+ "endIndex": 2
8048
+ },
8049
+ "isOptional": false
8050
+ }
8051
+ ],
8052
+ "typeParameters": [
8053
+ {
8054
+ "typeParameterName": "T",
8055
+ "constraintTokenRange": {
8056
+ "startIndex": 0,
8057
+ "endIndex": 0
8058
+ },
8059
+ "defaultTypeTokenRange": {
8060
+ "startIndex": 0,
8061
+ "endIndex": 0
8062
+ }
8063
+ }
8064
+ ],
8065
+ "name": "getById"
8066
+ },
8067
+ {
8068
+ "kind": "MethodSignature",
8069
+ "canonicalReference": "@microsoft/fast-element!FASTGlobal#getById:member(2)",
8070
+ "docComment": "",
8071
+ "excerptTokens": [
8072
+ {
8073
+ "kind": "Content",
8074
+ "text": "getById<T>(id: "
8075
+ },
8076
+ {
8077
+ "kind": "Content",
8078
+ "text": "string | number"
8079
+ },
8080
+ {
8081
+ "kind": "Content",
8082
+ "text": ", initialize: "
8083
+ },
8084
+ {
8085
+ "kind": "Content",
8086
+ "text": "() => T"
8087
+ },
8088
+ {
8089
+ "kind": "Content",
8090
+ "text": "): "
8091
+ },
8092
+ {
8093
+ "kind": "Content",
8094
+ "text": "T"
8095
+ },
8096
+ {
8097
+ "kind": "Content",
8098
+ "text": ";"
8099
+ }
8100
+ ],
8101
+ "isOptional": false,
8102
+ "returnTypeTokenRange": {
8103
+ "startIndex": 5,
8104
+ "endIndex": 6
8105
+ },
8106
+ "releaseTag": "Public",
8107
+ "overloadIndex": 2,
8108
+ "parameters": [
8109
+ {
8110
+ "parameterName": "id",
8111
+ "parameterTypeTokenRange": {
8112
+ "startIndex": 1,
8113
+ "endIndex": 2
8114
+ },
8115
+ "isOptional": false
8116
+ },
8117
+ {
8118
+ "parameterName": "initialize",
8119
+ "parameterTypeTokenRange": {
8120
+ "startIndex": 3,
8121
+ "endIndex": 4
8122
+ },
8123
+ "isOptional": false
8124
+ }
8125
+ ],
8126
+ "typeParameters": [
8127
+ {
8128
+ "typeParameterName": "T",
8129
+ "constraintTokenRange": {
8130
+ "startIndex": 0,
8131
+ "endIndex": 0
8132
+ },
8133
+ "defaultTypeTokenRange": {
8134
+ "startIndex": 0,
8135
+ "endIndex": 0
8136
+ }
8137
+ }
8138
+ ],
8139
+ "name": "getById"
8140
+ },
8141
+ {
8142
+ "kind": "PropertySignature",
8143
+ "canonicalReference": "@microsoft/fast-element!FASTGlobal#versions:member",
8144
+ "docComment": "/**\n * The list of loaded versions.\n */\n",
8145
+ "excerptTokens": [
8146
+ {
8147
+ "kind": "Content",
8148
+ "text": "readonly versions: "
8149
+ },
8150
+ {
8151
+ "kind": "Content",
8152
+ "text": "string[]"
8153
+ },
8154
+ {
8155
+ "kind": "Content",
8156
+ "text": ";"
8157
+ }
8158
+ ],
8159
+ "isOptional": false,
8160
+ "releaseTag": "Public",
8161
+ "name": "versions",
8162
+ "propertyTypeTokenRange": {
8163
+ "startIndex": 1,
8164
+ "endIndex": 2
8165
+ }
8166
+ },
8167
+ {
8168
+ "kind": "MethodSignature",
8169
+ "canonicalReference": "@microsoft/fast-element!FASTGlobal#warn:member(1)",
8170
+ "docComment": "/**\n * Sends a warning to the developer.\n *\n * @param code - The warning code to send.\n *\n * @param values - Values relevant for the warning message.\n */\n",
8171
+ "excerptTokens": [
8172
+ {
8173
+ "kind": "Content",
8174
+ "text": "warn(code: "
8175
+ },
8176
+ {
8177
+ "kind": "Content",
8178
+ "text": "number"
8179
+ },
8180
+ {
8181
+ "kind": "Content",
8182
+ "text": ", values?: "
8183
+ },
8184
+ {
8185
+ "kind": "Reference",
8186
+ "text": "Record",
8187
+ "canonicalReference": "!Record:type"
8188
+ },
8189
+ {
8190
+ "kind": "Content",
8191
+ "text": "<string, any>"
8192
+ },
8193
+ {
8194
+ "kind": "Content",
8195
+ "text": "): "
8196
+ },
8197
+ {
8198
+ "kind": "Content",
8199
+ "text": "void"
8200
+ },
8201
+ {
8202
+ "kind": "Content",
8203
+ "text": ";"
8204
+ }
8205
+ ],
8206
+ "isOptional": false,
8207
+ "returnTypeTokenRange": {
8208
+ "startIndex": 6,
8209
+ "endIndex": 7
8210
+ },
8211
+ "releaseTag": "Public",
8212
+ "overloadIndex": 1,
8213
+ "parameters": [
8214
+ {
8215
+ "parameterName": "code",
8216
+ "parameterTypeTokenRange": {
8217
+ "startIndex": 1,
8218
+ "endIndex": 2
8219
+ },
8220
+ "isOptional": false
8221
+ },
8222
+ {
8223
+ "parameterName": "values",
8224
+ "parameterTypeTokenRange": {
8225
+ "startIndex": 3,
8226
+ "endIndex": 5
8227
+ },
8228
+ "isOptional": true
8229
+ }
8230
+ ],
8231
+ "name": "warn"
8232
+ }
8233
+ ],
8234
+ "extendsTokenRanges": []
8235
+ },
7857
8236
  {
7858
8237
  "kind": "Interface",
7859
8238
  "canonicalReference": "@microsoft/fast-element!HostBehavior:interface",
@@ -1078,7 +1078,11 @@ export declare interface ExpressionObserver<TSource = any, TReturn = any, TParen
1078
1078
  bind(controller: ExpressionController<TSource, TParent>): TReturn;
1079
1079
  }
1080
1080
 
1081
- /* Excluded from this release type: FAST */
1081
+ /**
1082
+ * The FAST global.
1083
+ * @public
1084
+ */
1085
+ export declare const FAST: FASTGlobal;
1082
1086
 
1083
1087
  /**
1084
1088
  * Represents a custom element based on the FASTElement infrastructure.
@@ -1215,7 +1219,43 @@ export declare class FASTElementDefinition<TType extends Constructable<HTMLEleme
1215
1219
  static readonly getForInstance: (object: any) => FASTElementDefinition<Constructable<HTMLElement>> | undefined;
1216
1220
  }
1217
1221
 
1218
- /* Excluded from this release type: FASTGlobal */
1222
+ /**
1223
+ * The FAST global.
1224
+ * @public
1225
+ */
1226
+ export declare interface FASTGlobal {
1227
+ /**
1228
+ * The list of loaded versions.
1229
+ */
1230
+ readonly versions: string[];
1231
+ /**
1232
+ * Gets a kernel value.
1233
+ * @param id - The id to get the value for.
1234
+ * @param initialize - Creates the initial value for the id if not already existing.
1235
+ */
1236
+ getById<T>(id: string | number): T | null;
1237
+ getById<T>(id: string | number, initialize: () => T): T;
1238
+ /**
1239
+ * Sends a warning to the developer.
1240
+ * @param code - The warning code to send.
1241
+ * @param values - Values relevant for the warning message.
1242
+ */
1243
+ warn(code: number, values?: Record<string, any>): void;
1244
+ /**
1245
+ * Creates an error.
1246
+ * @param code - The error code to send.
1247
+ * @param values - Values relevant for the error message.
1248
+ */
1249
+ error(code: number, values?: Record<string, any>): Error;
1250
+ /**
1251
+ * Adds debug messages for errors and warnings.
1252
+ * @param messages - The message dictionary to add.
1253
+ * @remarks
1254
+ * Message can include placeholders like $\{name\} which can be
1255
+ * replaced by values passed at runtime.
1256
+ */
1257
+ addMessages(messages: Record<number, string>): void;
1258
+ }
1219
1259
 
1220
1260
  declare function from<TBase extends typeof HTMLElement>(BaseType: TBase): new () => InstanceType<TBase> & FASTElement;
1221
1261
 
@@ -17,6 +17,7 @@ const debugMessages = {
17
17
  [1206 /* directCallToHTMLTagNotAllowed */]: "Calling html`` as a normal function invalidates the security guarantees provided by FAST.",
18
18
  [1207 /* onlySetTemplatePolicyOnce */]: "The DOM Policy for an HTML template can only be set once.",
19
19
  [1208 /* cannotSetTemplatePolicyAfterCompilation */]: "The DOM Policy cannot be set after a template is compiled.",
20
+ [1209 /* blockedByDOMPolicy */]: "'${aspectName}' on '${tagName}' is blocked by the current DOMPolicy.",
20
21
  [1401 /* missingElementDefinition */]: "Missing FASTElement definition.",
21
22
  [1501 /* noRegistrationForContext */]: "No registration for Context/Interface '${name}'.",
22
23
  [1502 /* noFactoryForResolver */]: "Dependency injection resolver for '${key}' returned a null factory.",
@@ -161,7 +162,7 @@ if (globalThis.FAST === void 0) {
161
162
  }
162
163
  /**
163
164
  * The FAST global.
164
- * @internal
165
+ * @public
165
166
  */
166
167
  const FAST = globalThis.FAST;
167
168
  if (FAST.getById === void 0) {
@@ -347,7 +348,10 @@ function safeURL(tagName, aspect, aspectName, sink) {
347
348
  };
348
349
  }
349
350
  function block(tagName, aspect, aspectName, sink) {
350
- throw new Error(`${aspectName} on ${tagName !== null && tagName !== void 0 ? tagName : "text"} is blocked by the current DOMPolicy.`);
351
+ throw FAST.error(1209 /* Message.blockedByDOMPolicy */, {
352
+ aspectName,
353
+ tagName: tagName !== null && tagName !== void 0 ? tagName : "text",
354
+ });
351
355
  }
352
356
  const defaultDOMElementGuards = {
353
357
  a: {
@@ -641,6 +645,10 @@ function tryGuard(aspectGuards, tagName, aspect, aspectName, sink) {
641
645
  }
642
646
  }
643
647
  }
648
+ /**
649
+ * A helper for creating DOM policies.
650
+ * @public
651
+ */
644
652
  const DOMPolicy = Object.freeze({
645
653
  /**
646
654
  * Creates a new DOM Policy object.
@@ -4452,7 +4460,6 @@ class StyleElementStrategy {
4452
4460
  removeStylesFrom(target) {
4453
4461
  target = usableStyleTarget(normalizeStyleTarget(target));
4454
4462
  const styles = target.querySelectorAll(`.${this.styleClass}`);
4455
- styles[0].parentNode;
4456
4463
  for (let i = 0, ii = styles.length; i < ii; ++i) {
4457
4464
  target.removeChild(styles[i]);
4458
4465
  }