@player-tools/json-language-service 0.9.0-next.1 → 0.9.0-next.3
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/cjs/index.cjs +29 -167
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +20 -158
- package/dist/index.mjs +20 -158
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
- package/src/constants.ts +3 -5
- package/src/index.ts +47 -16
- package/src/parser/index.ts +1 -1
- package/src/plugins/asset-wrapper-array-plugin.ts +1 -1
- package/src/plugins/binding-schema-plugin.ts +1 -1
- package/src/plugins/duplicate-id-plugin.ts +1 -1
- package/src/plugins/nav-state-plugin.ts +1 -1
- package/src/plugins/view-node-plugin.ts +1 -1
- package/src/plugins/xlr-plugin.ts +1 -1
- package/src/utils.ts +3 -1
- package/types/constants.d.ts +2 -1
- package/types/index.d.ts +19 -9
- package/src/plugins/__tests__/action-plugin.test.ts +0 -168
- package/src/plugins/__tests__/template-plugin.test.ts +0 -97
- package/src/plugins/legacy-action-plugin.ts +0 -79
- package/src/plugins/legacy-template-plugin.ts +0 -125
- package/types/plugins/legacy-action-plugin.d.ts +0 -7
- package/types/plugins/legacy-template-plugin.d.ts +0 -7
package/dist/cjs/index.cjs
CHANGED
|
@@ -89,7 +89,7 @@ __export(src_exports, {
|
|
|
89
89
|
module.exports = __toCommonJS(src_exports);
|
|
90
90
|
var import_jsonc_parser4 = require("jsonc-parser");
|
|
91
91
|
var import_tapable_ts = require("tapable-ts");
|
|
92
|
-
var
|
|
92
|
+
var import_vscode_languageserver_types11 = require("vscode-languageserver-types");
|
|
93
93
|
|
|
94
94
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-service/src/plugins/asset-wrapper-array-plugin.ts
|
|
95
95
|
var import_vscode_languageserver_types4 = require("vscode-languageserver-types");
|
|
@@ -1340,146 +1340,8 @@ var DuplicateIDPlugin = class {
|
|
|
1340
1340
|
}
|
|
1341
1341
|
};
|
|
1342
1342
|
|
|
1343
|
-
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-service/src/plugins/legacy-action-plugin.ts
|
|
1344
|
-
var import_vscode_languageserver_types8 = require("vscode-languageserver-types");
|
|
1345
|
-
function createRuleVisitor(context) {
|
|
1346
|
-
const checkForLegacyAction = (node) => {
|
|
1347
|
-
if (node.type === "asset") {
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
if (node.type === "object" && !node.properties.some(
|
|
1351
|
-
(p) => p.keyNode.value === "asset" || p.keyNode.value === "dynamicSwitch" || p.keyNode.value === "staticSwitch"
|
|
1352
|
-
)) {
|
|
1353
|
-
context.addViolation({
|
|
1354
|
-
message: "Migrate to an action-asset",
|
|
1355
|
-
node,
|
|
1356
|
-
severity: import_vscode_languageserver_types8.DiagnosticSeverity.Warning,
|
|
1357
|
-
fix: () => {
|
|
1358
|
-
const newActionAsset = {
|
|
1359
|
-
asset: {
|
|
1360
|
-
type: "action",
|
|
1361
|
-
...getNodeValue(node)
|
|
1362
|
-
}
|
|
1363
|
-
};
|
|
1364
|
-
return {
|
|
1365
|
-
name: "Convert to Asset",
|
|
1366
|
-
edit: {
|
|
1367
|
-
type: "replace",
|
|
1368
|
-
node,
|
|
1369
|
-
value: JSON.stringify(newActionAsset, null, 2)
|
|
1370
|
-
}
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
});
|
|
1374
|
-
}
|
|
1375
|
-
};
|
|
1376
|
-
return {
|
|
1377
|
-
ViewNode: (viewNode) => {
|
|
1378
|
-
const actionsProp = viewNode.properties.find(
|
|
1379
|
-
(p) => p.keyNode.value === "actions"
|
|
1380
|
-
);
|
|
1381
|
-
if (!actionsProp || actionsProp.valueNode?.type !== "array") {
|
|
1382
|
-
return;
|
|
1383
|
-
}
|
|
1384
|
-
actionsProp.valueNode.children.forEach((action) => {
|
|
1385
|
-
checkForLegacyAction(action);
|
|
1386
|
-
});
|
|
1387
|
-
}
|
|
1388
|
-
};
|
|
1389
|
-
}
|
|
1390
|
-
var LegacyActionPlugin = class {
|
|
1391
|
-
name = "legacy-action";
|
|
1392
|
-
apply(service) {
|
|
1393
|
-
service.hooks.validate.tap(this.name, async (ctx, validationContext) => {
|
|
1394
|
-
validationContext.useASTVisitor(createRuleVisitor(validationContext));
|
|
1395
|
-
});
|
|
1396
|
-
}
|
|
1397
|
-
};
|
|
1398
|
-
|
|
1399
|
-
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-service/src/plugins/legacy-template-plugin.ts
|
|
1400
|
-
var import_timm = require("timm");
|
|
1401
|
-
var import_vscode_languageserver_types9 = require("vscode-languageserver-types");
|
|
1402
|
-
function createRuleVisitor2(context, docInfo) {
|
|
1403
|
-
const checkForLegacyTemplate = (node) => {
|
|
1404
|
-
const templateDataProp = node.properties.find(
|
|
1405
|
-
(p) => p.keyNode.value === "templateData"
|
|
1406
|
-
);
|
|
1407
|
-
const templateValueProp = node.properties.find(
|
|
1408
|
-
(p) => p.keyNode.value === "template"
|
|
1409
|
-
);
|
|
1410
|
-
const templateOutputProp = node.properties.find(
|
|
1411
|
-
(p) => p.keyNode.value === "templateOutput"
|
|
1412
|
-
);
|
|
1413
|
-
if (!templateDataProp && !templateOutputProp && (!templateValueProp || templateValueProp.valueNode?.type === "array")) {
|
|
1414
|
-
return;
|
|
1415
|
-
}
|
|
1416
|
-
const templateViolation = {
|
|
1417
|
-
severity: import_vscode_languageserver_types9.DiagnosticSeverity.Error,
|
|
1418
|
-
message: `Migrate to the template[] syntax.`,
|
|
1419
|
-
fix: () => {
|
|
1420
|
-
const path = [
|
|
1421
|
-
"template",
|
|
1422
|
-
templateValueProp?.valueNode?.type === "array" ? templateValueProp.valueNode.children.length : 0
|
|
1423
|
-
];
|
|
1424
|
-
const newTemplateObj = {
|
|
1425
|
-
value: templateValueProp?.valueNode?.type !== "array" && templateValueProp?.valueNode ? getNodeValue(templateValueProp?.valueNode) : {},
|
|
1426
|
-
output: templateOutputProp?.valueNode?.jsonNode.value ?? "",
|
|
1427
|
-
data: templateDataProp?.valueNode?.jsonNode.value ?? ""
|
|
1428
|
-
};
|
|
1429
|
-
const oldValue = getNodeValue(node);
|
|
1430
|
-
let newValue = (0, import_timm.omit)(oldValue, "templateData");
|
|
1431
|
-
newValue = (0, import_timm.omit)(newValue, "templateOutput");
|
|
1432
|
-
if (templateValueProp?.valueNode?.type !== "array") {
|
|
1433
|
-
newValue = (0, import_timm.omit)(newValue, "template");
|
|
1434
|
-
}
|
|
1435
|
-
newValue = (0, import_timm.set)(
|
|
1436
|
-
newValue,
|
|
1437
|
-
"template",
|
|
1438
|
-
(0, import_timm.addLast)(newValue.template ?? [], newTemplateObj)
|
|
1439
|
-
);
|
|
1440
|
-
return {
|
|
1441
|
-
edit: {
|
|
1442
|
-
type: "replace",
|
|
1443
|
-
path,
|
|
1444
|
-
node,
|
|
1445
|
-
value: formatLikeNode(docInfo.document, node, newValue)
|
|
1446
|
-
},
|
|
1447
|
-
name: "Convert to template[]"
|
|
1448
|
-
};
|
|
1449
|
-
}
|
|
1450
|
-
};
|
|
1451
|
-
if (templateDataProp) {
|
|
1452
|
-
context.addViolation({
|
|
1453
|
-
...templateViolation,
|
|
1454
|
-
node: templateDataProp
|
|
1455
|
-
});
|
|
1456
|
-
}
|
|
1457
|
-
if (templateOutputProp) {
|
|
1458
|
-
context.addViolation({
|
|
1459
|
-
...templateViolation,
|
|
1460
|
-
node: templateOutputProp
|
|
1461
|
-
});
|
|
1462
|
-
}
|
|
1463
|
-
};
|
|
1464
|
-
return {
|
|
1465
|
-
ViewNode: checkForLegacyTemplate,
|
|
1466
|
-
AssetNode: checkForLegacyTemplate,
|
|
1467
|
-
ObjectNode: checkForLegacyTemplate
|
|
1468
|
-
};
|
|
1469
|
-
}
|
|
1470
|
-
var LegacyTemplatePlugin = class {
|
|
1471
|
-
name = "legacy-template";
|
|
1472
|
-
apply(service) {
|
|
1473
|
-
service.hooks.validate.tap(this.name, async (ctx, validationContext) => {
|
|
1474
|
-
validationContext.useASTVisitor(
|
|
1475
|
-
createRuleVisitor2(validationContext, ctx)
|
|
1476
|
-
);
|
|
1477
|
-
});
|
|
1478
|
-
}
|
|
1479
|
-
};
|
|
1480
|
-
|
|
1481
1343
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-service/src/plugins/missing-asset-wrapper-plugin.ts
|
|
1482
|
-
var
|
|
1344
|
+
var import_vscode_languageserver_types8 = require("vscode-languageserver-types");
|
|
1483
1345
|
var getObjectTarget = (node) => {
|
|
1484
1346
|
if (isObjectNode(node)) {
|
|
1485
1347
|
return node;
|
|
@@ -1515,7 +1377,7 @@ var MissingAssetWrapperPlugin = class {
|
|
|
1515
1377
|
addFixableViolation(d, {
|
|
1516
1378
|
node: originalNode,
|
|
1517
1379
|
message: d.message,
|
|
1518
|
-
severity: d.severity ??
|
|
1380
|
+
severity: d.severity ?? import_vscode_languageserver_types8.DiagnosticSeverity.Error,
|
|
1519
1381
|
fix: () => ({
|
|
1520
1382
|
name: `Wrap in "asset"`,
|
|
1521
1383
|
edit: {
|
|
@@ -1539,7 +1401,7 @@ var MissingAssetWrapperPlugin = class {
|
|
|
1539
1401
|
};
|
|
1540
1402
|
|
|
1541
1403
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-service/src/plugins/nav-state-plugin.ts
|
|
1542
|
-
var
|
|
1404
|
+
var import_vscode_languageserver_types9 = require("vscode-languageserver-types");
|
|
1543
1405
|
var createValidationVisitor3 = (ctx) => {
|
|
1544
1406
|
const validTransitions = /* @__PURE__ */ new Map();
|
|
1545
1407
|
return {
|
|
@@ -1566,7 +1428,7 @@ var createValidationVisitor3 = (ctx) => {
|
|
|
1566
1428
|
if (!validTransitions.get(flowNodeId)?.has(transitionObjects.valueNode.value)) {
|
|
1567
1429
|
ctx.addViolation({
|
|
1568
1430
|
node: transitionObjects.valueNode,
|
|
1569
|
-
severity:
|
|
1431
|
+
severity: import_vscode_languageserver_types9.DiagnosticSeverity.Error,
|
|
1570
1432
|
message: `Node "${transitionObjects.valueNode.value}" not found`
|
|
1571
1433
|
});
|
|
1572
1434
|
}
|
|
@@ -1600,7 +1462,7 @@ var NavStatePlugin = class {
|
|
|
1600
1462
|
const flowNode = getFlowNode(ctx.node);
|
|
1601
1463
|
flowNode?.states.forEach((p) => {
|
|
1602
1464
|
completionCtx.addCompletionItem({
|
|
1603
|
-
kind:
|
|
1465
|
+
kind: import_vscode_languageserver_types9.CompletionItemKind.Value,
|
|
1604
1466
|
label: p.keyNode.value
|
|
1605
1467
|
});
|
|
1606
1468
|
});
|
|
@@ -1625,7 +1487,7 @@ var NavStatePlugin = class {
|
|
|
1625
1487
|
};
|
|
1626
1488
|
|
|
1627
1489
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-service/src/plugins/view-node-plugin.ts
|
|
1628
|
-
var
|
|
1490
|
+
var import_vscode_languageserver_types10 = require("vscode-languageserver-types");
|
|
1629
1491
|
var createValidationVisitor4 = (ctx, viewInfo) => {
|
|
1630
1492
|
return {
|
|
1631
1493
|
FlowStateNode: (flowState) => {
|
|
@@ -1641,7 +1503,7 @@ var createValidationVisitor4 = (ctx, viewInfo) => {
|
|
|
1641
1503
|
ctx.addViolation({
|
|
1642
1504
|
node: refNode.valueNode,
|
|
1643
1505
|
message: `View with id: ${refID} does not exist.`,
|
|
1644
|
-
severity:
|
|
1506
|
+
severity: import_vscode_languageserver_types10.DiagnosticSeverity.Error
|
|
1645
1507
|
});
|
|
1646
1508
|
}
|
|
1647
1509
|
},
|
|
@@ -1651,7 +1513,7 @@ var createValidationVisitor4 = (ctx, viewInfo) => {
|
|
|
1651
1513
|
ctx.addViolation({
|
|
1652
1514
|
node: viewNode.id.valueNode,
|
|
1653
1515
|
message: `View is not reachable`,
|
|
1654
|
-
severity:
|
|
1516
|
+
severity: import_vscode_languageserver_types10.DiagnosticSeverity.Warning
|
|
1655
1517
|
});
|
|
1656
1518
|
}
|
|
1657
1519
|
}
|
|
@@ -1713,14 +1575,14 @@ var ViewNodePlugin = class {
|
|
|
1713
1575
|
if (ctx.node.type === "string" && isPropertyNode(ctx.node.parent) && isStateNode(ctx.node.parent.parent) && ctx.node.parent.keyNode.value === "ref") {
|
|
1714
1576
|
Array.from(viewInfo?.views.keys() ?? []).forEach((vID) => {
|
|
1715
1577
|
completionCtx.addCompletionItem({
|
|
1716
|
-
kind:
|
|
1578
|
+
kind: import_vscode_languageserver_types10.CompletionItemKind.Value,
|
|
1717
1579
|
label: vID
|
|
1718
1580
|
});
|
|
1719
1581
|
});
|
|
1720
1582
|
} else if (ctx.node.type === "string" && isPropertyNode(ctx.node.parent) && isViewNode(ctx.node.parent.parent) && ctx.node.parent.keyNode.value === "id") {
|
|
1721
1583
|
Array.from(viewInfo?.nodes.keys() ?? []).forEach((vID) => {
|
|
1722
1584
|
completionCtx.addCompletionItem({
|
|
1723
|
-
kind:
|
|
1585
|
+
kind: import_vscode_languageserver_types10.CompletionItemKind.Value,
|
|
1724
1586
|
label: vID
|
|
1725
1587
|
});
|
|
1726
1588
|
});
|
|
@@ -1880,8 +1742,6 @@ var PLUGINS = [
|
|
|
1880
1742
|
new DuplicateIDPlugin(),
|
|
1881
1743
|
new ViewNodePlugin(),
|
|
1882
1744
|
new SchemaInfoPlugin(),
|
|
1883
|
-
new LegacyTemplatePlugin(),
|
|
1884
|
-
new LegacyActionPlugin(),
|
|
1885
1745
|
new AssetWrapperArrayPlugin(),
|
|
1886
1746
|
new NavStatePlugin(),
|
|
1887
1747
|
new MissingAssetWrapperPlugin(),
|
|
@@ -2187,8 +2047,8 @@ var PlayerLanguageService = class {
|
|
|
2187
2047
|
}
|
|
2188
2048
|
return (0, import_jsonc_parser4.format)(document.getText(), formatRange, formattingOptions).map(
|
|
2189
2049
|
(edit) => {
|
|
2190
|
-
return
|
|
2191
|
-
|
|
2050
|
+
return import_vscode_languageserver_types11.TextEdit.replace(
|
|
2051
|
+
import_vscode_languageserver_types11.Range.create(
|
|
2192
2052
|
document.positionAt(edit.offset),
|
|
2193
2053
|
document.positionAt(edit.offset + edit.length)
|
|
2194
2054
|
),
|
|
@@ -2257,7 +2117,7 @@ var PlayerLanguageService = class {
|
|
|
2257
2117
|
async getCompletionsAtPosition(document, position) {
|
|
2258
2118
|
const ctxWithPos = await this.updateSourceWithPosition(document, position);
|
|
2259
2119
|
if (!ctxWithPos) {
|
|
2260
|
-
return
|
|
2120
|
+
return import_vscode_languageserver_types11.CompletionList.create();
|
|
2261
2121
|
}
|
|
2262
2122
|
const completionItems = [];
|
|
2263
2123
|
const completionContext = {
|
|
@@ -2266,7 +2126,7 @@ var PlayerLanguageService = class {
|
|
|
2266
2126
|
}
|
|
2267
2127
|
};
|
|
2268
2128
|
await this.hooks.complete.call(ctxWithPos, completionContext);
|
|
2269
|
-
return
|
|
2129
|
+
return import_vscode_languageserver_types11.CompletionList.create(completionItems);
|
|
2270
2130
|
}
|
|
2271
2131
|
async resolveCompletionItem(completionItem) {
|
|
2272
2132
|
return completionItem;
|
|
@@ -2296,7 +2156,7 @@ var PlayerLanguageService = class {
|
|
|
2296
2156
|
}
|
|
2297
2157
|
actions.push({
|
|
2298
2158
|
title: fixedAction.name,
|
|
2299
|
-
kind:
|
|
2159
|
+
kind: import_vscode_languageserver_types11.CodeActionKind.QuickFix,
|
|
2300
2160
|
edit: {
|
|
2301
2161
|
changes: {
|
|
2302
2162
|
[document.uri]: [toTextEdit(document, fixedAction.edit)]
|
|
@@ -2335,17 +2195,19 @@ var PlayerLanguageService = class {
|
|
|
2335
2195
|
});
|
|
2336
2196
|
}
|
|
2337
2197
|
async setAssetTypesFromModule(manifest) {
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2198
|
+
await Promise.allSettled(
|
|
2199
|
+
manifest.map((m) => {
|
|
2200
|
+
if (m.capabilities["Types"]?.length) {
|
|
2201
|
+
return this.XLRService.XLRSDK.loadDefinitionsFromModule(m);
|
|
2202
|
+
} else {
|
|
2203
|
+
return this.XLRService.XLRSDK.loadDefinitionsFromModule(
|
|
2204
|
+
m,
|
|
2205
|
+
DEFAULT_FILTERS,
|
|
2206
|
+
TRANSFORM_FUNCTIONS
|
|
2207
|
+
);
|
|
2208
|
+
}
|
|
2209
|
+
})
|
|
2210
|
+
);
|
|
2349
2211
|
}
|
|
2350
2212
|
};
|
|
2351
2213
|
// Annotate the CommonJS export names for ESM import in node:
|