sfmc-language-lsp 1.10.2 → 2.0.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/README.md +20 -0
- package/dist/cjs/codeActions/mcnHandlebars.cjs +77 -0
- package/dist/cjs/codeActions/mcnHandlebars.d.ts +17 -0
- package/dist/cjs/codeActions/mcnHandlebars.d.ts.map +1 -0
- package/dist/cjs/codeActions/mcnHandlebars.js.map +1 -0
- package/dist/cjs/completions/ampscript.cjs +7 -2
- package/dist/cjs/completions/ampscript.d.ts +3 -2
- package/dist/cjs/completions/ampscript.d.ts.map +1 -1
- package/dist/cjs/completions/ampscript.js.map +1 -1
- package/dist/cjs/completions/mcnHandlebars.cjs +135 -0
- package/dist/cjs/completions/mcnHandlebars.d.ts +33 -0
- package/dist/cjs/completions/mcnHandlebars.d.ts.map +1 -0
- package/dist/cjs/completions/mcnHandlebars.js.map +1 -0
- package/dist/cjs/data/handlebars.cjs +34 -0
- package/dist/cjs/data/handlebars.d.ts +25 -0
- package/dist/cjs/data/handlebars.d.ts.map +1 -0
- package/dist/cjs/data/handlebars.js.map +1 -0
- package/dist/cjs/hover/mcnHandlebars.cjs +102 -0
- package/dist/cjs/hover/mcnHandlebars.d.ts +20 -0
- package/dist/cjs/hover/mcnHandlebars.d.ts.map +1 -0
- package/dist/cjs/hover/mcnHandlebars.js.map +1 -0
- package/dist/cjs/index.cjs +97 -7
- package/dist/cjs/index.d.ts +37 -4
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/signature/mcnHandlebars.cjs +163 -0
- package/dist/cjs/signature/mcnHandlebars.d.ts +39 -0
- package/dist/cjs/signature/mcnHandlebars.d.ts.map +1 -0
- package/dist/cjs/signature/mcnHandlebars.js.map +1 -0
- package/dist/cjs/utils/closestMatch.cjs +63 -0
- package/dist/cjs/utils/closestMatch.d.ts +25 -0
- package/dist/cjs/utils/closestMatch.d.ts.map +1 -0
- package/dist/cjs/utils/closestMatch.js.map +1 -0
- package/dist/cjs/utils/handlebarsAst.cjs +130 -0
- package/dist/cjs/utils/handlebarsAst.d.ts +52 -0
- package/dist/cjs/utils/handlebarsAst.d.ts.map +1 -0
- package/dist/cjs/utils/handlebarsAst.js.map +1 -0
- package/dist/cjs/utils/handlebarsScopeTracker.cjs +144 -0
- package/dist/cjs/utils/handlebarsScopeTracker.d.ts +58 -0
- package/dist/cjs/utils/handlebarsScopeTracker.d.ts.map +1 -0
- package/dist/cjs/utils/handlebarsScopeTracker.js.map +1 -0
- package/dist/cjs/utils/markdown.cjs +80 -0
- package/dist/cjs/utils/markdown.d.ts +26 -0
- package/dist/cjs/utils/markdown.d.ts.map +1 -1
- package/dist/cjs/utils/markdown.js.map +1 -1
- package/dist/cjs/utils/regions.cjs +48 -0
- package/dist/cjs/utils/regions.d.ts +20 -0
- package/dist/cjs/utils/regions.d.ts.map +1 -1
- package/dist/cjs/utils/regions.js.map +1 -1
- package/dist/cjs/validators/ampscript.cjs +13 -3
- package/dist/cjs/validators/ampscript.d.ts.map +1 -1
- package/dist/cjs/validators/ampscript.js.map +1 -1
- package/dist/cjs/validators/mcnHandlebars.cjs +214 -0
- package/dist/cjs/validators/mcnHandlebars.d.ts +44 -0
- package/dist/cjs/validators/mcnHandlebars.d.ts.map +1 -0
- package/dist/cjs/validators/mcnHandlebars.js.map +1 -0
- package/dist/esm/codeActions/mcnHandlebars.d.ts +17 -0
- package/dist/esm/codeActions/mcnHandlebars.d.ts.map +1 -0
- package/dist/esm/codeActions/mcnHandlebars.js +74 -0
- package/dist/esm/codeActions/mcnHandlebars.js.map +1 -0
- package/dist/esm/completions/ampscript.d.ts +3 -2
- package/dist/esm/completions/ampscript.d.ts.map +1 -1
- package/dist/esm/completions/ampscript.js +7 -2
- package/dist/esm/completions/ampscript.js.map +1 -1
- package/dist/esm/completions/mcnHandlebars.d.ts +33 -0
- package/dist/esm/completions/mcnHandlebars.d.ts.map +1 -0
- package/dist/esm/completions/mcnHandlebars.js +130 -0
- package/dist/esm/completions/mcnHandlebars.js.map +1 -0
- package/dist/esm/data/handlebars.d.ts +25 -0
- package/dist/esm/data/handlebars.d.ts.map +1 -0
- package/dist/esm/data/handlebars.js +18 -0
- package/dist/esm/data/handlebars.js.map +1 -0
- package/dist/esm/hover/mcnHandlebars.d.ts +20 -0
- package/dist/esm/hover/mcnHandlebars.d.ts.map +1 -0
- package/dist/esm/hover/mcnHandlebars.js +99 -0
- package/dist/esm/hover/mcnHandlebars.js.map +1 -0
- package/dist/esm/index.d.ts +37 -4
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +97 -7
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/signature/mcnHandlebars.d.ts +39 -0
- package/dist/esm/signature/mcnHandlebars.d.ts.map +1 -0
- package/dist/esm/signature/mcnHandlebars.js +159 -0
- package/dist/esm/signature/mcnHandlebars.js.map +1 -0
- package/dist/esm/utils/closestMatch.d.ts +25 -0
- package/dist/esm/utils/closestMatch.d.ts.map +1 -0
- package/dist/esm/utils/closestMatch.js +59 -0
- package/dist/esm/utils/closestMatch.js.map +1 -0
- package/dist/esm/utils/handlebarsAst.d.ts +52 -0
- package/dist/esm/utils/handlebarsAst.d.ts.map +1 -0
- package/dist/esm/utils/handlebarsAst.js +124 -0
- package/dist/esm/utils/handlebarsAst.js.map +1 -0
- package/dist/esm/utils/handlebarsScopeTracker.d.ts +58 -0
- package/dist/esm/utils/handlebarsScopeTracker.d.ts.map +1 -0
- package/dist/esm/utils/handlebarsScopeTracker.js +140 -0
- package/dist/esm/utils/handlebarsScopeTracker.js.map +1 -0
- package/dist/esm/utils/markdown.d.ts +26 -0
- package/dist/esm/utils/markdown.d.ts.map +1 -1
- package/dist/esm/utils/markdown.js +77 -0
- package/dist/esm/utils/markdown.js.map +1 -1
- package/dist/esm/utils/regions.d.ts +20 -0
- package/dist/esm/utils/regions.d.ts.map +1 -1
- package/dist/esm/utils/regions.js +46 -0
- package/dist/esm/utils/regions.js.map +1 -1
- package/dist/esm/validators/ampscript.d.ts.map +1 -1
- package/dist/esm/validators/ampscript.js +13 -3
- package/dist/esm/validators/ampscript.js.map +1 -1
- package/dist/esm/validators/mcnHandlebars.d.ts +44 -0
- package/dist/esm/validators/mcnHandlebars.d.ts.map +1 -0
- package/dist/esm/validators/mcnHandlebars.js +210 -0
- package/dist/esm/validators/mcnHandlebars.js.map +1 -0
- package/dist/types/codeActions/mcnHandlebars.d.ts +17 -0
- package/dist/types/codeActions/mcnHandlebars.d.ts.map +1 -0
- package/dist/types/completions/ampscript.d.ts +3 -2
- package/dist/types/completions/ampscript.d.ts.map +1 -1
- package/dist/types/completions/mcnHandlebars.d.ts +33 -0
- package/dist/types/completions/mcnHandlebars.d.ts.map +1 -0
- package/dist/types/data/handlebars.d.ts +25 -0
- package/dist/types/data/handlebars.d.ts.map +1 -0
- package/dist/types/hover/mcnHandlebars.d.ts +20 -0
- package/dist/types/hover/mcnHandlebars.d.ts.map +1 -0
- package/dist/types/index.d.ts +37 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/signature/mcnHandlebars.d.ts +39 -0
- package/dist/types/signature/mcnHandlebars.d.ts.map +1 -0
- package/dist/types/utils/closestMatch.d.ts +25 -0
- package/dist/types/utils/closestMatch.d.ts.map +1 -0
- package/dist/types/utils/handlebarsAst.d.ts +52 -0
- package/dist/types/utils/handlebarsAst.d.ts.map +1 -0
- package/dist/types/utils/handlebarsScopeTracker.d.ts +58 -0
- package/dist/types/utils/handlebarsScopeTracker.d.ts.map +1 -0
- package/dist/types/utils/markdown.d.ts +26 -0
- package/dist/types/utils/markdown.d.ts.map +1 -1
- package/dist/types/utils/regions.d.ts +20 -0
- package/dist/types/utils/regions.d.ts.map +1 -1
- package/dist/types/validators/ampscript.d.ts.map +1 -1
- package/dist/types/validators/mcnHandlebars.d.ts +44 -0
- package/dist/types/validators/mcnHandlebars.d.ts.map +1 -0
- package/package.json +4 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { Diagnostic, CompletionItem, Hover, SignatureHelp, Location, CodeAc
|
|
|
9
9
|
import type { SfmcSettings } from './types.js';
|
|
10
10
|
import type { AmpscriptCallSite } from './validators/ampscript.js';
|
|
11
11
|
import type { SsjsFunction } from './data/ssjs.js';
|
|
12
|
+
import type { HandlebarsHelper, HandlebarsBinding, HandlebarsUnsupportedConstruct } from './data/handlebars.js';
|
|
12
13
|
export type { DocumentContext, SfmcSettings } from './types.js';
|
|
13
14
|
export { DEFAULT_SETTINGS } from './types.js';
|
|
14
15
|
export type { AmpscriptFunction, AmpscriptFunctionParam } from './data/ampscript.js';
|
|
@@ -16,6 +17,7 @@ export { isMcnSupported, getMcnApiVersion, getMcnNotes } from './data/ampscript.
|
|
|
16
17
|
export type { AmpscriptCallSite } from './validators/ampscript.js';
|
|
17
18
|
export type { SsjsFunction, SsjsFunctionParam, EcmascriptBuiltin, SsjsObject, } from './data/ssjs.js';
|
|
18
19
|
export type { LocalSsjsFunction } from './utils/markdown.js';
|
|
20
|
+
export type { HandlebarsHelper, HandlebarsBinding, HandlebarsUnsupportedConstruct, HandlebarsDataParam, } from './data/handlebars.js';
|
|
19
21
|
/** Import DocumentContext type locally for use in this file */
|
|
20
22
|
import type { DocumentContext } from './types.js';
|
|
21
23
|
/**
|
|
@@ -34,9 +36,10 @@ export declare class SfmcLanguageService {
|
|
|
34
36
|
* Return completion items at the given cursor position.
|
|
35
37
|
* @param doc - Document context with text and language ID.
|
|
36
38
|
* @param position - Cursor position.
|
|
39
|
+
* @param settings - Service settings (gates MCN Handlebars completions).
|
|
37
40
|
* @returns Array of LSP CompletionItem objects.
|
|
38
41
|
*/
|
|
39
|
-
getCompletions(doc: DocumentContext, position: Position): CompletionItem[];
|
|
42
|
+
getCompletions(doc: DocumentContext, position: Position, settings?: SfmcSettings): CompletionItem[];
|
|
40
43
|
/**
|
|
41
44
|
* Resolve documentation for a completion item (lazy-loaded).
|
|
42
45
|
* @param item - Completion item to resolve.
|
|
@@ -48,16 +51,18 @@ export declare class SfmcLanguageService {
|
|
|
48
51
|
* @param doc - Document context with text and language ID.
|
|
49
52
|
* @param line - The current document line text.
|
|
50
53
|
* @param position - The cursor position.
|
|
54
|
+
* @param settings - Service settings (gates MCN Handlebars hover).
|
|
51
55
|
* @returns Hover object with Markdown documentation, or null.
|
|
52
56
|
*/
|
|
53
|
-
getHover(doc: DocumentContext, line: string, position: Position): Hover | null;
|
|
57
|
+
getHover(doc: DocumentContext, line: string, position: Position, settings?: SfmcSettings): Hover | null;
|
|
54
58
|
/**
|
|
55
59
|
* Return signature help at the given cursor position.
|
|
56
60
|
* @param doc - Document context with text and language ID.
|
|
57
61
|
* @param textUpToCursor - The document text from the start up to the cursor.
|
|
62
|
+
* @param settings - Service settings (gates MCN Handlebars signature help).
|
|
58
63
|
* @returns SignatureHelp object, or null if outside a function call.
|
|
59
64
|
*/
|
|
60
|
-
getSignatureHelp(doc: DocumentContext, textUpToCursor: string): SignatureHelp | null;
|
|
65
|
+
getSignatureHelp(doc: DocumentContext, textUpToCursor: string, settings?: SfmcSettings): SignatureHelp | null;
|
|
61
66
|
/**
|
|
62
67
|
* Return the definition location for the word at the given position. Only SSJS is supported.
|
|
63
68
|
* @param doc - Document context with text and language ID.
|
|
@@ -69,9 +74,10 @@ export declare class SfmcLanguageService {
|
|
|
69
74
|
* Return quick-fix code actions for the given diagnostics.
|
|
70
75
|
* @param doc - Document context with text and language ID.
|
|
71
76
|
* @param diagnostics - Diagnostics to generate actions for.
|
|
77
|
+
* @param settings - Service settings (gates MCN Handlebars code actions).
|
|
72
78
|
* @returns Array of code actions.
|
|
73
79
|
*/
|
|
74
|
-
getCodeActions(doc: DocumentContext, diagnostics: Diagnostic[]): CodeAction[];
|
|
80
|
+
getCodeActions(doc: DocumentContext, diagnostics: Diagnostic[], settings?: SfmcSettings): CodeAction[];
|
|
75
81
|
/**
|
|
76
82
|
* Look up an AMPscript function by name. Case-insensitive.
|
|
77
83
|
* @param name - Function name to look up.
|
|
@@ -122,6 +128,33 @@ export declare class SfmcLanguageService {
|
|
|
122
128
|
* @returns Array of pre-built AMPscript function completion items.
|
|
123
129
|
*/
|
|
124
130
|
getAmpscriptFunctionCompletionItems(): CompletionItem[];
|
|
131
|
+
/**
|
|
132
|
+
* Look up an MCN Handlebars helper by name. Case-insensitive.
|
|
133
|
+
* @param name - Helper name to look up (camelCase invoke form).
|
|
134
|
+
* @returns The Handlebars helper descriptor, or null if not found.
|
|
135
|
+
*/
|
|
136
|
+
lookupHandlebarsHelper(name: string): HandlebarsHelper | null;
|
|
137
|
+
/**
|
|
138
|
+
* Return all MCN Handlebars helpers from the catalog.
|
|
139
|
+
* @returns Array of all Handlebars helper descriptors.
|
|
140
|
+
*/
|
|
141
|
+
listHandlebarsHelpers(): HandlebarsHelper[];
|
|
142
|
+
/**
|
|
143
|
+
* Return all built-in `{!$...}` data bindings from the catalog.
|
|
144
|
+
* @returns Array of all Handlebars binding descriptors.
|
|
145
|
+
*/
|
|
146
|
+
listHandlebarsBindings(): HandlebarsBinding[];
|
|
147
|
+
/**
|
|
148
|
+
* Return all unsupported Handlebars constructs (partials, decorators, and
|
|
149
|
+
* built-in helpers absent from MCN's locked-down engine).
|
|
150
|
+
* @returns Array of unsupported-construct descriptors.
|
|
151
|
+
*/
|
|
152
|
+
listHandlebarsUnsupportedConstructs(): HandlebarsUnsupportedConstruct[];
|
|
153
|
+
/**
|
|
154
|
+
* Return the pre-built MCN Handlebars helper completion items.
|
|
155
|
+
* @returns Array of pre-built Handlebars helper completion items.
|
|
156
|
+
*/
|
|
157
|
+
getHandlebarsCompletionCatalog(): CompletionItem[];
|
|
125
158
|
/**
|
|
126
159
|
* Extract every AMPscript function call site from the given code.
|
|
127
160
|
* Only calls to known AMPscript catalog functions are returned; unknown
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OA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;;OAGG;IACH,wBAAwB,IAAI,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IA4BvE;;;OAGG;IACH,wBAAwB,IAAI,cAAc,EAAE;IAI5C;;;OAGG;IACH,mCAAmC,IAAI,cAAc,EAAE;IAMvD;;;;OAIG;IACH,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAI7D;;;OAGG;IACH,qBAAqB,IAAI,gBAAgB,EAAE;IAI3C;;;OAGG;IACH,sBAAsB,IAAI,iBAAiB,EAAE;IAI7C;;;;OAIG;IACH,mCAAmC,IAAI,8BAA8B,EAAE;IAIvE;;;OAGG;IACH,8BAA8B,IAAI,cAAc,EAAE;IAMlD;;;;;;OAMG;IACH,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,EAAE;CAGnE;AAED,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,qBAA4B,CAAC;AAG7D,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signature help for Handlebars for Marketing Cloud Next (MCN) helpers.
|
|
3
|
+
*
|
|
4
|
+
* Active only when a document targets Marketing Cloud Next
|
|
5
|
+
* (`targetPlatform: 'next'`). Unlike AMPscript/SSJS calls, Handlebars helpers
|
|
6
|
+
* take whitespace-separated arguments inside a `{{ ... }}` mustache, a `{{# ...}}`
|
|
7
|
+
* block, or a `( ... )` subexpression — so the active call context is resolved
|
|
8
|
+
* by a small scope-aware tokenizer rather than `findFunctionContext`.
|
|
9
|
+
*/
|
|
10
|
+
import type { SignatureHelp } from '../types.js';
|
|
11
|
+
/** Resolved Handlebars helper call context at the cursor. */
|
|
12
|
+
interface HandlebarsCallContext {
|
|
13
|
+
/** The helper name leading the innermost active expression scope. */
|
|
14
|
+
helperName: string;
|
|
15
|
+
/** Zero-based index of the argument currently being typed. */
|
|
16
|
+
argIndex: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the innermost Handlebars helper call context from the document text
|
|
20
|
+
* up to the cursor. Returns null when the cursor is not inside an open `{{ }}`
|
|
21
|
+
* expression, or when the leading helper name has not been typed yet.
|
|
22
|
+
* @param textUpToCursor - Document text from start up to the cursor position.
|
|
23
|
+
* @returns The active helper call context, or null.
|
|
24
|
+
*/
|
|
25
|
+
export declare function findHandlebarsCallContext(textUpToCursor: string): HandlebarsCallContext | null;
|
|
26
|
+
/**
|
|
27
|
+
* Return signature help for the Handlebars helper at the given call context.
|
|
28
|
+
* @param context - The resolved helper call context.
|
|
29
|
+
* @param context.helperName - Name of the helper being invoked.
|
|
30
|
+
* @param context.argIndex - Zero-based index of the active argument.
|
|
31
|
+
* @returns SignatureHelp object, or null when the helper is unknown or takes no
|
|
32
|
+
* parameters.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getHandlebarsSignatureHelp(context: {
|
|
35
|
+
helperName: string;
|
|
36
|
+
argIndex: number;
|
|
37
|
+
}): SignatureHelp | null;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=mcnHandlebars.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcnHandlebars.d.ts","sourceRoot":"","sources":["../../../src/signature/mcnHandlebars.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAwB,MAAM,aAAa,CAAC;AAOvE,6DAA6D;AAC7D,UAAU,qBAAqB;IAC3B,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;CACpB;AAYD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,cAAc,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CA6E9F;AA+BD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CACpB,GAAG,aAAa,GAAG,IAAI,CA8BvB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small closest-match helper used to power "Did you mean …?" quick fixes.
|
|
3
|
+
*
|
|
4
|
+
* Implements an iterative Levenshtein edit distance and a conservative
|
|
5
|
+
* suggestion threshold so that only genuinely close typos are offered.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Compute the Levenshtein edit distance between two strings.
|
|
9
|
+
* @param a - First string.
|
|
10
|
+
* @param b - Second string.
|
|
11
|
+
* @returns The minimum number of single-character edits to turn `a` into `b`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function levenshtein(a: string, b: string): number;
|
|
14
|
+
/**
|
|
15
|
+
* Return the candidate closest to `word` (case-insensitive) when it is within a
|
|
16
|
+
* conservative typo threshold, or null when nothing is close enough.
|
|
17
|
+
*
|
|
18
|
+
* The threshold scales with the word length: very short words allow at most one
|
|
19
|
+
* edit, longer words up to two. This avoids suggesting unrelated names.
|
|
20
|
+
* @param word - The unknown word typed by the user.
|
|
21
|
+
* @param candidates - Known valid names to match against.
|
|
22
|
+
* @returns The closest candidate (in its original casing), or null.
|
|
23
|
+
*/
|
|
24
|
+
export declare function closestMatch(word: string, candidates: Iterable<string>): string | null;
|
|
25
|
+
//# sourceMappingURL=closestMatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closestMatch.d.ts","sourceRoot":"","sources":["../../../src/utils/closestMatch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAiBxD;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAmBtF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin wrapper around the `@handlebars/parser` for Marketing Cloud Next.
|
|
3
|
+
*
|
|
4
|
+
* Provides a safe parse that converts parser exceptions into a structured
|
|
5
|
+
* result, plus helpers to map the parser's 1-based-line / 0-based-column
|
|
6
|
+
* locations onto LSP Positions and to walk every node in the AST.
|
|
7
|
+
*/
|
|
8
|
+
import { type AST } from '@handlebars/parser';
|
|
9
|
+
import type { Position, Range } from 'vscode-languageserver-types';
|
|
10
|
+
/** A node in the Handlebars AST (re-exported for validator consumers). */
|
|
11
|
+
export type HandlebarsAstNode = AST.Node;
|
|
12
|
+
/** A Handlebars syntax error with an LSP range describing where it occurred. */
|
|
13
|
+
export interface HandlebarsSyntaxError {
|
|
14
|
+
message: string;
|
|
15
|
+
range: Range;
|
|
16
|
+
}
|
|
17
|
+
/** Result of attempting to parse a Handlebars document. */
|
|
18
|
+
export interface HandlebarsParseResult {
|
|
19
|
+
/** The parsed program, or null when a syntax error prevented parsing. */
|
|
20
|
+
ast: AST.Program | null;
|
|
21
|
+
/** The syntax error, when parsing failed. */
|
|
22
|
+
error: HandlebarsSyntaxError | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Convert a parser AST position (1-based line, 0-based column) to an LSP
|
|
26
|
+
* Position (0-based line and character).
|
|
27
|
+
* @param pos - The AST position.
|
|
28
|
+
* @returns The equivalent LSP Position.
|
|
29
|
+
*/
|
|
30
|
+
export declare function astPositionToLsp(pos: AST.Position): Position;
|
|
31
|
+
/**
|
|
32
|
+
* Convert an AST node's source location to an LSP Range.
|
|
33
|
+
* @param loc - The AST source location.
|
|
34
|
+
* @returns The equivalent LSP Range.
|
|
35
|
+
*/
|
|
36
|
+
export declare function astLocToRange(loc: AST.SourceLocation): Range;
|
|
37
|
+
/**
|
|
38
|
+
* Parse Handlebars source, returning either the AST or a structured syntax error.
|
|
39
|
+
* Never throws.
|
|
40
|
+
* @param text - The (already sanitized) Handlebars document text.
|
|
41
|
+
* @returns The parse result.
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseHandlebars(text: string): HandlebarsParseResult;
|
|
44
|
+
/**
|
|
45
|
+
* Depth-first walk over every node in a Handlebars AST, invoking the visitor
|
|
46
|
+
* for each. Traversal descends into block programs/inverses, statement params,
|
|
47
|
+
* subexpressions, and hash pair values.
|
|
48
|
+
* @param node - The root node (typically a Program).
|
|
49
|
+
* @param visit - Callback invoked for every node.
|
|
50
|
+
*/
|
|
51
|
+
export declare function walkHandlebars(node: AST.Node, visit: (node: AST.Node) => void): void;
|
|
52
|
+
//# sourceMappingURL=handlebarsAst.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlebarsAst.d.ts","sourceRoot":"","sources":["../../../src/utils/handlebarsAst.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAS,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAEnE,0EAA0E;AAC1E,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,IAAI,CAAC;AAEzC,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,CAAC;CAChB;AAED,2DAA2D;AAC3D,MAAM,WAAW,qBAAqB;IAClC,yEAAyE;IACzE,GAAG,EAAE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,6CAA6C;IAC7C,KAAK,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACvC;AAUD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAE5D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,GAAG,KAAK,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,CAOnE;AAwCD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,IAAI,GAAG,IAAI,CA6CpF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block-scope tracker for Handlebars for Marketing Cloud Next (MCN).
|
|
3
|
+
*
|
|
4
|
+
* Walks a Handlebars AST to collect the local identifiers that block helpers
|
|
5
|
+
* introduce into their inner body, together with the source range over which
|
|
6
|
+
* each local is visible:
|
|
7
|
+
*
|
|
8
|
+
* - `{{#each items as |item index|}}` — block params (`item`, `index`).
|
|
9
|
+
* - `{{#each ...}}` / `{{#repeat n}}` — loop data variables (`@index`,
|
|
10
|
+
* `@first`, `@last`, and `@key` for `each`).
|
|
11
|
+
* - `{{#with obj as |o|}}` — the context alias when block params are used.
|
|
12
|
+
*
|
|
13
|
+
* Consumers (completions, hover, signature help) call
|
|
14
|
+
* {@link getHandlebarsLocalsAtOffset} to obtain only the locals that are in
|
|
15
|
+
* scope at the cursor, so block params and loop vars are never offered outside
|
|
16
|
+
* the block that declares them.
|
|
17
|
+
*
|
|
18
|
+
* Mirrors the single-pass tracker pattern used by
|
|
19
|
+
* {@link ../utils/ampscriptVariableTracker.buildVariableTypeMap} for AMPscript.
|
|
20
|
+
*/
|
|
21
|
+
/** The origin of a Handlebars block-local identifier. */
|
|
22
|
+
export type HandlebarsLocalKind = 'block-param' | 'loop-var';
|
|
23
|
+
/** A single identifier introduced by a block helper. */
|
|
24
|
+
export interface HandlebarsLocal {
|
|
25
|
+
/** The identifier as written in source, e.g. `item` or `@index`. */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Where the identifier originates. */
|
|
28
|
+
kind: HandlebarsLocalKind;
|
|
29
|
+
/** Short human-readable detail, e.g. `block param of #each`. */
|
|
30
|
+
detail: string;
|
|
31
|
+
}
|
|
32
|
+
/** A lexical scope: a set of locals visible across a half-open offset range. */
|
|
33
|
+
export interface HandlebarsScope {
|
|
34
|
+
/** Inclusive start offset of the block body. */
|
|
35
|
+
start: number;
|
|
36
|
+
/** Exclusive end offset of the block body. */
|
|
37
|
+
end: number;
|
|
38
|
+
/** Locals introduced by the block, visible within `[start, end)`. */
|
|
39
|
+
locals: HandlebarsLocal[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Build the list of block scopes for a (possibly mixed) document. AMPscript
|
|
43
|
+
* regions are blanked before parsing so the Handlebars parser does not choke on
|
|
44
|
+
* `%%[...]%%` / `%%=...=%%`. Offsets in the returned scopes map onto the
|
|
45
|
+
* original `text` (the sanitizer preserves offsets).
|
|
46
|
+
* @param text - Full document text.
|
|
47
|
+
* @returns The block scopes, outermost first in document order.
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildHandlebarsScopes(text: string): HandlebarsScope[];
|
|
50
|
+
/**
|
|
51
|
+
* Return the Handlebars block-locals in scope at the given offset. Locals from
|
|
52
|
+
* nested blocks shadow outer ones by name (inner declaration wins).
|
|
53
|
+
* @param text - Full document text.
|
|
54
|
+
* @param offset - Character offset of the cursor.
|
|
55
|
+
* @returns The in-scope locals, de-duplicated by name.
|
|
56
|
+
*/
|
|
57
|
+
export declare function getHandlebarsLocalsAtOffset(text: string, offset: number): HandlebarsLocal[];
|
|
58
|
+
//# sourceMappingURL=handlebarsScopeTracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlebarsScopeTracker.d.ts","sourceRoot":"","sources":["../../../src/utils/handlebarsScopeTracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAOH,yDAAyD;AACzD,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG,UAAU,CAAC;AAE7D,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC5B,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,gFAAgF;AAChF,MAAM,WAAW,eAAe;IAC5B,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,GAAG,EAAE,MAAM,CAAC;IACZ,qEAAqE;IACrE,MAAM,EAAE,eAAe,EAAE,CAAC;CAC7B;AA2DD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,EAAE,CA+BrE;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,EAAE,CAa3F"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { AmpscriptFunction } from '../data/ampscript.js';
|
|
6
6
|
import type { SsjsFunction, EcmascriptBuiltin } from '../data/ssjs.js';
|
|
7
|
+
import type { HandlebarsHelper, HandlebarsBinding } from '../data/handlebars.js';
|
|
7
8
|
export interface LocalSsjsFunction {
|
|
8
9
|
name: string;
|
|
9
10
|
params: string[];
|
|
@@ -61,4 +62,29 @@ export declare function buildFunctionSnippet(fn: AmpscriptFunction): string;
|
|
|
61
62
|
* @returns VS Code snippet string with tab-stop placeholders.
|
|
62
63
|
*/
|
|
63
64
|
export declare function buildSsjsFunctionSnippet(fn: SsjsFunction): string;
|
|
65
|
+
/**
|
|
66
|
+
* Build typed-signature Markdown for an MCN Handlebars helper.
|
|
67
|
+
* @param helper - Handlebars helper descriptor.
|
|
68
|
+
* @returns Markdown string with signature, description, params, and doc link.
|
|
69
|
+
*/
|
|
70
|
+
export declare function buildHandlebarsHelperMarkdown(helper: HandlebarsHelper): string;
|
|
71
|
+
/**
|
|
72
|
+
* Build Markdown documentation for a built-in `{!$...}` data binding.
|
|
73
|
+
* @param binding - Handlebars binding descriptor.
|
|
74
|
+
* @returns Markdown string with the token, description, and metadata.
|
|
75
|
+
*/
|
|
76
|
+
export declare function buildHandlebarsBindingMarkdown(binding: HandlebarsBinding): string;
|
|
77
|
+
/**
|
|
78
|
+
* Build a snippet string for an MCN Handlebars helper.
|
|
79
|
+
*
|
|
80
|
+
* The snippet contains no `{{ }}` braces — completion is triggered while the
|
|
81
|
+
* cursor is already inside a mustache, and brace auto-closing behavior varies
|
|
82
|
+
* by editor, so emitting braces here risks producing broken fragments. Block
|
|
83
|
+
* helpers are prefixed with `#` (e.g. `#each collection`); inline helpers use
|
|
84
|
+
* the bare name (e.g. `add value1 value2`). Helpers declared as `both` default
|
|
85
|
+
* to the inline form.
|
|
86
|
+
* @param helper - Handlebars helper descriptor.
|
|
87
|
+
* @returns VS Code snippet string with tab-stop placeholders.
|
|
88
|
+
*/
|
|
89
|
+
export declare function buildHandlebarsHelperSnippet(helper: HandlebarsHelper): string;
|
|
64
90
|
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/utils/markdown.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../src/utils/markdown.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,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AAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAwC9E;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAWjF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAK7E"}
|
|
@@ -17,6 +17,26 @@ export declare function isInsideAmpscript(text: string, offset: number): boolean
|
|
|
17
17
|
* @returns True if the offset is inside a GTL expression.
|
|
18
18
|
*/
|
|
19
19
|
export declare function isInsideGtl(text: string, offset: number): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Returns true when the given character offset falls inside a Handlebars {{...}}
|
|
22
|
+
* expression (Handlebars for Marketing Cloud Next). The syntax is identical to
|
|
23
|
+
* GTL, but the two are mutually exclusive: GTL is detected only in Engagement
|
|
24
|
+
* mode, Handlebars only in MCN Next mode.
|
|
25
|
+
* @param text - Full document text.
|
|
26
|
+
* @param offset - Character offset to test.
|
|
27
|
+
* @returns True if the offset is inside a Handlebars expression.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isInsideHandlebars(text: string, offset: number): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Returns a copy of the document where every AMPscript region (%%[...]%%,
|
|
32
|
+
* %%=...=%%, and <script language="ampscript"> bodies) is replaced with spaces,
|
|
33
|
+
* preserving offsets. HTML, Handlebars {{...}} expressions, and {!$...} bindings
|
|
34
|
+
* are kept verbatim so the Handlebars parser can run over a mixed document
|
|
35
|
+
* without choking on AMPscript syntax.
|
|
36
|
+
* @param text - Full document text.
|
|
37
|
+
* @returns Text with AMPscript regions blanked out.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getSanitizedHandlebarsText(text: string): string;
|
|
20
40
|
/**
|
|
21
41
|
* Returns a sanitized copy of the document where only the code inside
|
|
22
42
|
* AMPscript regions is preserved (strings blanked, comments blanked).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regions.d.ts","sourceRoot":"","sources":["../../../src/utils/regions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAgCvE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAKjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAwB9D"}
|
|
1
|
+
{"version":3,"file":"regions.d.ts","sourceRoot":"","sources":["../../../src/utils/regions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAgCvE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAKjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAKxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAuB/D;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAwB9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ampscript.d.ts","sourceRoot":"","sources":["../../../src/validators/ampscript.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"ampscript.d.ts","sourceRoot":"","sources":["../../../src/validators/ampscript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next (`targetPlatform:
|
|
5
|
+
* 'next'`). It is mutually exclusive with the GTL validator, which runs only
|
|
6
|
+
* for Engagement. Diagnostics emitted here:
|
|
7
|
+
*
|
|
8
|
+
* - `handlebars/syntax-error` (Error) malformed Handlebars syntax
|
|
9
|
+
* - `handlebars/unsupported-construct` (Error) partials, decorators, log, …
|
|
10
|
+
* - `handlebars/unknown-helper` (Warning) helper not in the MCN catalog
|
|
11
|
+
* - `handlebars/unknown-binding` (Warning) unknown `{!$...}` data binding
|
|
12
|
+
*
|
|
13
|
+
* The MCN templating engine is based on Handlebars.Net and is locked down: you
|
|
14
|
+
* cannot register helpers, partials, or decorators. Anything outside the fixed
|
|
15
|
+
* catalog is therefore flagged.
|
|
16
|
+
*/
|
|
17
|
+
import type { Diagnostic } from '../types.js';
|
|
18
|
+
export declare const DIAG_CODE_HBS_SYNTAX = "handlebars/syntax-error";
|
|
19
|
+
export declare const DIAG_CODE_HBS_UNSUPPORTED_CONSTRUCT = "handlebars/unsupported-construct";
|
|
20
|
+
export declare const DIAG_CODE_HBS_UNKNOWN_HELPER = "handlebars/unknown-helper";
|
|
21
|
+
export declare const DIAG_CODE_HBS_UNKNOWN_BINDING = "handlebars/unknown-binding";
|
|
22
|
+
/** Payload attached to unknown-helper / unknown-binding diagnostics for quick fixes. */
|
|
23
|
+
export interface HandlebarsSuggestionData {
|
|
24
|
+
/** The unknown name the user typed (helper name or binding token). */
|
|
25
|
+
typed: string;
|
|
26
|
+
/** The closest known name to suggest as a replacement. */
|
|
27
|
+
suggestion: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* MCN Handlebars diagnostic codes that duplicate eslint-plugin-sfmc (`-next`
|
|
31
|
+
* config) rules and can be suppressed via `disableLspDiagnosticsForEslintRules`.
|
|
32
|
+
*/
|
|
33
|
+
export declare const HBS_ESLINT_DUPLICATE_DIAG_CODES: Set<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Validate Handlebars for Marketing Cloud Next within a (possibly mixed)
|
|
36
|
+
* document. AMPscript regions are blanked before parsing so the Handlebars
|
|
37
|
+
* parser does not choke on `%%[...]%%` / `%%=...=%%` syntax. Diagnostics are
|
|
38
|
+
* pushed in place, honoring the shared problem budget.
|
|
39
|
+
* @param text - Full document text.
|
|
40
|
+
* @param diagnostics - Diagnostics sink (shared across validators).
|
|
41
|
+
* @param remainingBudget - Maximum number of additional problems to report.
|
|
42
|
+
*/
|
|
43
|
+
export declare function validateMcnHandlebars(text: string, diagnostics: Diagnostic[], remainingBudget: number): void;
|
|
44
|
+
//# sourceMappingURL=mcnHandlebars.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcnHandlebars.d.ts","sourceRoot":"","sources":["../../../src/validators/mcnHandlebars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA0B9C,eAAO,MAAM,oBAAoB,4BAA4B,CAAC;AAC9D,eAAO,MAAM,mCAAmC,qCAAqC,CAAC;AACtF,eAAO,MAAM,4BAA4B,8BAA8B,CAAC;AACxE,eAAO,MAAM,6BAA6B,+BAA+B,CAAC;AAE1E,wFAAwF;AACxF,MAAM,WAAW,wBAAwB;IACrC,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,+BAA+B,aAG1C,CAAC;AAgGH;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACjC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,UAAU,EAAE,EACzB,eAAe,EAAE,MAAM,GACxB,IAAI,CA8FN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sfmc-language-lsp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Protocol-agnostic, browser-compatible language service for Salesforce Marketing Cloud  AMPscript, SSJS, and GTL. Provides validation, completions, hover, signature help, and code actions.",
|
|
6
6
|
"author": "Jörn Berkefeld",
|
|
@@ -54,7 +54,9 @@
|
|
|
54
54
|
"format:check": "prettier --check ."
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"
|
|
57
|
+
"@handlebars/parser": "^1.1.0",
|
|
58
|
+
"ampscript-data": "^2.1.0",
|
|
59
|
+
"handlebars-data": "^0.1.0",
|
|
58
60
|
"ssjs-data": "^0.12.1",
|
|
59
61
|
"vscode-languageserver-types": "^3.17.5"
|
|
60
62
|
},
|