@alloy-js/json 0.24.0-dev.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/dev/src/components/array.test.js +9 -11
  3. package/dist/dev/src/components/array.test.js.map +1 -1
  4. package/dist/dev/src/components/object.test.js +11 -13
  5. package/dist/dev/src/components/object.test.js.map +1 -1
  6. package/dist/dev/src/components/primitives.test.js +0 -1
  7. package/dist/dev/src/components/primitives.test.js.map +1 -1
  8. package/dist/dev/src/components/reference.test.js +49 -50
  9. package/dist/dev/src/components/reference.test.js.map +1 -1
  10. package/dist/src/components/array.test.d.ts +1 -1
  11. package/dist/src/components/array.test.d.ts.map +1 -1
  12. package/dist/src/components/array.test.js +9 -11
  13. package/dist/src/components/array.test.js.map +1 -1
  14. package/dist/src/components/object.test.d.ts +1 -1
  15. package/dist/src/components/object.test.d.ts.map +1 -1
  16. package/dist/src/components/object.test.js +5 -7
  17. package/dist/src/components/object.test.js.map +1 -1
  18. package/dist/src/components/primitives.test.d.ts +1 -1
  19. package/dist/src/components/primitives.test.d.ts.map +1 -1
  20. package/dist/src/components/primitives.test.js +0 -1
  21. package/dist/src/components/primitives.test.js.map +1 -1
  22. package/dist/src/components/reference.test.d.ts +1 -1
  23. package/dist/src/components/reference.test.d.ts.map +1 -1
  24. package/dist/src/components/reference.test.js +0 -1
  25. package/dist/src/components/reference.test.js.map +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/docs/api/components/JsonArrayElement.md +1 -1
  28. package/docs/api/components/JsonObjectProperty.md +1 -1
  29. package/docs/api/components/SourceFile.md +1 -1
  30. package/package.json +11 -10
  31. package/src/components/array.test.tsx +11 -9
  32. package/src/components/object.test.tsx +6 -7
  33. package/src/components/primitives.test.tsx +0 -1
  34. package/src/components/reference.test.tsx +0 -1
  35. package/temp/api.json +37 -21
  36. package/tsdoc-metadata.json +1 -1
  37. package/vitest.config.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alloy-js/json",
3
- "version": "0.24.0-dev.0",
3
+ "version": "0.24.0",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,17 +23,18 @@
23
23
  "author": "brian.terlson@microsoft.com",
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "@alloy-js/core": "~0.23.0 || >= 0.24.0-dev.1",
27
- "pathe": "^2.0.3"
26
+ "pathe": "^2.0.3",
27
+ "@alloy-js/core": "~0.24.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@alloy-js/cli": "~0.23.0 || >= 0.24.0-dev.0",
31
- "@alloy-js/rollup-plugin": "~0.1.1 || >= 0.1.2-dev.1",
32
- "@microsoft/api-extractor": "~7.52.8",
33
- "@rollup/plugin-typescript": "^12.1.2",
34
- "concurrently": "^9.2.0",
35
- "typescript": "^5.8.3",
36
- "vitest": "3.2.4"
30
+ "@microsoft/api-extractor": "~7.58.8",
31
+ "@rollup/plugin-typescript": "^12.3.0",
32
+ "@types/node": "^25.9.2",
33
+ "concurrently": "^10.0.3",
34
+ "typescript": "^6.0.3",
35
+ "vitest": "4.1.8",
36
+ "@alloy-js/cli": "~0.24.0",
37
+ "@alloy-js/rollup-plugin": "~0.1.2"
37
38
  },
38
39
  "type": "module",
