@player-lang/json-language-service 0.0.2-next.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/dist/cjs/index.cjs +2314 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/index.legacy-esm.js +2249 -0
- package/dist/index.mjs +2249 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +40 -0
- package/src/__tests__/__snapshots__/service.test.ts.snap +213 -0
- package/src/__tests__/service.test.ts +298 -0
- package/src/constants.ts +38 -0
- package/src/index.ts +490 -0
- package/src/parser/__tests__/parse.test.ts +18 -0
- package/src/parser/document.ts +456 -0
- package/src/parser/edits.ts +31 -0
- package/src/parser/index.ts +38 -0
- package/src/parser/jsonParseErrors.ts +69 -0
- package/src/parser/types.ts +314 -0
- package/src/parser/utils.ts +94 -0
- package/src/plugins/__tests__/asset-wrapper-array-plugin.test.ts +112 -0
- package/src/plugins/__tests__/binding-schema-plugin.test.ts +62 -0
- package/src/plugins/__tests__/duplicate-id-plugin.test.ts +195 -0
- package/src/plugins/__tests__/missing-asset-wrapper-plugin.test.ts +190 -0
- package/src/plugins/__tests__/nav-state-plugin.test.ts +136 -0
- package/src/plugins/__tests__/view-node-plugin.test.ts +154 -0
- package/src/plugins/asset-wrapper-array-plugin.ts +123 -0
- package/src/plugins/binding-schema-plugin.ts +289 -0
- package/src/plugins/duplicate-id-plugin.ts +158 -0
- package/src/plugins/missing-asset-wrapper-plugin.ts +96 -0
- package/src/plugins/nav-state-plugin.ts +139 -0
- package/src/plugins/view-node-plugin.ts +225 -0
- package/src/plugins/xlr-plugin.ts +371 -0
- package/src/types.ts +119 -0
- package/src/utils.ts +143 -0
- package/src/xlr/__tests__/__snapshots__/transform.test.ts.snap +390 -0
- package/src/xlr/__tests__/transform.test.ts +108 -0
- package/src/xlr/index.ts +3 -0
- package/src/xlr/registry.ts +99 -0
- package/src/xlr/service.ts +190 -0
- package/src/xlr/transforms.ts +169 -0
- package/types/constants.d.ts +7 -0
- package/types/index.d.ts +69 -0
- package/types/parser/document.d.ts +25 -0
- package/types/parser/edits.d.ts +10 -0
- package/types/parser/index.d.ts +16 -0
- package/types/parser/jsonParseErrors.d.ts +27 -0
- package/types/parser/types.d.ts +188 -0
- package/types/parser/utils.d.ts +26 -0
- package/types/plugins/asset-wrapper-array-plugin.d.ts +9 -0
- package/types/plugins/binding-schema-plugin.d.ts +15 -0
- package/types/plugins/duplicate-id-plugin.d.ts +7 -0
- package/types/plugins/missing-asset-wrapper-plugin.d.ts +9 -0
- package/types/plugins/nav-state-plugin.d.ts +9 -0
- package/types/plugins/view-node-plugin.d.ts +9 -0
- package/types/plugins/xlr-plugin.d.ts +7 -0
- package/types/types.d.ts +81 -0
- package/types/utils.d.ts +24 -0
- package/types/xlr/index.d.ts +4 -0
- package/types/xlr/registry.d.ts +17 -0
- package/types/xlr/service.d.ts +22 -0
- package/types/xlr/transforms.d.ts +18 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/plugins/asset-wrapper-array-plugin.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/parser/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/parser/utils.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/parser/document.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/parser/types.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/parser/jsonParseErrors.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/parser/edits.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/utils.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/plugins/binding-schema-plugin.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/plugins/xlr-plugin.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/plugins/duplicate-id-plugin.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/plugins/missing-asset-wrapper-plugin.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/plugins/nav-state-plugin.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/plugins/view-node-plugin.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/xlr/transforms.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/constants.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/xlr/registry.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/xlr/service.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/lsp/json-language-service/src/types.ts"],"sourcesContent":["import type {\n Range as JSONRange,\n FormattingOptions as JSONFormattingOptions,\n} from \"jsonc-parser\";\nimport { format as formatJSON } from \"jsonc-parser\";\nimport type { TextDocument } from \"vscode-languageserver-textdocument\";\nimport {\n AsyncParallelHook,\n SyncBailHook,\n SyncHook,\n SyncWaterfallHook,\n} from \"tapable-ts\";\nimport type {\n CodeAction,\n CodeActionContext,\n CompletionItem,\n Diagnostic,\n FormattingOptions,\n Hover,\n Position,\n Location,\n} from \"vscode-languageserver-types\";\nimport {\n CompletionList,\n Range,\n TextEdit,\n CodeActionKind,\n} from \"vscode-languageserver-types\";\n\nimport type { TransformFunction } from \"@xlr-lib/xlr\";\nimport type {\n DocumentContext,\n ValidationContext,\n CompletionContext,\n EnhancedDocumentContextWithPosition,\n Violation,\n ASTVisitor,\n} from \"./types\";\nimport { DEFAULT_FILTERS, PLUGINS, TRANSFORM_FUNCTIONS } from \"./constants\";\n\nimport type { ASTNode, PlayerContent } from \"./parser\";\nimport { parse, toRange, toTextEdit, walk } from \"./parser\";\n\nimport { containsRange, isKnownRootType, typeToVisitorMap } from \"./utils\";\nimport { XLRService } from \"./xlr\";\nimport { TSManifest } from \"@xlr-lib/xlr\";\n\nexport * from \"./utils\";\nexport * from \"./constants\";\nexport * from \"./types\";\nexport * from \"./parser\";\nexport * from \"./xlr/index\";\n\nexport interface PlayerLanguageServicePlugin {\n /** The name of the plugin */\n name: string;\n\n /** the handle to get the LSP */\n apply(languageService: PlayerLanguageService): void;\n}\n\n/** The thing that handles most of the LSP work */\nexport class PlayerLanguageService {\n public readonly XLRService: XLRService;\n\n private parseCache = new Map<\n string,\n {\n /** the version of the document */\n version: number;\n\n /** The parsed document */\n parsed: PlayerContent;\n }\n >();\n\n private fixableViolationsForDocument = new Map<\n string,\n Map<Diagnostic, Violation>\n >();\n\n public readonly hooks: {\n onDocumentUpdate: SyncHook<[DocumentContext], Record<string, any>>;\n validate: AsyncParallelHook<[DocumentContext, ValidationContext], void>;\n onValidateEnd: SyncWaterfallHook<\n [\n Diagnostic[],\n {\n /** The context of the document */\n documentContext: DocumentContext;\n /** A callback for adding a new fixable rule */\n addFixableViolation: (diag: Diagnostic, violation: Violation) => void;\n },\n ],\n Record<string, any>\n >;\n complete: AsyncParallelHook<\n [EnhancedDocumentContextWithPosition, CompletionContext],\n void\n >;\n hover: SyncBailHook<\n [EnhancedDocumentContextWithPosition],\n Hover | undefined,\n Record<string, any>\n >;\n definition: SyncBailHook<\n [EnhancedDocumentContextWithPosition],\n Location | undefined,\n Record<string, any>\n >;\n } = {\n onDocumentUpdate: new SyncHook<[DocumentContext]>(),\n\n validate: new AsyncParallelHook<\n [DocumentContext, ValidationContext],\n void\n >(),\n\n onValidateEnd: new SyncWaterfallHook<\n [\n Diagnostic[],\n {\n /** The context of the document */\n documentContext: DocumentContext;\n /** A callback for adding a new fixable rule */\n addFixableViolation: (diag: Diagnostic, violation: Violation) => void;\n },\n ]\n >(),\n\n complete: new AsyncParallelHook<\n [EnhancedDocumentContextWithPosition, CompletionContext],\n void\n >(),\n\n hover: new SyncBailHook<\n [EnhancedDocumentContextWithPosition],\n Hover | undefined\n >(),\n\n definition: new SyncBailHook<\n [EnhancedDocumentContextWithPosition],\n Location | undefined\n >(),\n };\n\n constructor(config?: {\n /** A list of plugins to include */\n plugins?: Array<PlayerLanguageServicePlugin>;\n }) {\n // load base definitions?\n this.XLRService = new XLRService();\n\n PLUGINS.forEach((p) => p.apply(this));\n config?.plugins?.forEach((p) => p.apply(this));\n }\n\n private parseTextDocument(document: TextDocument): PlayerContent {\n if (!this.parseCache.has(document.uri)) {\n const parsed = parse(document);\n this.parseCache.set(document.uri, { version: document.version, parsed });\n return parsed;\n }\n\n const cached = this.parseCache.get(document.uri);\n\n if (!cached || cached.version < document.version) {\n this.parseCache.delete(document.uri);\n return this.parseTextDocument(document);\n }\n\n return cached.parsed;\n }\n\n private async updateSource(document: TextDocument): Promise<DocumentContext> {\n const parsed = this.parseTextDocument(document);\n const documentContext: DocumentContext = {\n log: {\n debug: console.log,\n info: console.log,\n warn: console.warn,\n error: console.error,\n },\n document,\n PlayerContent: parsed,\n };\n\n const ctx = {\n ...documentContext,\n };\n\n this.hooks.onDocumentUpdate.call(ctx);\n return ctx;\n }\n\n private async getJSONPositionInfo(\n ctx: DocumentContext,\n position: Position,\n ): Promise<{\n /** the node at the given node */\n node?: ASTNode;\n }> {\n const { document, PlayerContent } = ctx;\n const node = PlayerContent.getNodeFromOffset(document.offsetAt(position));\n\n return {\n node,\n };\n }\n\n private async updateSourceWithPosition(\n document: TextDocument,\n position: Position,\n ): Promise<EnhancedDocumentContextWithPosition | undefined> {\n const ctx = await this.updateSource(document);\n\n const { node } = await this.getJSONPositionInfo(ctx, position);\n\n const XLRInfo = this.XLRService.getTypeInfoAtPosition(node);\n if (!node || !XLRInfo) {\n return undefined;\n }\n\n return {\n ...ctx,\n node,\n position,\n XLR: XLRInfo,\n };\n }\n\n public onClose(document: TextDocument): void {\n this.fixableViolationsForDocument.delete(document.uri);\n this.parseCache.delete(document.uri);\n }\n\n async formatTextDocument(\n document: TextDocument,\n options: FormattingOptions,\n range?: Range,\n ): Promise<Array<TextEdit> | undefined> {\n const formattingOptions: JSONFormattingOptions = {\n tabSize: options.tabSize,\n insertSpaces: options.insertSpaces,\n };\n\n let formatRange: JSONRange | undefined;\n\n if (range) {\n const startOffset = document.offsetAt(range.start);\n formatRange = {\n offset: startOffset,\n length: document.offsetAt(range.end) - startOffset,\n };\n }\n\n return formatJSON(document.getText(), formatRange, formattingOptions).map(\n (edit) => {\n return TextEdit.replace(\n Range.create(\n document.positionAt(edit.offset),\n document.positionAt(edit.offset + edit.length),\n ),\n edit.content,\n );\n },\n );\n }\n\n async validateTextDocument(\n document: TextDocument,\n ): Promise<Array<Diagnostic> | undefined> {\n const ctx = await this.updateSource(document);\n this.fixableViolationsForDocument.delete(document.uri);\n\n if (!isKnownRootType(ctx.PlayerContent)) {\n return;\n }\n\n const diagnostics = [...ctx.PlayerContent.syntaxErrors];\n const astVisitors: Array<ASTVisitor> = [];\n\n /** Add a matching violation fix to the original diagnostic */\n const addFixableViolation = (\n diagnostic: Diagnostic,\n violation: Violation,\n ) => {\n if (!this.fixableViolationsForDocument.has(document.uri)) {\n this.fixableViolationsForDocument.set(document.uri, new Map());\n }\n\n const fixableDiags = this.fixableViolationsForDocument.get(document.uri);\n\n fixableDiags?.set(diagnostic, violation);\n };\n\n if (ctx.PlayerContent.root) {\n const validationContext: ValidationContext = {\n addViolation: (violation) => {\n const { message, node, severity, fix } = violation;\n\n const range: Range = toRange(document, node);\n\n const diagnostic: Diagnostic = {\n message,\n severity,\n range,\n };\n\n if (fix) {\n addFixableViolation(diagnostic, violation);\n }\n\n diagnostics.push(diagnostic);\n },\n useASTVisitor: (visitor) => {\n astVisitors.push(visitor);\n },\n addDiagnostic(d) {\n diagnostics.push(d);\n },\n };\n\n await this.hooks.validate.call(ctx, validationContext);\n\n // Walk the tree using any of the registered visitors\n // This is for perf so we only walk the tree once\n\n await walk(ctx.PlayerContent.root, async (node) => {\n const visitorProp = typeToVisitorMap[node.type];\n\n astVisitors.forEach(async (visitor) => {\n try {\n await visitor[visitorProp]?.(node as any);\n } catch (e: any) {\n ctx.log?.error(\n `Error running rules for ${visitorProp}: ${e.message}, Stack ${e.stack}`,\n );\n }\n });\n\n return false;\n });\n }\n\n return this.hooks.onValidateEnd.call(diagnostics, {\n documentContext: ctx,\n addFixableViolation,\n });\n }\n\n async getCompletionsAtPosition(\n document: TextDocument,\n position: Position,\n ): Promise<CompletionList> {\n const ctxWithPos = await this.updateSourceWithPosition(document, position);\n\n if (!ctxWithPos) {\n return CompletionList.create();\n }\n\n const completionItems: Array<CompletionItem> = [];\n\n const completionContext: CompletionContext = {\n addCompletionItem: (i) => {\n completionItems.push(i);\n },\n };\n await this.hooks.complete.call(ctxWithPos, completionContext);\n\n return CompletionList.create(completionItems);\n }\n\n async resolveCompletionItem(\n completionItem: CompletionItem,\n ): Promise<CompletionItem> {\n return completionItem;\n }\n\n async getHoverInfoAtPosition(\n document: TextDocument,\n position: Position,\n ): Promise<Hover | undefined | null> {\n const context = await this.updateSourceWithPosition(document, position);\n\n if (!context) {\n return undefined;\n }\n\n return this.hooks.hover.call(context);\n }\n\n async getCodeActionsInRange(\n document: TextDocument,\n context: CodeActionContext,\n ): Promise<CodeAction[]> {\n const diagsForDocument = this.fixableViolationsForDocument.get(\n document.uri,\n );\n\n if (\n !diagsForDocument ||\n diagsForDocument.size === 0 ||\n context.diagnostics.length === 0\n ) {\n return [];\n }\n\n const actions: CodeAction[] = [];\n // Get all overlapping rules\n\n diagsForDocument.forEach((violation, diagnostic) => {\n const matching = context.diagnostics.find((diag) =>\n containsRange(diagnostic.range, diag.range),\n );\n const fixedAction = violation.fix?.();\n\n if (!matching || !fixedAction) {\n return;\n }\n\n actions.push({\n title: fixedAction.name,\n kind: CodeActionKind.QuickFix,\n edit: {\n changes: {\n [document.uri]: [toTextEdit(document, fixedAction.edit)],\n },\n },\n });\n });\n\n return actions;\n }\n\n public async getDefinitionAtPosition(\n document: TextDocument,\n position: Position,\n ): Promise<Location | undefined | null> {\n const context = await this.updateSourceWithPosition(document, position);\n\n if (!context) {\n return undefined;\n }\n\n return this.hooks.definition.call(context);\n }\n\n public addXLRTransforms(transforms: Record<string, TransformFunction>): void {\n Object.entries(transforms).forEach(([name, fn]) =>\n this.XLRService.XLRSDK.addTransformFunction(name, fn),\n );\n }\n\n public addLSPPlugin(plugin: PlayerLanguageServicePlugin): void {\n plugin.apply(this);\n }\n\n async setAssetTypes(typeFiles: Array<string>): Promise<void> {\n // await this.typescriptService.setAssetTypes(typeFiles);\n typeFiles.forEach((file) => {\n // Find a better way of loading default types\n if (file.includes(\"types\")) {\n this.XLRService.XLRSDK.loadDefinitionsFromDisk(file, {});\n } else {\n this.XLRService.XLRSDK.loadDefinitionsFromDisk(\n file,\n DEFAULT_FILTERS,\n TRANSFORM_FUNCTIONS,\n );\n }\n });\n }\n\n async setAssetTypesFromModule(manifest: Array<TSManifest>): Promise<void> {\n await Promise.allSettled(\n manifest.map((m) => {\n if (m.capabilities[\"Types\"]?.length) {\n return this.XLRService.XLRSDK.loadDefinitionsFromModule(m);\n } else {\n return this.XLRService.XLRSDK.loadDefinitionsFromModule(\n m,\n DEFAULT_FILTERS,\n TRANSFORM_FUNCTIONS,\n );\n }\n }),\n );\n }\n}\n","import type { NodeType } from \"@xlr-lib/xlr\";\nimport { DiagnosticSeverity } from \"vscode-languageserver-types\";\nimport type { PlayerLanguageService, PlayerLanguageServicePlugin } from \"..\";\nimport type { ASTNode, StringASTNode } from \"../parser\";\nimport { getNodeValue } from \"../parser\";\nimport { formatLikeNode } from \"../utils\";\n\n/** Check if the node is defined within a view */\nconst isInView = (node: ASTNode): boolean => {\n if (node.type === \"view\") {\n return true;\n }\n\n if (!node.parent) {\n return false;\n }\n\n return isInView(node.parent);\n};\n\n/**\n * Checks to see if there is an AssetWrapper ref node somewhere at this level\n *\n * - @param nodes Array of nodes to check for an AssetWrapper ref\n */\nconst checkTypesForAssetWrapper = (nodes: Array<NodeType>): boolean => {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node.type === \"object\" && node.title?.includes(\"AssetWrapper\")) {\n return true;\n } else if (node.type === \"or\") {\n return checkTypesForAssetWrapper(node.or);\n } else if (node.type === \"and\") {\n return checkTypesForAssetWrapper(node.and);\n }\n }\n\n return false;\n};\n\n/**\n * Checks to see if the array's parent property is a switch statement\n */\nconst checkSwitchCase = (node: StringASTNode): boolean => {\n return node.value === \"staticSwitch\" || node.value === \"dynamicSwitch\";\n};\n\n/**\n * Looks for an array where there _should_ be an AssetWrapper\n */\nexport class AssetWrapperArrayPlugin implements PlayerLanguageServicePlugin {\n name = \"asset-wrapper-to-array\";\n\n apply(service: PlayerLanguageService): void {\n service.hooks.validate.tap(\n this.name,\n async (documentInfo, validationContext) => {\n validationContext.useASTVisitor({\n ArrayNode: async (arrayNode) => {\n if (!isInView(arrayNode)) {\n return;\n }\n\n const xlrInfo = service.XLRService.getTypeInfoAtPosition(arrayNode);\n if (!xlrInfo) return;\n\n const isAssetWrapper = checkTypesForAssetWrapper(xlrInfo.nodes);\n\n const parentNode = arrayNode.parent;\n\n if (parentNode?.type !== \"property\") {\n return;\n }\n\n const targetLabel = parentNode.keyNode;\n\n // manual check because switch types have arrays of asset wrappers but don't extend asset wrapper\n const isSwitchCase = checkSwitchCase(targetLabel);\n\n if (isAssetWrapper && !isSwitchCase) {\n // This is an array node that _should_ be an asset wrapper.\n // Convert it to a collection\n\n let newAsset = {\n asset: {\n id: \"\",\n type: \"collection\",\n values: getNodeValue(arrayNode),\n },\n };\n\n if (arrayNode.children.length === 1) {\n newAsset = getNodeValue(arrayNode.children[0]);\n }\n\n validationContext.addViolation({\n node: targetLabel,\n severity: DiagnosticSeverity.Error,\n message: `Implicit Array -> \"collection\" assets is not supported.`,\n fix: () => {\n return {\n name: `Convert to ${\n arrayNode.children.length > 0 ? \"collection\" : \"asset\"\n }`,\n edit: {\n type: \"replace\",\n node: arrayNode,\n value: formatLikeNode(\n documentInfo.document,\n arrayNode,\n newAsset,\n ),\n },\n };\n },\n });\n }\n },\n });\n },\n );\n }\n}\n","import type { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { getNodeValue as getJSONNodeValue } from \"jsonc-parser\";\nimport type { PlayerContent } from \"./document\";\nimport type { ASTNode } from \"./types\";\n\nexport * from \"./utils\";\nexport { parse } from \"./document\";\nexport * from \"./types\";\nexport * from \"./document\";\n\nexport interface PlayerContentProvider {\n parse(document: TextDocument): PlayerContent;\n}\n\n/** traverse a node and call the visitor for each nested item */\nexport async function walk(\n node: ASTNode,\n visitor: (n: ASTNode) => Promise<boolean>,\n): Promise<void> {\n const queue: ASTNode[] = [node];\n let stop = false;\n\n while (queue.length > 0 && !stop) {\n const nodeToVisit = queue.shift();\n if (nodeToVisit?.children) {\n queue.push(...nodeToVisit.children);\n }\n\n stop = nodeToVisit ? await visitor(nodeToVisit) : true;\n }\n}\n\n/** Get the JSON value for a node */\nexport function getNodeValue(node: ASTNode): any {\n return getJSONNodeValue(node.jsonNode);\n}\n\nexport * from \"./edits\";\n","import type {\n ASTNode,\n PropertyASTNode,\n StringASTNode,\n ViewASTNode,\n ContentASTNode,\n FlowStateASTNode,\n ObjectASTNode,\n FlowASTNode,\n NavigationASTNode,\n AssetASTNode,\n} from \"./types\";\n\n/** check if the node is a property */\nexport function isPropertyNode(node?: ASTNode): node is PropertyASTNode {\n return node?.type === \"property\";\n}\n\n/** check if the node is an object ast */\nexport function isObjectNode(node?: ASTNode): node is ObjectASTNode {\n return node?.type === \"object\";\n}\n\n/** check if the node is a key */\nexport function isKeyNode(node?: ASTNode): node is StringASTNode {\n return isPropertyNode(node?.parent) && node?.parent.keyNode === node;\n}\n\n/** check if the node is a value */\nexport function isValueNode(node?: ASTNode): boolean {\n return isPropertyNode(node?.parent) && node?.parent.valueNode === node;\n}\n\n/** check if the node is a view */\nexport function isViewNode(node?: ASTNode): node is ViewASTNode {\n return node?.type === \"view\";\n}\n\n/** check if the node is a state */\nexport function isStateNode(node?: ASTNode): node is FlowStateASTNode {\n return node?.type === \"state\";\n}\n\n/** check if the node is a flow */\nexport function isFlowNode(node?: ASTNode): node is FlowASTNode {\n return node?.type === \"flow\";\n}\n\n/** check if the node is a nav */\nexport function isNavigationNode(node?: ASTNode): node is NavigationASTNode {\n return node?.type === \"navigation\";\n}\n\n/** get the value for a given key in the object */\nexport function getValForKey<T extends ObjectASTNode<any>>(\n node: T,\n key: string,\n): any {\n const prop = node.properties.find((k) => k.keyNode.value === key);\n return prop?.valueNode?.jsonNode.value;\n}\n\n/** get the key for the given value node */\nexport function getPropForValNode(node?: ASTNode): string | undefined {\n if (isValueNode(node) && isPropertyNode(node?.parent)) {\n return node?.parent.keyNode.value;\n }\n}\n\n/** find the view node */\nexport function getViewNode(\n node: ASTNode,\n): ViewASTNode | AssetASTNode | undefined {\n if (node.parent) {\n if (node.parent.type === \"view\") {\n return node.parent;\n }\n\n return getViewNode(node.parent);\n }\n\n if (node.type === \"asset\") {\n return node;\n }\n}\n\n/** traverse up until we find the root content node */\nexport function getContentNode(node: ASTNode): ContentASTNode | undefined {\n if (node.type === \"content\") {\n return node;\n }\n\n return node.parent ? getContentNode(node.parent) : undefined;\n}\n","import { parseTree, findNodeAtOffset } from \"jsonc-parser\";\nimport type { Node, ParseError } from \"jsonc-parser\";\nimport type { Diagnostic } from \"vscode-languageserver-types\";\nimport type { TextDocument } from \"vscode-languageserver-textdocument\";\nimport type {\n ASTNode,\n ContentASTNode,\n PropertyASTNode,\n ViewASTNode,\n AssetASTNode,\n StringASTNode,\n ArrayASTNode,\n NavigationASTNode,\n FlowASTNode,\n FlowStateASTNode,\n} from \"./types\";\nimport {\n ViewASTNodeImpl,\n StringASTNodeImpl,\n PropertyASTNodeImpl,\n NullASTNodeImpl,\n BooleanASTNodeImpl,\n NumberASTNodeImpl,\n ArrayASTNodeImpl,\n AssetASTNodeImpl,\n ObjectASTNodeImpl,\n ContentASTNodeImpl,\n NavigationASTNodeImpl,\n FlowASTNodeImpl,\n FlowStateASTNodeImpl,\n} from \"./types\";\nimport { convertErrorsToDiags } from \"./jsonParseErrors\";\n\n/** Check if the property is a string */\nfunction isStringProperty(\n node: PropertyASTNode,\n): node is PropertyASTNode<StringASTNode> {\n return node.valueNode?.type === \"string\";\n}\n\n/**\n * The top level document\n */\nexport class PlayerContent {\n public readonly root: ASTNode;\n public readonly syntaxErrors: Array<Diagnostic>;\n private readonly jsonNodeToNode: Map<Node, ASTNode>;\n\n constructor(\n root: ASTNode,\n errors: Array<Diagnostic>,\n jsonToNodeMap: Map<Node, ASTNode>,\n ) {\n this.root = root;\n this.jsonNodeToNode = jsonToNodeMap;\n this.syntaxErrors = errors;\n }\n\n getNodeFromOffset(offset: number): ASTNode | undefined {\n const jsonNode = findNodeAtOffset(this.root.jsonNode, offset);\n if (!jsonNode) {\n return;\n }\n\n if (this.jsonNodeToNode.has(jsonNode)) {\n return this.jsonNodeToNode.get(jsonNode);\n }\n\n // walk up one level to see if you're at an empty property line\n const parentNode = jsonNode.parent as Node;\n if (this.jsonNodeToNode.has(parentNode)) {\n return this.jsonNodeToNode.get(parentNode);\n }\n\n // Check for a (great)-grand-parent match\n // This means we're completing a property on one of these nodes\n const grandparentNode = parentNode.parent as Node;\n if (this.jsonNodeToNode.has(grandparentNode)) {\n return this.jsonNodeToNode.get(grandparentNode);\n }\n\n const greatGrandparentNode = grandparentNode.parent as Node;\n if (this.jsonNodeToNode.has(greatGrandparentNode)) {\n return this.jsonNodeToNode.get(greatGrandparentNode);\n }\n }\n}\n\nexport enum ObjType {\n FLOW,\n ASSET,\n ASSET_WRAPPER,\n UNKNOWN,\n}\n\n/** Try to identify any object as an Asset or Flow */\nexport default function identify(node: Node): ObjType {\n if (node === undefined || node.type !== \"object\") {\n return ObjType.UNKNOWN;\n }\n\n const knownProps = node.children?.reduce((props, childNode) => {\n if (childNode.type === \"property\" && childNode.children) {\n const [key] = childNode.children;\n props.add(key.value);\n }\n\n return props;\n }, new Set<string>());\n\n if (knownProps?.has(\"type\")) {\n return ObjType.ASSET;\n }\n\n return ObjType.FLOW;\n}\n\n/** parse a text document into a player one */\nexport function parse(document: TextDocument): PlayerContent {\n const errors: Array<ParseError> = [];\n const jsonToNode = new Map<Node, ASTNode>();\n const root = parseTree(document.getText(), errors, {\n disallowComments: true,\n });\n\n // TODO: convert runtime errors to diags\n const diags: Diagnostic[] = convertErrorsToDiags(document, errors);\n\n /** parse an asset */\n function parseAsset(node: Node, parent?: ASTNode): AssetASTNode {\n const assetNode = new AssetASTNodeImpl(node, parent);\n node.children?.forEach((prop) => {\n if (prop.type === \"property\" && prop.children?.length) {\n const [key, val] = prop.children;\n\n const keyNode = new StringASTNodeImpl(key);\n const property = new PropertyASTNodeImpl(prop, assetNode, keyNode);\n property.keyNode = new StringASTNodeImpl(key, property);\n\n property.valueNode = parseUnknownNode(val, property);\n\n if (key.value === \"id\" && isStringProperty(property)) {\n assetNode.id = property;\n } else if (key.value === \"type\" && isStringProperty(property)) {\n assetNode.assetType = property;\n }\n\n assetNode.properties.push(property);\n\n jsonToNode.set(prop, property);\n jsonToNode.set(key, property.keyNode);\n if (property.valueNode) {\n jsonToNode.set(val, property.valueNode);\n }\n }\n });\n return assetNode;\n }\n\n /** parse a node that we don't know about */\n function parseUnknownNode(\n node?: Node,\n parent?: ASTNode,\n ): ASTNode | undefined {\n switch (node?.type) {\n case \"string\": {\n const newNode = new StringASTNodeImpl(node, parent);\n jsonToNode.set(node, newNode);\n return newNode;\n }\n\n case \"null\": {\n const newNode = new NullASTNodeImpl(node, parent);\n jsonToNode.set(node, newNode);\n return newNode;\n }\n\n case \"boolean\": {\n const newNode = new BooleanASTNodeImpl(node, parent);\n jsonToNode.set(node, newNode);\n return newNode;\n }\n\n case \"number\": {\n const newNode = new NumberASTNodeImpl(node, parent);\n jsonToNode.set(node, newNode);\n return newNode;\n }\n\n case \"array\": {\n const arr = new ArrayASTNodeImpl(node, parent);\n node.children?.forEach((arrChild) => {\n const child = parseUnknownNode(arrChild, arr);\n if (child) {\n jsonToNode.set(arrChild, child);\n arr.items.push(child);\n }\n });\n jsonToNode.set(node, arr);\n return arr;\n }\n\n case \"object\": {\n const obj = new ObjectASTNodeImpl(node, parent);\n jsonToNode.set(node, obj);\n node.children?.forEach((prop) => {\n if (prop.type === \"property\" && prop.children?.length) {\n const [key, val] = prop.children;\n const keyNode = new StringASTNodeImpl(key);\n const propNode = new PropertyASTNodeImpl(prop, obj, keyNode);\n propNode.keyNode = new StringASTNodeImpl(key, propNode);\n\n if (val) {\n if (keyNode.value === \"asset\") {\n propNode.valueNode = parseAsset(val, propNode);\n } else {\n propNode.valueNode = parseUnknownNode(val, propNode);\n }\n }\n\n jsonToNode.set(prop, propNode);\n jsonToNode.set(key, propNode.keyNode);\n if (propNode.valueNode) {\n jsonToNode.set(val, propNode.valueNode);\n }\n\n obj.properties.push(propNode);\n }\n });\n return obj;\n }\n\n default:\n }\n }\n\n /** parse a view */\n function parseView(node: Node, parent?: ASTNode): ViewASTNode {\n const viewNode = new ViewASTNodeImpl(node, parent);\n\n node.children?.forEach((prop) => {\n if (prop.type === \"property\" && (prop.children?.length ?? 0) > 0) {\n const [key, val] = prop.children ?? [];\n\n const keyNode = new StringASTNodeImpl(key);\n const property = new PropertyASTNodeImpl(prop, viewNode, keyNode);\n property.keyNode = new StringASTNodeImpl(key, property);\n\n if (val) {\n property.valueNode = parseUnknownNode(val, property);\n if (key.value === \"id\" && isStringProperty(property)) {\n viewNode.id = property;\n } else if (key.value === \"type\" && isStringProperty(property)) {\n viewNode.viewType = property;\n }\n }\n\n jsonToNode.set(prop, property);\n jsonToNode.set(key, property.keyNode);\n if (property.valueNode) {\n jsonToNode.set(val, property.valueNode);\n }\n\n viewNode.properties.push(property);\n }\n });\n\n jsonToNode.set(node, viewNode);\n return viewNode;\n }\n\n /** parse a flow state */\n function parseFlowState(node: Node, parent?: ASTNode): FlowStateASTNode {\n const state = new FlowStateASTNodeImpl(node, parent);\n jsonToNode.set(node, state);\n\n if (node.type === \"object\") {\n node.children?.forEach((prop) => {\n if (prop.type === \"property\" && prop.children?.length) {\n const [key, val] = prop.children;\n\n const keyNode = new StringASTNodeImpl(key);\n const property = new PropertyASTNodeImpl(prop, state, keyNode);\n property.keyNode = new StringASTNodeImpl(key, property);\n\n if (key.value === \"state_type\" && val?.type === \"string\") {\n property.valueNode = parseUnknownNode(val, property);\n state.stateType = property as PropertyASTNode<StringASTNode>;\n } else {\n property.valueNode = parseUnknownNode(val, property);\n }\n\n jsonToNode.set(prop, property);\n jsonToNode.set(key, property.keyNode);\n if (property.valueNode) {\n jsonToNode.set(val, property.valueNode);\n }\n\n state.properties.push(property);\n }\n });\n }\n\n return state;\n }\n\n /** parse a flow */\n function parseFlow(node: Node, parent?: ASTNode): FlowASTNode {\n const flow = new FlowASTNodeImpl(node, parent);\n jsonToNode.set(node, flow);\n\n if (node.type === \"object\") {\n node.children?.forEach((prop) => {\n if (prop.type === \"property\" && prop.children?.length) {\n const [key, val] = prop.children;\n\n const keyNode = new StringASTNodeImpl(key);\n const property = new PropertyASTNodeImpl(prop, flow, keyNode);\n property.keyNode = new StringASTNodeImpl(key, property);\n\n if (key.value === \"startState\" && val?.type === \"string\") {\n property.valueNode = parseUnknownNode(val, property);\n flow.start = property as PropertyASTNode<StringASTNode>;\n } else if (\n val?.type === \"object\" &&\n property.keyNode.value !== \"onStart\" &&\n property.keyNode.value !== \"onEnd\"\n ) {\n // Anything else in here is a state-type\n property.valueNode = parseFlowState(val, property);\n flow.states.push(property as PropertyASTNode<FlowStateASTNode>);\n } else {\n property.valueNode = parseUnknownNode(val, property);\n }\n\n jsonToNode.set(prop, property);\n jsonToNode.set(key, property.keyNode);\n if (property.valueNode) {\n jsonToNode.set(val, property.valueNode);\n }\n\n flow.properties.push(property);\n }\n });\n }\n\n return flow;\n }\n\n /** parse a nav node */\n function parseNavigation(node: Node, parent?: ASTNode): NavigationASTNode {\n const navNode = new NavigationASTNodeImpl(node, parent);\n jsonToNode.set(node, navNode);\n if (node.type === \"object\") {\n node.children?.forEach((prop) => {\n if (prop.type === \"property\" && prop.children?.length) {\n const [key, val] = prop.children;\n\n const keyNode = new StringASTNodeImpl(key);\n const property = new PropertyASTNodeImpl(prop, navNode, keyNode);\n property.keyNode = new StringASTNodeImpl(key, property);\n\n if (key.value === \"BEGIN\" && val?.type === \"string\") {\n property.valueNode = parseUnknownNode(val, property);\n navNode.begin = property as PropertyASTNode<StringASTNode>;\n } else if (val?.type === \"object\") {\n // Anything else in here is a state-type\n property.valueNode = parseFlow(val, property);\n navNode.flows.push(property as PropertyASTNode<FlowASTNode>);\n }\n\n jsonToNode.set(prop, property);\n jsonToNode.set(key, property.keyNode);\n if (property.valueNode) {\n jsonToNode.set(val, property.valueNode);\n }\n\n navNode.properties.push(property);\n }\n });\n }\n\n return navNode;\n }\n\n /** parse a full doc */\n function parseContent(node: Node): ContentASTNode {\n const contentNode = new ContentASTNodeImpl(node, undefined);\n\n if (node.type === \"object\") {\n node.children?.forEach((childProp) => {\n if (childProp.type === \"property\" && childProp.children?.length) {\n const [key, val] = childProp.children;\n\n const keyNode = new StringASTNodeImpl(key);\n const property = new PropertyASTNodeImpl(\n childProp,\n contentNode,\n keyNode,\n );\n property.keyNode = new StringASTNodeImpl(key, property);\n\n if (key.value === \"views\" && val?.type === \"array\") {\n const views = new ArrayASTNodeImpl(val, property);\n val.children?.forEach((view) => {\n const parsedV = parseView(view, views);\n jsonToNode.set(view, parsedV);\n views.items.push(parsedV);\n });\n property.valueNode = views;\n contentNode.views = property as PropertyASTNode<ArrayASTNode>;\n } else if (key.value === \"navigation\" && val) {\n const nav = parseNavigation(val, property);\n contentNode.navigation =\n property as PropertyASTNode<NavigationASTNode>;\n property.valueNode = nav;\n } else if (val) {\n property.valueNode = parseUnknownNode(val, property);\n }\n\n jsonToNode.set(childProp, property);\n jsonToNode.set(key, property.keyNode);\n if (property.valueNode) {\n jsonToNode.set(val, property.valueNode);\n }\n\n contentNode.properties.push(property);\n }\n });\n }\n\n jsonToNode.set(node, contentNode);\n return contentNode;\n }\n\n let rootASTNode: ASTNode = {\n type: \"empty\",\n value: undefined,\n jsonNode: root,\n };\n\n const objType = identify(root);\n\n switch (objType) {\n case ObjType.ASSET:\n rootASTNode = parseAsset(root);\n break;\n case ObjType.FLOW:\n rootASTNode = parseContent(root);\n break;\n default:\n break;\n }\n\n return new PlayerContent(rootASTNode, diags, jsonToNode);\n}\n","// https://github.com/microsoft/vscode-json-languageservice/blob/master/src/jsonLanguageTypes.ts\nimport type { Node } from \"jsonc-parser\";\n\nexport type ASTNode =\n | StringASTNode\n | NumberASTNode\n | BooleanASTNode\n | ArrayASTNode\n | NullASTNode\n | PropertyASTNode\n | ObjectASTNode\n | AssetASTNode\n | ViewASTNode\n | ContentASTNode\n | NavigationASTNode\n | FlowASTNode\n | EmptyASTNode\n | FlowStateASTNode;\n\nexport interface BaseASTNode<T extends string> {\n /** The base type of the node */\n readonly type: T;\n\n /** an optional parent */\n readonly parent?: ASTNode;\n\n /** the underlying json node */\n readonly jsonNode: Node;\n\n /** any children of the node */\n readonly children?: ASTNode[];\n}\n\n// Base JSON types\nexport interface StringASTNode extends BaseASTNode<\"string\"> {\n /** the raw value */\n readonly value: string;\n}\n\nexport interface NumberASTNode extends BaseASTNode<\"number\"> {\n /** the raw value */\n readonly value: number;\n}\n\nexport interface BooleanASTNode extends BaseASTNode<\"boolean\"> {\n /** the raw value */\n readonly value: boolean;\n}\n\nexport interface ArrayASTNode extends BaseASTNode<\"array\"> {\n /** the array items */\n readonly children: Array<ASTNode>;\n}\n\nexport interface NullASTNode extends BaseASTNode<\"null\"> {\n /** the raw value */\n readonly value: null;\n}\n\nexport interface EmptyASTNode extends BaseASTNode<\"empty\"> {\n /** the raw value */\n readonly value: undefined;\n}\n\nexport interface PropertyASTNode<\n T extends ASTNode = ASTNode,\n> extends BaseASTNode<\"property\"> {\n /** the key of the property */\n readonly keyNode: StringASTNode;\n\n /** the value of the property */\n readonly valueNode?: T;\n}\n\n// Object like things\nexport interface ObjectASTNode<\n T extends string = \"object\",\n> extends BaseASTNode<T> {\n /** an array of properties of this object */\n properties: Array<PropertyASTNode>;\n}\n\n// Player Semantic Nodes\nexport interface AssetASTNode extends ObjectASTNode<\"asset\"> {\n /** The id property for this asset */\n readonly id?: PropertyASTNode<StringASTNode>;\n\n /** The type property for this asset */\n readonly assetType?: PropertyASTNode<StringASTNode>;\n}\n\nexport interface ViewASTNode extends ObjectASTNode<\"view\"> {\n /** the id property for this view */\n readonly id?: PropertyASTNode<StringASTNode>;\n\n /** the type of the view */\n readonly viewType?: PropertyASTNode<StringASTNode>;\n}\n\nexport interface ContentASTNode extends ObjectASTNode<\"content\"> {\n /** the views prop of the flow */\n readonly views?: PropertyASTNode<ArrayASTNode>;\n\n /** the nav prop of the flow */\n readonly navigation?: PropertyASTNode<NavigationASTNode>;\n}\n\nexport interface NavigationASTNode extends ObjectASTNode<\"navigation\"> {\n /** the begin prop of the navigation node */\n readonly begin?: PropertyASTNode;\n\n /** the flows of the navigation node */\n readonly flows: Array<PropertyASTNode<FlowASTNode>>;\n}\n\nexport interface FlowASTNode extends ObjectASTNode<\"flow\"> {\n /** the start prop of the node */\n readonly start?: PropertyASTNode<StringASTNode>;\n\n /** the defined states */\n readonly states: Array<PropertyASTNode<FlowStateASTNode>>;\n}\n\nexport interface FlowStateASTNode extends ObjectASTNode<\"state\"> {\n /** the type of the flow state */\n readonly stateType?: PropertyASTNode<StringASTNode>;\n}\n\n/** The base class for any node implementation */\nexport abstract class ASTNodeImpl {\n public readonly parent: ASTNode | undefined;\n public readonly jsonNode: Node;\n\n constructor(jsonNode: Node, parent: ASTNode | undefined) {\n this.jsonNode = jsonNode;\n this.parent = parent;\n }\n}\n\n/** An implementation of a string node */\nexport class StringASTNodeImpl extends ASTNodeImpl implements StringASTNode {\n public type = \"string\" as const;\n public value: string;\n\n constructor(jsonNode: Node, parent?: ASTNode) {\n super(jsonNode, parent);\n this.value = jsonNode.value;\n }\n}\n\n/** An implementation of the number node */\nexport class NumberASTNodeImpl extends ASTNodeImpl implements NumberASTNode {\n public type = \"number\" as const;\n public value: number;\n\n constructor(jsonNode: Node, parent?: ASTNode) {\n super(jsonNode, parent);\n this.value = jsonNode.value;\n }\n}\n\n/** An implementation of a boolean node */\nexport class BooleanASTNodeImpl extends ASTNodeImpl implements BooleanASTNode {\n public type = \"boolean\" as const;\n public value: boolean;\n\n constructor(jsonNode: Node, parent?: ASTNode) {\n super(jsonNode, parent);\n this.value = jsonNode.value;\n }\n}\n\n/** An implementation of a null node */\nexport class NullASTNodeImpl extends ASTNodeImpl implements NullASTNode {\n public type = \"null\" as const;\n public value = null;\n}\n\n/** An implementation of a property node */\nexport class PropertyASTNodeImpl\n extends ASTNodeImpl\n implements PropertyASTNode\n{\n public type = \"property\" as const;\n public keyNode: StringASTNode;\n public valueNode?: ASTNode;\n\n constructor(\n jsonNode: Node,\n parent: ASTNode | undefined,\n keyNode: StringASTNode,\n ) {\n super(jsonNode, parent);\n this.keyNode = keyNode;\n }\n\n public get children() {\n return this.valueNode ? [this.keyNode, this.valueNode] : [this.keyNode];\n }\n}\n\n/** An implementation of a view node */\nexport class ViewASTNodeImpl extends ASTNodeImpl implements ViewASTNode {\n public type = \"view\" as const;\n public properties: PropertyASTNode[] = [];\n public id?: PropertyASTNode<StringASTNode> = undefined;\n public viewType?: PropertyASTNode<StringASTNode> = undefined;\n\n public get children() {\n return this.properties;\n }\n}\n\n/** An implementation of a top flow node */\nexport class ContentASTNodeImpl extends ASTNodeImpl implements ContentASTNode {\n public type = \"content\" as const;\n public properties: PropertyASTNode[] = [];\n public views?: PropertyASTNode<ArrayASTNode> = undefined;\n public navigation?: PropertyASTNode<NavigationASTNode> = undefined;\n\n public get children() {\n return this.properties;\n }\n}\n\n/** An implementation of a navigation node */\nexport class NavigationASTNodeImpl\n extends ASTNodeImpl\n implements NavigationASTNode\n{\n public type = \"navigation\" as const;\n public properties: PropertyASTNode[] = [];\n public begin?: PropertyASTNode<StringASTNode> = undefined;\n public flows: Array<PropertyASTNode<FlowASTNode>> = [];\n\n public get children() {\n return this.properties;\n }\n}\n\n/** An implementation of a flow node */\nexport class FlowASTNodeImpl extends ASTNodeImpl implements FlowASTNode {\n public type = \"flow\" as const;\n public properties: PropertyASTNode[] = [];\n public start?: PropertyASTNode<StringASTNode> = undefined;\n public states: Array<PropertyASTNode<FlowStateASTNode>> = [];\n\n public get children() {\n return this.properties;\n }\n}\n\n/** An implementation of a flow-state node */\nexport class FlowStateASTNodeImpl\n extends ASTNodeImpl\n implements FlowStateASTNode\n{\n public type = \"state\" as const;\n public properties: PropertyASTNode[] = [];\n public stateType?: PropertyASTNode<StringASTNode> = undefined;\n\n public get children() {\n return this.properties;\n }\n}\n\n/** An implementation of an asset node */\nexport class AssetASTNodeImpl extends ASTNodeImpl implements AssetASTNode {\n public type = \"asset\" as const;\n public properties: PropertyASTNode[] = [];\n public id?: PropertyASTNode<StringASTNode> = undefined;\n public assetType?: PropertyASTNode<StringASTNode> = undefined;\n\n public get children() {\n return this.properties;\n }\n}\n\n/** An implementation of a array node */\nexport class ArrayASTNodeImpl extends ASTNodeImpl implements ArrayASTNode {\n public type = \"array\" as const;\n public items: ASTNode[] = [];\n\n public get children() {\n return this.items;\n }\n}\n\n/** An implementation of an object node */\nexport class ObjectASTNodeImpl extends ASTNodeImpl implements ObjectASTNode {\n public type = \"object\" as const;\n public properties: PropertyASTNode[] = [];\n\n public get children() {\n return this.properties;\n }\n}\n\n// Edits\n\nexport type NodeEdit = ReplaceEdit;\n\nexport interface BaseNodeEdit<T extends string> {\n /** The type of node edit */\n type: T;\n\n /** the node to edit */\n node: ASTNode;\n}\n\nexport interface ReplaceEdit extends BaseNodeEdit<\"replace\"> {\n /** the new value to replace with */\n value: any;\n}\n","import { printParseErrorCode } from \"jsonc-parser\";\nimport {\n Diagnostic,\n Range,\n DiagnosticSeverity,\n} from \"vscode-languageserver-types\";\n\nimport type { ParseError } from \"jsonc-parser\";\nimport type { TextDocument } from \"vscode-languageserver-textdocument\";\n\nenum ParseErrorCode {\n InvalidSymbol = 1,\n InvalidNumberFormat = 2,\n PropertyNameExpected = 3,\n ValueExpected = 4,\n ColonExpected = 5,\n CommaExpected = 6,\n CloseBraceExpected = 7,\n CloseBracketExpected = 8,\n EndOfFileExpected = 9,\n InvalidCommentToken = 10,\n UnexpectedEndOfComment = 11,\n UnexpectedEndOfString = 12,\n UnexpectedEndOfNumber = 13,\n InvalidUnicode = 14,\n InvalidEscapeCharacter = 15,\n InvalidCharacter = 16,\n}\n\n/** Just what the function says */\nexport function prettyPrintParseErrorCode(code: ParseErrorCode): string {\n switch (code) {\n case ParseErrorCode.CommaExpected:\n return `Expected comma`;\n case ParseErrorCode.ColonExpected:\n return `Expected colon`;\n case ParseErrorCode.PropertyNameExpected:\n return `Expected property name`;\n case ParseErrorCode.ValueExpected:\n return `Expected value`;\n case ParseErrorCode.CloseBraceExpected:\n return `Expected }`;\n case ParseErrorCode.EndOfFileExpected:\n return `Expected end of file`;\n case ParseErrorCode.CloseBracketExpected:\n return `Expected ]`;\n case ParseErrorCode.UnexpectedEndOfString:\n return `Expected \"`;\n default:\n return printParseErrorCode(code as any);\n }\n}\n\n/** Convert any JSON parsing errors to LSP diagnostics */\nexport function convertErrorsToDiags(\n document: TextDocument,\n errors: Array<ParseError>,\n): Array<Diagnostic> {\n return errors.map((parseError) => {\n return Diagnostic.create(\n Range.create(\n document.positionAt(parseError.offset),\n document.positionAt(parseError.offset + parseError.length),\n ),\n prettyPrintParseErrorCode(parseError.error as any as ParseErrorCode),\n DiagnosticSeverity.Error,\n );\n });\n}\n","import type { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { TextEdit, Range } from \"vscode-languageserver-types\";\nimport type { StringASTNode, NodeEdit, ASTNode } from \"./types\";\n\n/** Create a NodeEdit by replacing a string */\nexport function replaceString(node: StringASTNode, newText: string): NodeEdit {\n return {\n type: \"replace\",\n node,\n value: newText,\n };\n}\n\n/** Get the range for a given node */\nexport function toRange(document: TextDocument, node: ASTNode): Range {\n return Range.create(\n document.positionAt(node.jsonNode.offset),\n document.positionAt(node.jsonNode.offset + node.jsonNode.length),\n );\n}\n\n/** Convert a NodeEdit to a TextEdit */\nexport function toTextEdit(document: TextDocument, edit: NodeEdit): TextEdit {\n switch (edit.type) {\n case \"replace\":\n return TextEdit.replace(toRange(document, edit.node), edit.value);\n\n default:\n throw new Error(\"Dont know how to convert this to a TextEdit\");\n }\n}\n","import { Range, Location } from \"vscode-languageserver-types\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\nimport detectIndent from \"detect-indent\";\nimport type {\n ASTNode,\n PlayerContent,\n ObjectASTNode,\n PropertyASTNode,\n} from \"./parser\";\nimport type { ASTVisitor } from \"./types\";\n\nexport const typeToVisitorMap: Record<ASTNode[\"type\"], keyof ASTVisitor> = {\n string: \"StringNode\",\n number: \"NumberNode\",\n boolean: \"BooleanNode\",\n array: \"ArrayNode\",\n null: \"NullNode\",\n empty: \"EmptyNode\",\n property: \"PropertyNode\",\n object: \"ObjectNode\",\n asset: \"AssetNode\",\n view: \"ViewNode\",\n content: \"ContentNode\",\n navigation: \"NavigationNode\",\n flow: \"FlowNode\",\n state: \"FlowStateNode\",\n};\n\n/** Check to see if the source range contains the target one */\nexport function containsRange(source: Range, range: Range): boolean {\n const { start, end } = range;\n const { start: srcStart, end: srcEnd } = source;\n\n return (\n start.line === srcStart.line &&\n end.line === srcEnd.line &&\n start.character >= srcStart.character &&\n end.character <= srcEnd.character\n );\n}\n\n/** Create a dummy TextDocument from the given string */\nexport function toTextDocument(str: string): TextDocument {\n return TextDocument.create(\"foo\", \"json\", 1, str);\n}\n\n/** Check to see if the document successfully parsed into a known root type */\nexport function isKnownRootType(document: PlayerContent): boolean {\n const { type } = document.root;\n\n return type === \"view\" || type === \"asset\" || type === \"content\";\n}\n\n/** Check to see if the node is the value of an object */\nexport function isValueCompletion(node: ASTNode): boolean {\n return node.parent?.type === \"property\" && node.parent.valueNode === node;\n}\n\n/** Check to see if the node is the key of an object */\nexport function isPropertyCompletion(node: ASTNode): boolean {\n return node.parent?.type === \"property\" && node.parent.keyNode === node;\n}\n\n/** Search the object for a property with the given name */\nexport function getProperty<T extends ASTNode>(\n obj: T,\n name: string,\n): PropertyASTNode | undefined {\n if (\"properties\" in obj) {\n return (obj as ObjectASTNode).properties.find(\n (p) => p.keyNode.value === name,\n );\n }\n}\n\n/** Get the LSP Location of an AST node in a document */\nexport function getLSLocationOfNode(\n document: TextDocument,\n node: ASTNode,\n): Location {\n const nodeRange = Range.create(\n document.positionAt(node.jsonNode.offset),\n document.positionAt(node.jsonNode.offset + node.jsonNode.length),\n );\n\n return Location.create(document.uri, nodeRange);\n}\n\n/** Get the depth of the property */\nfunction getDepth(node: ASTNode): number {\n if (!node.parent) {\n return 0;\n }\n\n if (node.type === \"property\") {\n return getDepth(node.parent);\n }\n\n return 1 + getDepth(node.parent);\n}\n\n/** Format a new node like an existing one (including the indentation) */\nexport function formatLikeNode(\n document: TextDocument,\n originalNode: ASTNode,\n replacement: Record<string, unknown>,\n): string {\n const { indent } = detectIndent(document.getText());\n const depth = getDepth(originalNode);\n\n return JSON.stringify(replacement, null, indent)\n .split(\"\\n\")\n .map((l, index) => (index === 0 ? l : `${indent.repeat(depth)}${l}`))\n .join(\"\\n\");\n}\n\n/** Maps the string identifying the FlowType to the named type */\nexport function mapFlowStateToType(\n flowType: string | undefined,\n): string | undefined {\n let flowXLR;\n switch (flowType) {\n case \"VIEW\":\n flowXLR = \"NavigationFlowViewState\";\n break;\n case \"END\":\n flowXLR = \"NavigationFlowEndState\";\n break;\n case \"ACTION\":\n flowXLR = \"NavigationFlowActionState\";\n break;\n case \"EXTERNAL\":\n flowXLR = \"NavigationFlowExternalState\";\n break;\n case \"FLOW\":\n flowXLR = \"NavigationFlowFlowState\";\n break;\n default:\n break;\n }\n\n return flowXLR;\n}\n","import type { Location } from \"vscode-languageserver-types\";\nimport { CompletionItemKind } from \"vscode-languageserver-types\";\nimport type { NodeType } from \"@xlr-lib/xlr\";\nimport type { PlayerLanguageService, PlayerLanguageServicePlugin } from \"..\";\nimport type {\n DocumentContext,\n EnhancedDocumentContextWithPosition,\n} from \"../types\";\nimport { getLSLocationOfNode, getProperty, isValueCompletion } from \"../utils\";\nimport type { PropertyASTNode, StringASTNode } from \"../parser\";\nimport { getContentNode } from \"../parser\";\n\ninterface SchemaInfo {\n /** mapping of binding to schema path */\n bindingToSchemaType: Map<\n string,\n {\n /** the binding */\n binding: string;\n\n /** the type name */\n typeName: string;\n\n /** the name of the key */\n key: string;\n }\n >;\n\n /** JSON AST mapping of type to the node */\n typeToNode: Map<\n string,\n {\n /** the type */\n type: string;\n\n /** the json node */\n typeNode: PropertyASTNode;\n }\n >;\n}\n\n/** parse the document for the schema info */\nfunction getBindingInfo(ctx: DocumentContext): SchemaInfo {\n const info: SchemaInfo = {\n bindingToSchemaType: new Map(),\n typeToNode: new Map(),\n };\n\n if (ctx.PlayerContent.root.type !== \"content\") {\n return info;\n }\n\n const schemaRoot = ctx.PlayerContent.root.properties?.find(\n (child) => child.keyNode.value === \"schema\",\n );\n\n if (!schemaRoot || schemaRoot.valueNode?.type !== \"object\") {\n return info;\n }\n\n const schemaTypeQueue: Array<{\n /** the current path */\n currentPath: string;\n\n /** the next type to visit */\n typeToVisit: string;\n\n /** list of visited types (to prevent loops) */\n visited: Set<string>;\n }> = [\n {\n currentPath: \"\",\n typeToVisit: \"ROOT\",\n visited: new Set(),\n },\n ];\n\n while (schemaTypeQueue.length > 0) {\n const next = schemaTypeQueue.shift();\n if (!next) {\n break;\n }\n\n if (next.visited.has(next.typeToVisit)) {\n continue;\n }\n\n const visited = new Set(...next.visited, next.typeToVisit);\n const { currentPath, typeToVisit } = next;\n\n const typeNode = schemaRoot.valueNode.properties.find(\n (child) => child.keyNode.value === typeToVisit,\n );\n\n if (!typeNode || typeNode.valueNode?.type !== \"object\") {\n continue;\n }\n\n info.typeToNode.set(typeToVisit, { type: typeToVisit, typeNode });\n\n typeNode.valueNode.properties.forEach((prop) => {\n // PropName is the path\n // { type: TYPE } is the next nested type\n\n const nextPath = [currentPath, prop.keyNode.value].join(\n currentPath === \"\" ? \"\" : \".\",\n );\n\n info.bindingToSchemaType.set(nextPath, {\n binding: nextPath,\n typeName: typeToVisit,\n key: prop.keyNode.value,\n });\n\n if (prop.valueNode?.type === \"object\") {\n const nestedTypeName = prop.valueNode.properties.find(\n (c) => c.keyNode.value === \"type\",\n );\n\n if (nestedTypeName && nestedTypeName.valueNode?.type === \"string\") {\n schemaTypeQueue.push({\n currentPath: nextPath,\n typeToVisit: nestedTypeName.valueNode.value,\n visited,\n });\n }\n }\n });\n }\n\n return info;\n}\n\n/**\n * Checks to see if there is a Binding ref node somewhere at this level\n *\n * - @param nodes Array of nodes to check for an AssetWrapper ref\n */\nconst checkTypesForBinding = (nodes: Array<NodeType>): boolean => {\n for (let i = 0; i < nodes.length; i++) {\n const node = nodes[i];\n if (node.type === \"string\" && node.name === \"Binding\") return true;\n if (node.type === \"or\") return checkTypesForBinding(node.or);\n if (node.type === \"and\") return checkTypesForBinding(node.and);\n }\n\n return false;\n};\n\n/** check if the property is of type Binding */\nfunction isBindingPropertyAssignment(\n ctx: EnhancedDocumentContextWithPosition,\n): boolean {\n if (ctx.node.type !== \"string\" || ctx.node.parent?.type !== \"property\") {\n return false;\n }\n\n if (checkTypesForBinding(ctx.XLR?.nodes ?? [])) {\n return true;\n }\n\n return false;\n}\n\n/** find where in the document the type def is located */\nfunction getLocationForBindingTypeDefinition(\n ctx: EnhancedDocumentContextWithPosition,\n schemaInfo: SchemaInfo,\n): Location | undefined {\n if (!isBindingPropertyAssignment(ctx)) {\n return;\n }\n\n const existingBindingValue = (ctx.node as StringASTNode).value;\n const info = schemaInfo.bindingToSchemaType.get(existingBindingValue);\n\n if (!info) {\n return;\n }\n\n const nodeLocation = schemaInfo.typeToNode.get(info.typeName);\n\n if (!nodeLocation || nodeLocation.typeNode.valueNode?.type !== \"object\") {\n return;\n }\n\n const prop = getProperty(nodeLocation.typeNode.valueNode, info.key);\n\n if (!prop) {\n return;\n }\n\n return getLSLocationOfNode(ctx.document, prop);\n}\n\n/** find where the schema is for a type */\nfunction getLocationForSchemaType(\n ctx: EnhancedDocumentContextWithPosition,\n schemaInfo: SchemaInfo,\n): Location | undefined {\n if (isValueCompletion(ctx.node)) {\n // See if we're the \"type\" prop of a schema lookup\n\n if (\n ctx.node.parent?.type === \"property\" &&\n ctx.node.type === \"string\" &&\n ctx.node.parent.keyNode.value === \"type\"\n ) {\n const typeName = ctx.node.value;\n const node = schemaInfo.typeToNode.get(typeName);\n\n if (!node) {\n return;\n }\n\n const schemaPropNode = getContentNode(ctx.node)?.properties.find(\n (p) => p.keyNode.value === \"schema\",\n );\n\n if (schemaPropNode?.valueNode?.type !== \"object\") {\n return;\n }\n\n const schemaTypeNode = schemaPropNode.valueNode.properties.find(\n (p) => p.keyNode.value === typeName,\n );\n\n if (schemaTypeNode !== node.typeNode) {\n return;\n }\n\n return getLSLocationOfNode(ctx.document, node.typeNode);\n }\n }\n}\n\n/**\n *\n * Adds completions for:\n * - any `Binding` type from TS\n * - \"type\" and \"key\" for non-defined types\n *\n * Adds definitions for:\n * - any `Binding` reference to the schema def\n */\nexport class SchemaInfoPlugin implements PlayerLanguageServicePlugin {\n name = \"view-node\";\n\n apply(service: PlayerLanguageService): void {\n let schemaInfo: SchemaInfo | undefined;\n\n service.hooks.onDocumentUpdate.tap(this.name, (ctx) => {\n schemaInfo = getBindingInfo(ctx);\n });\n\n service.hooks.complete.tap(this.name, async (ctx, completionCtx) => {\n // Is this a `binding` type\n if (!isBindingPropertyAssignment(ctx)) {\n return;\n }\n\n const existingBindingValue = (ctx.node as StringASTNode).value;\n\n const bindings = Array.from(\n schemaInfo?.bindingToSchemaType.keys() ?? [],\n ).filter((k) => k.startsWith(existingBindingValue));\n\n bindings.forEach((b) => {\n completionCtx.addCompletionItem({\n kind: CompletionItemKind.Value,\n label: b.substring(existingBindingValue.length),\n });\n });\n\n // get bindings from schema\n });\n\n service.hooks.definition.tap(this.name, (ctx) => {\n if (!schemaInfo) {\n return;\n }\n\n return (\n getLocationForSchemaType(ctx, schemaInfo) ||\n getLocationForBindingTypeDefinition(ctx, schemaInfo)\n );\n });\n }\n}\n","import type { NodeType } from \"@xlr-lib/xlr\";\nimport type { ValidationMessage } from \"@xlr-lib/xlr-sdk\";\nimport { ValidationSeverity, XLRSDK } from \"@xlr-lib/xlr-sdk\";\nimport type { CompletionItem } from \"vscode-languageserver-types\";\nimport {\n CompletionItemKind,\n DiagnosticSeverity,\n MarkupKind,\n} from \"vscode-languageserver-types\";\nimport type { Node } from \"jsonc-parser\";\nimport type {\n ASTVisitor,\n PlayerLanguageService,\n PlayerLanguageServicePlugin,\n ValidationContext,\n} from \"..\";\nimport { mapFlowStateToType } from \"../utils\";\nimport type { ASTNode, ObjectASTNode } from \"../parser\";\nimport type { EnhancedDocumentContextWithPosition } from \"../types\";\n\nfunction isError(issue: ValidationMessage): boolean {\n return issue.severity === DiagnosticSeverity.Error;\n}\n\n/** BFS search to find a JSONC node in children of some AST Node */\nconst findErrorNode = (rootNode: ASTNode, nodeToFind: Node): ASTNode => {\n const children: Array<ASTNode> = [rootNode];\n\n while (children.length > 0) {\n const child = children.pop() as ASTNode;\n if (child.jsonNode === nodeToFind) {\n return child;\n }\n\n if (child.children) {\n children.push(...child.children);\n }\n }\n\n // if the node can't be found return the original\n return rootNode;\n};\n\n/**\n * Translates an SDK severity level to an LSP severity level\n * Relies on both levels having the values associated to the underlying levels\n */\nconst translateSeverity = (\n severity: ValidationSeverity,\n): DiagnosticSeverity => {\n return severity as DiagnosticSeverity;\n};\n\n/**\n * Create Validation walkers\n */\nfunction createValidationVisitor(\n ctx: ValidationContext,\n sdk: XLRSDK,\n): ASTVisitor {\n const nodesWithErrors = new Set<Node>();\n\n // TODO cache nodes for LSP usecase. Need to examine which nodes can be cached and how to cache complex objects\n return {\n AssetNode: (assetNode) => {\n // Try and find custom asset but fall back on just validating if its an valid asset if its not found.\n let expectedType = assetNode.assetType?.valueNode?.value as string;\n\n if (!sdk.hasType(expectedType)) {\n ctx.addViolation({\n node: assetNode,\n message: `Warning - Asset Type ${assetNode.assetType?.valueNode?.value} was not loaded into Validator definitions`,\n severity: DiagnosticSeverity.Error,\n });\n expectedType = \"Asset\";\n }\n\n const validationIssues = sdk.validateByName(\n expectedType,\n assetNode.jsonNode,\n );\n validationIssues.forEach((issue) => {\n if (!(nodesWithErrors.has(issue.node) && isError(issue))) {\n ctx.addViolation({\n node: findErrorNode(assetNode, issue.node),\n message: isError(issue)\n ? `Asset Validation Error - ${issue.type}: ${issue.message}`\n : issue.message,\n severity: translateSeverity(issue.severity),\n });\n if (isError(issue)) {\n nodesWithErrors.add(issue.node);\n }\n }\n });\n },\n ViewNode: (viewNode) => {\n let expectedType = viewNode.viewType?.valueNode?.value as string;\n\n if (!sdk.hasType(expectedType)) {\n ctx.addViolation({\n node: viewNode,\n message: `Warning - View Type ${viewNode.viewType?.valueNode?.value} was not loaded into Validator definitions`,\n severity: DiagnosticSeverity.Error,\n });\n expectedType = \"View\";\n }\n\n const validationIssues = sdk.validateByName(\n expectedType,\n viewNode.jsonNode,\n );\n validationIssues.forEach((issue) => {\n if (!(nodesWithErrors.has(issue.node) && isError(issue))) {\n ctx.addViolation({\n node: findErrorNode(viewNode, issue.node),\n message: isError(issue)\n ? `View Validation Error - ${issue.type}: ${issue.message}`\n : issue.message,\n severity: translateSeverity(issue.severity),\n });\n if (isError(issue)) {\n nodesWithErrors.add(issue.node);\n }\n }\n });\n },\n ContentNode: (contentNode) => {\n const flowType = sdk.getType(\"Flow\");\n\n if (!flowType) {\n throw new Error(\n \"Flow is not a registered type, can't validate content. Did you load a version of the base Player types?\",\n );\n }\n\n /**\n * Since the `views.validation` property contains a runtime conditional that is validated anyways when we get to\n * the ViewNode, replace the reference to `View` with a basic `Asset` instead of trying to solve the generic\n * for every view present\n */\n\n const assetType = sdk.getType(\"Asset\");\n if (!assetType) {\n throw new Error(\n \"Asset is not a registered type, can't validate content. Did you load a version of the base Player types?\",\n );\n }\n\n if (\n flowType.type === \"object\" &&\n flowType.properties.views?.node.type === \"array\"\n ) {\n flowType.properties.views.node.elementType = assetType;\n }\n\n const validationIssues = sdk.validateByType(\n flowType,\n contentNode.jsonNode,\n );\n\n validationIssues.forEach((issue) => {\n if (!nodesWithErrors.has(issue.node) || issue.type === \"missing\") {\n nodesWithErrors.add(issue.node);\n ctx.addViolation({\n node: findErrorNode(contentNode, issue.node),\n message: `Content Validation Error - ${issue.type}: ${issue.message}`,\n severity: DiagnosticSeverity.Error,\n });\n }\n });\n },\n NavigationNode: (navigationNode) => {\n const expectedType = \"Navigation\";\n const validationIssues = sdk.validateByName(\n expectedType,\n navigationNode.jsonNode,\n );\n validationIssues.forEach((issue) => {\n if (!nodesWithErrors.has(issue.node) || issue.type === \"missing\") {\n nodesWithErrors.add(issue.node);\n ctx.addViolation({\n node: findErrorNode(navigationNode, issue.node),\n message: `Navigation Validation Error - ${issue.type}: ${issue.message}`,\n severity: DiagnosticSeverity.Error,\n });\n }\n });\n },\n FlowNode: (flowNode) => {\n const expectedType = \"NavigationFlow\";\n const validationIssues = sdk.validateByName(\n expectedType,\n flowNode.jsonNode,\n );\n validationIssues.forEach((issue) => {\n if (!nodesWithErrors.has(issue.node) || issue.type === \"missing\") {\n nodesWithErrors.add(issue.node);\n ctx.addViolation({\n node: findErrorNode(flowNode, issue.node),\n message: `Navigation Flow Validation Error - ${issue.type}: ${issue.message}`,\n severity: DiagnosticSeverity.Error,\n });\n }\n });\n },\n FlowStateNode: (flowStateNode) => {\n const flowxlr = mapFlowStateToType(\n flowStateNode.stateType?.valueNode?.value,\n );\n\n if (flowxlr) {\n const validationIssues = sdk.validateByName(\n flowxlr,\n flowStateNode.jsonNode,\n );\n validationIssues.forEach((issue) => {\n if (!nodesWithErrors.has(issue.node) || issue.type === \"missing\") {\n nodesWithErrors.add(issue.node);\n ctx.addViolation({\n node: findErrorNode(flowStateNode, issue.node),\n message: `Navigation Node Validation Error - ${issue.type}: ${issue.message}`,\n severity: DiagnosticSeverity.Error,\n });\n }\n });\n } else {\n ctx.addViolation({\n node: flowStateNode,\n message:\n \"Unknown Flow Type, valid options are: VIEW, END, ACTION, EXTERNAL, FLOW\",\n severity: DiagnosticSeverity.Error,\n });\n }\n },\n };\n}\n\n/** Gets object completions */\nfunction getObjectCompletions(\n authoredNode: ASTNode,\n potentialTypes: Array<NodeType>,\n) {\n const completions: Array<CompletionItem> = [];\n\n const presentKeys = new Set();\n if ((authoredNode as ObjectASTNode).properties) {\n (authoredNode as ObjectASTNode).properties.forEach((propertyNode) =>\n presentKeys.add(propertyNode.keyNode.value),\n );\n }\n\n potentialTypes.forEach((node) => {\n if (node.type === \"object\") {\n Object.keys(node.properties).forEach((prop) => {\n if (!presentKeys.has(prop)) {\n completions.push({\n label: prop,\n documentation:\n node.properties[prop].node.description ??\n node.properties[prop].node.title,\n kind: CompletionItemKind.Property,\n });\n }\n });\n } else if (node.type === \"and\") {\n completions.push(...getObjectCompletions(authoredNode, node.and));\n } else if (node.type === \"or\") {\n completions.push(...getObjectCompletions(authoredNode, node.or));\n }\n });\n\n return completions;\n}\n\n/** get value completions */\nfunction getPropertyCompletions(\n propertyName: string,\n potentialTypes: Array<NodeType>,\n) {\n const completions: Array<CompletionItem> = [];\n potentialTypes.forEach((nodeType) => {\n if (nodeType.type === \"object\") {\n const propertyNode = nodeType.properties[propertyName]?.node;\n if (\n propertyNode &&\n propertyNode.type === \"string\" &&\n propertyNode.const\n ) {\n completions.push({\n label: propertyNode.const,\n kind: CompletionItemKind.Value,\n });\n }\n }\n });\n\n return completions;\n}\n\n/** returns completions for object properties */\nfunction complete(\n ctx: EnhancedDocumentContextWithPosition,\n): Array<CompletionItem> {\n if (ctx.XLR?.nearestObjects) {\n if (ctx.node.type === \"string\" && ctx.node?.parent?.type === \"property\") {\n return getPropertyCompletions(\n ctx.node.parent.keyNode.value,\n ctx.XLR.nearestObjects,\n );\n }\n\n return getObjectCompletions(ctx.node, ctx.XLR.nearestObjects);\n }\n\n return [];\n}\n\n/** gets hover docs */\nfunction hover(ctx: EnhancedDocumentContextWithPosition) {\n if (ctx.XLR && ctx.node.type === \"string\") {\n const docStrings: Array<string> = [];\n const prop = ctx.node.value;\n\n ctx.XLR.nearestObjects.forEach((typeNode) => {\n const docString =\n typeNode.properties[prop]?.node?.description ??\n typeNode.properties[prop]?.node?.title ??\n undefined;\n if (docString) {\n docStrings.push(docString);\n }\n });\n\n if (docStrings.length > 1) {\n return {\n contents: {\n kind: MarkupKind.PlainText,\n value:\n \"Docs unavailable - More than one type could exist at this location\",\n },\n };\n }\n\n return {\n contents: {\n kind: MarkupKind.PlainText,\n value: docStrings[0] ?? \"Error getting docs\",\n },\n };\n }\n}\n\n/** The plugin to enable duplicate id checking/fixing */\nexport class XLRPlugin implements PlayerLanguageServicePlugin {\n name = \"xlr-plugin\";\n\n apply(service: PlayerLanguageService): void {\n service.hooks.validate.tap(this.name, async (ctx, validation) => {\n validation.useASTVisitor(\n createValidationVisitor(validation, service.XLRService.XLRSDK),\n );\n });\n service.hooks.complete.tap(this.name, async (ctx, completion) => {\n complete(ctx).map((i) => completion.addCompletionItem(i));\n });\n service.hooks.hover.tap(this.name, (ctx) => {\n return hover(ctx);\n });\n }\n}\n","import { DiagnosticSeverity } from \"vscode-languageserver-types\";\nimport type { AssetASTNode, ASTNode, ViewASTNode } from \"../parser\";\nimport { getViewNode, isPropertyNode, replaceString } from \"../parser\";\nimport type { PlayerLanguageService, PlayerLanguageServicePlugin } from \"..\";\nimport type { Violation, ValidationContext, ASTVisitor } from \"../types\";\n\n/** Recurse up tree from node to find how many parents are templates */\nconst checkParentTemplate = (node: ASTNode, depth = 0) => {\n if (node.parent) {\n if (\n isPropertyNode(node.parent) &&\n node.parent.keyNode.value === \"template\"\n ) {\n // Increase the template count each time it finds a nested template\n\n depth += 1;\n\n return checkParentTemplate(node.parent, depth);\n }\n return checkParentTemplate(node.parent, depth);\n }\n return depth;\n};\n\n/** Create an id for the node given it's path */\nconst generateID = (node?: ASTNode): string => {\n if (!node || node.type === \"view\") {\n return \"\";\n }\n\n const prefix = generateID(node.parent);\n let current = \"\";\n\n if (node.type === \"property\") {\n current = node.keyNode.value;\n } else if (node.type === \"asset\" && node.assetType?.valueNode?.value) {\n current = node.assetType.valueNode?.value;\n }\n\n return [prefix, current].filter(Boolean).join(\"-\");\n};\n\n/** Create a duplicate id violation for the given node */\nconst createViolation = (node: AssetASTNode): Violation | undefined => {\n const valueNode = node.id?.valueNode;\n\n if (!valueNode) {\n return;\n }\n\n return {\n node: valueNode,\n severity: DiagnosticSeverity.Error,\n message: `The id \"${node.id?.valueNode?.value}\" is already in use in this view.`,\n fix: () => {\n return {\n name: \"Generate new ID\",\n edit: replaceString(valueNode, `\"${generateID(node)}\"`),\n };\n },\n };\n};\n\n/** visit each of the assets in a view and check for duplicate ids */\nconst createValidationVisitor = (ctx: ValidationContext): ASTVisitor => {\n const viewInfo = new Map<\n ViewASTNode | AssetASTNode,\n Map<\n string,\n {\n /** the original asset node */\n original: AssetASTNode;\n\n /** if we've accounted for this node already */\n handled: boolean;\n }\n >\n >();\n\n return {\n AssetNode: (assetNode) => {\n const view = getViewNode(assetNode);\n if (!view) {\n // not sure how you can get here\n throw new Error(\n \"Asset found but not within a view. Something is wrong\",\n );\n }\n\n const assetID = assetNode.id;\n\n if (!assetID || !assetID.valueNode?.value) {\n // Can\"t check for dupe ids if the asset doesn\"t have one\n return;\n }\n\n const id = assetID.valueNode?.value;\n if (!viewInfo.has(view)) {\n viewInfo.set(view, new Map());\n }\n\n const assetIDMap = viewInfo.get(view);\n const idInfo = assetIDMap?.get(id);\n\n const templateDepth = checkParentTemplate(assetNode);\n\n if (templateDepth > 0) {\n const expectedIndexElements = [];\n for (let i = 0; i < templateDepth; i++) {\n expectedIndexElements.push(`_index${i === 0 ? \"\" : i}_`);\n }\n const missingIndexSegments = expectedIndexElements.filter(\n (e) => !id.includes(e),\n );\n\n if (missingIndexSegments.length !== 0) {\n ctx.addViolation({\n node: assetNode,\n severity: DiagnosticSeverity.Error,\n message: `The id for this templated elements is missing the following index segments: ${missingIndexSegments.join(\n \", \",\n )}`,\n });\n }\n }\n\n if (idInfo) {\n if (!idInfo.handled) {\n const origViolation = createViolation(idInfo.original);\n if (origViolation) {\n ctx.addViolation(origViolation);\n }\n\n idInfo.handled = true;\n }\n\n const assetViolation = createViolation(assetNode);\n if (assetViolation) {\n ctx.addViolation(assetViolation);\n }\n } else {\n // not claimed yet so this is the first\n assetIDMap?.set(id, { original: assetNode, handled: false });\n }\n },\n };\n};\n\n/** The plugin to enable duplicate id checking/fixing */\nexport class DuplicateIDPlugin implements PlayerLanguageServicePlugin {\n name = \"duplicate-id\";\n\n apply(service: PlayerLanguageService): void {\n service.hooks.validate.tap(this.name, async (ctx, validation) => {\n validation.useASTVisitor(createValidationVisitor(validation));\n });\n }\n}\n","import { DiagnosticSeverity } from \"vscode-languageserver-types\";\nimport type { PlayerLanguageService, PlayerLanguageServicePlugin } from \"..\";\nimport type { ASTNode, ObjectASTNode } from \"../parser\";\nimport {\n getNodeValue,\n isKeyNode,\n isObjectNode,\n isPropertyNode,\n} from \"../parser\";\nimport { formatLikeNode } from \"../utils\";\n\n/** Get the JSON object that the validation targets */\nconst getObjectTarget = (node?: ASTNode): ObjectASTNode | undefined => {\n if (isObjectNode(node)) {\n return node;\n }\n\n if (\n isKeyNode(node) &&\n isPropertyNode(node.parent) &&\n isObjectNode(node.parent.valueNode)\n ) {\n return node.parent.valueNode;\n }\n};\n\n/**\n * A plugin to help identify and fix the issue of forgetting the \"asset\" wrapper object\n */\nexport class MissingAssetWrapperPlugin implements PlayerLanguageServicePlugin {\n name = \"missing-asset-wrapper\";\n\n apply(languageService: PlayerLanguageService): void {\n languageService.hooks.onValidateEnd.tap(\n this.name,\n (diagnostics, { addFixableViolation, documentContext }) => {\n // Just be naive here\n // If there's an error for \"expected asset\" + an unexpected `id` and `type`, replace that with our own\n\n let filteredDiags = diagnostics;\n\n const expectedAssetDiags = diagnostics.filter(\n (d) =>\n d.message.includes(\n `Does not match any of the expected types for type: 'AssetWrapperOrSwitch'`,\n ) || d.message.startsWith(\"Expected property: asset\"),\n );\n\n expectedAssetDiags.forEach((d) => {\n const originalNode = documentContext.PlayerContent.getNodeFromOffset(\n documentContext.document.offsetAt(d.range.start),\n );\n\n const objectNode = getObjectTarget(originalNode);\n\n if (objectNode && originalNode) {\n // This \"expected property\" diag is for the key of a property, where the value is the stubbed out asset\n // Check for diags for keys in that nested object\n\n // Now group the other diagnostics that are for unexpected props underneath that object\n // We\"ll suppress these for now since they are bound to be wrong until they\"re wrapped in an asset\n const associatedDiags = filteredDiags.filter((nestedDiag) => {\n const diagNode = documentContext.PlayerContent.getNodeFromOffset(\n documentContext.document.offsetAt(nestedDiag.range.start),\n );\n\n return objectNode.properties.some((p) => p.keyNode === diagNode);\n });\n\n addFixableViolation(d, {\n node: originalNode,\n message: d.message,\n severity: d.severity ?? DiagnosticSeverity.Error,\n fix: () => ({\n name: `Wrap in \"asset\"`,\n edit: {\n type: \"replace\",\n node: objectNode,\n value: formatLikeNode(documentContext.document, objectNode, {\n asset: getNodeValue(objectNode),\n }),\n },\n }),\n });\n\n filteredDiags = filteredDiags.filter(\n (filteredD) => !associatedDiags.includes(filteredD),\n );\n }\n });\n\n return filteredDiags;\n },\n );\n }\n}\n","import {\n CompletionItemKind,\n DiagnosticSeverity,\n} from \"vscode-languageserver-types\";\nimport type { PlayerLanguageService, PlayerLanguageServicePlugin } from \"..\";\nimport type { ASTNode, FlowASTNode } from \"../parser\";\nimport { isFlowNode, isPropertyNode, isStateNode } from \"../parser\";\nimport type { ASTVisitor, ValidationContext } from \"../types\";\nimport type { PropertyASTNode } from \"..\";\nimport { getLSLocationOfNode, isValueCompletion } from \"../utils\";\n\n/** Create a validation visitor for dealing with transition states */\nconst createValidationVisitor = (ctx: ValidationContext): ASTVisitor => {\n const validTransitions = new Map<string, Set<string>>();\n\n return {\n FlowNode: (flowNode) => {\n const flowNodeId = (flowNode.parent as PropertyASTNode)?.keyNode.value;\n\n flowNode.states.forEach((p) => {\n if (!validTransitions.has(flowNodeId)) {\n validTransitions.set(flowNodeId, new Set());\n }\n\n validTransitions.get(flowNodeId)?.add(p.keyNode.value);\n });\n },\n\n FlowStateNode: (flowState) => {\n const transitions = flowState.properties.find(\n (p) => p.keyNode.value === \"transitions\",\n );\n\n let flowNode = flowState.parent;\n while (flowNode && !isFlowNode(flowNode)) {\n flowNode = flowNode?.parent;\n }\n\n const flowNodeId = (flowNode?.parent as PropertyASTNode)?.keyNode.value;\n\n transitions?.valueNode?.children?.forEach((transitionObjects) => {\n if (\n transitionObjects.type === \"property\" &&\n transitionObjects.valueNode?.type === \"string\"\n ) {\n // Validate that the target is valid\n\n if (\n !validTransitions\n .get(flowNodeId)\n ?.has(transitionObjects.valueNode.value)\n ) {\n ctx.addViolation({\n node: transitionObjects.valueNode,\n severity: DiagnosticSeverity.Error,\n message: `Node \"${transitionObjects.valueNode.value}\" not found`,\n });\n }\n }\n });\n },\n };\n};\n\n/** Check that the node is a string completion of a transition state */\nconst isTransitionValue = (node: ASTNode): boolean => {\n return (\n node.type === \"string\" &&\n isPropertyNode(node.parent) &&\n node.parent.parent?.type === \"object\" &&\n isPropertyNode(node.parent.parent.parent) &&\n node.parent.parent.parent.keyNode.value === \"transitions\" &&\n isStateNode(node.parent.parent.parent.parent) &&\n isPropertyNode(node.parent.parent.parent.parent.parent) &&\n isFlowNode(node.parent.parent.parent.parent.parent.parent)\n );\n};\n\n/** Find the first parent flow node */\nconst getFlowNode = (node: ASTNode): FlowASTNode | undefined => {\n if (isFlowNode(node)) {\n return node;\n }\n\n if (node.parent) {\n return getFlowNode(node.parent);\n }\n};\n\n/**\n * Handles everything associated with navigation nodes (transitions, jump-to-def, reachability)\n */\nexport class NavStatePlugin implements PlayerLanguageServicePlugin {\n name = \"nav-state\";\n\n apply(service: PlayerLanguageService): void {\n service.hooks.validate.tap(this.name, async (ctx, validation) => {\n validation.useASTVisitor(createValidationVisitor(validation));\n });\n\n service.hooks.complete.tap(this.name, async (ctx, completionCtx) => {\n // auto-complete any transition nodes\n\n if (!isValueCompletion(ctx.node)) {\n return;\n }\n\n if (isTransitionValue(ctx.node)) {\n const flowNode = getFlowNode(ctx.node);\n\n flowNode?.states.forEach((p) => {\n completionCtx.addCompletionItem({\n kind: CompletionItemKind.Value,\n label: p.keyNode.value,\n });\n });\n }\n });\n\n service.hooks.definition.tap(this.name, (ctx) => {\n if (!isValueCompletion(ctx.node)) {\n return;\n }\n\n if (ctx.node.type === \"string\" && isTransitionValue(ctx.node)) {\n const flowNode = getFlowNode(ctx.node);\n const { value } = ctx.node;\n\n const flowProp = flowNode?.states.find(\n (n) => n.keyNode.value === value,\n );\n\n if (flowProp) {\n return getLSLocationOfNode(ctx.document, flowProp.keyNode);\n }\n }\n });\n }\n}\n","import {\n CompletionItemKind,\n DiagnosticSeverity,\n} from \"vscode-languageserver-types\";\nimport type { PlayerLanguageService, PlayerLanguageServicePlugin } from \"..\";\nimport type { PropertyASTNode, StringASTNode } from \"../parser\";\nimport { isPropertyNode, isStateNode, isViewNode } from \"../parser\";\nimport type { ASTVisitor, DocumentContext, ValidationContext } from \"../types\";\nimport { getLSLocationOfNode, getProperty, isValueCompletion } from \"../utils\";\n\ninterface DocumentViewInfo {\n /** list of views */\n views: Map<\n string,\n {\n /** view id */\n id: string;\n\n /** view id prop */\n idProp: PropertyASTNode<StringASTNode>;\n }\n >;\n\n /** list of view nodes */\n nodes: Map<\n string,\n {\n /** id of the view */\n id: string;\n\n /** view ref */\n refProp: PropertyASTNode<StringASTNode>;\n }\n >;\n}\n\n/** create a visitor to handle view nodes */\nconst createValidationVisitor = (\n ctx: ValidationContext,\n viewInfo: DocumentViewInfo,\n): ASTVisitor => {\n return {\n FlowStateNode: (flowState) => {\n if (flowState.stateType?.valueNode?.value === \"VIEW\") {\n const refNode = getProperty(flowState, \"ref\");\n if (!refNode || refNode.valueNode?.type !== \"string\") {\n return;\n }\n\n const refID = refNode.valueNode.value;\n\n if (viewInfo.views.has(refID)) {\n return;\n }\n\n ctx.addViolation({\n node: refNode.valueNode,\n message: `View with id: ${refID} does not exist.`,\n severity: DiagnosticSeverity.Error,\n });\n }\n },\n ViewNode: (viewNode) => {\n if (viewNode.id && viewNode.id.valueNode?.value !== undefined) {\n if (!viewInfo.nodes.get(viewNode.id.valueNode?.value)) {\n ctx.addViolation({\n node: viewNode.id.valueNode,\n message: `View is not reachable`,\n severity: DiagnosticSeverity.Warning,\n });\n }\n }\n },\n };\n};\n\n/** get the info for a given view */\nconst getViewInfo = (ctx: DocumentContext): DocumentViewInfo => {\n const views = new Map<\n string,\n {\n /** view id */\n id: string;\n\n /** view id prop */\n idProp: PropertyASTNode<StringASTNode>;\n }\n >();\n\n const nodes = new Map<\n string,\n {\n /** id of the view */\n id: string;\n\n /** view ref */\n refProp: PropertyASTNode<StringASTNode>;\n }\n >();\n\n // Go through the views array and fetch the ID\n\n const { root } = ctx.PlayerContent;\n\n if (root.type === \"content\") {\n root.views?.valueNode?.children.forEach((c) => {\n if (isViewNode(c) && c.id?.valueNode) {\n views.set(c.id.valueNode.value, {\n id: c.id.valueNode.value,\n idProp: c.id,\n });\n }\n });\n\n root.navigation?.valueNode?.flows.forEach((flow) => {\n flow.valueNode?.states?.forEach((state) => {\n if (state.valueNode?.stateType?.valueNode?.value === \"VIEW\") {\n const ref = state.valueNode.properties.find(\n (p) => p.keyNode.value === \"ref\",\n );\n if (ref?.valueNode?.type === \"string\") {\n const refVal = ref.valueNode.value;\n nodes.set(refVal, {\n id: refVal,\n refProp: ref as PropertyASTNode<StringASTNode>,\n });\n }\n }\n });\n });\n }\n\n return {\n views,\n nodes,\n };\n};\n\n/**\n * Handles everything associated with the VIEW node type (definition, validation, auto-complete)\n */\nexport class ViewNodePlugin implements PlayerLanguageServicePlugin {\n name = \"view-node\";\n\n apply(service: PlayerLanguageService): void {\n let viewInfo: DocumentViewInfo | undefined;\n\n service.hooks.validate.tap(this.name, async (ctx, validation) => {\n if (!viewInfo) {\n return;\n }\n\n validation.useASTVisitor(createValidationVisitor(validation, viewInfo));\n });\n\n service.hooks.onDocumentUpdate.tap(this.name, (ctx) => {\n // Update the parsing for the locations of view info across the document\n viewInfo = getViewInfo(ctx);\n });\n\n service.hooks.complete.tap(this.name, async (ctx, completionCtx) => {\n // Auto-complete ViewNode refs and view-ids based on the document\n\n if (!isValueCompletion(ctx.node)) {\n return;\n }\n\n if (\n ctx.node.type === \"string\" &&\n isPropertyNode(ctx.node.parent) &&\n isStateNode(ctx.node.parent.parent) &&\n ctx.node.parent.keyNode.value === \"ref\"\n ) {\n Array.from(viewInfo?.views.keys() ?? []).forEach((vID) => {\n completionCtx.addCompletionItem({\n kind: CompletionItemKind.Value,\n label: vID,\n });\n });\n } else if (\n ctx.node.type === \"string\" &&\n isPropertyNode(ctx.node.parent) &&\n isViewNode(ctx.node.parent.parent) &&\n ctx.node.parent.keyNode.value === \"id\"\n ) {\n Array.from(viewInfo?.nodes.keys() ?? []).forEach((vID) => {\n completionCtx.addCompletionItem({\n kind: CompletionItemKind.Value,\n label: vID,\n });\n });\n }\n });\n\n service.hooks.definition.tap(this.name, (ctx) => {\n // Jump between view-refs and ViewNode's\n\n if (!isValueCompletion(ctx.node)) {\n return;\n }\n\n if (ctx.node.type === \"string\" && isPropertyNode(ctx.node.parent)) {\n if (\n isViewNode(ctx.node.parent.parent) &&\n ctx.node.parent.keyNode.value === \"id\"\n ) {\n const { value } = ctx.node;\n const stateNode = viewInfo?.nodes.get(value);\n if (stateNode) {\n return getLSLocationOfNode(ctx.document, stateNode.refProp);\n }\n } else if (\n isStateNode(ctx.node.parent.parent) &&\n ctx.node.parent.keyNode.value === \"ref\"\n ) {\n const { value } = ctx.node;\n const viewNode = viewInfo?.views.get(value);\n if (viewNode) {\n return getLSLocationOfNode(ctx.document, viewNode.idProp);\n }\n }\n }\n });\n }\n}\n","import type {\n ArrayType,\n OrType,\n RefType,\n TransformFunction,\n} from \"@xlr-lib/xlr\";\nimport { simpleTransformGenerator } from \"@xlr-lib/xlr-sdk\";\nimport { isPrimitiveTypeNode } from \"@xlr-lib/xlr-utils\";\n\n/**\n * Adds applicability and _comment properties to Assets\n */\n\nexport const applyCommonProps: TransformFunction = (node, capability) => {\n return simpleTransformGenerator(\"object\", [\"Assets\", \"Views\"], (xlrNode) => {\n if (!xlrNode.properties.applicability) {\n xlrNode.properties.applicability = {\n required: false,\n node: {\n type: \"or\",\n name: \"Applicability\",\n description:\n \"Evaluate the given expression (or boolean) and if falsy, remove this node from the tree. This is re-computed for each change in the data-model\",\n or: [\n {\n type: \"boolean\",\n },\n {\n type: \"ref\",\n ref: \"Expression\",\n },\n ],\n },\n };\n }\n\n if (!xlrNode.properties._comment) {\n xlrNode.properties._comment = {\n required: false,\n node: {\n description: \"Adds a comment for the given node\",\n type: \"string\",\n },\n };\n }\n\n return xlrNode;\n })(node, capability);\n};\n\n/**\n * Replaces AssetWrapper References with AssetWrapperOrSwitch\n */\nexport const applyAssetWrapperOrSwitch: TransformFunction = (\n node,\n capability,\n) => {\n return simpleTransformGenerator(\"ref\", [\"Assets\", \"Views\"], (xlrNode) => {\n if (xlrNode.ref.includes(\"AssetWrapper\")) {\n return {\n ...xlrNode,\n ref: xlrNode.ref.replace(\"AssetWrapper\", \"AssetWrapperOrSwitch\"),\n };\n }\n\n return xlrNode;\n })(node, capability);\n};\n\n/**\n * Modifies any primitive type property node (except id/type) to be Bindings or Expressions\n */\nexport const applyValueRefs: TransformFunction = (node, capability) => {\n return simpleTransformGenerator(\n \"object\",\n [\"Assets\", \"Views\"],\n (inputNode) => {\n const xlrNode = { ...inputNode };\n for (const key in xlrNode.properties) {\n if (key === \"id\") {\n continue;\n }\n\n const value = xlrNode.properties[key];\n if (value.node.type === \"or\") {\n value.node.or.push({\n type: \"ref\",\n ref: \"ExpressionRef\",\n });\n value.node.or.push({\n type: \"ref\",\n ref: \"BindingRef\",\n });\n } else if (isPrimitiveTypeNode(value.node)) {\n const newUnionType: OrType = {\n type: \"or\",\n description: value.node.description,\n or: [\n value.node,\n {\n type: \"ref\",\n ref: \"ExpressionRef\",\n },\n {\n type: \"ref\",\n ref: \"BindingRef\",\n },\n ],\n };\n value.node = newUnionType;\n }\n }\n\n return xlrNode;\n },\n )(node, capability);\n};\n\n/**\n * Computes possible template keys and adds them to an Asset\n */\nexport const applyTemplateProperty: TransformFunction = (node, capability) => {\n return simpleTransformGenerator(\n \"object\",\n [\"Assets\", \"Views\"],\n (inputNode) => {\n const templateTypes: Array<RefType> = [];\n const xlrNode = { ...inputNode };\n for (const key in xlrNode.properties) {\n const value = xlrNode.properties[key];\n if (value.node.type === \"array\") {\n value.required = false;\n templateTypes.push({\n type: \"ref\",\n ref: `Template<${\n value.node.elementType.type === \"ref\"\n ? value.node.elementType.ref\n : value.node.elementType.name\n }, \"${key}\">`,\n genericArguments: [\n value.node.elementType,\n {\n type: \"string\",\n const: key,\n },\n ],\n });\n }\n }\n\n if (templateTypes.length > 0) {\n const templateType: ArrayType = {\n type: \"array\",\n elementType:\n templateTypes.length > 1\n ? { type: \"or\", or: templateTypes }\n : templateTypes[0],\n description: \"A list of templates to process for this node\",\n };\n xlrNode.properties.template = {\n required: false,\n node: templateType,\n };\n }\n\n return xlrNode;\n },\n )(node, capability);\n};\n","import type { Filters } from \"@xlr-lib/xlr-sdk\";\nimport { TransformFunction } from \"@xlr-lib/xlr\";\n\nimport type { PlayerLanguageServicePlugin } from \".\";\nimport { AssetWrapperArrayPlugin } from \"./plugins/asset-wrapper-array-plugin\";\nimport { SchemaInfoPlugin } from \"./plugins/binding-schema-plugin\";\nimport { XLRPlugin } from \"./plugins/xlr-plugin\";\nimport { DuplicateIDPlugin } from \"./plugins/duplicate-id-plugin\";\nimport { MissingAssetWrapperPlugin } from \"./plugins/missing-asset-wrapper-plugin\";\nimport { NavStatePlugin } from \"./plugins/nav-state-plugin\";\nimport { ViewNodePlugin } from \"./plugins/view-node-plugin\";\nimport {\n applyAssetWrapperOrSwitch,\n applyCommonProps,\n applyTemplateProperty,\n applyValueRefs,\n} from \"./xlr/transforms\";\n\nexport const PLUGINS: Array<PlayerLanguageServicePlugin> = [\n new DuplicateIDPlugin(),\n new ViewNodePlugin(),\n new SchemaInfoPlugin(),\n new AssetWrapperArrayPlugin(),\n new NavStatePlugin(),\n new MissingAssetWrapperPlugin(),\n new XLRPlugin(),\n];\n\nexport const DEFAULT_FILTERS: Filters = {\n typeFilter: \"Transformed\",\n};\n\nexport const TRANSFORM_FUNCTIONS: Array<TransformFunction> = [\n applyAssetWrapperOrSwitch,\n applyValueRefs,\n applyCommonProps,\n applyTemplateProperty,\n];\n","import type { Filters, TypeMetadata } from \"@xlr-lib/xlr-sdk\";\nimport { BasicXLRRegistry } from \"@xlr-lib/xlr-sdk\";\nimport type { NamedType, NodeType } from \"@xlr-lib/xlr\";\n\n/**\n * Player specific implementation of a XLRs Registry\n */\nexport class PlayerXLRRegistry extends BasicXLRRegistry {\n /** Keeps the mapping of how a type is referenced by Player to the underlying XLR */\n private registrationMap: Map<string, string | Array<string>>;\n\n constructor() {\n super();\n this.registrationMap = new Map();\n }\n\n get(id: string): NamedType<NodeType> | undefined {\n const realNames = this.registrationMap.get(id);\n if (realNames === undefined) {\n return undefined;\n }\n\n if (Array.isArray(realNames)) {\n return {\n name: `${id}PartialMatchType`,\n source: \"registry.ts\",\n type: \"or\",\n or: realNames.map(\n (partialMatchID) => super.get(partialMatchID) as NamedType,\n ),\n };\n }\n\n return super.get(realNames);\n }\n\n add(type: NamedType<NodeType>, plugin: string, capability: string): void {\n let registeredName = type.name;\n // Figure out how the Asset/View will be referenced from the type argument that will fill in Asset\n if (\n (capability === \"Assets\" || capability === \"Views\") &&\n type.type === \"object\" &&\n type.extends?.genericArguments?.[0]?.type === \"string\" &&\n type.extends?.genericArguments?.[0]?.const\n ) {\n this.registrationMap.set(registeredName, type.name);\n registeredName = type.extends.genericArguments[0].const;\n }\n\n if (this.registrationMap.has(registeredName)) {\n const current = this.registrationMap.get(registeredName) as\n | string\n | string[];\n if (Array.isArray(current)) {\n current.push(registeredName);\n } else {\n this.registrationMap.set(registeredName, [current, type.name]);\n }\n } else {\n this.registrationMap.set(registeredName, type.name);\n }\n\n super.add(type, plugin, capability);\n }\n\n has(id: string): boolean {\n return this.registrationMap.has(id);\n }\n\n list(filterArgs?: Filters): NamedType<NodeType>[] {\n return super.list(filterArgs);\n }\n\n info(id: string): TypeMetadata | undefined {\n const realNames = this.registrationMap.get(id);\n if (realNames === undefined) {\n return undefined;\n }\n\n if (Array.isArray(realNames)) {\n const metaDataArrays = realNames.map((name) => super.info(name));\n const firstElement = metaDataArrays[0];\n const equal = metaDataArrays.every(\n (metaData) =>\n metaData?.plugin === firstElement?.plugin &&\n metaData?.capability === firstElement?.capability,\n );\n if (equal) {\n return firstElement;\n }\n\n throw Error(\n `Error: can't determine accurate info for type ${id} as it is provided by multiple plugins/capabilities`,\n );\n }\n\n return super.info(realNames);\n }\n}\n","import { XLRSDK } from \"@xlr-lib/xlr-sdk\";\nimport type { ArrayType, NodeType, ObjectType } from \"@xlr-lib/xlr\";\nimport type { ASTNode } from \"../parser\";\nimport { mapFlowStateToType } from \"../utils\";\nimport { PlayerXLRRegistry } from \"./registry\";\n\nexport interface XLRContext {\n /** The name of the XLR at the provided position */\n name: string;\n\n /** The position(s) in the XLR at the specified node */\n nodes: Array<NodeType>;\n\n /** The nearest objects(s) to the specified node */\n nearestObjects: Array<ObjectType>;\n}\n\n/**\n * XLRs Manager for\n */\nexport class XLRService {\n private baseTypes = [\n \"asset\",\n \"view\",\n \"flow\",\n \"content\",\n \"navigation\",\n \"state\",\n ];\n\n public XLRSDK: XLRSDK;\n\n constructor() {\n this.XLRSDK = new XLRSDK(new PlayerXLRRegistry());\n }\n\n private walker(\n n: ASTNode,\n path: ASTNode[],\n ):\n | {\n /** name of type */\n name: string;\n\n /** path to get there from n */\n path: ASTNode[];\n }\n | undefined {\n if (this.baseTypes.indexOf(n.type) > -1) {\n if (n.type === \"asset\") {\n const name = this.XLRSDK.hasType(n.assetType?.valueNode?.value ?? \"\")\n ? (n.assetType?.valueNode?.value as string)\n : \"Asset\";\n return {\n name,\n path,\n };\n }\n\n if (n.type === \"view\") {\n const name = this.XLRSDK.hasType(n.viewType?.valueNode?.value ?? \"\")\n ? (n.viewType?.valueNode?.value as string)\n : \"View\";\n return { name, path };\n }\n\n if (n.type === \"state\") {\n if (n.stateType?.valueNode?.value) {\n const flowStateType = mapFlowStateToType(\n n.stateType?.valueNode?.value,\n );\n if (flowStateType) {\n return { name: flowStateType, path };\n }\n }\n }\n\n if (n.type === \"content\") {\n return { name: \"Flow\", path };\n }\n\n if (n.type === \"flow\") {\n return { name: \"NavigationFlow\", path };\n }\n\n if (n.type === \"navigation\") {\n return { name: \"Navigation\", path };\n }\n }\n\n if (n.parent) {\n path.push(n.parent);\n return this.walker(n.parent, path);\n }\n\n return undefined;\n }\n\n public getTypeInfoAtPosition(\n node: ASTNode | undefined,\n ): XLRContext | undefined {\n if (!node) return;\n\n const pointer = node;\n const xlrInfo = this.walker(pointer, []);\n\n // bail if we can\"t figure out the type or don\"t have it\n if (!xlrInfo) return;\n\n const activeNode = this.XLRSDK.getType(xlrInfo.name);\n if (!activeNode) return;\n\n let nearestObjectTypes = [activeNode as ObjectType];\n let pointers = [];\n\n if (activeNode.type === \"and\") {\n pointers = activeNode.and;\n } else if (activeNode.type === \"or\") {\n pointers = activeNode.or;\n } else {\n pointers = [activeNode];\n }\n\n for (const pathSegment of xlrInfo.path.reverse()) {\n const newPointers: NodeType[] = [];\n\n for (let nodePointer of pointers) {\n let newNode;\n\n if (nodePointer.type === \"ref\") {\n if (this.XLRSDK.hasType(nodePointer.ref)) {\n nodePointer = this.XLRSDK.getType(nodePointer.ref) as ObjectType;\n } else {\n continue;\n }\n }\n\n if (pathSegment.type === \"property\" && nodePointer.type === \"object\") {\n if (nodePointer?.properties[pathSegment.keyNode.value]) {\n newNode = nodePointer?.properties[pathSegment.keyNode.value]?.node;\n } else if (nodePointer?.additionalProperties) {\n // search through additional properties types\n const adNode = nodePointer?.additionalProperties;\n if (typeof adNode !== \"boolean\") {\n newNode = adNode;\n }\n }\n } else if (\n pathSegment.type === \"object\" ||\n this.baseTypes.indexOf(pathSegment.type) !== -1\n ) {\n newNode = nodePointer;\n } else if (pathSegment.type === \"array\") {\n newNode = (nodePointer as ArrayType).elementType;\n }\n\n if (!newNode) {\n continue;\n } else if (newNode.type === \"or\") {\n newPointers.push(...newNode.or);\n } else if (newNode.type === \"and\") {\n newPointers.push(...newNode.and);\n } else if (newNode.type === \"ref\" && this.XLRSDK.hasType(newNode.ref)) {\n newPointers.push(this.XLRSDK.getType(newNode.ref) as ObjectType);\n } else {\n newPointers.push(newNode);\n }\n }\n\n if (newPointers.filter((n) => n).length === 0) {\n break;\n }\n\n const newObjectTypes = newPointers.filter(\n (n) => n.type === \"object\",\n ) as ObjectType[];\n if (newObjectTypes.length > 0) {\n nearestObjectTypes = newObjectTypes;\n }\n\n pointers = newPointers;\n }\n\n return {\n name: xlrInfo.name,\n nodes: pointers,\n nearestObjects: nearestObjectTypes,\n };\n }\n}\n","import type { TextDocument } from \"vscode-languageserver-textdocument\";\nimport type {\n Position,\n DiagnosticSeverity,\n Diagnostic,\n CompletionItem,\n} from \"vscode-languageserver-types\";\nimport type {\n ASTNode,\n PlayerContent,\n StringASTNode,\n NumberASTNode,\n ArrayASTNode,\n BooleanASTNode,\n PropertyASTNode,\n ObjectASTNode,\n ViewASTNode,\n ContentASTNode,\n NullASTNode,\n AssetASTNode,\n FlowStateASTNode,\n NavigationASTNode,\n FlowASTNode,\n NodeEdit,\n EmptyASTNode,\n} from \"./parser\";\nimport type { XLRContext } from \"./xlr\";\n\nexport type LogFn = (msg: string) => void;\nexport const LOG_TYPES = [\"debug\", \"info\", \"warn\", \"error\"] as const;\nexport type LogType = (typeof LOG_TYPES)[number];\nexport type Logger = Record<LogType, LogFn>;\n\nexport interface DocumentContext {\n /** A logger to log messages */\n log: Logger;\n\n /** the underlying text document */\n document: TextDocument;\n\n /** the json parsed text document */\n PlayerContent: PlayerContent;\n}\n\nexport interface DocumentContextWithPosition extends DocumentContext {\n /** the position we care about */\n position: Position;\n\n /** the node at that position */\n node: ASTNode;\n}\n\nexport interface EnhancedDocumentContextWithPosition extends DocumentContextWithPosition {\n /** the XLRs context */\n XLR?: XLRContext;\n}\n\nexport type ASTVisitorFn<T extends ASTNode> = (node: T) => void;\n\nexport interface ASTVisitor {\n /** a string node visitor */\n StringNode?: ASTVisitorFn<StringASTNode>;\n /** a number node visitor */\n NumberNode?: ASTVisitorFn<NumberASTNode>;\n /** an boolean node visitor */\n BooleanNode?: ASTVisitorFn<BooleanASTNode>;\n /** an array node visitor */\n ArrayNode?: ASTVisitorFn<ArrayASTNode>;\n /** a null node visitor */\n NullNode?: ASTVisitorFn<NullASTNode>;\n /** an empty node visitor */\n EmptyNode?: ASTVisitorFn<EmptyASTNode>;\n /** a property node visitor */\n PropertyNode?: ASTVisitorFn<PropertyASTNode>;\n /** an object node visitor */\n ObjectNode?: ASTVisitorFn<ObjectASTNode>;\n /** an asset node visitor */\n AssetNode?: ASTVisitorFn<AssetASTNode>;\n /** a view node visitor */\n ViewNode?: ASTVisitorFn<ViewASTNode>;\n /** a flow node visitor */\n ContentNode?: ASTVisitorFn<ContentASTNode>;\n /** a navigation node visitor */\n NavigationNode?: ASTVisitorFn<NavigationASTNode>;\n /** a flow node visitor */\n FlowNode?: ASTVisitorFn<FlowASTNode>;\n /** a flow state node visitor */\n FlowStateNode?: ASTVisitorFn<FlowStateASTNode>;\n}\n\nexport interface Violation {\n /** the node the violation is for */\n node: ASTNode;\n\n /** the message to show */\n message: string;\n\n /** how much do we care? */\n severity: DiagnosticSeverity;\n\n /** A function that can make this good */\n fix?: () => {\n /** the edit to apply */\n edit: NodeEdit;\n\n /** A name for your fix */\n name: string;\n };\n}\n\nexport interface ValidationContext {\n addViolation(violation: Violation): void;\n addDiagnostic(diagnostic: Diagnostic): void;\n useASTVisitor(visitor: ASTVisitor): void;\n}\n\nexport interface CompletionContext {\n addCompletionItem(item: CompletionItem): void;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,IAAAA,uBAAqC;AAErC,wBAKO;AAWP,IAAAC,uCAKO;;;AC1BP,IAAAC,sCAAmC;;;ACAnC,IAAAC,uBAAiD;;;ACa1C,SAAS,eAAe,MAAyC;AACtE,SAAO,MAAM,SAAS;AACxB;AAGO,SAAS,aAAa,MAAuC;AAClE,SAAO,MAAM,SAAS;AACxB;AAGO,SAAS,UAAU,MAAuC;AAC/D,SAAO,eAAe,MAAM,MAAM,KAAK,MAAM,OAAO,YAAY;AAClE;AAGO,SAAS,YAAY,MAAyB;AACnD,SAAO,eAAe,MAAM,MAAM,KAAK,MAAM,OAAO,cAAc;AACpE;AAGO,SAAS,WAAW,MAAqC;AAC9D,SAAO,MAAM,SAAS;AACxB;AA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AQ;AAAA,MACZ,SAAS,IAAI,CAAC,MAAM;AAClB,YAAI,EAAE,aAAa,OAAO,GAAG,QAAQ;AACnC,iBAAO,KAAK,WAAW,OAAO,0BAA0B,CAAC;AAAA,QAC3D,OAAO;AACL,iBAAO,KAAK,WAAW,OAAO;AAAA,YAC5B;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["import_jsonc_parser","import_vscode_languageserver_types","import_vscode_languageserver_types","import_jsonc_parser","import_jsonc_parser","ObjType","import_vscode_languageserver_types","getJSONNodeValue","import_vscode_languageserver_types","detectIndent","import_vscode_languageserver_types","import_vscode_languageserver_types","import_vscode_languageserver_types","createValidationVisitor","import_vscode_languageserver_types","import_vscode_languageserver_types","createValidationVisitor","import_vscode_languageserver_types","createValidationVisitor","import_xlr_sdk","import_xlr_sdk","PlayerContent","formatJSON"]}
|