@microsoft/fast-html 1.0.0-alpha.34 → 1.0.0-alpha.35

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.
@@ -1,4 +1,40 @@
1
1
  import { attr } from "@microsoft/fast-element";
2
+ import { deferHydrationAttribute } from "@microsoft/fast-element/element-hydration.js";
3
+ import { composedParent } from "@microsoft/fast-element/utilities.js";
4
+ /**
5
+ * Waits for the `defer-hydration` attribute to be removed from the target element.
6
+ *
7
+ * @param target - The target element to wait for attribute removal
8
+ */
9
+ function waitForAttributeRemoval(target) {
10
+ if (!target.hasAttribute(deferHydrationAttribute)) {
11
+ return Promise.resolve();
12
+ }
13
+ return new Promise(resolve => {
14
+ const observer = new MutationObserver(() => {
15
+ if (!target.hasAttribute(deferHydrationAttribute)) {
16
+ observer.disconnect();
17
+ resolve();
18
+ }
19
+ });
20
+ observer.observe(target, { attributeFilter: [deferHydrationAttribute] });
21
+ });
22
+ }
23
+ /**
24
+ * Waits until all ancestor elements no longer have the `defer-hydration` attribute.
25
+ *
26
+ * @param element - The element to wait for ancestor hydration
27
+ */
28
+ async function waitForAncestorHydration(element) {
29
+ let ancestor = composedParent(element);
30
+ while (ancestor) {
31
+ if (ancestor instanceof HTMLElement &&
32
+ ancestor.hasAttribute(deferHydrationAttribute)) {
33
+ await waitForAttributeRemoval(ancestor);
34
+ }
35
+ ancestor = composedParent(ancestor);
36
+ }
37
+ }
2
38
  /**
3
39
  * A mixin function that extends a base class with additional functionality for
4
40
  * rendering and hydration.
@@ -9,15 +45,25 @@ import { attr } from "@microsoft/fast-element";
9
45
  */
