@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,188 @@
|
|
|
1
|
+
import type { Node } from "jsonc-parser";
|
|
2
|
+
export type ASTNode = StringASTNode | NumberASTNode | BooleanASTNode | ArrayASTNode | NullASTNode | PropertyASTNode | ObjectASTNode | AssetASTNode | ViewASTNode | ContentASTNode | NavigationASTNode | FlowASTNode | EmptyASTNode | FlowStateASTNode;
|
|
3
|
+
export interface BaseASTNode<T extends string> {
|
|
4
|
+
/** The base type of the node */
|
|
5
|
+
readonly type: T;
|
|
6
|
+
/** an optional parent */
|
|
7
|
+
readonly parent?: ASTNode;
|
|
8
|
+
/** the underlying json node */
|
|
9
|
+
readonly jsonNode: Node;
|
|
10
|
+
/** any children of the node */
|
|
11
|
+
readonly children?: ASTNode[];
|
|
12
|
+
}
|
|
13
|
+
export interface StringASTNode extends BaseASTNode<"string"> {
|
|
14
|
+
/** the raw value */
|
|
15
|
+
readonly value: string;
|
|
16
|
+
}
|
|
17
|
+
export interface NumberASTNode extends BaseASTNode<"number"> {
|
|
18
|
+
/** the raw value */
|
|
19
|
+
readonly value: number;
|
|
20
|
+
}
|
|
21
|
+
export interface BooleanASTNode extends BaseASTNode<"boolean"> {
|
|
22
|
+
/** the raw value */
|
|
23
|
+
readonly value: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface ArrayASTNode extends BaseASTNode<"array"> {
|
|
26
|
+
/** the array items */
|
|
27
|
+
readonly children: Array<ASTNode>;
|
|
28
|
+
}
|
|
29
|
+
export interface NullASTNode extends BaseASTNode<"null"> {
|
|
30
|
+
/** the raw value */
|
|
31
|
+
readonly value: null;
|
|
32
|
+
}
|
|
33
|
+
export interface EmptyASTNode extends BaseASTNode<"empty"> {
|
|
34
|
+
/** the raw value */
|
|
35
|
+
readonly value: undefined;
|
|
36
|
+
}
|
|
37
|
+
export interface PropertyASTNode<T extends ASTNode = ASTNode> extends BaseASTNode<"property"> {
|
|
38
|
+
/** the key of the property */
|
|
39
|
+
readonly keyNode: StringASTNode;
|
|
40
|
+
/** the value of the property */
|
|
41
|
+
readonly valueNode?: T;
|
|
42
|
+
}
|
|
43
|
+
export interface ObjectASTNode<T extends string = "object"> extends BaseASTNode<T> {
|
|
44
|
+
/** an array of properties of this object */
|
|
45
|
+
properties: Array<PropertyASTNode>;
|
|
46
|
+
}
|
|
47
|
+
export interface AssetASTNode extends ObjectASTNode<"asset"> {
|
|
48
|
+
/** The id property for this asset */
|
|
49
|
+
readonly id?: PropertyASTNode<StringASTNode>;
|
|
50
|
+
/** The type property for this asset */
|
|
51
|
+
readonly assetType?: PropertyASTNode<StringASTNode>;
|
|
52
|
+
}
|
|
53
|
+
export interface ViewASTNode extends ObjectASTNode<"view"> {
|
|
54
|
+
/** the id property for this view */
|
|
55
|
+
readonly id?: PropertyASTNode<StringASTNode>;
|
|
56
|
+
/** the type of the view */
|
|
57
|
+
readonly viewType?: PropertyASTNode<StringASTNode>;
|
|
58
|
+
}
|
|
59
|
+
export interface ContentASTNode extends ObjectASTNode<"content"> {
|
|
60
|
+
/** the views prop of the flow */
|
|
61
|
+
readonly views?: PropertyASTNode<ArrayASTNode>;
|
|
62
|
+
/** the nav prop of the flow */
|
|
63
|
+
readonly navigation?: PropertyASTNode<NavigationASTNode>;
|
|
64
|
+
}
|
|
65
|
+
export interface NavigationASTNode extends ObjectASTNode<"navigation"> {
|
|
66
|
+
/** the begin prop of the navigation node */
|
|
67
|
+
readonly begin?: PropertyASTNode;
|
|
68
|
+
/** the flows of the navigation node */
|
|
69
|
+
readonly flows: Array<PropertyASTNode<FlowASTNode>>;
|
|
70
|
+
}
|
|
71
|
+
export interface FlowASTNode extends ObjectASTNode<"flow"> {
|
|
72
|
+
/** the start prop of the node */
|
|
73
|
+
readonly start?: PropertyASTNode<StringASTNode>;
|
|
74
|
+
/** the defined states */
|
|
75
|
+
readonly states: Array<PropertyASTNode<FlowStateASTNode>>;
|
|
76
|
+
}
|
|
77
|
+
export interface FlowStateASTNode extends ObjectASTNode<"state"> {
|
|
78
|
+
/** the type of the flow state */
|
|
79
|
+
readonly stateType?: PropertyASTNode<StringASTNode>;
|
|
80
|
+
}
|
|
81
|
+
/** The base class for any node implementation */
|
|
82
|
+
export declare abstract class ASTNodeImpl {
|
|
83
|
+
readonly parent: ASTNode | undefined;
|
|
84
|
+
readonly jsonNode: Node;
|
|
85
|
+
constructor(jsonNode: Node, parent: ASTNode | undefined);
|
|
86
|
+
}
|
|
87
|
+
/** An implementation of a string node */
|
|
88
|
+
export declare class StringASTNodeImpl extends ASTNodeImpl implements StringASTNode {
|
|
89
|
+
type: "string";
|
|
90
|
+
value: string;
|
|
91
|
+
constructor(jsonNode: Node, parent?: ASTNode);
|
|
92
|
+
}
|
|
93
|
+
/** An implementation of the number node */
|
|
94
|
+
export declare class NumberASTNodeImpl extends ASTNodeImpl implements NumberASTNode {
|
|
95
|
+
type: "number";
|
|
96
|
+
value: number;
|
|
97
|
+
constructor(jsonNode: Node, parent?: ASTNode);
|
|
98
|
+
}
|
|
99
|
+
/** An implementation of a boolean node */
|
|
100
|
+
export declare class BooleanASTNodeImpl extends ASTNodeImpl implements BooleanASTNode {
|
|
101
|
+
type: "boolean";
|
|
102
|
+
value: boolean;
|
|
103
|
+
constructor(jsonNode: Node, parent?: ASTNode);
|
|
104
|
+
}
|
|
105
|
+
/** An implementation of a null node */
|
|
106
|
+
export declare class NullASTNodeImpl extends ASTNodeImpl implements NullASTNode {
|
|
107
|
+
type: "null";
|
|
108
|
+
value: null;
|
|
109
|
+
}
|
|
110
|
+
/** An implementation of a property node */
|
|
111
|
+
export declare class PropertyASTNodeImpl extends ASTNodeImpl implements PropertyASTNode {
|
|
112
|
+
type: "property";
|
|
113
|
+
keyNode: StringASTNode;
|
|
114
|
+
valueNode?: ASTNode;
|
|
115
|
+
constructor(jsonNode: Node, parent: ASTNode | undefined, keyNode: StringASTNode);
|
|
116
|
+
get children(): ASTNode[];
|
|
117
|
+
}
|
|
118
|
+
/** An implementation of a view node */
|
|
119
|
+
export declare class ViewASTNodeImpl extends ASTNodeImpl implements ViewASTNode {
|
|
120
|
+
type: "view";
|
|
121
|
+
properties: PropertyASTNode[];
|
|
122
|
+
id?: PropertyASTNode<StringASTNode>;
|
|
123
|
+
viewType?: PropertyASTNode<StringASTNode>;
|
|
124
|
+
get children(): PropertyASTNode<ASTNode>[];
|
|
125
|
+
}
|
|
126
|
+
/** An implementation of a top flow node */
|
|
127
|
+
export declare class ContentASTNodeImpl extends ASTNodeImpl implements ContentASTNode {
|
|
128
|
+
type: "content";
|
|
129
|
+
properties: PropertyASTNode[];
|
|
130
|
+
views?: PropertyASTNode<ArrayASTNode>;
|
|
131
|
+
navigation?: PropertyASTNode<NavigationASTNode>;
|
|
132
|
+
get children(): PropertyASTNode<ASTNode>[];
|
|
133
|
+
}
|
|
134
|
+
/** An implementation of a navigation node */
|
|
135
|
+
export declare class NavigationASTNodeImpl extends ASTNodeImpl implements NavigationASTNode {
|
|
136
|
+
type: "navigation";
|
|
137
|
+
properties: PropertyASTNode[];
|
|
138
|
+
begin?: PropertyASTNode<StringASTNode>;
|
|
139
|
+
flows: Array<PropertyASTNode<FlowASTNode>>;
|
|
140
|
+
get children(): PropertyASTNode<ASTNode>[];
|
|
141
|
+
}
|
|
142
|
+
/** An implementation of a flow node */
|
|
143
|
+
export declare class FlowASTNodeImpl extends ASTNodeImpl implements FlowASTNode {
|
|
144
|
+
type: "flow";
|
|
145
|
+
properties: PropertyASTNode[];
|
|
146
|
+
start?: PropertyASTNode<StringASTNode>;
|
|
147
|
+
states: Array<PropertyASTNode<FlowStateASTNode>>;
|
|
148
|
+
get children(): PropertyASTNode<ASTNode>[];
|
|
149
|
+
}
|
|
150
|
+
/** An implementation of a flow-state node */
|
|
151
|
+
export declare class FlowStateASTNodeImpl extends ASTNodeImpl implements FlowStateASTNode {
|
|
152
|
+
type: "state";
|
|
153
|
+
properties: PropertyASTNode[];
|
|
154
|
+
stateType?: PropertyASTNode<StringASTNode>;
|
|
155
|
+
get children(): PropertyASTNode<ASTNode>[];
|
|
156
|
+
}
|
|
157
|
+
/** An implementation of an asset node */
|
|
158
|
+
export declare class AssetASTNodeImpl extends ASTNodeImpl implements AssetASTNode {
|
|
159
|
+
type: "asset";
|
|
160
|
+
properties: PropertyASTNode[];
|
|
161
|
+
id?: PropertyASTNode<StringASTNode>;
|
|
162
|
+
assetType?: PropertyASTNode<StringASTNode>;
|
|
163
|
+
get children(): PropertyASTNode<ASTNode>[];
|
|
164
|
+
}
|
|
165
|
+
/** An implementation of a array node */
|
|
166
|
+
export declare class ArrayASTNodeImpl extends ASTNodeImpl implements ArrayASTNode {
|
|
167
|
+
type: "array";
|
|
168
|
+
items: ASTNode[];
|
|
169
|
+
get children(): ASTNode[];
|
|
170
|
+
}
|
|
171
|
+
/** An implementation of an object node */
|
|
172
|
+
export declare class ObjectASTNodeImpl extends ASTNodeImpl implements ObjectASTNode {
|
|
173
|
+
type: "object";
|
|
174
|
+
properties: PropertyASTNode[];
|
|
175
|
+
get children(): PropertyASTNode<ASTNode>[];
|
|
176
|
+
}
|
|
177
|
+
export type NodeEdit = ReplaceEdit;
|
|
178
|
+
export interface BaseNodeEdit<T extends string> {
|
|
179
|
+
/** The type of node edit */
|
|
180
|
+
type: T;
|
|
181
|
+
/** the node to edit */
|
|
182
|
+
node: ASTNode;
|
|
183
|
+
}
|
|
184
|
+
export interface ReplaceEdit extends BaseNodeEdit<"replace"> {
|
|
185
|
+
/** the new value to replace with */
|
|
186
|
+
value: any;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ASTNode, PropertyASTNode, StringASTNode, ViewASTNode, ContentASTNode, FlowStateASTNode, ObjectASTNode, FlowASTNode, NavigationASTNode, AssetASTNode } from "./types";
|
|
2
|
+
/** check if the node is a property */
|
|
3
|
+
export declare function isPropertyNode(node?: ASTNode): node is PropertyASTNode;
|
|
4
|
+
/** check if the node is an object ast */
|
|
5
|
+
export declare function isObjectNode(node?: ASTNode): node is ObjectASTNode;
|
|
6
|
+
/** check if the node is a key */
|
|
7
|
+
export declare function isKeyNode(node?: ASTNode): node is StringASTNode;
|
|
8
|
+
/** check if the node is a value */
|
|
9
|
+
export declare function isValueNode(node?: ASTNode): boolean;
|
|
10
|
+
/** check if the node is a view */
|
|
11
|
+
export declare function isViewNode(node?: ASTNode): node is ViewASTNode;
|
|
12
|
+
/** check if the node is a state */
|
|
13
|
+
export declare function isStateNode(node?: ASTNode): node is FlowStateASTNode;
|
|
14
|
+
/** check if the node is a flow */
|
|
15
|
+
export declare function isFlowNode(node?: ASTNode): node is FlowASTNode;
|
|
16
|
+
/** check if the node is a nav */
|
|
17
|
+
export declare function isNavigationNode(node?: ASTNode): node is NavigationASTNode;
|
|
18
|
+
/** get the value for a given key in the object */
|
|
19
|
+
export declare function getValForKey<T extends ObjectASTNode<any>>(node: T, key: string): any;
|
|
20
|
+
/** get the key for the given value node */
|
|
21
|
+
export declare function getPropForValNode(node?: ASTNode): string | undefined;
|
|
22
|
+
/** find the view node */
|
|
23
|
+
export declare function getViewNode(node: ASTNode): ViewASTNode | AssetASTNode | undefined;
|
|
24
|
+
/** traverse up until we find the root content node */
|
|
25
|
+
export declare function getContentNode(node: ASTNode): ContentASTNode | undefined;
|
|
26
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PlayerLanguageService, PlayerLanguageServicePlugin } from "..";
|
|
2
|
+
/**
|
|
3
|
+
* Looks for an array where there _should_ be an AssetWrapper
|
|
4
|
+
*/
|
|
5
|
+
export declare class AssetWrapperArrayPlugin implements PlayerLanguageServicePlugin {
|
|
6
|
+
name: string;
|
|
7
|
+
apply(service: PlayerLanguageService): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=asset-wrapper-array-plugin.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PlayerLanguageService, PlayerLanguageServicePlugin } from "..";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Adds completions for:
|
|
5
|
+
* - any `Binding` type from TS
|
|
6
|
+
* - "type" and "key" for non-defined types
|
|
7
|
+
*
|
|
8
|
+
* Adds definitions for:
|
|
9
|
+
* - any `Binding` reference to the schema def
|
|
10
|
+
*/
|
|
11
|
+
export declare class SchemaInfoPlugin implements PlayerLanguageServicePlugin {
|
|
12
|
+
name: string;
|
|
13
|
+
apply(service: PlayerLanguageService): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=binding-schema-plugin.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PlayerLanguageService, PlayerLanguageServicePlugin } from "..";
|
|
2
|
+
/** The plugin to enable duplicate id checking/fixing */
|
|
3
|
+
export declare class DuplicateIDPlugin implements PlayerLanguageServicePlugin {
|
|
4
|
+
name: string;
|
|
5
|
+
apply(service: PlayerLanguageService): void;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=duplicate-id-plugin.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PlayerLanguageService, PlayerLanguageServicePlugin } from "..";
|
|
2
|
+
/**
|
|
3
|
+
* A plugin to help identify and fix the issue of forgetting the "asset" wrapper object
|
|
4
|
+
*/
|
|
5
|
+
export declare class MissingAssetWrapperPlugin implements PlayerLanguageServicePlugin {
|
|
6
|
+
name: string;
|
|
7
|
+
apply(languageService: PlayerLanguageService): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=missing-asset-wrapper-plugin.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PlayerLanguageService, PlayerLanguageServicePlugin } from "..";
|
|
2
|
+
/**
|
|
3
|
+
* Handles everything associated with navigation nodes (transitions, jump-to-def, reachability)
|
|
4
|
+
*/
|
|
5
|
+
export declare class NavStatePlugin implements PlayerLanguageServicePlugin {
|
|
6
|
+
name: string;
|
|
7
|
+
apply(service: PlayerLanguageService): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=nav-state-plugin.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PlayerLanguageService, PlayerLanguageServicePlugin } from "..";
|
|
2
|
+
/**
|
|
3
|
+
* Handles everything associated with the VIEW node type (definition, validation, auto-complete)
|
|
4
|
+
*/
|
|
5
|
+
export declare class ViewNodePlugin implements PlayerLanguageServicePlugin {
|
|
6
|
+
name: string;
|
|
7
|
+
apply(service: PlayerLanguageService): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=view-node-plugin.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PlayerLanguageService, PlayerLanguageServicePlugin } from "..";
|
|
2
|
+
/** The plugin to enable duplicate id checking/fixing */
|
|
3
|
+
export declare class XLRPlugin implements PlayerLanguageServicePlugin {
|
|
4
|
+
name: string;
|
|
5
|
+
apply(service: PlayerLanguageService): void;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=xlr-plugin.d.ts.map
|
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { TextDocument } from "vscode-languageserver-textdocument";
|
|
2
|
+
import type { Position, DiagnosticSeverity, Diagnostic, CompletionItem } from "vscode-languageserver-types";
|
|
3
|
+
import type { ASTNode, PlayerContent, StringASTNode, NumberASTNode, ArrayASTNode, BooleanASTNode, PropertyASTNode, ObjectASTNode, ViewASTNode, ContentASTNode, NullASTNode, AssetASTNode, FlowStateASTNode, NavigationASTNode, FlowASTNode, NodeEdit, EmptyASTNode } from "./parser";
|
|
4
|
+
import type { XLRContext } from "./xlr";
|
|
5
|
+
export type LogFn = (msg: string) => void;
|
|
6
|
+
export declare const LOG_TYPES: readonly ["debug", "info", "warn", "error"];
|
|
7
|
+
export type LogType = (typeof LOG_TYPES)[number];
|
|
8
|
+
export type Logger = Record<LogType, LogFn>;
|
|
9
|
+
export interface DocumentContext {
|
|
10
|
+
/** A logger to log messages */
|
|
11
|
+
log: Logger;
|
|
12
|
+
/** the underlying text document */
|
|
13
|
+
document: TextDocument;
|
|
14
|
+
/** the json parsed text document */
|
|
15
|
+
PlayerContent: PlayerContent;
|
|
16
|
+
}
|
|
17
|
+
export interface DocumentContextWithPosition extends DocumentContext {
|
|
18
|
+
/** the position we care about */
|
|
19
|
+
position: Position;
|
|
20
|
+
/** the node at that position */
|
|
21
|
+
node: ASTNode;
|
|
22
|
+
}
|
|
23
|
+
export interface EnhancedDocumentContextWithPosition extends DocumentContextWithPosition {
|
|
24
|
+
/** the XLRs context */
|
|
25
|
+
XLR?: XLRContext;
|
|
26
|
+
}
|
|
27
|
+
export type ASTVisitorFn<T extends ASTNode> = (node: T) => void;
|
|
28
|
+
export interface ASTVisitor {
|
|
29
|
+
/** a string node visitor */
|
|
30
|
+
StringNode?: ASTVisitorFn<StringASTNode>;
|
|
31
|
+
/** a number node visitor */
|
|
32
|
+
NumberNode?: ASTVisitorFn<NumberASTNode>;
|
|
33
|
+
/** an boolean node visitor */
|
|
34
|
+
BooleanNode?: ASTVisitorFn<BooleanASTNode>;
|
|
35
|
+
/** an array node visitor */
|
|
36
|
+
ArrayNode?: ASTVisitorFn<ArrayASTNode>;
|
|
37
|
+
/** a null node visitor */
|
|
38
|
+
NullNode?: ASTVisitorFn<NullASTNode>;
|
|
39
|
+
/** an empty node visitor */
|
|
40
|
+
EmptyNode?: ASTVisitorFn<EmptyASTNode>;
|
|
41
|
+
/** a property node visitor */
|
|
42
|
+
PropertyNode?: ASTVisitorFn<PropertyASTNode>;
|
|
43
|
+
/** an object node visitor */
|
|
44
|
+
ObjectNode?: ASTVisitorFn<ObjectASTNode>;
|
|
45
|
+
/** an asset node visitor */
|
|
46
|
+
AssetNode?: ASTVisitorFn<AssetASTNode>;
|
|
47
|
+
/** a view node visitor */
|
|
48
|
+
ViewNode?: ASTVisitorFn<ViewASTNode>;
|
|
49
|
+
/** a flow node visitor */
|
|
50
|
+
ContentNode?: ASTVisitorFn<ContentASTNode>;
|
|
51
|
+
/** a navigation node visitor */
|
|
52
|
+
NavigationNode?: ASTVisitorFn<NavigationASTNode>;
|
|
53
|
+
/** a flow node visitor */
|
|
54
|
+
FlowNode?: ASTVisitorFn<FlowASTNode>;
|
|
55
|
+
/** a flow state node visitor */
|
|
56
|
+
FlowStateNode?: ASTVisitorFn<FlowStateASTNode>;
|
|
57
|
+
}
|
|
58
|
+
export interface Violation {
|
|
59
|
+
/** the node the violation is for */
|
|
60
|
+
node: ASTNode;
|
|
61
|
+
/** the message to show */
|
|
62
|
+
message: string;
|
|
63
|
+
/** how much do we care? */
|
|
64
|
+
severity: DiagnosticSeverity;
|
|
65
|
+
/** A function that can make this good */
|
|
66
|
+
fix?: () => {
|
|
67
|
+
/** the edit to apply */
|
|
68
|
+
edit: NodeEdit;
|
|
69
|
+
/** A name for your fix */
|
|
70
|
+
name: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export interface ValidationContext {
|
|
74
|
+
addViolation(violation: Violation): void;
|
|
75
|
+
addDiagnostic(diagnostic: Diagnostic): void;
|
|
76
|
+
useASTVisitor(visitor: ASTVisitor): void;
|
|
77
|
+
}
|
|
78
|
+
export interface CompletionContext {
|
|
79
|
+
addCompletionItem(item: CompletionItem): void;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=types.d.ts.map
|
package/types/utils.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Range, Location } from "vscode-languageserver-types";
|
|
2
|
+
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
|
+
import type { ASTNode, PlayerContent, PropertyASTNode } from "./parser";
|
|
4
|
+
import type { ASTVisitor } from "./types";
|
|
5
|
+
export declare const typeToVisitorMap: Record<ASTNode["type"], keyof ASTVisitor>;
|
|
6
|
+
/** Check to see if the source range contains the target one */
|
|
7
|
+
export declare function containsRange(source: Range, range: Range): boolean;
|
|
8
|
+
/** Create a dummy TextDocument from the given string */
|
|
9
|
+
export declare function toTextDocument(str: string): TextDocument;
|
|
10
|
+
/** Check to see if the document successfully parsed into a known root type */
|
|
11
|
+
export declare function isKnownRootType(document: PlayerContent): boolean;
|
|
12
|
+
/** Check to see if the node is the value of an object */
|
|
13
|
+
export declare function isValueCompletion(node: ASTNode): boolean;
|
|
14
|
+
/** Check to see if the node is the key of an object */
|
|
15
|
+
export declare function isPropertyCompletion(node: ASTNode): boolean;
|
|
16
|
+
/** Search the object for a property with the given name */
|
|
17
|
+
export declare function getProperty<T extends ASTNode>(obj: T, name: string): PropertyASTNode | undefined;
|
|
18
|
+
/** Get the LSP Location of an AST node in a document */
|
|
19
|
+
export declare function getLSLocationOfNode(document: TextDocument, node: ASTNode): Location;
|
|
20
|
+
/** Format a new node like an existing one (including the indentation) */
|
|
21
|
+
export declare function formatLikeNode(document: TextDocument, originalNode: ASTNode, replacement: Record<string, unknown>): string;
|
|
22
|
+
/** Maps the string identifying the FlowType to the named type */
|
|
23
|
+
export declare function mapFlowStateToType(flowType: string | undefined): string | undefined;
|
|
24
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Filters, TypeMetadata } from "@xlr-lib/xlr-sdk";
|
|
2
|
+
import { BasicXLRRegistry } from "@xlr-lib/xlr-sdk";
|
|
3
|
+
import type { NamedType, NodeType } from "@xlr-lib/xlr";
|
|
4
|
+
/**
|
|
5
|
+
* Player specific implementation of a XLRs Registry
|
|
6
|
+
*/
|
|
7
|
+
export declare class PlayerXLRRegistry extends BasicXLRRegistry {
|
|
8
|
+
/** Keeps the mapping of how a type is referenced by Player to the underlying XLR */
|
|
9
|
+
private registrationMap;
|
|
10
|
+
constructor();
|
|
11
|
+
get(id: string): NamedType<NodeType> | undefined;
|
|
12
|
+
add(type: NamedType<NodeType>, plugin: string, capability: string): void;
|
|
13
|
+
has(id: string): boolean;
|
|
14
|
+
list(filterArgs?: Filters): NamedType<NodeType>[];
|
|
15
|
+
info(id: string): TypeMetadata | undefined;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { XLRSDK } from "@xlr-lib/xlr-sdk";
|
|
2
|
+
import type { NodeType, ObjectType } from "@xlr-lib/xlr";
|
|
3
|
+
import type { ASTNode } from "../parser";
|
|
4
|
+
export interface XLRContext {
|
|
5
|
+
/** The name of the XLR at the provided position */
|
|
6
|
+
name: string;
|
|
7
|
+
/** The position(s) in the XLR at the specified node */
|
|
8
|
+
nodes: Array<NodeType>;
|
|
9
|
+
/** The nearest objects(s) to the specified node */
|
|
10
|
+
nearestObjects: Array<ObjectType>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* XLRs Manager for
|
|
14
|
+
*/
|
|
15
|
+
export declare class XLRService {
|
|
16
|
+
private baseTypes;
|
|
17
|
+
XLRSDK: XLRSDK;
|
|
18
|
+
constructor();
|
|
19
|
+
private walker;
|
|
20
|
+
getTypeInfoAtPosition(node: ASTNode | undefined): XLRContext | undefined;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TransformFunction } from "@xlr-lib/xlr";
|
|
2
|
+
/**
|
|
3
|
+
* Adds applicability and _comment properties to Assets
|
|
4
|
+
*/
|
|
5
|
+
export declare const applyCommonProps: TransformFunction;
|
|
6
|
+
/**
|
|
7
|
+
* Replaces AssetWrapper References with AssetWrapperOrSwitch
|
|
8
|
+
*/
|
|
9
|
+
export declare const applyAssetWrapperOrSwitch: TransformFunction;
|
|
10
|
+
/**
|
|
11
|
+
* Modifies any primitive type property node (except id/type) to be Bindings or Expressions
|
|
12
|
+
*/
|
|
13
|
+
export declare const applyValueRefs: TransformFunction;
|
|
14
|
+
/**
|
|
15
|
+
* Computes possible template keys and adds them to an Asset
|
|
16
|
+
*/
|
|
17
|
+
export declare const applyTemplateProperty: TransformFunction;
|
|
18
|
+
//# sourceMappingURL=transforms.d.ts.map
|