@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
|
@@ -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,EACZ,UAAU,EACV,GAAG,EACH,MAAM,EACN,IAAI,EACJ,iBAAiB,EACjB,WAAW,EACX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gB,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;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,EAAI,CAAC;EACpD;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-object.d.ts","sourceRoot":"","sources":["../../../src/components/json-object.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"json-object.d.ts","sourceRoot":"","sources":["../../../src/components/json-object.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAkBvD,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,YA2DhD;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,YA0B5D"}
|
|
@@ -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,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,cAAc,QACT,gBAAgB;AAEvB,SAAS,gBAAgB,QAAQ,2BAA2B;AAC5D,SAAS,SAAS;;AAYlB;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,UAAU,CAAC,KAAsB,EAAE;EACjD,MAAM,SAAS,GAAG,YAAY,CAAC,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE;IAC3E,SAAS,EAAE,IAAI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-value.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"json-value.d.ts","sourceRoot":"","sources":["../../../src/components/json-value.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAMvD,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 +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,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE;IAC3E,eAAe,CAAC,OAAO,CAAC;IACxB,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;EAC9B;EAEA,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;IACrC,eAAe,CAAC,OAAO,CAAC;IACxB,OAAO,IAAI,KAAK,CAAC,OAAO,GAAG;EAC7B;EAEA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;IAChC,yBAAQ,SAAS;MAAA,IAAC,OAAO;QAAA,OAAE,KAAK,CAAC,OAAO;MAAA;IAAA;EAC1C;EAEA,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;IACrC,yBAAQ,UAAU;MAAA,IAAC,OAAO;QAAA,OAAE,KAAK,CAAC,OAAO;MAAA;IAAA;EAC3C;EAEA,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,UAAU,EAAE;IACvC;IACA,OAAO,KAAK,CAAC,OAAO;EACtB;EAEA,MAAM,IAAI,KAAK,CAAC,oCAAoC,GAAG,OAAO,KAAK,CAAC,OAAO,CAAC;AAC9E;AAEA,SAAS,eAAe,CAAC,IAAc,EAAE;EACvC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;EACvB,MAAM,MAAM,GAAG,oBAAoB,CAAC,CAAC;EACrC,IAAI,CAAC,MAAM,EAAE;IACX,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC;EAChD;EAEA,MAAM,CAAC,OAAO,GAAG,IAAI;AACvB","ignoreList":[]}
|
|
@@ -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;IACpB;EAAC;AAGP,CAAC;AAED,MAAM,GAAG,GAAG,MAAM;EAChB,yBACG,SAAS;IACR,OAAO,EAAE;MACP,GAAG,EAAE;IACP;EAAC;AAGP,CAAC;AAED,EAAE,CAAC,mCAAmC,EAAE,MAAM;EAC5C,MAAM,mBACH,MAAM;IAAA;MAAA,yBACJ,UAAU;QAAC,IAAI;QAAA;UAAA,yBACb,iBAAiB;QAAA;MAAA;IAAA;EAAA,EAGxB,CAAC,CAAC,UAAU,CAAC;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -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;AACA;AACA;AACA,GAAG,CAAC;AACJ,CAAC,CAAC;AAEF,EAAE,CAAC,mCAAmC,EAAE,MAAM;EAC5C,MAAM,QAAQ,qBACX,MAAM;IAAA;MAAA,yBACJ,UAAU;QAAC,IAAI;QAAA;UAAA,yBACb,UAAU;YAAA;cAAA,yBACR,IAAI;gBAAC,KAAK;gBAAC,QAAQ;gBAAA;kBAAA,0BACjB,kBAAkB;oBAAC,IAAI;oBAAA;kBAAA,sBACvB,kBAAkB;oBAAC,IAAI;oBAAA;kBAAA;gBAAA;cAAA;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA,EAKjC;EAED,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC;AAC9B;AACA;AACA;AACA;AACA,GAAG,CAAC;AACJ,CAAC,CAAC;AAEF,EAAE,CAAC,kBAAkB,EAAE,MAAM;EAC3B,MAAM,GAAG,GAAG,QAAQ,CAAC;IAAE,CAAC,EAAE;EAAE,CAA4B,CAAC;EAEzD,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC;EAE9B,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC;AAC9B;AACA;AACA;AACA,GAAG,CAAC;EAEF,MAAM,IAAI,GAAG,QAAQ;EAEpB,GAAG,CAAC,CAAC,EAAU;EAEhB,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;AAC1B;AACA;AACA;AACA,GAAG,CAAC;EAEF,GAAG,CAAC,CAAC,GAAG,OAAO;EAEf,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;AAC1B;AACA;AACA;AACA;AACA,GAAG,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
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,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/components/reference.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/components/reference.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI7C,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,qCAG9C"}
|
|
@@ -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":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/components/reference.test.tsx"],"sourcesContent":["import { Output, refkey, SourceDirectory } from \"@alloy-js/core\";\nimport { expect, it } from \"vitest\";\n\nimport { JsonArray, JsonArrayElement } from \"./json-array.jsx\";\nimport { JsonObject, JsonObjectProperty } from \"./json-object.jsx\";\nimport { JsonValue } from \"./json-value.jsx\";\nimport { SourceFile } from \"./source-file.jsx\";\n\nit(\"references objects within the same file\", () => {\n const objectValue = refkey();\n const nullKey = refkey();\n const template = (\n <Output>\n <SourceFile path=\"test.json\">\n <JsonObject refkey={objectValue}>\n <JsonObjectProperty name=\"nullValue\">\n <JsonValue jsValue={null} refkey={nullKey} />\n </JsonObjectProperty>\n <JsonObjectProperty name=\"refToNull\">{nullKey}</JsonObjectProperty>\n <JsonObjectProperty name=\"refToObject\">\n {objectValue}\n </JsonObjectProperty>\n </JsonObject>\n </SourceFile>\n </Output>\n );\n\n expect(template).toRenderTo(`\n {\n \"nullValue\": null,\n \"refToNull\": \"#/nullValue\",\n \"refToObject\": \"#\"\n }\n `);\n});\n\nit(\"references objects across files\", () => {\n const objectValue = refkey();\n const nullKey = refkey();\n const template = (\n <Output>\n <SourceFile path=\"test1.json\">\n <JsonObject refkey={objectValue}>\n <JsonObjectProperty name=\"nullValue\">\n <JsonValue jsValue={null} refkey={nullKey} />\n </JsonObjectProperty>\n </JsonObject>\n </SourceFile>\n <SourceFile path=\"test2.json\">\n <JsonObject>\n <JsonObjectProperty name=\"refToNull\">{nullKey}</JsonObjectProperty>\n <JsonObjectProperty name=\"refToObject\">\n {objectValue}\n </JsonObjectProperty>\n </JsonObject>\n </SourceFile>\n </Output>\n );\n\n expect(template).toRenderTo({\n \"test1.json\": `\n {\n \"nullValue\": null\n }\n `,\n \"test2.json\": `\n {\n \"refToNull\": \"test1.json#/nullValue\",\n \"refToObject\": \"test1.json#\"\n }\n `,\n });\n});\n\nit(\"references objects across files and directories\", () => {\n const objectValue = refkey();\n const nullKey = refkey();\n const template = (\n <Output>\n <SourceDirectory path=\"subdir\">\n <SourceFile path=\"test.json\">\n <JsonObject refkey={objectValue}>\n <JsonObjectProperty name=\"nullValue\">\n <JsonValue jsValue={null} refkey={nullKey} />\n </JsonObjectProperty>\n </JsonObject>\n </SourceFile>\n </SourceDirectory>\n <SourceFile path=\"test.json\">\n <JsonObject>\n <JsonObjectProperty name=\"refToNull\">{nullKey}</JsonObjectProperty>\n <JsonObjectProperty name=\"refToObject\">\n {objectValue}\n </JsonObjectProperty>\n </JsonObject>\n </SourceFile>\n </Output>\n );\n\n expect(template).toRenderTo({\n \"subdir/test.json\": `\n {\n \"nullValue\": null\n }\n `,\n \"test.json\": `\n {\n \"refToNull\": \"subdir/test.json#/nullValue\",\n \"refToObject\": \"subdir/test.json#\"\n }\n `,\n });\n});\n\nit(\"references arrays within the same file\", () => {\n const arrayValue = refkey();\n const nullKey = refkey();\n const template = (\n <Output>\n <SourceFile path=\"test.json\">\n <JsonArray refkey={arrayValue}>\n <JsonArrayElement>{nullKey}</JsonArrayElement>\n <JsonArrayElement>{arrayValue}</JsonArrayElement>\n <JsonArrayElement>\n <JsonValue jsValue={null} refkey={nullKey} />\n </JsonArrayElement>\n </JsonArray>\n </SourceFile>\n </Output>\n );\n\n expect(template).toRenderTo(`\n [\"#/2\", \"#\", null]\n `);\n});\n\nit(\"does complex references\", () => {\n const objectValue = refkey();\n const arrayValue = refkey();\n const nullKey = refkey();\n const nestedKey = refkey();\n const template = (\n <Output>\n <SourceFile path=\"test.json\">\n <JsonObject refkey={objectValue}>\n <JsonObjectProperty name=\"nullValue\">\n <JsonValue jsValue={null} refkey={nullKey} />\n </JsonObjectProperty>\n <JsonObjectProperty name=\"refToNull\">{nullKey}</JsonObjectProperty>\n <JsonObjectProperty name=\"refToObject\">\n {objectValue}\n </JsonObjectProperty>\n <JsonObjectProperty name=\"refToNested\">\n {nestedKey}\n </JsonObjectProperty>\n <JsonObjectProperty name=\"nestedArray\">\n <JsonArray refkey={arrayValue}>\n <JsonArrayElement>{nullKey}</JsonArrayElement>\n <JsonArrayElement>{arrayValue}</JsonArrayElement>\n <JsonArrayElement>\n <JsonObject>\n <JsonObjectProperty name=\"nestedProp\">\n <JsonValue jsValue=\"hi\" refkey={nestedKey} />\n </JsonObjectProperty>\n </JsonObject>\n </JsonArrayElement>\n </JsonArray>\n </JsonObjectProperty>\n </JsonObject>\n </SourceFile>\n </Output>\n );\n\n expect(template).toRenderTo(`\n {\n \"nullValue\": null,\n \"refToNull\": \"#/nullValue\",\n \"refToObject\": \"#\",\n \"refToNested\": \"#/nestedArray/2/nestedProp\",\n \"nestedAr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;cAAS,sBAEX,kBAAkB;gBAAC,IAAI;gBAAA;kBAAA,yBACrB,SAAS;oBAAC,MAAM,EAAE,UAAU;oBAAA;sBAAA,0BAC1B,gBAAgB;wBAAA,UAAE;sBAAO,sBACzB,gBAAgB;wBAAA,UAAE;sBAAU,sBAC5B,gBAAgB;wBAAA;0BAAA,yBACd,UAAU;4BAAA;8BAAA,yBACR,kBAAkB;gCAAC,IAAI;gCAAA;kCAAA,yBACrB,SAAS;oCAAC,OAAO;oCAAM,MAAM,EAAE;kCAAS;gCAAA;8BAAA;4BAAA;0BAAA;wBAAA;sBAAA;oBAAA;kBAAA;gBAAA;cAAA;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA,EAS1D;EAED,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-file.d.ts","sourceRoot":"","sources":["../../../src/components/source-file.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"source-file.d.ts","sourceRoot":"","sources":["../../../src/components/source-file.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAY/C,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,YAoBhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/components/source-file.tsx"],"sourcesContent":["import type { Children } from \"@alloy-js/core\";\nimport {\n SourceFile as CoreSourceFile,\n createSourceFileTap,\n createSymbol,\n moveTakenMembersTo,\n} from \"@alloy-js/core\";\n\nimport { JsonFileContext } from \"../context/JsonFileContext.js\";\nimport { JsonOutputSymbol } from \"../symbols/json-symbol.js\";\nimport { Reference } from \"./reference.jsx\";\n\nexport interface SourceFileProps {\n /** The path for this source file relative to the parent directory */\n path: string;\n\n /** The contents of the source file */\n children?: Children;\n}\n\n/**\n * Creates a JSON source file which defines a JSON value.\n *\n * @see {@link (JsonFileContext:variable)}\n * @see {@link @alloy-js/core#(MemberDeclarationContext:variable)}\n * @see {@link @alloy-js/core#(SourceFileContext:variable)}\n *\n */\nexport function SourceFile(props: SourceFileProps) {\n const jsonValueSym = createSymbol(JsonOutputSymbol, props.path, undefined);\n moveTakenMembersTo(jsonValueSym);\n const fileContext: JsonFileContext = {\n symbol: jsonValueSym,\n path: props.path,\n };\n\n const SfTapper = createSourceFileTap((context) => {\n jsonValueSym.name = context.path;\n });\n\n return (\n <CoreSourceFile filetype=\"json\" path={props.path} reference={Reference}>\n <SfTapper />\n <JsonFileContext.Provider value={fileContext}>\n {props.children}\n </JsonFileContext.Provider>\n </CoreSourceFile>\n );\n}\n"],"mappings":";AACA,SACE,UAAU,IAAI,cAAc,EAC5B,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,QACb,gBAAgB;AAEvB,SAAS,eAAe,QAAQ,+BAA+B;AAC/D,SAAS,gBAAgB,QAAQ,2BAA2B;AAC5D,SAAS,SAAS;AAUlB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,UAAU,CAAC,KAAsB,EAAE;EACjD,MAAM,YAAY,GAAG,YAAY,CAAC,gBAAgB,EAAE,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC;EAC1E,kBAAkB,CAAC,YAAY,CAAC;EAChC,MAAM,WAA4B,GAAG;IACnC,MAAM,EAAE,YAAY;IACpB,IAAI,EAAE,KAAK,CAAC;EACd,CAAC;EAED,MAAM,QAAQ,GAAG,mBAAmB,CAAE,OAAO,IAAK;IAChD,YAAY,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI;EAClC,CAAC,CAAC;EAEF,yBACG,cAAc;IAAC,QAAQ;IAAA,IAAQ,IAAI;MAAA,OAAE,KAAK,CAAC,IAAI;IAAA;IAAE,SAAS,EAAE,SAAS;IAAA;MAAA,0BACnE,QAAQ,yBACR,eAAe,CAAC,QAAQ;QAAC,KAAK,EAAE,WAAW;QAAA;UAAA,OACzC,KAAK,CAAC,QAAQ;QAAA;MAAA;IAAA;EAAA;AAIvB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stc/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stc/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AAEvC,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,eAAO,MAAM,SAAS,uCAA0B,CAAC;AACjD,eAAO,MAAM,gBAAgB,8CAAiC,CAAC;AAC/D,eAAO,MAAM,UAAU,wCAA2B,CAAC;AACnD,eAAO,MAAM,kBAAkB,4CAAmC,CAAC;AACnE,eAAO,MAAM,SAAS,uCAA0B,CAAC;AACjD,eAAO,MAAM,SAAS,uCAA0B,CAAC;AACjD,eAAO,MAAM,UAAU,wCAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/components/stc/index.ts"],"sourcesContent":["import * as core from \"@alloy-js/core\";\n\nimport * as Jsx from \"../index.js\";\n\nexport const JsonArray = core.stc(Jsx.JsonArray);\nexport const JsonArrayElement = core.stc(Jsx.JsonArrayElement);\nexport const JsonObject = core.stc(Jsx.JsonObject);\nexport const JsonObjectProperty = core.stc(Jsx.JsonObjectProperty);\nexport const JsonValue = core.stc(Jsx.JsonValue);\nexport const Reference = core.stc(Jsx.Reference);\nexport const SourceFile = core.stc(Jsx.SourceFile);\n"],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB;AAEtC,OAAO,KAAK,GAAG,MAAM,aAAa;AAElC,OAAO,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC;AAChD,OAAO,MAAM,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC;AAC9D,OAAO,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC;AAClD,OAAO,MAAM,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,kBAAkB,CAAC;AAClE,OAAO,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC;AAChD,OAAO,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC;AAChD,OAAO,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentContext } from "@alloy-js/core";
|
|
2
|
-
import { JsonOutputSymbol } from "../symbols/json-symbol.js";
|
|
1
|
+
import type { ComponentContext } from "@alloy-js/core";
|
|
2
|
+
import type { JsonOutputSymbol } from "../symbols/json-symbol.js";
|
|
3
3
|
export interface JsonFileContext {
|
|
4
4
|
/** The path of the current JSON file. May be different from the path on disk. */
|
|
5
5
|
path?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonFileContext.d.ts","sourceRoot":"","sources":["../../../src/context/JsonFileContext.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"JsonFileContext.d.ts","sourceRoot":"","sources":["../../../src/context/JsonFileContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAElE,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,uCAAuC;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,iDAAiD;IACjD,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,eAAe,CACb,CAAC;AAElD,wBAAgB,kBAAkB,IAAI,eAAe,GAAG,SAAS,CAEhE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/context/JsonFileContext.ts"],"sourcesContent":["import type { ComponentContext } from \"@alloy-js/core\";\nimport { createNamedContext, useContext } from \"@alloy-js/core\";\n\nimport type { JsonOutputSymbol } from \"../symbols/json-symbol.js\";\n\nexport interface JsonFileContext {\n /** The path of the current JSON file. May be different from the path on disk. */\n path?: string;\n\n /** The URL of the current JSON file */\n url?: string;\n\n /** The symbol for the value in this JSON file */\n symbol: JsonOutputSymbol;\n}\n\n/**\n * Provides information about the current JSON source file. This context is used\n * to allow references between JSON files.\n */\nexport const JsonFileContext: ComponentContext<JsonFileContext> =\n createNamedContext<JsonFileContext>(\"JsonFile\");\n\nexport function useJsonFileContext(): JsonFileContext | undefined {\n return useContext(JsonFileContext);\n}\n"],"mappings":"AACA,SAAS,kBAAkB,EAAE,UAAU,QAAQ,gBAAgB;AAe/D;AACA;AACA;AACA;AACA,OAAO,MAAM,eAAkD,GAC7D,kBAAkB,CAAkB,UAAU,CAAC;AAEjD,OAAO,SAAS,kBAAkB,GAAgC;EAChE,OAAO,UAAU,CAAC,eAAe,CAAC;AACpC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../src/context/index.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/context/index.ts"],"sourcesContent":["export * from \"./JsonFileContext.js\";\n"],"mappings":"AAAA,cAAc,sBAAsB","ignoreList":[]}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"./components/index.js\";\nexport * from \"./context/index.js\";\nexport * from \"./symbols/index.js\";\n"],"mappings":"AAAA,cAAc,uBAAuB;AACrC,cAAc,oBAAoB;AAClC,cAAc,oBAAoB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/symbols/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/symbols/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAM1D,cAAc,kBAAkB,CAAC;AAEjC,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,2BAkEjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/symbols/index.ts"],"sourcesContent":["import type { OutputScope, Refkey } from \"@alloy-js/core\";\nimport { memo, resolve, unresolvedRefkey } from \"@alloy-js/core\";\nimport { dirname, relative } from \"pathe\";\n\nimport { useJsonFileContext } from \"../context/JsonFileContext.js\";\nimport type { JsonOutputSymbol } from \"./json-symbol.js\";\nexport * from \"./json-symbol.js\";\n\nexport function ref(refkey: Refkey) {\n const sourceFile = useJsonFileContext();\n if (!sourceFile) {\n return unresolvedRefkey(refkey);\n }\n\n const resolveResult = resolve<OutputScope, JsonOutputSymbol>(refkey);\n\n return memo(() => {\n if (resolveResult.value === undefined) {\n return unresolvedRefkey(refkey);\n }\n const {\n pathDown,\n pathUp,\n lexicalDeclaration,\n memberPath,\n commonScope,\n fullSymbolPath,\n } = resolveResult.value;\n\n let ref = \"\";\n let isCrossFile = false;\n // When we have no common scope and we don't path up through the symbol\n // we're referencing (i.e. the symbol we're referencing isn't the symbol for\n // the file the reference occurs in), append the file path.\n if (\n commonScope === undefined &&\n pathUp[0] &&\n pathUp[0].ownerSymbol !== lexicalDeclaration\n ) {\n const currentPath = sourceFile.symbol.name;\n const targetPath = lexicalDeclaration.name;\n isCrossFile = true;\n ref += relative(dirname(currentPath), targetPath);\n }\n\n ref += \"#\";\n\n if (\n commonScope === undefined &&\n pathDown.length === 0 &&\n memberPath.length === 0\n ) {\n // we are referring to the root of a file\n return ref;\n }\n\n ref += \"/\";\n\n if (isCrossFile) {\n // the lexical declaration is the file symbol, so we just need any\n // additional members.\n ref += memberPath.map((s) => s.name).join(\"/\");\n } else {\n // merge together the member scopes, lexical declaration, and member path\n ref += fullSymbolPath\n .slice(1)\n .map((s) => s.ownerSymbol!.name)\n .concat(lexicalDeclaration.name)\n .concat(memberPath.map((s) => s.name))\n .join(\"/\");\n }\n\n return ref;\n });\n}\n"],"mappings":"AACA,SAAS,IAAI,EAAE,OAAO,EAAE,gBAAgB,QAAQ,gBAAgB;AAChE,SAAS,OAAO,EAAE,QAAQ,QAAQ,OAAO;AAEzC,SAAS,kBAAkB,QAAQ,+BAA+B;AAElE,cAAc,kBAAkB;AAEhC,OAAO,SAAS,GAAG,CAAC,MAAc,EAAE;EAClC,MAAM,UAAU,GAAG,kBAAkB,CAAC,CAAC;EACvC,IAAI,CAAC,UAAU,EAAE;IACf,OAAO,gBAAgB,CAAC,MAAM,CAAC;EACjC;EAEA,MAAM,aAAa,GAAG,OAAO,CAAgC,MAAM,CAAC;EAEpE,OAAO,IAAI,CAAC,MAAM;IAChB,IAAI,aAAa,CAAC,KAAK,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AC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/json-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"json-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/json-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EAEL,YAAY,EAKb,MAAM,gBAAgB,CAAC;AAGxB,oBAAY,eAAe;IACzB,IAAI,IAAI;IACR,MAAM,IAAS;IACf,KAAK,IAAS;CACf;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;;IAChD,MAAM,CAAC,QAAQ,CAAC,YAAY,YAAI,QAAQ,EAAW;IAGnD,IAAI,SAAS,IAAI,eAAe,CAG/B;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,eAAe,EAQnC;IAED,YACE,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,GAAG,SAAS,EAC/C,OAAO,GAAE,uBAA4B,EAKtC;IAED,IAAI,qBAUH;IAED,IAAa,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOhD;IAED,IAAI,aAAa,+CAEhB;CACF;AAED,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IAClE,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/symbols/json-symbol.ts"],"sourcesContent":["import type { OutputSpace, OutputSymbolOptions } from \"@alloy-js/core\";\nimport {\n createSymbol,\n OutputSymbol,\n track,\n TrackOpTypes,\n trigger,\n TriggerOpTypes,\n} from \"@alloy-js/core\";\n\n// prettier-ignore\nexport enum JsonSymbolFlags {\n None = 0,\n Object = 1 << 0,\n Array = 1 << 1,\n}\n\n/**\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 */\nexport class JsonOutputSymbol extends OutputSymbol {\n static readonly memberSpaces = [\"static\"] as const;\n\n #jsonFlags: JsonSymbolFlags;\n get jsonFlags(): JsonSymbolFlags {\n track(this, TrackOpTypes.GET, \"jsonFlags\");\n return this.#jsonFlags;\n }\n\n set jsonFlags(value: JsonSymbolFlags) {\n const old = this.#jsonFlags;\n if (old === value) {\n return;\n }\n\n this.#jsonFlags = value;\n trigger(this, TriggerOpTypes.SET, \"jsonFlags\", value, old);\n }\n\n constructor(\n name: string,\n spaces: OutputSpace[] | OutputSpace | undefined,\n options: CreateJsonSymbolOptions = {},\n ) {\n super(name, spaces, options);\n\n this.#jsonFlags = options.jsonFlags ?? JsonSymbolFlags.None;\n }\n\n copy() {\n const options = this.getCopyOptions();\n const binder = this.binder;\n const copy = createSymbol(JsonOutputSymbol, this.name, undefined, {\n ...options,\n binder,\n jsonFlags: this.#jsonFlags,\n });\n this.initializeCopy(copy);\n return copy;\n }\n\n override get debugInfo(): Record<string, unknown> {\n return {\n ...super.debugInfo,\n jsonFlags: this.#jsonFlags,\n isObject: Boolean(this.#jsonFlags & JsonSymbolFlags.Object),\n isArray: Boolean(this.#jsonFlags & JsonSymbolFlags.Array),\n };\n }\n\n get staticMembers() {\n return this.memberSpaceFor(\"static\")!;\n }\n}\n\nexport interface CreateJsonSymbolOptions extends OutputSymbolOptions {\n jsonFlags?: JsonSymbolFlags;\n}\n"],"mappings":"AACA,SACE,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,OAAO,EACP,cAAc,QACT,gBAAgB;;AAEvB;AACA,WAAY,eAAe,0BAAf,eAAe;EAAf,eAAe,CAAf,eAAe;EAAf,eAAe,CAAf,eAAe;EAAf,eAAe,CAAf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AC,CAAC,SAAS;MAC1B,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC;MAC3D,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,eAAe,CAAC,KAAK;IAC1D,CAAC;EACH;EAEA,IAAI,aAAa,GAAG;IAClB,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC;EACtC;AACF","ignoreList":[]}
|
package/dist/test/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../test/utils.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../test/utils.tsx"],"names":[],"mappings":"AAKA,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,qCAQxC"}
|
package/dist/test/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["../../test/utils.tsx"],"sourcesContent":["import { Output } from \"@alloy-js/core\";\n\nimport { JsonValue } from \"../src/components/json-value.jsx\";\nimport { SourceFile } from \"../src/components/source-file.jsx\";\n\nexport function jsonTest(jsValue: unknown) {\n return (\n <Output>\n <SourceFile path=\"test.json\">\n <JsonValue jsValue={jsValue} />\n </SourceFile>\n </Output>\n );\n}\n"],"mappings":";AAAA,SAAS,MAAM,QAAQ,gBAAgB;AAEvC,SAAS,SAAS;AAClB,SAAS,UAAU;AAEnB,OAAO,SAAS,QAAQ,CAAC,OAAgB,EAAE;EACzC,yBACG,MAAM;IAAA;MAAA,yBACJ,UAAU;QAAC,IAAI;QAAA;UAAA,yBACb,SAAS;YAAC,OAAO,EAAE;UAAO;QAAA;MAAA;IAAA;EAAA;AAInC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../test/vitest.setup.ts"],"sourcesContent":[
|
|
1
|
+
{"version":3,"names":[],"sources":["../../test/vitest.setup.ts"],"sourcesContent":["import \"@alloy-js/core/testing\";\n"],"mappings":"AAAA,OAAO,wBAAwB","ignoreList":[]}
|