@flanksource/clicky-ui 0.3.87 → 0.3.88
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/data/version-info.cjs +3 -3
- package/dist/data/version-info.js +3 -3
- package/dist/expressions/lang/attributes.cjs.map +1 -1
- package/dist/expressions/lang/attributes.d.ts.map +1 -1
- package/dist/expressions/lang/attributes.js.map +1 -1
- package/dist/expressions/lang/completion.cjs.map +1 -1
- package/dist/expressions/lang/completion.d.ts.map +1 -1
- package/dist/expressions/lang/completion.js.map +1 -1
- package/dist/expressions/lang/generated/conformance.json.d.ts +280 -0
- package/dist/expressions/lang/generated/index.cjs.map +1 -1
- package/dist/expressions/lang/generated/index.d.ts.map +1 -1
- package/dist/expressions/lang/generated/index.js.map +1 -1
- package/dist/expressions/lang/generated/languages.cjs +2 -0
- package/dist/expressions/lang/generated/languages.cjs.map +1 -1
- package/dist/expressions/lang/generated/languages.js +2 -0
- package/dist/expressions/lang/generated/languages.js.map +1 -1
- package/dist/expressions/lang/generated/languages.json.d.ts +2 -0
- package/dist/expressions/lang/generated/spec.cjs +2 -2
- package/dist/expressions/lang/generated/spec.cjs.map +1 -1
- package/dist/expressions/lang/generated/spec.js +2 -2
- package/dist/expressions/lang/generated/spec.js.map +1 -1
- package/dist/expressions/lang/generated/spec.json.d.ts +81 -26
- package/dist/expressions/lang/hover.cjs +3 -1
- package/dist/expressions/lang/hover.cjs.map +1 -1
- package/dist/expressions/lang/hover.d.ts.map +1 -1
- package/dist/expressions/lang/hover.js +3 -1
- package/dist/expressions/lang/hover.js.map +1 -1
- package/dist/expressions/lang/index.cjs.map +1 -1
- package/dist/expressions/lang/index.d.ts.map +1 -1
- package/dist/expressions/lang/index.js.map +1 -1
- package/dist/expressions/lang/merge.cjs +5 -0
- package/dist/expressions/lang/merge.cjs.map +1 -1
- package/dist/expressions/lang/merge.d.ts +4 -0
- package/dist/expressions/lang/merge.d.ts.map +1 -1
- package/dist/expressions/lang/merge.js +5 -0
- package/dist/expressions/lang/merge.js.map +1 -1
- package/dist/expressions/lang/prefix.cjs.map +1 -1
- package/dist/expressions/lang/prefix.d.ts.map +1 -1
- package/dist/expressions/lang/prefix.js.map +1 -1
- package/dist/expressions/lang/spec.d.ts.map +1 -1
- package/dist/expressions/lang/theme.cjs.map +1 -1
- package/dist/expressions/lang/theme.d.ts.map +1 -1
- package/dist/expressions/lang/theme.js.map +1 -1
- package/dist/expressions/lang/types.d.ts +12 -0
- package/dist/expressions/lang/types.d.ts.map +1 -1
- package/dist/expressions/playground/EmbeddedPlayground.cjs +6 -5
- package/dist/expressions/playground/EmbeddedPlayground.cjs.map +1 -1
- package/dist/expressions/playground/EmbeddedPlayground.d.ts +12 -4
- package/dist/expressions/playground/EmbeddedPlayground.d.ts.map +1 -1
- package/dist/expressions/playground/EmbeddedPlayground.js +6 -5
- package/dist/expressions/playground/EmbeddedPlayground.js.map +1 -1
- package/dist/expressions/playground/ExpressionPlayground.cjs +14 -4
- package/dist/expressions/playground/ExpressionPlayground.cjs.map +1 -1
- package/dist/expressions/playground/ExpressionPlayground.d.ts +7 -1
- package/dist/expressions/playground/ExpressionPlayground.d.ts.map +1 -1
- package/dist/expressions/playground/ExpressionPlayground.js +14 -4
- package/dist/expressions/playground/ExpressionPlayground.js.map +1 -1
- package/dist/expressions/playground/panels/ReferencePanel.cjs +34 -0
- package/dist/expressions/playground/panels/ReferencePanel.cjs.map +1 -0
- package/dist/expressions/playground/panels/ReferencePanel.d.ts +22 -0
- package/dist/expressions/playground/panels/ReferencePanel.d.ts.map +1 -0
- package/dist/expressions/playground/panels/ReferencePanel.js +33 -0
- package/dist/expressions/playground/panels/ReferencePanel.js.map +1 -0
- package/dist/expressions/playground/panels/SpecPanel.cjs +10 -2
- package/dist/expressions/playground/panels/SpecPanel.cjs.map +1 -1
- package/dist/expressions/playground/panels/SpecPanel.d.ts.map +1 -1
- package/dist/expressions/playground/panels/SpecPanel.js +10 -2
- package/dist/expressions/playground/panels/SpecPanel.js.map +1 -1
- package/dist/runtime/barrels.json +1574 -1574
- package/dist/runtime/importmap.json +2185 -2184
- package/package.json +1 -1
|
@@ -14,9 +14,9 @@ function detectMode() {
|
|
|
14
14
|
/** Resolve build + runtime version metadata. */
|
|
15
15
|
function getVersionInfo() {
|
|
16
16
|
return {
|
|
17
|
-
commit: read(() => "
|
|
18
|
-
tag: read(() => "page-runtime-build@0.1.
|
|
19
|
-
date: read(() => "2026-12-
|
|
17
|
+
commit: read(() => "e5b4fae76", ""),
|
|
18
|
+
tag: read(() => "page-runtime-build@0.1.4", ""),
|
|
19
|
+
date: read(() => "2026-12-03T10:47:59.891Z", ""),
|
|
20
20
|
dirty: read(() => true, false),
|
|
21
21
|
mode: detectMode()
|
|
22
22
|
};
|
|
@@ -14,9 +14,9 @@ function detectMode() {
|
|
|
14
14
|
/** Resolve build + runtime version metadata. */
|
|
15
15
|
function getVersionInfo() {
|
|
16
16
|
return {
|
|
17
|
-
commit: read(() => "
|
|
18
|
-
tag: read(() => "page-runtime-build@0.1.
|
|
19
|
-
date: read(() => "2026-12-
|
|
17
|
+
commit: read(() => "e5b4fae76", ""),
|
|
18
|
+
tag: read(() => "page-runtime-build@0.1.4", ""),
|
|
19
|
+
date: read(() => "2026-12-03T10:47:25.757Z", ""),
|
|
20
20
|
dirty: read(() => true, false),
|
|
21
21
|
mode: detectMode()
|
|
22
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.cjs","names":["pathFlavour"],"sources":["../../../src/expressions/lang/attributes.ts"],"sourcesContent":["import type { CelSpec, GoTemplateSpec, GomplateSpec } from \"./types\";\nimport { pathFlavour } from \"./environment\";\n\n/**\n * The Monarch word lists a tokenizer rule refers to as `@name`.\n *\n * The tokenizers themselves are fixed: their rules match any dotted call and\n * then dispatch on these lists (`$1@namespaces`, `$1@globalFunctions`, …). So a\n * host's own `catalog.query` needs no new grammar — only `catalog` in\n * `namespaces` and `query` in `globalFunctions`.\n *\n * This mirrors the derivation in `genmonarch/lang_cel.go` and\n * `lang_gotemplate.go`. `attributes.test.ts` recomputes the generated bundle\n * from the generated spec and asserts the two agree, so the mirror cannot drift\n * silently.\n */\nexport type Attributes = Record<string, string[]>;\n\n/** CEL's word lists, minus `operators`, which comes from the grammar. */\nexport function celAttributes(spec: CelSpec): Attributes {\n const global: string[] = [];\n const member: string[] = [];\n for (const fn of spec.functions) {\n if (fn.memberOnly) member.push(fn.name);\n else global.push(leafOf(fn.name));\n }\n\n return {\n // `true`/`false`/`null` are constants, and colouring them as keywords too\n // would let whichever rule ran first decide.\n keywords: spec.keywords.filter((word) => !CONSTANTS.includes(word)),\n constants: [...CONSTANTS],\n typeKeywords: spec.types,\n macros: spec.macros.map((macro) => macro.name),\n namespaces: spec.namespaces,\n globalFunctions: global,\n memberFunctions: member,\n };\n}\n\n/** The go-template word lists, shared by the bare and embedded languages. */\nexport function goTemplateAttributes(spec: GoTemplateSpec): Attributes {\n return {\n keywords: spec.keywords,\n builtins: spec.builtins,\n namespaces: spec.namespaces,\n functions: spec.functions.filter((fn) => !fn.namespace).map((fn) => fn.name),\n };\n}\n\n/** The word lists for one language id, or null where a spec does not drive it. */\nexport function attributesFor(languageId: string, spec: GomplateSpec): Attributes | null {\n switch (pathFlavour(languageId)) {\n case \"cel\":\n return normalize(celAttributes(spec.cel));\n case \"gotemplate\":\n return normalize(goTemplateAttributes(spec.gotemplate));\n default:\n // JSONPath's vocabulary is the grammar's own, with nothing to extend.\n return null;\n }\n}\n\nconst CONSTANTS = [\"true\", \"false\", \"null\"];\n\n/**\n * Sorted and deduplicated, matching `Language.MarshalJSON` on the Go side, so a\n * recomputed list compares equal to a generated one.\n */\nfunction normalize(attributes: Attributes): Attributes {\n const out: Attributes = {};\n for (const [name, words] of Object.entries(attributes)) {\n out[name] = [...new Set(words)].sort();\n }\n return out;\n}\n\nfunction leafOf(name: string) {\n const dot = name.lastIndexOf(\".\");\n return dot < 0 ? name : name.slice(dot + 1);\n}\n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|
1
|
+
{"version":3,"file":"attributes.cjs","names":["pathFlavour"],"sources":["../../../src/expressions/lang/attributes.ts"],"sourcesContent":["import type { CelSpec, GoTemplateSpec, GomplateSpec } from \"./types.js\";\nimport { pathFlavour } from \"./environment.js\";\n\n/**\n * The Monarch word lists a tokenizer rule refers to as `@name`.\n *\n * The tokenizers themselves are fixed: their rules match any dotted call and\n * then dispatch on these lists (`$1@namespaces`, `$1@globalFunctions`, …). So a\n * host's own `catalog.query` needs no new grammar — only `catalog` in\n * `namespaces` and `query` in `globalFunctions`.\n *\n * This mirrors the derivation in `genmonarch/lang_cel.go` and\n * `lang_gotemplate.go`. `attributes.test.ts` recomputes the generated bundle\n * from the generated spec and asserts the two agree, so the mirror cannot drift\n * silently.\n */\nexport type Attributes = Record<string, string[]>;\n\n/** CEL's word lists, minus `operators`, which comes from the grammar. */\nexport function celAttributes(spec: CelSpec): Attributes {\n const global: string[] = [];\n const member: string[] = [];\n for (const fn of spec.functions) {\n if (fn.memberOnly) member.push(fn.name);\n else global.push(leafOf(fn.name));\n }\n\n return {\n // `true`/`false`/`null` are constants, and colouring them as keywords too\n // would let whichever rule ran first decide.\n keywords: spec.keywords.filter((word) => !CONSTANTS.includes(word)),\n constants: [...CONSTANTS],\n typeKeywords: spec.types,\n macros: spec.macros.map((macro) => macro.name),\n namespaces: spec.namespaces,\n globalFunctions: global,\n memberFunctions: member,\n };\n}\n\n/** The go-template word lists, shared by the bare and embedded languages. */\nexport function goTemplateAttributes(spec: GoTemplateSpec): Attributes {\n return {\n keywords: spec.keywords,\n builtins: spec.builtins,\n namespaces: spec.namespaces,\n functions: spec.functions.filter((fn) => !fn.namespace).map((fn) => fn.name),\n };\n}\n\n/** The word lists for one language id, or null where a spec does not drive it. */\nexport function attributesFor(languageId: string, spec: GomplateSpec): Attributes | null {\n switch (pathFlavour(languageId)) {\n case \"cel\":\n return normalize(celAttributes(spec.cel));\n case \"gotemplate\":\n return normalize(goTemplateAttributes(spec.gotemplate));\n default:\n // JSONPath's vocabulary is the grammar's own, with nothing to extend.\n return null;\n }\n}\n\nconst CONSTANTS = [\"true\", \"false\", \"null\"];\n\n/**\n * Sorted and deduplicated, matching `Language.MarshalJSON` on the Go side, so a\n * recomputed list compares equal to a generated one.\n */\nfunction normalize(attributes: Attributes): Attributes {\n const out: Attributes = {};\n for (const [name, words] of Object.entries(attributes)) {\n out[name] = [...new Set(words)].sort();\n }\n return out;\n}\n\nfunction leafOf(name: string) {\n const dot = name.lastIndexOf(\".\");\n return dot < 0 ? name : name.slice(dot + 1);\n}\n"],"mappings":";;;AAmBA,SAAgB,cAAc,MAA2B;CACvD,MAAM,SAAmB,CAAC;CAC1B,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,MAAM,KAAK,WACpB,IAAI,GAAG,YAAY,OAAO,KAAK,GAAG,IAAI;MACjC,OAAO,KAAK,OAAO,GAAG,IAAI,CAAC;CAGlC,OAAO;EAGL,UAAU,KAAK,SAAS,QAAQ,SAAS,CAAC,UAAU,SAAS,IAAI,CAAC;EAClE,WAAW,CAAC,GAAG,SAAS;EACxB,cAAc,KAAK;EACnB,QAAQ,KAAK,OAAO,KAAK,UAAU,MAAM,IAAI;EAC7C,YAAY,KAAK;EACjB,iBAAiB;EACjB,iBAAiB;CACnB;AACF;;AAGA,SAAgB,qBAAqB,MAAkC;CACrE,OAAO;EACL,UAAU,KAAK;EACf,UAAU,KAAK;EACf,YAAY,KAAK;EACjB,WAAW,KAAK,UAAU,QAAQ,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,KAAK,OAAO,GAAG,IAAI;CAC7E;AACF;;AAGA,SAAgB,cAAc,YAAoB,MAAuC;CACvF,QAAQA,oBAAAA,YAAY,UAAU,GAA9B;EACE,KAAK,OACH,OAAO,UAAU,cAAc,KAAK,GAAG,CAAC;EAC1C,KAAK,cACH,OAAO,UAAU,qBAAqB,KAAK,UAAU,CAAC;EACxD,SAEE,OAAO;CACX;AACF;AAEA,IAAM,YAAY;CAAC;CAAQ;CAAS;AAAM;;;;;AAM1C,SAAS,UAAU,YAAoC;CACrD,MAAM,MAAkB,CAAC;CACzB,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,UAAU,GACnD,IAAI,QAAQ,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK;CAEvC,OAAO;AACT;AAEA,SAAS,OAAO,MAAc;CAC5B,MAAM,MAAM,KAAK,YAAY,GAAG;CAChC,OAAO,MAAM,IAAI,OAAO,KAAK,MAAM,MAAM,CAAC;AAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../src/expressions/lang/attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../src/expressions/lang/attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGxE;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAElD,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,CAmBvD;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,cAAc,GAAG,UAAU,CAOrE;AAED,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,UAAU,GAAG,IAAI,CAUvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.js","names":[],"sources":["../../../src/expressions/lang/attributes.ts"],"sourcesContent":["import type { CelSpec, GoTemplateSpec, GomplateSpec } from \"./types\";\nimport { pathFlavour } from \"./environment\";\n\n/**\n * The Monarch word lists a tokenizer rule refers to as `@name`.\n *\n * The tokenizers themselves are fixed: their rules match any dotted call and\n * then dispatch on these lists (`$1@namespaces`, `$1@globalFunctions`, …). So a\n * host's own `catalog.query` needs no new grammar — only `catalog` in\n * `namespaces` and `query` in `globalFunctions`.\n *\n * This mirrors the derivation in `genmonarch/lang_cel.go` and\n * `lang_gotemplate.go`. `attributes.test.ts` recomputes the generated bundle\n * from the generated spec and asserts the two agree, so the mirror cannot drift\n * silently.\n */\nexport type Attributes = Record<string, string[]>;\n\n/** CEL's word lists, minus `operators`, which comes from the grammar. */\nexport function celAttributes(spec: CelSpec): Attributes {\n const global: string[] = [];\n const member: string[] = [];\n for (const fn of spec.functions) {\n if (fn.memberOnly) member.push(fn.name);\n else global.push(leafOf(fn.name));\n }\n\n return {\n // `true`/`false`/`null` are constants, and colouring them as keywords too\n // would let whichever rule ran first decide.\n keywords: spec.keywords.filter((word) => !CONSTANTS.includes(word)),\n constants: [...CONSTANTS],\n typeKeywords: spec.types,\n macros: spec.macros.map((macro) => macro.name),\n namespaces: spec.namespaces,\n globalFunctions: global,\n memberFunctions: member,\n };\n}\n\n/** The go-template word lists, shared by the bare and embedded languages. */\nexport function goTemplateAttributes(spec: GoTemplateSpec): Attributes {\n return {\n keywords: spec.keywords,\n builtins: spec.builtins,\n namespaces: spec.namespaces,\n functions: spec.functions.filter((fn) => !fn.namespace).map((fn) => fn.name),\n };\n}\n\n/** The word lists for one language id, or null where a spec does not drive it. */\nexport function attributesFor(languageId: string, spec: GomplateSpec): Attributes | null {\n switch (pathFlavour(languageId)) {\n case \"cel\":\n return normalize(celAttributes(spec.cel));\n case \"gotemplate\":\n return normalize(goTemplateAttributes(spec.gotemplate));\n default:\n // JSONPath's vocabulary is the grammar's own, with nothing to extend.\n return null;\n }\n}\n\nconst CONSTANTS = [\"true\", \"false\", \"null\"];\n\n/**\n * Sorted and deduplicated, matching `Language.MarshalJSON` on the Go side, so a\n * recomputed list compares equal to a generated one.\n */\nfunction normalize(attributes: Attributes): Attributes {\n const out: Attributes = {};\n for (const [name, words] of Object.entries(attributes)) {\n out[name] = [...new Set(words)].sort();\n }\n return out;\n}\n\nfunction leafOf(name: string) {\n const dot = name.lastIndexOf(\".\");\n return dot < 0 ? name : name.slice(dot + 1);\n}\n"],"mappings":";;;AAmBA,SAAgB,cAAc,MAA2B;CACvD,MAAM,SAAmB,CAAC;CAC1B,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,MAAM,KAAK,WACpB,IAAI,GAAG,YAAY,OAAO,KAAK,GAAG,IAAI;MACjC,OAAO,KAAK,OAAO,GAAG,IAAI,CAAC;CAGlC,OAAO;EAGL,UAAU,KAAK,SAAS,QAAQ,SAAS,CAAC,UAAU,SAAS,IAAI,CAAC;EAClE,WAAW,CAAC,GAAG,SAAS;EACxB,cAAc,KAAK;EACnB,QAAQ,KAAK,OAAO,KAAK,UAAU,MAAM,IAAI;EAC7C,YAAY,KAAK;EACjB,iBAAiB;EACjB,iBAAiB;CACnB;AACF;;AAGA,SAAgB,qBAAqB,MAAkC;CACrE,OAAO;EACL,UAAU,KAAK;EACf,UAAU,KAAK;EACf,YAAY,KAAK;EACjB,WAAW,KAAK,UAAU,QAAQ,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,KAAK,OAAO,GAAG,IAAI;CAC7E;AACF;;AAGA,SAAgB,cAAc,YAAoB,MAAuC;CACvF,QAAQ,YAAY,UAAU,GAA9B;EACE,KAAK,OACH,OAAO,UAAU,cAAc,KAAK,GAAG,CAAC;EAC1C,KAAK,cACH,OAAO,UAAU,qBAAqB,KAAK,UAAU,CAAC;EACxD,SAEE,OAAO;CACX;AACF;AAEA,IAAM,YAAY;CAAC;CAAQ;CAAS;AAAM;;;;;AAM1C,SAAS,UAAU,YAAoC;CACrD,MAAM,MAAkB,CAAC;CACzB,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,UAAU,GACnD,IAAI,QAAQ,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK;CAEvC,OAAO;AACT;AAEA,SAAS,OAAO,MAAc;CAC5B,MAAM,MAAM,KAAK,YAAY,GAAG;CAChC,OAAO,MAAM,IAAI,OAAO,KAAK,MAAM,MAAM,CAAC;AAC5C"}
|
|
1
|
+
{"version":3,"file":"attributes.js","names":[],"sources":["../../../src/expressions/lang/attributes.ts"],"sourcesContent":["import type { CelSpec, GoTemplateSpec, GomplateSpec } from \"./types.js\";\nimport { pathFlavour } from \"./environment.js\";\n\n/**\n * The Monarch word lists a tokenizer rule refers to as `@name`.\n *\n * The tokenizers themselves are fixed: their rules match any dotted call and\n * then dispatch on these lists (`$1@namespaces`, `$1@globalFunctions`, …). So a\n * host's own `catalog.query` needs no new grammar — only `catalog` in\n * `namespaces` and `query` in `globalFunctions`.\n *\n * This mirrors the derivation in `genmonarch/lang_cel.go` and\n * `lang_gotemplate.go`. `attributes.test.ts` recomputes the generated bundle\n * from the generated spec and asserts the two agree, so the mirror cannot drift\n * silently.\n */\nexport type Attributes = Record<string, string[]>;\n\n/** CEL's word lists, minus `operators`, which comes from the grammar. */\nexport function celAttributes(spec: CelSpec): Attributes {\n const global: string[] = [];\n const member: string[] = [];\n for (const fn of spec.functions) {\n if (fn.memberOnly) member.push(fn.name);\n else global.push(leafOf(fn.name));\n }\n\n return {\n // `true`/`false`/`null` are constants, and colouring them as keywords too\n // would let whichever rule ran first decide.\n keywords: spec.keywords.filter((word) => !CONSTANTS.includes(word)),\n constants: [...CONSTANTS],\n typeKeywords: spec.types,\n macros: spec.macros.map((macro) => macro.name),\n namespaces: spec.namespaces,\n globalFunctions: global,\n memberFunctions: member,\n };\n}\n\n/** The go-template word lists, shared by the bare and embedded languages. */\nexport function goTemplateAttributes(spec: GoTemplateSpec): Attributes {\n return {\n keywords: spec.keywords,\n builtins: spec.builtins,\n namespaces: spec.namespaces,\n functions: spec.functions.filter((fn) => !fn.namespace).map((fn) => fn.name),\n };\n}\n\n/** The word lists for one language id, or null where a spec does not drive it. */\nexport function attributesFor(languageId: string, spec: GomplateSpec): Attributes | null {\n switch (pathFlavour(languageId)) {\n case \"cel\":\n return normalize(celAttributes(spec.cel));\n case \"gotemplate\":\n return normalize(goTemplateAttributes(spec.gotemplate));\n default:\n // JSONPath's vocabulary is the grammar's own, with nothing to extend.\n return null;\n }\n}\n\nconst CONSTANTS = [\"true\", \"false\", \"null\"];\n\n/**\n * Sorted and deduplicated, matching `Language.MarshalJSON` on the Go side, so a\n * recomputed list compares equal to a generated one.\n */\nfunction normalize(attributes: Attributes): Attributes {\n const out: Attributes = {};\n for (const [name, words] of Object.entries(attributes)) {\n out[name] = [...new Set(words)].sort();\n }\n return out;\n}\n\nfunction leafOf(name: string) {\n const dot = name.lastIndexOf(\".\");\n return dot < 0 ? name : name.slice(dot + 1);\n}\n"],"mappings":";;;AAmBA,SAAgB,cAAc,MAA2B;CACvD,MAAM,SAAmB,CAAC;CAC1B,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,MAAM,KAAK,WACpB,IAAI,GAAG,YAAY,OAAO,KAAK,GAAG,IAAI;MACjC,OAAO,KAAK,OAAO,GAAG,IAAI,CAAC;CAGlC,OAAO;EAGL,UAAU,KAAK,SAAS,QAAQ,SAAS,CAAC,UAAU,SAAS,IAAI,CAAC;EAClE,WAAW,CAAC,GAAG,SAAS;EACxB,cAAc,KAAK;EACnB,QAAQ,KAAK,OAAO,KAAK,UAAU,MAAM,IAAI;EAC7C,YAAY,KAAK;EACjB,iBAAiB;EACjB,iBAAiB;CACnB;AACF;;AAGA,SAAgB,qBAAqB,MAAkC;CACrE,OAAO;EACL,UAAU,KAAK;EACf,UAAU,KAAK;EACf,YAAY,KAAK;EACjB,WAAW,KAAK,UAAU,QAAQ,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,KAAK,OAAO,GAAG,IAAI;CAC7E;AACF;;AAGA,SAAgB,cAAc,YAAoB,MAAuC;CACvF,QAAQ,YAAY,UAAU,GAA9B;EACE,KAAK,OACH,OAAO,UAAU,cAAc,KAAK,GAAG,CAAC;EAC1C,KAAK,cACH,OAAO,UAAU,qBAAqB,KAAK,UAAU,CAAC;EACxD,SAEE,OAAO;CACX;AACF;AAEA,IAAM,YAAY;CAAC;CAAQ;CAAS;AAAM;;;;;AAM1C,SAAS,UAAU,YAAoC;CACrD,MAAM,MAAkB,CAAC;CACzB,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,UAAU,GACnD,IAAI,QAAQ,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK;CAEvC,OAAO;AACT;AAEA,SAAS,OAAO,MAAc;CAC5B,MAAM,MAAM,KAAK,YAAY,GAAG;CAChC,OAAO,MAAM,IAAI,OAAO,KAAK,MAAM,MAAM,CAAC;AAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion.cjs","names":["pathFlavour","environmentPrefixAt","resolvePath","childEntries","pathExpression","functionDocumentation","macroDocumentation"],"sources":["../../../src/expressions/lang/completion.ts"],"sourcesContent":["import type * as monaco from \"monaco-editor\";\nimport type { GomplateSpec, Monaco, SpecFunction, SpecMacro } from \"./types\";\nimport { functionDocumentation, macroDocumentation } from \"./hover\";\nimport { childEntries, pathExpression, pathFlavour, resolvePath } from \"./environment\";\nimport { environmentPrefixAt } from \"./prefix\";\n\n/** Supplies the document expressions are evaluated against, on every request. */\nexport type EnvironmentSource = () => unknown;\n\nexport interface CompletionOptions {\n /** The catalogue to complete from — gomplate's, or a host's merged over it. */\n spec: GomplateSpec;\n environment?: EnvironmentSource | undefined;\n}\n\n/**\n * Registers completion for one language.\n *\n * The catalogue half is built once per registration, so a host that supplies\n * its own spec re-registers rather than mutating in place. The document half is\n * rebuilt per request, because the document is being edited alongside the\n * expression.\n */\nexport function registerCompletion(\n monaco: Monaco,\n languageId: string,\n options: CompletionOptions,\n) {\n return monaco.languages.registerCompletionItemProvider(\n languageId,\n completionProvider(monaco, languageId, options),\n );\n}\n\n/**\n * The provider `registerCompletion` installs, exposed so it can be driven\n * directly by a test over a real model rather than through Monaco's registry.\n */\nexport function completionProvider(\n monaco: Monaco,\n languageId: string,\n { spec, environment }: CompletionOptions,\n) {\n const items = catalogueItems(monaco, languageId, spec);\n return {\n // A dot must retrigger, or `k8s.` offers nothing until another key is hit.\n triggerCharacters: [\".\"],\n provideCompletionItems(model: monaco.editor.ITextModel, position: monaco.Position) {\n const suggestions: monaco.languages.CompletionItem[] = environmentItems(\n monaco,\n model,\n position,\n languageId,\n environment,\n );\n const range = wordRange(model, position);\n for (const item of items) suggestions.push({ ...item, range });\n return { suggestions };\n },\n };\n}\n\n/**\n * A completion item without its range. The range depends on the cursor, so it\n * is attached per request while the rest of the item is built once.\n */\ntype Item = Omit<monaco.languages.CompletionItem, \"range\">;\n\nfunction catalogueItems(monaco: Monaco, languageId: string, spec: GomplateSpec): Item[] {\n switch (pathFlavour(languageId)) {\n case \"cel\":\n return celCompletionItems(monaco, spec);\n case \"gotemplate\":\n return goTemplateCompletionItems(monaco, spec);\n default:\n // JSONPath's dialect has no catalogue to generate from; its completions\n // come entirely from the document.\n return [];\n }\n}\n\n/**\n * The keys reachable from the cursor's position in the document.\n *\n * Each item replaces the whole path typed so far with a freshly rendered one,\n * rather than appending to it, so what lands in the editor is always valid in\n * that language — quoting an awkward key, or dropping the suggestion entirely\n * where the language cannot express the path.\n */\nfunction environmentItems(\n monaco: Monaco,\n model: monaco.editor.ITextModel,\n position: monaco.Position,\n languageId: string,\n environment: EnvironmentSource | undefined,\n): monaco.languages.CompletionItem[] {\n if (!environment) return [];\n const document = environment();\n if (document === undefined || document === null) return [];\n\n const prefix = environmentPrefixAt(model, position, languageId);\n if (!prefix) return [];\n\n const parent = resolvePath(document, prefix.segments);\n if (parent === undefined) return [];\n\n const kinds = monaco.languages.CompletionItemKind;\n const range = {\n startLineNumber: position.lineNumber,\n endLineNumber: position.lineNumber,\n startColumn: prefix.startColumn,\n endColumn: prefix.endColumn,\n };\n\n // Monaco filters a candidate against the model text from the range start to\n // the cursor, so `filterText` has to continue what was typed rather than\n // repeat the rendered path: `pod.items[0]` does not match `pod.items.`, and\n // the subscripted keys would be filtered straight back out.\n const typedHead = prefix.typed.slice(0, prefix.typed.length - prefix.leaf.length);\n\n const items: monaco.languages.CompletionItem[] = [];\n for (const entry of childEntries(parent)) {\n const insertText = pathExpression(languageId, [...prefix.segments, entry.segment]);\n if (insertText === null) continue;\n items.push({\n label: entry.key,\n kind: entry.container ? kinds.Folder : kinds.Field,\n insertText,\n filterText: `${typedHead}${entry.key}`,\n detail: `${entry.kind} · ${entry.summary}`,\n // A key of the document being evaluated beats any catalogue entry: it is\n // what the author came to the editor to write.\n sortText: `0${entry.key}`,\n range,\n });\n }\n return items;\n}\n\nfunction celCompletionItems(monaco: Monaco, spec: GomplateSpec) {\n const kinds = monaco.languages.CompletionItemKind;\n const items: Item[] = [];\n\n for (const fn of spec.cel.functions) {\n items.push(buildFunctionItem(monaco, fn, celInsertText(fn), kinds.Function));\n }\n for (const macro of spec.cel.macros) {\n items.push(buildMacroItem(monaco, macro));\n }\n for (const keyword of spec.cel.keywords) {\n items.push({\n label: keyword,\n kind: kinds.Keyword,\n insertText: keyword,\n detail: \"CEL keyword\",\n });\n }\n for (const type of spec.cel.types) {\n items.push({ label: type, kind: kinds.TypeParameter, insertText: type, detail: \"CEL type\" });\n }\n return items;\n}\n\nfunction goTemplateCompletionItems(monaco: Monaco, spec: GomplateSpec) {\n const kinds = monaco.languages.CompletionItemKind;\n const items: Item[] = [];\n\n for (const fn of spec.gotemplate.functions) {\n items.push(buildFunctionItem(monaco, fn, fn.name, kinds.Function));\n }\n for (const builtin of spec.gotemplate.builtins) {\n items.push({\n label: builtin,\n kind: kinds.Function,\n insertText: builtin,\n detail: \"text/template builtin\",\n });\n }\n for (const keyword of spec.gotemplate.keywords) {\n items.push({\n label: keyword,\n kind: kinds.Keyword,\n insertText: keyword,\n detail: \"template keyword\",\n });\n }\n return items;\n}\n\nfunction buildFunctionItem(\n monaco: Monaco,\n fn: SpecFunction,\n insertText: string,\n kind: monaco.languages.CompletionItemKind,\n): Item {\n // A function with neither a Go signature nor an overload has no detail to\n // show; the key has to be absent rather than explicitly undefined.\n const detail = fn.signature ?? fn.overloads?.[0]?.result;\n return {\n label: fn.name,\n kind: fn.memberOnly ? monaco.languages.CompletionItemKind.Method : kind,\n insertText,\n ...(detail === undefined ? {} : { detail }),\n documentation: { value: functionDocumentation(fn) },\n filterText: fn.name,\n // Un-namespaced names first: they are the short, common ones, and a\n // namespace is easy to reach by typing its prefix.\n sortText: fn.namespace ? `2${fn.name}` : `1${fn.name}`,\n };\n}\n\nfunction buildMacroItem(monaco: Monaco, macro: SpecMacro): Item {\n return {\n label: macro.name,\n kind: monaco.languages.CompletionItemKind.Keyword,\n insertText: macro.name,\n detail: `macro (${macro.argCount === 0 ? \"variadic\" : `${macro.argCount} args`})`,\n documentation: { value: macroDocumentation(macro) },\n filterText: macro.name,\n sortText: `1${macro.name}`,\n };\n}\n\n/**\n * CEL functions take parentheses; a member-only function is offered without a\n * leading dot because the dot is already typed when completion fires.\n */\nfunction celInsertText(fn: SpecFunction) {\n const arity = fn.overloads?.[0]?.args.length ?? 0;\n const receiver = fn.overloads?.[0]?.member ? 1 : 0;\n return arity - receiver === 0 ? `${fn.name}()` : `${fn.name}(`;\n}\n\nfunction wordRange(\n model: {\n getWordUntilPosition(p: { lineNumber: number; column: number }): {\n startColumn: number;\n endColumn: number;\n };\n },\n position: { lineNumber: number; column: number },\n) {\n const word = model.getWordUntilPosition(position);\n return {\n startLineNumber: position.lineNumber,\n endLineNumber: position.lineNumber,\n startColumn: word.startColumn,\n endColumn: word.endColumn,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,SAAgB,mBACd,QACA,YACA,SACA;CACA,OAAO,OAAO,UAAU,+BACtB,YACA,mBAAmB,QAAQ,YAAY,OAAO,CAChD;AACF;;;;;AAMA,SAAgB,mBACd,QACA,YACA,EAAE,MAAM,eACR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;CACV,CAAC;CAEH,OAAO;AACT;AAEA,SAAS,kBACP,QACA,IACA,YACA,MACM;CAGN,MAAM,SAAS,GAAG,aAAa,GAAG,YAAY,EAAE,EAAE;CAClD,OAAO;EACL,OAAO,GAAG;EACV,MAAM,GAAG,aAAa,OAAO,UAAU,mBAAmB,SAAS;EACnE;EACA,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;EACzC,eAAe,EAAE,OAAOC,cAAAA,sBAAsB,EAAE,EAAE;EAClD,YAAY,GAAG;EAGf,UAAU,GAAG,YAAY,IAAI,GAAG,SAAS,IAAI,GAAG;CAClD;AACF;AAEA,SAAS,eAAe,QAAgB,OAAwB;CAC9D,OAAO;EACL,OAAO,MAAM;EACb,MAAM,OAAO,UAAU,mBAAmB;EAC1C,YAAY,MAAM;EAClB,QAAQ,UAAU,MAAM,aAAa,IAAI,aAAa,GAAG,MAAM,SAAS,OAAO;EAC/E,eAAe,EAAE,OAAOC,cAAAA,mBAAmB,KAAK,EAAE;EAClD,YAAY,MAAM;EAClB,UAAU,IAAI,MAAM;CACtB;AACF;;;;;AAMA,SAAS,cAAc,IAAkB;CAGvC,QAFc,GAAG,YAAY,EAAE,EAAE,KAAK,UAAU,MAC/B,GAAG,YAAY,EAAE,EAAE,SAAS,IAAI,OACrB,IAAI,GAAG,GAAG,KAAK,MAAM,GAAG,GAAG,KAAK;AAC9D;AAEA,SAAS,UACP,OAMA,UACA;CACA,MAAM,OAAO,MAAM,qBAAqB,QAAQ;CAChD,OAAO;EACL,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,aAAa,KAAK;EAClB,WAAW,KAAK;CAClB;AACF"}
|
|
1
|
+
{"version":3,"file":"completion.cjs","names":["pathFlavour","environmentPrefixAt","resolvePath","childEntries","pathExpression","functionDocumentation","macroDocumentation"],"sources":["../../../src/expressions/lang/completion.ts"],"sourcesContent":["import type * as monaco from \"monaco-editor\";\nimport type { GomplateSpec, Monaco, SpecFunction, SpecMacro } from \"./types.js\";\nimport { functionDocumentation, macroDocumentation } from \"./hover.js\";\nimport { childEntries, pathExpression, pathFlavour, resolvePath } from \"./environment.js\";\nimport { environmentPrefixAt } from \"./prefix.js\";\n\n/** Supplies the document expressions are evaluated against, on every request. */\nexport type EnvironmentSource = () => unknown;\n\nexport interface CompletionOptions {\n /** The catalogue to complete from — gomplate's, or a host's merged over it. */\n spec: GomplateSpec;\n environment?: EnvironmentSource | undefined;\n}\n\n/**\n * Registers completion for one language.\n *\n * The catalogue half is built once per registration, so a host that supplies\n * its own spec re-registers rather than mutating in place. The document half is\n * rebuilt per request, because the document is being edited alongside the\n * expression.\n */\nexport function registerCompletion(\n monaco: Monaco,\n languageId: string,\n options: CompletionOptions,\n) {\n return monaco.languages.registerCompletionItemProvider(\n languageId,\n completionProvider(monaco, languageId, options),\n );\n}\n\n/**\n * The provider `registerCompletion` installs, exposed so it can be driven\n * directly by a test over a real model rather than through Monaco's registry.\n */\nexport function completionProvider(\n monaco: Monaco,\n languageId: string,\n { spec, environment }: CompletionOptions,\n) {\n const items = catalogueItems(monaco, languageId, spec);\n return {\n // A dot must retrigger, or `k8s.` offers nothing until another key is hit.\n triggerCharacters: [\".\"],\n provideCompletionItems(model: monaco.editor.ITextModel, position: monaco.Position) {\n const suggestions: monaco.languages.CompletionItem[] = environmentItems(\n monaco,\n model,\n position,\n languageId,\n environment,\n );\n const range = wordRange(model, position);\n for (const item of items) suggestions.push({ ...item, range });\n return { suggestions };\n },\n };\n}\n\n/**\n * A completion item without its range. The range depends on the cursor, so it\n * is attached per request while the rest of the item is built once.\n */\ntype Item = Omit<monaco.languages.CompletionItem, \"range\">;\n\nfunction catalogueItems(monaco: Monaco, languageId: string, spec: GomplateSpec): Item[] {\n switch (pathFlavour(languageId)) {\n case \"cel\":\n return celCompletionItems(monaco, spec);\n case \"gotemplate\":\n return goTemplateCompletionItems(monaco, spec);\n default:\n // JSONPath's dialect has no catalogue to generate from; its completions\n // come entirely from the document.\n return [];\n }\n}\n\n/**\n * The keys reachable from the cursor's position in the document.\n *\n * Each item replaces the whole path typed so far with a freshly rendered one,\n * rather than appending to it, so what lands in the editor is always valid in\n * that language — quoting an awkward key, or dropping the suggestion entirely\n * where the language cannot express the path.\n */\nfunction environmentItems(\n monaco: Monaco,\n model: monaco.editor.ITextModel,\n position: monaco.Position,\n languageId: string,\n environment: EnvironmentSource | undefined,\n): monaco.languages.CompletionItem[] {\n if (!environment) return [];\n const document = environment();\n if (document === undefined || document === null) return [];\n\n const prefix = environmentPrefixAt(model, position, languageId);\n if (!prefix) return [];\n\n const parent = resolvePath(document, prefix.segments);\n if (parent === undefined) return [];\n\n const kinds = monaco.languages.CompletionItemKind;\n const range = {\n startLineNumber: position.lineNumber,\n endLineNumber: position.lineNumber,\n startColumn: prefix.startColumn,\n endColumn: prefix.endColumn,\n };\n\n // Monaco filters a candidate against the model text from the range start to\n // the cursor, so `filterText` has to continue what was typed rather than\n // repeat the rendered path: `pod.items[0]` does not match `pod.items.`, and\n // the subscripted keys would be filtered straight back out.\n const typedHead = prefix.typed.slice(0, prefix.typed.length - prefix.leaf.length);\n\n const items: monaco.languages.CompletionItem[] = [];\n for (const entry of childEntries(parent)) {\n const insertText = pathExpression(languageId, [...prefix.segments, entry.segment]);\n if (insertText === null) continue;\n items.push({\n label: entry.key,\n kind: entry.container ? kinds.Folder : kinds.Field,\n insertText,\n filterText: `${typedHead}${entry.key}`,\n detail: `${entry.kind} · ${entry.summary}`,\n // A key of the document being evaluated beats any catalogue entry: it is\n // what the author came to the editor to write.\n sortText: `0${entry.key}`,\n range,\n });\n }\n return items;\n}\n\nfunction celCompletionItems(monaco: Monaco, spec: GomplateSpec) {\n const kinds = monaco.languages.CompletionItemKind;\n const items: Item[] = [];\n\n for (const fn of spec.cel.functions) {\n items.push(buildFunctionItem(monaco, fn, celInsertText(fn), kinds.Function));\n }\n for (const macro of spec.cel.macros) {\n items.push(buildMacroItem(monaco, macro));\n }\n for (const keyword of spec.cel.keywords) {\n items.push({\n label: keyword,\n kind: kinds.Keyword,\n insertText: keyword,\n detail: \"CEL keyword\",\n });\n }\n for (const type of spec.cel.types) {\n items.push({ label: type, kind: kinds.TypeParameter, insertText: type, detail: \"CEL type\" });\n }\n return items;\n}\n\nfunction goTemplateCompletionItems(monaco: Monaco, spec: GomplateSpec) {\n const kinds = monaco.languages.CompletionItemKind;\n const items: Item[] = [];\n\n for (const fn of spec.gotemplate.functions) {\n items.push(buildFunctionItem(monaco, fn, fn.name, kinds.Function));\n }\n for (const builtin of spec.gotemplate.builtins) {\n items.push({\n label: builtin,\n kind: kinds.Function,\n insertText: builtin,\n detail: \"text/template builtin\",\n });\n }\n for (const keyword of spec.gotemplate.keywords) {\n items.push({\n label: keyword,\n kind: kinds.Keyword,\n insertText: keyword,\n detail: \"template keyword\",\n });\n }\n return items;\n}\n\nfunction buildFunctionItem(\n monaco: Monaco,\n fn: SpecFunction,\n insertText: string,\n kind: monaco.languages.CompletionItemKind,\n): Item {\n // A function with neither a Go signature nor an overload has no detail to\n // show; the key has to be absent rather than explicitly undefined.\n const detail = fn.signature ?? fn.overloads?.[0]?.result;\n return {\n label: fn.name,\n kind: fn.memberOnly ? monaco.languages.CompletionItemKind.Method : kind,\n insertText,\n ...(detail === undefined ? {} : { detail }),\n documentation: { value: functionDocumentation(fn) },\n filterText: fn.name,\n // Un-namespaced names first: they are the short, common ones, and a\n // namespace is easy to reach by typing its prefix.\n sortText: fn.namespace ? `2${fn.name}` : `1${fn.name}`,\n };\n}\n\nfunction buildMacroItem(monaco: Monaco, macro: SpecMacro): Item {\n return {\n label: macro.name,\n kind: monaco.languages.CompletionItemKind.Keyword,\n insertText: macro.name,\n detail: `macro (${macro.argCount === 0 ? \"variadic\" : `${macro.argCount} args`})`,\n documentation: { value: macroDocumentation(macro) },\n filterText: macro.name,\n sortText: `1${macro.name}`,\n };\n}\n\n/**\n * CEL functions take parentheses; a member-only function is offered without a\n * leading dot because the dot is already typed when completion fires.\n */\nfunction celInsertText(fn: SpecFunction) {\n const arity = fn.overloads?.[0]?.args.length ?? 0;\n const receiver = fn.overloads?.[0]?.member ? 1 : 0;\n return arity - receiver === 0 ? `${fn.name}()` : `${fn.name}(`;\n}\n\nfunction wordRange(\n model: {\n getWordUntilPosition(p: { lineNumber: number; column: number }): {\n startColumn: number;\n endColumn: number;\n };\n },\n position: { lineNumber: number; column: number },\n) {\n const word = model.getWordUntilPosition(position);\n return {\n startLineNumber: position.lineNumber,\n endLineNumber: position.lineNumber,\n startColumn: word.startColumn,\n endColumn: word.endColumn,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,SAAgB,mBACd,QACA,YACA,SACA;CACA,OAAO,OAAO,UAAU,+BACtB,YACA,mBAAmB,QAAQ,YAAY,OAAO,CAChD;AACF;;;;;AAMA,SAAgB,mBACd,QACA,YACA,EAAE,MAAM,eACR;CACA,MAAM,QAAQ,eAAe,QAAQ,YAAY,IAAI;CACrD,OAAO;EAEL,mBAAmB,CAAC,GAAG;EACvB,uBAAuB,OAAiC,UAA2B;GACjF,MAAM,cAAiD,iBACrD,QACA,OACA,UACA,YACA,WACF;GACA,MAAM,QAAQ,UAAU,OAAO,QAAQ;GACvC,KAAK,MAAM,QAAQ,OAAO,YAAY,KAAK;IAAE,GAAG;IAAM;GAAM,CAAC;GAC7D,OAAO,EAAE,YAAY;EACvB;CACF;AACF;AAQA,SAAS,eAAe,QAAgB,YAAoB,MAA4B;CACtF,QAAQA,oBAAAA,YAAY,UAAU,GAA9B;EACE,KAAK,OACH,OAAO,mBAAmB,QAAQ,IAAI;EACxC,KAAK,cACH,OAAO,0BAA0B,QAAQ,IAAI;EAC/C,SAGE,OAAO,CAAC;CACZ;AACF;;;;;;;;;AAUA,SAAS,iBACP,QACA,OACA,UACA,YACA,aACmC;CACnC,IAAI,CAAC,aAAa,OAAO,CAAC;CAC1B,MAAM,WAAW,YAAY;CAC7B,IAAI,aAAa,KAAA,KAAa,aAAa,MAAM,OAAO,CAAC;CAEzD,MAAM,SAASC,eA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B;CAGvC,QAFc,GAAG,YAAY,EAAE,EAAE,KAAK,UAAU,MAC/B,GAAG,YAAY,EAAE,EAAE,SAAS,IAAI,OACrB,IAAI,GAAG,GAAG,KAAK,MAAM,GAAG,GAAG,KAAK;AAC9D;AAEA,SAAS,UACP,OAMA,UACA;CACA,MAAM,OAAO,MAAM,qBAAqB,QAAQ;CAChD,OAAO;EACL,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,aAAa,KAAK;EAClB,WAAW,KAAK;CAClB;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../../src/expressions/lang/completion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAA2B,MAAM,
|
|
1
|
+
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../../src/expressions/lang/completion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAA2B,MAAM,YAAY,CAAC;AAKhF,iFAAiF;AACjF,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC;AAE9C,MAAM,WAAW,iBAAiB;IAChC,+EAA+E;IAC/E,IAAI,EAAE,YAAY,CAAC;IACnB,WAAW,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;CAC7C;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,iBAAiB,sBAM3B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,iBAAiB;;kCAMR,MAAM,CAAC,MAAM,CAAC,UAAU,YAAY,MAAM,CAAC,QAAQ;;;EAapF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"completion.js","names":[],"sources":["../../../src/expressions/lang/completion.ts"],"sourcesContent":["import type * as monaco from \"monaco-editor\";\nimport type { GomplateSpec, Monaco, SpecFunction, SpecMacro } from \"./types\";\nimport { functionDocumentation, macroDocumentation } from \"./hover\";\nimport { childEntries, pathExpression, pathFlavour, resolvePath } from \"./environment\";\nimport { environmentPrefixAt } from \"./prefix\";\n\n/** Supplies the document expressions are evaluated against, on every request. */\nexport type EnvironmentSource = () => unknown;\n\nexport interface CompletionOptions {\n /** The catalogue to complete from — gomplate's, or a host's merged over it. */\n spec: GomplateSpec;\n environment?: EnvironmentSource | undefined;\n}\n\n/**\n * Registers completion for one language.\n *\n * The catalogue half is built once per registration, so a host that supplies\n * its own spec re-registers rather than mutating in place. The document half is\n * rebuilt per request, because the document is being edited alongside the\n * expression.\n */\nexport function registerCompletion(\n monaco: Monaco,\n languageId: string,\n options: CompletionOptions,\n) {\n return monaco.languages.registerCompletionItemProvider(\n languageId,\n completionProvider(monaco, languageId, options),\n );\n}\n\n/**\n * The provider `registerCompletion` installs, exposed so it can be driven\n * directly by a test over a real model rather than through Monaco's registry.\n */\nexport function completionProvider(\n monaco: Monaco,\n languageId: string,\n { spec, environment }: CompletionOptions,\n) {\n const items = catalogueItems(monaco, languageId, spec);\n return {\n // A dot must retrigger, or `k8s.` offers nothing until another key is hit.\n triggerCharacters: [\".\"],\n provideCompletionItems(model: monaco.editor.ITextModel, position: monaco.Position) {\n const suggestions: monaco.languages.CompletionItem[] = environmentItems(\n monaco,\n model,\n position,\n languageId,\n environment,\n );\n const range = wordRange(model, position);\n for (const item of items) suggestions.push({ ...item, range });\n return { suggestions };\n },\n };\n}\n\n/**\n * A completion item without its range. The range depends on the cursor, so it\n * is attached per request while the rest of the item is built once.\n */\ntype Item = Omit<monaco.languages.CompletionItem, \"range\">;\n\nfunction catalogueItems(monaco: Monaco, languageId: string, spec: GomplateSpec): Item[] {\n switch (pathFlavour(languageId)) {\n case \"cel\":\n return celCompletionItems(monaco, spec);\n case \"gotemplate\":\n return goTemplateCompletionItems(monaco, spec);\n default:\n // JSONPath's dialect has no catalogue to generate from; its completions\n // come entirely from the document.\n return [];\n }\n}\n\n/**\n * The keys reachable from the cursor's position in the document.\n *\n * Each item replaces the whole path typed so far with a freshly rendered one,\n * rather than appending to it, so what lands in the editor is always valid in\n * that language — quoting an awkward key, or dropping the suggestion entirely\n * where the language cannot express the path.\n */\nfunction environmentItems(\n monaco: Monaco,\n model: monaco.editor.ITextModel,\n position: monaco.Position,\n languageId: string,\n environment: EnvironmentSource | undefined,\n): monaco.languages.CompletionItem[] {\n if (!environment) return [];\n const document = environment();\n if (document === undefined || document === null) return [];\n\n const prefix = environmentPrefixAt(model, position, languageId);\n if (!prefix) return [];\n\n const parent = resolvePath(document, prefix.segments);\n if (parent === undefined) return [];\n\n const kinds = monaco.languages.CompletionItemKind;\n const range = {\n startLineNumber: position.lineNumber,\n endLineNumber: position.lineNumber,\n startColumn: prefix.startColumn,\n endColumn: prefix.endColumn,\n };\n\n // Monaco filters a candidate against the model text from the range start to\n // the cursor, so `filterText` has to continue what was typed rather than\n // repeat the rendered path: `pod.items[0]` does not match `pod.items.`, and\n // the subscripted keys would be filtered straight back out.\n const typedHead = prefix.typed.slice(0, prefix.typed.length - prefix.leaf.length);\n\n const items: monaco.languages.CompletionItem[] = [];\n for (const entry of childEntries(parent)) {\n const insertText = pathExpression(languageId, [...prefix.segments, entry.segment]);\n if (insertText === null) continue;\n items.push({\n label: entry.key,\n kind: entry.container ? kinds.Folder : kinds.Field,\n insertText,\n filterText: `${typedHead}${entry.key}`,\n detail: `${entry.kind} · ${entry.summary}`,\n // A key of the document being evaluated beats any catalogue entry: it is\n // what the author came to the editor to write.\n sortText: `0${entry.key}`,\n range,\n });\n }\n return items;\n}\n\nfunction celCompletionItems(monaco: Monaco, spec: GomplateSpec) {\n const kinds = monaco.languages.CompletionItemKind;\n const items: Item[] = [];\n\n for (const fn of spec.cel.functions) {\n items.push(buildFunctionItem(monaco, fn, celInsertText(fn), kinds.Function));\n }\n for (const macro of spec.cel.macros) {\n items.push(buildMacroItem(monaco, macro));\n }\n for (const keyword of spec.cel.keywords) {\n items.push({\n label: keyword,\n kind: kinds.Keyword,\n insertText: keyword,\n detail: \"CEL keyword\",\n });\n }\n for (const type of spec.cel.types) {\n items.push({ label: type, kind: kinds.TypeParameter, insertText: type, detail: \"CEL type\" });\n }\n return items;\n}\n\nfunction goTemplateCompletionItems(monaco: Monaco, spec: GomplateSpec) {\n const kinds = monaco.languages.CompletionItemKind;\n const items: Item[] = [];\n\n for (const fn of spec.gotemplate.functions) {\n items.push(buildFunctionItem(monaco, fn, fn.name, kinds.Function));\n }\n for (const builtin of spec.gotemplate.builtins) {\n items.push({\n label: builtin,\n kind: kinds.Function,\n insertText: builtin,\n detail: \"text/template builtin\",\n });\n }\n for (const keyword of spec.gotemplate.keywords) {\n items.push({\n label: keyword,\n kind: kinds.Keyword,\n insertText: keyword,\n detail: \"template keyword\",\n });\n }\n return items;\n}\n\nfunction buildFunctionItem(\n monaco: Monaco,\n fn: SpecFunction,\n insertText: string,\n kind: monaco.languages.CompletionItemKind,\n): Item {\n // A function with neither a Go signature nor an overload has no detail to\n // show; the key has to be absent rather than explicitly undefined.\n const detail = fn.signature ?? fn.overloads?.[0]?.result;\n return {\n label: fn.name,\n kind: fn.memberOnly ? monaco.languages.CompletionItemKind.Method : kind,\n insertText,\n ...(detail === undefined ? {} : { detail }),\n documentation: { value: functionDocumentation(fn) },\n filterText: fn.name,\n // Un-namespaced names first: they are the short, common ones, and a\n // namespace is easy to reach by typing its prefix.\n sortText: fn.namespace ? `2${fn.name}` : `1${fn.name}`,\n };\n}\n\nfunction buildMacroItem(monaco: Monaco, macro: SpecMacro): Item {\n return {\n label: macro.name,\n kind: monaco.languages.CompletionItemKind.Keyword,\n insertText: macro.name,\n detail: `macro (${macro.argCount === 0 ? \"variadic\" : `${macro.argCount} args`})`,\n documentation: { value: macroDocumentation(macro) },\n filterText: macro.name,\n sortText: `1${macro.name}`,\n };\n}\n\n/**\n * CEL functions take parentheses; a member-only function is offered without a\n * leading dot because the dot is already typed when completion fires.\n */\nfunction celInsertText(fn: SpecFunction) {\n const arity = fn.overloads?.[0]?.args.length ?? 0;\n const receiver = fn.overloads?.[0]?.member ? 1 : 0;\n return arity - receiver === 0 ? `${fn.name}()` : `${fn.name}(`;\n}\n\nfunction wordRange(\n model: {\n getWordUntilPosition(p: { lineNumber: number; column: number }): {\n startColumn: number;\n endColumn: number;\n };\n },\n position: { lineNumber: number; column: number },\n) {\n const word = model.getWordUntilPosition(position);\n return {\n startLineNumber: position.lineNumber,\n endLineNumber: position.lineNumber,\n startColumn: word.startColumn,\n endColumn: word.endColumn,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,SAAgB,mBACd,QACA,YACA,SACA;CACA,OAAO,OAAO,UAAU,+BACtB,YACA,mBAAmB,QAAQ,YAAY,OAAO,CAChD;AACF;;;;;AAMA,SAAgB,mBACd,QACA,YACA,EAAE,MAAM,eACR;CACA,MAAM,QAAQ,eAAe,QAAQ,YAAY,IAAI;CACrD,OAAO;EAEL,mBAAmB,CAAC,GAAG;EACvB,uBAAuB,OAAiC,UAA2B;GACjF,MAAM,cAAiD,iBACrD,QACA,OACA,UACA,YACA,WACF;GACA,MAAM,QAAQ,UAAU,OAAO,QAAQ;GACvC,KAAK,MAAM,QAAQ,OAAO,YAAY,KAAK;IAAE,GAAG;IAAM;GAAM,CAAC;GAC7D,OAAO,EAAE,YAAY;EACvB;CACF;AACF;AAQA,SAAS,eAAe,QAAgB,YAAoB,MAA4B;CACtF,QAAQ,YAAY,UAAU,GAA9B;EACE,KAAK,OACH,OAAO,mBAAmB,QAAQ,IAAI;EACxC,KAAK,cACH,OAAO,0BAA0B,QAAQ,IAAI;EAC/C,SAGE,OAAO,CAAC;CACZ;AACF;;;;;;;;;AAUA,SAA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E,eAAe,EAAE,OAAO,mBAAmB,KAAK,EAAE;EAClD,YAAY,MAAM;EAClB,UAAU,IAAI,MAAM;CACtB;AACF;;;;;AAMA,SAAS,cAAc,IAAkB;CAGvC,QAFc,GAAG,YAAY,EAAE,EAAE,KAAK,UAAU,MAC/B,GAAG,YAAY,EAAE,EAAE,SAAS,IAAI,OACrB,IAAI,GAAG,GAAG,KAAK,MAAM,GAAG,GAAG,KAAK;AAC9D;AAEA,SAAS,UACP,OAMA,UACA;CACA,MAAM,OAAO,MAAM,qBAAqB,QAAQ;CAChD,OAAO;EACL,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,aAAa,KAAK;EAClB,WAAW,KAAK;CAClB;AACF"}
|
|
1
|
+
{"version":3,"file":"completion.js","names":[],"sources":["../../../src/expressions/lang/completion.ts"],"sourcesContent":["import type * as monaco from \"monaco-editor\";\nimport type { GomplateSpec, Monaco, SpecFunction, SpecMacro } from \"./types.js\";\nimport { functionDocumentation, macroDocumentation } from \"./hover.js\";\nimport { childEntries, pathExpression, pathFlavour, resolvePath } from \"./environment.js\";\nimport { environmentPrefixAt } from \"./prefix.js\";\n\n/** Supplies the document expressions are evaluated against, on every request. */\nexport type EnvironmentSource = () => unknown;\n\nexport interface CompletionOptions {\n /** The catalogue to complete from — gomplate's, or a host's merged over it. */\n spec: GomplateSpec;\n environment?: EnvironmentSource | undefined;\n}\n\n/**\n * Registers completion for one language.\n *\n * The catalogue half is built once per registration, so a host that supplies\n * its own spec re-registers rather than mutating in place. The document half is\n * rebuilt per request, because the document is being edited alongside the\n * expression.\n */\nexport function registerCompletion(\n monaco: Monaco,\n languageId: string,\n options: CompletionOptions,\n) {\n return monaco.languages.registerCompletionItemProvider(\n languageId,\n completionProvider(monaco, languageId, options),\n );\n}\n\n/**\n * The provider `registerCompletion` installs, exposed so it can be driven\n * directly by a test over a real model rather than through Monaco's registry.\n */\nexport function completionProvider(\n monaco: Monaco,\n languageId: string,\n { spec, environment }: CompletionOptions,\n) {\n const items = catalogueItems(monaco, languageId, spec);\n return {\n // A dot must retrigger, or `k8s.` offers nothing until another key is hit.\n triggerCharacters: [\".\"],\n provideCompletionItems(model: monaco.editor.ITextModel, position: monaco.Position) {\n const suggestions: monaco.languages.CompletionItem[] = environmentItems(\n monaco,\n model,\n position,\n languageId,\n environment,\n );\n const range = wordRange(model, position);\n for (const item of items) suggestions.push({ ...item, range });\n return { suggestions };\n },\n };\n}\n\n/**\n * A completion item without its range. The range depends on the cursor, so it\n * is attached per request while the rest of the item is built once.\n */\ntype Item = Omit<monaco.languages.CompletionItem, \"range\">;\n\nfunction catalogueItems(monaco: Monaco, languageId: string, spec: GomplateSpec): Item[] {\n switch (pathFlavour(languageId)) {\n case \"cel\":\n return celCompletionItems(monaco, spec);\n case \"gotemplate\":\n return goTemplateCompletionItems(monaco, spec);\n default:\n // JSONPath's dialect has no catalogue to generate from; its completions\n // come entirely from the document.\n return [];\n }\n}\n\n/**\n * The keys reachable from the cursor's position in the document.\n *\n * Each item replaces the whole path typed so far with a freshly rendered one,\n * rather than appending to it, so what lands in the editor is always valid in\n * that language — quoting an awkward key, or dropping the suggestion entirely\n * where the language cannot express the path.\n */\nfunction environmentItems(\n monaco: Monaco,\n model: monaco.editor.ITextModel,\n position: monaco.Position,\n languageId: string,\n environment: EnvironmentSource | undefined,\n): monaco.languages.CompletionItem[] {\n if (!environment) return [];\n const document = environment();\n if (document === undefined || document === null) return [];\n\n const prefix = environmentPrefixAt(model, position, languageId);\n if (!prefix) return [];\n\n const parent = resolvePath(document, prefix.segments);\n if (parent === undefined) return [];\n\n const kinds = monaco.languages.CompletionItemKind;\n const range = {\n startLineNumber: position.lineNumber,\n endLineNumber: position.lineNumber,\n startColumn: prefix.startColumn,\n endColumn: prefix.endColumn,\n };\n\n // Monaco filters a candidate against the model text from the range start to\n // the cursor, so `filterText` has to continue what was typed rather than\n // repeat the rendered path: `pod.items[0]` does not match `pod.items.`, and\n // the subscripted keys would be filtered straight back out.\n const typedHead = prefix.typed.slice(0, prefix.typed.length - prefix.leaf.length);\n\n const items: monaco.languages.CompletionItem[] = [];\n for (const entry of childEntries(parent)) {\n const insertText = pathExpression(languageId, [...prefix.segments, entry.segment]);\n if (insertText === null) continue;\n items.push({\n label: entry.key,\n kind: entry.container ? kinds.Folder : kinds.Field,\n insertText,\n filterText: `${typedHead}${entry.key}`,\n detail: `${entry.kind} · ${entry.summary}`,\n // A key of the document being evaluated beats any catalogue entry: it is\n // what the author came to the editor to write.\n sortText: `0${entry.key}`,\n range,\n });\n }\n return items;\n}\n\nfunction celCompletionItems(monaco: Monaco, spec: GomplateSpec) {\n const kinds = monaco.languages.CompletionItemKind;\n const items: Item[] = [];\n\n for (const fn of spec.cel.functions) {\n items.push(buildFunctionItem(monaco, fn, celInsertText(fn), kinds.Function));\n }\n for (const macro of spec.cel.macros) {\n items.push(buildMacroItem(monaco, macro));\n }\n for (const keyword of spec.cel.keywords) {\n items.push({\n label: keyword,\n kind: kinds.Keyword,\n insertText: keyword,\n detail: \"CEL keyword\",\n });\n }\n for (const type of spec.cel.types) {\n items.push({ label: type, kind: kinds.TypeParameter, insertText: type, detail: \"CEL type\" });\n }\n return items;\n}\n\nfunction goTemplateCompletionItems(monaco: Monaco, spec: GomplateSpec) {\n const kinds = monaco.languages.CompletionItemKind;\n const items: Item[] = [];\n\n for (const fn of spec.gotemplate.functions) {\n items.push(buildFunctionItem(monaco, fn, fn.name, kinds.Function));\n }\n for (const builtin of spec.gotemplate.builtins) {\n items.push({\n label: builtin,\n kind: kinds.Function,\n insertText: builtin,\n detail: \"text/template builtin\",\n });\n }\n for (const keyword of spec.gotemplate.keywords) {\n items.push({\n label: keyword,\n kind: kinds.Keyword,\n insertText: keyword,\n detail: \"template keyword\",\n });\n }\n return items;\n}\n\nfunction buildFunctionItem(\n monaco: Monaco,\n fn: SpecFunction,\n insertText: string,\n kind: monaco.languages.CompletionItemKind,\n): Item {\n // A function with neither a Go signature nor an overload has no detail to\n // show; the key has to be absent rather than explicitly undefined.\n const detail = fn.signature ?? fn.overloads?.[0]?.result;\n return {\n label: fn.name,\n kind: fn.memberOnly ? monaco.languages.CompletionItemKind.Method : kind,\n insertText,\n ...(detail === undefined ? {} : { detail }),\n documentation: { value: functionDocumentation(fn) },\n filterText: fn.name,\n // Un-namespaced names first: they are the short, common ones, and a\n // namespace is easy to reach by typing its prefix.\n sortText: fn.namespace ? `2${fn.name}` : `1${fn.name}`,\n };\n}\n\nfunction buildMacroItem(monaco: Monaco, macro: SpecMacro): Item {\n return {\n label: macro.name,\n kind: monaco.languages.CompletionItemKind.Keyword,\n insertText: macro.name,\n detail: `macro (${macro.argCount === 0 ? \"variadic\" : `${macro.argCount} args`})`,\n documentation: { value: macroDocumentation(macro) },\n filterText: macro.name,\n sortText: `1${macro.name}`,\n };\n}\n\n/**\n * CEL functions take parentheses; a member-only function is offered without a\n * leading dot because the dot is already typed when completion fires.\n */\nfunction celInsertText(fn: SpecFunction) {\n const arity = fn.overloads?.[0]?.args.length ?? 0;\n const receiver = fn.overloads?.[0]?.member ? 1 : 0;\n return arity - receiver === 0 ? `${fn.name}()` : `${fn.name}(`;\n}\n\nfunction wordRange(\n model: {\n getWordUntilPosition(p: { lineNumber: number; column: number }): {\n startColumn: number;\n endColumn: number;\n };\n },\n position: { lineNumber: number; column: number },\n) {\n const word = model.getWordUntilPosition(position);\n return {\n startLineNumber: position.lineNumber,\n endLineNumber: position.lineNumber,\n startColumn: word.startColumn,\n endColumn: word.endColumn,\n };\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,SAAgB,mBACd,QACA,YACA,SACA;CACA,OAAO,OAAO,UAAU,+BACtB,YACA,mBAAmB,QAAQ,YAAY,OAAO,CAChD;AACF;;;;;AAMA,SAAgB,mBACd,QACA,YACA,EAAE,MAAM,eACR;CACA,MAAM,QAAQ,eAAe,QAAQ,YAAY,IAAI;CACrD,OAAO;EAEL,mBAAmB,CAAC,GAAG;EACvB,uBAAuB,OAAiC,UAA2B;GACjF,MAAM,cAAi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a,OAAO,UAAU,mBAAmB,SAAS;EACnE;EACA,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;EACzC,eAAe,EAAE,OAAO,sBAAsB,EAAE,EAAE;EAClD,YAAY,GAAG;EAGf,UAAU,GAAG,YAAY,IAAI,GAAG,SAAS,IAAI,GAAG;CAClD;AACF;AAEA,SAAS,eAAe,QAAgB,OAAwB;CAC9D,OAAO;EACL,OAAO,MAAM;EACb,MAAM,OAAO,UAAU,mBAAmB;EAC1C,YAAY,MAAM;EAClB,QAAQ,UAAU,MAAM,aAAa,IAAI,aAAa,GAAG,MAAM,SAAS,OAAO;EAC/E,eAAe,EAAE,OAAO,mBAAmB,KAAK,EAAE;EAClD,YAAY,MAAM;EAClB,UAAU,IAAI,MAAM;CACtB;AACF;;;;;AAMA,SAAS,cAAc,IAAkB;CAGvC,QAFc,GAAG,YAAY,EAAE,EAAE,KAAK,UAAU,MAC/B,GAAG,YAAY,EAAE,EAAE,SAAS,IAAI,OACrB,IAAI,GAAG,GAAG,KAAK,MAAM,GAAG,GAAG,KAAK;AAC9D;AAEA,SAAS,UACP,OAMA,UACA;CACA,MAAM,OAAO,MAAM,qBAAqB,QAAQ;CAChD,OAAO;EACL,iBAAiB,SAAS;EAC1B,eAAe,SAAS;EACxB,aAAa,KAAK;EAClB,WAAW,KAAK;CAClB;AACF"}
|
|
@@ -975,6 +975,40 @@ declare const _default: [
|
|
|
975
975
|
],
|
|
976
976
|
"origin": "GO_TEMPLATE.md"
|
|
977
977
|
},
|
|
978
|
+
{
|
|
979
|
+
"language": "cel",
|
|
980
|
+
"source": "CEL: acmeDeclarations,",
|
|
981
|
+
"boundaries": [
|
|
982
|
+
0,
|
|
983
|
+
3,
|
|
984
|
+
5,
|
|
985
|
+
21
|
|
986
|
+
],
|
|
987
|
+
"origin": "README.md"
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
"language": "cel",
|
|
991
|
+
"source": "CEL: catalog.Page{URL: \"/docs/reference/cel/\", Options: gendocs.Options{",
|
|
992
|
+
"boundaries": [
|
|
993
|
+
0,
|
|
994
|
+
3,
|
|
995
|
+
5,
|
|
996
|
+
12,
|
|
997
|
+
13,
|
|
998
|
+
17,
|
|
999
|
+
18,
|
|
1000
|
+
21,
|
|
1001
|
+
23,
|
|
1002
|
+
45,
|
|
1003
|
+
47,
|
|
1004
|
+
54,
|
|
1005
|
+
56,
|
|
1006
|
+
63,
|
|
1007
|
+
64,
|
|
1008
|
+
71
|
|
1009
|
+
],
|
|
1010
|
+
"origin": "README.md"
|
|
1011
|
+
},
|
|
978
1012
|
{
|
|
979
1013
|
"language": "cel",
|
|
980
1014
|
"source": "CSV([\"Alice,30\", \"Bob,31\"])[0][0]",
|
|
@@ -1005,6 +1039,30 @@ declare const _default: [
|
|
|
1005
1039
|
],
|
|
1006
1040
|
"origin": "README.md"
|
|
1007
1041
|
},
|
|
1042
|
+
{
|
|
1043
|
+
"language": "cel",
|
|
1044
|
+
"source": "Docs: catalog.Docs{",
|
|
1045
|
+
"boundaries": [
|
|
1046
|
+
0,
|
|
1047
|
+
4,
|
|
1048
|
+
6,
|
|
1049
|
+
13,
|
|
1050
|
+
14,
|
|
1051
|
+
18
|
|
1052
|
+
],
|
|
1053
|
+
"origin": "README.md"
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
"language": "cel",
|
|
1057
|
+
"source": "Frontmatter: true,",
|
|
1058
|
+
"boundaries": [
|
|
1059
|
+
0,
|
|
1060
|
+
11,
|
|
1061
|
+
13,
|
|
1062
|
+
17
|
|
1063
|
+
],
|
|
1064
|
+
"origin": "README.md"
|
|
1065
|
+
},
|
|
1008
1066
|
{
|
|
1009
1067
|
"language": "cel",
|
|
1010
1068
|
"source": "Go,25",
|
|
@@ -1015,6 +1073,35 @@ declare const _default: [
|
|
|
1015
1073
|
],
|
|
1016
1074
|
"origin": "GO_TEMPLATE.md"
|
|
1017
1075
|
},
|
|
1076
|
+
{
|
|
1077
|
+
"language": "cel",
|
|
1078
|
+
"source": "GoTemplate: catalog.Page{URL: \"/docs/reference/templates/\"},",
|
|
1079
|
+
"boundaries": [
|
|
1080
|
+
0,
|
|
1081
|
+
10,
|
|
1082
|
+
12,
|
|
1083
|
+
19,
|
|
1084
|
+
20,
|
|
1085
|
+
24,
|
|
1086
|
+
25,
|
|
1087
|
+
28,
|
|
1088
|
+
30,
|
|
1089
|
+
58,
|
|
1090
|
+
59
|
|
1091
|
+
],
|
|
1092
|
+
"origin": "README.md"
|
|
1093
|
+
},
|
|
1094
|
+
{
|
|
1095
|
+
"language": "cel",
|
|
1096
|
+
"source": "Intro: \"Acme evaluates CEL in rule conditions.\",",
|
|
1097
|
+
"boundaries": [
|
|
1098
|
+
0,
|
|
1099
|
+
5,
|
|
1100
|
+
13,
|
|
1101
|
+
53
|
|
1102
|
+
],
|
|
1103
|
+
"origin": "README.md"
|
|
1104
|
+
},
|
|
1018
1105
|
{
|
|
1019
1106
|
"language": "cel",
|
|
1020
1107
|
"source": "Message string",
|
|
@@ -1024,6 +1111,17 @@ declare const _default: [
|
|
|
1024
1111
|
],
|
|
1025
1112
|
"origin": "README.md"
|
|
1026
1113
|
},
|
|
1114
|
+
{
|
|
1115
|
+
"language": "cel",
|
|
1116
|
+
"source": "Name: \"Acme\",",
|
|
1117
|
+
"boundaries": [
|
|
1118
|
+
0,
|
|
1119
|
+
4,
|
|
1120
|
+
6,
|
|
1121
|
+
12
|
|
1122
|
+
],
|
|
1123
|
+
"origin": "README.md"
|
|
1124
|
+
},
|
|
1027
1125
|
{
|
|
1028
1126
|
"language": "cel",
|
|
1029
1127
|
"source": "R'raw\\dstring'",
|
|
@@ -1032,6 +1130,27 @@ declare const _default: [
|
|
|
1032
1130
|
],
|
|
1033
1131
|
"origin": "edge-case"
|
|
1034
1132
|
},
|
|
1133
|
+
{
|
|
1134
|
+
"language": "cel",
|
|
1135
|
+
"source": "Template: must(catalog.TemplateFunctions(acmeFuncs, acmeDocs)),",
|
|
1136
|
+
"boundaries": [
|
|
1137
|
+
0,
|
|
1138
|
+
8,
|
|
1139
|
+
10,
|
|
1140
|
+
14,
|
|
1141
|
+
15,
|
|
1142
|
+
22,
|
|
1143
|
+
23,
|
|
1144
|
+
40,
|
|
1145
|
+
41,
|
|
1146
|
+
50,
|
|
1147
|
+
52,
|
|
1148
|
+
60,
|
|
1149
|
+
61,
|
|
1150
|
+
62
|
|
1151
|
+
],
|
|
1152
|
+
"origin": "README.md"
|
|
1153
|
+
},
|
|
1035
1154
|
{
|
|
1036
1155
|
"language": "cel",
|
|
1037
1156
|
"source": "ValuesProvider: redacting{},",
|
|
@@ -1194,6 +1313,138 @@ declare const _default: [
|
|
|
1194
1313
|
],
|
|
1195
1314
|
"origin": "CEL.md"
|
|
1196
1315
|
},
|
|
1316
|
+
{
|
|
1317
|
+
"language": "cel",
|
|
1318
|
+
"source": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].percentile(90)",
|
|
1319
|
+
"boundaries": [
|
|
1320
|
+
0,
|
|
1321
|
+
1,
|
|
1322
|
+
2,
|
|
1323
|
+
4,
|
|
1324
|
+
5,
|
|
1325
|
+
7,
|
|
1326
|
+
8,
|
|
1327
|
+
10,
|
|
1328
|
+
11,
|
|
1329
|
+
13,
|
|
1330
|
+
14,
|
|
1331
|
+
16,
|
|
1332
|
+
17,
|
|
1333
|
+
19,
|
|
1334
|
+
20,
|
|
1335
|
+
22,
|
|
1336
|
+
23,
|
|
1337
|
+
25,
|
|
1338
|
+
26,
|
|
1339
|
+
28,
|
|
1340
|
+
30,
|
|
1341
|
+
31,
|
|
1342
|
+
32,
|
|
1343
|
+
42,
|
|
1344
|
+
43,
|
|
1345
|
+
45
|
|
1346
|
+
],
|
|
1347
|
+
"origin": "CEL.md"
|
|
1348
|
+
},
|
|
1349
|
+
{
|
|
1350
|
+
"language": "cel",
|
|
1351
|
+
"source": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].percentile(95)",
|
|
1352
|
+
"boundaries": [
|
|
1353
|
+
0,
|
|
1354
|
+
1,
|
|
1355
|
+
2,
|
|
1356
|
+
4,
|
|
1357
|
+
5,
|
|
1358
|
+
7,
|
|
1359
|
+
8,
|
|
1360
|
+
10,
|
|
1361
|
+
11,
|
|
1362
|
+
13,
|
|
1363
|
+
14,
|
|
1364
|
+
16,
|
|
1365
|
+
17,
|
|
1366
|
+
19,
|
|
1367
|
+
20,
|
|
1368
|
+
22,
|
|
1369
|
+
23,
|
|
1370
|
+
25,
|
|
1371
|
+
26,
|
|
1372
|
+
28,
|
|
1373
|
+
30,
|
|
1374
|
+
31,
|
|
1375
|
+
32,
|
|
1376
|
+
42,
|
|
1377
|
+
43,
|
|
1378
|
+
45
|
|
1379
|
+
],
|
|
1380
|
+
"origin": "CEL.md"
|
|
1381
|
+
},
|
|
1382
|
+
{
|
|
1383
|
+
"language": "cel",
|
|
1384
|
+
"source": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].stats()",
|
|
1385
|
+
"boundaries": [
|
|
1386
|
+
0,
|
|
1387
|
+
1,
|
|
1388
|
+
2,
|
|
1389
|
+
4,
|
|
1390
|
+
5,
|
|
1391
|
+
7,
|
|
1392
|
+
8,
|
|
1393
|
+
10,
|
|
1394
|
+
11,
|
|
1395
|
+
13,
|
|
1396
|
+
14,
|
|
1397
|
+
16,
|
|
1398
|
+
17,
|
|
1399
|
+
19,
|
|
1400
|
+
20,
|
|
1401
|
+
22,
|
|
1402
|
+
23,
|
|
1403
|
+
25,
|
|
1404
|
+
26,
|
|
1405
|
+
28,
|
|
1406
|
+
30,
|
|
1407
|
+
31,
|
|
1408
|
+
32,
|
|
1409
|
+
37,
|
|
1410
|
+
38
|
|
1411
|
+
],
|
|
1412
|
+
"origin": "CEL.md"
|
|
1413
|
+
},
|
|
1414
|
+
{
|
|
1415
|
+
"language": "cel",
|
|
1416
|
+
"source": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].stats().p90",
|
|
1417
|
+
"boundaries": [
|
|
1418
|
+
0,
|
|
1419
|
+
1,
|
|
1420
|
+
2,
|
|
1421
|
+
4,
|
|
1422
|
+
5,
|
|
1423
|
+
7,
|
|
1424
|
+
8,
|
|
1425
|
+
10,
|
|
1426
|
+
11,
|
|
1427
|
+
13,
|
|
1428
|
+
14,
|
|
1429
|
+
16,
|
|
1430
|
+
17,
|
|
1431
|
+
19,
|
|
1432
|
+
20,
|
|
1433
|
+
22,
|
|
1434
|
+
23,
|
|
1435
|
+
25,
|
|
1436
|
+
26,
|
|
1437
|
+
28,
|
|
1438
|
+
30,
|
|
1439
|
+
31,
|
|
1440
|
+
32,
|
|
1441
|
+
37,
|
|
1442
|
+
38,
|
|
1443
|
+
39,
|
|
1444
|
+
40
|
|
1445
|
+
],
|
|
1446
|
+
"origin": "CEL.md"
|
|
1447
|
+
},
|
|
1197
1448
|
{
|
|
1198
1449
|
"language": "cel",
|
|
1199
1450
|
"source": "[1, 2, 3, 4].filter(e, e \u003e 2)",
|
|
@@ -1651,6 +1902,25 @@ declare const _default: [
|
|
|
1651
1902
|
],
|
|
1652
1903
|
"origin": "CEL.md"
|
|
1653
1904
|
},
|
|
1905
|
+
{
|
|
1906
|
+
"language": "cel",
|
|
1907
|
+
"source": "[3, 2.5, 1].percentile(50)",
|
|
1908
|
+
"boundaries": [
|
|
1909
|
+
0,
|
|
1910
|
+
1,
|
|
1911
|
+
2,
|
|
1912
|
+
4,
|
|
1913
|
+
7,
|
|
1914
|
+
9,
|
|
1915
|
+
10,
|
|
1916
|
+
11,
|
|
1917
|
+
12,
|
|
1918
|
+
22,
|
|
1919
|
+
23,
|
|
1920
|
+
25
|
|
1921
|
+
],
|
|
1922
|
+
"origin": "CEL.md"
|
|
1923
|
+
},
|
|
1654
1924
|
{
|
|
1655
1925
|
"language": "cel",
|
|
1656
1926
|
"source": "[[1, 2], [3, 4]].flatten()",
|
|
@@ -4979,6 +5249,16 @@ declare const _default: [
|
|
|
4979
5249
|
],
|
|
4980
5250
|
"origin": "README.md"
|
|
4981
5251
|
},
|
|
5252
|
+
{
|
|
5253
|
+
"language": "cel",
|
|
5254
|
+
"source": "}},",
|
|
5255
|
+
"boundaries": [
|
|
5256
|
+
0,
|
|
5257
|
+
1,
|
|
5258
|
+
2
|
|
5259
|
+
],
|
|
5260
|
+
"origin": "README.md"
|
|
5261
|
+
},
|
|
4982
5262
|
{
|
|
4983
5263
|
"language": "gomplate",
|
|
4984
5264
|
"source": "{{ $x := coll.Dict \"a\" 1 }}{{ $x }}",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["specJson","languagesJson"],"sources":["../../../../src/expressions/lang/generated/index.ts"],"sourcesContent":["// Code generated by cmd/genmonarch. DO NOT EDIT.\n//\n// Regenerate with: make monarch\n// The tokenizers come from cel-go's CEL.g4 and text/template's lexer; the\n// function catalogue is read from a live cel.Env and gomplate's FuncMap.\n\nimport type { ConformanceCase, LanguageDefinition, GomplateSpec } from \"../types\";\n\nimport languagesJson from \"./languages.json\";\nimport specJson from \"./spec.json\";\nimport conformanceJson from \"./conformance.json\";\n\nexport const spec = specJson as GomplateSpec;\n\n/** Token boundaries produced by the languages' real lexers. */\nexport const conformance = conformanceJson as ConformanceCase[];\n\n/** Every language id this package registers. */\nexport const LANGUAGE_IDS = [\n \"cel\",\n \"gomplate\",\n \"json-gomplate\",\n \"jsonpath\",\n \"text-gomplate\",\n \"yaml-gomplate\",\n] as const;\n\nexport type LanguageId = (typeof LANGUAGE_IDS)[number];\n\nexport const definitions = languagesJson as unknown as Record<LanguageId, LanguageDefinition>;\n"],"mappings":";;AAYA,IAAa,O,oBAAOA,CAAAA,CAAAA;;AAMpB,IAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAa,cAAcC,kBAAAA"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["specJson","languagesJson"],"sources":["../../../../src/expressions/lang/generated/index.ts"],"sourcesContent":["// Code generated by cmd/genmonarch. DO NOT EDIT.\n//\n// Regenerate with: make monarch\n// The tokenizers come from cel-go's CEL.g4 and text/template's lexer; the\n// function catalogue is read from a live cel.Env and gomplate's FuncMap.\n\nimport type { ConformanceCase, LanguageDefinition, GomplateSpec } from \"../types.js\";\n\nimport languagesJson from \"./languages.json\";\nimport specJson from \"./spec.json\";\nimport conformanceJson from \"./conformance.json\";\n\nexport const spec = specJson as GomplateSpec;\n\n/** Token boundaries produced by the languages' real lexers. */\nexport const conformance = conformanceJson as ConformanceCase[];\n\n/** Every language id this package registers. */\nexport const LANGUAGE_IDS = [\n \"cel\",\n \"gomplate\",\n \"json-gomplate\",\n \"jsonpath\",\n \"text-gomplate\",\n \"yaml-gomplate\",\n] as const;\n\nexport type LanguageId = (typeof LANGUAGE_IDS)[number];\n\nexport const definitions = languagesJson as unknown as Record<LanguageId, LanguageDefinition>;\n"],"mappings":";;AAYA,IAAa,O,oBAAOA,CAAAA,CAAAA;;AAMpB,IAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAa,cAAcC,kBAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/expressions/lang/generated/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/expressions/lang/generated/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMrF,eAAO,MAAM,IAAI,EAAe,YAAY,CAAC;AAE7C,+DAA+D;AAC/D,eAAO,MAAM,WAAW,EAAsB,eAAe,EAAE,CAAC;AAEhE,gDAAgD;AAChD,eAAO,MAAM,YAAY,6FAOf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,eAAO,MAAM,WAAW,EAA+B,MAAM,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["specJson","languagesJson"],"sources":["../../../../src/expressions/lang/generated/index.ts"],"sourcesContent":["// Code generated by cmd/genmonarch. DO NOT EDIT.\n//\n// Regenerate with: make monarch\n// The tokenizers come from cel-go's CEL.g4 and text/template's lexer; the\n// function catalogue is read from a live cel.Env and gomplate's FuncMap.\n\nimport type { ConformanceCase, LanguageDefinition, GomplateSpec } from \"../types\";\n\nimport languagesJson from \"./languages.json\";\nimport specJson from \"./spec.json\";\nimport conformanceJson from \"./conformance.json\";\n\nexport const spec = specJson as GomplateSpec;\n\n/** Token boundaries produced by the languages' real lexers. */\nexport const conformance = conformanceJson as ConformanceCase[];\n\n/** Every language id this package registers. */\nexport const LANGUAGE_IDS = [\n \"cel\",\n \"gomplate\",\n \"json-gomplate\",\n \"jsonpath\",\n \"text-gomplate\",\n \"yaml-gomplate\",\n] as const;\n\nexport type LanguageId = (typeof LANGUAGE_IDS)[number];\n\nexport const definitions = languagesJson as unknown as Record<LanguageId, LanguageDefinition>;\n"],"mappings":";;;AAYA,IAAa,OAAOA;;AAMpB,IAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAa,cAAcC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["specJson","languagesJson"],"sources":["../../../../src/expressions/lang/generated/index.ts"],"sourcesContent":["// Code generated by cmd/genmonarch. DO NOT EDIT.\n//\n// Regenerate with: make monarch\n// The tokenizers come from cel-go's CEL.g4 and text/template's lexer; the\n// function catalogue is read from a live cel.Env and gomplate's FuncMap.\n\nimport type { ConformanceCase, LanguageDefinition, GomplateSpec } from \"../types.js\";\n\nimport languagesJson from \"./languages.json\";\nimport specJson from \"./spec.json\";\nimport conformanceJson from \"./conformance.json\";\n\nexport const spec = specJson as GomplateSpec;\n\n/** Token boundaries produced by the languages' real lexers. */\nexport const conformance = conformanceJson as ConformanceCase[];\n\n/** Every language id this package registers. */\nexport const LANGUAGE_IDS = [\n \"cel\",\n \"gomplate\",\n \"json-gomplate\",\n \"jsonpath\",\n \"text-gomplate\",\n \"yaml-gomplate\",\n] as const;\n\nexport type LanguageId = (typeof LANGUAGE_IDS)[number];\n\nexport const definitions = languagesJson as unknown as Record<LanguageId, LanguageDefinition>;\n"],"mappings":";;;AAYA,IAAa,OAAOA;;AAMpB,IAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAa,cAAcC"}
|
|
@@ -305,6 +305,7 @@ var cel = {
|
|
|
305
305
|
"one",
|
|
306
306
|
"or",
|
|
307
307
|
"orValue",
|
|
308
|
+
"percentile",
|
|
308
309
|
"pick",
|
|
309
310
|
"quote",
|
|
310
311
|
"repeat",
|
|
@@ -323,6 +324,7 @@ var cel = {
|
|
|
323
324
|
"splitRegex",
|
|
324
325
|
"squote",
|
|
325
326
|
"startsWith",
|
|
327
|
+
"stats",
|
|
326
328
|
"substring",
|
|
327
329
|
"sum",
|
|
328
330
|
"title",
|