@player-tools/typescript-expression-plugin 0.5.3-next.0 → 0.6.0-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 +8 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +8 -1
- package/dist/index.mjs +8 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -136,8 +136,11 @@ var toFunction = (0, import_xlr_sdk.simpleTransformGenerator)(
|
|
|
136
136
|
|
|
137
137
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/service.ts
|
|
138
138
|
var ExpressionLanguageService = class {
|
|
139
|
+
logger;
|
|
140
|
+
_plugins = [];
|
|
141
|
+
_expressions;
|
|
142
|
+
xlr;
|
|
139
143
|
constructor(options) {
|
|
140
|
-
this._plugins = [];
|
|
141
144
|
this.logger = options?.logger;
|
|
142
145
|
this._plugins = options?.plugins ?? [];
|
|
143
146
|
this.xlr = new import_xlr_sdk2.XLRSDK();
|
|
@@ -348,6 +351,7 @@ var ExpressionLanguageService = class {
|
|
|
348
351
|
|
|
349
352
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/logger.ts
|
|
350
353
|
var LSPLogger = class {
|
|
354
|
+
info;
|
|
351
355
|
constructor(info) {
|
|
352
356
|
this.info = info;
|
|
353
357
|
}
|
|
@@ -358,6 +362,9 @@ var LSPLogger = class {
|
|
|
358
362
|
|
|
359
363
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/index.ts
|
|
360
364
|
var Plugin = class {
|
|
365
|
+
initOptions;
|
|
366
|
+
logger;
|
|
367
|
+
templateService;
|
|
361
368
|
constructor(initOptions) {
|
|
362
369
|
this.initOptions = initOptions;
|
|
363
370
|
}
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/service.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/utils.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/transforms.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/logger.ts"],"sourcesContent":["import ts from \"typescript/lib/tsserverlibrary\";\nimport { decorateWithTemplateLanguageService } from \"typescript-template-language-service-decorator\";\nimport { ExpressionLanguageService } from \"./service\";\nimport { LSPLogger } from \"./logger\";\n\ninterface InitParams {\n typescript: typeof ts;\n}\nclass Plugin implements ts.server.PluginModule {\n private readonly initOptions: InitParams;\n private logger?: LSPLogger;\n private templateService?: ExpressionLanguageService;\n\n constructor(initOptions: InitParams) {\n this.initOptions = initOptions;\n }\n\n create(info: ts.server.PluginCreateInfo): ts.LanguageService {\n const logger = new LSPLogger(info);\n this.logger = logger;\n\n const templateService = new ExpressionLanguageService({ logger });\n this.templateService = templateService;\n\n return decorateWithTemplateLanguageService(\n this.initOptions.typescript,\n info.languageService,\n info.project,\n templateService,\n {\n tags: [\"e\", \"expr\", \"expression\"],\n enableForStringWithSubstitutions: true,\n },\n { logger }\n );\n }\n\n onConfigurationChanged(config: any) {\n this.templateService?.setConfig(config);\n }\n}\n\nfunction init(mod: InitParams): ts.server.PluginModule {\n return new Plugin(mod);\n}\n\nexport default init;\n// export = init;\n","import ts from \"typescript/lib/tsserverlibrary\";\nimport type {\n TemplateLanguageService,\n TemplateContext,\n Logger,\n} from \"typescript-template-language-service-decorator\";\nimport type { FunctionType, TSManifest, NodeType } from \"@player-tools/xlr\";\nimport { createTSDocString } from \"@player-tools/xlr-utils\";\nimport { XLRSDK } from \"@player-tools/xlr-sdk\";\nimport type { ExpressionNode } from \"@player-ui/player\";\nimport { parseExpression } from \"@player-ui/player\";\nimport {\n getTokenAtPosition,\n toTSLocation,\n convertExprToJSONNode,\n} from \"./utils\";\nimport { toFunction } from \"./transforms\";\n\ninterface ExpressionEntry {\n /**\n * The name of the expression\n */\n name: string;\n /**\n * The description of the expression\n */\n description?: string;\n /**\n * The XLR type of the expression\n */\n type: FunctionType;\n /**\n * The XLR enabled plugin the expression was sourced from\n */\n source: TSManifest;\n}\n\nexport interface ExpressionLanguageServiceConfig {\n /**\n * The list of XLR enabled plugins to load\n */\n plugins: Array<TSManifest>;\n}\n\n/**\n * Language server to check Player expression syntax and usage\n */\nexport class ExpressionLanguageService implements TemplateLanguageService {\n private logger?: Logger;\n private _plugins: Array<TSManifest> = [];\n private _expressions: Map<string, ExpressionEntry>;\n private xlr: XLRSDK;\n\n constructor(\n options?: { logger?: Logger } & Partial<ExpressionLanguageServiceConfig>\n ) {\n this.logger = options?.logger;\n this._plugins = options?.plugins ?? [];\n this.xlr = new XLRSDK();\n\n this._plugins.forEach((p) => {\n this.xlr.loadDefinitionsFromModule(p, undefined, [toFunction]);\n });\n this._expressions = this.reduceExpression();\n }\n\n setConfig(config: ExpressionLanguageServiceConfig) {\n this._plugins = config.plugins;\n this.xlr = new XLRSDK();\n\n this._plugins.forEach((p) => {\n this.xlr.loadDefinitionsFromModule(p, undefined, [toFunction]);\n });\n this._expressions = this.reduceExpression();\n }\n\n private reduceExpression(): Map<string, ExpressionEntry> {\n // Overlaps in names will be resolved by the last plugin to be loaded\n // So use a map to ensure no duplicates\n const expressions = new Map<string, ExpressionEntry>();\n\n this.xlr.listTypes().forEach((type) => {\n const typeInfo = this.xlr.getTypeInfo(type.name);\n const source = this._plugins.find(\n (value) => value.pluginName === typeInfo?.plugin\n );\n\n if (\n type.type === \"function\" &&\n typeInfo?.capability === \"Expressions\" &&\n source\n ) {\n expressions.set(type.name, {\n name: type.name,\n description: type.description,\n type: type as FunctionType,\n source,\n });\n }\n });\n\n return expressions;\n }\n\n getCompletionsAtPosition(\n context: TemplateContext,\n position: ts.LineAndCharacter\n ): ts.CompletionInfo {\n const completionInfo: ts.CompletionInfo = {\n isGlobalCompletion: false,\n isMemberCompletion: false,\n isNewIdentifierLocation: true,\n entries: [],\n };\n\n if (context.text.length === 0) {\n // This happens for the start of an expression (e``)\n // Provide all the completions in this case\n\n this._expressions.forEach((exp) => {\n completionInfo.entries.push({\n name: exp.name,\n kind: ts.ScriptElementKind.functionElement,\n sortText: exp.name,\n isRecommended: true,\n insertText: `${exp.name}()`,\n });\n });\n\n return completionInfo;\n }\n\n const line = context.text.split(/\\n/g)[position.line];\n const parsed = parseExpression(line, { strict: false });\n const token = getTokenAtPosition(parsed, position);\n\n if (token?.type === \"Compound\" && token.error) {\n // We hit the end of the expression, and it's expecting more\n // so provide all the completions\n this._expressions.forEach((exp) => {\n completionInfo.entries.push({\n name: exp.name,\n kind: ts.ScriptElementKind.functionElement,\n sortText: exp.name,\n isRecommended: true,\n insertText: `${exp.name}()`,\n });\n });\n\n return completionInfo;\n }\n\n if (token?.type === \"Identifier\") {\n // get the relevant start of the identifier\n const start = token.location?.start ?? { character: 0 };\n const wordFromStart = line.slice(start.character, position.character);\n const allCompletions = Array.from(this._expressions.keys()).filter(\n (key) => key.startsWith(wordFromStart)\n );\n\n allCompletions.forEach((c) => {\n completionInfo.entries.push({\n name: c,\n kind: ts.ScriptElementKind.functionElement,\n sortText: c,\n isRecommended: true,\n insertText: `${c}()`,\n });\n });\n }\n\n return completionInfo;\n }\n\n getCompletionEntryDetails(\n context: TemplateContext,\n position: ts.LineAndCharacter,\n name: string\n ): ts.CompletionEntryDetails {\n const expression = this._expressions.get(name);\n\n const completionDetails: ts.CompletionEntryDetails = {\n name,\n kind: ts.ScriptElementKind.functionElement,\n kindModifiers: ts.ScriptElementKindModifier.none,\n\n documentation: [\n {\n kind: \"text\",\n text: expression?.type.description ?? \"\",\n },\n ],\n displayParts: expression ? createTSDocString(expression.type) : [],\n };\n\n return completionDetails;\n }\n\n getQuickInfoAtPosition(\n context: TemplateContext,\n position: ts.LineAndCharacter\n ): ts.QuickInfo | undefined {\n const parsed = parseExpression(context.text, { strict: false });\n const token = getTokenAtPosition(parsed, position);\n\n if (token?.type === \"Identifier\") {\n const expression = this._expressions.get(token.name);\n\n if (expression) {\n const completionDetails = this.getCompletionEntryDetails(\n context,\n position,\n expression.name\n );\n\n return {\n ...completionDetails,\n textSpan: toTSLocation(token),\n };\n }\n }\n\n return undefined;\n }\n\n private checkNode(\n context: TemplateContext,\n node: ExpressionNode,\n xlrType: NodeType\n ): ts.Diagnostic[] {\n const diagnostics: ts.Diagnostic[] = [];\n const asJsonNodeValue = convertExprToJSONNode(node);\n\n if (asJsonNodeValue) {\n const xlrDiags = this.xlr.validateByType(xlrType, asJsonNodeValue);\n\n xlrDiags.forEach((d) => {\n diagnostics.push({\n file: context.node.getSourceFile(),\n ...toTSLocation(node),\n messageText: d.message,\n category: ts.DiagnosticCategory.Error,\n code: 1,\n });\n });\n }\n\n return diagnostics;\n }\n\n private getDiagnosticsForNode(\n context: TemplateContext,\n node: ExpressionNode\n ): ts.Diagnostic[] {\n const diags: ts.Diagnostic[] = [];\n\n if (node.type === \"Compound\") {\n node.body.forEach((n) => {\n diags.push(...this.getDiagnosticsForNode(context, n));\n });\n }\n\n if (node.type === \"CallExpression\") {\n // Check that the expression is valid\n const exprName = node.callTarget.name;\n const expression = this._expressions.get(exprName);\n\n node.args.forEach((n) => {\n diags.push(...this.getDiagnosticsForNode(context, n));\n });\n\n if (expression) {\n // Double check the arguments match what we expect\n const expectedArgs = expression.type.parameters;\n const actualArgs = node.args;\n\n actualArgs.forEach((actualArg, index) => {\n const expectedArg = expectedArgs[index];\n\n if (expectedArg) {\n // Check that the type satisfies the expected type\n diags.push(...this.checkNode(context, actualArg, expectedArg.type));\n }\n });\n\n if (expectedArgs.length > actualArgs.length) {\n const requiredArgs = expectedArgs.filter((a) => !a.optional);\n if (actualArgs.length < requiredArgs.length) {\n diags.push({\n category: ts.DiagnosticCategory.Error,\n code: 1,\n file: context.node.getSourceFile(),\n ...toTSLocation(node.callTarget),\n messageText: `Expected ${requiredArgs.length} argument(s), got ${actualArgs.length}`,\n });\n }\n }\n } else {\n diags.push({\n category: ts.DiagnosticCategory.Error,\n code: 1,\n file: context.node.getSourceFile(),\n ...toTSLocation(node.callTarget),\n messageText: `Unknown expression ${exprName}`,\n });\n }\n }\n\n return diags;\n }\n\n getSemanticDiagnostics(context: TemplateContext): ts.Diagnostic[] {\n // Shortcut any type-checking if we don't have any info about what expressions are registered\n if (this._plugins.length === 0) {\n return [];\n }\n\n const parsed = parseExpression(context.text.trim(), { strict: false });\n return this.getDiagnosticsForNode(context, parsed);\n }\n\n getSyntacticDiagnostics(context: TemplateContext): ts.Diagnostic[] {\n const parsed = parseExpression(context.text.trim(), { strict: false });\n\n if (parsed.error) {\n return [\n {\n category: ts.DiagnosticCategory.Error,\n code: 1,\n file: context.node.getSourceFile(),\n ...toTSLocation(parsed),\n messageText: parsed.error.message,\n },\n ];\n }\n\n return [];\n }\n}\n","import type { TextSpan } from \"typescript\";\nimport type { Position } from \"vscode-languageserver-types\";\nimport type { ExpressionNode, NodeLocation } from \"@player-ui/player\";\nimport { parseTree } from \"jsonc-parser\";\nimport type { Node } from \"jsonc-parser\";\n\n/** Check if the vscode position overlaps with the expression location */\nexport function isInRange(position: Position, location: NodeLocation) {\n return (\n position.character >= location.start.character &&\n position.character <= location.end.character\n );\n}\n\n/** Find the closest marked token at the given position */\nexport function getTokenAtPosition(\n node: ExpressionNode,\n position: Position\n): ExpressionNode | undefined {\n if (node.type === \"CallExpression\") {\n const anyArgs = node.args.find((arg) => {\n return getTokenAtPosition(arg, position);\n });\n\n if (anyArgs) {\n return anyArgs;\n }\n\n const asTarget = getTokenAtPosition(node.callTarget, position);\n if (asTarget) {\n return asTarget;\n }\n }\n\n if (node.type === \"Assignment\") {\n const asTarget =\n getTokenAtPosition(node.left, position) ??\n getTokenAtPosition(node.right, position);\n if (asTarget) {\n return asTarget;\n }\n }\n\n // Lastly check for yourself\n if (node.location && isInRange(position, node.location)) {\n return node;\n }\n}\n\n/** Get the location info that TS expects for it's diags */\nexport function toTSLocation(node: ExpressionNode): TextSpan {\n const start = node.location?.start.character;\n const end = node.location?.end.character;\n if (start === undefined || end === undefined) {\n return {\n start: 0,\n length: 0,\n };\n }\n\n return {\n start,\n length: end - start,\n };\n}\n\n/** ExpressionNode -> raw value */\nexport function convertExprToValue(exprNode: ExpressionNode): any {\n let val;\n\n if (exprNode.type === \"Literal\") {\n val = exprNode.value;\n } else if (exprNode.type === \"Object\") {\n val = {};\n exprNode.attributes.forEach((prop) => {\n val[convertExprToValue(prop.key)] = convertExprToValue(prop.value);\n });\n } else if (exprNode.type === \"ArrayExpression\") {\n val = exprNode.elements.map(convertExprToValue);\n }\n\n return val;\n}\n\n/** ExpressionNode -> JSONC Node */\nexport function convertExprToJSONNode(\n exprNode: ExpressionNode\n): Node | undefined {\n const val = convertExprToValue(exprNode);\n if (val === undefined) {\n return undefined;\n }\n\n return parseTree(JSON.stringify(val));\n}\n","import type { FunctionType, FunctionTypeParameters } from \"@player-tools/xlr\";\nimport { simpleTransformGenerator } from \"@player-tools/xlr-sdk\";\n\nexport const toFunction = simpleTransformGenerator(\n \"ref\",\n \"Expressions\",\n (exp) => {\n if (!exp.genericArguments || exp.ref !== \"ExpressionHandler\") {\n return exp;\n }\n\n const [args, returnType] = exp.genericArguments;\n\n const parameters: Array<FunctionTypeParameters> = (\n args.type === \"tuple\" ? args.elementTypes : []\n ).map((elementType, index) => {\n return {\n name:\n elementType.name ??\n elementType.type.name ??\n elementType.type.title ??\n `arg_${index}`,\n\n type: {\n name:\n elementType.name ??\n elementType.type.name ??\n elementType.type.title ??\n `arg_${index}`,\n ...elementType.type,\n },\n optional:\n elementType.optional === true ? elementType.optional : undefined,\n };\n });\n\n return {\n ...exp,\n type: \"function\",\n parameters,\n returnType,\n } as FunctionType as any;\n }\n);\n","import type { Logger } from \"typescript-template-language-service-decorator\";\nimport ts from \"typescript/lib/tsserverlibrary\";\n\nexport class LSPLogger implements Logger {\n private readonly info: ts.server.PluginCreateInfo;\n\n constructor(info: ts.server.PluginCreateInfo) {\n this.info = info;\n }\n\n log(msg: string) {\n this.info.project.projectService.logger.info(`[player-expr-lsp] ${msg}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4DAAoD;;;ACDpD,6BAAe;AAOf,uBAAkC;AAClC,IAAAA,kBAAuB;AAEvB,oBAAgC;;;ACPhC,0BAA0B;AAInB,SAAS,UAAU,UAAoB,UAAwB;AACpE,SACE,SAAS,aAAa,SAAS,MAAM,aACrC,SAAS,aAAa,SAAS,IAAI;AAEvC;AAGO,SAAS,mBACd,MACA,UAC4B;AAC5B,MAAI,KAAK,SAAS,kBAAkB;AAClC,UAAM,UAAU,KAAK,KAAK,KAAK,CAAC,QAAQ;AACtC,aAAO,mBAAmB,KAAK,QAAQ;AAAA,IACzC,CAAC;AAED,QAAI,SAAS;AACX,aAAO;AAAA,IACT;AAEA,UAAM,WAAW,mBAAmB,KAAK,YAAY,QAAQ;AAC7D,QAAI,UAAU;AACZ,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,KAAK,SAAS,cAAc;AAC9B,UAAM,WACJ,mBAAmB,KAAK,MAAM,QAAQ,KACtC,mBAAmB,KAAK,OAAO,QAAQ;AACzC,QAAI,UAAU;AACZ,aAAO;AAAA,IACT;AAAA,EACF;AAGA,MAAI,KAAK,YAAY,UAAU,UAAU,KAAK,QAAQ,GAAG;AACvD,WAAO;AAAA,EACT;AACF;AAGO,SAAS,aAAa,MAAgC;AAC3D,QAAM,QAAQ,KAAK,UAAU,MAAM;AACnC,QAAM,MAAM,KAAK,UAAU,IAAI;AAC/B,MAAI,UAAU,UAAa,QA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AC;AAChE,SAAK,kBAAkB;AAEvB,eAAO;AAAA,MACL,KAAK,YAAY;AAAA,MACjB,KAAK;AAAA,MACL,KAAK;AAAA,MACL;AAAA,MACA;AAAA,QACE,MAAM,CAAC,KAAK,QAAQ,YAAY;AAAA,QAChC,kCAAkC;AAAA,MACpC;AAAA,MACA,EAAE,OAAO;AAAA,IACX;AAAA,EACF;AAAA,EAEA,uBAAuB,QAAa;AAClC,SAAK,iBAAiB,UAAU,MAAM;AAAA,EACxC;AACF;AAEA,SAAS,KAAK,KAAyC;AACrD,SAAO,IAAI,OAAO,GAAG;AACvB;AAEA,IAAO,cAAQ;","names":["import_xlr_sdk","ts"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/service.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/utils.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/transforms.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/logger.ts"],"sourcesContent":["import ts from \"typescript/lib/tsserverlibrary\";\nimport { decorateWithTemplateLanguageService } from \"typescript-template-language-service-decorator\";\nimport { ExpressionLanguageService } from \"./service\";\nimport { LSPLogger } from \"./logger\";\n\ninterface InitParams {\n typescript: typeof ts;\n}\nclass Plugin implements ts.server.PluginModule {\n private readonly initOptions: InitParams;\n private logger?: LSPLogger;\n private templateService?: ExpressionLanguageService;\n\n constructor(initOptions: InitParams) {\n this.initOptions = initOptions;\n }\n\n create(info: ts.server.PluginCreateInfo): ts.LanguageService {\n const logger = new LSPLogger(info);\n this.logger = logger;\n\n const templateService = new ExpressionLanguageService({ logger });\n this.templateService = templateService;\n\n return decorateWithTemplateLanguageService(\n this.initOptions.typescript,\n info.languageService,\n info.project,\n templateService,\n {\n tags: [\"e\", \"expr\", \"expression\"],\n enableForStringWithSubstitutions: true,\n },\n { logger }\n );\n }\n\n onConfigurationChanged(config: any) {\n this.templateService?.setConfig(config);\n }\n}\n\nfunction init(mod: InitParams): ts.server.PluginModule {\n return new Plugin(mod);\n}\n\nexport default init;\n// export = init;\n","import ts from \"typescript/lib/tsserverlibrary\";\nimport type {\n TemplateLanguageService,\n TemplateContext,\n Logger,\n} from \"typescript-template-language-service-decorator\";\nimport type { FunctionType, TSManifest, NodeType } from \"@player-tools/xlr\";\nimport { createTSDocString } from \"@player-tools/xlr-utils\";\nimport { XLRSDK } from \"@player-tools/xlr-sdk\";\nimport type { ExpressionNode } from \"@player-ui/player\";\nimport { parseExpression } from \"@player-ui/player\";\nimport {\n getTokenAtPosition,\n toTSLocation,\n convertExprToJSONNode,\n} from \"./utils\";\nimport { toFunction } from \"./transforms\";\n\ninterface ExpressionEntry {\n /**\n * The name of the expression\n */\n name: string;\n /**\n * The description of the expression\n */\n description?: string;\n /**\n * The XLR type of the expression\n */\n type: FunctionType;\n /**\n * The XLR enabled plugin the expression was sourced from\n */\n source: TSManifest;\n}\n\nexport interface ExpressionLanguageServiceConfig {\n /**\n * The list of XLR enabled plugins to load\n */\n plugins: Array<TSManifest>;\n}\n\n/**\n * Language server to check Player expression syntax and usage\n */\nexport class ExpressionLanguageService implements TemplateLanguageService {\n private logger?: Logger;\n private _plugins: Array<TSManifest> = [];\n private _expressions: Map<string, ExpressionEntry>;\n private xlr: XLRSDK;\n\n constructor(\n options?: { logger?: Logger } & Partial<ExpressionLanguageServiceConfig>\n ) {\n this.logger = options?.logger;\n this._plugins = options?.plugins ?? [];\n this.xlr = new XLRSDK();\n\n this._plugins.forEach((p) => {\n this.xlr.loadDefinitionsFromModule(p, undefined, [toFunction]);\n });\n this._expressions = this.reduceExpression();\n }\n\n setConfig(config: ExpressionLanguageServiceConfig) {\n this._plugins = config.plugins;\n this.xlr = new XLRSDK();\n\n this._plugins.forEach((p) => {\n this.xlr.loadDefinitionsFromModule(p, undefined, [toFunction]);\n });\n this._expressions = this.reduceExpression();\n }\n\n private reduceExpression(): Map<string, ExpressionEntry> {\n // Overlaps in names will be resolved by the last plugin to be loaded\n // So use a map to ensure no duplicates\n const expressions = new Map<string, ExpressionEntry>();\n\n this.xlr.listTypes().forEach((type) => {\n const typeInfo = this.xlr.getTypeInfo(type.name);\n const source = this._plugins.find(\n (value) => value.pluginName === typeInfo?.plugin\n );\n\n if (\n type.type === \"function\" &&\n typeInfo?.capability === \"Expressions\" &&\n source\n ) {\n expressions.set(type.name, {\n name: type.name,\n description: type.description,\n type: type as FunctionType,\n source,\n });\n }\n });\n\n return expressions;\n }\n\n getCompletionsAtPosition(\n context: TemplateContext,\n position: ts.LineAndCharacter\n ): ts.CompletionInfo {\n const completionInfo: ts.CompletionInfo = {\n isGlobalCompletion: false,\n isMemberCompletion: false,\n isNewIdentifierLocation: true,\n entries: [],\n };\n\n if (context.text.length === 0) {\n // This happens for the start of an expression (e``)\n // Provide all the completions in this case\n\n this._expressions.forEach((exp) => {\n completionInfo.entries.push({\n name: exp.name,\n kind: ts.ScriptElementKind.functionElement,\n sortText: exp.name,\n isRecommended: true,\n insertText: `${exp.name}()`,\n });\n });\n\n return completionInfo;\n }\n\n const line = context.text.split(/\\n/g)[position.line];\n const parsed = parseExpression(line, { strict: false });\n const token = getTokenAtPosition(parsed, position);\n\n if (token?.type === \"Compound\" && token.error) {\n // We hit the end of the expression, and it's expecting more\n // so provide all the completions\n this._expressions.forEach((exp) => {\n completionInfo.entries.push({\n name: exp.name,\n kind: ts.ScriptElementKind.functionElement,\n sortText: exp.name,\n isRecommended: true,\n insertText: `${exp.name}()`,\n });\n });\n\n return completionInfo;\n }\n\n if (token?.type === \"Identifier\") {\n // get the relevant start of the identifier\n const start = token.location?.start ?? { character: 0 };\n const wordFromStart = line.slice(start.character, position.character);\n const allCompletions = Array.from(this._expressions.keys()).filter(\n (key) => key.startsWith(wordFromStart)\n );\n\n allCompletions.forEach((c) => {\n completionInfo.entries.push({\n name: c,\n kind: ts.ScriptElementKind.functionElement,\n sortText: c,\n isRecommended: true,\n insertText: `${c}()`,\n });\n });\n }\n\n return completionInfo;\n }\n\n getCompletionEntryDetails(\n context: TemplateContext,\n position: ts.LineAndCharacter,\n name: string\n ): ts.CompletionEntryDetails {\n const expression = this._expressions.get(name);\n\n const completionDetails: ts.CompletionEntryDetails = {\n name,\n kind: ts.ScriptElementKind.functionElement,\n kindModifiers: ts.ScriptElementKindModifier.none,\n\n documentation: [\n {\n kind: \"text\",\n text: expression?.type.description ?? \"\",\n },\n ],\n displayParts: expression ? createTSDocString(expression.type) : [],\n };\n\n return completionDetails;\n }\n\n getQuickInfoAtPosition(\n context: TemplateContext,\n position: ts.LineAndCharacter\n ): ts.QuickInfo | undefined {\n const parsed = parseExpression(context.text, { strict: false });\n const token = getTokenAtPosition(parsed, position);\n\n if (token?.type === \"Identifier\") {\n const expression = this._expressions.get(token.name);\n\n if (expression) {\n const completionDetails = this.getCompletionEntryDetails(\n context,\n position,\n expression.name\n );\n\n return {\n ...completionDetails,\n textSpan: toTSLocation(token),\n };\n }\n }\n\n return undefined;\n }\n\n private checkNode(\n context: TemplateContext,\n node: ExpressionNode,\n xlrType: NodeType\n ): ts.Diagnostic[] {\n const diagnostics: ts.Diagnostic[] = [];\n const asJsonNodeValue = convertExprToJSONNode(node);\n\n if (asJsonNodeValue) {\n const xlrDiags = this.xlr.validateByType(xlrType, asJsonNodeValue);\n\n xlrDiags.forEach((d) => {\n diagnostics.push({\n file: context.node.getSourceFile(),\n ...toTSLocation(node),\n messageText: d.message,\n category: ts.DiagnosticCategory.Error,\n code: 1,\n });\n });\n }\n\n return diagnostics;\n }\n\n private getDiagnosticsForNode(\n context: TemplateContext,\n node: ExpressionNode\n ): ts.Diagnostic[] {\n const diags: ts.Diagnostic[] = [];\n\n if (node.type === \"Compound\") {\n node.body.forEach((n) => {\n diags.push(...this.getDiagnosticsForNode(context, n));\n });\n }\n\n if (node.type === \"CallExpression\") {\n // Check that the expression is valid\n const exprName = node.callTarget.name;\n const expression = this._expressions.get(exprName);\n\n node.args.forEach((n) => {\n diags.push(...this.getDiagnosticsForNode(context, n));\n });\n\n if (expression) {\n // Double check the arguments match what we expect\n const expectedArgs = expression.type.parameters;\n const actualArgs = node.args;\n\n actualArgs.forEach((actualArg, index) => {\n const expectedArg = expectedArgs[index];\n\n if (expectedArg) {\n // Check that the type satisfies the expected type\n diags.push(...this.checkNode(context, actualArg, expectedArg.type));\n }\n });\n\n if (expectedArgs.length > actualArgs.length) {\n const requiredArgs = expectedArgs.filter((a) => !a.optional);\n if (actualArgs.length < requiredArgs.length) {\n diags.push({\n category: ts.DiagnosticCategory.Error,\n code: 1,\n file: context.node.getSourceFile(),\n ...toTSLocation(node.callTarget),\n messageText: `Expected ${requiredArgs.length} argument(s), got ${actualArgs.length}`,\n });\n }\n }\n } else {\n diags.push({\n category: ts.DiagnosticCategory.Error,\n code: 1,\n file: context.node.getSourceFile(),\n ...toTSLocation(node.callTarget),\n messageText: `Unknown expression ${exprName}`,\n });\n }\n }\n\n return diags;\n }\n\n getSemanticDiagnostics(context: TemplateContext): ts.Diagnostic[] {\n // Shortcut any type-checking if we don't have any info about what expressions are registered\n if (this._plugins.length === 0) {\n return [];\n }\n\n const parsed = parseExpression(context.text.trim(), { strict: false });\n return this.getDiagnosticsForNode(context, parsed);\n }\n\n getSyntacticDiagnostics(context: TemplateContext): ts.Diagnostic[] {\n const parsed = parseExpression(context.text.trim(), { strict: false });\n\n if (parsed.error) {\n return [\n {\n category: ts.DiagnosticCategory.Error,\n code: 1,\n file: context.node.getSourceFile(),\n ...toTSLocation(parsed),\n messageText: parsed.error.message,\n },\n ];\n }\n\n return [];\n }\n}\n","import type { TextSpan } from \"typescript\";\nimport type { Position } from \"vscode-languageserver-types\";\nimport type { ExpressionNode, NodeLocation } from \"@player-ui/player\";\nimport { parseTree } from \"jsonc-parser\";\nimport type { Node } from \"jsonc-parser\";\n\n/** Check if the vscode position overlaps with the expression location */\nexport function isInRange(position: Position, location: NodeLocation) {\n return (\n position.character >= location.start.character &&\n position.character <= location.end.character\n );\n}\n\n/** Find the closest marked token at the given position */\nexport function getTokenAtPosition(\n node: ExpressionNode,\n position: Position\n): ExpressionNode | undefined {\n if (node.type === \"CallExpression\") {\n const anyArgs = node.args.find((arg) => {\n return getTokenAtPosition(arg, position);\n });\n\n if (anyArgs) {\n return anyArgs;\n }\n\n const asTarget = getTokenAtPosition(node.callTarget, position);\n if (asTarget) {\n return asTarget;\n }\n }\n\n if (node.type === \"Assignment\") {\n const asTarget =\n getTokenAtPosition(node.left, position) ??\n getTokenAtPosition(node.right, position);\n if (asTarget) {\n return asTarget;\n }\n }\n\n // Lastly check for yourself\n if (node.location && isInRange(position, node.location)) {\n return node;\n }\n}\n\n/** Get the location info that TS expects for it's diags */\nexport function toTSLocation(node: ExpressionNode): TextSpan {\n const start = node.location?.start.character;\n const end = node.location?.end.character;\n if (start === undefined || end === undefined) {\n return {\n start: 0,\n length: 0,\n };\n }\n\n return {\n start,\n length: end - start,\n };\n}\n\n/** ExpressionNode -> raw value */\nexport function convertExprToValue(exprNode: ExpressionNode): any {\n let val;\n\n if (exprNode.type === \"Literal\") {\n val = exprNode.value;\n } else if (exprNode.type === \"Object\") {\n val = {};\n exprNode.attributes.forEach((prop) => {\n val[convertExprToValue(prop.key)] = convertExprToValue(prop.value);\n });\n } else if (exprNode.type === \"ArrayExpression\") {\n val = exprNode.elements.map(convertExprToValue);\n }\n\n return val;\n}\n\n/** ExpressionNode -> JSONC Node */\nexport function convertExprToJSONNode(\n exprNode: ExpressionNode\n): Node | undefined {\n const val = convertExprToValue(exprNode);\n if (val === undefined) {\n return undefined;\n }\n\n return parseTree(JSON.stringify(val));\n}\n","import type { FunctionType, FunctionTypeParameters } from \"@player-tools/xlr\";\nimport { simpleTransformGenerator } from \"@player-tools/xlr-sdk\";\n\nexport const toFunction = simpleTransformGenerator(\n \"ref\",\n \"Expressions\",\n (exp) => {\n if (!exp.genericArguments || exp.ref !== \"ExpressionHandler\") {\n return exp;\n }\n\n const [args, returnType] = exp.genericArguments;\n\n const parameters: Array<FunctionTypeParameters> = (\n args.type === \"tuple\" ? args.elementTypes : []\n ).map((elementType, index) => {\n return {\n name:\n elementType.name ??\n elementType.type.name ??\n elementType.type.title ??\n `arg_${index}`,\n\n type: {\n name:\n elementType.name ??\n elementType.type.name ??\n elementType.type.title ??\n `arg_${index}`,\n ...elementType.type,\n },\n optional:\n elementType.optional === true ? elementType.optional : undefined,\n };\n });\n\n return {\n ...exp,\n type: \"function\",\n parameters,\n returnType,\n } as FunctionType as any;\n }\n);\n","import type { Logger } from \"typescript-template-language-service-decorator\";\nimport ts from \"typescript/lib/tsserverlibrary\";\n\nexport class LSPLogger implements Logger {\n private readonly info: ts.server.PluginCreateInfo;\n\n constructor(info: ts.server.PluginCreateInfo) {\n this.info = info;\n }\n\n log(msg: string) {\n this.info.project.projectService.logger.info(`[player-expr-lsp] ${msg}`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4DAAoD;;;ACDpD,6BAAe;AAOf,uBAAkC;AAClC,IAAAA,kBAAuB;AAEvB,oBAAgC;;;ACPhC,0BAA0B;AAInB,SAAS,UAAU,UAAoB,UAAwB;AACpE,SACE,SAAS,aAAa,SAAS,MAAM,aACrC,SAAS,aAAa,SAAS,IAAI;AAEvC;AAGO,SAAS,mBACd,MACA,UAC4B;AAC5B,MAAI,KAAK,SAAS,kBAAkB;AAClC,UAAM,UAAU,KAAK,KAAK,KAAK,CAAC,QAAQ;AACtC,aAAO,mBAAmB,KAAK,QAAQ;AAAA,IACzC,CAAC;AAED,QAAI,SAAS;AACX,aAAO;AAAA,IACT;AAEA,UAAM,WAAW,mBAAmB,KAAK,YAAY,QAAQ;AAC7D,QAAI,UAAU;AACZ,aAAO;AAAA,IACT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A,EACV;AACF;;;AG/UO,IAAM,YAAN,MAAkC;AAAA,EACtB;AAAA,EAEjB,YAAY,MAAkC;AAC5C,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,IAAI,KAAa;AACf,SAAK,KAAK,QAAQ,eAAe,OAAO,KAAK,qBAAqB,GAAG,EAAE;AAAA,EACzE;AACF;;;AJLA,IAAM,SAAN,MAA+C;AAAA,EAC5B;AAAA,EACT;AAAA,EACA;AAAA,EAER,YAAY,aAAyB;AACnC,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,OAAO,MAAsD;AAC3D,UAAM,SAAS,IAAI,UAAU,IAAI;AACjC,SAAK,SAAS;AAEd,UAAM,kBAAkB,IAAI,0BAA0B,EAAE,OAAO,CAAC;AAChE,SAAK,kBAAkB;AAEvB,eAAO;AAAA,MACL,KAAK,YAAY;AAAA,MACjB,KAAK;AAAA,MACL,KAAK;AAAA,MACL;AAAA,MACA;AAAA,QACE,MAAM,CAAC,KAAK,QAAQ,YAAY;AAAA,QAChC,kCAAkC;AAAA,MACpC;AAAA,MACA,EAAE,OAAO;AAAA,IACX;AAAA,EACF;AAAA,EAEA,uBAAuB,QAAa;AAClC,SAAK,iBAAiB,UAAU,MAAM;AAAA,EACxC;AACF;AAEA,SAAS,KAAK,KAAyC;AACrD,SAAO,IAAI,OAAO,GAAG;AACvB;AAEA,IAAO,cAAQ;","names":["import_xlr_sdk","ts"]}
|
package/dist/index.legacy-esm.js
CHANGED
|
@@ -102,8 +102,11 @@ var toFunction = simpleTransformGenerator(
|
|
|
102
102
|
|
|
103
103
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/service.ts
|
|
104
104
|
var ExpressionLanguageService = class {
|
|
105
|
+
logger;
|
|
106
|
+
_plugins = [];
|
|
107
|
+
_expressions;
|
|
108
|
+
xlr;
|
|
105
109
|
constructor(options) {
|
|
106
|
-
this._plugins = [];
|
|
107
110
|
this.logger = options?.logger;
|
|
108
111
|
this._plugins = options?.plugins ?? [];
|
|
109
112
|
this.xlr = new XLRSDK();
|
|
@@ -314,6 +317,7 @@ var ExpressionLanguageService = class {
|
|
|
314
317
|
|
|
315
318
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/logger.ts
|
|
316
319
|
var LSPLogger = class {
|
|
320
|
+
info;
|
|
317
321
|
constructor(info) {
|
|
318
322
|
this.info = info;
|
|
319
323
|
}
|
|
@@ -324,6 +328,9 @@ var LSPLogger = class {
|
|
|
324
328
|
|
|
325
329
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/index.ts
|
|
326
330
|
var Plugin = class {
|
|
331
|
+
initOptions;
|
|
332
|
+
logger;
|
|
333
|
+
templateService;
|
|
327
334
|
constructor(initOptions) {
|
|
328
335
|
this.initOptions = initOptions;
|
|
329
336
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -102,8 +102,11 @@ var toFunction = simpleTransformGenerator(
|
|
|
102
102
|
|
|
103
103
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/service.ts
|
|
104
104
|
var ExpressionLanguageService = class {
|
|
105
|
+
logger;
|
|
106
|
+
_plugins = [];
|
|
107
|
+
_expressions;
|
|
108
|
+
xlr;
|
|
105
109
|
constructor(options) {
|
|
106
|
-
this._plugins = [];
|
|
107
110
|
this.logger = options?.logger;
|
|
108
111
|
this._plugins = options?.plugins ?? [];
|
|
109
112
|
this.xlr = new XLRSDK();
|
|
@@ -314,6 +317,7 @@ var ExpressionLanguageService = class {
|
|
|
314
317
|
|
|
315
318
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/logger.ts
|
|
316
319
|
var LSPLogger = class {
|
|
320
|
+
info;
|
|
317
321
|
constructor(info) {
|
|
318
322
|
this.info = info;
|
|
319
323
|
}
|
|
@@ -324,6 +328,9 @@ var LSPLogger = class {
|
|
|
324
328
|
|
|
325
329
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/index.ts
|
|
326
330
|
var Plugin = class {
|
|
331
|
+
initOptions;
|
|
332
|
+
logger;
|
|
333
|
+
templateService;
|
|
327
334
|
constructor(initOptions) {
|
|
328
335
|
this.initOptions = initOptions;
|
|
329
336
|
}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/service.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/utils.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/transforms.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/logger.ts"],"sourcesContent":["import ts from \"typescript/lib/tsserverlibrary\";\nimport { decorateWithTemplateLanguageService } from \"typescript-template-language-service-decorator\";\nimport { ExpressionLanguageService } from \"./service\";\nimport { LSPLogger } from \"./logger\";\n\ninterface InitParams {\n typescript: typeof ts;\n}\nclass Plugin implements ts.server.PluginModule {\n private readonly initOptions: InitParams;\n private logger?: LSPLogger;\n private templateService?: ExpressionLanguageService;\n\n constructor(initOptions: InitParams) {\n this.initOptions = initOptions;\n }\n\n create(info: ts.server.PluginCreateInfo): ts.LanguageService {\n const logger = new LSPLogger(info);\n this.logger = logger;\n\n const templateService = new ExpressionLanguageService({ logger });\n this.templateService = templateService;\n\n return decorateWithTemplateLanguageService(\n this.initOptions.typescript,\n info.languageService,\n info.project,\n templateService,\n {\n tags: [\"e\", \"expr\", \"expression\"],\n enableForStringWithSubstitutions: true,\n },\n { logger }\n );\n }\n\n onConfigurationChanged(config: any) {\n this.templateService?.setConfig(config);\n }\n}\n\nfunction init(mod: InitParams): ts.server.PluginModule {\n return new Plugin(mod);\n}\n\nexport default init;\n// export = init;\n","import ts from \"typescript/lib/tsserverlibrary\";\nimport type {\n TemplateLanguageService,\n TemplateContext,\n Logger,\n} from \"typescript-template-language-service-decorator\";\nimport type { FunctionType, TSManifest, NodeType } from \"@player-tools/xlr\";\nimport { createTSDocString } from \"@player-tools/xlr-utils\";\nimport { XLRSDK } from \"@player-tools/xlr-sdk\";\nimport type { ExpressionNode } from \"@player-ui/player\";\nimport { parseExpression } from \"@player-ui/player\";\nimport {\n getTokenAtPosition,\n toTSLocation,\n convertExprToJSONNode,\n} from \"./utils\";\nimport { toFunction } from \"./transforms\";\n\ninterface ExpressionEntry {\n /**\n * The name of the expression\n */\n name: string;\n /**\n * The description of the expression\n */\n description?: string;\n /**\n * The XLR type of the expression\n */\n type: FunctionType;\n /**\n * The XLR enabled plugin the expression was sourced from\n */\n source: TSManifest;\n}\n\nexport interface ExpressionLanguageServiceConfig {\n /**\n * The list of XLR enabled plugins to load\n */\n plugins: Array<TSManifest>;\n}\n\n/**\n * Language server to check Player expression syntax and usage\n */\nexport class ExpressionLanguageService implements TemplateLanguageService {\n private logger?: Logger;\n private _plugins: Array<TSManifest> = [];\n private _expressions: Map<string, ExpressionEntry>;\n private xlr: XLRSDK;\n\n constructor(\n options?: { logger?: Logger } & Partial<ExpressionLanguageServiceConfig>\n ) {\n this.logger = options?.logger;\n this._plugins = options?.plugins ?? [];\n this.xlr = new XLRSDK();\n\n this._plugins.forEach((p) => {\n this.xlr.loadDefinitionsFromModule(p, undefined, [toFunction]);\n });\n this._expressions = this.reduceExpression();\n }\n\n setConfig(config: ExpressionLanguageServiceConfig) {\n this._plugins = config.plugins;\n this.xlr = new XLRSDK();\n\n this._plugins.forEach((p) => {\n this.xlr.loadDefinitionsFromModule(p, undefined, [toFunction]);\n });\n this._expressions = this.reduceExpression();\n }\n\n private reduceExpression(): Map<string, ExpressionEntry> {\n // Overlaps in names will be resolved by the last plugin to be loaded\n // So use a map to ensure no duplicates\n const expressions = new Map<string, ExpressionEntry>();\n\n this.xlr.listTypes().forEach((type) => {\n const typeInfo = this.xlr.getTypeInfo(type.name);\n const source = this._plugins.find(\n (value) => value.pluginName === typeInfo?.plugin\n );\n\n if (\n type.type === \"function\" &&\n typeInfo?.capability === \"Expressions\" &&\n source\n ) {\n expressions.set(type.name, {\n name: type.name,\n description: type.description,\n type: type as FunctionType,\n source,\n });\n }\n });\n\n return expressions;\n }\n\n getCompletionsAtPosition(\n context: TemplateContext,\n position: ts.LineAndCharacter\n ): ts.CompletionInfo {\n const completionInfo: ts.CompletionInfo = {\n isGlobalCompletion: false,\n isMemberCompletion: false,\n isNewIdentifierLocation: true,\n entries: [],\n };\n\n if (context.text.length === 0) {\n // This happens for the start of an expression (e``)\n // Provide all the completions in this case\n\n this._expressions.forEach((exp) => {\n completionInfo.entries.push({\n name: exp.name,\n kind: ts.ScriptElementKind.functionElement,\n sortText: exp.name,\n isRecommended: true,\n insertText: `${exp.name}()`,\n });\n });\n\n return completionInfo;\n }\n\n const line = context.text.split(/\\n/g)[position.line];\n const parsed = parseExpression(line, { strict: false });\n const token = getTokenAtPosition(parsed, position);\n\n if (token?.type === \"Compound\" && token.error) {\n // We hit the end of the expression, and it's expecting more\n // so provide all the completions\n this._expressions.forEach((exp) => {\n completionInfo.entries.push({\n name: exp.name,\n kind: ts.ScriptElementKind.functionElement,\n sortText: exp.name,\n isRecommended: true,\n insertText: `${exp.name}()`,\n });\n });\n\n return completionInfo;\n }\n\n if (token?.type === \"Identifier\") {\n // get the relevant start of the identifier\n const start = token.location?.start ?? { character: 0 };\n const wordFromStart = line.slice(start.character, position.character);\n const allCompletions = Array.from(this._expressions.keys()).filter(\n (key) => key.startsWith(wordFromStart)\n );\n\n allCompletions.forEach((c) => {\n completionInfo.entries.push({\n name: c,\n kind: ts.ScriptElementKind.functionElement,\n sortText: c,\n isRecommended: true,\n insertText: `${c}()`,\n });\n });\n }\n\n return completionInfo;\n }\n\n getCompletionEntryDetails(\n context: TemplateContext,\n position: ts.LineAndCharacter,\n name: string\n ): ts.CompletionEntryDetails {\n const expression = this._expressions.get(name);\n\n const completionDetails: ts.CompletionEntryDetails = {\n name,\n kind: ts.ScriptElementKind.functionElement,\n kindModifiers: ts.ScriptElementKindModifier.none,\n\n documentation: [\n {\n kind: \"text\",\n text: expression?.type.description ?? \"\",\n },\n ],\n displayParts: expression ? createTSDocString(expression.type) : [],\n };\n\n return completionDetails;\n }\n\n getQuickInfoAtPosition(\n context: TemplateContext,\n position: ts.LineAndCharacter\n ): ts.QuickInfo | undefined {\n const parsed = parseExpression(context.text, { strict: false });\n const token = getTokenAtPosition(parsed, position);\n\n if (token?.type === \"Identifier\") {\n const expression = this._expressions.get(token.name);\n\n if (expression) {\n const completionDetails = this.getCompletionEntryDetails(\n context,\n position,\n expression.name\n );\n\n return {\n ...completionDetails,\n textSpan: toTSLocation(token),\n };\n }\n }\n\n return undefined;\n }\n\n private checkNode(\n context: TemplateContext,\n node: ExpressionNode,\n xlrType: NodeType\n ): ts.Diagnostic[] {\n const diagnostics: ts.Diagnostic[] = [];\n const asJsonNodeValue = convertExprToJSONNode(node);\n\n if (asJsonNodeValue) {\n const xlrDiags = this.xlr.validateByType(xlrType, asJsonNodeValue);\n\n xlrDiags.forEach((d) => {\n diagnostics.push({\n file: context.node.getSourceFile(),\n ...toTSLocation(node),\n messageText: d.message,\n category: ts.DiagnosticCategory.Error,\n code: 1,\n });\n });\n }\n\n return diagnostics;\n }\n\n private getDiagnosticsForNode(\n context: TemplateContext,\n node: ExpressionNode\n ): ts.Diagnostic[] {\n const diags: ts.Diagnostic[] = [];\n\n if (node.type === \"Compound\") {\n node.body.forEach((n) => {\n diags.push(...this.getDiagnosticsForNode(context, n));\n });\n }\n\n if (node.type === \"CallExpression\") {\n // Check that the expression is valid\n const exprName = node.callTarget.name;\n const expression = this._expressions.get(exprName);\n\n node.args.forEach((n) => {\n diags.push(...this.getDiagnosticsForNode(context, n));\n });\n\n if (expression) {\n // Double check the arguments match what we expect\n const expectedArgs = expression.type.parameters;\n const actualArgs = node.args;\n\n actualArgs.forEach((actualArg, index) => {\n const expectedArg = expectedArgs[index];\n\n if (expectedArg) {\n // Check that the type satisfies the expected type\n diags.push(...this.checkNode(context, actualArg, expectedArg.type));\n }\n });\n\n if (expectedArgs.length > actualArgs.length) {\n const requiredArgs = expectedArgs.filter((a) => !a.optional);\n if (actualArgs.length < requiredArgs.length) {\n diags.push({\n category: ts.DiagnosticCategory.Error,\n code: 1,\n file: context.node.getSourceFile(),\n ...toTSLocation(node.callTarget),\n messageText: `Expected ${requiredArgs.length} argument(s), got ${actualArgs.length}`,\n });\n }\n }\n } else {\n diags.push({\n category: ts.DiagnosticCategory.Error,\n code: 1,\n file: context.node.getSourceFile(),\n ...toTSLocation(node.callTarget),\n messageText: `Unknown expression ${exprName}`,\n });\n }\n }\n\n return diags;\n }\n\n getSemanticDiagnostics(context: TemplateContext): ts.Diagnostic[] {\n // Shortcut any type-checking if we don't have any info about what expressions are registered\n if (this._plugins.length === 0) {\n return [];\n }\n\n const parsed = parseExpression(context.text.trim(), { strict: false });\n return this.getDiagnosticsForNode(context, parsed);\n }\n\n getSyntacticDiagnostics(context: TemplateContext): ts.Diagnostic[] {\n const parsed = parseExpression(context.text.trim(), { strict: false });\n\n if (parsed.error) {\n return [\n {\n category: ts.DiagnosticCategory.Error,\n code: 1,\n file: context.node.getSourceFile(),\n ...toTSLocation(parsed),\n messageText: parsed.error.message,\n },\n ];\n }\n\n return [];\n }\n}\n","import type { TextSpan } from \"typescript\";\nimport type { Position } from \"vscode-languageserver-types\";\nimport type { ExpressionNode, NodeLocation } from \"@player-ui/player\";\nimport { parseTree } from \"jsonc-parser\";\nimport type { Node } from \"jsonc-parser\";\n\n/** Check if the vscode position overlaps with the expression location */\nexport function isInRange(position: Position, location: NodeLocation) {\n return (\n position.character >= location.start.character &&\n position.character <= location.end.character\n );\n}\n\n/** Find the closest marked token at the given position */\nexport function getTokenAtPosition(\n node: ExpressionNode,\n position: Position\n): ExpressionNode | undefined {\n if (node.type === \"CallExpression\") {\n const anyArgs = node.args.find((arg) => {\n return getTokenAtPosition(arg, position);\n });\n\n if (anyArgs) {\n return anyArgs;\n }\n\n const asTarget = getTokenAtPosition(node.callTarget, position);\n if (asTarget) {\n return asTarget;\n }\n }\n\n if (node.type === \"Assignment\") {\n const asTarget =\n getTokenAtPosition(node.left, position) ??\n getTokenAtPosition(node.right, position);\n if (asTarget) {\n return asTarget;\n }\n }\n\n // Lastly check for yourself\n if (node.location && isInRange(position, node.location)) {\n return node;\n }\n}\n\n/** Get the location info that TS expects for it's diags */\nexport function toTSLocation(node: ExpressionNode): TextSpan {\n const start = node.location?.start.character;\n const end = node.location?.end.character;\n if (start === undefined || end === undefined) {\n return {\n start: 0,\n length: 0,\n };\n }\n\n return {\n start,\n length: end - start,\n };\n}\n\n/** ExpressionNode -> raw value */\nexport function convertExprToValue(exprNode: ExpressionNode): any {\n let val;\n\n if (exprNode.type === \"Literal\") {\n val = exprNode.value;\n } else if (exprNode.type === \"Object\") {\n val = {};\n exprNode.attributes.forEach((prop) => {\n val[convertExprToValue(prop.key)] = convertExprToValue(prop.value);\n });\n } else if (exprNode.type === \"ArrayExpression\") {\n val = exprNode.elements.map(convertExprToValue);\n }\n\n return val;\n}\n\n/** ExpressionNode -> JSONC Node */\nexport function convertExprToJSONNode(\n exprNode: ExpressionNode\n): Node | undefined {\n const val = convertExprToValue(exprNode);\n if (val === undefined) {\n return undefined;\n }\n\n return parseTree(JSON.stringify(val));\n}\n","import type { FunctionType, FunctionTypeParameters } from \"@player-tools/xlr\";\nimport { simpleTransformGenerator } from \"@player-tools/xlr-sdk\";\n\nexport const toFunction = simpleTransformGenerator(\n \"ref\",\n \"Expressions\",\n (exp) => {\n if (!exp.genericArguments || exp.ref !== \"ExpressionHandler\") {\n return exp;\n }\n\n const [args, returnType] = exp.genericArguments;\n\n const parameters: Array<FunctionTypeParameters> = (\n args.type === \"tuple\" ? args.elementTypes : []\n ).map((elementType, index) => {\n return {\n name:\n elementType.name ??\n elementType.type.name ??\n elementType.type.title ??\n `arg_${index}`,\n\n type: {\n name:\n elementType.name ??\n elementType.type.name ??\n elementType.type.title ??\n `arg_${index}`,\n ...elementType.type,\n },\n optional:\n elementType.optional === true ? elementType.optional : undefined,\n };\n });\n\n return {\n ...exp,\n type: \"function\",\n parameters,\n returnType,\n } as FunctionType as any;\n }\n);\n","import type { Logger } from \"typescript-template-language-service-decorator\";\nimport ts from \"typescript/lib/tsserverlibrary\";\n\nexport class LSPLogger implements Logger {\n private readonly info: ts.server.PluginCreateInfo;\n\n constructor(info: ts.server.PluginCreateInfo) {\n this.info = info;\n }\n\n log(msg: string) {\n this.info.project.projectService.logger.info(`[player-expr-lsp] ${msg}`);\n }\n}\n"],"mappings":";AACA,SAAS,2CAA2C;;;ACDpD,OAAO,QAAQ;AAOf,SAAS,yBAAyB;AAClC,SAAS,cAAc;AAEvB,SAAS,uBAAuB;;;ACPhC,SAAS,iBAAiB;AAInB,SAAS,UAAU,UAAoB,UAAwB;AACpE,SACE,SAAS,aAAa,SAAS,MAAM,aACrC,SAAS,aAAa,SAAS,IAAI;AAEvC;AAGO,SAAS,mBACd,MACA,UAC4B;AAC5B,MAAI,KAAK,SAAS,kBAAkB;AAClC,UAAM,UAAU,KAAK,KAAK,KAAK,CAAC,QAAQ;AACtC,aAAO,mBAAmB,KAAK,QAAQ;AAAA,IACzC,CAAC;AAED,QAAI,SAAS;AACX,aAAO;AAAA,IACT;AAEA,UAAM,WAAW,mBAAmB,KAAK,YAAY,QAAQ;AAC7D,QAAI,UAAU;AACZ,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,KAAK,SAAS,cAAc;AAC9B,UAAM,WACJ,mBAAmB,KAAK,MAAM,QAAQ,KACtC,mBAAmB,KAAK,OAAO,QAAQ;AACzC,QAAI,UAAU;AACZ,aAAO;AAAA,IACT;AAAA,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AA,EACrB;AAAA,EAEA,OAAO,MAAsD;AAC3D,UAAM,SAAS,IAAI,UAAU,IAAI;AACjC,SAAK,SAAS;AAEd,UAAM,kBAAkB,IAAI,0BAA0B,EAAE,OAAO,CAAC;AAChE,SAAK,kBAAkB;AAEvB,WAAO;AAAA,MACL,KAAK,YAAY;AAAA,MACjB,KAAK;AAAA,MACL,KAAK;AAAA,MACL;AAAA,MACA;AAAA,QACE,MAAM,CAAC,KAAK,QAAQ,YAAY;AAAA,QAChC,kCAAkC;AAAA,MACpC;AAAA,MACA,EAAE,OAAO;AAAA,IACX;AAAA,EACF;AAAA,EAEA,uBAAuB,QAAa;AAClC,SAAK,iBAAiB,UAAU,MAAM;AAAA,EACxC;AACF;AAEA,SAAS,KAAK,KAAyC;AACrD,SAAO,IAAI,OAAO,GAAG;AACvB;AAEA,IAAO,cAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/service.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/utils.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/transforms.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/typescript-expression-plugin/src/logger.ts"],"sourcesContent":["import ts from \"typescript/lib/tsserverlibrary\";\nimport { decorateWithTemplateLanguageService } from \"typescript-template-language-service-decorator\";\nimport { ExpressionLanguageService } from \"./service\";\nimport { LSPLogger } from \"./logger\";\n\ninterface InitParams {\n typescript: typeof ts;\n}\nclass Plugin implements ts.server.PluginModule {\n private readonly initOptions: InitParams;\n private logger?: LSPLogger;\n private templateService?: ExpressionLanguageService;\n\n constructor(initOptions: InitParams) {\n this.initOptions = initOptions;\n }\n\n create(info: ts.server.PluginCreateInfo): ts.LanguageService {\n const logger = new LSPLogger(info);\n this.logger = logger;\n\n const templateService = new ExpressionLanguageService({ logger });\n this.templateService = templateService;\n\n return decorateWithTemplateLanguageService(\n this.initOptions.typescript,\n info.languageService,\n info.project,\n templateService,\n {\n tags: [\"e\", \"expr\", \"expression\"],\n enableForStringWithSubstitutions: true,\n },\n { logger }\n );\n }\n\n onConfigurationChanged(config: any) {\n this.templateService?.setConfig(config);\n }\n}\n\nfunction init(mod: InitParams): ts.server.PluginModule {\n return new Plugin(mod);\n}\n\nexport default init;\n// export = init;\n","import ts from \"typescript/lib/tsserverlibrary\";\nimport type {\n TemplateLanguageService,\n TemplateContext,\n Logger,\n} from \"typescript-template-language-service-decorator\";\nimport type { FunctionType, TSManifest, NodeType } from \"@player-tools/xlr\";\nimport { createTSDocString } from \"@player-tools/xlr-utils\";\nimport { XLRSDK } from \"@player-tools/xlr-sdk\";\nimport type { ExpressionNode } from \"@player-ui/player\";\nimport { parseExpression } from \"@player-ui/player\";\nimport {\n getTokenAtPosition,\n toTSLocation,\n convertExprToJSONNode,\n} from \"./utils\";\nimport { toFunction } from \"./transforms\";\n\ninterface ExpressionEntry {\n /**\n * The name of the expression\n */\n name: string;\n /**\n * The description of the expression\n */\n description?: string;\n /**\n * The XLR type of the expression\n */\n type: FunctionType;\n /**\n * The XLR enabled plugin the expression was sourced from\n */\n source: TSManifest;\n}\n\nexport interface ExpressionLanguageServiceConfig {\n /**\n * The list of XLR enabled plugins to load\n */\n plugins: Array<TSManifest>;\n}\n\n/**\n * Language server to check Player expression syntax and usage\n */\nexport class ExpressionLanguageService implements TemplateLanguageService {\n private logger?: Logger;\n private _plugins: Array<TSManifest> = [];\n private _expressions: Map<string, ExpressionEntry>;\n private xlr: XLRSDK;\n\n constructor(\n options?: { logger?: Logger } & Partial<ExpressionLanguageServiceConfig>\n ) {\n this.logger = options?.logger;\n this._plugins = options?.plugins ?? [];\n this.xlr = new XLRSDK();\n\n this._plugins.forEach((p) => {\n this.xlr.loadDefinitionsFromModule(p, undefined, [toFunction]);\n });\n this._expressions = this.reduceExpression();\n }\n\n setConfig(config: ExpressionLanguageServiceConfig) {\n this._plugins = config.plugins;\n this.xlr = new XLRSDK();\n\n this._plugins.forEach((p) => {\n this.xlr.loadDefinitionsFromModule(p, undefined, [toFunction]);\n });\n this._expressions = this.reduceExpression();\n }\n\n private reduceExpression(): Map<string, ExpressionEntry> {\n // Overlaps in names will be resolved by the last plugin to be loaded\n // So use a map to ensure no duplicates\n const expressions = new Map<string, ExpressionEntry>();\n\n this.xlr.listTypes().forEach((type) => {\n const typeInfo = this.xlr.getTypeInfo(type.name);\n const source = this._plugins.find(\n (value) => value.pluginName === typeInfo?.plugin\n );\n\n if (\n type.type === \"function\" &&\n typeInfo?.capability === \"Expressions\" &&\n source\n ) {\n expressions.set(type.name, {\n name: type.name,\n description: type.description,\n type: type as FunctionType,\n source,\n });\n }\n });\n\n return expressions;\n }\n\n getCompletionsAtPosition(\n context: TemplateContext,\n position: ts.LineAndCharacter\n ): ts.CompletionInfo {\n const completionInfo: ts.CompletionInfo = {\n isGlobalCompletion: false,\n isMemberCompletion: false,\n isNewIdentifierLocation: true,\n entries: [],\n };\n\n if (context.text.length === 0) {\n // This happens for the start of an expression (e``)\n // Provide all the completions in this case\n\n this._expressions.forEach((exp) => {\n completionInfo.entries.push({\n name: exp.name,\n kind: ts.ScriptElementKind.functionElement,\n sortText: exp.name,\n isRecommended: true,\n insertText: `${exp.name}()`,\n });\n });\n\n return completionInfo;\n }\n\n const line = context.text.split(/\\n/g)[position.line];\n const parsed = parseExpression(line, { strict: false });\n const token = getTokenAtPosition(parsed, position);\n\n if (token?.type === \"Compound\" && token.error) {\n // We hit the end of the expression, and it's expecting more\n // so provide all the completions\n this._expressions.forEach((exp) => {\n completionInfo.entries.push({\n name: exp.name,\n kind: ts.ScriptElementKind.functionElement,\n sortText: exp.name,\n isRecommended: true,\n insertText: `${exp.name}()`,\n });\n });\n\n return completionInfo;\n }\n\n if (token?.type === \"Identifier\") {\n // get the relevant start of the identifier\n const start = token.location?.start ?? { character: 0 };\n const wordFromStart = line.slice(start.character, position.character);\n const allCompletions = Array.from(this._expressions.keys()).filter(\n (key) => key.startsWith(wordFromStart)\n );\n\n allCompletions.forEach((c) => {\n completionInfo.entries.push({\n name: c,\n kind: ts.ScriptElementKind.functionElement,\n sortText: c,\n isRecommended: true,\n insertText: `${c}()`,\n });\n });\n }\n\n return completionInfo;\n }\n\n getCompletionEntryDetails(\n context: TemplateContext,\n position: ts.LineAndCharacter,\n name: string\n ): ts.CompletionEntryDetails {\n const expression = this._expressions.get(name);\n\n const completionDetails: ts.CompletionEntryDetails = {\n name,\n kind: ts.ScriptElementKind.functionElement,\n kindModifiers: ts.ScriptElementKindModifier.none,\n\n documentation: [\n {\n kind: \"text\",\n text: expression?.type.description ?? \"\",\n },\n ],\n displayParts: expression ? createTSDocString(expression.type) : [],\n };\n\n return completionDetails;\n }\n\n getQuickInfoAtPosition(\n context: TemplateContext,\n position: ts.LineAndCharacter\n ): ts.QuickInfo | undefined {\n const parsed = parseExpression(context.text, { strict: false });\n const token = getTokenAtPosition(parsed, position);\n\n if (token?.type === \"Identifier\") {\n const expression = this._expressions.get(token.name);\n\n if (expression) {\n const completionDetails = this.getCompletionEntryDetails(\n context,\n position,\n expression.name\n );\n\n return {\n ...completionDetails,\n textSpan: toTSLocation(token),\n };\n }\n }\n\n return undefined;\n }\n\n private checkNode(\n context: TemplateContext,\n node: ExpressionNode,\n xlrType: NodeType\n ): ts.Diagnostic[] {\n const diagnostics: ts.Diagnostic[] = [];\n const asJsonNodeValue = convertExprToJSONNode(node);\n\n if (asJsonNodeValue) {\n const xlrDiags = this.xlr.validateByType(xlrType, asJsonNodeValue);\n\n xlrDiags.forEach((d) => {\n diagnostics.push({\n file: context.node.getSourceFile(),\n ...toTSLocation(node),\n messageText: d.message,\n category: ts.DiagnosticCategory.Error,\n code: 1,\n });\n });\n }\n\n return diagnostics;\n }\n\n private getDiagnosticsForNode(\n context: TemplateContext,\n node: ExpressionNode\n ): ts.Diagnostic[] {\n const diags: ts.Diagnostic[] = [];\n\n if (node.type === \"Compound\") {\n node.body.forEach((n) => {\n diags.push(...this.getDiagnosticsForNode(context, n));\n });\n }\n\n if (node.type === \"CallExpression\") {\n // Check that the expression is valid\n const exprName = node.callTarget.name;\n const expression = this._expressions.get(exprName);\n\n node.args.forEach((n) => {\n diags.push(...this.getDiagnosticsForNode(context, n));\n });\n\n if (expression) {\n // Double check the arguments match what we expect\n const expectedArgs = expression.type.parameters;\n const actualArgs = node.args;\n\n actualArgs.forEach((actualArg, index) => {\n const expectedArg = expectedArgs[index];\n\n if (expectedArg) {\n // Check that the type satisfies the expected type\n diags.push(...this.checkNode(context, actualArg, expectedArg.type));\n }\n });\n\n if (expectedArgs.length > actualArgs.length) {\n const requiredArgs = expectedArgs.filter((a) => !a.optional);\n if (actualArgs.length < requiredArgs.length) {\n diags.push({\n category: ts.DiagnosticCategory.Error,\n code: 1,\n file: context.node.getSourceFile(),\n ...toTSLocation(node.callTarget),\n messageText: `Expected ${requiredArgs.length} argument(s), got ${actualArgs.length}`,\n });\n }\n }\n } else {\n diags.push({\n category: ts.DiagnosticCategory.Error,\n code: 1,\n file: context.node.getSourceFile(),\n ...toTSLocation(node.callTarget),\n messageText: `Unknown expression ${exprName}`,\n });\n }\n }\n\n return diags;\n }\n\n getSemanticDiagnostics(context: TemplateContext): ts.Diagnostic[] {\n // Shortcut any type-checking if we don't have any info about what expressions are registered\n if (this._plugins.length === 0) {\n return [];\n }\n\n const parsed = parseExpression(context.text.trim(), { strict: false });\n return this.getDiagnosticsForNode(context, parsed);\n }\n\n getSyntacticDiagnostics(context: TemplateContext): ts.Diagnostic[] {\n const parsed = parseExpression(context.text.trim(), { strict: false });\n\n if (parsed.error) {\n return [\n {\n category: ts.DiagnosticCategory.Error,\n code: 1,\n file: context.node.getSourceFile(),\n ...toTSLocation(parsed),\n messageText: parsed.error.message,\n },\n ];\n }\n\n return [];\n }\n}\n","import type { TextSpan } from \"typescript\";\nimport type { Position } from \"vscode-languageserver-types\";\nimport type { ExpressionNode, NodeLocation } from \"@player-ui/player\";\nimport { parseTree } from \"jsonc-parser\";\nimport type { Node } from \"jsonc-parser\";\n\n/** Check if the vscode position overlaps with the expression location */\nexport function isInRange(position: Position, location: NodeLocation) {\n return (\n position.character >= location.start.character &&\n position.character <= location.end.character\n );\n}\n\n/** Find the closest marked token at the given position */\nexport function getTokenAtPosition(\n node: ExpressionNode,\n position: Position\n): ExpressionNode | undefined {\n if (node.type === \"CallExpression\") {\n const anyArgs = node.args.find((arg) => {\n return getTokenAtPosition(arg, position);\n });\n\n if (anyArgs) {\n return anyArgs;\n }\n\n const asTarget = getTokenAtPosition(node.callTarget, position);\n if (asTarget) {\n return asTarget;\n }\n }\n\n if (node.type === \"Assignment\") {\n const asTarget =\n getTokenAtPosition(node.left, position) ??\n getTokenAtPosition(node.right, position);\n if (asTarget) {\n return asTarget;\n }\n }\n\n // Lastly check for yourself\n if (node.location && isInRange(position, node.location)) {\n return node;\n }\n}\n\n/** Get the location info that TS expects for it's diags */\nexport function toTSLocation(node: ExpressionNode): TextSpan {\n const start = node.location?.start.character;\n const end = node.location?.end.character;\n if (start === undefined || end === undefined) {\n return {\n start: 0,\n length: 0,\n };\n }\n\n return {\n start,\n length: end - start,\n };\n}\n\n/** ExpressionNode -> raw value */\nexport function convertExprToValue(exprNode: ExpressionNode): any {\n let val;\n\n if (exprNode.type === \"Literal\") {\n val = exprNode.value;\n } else if (exprNode.type === \"Object\") {\n val = {};\n exprNode.attributes.forEach((prop) => {\n val[convertExprToValue(prop.key)] = convertExprToValue(prop.value);\n });\n } else if (exprNode.type === \"ArrayExpression\") {\n val = exprNode.elements.map(convertExprToValue);\n }\n\n return val;\n}\n\n/** ExpressionNode -> JSONC Node */\nexport function convertExprToJSONNode(\n exprNode: ExpressionNode\n): Node | undefined {\n const val = convertExprToValue(exprNode);\n if (val === undefined) {\n return undefined;\n }\n\n return parseTree(JSON.stringify(val));\n}\n","import type { FunctionType, FunctionTypeParameters } from \"@player-tools/xlr\";\nimport { simpleTransformGenerator } from \"@player-tools/xlr-sdk\";\n\nexport const toFunction = simpleTransformGenerator(\n \"ref\",\n \"Expressions\",\n (exp) => {\n if (!exp.genericArguments || exp.ref !== \"ExpressionHandler\") {\n return exp;\n }\n\n const [args, returnType] = exp.genericArguments;\n\n const parameters: Array<FunctionTypeParameters> = (\n args.type === \"tuple\" ? args.elementTypes : []\n ).map((elementType, index) => {\n return {\n name:\n elementType.name ??\n elementType.type.name ??\n elementType.type.title ??\n `arg_${index}`,\n\n type: {\n name:\n elementType.name ??\n elementType.type.name ??\n elementType.type.title ??\n `arg_${index}`,\n ...elementType.type,\n },\n optional:\n elementType.optional === true ? elementType.optional : undefined,\n };\n });\n\n return {\n ...exp,\n type: \"function\",\n parameters,\n returnType,\n } as FunctionType as any;\n }\n);\n","import type { Logger } from \"typescript-template-language-service-decorator\";\nimport ts from \"typescript/lib/tsserverlibrary\";\n\nexport class LSPLogger implements Logger {\n private readonly info: ts.server.PluginCreateInfo;\n\n constructor(info: ts.server.PluginCreateInfo) {\n this.info = info;\n }\n\n log(msg: string) {\n this.info.project.projectService.logger.info(`[player-expr-lsp] ${msg}`);\n }\n}\n"],"mappings":";AACA,SAAS,2CAA2C;;;ACDpD,OAAO,QAAQ;AAOf,SAAS,yBAAyB;AAClC,SAAS,cAAc;AAEvB,SAAS,uBAAuB;;;ACPhC,SAAS,iBAAiB;AAInB,SAAS,UAAU,UAAoB,UAAwB;AACpE,SACE,SAAS,aAAa,SAAS,MAAM,aACrC,SAAS,aAAa,SAAS,IAAI;AAEvC;AAGO,SAAS,mBACd,MACA,UAC4B;AAC5B,MAAI,KAAK,SAAS,kBAAkB;AAClC,UAAM,UAAU,KAAK,KAAK,KAAK,CAAC,QAAQ;AACtC,aAAO,mBAAmB,KAAK,QAAQ;AAAA,IACzC,CAAC;AAED,QAAI,SAAS;AACX,aAAO;AAAA,IACT;AAEA,U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AAAA,EACV;AACF;;;AG/UO,IAAM,YAAN,MAAkC;AAAA,EACtB;AAAA,EAEjB,YAAY,MAAkC;AAC5C,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,IAAI,KAAa;AACf,SAAK,KAAK,QAAQ,eAAe,OAAO,KAAK,qBAAqB,GAAG,EAAE;AAAA,EACzE;AACF;;;AJLA,IAAM,SAAN,MAA+C;AAAA,EAC5B;AAAA,EACT;AAAA,EACA;AAAA,EAER,YAAY,aAAyB;AACnC,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,OAAO,MAAsD;AAC3D,UAAM,SAAS,IAAI,UAAU,IAAI;AACjC,SAAK,SAAS;AAEd,UAAM,kBAAkB,IAAI,0BAA0B,EAAE,OAAO,CAAC;AAChE,SAAK,kBAAkB;AAEvB,WAAO;AAAA,MACL,KAAK,YAAY;AAAA,MACjB,KAAK;AAAA,MACL,KAAK;AAAA,MACL;AAAA,MACA;AAAA,QACE,MAAM,CAAC,KAAK,QAAQ,YAAY;AAAA,QAChC,kCAAkC;AAAA,MACpC;AAAA,MACA,EAAE,OAAO;AAAA,IACX;AAAA,EACF;AAAA,EAEA,uBAAuB,QAAa;AAClC,SAAK,iBAAiB,UAAU,MAAM;AAAA,EACxC;AACF;AAEA,SAAS,KAAK,KAAyC;AACrD,SAAO,IAAI,OAAO,GAAG;AACvB;AAEA,IAAO,cAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@player-tools/typescript-expression-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-next.0",
|
|
4
4
|
"main": "dist/cjs/index.cjs",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@player-tools/xlr": "0.
|
|
7
|
-
"@player-tools/xlr-sdk": "0.
|
|
8
|
-
"@player-tools/xlr-utils": "0.
|
|
6
|
+
"@player-tools/xlr": "0.6.0-next.0",
|
|
7
|
+
"@player-tools/xlr-sdk": "0.6.0-next.0",
|
|
8
|
+
"@player-tools/xlr-utils": "0.6.0-next.0",
|
|
9
9
|
"@player-ui/player": "0.7.2-next.4",
|
|
10
10
|
"jsonc-parser": "^2.3.1",
|
|
11
11
|
"typescript-template-language-service-decorator": "^2.3.1",
|