@alloy-js/json 0.16.0 → 0.18.0-dev.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.
@@ -1,10 +1,10 @@
1
- import { stc } from "@alloy-js/core";
1
+ import * as core from "@alloy-js/core";
2
2
  import * as Jsx from "../index.js";
3
3
 
4
- export const JsonArray = stc(Jsx.JsonArray);
5
- export const JsonArrayElement = stc(Jsx.JsonArrayElement);
6
- export const JsonObject = stc(Jsx.JsonObject);
7
- export const JsonObjectProperty = stc(Jsx.JsonObjectProperty);
8
- export const JsonValue = stc(Jsx.JsonValue);
9
- export const Reference = stc(Jsx.Reference);
10
- export const SourceFile = stc(Jsx.SourceFile);
4
+ export const JsonArray = core.stc(Jsx.JsonArray);
5
+ export const JsonArrayElement = core.stc(Jsx.JsonArrayElement);
6
+ export const JsonObject = core.stc(Jsx.JsonObject);
7
+ export const JsonObjectProperty = core.stc(Jsx.JsonObjectProperty);
8
+ export const JsonValue = core.stc(Jsx.JsonValue);
9
+ export const Reference = core.stc(Jsx.Reference);
10
+ export const SourceFile = core.stc(Jsx.SourceFile);
@@ -1,10 +1,10 @@
1
1
  import {
2
- CreateSymbolOptions,
3
- OutputScope,
4
2
  OutputSymbol,
5
- OutputSymbolFlags,
6
- useBinder,
7
- useMemberScope,
3
+ OutputSymbolOptions,
4
+ track,
5
+ TrackOpTypes,
6
+ trigger,
7
+ TriggerOpTypes,
8
8
  } from "@alloy-js/core";
9
9
 
10
10
  // prettier-ignore