39
40
  "scripts": {
@@ -1,6 +1,4 @@
1
- import { reactive, renderTree } from "@alloy-js/core";
2
- import "@alloy-js/core/testing";
3
- import { d, printTree } from "@alloy-js/core/testing";
1
+ import { reactive } from "@alloy-js/core";
4
2
  import { expect, it } from "vitest";
5
3
  import { jsonTest } from "../../test/utils.jsx";
6
4
 
@@ -38,24 +36,28 @@ it("works reactively", () => {
38
36
  const arr = reactive([] as (number | string)[]);
39
37
 
40
38
  const template = jsonTest(arr);
41
- const tree = renderTree(template);
42
39
 
43
- expect(printTree(tree)).toEqual(`[]`);
40
+ expect(template).toRenderTo(`[]`);
41
+
42
+ const tree = template;
44
43
 
45
44
  arr.push(1);
46
- expect(printTree(tree)).toEqual(`[1]`);
45
+ expect(tree).toRenderTo(`[1]`);
47
46
 
48
47
  arr.push(2);
49
- expect(printTree(tree)).toEqual(d`
48
+ expect(tree).toRenderTo(`
50
49
  [1, 2]
51
50
  `);
52
51
 
53
52
  arr.push("this is a long item that should be wrapped");
54
- expect(printTree(tree, { printWidth: 20 })).toEqual(d`
53
+ expect(tree).toRenderTo(
54
+ `
55
55
  [
56
56
  1,
57
57
  2,
58
58
  "this is a long item that should be wrapped"
59
59
  ]
60
- `);
60
+ `,
61
+ { printWidth: 20 },
62
+ );
61
63
  });
@@ -1,6 +1,4 @@
1
- import { List, Output, reactive, renderTree } from "@alloy-js/core";
2
- import "@alloy-js/core/testing";
3
- import { d, printTree } from "@alloy-js/core/testing";
1
+ import { List, Output, reactive } from "@alloy-js/core";
4
2
  import { expect, it } from "vitest";
5
3
  import { jsonTest } from "../../test/utils.jsx";
6
4
  import { JsonObject, JsonObjectProperty } from "./json-object.jsx";
@@ -59,17 +57,18 @@ it("works reactively", () => {
59
57
  const obj = reactive({ a: 1 } as Record<string, unknown>);
60
58
 
61
59
  const template = jsonTest(obj);
62
- const tree = renderTree(template);
63
60
 
64
- expect(printTree(tree)).toEqual(d`
61
+ expect(template).toRenderTo(`
65
62
  {
66
63
  "a": 1
67
64
  }
68
65
  `);
69
66
 
67
+ const tree = template;
68
+
70
69
  (obj.a as any)++;
71
70
 
72
- expect(printTree(tree)).toEqual(d`
71
+ expect(tree).toRenderTo(`
73
72
  {
74
73
  "a": 2
75
74
  }
@@ -77,7 +76,7 @@ it("works reactively", () => {
77
76
 
78
77
  obj.b = "hello";
79
78
 
80
- expect(printTree(tree)).toEqual(d`
79
+ expect(tree).toRenderTo(`
81
80
  {
82
81
  "a": 2,
83
82
  "b": "hello"
@@ -1,5 +1,4 @@
1
1
  import { jsonTest } from "#test/utils.jsx";
2
- import "@alloy-js/core/testing";
3
2
  import { expect, it } from "vitest";
4
3
 
5
4
  it.each([
@@ -1,5 +1,4 @@
1
1
  import { Output, refkey, SourceDirectory } from "@alloy-js/core";
2
- import "@alloy-js/core/testing";
3
2
  import { expect, it } from "vitest";
4
3
  import { JsonArray, JsonArrayElement } from "./json-array.jsx";
5
4
  import { JsonObject, JsonObjectProperty } from "./json-object.jsx";
package/temp/api.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "metadata": {
3
3
  "toolPackage": "@microsoft/api-extractor",
4
- "toolVersion": "7.52.9",
4
+ "toolVersion": "7.58.8",
5
5
  "schemaVersion": 1011,
6
6
  "oldestForwardsCompatibleVersion": 1001,
7
7
  "tsdocConfig": {
@@ -114,6 +114,22 @@
114
114
  "tagName": "@virtual",
115
115
  "syntaxKind": "modifier"
116
116
  },
117
+ {
118
+ "tagName": "@jsx",
119
+ "syntaxKind": "block"
120
+ },
121
+ {
122
+ "tagName": "@jsxRuntime",
123
+ "syntaxKind": "block"
124
+ },
125
+ {
126
+ "tagName": "@jsxFrag",
127
+ "syntaxKind": "block"
128
+ },
129
+ {
130
+ "tagName": "@jsxImportSource",
131
+ "syntaxKind": "block"
132
+ },
117
133
  {
118
134
  "tagName": "@betaDocumentation",
119
135
  "syntaxKind": "modifier"
@@ -235,7 +251,7 @@
235
251
  {
236
252
  "kind": "Function",
237
253
  "canonicalReference": "@alloy-js/json!JsonArray:function(1)",
238
- "docComment": "/**\n * Create a JSON Array. You can provide children, or else pass a JS value that\n * will be serialized to JSON.\n *\n * @see\n *\n * {@link @alloy-js/core#(MemberScopeContext:variable)}\n */\n",
254
+ "docComment": "/**\n * Create a JSON Array. You can provide children, or else pass a JS value that will be serialized to JSON.\n *\n * @see\n *\n * {@link @alloy-js/core#(MemberScopeContext:variable)}\n */\n",
239
255
  "excerptTokens": [
240
256
  {
241
257
  "kind": "Content",
@@ -282,7 +298,7 @@
282
298
  {
283
299
  "kind": "Function",
284
300
  "canonicalReference": "@alloy-js/json!JsonArrayElement:function(1)",
285
- "docComment": "/**\n * Create a JSON Array element. This component should be used inside of a\n * {@link JsonArray} component. Can either be provided `children`, or a JS\n * value which will be serialized to JSON.\n *\n * @see\n *\n * {@link @alloy-js/core#(MemberDeclarationContext:variable)}\n */\n",
301
+ "docComment": "/**\n * Create a JSON Array element. This component should be used inside of a {@link JsonArray} component. Can either be provided `children`, or a JS value which will be serialized to JSON.\n *\n * @see\n *\n * {@link @alloy-js/core#(MemberDeclarationContext:variable)}\n */\n",
286
302
  "excerptTokens": [
287
303
  {
288
304
  "kind": "Content",
@@ -411,7 +427,7 @@
411
427
  {
412
428
  "kind": "Interface",
413
429
  "canonicalReference": "@alloy-js/json!JsonArrayElementPropsWithJsValue:interface",
414
- "docComment": "/**\n * Create a JSON Array element by providing a JS value that will be serialized\n * to JSON.\n */\n",
430
+ "docComment": "/**\n * Create a JSON Array element by providing a JS value that will be serialized to JSON.\n */\n",
415
431
  "excerptTokens": [
416
432
  {
417
433
  "kind": "Content",
@@ -507,7 +523,7 @@
507
523
  {
508
524
  "kind": "PropertySignature",
509
525
  "canonicalReference": "@alloy-js/json!JsonArrayPropsBase#refkey:member",
510
- "docComment": "/**\n * The refkey or array of refkeys for the JSON array. When provided, this\n * value can be referenced elsewhere via this refkey.\n */\n",
526
+ "docComment": "/**\n * The refkey or array of refkeys for the JSON array. When provided, this value can be referenced elsewhere via this refkey.\n */\n",
511
527
  "excerptTokens": [
512
528
  {
513
529
  "kind": "Content",
@@ -551,7 +567,7 @@
551
567
  {
552
568
  "kind": "Interface",
553
569
  "canonicalReference": "@alloy-js/json!JsonArrayPropsWithChildren:interface",
554
- "docComment": "/**\n * Create a JSON Array by providing the children. To create an array element,\n * see {@link JsonArrayElement}.\n */\n",
570
+ "docComment": "/**\n * Create a JSON Array by providing the children. To create an array element, see {@link JsonArrayElement}.\n */\n",
555
571
  "excerptTokens": [
556
572
  {
557
573
  "kind": "Content",
@@ -575,7 +591,7 @@
575
591
  {
576
592
  "kind": "PropertySignature",
577
593
  "canonicalReference": "@alloy-js/json!JsonArrayPropsWithChildren#children:member",
578
- "docComment": "/**\n * The contents of the JSON Array. Likely to contain {@link JsonArrayElement}\n * components.\n */\n",
594
+ "docComment": "/**\n * The contents of the JSON Array. Likely to contain {@link JsonArrayElement} components.\n */\n",
579
595
  "excerptTokens": [
580
596
  {
581
597
  "kind": "Content",
@@ -770,7 +786,7 @@
770
786
  {
771
787
  "kind": "Variable",
772
788
  "canonicalReference": "@alloy-js/json!JsonFileContext:var",
773
- "docComment": "/**\n * Provides information about the current JSON source file. This context is used\n * to allow references between JSON files.\n */\n",
789
+ "docComment": "/**\n * Provides information about the current JSON source file. This context is used to allow references between JSON files.\n */\n",
774
790
  "excerptTokens": [
775
791
  {
776
792
  "kind": "Content",
@@ -807,7 +823,7 @@
807
823
  {
808
824
  "kind": "Function",
809
825
  "canonicalReference": "@alloy-js/json!JsonObject:function(1)",
810
- "docComment": "/**\n * Create a JSON Object. An object can be created by providing a JS object\n * value which will be serialized to JSON. Else, you can provide children that\n * comprise the object's JSON representation.\n *\n * @see\n *\n * {@link @alloy-js/core#MemberScopeContext}\n */\n",
826
+ "docComment": "/**\n * Create a JSON Object. An object can be created by providing a JS object value which will be serialized to JSON. Else, you can provide children that comprise the object's JSON representation.\n *\n * @see\n *\n * {@link @alloy-js/core#MemberScopeContext}\n */\n",
811
827
  "excerptTokens": [
812
828
  {
813
829
  "kind": "Content",
@@ -854,7 +870,7 @@
854
870
  {
855
871
  "kind": "Function",
856
872
  "canonicalReference": "@alloy-js/json!JsonObjectProperty:function(1)",
857
- "docComment": "/**\n * Create a JSON object property. A property can be created by providing a JS\n * property value or children that defines the value.\n *\n * @see\n *\n * {@link @alloy-js/core#(MemberDeclarationContext:variable)}\n */\n",
873
+ "docComment": "/**\n * Create a JSON object property. A property can be created by providing a JS property value or children that defines the value.\n *\n * @see\n *\n * {@link @alloy-js/core#(MemberDeclarationContext:variable)}\n */\n",
858
874
  "excerptTokens": [
859
875
  {
860
876
  "kind": "Content",
@@ -952,7 +968,7 @@
952
968
  {
953
969
  "kind": "PropertySignature",
954
970
  "canonicalReference": "@alloy-js/json!JsonObjectPropsBase#refkey:member",
955
- "docComment": "/**\n * The refkey or array of refkeys for the JSON object. When provided, this\n * value can be referenced elsewhere via this refkey.\n */\n",
971
+ "docComment": "/**\n * The refkey or array of refkeys for the JSON object. When provided, this value can be referenced elsewhere via this refkey.\n */\n",
956
972
  "excerptTokens": [
957
973
  {
958
974
  "kind": "Content",
@@ -1023,7 +1039,7 @@
1023
1039
  {
1024
1040
  "kind": "Interface",
1025
1041
  "canonicalReference": "@alloy-js/json!JsonObjectPropsWithChildren:interface",
1026
- "docComment": "/**\n * Create a JSON object by providing children that define the object's contents.\n * The children should use the {@link JsonObjectProperty} component to define\n * individual object properties.\n */\n",
1042
+ "docComment": "/**\n * Create a JSON object by providing children that define the object's contents. The children should use the {@link JsonObjectProperty} component to define individual object properties.\n */\n",
1027
1043
  "excerptTokens": [
1028
1044
  {
1029
1045
  "kind": "Content",
@@ -1047,7 +1063,7 @@
1047
1063
  {
1048
1064
  "kind": "PropertySignature",
1049
1065
  "canonicalReference": "@alloy-js/json!JsonObjectPropsWithChildren#children:member",
1050
- "docComment": "/**\n * The contents of the JSON object. Likely to contain\n * {@link JsonObjectProperty} components.\n */\n",
1066
+ "docComment": "/**\n * The contents of the JSON object. Likely to contain {@link JsonObjectProperty} components.\n */\n",
1051
1067
  "excerptTokens": [
1052
1068
  {
1053
1069
  "kind": "Content",
@@ -1107,7 +1123,7 @@
1107
1123
  {
1108
1124
  "kind": "PropertySignature",
1109
1125
  "canonicalReference": "@alloy-js/json!JsonObjectPropsWithJsValue#jsValue:member",
1110
- "docComment": "/**\n * The JS value to serialize to JSON. This can be an array of key-value pairs,\n * a map, or a vanilla JS object.\n */\n",
1126
+ "docComment": "/**\n * The JS value to serialize to JSON. This can be an array of key-value pairs, a map, or a vanilla JS object.\n */\n",
1111
1127
  "excerptTokens": [
1112
1128
  {
1113
1129
  "kind": "Content",
@@ -1160,7 +1176,7 @@
1160
1176
  {
1161
1177
  "kind": "Class",
1162
1178
  "canonicalReference": "@alloy-js/json!JsonOutputSymbol:class",
1163
- "docComment": "/**\n * JsonOutputSymbol is created for JSON Values with a refkey. For JSON objects\n * and arrays, the symbol will have the `StaticMemberContainer` flag. For JSON\n * values that are members of an object or an array, the symbol will have the\n * `StaticMember` flag.\n */\n",
1179
+ "docComment": "/**\n * JsonOutputSymbol is created for JSON Values with a refkey. For JSON objects and arrays, the symbol will have the `StaticMemberContainer` flag. For JSON values that are members of an object or an array, the symbol will have the `StaticMember` flag.\n */\n",
1164
1180
  "excerptTokens": [
1165
1181
  {
1166
1182
  "kind": "Content",
@@ -1523,7 +1539,7 @@
1523
1539
  {
1524
1540
  "kind": "Function",
1525
1541
  "canonicalReference": "@alloy-js/json!JsonValue:function(1)",
1526
- "docComment": "/**\n * Create a JSON value from a JS value. When the provided JS value is an object,\n * the {@link JsonObject} component will be used. When the provided JS value is\n * an array, the {@link JsonArray} component will be used. Otherwise, the JS\n * value will be serialized to a string, number, boolean, or null as\n * appropriate.\n */\n",
1542
+ "docComment": "/**\n * Create a JSON value from a JS value. When the provided JS value is an object, the {@link JsonObject} component will be used. When the provided JS value is an array, the {@link JsonArray} component will be used. Otherwise, the JS value will be serialized to a string, number, boolean, or null as appropriate.\n */\n",
1527
1543
  "excerptTokens": [
1528
1544
  {
1529
1545
  "kind": "Content",
@@ -1612,7 +1628,7 @@
1612
1628
  {
1613
1629
  "kind": "PropertySignature",
1614
1630
  "canonicalReference": "@alloy-js/json!JsonValueProps#refkey:member",
1615
- "docComment": "/**\n * The refkey or array of refkeys for the JSON value. When provided, this\n * value can be referenced elsewhere via this refkey.\n */\n",
1631
+ "docComment": "/**\n * The refkey or array of refkeys for the JSON value. When provided, this value can be referenced elsewhere via this refkey.\n */\n",
1616
1632
  "excerptTokens": [
1617
1633
  {
1618
1634
  "kind": "Content",
@@ -1692,7 +1708,7 @@
1692
1708
  {
1693
1709
  "kind": "Interface",
1694
1710
  "canonicalReference": "@alloy-js/json!ObjectPropertyPropsWithChildren:interface",
1695
- "docComment": "/**\n * Create a JSON object property with a name and children. The children become\n * the value of the property.\n */\n",
1711
+ "docComment": "/**\n * Create a JSON object property with a name and children. The children become the value of the property.\n */\n",
1696
1712
  "excerptTokens": [
1697
1713
  {
1698
1714
  "kind": "Content",
@@ -1765,7 +1781,7 @@
1765
1781
  {
1766
1782
  "kind": "Interface",
1767
1783
  "canonicalReference": "@alloy-js/json!ObjectPropertyPropsWithJsValue:interface",
1768
- "docComment": "/**\n * Create a JSON object property with a name and a JS value. The JS value is\n * serialized to JSON for the property\n */\n",
1784
+ "docComment": "/**\n * Create a JSON object property with a name and a JS value. The JS value is serialized to JSON for the property\n */\n",
1769
1785
  "excerptTokens": [
1770
1786
  {
1771
1787
  "kind": "Content",
@@ -1883,7 +1899,7 @@
1883
1899
  {
1884
1900
  "kind": "Function",
1885
1901
  "canonicalReference": "@alloy-js/json!Reference:function(1)",
1886
- "docComment": "/**\n * Emit a reference to a JSON value by its refkey.\n *\n * @remarks\n *\n *\n *\n * Note that when you place a refkey in a template, the refkey will be converted\n * into a reference automatically. Using this component directly is generally\n * not required or recommended.\n */\n",
1902
+ "docComment": "/**\n * Emit a reference to a JSON value by its refkey.\n *\n * @remarks\n *\n * Note that when you place a refkey in a template, the refkey will be converted into a reference automatically. Using this component directly is generally not required or recommended.\n */\n",
1887
1903
  "excerptTokens": [
1888
1904
  {
1889
1905
  "kind": "Content",
@@ -1980,7 +1996,7 @@
1980
1996
  {
1981
1997
  "kind": "Function",
1982
1998
  "canonicalReference": "@alloy-js/json!SourceFile:function(1)",
1983
- "docComment": "/**\n * Creates a JSON source file which defines a JSON value.\n *\n * @see\n *\n * {@link (JsonFileContext:variable)}\n *\n * @see\n *\n * {@link @alloy-js/core#(MemberDeclarationContext:variable)}\n *\n * @see\n *\n * {@link @alloy-js/core#(SourceFileContext:variable)}\n *\n */\n",
1999
+ "docComment": "/**\n * Creates a JSON source file which defines a JSON value.\n *\n * @see\n *\n * {@link (JsonFileContext:variable)}\n *\n * @see\n *\n * {@link @alloy-js/core#(MemberDeclarationContext:variable)}\n *\n * @see\n *\n * {@link @alloy-js/core#(SourceFileContext:variable)}\n */\n",
1984
2000
  "excerptTokens": [
1985
2001
  {
1986
2002
  "kind": "Content",
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.9"
8
+ "packageVersion": "7.58.8"
9
9
  }
10
10
  ]
11
11
  }
package/vitest.config.ts CHANGED
@@ -15,6 +15,7 @@ export default defineConfig({
15
15
  sourcemap: "both",
16
16
  },
17
17
  test: {
18
+ exclude: ["**/dist/**", "**/node_modules/**"],
18
19
  setupFiles: ["./test/vitest.setup.ts"],
19
20
  },
20
21
  plugins: [alloyPlugin()],