10
46
  export function RenderableFASTElement(BaseCtor) {
11
47
  const C = class extends BaseCtor {
48
+ /**
49
+ * Prepares the element for hydration by calling the user-defined prepare method
50
+ * and waiting for all ancestor elements to be hydrated.
51
+ *
52
+ * @returns A promise that resolves when the element is ready for hydration.
53
+ */
54
+ async _prepare() {
55
+ if (this.prepare) {
56
+ await this.prepare();
57
+ }
58
+ await waitForAncestorHydration(this);
59
+ this.deferHydration = false;
60
+ }
12
61
  constructor(...args) {
13
- var _a, _b;
14
62
  super(...args);
15
63
  this.deferHydration = true;
16
- ((_b = (_a = this.prepare) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : Promise.resolve()).then(() => {
17
- this.deferHydration = false;
18
- });
64
+ void this._prepare();
19
65
  }
20
66
  };
21
- attr({ mode: "boolean", attribute: "defer-hydration" })(C.prototype, "deferHydration");
67
+ attr({ mode: "boolean", attribute: deferHydrationAttribute })(C.prototype, "deferHydration");
22
68
  return C;
23
69
  }
@@ -1,5 +1,5 @@
1
1
  import { Observable } from "@microsoft/fast-element/observable.js";
2
- import { assignObservables } from "./utilities.js";
2
+ import { assignObservables, deepMerge } from "./utilities.js";
3
3
  /**
4
4
  * ObserverMap provides functionality for caching binding paths, extracting root properties,
5
5
  * and defining observable properties on class prototypes
@@ -17,15 +17,21 @@ export class ObserverMap {
17
17
  const getAndAssignObservablesAlias = this.getAndAssignObservables;
18
18
  const schema = this.schema;
19
19
  function instanceResolverChanged(prev, next) {
20
- if (next === null || typeof next !== "object") {
21
- this[propertyName] = next;
20
+ const isObjectAssignment = next !== null && typeof next === "object";
21
+ const isManagedArray = Array.isArray(next) && (next === null || next === void 0 ? void 0 : next.$fastController);
22
+ const shouldAssignProxy = isObjectAssignment && !(next === null || next === void 0 ? void 0 : next.$isProxy) && !isManagedArray;
23
+ const hasExistingProxy = prev !== null && typeof prev === "object" && prev.$isProxy;
24
+ if (shouldAssignProxy) {
25
+ if (hasExistingProxy) {
26
+ deepMerge(prev, next);
27
+ this[`_${propertyName}`] = prev;
28
+ }
29
+ else {
30
+ this[propertyName] = getAndAssignObservablesAlias(this, propertyName, next, schema);
31
+ }
22
32
  }
23
- else if (prev === undefined ||
24
- ((prev === null || prev === void 0 ? void 0 : prev.$isProxy) && !(next === null || next === void 0 ? void 0 : next.$isProxy)) ||
25
- (Array.isArray(prev) &&
26
- Array.isArray(next) &&
27
- !(next === null || next === void 0 ? void 0 : next.$fastController))) {
28
- this[propertyName] = getAndAssignObservablesAlias(this, propertyName, next, schema);
33
+ else if (!isObjectAssignment) {
34
+ this[propertyName] = next;
29
35
  }
30
36
  existingChangedMethod === null || existingChangedMethod === void 0 ? void 0 : existingChangedMethod.call(this, prev, next);
31
37
  }
@@ -1,19 +1,39 @@
1
- import { __awaiter } from "tslib";
2
1
  import { expect, test } from "@playwright/test";
3
2
  import { ObserverMap } from "./observer-map.js";
4
- import { Schema } from "./schema.js";
5
- test.describe("ObserverMap", () => __awaiter(void 0, void 0, void 0, function* () {
3
+ import { Schema, defsPropertyName } from "./schema.js";
4
+ const testElementName = "test-class";
5
+ test.describe("ObserverMap", async () => {
6
6
  let observerMap;
7
- let schema = new Schema("test-class");
7
+ let schema;
8
8
  class TestClass {
9
9
  }
10
- test.beforeEach(() => __awaiter(void 0, void 0, void 0, function* () {
10
+ test.beforeEach(async () => {
11
+ schema = new Schema(testElementName);
11
12
  // Use TestClass.prototype so instances will have the observable properties
12
13
  observerMap = new ObserverMap(TestClass.prototype, schema);
13
- }));
14
- test("should create new instances", () => __awaiter(void 0, void 0, void 0, function* () {
14
+ });
15
+ test("should create new instances", async () => {
15
16
  const instance1 = new ObserverMap(TestClass.prototype, schema);
16
17
  const instance2 = new ObserverMap(TestClass.prototype, schema);
17
18
  expect(instance1).not.toBe(instance2);
18
- }));
19
- }));
19
+ });
20
+ test("proxies direct object assignments", async () => {
21
+ const schemaMap = Schema.jsonSchemaMap.get(testElementName);
22
+ schemaMap.set("someData", {
23
+ $schema: "https://json-schema.org/draft/2019-09/schema",
24
+ $id: `https://fast.design/schemas/${testElementName}/someData.json`,
25
+ type: "object",
26
+ properties: {
27
+ foo: { type: "string" },
28
+ },
29
+ [defsPropertyName]: {},
30
+ });
31
+ observerMap.defineProperties();
32
+ const instance = new TestClass();
33
+ instance.someData = null;
34
+ const nextValue = { foo: "bar" };
35
+ instance.someData = nextValue;
36
+ expect(instance.someData).not.toBe(nextValue);
37
+ expect(instance.someData.$isProxy).toBeTruthy();
38
+ });
39
+ });
@@ -1,15 +1,14 @@
1
- import { __awaiter } from "tslib";
2
1
  import { expect, test } from "@playwright/test";
3
2
  import { refPropertyName, Schema } from "./schema.js";
4
- test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
5
- test("should instantiate with a custom element name without throwing", () => __awaiter(void 0, void 0, void 0, function* () {
3
+ test.describe("Schema", async () => {
4
+ test("should instantiate with a custom element name without throwing", async () => {
6
5
  expect(() => new Schema("my-custom-element")).not.toThrow();
7
- }));
8
- test("should return null when a JSON schema is requested but none exists for that property name", () => __awaiter(void 0, void 0, void 0, function* () {
6
+ });
7
+ test("should return null when a JSON schema is requested but none exists for that property name", async () => {
9
8
  const schema = new Schema("my-custom-element");
10
9
  expect(schema.getSchema("foo")).toEqual(null);
11
- }));
12
- test("should be able to return a JSON schema after adding a path", () => __awaiter(void 0, void 0, void 0, function* () {
10
+ });
11
+ test("should be able to return a JSON schema after adding a path", async () => {
13
12
  const schema = new Schema("my-custom-element");
14
13
  schema.addPath({
15
14
  rootPropertyName: "a",
@@ -25,8 +24,8 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
25
24
  expect(schemaA).not.toBe(null);
26
25
  expect(schemaA.$id).toEqual("https://fast.design/schemas/my-custom-element/a.json");
27
26
  expect(schemaA.$schema).toEqual("https://json-schema.org/draft/2019-09/schema");
28
- }));
29
- test("should add a property and cast the schema as type object if a nested path is given", () => __awaiter(void 0, void 0, void 0, function* () {
27
+ });
28
+ test("should add a property and cast the schema as type object if a nested path is given", async () => {
30
29
  const schema = new Schema("my-custom-element");
31
30
  schema.addPath({
32
31
  rootPropertyName: "a",
@@ -56,8 +55,8 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
56
55
  expect(schemaA.properties).toHaveProperty("b");
57
56
  expect(schemaA.properties.b.properties).toBeDefined();
58
57
  expect(schemaA.properties.b.properties).toHaveProperty("c");
59
- }));
60
- test("should add a new context in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
58
+ });
59
+ test("should add a new context in a schema", async () => {
61
60
  var _a, _b, _c;
62
61
  const schema = new Schema("my-custom-element");
63
62
  schema.addPath({
@@ -78,9 +77,9 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
78
77
  expect((_a = schemaA.$defs) === null || _a === void 0 ? void 0 : _a["item"]).toBeDefined();
79
78
  expect((_b = schemaA.$defs) === null || _b === void 0 ? void 0 : _b["item"].$fast_context).toEqual("items");
80
79
  expect((_c = schemaA.$defs) === null || _c === void 0 ? void 0 : _c["item"].$fast_parent_contexts).toEqual([null]);
81
- }));
82
- test("should add an object to a context in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
83
- var _d, _e, _f, _g, _h, _j;
80
+ });
81
+ test("should add an object to a context in a schema", async () => {
82
+ var _a, _b, _c, _d, _e, _f;
84
83
  const schema = new Schema("my-custom-element");
85
84
  schema.addPath({
86
85
  rootPropertyName: "items",
@@ -107,15 +106,15 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
107
106
  expect(schemaA.$ref).toBeDefined();
108
107
  expect(schemaA.$ref).toEqual("#/$defs/item");
109
108
  expect(schemaA.type).toEqual("array");
110
- expect((_d = schemaA.$defs) === null || _d === void 0 ? void 0 : _d["item"]).toBeDefined();
111
- expect((_e = schemaA.$defs) === null || _e === void 0 ? void 0 : _e["item"].$fast_context).toEqual("items");
112
- expect((_f = schemaA.$defs) === null || _f === void 0 ? void 0 : _f["item"].$fast_parent_contexts).toEqual([null]);
113
- expect((_g = schemaA.$defs) === null || _g === void 0 ? void 0 : _g["item"].properties).toBeDefined();
114
- expect((_h = schemaA.$defs) === null || _h === void 0 ? void 0 : _h["item"].properties["a"]).toBeDefined();
115
- expect((_j = schemaA.$defs) === null || _j === void 0 ? void 0 : _j["item"].properties["a"].type).toEqual("object");
116
- }));
117
- test("should add a nested context in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
118
- var _k, _l, _m, _o, _p;
109
+ expect((_a = schemaA.$defs) === null || _a === void 0 ? void 0 : _a["item"]).toBeDefined();
110
+ expect((_b = schemaA.$defs) === null || _b === void 0 ? void 0 : _b["item"].$fast_context).toEqual("items");
111
+ expect((_c = schemaA.$defs) === null || _c === void 0 ? void 0 : _c["item"].$fast_parent_contexts).toEqual([null]);
112
+ expect((_d = schemaA.$defs) === null || _d === void 0 ? void 0 : _d["item"].properties).toBeDefined();
113
+ expect((_e = schemaA.$defs) === null || _e === void 0 ? void 0 : _e["item"].properties["a"]).toBeDefined();
114
+ expect((_f = schemaA.$defs) === null || _f === void 0 ? void 0 : _f["item"].properties["a"].type).toEqual("object");
115
+ });
116
+ test("should add a nested context in a schema", async () => {
117
+ var _a, _b, _c, _d, _e;
119
118
  const schema = new Schema("my-custom-element");
120
119
  schema.addPath({
121
120
  rootPropertyName: "a",
@@ -139,14 +138,14 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
139
138
  });
140
139
  const schemaA = schema.getSchema("a");
141
140
  expect(schemaA).toBeDefined();
142
- expect((_k = schemaA === null || schemaA === void 0 ? void 0 : schemaA.properties) === null || _k === void 0 ? void 0 : _k["items"]).toBeDefined();
143
- expect((_l = schemaA === null || schemaA === void 0 ? void 0 : schemaA.properties) === null || _l === void 0 ? void 0 : _l["items"].items.$ref).toEqual("#/$defs/item");
144
- expect((_m = schemaA.$defs) === null || _m === void 0 ? void 0 : _m["item"]).toBeDefined();
145
- expect((_o = schemaA.$defs) === null || _o === void 0 ? void 0 : _o["item"].$fast_context).toEqual("items");
146
- expect((_p = schemaA.$defs) === null || _p === void 0 ? void 0 : _p["item"].$fast_parent_contexts).toEqual([null]);
147
- }));
148
- test("should define an object as a nested context in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
149
- var _q, _r, _s, _t, _u, _v, _w;
141
+ expect((_a = schemaA === null || schemaA === void 0 ? void 0 : schemaA.properties) === null || _a === void 0 ? void 0 : _a["items"]).toBeDefined();
142
+ expect((_b = schemaA === null || schemaA === void 0 ? void 0 : schemaA.properties) === null || _b === void 0 ? void 0 : _b["items"].items.$ref).toEqual("#/$defs/item");
143
+ expect((_c = schemaA.$defs) === null || _c === void 0 ? void 0 : _c["item"]).toBeDefined();
144
+ expect((_d = schemaA.$defs) === null || _d === void 0 ? void 0 : _d["item"].$fast_context).toEqual("items");
145
+ expect((_e = schemaA.$defs) === null || _e === void 0 ? void 0 : _e["item"].$fast_parent_contexts).toEqual([null]);
146
+ });
147
+ test("should define an object as a nested context in a schema", async () => {
148
+ var _a, _b, _c, _d, _e, _f, _g;
150
149
  const schema = new Schema("my-custom-element");
151
150
  schema.addPath({
152
151
  rootPropertyName: "a",
@@ -180,15 +179,15 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
180
179
  });
181
180
  const schemaA = schema.getSchema("a");
182
181
  expect(schemaA).toBeDefined();
183
- expect((_q = schemaA.$defs) === null || _q === void 0 ? void 0 : _q["item"]).toBeDefined();
184
- expect((_r = schemaA.$defs) === null || _r === void 0 ? void 0 : _r["item"].$fast_context).toEqual("items");
185
- expect((_s = schemaA.$defs) === null || _s === void 0 ? void 0 : _s["item"].$fast_parent_contexts).toEqual([null]);
186
- expect((_t = schemaA.$defs) === null || _t === void 0 ? void 0 : _t["item"].type).toEqual("object");
187
- expect((_u = schemaA.$defs) === null || _u === void 0 ? void 0 : _u["item"].properties).toBeDefined();
188
- expect((_w = (_v = schemaA.$defs) === null || _v === void 0 ? void 0 : _v["item"].properties) === null || _w === void 0 ? void 0 : _w["b"]).toBeDefined();
189
- }));
190
- test("should define nested contexts in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
191
- var _x, _y, _z, _0, _1, _2;
182
+ expect((_a = schemaA.$defs) === null || _a === void 0 ? void 0 : _a["item"]).toBeDefined();
183
+ expect((_b = schemaA.$defs) === null || _b === void 0 ? void 0 : _b["item"].$fast_context).toEqual("items");
184
+ expect((_c = schemaA.$defs) === null || _c === void 0 ? void 0 : _c["item"].$fast_parent_contexts).toEqual([null]);
185
+ expect((_d = schemaA.$defs) === null || _d === void 0 ? void 0 : _d["item"].type).toEqual("object");
186
+ expect((_e = schemaA.$defs) === null || _e === void 0 ? void 0 : _e["item"].properties).toBeDefined();
187
+ expect((_g = (_f = schemaA.$defs) === null || _f === void 0 ? void 0 : _f["item"].properties) === null || _g === void 0 ? void 0 : _g["b"]).toBeDefined();
188
+ });
189
+ test("should define nested contexts in a schema", async () => {
190
+ var _a, _b, _c, _d, _e, _f;
192
191
  const schema = new Schema("my-custom-element");
193
192
  schema.addPath({
194
193
  rootPropertyName: "a",
@@ -222,15 +221,15 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
222
221
  });
223
222
  const schemaA = schema.getSchema("a");
224
223
  expect(schemaA).toBeDefined();
225
- expect((_x = schemaA.$defs) === null || _x === void 0 ? void 0 : _x["user"]).toBeDefined();
226
- expect((_y = schemaA.$defs) === null || _y === void 0 ? void 0 : _y["user"].$fast_context).toEqual("users");
227
- expect((_z = schemaA.$defs) === null || _z === void 0 ? void 0 : _z["user"].$fast_parent_contexts).toEqual([null]);
228
- expect((_0 = schemaA.$defs) === null || _0 === void 0 ? void 0 : _0["post"]).toBeDefined();
229
- expect((_1 = schemaA.$defs) === null || _1 === void 0 ? void 0 : _1["post"].$fast_context).toEqual("posts");
230
- expect((_2 = schemaA.$defs) === null || _2 === void 0 ? void 0 : _2["post"].$fast_parent_contexts).toEqual([null, "user"]);
231
- }));
232
- test("should define nested contexts with objects in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
233
- var _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23;
224
+ expect((_a = schemaA.$defs) === null || _a === void 0 ? void 0 : _a["user"]).toBeDefined();
225
+ expect((_b = schemaA.$defs) === null || _b === void 0 ? void 0 : _b["user"].$fast_context).toEqual("users");
226
+ expect((_c = schemaA.$defs) === null || _c === void 0 ? void 0 : _c["user"].$fast_parent_contexts).toEqual([null]);
227
+ expect((_d = schemaA.$defs) === null || _d === void 0 ? void 0 : _d["post"]).toBeDefined();
228
+ expect((_e = schemaA.$defs) === null || _e === void 0 ? void 0 : _e["post"].$fast_context).toEqual("posts");
229
+ expect((_f = schemaA.$defs) === null || _f === void 0 ? void 0 : _f["post"].$fast_parent_contexts).toEqual([null, "user"]);
230
+ });
231
+ test("should define nested contexts with objects in a schema", async () => {
232
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
234
233
  const schema = new Schema("my-custom-element");
235
234
  schema.addPath({
236
235
  rootPropertyName: "a",
@@ -284,30 +283,30 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
284
283
  });
285
284
  const schemaA = schema.getSchema("a");
286
285
  expect(schemaA).toBeDefined();
287
- expect((_3 = schemaA.$defs) === null || _3 === void 0 ? void 0 : _3["user"]).toBeDefined();
288
- expect((_4 = schemaA.$defs) === null || _4 === void 0 ? void 0 : _4["user"].$fast_context).toEqual("users");
289
- expect((_5 = schemaA.$defs) === null || _5 === void 0 ? void 0 : _5["user"].$fast_parent_contexts).toEqual([null]);
290
- expect((_6 = schemaA.$defs) === null || _6 === void 0 ? void 0 : _6["user"].type).toEqual("object");
291
- expect((_7 = schemaA.$defs) === null || _7 === void 0 ? void 0 : _7["user"].properties).toBeDefined();
292
- expect((_8 = schemaA.$defs) === null || _8 === void 0 ? void 0 : _8["user"].properties["a"]).toBeDefined();
293
- expect((_9 = schemaA.$defs) === null || _9 === void 0 ? void 0 : _9["user"].properties["a"].properties["b"]).toBeDefined();
294
- expect((_10 = schemaA.$defs) === null || _10 === void 0 ? void 0 : _10["post"]).toBeDefined();
295
- expect((_11 = schemaA.$defs) === null || _11 === void 0 ? void 0 : _11["post"].$fast_context).toEqual("posts");
296
- expect((_12 = schemaA.$defs) === null || _12 === void 0 ? void 0 : _12["post"].$fast_parent_contexts).toEqual([null, "user"]);
297
- expect((_13 = schemaA.$defs) === null || _13 === void 0 ? void 0 : _13["post"].type).toEqual("object");
298
- expect((_14 = schemaA.$defs) === null || _14 === void 0 ? void 0 : _14["post"].properties).toBeDefined();
299
- expect((_15 = schemaA.$defs) === null || _15 === void 0 ? void 0 : _15["post"].properties["c"]).toBeDefined();
300
- expect((_16 = schemaA.$defs) === null || _16 === void 0 ? void 0 : _16["post"].properties["c"].properties["d"]).toBeDefined();
301
- expect((_17 = schemaA.$defs) === null || _17 === void 0 ? void 0 : _17["post"].properties["meta"]).toBeDefined();
302
- expect((_18 = schemaA.$defs) === null || _18 === void 0 ? void 0 : _18["post"].properties["meta"].properties["tags"]).toBeDefined();
303
- expect((_19 = schemaA.$defs) === null || _19 === void 0 ? void 0 : _19["post"].properties["meta"].properties["tags"].items).toBeDefined();
304
- expect((_20 = schemaA.$defs) === null || _20 === void 0 ? void 0 : _20["post"].properties["meta"].properties["tags"].items.$ref).toEqual("#/$defs/tag");
305
- expect((_21 = schemaA.$defs) === null || _21 === void 0 ? void 0 : _21["tag"]).toBeDefined();
306
- expect((_22 = schemaA.$defs) === null || _22 === void 0 ? void 0 : _22["tag"].$fast_context).toEqual("tags");
307
- expect((_23 = schemaA.$defs) === null || _23 === void 0 ? void 0 : _23["tag"].$fast_parent_contexts).toEqual([null, "user", "post"]);
308
- }));
309
- test("should define an anyOf with a $ref to another schema", () => __awaiter(void 0, void 0, void 0, function* () {
310
- var _24;
286
+ expect((_a = schemaA.$defs) === null || _a === void 0 ? void 0 : _a["user"]).toBeDefined();
287
+ expect((_b = schemaA.$defs) === null || _b === void 0 ? void 0 : _b["user"].$fast_context).toEqual("users");
288
+ expect((_c = schemaA.$defs) === null || _c === void 0 ? void 0 : _c["user"].$fast_parent_contexts).toEqual([null]);
289
+ expect((_d = schemaA.$defs) === null || _d === void 0 ? void 0 : _d["user"].type).toEqual("object");
290
+ expect((_e = schemaA.$defs) === null || _e === void 0 ? void 0 : _e["user"].properties).toBeDefined();
291
+ expect((_f = schemaA.$defs) === null || _f === void 0 ? void 0 : _f["user"].properties["a"]).toBeDefined();
292
+ expect((_g = schemaA.$defs) === null || _g === void 0 ? void 0 : _g["user"].properties["a"].properties["b"]).toBeDefined();
293
+ expect((_h = schemaA.$defs) === null || _h === void 0 ? void 0 : _h["post"]).toBeDefined();
294
+ expect((_j = schemaA.$defs) === null || _j === void 0 ? void 0 : _j["post"].$fast_context).toEqual("posts");
295
+ expect((_k = schemaA.$defs) === null || _k === void 0 ? void 0 : _k["post"].$fast_parent_contexts).toEqual([null, "user"]);
296
+ expect((_l = schemaA.$defs) === null || _l === void 0 ? void 0 : _l["post"].type).toEqual("object");
297
+ expect((_m = schemaA.$defs) === null || _m === void 0 ? void 0 : _m["post"].properties).toBeDefined();
298
+ expect((_o = schemaA.$defs) === null || _o === void 0 ? void 0 : _o["post"].properties["c"]).toBeDefined();
299
+ expect((_p = schemaA.$defs) === null || _p === void 0 ? void 0 : _p["post"].properties["c"].properties["d"]).toBeDefined();
300
+ expect((_q = schemaA.$defs) === null || _q === void 0 ? void 0 : _q["post"].properties["meta"]).toBeDefined();
301
+ expect((_r = schemaA.$defs) === null || _r === void 0 ? void 0 : _r["post"].properties["meta"].properties["tags"]).toBeDefined();
302
+ expect((_s = schemaA.$defs) === null || _s === void 0 ? void 0 : _s["post"].properties["meta"].properties["tags"].items).toBeDefined();
303
+ expect((_t = schemaA.$defs) === null || _t === void 0 ? void 0 : _t["post"].properties["meta"].properties["tags"].items.$ref).toEqual("#/$defs/tag");
304
+ expect((_u = schemaA.$defs) === null || _u === void 0 ? void 0 : _u["tag"]).toBeDefined();
305
+ expect((_v = schemaA.$defs) === null || _v === void 0 ? void 0 : _v["tag"].$fast_context).toEqual("tags");
306
+ expect((_w = schemaA.$defs) === null || _w === void 0 ? void 0 : _w["tag"].$fast_parent_contexts).toEqual([null, "user", "post"]);
307
+ });
308
+ test("should define an anyOf with a $ref to another schema", async () => {
309
+ var _a;
311
310
  const schema = new Schema("my-custom-element");
312
311
  schema.addPath({
313
312
  rootPropertyName: "a",
@@ -328,10 +327,10 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
328
327
  expect(schemaA.$schema).toEqual("https://json-schema.org/draft/2019-09/schema");
329
328
  expect(schemaA.anyOf).not.toBeUndefined();
330
329
  expect(schemaA.anyOf).toHaveLength(1);
331
- expect((_24 = schemaA.anyOf) === null || _24 === void 0 ? void 0 : _24[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/b.json");
332
- }));
333
- test("should define an anyOf with a $ref to multiple schemas", () => __awaiter(void 0, void 0, void 0, function* () {
334
- var _25, _26;
330
+ expect((_a = schemaA.anyOf) === null || _a === void 0 ? void 0 : _a[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/b.json");
331
+ });
332
+ test("should define an anyOf with a $ref to multiple schemas", async () => {
333
+ var _a, _b;
335
334
  const schema = new Schema("my-custom-element");
336
335
  schema.addPath({
337
336
  rootPropertyName: "a",
@@ -365,10 +364,10 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
365
364
  expect(schemaA.$schema).toEqual("https://json-schema.org/draft/2019-09/schema");
366
365
  expect(schemaA.anyOf).not.toBeUndefined();
367
366
  expect(schemaA.anyOf).toHaveLength(2);
368
- expect((_25 = schemaA.anyOf) === null || _25 === void 0 ? void 0 : _25[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/b.json");
369
- expect((_26 = schemaA.anyOf) === null || _26 === void 0 ? void 0 : _26[1].$ref).toEqual("https://fast.design/schemas/my-custom-element-3/c.json");
370
- }));
371
- test("should define an anyOf with a $ref to another schema in a nested object", () => __awaiter(void 0, void 0, void 0, function* () {
367
+ expect((_a = schemaA.anyOf) === null || _a === void 0 ? void 0 : _a[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/b.json");
368
+ expect((_b = schemaA.anyOf) === null || _b === void 0 ? void 0 : _b[1].$ref).toEqual("https://fast.design/schemas/my-custom-element-3/c.json");
369
+ });
370
+ test("should define an anyOf with a $ref to another schema in a nested object", async () => {
372
371
  const schema = new Schema("my-custom-element");
373
372
  schema.addPath({
374
373
  rootPropertyName: "a",
@@ -398,8 +397,8 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
398
397
  expect(schemaA.properties.b.properties.c).toBeDefined();
399
398
  expect(schemaA.properties.b.properties.c.anyOf).not.toBeUndefined();
400
399
  expect(schemaA.properties.b.properties.c.anyOf[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/test.json");
401
- }));
402
- test("should define an anyOf with a $ref to multiple schemas in a nested object", () => __awaiter(void 0, void 0, void 0, function* () {
400
+ });
401
+ test("should define an anyOf with a $ref to multiple schemas in a nested object", async () => {
403
402
  const schema = new Schema("my-custom-element");
404
403
  schema.addPath({
405
404
  rootPropertyName: "a",
@@ -443,9 +442,9 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
443
442
  expect(schemaA.properties.b.properties.c.anyOf).not.toBeUndefined();
444
443
  expect(schemaA.properties.b.properties.c.anyOf[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/test.json");
445
444
  expect(schemaA.properties.b.properties.c.anyOf[1].$ref).toEqual("https://fast.design/schemas/my-custom-element-3/test-2.json");
446
- }));
447
- test("should define an anyOf with a $ref in a nested object in a context", () => __awaiter(void 0, void 0, void 0, function* () {
448
- var _27, _28, _29, _30, _31, _32, _33, _34, _35;
445
+ });
446
+ test("should define an anyOf with a $ref in a nested object in a context", async () => {
447
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
449
448
  const schema = new Schema("my-custom-element");
450
449
  schema.addPath({
451
450
  rootPropertyName: "a",
@@ -472,14 +471,14 @@ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
472
471
  });
473
472
  const schemaA = schema.getSchema("a");
474
473
  expect(schemaA).toBeDefined();
475
- expect((_27 = schemaA.$defs) === null || _27 === void 0 ? void 0 : _27["user"]).toBeDefined();
476
- expect((_28 = schemaA.$defs) === null || _28 === void 0 ? void 0 : _28["user"].$fast_context).toEqual("users");
477
- expect((_29 = schemaA.$defs) === null || _29 === void 0 ? void 0 : _29["user"].$fast_parent_contexts).toEqual([null]);
478
- expect((_30 = schemaA.$defs) === null || _30 === void 0 ? void 0 : _30["user"].type).toEqual("object");
479
- expect((_31 = schemaA.$defs) === null || _31 === void 0 ? void 0 : _31["user"].properties).toBeDefined();
480
- expect((_32 = schemaA.$defs) === null || _32 === void 0 ? void 0 : _32["user"].properties["a"]).toBeDefined();
481
- expect((_33 = schemaA.$defs) === null || _33 === void 0 ? void 0 : _33["user"].properties["a"].properties["b"]).toBeDefined();
482
- expect((_34 = schemaA.$defs) === null || _34 === void 0 ? void 0 : _34["user"].properties["a"].properties["b"].anyOf).toHaveLength(1);
483
- expect((_35 = schemaA.$defs) === null || _35 === void 0 ? void 0 : _35["user"].properties["a"].properties["b"].anyOf[0][refPropertyName]).toEqual("https://fast.design/schemas/my-custom-element-2/c.json");
484
- }));
485
- }));
474
+ expect((_a = schemaA.$defs) === null || _a === void 0 ? void 0 : _a["user"]).toBeDefined();
475
+ expect((_b = schemaA.$defs) === null || _b === void 0 ? void 0 : _b["user"].$fast_context).toEqual("users");
476
+ expect((_c = schemaA.$defs) === null || _c === void 0 ? void 0 : _c["user"].$fast_parent_contexts).toEqual([null]);
477
+ expect((_d = schemaA.$defs) === null || _d === void 0 ? void 0 : _d["user"].type).toEqual("object");
478
+ expect((_e = schemaA.$defs) === null || _e === void 0 ? void 0 : _e["user"].properties).toBeDefined();
479
+ expect((_f = schemaA.$defs) === null || _f === void 0 ? void 0 : _f["user"].properties["a"]).toBeDefined();
480
+ expect((_g = schemaA.$defs) === null || _g === void 0 ? void 0 : _g["user"].properties["a"].properties["b"]).toBeDefined();
481
+ expect((_h = schemaA.$defs) === null || _h === void 0 ? void 0 : _h["user"].properties["a"].properties["b"].anyOf).toHaveLength(1);
482
+ expect((_j = schemaA.$defs) === null || _j === void 0 ? void 0 : _j["user"].properties["a"].properties["b"].anyOf[0][refPropertyName]).toEqual("https://fast.design/schemas/my-custom-element-2/c.json");
483
+ });
484
+ });