@typespec/emitter-framework 0.11.0-dev.0 → 0.11.0-dev.10
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.
- package/dist/src/core/components/index.d.ts +2 -0
- package/dist/src/core/components/index.d.ts.map +1 -1
- package/dist/src/core/components/index.js +4 -1
- package/dist/src/core/components/index.js.map +1 -0
- package/dist/src/core/components/output.js +2 -1
- package/dist/src/core/components/output.js.map +1 -0
- package/dist/src/core/components/overrides/component-overrides.d.ts +64 -0
- package/dist/src/core/components/overrides/component-overrides.d.ts.map +1 -0
- package/dist/src/core/components/overrides/component-overrides.js +41 -0
- package/dist/src/core/components/overrides/component-overrides.js.map +1 -0
- package/dist/src/core/components/overrides/config.d.ts +28 -0
- package/dist/src/core/components/overrides/config.d.ts.map +1 -0
- package/dist/src/core/components/overrides/config.js +55 -0
- package/dist/src/core/components/overrides/config.js.map +1 -0
- package/dist/src/core/components/overrides/context.d.ts +11 -0
- package/dist/src/core/components/overrides/context.d.ts.map +1 -0
- package/dist/src/core/components/overrides/context.js +9 -0
- package/dist/src/core/components/overrides/context.js.map +1 -0
- package/dist/src/core/context/index.js +2 -1
- package/dist/src/core/context/index.js.map +1 -0
- package/dist/src/core/context/name-policy-context.js +2 -1
- package/dist/src/core/context/name-policy-context.js.map +1 -0
- package/dist/src/core/context/tsp-context.js +2 -1
- package/dist/src/core/context/tsp-context.js.map +1 -0
- package/dist/src/core/index.js +2 -1
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/transport-name-policy.js +2 -1
- package/dist/src/core/transport-name-policy.js.map +1 -0
- package/dist/src/core/write-output.d.ts.map +1 -1
- package/dist/src/core/write-output.js +4 -3
- package/dist/src/core/write-output.js.map +1 -0
- package/dist/src/csharp/components/class/declaration.d.ts +1 -1
- package/dist/src/csharp/components/class/declaration.d.ts.map +1 -1
- package/dist/src/csharp/components/class/declaration.js +14 -5
- package/dist/src/csharp/components/class/declaration.js.map +1 -0
- package/dist/src/csharp/components/class/declaration.test.js +125 -92
- package/dist/src/csharp/components/class/declaration.test.js.map +1 -0
- package/dist/src/csharp/components/enum/declaration.js +2 -1
- package/dist/src/csharp/components/enum/declaration.js.map +1 -0
- package/dist/src/csharp/components/enum/declaration.test.js +52 -88
- package/dist/src/csharp/components/enum/declaration.test.js.map +1 -0
- package/dist/src/csharp/components/index.js +2 -1
- package/dist/src/csharp/components/index.js.map +1 -0
- package/dist/src/csharp/components/property/property.d.ts.map +1 -1
- package/dist/src/csharp/components/property/property.js +40 -14
- package/dist/src/csharp/components/property/property.js.map +1 -0
- package/dist/src/csharp/components/property/property.test.js +129 -29
- package/dist/src/csharp/components/property/property.test.js.map +1 -0
- package/dist/src/csharp/components/type-expression.d.ts.map +1 -1
- package/dist/src/csharp/components/type-expression.js +34 -6
- package/dist/src/csharp/components/type-expression.js.map +1 -0
- package/dist/src/csharp/components/type-expression.test.js +87 -54
- package/dist/src/csharp/components/type-expression.test.js.map +1 -0
- package/dist/src/csharp/components/utils/doc-comments.js +2 -1
- package/dist/src/csharp/components/utils/doc-comments.js.map +1 -0
- package/dist/src/csharp/components/utils/nullable-util.d.ts +4 -0
- package/dist/src/csharp/components/utils/nullable-util.d.ts.map +1 -0
- package/dist/src/csharp/components/utils/nullable-util.js +27 -0
- package/dist/src/csharp/components/utils/nullable-util.js.map +1 -0
- package/dist/src/csharp/components/utils/refkey.js +2 -1
- package/dist/src/csharp/components/utils/refkey.js.map +1 -0
- package/dist/src/csharp/index.js +2 -1
- package/dist/src/csharp/index.js.map +1 -0
- package/dist/src/lib.js +2 -1
- package/dist/src/lib.js.map +1 -0
- package/dist/src/testing/index.js +2 -1
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/testing/scenario-test/code-block-expectation.js +2 -1
- package/dist/src/testing/scenario-test/code-block-expectation.js.map +1 -0
- package/dist/src/testing/scenario-test/code-block-expectation.test.js +2 -1
- package/dist/src/testing/scenario-test/code-block-expectation.test.js.map +1 -0
- package/dist/src/testing/scenario-test/harness.js +8 -2
- package/dist/src/testing/scenario-test/harness.js.map +1 -0
- package/dist/src/testing/scenario-test/index.js +2 -1
- package/dist/src/testing/scenario-test/index.js.map +1 -0
- package/dist/src/testing/scenario-test/snippet-extractor.js +2 -1
- package/dist/src/testing/scenario-test/snippet-extractor.js.map +1 -0
- package/dist/src/typescript/components/array-expression.js +2 -1
- package/dist/src/typescript/components/array-expression.js.map +1 -0
- package/dist/src/typescript/components/arrow-function.js +2 -1
- package/dist/src/typescript/components/arrow-function.js.map +1 -0
- package/dist/src/typescript/components/class-method.js +2 -1
- package/dist/src/typescript/components/class-method.js.map +1 -0
- package/dist/src/typescript/components/enum-declaration.js +2 -1
- package/dist/src/typescript/components/enum-declaration.js.map +1 -0
- package/dist/src/typescript/components/function-declaration.js +2 -1
- package/dist/src/typescript/components/function-declaration.js.map +1 -0
- package/dist/src/typescript/components/function-expression.js +2 -1
- package/dist/src/typescript/components/function-expression.js.map +1 -0
- package/dist/src/typescript/components/function-type.js +2 -1
- package/dist/src/typescript/components/function-type.js.map +1 -0
- package/dist/src/typescript/components/index.js +2 -1
- package/dist/src/typescript/components/index.js.map +1 -0
- package/dist/src/typescript/components/interface-declaration.js +2 -1
- package/dist/src/typescript/components/interface-declaration.js.map +1 -0
- package/dist/src/typescript/components/interface-member.d.ts.map +1 -1
- package/dist/src/typescript/components/interface-member.js +13 -20
- package/dist/src/typescript/components/interface-member.js.map +1 -0
- package/dist/src/typescript/components/interface-method.js +2 -1
- package/dist/src/typescript/components/interface-method.js.map +1 -0
- package/dist/src/typescript/components/record-expression.js +2 -1
- package/dist/src/typescript/components/record-expression.js.map +1 -0
- package/dist/src/typescript/components/static-serializers.js +2 -1
- package/dist/src/typescript/components/static-serializers.js.map +1 -0
- package/dist/src/typescript/components/type-alias-declaration.js +2 -1
- package/dist/src/typescript/components/type-alias-declaration.js.map +1 -0
- package/dist/src/typescript/components/type-declaration.js +2 -1
- package/dist/src/typescript/components/type-declaration.js.map +1 -0
- package/dist/src/typescript/components/type-expression.d.ts +0 -1
- package/dist/src/typescript/components/type-expression.d.ts.map +1 -1
- package/dist/src/typescript/components/type-expression.js +13 -12
- package/dist/src/typescript/components/type-expression.js.map +1 -0
- package/dist/src/typescript/components/type-transform.d.ts.map +1 -1
- package/dist/src/typescript/components/type-transform.js +5 -4
- package/dist/src/typescript/components/type-transform.js.map +1 -0
- package/dist/src/typescript/components/union/declaration.js +2 -1
- package/dist/src/typescript/components/union/declaration.js.map +1 -0
- package/dist/src/typescript/components/union/declaration.test.js +2 -1
- package/dist/src/typescript/components/union/declaration.test.js.map +1 -0
- package/dist/src/typescript/components/union/expression.js +2 -1
- package/dist/src/typescript/components/union/expression.js.map +1 -0
- package/dist/src/typescript/components/union/expression.test.js +2 -1
- package/dist/src/typescript/components/union/expression.test.js.map +1 -0
- package/dist/src/typescript/components/value-expression.js +2 -1
- package/dist/src/typescript/components/value-expression.js.map +1 -0
- package/dist/src/typescript/index.js +2 -1
- package/dist/src/typescript/index.js.map +1 -0
- package/dist/src/typescript/lib.js +2 -1
- package/dist/src/typescript/lib.js.map +1 -0
- package/dist/src/typescript/utils/index.js +2 -1
- package/dist/src/typescript/utils/index.js.map +1 -0
- package/dist/src/typescript/utils/operation.js +2 -1
- package/dist/src/typescript/utils/operation.js.map +1 -0
- package/dist/src/typescript/utils/refkey.js +2 -1
- package/dist/src/typescript/utils/refkey.js.map +1 -0
- package/dist/test/test-host.js +2 -1
- package/dist/test/test-host.js.map +1 -0
- package/dist/test/testing/snippet-extractor-csharp.test.js +2 -1
- package/dist/test/testing/snippet-extractor-csharp.test.js.map +1 -0
- package/dist/test/testing/snippet-extractor-java.test.js +2 -1
- package/dist/test/testing/snippet-extractor-java.test.js.map +1 -0
- package/dist/test/testing/snippet-extractor-python.test.js +2 -1
- package/dist/test/testing/snippet-extractor-python.test.js.map +1 -0
- package/dist/test/testing/snippet-extractor-typescript.test.js +2 -1
- package/dist/test/testing/snippet-extractor-typescript.test.js.map +1 -0
- package/dist/test/typescript/components/arrow-function.test.js +18 -22
- package/dist/test/typescript/components/arrow-function.test.js.map +1 -0
- package/dist/test/typescript/components/component-override.test.d.ts +2 -0
- package/dist/test/typescript/components/component-override.test.d.ts.map +1 -0
- package/dist/test/typescript/components/component-override.test.js +78 -0
- package/dist/test/typescript/components/component-override.test.js.map +1 -0
- package/dist/test/typescript/components/enum-declaration.test.js +2 -1
- package/dist/test/typescript/components/enum-declaration.test.js.map +1 -0
- package/dist/test/typescript/components/function-declaration.test.js +3 -2
- package/dist/test/typescript/components/function-declaration.test.js.map +1 -0
- package/dist/test/typescript/components/function-expression.test.js +18 -22
- package/dist/test/typescript/components/function-expression.test.js.map +1 -0
- package/dist/test/typescript/components/function-type.test.js +18 -22
- package/dist/test/typescript/components/function-type.test.js.map +1 -0
- package/dist/test/typescript/components/interface-declaration.test.js +3 -2
- package/dist/test/typescript/components/interface-declaration.test.js.map +1 -0
- package/dist/test/typescript/components/interface-method.test.js +37 -45
- package/dist/test/typescript/components/interface-method.test.js.map +1 -0
- package/dist/test/typescript/components/member-expression.test.js +2 -1
- package/dist/test/typescript/components/member-expression.test.js.map +1 -0
- package/dist/test/typescript/components/type-alias-declaration.test.js +8 -5
- package/dist/test/typescript/components/type-alias-declaration.test.js.map +1 -0
- package/dist/test/typescript/components/type-transform.test.js +29 -27
- package/dist/test/typescript/components/type-transform.test.js.map +1 -0
- package/dist/test/typescript/components/value-expression.test.js +3 -2
- package/dist/test/typescript/components/value-expression.test.js.map +1 -0
- package/dist/test/typescript/utils.js +2 -1
- package/dist/test/typescript/utils.js.map +1 -0
- package/dist/test/utils.d.ts +1 -0
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +13 -3
- package/dist/test/utils.js.map +1 -0
- package/dist/test/vitest.setup.js +2 -1
- package/dist/test/vitest.setup.js.map +1 -0
- package/package.json +9 -13
- package/src/core/components/index.tsx +2 -0
- package/src/core/components/overrides/component-overrides.tsx +134 -0
- package/src/core/components/overrides/config.ts +85 -0
- package/src/core/components/overrides/context.ts +14 -0
- package/src/core/write-output.ts +2 -2
- package/src/csharp/components/class/declaration.test.tsx +114 -88
- package/src/csharp/components/class/declaration.tsx +13 -3
- package/src/csharp/components/enum/declaration.test.tsx +47 -78
- package/src/csharp/components/property/property.test.tsx +108 -25
- package/src/csharp/components/property/property.tsx +43 -11
- package/src/csharp/components/type-expression.test.tsx +84 -69
- package/src/csharp/components/type-expression.tsx +31 -5
- package/src/csharp/components/utils/nullable-util.ts +25 -0
- package/src/testing/scenario-test/harness.ts +6 -1
- package/src/typescript/components/interface-member.tsx +8 -14
- package/src/typescript/components/type-expression.tsx +7 -8
- package/src/typescript/components/type-transform.tsx +3 -7
- package/test/typescript/components/arrow-function.test.tsx +23 -42
- package/test/typescript/components/component-override.test.tsx +71 -0
- package/test/typescript/components/function-declaration.test.tsx +2 -1
- package/test/typescript/components/function-expression.test.tsx +23 -42
- package/test/typescript/components/function-type.test.tsx +22 -40
- package/test/typescript/components/interface-declaration.test.tsx +1 -1
- package/test/typescript/components/interface-method.test.tsx +50 -92
- package/test/typescript/components/type-alias-declaration.test.tsx +8 -6
- package/test/typescript/components/type-transform.test.tsx +37 -37
- package/test/typescript/components/value-expression.test.tsx +1 -1
- package/test/utils.ts +10 -3
- package/dist/test/typescript/test-host.d.ts +0 -16
- package/dist/test/typescript/test-host.d.ts.map +0 -1
- package/dist/test/typescript/test-host.js +0 -40
- package/test/typescript/test-host.ts +0 -49
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Tester } from "#test/test-host.js";
|
|
2
3
|
import { code, Output } from "@alloy-js/core";
|
|
3
4
|
import * as ts from "@alloy-js/typescript";
|
|
4
5
|
import { SourceFile } from "@alloy-js/typescript";
|
|
6
|
+
import { t } from "@typespec/compiler/testing";
|
|
5
7
|
import { beforeEach, describe, expect, it } from "vitest";
|
|
6
8
|
import { ArraySerializer, DateDeserializer, RecordSerializer } from "../../../src/typescript/components/static-serializers.js";
|
|
7
9
|
import { getTypeTransformerRefkey, ModelTransformExpression, TypeTransformCall, TypeTransformDeclaration } from "../../../src/typescript/components/type-transform.js";
|
|
8
10
|
import { TypeDeclaration } from "../../../src/typescript/index.js";
|
|
9
|
-
import { createEmitterFrameworkTestRunner } from "../test-host.js";
|
|
10
11
|
describe.skip("Typescript Type Transform", () => {
|
|
11
12
|
let testRunner;
|
|
12
13
|
const namePolicy = ts.createTSNamePolicy();
|
|
13
14
|
beforeEach(async () => {
|
|
14
|
-
testRunner = await
|
|
15
|
+
testRunner = await Tester.createInstance();
|
|
15
16
|
});
|
|
16
17
|
describe("Model Transforms", () => {
|
|
17
18
|
describe("ModelTransformExpression", () => {
|
|
18
19
|
it("should render a transform expression to client", async () => {
|
|
19
|
-
const spec = `
|
|
20
|
+
const spec = t.code`
|
|
20
21
|
namespace DemoService;
|
|
21
|
-
@test model Widget {
|
|
22
|
+
@test model ${t.model("Widget")} {
|
|
22
23
|
id: string;
|
|
23
24
|
birth_year: int32;
|
|
24
25
|
color: "blue" | "red";
|
|
@@ -52,9 +53,9 @@ describe.skip("Typescript Type Transform", () => {
|
|
|
52
53
|
}`);
|
|
53
54
|
});
|
|
54
55
|
it("should render a transform expression to wire", async () => {
|
|
55
|
-
const spec = `
|
|
56
|
+
const spec = t.code`
|
|
56
57
|
namespace DemoService;
|
|
57
|
-
@test model Widget {
|
|
58
|
+
@test model ${t.model("Widget")} {
|
|
58
59
|
id: string;
|
|
59
60
|
birth_year: int32;
|
|
60
61
|
color: "blue" | "red";
|
|
@@ -88,9 +89,9 @@ describe.skip("Typescript Type Transform", () => {
|
|
|
88
89
|
}`);
|
|
89
90
|
});
|
|
90
91
|
it("should render a transform expression that contains a utcDateTime to client", async () => {
|
|
91
|
-
const spec = `
|
|
92
|
+
const spec = t.code`
|
|
92
93
|
namespace DemoService;
|
|
93
|
-
@test model Widget {
|
|
94
|
+
@test model ${t.model("Widget")} {
|
|
94
95
|
id: string;
|
|
95
96
|
birth_date: utcDateTime;
|
|
96
97
|
color: "blue" | "red";
|
|
@@ -133,9 +134,9 @@ describe.skip("Typescript Type Transform", () => {
|
|
|
133
134
|
});
|
|
134
135
|
describe("TypeTransformDeclaration", () => {
|
|
135
136
|
it("should render a transform functions for a model containing array", async () => {
|
|
136
|
-
const spec = `
|
|
137
|
+
const spec = t.code`
|
|
137
138
|
namespace DemoService;
|
|
138
|
-
@test model Widget {
|
|
139
|
+
@test model ${t.model("Widget")} {
|
|
139
140
|
id: string;
|
|
140
141
|
my_color: "blue" | "red";
|
|
141
142
|
simple?: string[];
|
|
@@ -205,9 +206,9 @@ describe.skip("Typescript Type Transform", () => {
|
|
|
205
206
|
`);
|
|
206
207
|
});
|
|
207
208
|
it("should render a transform functions for a model containing record", async () => {
|
|
208
|
-
const spec = `
|
|
209
|
+
const spec = t.code`
|
|
209
210
|
namespace DemoService;
|
|
210
|
-
@test model Widget {
|
|
211
|
+
@test model ${t.model("Widget")} {
|
|
211
212
|
id: string;
|
|
212
213
|
my_color: "blue" | "red";
|
|
213
214
|
simple: Record<string>;
|
|
@@ -273,9 +274,9 @@ describe.skip("Typescript Type Transform", () => {
|
|
|
273
274
|
`);
|
|
274
275
|
});
|
|
275
276
|
it("should render a transform functions for a model", async () => {
|
|
276
|
-
const spec = `
|
|
277
|
+
const spec = t.code`
|
|
277
278
|
namespace DemoService;
|
|
278
|
-
@test model Widget {
|
|
279
|
+
@test model ${t.model("Widget")} {
|
|
279
280
|
id: string;
|
|
280
281
|
my_color: "blue" | "red";
|
|
281
282
|
}
|
|
@@ -324,9 +325,9 @@ describe.skip("Typescript Type Transform", () => {
|
|
|
324
325
|
});
|
|
325
326
|
describe("Calling a model transform functions", () => {
|
|
326
327
|
it("should collapse a model with single property", async () => {
|
|
327
|
-
const spec = `
|
|
328
|
+
const spec = t.code`
|
|
328
329
|
namespace DemoService;
|
|
329
|
-
@test model Widget {
|
|
330
|
+
@test model ${t.model("Widget")} {
|
|
330
331
|
id: string;
|
|
331
332
|
}
|
|
332
333
|
`;
|
|
@@ -357,9 +358,9 @@ describe.skip("Typescript Type Transform", () => {
|
|
|
357
358
|
`);
|
|
358
359
|
});
|
|
359
360
|
it("should call transform functions for a model", async () => {
|
|
360
|
-
const spec = `
|
|
361
|
+
const spec = t.code`
|
|
361
362
|
namespace DemoService;
|
|
362
|
-
@test model Widget {
|
|
363
|
+
@test model ${t.model("Widget")} {
|
|
363
364
|
id: string;
|
|
364
365
|
my_color: "blue" | "red";
|
|
365
366
|
}
|
|
@@ -423,17 +424,17 @@ describe.skip("Typescript Type Transform", () => {
|
|
|
423
424
|
Pet,
|
|
424
425
|
Cat,
|
|
425
426
|
Dog
|
|
426
|
-
} = await testRunner.compile(`
|
|
427
|
+
} = await testRunner.compile(t.code`
|
|
427
428
|
@discriminator("kind")
|
|
428
|
-
@test model Pet {
|
|
429
|
+
@test model ${t.model("Pet")} {
|
|
429
430
|
kind: string;
|
|
430
431
|
}
|
|
431
432
|
|
|
432
|
-
@test model Cat extends Pet {
|
|
433
|
+
@test model ${t.model("Cat")} extends Pet {
|
|
433
434
|
kind: "cat";
|
|
434
435
|
}
|
|
435
436
|
|
|
436
|
-
@test model Dog extends Pet {
|
|
437
|
+
@test model ${t.model("Dog")} extends Pet {
|
|
437
438
|
kind: "dog";
|
|
438
439
|
}
|
|
439
440
|
`);
|
|
@@ -529,18 +530,18 @@ describe.skip("Typescript Type Transform", () => {
|
|
|
529
530
|
Pet,
|
|
530
531
|
Cat,
|
|
531
532
|
Dog
|
|
532
|
-
} = await testRunner.compile(`
|
|
533
|
+
} = await testRunner.compile(t.code`
|
|
533
534
|
@discriminator("kind")
|
|
534
|
-
@test union Pet
|
|
535
|
+
@test union ${t.union("Pet")}{
|
|
535
536
|
cat: Cat;
|
|
536
537
|
dog: Dog;
|
|
537
538
|
}
|
|
538
539
|
|
|
539
|
-
@test model Cat
|
|
540
|
+
@test model ${t.model("Cat")} {
|
|
540
541
|
kind: "cat";
|
|
541
542
|
}
|
|
542
543
|
|
|
543
|
-
@test model Dog {
|
|
544
|
+
@test model ${t.model("Dog")} {
|
|
544
545
|
kind: "dog";
|
|
545
546
|
}
|
|
546
547
|
`);
|
|
@@ -628,4 +629,5 @@ describe.skip("Typescript Type Transform", () => {
|
|
|
628
629
|
`);
|
|
629
630
|
});
|
|
630
631
|
});
|
|
631
|
-
});
|
|
632
|
+
});
|
|
633
|
+
//# sourceMappingURL=type-transform.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Tester","code","Output","ts","SourceFile","t","beforeEach","describe","expect","it","ArraySerializer","DateDeserializer","RecordSerializer","getTypeTransformerRefkey","ModelTransformExpression","TypeTransformCall","TypeTransformDeclaration","TypeDeclaration","skip","testRunner","namePolicy","createTSNamePolicy","createInstance","spec","model","Widget","compile","_$createComponent","children","path","type","target","itemPath","toRenderTo","collapse","FunctionCallExpression","args","Pet","Cat","Dog","union"],"sources":["../../../../test/typescript/components/type-transform.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,IAAI,EAAEC,MAAM,QAAQ,gBAAgB;AAC7C,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAC1C,SAASC,UAAU,QAAQ,sBAAsB;AAEjD,SAASC,CAAC,QAA6B,4BAA4B;AACnE,SAASC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACzD,SACEC,eAAe,EACfC,gBAAgB,EAChBC,gBAAgB,QACX,0DAA0D;AACjE,SACEC,wBAAwB,EACxBC,wBAAwB,EACxBC,iBAAiB,EACjBC,wBAAwB,QACnB,sDAAsD;AAC7D,SAASC,eAAe,QAAQ,kCAAkC;AAElEV,QAAQ,CAACW,IAAI,CAAC,2BAA2B,EAAE,MAAM;EAC/C,IAAIC,UAA0B;EAC9B,MAAMC,UAAU,GAAGjB,EAAE,CAACkB,kBAAkB,CAA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AAA,CAC1CX,wBAAwB;gBAACc,IAAI,EAAEQ,GAAG;gBAAEP,MAAM;cAAA,IAAAJ,iBAAA,CAC1CX,wBAAwB;gBAACc,IAAI,EAAEQ,GAAG;gBAAEP,MAAM;cAAA,IAAAJ,iBAAA,CAC1CX,wBAAwB;gBAACc,IAAI,EAAEO,GAAG;gBAAEN,MAAM;cAAA,IAAAJ,iBAAA,CAC1CX,wBAAwB;gBAACc,IAAI,EAAEO,GAAG;gBAAEN,MAAM;cAAA;YAAA;UAAA;QAAA;MAAA,EAGjD,CAAC,CAACE,UAAU,CAAC;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,QAAQ,CAAC;IACL,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { getProgram } from "#test/utils.js";
|
|
2
3
|
import { Output } from "@alloy-js/core";
|
|
3
4
|
import { dedent } from "@alloy-js/core/testing";
|
|
4
5
|
import { SourceFile } from "@alloy-js/typescript";
|
|
@@ -6,7 +7,6 @@ import { Numeric } from "@typespec/compiler";
|
|
|
6
7
|
import { $ } from "@typespec/compiler/typekit";
|
|
7
8
|
import { assert, beforeAll, describe, expect, it } from "vitest";
|
|
8
9
|
import { ValueExpression } from "../../../src/typescript/components/value-expression.js";
|
|
9
|
-
import { getProgram } from "../test-host.js";
|
|
10
10
|
let program;
|
|
11
11
|
beforeAll(async () => {
|
|
12
12
|
program = await getProgram("");
|
|
@@ -195,4 +195,5 @@ function getExampleValue(model) {
|
|
|
195
195
|
const decorator = model?.decorators.find(d => d.definition?.name === "@example");
|
|
196
196
|
assert.exists(decorator?.args[0]?.value, "unable to find example decorator");
|
|
197
197
|
return decorator.args[0].value;
|
|
198
|
-
}
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=value-expression.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getProgram","Output","dedent","SourceFile","Numeric","$","assert","beforeAll","describe","expect","it","ValueExpression","program","value","createString","testValueExpression","createNumeric","digits","entityKind","valueKind","rejects","toThrow","createBoolean","values","tk","namespace","resolveTypeReference","dateRange","models","get","minDate","properties","defaultValue","exists","model","getExampleValue","colors","enums","red","members","green","expected","prefix","_$createComponent","children","path","toRenderTo","decorator","decorators","find","d","definition","name","args"],"sources":["../../../../test/typescript/components/value-expression.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,UAAU,QAAQ,sBAAsB;AACjD,SAIEC,OAAO,QAIF,oBAAoB;AAC3B,SAASC,CAAC,QAAQ,4BAA4B;AAC9C,SAASC,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAChE,SAASC,eAAe,QAAQ,wDAAwD;AAExF,IAAIC,OAAgB;AACpBL,SAAS,CAAC,YAAY;EACpBK,OAAO,GAAG,MAAMZ,UAAU,CAAC,EAAE,CAAC;AAChC,CAAC,CAAC;AAEFU,EAAE,CAAC,iBAAiB,EAAE,YAAY;EAChC,MAAMG,KAAK,GAAGR,CAAC,CAACO,OAAO,CAAC,CAACC,KAAK,CAACC,YAAY,CAAC,MAAM,CAAC;EAEnD,MAAMC,mBAAmB,CAACF,KAAK,EAAE,QAAQ,CAAC;AAC5C,CAAC,CAAC;AAEFL,QAAQ,CAAC,gBAAgB,EAAE,MAAM;EAC/BE,EAAE,CAAC,kBAAkB,EAAE,YAAY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EAAE2B;EACT,CAAC,EACD,GACF,CAAC;AACH,CAAC,CAAC;;AAEF;AACA;AACA;AACA,eAAezB,mBAAmBA,CAACF,KAAY,EAAE4B,QAAgB,EAAE;EACjE,MAAMC,MAAM,GAAG,cAAc;EAE7BjC,MAAM,CAAAkC,iBAAA,CACH1C,MAAM;IAAA,IAAA2C,SAAA;MAAA,OAAAD,iBAAA,CACJxC,UAAU;QAAC0C,IAAI;QAAA,IAAAD,SAAA;UAAA,QACbF,MAAM,EAAAC,iBAAA,CACNhC,eAAe;YAACE,KAAK,EAAEA;UAAK;QAAA;MAAA;IAAA;EAAA,EAGnC,CAAC,CAACiC,UAAU,CAAC,GAAGJ,MAAM,GAAGD,QAAQ,EAAE,CAAC;AACtC;;AAEA;AACA;AACA;AACA,SAASN,eAAeA,CAACD,KAAY,EAAS;EAC5C,MAAMa,SAAS,GAAGb,KAAK,EAAEc,UAAU,CAACC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,UAAU,EAAEC,IAAI,KAAK,UAAU,CAAC;EAClF9C,MAAM,CAAC2B,MAAM,CAACc,SAAS,EAAEM,IAAI,CAAC,CAAC,CAAC,EAAExC,KAAK,EAAE,kCAAkC,CAAC;EAC5E,OAAOkC,SAAS,CAACM,IAAI,CAAC,CAAC,CAAC,CAACxC,KAAK;AAChC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SourceFile","Output","TestFile","props","_$createComponent","program","children","path"],"sources":["../../../test/typescript/utils.tsx"],"sourcesContent":[null],"mappings":";AACA,SAASA,UAAU,QAAQ,sBAAsB;AAEjD,SAASC,MAAM;AAEf,OAAO,SAASC,QAAQA,CAACC,KAA+C,EAAE;EACxE,OAAAC,iBAAA,CACGH,MAAM;IAAA,IAACI,OAAOA,CAAA;MAAA,OAAEF,KAAK,CAACE,OAAO;IAAA;IAAA,IAAAC,SAAA;MAAA,OAAAF,iBAAA,CAC3BJ,UAAU;QAACO,IAAI;QAAA,IAAAD,SAAA;UAAA,OAAYH,KAAK,CAACG,QAAQ;QAAA;MAAA;IAAA;EAAA;AAGhD","ignoreList":[]}
|
package/dist/test/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Children, type OutputDirectory } from "@alloy-js/core";
|
|
2
2
|
import type { Program } from "@typespec/compiler";
|
|
3
3
|
export declare function getEmitOutput(tspCode: string, cb: (program: Program) => Children): Promise<string | (OutputDirectory | import("@alloy-js/core").OutputFile)[]>;
|
|
4
|
+
export declare function getProgram(tspCode: string): Promise<Program>;
|
|
4
5
|
export declare function assertFileContents(res: OutputDirectory, contents: string): void;
|
|
5
6
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/test/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../test/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../test/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,eAAe,EAAU,MAAM,gBAAgB,CAAC;AAG7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,+EAQtF;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,oBAI/C;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,QAKxE"}
|
package/dist/test/utils.js
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
|
+
import { Tester } from "#test/test-host.js";
|
|
1
2
|
import { render } from "@alloy-js/core";
|
|
2
3
|
import { Output } from "@alloy-js/core/stc";
|
|
3
4
|
import { SourceFile } from "@alloy-js/typescript/stc";
|
|
4
5
|
import { assert } from "vitest";
|
|
5
|
-
import { getProgram } from "./typescript/test-host.js";
|
|
6
6
|
export async function getEmitOutput(tspCode, cb) {
|
|
7
7
|
const program = await getProgram(tspCode);
|
|
8
8
|
const res = render(Output().children(SourceFile({
|
|
9
9
|
path: "test.ts"
|
|
10
|
-
}).children(cb(program)))
|
|
10
|
+
}).children(cb(program))), {
|
|
11
|
+
insertFinalNewLine: false
|
|
12
|
+
});
|
|
11
13
|
const testFile = res.contents.find(file => file.path === "test.ts");
|
|
12
14
|
assert("contents" in testFile, "test.ts file does not have contents");
|
|
13
15
|
return testFile.contents;
|
|
14
16
|
}
|
|
17
|
+
export async function getProgram(tspCode) {
|
|
18
|
+
const runner = await Tester.createInstance();
|
|
19
|
+
const {
|
|
20
|
+
program
|
|
21
|
+
} = await runner.compile(tspCode);
|
|
22
|
+
return program;
|
|
23
|
+
}
|
|
15
24
|
export function assertFileContents(res, contents) {
|
|
16
25
|
const testFile = res.contents.find(file => file.path === "test.ts");
|
|
17
26
|
assert(testFile, "test.ts file not rendered");
|
|
18
27
|
assert("contents" in testFile, "test.ts file does not have contents");
|
|
19
28
|
assert.equal(testFile.contents, contents);
|
|
20
|
-
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Tester","render","Output","SourceFile","assert","getEmitOutput","tspCode","cb","program","getProgram","res","children","path","insertFinalNewLine","testFile","contents","find","file","runner","createInstance","compile","assertFileContents","equal"],"sources":["../../test/utils.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SAA8CC,MAAM,QAAQ,gBAAgB;AAC5E,SAASC,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,UAAU,QAAQ,0BAA0B;AAErD,SAASC,MAAM,QAAQ,QAAQ;AAE/B,OAAO,eAAeC,aAAaA,CAACC,OAAe,EAAEC,EAAkC,EAAE;EACvF,MAAMC,OAAO,GAAG,MAAMC,UA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"sources":["../../test/vitest.setup.ts"],"sourcesContent":[null],"mappings":"AAAA,OAAO,wBAAwB","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/emitter-framework",
|
|
3
|
-
"version": "0.11.0-dev.
|
|
3
|
+
"version": "0.11.0-dev.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -41,21 +41,17 @@
|
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"description": "",
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@alloy-js/core": "^0.
|
|
45
|
-
"@alloy-js/csharp": "^0.
|
|
46
|
-
"@alloy-js/typescript": "^0.
|
|
47
|
-
"@typespec/compiler": "^1.3.0"
|
|
48
|
-
"@typespec/http": "^1.3.0",
|
|
49
|
-
"@typespec/rest": "^0.73.0 || >=0.74.0-dev <0.74.0"
|
|
44
|
+
"@alloy-js/core": "^0.20.0",
|
|
45
|
+
"@alloy-js/csharp": "^0.20.0",
|
|
46
|
+
"@alloy-js/typescript": "^0.20.0",
|
|
47
|
+
"@typespec/compiler": "^1.3.0"
|
|
50
48
|
},
|
|
51
49
|
"devDependencies": {
|
|
52
|
-
"@alloy-js/cli": "^0.
|
|
53
|
-
"@alloy-js/core": "^0.
|
|
50
|
+
"@alloy-js/cli": "^0.20.0",
|
|
51
|
+
"@alloy-js/core": "^0.20.0",
|
|
54
52
|
"@alloy-js/rollup-plugin": "^0.1.0",
|
|
55
|
-
"@alloy-js/typescript": "^0.
|
|
53
|
+
"@alloy-js/typescript": "^0.20.0",
|
|
56
54
|
"@typespec/compiler": "^1.3.0",
|
|
57
|
-
"@typespec/http": "^1.3.0",
|
|
58
|
-
"@typespec/rest": "^0.73.0 || >=0.74.0-dev <0.74.0",
|
|
59
55
|
"concurrently": "^9.1.2",
|
|
60
56
|
"pathe": "^2.0.3",
|
|
61
57
|
"prettier": "~3.6.2",
|
|
@@ -64,7 +60,7 @@
|
|
|
64
60
|
"tree-sitter-javascript": "^0.23.0",
|
|
65
61
|
"tree-sitter-python": "^0.23.2",
|
|
66
62
|
"tree-sitter-typescript": "^0.23.0",
|
|
67
|
-
"typescript": "~5.
|
|
63
|
+
"typescript": "~5.9.2",
|
|
68
64
|
"vitest": "^3.1.2",
|
|
69
65
|
"web-tree-sitter": "^0.25.4"
|
|
70
66
|
},
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { type Children, type ComponentDefinition } from "@alloy-js/core";
|
|
2
|
+
import type { ObjectPropertyProps, VarDeclarationProps } from "@alloy-js/typescript";
|
|
3
|
+
import type {
|
|
4
|
+
Enum,
|
|
5
|
+
EnumMember,
|
|
6
|
+
Model,
|
|
7
|
+
ModelProperty,
|
|
8
|
+
Scalar,
|
|
9
|
+
Type,
|
|
10
|
+
Union,
|
|
11
|
+
UnionVariant,
|
|
12
|
+
} from "@typespec/compiler";
|
|
13
|
+
import { useTsp } from "../../context/index.js";
|
|
14
|
+
import {
|
|
15
|
+
type Experimental_ComponentOverridesConfig,
|
|
16
|
+
getOverrideForType,
|
|
17
|
+
getOverridesForTypeKind,
|
|
18
|
+
} from "./config.js";
|
|
19
|
+
import { type ComponentOverridesContext, OverridesContext, useOverrides } from "./context.js";
|
|
20
|
+
|
|
21
|
+
export interface Experimental_OverrideEmitPropsBase<TCustomType extends Type> {
|
|
22
|
+
/**
|
|
23
|
+
* The TypeSpec type to render.
|
|
24
|
+
*/
|
|
25
|
+
type: TCustomType;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The default emitted output for this type.
|
|
29
|
+
*/
|
|
30
|
+
default: Children;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type Experimental_CustomTypeToProps<TCustomType extends Type> =
|
|
34
|
+
TCustomType extends ModelProperty
|
|
35
|
+
? ObjectPropertyProps
|
|
36
|
+
: TCustomType extends EnumMember
|
|
37
|
+
? {}
|
|
38
|
+
: TCustomType extends UnionVariant
|
|
39
|
+
? {}
|
|
40
|
+
: TCustomType extends Model | Scalar | Union | Enum
|
|
41
|
+
? VarDeclarationProps
|
|
42
|
+
: VarDeclarationProps | ObjectPropertyProps;
|
|
43
|
+
|
|
44
|
+
export interface Experimental_OverrideReferenceProps<TCustomType extends Type>
|
|
45
|
+
extends Experimental_OverrideEmitPropsBase<TCustomType> {
|
|
46
|
+
/**
|
|
47
|
+
* The member this type is referenced from, if any. This member may contain
|
|
48
|
+
* additional metadata that should be represented in the emitted output.
|
|
49
|
+
*/
|
|
50
|
+
member?: ModelProperty;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface Experimental_OverrideDeclareProps<TCustomType extends Type>
|
|
54
|
+
extends Experimental_OverrideEmitPropsBase<TCustomType> {
|
|
55
|
+
Declaration: ComponentDefinition<Experimental_CustomTypeToProps<TCustomType>>;
|
|
56
|
+
declarationProps: Experimental_CustomTypeToProps<TCustomType>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type Experimental_OverrideDeclarationComponent<TCustomType extends Type> =
|
|
60
|
+
ComponentDefinition<Experimental_OverrideDeclareProps<TCustomType>>;
|
|
61
|
+
|
|
62
|
+
export type Experimental_OverrideReferenceComponent<TCustomType extends Type> = ComponentDefinition<
|
|
63
|
+
Experimental_OverrideReferenceProps<TCustomType>
|
|
64
|
+
>;
|
|
65
|
+
|
|
66
|
+
export interface Experimental_ComponentOverridesConfigBase<TCustomType extends Type> {
|
|
67
|
+
/**
|
|
68
|
+
* Override when this type is referenced.
|
|
69
|
+
* e.g. When used in <TypeExpression type={type} />
|
|
70
|
+
*/
|
|
71
|
+
reference?: Experimental_OverrideReferenceComponent<TCustomType>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface Experimental_ComponentOverridesProps {
|
|
75
|
+
overrides: Experimental_ComponentOverridesConfig;
|
|
76
|
+
children?: Children;
|
|
77
|
+
}
|
|
78
|
+
export function Experimental_ComponentOverrides(props: Experimental_ComponentOverridesProps) {
|
|
79
|
+
const context: ComponentOverridesContext = {
|
|
80
|
+
overrides: props.overrides,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return <OverridesContext.Provider value={context}>{props.children}</OverridesContext.Provider>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface Experimental_OverrideTypeComponentCommonProps<T extends Type> {
|
|
87
|
+
/**
|
|
88
|
+
* The TypeSpec type to render.
|
|
89
|
+
*/
|
|
90
|
+
type: T;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The default rendering.
|
|
94
|
+
*/
|
|
95
|
+
children: Children;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface Experimental_OverridableComponentReferenceProps<T extends Type>
|
|
99
|
+
extends Experimental_OverrideTypeComponentCommonProps<T> {
|
|
100
|
+
/**
|
|
101
|
+
* Pass when rendering a reference to the provided type or type kind.
|
|
102
|
+
*/
|
|
103
|
+
reference: true;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The member this type is referenced from, if any. This member may contain
|
|
107
|
+
* additional metadata that should be represented in the emitted output.
|
|
108
|
+
*/
|
|
109
|
+
member?: ModelProperty;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export type Experimental_OverridableComponentProps<T extends Type> =
|
|
113
|
+
Experimental_OverridableComponentReferenceProps<T>;
|
|
114
|
+
|
|
115
|
+
export function Experimental_OverridableComponent<T extends Type>(
|
|
116
|
+
props: Experimental_OverridableComponentProps<T>,
|
|
117
|
+
) {
|
|
118
|
+
const options = useOverrides();
|
|
119
|
+
const { $ } = useTsp();
|
|
120
|
+
const descriptor =
|
|
121
|
+
getOverrideForType($.program, props.type, options.overrides) ??
|
|
122
|
+
getOverridesForTypeKind($.program, props.type.kind, options.overrides);
|
|
123
|
+
|
|
124
|
+
if (!descriptor) {
|
|
125
|
+
return <>{props.children}</>;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if ("reference" in props && props.reference && descriptor.reference) {
|
|
129
|
+
const CustomComponent = descriptor.reference;
|
|
130
|
+
return <CustomComponent type={props.type} member={props.member} default={props.children} />;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return <>{props.children}</>;
|
|
134
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Program, Scalar, Type } from "@typespec/compiler";
|
|
2
|
+
import { $ } from "@typespec/compiler/typekit";
|
|
3
|
+
import type { Experimental_ComponentOverridesConfigBase } from "./component-overrides.jsx";
|
|
4
|
+
|
|
5
|
+
const getOverrideForTypeSym: unique symbol = Symbol.for("ef-ts:getOverrideForType");
|
|
6
|
+
const getOverrideForTypeKindSym: unique symbol = Symbol.for("ef-ts:getOverrideForTypeKind");
|
|
7
|
+
|
|
8
|
+
export type Experimental_ComponentOverridesConfig = Experimental_ComponentOverridesClass;
|
|
9
|
+
export const Experimental_ComponentOverridesConfig = function () {
|
|
10
|
+
return new Experimental_ComponentOverridesClass();
|
|
11
|
+
} as {
|
|
12
|
+
new (): Experimental_ComponentOverridesClass;
|
|
13
|
+
(): Experimental_ComponentOverridesClass;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export class Experimental_ComponentOverridesClass {
|
|
17
|
+
#typeEmitOptions: Map<Type, Experimental_ComponentOverridesConfigBase<any>> = new Map();
|
|
18
|
+
#typeKindEmitOptions: Map<Type["kind"], Experimental_ComponentOverridesConfigBase<any>> =
|
|
19
|
+
new Map();
|
|
20
|
+
|
|
21
|
+
forType<const T extends Type>(type: T, options: Experimental_ComponentOverridesConfigBase<T>) {
|
|
22
|
+
this.#typeEmitOptions.set(type, options);
|
|
23
|
+
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
forTypeKind<const TKind extends Type["kind"]>(
|
|
28
|
+
typeKind: TKind,
|
|
29
|
+
options: Experimental_ComponentOverridesConfigBase<Extract<Type, { kind: TKind }>>,
|
|
30
|
+
) {
|
|
31
|
+
this.#typeKindEmitOptions.set(typeKind, options);
|
|
32
|
+
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
[getOverrideForTypeSym](program: Program, type: Type) {
|
|
40
|
+
const options = this.#typeEmitOptions.get(type);
|
|
41
|
+
if (options || !$(program).scalar.is(type) /** || isBuiltIn(program, type) */) {
|
|
42
|
+
return options;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// have a scalar, it's not a built-in scalar, and didn't find options, so
|
|
46
|
+
// see if we have options for a base scalar.
|
|
47
|
+
let currentScalar: Scalar | undefined = type;
|
|
48
|
+
while (
|
|
49
|
+
currentScalar &&
|
|
50
|
+
// !isBuiltIn(program, currentScalar) &&
|
|
51
|
+
!this.#typeEmitOptions.has(currentScalar)
|
|
52
|
+
) {
|
|
53
|
+
currentScalar = currentScalar?.baseScalar;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!currentScalar) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return this.#typeEmitOptions.get(currentScalar);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
[getOverrideForTypeKindSym](program: Program, typeKind: Type["kind"]) {
|
|
67
|
+
return this.#typeKindEmitOptions.get(typeKind);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function getOverrideForType(
|
|
72
|
+
program: Program,
|
|
73
|
+
type: Type,
|
|
74
|
+
options?: Experimental_ComponentOverridesConfig,
|
|
75
|
+
) {
|
|
76
|
+
return options?.[getOverrideForTypeSym](program, type);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function getOverridesForTypeKind(
|
|
80
|
+
program: Program,
|
|
81
|
+
typeKind: Type["kind"],
|
|
82
|
+
options?: Experimental_ComponentOverridesConfig,
|
|
83
|
+
) {
|
|
84
|
+
return options?.[getOverrideForTypeKindSym](program, typeKind);
|
|
85
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createContext, useContext, type ComponentContext } from "@alloy-js/core";
|
|
2
|
+
import type { Experimental_ComponentOverridesConfig } from "./config.js";
|
|
3
|
+
|
|
4
|
+
export interface ComponentOverridesContext {
|
|
5
|
+
overrides?: Experimental_ComponentOverridesConfig;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Context for setting overrides for components
|
|
9
|
+
*/
|
|
10
|
+
export const OverridesContext: ComponentContext<ComponentOverridesContext> = createContext({});
|
|
11
|
+
|
|
12
|
+
export function useOverrides(): ComponentOverridesContext {
|
|
13
|
+
return useContext(OverridesContext)!;
|
|
14
|
+
}
|
package/src/core/write-output.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Children, type OutputDirectory
|
|
1
|
+
import { renderAsync, type Children, type OutputDirectory } from "@alloy-js/core";
|
|
2
2
|
import { emitFile, joinPaths, type Program } from "@typespec/compiler";
|
|
3
3
|
|
|
4
4
|
export async function writeOutput(
|
|
@@ -6,7 +6,7 @@ export async function writeOutput(
|
|
|
6
6
|
rootComponent: Children,
|
|
7
7
|
emitterOutputDir: string,
|
|
8
8
|
) {
|
|
9
|
-
const tree =
|
|
9
|
+
const tree = await renderAsync(rootComponent);
|
|
10
10
|
await writeOutputDirectory(program, tree, emitterOutputDir);
|
|
11
11
|
}
|
|
12
12
|
|