@@ -20,49 +20,30 @@ export enum JsonSymbolFlags {
20
20
  * values that are members of an object or an array, the symbol will have the
21
21
  * `StaticMember` flag.
22
22
  */
23
- export interface JsonOutputSymbol extends OutputSymbol {
24
- scope: OutputScope;
25
- jsonFlags: JsonSymbolFlags;
26
- }
23
+ export class JsonOutputSymbol extends OutputSymbol {
24
+ #jsonFlags: JsonSymbolFlags;
25
+ get jsonFlags(): JsonSymbolFlags {
26
+ track(this, TrackOpTypes.GET, "jsonFlags");
27
+ return this.#jsonFlags;
28
+ }
27
29
 
28
- export interface createJsonSymbolOptions extends CreateSymbolOptions {
29
- jsonFlags?: JsonSymbolFlags;
30
- }
30
+ set jsonFlags(value: JsonSymbolFlags) {
31
+ const old = this.#jsonFlags;
32
+ if (old === value) {
33
+ return;
34
+ }
31
35
 
32
- export function createJsonOutputSymbol(
33
- options: createJsonSymbolOptions,
34
- ): JsonOutputSymbol {
35
- const scope =
36
- options.scope ??
37
- (useDefaultScope(options.flags) as OutputScope) ??
38
- useBinder().globalScope;
36
+ this.#jsonFlags = value;
37
+ trigger(this, TriggerOpTypes.SET, "jsonFlags", value, old);
38
+ }
39
39
 
40
- const binder = scope.binder;
41
- const sym = binder.createSymbol<JsonOutputSymbol>({
42
- name: options.name,
43
- scope,
44
- refkey: options.refkey,
45
- flags: options.flags ?? OutputSymbolFlags.None,
46
- jsonFlags: options.jsonFlags ?? JsonSymbolFlags.None,
47
- });
40
+ constructor(name: string, options: CreateJsonSymbolOptions = {}) {
41
+ super(name, options);
48
42
 
49
- return sym;
43
+ this.#jsonFlags = options.jsonFlags ?? JsonSymbolFlags.None;
44
+ }
50
45
  }
51
46
 
52
- export function useDefaultScope(
53
- flags: OutputSymbolFlags = OutputSymbolFlags.None,
54
- ) {
55
- if ((flags & OutputSymbolFlags.Member) === 0) {
56
- return useBinder().globalScope;
57
- } else {
58
- const memberScope = useMemberScope();
59
- if (!memberScope) {
60
- throw new Error("Cannot declare member symbols without a member scope");
61
- }
62
- if (flags & OutputSymbolFlags.InstanceMember) {
63
- return memberScope.instanceMembers;
64
- } else {
65
- return memberScope.staticMembers;
66
- }
67
- }
47
+ export interface CreateJsonSymbolOptions extends OutputSymbolOptions {
48
+ jsonFlags?: JsonSymbolFlags;
68
49
  }
package/temp/api.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "metadata": {
3
3
  "toolPackage": "@microsoft/api-extractor",
4
- "toolVersion": "7.47.12",
4
+ "toolVersion": "7.52.8",
5
5
  "schemaVersion": 1011,
6
6
  "oldestForwardsCompatibleVersion": 1001,
7
7
  "tsdocConfig": {
@@ -172,66 +172,19 @@
172
172
  "name": "",
173
173
  "preserveMemberOrder": false,
174
174
  "members": [
175
- {
176
- "kind": "Function",
177
- "canonicalReference": "@alloy-js/json!createJsonOutputSymbol:function(1)",
178
- "docComment": "",
179
- "excerptTokens": [
180
- {
181
- "kind": "Content",
182
- "text": "export declare function createJsonOutputSymbol(options: "
183
- },
184
- {
185
- "kind": "Reference",
186
- "text": "createJsonSymbolOptions",
187
- "canonicalReference": "@alloy-js/json!createJsonSymbolOptions:interface"
188
- },
189
- {
190
- "kind": "Content",
191
- "text": "): "
192
- },
193
- {
194
- "kind": "Reference",
195
- "text": "JsonOutputSymbol",
196
- "canonicalReference": "@alloy-js/json!JsonOutputSymbol:interface"
197
- },
198
- {
199
- "kind": "Content",
200
- "text": ";"
201
- }
202
- ],
203
- "fileUrlPath": "src/symbols/json-symbol.ts",
204
- "returnTypeTokenRange": {
205
- "startIndex": 3,
206
- "endIndex": 4
207
- },
208
- "releaseTag": "Public",
209
- "overloadIndex": 1,
210
- "parameters": [
211
- {
212
- "parameterName": "options",
213
- "parameterTypeTokenRange": {
214
- "startIndex": 1,
215
- "endIndex": 2
216
- },
217
- "isOptional": false
218
- }
219
- ],
220
- "name": "createJsonOutputSymbol"
221
- },
222
175
  {
223
176
  "kind": "Interface",
224
- "canonicalReference": "@alloy-js/json!createJsonSymbolOptions:interface",
177
+ "canonicalReference": "@alloy-js/json!CreateJsonSymbolOptions:interface",
225
178
  "docComment": "",
226
179
  "excerptTokens": [
227
180
  {
228
181
  "kind": "Content",
229
- "text": "export interface createJsonSymbolOptions extends "
182
+ "text": "export interface CreateJsonSymbolOptions extends "
230
183
  },
231
184
  {
232
185
  "kind": "Reference",
233
- "text": "CreateSymbolOptions",
234
- "canonicalReference": "@alloy-js/core!CreateSymbolOptions:type"
186
+ "text": "OutputSymbolOptions",
187
+ "canonicalReference": "@alloy-js/core!OutputSymbolOptions:interface"
235
188
  },
236
189
  {
237
190
  "kind": "Content",
@@ -240,12 +193,12 @@
240
193
  ],
241
194
  "fileUrlPath": "src/symbols/json-symbol.ts",
242
195
  "releaseTag": "Public",
243
- "name": "createJsonSymbolOptions",
196
+ "name": "CreateJsonSymbolOptions",
244
197
  "preserveMemberOrder": false,
245
198
  "members": [
246
199
  {
247
200
  "kind": "PropertySignature",
248
- "canonicalReference": "@alloy-js/json!createJsonSymbolOptions#jsonFlags:member",
201
+ "canonicalReference": "@alloy-js/json!CreateJsonSymbolOptions#jsonFlags:member",
249
202
  "docComment": "",
250
203
  "excerptTokens": [
251
204
  {
@@ -768,7 +721,7 @@
768
721
  {
769
722
  "kind": "Reference",
770
723
  "text": "JsonOutputSymbol",
771
- "canonicalReference": "@alloy-js/json!JsonOutputSymbol:interface"
724
+ "canonicalReference": "@alloy-js/json!JsonOutputSymbol:class"
772
725
  },
773
726
  {
774
727
  "kind": "Content",
@@ -1205,18 +1158,18 @@
1205
1158
  ]
1206
1159
  },
1207
1160
  {
1208
- "kind": "Interface",
1209
- "canonicalReference": "@alloy-js/json!JsonOutputSymbol:interface",
1161
+ "kind": "Class",
1162
+ "canonicalReference": "@alloy-js/json!JsonOutputSymbol:class",
1210
1163
  "docComment": "/**\n * JsonOutputSymbol is created for JSON Values with a refkey. For JSON objects\n * and arrays, the symbol will have the `StaticMemberContainer` flag. For JSON\n * values that are members of an object or an array, the symbol will have the\n * `StaticMember` flag.\n */\n",
1211
1164
  "excerptTokens": [
1212
1165
  {
1213
1166
  "kind": "Content",
1214
- "text": "export interface JsonOutputSymbol extends "
1167
+ "text": "export declare class JsonOutputSymbol extends "
1215
1168
  },
1216
1169
  {
1217
1170
  "kind": "Reference",
1218
1171
  "text": "OutputSymbol",
1219
- "canonicalReference": "@alloy-js/core!OutputSymbol:interface"
1172
+ "canonicalReference": "@alloy-js/core!OutputSymbol:class"
1220
1173
  },
1221
1174
  {
1222
1175
  "kind": "Content",
@@ -1225,72 +1178,105 @@
1225
1178
  ],
1226
1179
  "fileUrlPath": "src/symbols/json-symbol.ts",
1227
1180
  "releaseTag": "Public",
1181
+ "isAbstract": false,
1228
1182
  "name": "JsonOutputSymbol",
1229
1183
  "preserveMemberOrder": false,
1230
1184
  "members": [
1231
1185
  {
1232
- "kind": "PropertySignature",
1233
- "canonicalReference": "@alloy-js/json!JsonOutputSymbol#jsonFlags:member",
1234
- "docComment": "",
1186
+ "kind": "Constructor",
1187
+ "canonicalReference": "@alloy-js/json!JsonOutputSymbol:constructor(1)",
1188
+ "docComment": "/**\n * Constructs a new instance of the `JsonOutputSymbol` class\n */\n",
1235
1189
  "excerptTokens": [
1236
1190
  {
1237
1191
  "kind": "Content",
1238
- "text": "jsonFlags: "
1192
+ "text": "constructor(name: "
1193
+ },
1194
+ {
1195
+ "kind": "Content",
1196
+ "text": "string"
1197
+ },
1198
+ {
1199
+ "kind": "Content",
1200
+ "text": ", options?: "
1239
1201
  },
1240
1202
  {
1241
1203
  "kind": "Reference",
1242
- "text": "JsonSymbolFlags",
1243
- "canonicalReference": "@alloy-js/json!JsonSymbolFlags:enum"
1204
+ "text": "CreateJsonSymbolOptions",
1205
+ "canonicalReference": "@alloy-js/json!CreateJsonSymbolOptions:interface"
1244
1206
  },
1245
1207
  {
1246
1208
  "kind": "Content",
1247
- "text": ";"
1209
+ "text": ");"
1248
1210
  }
1249
1211
  ],
1250
- "isReadonly": false,
1251
- "isOptional": false,
1252
1212
  "releaseTag": "Public",
1253
- "name": "jsonFlags",
1254
- "propertyTypeTokenRange": {
1255
- "startIndex": 1,
1256
- "endIndex": 2
1257
- }
1213
+ "isProtected": false,
1214
+ "overloadIndex": 1,
1215
+ "parameters": [
1216
+ {
1217
+ "parameterName": "name",
1218
+ "parameterTypeTokenRange": {
1219
+ "startIndex": 1,
1220
+ "endIndex": 2
1221
+ },
1222
+ "isOptional": false
1223
+ },
1224
+ {
1225
+ "parameterName": "options",
1226
+ "parameterTypeTokenRange": {
1227
+ "startIndex": 3,
1228
+ "endIndex": 4
1229
+ },
1230
+ "isOptional": true
1231
+ }
1232
+ ]
1258
1233
  },
1259
1234
  {
1260
- "kind": "PropertySignature",
1261
- "canonicalReference": "@alloy-js/json!JsonOutputSymbol#scope:member",
1235
+ "kind": "Property",
1236
+ "canonicalReference": "@alloy-js/json!JsonOutputSymbol#jsonFlags:member",
1262
1237
  "docComment": "",
1263
1238
  "excerptTokens": [
1264
1239
  {
1265
1240
  "kind": "Content",
1266
- "text": "scope: "
1241
+ "text": "get jsonFlags(): "
1267
1242
  },
1268
1243
  {
1269
1244
  "kind": "Reference",
1270
- "text": "OutputScope",
1271
- "canonicalReference": "@alloy-js/core!OutputScope:interface"
1245
+ "text": "JsonSymbolFlags",
1246
+ "canonicalReference": "@alloy-js/json!JsonSymbolFlags:enum"
1272
1247
  },
1273
1248
  {
1274
1249
  "kind": "Content",
1275
- "text": ";"
1250
+ "text": ";\n\nset jsonFlags(value: "
1251
+ },
1252
+ {
1253
+ "kind": "Reference",
1254
+ "text": "JsonSymbolFlags",
1255
+ "canonicalReference": "@alloy-js/json!JsonSymbolFlags:enum"
1256
+ },
1257
+ {
1258
+ "kind": "Content",
1259
+ "text": ");"
1276
1260
  }
1277
1261
  ],
1278
1262
  "isReadonly": false,
1279
1263
  "isOptional": false,
1280
1264
  "releaseTag": "Public",
1281
- "name": "scope",
1265
+ "name": "jsonFlags",
1282
1266
  "propertyTypeTokenRange": {
1283
1267
  "startIndex": 1,
1284
1268
  "endIndex": 2
1285
- }
1269
+ },
1270
+ "isStatic": false,
1271
+ "isProtected": false,
1272
+ "isAbstract": false
1286
1273
  }
1287
1274
  ],
1288
- "extendsTokenRanges": [
1289
- {
1290
- "startIndex": 1,
1291
- "endIndex": 2
1292
- }
1293
- ]
1275
+ "extendsTokenRange": {
1276
+ "startIndex": 1,
1277
+ "endIndex": 2
1278
+ },
1279
+ "implementsTokenRanges": []
1294
1280
  },
1295
1281
  {
1296
1282
  "kind": "Enum",
@@ -1953,57 +1939,6 @@
1953
1939
  ],
1954
1940
  "extendsTokenRanges": []
1955
1941
  },
1956
- {
1957
- "kind": "Function",
1958
- "canonicalReference": "@alloy-js/json!useDefaultScope:function(1)",
1959
- "docComment": "",
1960
- "excerptTokens": [
1961
- {
1962
- "kind": "Content",
1963
- "text": "export declare function useDefaultScope(flags?: "
1964
- },
1965
- {
1966
- "kind": "Reference",
1967
- "text": "OutputSymbolFlags",
1968
- "canonicalReference": "@alloy-js/core!OutputSymbolFlags:enum"
1969
- },
1970
- {
1971
- "kind": "Content",
1972
- "text": "): "
1973
- },
1974
- {
1975
- "kind": "Reference",
1976
- "text": "OutputScope",
1977
- "canonicalReference": "@alloy-js/core!OutputScope:interface"
1978
- },
1979
- {
1980
- "kind": "Content",
1981
- "text": " | undefined"
1982
- },
1983
- {
1984
- "kind": "Content",
1985
- "text": ";"
1986
- }
1987
- ],
1988
- "fileUrlPath": "src/symbols/json-symbol.ts",
1989
- "returnTypeTokenRange": {
1990
- "startIndex": 3,
1991
- "endIndex": 5
1992
- },
1993
- "releaseTag": "Public",
1994
- "overloadIndex": 1,
1995
- "parameters": [
1996
- {
1997
- "parameterName": "flags",
1998
- "parameterTypeTokenRange": {
1999
- "startIndex": 1,
2000
- "endIndex": 2
2001
- },
2002
- "isOptional": true
2003
- }
2004
- ],
2005
- "name": "useDefaultScope"
2006
- },
2007
1942
  {
2008
1943
  "kind": "Function",
2009
1944
  "canonicalReference": "@alloy-js/json!useJsonFileContext:function(1)",
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.47.12"
8
+ "packageVersion": "7.52.8"
9
9
  }
10
10
  ]
11
11
  }
package/LICENSE DELETED
@@ -1,7 +0,0 @@
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.