@alloy-js/json 0.3.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/LICENSE +7 -0
- package/api-extractor.json +4 -0
- package/babel.config.cjs +4 -0
- package/dist/src/components/JsonArray.d.ts +52 -0
- package/dist/src/components/JsonArray.d.ts.map +1 -0
- package/dist/src/components/JsonArray.js +107 -0
- package/dist/src/components/JsonArray.js.map +1 -0
- package/dist/src/components/JsonObject.d.ts +63 -0
- package/dist/src/components/JsonObject.d.ts.map +1 -0
- package/dist/src/components/JsonObject.js +119 -0
- package/dist/src/components/JsonObject.js.map +1 -0
- package/dist/src/components/JsonValue.d.ts +21 -0
- package/dist/src/components/JsonValue.d.ts.map +1 -0
- package/dist/src/components/JsonValue.js +49 -0
- package/dist/src/components/JsonValue.js.map +1 -0
- package/dist/src/components/Reference.d.ts +18 -0
- package/dist/src/components/Reference.d.ts.map +1 -0
- package/dist/src/components/Reference.js +15 -0
- package/dist/src/components/Reference.js.map +1 -0
- package/dist/src/components/SourceFile.d.ts +17 -0
- package/dist/src/components/SourceFile.d.ts.map +1 -0
- package/dist/src/components/SourceFile.js +47 -0
- package/dist/src/components/SourceFile.js.map +1 -0
- package/dist/src/components/index.d.ts +6 -0
- package/dist/src/components/index.d.ts.map +1 -0
- package/dist/src/components/index.js +6 -0
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/stc/index.d.ts +30 -0
- package/dist/src/components/stc/index.d.ts.map +1 -0
- package/dist/src/components/stc/index.js +10 -0
- package/dist/src/components/stc/index.js.map +1 -0
- package/dist/src/context/JsonFileContext.d.ts +17 -0
- package/dist/src/context/JsonFileContext.d.ts.map +1 -0
- package/dist/src/context/JsonFileContext.js +10 -0
- package/dist/src/context/JsonFileContext.js.map +1 -0
- package/dist/src/context/index.d.ts +2 -0
- package/dist/src/context/index.d.ts.map +1 -0
- package/dist/src/context/index.js +1 -0
- package/dist/src/context/index.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/symbols/index.d.ts +4 -0
- package/dist/src/symbols/index.d.ts.map +1 -0
- package/dist/src/symbols/index.js +34 -0
- package/dist/src/symbols/index.js.map +1 -0
- package/dist/src/symbols/json-symbol.d.ts +22 -0
- package/dist/src/symbols/json-symbol.d.ts.map +1 -0
- package/dist/src/symbols/json-symbol.js +45 -0
- package/dist/src/symbols/json-symbol.js.map +1 -0
- package/dist/test/array.test.d.ts +2 -0
- package/dist/test/array.test.d.ts.map +1 -0
- package/dist/test/object.test.d.ts +2 -0
- package/dist/test/object.test.d.ts.map +1 -0
- package/dist/test/primitives.test.d.ts +2 -0
- package/dist/test/primitives.test.d.ts.map +1 -0
- package/dist/test/reference.test.d.ts +2 -0
- package/dist/test/reference.test.d.ts.map +1 -0
- package/dist/test/utils.d.ts +2 -0
- package/dist/test/utils.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +45 -0
- package/src/components/JsonArray.tsx +138 -0
- package/src/components/JsonObject.tsx +150 -0
- package/src/components/JsonValue.tsx +59 -0
- package/src/components/Reference.tsx +23 -0
- package/src/components/SourceFile.tsx +48 -0
- package/src/components/index.ts +5 -0
- package/src/components/stc/index.ts +10 -0
- package/src/context/JsonFileContext.ts +28 -0
- package/src/context/index.ts +1 -0
- package/src/index.ts +3 -0
- package/src/symbols/index.ts +43 -0
- package/src/symbols/json-symbol.ts +68 -0
- package/temp/api.json +1896 -0
- package/test/array.test.tsx +31 -0
- package/test/object.test.tsx +60 -0
- package/test/primitives.test.tsx +16 -0
- package/test/reference.test.tsx +173 -0
- package/test/utils.tsx +11 -0
- package/test/vitest.d.ts +10 -0
- package/tsconfig.json +11 -0
- package/tsdoc-metadata.json +11 -0
- package/vitest.config.ts +18 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2024 Microsoft
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/babel.config.cjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Children, Refkey } from "@alloy-js/core";
|
|
2
|
+
export interface JsonArrayPropsBase {
|
|
3
|
+
/** The refkey for the JSON array. When provided, this value can be referenced
|
|
4
|
+
* elsewhere via this refkey.
|
|
5
|
+
**/
|
|
6
|
+
refkey?: Refkey;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Create a JSON Array by serializing the given JavaScript array to JSON.
|
|
10
|
+
*/
|
|
11
|
+
export interface JsonArrayPropsWithJsValue extends JsonArrayPropsBase {
|
|
12
|
+
/**
|
|
13
|
+
* The value to serialize to a JSON array.
|
|
14
|
+
*/
|
|
15
|
+
jsValue: unknown[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a JSON Array by providing the children. To create an array element,
|
|
19
|
+
* see {@link JsonArrayElement}.
|
|
20
|
+
*/
|
|
21
|
+
export interface JsonArrayPropsWithChildren extends JsonArrayPropsBase {
|
|
22
|
+
/**
|
|
23
|
+
* The contents of the JSON Array. Likely to contain {@link JsonArrayElement}
|
|
24
|
+
* components.
|
|
25
|
+
*/
|
|
26
|
+
children?: Children;
|
|
27
|
+
}
|
|
28
|
+
export type JsonArrayProps = JsonArrayPropsWithJsValue | JsonArrayPropsWithChildren;
|
|
29
|
+
/**
|
|
30
|
+
* Create a JSON Array. You can provide children, or else pass a JS value that
|
|
31
|
+
* will be serialized to JSON.
|
|
32
|
+
*
|
|
33
|
+
* @see {@link @alloy-js/core#(MemberScopeContext:variable)}
|
|
34
|
+
*/
|
|
35
|
+
export declare function JsonArray(props: JsonArrayProps): Children;
|
|
36
|
+
export interface JsonArrayElementProps {
|
|
37
|
+
children: Children;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Create a JSON Array element. This component should be used inside of a
|
|
41
|
+
* {@link JsonArray} component.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
*
|
|
45
|
+
* It does not add any syntax, but is required in
|
|
46
|
+
* order to establish the correct scope for the array element, allowing
|
|
47
|
+
* references to array elements to work properly.
|
|
48
|
+
*
|
|
49
|
+
* @see {@link @alloy-js/core#(MemberDeclarationContext:variable)}
|
|
50
|
+
*/
|
|
51
|
+
export declare function JsonArrayElement(props: JsonArrayElementProps): Children;
|
|
52
|
+
//# sourceMappingURL=JsonArray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonArray.d.ts","sourceRoot":"","sources":["../../../src/components/JsonArray.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAKR,MAAM,EAGP,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,kBAAkB;IACjC;;QAEI;IACJ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE;;OAEG;IACH,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GACtB,yBAAyB,GACzB,0BAA0B,CAAC;AAE/B;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,YA+C9C;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,YAoB5D"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { Indent as _$Indent } from "@alloy-js/core";
|
|
4
|
+
import { mapJoin, MemberDeclaration, MemberScope, OutputSymbolFlags, useMemberDeclaration, useMemberScope } from "@alloy-js/core";
|
|
5
|
+
import { createJsonOutputSymbol } from "../symbols/json-symbol.js";
|
|
6
|
+
import { JsonValue } from "./JsonValue.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create a JSON Array by serializing the given JavaScript array to JSON.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Create a JSON Array by providing the children. To create an array element,
|
|
14
|
+
* see {@link JsonArrayElement}.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Create a JSON Array. You can provide children, or else pass a JS value that
|
|
19
|
+
* will be serialized to JSON.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link @alloy-js/core#(MemberScopeContext:variable)}
|
|
22
|
+
*/
|
|
23
|
+
export function JsonArray(props) {
|
|
24
|
+
const memberSymbol = useMemberDeclaration();
|
|
25
|
+
if (!memberSymbol) {
|
|
26
|
+
throw new Error("Missing assignment symbol.");
|
|
27
|
+
}
|
|
28
|
+
const binder = memberSymbol.binder;
|
|
29
|
+
binder.addStaticMembersToSymbol(memberSymbol);
|
|
30
|
+
if (props.refkey) {
|
|
31
|
+
memberSymbol.refkey = props.refkey;
|
|
32
|
+
}
|
|
33
|
+
if (!("jsValue" in props)) {
|
|
34
|
+
return _$createComponent(MemberScope, {
|
|
35
|
+
owner: memberSymbol,
|
|
36
|
+
get children() {
|
|
37
|
+
return ["[", _$createComponent(_$Indent, {
|
|
38
|
+
get children() {
|
|
39
|
+
return ["\n", _$memo(() => props.children)];
|
|
40
|
+
}
|
|
41
|
+
}), "\n]"];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const jsValue = props.jsValue ?? [];
|
|
46
|
+
if (jsValue.length === 0) {
|
|
47
|
+
return "[]";
|
|
48
|
+
}
|
|
49
|
+
const elements = mapJoin(jsValue, value => {
|
|
50
|
+
return _$createComponent(JsonArrayElement, {
|
|
51
|
+
get children() {
|
|
52
|
+
return _$createComponent(JsonValue, {
|
|
53
|
+
jsValue: value
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}, {
|
|
58
|
+
joiner: ",\n"
|
|
59
|
+
});
|
|
60
|
+
let contents;
|
|
61
|
+
if (jsValue.length === 1) {
|
|
62
|
+
contents = ["[", elements, "]"];
|
|
63
|
+
} else {
|
|
64
|
+
contents = ["[", _$createComponent(_$Indent, {
|
|
65
|
+
get children() {
|
|
66
|
+
return ["\n", elements];
|
|
67
|
+
}
|
|
68
|
+
}), "\n]"];
|
|
69
|
+
}
|
|
70
|
+
return _$createComponent(MemberScope, {
|
|
71
|
+
owner: memberSymbol,
|
|
72
|
+
children: contents
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Create a JSON Array element. This component should be used inside of a
|
|
77
|
+
* {@link JsonArray} component.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
*
|
|
81
|
+
* It does not add any syntax, but is required in
|
|
82
|
+
* order to establish the correct scope for the array element, allowing
|
|
83
|
+
* references to array elements to work properly.
|
|
84
|
+
*
|
|
85
|
+
* @see {@link @alloy-js/core#(MemberDeclarationContext:variable)}
|
|
86
|
+
*/
|
|
87
|
+
export function JsonArrayElement(props) {
|
|
88
|
+
const memberScope = useMemberScope();
|
|
89
|
+
if (!memberScope) {
|
|
90
|
+
throw new Error("Missing member scope.");
|
|
91
|
+
}
|
|
92
|
+
if (!memberScope.staticMembers) {
|
|
93
|
+
throw new Error("Missing static members scope.");
|
|
94
|
+
}
|
|
95
|
+
const name = String(memberScope.staticMembers.symbols.size);
|
|
96
|
+
const sym = createJsonOutputSymbol({
|
|
97
|
+
name,
|
|
98
|
+
flags: OutputSymbolFlags.StaticMember
|
|
99
|
+
});
|
|
100
|
+
return _$createComponent(MemberDeclaration, {
|
|
101
|
+
symbol: sym,
|
|
102
|
+
get children() {
|
|
103
|
+
return props.children;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=JsonArray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonArray.js","names":["mapJoin","MemberDeclaration","MemberScope","OutputSymbolFlags","useMemberDeclaration","useMemberScope","createJsonOutputSymbol","JsonValue","JsonArray","props","memberSymbol","Error","binder","addStaticMembersToSymbol","refkey","_$createComponent","owner","children","_$Indent","_$memo","jsValue","length","elements","value","JsonArrayElement","joiner","contents","memberScope","staticMembers","name","String","symbols","size","sym","flags","StaticMember","symbol"],"sources":["../../../src/components/JsonArray.tsx"],"sourcesContent":[null],"mappings":";;;AAAA,SAEEA,OAAO,EACPC,iBAAiB,EACjBC,WAAW,EACXC,iBAAiB,EAEjBC,oBAAoB,EACpBC,cAAc,QACT,gBAAgB;AACvB,SAASC,sBAAsB,QAAQ,2BAA2B;AAClE,SAASC,SAAS;;AASlB;AACA;AACA;;AAQA;AACA;AACA;AACA;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A;IAAA,UAEV;EACL;EAEA,OAAAP,iBAAA,CAAQb,WAAW;IAACc,KAAK,EAAEN,YAAY;IAAAO,QAAA,EACpCS;EAAQ;AAEb;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASF,gBAAgBA,CAACf,KAA4B,EAAE;EAC7D,MAAMkB,WAAW,GAAGtB,cAAc,CAAC,CAAC;EACpC,IAAI,CAACsB,WAAW,EAAE;IAChB,MAAM,IAAIhB,KAAK,CAAC,uBAAuB,CAAC;EAC1C;EAEA,IAAI,CAACgB,WAAW,CAACC,aAAa,EAAE;IAC9B,MAAM,IAAIjB,KAAK,CAAC,+BAA+B,CAAC;EAClD;EAEA,MAAMkB,IAAI,GAAGC,MAAM,CAACH,WAAW,CAACC,aAAa,CAACG,OAAO,CAACC,IAAI,CAAC;EAE3D,MAAMC,GAAG,GAAG3B,sBAAsB,CAAC;IACjCuB,IAAI;IACJK,KAAK,EAAE/B,iBAAiB,CAACgC;EAC3B,CAAC,CAAC;EAEF,OAAApB,iBAAA,CAAQd,iBAAiB;IAACmC,MAAM,EAAEH,GAAG;IAAA,IAAAhB,SAAA;MAAA,OAClCR,KAAK,CAACQ,QAAQ;IAAA;EAAA;AAEnB","ignoreList":[]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Children, Refkey } from "@alloy-js/core";
|
|
2
|
+
export interface JsonObjectPropsBase {
|
|
3
|
+
/** The refkey for the JSON array. When provided, this value can be referenced
|
|
4
|
+
* elsewhere via this refkey.
|
|
5
|
+
**/
|
|
6
|
+
refkey?: Refkey;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Create a JSON object by providing children that define the object's contents.
|
|
10
|
+
* The children should use the {@link JsonObjectProperty} component to define
|
|
11
|
+
* individual object properties.
|
|
12
|
+
*/
|
|
13
|
+
export interface JsonObjectPropsWithChildren extends JsonObjectPropsBase {
|
|
14
|
+
/**
|
|
15
|
+
* The contents of the JSON object. Likely to contain
|
|
16
|
+
* {@link JsonObjectProperty} components.
|
|
17
|
+
*/
|
|
18
|
+
children: Children;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a JSON object by providing a JS value that will be serialized to JSON.
|
|
22
|
+
*/
|
|
23
|
+
export interface JsonObjectPropsWithJsValue extends JsonObjectPropsBase {
|
|
24
|
+
/**
|
|
25
|
+
* The JS value to serialize to JSON. This can be an array of key-value pairs,
|
|
26
|
+
* a map, or a vanilla JS object.
|
|
27
|
+
*/
|
|
28
|
+
jsValue: [string, unknown][] | Map<string, unknown> | Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
export type JsonObjectProps = JsonObjectPropsWithChildren | JsonObjectPropsWithJsValue;
|
|
31
|
+
/**
|
|
32
|
+
* Create a JSON Object. An object can be created by providing a JS object
|
|
33
|
+
* value which will be serialized to JSON. Else, you can provide children that
|
|
34
|
+
* comprise the object's JSON representation.
|
|
35
|
+
*
|
|
36
|
+
* @see {@link @alloy-js/core#MemberScopeContext}
|
|
37
|
+
*/
|
|
38
|
+
export declare function JsonObject(props: JsonObjectProps): Children;
|
|
39
|
+
/**
|
|
40
|
+
* Create a JSON object property with a name and children. The children become
|
|
41
|
+
* the value of the property.
|
|
42
|
+
*/
|
|
43
|
+
export interface ObjectPropertyPropsWithChildren {
|
|
44
|
+
name: string;
|
|
45
|
+
children: Children;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a JSON object property with a name and a JS value. The JS value is
|
|
49
|
+
* serialized to JSON for the property
|
|
50
|
+
*/
|
|
51
|
+
export interface ObjectPropertyPropsWithJsValue {
|
|
52
|
+
name: string;
|
|
53
|
+
jsValue: unknown;
|
|
54
|
+
}
|
|
55
|
+
export type ObjectPropertyProps = ObjectPropertyPropsWithChildren | ObjectPropertyPropsWithJsValue;
|
|
56
|
+
/**
|
|
57
|
+
* Create a JSON object property. A property can be created by providing a JS
|
|
58
|
+
* property value or children that defines the value.
|
|
59
|
+
*
|
|
60
|
+
* @see {@link @alloy-js/core#(MemberDeclarationContext:variable)}
|
|
61
|
+
*/
|
|
62
|
+
export declare function JsonObjectProperty(props: ObjectPropertyProps): Children;
|
|
63
|
+
//# sourceMappingURL=JsonObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonObject.d.ts","sourceRoot":"","sources":["../../../src/components/JsonObject.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAMR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,mBAAmB;IAClC;;QAEI;IACJ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IACrE;;;OAGG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/E;AAED,MAAM,MAAM,eAAe,GACvB,2BAA2B,GAC3B,0BAA0B,CAAC;AAE/B;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YA+ChD;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,YAiB5D"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { Indent as _$Indent } from "@alloy-js/core";
|
|
4
|
+
import { computed, mapJoin, MemberDeclaration, MemberScope, OutputSymbolFlags, useMemberDeclaration } from "@alloy-js/core";
|
|
5
|
+
import { createJsonOutputSymbol } from "../symbols/json-symbol.js";
|
|
6
|
+
import { JsonValue } from "./JsonValue.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Create a JSON object by providing children that define the object's contents.
|
|
10
|
+
* The children should use the {@link JsonObjectProperty} component to define
|
|
11
|
+
* individual object properties.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create a JSON object by providing a JS value that will be serialized to JSON.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a JSON Object. An object can be created by providing a JS object
|
|
20
|
+
* value which will be serialized to JSON. Else, you can provide children that
|
|
21
|
+
* comprise the object's JSON representation.
|
|
22
|
+
*
|
|
23
|
+
* @see {@link @alloy-js/core#MemberScopeContext}
|
|
24
|
+
*/
|
|
25
|
+
export function JsonObject(props) {
|
|
26
|
+
const memberSymbol = useMemberDeclaration();
|
|
27
|
+
if (!memberSymbol) {
|
|
28
|
+
throw new Error("Missing assignment symbol.");
|
|
29
|
+
}
|
|
30
|
+
const binder = memberSymbol.binder;
|
|
31
|
+
binder.addStaticMembersToSymbol(memberSymbol);
|
|
32
|
+
if (props.refkey) {
|
|
33
|
+
memberSymbol.refkey = props.refkey;
|
|
34
|
+
}
|
|
35
|
+
if (!("jsValue" in props)) {
|
|
36
|
+
return _$createComponent(MemberScope, {
|
|
37
|
+
owner: memberSymbol,
|
|
38
|
+
get children() {
|
|
39
|
+
return ["{", _$createComponent(_$Indent, {
|
|
40
|
+
get children() {
|
|
41
|
+
return ["\n", _$memo(() => props.children)];
|
|
42
|
+
}
|
|
43
|
+
}), "\n", "}"];
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const elements = computed(() => {
|
|
48
|
+
const jsValue = props.jsValue;
|
|
49
|
+
let properties;
|
|
50
|
+
if (Array.isArray(jsValue)) {
|
|
51
|
+
properties = jsValue;
|
|
52
|
+
} else if (jsValue instanceof Map) {
|
|
53
|
+
properties = [...jsValue.entries()];
|
|
54
|
+
} else if (jsValue !== undefined) {
|
|
55
|
+
properties = globalThis.Object.entries(jsValue);
|
|
56
|
+
} else {
|
|
57
|
+
properties = [];
|
|
58
|
+
}
|
|
59
|
+
const elements = mapJoin(properties, ([name, value]) => {
|
|
60
|
+
return _$createComponent(JsonObjectProperty, {
|
|
61
|
+
name: name,
|
|
62
|
+
jsValue: value
|
|
63
|
+
});
|
|
64
|
+
}, {
|
|
65
|
+
joiner: ",\n"
|
|
66
|
+
});
|
|
67
|
+
return elements;
|
|
68
|
+
});
|
|
69
|
+
return _$createComponent(MemberScope, {
|
|
70
|
+
owner: memberSymbol,
|
|
71
|
+
get children() {
|
|
72
|
+
return ["{", _$createComponent(_$Indent, {
|
|
73
|
+
get children() {
|
|
74
|
+
return ["\n", elements];
|
|
75
|
+
}
|
|
76
|
+
}), "\n", "}"];
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Create a JSON object property with a name and children. The children become
|
|
83
|
+
* the value of the property.
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Create a JSON object property with a name and a JS value. The JS value is
|
|
88
|
+
* serialized to JSON for the property
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Create a JSON object property. A property can be created by providing a JS
|
|
93
|
+
* property value or children that defines the value.
|
|
94
|
+
*
|
|
95
|
+
* @see {@link @alloy-js/core#(MemberDeclarationContext:variable)}
|
|
96
|
+
*/
|
|
97
|
+
export function JsonObjectProperty(props) {
|
|
98
|
+
const sym = createJsonOutputSymbol({
|
|
99
|
+
name: props.name,
|
|
100
|
+
flags: OutputSymbolFlags.StaticMember
|
|
101
|
+
});
|
|
102
|
+
const wrap = children => {
|
|
103
|
+
return _$createComponent(MemberDeclaration, {
|
|
104
|
+
symbol: sym,
|
|
105
|
+
get children() {
|
|
106
|
+
return ["\"", _$memo(() => props.name), "\": ", children];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
if (!("jsValue" in props)) {
|
|
111
|
+
return wrap(props.children);
|
|
112
|
+
}
|
|
113
|
+
return wrap(_$createComponent(JsonValue, {
|
|
114
|
+
get jsValue() {
|
|
115
|
+
return props.jsValue;
|
|
116
|
+
}
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=JsonObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonObject.js","names":["computed","mapJoin","MemberDeclaration","MemberScope","OutputSymbolFlags","useMemberDeclaration","createJsonOutputSymbol","JsonValue","JsonObject","props","memberSymbol","Error","binder","addStaticMembersToSymbol","refkey","_$createComponent","owner","children","_$Indent","_$memo","elements","jsValue","properties","Array","isArray","Map","entries","undefined","globalThis","Object","name","value","JsonObjectProperty","joiner","sym","flags","StaticMember","wrap","symbol"],"sources":["../../../src/components/JsonObject.tsx"],"sourcesContent":[null],"mappings":";;;AAAA,SAEEA,QAAQ,EACRC,OAAO,EACPC,iBAAiB,EACjBC,WAAW,EACXC,iBAAiB,EAEjBC,oBAAoB,QACf,gBAAgB;AACvB,SAASC,sBAAsB,QAAQ,2BAA2B;AAClE,SAASC,SAAS;;AASlB;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,KAAsB,EAAE;EACjD,MAAMC,YAAY,GAAGL,oBAAoB,CAAC,CAAC;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C,EACD;MAAEE,MAAM,EAAE;IAAM,CAClB,CAAC;IAED,OAAOb,QAAQ;EACjB,CAAC,CAAC;EAEF,OAAAL,iBAAA,CAAQZ,WAAW;IAACa,KAAK,EAAEN,YAAY;IAAA,IAAAO,SAAA;MAAA,QACpC,GAAG,EAAAF,iBAAA,CAAAG,QAAA;QAAA,IAAAD,SAAA;UAAA,cACDG,QAAQ;QAAA;MAAA,UACV,GAAG;IAAA;EAAA;AAER;;AAEA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASY,kBAAkBA,CAACvB,KAA0B,EAAE;EAC7D,MAAMyB,GAAG,GAAG5B,sBAAsB,CAAC;IACjCwB,IAAI,EAAErB,KAAK,CAACqB,IAAI;IAChBK,KAAK,EAAE/B,iBAAiB,CAACgC;EAC3B,CAAC,CAAC;EAEF,MAAMC,IAAI,GAAIpB,QAAkB,IAAK;IACnC,OAAAF,iBAAA,CAAQb,iBAAiB;MAACoC,MAAM,EAAEJ,GAAG;MAAA,IAAAjB,SAAA;QAAA,cAAAE,MAAA,OACjCV,KAAK,CAACqB,IAAI,WAAKb,QAAQ;MAAA;IAAA;EAE7B,CAAC;EAED,IAAI,EAAE,SAAS,IAAIR,KAAK,CAAC,EAAE;IACzB,OAAO4B,IAAI,CAAC5B,KAAK,CAACQ,QAAQ,CAAC;EAC7B;EAEA,OAAOoB,IAAI,CAAAtB,iBAAA,CAAER,SAAS;IAAA,IAACc,OAAOA,CAAA;MAAA,OAAEZ,KAAK,CAACY,OAAO;IAAA;EAAA,EAAI,CAAC;AACpD","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Refkey } from "@alloy-js/core";
|
|
2
|
+
export interface JsonValueProps {
|
|
3
|
+
/**
|
|
4
|
+
* The refkey for the JSON value. When provided, this value can be referenced
|
|
5
|
+
* elsewhere via this refkey.
|
|
6
|
+
**/
|
|
7
|
+
refkey?: Refkey;
|
|
8
|
+
/**
|
|
9
|
+
* The JS value to serialize to JSON. When provided, thi
|
|
10
|
+
*/
|
|
11
|
+
jsValue: unknown;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a JSON value from a JS value. When the provided JS value is an object,
|
|
15
|
+
* the {@link JsonObject} component will be used. When the provided JS value is
|
|
16
|
+
* an array, the {@link JsonArray} component will be used. Otherwise, the JS
|
|
17
|
+
* value will be serialized to a string, number, boolean, or null as
|
|
18
|
+
* appropriate.
|
|
19
|
+
*/
|
|
20
|
+
export declare function JsonValue(props: JsonValueProps): import("@alloy-js/core").Children;
|
|
21
|
+
//# sourceMappingURL=JsonValue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonValue.d.ts","sourceRoot":"","sources":["../../../src/components/JsonValue.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAwB,MAAM,gBAAgB,CAAC;AAI9D,MAAM,WAAW,cAAc;IAC7B;;;QAGI;IACJ,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,qCAyB9C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { useMemberDeclaration } from "@alloy-js/core";
|
|
3
|
+
import { JsonArray } from "./JsonArray.js";
|
|
4
|
+
import { JsonObject } from "./JsonObject.js";
|
|
5
|
+
/**
|
|
6
|
+
* Create a JSON value from a JS value. When the provided JS value is an object,
|
|
7
|
+
* the {@link JsonObject} component will be used. When the provided JS value is
|
|
8
|
+
* an array, the {@link JsonArray} component will be used. Otherwise, the JS
|
|
9
|
+
* value will be serialized to a string, number, boolean, or null as
|
|
10
|
+
* appropriate.
|
|
11
|
+
*/
|
|
12
|
+
export function JsonValue(props) {
|
|
13
|
+
if (props.jsValue === null) {
|
|
14
|
+
setMemberRefkey(props.refkey);
|
|
15
|
+
return "null";
|
|
16
|
+
}
|
|
17
|
+
if (typeof props.jsValue === "number" || typeof props.jsValue === "boolean") {
|
|
18
|
+
setMemberRefkey(props.refkey);
|
|
19
|
+
return String(props.jsValue);
|
|
20
|
+
}
|
|
21
|
+
if (typeof props.jsValue === "string") {
|
|
22
|
+
setMemberRefkey(props.refkey);
|
|
23
|
+
return `"${props.jsValue}"`;
|
|
24
|
+
}
|
|
25
|
+
if (Array.isArray(props.jsValue)) {
|
|
26
|
+
return _$createComponent(JsonArray, {
|
|
27
|
+
get jsValue() {
|
|
28
|
+
return props.jsValue;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (typeof props.jsValue === "object") {
|
|
33
|
+
return _$createComponent(JsonObject, {
|
|
34
|
+
get jsValue() {
|
|
35
|
+
return props.jsValue;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
throw new Error("Cannot emit js value with type of " + typeof props.jsValue);
|
|
40
|
+
}
|
|
41
|
+
function setMemberRefkey(key) {
|
|
42
|
+
if (!key) return;
|
|
43
|
+
const member = useMemberDeclaration();
|
|
44
|
+
if (!member) {
|
|
45
|
+
throw new Error("Missing member declaration.");
|
|
46
|
+
}
|
|
47
|
+
member.refkey = key;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=JsonValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonValue.js","names":["useMemberDeclaration","JsonArray","JsonObject","JsonValue","props","jsValue","setMemberRefkey","refkey","String","Array","isArray","_$createComponent","Error","key","member"],"sources":["../../../src/components/JsonValue.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAAiBA,oBAAoB,QAAQ,gBAAgB;AAC7D,SAASC,SAAS;AAClB,SAASC,UAAU;AAenB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA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
2
|
+
export interface ReferenceProps {
|
|
3
|
+
/**
|
|
4
|
+
* The refkey for the symbol to reference.
|
|
5
|
+
*/
|
|
6
|
+
refkey: Refkey;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Emit a reference to a JSON value by its refkey.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
*
|
|
13
|
+
* Note that when you place a refkey in a template, the refkey will be converted
|
|
14
|
+
* into a reference automatically. Using this component directly is generally
|
|
15
|
+
* not required or recommended.
|
|
16
|
+
*/
|
|
17
|
+
export declare function Reference(props: ReferenceProps): import("@alloy-js/core").Children;
|
|
18
|
+
//# sourceMappingURL=Reference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Reference.d.ts","sourceRoot":"","sources":["../../../src/components/Reference.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,qCAG9C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ref } from "../symbols/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Emit a reference to a JSON value by its refkey.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
*
|
|
7
|
+
* Note that when you place a refkey in a template, the refkey will be converted
|
|
8
|
+
* into a reference automatically. Using this component directly is generally
|
|
9
|
+
* not required or recommended.
|
|
10
|
+
*/
|
|
11
|
+
export function Reference(props) {
|
|
12
|
+
const reference = ref(props.refkey);
|
|
13
|
+
return ["\"", reference, "\""];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=Reference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Reference.js","names":["ref","Reference","props","reference","refkey"],"sources":["../../../src/components/Reference.tsx"],"sourcesContent":[null],"mappings":"AACA,SAASA,GAAG,QAAQ,qBAAqB;AASzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAACC,KAAqB,EAAE;EAC/C,MAAMC,SAAS,GAAGH,GAAG,CAACE,KAAK,CAACE,MAAM,CAAC;EACnC,cAAWD,SAAS;AACtB","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Children } from "@alloy-js/core";
|
|
2
|
+
export interface SourceFileProps {
|
|
3
|
+
/** The path for this source file relative to the parent directory */
|
|
4
|
+
path: string;
|
|
5
|
+
/** The contents of the source file */
|
|
6
|
+
children?: Children;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Creates a JSON source file which defines a JSON value.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link (JsonFileContext:variable)}
|
|
12
|
+
* @see {@link @alloy-js/core#(MemberDeclarationContext:variable)}
|
|
13
|
+
* @see {@link @alloy-js/core#(SourceFileContext:variable)}
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export declare function SourceFile(props: SourceFileProps): Children;
|
|
17
|
+
//# sourceMappingURL=SourceFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceFile.d.ts","sourceRoot":"","sources":["../../../src/components/SourceFile.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAIT,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IAEb,sCAAsC;IACtC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAqBhD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { SourceFile as CoreSourceFile, createSourceFileTap, MemberDeclaration } from "@alloy-js/core";
|
|
4
|
+
import { JsonFileContext } from "../context/JsonFileContext.js";
|
|
5
|
+
import { createJsonOutputSymbol } from "../symbols/json-symbol.js";
|
|
6
|
+
import { Reference } from "./Reference.js";
|
|
7
|
+
/**
|
|
8
|
+
* Creates a JSON source file which defines a JSON value.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link (JsonFileContext:variable)}
|
|
11
|
+
* @see {@link @alloy-js/core#(MemberDeclarationContext:variable)}
|
|
12
|
+
* @see {@link @alloy-js/core#(SourceFileContext:variable)}
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export function SourceFile(props) {
|
|
16
|
+
const jsonValueSym = createJsonOutputSymbol({
|
|
17
|
+
name: ""
|
|
18
|
+
});
|
|
19
|
+
const fileContext = {
|
|
20
|
+
symbol: jsonValueSym,
|
|
21
|
+
path: props.path
|
|
22
|
+
};
|
|
23
|
+
const SfTapper = createSourceFileTap(context => {
|
|
24
|
+
jsonValueSym.name = context.path;
|
|
25
|
+
});
|
|
26
|
+
return _$createComponent(CoreSourceFile, {
|
|
27
|
+
filetype: "json",
|
|
28
|
+
get path() {
|
|
29
|
+
return props.path;
|
|
30
|
+
},
|
|
31
|
+
reference: Reference,
|
|
32
|
+
get children() {
|
|
33
|
+
return [_$createComponent(SfTapper, {}), _$createComponent(JsonFileContext.Provider, {
|
|
34
|
+
value: fileContext,
|
|
35
|
+
get children() {
|
|
36
|
+
return _$createComponent(MemberDeclaration, {
|
|
37
|
+
symbol: jsonValueSym,
|
|
38
|
+
get children() {
|
|
39
|
+
return props.children;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
})];
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=SourceFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceFile.js","names":["SourceFile","CoreSourceFile","createSourceFileTap","MemberDeclaration","JsonFileContext","createJsonOutputSymbol","Reference","props","jsonValueSym","name","fileContext","symbol","path","SfTapper","context","_$createComponent","filetype","reference","children","Provider","value"],"sources":["../../../src/components/SourceFile.tsx"],"sourcesContent":[null],"mappings":";;AAAA,SAEEA,UAAU,IAAIC,cAAc,EAC5BC,mBAAmB,EACnBC,iBAAiB,QACZ,gBAAgB;AACvB,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,SAASC,sBAAsB,QAAQ,2BAA2B;AAClE,SAASC,SAAS;AAUlB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASN,UAAUA,CAACO,KAAsB,EAAE;EACjD,MAAMC,YAAY,GAAGH,sBAAsB,CAAC;IAC1CI,IAAI,EAAE;EACR,CAAC,CAAC;EAEF,MAAMC,WAA4B,GAAG;IACnCC,MAAM,EAAEH,YAAY;IACpBI,IAAI,EAAEL,KAAK,CAACK;EACd,CAAC;EAED,MAAMC,QAAQ,GAAGX,mBAAmB,CAAEY,OAAO,IAAK;IAChDN,YAAY,CAACC,IAAI,GAAGK,OAAO,CAACF,IAAI;EAClC,CAAC,CAAC;EAEF,OAAAG,iBAAA,CAAQd,cAAc;IAACe,QAAQ;IAAA,IAAQJ,IAAIA,CAAA;MAAA,OAAEL,KAAK,CAACK,IAAI;IAAA;IAAEK,SAAS,EAAEX,SAAS;IAAA,IAAAY,SAAA;MAAA,QAAAH,iBAAA,CAC1EF,QAAQ,OAAAE,iBAAA,CAAIX,eAAe,CAACe,QAAQ;QAACC,KAAK,EAAEV,WAAW;QAAA,IAAAQ,SAAA;UAAA,OAAAH,iBAAA,CACrDZ,iBAAiB;YAACQ,MAAM,EAAEH,YAAY;YAAA,IAAAU,SAAA;cAAA,OACpCX,KAAK,CAACW,QAAQ;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA;AAIvB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/index.ts"],"sourcesContent":[null],"mappings":"AAAA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as Jsx from "../index.js";
|
|
2
|
+
export declare const JsonArray: (props?: Jsx.JsonArrayProps | undefined) => import("@alloy-js/core").ComponentCreator<Jsx.JsonArrayProps> & {
|
|
3
|
+
code(template: TemplateStringsArray, ...substitutions: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.JsonArrayProps>;
|
|
4
|
+
children(...children: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.JsonArrayProps>;
|
|
5
|
+
};
|
|
6
|
+
export declare const JsonArrayElement: (props?: Jsx.JsonArrayElementProps | undefined) => import("@alloy-js/core").ComponentCreator<Jsx.JsonArrayElementProps> & {
|
|
7
|
+
code(template: TemplateStringsArray, ...substitutions: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.JsonArrayElementProps>;
|
|
8
|
+
children(...children: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.JsonArrayElementProps>;
|
|
9
|
+
};
|
|
10
|
+
export declare const JsonObject: (props?: Jsx.JsonObjectProps | undefined) => import("@alloy-js/core").ComponentCreator<Jsx.JsonObjectProps> & {
|
|
11
|
+
code(template: TemplateStringsArray, ...substitutions: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.JsonObjectProps>;
|
|
12
|
+
children(...children: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.JsonObjectProps>;
|
|
13
|
+
};
|
|
14
|
+
export declare const JsonObjectProperty: (props: Jsx.ObjectPropertyProps) => import("@alloy-js/core").ComponentCreator<Jsx.ObjectPropertyProps> & {
|
|
15
|
+
code(template: TemplateStringsArray, ...substitutions: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.ObjectPropertyProps>;
|
|
16
|
+
children(...children: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.ObjectPropertyProps>;
|
|
17
|
+
};
|
|
18
|
+
export declare const JsonValue: (props: Jsx.JsonValueProps) => import("@alloy-js/core").ComponentCreator<Jsx.JsonValueProps> & {
|
|
19
|
+
code(template: TemplateStringsArray, ...substitutions: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.JsonValueProps>;
|
|
20
|
+
children(...children: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.JsonValueProps>;
|
|
21
|
+
};
|
|
22
|
+
export declare const Reference: (props: Jsx.ReferenceProps) => import("@alloy-js/core").ComponentCreator<Jsx.ReferenceProps> & {
|
|
23
|
+
code(template: TemplateStringsArray, ...substitutions: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.ReferenceProps>;
|
|
24
|
+
children(...children: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.ReferenceProps>;
|
|
25
|
+
};
|
|
26
|
+
export declare const SourceFile: (props: Jsx.SourceFileProps) => import("@alloy-js/core").ComponentCreator<Jsx.SourceFileProps> & {
|
|
27
|
+
code(template: TemplateStringsArray, ...substitutions: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.SourceFileProps>;
|
|
28
|
+
children(...children: import("@alloy-js/core").Children[]): import("@alloy-js/core").ComponentCreator<Jsx.SourceFileProps>;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stc/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,aAAa,CAAC;AAEnC,eAAO,MAAM,SAAS;;;CAAqB,CAAC;AAC5C,eAAO,MAAM,gBAAgB;;;CAA4B,CAAC;AAC1D,eAAO,MAAM,UAAU;;;CAAsB,CAAC;AAC9C,eAAO,MAAM,kBAAkB;;;CAA8B,CAAC;AAC9D,eAAO,MAAM,SAAS;;;CAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS;;;CAAqB,CAAC;AAC5C,eAAO,MAAM,UAAU;;;CAAsB,CAAC"}
|