@alloy-js/json 0.19.0-dev.0 → 0.19.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.
- package/CHANGELOG.md +7 -0
- package/dist/src/components/array.test.d.ts.map +1 -0
- package/dist/{test → src/components}/array.test.js +1 -1
- package/dist/src/components/index.d.ts +5 -5
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +5 -5
- package/dist/src/components/{JsonArray.d.ts → json-array.d.ts} +1 -1
- package/dist/src/components/json-array.d.ts.map +1 -0
- package/dist/src/components/{JsonArray.js → json-array.js} +1 -1
- package/dist/src/components/{JsonObject.d.ts → json-object.d.ts} +1 -1
- package/dist/src/components/json-object.d.ts.map +1 -0
- package/dist/src/components/{JsonObject.js → json-object.js} +1 -1
- package/dist/src/components/{JsonValue.d.ts → json-value.d.ts} +3 -3
- package/dist/src/components/json-value.d.ts.map +1 -0
- package/dist/src/components/{JsonValue.js → json-value.js} +6 -2
- package/dist/src/components/json-value.test.d.ts +2 -0
- package/dist/src/components/json-value.test.d.ts.map +1 -0
- package/dist/src/components/json-value.test.js +41 -0
- package/dist/src/components/object.test.d.ts.map +1 -0
- package/dist/{test → src/components}/object.test.js +3 -3
- package/dist/src/components/primitives.test.d.ts.map +1 -0
- package/dist/src/components/primitives.test.js +6 -0
- package/dist/src/components/{Reference.d.ts → reference.d.ts} +1 -1
- package/dist/src/components/reference.d.ts.map +1 -0
- package/dist/src/components/reference.test.d.ts.map +1 -0
- package/dist/{test → src/components}/reference.test.js +32 -22
- package/dist/src/components/{SourceFile.d.ts → source-file.d.ts} +1 -1
- package/dist/src/components/source-file.d.ts.map +1 -0
- package/dist/src/components/{SourceFile.js → source-file.js} +1 -1
- package/dist/test/utils.js +2 -2
- package/dist/test/vitest.setup.d.ts +2 -0
- package/dist/test/vitest.setup.d.ts.map +1 -0
- package/dist/test/vitest.setup.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -6
- package/{test → src/components}/array.test.tsx +1 -1
- package/src/components/index.ts +5 -5
- package/src/components/{JsonArray.tsx → json-array.tsx} +1 -1
- package/src/components/{JsonObject.tsx → json-object.tsx} +1 -1
- package/src/components/json-value.test.tsx +44 -0
- package/src/components/{JsonValue.tsx → json-value.tsx} +10 -5
- package/{test → src/components}/object.test.tsx +3 -6
- package/src/components/primitives.test.tsx +15 -0
- package/{test → src/components}/reference.test.tsx +32 -25
- package/src/components/{SourceFile.tsx → source-file.tsx} +1 -1
- package/temp/api.json +25 -29
- package/test/utils.tsx +2 -2
- package/test/vitest.setup.ts +1 -0
- package/tsconfig.json +2 -1
- package/vitest.config.ts +3 -0
- package/dist/src/components/JsonArray.d.ts.map +0 -1
- package/dist/src/components/JsonObject.d.ts.map +0 -1
- package/dist/src/components/JsonValue.d.ts.map +0 -1
- package/dist/src/components/Reference.d.ts.map +0 -1
- package/dist/src/components/SourceFile.d.ts.map +0 -1
- package/dist/test/array.test.d.ts.map +0 -1
- package/dist/test/object.test.d.ts.map +0 -1
- package/dist/test/primitives.test.d.ts.map +0 -1
- package/dist/test/primitives.test.js +0 -12
- package/dist/test/reference.test.d.ts.map +0 -1
- package/dist/test/vitest.d.js +0 -1
- package/test/primitives.test.tsx +0 -16
- package/test/vitest.d.ts +0 -16
- /package/dist/{test → src/components}/array.test.d.ts +0 -0
- /package/dist/{test → src/components}/object.test.d.ts +0 -0
- /package/dist/{test → src/components}/primitives.test.d.ts +0 -0
- /package/dist/src/components/{Reference.js → reference.js} +0 -0
- /package/dist/{test → src/components}/reference.test.d.ts +0 -0
- /package/src/components/{Reference.tsx → reference.tsx} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.test.d.ts","sourceRoot":"","sources":["../../../src/components/array.test.tsx"],"names":[],"mappings":"AACA,OAAO,wBAAwB,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { reactive, renderTree } from "@alloy-js/core";
|
|
|
2
2
|
import "@alloy-js/core/testing";
|
|
3
3
|
import { d, printTree } from "@alloy-js/core/testing";
|
|
4
4
|
import { expect, it } from "vitest";
|
|
5
|
-
import { jsonTest } from "
|
|
5
|
+
import { jsonTest } from "../../test/utils.js";
|
|
6
6
|
it("renders empty arrays", () => {
|
|
7
7
|
const template = jsonTest([]);
|
|
8
8
|
expect(template).toRenderTo(`[]`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
1
|
+
export * from "./json-array.jsx";
|
|
2
|
+
export * from "./json-object.jsx";
|
|
3
|
+
export * from "./json-value.jsx";
|
|
4
|
+
export * from "./reference.jsx";
|
|
5
|
+
export * from "./source-file.jsx";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
1
|
+
export * from "./json-array.js";
|
|
2
|
+
export * from "./json-object.js";
|
|
3
|
+
export * from "./json-value.js";
|
|
4
|
+
export * from "./reference.js";
|
|
5
|
+
export * from "./source-file.js";
|
|
@@ -56,4 +56,4 @@ export type JsonArrayElementProps = JsonArrayElementPropsWithJsValue | JsonArray
|
|
|
56
56
|
* @see {@link @alloy-js/core#(MemberDeclarationContext:variable)}
|
|
57
57
|
*/
|
|
58
58
|
export declare function JsonArrayElement(props: JsonArrayElementProps): Children;
|
|
59
|
-
//# sourceMappingURL=
|
|
59
|
+
//# sourceMappingURL=json-array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-array.d.ts","sourceRoot":"","sources":["../../../src/components/json-array.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQR,MAAM,EAGP,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,kBAAkB;IACjC;;;QAGI;IACJ,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE;;OAEG;IACH,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GACtB,yBAAyB,GACzB,0BAA0B,CAAC;AAE/B;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,YA0C9C;AAED;;;GAGG;AACH,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,MAAM,qBAAqB,GAC7B,gCAAgC,GAChC,iCAAiC,CAAC;AAEtC;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,YA4B5D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { For, Indent, List, MemberDeclaration, MemberScope, onCleanup, OutputSymbolFlags, useMemberDeclaration, useMemberScope } from "@alloy-js/core";
|
|
3
3
|
import { JsonOutputSymbol } from "../symbols/json-symbol.js";
|
|
4
|
-
import { JsonValue } from "./
|
|
4
|
+
import { JsonValue } from "./json-value.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a JSON Array by serializing the given JavaScript array to JSON.
|
|
@@ -64,4 +64,4 @@ export type ObjectPropertyProps = ObjectPropertyPropsWithChildren | ObjectProper
|
|
|
64
64
|
* @see {@link @alloy-js/core#(MemberDeclarationContext:variable)}
|
|
65
65
|
*/
|
|
66
66
|
export declare function JsonObjectProperty(props: ObjectPropertyProps): Children;
|
|
67
|
-
//# sourceMappingURL=
|
|
67
|
+
//# sourceMappingURL=json-object.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-object.d.ts","sourceRoot":"","sources":["../../../src/components/json-object.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EASR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,mBAAmB;IAClC;;;QAGI;IACJ,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE3B,KAAK,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IACrE;;;OAGG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/E;AAED,MAAM,MAAM,eAAe,GACvB,2BAA2B,GAC3B,0BAA0B,CAAC;AAE/B;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YA+DhD;AAED;;;GAGG;AACH,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,mBAAmB,GAC3B,+BAA+B,GAC/B,8BAA8B,CAAC;AAEnC;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,YAsB5D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { computed, For, Indent, List, MemberDeclaration, MemberScope, onCleanup, OutputSymbolFlags, useMemberDeclaration } from "@alloy-js/core";
|
|
3
3
|
import { JsonOutputSymbol } from "../symbols/json-symbol.js";
|
|
4
|
-
import { JsonValue } from "./
|
|
4
|
+
import { JsonValue } from "./json-value.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a JSON object by providing children that define the object's contents.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Refkey } from "@alloy-js/core";
|
|
1
|
+
import { Children, Refkey } from "@alloy-js/core";
|
|
2
2
|
export interface JsonValueProps {
|
|
3
3
|
/**
|
|
4
4
|
* The refkey or array of refkeys for the JSON value. When provided, this
|
|
@@ -17,5 +17,5 @@ export interface JsonValueProps {
|
|
|
17
17
|
* value will be serialized to a string, number, boolean, or null as
|
|
18
18
|
* appropriate.
|
|
19
19
|
*/
|
|
20
|
-
export declare function JsonValue(props: JsonValueProps):
|
|
21
|
-
//# sourceMappingURL=
|
|
20
|
+
export declare function JsonValue(props: JsonValueProps): Children;
|
|
21
|
+
//# sourceMappingURL=json-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-value.d.ts","sourceRoot":"","sources":["../../../src/components/json-value.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAwB,MAAM,gBAAgB,CAAC;AAIxE,MAAM,WAAW,cAAc;IAC7B;;;QAGI;IACJ,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE3B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,QAAQ,CA+BzD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { useMemberDeclaration } from "@alloy-js/core";
|
|
3
|
-
import { JsonArray } from "./
|
|
4
|
-
import { JsonObject } from "./
|
|
3
|
+
import { JsonArray } from "./json-array.js";
|
|
4
|
+
import { JsonObject } from "./json-object.js";
|
|
5
5
|
/**
|
|
6
6
|
* Create a JSON value from a JS value. When the provided JS value is an object,
|
|
7
7
|
* the {@link JsonObject} component will be used. When the provided JS value is
|
|
@@ -37,6 +37,10 @@ export function JsonValue(props) {
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
+
if (typeof props.jsValue === "function") {
|
|
41
|
+
// functions are inserted as-is.
|
|
42
|
+
return props.jsValue;
|
|
43
|
+
}
|
|
40
44
|
throw new Error("Cannot emit js value with type of " + typeof props.jsValue);
|
|
41
45
|
}
|
|
42
46
|
function setMemberRefkey(keys) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-value.test.d.ts","sourceRoot":"","sources":["../../../src/components/json-value.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Output } from "@alloy-js/core";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
import { JsonValue } from "./json-value.js";
|
|
5
|
+
import { SourceFile } from "./source-file.js";
|
|
6
|
+
const TestingJsonObject = () => {
|
|
7
|
+
return _$createComponent(JsonValue, {
|
|
8
|
+
jsValue: {
|
|
9
|
+
id: "test-id",
|
|
10
|
+
name: "Test Name",
|
|
11
|
+
nested: () => _$createComponent(Bar, {})
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
const Bar = () => {
|
|
16
|
+
return _$createComponent(JsonValue, {
|
|
17
|
+
jsValue: {
|
|
18
|
+
bar: "Foo"
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
it("compose json data with components", () => {
|
|
23
|
+
expect(_$createComponent(Output, {
|
|
24
|
+
get children() {
|
|
25
|
+
return _$createComponent(SourceFile, {
|
|
26
|
+
path: "test.json",
|
|
27
|
+
get children() {
|
|
28
|
+
return _$createComponent(TestingJsonObject, {});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
})).toRenderTo(`
|
|
33
|
+
{
|
|
34
|
+
"id": "test-id",
|
|
35
|
+
"name": "Test Name",
|
|
36
|
+
"nested": {
|
|
37
|
+
"bar": "Foo"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`);
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.test.d.ts","sourceRoot":"","sources":["../../../src/components/object.test.tsx"],"names":[],"mappings":"AACA,OAAO,wBAAwB,CAAC"}
|
|
@@ -3,9 +3,9 @@ import { List, Output, reactive, renderTree } from "@alloy-js/core";
|
|
|
3
3
|
import "@alloy-js/core/testing";
|
|
4
4
|
import { d, printTree } from "@alloy-js/core/testing";
|
|
5
5
|
import { expect, it } from "vitest";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { jsonTest } from "../../test/utils.js";
|
|
7
|
+
import { JsonObject, JsonObjectProperty } from "./json-object.js";
|
|
8
|
+
import { SourceFile } from "./source-file.js";
|
|
9
9
|
it("renders objects", () => {
|
|
10
10
|
const template = jsonTest({
|
|
11
11
|
a: 1,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.test.d.ts","sourceRoot":"","sources":["../../../src/components/primitives.test.tsx"],"names":[],"mappings":"AACA,OAAO,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsonTest } from "#test/utils.js";
|
|
2
|
+
import "@alloy-js/core/testing";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
it.each([["boolean (true)", true, "true"], ["boolean (false)", false, "false"], ["integer", 10, "10"], ["negative integer", -10, "-10"], ["float", 1.314, "1.314"], ["string", "Hello, world!", `"Hello, world!"`], ["null", null, "null"]])("%s", (_, data, expected) => {
|
|
5
|
+
expect(jsonTest(data)).toRenderTo(expected);
|
|
6
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/components/reference.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,qCAG9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference.test.d.ts","sourceRoot":"","sources":["../../../src/components/reference.test.tsx"],"names":[],"mappings":"AACA,OAAO,wBAAwB,CAAC"}
|
|
@@ -2,10 +2,10 @@ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime
|
|
|
2
2
|
import { Output, refkey, SourceDirectory } from "@alloy-js/core";
|
|
3
3
|
import "@alloy-js/core/testing";
|
|
4
4
|
import { expect, it } from "vitest";
|
|
5
|
-
import { JsonArray, JsonArrayElement } from "
|
|
6
|
-
import { JsonObject, JsonObjectProperty } from "
|
|
7
|
-
import { JsonValue } from "
|
|
8
|
-
import { SourceFile } from "
|
|
5
|
+
import { JsonArray, JsonArrayElement } from "./json-array.js";
|
|
6
|
+
import { JsonObject, JsonObjectProperty } from "./json-object.js";
|
|
7
|
+
import { JsonValue } from "./json-value.js";
|
|
8
|
+
import { SourceFile } from "./source-file.js";
|
|
9
9
|
it("references objects within the same file", () => {
|
|
10
10
|
const objectValue = refkey();
|
|
11
11
|
const nullKey = refkey();
|
|
@@ -52,7 +52,7 @@ it("references objects across files", () => {
|
|
|
52
52
|
const template = _$createComponent(Output, {
|
|
53
53
|
get children() {
|
|
54
54
|
return [_$createComponent(SourceFile, {
|
|
55
|
-
path: "
|
|
55
|
+
path: "test1.json",
|
|
56
56
|
get children() {
|
|
57
57
|
return _$createComponent(JsonObject, {
|
|
58
58
|
refkey: objectValue,
|
|
@@ -70,7 +70,7 @@ it("references objects across files", () => {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
}), _$createComponent(SourceFile, {
|
|
73
|
-
path: "
|
|
73
|
+
path: "test2.json",
|
|
74
74
|
get children() {
|
|
75
75
|
return _$createComponent(JsonObject, {
|
|
76
76
|
get children() {
|
|
@@ -87,14 +87,19 @@ it("references objects across files", () => {
|
|
|
87
87
|
})];
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
-
expect(template).toRenderTo(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
expect(template).toRenderTo({
|
|
91
|
+
"test1.json": `
|
|
92
|
+
{
|
|
93
|
+
"nullValue": null
|
|
94
|
+
}
|
|
95
|
+
`,
|
|
96
|
+
"test2.json": `
|
|
97
|
+
{
|
|
98
|
+
"refToNull": "test1.json#/nullValue",
|
|
99
|
+
"refToObject": "test1.json#"
|
|
100
|
+
}
|
|
101
|
+
`
|
|
102
|
+
});
|
|
98
103
|
});
|
|
99
104
|
it("references objects across files and directories", () => {
|
|
100
105
|
const objectValue = refkey();
|
|
@@ -142,14 +147,19 @@ it("references objects across files and directories", () => {
|
|
|
142
147
|
})];
|
|
143
148
|
}
|
|
144
149
|
});
|
|
145
|
-
expect(template).toRenderTo(
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
expect(template).toRenderTo({
|
|
151
|
+
"subdir/test.json": `
|
|
152
|
+
{
|
|
153
|
+
"nullValue": null
|
|
154
|
+
}
|
|
155
|
+
`,
|
|
156
|
+
"test.json": `
|
|
157
|
+
{
|
|
158
|
+
"refToNull": "subdir/test.json#/nullValue",
|
|
159
|
+
"refToObject": "subdir/test.json#"
|
|
160
|
+
}
|
|
161
|
+
`
|
|
162
|
+
});
|
|
153
163
|
});
|
|
154
164
|
it("references arrays within the same file", () => {
|
|
155
165
|
const arrayValue = refkey();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-file.d.ts","sourceRoot":"","sources":["../../../src/components/source-file.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAIT,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IAEb,sCAAsC;IACtC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAsBhD"}
|
|
@@ -2,7 +2,7 @@ import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/
|
|
|
2
2
|
import { SourceFile as CoreSourceFile, createSourceFileTap, MemberDeclaration } from "@alloy-js/core";
|
|
3
3
|
import { JsonFileContext } from "../context/JsonFileContext.js";
|
|
4
4
|
import { JsonOutputSymbol } from "../symbols/json-symbol.js";
|
|
5
|
-
import { Reference } from "./
|
|
5
|
+
import { Reference } from "./reference.js";
|
|
6
6
|
/**
|
|
7
7
|
* Creates a JSON source file which defines a JSON value.
|
|
8
8
|
*
|
package/dist/test/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { Output } from "@alloy-js/core";
|
|
3
|
-
import { JsonValue } from "../src/components/
|
|
4
|
-
import { SourceFile } from "../src/components/
|
|
3
|
+
import { JsonValue } from "../src/components/json-value.js";
|
|
4
|
+
import { SourceFile } from "../src/components/source-file.js";
|
|
5
5
|
export function jsonTest(jsValue) {
|
|
6
6
|
return _$createComponent(Output, {
|
|
7
7
|
get children() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.setup.d.ts","sourceRoot":"","sources":["../../test/vitest.setup.ts"],"names":[],"mappings":"AAAA,OAAO,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@alloy-js/core/testing";
|