@alloy-js/json 0.25.0-dev.1 → 0.25.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 +4 -0
- package/dist/dev/src/components/array.test.js.map +1 -1
- package/dist/dev/src/components/index.js.map +1 -1
- package/dist/dev/src/components/json-array.js.map +1 -1
- package/dist/dev/src/components/json-object.js.map +1 -1
- package/dist/dev/src/components/json-value.js +2 -2
- package/dist/dev/src/components/json-value.js.map +1 -1
- package/dist/dev/src/components/json-value.test.js +6 -6
- package/dist/dev/src/components/json-value.test.js.map +1 -1
- package/dist/dev/src/components/object.test.js +6 -6
- package/dist/dev/src/components/object.test.js.map +1 -1
- package/dist/dev/src/components/primitives.test.js +1 -1
- package/dist/dev/src/components/primitives.test.js.map +1 -1
- package/dist/dev/src/components/reference.js.map +1 -1
- package/dist/dev/src/components/reference.test.js +49 -49
- package/dist/dev/src/components/reference.test.js.map +1 -1
- package/dist/dev/src/components/source-file.js +3 -3
- package/dist/dev/src/components/source-file.js.map +1 -1
- package/dist/dev/src/components/stc/index.js.map +1 -1
- package/dist/dev/src/context/JsonFileContext.js.map +1 -1
- package/dist/dev/src/context/index.js.map +1 -1
- package/dist/dev/src/index.js.map +1 -1
- package/dist/dev/src/symbols/index.js.map +1 -1
- package/dist/dev/src/symbols/json-symbol.js.map +1 -1
- package/dist/dev/test/utils.js +3 -3
- package/dist/dev/test/utils.js.map +1 -1
- package/dist/dev/test/vitest.setup.js.map +1 -1
- package/dist/src/components/array.test.js.map +1 -1
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/components/json-array.d.ts +1 -1
- package/dist/src/components/json-array.d.ts.map +1 -1
- package/dist/src/components/json-array.js.map +1 -1
- package/dist/src/components/json-object.d.ts +1 -1
- package/dist/src/components/json-object.d.ts.map +1 -1
- package/dist/src/components/json-object.js.map +1 -1
- package/dist/src/components/json-value.d.ts +1 -1
- package/dist/src/components/json-value.d.ts.map +1 -1
- package/dist/src/components/json-value.js.map +1 -1
- package/dist/src/components/json-value.test.js.map +1 -1
- package/dist/src/components/object.test.js.map +1 -1
- package/dist/src/components/primitives.test.js +1 -1
- package/dist/src/components/primitives.test.js.map +1 -1
- package/dist/src/components/reference.d.ts +1 -1
- package/dist/src/components/reference.d.ts.map +1 -1
- package/dist/src/components/reference.js.map +1 -1
- package/dist/src/components/reference.test.js.map +1 -1
- package/dist/src/components/source-file.d.ts +1 -1
- package/dist/src/components/source-file.d.ts.map +1 -1
- package/dist/src/components/source-file.js.map +1 -1
- package/dist/src/components/stc/index.d.ts.map +1 -1
- package/dist/src/components/stc/index.js.map +1 -1
- package/dist/src/context/JsonFileContext.d.ts +2 -2
- package/dist/src/context/JsonFileContext.d.ts.map +1 -1
- package/dist/src/context/JsonFileContext.js.map +1 -1
- package/dist/src/context/index.js.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/symbols/index.d.ts +1 -1
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js.map +1 -1
- package/dist/src/symbols/json-symbol.d.ts +2 -1
- package/dist/src/symbols/json-symbol.d.ts.map +1 -1
- package/dist/src/symbols/json-symbol.js.map +1 -1
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js.map +1 -1
- package/dist/test/vitest.setup.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/api/components/JsonObject.md +10 -10
- package/docs/api/components/JsonValue.md +4 -4
- package/docs/api/components/SourceFile.md +4 -4
- package/docs/api/types/CreateJsonSymbolOptions.md +3 -3
- package/docs/api/types/JsonArrayPropsBase.md +3 -3
- package/docs/api/types/JsonObjectPropsBase.md +4 -4
- package/package.json +8 -8
- package/src/components/array.test.tsx +1 -0
- package/src/components/json-array.tsx +2 -2
- package/src/components/json-object.tsx +2 -2
- package/src/components/json-value.test.tsx +1 -0
- package/src/components/json-value.tsx +3 -1
- package/src/components/object.test.tsx +1 -0
- package/src/components/primitives.test.tsx +2 -1
- package/src/components/reference.test.tsx +1 -0
- package/src/components/reference.tsx +2 -1
- package/src/components/source-file.tsx +2 -1
- package/src/components/stc/index.ts +1 -0
- package/src/context/JsonFileContext.ts +4 -6
- package/src/symbols/index.ts +4 -8
- package/src/symbols/json-symbol.ts +1 -2
- package/temp/api.json +1 -1
- package/test/utils.tsx +1 -0
- package/tsdoc-metadata.json +1 -1
- package/vitest.config.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/components/array.test.tsx"],"sourcesContent":["import { reactive } from \"@alloy-js/core\";\nimport { expect, it } from \"vitest\";\n\nimport { jsonTest } from \"../../test/utils.jsx\";\n\nit(\"renders empty arrays\", () => {\n const template = jsonTest([]);\n\n expect(template).toRenderTo(`[]`);\n});\n\nit(\"renders arrays\", () => {\n const template = jsonTest([1, \"hello\"]);\n\n expect(template).toRenderTo(`\n [1, \"hello\"]\n `);\n});\n\nit(\"renders nested arrays\", () => {\n const template = jsonTest([1, [\"hello there this is a long thing\"]]);\n\n expect(template).toRenderTo(\n `\n [\n 1,\n [\n \"hello there this is a long thing\"\n ]\n ]\n `,\n { printWidth: 20 },\n );\n});\n\nit(\"works reactively\", () => {\n const arr = reactive([] as (number | string)[]);\n\n const template = jsonTest(arr);\n\n expect(template).toRenderTo(`[]`);\n\n const tree = template;\n\n arr.push(1);\n expect(tree).toRenderTo(`[1]`);\n\n arr.push(2);\n expect(tree).toRenderTo(`\n [1, 2]\n `);\n\n arr.push(\"this is a long item that should be wrapped\");\n expect(tree).toRenderTo(\n `\n [\n 1,\n 2,\n \"this is a long item that should be wrapped\"\n ]\n `,\n { printWidth: 20 },\n );\n});\n"],"mappings":"AAAA,SAAS,QAAQ,QAAQ,gBAAgB;AACzC,SAAS,MAAM,EAAE,EAAE,QAAQ,QAAQ;AAEnC,SAAS,QAAQ;AAEjB,EAAE,CAAC,sBAAsB,EAAE,MAAM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CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../../src/components/index.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/components/index.ts"],"sourcesContent":["export * from \"./json-array.jsx\";\nexport * from \"./json-object.jsx\";\nexport * from \"./json-value.jsx\";\nexport * from \"./reference.jsx\";\nexport * from \"./source-file.jsx\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/components/json-array.tsx"],"sourcesContent":["import type { Children, Refkey } from \"@alloy-js/core\";\nimport {\n createSymbol,\n emitSymbol,\n For,\n Indent,\n List,\n MemberDeclaration,\n MemberScope,\n moveTakenMembersTo,\n onCleanup,\n useMemberScope,\n} from \"@alloy-js/core\";\n\nimport { JsonOutputSymbol } from \"../symbols/json-symbol.js\";\nimport { JsonValue } from \"./json-value.jsx\";\n\nexport interface JsonArrayPropsBase {\n /**\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 refkey?: Refkey | Refkey[];\n}\n\n/**\n * Create a JSON Array by serializing the given JavaScript array to JSON.\n */\nexport interface JsonArrayPropsWithJsValue extends JsonArrayPropsBase {\n /**\n * The value to serialize to a JSON array.\n */\n jsValue: unknown[];\n}\n\n/**\n * Create a JSON Array by providing the children. To create an array element,\n * see {@link JsonArrayElement}.\n */\nexport interface JsonArrayPropsWithChildren extends JsonArrayPropsBase {\n /**\n * The contents of the JSON Array. Likely to contain {@link JsonArrayElement}\n * components.\n */\n children?: Children;\n}\n\nexport type JsonArrayProps =\n | JsonArrayPropsWithJsValue\n | JsonArrayPropsWithChildren;\n\n/**\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 {@link @alloy-js/core#(MemberScopeContext:variable)}\n */\nexport function JsonArray(props: JsonArrayProps) {\n const arraySym = createSymbol(JsonOutputSymbol, \"array symbol\", undefined, {\n transient: true,\n refkeys: props.refkey ? [props.refkey].flat() : undefined,\n });\n emitSymbol(arraySym);\n\n if (!(\"jsValue\" in props)) {\n return (\n <MemberScope ownerSymbol={arraySym} name=\"array scope\">\n <group>\n [\n <Indent softline trailingBreak>\n <List comma line>\n {props.children}\n </List>\n </Indent>\n ]\n </group>\n </MemberScope>\n );\n }\n\n const jsValue = props.jsValue ?? [];\n\n return (\n <MemberScope ownerSymbol={arraySym}>\n <group>\n [\n <Indent softline trailingBreak>\n <For each={jsValue} comma line>\n {(value) => <JsonArrayElement jsValue={value} />}\n </For>\n </Indent>\n ]\n </group>\n </MemberScope>\n );\n}\n\n/**\n * Create a JSON Array element by providing a JS value that will be serialized\n * to JSON.\n */\nexport interface JsonArrayElementPropsWithJsValue {\n jsValue: unknown;\n}\n\n/**\n * Create a JSON Array element by providing children.\n */\nexport interface JsonArrayElementPropsWithChildren {\n children: Children;\n}\n\nexport type JsonArrayElementProps =\n | JsonArrayElementPropsWithJsValue\n | JsonArrayElementPropsWithChildren;\n\n/**\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 {@link @alloy-js/core#(MemberDeclarationContext:variable)}\n */\nexport function JsonArrayElement(props: JsonArrayElementProps) {\n const memberScope = useMemberScope();\n const ownerSymbol = memberScope.ownerSymbol as JsonOutputSymbol;\n const name = String(ownerSymbol.staticMembers.size);\n const sym = createSymbol(JsonOutputSymbol, name, ownerSymbol.staticMembers);\n moveTakenMembersTo(sym);\n onCleanup(() => {\n sym.delete();\n });\n\n function wrap(children: Children) {\n return <MemberDeclaration symbol={sym}>{children}</MemberDeclaration>;\n }\n if (!(\"jsValue\" in props)) {\n return wrap(() => props.children);\n } else {\n return wrap(<JsonValue jsValue={props.jsValue} />);\n }\n}\n"],"mappings":";AACA,SACE,YAAY,E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gB;kBAAC,OAAO,EAAE;gBAAK;kBAAA;kBAAA;kBAAA;gBAAA;cAAI;gBAAA;gBAAA;gBAAA;cAAA;YAAA;UAAA;YAAA;YAAA;YAAA;UAAA;QAAA;MAAA;QAAA;QAAA;QAAA;MAAA;IAAA;EAAA;IAAA;IAAA;IAAA;EAAA;AAO5D;;AAEA;AACA;AACA;AACA;;AAKA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,gBAAgB,CAAC,KAA4B,EAAE;EAC7D,MAAM,WAAW,GAAG,cAAc,CAAC,CAAC;EACpC,MAAM,WAAW,GAAG,WAAW,CAAC,WAA+B;EAC/D,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC;EACnD,MAAM,GAAG,GAAG,YAAY,CAAC,gBAAgB,EAAE,IAAI,EAAE,WAAW,CAAC,aAAa,CAAC;EAC3E,kBAAkB,CAAC,GAAG,CAAC;EACvB,SAAS,CAAC,MAAM;IACd,GAAG,CAAC,MAAM,CAAC,CAAC;EACd,CAAC,CAAC;EAEF,SAAS,IAAI,CAAC,QAAkB,EAAE;IAChC,yBAAQ,iBAAiB;MAAC,MAAM,EAAE,GAAG;MAAA,UAAG;IAAQ;MAAA;MAAA;MAAA;IAAA;EAClD;EACA,IAAI,EAAE,SAAS,IAAI,KAAK,CAAC,EAAE;IACzB,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC;EACnC,CAAC,MAAM;IACL,OAAO,IAAI,mBAAE,SAAS;MAAA,IAAC,OAAO;QAAA,OAAE,KAAK,CAAC,OAAO;MAAA;IAAA;MAAA;MAAA;MAAA;IAAA,EAAI,CAAC;EACpD;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/components/json-object.tsx"],"sourcesContent":["import type { Children, Refkey } from \"@alloy-js/core\";\nimport {\n computed,\n createSymbol,\n emitSymbol,\n For,\n Indent,\n List,\n MemberDeclaration,\n MemberScope,\n moveTakenMembersTo,\n onCleanup,\n useMemberScope,\n} from \"@alloy-js/core\";\n\nimport { JsonOutputSymbol } from \"../symbols/json-symbol.js\";\nimport { JsonValue } from \"./json-value.jsx\";\n\nexport interface JsonObjectPropsBase {\n /**\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 refkey?: Refkey | Refkey[];\n\n style?: { concise?: boolean };\n}\n\n/**\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 */\nexport interface JsonObjectPropsWithChildren extends JsonObjectPropsBase {\n /**\n * The contents of the JSON object. Likely to contain\n * {@link JsonObjectProperty} components.\n */\n children: Children;\n}\n\n/**\n * Create a JSON object by providing a JS value that will be serialized to JSON.\n */\nexport interface JsonObjectPropsWithJsValue extends JsonObjectPropsBase {\n /**\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 jsValue: [string, unknown][] | Map<string, unknown> | Record<string, unknown>;\n}\n\nexport type JsonObjectProps =\n | JsonObjectPropsWithChildren\n | JsonObjectPropsWithJsValue;\n\n/**\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 {@link @alloy-js/core#MemberScopeContext}\n */\nexport function JsonObject(props: JsonObjectProps) {\n const objectSym = createSymbol(JsonOutputSymbol, \"object symbol\", undefined, {\n transient: true,\n refkeys: props.refkey ? [props.refkey].flat() : undefined,\n });\n emitSymbol(objectSym);\n\n if (!(\"jsValue\" in props)) {\n return (\n <MemberScope ownerSymbol={objectSym} name=\"object scope\">\n <group>\n {\"{\"}\n <Indent\n softline={!!props.style?.concise}\n hardline={!props.style?.concise}\n trailingBreak\n >\n <List comma softline>\n {props.children}\n </List>\n </Indent>\n {\"}\"}\n </group>\n </MemberScope>\n );\n }\n\n const entries = computed(() => {\n const jsValue = props.jsValue;\n if (Array.isArray(jsValue)) {\n return jsValue;\n } else if (jsValue instanceof Map) {\n return [...jsValue.entries()];\n } else if (jsValue !== undefined) {\n return globalThis.Object.entries(jsValue);\n } else {\n return [];\n }\n });\n\n return (\n <MemberScope ownerSymbol={objectSym}>\n <group>\n {\"{\"}\n <Indent\n softline={!!props.style?.concise}\n hardline={!props.style?.concise}\n trailingBreak\n >\n <For each={entries} comma softline>\n {([name, value]) => (\n <JsonObjectProperty name={name} jsValue={value} />\n )}\n </For>\n </Indent>\n {\"}\"}\n </group>\n </MemberScope>\n );\n}\n\n/**\n * Create a JSON object property with a name and children. The children become\n * the value of the property.\n */\nexport interface ObjectPropertyPropsWithChildren {\n name: string;\n children: Children;\n}\n\n/**\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 */\nexport interface ObjectPropertyPropsWithJsValue {\n name: string;\n jsValue: unknown;\n}\n\nexport type ObjectPropertyProps =\n | ObjectPropertyPropsWithChildren\n | ObjectPropertyPropsWithJsValue;\n\n/**\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 {@link @alloy-js/core#(MemberDeclarationContext:variable)}\n */\nexport function JsonObjectProperty(props: ObjectPropertyProps) {\n const memberScope = useMemberScope();\n const ownerSymbol = memberScope.ownerSymbol as JsonOutputSymbol;\n const sym = createSymbol(\n JsonOutputSymbol,\n props.name,\n ownerSymbol.staticMembers,\n );\n moveTakenMembersTo(sym);\n onCleanup(() => {\n sym.delete();\n });\n\n const wrap = (children: Children) => {\n return (\n <MemberDeclaration symbol={sym}>\n \"{props.name}\": {children}\n </MemberDeclaration>\n );\n };\n\n if (!(\"jsValue\" in props)) {\n return wrap(props.children);\n }\n\n return wrap(<JsonValue jsValue={props.jsValue} />);\n}\n"],"mappings":";AACA,SACE,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,GAAG,EACH,MAAM,EACN,IAAI,EACJ,iBAAiB,EACjB,WA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CAAC,GAAG,CAAC;EACvB,SAAS,CAAC,MAAM;IACd,GAAG,CAAC,MAAM,CAAC,CAAC;EACd,CAAC,CAAC;EAEF,MAAM,IAAI,GAAI,QAAkB,IAAK;IACnC,yBACG,iBAAiB;MAAC,MAAM,EAAE,GAAG;MAAA;QAAA,2BAC1B,KAAK,CAAC,IAAI,gCAAK,QAAQ;MAAA;IAAA;MAAA;MAAA;MAAA;IAAA;EAG/B,CAAC;EAED,IAAI,EAAE,SAAS,IAAI,KAAK,CAAC,EAAE;IACzB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;EAC7B;EAEA,OAAO,IAAI,mBAAE,SAAS;IAAA,IAAC,OAAO;MAAA,OAAE,KAAK,CAAC,OAAO;IAAA;EAAA;IAAA;IAAA;IAAA;EAAA,EAAI,CAAC;AACpD","ignoreList":[]}
|
|
@@ -30,7 +30,7 @@ export function JsonValue(props) {
|
|
|
30
30
|
}
|
|
31
31
|
}, {
|
|
32
32
|
fileName: import.meta.url,
|
|
33
|
-
lineNumber:
|
|
33
|
+
lineNumber: 45,
|
|
34
34
|
columnNumber: 12
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -41,7 +41,7 @@ export function JsonValue(props) {
|
|
|
41
41
|
}
|
|
42
42
|
}, {
|
|
43
43
|
fileName: import.meta.url,
|
|
44
|
-
lineNumber:
|
|
44
|
+
lineNumber: 49,
|
|
45
45
|
columnNumber: 12
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/components/json-value.tsx"],"sourcesContent":["import type { Children, Refkey } from \"@alloy-js/core\";\nimport { useMemberDeclaration } from \"@alloy-js/core\";\n\nimport { JsonArray } from \"./json-array.jsx\";\nimport { JsonObject } from \"./json-object.jsx\";\n\nexport interface JsonValueProps {\n /**\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 refkey?: Refkey | Refkey[];\n\n /**\n * The JS value to serialize to JSON. When provided, thi\n */\n jsValue: unknown;\n}\n\n/**\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 */\nexport function JsonValue(props: JsonValueProps): Children {\n const refkeys = [props.refkey ?? []].flat();\n if (props.jsValue === null) {\n setMemberRefkey(refkeys);\n return \"null\";\n }\n\n if (typeof props.jsValue === \"number\" || typeof props.jsValue === \"boolean\") {\n setMemberRefkey(refkeys);\n return String(props.jsValue);\n }\n\n if (typeof props.jsValue === \"string\") {\n setMemberRefkey(refkeys);\n return `\"${props.jsValue}\"`;\n }\n\n if (Array.isArray(props.jsValue)) {\n return <JsonArray jsValue={props.jsValue} />;\n }\n\n if (typeof props.jsValue === \"object\") {\n return <JsonObject jsValue={props.jsValue as Record<string, unknown>} />;\n }\n\n if (typeof props.jsValue === \"function\") {\n // functions are inserted as-is.\n return props.jsValue as () => Children;\n }\n\n throw new Error(\"Cannot emit js value with type of \" + typeof props.jsValue);\n}\n\nfunction setMemberRefkey(keys: Refkey[]) {\n if (keys.length === 0) return;\n const member = useMemberDeclaration();\n if (!member) {\n throw new Error(\"Missing member declaration.\");\n }\n\n member.refkeys = keys;\n}\n"],"mappings":";AACA,SAAS,oBAAoB,QAAQ,gBAAgB;AAErD,SAAS,SAAS;AAClB,SAAS,UAAU;AAenB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,SAAS,CAAC,KAAqB,EAAY;EACzD,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;EAC3C,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE;IAC1B,eAAe,CAAC,OAAO,CAAC;IACxB,OAAO,MAAM;EACf;EAEA,IAAI,OAAO,KAAK,CAAC,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
+
lineNumber: 13,
|
|
14
14
|
columnNumber: 23
|
|
15
15
|
})
|
|
16
16
|
}
|
|
17
17
|
}, {
|
|
18
18
|
fileName: import.meta.url,
|
|
19
|
-
lineNumber:
|
|
19
|
+
lineNumber: 9,
|
|
20
20
|
columnNumber: 5
|
|
21
21
|
});
|
|
22
22
|
};
|
|
@@ -27,7 +27,7 @@ const Bar = () => {
|
|
|
27
27
|
}
|
|
28
28
|
}, {
|
|
29
29
|
fileName: import.meta.url,
|
|
30
|
-
lineNumber:
|
|
30
|
+
lineNumber: 21,
|
|
31
31
|
columnNumber: 5
|
|
32
32
|
});
|
|
33
33
|
};
|
|
@@ -39,19 +39,19 @@ it("compose json data with components", () => {
|
|
|
39
39
|
get children() {
|
|
40
40
|
return _$createComponent(TestingJsonObject, {}, {
|
|
41
41
|
fileName: import.meta.url,
|
|
42
|
-
lineNumber:
|
|
42
|
+
lineNumber: 33,
|
|
43
43
|
columnNumber: 9
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
}, {
|
|
47
47
|
fileName: import.meta.url,
|
|
48
|
-
lineNumber:
|
|
48
|
+
lineNumber: 32,
|
|
49
49
|
columnNumber: 7
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
}, {
|
|
53
53
|
fileName: import.meta.url,
|
|
54
|
-
lineNumber:
|
|
54
|
+
lineNumber: 31,
|
|
55
55
|
columnNumber: 5
|
|
56
56
|
})).toRenderTo(`
|
|
57
57
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/components/json-value.test.tsx"],"sourcesContent":["import { Output } from \"@alloy-js/core\";\nimport { expect, it } from \"vitest\";\n\nimport { JsonValue } from \"./json-value.jsx\";\nimport { SourceFile } from \"./source-file.jsx\";\n\nconst TestingJsonObject = () => {\n return (\n <JsonValue\n jsValue={{\n id: \"test-id\",\n name: \"Test Name\",\n nested: () => <Bar />,\n }}\n />\n );\n};\n\nconst Bar = () => {\n return (\n <JsonValue\n jsValue={{\n bar: \"Foo\",\n }}\n />\n );\n};\n\nit(\"compose json data with components\", () => {\n expect(\n <Output>\n <SourceFile path=\"test.json\">\n <TestingJsonObject />\n </SourceFile>\n </Output>,\n ).toRenderTo(`\n {\n \"id\": \"test-id\",\n \"name\": \"Test Name\",\n \"nested\": {\n \"bar\": \"Foo\"\n }\n }\n `);\n});\n"],"mappings":";AAAA,SAAS,MAAM,QAAQ,gBAAgB;AACvC,SAAS,MAAM,EAAE,EAAE,QAAQ,QAAQ;AAEnC,SAAS,SAAS;AAClB,SAAS,UAAU;AAEnB,MAAM,iBAAiB,GAAG,MAAM;EAC9B,yBACG,SAAS;IACR,OAAO,EAAE;MACP,EAAE,EAAE,SAAS;MACb,IAAI,EAAE,WAAW;MACjB,MAAM,EAAE,wBAAO,GAAG;QAAA;QAAA;QAAA;MAAA;IACpB;EAAC;IAAA;IAAA;IAAA;EAAA;AAGP,CAAC;AAED,MAAM,GAAG,GAAG,MAAM;EAChB,yBACG,SAAS;IACR,OAAO,EAAE;MACP,GAAG,EAAE;IACP;EAAC;IAAA;IAAA;IAAA;EAAA;AAGP,CAAC;AAED,EAAE,CAAC,mCAAmC,EAAE,MAAM;EAC5C,MAAM,mBACH,MAAM;IAAA;MAAA,yBACJ,UAAU;QAAC,IAAI;QAAA;UAAA,yBACb,iBAAiB;YAAA;YAAA;YAAA;UAAA;QAAA;MAAA;QAAA;QAAA;QAAA;MAAA;IAAA;EAAA;IAAA;IAAA;IAAA;EAAA,EAGxB,CAAC,CAAC,UAAU,CAAC;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -47,38 +47,38 @@ it("can can manually assemble objects", () => {
|
|
|
47
47
|
children: "12"
|
|
48
48
|
}, {
|
|
49
49
|
fileName: import.meta.url,
|
|
50
|
-
lineNumber:
|
|
50
|
+
lineNumber: 41,
|
|
51
51
|
columnNumber: 13
|
|
52
52
|
}), _$createComponent(JsonObjectProperty, {
|
|
53
53
|
name: "bar",
|
|
54
54
|
children: "13"
|
|
55
55
|
}, {
|
|
56
56
|
fileName: import.meta.url,
|
|
57
|
-
lineNumber:
|
|
57
|
+
lineNumber: 42,
|
|
58
58
|
columnNumber: 13
|
|
59
59
|
})];
|
|
60
60
|
}
|
|
61
61
|
}, {
|
|
62
62
|
fileName: import.meta.url,
|
|
63
|
-
lineNumber:
|
|
63
|
+
lineNumber: 40,
|
|
64
64
|
columnNumber: 11
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
}, {
|
|
68
68
|
fileName: import.meta.url,
|
|
69
|
-
lineNumber:
|
|
69
|
+
lineNumber: 39,
|
|
70
70
|
columnNumber: 9
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
}, {
|
|
74
74
|
fileName: import.meta.url,
|
|
75
|
-
lineNumber:
|
|
75
|
+
lineNumber: 38,
|
|
76
76
|
columnNumber: 7
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
}, {
|
|
80
80
|
fileName: import.meta.url,
|
|
81
|
-
lineNumber:
|
|
81
|
+
lineNumber: 37,
|
|
82
82
|
columnNumber: 5
|
|
83
83
|
});
|
|
84
84
|
expect(template).toRenderTo(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/components/object.test.tsx"],"sourcesContent":["import { List, Output, reactive } from \"@alloy-js/core\";\nimport { expect, it } from \"vitest\";\n\nimport { jsonTest } from \"../../test/utils.jsx\";\nimport { JsonObject, JsonObjectProperty } from \"./json-object.jsx\";\nimport { SourceFile } from \"./source-file.jsx\";\n\nit(\"renders objects\", () => {\n const template = jsonTest({ a: 1, b: \"hello\" });\n\n expect(template).toRenderTo(`\n {\n \"a\": 1,\n \"b\": \"hello\"\n }\n `);\n});\n\nit(\"renders nested objects\", () => {\n const template = jsonTest({\n a: {\n b: 1,\n },\n });\n\n expect(template).toRenderTo(`\n {\n \"a\": {\n \"b\": 1\n }\n }\n `);\n});\n\nit(\"can can manually assemble objects\", () => {\n const template = (\n <Output>\n <SourceFile path=\"test.json\">\n <JsonObject>\n <List comma softline>\n <JsonObjectProperty name=\"foo\">12</JsonObjectProperty>\n <JsonObjectProperty name=\"bar\">13</JsonObjectProperty>\n </List>\n </JsonObject>\n </SourceFile>\n </Output>\n );\n\n expect(template).toRenderTo(`\n {\n \"foo\": 12,\n \"bar\": 13\n }\n `);\n});\n\nit(\"works reactively\", () => {\n const obj = reactive({ a: 1 } as Record<string, unknown>);\n\n const template = jsonTest(obj);\n\n expect(template).toRenderTo(`\n {\n \"a\": 1\n }\n `);\n\n const tree = template;\n\n (obj.a as any)++;\n\n expect(tree).toRenderTo(`\n {\n \"a\": 2\n }\n `);\n\n obj.b = \"hello\";\n\n expect(tree).toRenderTo(`\n {\n \"a\": 2,\n \"b\": \"hello\"\n }\n `);\n});\n"],"mappings":";AAAA,SAAS,IAAI,EAAE,MAAM,EAAE,QAAQ,QAAQ,gBAAgB;AACvD,SAAS,MAAM,EAAE,EAAE,QAAQ,QAAQ;AAEnC,SAAS,QAAQ;AACjB,SAAS,UAAU,EAAE,kBAAkB;AACvC,SAAS,UAAU;AAEnB,EAAE,CAAC,iBAAiB,EAAE,MAAM;EAC1B,MAAM,QAAQ,GAAG,QAAQ,CAAC;IAAE,CAAC,EAAE,CAAC;IAAE,CAAC,EAAE;EAAQ,CAAC,CAAC;EAE/C,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC;AAC9B;AACA;AACA;AACA;AACA,GAAG,CAAC;AACJ,CAAC,CAAC;AAEF,EAAE,CAAC,wBAAwB,EAAE,MAAM;EACjC,MAAM,QAAQ,GAAG,QAAQ,CAAC;IACxB,CAAC,EAAE;MACD,CAAC,EAAE;IACL;EACF,CAAC,CAAC;EAEF,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC;AAC9B;AACA;AACA;AAC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
import { jsonTest } from "#test/utils.js";
|
|
2
1
|
import { expect, it } from "vitest";
|
|
2
|
+
import { jsonTest } from "#test/utils.js";
|
|
3
3
|
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) => {
|
|
4
4
|
expect(jsonTest(data)).toRenderTo(expected);
|
|
5
5
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/components/primitives.test.tsx"],"sourcesContent":["import { expect, it } from \"vitest\";\n\nimport { jsonTest } from \"#test/utils.jsx\";\n\nit.each([\n [\"boolean (true)\", true, \"true\"],\n [\"boolean (false)\", false, \"false\"],\n [\"integer\", 10, \"10\"],\n [\"negative integer\", -10, \"-10\"],\n [\"float\", 1.314, \"1.314\"],\n [\"string\", \"Hello, world!\", `\"Hello, world!\"`],\n [\"null\", null, \"null\"],\n])(\"%s\", (_, data, expected) => {\n expect(jsonTest(data)).toRenderTo(expected);\n});\n"],"mappings":"AAAA,SAAS,MAAM,EAAE,EAAE,QAAQ,QAAQ;AAEnC,SAAS,QAAQ;AAEjB,EAAE,CAAC,IAAI,CAAC,CACN,CAAC,gBAAgB,EAAE,IAAI,EAAE,MAAM,CAAC,EAChC,CAAC,iBAAiB,EAAE,KAAK,EAAE,OAAO,CAAC,EACnC,CAAC,SAAS,EAAE,EAAE,EAAE,IAAI,CAAC,EACrB,CAAC,kBAAkB,EAAE,CAAC,EAAE,EAAE,KAAK,CAAC,EAChC,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,EACzB,CAAC,QAAQ,EAAE,eAAe,EAAE,iBAAiB,CAAC,EAC9C,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CACvB,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,KAAK;EAC9B,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;AAC7C,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/components/reference.tsx"],"sourcesContent":["import type { Refkey } from \"@alloy-js/core\";\n\nimport { ref } from \"../symbols/index.js\";\n\nexport interface ReferenceProps {\n /**\n * The refkey for the symbol to reference.\n */\n refkey: Refkey;\n}\n\n/**\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\n * into a reference automatically. Using this component directly is generally\n * not required or recommended.\n */\nexport function Reference(props: ReferenceProps) {\n const reference = ref(props.refkey);\n return <>\"{reference}\"</>;\n}\n"],"mappings":"AAEA,SAAS,GAAG,QAAQ,qBAAqB;AASzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,SAAS,CAAC,KAAqB,EAAE;EAC/C,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;EACnC,cAAW,SAAS;AACtB","ignoreList":[]}
|