@alloy-js/json 0.19.0 → 0.20.0-dev.1
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/dist/src/components/json-array.d.ts.map +1 -1
- package/dist/src/components/json-array.js +13 -21
- package/dist/src/components/json-object.d.ts.map +1 -1
- package/dist/src/components/json-object.js +13 -14
- package/dist/src/components/source-file.d.ts.map +1 -1
- package/dist/src/components/source-file.js +4 -8
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +23 -6
- package/dist/src/symbols/json-symbol.d.ts +5 -2
- package/dist/src/symbols/json-symbol.d.ts.map +1 -1
- package/dist/src/symbols/json-symbol.js +15 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/components/json-array.tsx +13 -27
- package/src/components/json-object.tsx +14 -17
- package/src/components/source-file.tsx +4 -6
- package/src/symbols/index.ts +38 -8
- package/src/symbols/json-symbol.ts +23 -2
- package/temp/api.json +130 -3
- package/tsdoc-metadata.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-array.d.ts","sourceRoot":"","sources":["../../../src/components/json-array.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"json-array.d.ts","sourceRoot":"","sources":["../../../src/components/json-array.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EASR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,kBAAkB;IACjC;;;QAGI;IACJ,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACnE;;OAEG;IACH,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GACtB,yBAAyB,GACzB,0BAA0B,CAAC;AAE/B;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,YAsC9C;AAED;;;GAGG;AACH,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,MAAM,MAAM,qBAAqB,GAC7B,gCAAgC,GAChC,iCAAiC,CAAC;AAEtC;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,YAkB5D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { For, Indent, List, MemberDeclaration, MemberScope,
|
|
2
|
+
import { emitSymbol, For, Indent, List, MemberDeclaration, MemberScope, moveTakenMembersTo, onCleanup, useMemberScope } from "@alloy-js/core";
|
|
3
3
|
import { JsonOutputSymbol } from "../symbols/json-symbol.js";
|
|
4
4
|
import { JsonValue } from "./json-value.js";
|
|
5
5
|
|
|
@@ -19,17 +19,15 @@ import { JsonValue } from "./json-value.js";
|
|
|
19
19
|
* @see {@link @alloy-js/core#(MemberScopeContext:variable)}
|
|
20
20
|
*/
|
|
21
21
|
export function JsonArray(props) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (props.refkey) {
|
|
28
|
-
memberSymbol.refkeys = [props.refkey].flat();
|
|
29
|
-
}
|
|
22
|
+
const arraySym = new JsonOutputSymbol("array symbol", undefined, {
|
|
23
|
+
transient: true,
|
|
24
|
+
refkeys: props.refkey ? [props.refkey].flat() : undefined
|
|
25
|
+
});
|
|
26
|
+
emitSymbol(arraySym);
|
|
30
27
|
if (!("jsValue" in props)) {
|
|
31
28
|
return _$createComponent(MemberScope, {
|
|
32
|
-
|
|
29
|
+
ownerSymbol: arraySym,
|
|
30
|
+
name: "array scope",
|
|
33
31
|
get children() {
|
|
34
32
|
return _$createIntrinsic("group", {
|
|
35
33
|
get children() {
|
|
@@ -53,7 +51,7 @@ export function JsonArray(props) {
|
|
|
53
51
|
}
|
|
54
52
|
const jsValue = props.jsValue ?? [];
|
|
55
53
|
return _$createComponent(MemberScope, {
|
|
56
|
-
|
|
54
|
+
ownerSymbol: arraySym,
|
|
57
55
|
get children() {
|
|
58
56
|
return _$createIntrinsic("group", {
|
|
59
57
|
get children() {
|
|
@@ -95,16 +93,10 @@ export function JsonArray(props) {
|
|
|
95
93
|
*/
|
|
96
94
|
export function JsonArrayElement(props) {
|
|
97
95
|
const memberScope = useMemberScope();
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
throw new Error("Missing static members scope.");
|
|
103
|
-
}
|
|
104
|
-
const name = String(memberScope.staticMembers.symbols.size);
|
|
105
|
-
const sym = new JsonOutputSymbol(name, {
|
|
106
|
-
flags: OutputSymbolFlags.StaticMember
|
|
107
|
-
});
|
|
96
|
+
const ownerSymbol = memberScope.ownerSymbol;
|
|
97
|
+
const name = String(ownerSymbol.staticMembers.size);
|
|
98
|
+
const sym = new JsonOutputSymbol(name, ownerSymbol.staticMembers);
|
|
99
|
+
moveTakenMembersTo(sym);
|
|
108
100
|
onCleanup(() => {
|
|
109
101
|
sym.delete();
|
|
110
102
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-object.d.ts","sourceRoot":"","sources":["../../../src/components/json-object.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"json-object.d.ts","sourceRoot":"","sources":["../../../src/components/json-object.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUR,MAAM,EAEP,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,mBAAmB;IAClC;;;QAGI;IACJ,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE3B,KAAK,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA2B,SAAQ,mBAAmB;IACrE;;;OAGG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/E;AAED,MAAM,MAAM,eAAe,GACvB,2BAA2B,GAC3B,0BAA0B,CAAC;AAE/B;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,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,YAsB5D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { memo as _$memo, createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { computed, For, Indent, List, MemberDeclaration, MemberScope,
|
|
2
|
+
import { computed, emitSymbol, For, Indent, List, MemberDeclaration, MemberScope, moveTakenMembersTo, onCleanup, useMemberScope } from "@alloy-js/core";
|
|
3
3
|
import { JsonOutputSymbol } from "../symbols/json-symbol.js";
|
|
4
4
|
import { JsonValue } from "./json-value.js";
|
|
5
5
|
|
|
@@ -21,17 +21,15 @@ import { JsonValue } from "./json-value.js";
|
|
|
21
21
|
* @see {@link @alloy-js/core#MemberScopeContext}
|
|
22
22
|
*/
|
|
23
23
|
export function JsonObject(props) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (props.refkey) {
|
|
30
|
-
memberSymbol.refkeys = [props.refkey].flat();
|
|
31
|
-
}
|
|
24
|
+
const objectSym = new JsonOutputSymbol("object symbol", undefined, {
|
|
25
|
+
transient: true,
|
|
26
|
+
refkeys: props.refkey ? [props.refkey].flat() : undefined
|
|
27
|
+
});
|
|
28
|
+
emitSymbol(objectSym);
|
|
32
29
|
if (!("jsValue" in props)) {
|
|
33
30
|
return _$createComponent(MemberScope, {
|
|
34
|
-
|
|
31
|
+
ownerSymbol: objectSym,
|
|
32
|
+
name: "object scope",
|
|
35
33
|
get children() {
|
|
36
34
|
return _$createIntrinsic("group", {
|
|
37
35
|
get children() {
|
|
@@ -71,7 +69,7 @@ export function JsonObject(props) {
|
|
|
71
69
|
}
|
|
72
70
|
});
|
|
73
71
|
return _$createComponent(MemberScope, {
|
|
74
|
-
|
|
72
|
+
ownerSymbol: objectSym,
|
|
75
73
|
get children() {
|
|
76
74
|
return _$createIntrinsic("group", {
|
|
77
75
|
get children() {
|
|
@@ -118,9 +116,10 @@ export function JsonObject(props) {
|
|
|
118
116
|
* @see {@link @alloy-js/core#(MemberDeclarationContext:variable)}
|
|
119
117
|
*/
|
|
120
118
|
export function JsonObjectProperty(props) {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
const memberScope = useMemberScope();
|
|
120
|
+
const ownerSymbol = memberScope.ownerSymbol;
|
|
121
|
+
const sym = new JsonOutputSymbol(props.name, ownerSymbol.staticMembers);
|
|
122
|
+
moveTakenMembersTo(sym);
|
|
124
123
|
onCleanup(() => {
|
|
125
124
|
sym.delete();
|
|
126
125
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-file.d.ts","sourceRoot":"","sources":["../../../src/components/source-file.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAIT,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IAEb,sCAAsC;IACtC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"source-file.d.ts","sourceRoot":"","sources":["../../../src/components/source-file.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAIT,MAAM,gBAAgB,CAAC;AAKxB,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IAEb,sCAAsC;IACtC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,YAoBhD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import { SourceFile as CoreSourceFile, createSourceFileTap,
|
|
2
|
+
import { SourceFile as CoreSourceFile, createSourceFileTap, moveTakenMembersTo } from "@alloy-js/core";
|
|
3
3
|
import { JsonFileContext } from "../context/JsonFileContext.js";
|
|
4
4
|
import { JsonOutputSymbol } from "../symbols/json-symbol.js";
|
|
5
5
|
import { Reference } from "./reference.js";
|
|
@@ -12,7 +12,8 @@ import { Reference } from "./reference.js";
|
|
|
12
12
|
*
|
|
13
13
|
*/
|
|
14
14
|
export function SourceFile(props) {
|
|
15
|
-
const jsonValueSym = new JsonOutputSymbol(
|
|
15
|
+
const jsonValueSym = new JsonOutputSymbol(props.path, undefined);
|
|
16
|
+
moveTakenMembersTo(jsonValueSym);
|
|
16
17
|
const fileContext = {
|
|
17
18
|
symbol: jsonValueSym,
|
|
18
19
|
path: props.path
|
|
@@ -30,12 +31,7 @@ export function SourceFile(props) {
|
|
|
30
31
|
return [_$createComponent(SfTapper, {}), _$createComponent(JsonFileContext.Provider, {
|
|
31
32
|
value: fileContext,
|
|
32
33
|
get children() {
|
|
33
|
-
return
|
|
34
|
-
symbol: jsonValueSym,
|
|
35
|
-
get children() {
|
|
36
|
-
return props.children;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
34
|
+
return props.children;
|
|
39
35
|
}
|
|
40
36
|
})];
|
|
41
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/symbols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAW,MAAM,gBAAgB,CAAC;AAIpE,cAAc,kBAAkB,CAAC;AAEjC,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/symbols/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,MAAM,EAAW,MAAM,gBAAgB,CAAC;AAIpE,cAAc,kBAAkB,CAAC;AAEjC,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,0CAkEjC"}
|
|
@@ -13,21 +13,38 @@ export function ref(refkey) {
|
|
|
13
13
|
return "<Unresolved Symbol>";
|
|
14
14
|
}
|
|
15
15
|
const {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
pathDown,
|
|
17
|
+
pathUp,
|
|
18
|
+
lexicalDeclaration,
|
|
19
|
+
memberPath,
|
|
20
|
+
commonScope,
|
|
21
|
+
fullSymbolPath
|
|
18
22
|
} = resolveResult.value;
|
|
19
23
|
let ref = "";
|
|
20
|
-
|
|
24
|
+
let isCrossFile = false;
|
|
25
|
+
// When we have no common scope and we don't path up through the symbol
|
|
26
|
+
// we're referencing (i.e. the symbol we're referencing isn't the symbol for
|
|
27
|
+
// the file the reference occurs in), append the file path.
|
|
28
|
+
if (commonScope === undefined && pathUp[0] && pathUp[0].ownerSymbol !== lexicalDeclaration) {
|
|
21
29
|
const currentPath = sourceFile.symbol.name;
|
|
22
|
-
const targetPath =
|
|
30
|
+
const targetPath = lexicalDeclaration.name;
|
|
31
|
+
isCrossFile = true;
|
|
23
32
|
ref += relative(dirname(currentPath), targetPath);
|
|
24
33
|
}
|
|
25
34
|
ref += "#";
|
|
26
|
-
if (
|
|
35
|
+
if (commonScope === undefined && pathDown.length === 0 && memberPath.length === 0) {
|
|
36
|
+
// we are referring to the root of a file
|
|
27
37
|
return ref;
|
|
28
38
|
}
|
|
29
39
|
ref += "/";
|
|
30
|
-
|
|
40
|
+
if (isCrossFile) {
|
|
41
|
+
// the lexical declaration is the file symbol, so we just need any
|
|
42
|
+
// additional members.
|
|
43
|
+
ref += memberPath.map(s => s.name).join("/");
|
|
44
|
+
} else {
|
|
45
|
+
// merge together the member scopes, lexical declaration, and member path
|
|
46
|
+
ref += fullSymbolPath.slice(1).map(s => s.ownerSymbol.name).concat(lexicalDeclaration.name).concat(memberPath.map(s => s.name)).join("/");
|
|
47
|
+
}
|
|
31
48
|
return ref;
|
|
32
49
|
});
|
|
33
50
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OutputSymbol, OutputSymbolOptions } from "@alloy-js/core";
|
|
1
|
+
import { OutputSpace, OutputSymbol, OutputSymbolOptions } from "@alloy-js/core";
|
|
2
2
|
export declare enum JsonSymbolFlags {
|
|
3
3
|
None = 0,
|
|
4
4
|
Object = 1,
|
|
@@ -12,9 +12,12 @@ export declare enum JsonSymbolFlags {
|
|
|
12
12
|
*/
|
|
13
13
|
export declare class JsonOutputSymbol extends OutputSymbol {
|
|
14
14
|
#private;
|
|
15
|
+
static readonly memberSpaces: readonly ["static"];
|
|
15
16
|
get jsonFlags(): JsonSymbolFlags;
|
|
16
17
|
set jsonFlags(value: JsonSymbolFlags);
|
|
17
|
-
constructor(name: string, options?: CreateJsonSymbolOptions);
|
|
18
|
+
constructor(name: string, spaces: OutputSpace[] | OutputSpace | undefined, options?: CreateJsonSymbolOptions);
|
|
19
|
+
copy(): JsonOutputSymbol;
|
|
20
|
+
get staticMembers(): import("@alloy-js/core").OutputMemberSpace;
|
|
18
21
|
}
|
|
19
22
|
export interface CreateJsonSymbolOptions extends OutputSymbolOptions {
|
|
20
23
|
jsonFlags?: JsonSymbolFlags;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/json-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EAKpB,MAAM,gBAAgB,CAAC;AAGxB,oBAAY,eAAe;IACzB,IAAI,IAAI;IACR,MAAM,IAAS;IACf,KAAK,IAAS;CACf;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,YAAY;;
|
|
1
|
+
{"version":3,"file":"json-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/json-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,mBAAmB,EAKpB,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,sBAAuB;IAGnD,IAAI,SAAS,IAAI,eAAe,CAG/B;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,eAAe,EAQnC;gBAGC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,GAAG,SAAS,EAC/C,OAAO,GAAE,uBAA4B;IAOvC,IAAI;IAUJ,IAAI,aAAa,+CAEhB;CACF;AAED,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;IAClE,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B"}
|
|
@@ -15,6 +15,7 @@ export let JsonSymbolFlags = /*#__PURE__*/function (JsonSymbolFlags) {
|
|
|
15
15
|
* `StaticMember` flag.
|
|
16
16
|
*/
|
|
17
17
|
export class JsonOutputSymbol extends OutputSymbol {
|
|
18
|
+
static memberSpaces = ["static"];
|
|
18
19
|
#jsonFlags;
|
|
19
20
|
get jsonFlags() {
|
|
20
21
|
track(this, TrackOpTypes.GET, "jsonFlags");
|
|
@@ -28,8 +29,20 @@ export class JsonOutputSymbol extends OutputSymbol {
|
|
|
28
29
|
this.#jsonFlags = value;
|
|
29
30
|
trigger(this, TriggerOpTypes.SET, "jsonFlags", value, old);
|
|
30
31
|
}
|
|
31
|
-
constructor(name, options = {}) {
|
|
32
|
-
super(name, options);
|
|
32
|
+
constructor(name, spaces, options = {}) {
|
|
33
|
+
super(name, spaces, options);
|
|
33
34
|
this.#jsonFlags = options.jsonFlags ?? JsonSymbolFlags.None;
|
|
34
35
|
}
|
|
36
|
+
copy() {
|
|
37
|
+
const options = this.getCopyOptions();
|
|
38
|
+
const copy = new JsonOutputSymbol(this.name, undefined, {
|
|
39
|
+
...options,
|
|
40
|
+
jsonFlags: this.#jsonFlags
|
|
41
|
+
});
|
|
42
|
+
this.initializeCopy(copy);
|
|
43
|
+
return copy;
|
|
44
|
+
}
|
|
45
|
+
get staticMembers() {
|
|
46
|
+
return this.memberSpaceFor("static");
|
|
47
|
+
}
|
|
35
48
|
}
|