@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix.cjs","names":["pathFlavour","spec"],"sources":["../../../src/expressions/lang/prefix.ts"],"sourcesContent":["import { spec } from \"./generated\";\nimport { pathFlavour } from \"./environment\";\nimport type { PathSegment } from \"./environment\";\n\n/** The subset of a Monaco model this module reads. */\nexport interface PrefixModel {\n getLineContent(line: number): string;\n}\n\nexport interface PrefixPosition {\n lineNumber: number;\n column: number;\n}\n\n/** A path expression under construction at the cursor. */\nexport interface EnvironmentPrefix {\n /** The segments already committed, left of the trailing dot. */\n segments: PathSegment[];\n /** The partially typed leaf, empty right after a dot. */\n leaf: string;\n /**\n * 1-based columns spanning the whole expression typed so far, root marker\n * included. A completion replaces this range with a freshly rendered path, so\n * the inserted text is always well formed rather than glued onto what is\n * already there.\n */\n startColumn: number;\n endColumn: number;\n /** The text in that range, which Monaco filters candidates against. */\n typed: string;\n}\n\nconst IDENT = /[A-Za-z0-9_]/;\nconst SUBSCRIPT = /^(?:(\\d+)|\"((?:[^\"\\\\]|\\\\.)*)\"|'((?:[^'\\\\]|\\\\.)*)')$/;\n\n/**\n * Reads the path expression the cursor sits in, or null when it sits somewhere\n * the document's keys have no meaning.\n *\n * `dottedWordAt` in `hover.ts` cannot serve here: it scans past the cursor and\n * strips the trailing dot, and the trailing dot is precisely the signal that a\n * child is being completed.\n */\nexport function environmentPrefixAt(\n model: PrefixModel,\n position: PrefixPosition,\n languageId: string,\n): EnvironmentPrefix | null {\n const flavour = pathFlavour(languageId);\n if (!flavour) return null;\n\n const line = model.getLineContent(position.lineNumber);\n const before = line.slice(0, position.column - 1);\n\n if (flavour === \"gotemplate\" && !insideAction(before)) return null;\n\n let leafStart = before.length;\n while (leafStart > 0 && IDENT.test(before[leafStart - 1]!)) leafStart--;\n const leaf = before.slice(leafStart);\n const head = before.slice(0, leafStart);\n\n const chain = parseChain(head);\n if (!chain) return null;\n // Without a dot the leaf can only be a root name, so anything that looks like\n // the tail of a path before it (`items[0]name`) is malformed, not a prefix.\n if (leaf !== \"\" && !chain.dotted && chain.segments.length > 0) return null;\n\n // `chain.start` already sits on the leading `.` when there is one, so a go\n // template needs no adjustment; JSONPath's `$` sits one place further left.\n let start = chain.start;\n if (flavour === \"gotemplate\" && !chain.rooted) return null;\n if (flavour === \"jsonpath\") {\n const marker = head[chain.start - 1];\n if (marker !== \"$\" && marker !== \"@\") return null;\n start -= 1;\n }\n if (flavour === \"cel\" && chain.rooted) return null; // a leading `.` is not CEL\n\n return {\n segments: chain.segments,\n leaf,\n startColumn: start + 1,\n endColumn: position.column,\n typed: before.slice(start),\n };\n}\n\ninterface Chain {\n segments: PathSegment[];\n /** Index in `head` where the segment list starts, root marker excluded. */\n start: number;\n /** Whether `head` ends with the dot that opens a new segment. */\n dotted: boolean;\n /** Whether the outermost segment is preceded by a `.`, as go templates need. */\n rooted: boolean;\n}\n\n/**\n * Parses the trailing path of `head` backwards.\n *\n * Backwards because a path has no left boundary of its own: it ends where the\n * expression around it begins, and that is only knowable by walking off it.\n */\nfunction parseChain(head: string): Chain | null {\n let pos = head.length;\n const dotted = pos > 0 && head[pos - 1] === \".\";\n if (dotted) pos--;\n\n const reversed: PathSegment[] = [];\n let rooted = false;\n\n for (;;) {\n if (pos > 0 && head[pos - 1] === \"]\") {\n const open = head.lastIndexOf(\"[\", pos - 2);\n if (open < 0) return null;\n const segment = parseSubscript(head.slice(open + 1, pos - 1));\n if (segment === null) return null;\n reversed.push(segment);\n pos = open;\n rooted = false;\n continue;\n }\n if (pos > 0 && IDENT.test(head[pos - 1]!)) {\n let start = pos;\n while (start > 0 && IDENT.test(head[start - 1]!)) start--;\n reversed.push(head.slice(start, pos));\n pos = start;\n rooted = pos > 0 && head[pos - 1] === \".\";\n if (rooted) {\n pos--;\n continue;\n }\n break;\n }\n break;\n }\n\n // Only the trailing dot was consumed, so that dot is itself the root marker.\n if (reversed.length === 0 && dotted) rooted = true;\n\n return { segments: reversed.reverse(), start: pos, dotted, rooted };\n}\n\nfunction parseSubscript(inner: string): PathSegment | null {\n const match = SUBSCRIPT.exec(inner.trim());\n if (!match) return null;\n if (match[1] !== undefined) return Number(match[1]);\n const quoted = match[2] ?? match[3]!;\n try {\n return JSON.parse(`\"${quoted.replace(/\\\\'/g, \"'\")}\"`) as string;\n } catch {\n return null;\n }\n}\n\n/**\n * Whether the cursor sits between template delimiters. Outside them the text is\n * literal output, where a key path means nothing.\n */\nfunction insideAction(before: string): boolean {\n const { left, right, leftComment, rightComment } = spec.gotemplate.delimiters;\n\n const open = before.lastIndexOf(left);\n if (open < 0) return false;\n if (before.lastIndexOf(right) > open) return false;\n\n // `{{/*` opens with the ordinary left delimiter, so an unterminated comment\n // reads as an open action unless it is checked for separately.\n const comment = before.lastIndexOf(leftComment);\n if (comment >= open && before.lastIndexOf(rightComment) < comment) return false;\n\n return true;\n}\n"],"mappings":";;;AAgCA,IAAM,QAAQ;AACd,IAAM,YAAY;;;;;;;;;AAUlB,SAAgB,oBACd,OACA,UACA,YAC0B;CAC1B,MAAM,UAAUA,oBAAAA,YAAY,UAAU;CACtC,IAAI,CAAC,SAAS,OAAO;CAGrB,MAAM,SADO,MAAM,eAAe,SAAS,UAC5B,CAAA,CAAK,MAAM,GAAG,SAAS,SAAS,CAAC;CAEhD,IAAI,YAAY,gBAAgB,CAAC,aAAa,MAAM,GAAG,OAAO;CAE9D,IAAI,YAAY,OAAO;CACvB,OAAO,YAAY,KAAK,MAAM,KAAK,OAAO,YAAY,EAAG,GAAG;CAC5D,MAAM,OAAO,OAAO,MAAM,SAAS;CACnC,MAAM,OAAO,OAAO,MAAM,GAAG,SAAS;CAEtC,MAAM,QAAQ,WAAW,IAAI;CAC7B,IAAI,CAAC,OAAO,OAAO;CAGnB,IAAI,SAAS,MAAM,CAAC,MAAM,UAAU,MAAM,SAAS,SAAS,GAAG,OAAO;CAItE,I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,SAAS,eAAe,OAAmC;CACzD,MAAM,QAAQ,UAAU,KAAK,MAAM,KAAK,CAAC;CACzC,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI,MAAM,OAAO,KAAA,GAAW,OAAO,OAAO,MAAM,EAAE;CAClD,MAAM,SAAS,MAAM,MAAM,MAAM;CACjC,IAAI;EACF,OAAO,KAAK,MAAM,IAAI,OAAO,QAAQ,QAAQ,GAAG,EAAE,EAAE;CACtD,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,SAAS,aAAa,QAAyB;CAC7C,MAAM,EAAE,MAAM,OAAO,aAAa,iBAAiBC,cAAAA,KAAK,WAAW;CAEnE,MAAM,OAAO,OAAO,YAAY,IAAI;CACpC,IAAI,OAAO,GAAG,OAAO;CACrB,IAAI,OAAO,YAAY,KAAK,IAAI,MAAM,OAAO;CAI7C,MAAM,UAAU,OAAO,YAAY,WAAW;CAC9C,IAAI,WAAW,QAAQ,OAAO,YAAY,YAAY,IAAI,SAAS,OAAO;CAE1E,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"prefix.cjs","names":["pathFlavour","spec"],"sources":["../../../src/expressions/lang/prefix.ts"],"sourcesContent":["import { spec } from \"./generated/index.js\";\nimport { pathFlavour } from \"./environment.js\";\nimport type { PathSegment } from \"./environment.js\";\n\n/** The subset of a Monaco model this module reads. */\nexport interface PrefixModel {\n getLineContent(line: number): string;\n}\n\nexport interface PrefixPosition {\n lineNumber: number;\n column: number;\n}\n\n/** A path expression under construction at the cursor. */\nexport interface EnvironmentPrefix {\n /** The segments already committed, left of the trailing dot. */\n segments: PathSegment[];\n /** The partially typed leaf, empty right after a dot. */\n leaf: string;\n /**\n * 1-based columns spanning the whole expression typed so far, root marker\n * included. A completion replaces this range with a freshly rendered path, so\n * the inserted text is always well formed rather than glued onto what is\n * already there.\n */\n startColumn: number;\n endColumn: number;\n /** The text in that range, which Monaco filters candidates against. */\n typed: string;\n}\n\nconst IDENT = /[A-Za-z0-9_]/;\nconst SUBSCRIPT = /^(?:(\\d+)|\"((?:[^\"\\\\]|\\\\.)*)\"|'((?:[^'\\\\]|\\\\.)*)')$/;\n\n/**\n * Reads the path expression the cursor sits in, or null when it sits somewhere\n * the document's keys have no meaning.\n *\n * `dottedWordAt` in `hover.ts` cannot serve here: it scans past the cursor and\n * strips the trailing dot, and the trailing dot is precisely the signal that a\n * child is being completed.\n */\nexport function environmentPrefixAt(\n model: PrefixModel,\n position: PrefixPosition,\n languageId: string,\n): EnvironmentPrefix | null {\n const flavour = pathFlavour(languageId);\n if (!flavour) return null;\n\n const line = model.getLineContent(position.lineNumber);\n const before = line.slice(0, position.column - 1);\n\n if (flavour === \"gotemplate\" && !insideAction(before)) return null;\n\n let leafStart = before.length;\n while (leafStart > 0 && IDENT.test(before[leafStart - 1]!)) leafStart--;\n const leaf = before.slice(leafStart);\n const head = before.slice(0, leafStart);\n\n const chain = parseChain(head);\n if (!chain) return null;\n // Without a dot the leaf can only be a root name, so anything that looks like\n // the tail of a path before it (`items[0]name`) is malformed, not a prefix.\n if (leaf !== \"\" && !chain.dotted && chain.segments.length > 0) return null;\n\n // `chain.start` already sits on the leading `.` when there is one, so a go\n // template needs no adjustment; JSONPath's `$` sits one place further left.\n let start = chain.start;\n if (flavour === \"gotemplate\" && !chain.rooted) return null;\n if (flavour === \"jsonpath\") {\n const marker = head[chain.start - 1];\n if (marker !== \"$\" && marker !== \"@\") return null;\n start -= 1;\n }\n if (flavour === \"cel\" && chain.rooted) return null; // a leading `.` is not CEL\n\n return {\n segments: chain.segments,\n leaf,\n startColumn: start + 1,\n endColumn: position.column,\n typed: before.slice(start),\n };\n}\n\ninterface Chain {\n segments: PathSegment[];\n /** Index in `head` where the segment list starts, root marker excluded. */\n start: number;\n /** Whether `head` ends with the dot that opens a new segment. */\n dotted: boolean;\n /** Whether the outermost segment is preceded by a `.`, as go templates need. */\n rooted: boolean;\n}\n\n/**\n * Parses the trailing path of `head` backwards.\n *\n * Backwards because a path has no left boundary of its own: it ends where the\n * expression around it begins, and that is only knowable by walking off it.\n */\nfunction parseChain(head: string): Chain | null {\n let pos = head.length;\n const dotted = pos > 0 && head[pos - 1] === \".\";\n if (dotted) pos--;\n\n const reversed: PathSegment[] = [];\n let rooted = false;\n\n for (;;) {\n if (pos > 0 && head[pos - 1] === \"]\") {\n const open = head.lastIndexOf(\"[\", pos - 2);\n if (open < 0) return null;\n const segment = parseSubscript(head.slice(open + 1, pos - 1));\n if (segment === null) return null;\n reversed.push(segment);\n pos = open;\n rooted = false;\n continue;\n }\n if (pos > 0 && IDENT.test(head[pos - 1]!)) {\n let start = pos;\n while (start > 0 && IDENT.test(head[start - 1]!)) start--;\n reversed.push(head.slice(start, pos));\n pos = start;\n rooted = pos > 0 && head[pos - 1] === \".\";\n if (rooted) {\n pos--;\n continue;\n }\n break;\n }\n break;\n }\n\n // Only the trailing dot was consumed, so that dot is itself the root marker.\n if (reversed.length === 0 && dotted) rooted = true;\n\n return { segments: reversed.reverse(), start: pos, dotted, rooted };\n}\n\nfunction parseSubscript(inner: string): PathSegment | null {\n const match = SUBSCRIPT.exec(inner.trim());\n if (!match) return null;\n if (match[1] !== undefined) return Number(match[1]);\n const quoted = match[2] ?? match[3]!;\n try {\n return JSON.parse(`\"${quoted.replace(/\\\\'/g, \"'\")}\"`) as string;\n } catch {\n return null;\n }\n}\n\n/**\n * Whether the cursor sits between template delimiters. Outside them the text is\n * literal output, where a key path means nothing.\n */\nfunction insideAction(before: string): boolean {\n const { left, right, leftComment, rightComment } = spec.gotemplate.delimiters;\n\n const open = before.lastIndexOf(left);\n if (open < 0) return false;\n if (before.lastIndexOf(right) > open) return false;\n\n // `{{/*` opens with the ordinary left delimiter, so an unterminated comment\n // reads as an open action unless it is checked for separately.\n const comment = before.lastIndexOf(leftComment);\n if (comment >= open && before.lastIndexOf(rightComment) < comment) return false;\n\n return true;\n}\n"],"mappings":";;;AAgCA,IAAM,QAAQ;AACd,IAAM,YAAY;;;;;;;;;AAUlB,SAAgB,oBACd,OAC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ts","sourceRoot":"","sources":["../../../src/expressions/lang/prefix.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"prefix.d.ts","sourceRoot":"","sources":["../../../src/expressions/lang/prefix.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACtC;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,0DAA0D;AAC1D,MAAM,WAAW,iBAAiB;IAChC,gEAAgE;IAChE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;CACf;AAKD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,cAAc,EACxB,UAAU,EAAE,MAAM,GACjB,iBAAiB,GAAG,IAAI,CAsC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix.js","names":[],"sources":["../../../src/expressions/lang/prefix.ts"],"sourcesContent":["import { spec } from \"./generated\";\nimport { pathFlavour } from \"./environment\";\nimport type { PathSegment } from \"./environment\";\n\n/** The subset of a Monaco model this module reads. */\nexport interface PrefixModel {\n getLineContent(line: number): string;\n}\n\nexport interface PrefixPosition {\n lineNumber: number;\n column: number;\n}\n\n/** A path expression under construction at the cursor. */\nexport interface EnvironmentPrefix {\n /** The segments already committed, left of the trailing dot. */\n segments: PathSegment[];\n /** The partially typed leaf, empty right after a dot. */\n leaf: string;\n /**\n * 1-based columns spanning the whole expression typed so far, root marker\n * included. A completion replaces this range with a freshly rendered path, so\n * the inserted text is always well formed rather than glued onto what is\n * already there.\n */\n startColumn: number;\n endColumn: number;\n /** The text in that range, which Monaco filters candidates against. */\n typed: string;\n}\n\nconst IDENT = /[A-Za-z0-9_]/;\nconst SUBSCRIPT = /^(?:(\\d+)|\"((?:[^\"\\\\]|\\\\.)*)\"|'((?:[^'\\\\]|\\\\.)*)')$/;\n\n/**\n * Reads the path expression the cursor sits in, or null when it sits somewhere\n * the document's keys have no meaning.\n *\n * `dottedWordAt` in `hover.ts` cannot serve here: it scans past the cursor and\n * strips the trailing dot, and the trailing dot is precisely the signal that a\n * child is being completed.\n */\nexport function environmentPrefixAt(\n model: PrefixModel,\n position: PrefixPosition,\n languageId: string,\n): EnvironmentPrefix | null {\n const flavour = pathFlavour(languageId);\n if (!flavour) return null;\n\n const line = model.getLineContent(position.lineNumber);\n const before = line.slice(0, position.column - 1);\n\n if (flavour === \"gotemplate\" && !insideAction(before)) return null;\n\n let leafStart = before.length;\n while (leafStart > 0 && IDENT.test(before[leafStart - 1]!)) leafStart--;\n const leaf = before.slice(leafStart);\n const head = before.slice(0, leafStart);\n\n const chain = parseChain(head);\n if (!chain) return null;\n // Without a dot the leaf can only be a root name, so anything that looks like\n // the tail of a path before it (`items[0]name`) is malformed, not a prefix.\n if (leaf !== \"\" && !chain.dotted && chain.segments.length > 0) return null;\n\n // `chain.start` already sits on the leading `.` when there is one, so a go\n // template needs no adjustment; JSONPath's `$` sits one place further left.\n let start = chain.start;\n if (flavour === \"gotemplate\" && !chain.rooted) return null;\n if (flavour === \"jsonpath\") {\n const marker = head[chain.start - 1];\n if (marker !== \"$\" && marker !== \"@\") return null;\n start -= 1;\n }\n if (flavour === \"cel\" && chain.rooted) return null; // a leading `.` is not CEL\n\n return {\n segments: chain.segments,\n leaf,\n startColumn: start + 1,\n endColumn: position.column,\n typed: before.slice(start),\n };\n}\n\ninterface Chain {\n segments: PathSegment[];\n /** Index in `head` where the segment list starts, root marker excluded. */\n start: number;\n /** Whether `head` ends with the dot that opens a new segment. */\n dotted: boolean;\n /** Whether the outermost segment is preceded by a `.`, as go templates need. */\n rooted: boolean;\n}\n\n/**\n * Parses the trailing path of `head` backwards.\n *\n * Backwards because a path has no left boundary of its own: it ends where the\n * expression around it begins, and that is only knowable by walking off it.\n */\nfunction parseChain(head: string): Chain | null {\n let pos = head.length;\n const dotted = pos > 0 && head[pos - 1] === \".\";\n if (dotted) pos--;\n\n const reversed: PathSegment[] = [];\n let rooted = false;\n\n for (;;) {\n if (pos > 0 && head[pos - 1] === \"]\") {\n const open = head.lastIndexOf(\"[\", pos - 2);\n if (open < 0) return null;\n const segment = parseSubscript(head.slice(open + 1, pos - 1));\n if (segment === null) return null;\n reversed.push(segment);\n pos = open;\n rooted = false;\n continue;\n }\n if (pos > 0 && IDENT.test(head[pos - 1]!)) {\n let start = pos;\n while (start > 0 && IDENT.test(head[start - 1]!)) start--;\n reversed.push(head.slice(start, pos));\n pos = start;\n rooted = pos > 0 && head[pos - 1] === \".\";\n if (rooted) {\n pos--;\n continue;\n }\n break;\n }\n break;\n }\n\n // Only the trailing dot was consumed, so that dot is itself the root marker.\n if (reversed.length === 0 && dotted) rooted = true;\n\n return { segments: reversed.reverse(), start: pos, dotted, rooted };\n}\n\nfunction parseSubscript(inner: string): PathSegment | null {\n const match = SUBSCRIPT.exec(inner.trim());\n if (!match) return null;\n if (match[1] !== undefined) return Number(match[1]);\n const quoted = match[2] ?? match[3]!;\n try {\n return JSON.parse(`\"${quoted.replace(/\\\\'/g, \"'\")}\"`) as string;\n } catch {\n return null;\n }\n}\n\n/**\n * Whether the cursor sits between template delimiters. Outside them the text is\n * literal output, where a key path means nothing.\n */\nfunction insideAction(before: string): boolean {\n const { left, right, leftComment, rightComment } = spec.gotemplate.delimiters;\n\n const open = before.lastIndexOf(left);\n if (open < 0) return false;\n if (before.lastIndexOf(right) > open) return false;\n\n // `{{/*` opens with the ordinary left delimiter, so an unterminated comment\n // reads as an open action unless it is checked for separately.\n const comment = before.lastIndexOf(leftComment);\n if (comment >= open && before.lastIndexOf(rightComment) < comment) return false;\n\n return true;\n}\n"],"mappings":";;;AAgCA,IAAM,QAAQ;AACd,IAAM,YAAY;;;;;;;;;AAUlB,SAAgB,oBACd,OACA,UACA,YAC0B;CAC1B,MAAM,UAAU,YAAY,UAAU;CACtC,IAAI,CAAC,SAAS,OAAO;CAGrB,MAAM,SADO,MAAM,eAAe,SAAS,UAC5B,CAAA,CAAK,MAAM,GAAG,SAAS,SAAS,CAAC;CAEhD,IAAI,YAAY,gBAAgB,CAAC,aAAa,MAAM,GAAG,OAAO;CAE9D,IAAI,YAAY,OAAO;CACvB,OAAO,YAAY,KAAK,MAAM,KAAK,OAAO,YAAY,EAAG,GAAG;CAC5D,MAAM,OAAO,OAAO,MAAM,SAAS;CACnC,MAAM,OAAO,OAAO,MAAM,GAAG,SAAS;CAEtC,MAAM,QAAQ,WAAW,IAAI;CAC7B,IAAI,CAAC,OAAO,OAAO;CAGnB,IAAI,SAAS,MAAM,CAAC,MAAM,UAAU,MAAM,SAAS,SAAS,GAAG,OAAO;CAItE,IAAI,QAAQ,MAAM;CAClB,IAAI,YAAY,gBAAgB,CAAC,MAAM,QAAQ,OAAO;CACtD,IAAI,YAAY,YAAY;EAC1B,MAAM,SAAS,KAAK,MAAM,QAAQ;EAClC,IAAI,WAAW,OAAO,WAAW,KAAK,OAAO;EAC7C,SAAS;CACX;CACA,IAAI,YAAY,SAAS,MAAM,QAAQ,OAAO;CAE9C,OAAO;EACL,UAAU,MAAM;EAChB;EACA,aAAa,QAAQ;EACrB,WAAW,SAAS;EACpB,OAAO,OAAO,MAAM,KAAK;CAC3B;AACF;;;;;;;AAkBA,SAAS,WAAW,MAA4B;CAC9C,IAAI,MAAM,KAAK;CACf,MAAM,SAAS,MAAM,KAAK,KAAK,MAAM,OAAO;CAC5C,IAAI,QAAQ;CAEZ,MAAM,WAA0B,CAA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,MAAM,OAAO;CAI7C,MAAM,UAAU,OAAO,YAAY,WAAW;CAC9C,IAAI,WAAW,QAAQ,OAAO,YAAY,YAAY,IAAI,SAAS,OAAO;CAE1E,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"prefix.js","names":[],"sources":["../../../src/expressions/lang/prefix.ts"],"sourcesContent":["import { spec } from \"./generated/index.js\";\nimport { pathFlavour } from \"./environment.js\";\nimport type { PathSegment } from \"./environment.js\";\n\n/** The subset of a Monaco model this module reads. */\nexport interface PrefixModel {\n getLineContent(line: number): string;\n}\n\nexport interface PrefixPosition {\n lineNumber: number;\n column: number;\n}\n\n/** A path expression under construction at the cursor. */\nexport interface EnvironmentPrefix {\n /** The segments already committed, left of the trailing dot. */\n segments: PathSegment[];\n /** The partially typed leaf, empty right after a dot. */\n leaf: string;\n /**\n * 1-based columns spanning the whole expression typed so far, root marker\n * included. A completion replaces this range with a freshly rendered path, so\n * the inserted text is always well formed rather than glued onto what is\n * already there.\n */\n startColumn: number;\n endColumn: number;\n /** The text in that range, which Monaco filters candidates against. */\n typed: string;\n}\n\nconst IDENT = /[A-Za-z0-9_]/;\nconst SUBSCRIPT = /^(?:(\\d+)|\"((?:[^\"\\\\]|\\\\.)*)\"|'((?:[^'\\\\]|\\\\.)*)')$/;\n\n/**\n * Reads the path expression the cursor sits in, or null when it sits somewhere\n * the document's keys have no meaning.\n *\n * `dottedWordAt` in `hover.ts` cannot serve here: it scans past the cursor and\n * strips the trailing dot, and the trailing dot is precisely the signal that a\n * child is being completed.\n */\nexport function environmentPrefixAt(\n model: PrefixModel,\n position: PrefixPosition,\n languageId: string,\n): EnvironmentPrefix | null {\n const flavour = pathFlavour(languageId);\n if (!flavour) return null;\n\n const line = model.getLineContent(position.lineNumber);\n const before = line.slice(0, position.column - 1);\n\n if (flavour === \"gotemplate\" && !insideAction(before)) return null;\n\n let leafStart = before.length;\n while (leafStart > 0 && IDENT.test(before[leafStart - 1]!)) leafStart--;\n const leaf = before.slice(leafStart);\n const head = before.slice(0, leafStart);\n\n const chain = parseChain(head);\n if (!chain) return null;\n // Without a dot the leaf can only be a root name, so anything that looks like\n // the tail of a path before it (`items[0]name`) is malformed, not a prefix.\n if (leaf !== \"\" && !chain.dotted && chain.segments.length > 0) return null;\n\n // `chain.start` already sits on the leading `.` when there is one, so a go\n // template needs no adjustment; JSONPath's `$` sits one place further left.\n let start = chain.start;\n if (flavour === \"gotemplate\" && !chain.rooted) return null;\n if (flavour === \"jsonpath\") {\n const marker = head[chain.start - 1];\n if (marker !== \"$\" && marker !== \"@\") return null;\n start -= 1;\n }\n if (flavour === \"cel\" && chain.rooted) return null; // a leading `.` is not CEL\n\n return {\n segments: chain.segments,\n leaf,\n startColumn: start + 1,\n endColumn: position.column,\n typed: before.slice(start),\n };\n}\n\ninterface Chain {\n segments: PathSegment[];\n /** Index in `head` where the segment list starts, root marker excluded. */\n start: number;\n /** Whether `head` ends with the dot that opens a new segment. */\n dotted: boolean;\n /** Whether the outermost segment is preceded by a `.`, as go templates need. */\n rooted: boolean;\n}\n\n/**\n * Parses the trailing path of `head` backwards.\n *\n * Backwards because a path has no left boundary of its own: it ends where the\n * expression around it begins, and that is only knowable by walking off it.\n */\nfunction parseChain(head: string): Chain | null {\n let pos = head.length;\n const dotted = pos > 0 && head[pos - 1] === \".\";\n if (dotted) pos--;\n\n const reversed: PathSegment[] = [];\n let rooted = false;\n\n for (;;) {\n if (pos > 0 && head[pos - 1] === \"]\") {\n const open = head.lastIndexOf(\"[\", pos - 2);\n if (open < 0) return null;\n const segment = parseSubscript(head.slice(open + 1, pos - 1));\n if (segment === null) return null;\n reversed.push(segment);\n pos = open;\n rooted = false;\n continue;\n }\n if (pos > 0 && IDENT.test(head[pos - 1]!)) {\n let start = pos;\n while (start > 0 && IDENT.test(head[start - 1]!)) start--;\n reversed.push(head.slice(start, pos));\n pos = start;\n rooted = pos > 0 && head[pos - 1] === \".\";\n if (rooted) {\n pos--;\n continue;\n }\n break;\n }\n break;\n }\n\n // Only the trailing dot was consumed, so that dot is itself the root marker.\n if (reversed.length === 0 && dotted) rooted = true;\n\n return { segments: reversed.reverse(), start: pos, dotted, rooted };\n}\n\nfunction parseSubscript(inner: string): PathSegment | null {\n const match = SUBSCRIPT.exec(inner.trim());\n if (!match) return null;\n if (match[1] !== undefined) return Number(match[1]);\n const quoted = match[2] ?? match[3]!;\n try {\n return JSON.parse(`\"${quoted.replace(/\\\\'/g, \"'\")}\"`) as string;\n } catch {\n return null;\n }\n}\n\n/**\n * Whether the cursor sits between template delimiters. Outside them the text is\n * literal output, where a key path means nothing.\n */\nfunction insideAction(before: string): boolean {\n const { left, right, leftComment, rightComment } = spec.gotemplate.delimiters;\n\n const open = before.lastIndexOf(left);\n if (open < 0) return false;\n if (before.lastIndexOf(right) > open) return false;\n\n // `{{/*` opens with the ordinary left delimiter, so an unterminated comment\n // reads as an open action unless it is checked for separately.\n const comment = before.lastIndexOf(leftComment);\n if (comment >= open && before.lastIndexOf(rightComment) < comment) return false;\n\n return true;\n}\n"],"mappings":";;;AAgCA,IAAM,QAAQ;AACd,IAAM,YAAY;;;;;;;;;AAUlB,SAAgB,oBACd,OACA,UACA,YAC0B;CAC1B,MAAM,UAAU,YAAY,UAAU;CACtC,IAAI,CAAC,SAAS,OAAO;CAGrB,MAAM,SADO,MAAM,eAAe,SAAS,UAC5B,CAAA,CAAK,MAAM,GAAG,SAAS,SAAS,CAAC;CAEhD,IAAI,YAAY,gBAAgB,CAAC,aAAa,MAAM,GAAG,OAAO;CAE9D,IAAI,YAAY,OAAO;CACvB,OAAO,YAAY,KAAK,MAAM,KAAK,OAAO,YAAY,EAAG,GAAG;CAC5D,MAAM,OAAO,OAAO,MAAM,SAAS;CACnC,MAAM,OAAO,OAAO,MAAM,GAAG,SAAS;CAEtC,MAAM,QAAQ,WAAW,IAAI;CAC7B,IAAI,CAAC,OAAO,OAAO;CAGnB,IAAI,SAAS,MAAM,CAAC,MAAM,UAAU,MAAM,SAAS,SAAS,GAAG,OAAO;C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;AAEA,SAAS,eAAe,OAAmC;CACzD,MAAM,QAAQ,UAAU,KAAK,MAAM,KAAK,CAAC;CACzC,IAAI,CAAC,OAAO,OAAO;CACnB,IAAI,MAAM,OAAO,KAAA,GAAW,OAAO,OAAO,MAAM,EAAE;CAClD,MAAM,SAAS,MAAM,MAAM,MAAM;CACjC,IAAI;EACF,OAAO,KAAK,MAAM,IAAI,OAAO,QAAQ,QAAQ,GAAG,EAAE,EAAE;CACtD,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,SAAS,aAAa,QAAyB;CAC7C,MAAM,EAAE,MAAM,OAAO,aAAa,iBAAiB,KAAK,WAAW;CAEnE,MAAM,OAAO,OAAO,YAAY,IAAI;CACpC,IAAI,OAAO,GAAG,OAAO;CACrB,IAAI,OAAO,YAAY,KAAK,IAAI,MAAM,OAAO;CAI7C,MAAM,UAAU,OAAO,YAAY,WAAW;CAC9C,IAAI,WAAW,QAAQ,OAAO,YAAY,YAAY,IAAI,SAAS,OAAO;CAE1E,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../../src/expressions/lang/spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../../src/expressions/lang/spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAExE,OAAO,EAAE,IAAI,EAAE,CAAC;AAChB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;AAEtD,2DAA2D;AAC3D,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAElE;AAED,mEAAmE;AACnE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEzE;AAED,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,EAAE,CAE9D;AAED,iDAAiD;AACjD,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,EAAE,CAErE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.cjs","names":[],"sources":["../../../src/expressions/lang/theme.ts"],"sourcesContent":["import type { Monaco } from \"./types\";\n\nexport const GOMPLATE_LIGHT_THEME = \"gomplate-light\";\nexport const GOMPLATE_DARK_THEME = \"gomplate-dark\";\n\n/**\n * Token rules shared by both themes. Only the colours differ, so the token\n * vocabulary stays in one place.\n *\n * The token names are the ones the generated tokenizers emit; anything not\n * listed falls back to the base theme, which is why the themes inherit from\n * `vs` and `vs-dark` rather than starting from nothing.\n */\nconst TOKENS = [\n \"namespace\",\n \"function\",\n \"function.member\",\n \"function.builtin\",\n \"keyword.macro\",\n \"keyword.constant\",\n \"keyword.directive\",\n \"operator.optional\",\n \"operator.pipe\",\n \"delimiter.template\",\n \"variable\",\n \"variable.field\",\n \"variable.anchor\",\n \"variable.root\",\n \"variable.current\",\n \"identifier.escaped\",\n \"string.bytes\",\n \"number.uint\",\n \"number.float\",\n \"type.yaml\",\n \"type.json\",\n \"comment.directive\",\n] as const;\n\ntype Palette = Record<(typeof TOKENS)[number], string>;\n\nconst LIGHT: Palette = {\n namespace: \"267F99\",\n function: \"795E26\",\n \"function.member\": \"795E26\",\n \"function.builtin\": \"0000FF\",\n \"keyword.macro\": \"AF00DB\",\n \"keyword.constant\": \"0000FF\",\n \"keyword.directive\": \"AF00DB\",\n \"operator.optional\": \"AF00DB\",\n \"operator.pipe\": \"AF00DB\",\n \"delimiter.template\": \"AF00DB\",\n variable: \"001080\",\n \"variable.field\": \"001080\",\n \"variable.anchor\": \"267F99\",\n \"variable.root\": \"AF00DB\",\n \"variable.current\": \"AF00DB\",\n \"identifier.escaped\": \"001080\",\n \"string.bytes\": \"A31515\",\n \"number.uint\": \"098658\",\n \"number.float\": \"098658\",\n \"type.yaml\": \"0451A5\",\n \"type.json\": \"0451A5\",\n \"comment.directive\": \"008000\",\n};\n\nconst DARK: Palette = {\n namespace: \"4EC9B0\",\n function: \"DCDCAA\",\n \"function.member\": \"DCDCAA\",\n \"function.builtin\": \"569CD6\",\n \"keyword.macro\": \"C586C0\",\n \"keyword.constant\": \"569CD6\",\n \"keyword.directive\": \"C586C0\",\n \"operator.optional\": \"C586C0\",\n \"operator.pipe\": \"C586C0\",\n \"delimiter.template\": \"C586C0\",\n variable: \"9CDCFE\",\n \"variable.field\": \"9CDCFE\",\n \"variable.anchor\": \"4EC9B0\",\n \"variable.root\": \"C586C0\",\n \"variable.current\": \"C586C0\",\n \"identifier.escaped\": \"9CDCFE\",\n \"string.bytes\": \"CE9178\",\n \"number.uint\": \"B5CEA8\",\n \"number.float\": \"B5CEA8\",\n \"type.yaml\": \"9CDCFE\",\n \"type.json\": \"9CDCFE\",\n \"comment.directive\": \"6A9955\",\n};\n\n/** Defines the gomplate themes. Idempotent -- Monaco overwrites by name. */\nexport function defineThemes(monaco: Monaco) {\n monaco.editor.defineTheme(GOMPLATE_LIGHT_THEME, {\n base: \"vs\",\n inherit: true,\n rules: rulesFor(LIGHT),\n colors: {},\n });\n monaco.editor.defineTheme(GOMPLATE_DARK_THEME, {\n base: \"vs-dark\",\n inherit: true,\n rules: rulesFor(DARK),\n colors: {},\n });\n}\n\nfunction rulesFor(palette: Palette) {\n return TOKENS.map((token) => ({ token, foreground: palette[token] }));\n}\n"],"mappings":";AAEA,IAAa,uBAAuB;AACpC,IAAa,sBAAsB;;;;;;;;;AAUnC,IAAM,SAAS;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAM,QAAiB;CACrB,WAAW;CACX,UAAU;CACV,mBAAmB;CACnB,oBAAoB;CACpB,iBAAiB;CACjB,oBAAoB;CACpB,qBAAqB;CACrB,qBAAqB;CACrB,iBAAiB;CACjB,sBAAsB;CACtB,UAAU;CACV,kBAAkB;CAClB,mBAAmB;CACnB,iBAAiB;CACjB,oBAAoB;CACpB,sBAAsB;CACtB,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,aAAa;CACb,qBAAqB;AACvB;AAEA,IAAM,OAAgB;CACpB,WAAW;CACX,UAAU;CACV,mBAAmB;CACnB,oBAAoB;CACpB,iBAAiB;CACjB,oBAAoB;CACpB,qBAAqB;CACrB,qBAAqB;CACrB,iBAAiB;CACjB,sBAAsB;CACtB,UAAU;CACV,kBAAkB;CAClB,mBAAmB;CACnB,iBAAiB;CACjB,oBAAoB;CACpB,sBAAsB;CACtB,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,aAAa;CACb,qBAAqB;AACvB;;AAGA,SAAgB,aAAa,QAAgB;CAC3C,OAAO,OAAO,YAAY,sBAAsB;EAC9C,MAAM;EACN,SAAS;EACT,OAAO,SAAS,KAAK;EACrB,QAAQ,CAAC;CACX,CAAC;CACD,OAAO,OAAO,YAAY,qBAAqB;EAC7C,MAAM;EACN,SAAS;EACT,OAAO,SAAS,IAAI;EACpB,QAAQ,CAAC;CACX,CAAC;AACH;AAEA,SAAS,SAAS,SAAkB;CAClC,OAAO,OAAO,KAAK,WAAW;EAAE;EAAO,YAAY,QAAQ;CAAO,EAAE;AACtE"}
|
|
1
|
+
{"version":3,"file":"theme.cjs","names":[],"sources":["../../../src/expressions/lang/theme.ts"],"sourcesContent":["import type { Monaco } from \"./types.js\";\n\nexport const GOMPLATE_LIGHT_THEME = \"gomplate-light\";\nexport const GOMPLATE_DARK_THEME = \"gomplate-dark\";\n\n/**\n * Token rules shared by both themes. Only the colours differ, so the token\n * vocabulary stays in one place.\n *\n * The token names are the ones the generated tokenizers emit; anything not\n * listed falls back to the base theme, which is why the themes inherit from\n * `vs` and `vs-dark` rather than starting from nothing.\n */\nconst TOKENS = [\n \"namespace\",\n \"function\",\n \"function.member\",\n \"function.builtin\",\n \"keyword.macro\",\n \"keyword.constant\",\n \"keyword.directive\",\n \"operator.optional\",\n \"operator.pipe\",\n \"delimiter.template\",\n \"variable\",\n \"variable.field\",\n \"variable.anchor\",\n \"variable.root\",\n \"variable.current\",\n \"identifier.escaped\",\n \"string.bytes\",\n \"number.uint\",\n \"number.float\",\n \"type.yaml\",\n \"type.json\",\n \"comment.directive\",\n] as const;\n\ntype Palette = Record<(typeof TOKENS)[number], string>;\n\nconst LIGHT: Palette = {\n namespace: \"267F99\",\n function: \"795E26\",\n \"function.member\": \"795E26\",\n \"function.builtin\": \"0000FF\",\n \"keyword.macro\": \"AF00DB\",\n \"keyword.constant\": \"0000FF\",\n \"keyword.directive\": \"AF00DB\",\n \"operator.optional\": \"AF00DB\",\n \"operator.pipe\": \"AF00DB\",\n \"delimiter.template\": \"AF00DB\",\n variable: \"001080\",\n \"variable.field\": \"001080\",\n \"variable.anchor\": \"267F99\",\n \"variable.root\": \"AF00DB\",\n \"variable.current\": \"AF00DB\",\n \"identifier.escaped\": \"001080\",\n \"string.bytes\": \"A31515\",\n \"number.uint\": \"098658\",\n \"number.float\": \"098658\",\n \"type.yaml\": \"0451A5\",\n \"type.json\": \"0451A5\",\n \"comment.directive\": \"008000\",\n};\n\nconst DARK: Palette = {\n namespace: \"4EC9B0\",\n function: \"DCDCAA\",\n \"function.member\": \"DCDCAA\",\n \"function.builtin\": \"569CD6\",\n \"keyword.macro\": \"C586C0\",\n \"keyword.constant\": \"569CD6\",\n \"keyword.directive\": \"C586C0\",\n \"operator.optional\": \"C586C0\",\n \"operator.pipe\": \"C586C0\",\n \"delimiter.template\": \"C586C0\",\n variable: \"9CDCFE\",\n \"variable.field\": \"9CDCFE\",\n \"variable.anchor\": \"4EC9B0\",\n \"variable.root\": \"C586C0\",\n \"variable.current\": \"C586C0\",\n \"identifier.escaped\": \"9CDCFE\",\n \"string.bytes\": \"CE9178\",\n \"number.uint\": \"B5CEA8\",\n \"number.float\": \"B5CEA8\",\n \"type.yaml\": \"9CDCFE\",\n \"type.json\": \"9CDCFE\",\n \"comment.directive\": \"6A9955\",\n};\n\n/** Defines the gomplate themes. Idempotent -- Monaco overwrites by name. */\nexport function defineThemes(monaco: Monaco) {\n monaco.editor.defineTheme(GOMPLATE_LIGHT_THEME, {\n base: \"vs\",\n inherit: true,\n rules: rulesFor(LIGHT),\n colors: {},\n });\n monaco.editor.defineTheme(GOMPLATE_DARK_THEME, {\n base: \"vs-dark\",\n inherit: true,\n rules: rulesFor(DARK),\n colors: {},\n });\n}\n\nfunction rulesFor(palette: Palette) {\n return TOKENS.map((token) => ({ token, foreground: palette[token] }));\n}\n"],"mappings":";AAEA,IAAa,uBAAuB;AACpC,IAAa,sBAAsB;;;;;;;;;AAUnC,IAAM,SAAS;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAM,QAAiB;CACrB,WAAW;CACX,UAAU;CACV,mBAAmB;CACnB,oBAAoB;CACpB,iBAAiB;CACjB,oBAAoB;CACpB,qBAAqB;CACrB,qBAAqB;CACrB,iBAAiB;CACjB,sBAAsB;CACtB,UAAU;CACV,kBAAkB;CAClB,mBAAmB;CACnB,iBAAiB;CACjB,oBAAoB;CACpB,sBAAsB;CACtB,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,aAAa;CACb,qBAAqB;AACvB;AAEA,IAAM,OAAgB;CACpB,WAAW;CACX,UAAU;CACV,mBAAmB;CACnB,oBAAoB;CACpB,iBAAiB;CACjB,oBAAoB;CACpB,qBAAqB;CACrB,qBAAqB;CACrB,iBAAiB;CACjB,sBAAsB;CACtB,UAAU;CACV,kBAAkB;CAClB,mBAAmB;CACnB,iBAAiB;CACjB,oBAAoB;CACpB,sBAAsB;CACtB,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,aAAa;CACb,qBAAqB;AACvB;;AAGA,SAAgB,aAAa,QAAgB;CAC3C,OAAO,OAAO,YAAY,sBAAsB;EAC9C,MAAM;EACN,SAAS;EACT,OAAO,SAAS,KAAK;EACrB,QAAQ,CAAC;CACX,CAAC;CACD,OAAO,OAAO,YAAY,qBAAqB;EAC7C,MAAM;EACN,SAAS;EACT,OAAO,SAAS,IAAI;EACpB,QAAQ,CAAC;CACX,CAAC;AACH;AAEA,SAAS,SAAS,SAAkB;CAClC,OAAO,OAAO,KAAK,WAAW;EAAE;EAAO,YAAY,QAAQ;CAAO,EAAE;AACtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/expressions/lang/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/expressions/lang/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AACrD,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AAuFnD,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,QAa1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","names":[],"sources":["../../../src/expressions/lang/theme.ts"],"sourcesContent":["import type { Monaco } from \"./types\";\n\nexport const GOMPLATE_LIGHT_THEME = \"gomplate-light\";\nexport const GOMPLATE_DARK_THEME = \"gomplate-dark\";\n\n/**\n * Token rules shared by both themes. Only the colours differ, so the token\n * vocabulary stays in one place.\n *\n * The token names are the ones the generated tokenizers emit; anything not\n * listed falls back to the base theme, which is why the themes inherit from\n * `vs` and `vs-dark` rather than starting from nothing.\n */\nconst TOKENS = [\n \"namespace\",\n \"function\",\n \"function.member\",\n \"function.builtin\",\n \"keyword.macro\",\n \"keyword.constant\",\n \"keyword.directive\",\n \"operator.optional\",\n \"operator.pipe\",\n \"delimiter.template\",\n \"variable\",\n \"variable.field\",\n \"variable.anchor\",\n \"variable.root\",\n \"variable.current\",\n \"identifier.escaped\",\n \"string.bytes\",\n \"number.uint\",\n \"number.float\",\n \"type.yaml\",\n \"type.json\",\n \"comment.directive\",\n] as const;\n\ntype Palette = Record<(typeof TOKENS)[number], string>;\n\nconst LIGHT: Palette = {\n namespace: \"267F99\",\n function: \"795E26\",\n \"function.member\": \"795E26\",\n \"function.builtin\": \"0000FF\",\n \"keyword.macro\": \"AF00DB\",\n \"keyword.constant\": \"0000FF\",\n \"keyword.directive\": \"AF00DB\",\n \"operator.optional\": \"AF00DB\",\n \"operator.pipe\": \"AF00DB\",\n \"delimiter.template\": \"AF00DB\",\n variable: \"001080\",\n \"variable.field\": \"001080\",\n \"variable.anchor\": \"267F99\",\n \"variable.root\": \"AF00DB\",\n \"variable.current\": \"AF00DB\",\n \"identifier.escaped\": \"001080\",\n \"string.bytes\": \"A31515\",\n \"number.uint\": \"098658\",\n \"number.float\": \"098658\",\n \"type.yaml\": \"0451A5\",\n \"type.json\": \"0451A5\",\n \"comment.directive\": \"008000\",\n};\n\nconst DARK: Palette = {\n namespace: \"4EC9B0\",\n function: \"DCDCAA\",\n \"function.member\": \"DCDCAA\",\n \"function.builtin\": \"569CD6\",\n \"keyword.macro\": \"C586C0\",\n \"keyword.constant\": \"569CD6\",\n \"keyword.directive\": \"C586C0\",\n \"operator.optional\": \"C586C0\",\n \"operator.pipe\": \"C586C0\",\n \"delimiter.template\": \"C586C0\",\n variable: \"9CDCFE\",\n \"variable.field\": \"9CDCFE\",\n \"variable.anchor\": \"4EC9B0\",\n \"variable.root\": \"C586C0\",\n \"variable.current\": \"C586C0\",\n \"identifier.escaped\": \"9CDCFE\",\n \"string.bytes\": \"CE9178\",\n \"number.uint\": \"B5CEA8\",\n \"number.float\": \"B5CEA8\",\n \"type.yaml\": \"9CDCFE\",\n \"type.json\": \"9CDCFE\",\n \"comment.directive\": \"6A9955\",\n};\n\n/** Defines the gomplate themes. Idempotent -- Monaco overwrites by name. */\nexport function defineThemes(monaco: Monaco) {\n monaco.editor.defineTheme(GOMPLATE_LIGHT_THEME, {\n base: \"vs\",\n inherit: true,\n rules: rulesFor(LIGHT),\n colors: {},\n });\n monaco.editor.defineTheme(GOMPLATE_DARK_THEME, {\n base: \"vs-dark\",\n inherit: true,\n rules: rulesFor(DARK),\n colors: {},\n });\n}\n\nfunction rulesFor(palette: Palette) {\n return TOKENS.map((token) => ({ token, foreground: palette[token] }));\n}\n"],"mappings":";AAEA,IAAa,uBAAuB;AACpC,IAAa,sBAAsB;;;;;;;;;AAUnC,IAAM,SAAS;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAM,QAAiB;CACrB,WAAW;CACX,UAAU;CACV,mBAAmB;CACnB,oBAAoB;CACpB,iBAAiB;CACjB,oBAAoB;CACpB,qBAAqB;CACrB,qBAAqB;CACrB,iBAAiB;CACjB,sBAAsB;CACtB,UAAU;CACV,kBAAkB;CAClB,mBAAmB;CACnB,iBAAiB;CACjB,oBAAoB;CACpB,sBAAsB;CACtB,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,aAAa;CACb,qBAAqB;AACvB;AAEA,IAAM,OAAgB;CACpB,WAAW;CACX,UAAU;CACV,mBAAmB;CACnB,oBAAoB;CACpB,iBAAiB;CACjB,oBAAoB;CACpB,qBAAqB;CACrB,qBAAqB;CACrB,iBAAiB;CACjB,sBAAsB;CACtB,UAAU;CACV,kBAAkB;CAClB,mBAAmB;CACnB,iBAAiB;CACjB,oBAAoB;CACpB,sBAAsB;CACtB,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,aAAa;CACb,qBAAqB;AACvB;;AAGA,SAAgB,aAAa,QAAgB;CAC3C,OAAO,OAAO,YAAY,sBAAsB;EAC9C,MAAM;EACN,SAAS;EACT,OAAO,SAAS,KAAK;EACrB,QAAQ,CAAC;CACX,CAAC;CACD,OAAO,OAAO,YAAY,qBAAqB;EAC7C,MAAM;EACN,SAAS;EACT,OAAO,SAAS,IAAI;EACpB,QAAQ,CAAC;CACX,CAAC;AACH;AAEA,SAAS,SAAS,SAAkB;CAClC,OAAO,OAAO,KAAK,WAAW;EAAE;EAAO,YAAY,QAAQ;CAAO,EAAE;AACtE"}
|
|
1
|
+
{"version":3,"file":"theme.js","names":[],"sources":["../../../src/expressions/lang/theme.ts"],"sourcesContent":["import type { Monaco } from \"./types.js\";\n\nexport const GOMPLATE_LIGHT_THEME = \"gomplate-light\";\nexport const GOMPLATE_DARK_THEME = \"gomplate-dark\";\n\n/**\n * Token rules shared by both themes. Only the colours differ, so the token\n * vocabulary stays in one place.\n *\n * The token names are the ones the generated tokenizers emit; anything not\n * listed falls back to the base theme, which is why the themes inherit from\n * `vs` and `vs-dark` rather than starting from nothing.\n */\nconst TOKENS = [\n \"namespace\",\n \"function\",\n \"function.member\",\n \"function.builtin\",\n \"keyword.macro\",\n \"keyword.constant\",\n \"keyword.directive\",\n \"operator.optional\",\n \"operator.pipe\",\n \"delimiter.template\",\n \"variable\",\n \"variable.field\",\n \"variable.anchor\",\n \"variable.root\",\n \"variable.current\",\n \"identifier.escaped\",\n \"string.bytes\",\n \"number.uint\",\n \"number.float\",\n \"type.yaml\",\n \"type.json\",\n \"comment.directive\",\n] as const;\n\ntype Palette = Record<(typeof TOKENS)[number], string>;\n\nconst LIGHT: Palette = {\n namespace: \"267F99\",\n function: \"795E26\",\n \"function.member\": \"795E26\",\n \"function.builtin\": \"0000FF\",\n \"keyword.macro\": \"AF00DB\",\n \"keyword.constant\": \"0000FF\",\n \"keyword.directive\": \"AF00DB\",\n \"operator.optional\": \"AF00DB\",\n \"operator.pipe\": \"AF00DB\",\n \"delimiter.template\": \"AF00DB\",\n variable: \"001080\",\n \"variable.field\": \"001080\",\n \"variable.anchor\": \"267F99\",\n \"variable.root\": \"AF00DB\",\n \"variable.current\": \"AF00DB\",\n \"identifier.escaped\": \"001080\",\n \"string.bytes\": \"A31515\",\n \"number.uint\": \"098658\",\n \"number.float\": \"098658\",\n \"type.yaml\": \"0451A5\",\n \"type.json\": \"0451A5\",\n \"comment.directive\": \"008000\",\n};\n\nconst DARK: Palette = {\n namespace: \"4EC9B0\",\n function: \"DCDCAA\",\n \"function.member\": \"DCDCAA\",\n \"function.builtin\": \"569CD6\",\n \"keyword.macro\": \"C586C0\",\n \"keyword.constant\": \"569CD6\",\n \"keyword.directive\": \"C586C0\",\n \"operator.optional\": \"C586C0\",\n \"operator.pipe\": \"C586C0\",\n \"delimiter.template\": \"C586C0\",\n variable: \"9CDCFE\",\n \"variable.field\": \"9CDCFE\",\n \"variable.anchor\": \"4EC9B0\",\n \"variable.root\": \"C586C0\",\n \"variable.current\": \"C586C0\",\n \"identifier.escaped\": \"9CDCFE\",\n \"string.bytes\": \"CE9178\",\n \"number.uint\": \"B5CEA8\",\n \"number.float\": \"B5CEA8\",\n \"type.yaml\": \"9CDCFE\",\n \"type.json\": \"9CDCFE\",\n \"comment.directive\": \"6A9955\",\n};\n\n/** Defines the gomplate themes. Idempotent -- Monaco overwrites by name. */\nexport function defineThemes(monaco: Monaco) {\n monaco.editor.defineTheme(GOMPLATE_LIGHT_THEME, {\n base: \"vs\",\n inherit: true,\n rules: rulesFor(LIGHT),\n colors: {},\n });\n monaco.editor.defineTheme(GOMPLATE_DARK_THEME, {\n base: \"vs-dark\",\n inherit: true,\n rules: rulesFor(DARK),\n colors: {},\n });\n}\n\nfunction rulesFor(palette: Palette) {\n return TOKENS.map((token) => ({ token, foreground: palette[token] }));\n}\n"],"mappings":";AAEA,IAAa,uBAAuB;AACpC,IAAa,sBAAsB;;;;;;;;;AAUnC,IAAM,SAAS;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAM,QAAiB;CACrB,WAAW;CACX,UAAU;CACV,mBAAmB;CACnB,oBAAoB;CACpB,iBAAiB;CACjB,oBAAoB;CACpB,qBAAqB;CACrB,qBAAqB;CACrB,iBAAiB;CACjB,sBAAsB;CACtB,UAAU;CACV,kBAAkB;CAClB,mBAAmB;CACnB,iBAAiB;CACjB,oBAAoB;CACpB,sBAAsB;CACtB,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,aAAa;CACb,qBAAqB;AACvB;AAEA,IAAM,OAAgB;CACpB,WAAW;CACX,UAAU;CACV,mBAAmB;CACnB,oBAAoB;CACpB,iBAAiB;CACjB,oBAAoB;CACpB,qBAAqB;CACrB,qBAAqB;CACrB,iBAAiB;CACjB,sBAAsB;CACtB,UAAU;CACV,kBAAkB;CAClB,mBAAmB;CACnB,iBAAiB;CACjB,oBAAoB;CACpB,sBAAsB;CACtB,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,aAAa;CACb,qBAAqB;AACvB;;AAGA,SAAgB,aAAa,QAAgB;CAC3C,OAAO,OAAO,YAAY,sBAAsB;EAC9C,MAAM;EACN,SAAS;EACT,OAAO,SAAS,KAAK;EACrB,QAAQ,CAAC;CACX,CAAC;CACD,OAAO,OAAO,YAAY,qBAAqB;EAC7C,MAAM;EACN,SAAS;EACT,OAAO,SAAS,IAAI;EACpB,QAAQ,CAAC;CACX,CAAC;AACH;AAEA,SAAS,SAAS,SAAkB;CAClC,OAAO,OAAO,KAAK,WAAW;EAAE;EAAO,YAAY,QAAQ;CAAO,EAAE;AACtE"}
|
|
@@ -25,6 +25,10 @@ export interface SpecFunction {
|
|
|
25
25
|
signature?: string;
|
|
26
26
|
overloads?: Overload[];
|
|
27
27
|
examples?: string[];
|
|
28
|
+
/** The opt-in extension that registers it (its gomplate.Extension name); absent for the core. */
|
|
29
|
+
group?: string;
|
|
30
|
+
/** The function's section in a published reference page; hover and completion link to it. */
|
|
31
|
+
docsUrl?: string;
|
|
28
32
|
}
|
|
29
33
|
/** A CEL macro. Expanded at parse time, so never a function. */
|
|
30
34
|
export interface SpecMacro {
|
|
@@ -33,6 +37,8 @@ export interface SpecMacro {
|
|
|
33
37
|
receiverStyle: boolean;
|
|
34
38
|
doc?: string;
|
|
35
39
|
examples?: string[];
|
|
40
|
+
/** The macro's section in a published reference page. */
|
|
41
|
+
docsUrl?: string;
|
|
36
42
|
}
|
|
37
43
|
export interface CelSpec {
|
|
38
44
|
namespaces: string[];
|
|
@@ -60,6 +66,12 @@ export interface GoTemplateSpec {
|
|
|
60
66
|
export interface GomplateSpec {
|
|
61
67
|
cel: CelSpec;
|
|
62
68
|
gotemplate: GoTemplateSpec;
|
|
69
|
+
/**
|
|
70
|
+
* The host's whole surface (catalog.Build): it replaces the packaged
|
|
71
|
+
* catalogue instead of being added to it, so functions the host does not
|
|
72
|
+
* register are not offered.
|
|
73
|
+
*/
|
|
74
|
+
complete?: boolean;
|
|
63
75
|
}
|
|
64
76
|
/**
|
|
65
77
|
* One snippet plus the token boundaries the language's real lexer produces.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/expressions/lang/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,6DAA6D;AAC7D,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAEnC,0EAA0E;AAC1E,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC;IAC3C,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC;CACvD;AAED,6CA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UAAU,EAAE,cAAc,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,8DAA8D;IAC9D,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -9,11 +9,11 @@ var NO_EXAMPLES = [];
|
|
|
9
9
|
* The full expression playground, for a host that evaluates on its own engine.
|
|
10
10
|
*
|
|
11
11
|
* It owns the three things the playground would otherwise fetch from a gomplate
|
|
12
|
-
* server: the evaluator (the host's), the catalogue (the
|
|
13
|
-
* examples (the host's, or none). So nothing here makes a
|
|
14
|
-
* endpoint the host does not serve.
|
|
12
|
+
* server: the evaluator (the host's), the catalogue (the host's, else the
|
|
13
|
+
* packaged one) and the examples (the host's, or none). So nothing here makes a
|
|
14
|
+
* request to an endpoint the host does not serve.
|
|
15
15
|
*/
|
|
16
|
-
function EmbeddedPlayground({ language, source, input, onSourceChange, evaluate, samples, examples = NO_EXAMPLES, expectation, formatPath, executionMode }) {
|
|
16
|
+
function EmbeddedPlayground({ language, source, input, onSourceChange, evaluate, samples, examples = NO_EXAMPLES, expectation, formatPath, executionMode, spec: hostSpec, reference }) {
|
|
17
17
|
const languages = (0, react.useMemo)(() => [require_languages.languageById(language)], [language]);
|
|
18
18
|
const [initial] = (0, react.useState)(() => ({
|
|
19
19
|
language,
|
|
@@ -23,8 +23,9 @@ function EmbeddedPlayground({ language, source, input, onSourceChange, evaluate,
|
|
|
23
23
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ExpressionPlayground.ExpressionPlayground, {
|
|
24
24
|
className: "h-full",
|
|
25
25
|
languages,
|
|
26
|
-
spec: require_index.spec,
|
|
26
|
+
spec: hostSpec ?? require_index.spec,
|
|
27
27
|
examples,
|
|
28
|
+
...reference ? { reference } : {},
|
|
28
29
|
evaluate,
|
|
29
30
|
samples,
|
|
30
31
|
formatPath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedPlayground.cjs","names":["useMemo","languageById","useState","ExpressionPlayground"],"sources":["../../../src/expressions/playground/EmbeddedPlayground.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { spec } from \"../lang/index.ts\";\nimport type { EvalRequest, EvalResponse, Example, FormatPath, PlaygroundSample, ResultExpectation } from \"./api.ts\";\nimport { ExpressionPlayground } from \"./ExpressionPlayground.tsx\";\nimport { languageById } from \"./languages.ts\";\n\nconst NO_EXAMPLES: Example[] = [];\n\nexport interface EmbeddedPlaygroundProps {\n /** The one language this embedding writes; there is no switcher. */\n language: \"cel\" | \"jsonpath\";\n /** The expression the editor opens with. */\n source: string;\n /** The document the input pane opens with. */\n input: string;\n /** Called with the expression as it is edited, for the host's Apply. */\n onSourceChange: (source: string) => void;\n /** The host's evaluator: the engine that runs the expression for real. */\n evaluate: (request: EvalRequest) => Promise<EvalResponse>;\n samples: PlaygroundSample[];\n /** \"Load an example\" entries; none by default. */\n examples?: Example[];\n expectation?: ResultExpectation | undefined;\n formatPath: FormatPath;\n /** Explicit leaves evaluation to the Run button. */\n executionMode?: \"automatic\" | \"explicit\";\n}\n\n/**\n * The full expression playground, for a host that evaluates on its own engine.\n *\n * It owns the three things the playground would otherwise fetch from a gomplate\n * server: the evaluator (the host's), the catalogue (the packaged one) and the
|
|
1
|
+
{"version":3,"file":"EmbeddedPlayground.cjs","names":["useMemo","languageById","useState","ExpressionPlayground","spec"],"sources":["../../../src/expressions/playground/EmbeddedPlayground.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { spec } from \"../lang/index.ts\";\nimport type { GomplateSpec } from \"../lang/index.ts\";\nimport type { EvalRequest, EvalResponse, Example, FormatPath, PlaygroundSample, ResultExpectation } from \"./api.ts\";\nimport { ExpressionPlayground } from \"./ExpressionPlayground.tsx\";\nimport { languageById } from \"./languages.ts\";\n\nconst NO_EXAMPLES: Example[] = [];\n\nexport interface EmbeddedPlaygroundProps {\n /** The one language this embedding writes; there is no switcher. */\n language: \"cel\" | \"jsonpath\";\n /** The expression the editor opens with. */\n source: string;\n /** The document the input pane opens with. */\n input: string;\n /** Called with the expression as it is edited, for the host's Apply. */\n onSourceChange: (source: string) => void;\n /** The host's evaluator: the engine that runs the expression for real. */\n evaluate: (request: EvalRequest) => Promise<EvalResponse>;\n samples: PlaygroundSample[];\n /** \"Load an example\" entries; none by default. */\n examples?: Example[];\n expectation?: ResultExpectation | undefined;\n formatPath: FormatPath;\n /** Explicit leaves evaluation to the Run button. */\n executionMode?: \"automatic\" | \"explicit\";\n /**\n * The host's catalogue (a gomplate catalog.Build spec). Omitted, the packaged\n * one is used; a `complete` spec replaces it.\n */\n spec?: GomplateSpec | undefined;\n /** The host's reference page per catalogue, shown in place of the Functions table. */\n reference?: Partial<Record<\"cel\" | \"gotemplate\", string>> | undefined;\n}\n\n/**\n * The full expression playground, for a host that evaluates on its own engine.\n *\n * It owns the three things the playground would otherwise fetch from a gomplate\n * server: the evaluator (the host's), the catalogue (the host's, else the\n * packaged one) and the examples (the host's, or none). So nothing here makes a\n * request to an endpoint the host does not serve.\n */\nexport function EmbeddedPlayground({\n language,\n source,\n input,\n onSourceChange,\n evaluate,\n samples,\n examples = NO_EXAMPLES,\n expectation,\n formatPath,\n executionMode,\n spec: hostSpec,\n reference,\n}: EmbeddedPlaygroundProps) {\n const languages = useMemo(() => [languageById(language)], [language]);\n // The starting state only: the playground owns the text from here on, and\n // reports edits through `onSourceChange`.\n const [initial] = useState(() => ({ language, source, input }));\n\n return (\n <ExpressionPlayground\n className=\"h-full\"\n languages={languages}\n spec={hostSpec ?? spec}\n examples={examples}\n {...(reference ? { reference } : {})}\n evaluate={evaluate}\n samples={samples}\n formatPath={formatPath}\n pathInsertion={language === \"jsonpath\" ? \"replace\" : \"caret\"}\n defaultValue={initial}\n onChange={(state) => onSourceChange(state.source)}\n {...(expectation ? { expectation } : {})}\n {...(executionMode ? { executionMode } : {})}\n />\n );\n}\n"],"mappings":";;;;;;AAOA,IAAM,cAAyB,CAAC;;;;;;;;;AAqChC,SAAgB,mBAAmB,EACjC,UACA,QACA,OACA,gBACA,UACA,SACA,WAAW,aACX,aACA,YACA,eACA,MAAM,UACN,aAC0B;CAC1B,MAAM,aAAA,GAAYA,MAAAA,QAAAA,OAAc,CAACC,kBAAAA,aAAa,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;CAGpE,MAAM,CAAC,YAAA,GAAWC,MAAAA,SAAAA,QAAgB;EAAE;EAAU;EAAQ;CAAM,EAAE;CAE9D,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,6BAAAA,sBAAD;EACE,WAAU;EACC;EACX,MAAM,YAAYC,cAAAA;EACR;EACV,GAAK,YAAY,EAAE,UAAU,IAAI,CAAC;EACxB;EACD;EACG;EACZ,eAAe,aAAa,aAAa,YAAY;EACrD,cAAc;EACd,WAAW,UAAU,eAAe,MAAM,MAAM;EAChD,GAAK,cAAc,EAAE,YAAY,IAAI,CAAC;EACtC,GAAK,gBAAgB,EAAE,cAAc,IAAI,CAAC;CAC3C,CAAA;AAEL"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GomplateSpec } from '../lang/index.js';
|
|
1
2
|
import { EvalRequest, EvalResponse, Example, FormatPath, PlaygroundSample, ResultExpectation } from './api.js';
|
|
2
3
|
export interface EmbeddedPlaygroundProps {
|
|
3
4
|
/** The one language this embedding writes; there is no switcher. */
|
|
@@ -17,14 +18,21 @@ export interface EmbeddedPlaygroundProps {
|
|
|
17
18
|
formatPath: FormatPath;
|
|
18
19
|
/** Explicit leaves evaluation to the Run button. */
|
|
19
20
|
executionMode?: "automatic" | "explicit";
|
|
21
|
+
/**
|
|
22
|
+
* The host's catalogue (a gomplate catalog.Build spec). Omitted, the packaged
|
|
23
|
+
* one is used; a `complete` spec replaces it.
|
|
24
|
+
*/
|
|
25
|
+
spec?: GomplateSpec | undefined;
|
|
26
|
+
/** The host's reference page per catalogue, shown in place of the Functions table. */
|
|
27
|
+
reference?: Partial<Record<"cel" | "gotemplate", string>> | undefined;
|
|
20
28
|
}
|
|
21
29
|
/**
|
|
22
30
|
* The full expression playground, for a host that evaluates on its own engine.
|
|
23
31
|
*
|
|
24
32
|
* It owns the three things the playground would otherwise fetch from a gomplate
|
|
25
|
-
* server: the evaluator (the host's), the catalogue (the
|
|
26
|
-
* examples (the host's, or none). So nothing here makes a
|
|
27
|
-
* endpoint the host does not serve.
|
|
33
|
+
* server: the evaluator (the host's), the catalogue (the host's, else the
|
|
34
|
+
* packaged one) and the examples (the host's, or none). So nothing here makes a
|
|
35
|
+
* request to an endpoint the host does not serve.
|
|
28
36
|
*/
|
|
29
|
-
export declare function EmbeddedPlayground({ language, source, input, onSourceChange, evaluate, samples, examples, expectation, formatPath, executionMode, }: EmbeddedPlaygroundProps): import("react").JSX.Element;
|
|
37
|
+
export declare function EmbeddedPlayground({ language, source, input, onSourceChange, evaluate, samples, examples, expectation, formatPath, executionMode, spec: hostSpec, reference, }: EmbeddedPlaygroundProps): import("react").JSX.Element;
|
|
30
38
|
//# sourceMappingURL=EmbeddedPlayground.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedPlayground.d.ts","sourceRoot":"","sources":["../../../src/expressions/playground/EmbeddedPlayground.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAMpH,MAAM,WAAW,uBAAuB;IACtC,oEAAoE;IACpE,QAAQ,EAAE,KAAK,GAAG,UAAU,CAAC;IAC7B,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,wEAA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AAa,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IACzC;;;OAGG;IACH,IAAI,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IAChC,sFAAsF;IACtF,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,YAAY,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;CACvE;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,MAAM,EACN,KAAK,EACL,cAAc,EACd,QAAQ,EACR,OAAO,EACP,QAAsB,EACtB,WAAW,EACX,UAAU,EACV,aAAa,EACb,IAAI,EAAE,QAAQ,EACd,SAAS,GACV,EAAE,uBAAuB,+BAuBzB"}
|
|
@@ -9,11 +9,11 @@ var NO_EXAMPLES = [];
|
|
|
9
9
|
* The full expression playground, for a host that evaluates on its own engine.
|
|
10
10
|
*
|
|
11
11
|
* It owns the three things the playground would otherwise fetch from a gomplate
|
|
12
|
-
* server: the evaluator (the host's), the catalogue (the
|
|
13
|
-
* examples (the host's, or none). So nothing here makes a
|
|
14
|
-
* endpoint the host does not serve.
|
|
12
|
+
* server: the evaluator (the host's), the catalogue (the host's, else the
|
|
13
|
+
* packaged one) and the examples (the host's, or none). So nothing here makes a
|
|
14
|
+
* request to an endpoint the host does not serve.
|
|
15
15
|
*/
|
|
16
|
-
function EmbeddedPlayground({ language, source, input, onSourceChange, evaluate, samples, examples = NO_EXAMPLES, expectation, formatPath, executionMode }) {
|
|
16
|
+
function EmbeddedPlayground({ language, source, input, onSourceChange, evaluate, samples, examples = NO_EXAMPLES, expectation, formatPath, executionMode, spec: hostSpec, reference }) {
|
|
17
17
|
const languages = useMemo(() => [languageById(language)], [language]);
|
|
18
18
|
const [initial] = useState(() => ({
|
|
19
19
|
language,
|
|
@@ -23,8 +23,9 @@ function EmbeddedPlayground({ language, source, input, onSourceChange, evaluate,
|
|
|
23
23
|
return /* @__PURE__ */ jsx(ExpressionPlayground, {
|
|
24
24
|
className: "h-full",
|
|
25
25
|
languages,
|
|
26
|
-
spec,
|
|
26
|
+
spec: hostSpec ?? spec,
|
|
27
27
|
examples,
|
|
28
|
+
...reference ? { reference } : {},
|
|
28
29
|
evaluate,
|
|
29
30
|
samples,
|
|
30
31
|
formatPath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedPlayground.js","names":[],"sources":["../../../src/expressions/playground/EmbeddedPlayground.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { spec } from \"../lang/index.ts\";\nimport type { EvalRequest, EvalResponse, Example, FormatPath, PlaygroundSample, ResultExpectation } from \"./api.ts\";\nimport { ExpressionPlayground } from \"./ExpressionPlayground.tsx\";\nimport { languageById } from \"./languages.ts\";\n\nconst NO_EXAMPLES: Example[] = [];\n\nexport interface EmbeddedPlaygroundProps {\n /** The one language this embedding writes; there is no switcher. */\n language: \"cel\" | \"jsonpath\";\n /** The expression the editor opens with. */\n source: string;\n /** The document the input pane opens with. */\n input: string;\n /** Called with the expression as it is edited, for the host's Apply. */\n onSourceChange: (source: string) => void;\n /** The host's evaluator: the engine that runs the expression for real. */\n evaluate: (request: EvalRequest) => Promise<EvalResponse>;\n samples: PlaygroundSample[];\n /** \"Load an example\" entries; none by default. */\n examples?: Example[];\n expectation?: ResultExpectation | undefined;\n formatPath: FormatPath;\n /** Explicit leaves evaluation to the Run button. */\n executionMode?: \"automatic\" | \"explicit\";\n}\n\n/**\n * The full expression playground, for a host that evaluates on its own engine.\n *\n * It owns the three things the playground would otherwise fetch from a gomplate\n * server: the evaluator (the host's), the catalogue (the packaged one) and the
|
|
1
|
+
{"version":3,"file":"EmbeddedPlayground.js","names":[],"sources":["../../../src/expressions/playground/EmbeddedPlayground.tsx"],"sourcesContent":["import { useMemo, useState } from \"react\";\nimport { spec } from \"../lang/index.ts\";\nimport type { GomplateSpec } from \"../lang/index.ts\";\nimport type { EvalRequest, EvalResponse, Example, FormatPath, PlaygroundSample, ResultExpectation } from \"./api.ts\";\nimport { ExpressionPlayground } from \"./ExpressionPlayground.tsx\";\nimport { languageById } from \"./languages.ts\";\n\nconst NO_EXAMPLES: Example[] = [];\n\nexport interface EmbeddedPlaygroundProps {\n /** The one language this embedding writes; there is no switcher. */\n language: \"cel\" | \"jsonpath\";\n /** The expression the editor opens with. */\n source: string;\n /** The document the input pane opens with. */\n input: string;\n /** Called with the expression as it is edited, for the host's Apply. */\n onSourceChange: (source: string) => void;\n /** The host's evaluator: the engine that runs the expression for real. */\n evaluate: (request: EvalRequest) => Promise<EvalResponse>;\n samples: PlaygroundSample[];\n /** \"Load an example\" entries; none by default. */\n examples?: Example[];\n expectation?: ResultExpectation | undefined;\n formatPath: FormatPath;\n /** Explicit leaves evaluation to the Run button. */\n executionMode?: \"automatic\" | \"explicit\";\n /**\n * The host's catalogue (a gomplate catalog.Build spec). Omitted, the packaged\n * one is used; a `complete` spec replaces it.\n */\n spec?: GomplateSpec | undefined;\n /** The host's reference page per catalogue, shown in place of the Functions table. */\n reference?: Partial<Record<\"cel\" | \"gotemplate\", string>> | undefined;\n}\n\n/**\n * The full expression playground, for a host that evaluates on its own engine.\n *\n * It owns the three things the playground would otherwise fetch from a gomplate\n * server: the evaluator (the host's), the catalogue (the host's, else the\n * packaged one) and the examples (the host's, or none). So nothing here makes a\n * request to an endpoint the host does not serve.\n */\nexport function EmbeddedPlayground({\n language,\n source,\n input,\n onSourceChange,\n evaluate,\n samples,\n examples = NO_EXAMPLES,\n expectation,\n formatPath,\n executionMode,\n spec: hostSpec,\n reference,\n}: EmbeddedPlaygroundProps) {\n const languages = useMemo(() => [languageById(language)], [language]);\n // The starting state only: the playground owns the text from here on, and\n // reports edits through `onSourceChange`.\n const [initial] = useState(() => ({ language, source, input }));\n\n return (\n <ExpressionPlayground\n className=\"h-full\"\n languages={languages}\n spec={hostSpec ?? spec}\n examples={examples}\n {...(reference ? { reference } : {})}\n evaluate={evaluate}\n samples={samples}\n formatPath={formatPath}\n pathInsertion={language === \"jsonpath\" ? \"replace\" : \"caret\"}\n defaultValue={initial}\n onChange={(state) => onSourceChange(state.source)}\n {...(expectation ? { expectation } : {})}\n {...(executionMode ? { executionMode } : {})}\n />\n );\n}\n"],"mappings":";;;;;;AAOA,IAAM,cAAyB,CAAC;;;;;;;;;AAqChC,SAAgB,mBAAmB,EACjC,UACA,QACA,OACA,gBACA,UACA,SACA,WAAW,aACX,aACA,YACA,eACA,MAAM,UACN,aAC0B;CAC1B,MAAM,YAAY,cAAc,CAAC,aAAa,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC;CAGpE,MAAM,CAAC,WAAW,gBAAgB;EAAE;EAAU;EAAQ;CAAM,EAAE;CAE9D,OACE,oBAAC,sBAAD;EACE,WAAU;EACC;EACX,MAAM,YAAY;EACR;EACV,GAAK,YAAY,EAAE,UAAU,IAAI,CAAC;EACxB;EACD;EACG;EACZ,eAAe,aAAa,aAAa,YAAY;EACrD,cAAc;EACd,WAAW,UAAU,eAAe,MAAM,MAAM;EAChD,GAAK,cAAc,EAAE,YAAY,IAAI,CAAC;EACtC,GAAK,gBAAgB,EAAE,cAAc,IAAI,CAAC;CAC3C,CAAA;AAEL"}
|
|
@@ -10,6 +10,7 @@ const require_api = require("./api.cjs");
|
|
|
10
10
|
const require_languages = require("./languages.cjs");
|
|
11
11
|
const require_GraphPanel = require("./panels/GraphPanel.cjs");
|
|
12
12
|
const require_ResultView = require("./panels/ResultView.cjs");
|
|
13
|
+
const require_ReferencePanel = require("./panels/ReferencePanel.cjs");
|
|
13
14
|
const require_SpecPanel = require("./panels/SpecPanel.cjs");
|
|
14
15
|
const require_TokensPanel = require("./panels/TokensPanel.cjs");
|
|
15
16
|
const require_RunControls = require("./RunControls.cjs");
|
|
@@ -46,7 +47,7 @@ var NO_EXAMPLES = [];
|
|
|
46
47
|
* reports, so a host's own functions are first-class here without this
|
|
47
48
|
* component knowing anything about them.
|
|
48
49
|
*/
|
|
49
|
-
function ExpressionPlayground({ apiBase = require_api.DEFAULT_API_BASE, languages: offered = require_languages.LANGUAGES, examples, spec, evaluate, samples = NO_SAMPLES, expectation, executionMode, formatPath, pathInsertion = "caret", value, onChange, defaultValue, className }) {
|
|
50
|
+
function ExpressionPlayground({ apiBase = require_api.DEFAULT_API_BASE, languages: offered = require_languages.LANGUAGES, examples, spec, reference, evaluate, samples = NO_SAMPLES, expectation, executionMode, formatPath, pathInsertion = "caret", value, onChange, defaultValue, className }) {
|
|
50
51
|
const { state, update } = usePlaygroundState({
|
|
51
52
|
value,
|
|
52
53
|
onChange,
|
|
@@ -148,6 +149,7 @@ function ExpressionPlayground({ apiBase = require_api.DEFAULT_API_BASE, language
|
|
|
148
149
|
source: state.source,
|
|
149
150
|
onInsert: insertExpression,
|
|
150
151
|
formatPath,
|
|
152
|
+
reference,
|
|
151
153
|
result: {
|
|
152
154
|
view: resultView,
|
|
153
155
|
onViewChange: setResultView,
|
|
@@ -178,8 +180,9 @@ function ExamplePicker({ examples, onPick }) {
|
|
|
178
180
|
}
|
|
179
181
|
});
|
|
180
182
|
}
|
|
181
|
-
function PlaygroundOutput({ tab, onTabChange, language, spec, document, source, onInsert, formatPath, result }) {
|
|
183
|
+
function PlaygroundOutput({ tab, onTabChange, language, spec, document, source, onInsert, formatPath, reference, result }) {
|
|
182
184
|
const { catalogue, editorLanguage } = language;
|
|
185
|
+
const referenceUrl = catalogue ? reference?.[catalogue] : void 0;
|
|
183
186
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
184
187
|
className: "flex min-h-0 w-1/2 flex-col",
|
|
185
188
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -198,7 +201,10 @@ function PlaygroundOutput({ tab, onTabChange, language, spec, document, source,
|
|
|
198
201
|
id: "tokens",
|
|
199
202
|
label: "Tokens"
|
|
200
203
|
},
|
|
201
|
-
...
|
|
204
|
+
...referenceUrl ? [{
|
|
205
|
+
id: "spec",
|
|
206
|
+
label: "Reference"
|
|
207
|
+
}] : catalogue ? [{
|
|
202
208
|
id: "spec",
|
|
203
209
|
label: "Functions",
|
|
204
210
|
count: spec[catalogue].functions.length
|
|
@@ -221,7 +227,11 @@ function PlaygroundOutput({ tab, onTabChange, language, spec, document, source,
|
|
|
221
227
|
source,
|
|
222
228
|
languageId: editorLanguage
|
|
223
229
|
}),
|
|
224
|
-
tab === "spec" &&
|
|
230
|
+
tab === "spec" && referenceUrl && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ReferencePanel.ReferencePanel, {
|
|
231
|
+
url: referenceUrl,
|
|
232
|
+
title: `${language.label} reference`
|
|
233
|
+
}),
|
|
234
|
+
tab === "spec" && catalogue && !referenceUrl && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SpecPanel.SpecPanel, {
|
|
225
235
|
flavour: catalogue,
|
|
226
236
|
spec
|
|
227
237
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionPlayground.cjs","names":["DEFAULT_API_BASE","LANGUAGES","useMemo","languageById","useState","useEvaluator","useSampleRuns","useParsedInput","VerticalSplit","rowsToPaneHeight","RunControls","MonacoEditor","Combobox","Tabs","ResultView","GraphPanel","TokensPanel","SpecPanel","useCallback","spec","mergeSpec","packagedSpec","useLatest","useRef","registerGomplateLanguages","fetchSpec","fetchExamples","useEditorTheme","monacoEditor"],"sources":["../../../src/expressions/playground/ExpressionPlayground.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Combobox } from \"../../components/Combobox\";\nimport { useLatest } from \"../../hooks/use-latest\";\nimport { Tabs } from \"../../layout/Tabs\";\nimport { MonacoEditor } from \"../../monaco/MonacoEditor\";\nimport type { Monaco } from \"@monaco-editor/react\";\nimport * as monacoEditor from \"monaco-editor\";\n\nimport {\n mergeSpec,\n registerGomplateLanguages,\n spec as packagedSpec,\n} from \"../lang/index.ts\";\nimport type { GomplateSpec, RegisteredLanguages } from \"../lang/index.ts\";\nimport { DEFAULT_API_BASE, fetchExamples, fetchSpec } from \"./api.ts\";\nimport type { EvalRequest, EvalResponse, Example, FormatPath, PlaygroundSample, ResultExpectation } from \"./api.ts\";\nimport { LANGUAGES, languageById } from \"./languages.ts\";\nimport type { PlaygroundLanguage } from \"./languages.ts\";\nimport { GraphPanel } from \"./panels/GraphPanel.tsx\";\nimport { ResultView, type ResultViewId } from \"./panels/ResultView.tsx\";\nimport { SpecPanel } from \"./panels/SpecPanel.tsx\";\nimport { TokensPanel } from \"./panels/TokensPanel.tsx\";\nimport { RunControls } from \"./RunControls.tsx\";\nimport { registerRunAction } from \"./runAction.ts\";\nimport { useEditorTheme } from \"./useEditorTheme.ts\";\nimport { useEvaluator, type Evaluator } from \"./useEvaluator.ts\";\nimport { useParsedInput } from \"./useParsedInput.ts\";\nimport { useSampleRuns } from \"./useSampleRuns.ts\";\nimport { VerticalSplit } from \"./VerticalSplit.tsx\";\nimport { rowsToPaneHeight } from \"./verticalSplitModel\";\n\n/** What the author is editing. Hosts persist this wherever suits them. */\nexport interface PlaygroundState {\n language: string;\n source: string;\n input: string;\n}\n\nexport interface ExpressionPlaygroundProps {\n /**\n * Where the host mounted the playground API. Defaults to `/api`; a host\n * serving it behind a prefix passes that instead.\n */\n apiBase?: string;\n /** Languages offered. Defaults to everything gomplate evaluates. */\n languages?: PlaygroundLanguage[];\n /**\n * Samples to offer. Fetched from the server when omitted, so a host that\n * configured `Options.Examples` needs no prop at all.\n */\n examples?: Example[];\n /** Host catalogue. When supplied, the playground does not fetch /spec. */\n spec?: GomplateSpec;\n /** Host evaluator for runtimes beyond the packaged playground API. */\n evaluate?: (request: EvalRequest, signal: AbortSignal) => Promise<EvalResponse>;\n /**\n * Inputs the expression should hold for. With two or more, the Result tab\n * offers \"All samples\", which evaluates the expression against each in turn.\n */\n samples?: PlaygroundSample[];\n /** What the result is going into: allowed values, rules and a validator. */\n expectation?: ResultExpectation;\n /** Explicit mode disables evaluation on mount and edits. */\n executionMode?: \"automatic\" | \"explicit\";\n /** Host syntax for paths inserted from the object graph. */\n formatPath?: FormatPath;\n /**\n * Where a path picked in the object graph lands. `caret` (the default) writes\n * it at the cursor, which completes an expression half-written around it;\n * `replace` overwrites the whole expression, for a language whose expression\n * is a path — a JSONPath picked over `$.old` should be `$.new`, not both.\n */\n pathInsertion?: \"caret\" | \"replace\";\n /** Controlled state. Pair with `onChange`. */\n value?: PlaygroundState;\n onChange?: (state: PlaygroundState) => void;\n /** Starting state when uncontrolled. */\n defaultValue?: PlaygroundState;\n className?: string;\n}\n\nconst SOURCE_MODEL_PATH = \"inmemory://expressions/source\";\nconst INPUT_MODEL_PATH = \"inmemory://expressions/input.yaml\";\n\nconst EMPTY_STATE: PlaygroundState = { language: \"cel\", source: \"\", input: \"\" };\nconst NO_SAMPLES: PlaygroundSample[] = [];\nconst NO_EXAMPLES: Example[] = [];\n\n/**\n * An editor for one expression, the document it runs against, and its result.\n *\n * Deliberately shell-less: it renders the editors and the output panels and\n * nothing around them, so a host frames it with its own navigation. gomplate's\n * playground wraps it in an AppShell with a language rail; an app embedding it\n * in a drawer wraps it in nothing at all.\n *\n * Highlighting, completion and hover come from the catalogue the *server*\n * reports, so a host's own functions are first-class here without this\n * component knowing anything about them.\n */\nexport function ExpressionPlayground({\n apiBase = DEFAULT_API_BASE,\n languages: offered = LANGUAGES,\n examples,\n spec,\n evaluate,\n samples = NO_SAMPLES,\n expectation,\n executionMode,\n formatPath,\n pathInsertion = \"caret\",\n value,\n onChange,\n defaultValue,\n className,\n}: ExpressionPlaygroundProps) {\n const { state, update } = usePlaygroundState({ value, onChange, defaultValue, offered });\n const language = useMemo(\n () => languageById(state.language, offered),\n [state.language, offered],\n );\n const [selectedTab, setOutputTab] = useState(\"result\");\n const outputTab = selectedTab === \"spec\" && !language.catalogue ? \"result\" : selectedTab;\n if (outputTab !== selectedTab) setOutputTab(outputTab);\n\n const evaluator = useEvaluator(apiBase, {\n language: language.evalLanguage,\n source: state.source,\n input: state.input,\n }, {\n ...(executionMode ? { mode: executionMode } : {}),\n ...(evaluate ? { evaluate } : {}),\n });\n\n const [resultView, setResultView] = useState<ResultViewId>(\"input\");\n const sampleRuns = useSampleRuns(\n apiBase,\n { language: language.evalLanguage, source: state.source, samples },\n evaluate ? { evaluate } : undefined,\n );\n // Run, its shortcut and the Monaco action all drive whichever result view is\n // showing, so \"run\" never means evaluating something the author cannot see.\n const showingSamples = samples.length > 1 && outputTab === \"result\" && resultView === \"samples\";\n const runner: Evaluator = showingSamples\n ? { ...evaluator, explicit: true, autoRun: false, run: sampleRuns.run, pending: sampleRuns.pending, stale: sampleRuns.stale }\n : evaluator;\n\n const parsedInput = useParsedInput(state.input);\n const { activeSpec, registerLanguages } = usePlaygroundCatalogue({ apiBase, spec, environment: parsedInput.value });\n const forLanguage = usePlaygroundExamples(apiBase, examples).filter(\n (example) => example.language === language.evalLanguage,\n );\n const { onEditorMount, insertExpression } = usePlaygroundEditors({ run: runner.run, pathInsertion });\n useMarkers(evaluator.response);\n\n return (\n <div className={`flex h-full min-h-0 ${className ?? \"\"}`}>\n <div className=\"flex min-h-0 w-1/2 flex-col border-r border-border\">\n <VerticalSplit\n storageKey=\"expressions:editor-split\"\n defaultTopHeight={rowsToPaneHeight(language.editorRows)}\n top={\n <EditorPane\n label=\"Expression\"\n actions={<RunControls evaluator={runner} label={showingSamples ? \"Run all\" : \"Run\"} />}\n hint={\n <ExamplePicker examples={forLanguage} onPick={({ source, input }) => update({ source, input })} />\n }\n >\n <MonacoEditor\n value={state.source}\n onChange={(source) => update({ source: source ?? \"\" })}\n language={language.editorLanguage}\n path={SOURCE_MODEL_PATH}\n height=\"100%\"\n beforeMount={registerLanguages}\n onMount={onEditorMount}\n />\n </EditorPane>\n }\n bottom={\n <EditorPane\n label=\"Input\"\n hint={\n <span\n className={`truncate text-[11px] ${\n parsedInput.error\n ? \"text-destructive\"\n : \"text-muted-foreground/70\"\n }`}\n title={parsedInput.error ?? undefined}\n >\n {parsedInput.error ?? \"YAML or JSON\"}\n </span>\n }\n >\n <MonacoEditor\n value={state.input}\n onChange={(input) => update({ input: input ?? \"\" })}\n language=\"yaml\"\n path={INPUT_MODEL_PATH}\n height=\"100%\"\n onMount={onEditorMount}\n />\n </EditorPane>\n }\n />\n </div>\n\n <PlaygroundOutput\n tab={outputTab}\n onTabChange={setOutputTab}\n language={language}\n spec={activeSpec}\n document={parsedInput.value}\n source={state.source}\n onInsert={insertExpression}\n formatPath={formatPath}\n result={{\n view: resultView,\n onViewChange: setResultView,\n evaluator,\n sampleRuns,\n samples,\n expectation,\n onUseInput: (input) => update({ input }),\n }}\n />\n </div>\n );\n}\n\nfunction ExamplePicker({ examples, onPick }: { examples: Example[]; onPick: (example: Example) => void }) {\n if (examples.length === 0) return null;\n return (\n <Combobox\n options={examples.map(({ name }) => ({ value: name, label: name }))}\n value=\"\"\n allowCustomValue={false}\n placeholder=\"Load an example…\"\n ariaLabel=\"Load an example\"\n className=\"w-56\"\n onChange={(name) => {\n const example = examples.find((candidate) => candidate.name === name);\n if (example) onPick(example);\n }}\n />\n );\n}\n\nfunction PlaygroundOutput({\n tab,\n onTabChange,\n language,\n spec,\n document,\n source,\n onInsert,\n formatPath,\n result,\n}: {\n tab: string;\n onTabChange: (tab: string) => void;\n language: PlaygroundLanguage;\n spec: GomplateSpec;\n document: unknown;\n source: string;\n onInsert: (expression: string) => void;\n formatPath: FormatPath | undefined;\n result: ComponentProps<typeof ResultView>;\n}) {\n const { catalogue, editorLanguage } = language;\n return (\n <div className=\"flex min-h-0 w-1/2 flex-col\">\n <div className=\"border-b border-border px-4\">\n <Tabs\n tabs={[\n { id: \"result\", label: \"Result\" },\n { id: \"graph\", label: \"Object graph\" },\n { id: \"tokens\", label: \"Tokens\" },\n ...(catalogue\n ? [{ id: \"spec\", label: \"Functions\", count: spec[catalogue].functions.length }]\n : []),\n ]}\n value={tab}\n onChange={onTabChange}\n />\n </div>\n\n <div className=\"min-h-0 flex-1\">\n {tab === \"result\" && <ResultView {...result} />}\n {tab === \"graph\" && (\n <GraphPanel\n document={document}\n languageId={editorLanguage}\n onInsert={onInsert}\n {...(formatPath ? { formatPath } : {})}\n />\n )}\n {tab === \"tokens\" && <TokensPanel source={source} languageId={editorLanguage} />}\n {tab === \"spec\" && catalogue && <SpecPanel flavour={catalogue} spec={spec} />}\n </div>\n </div>\n );\n}\n\nfunction usePlaygroundState({ value, onChange, defaultValue, offered }: {\n value: PlaygroundState | undefined;\n onChange: ExpressionPlaygroundProps[\"onChange\"];\n defaultValue: PlaygroundState | undefined;\n offered: PlaygroundLanguage[];\n}) {\n const [uncontrolled, setUncontrolled] = useState<PlaygroundState>(\n () => defaultValue ?? { ...EMPTY_STATE, language: offered[0]?.id ?? \"cel\" },\n );\n const state = value ?? uncontrolled;\n const update = useCallback((patch: Partial<PlaygroundState>) => {\n const next = { ...state, ...patch };\n if (!value) setUncontrolled(next);\n onChange?.(next);\n }, [state, value, onChange]);\n return { state, update };\n}\n\nfunction usePlaygroundCatalogue({ apiBase, spec, environment }: {\n apiBase: string;\n spec: GomplateSpec | undefined;\n environment: unknown;\n}) {\n const [served, setServed] = useState<GomplateSpec>();\n const catalogue = spec ?? served;\n const activeSpec = useMemo(() => mergeSpec(packagedSpec, catalogue), [catalogue]);\n const latest = useLatest({ environment, catalogue });\n\n // Monaco registers languages before creating the first model. The catalogue\n // fetch and editor mount can finish in either order.\n const registered = useRef<RegisteredLanguages | null>(null);\n const registerLanguages = useCallback((monaco: Monaco) => {\n const current = latest.current.catalogue;\n registered.current = registerGomplateLanguages(monaco, {\n environment: () => latest.current.environment,\n ...(current ? { spec: current } : {}),\n });\n }, [latest]);\n\n useEffect(() => {\n if (spec) return;\n const controller = new AbortController();\n void fetchSpec(apiBase, controller.signal).then((next) => {\n if (!controller.signal.aborted) setServed(next);\n });\n return () => controller.abort();\n }, [apiBase, spec]);\n\n useEffect(() => {\n if (catalogue) registered.current?.setSpec(catalogue);\n }, [catalogue]);\n\n return { activeSpec, registerLanguages };\n}\n\nfunction usePlaygroundExamples(apiBase: string, examples: Example[] | undefined) {\n const [fetched, setFetched] = useState<Example[]>();\n useEffect(() => {\n if (examples) return;\n const controller = new AbortController();\n void fetchExamples(apiBase, controller.signal).then((next) => {\n if (!controller.signal.aborted && next) setFetched(next);\n });\n return () => controller.abort();\n }, [apiBase, examples]);\n return examples ?? fetched ?? NO_EXAMPLES;\n}\n\nfunction usePlaygroundEditors({ run, pathInsertion }: { run: Evaluator[\"run\"]; pathInsertion: \"caret\" | \"replace\" }) {\n const applyTheme = useEditorTheme();\n const runRef = useLatest(run);\n const sourceEditor = useRef<Parameters<typeof registerRunAction>[0] | null>(null);\n const onEditorMount = useCallback(\n (editor: Parameters<typeof registerRunAction>[0], monaco: Monaco) => {\n applyTheme();\n registerRunAction(editor, monaco, () => runRef.current());\n if (editor.getModel()?.uri.toString() === SOURCE_MODEL_PATH)\n sourceEditor.current = editor;\n },\n [applyTheme, runRef],\n );\n\n const insertExpression = useCallback((expression: string) => {\n const editor = sourceEditor.current;\n if (!editor) return;\n const range = pathInsertion === \"replace\" ? editor.getModel()?.getFullModelRange() : editor.getSelection();\n if (!range) return;\n editor.executeEdits(\"object-graph\", [\n { range, text: expression, forceMoveMarkers: true },\n ]);\n editor.focus();\n }, [pathInsertion]);\n return { onEditorMount, insertExpression };\n}\n\nfunction EditorPane({\n label,\n hint,\n actions,\n children,\n}: {\n label: string;\n hint?: React.ReactNode;\n actions?: React.ReactNode;\n children: React.ReactNode;\n}) {\n return (\n <section className=\"flex h-full min-h-0 flex-col bg-background\">\n <header className=\"flex h-[33px] shrink-0 items-center justify-between gap-2 px-4 py-2\">\n <div className=\"flex items-baseline gap-2\">\n <h2 className=\"text-xs font-medium uppercase tracking-wide text-muted-foreground\">\n {label}\n </h2>\n {hint}\n </div>\n {actions}\n </header>\n <div className=\"min-h-0 flex-1 [&_[data-slot=monaco-editor]]:h-full [&_[data-slot=monaco-editor]]:rounded-none [&_[data-slot=monaco-editor]]:border-0 [&_[data-slot=monaco-editor]]:border-t\">\n {children}\n </div>\n </section>\n );\n}\n\n/**\n * Mirrors a compile error onto the editor as a marker, so the position the\n * server reported is visible where the mistake is rather than only in the\n * result panel.\n */\nfunction useMarkers(response: EvalResponse | null) {\n useEffect(() => {\n const model = monacoEditor.editor\n .getModels()\n .find((candidate) => candidate.uri.toString() === SOURCE_MODEL_PATH);\n if (!model) return;\n\n const error = response?.error;\n if (!error?.line) {\n monacoEditor.editor.setModelMarkers(model, \"expressions\", []);\n return;\n }\n\n const column = error.column ?? 1;\n monacoEditor.editor.setModelMarkers(model, \"expressions\", [\n {\n severity: monacoEditor.MarkerSeverity.Error,\n message: error.message,\n startLineNumber: error.line,\n startColumn: column,\n endLineNumber: error.line,\n endColumn: column + 1,\n },\n ]);\n }, [response]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiFA,IAAM,oBAAoB;AAC1B,IAAM,mBAAmB;AAEzB,IAAM,cAA+B;CAAE,UAAU;CAAO,QAAQ;CAAI,OAAO;AAAG;AAC9E,IAAM,aAAiC,CAAC;AACxC,IAAM,cAAyB,CAAC;;;;;;;;;;;;;AAchC,SAAgB,qBAAqB,EACnC,UAAUA,YAAAA,kBACV,WAAW,UAAUC,kBAAAA,WACrB,UACA,MACA,UACA,UAAU,YACV,aACA,eACA,YACA,gBAAgB,SAChB,OACA,UACA,cACA,aAC4B;CAC5B,MAAM,EAAE,OAAO,WAAW,mBAAmB;EAAE;EAAO;EAAU;EAAc;CAAQ,CAAC;CACvF,MAAM,YAAA,GAAWC,MAAAA,QAAAA,OACTC,kBAAAA,aAAa,MAAM,UAAU,OAAO,GAC1C,CAAC,MAAM,UAAU,OAAO,CAC1B;CACA,MAAM,CAAC,aAAa,iBAAA,GAAgBC,MAAAA,SAAAA,CAAS,QAAQ;CACrD,MAAM,YAAY,gBAAgB,UAAU,CAAC,SAAS,YAAY,WAAW;CAC7E,IAAI,cAAc,aAAa,aAAa,SAAS;CAErD,MAAM,YAAYC,qBAAAA,aAAa,SA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,CACF,CAAC;CACH,GAAG,CAAC,QAAQ,CAAC;AACf"}
|
|
1
|
+
{"version":3,"file":"ExpressionPlayground.cjs","names":["DEFAULT_API_BASE","LANGUAGES","useMemo","languageById","useState","useEvaluator","useSampleRuns","useParsedInput","VerticalSplit","rowsToPaneHeight","RunControls","MonacoEditor","Combobox","Tabs","ResultView","GraphPanel","TokensPanel","ReferencePanel","SpecPanel","useCallback","spec","mergeSpec","packagedSpec","useLatest","useRef","registerGomplateLanguages","fetchSpec","fetchExamples","useEditorTheme","monacoEditor"],"sources":["../../../src/expressions/playground/ExpressionPlayground.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState, type ComponentProps } from \"react\";\nimport { Combobox } from \"../../components/Combobox\";\nimport { useLatest } from \"../../hooks/use-latest\";\nimport { Tabs } from \"../../layout/Tabs\";\nimport { MonacoEditor } from \"../../monaco/MonacoEditor\";\nimport type { Monaco } from \"@monaco-editor/react\";\nimport * as monacoEditor from \"monaco-editor\";\n\nimport {\n mergeSpec,\n registerGomplateLanguages,\n spec as packagedSpec,\n} from \"../lang/index.ts\";\nimport type { GomplateSpec, RegisteredLanguages } from \"../lang/index.ts\";\nimport { DEFAULT_API_BASE, fetchExamples, fetchSpec } from \"./api.ts\";\nimport type { EvalRequest, EvalResponse, Example, FormatPath, PlaygroundSample, ResultExpectation } from \"./api.ts\";\nimport { LANGUAGES, languageById } from \"./languages.ts\";\nimport type { PlaygroundLanguage } from \"./languages.ts\";\nimport { GraphPanel } from \"./panels/GraphPanel.tsx\";\nimport { ResultView, type ResultViewId } from \"./panels/ResultView.tsx\";\nimport { ReferencePanel } from \"./panels/ReferencePanel.tsx\";\nimport { SpecPanel } from \"./panels/SpecPanel.tsx\";\nimport { TokensPanel } from \"./panels/TokensPanel.tsx\";\nimport { RunControls } from \"./RunControls.tsx\";\nimport { registerRunAction } from \"./runAction.ts\";\nimport { useEditorTheme } from \"./useEditorTheme.ts\";\nimport { useEvaluator, type Evaluator } from \"./useEvaluator.ts\";\nimport { useParsedInput } from \"./useParsedInput.ts\";\nimport { useSampleRuns } from \"./useSampleRuns.ts\";\nimport { VerticalSplit } from \"./VerticalSplit.tsx\";\nimport { rowsToPaneHeight } from \"./verticalSplitModel\";\n\n/** What the author is editing. Hosts persist this wherever suits them. */\nexport interface PlaygroundState {\n language: string;\n source: string;\n input: string;\n}\n\nexport interface ExpressionPlaygroundProps {\n /**\n * Where the host mounted the playground API. Defaults to `/api`; a host\n * serving it behind a prefix passes that instead.\n */\n apiBase?: string;\n /** Languages offered. Defaults to everything gomplate evaluates. */\n languages?: PlaygroundLanguage[];\n /**\n * Samples to offer. Fetched from the server when omitted, so a host that\n * configured `Options.Examples` needs no prop at all.\n */\n examples?: Example[];\n /** Host catalogue. When supplied, the playground does not fetch /spec. */\n spec?: GomplateSpec;\n /**\n * The host's reference page per catalogue. A language with one shows it as\n * its Reference tab instead of the Functions table; the page is embedded with\n * `?embed&theme=<light|dark>` so it can drop its own navigation.\n */\n reference?: Partial<Record<\"cel\" | \"gotemplate\", string>>;\n /** Host evaluator for runtimes beyond the packaged playground API. */\n evaluate?: (request: EvalRequest, signal: AbortSignal) => Promise<EvalResponse>;\n /**\n * Inputs the expression should hold for. With two or more, the Result tab\n * offers \"All samples\", which evaluates the expression against each in turn.\n */\n samples?: PlaygroundSample[];\n /** What the result is going into: allowed values, rules and a validator. */\n expectation?: ResultExpectation;\n /** Explicit mode disables evaluation on mount and edits. */\n executionMode?: \"automatic\" | \"explicit\";\n /** Host syntax for paths inserted from the object graph. */\n formatPath?: FormatPath;\n /**\n * Where a path picked in the object graph lands. `caret` (the default) writes\n * it at the cursor, which completes an expression half-written around it;\n * `replace` overwrites the whole expression, for a language whose expression\n * is a path — a JSONPath picked over `$.old` should be `$.new`, not both.\n */\n pathInsertion?: \"caret\" | \"replace\";\n /** Controlled state. Pair with `onChange`. */\n value?: PlaygroundState;\n onChange?: (state: PlaygroundState) => void;\n /** Starting state when uncontrolled. */\n defaultValue?: PlaygroundState;\n className?: string;\n}\n\nconst SOURCE_MODEL_PATH = \"inmemory://expressions/source\";\nconst INPUT_MODEL_PATH = \"inmemory://expressions/input.yaml\";\n\nconst EMPTY_STATE: PlaygroundState = { language: \"cel\", source: \"\", input: \"\" };\nconst NO_SAMPLES: PlaygroundSample[] = [];\nconst NO_EXAMPLES: Example[] = [];\n\n/**\n * An editor for one expression, the document it runs against, and its result.\n *\n * Deliberately shell-less: it renders the editors and the output panels and\n * nothing around them, so a host frames it with its own navigation. gomplate's\n * playground wraps it in an AppShell with a language rail; an app embedding it\n * in a drawer wraps it in nothing at all.\n *\n * Highlighting, completion and hover come from the catalogue the *server*\n * reports, so a host's own functions are first-class here without this\n * component knowing anything about them.\n */\nexport function ExpressionPlayground({\n apiBase = DEFAULT_API_BASE,\n languages: offered = LANGUAGES,\n examples,\n spec,\n reference,\n evaluate,\n samples = NO_SAMPLES,\n expectation,\n executionMode,\n formatPath,\n pathInsertion = \"caret\",\n value,\n onChange,\n defaultValue,\n className,\n}: ExpressionPlaygroundProps) {\n const { state, update } = usePlaygroundState({ value, onChange, defaultValue, offered });\n const language = useMemo(\n () => languageById(state.language, offered),\n [state.language, offered],\n );\n const [selectedTab, setOutputTab] = useState(\"result\");\n const outputTab = selectedTab === \"spec\" && !language.catalogue ? \"result\" : selectedTab;\n if (outputTab !== selectedTab) setOutputTab(outputTab);\n\n const evaluator = useEvaluator(apiBase, {\n language: language.evalLanguage,\n source: state.source,\n input: state.input,\n }, {\n ...(executionMode ? { mode: executionMode } : {}),\n ...(evaluate ? { evaluate } : {}),\n });\n\n const [resultView, setResultView] = useState<ResultViewId>(\"input\");\n const sampleRuns = useSampleRuns(\n apiBase,\n { language: language.evalLanguage, source: state.source, samples },\n evaluate ? { evaluate } : undefined,\n );\n // Run, its shortcut and the Monaco action all drive whichever result view is\n // showing, so \"run\" never means evaluating something the author cannot see.\n const showingSamples = samples.length > 1 && outputTab === \"result\" && resultView === \"samples\";\n const runner: Evaluator = showingSamples\n ? { ...evaluator, explicit: true, autoRun: false, run: sampleRuns.run, pending: sampleRuns.pending, stale: sampleRuns.stale }\n : evaluator;\n\n const parsedInput = useParsedInput(state.input);\n const { activeSpec, registerLanguages } = usePlaygroundCatalogue({ apiBase, spec, environment: parsedInput.value });\n const forLanguage = usePlaygroundExamples(apiBase, examples).filter(\n (example) => example.language === language.evalLanguage,\n );\n const { onEditorMount, insertExpression } = usePlaygroundEditors({ run: runner.run, pathInsertion });\n useMarkers(evaluator.response);\n\n return (\n <div className={`flex h-full min-h-0 ${className ?? \"\"}`}>\n <div className=\"flex min-h-0 w-1/2 flex-col border-r border-border\">\n <VerticalSplit\n storageKey=\"expressions:editor-split\"\n defaultTopHeight={rowsToPaneHeight(language.editorRows)}\n top={\n <EditorPane\n label=\"Expression\"\n actions={<RunControls evaluator={runner} label={showingSamples ? \"Run all\" : \"Run\"} />}\n hint={\n <ExamplePicker examples={forLanguage} onPick={({ source, input }) => update({ source, input })} />\n }\n >\n <MonacoEditor\n value={state.source}\n onChange={(source) => update({ source: source ?? \"\" })}\n language={language.editorLanguage}\n path={SOURCE_MODEL_PATH}\n height=\"100%\"\n beforeMount={registerLanguages}\n onMount={onEditorMount}\n />\n </EditorPane>\n }\n bottom={\n <EditorPane\n label=\"Input\"\n hint={\n <span\n className={`truncate text-[11px] ${\n parsedInput.error\n ? \"text-destructive\"\n : \"text-muted-foreground/70\"\n }`}\n title={parsedInput.error ?? undefined}\n >\n {parsedInput.error ?? \"YAML or JSON\"}\n </span>\n }\n >\n <MonacoEditor\n value={state.input}\n onChange={(input) => update({ input: input ?? \"\" })}\n language=\"yaml\"\n path={INPUT_MODEL_PATH}\n height=\"100%\"\n onMount={onEditorMount}\n />\n </EditorPane>\n }\n />\n </div>\n\n <PlaygroundOutput\n tab={outputTab}\n onTabChange={setOutputTab}\n language={language}\n spec={activeSpec}\n document={parsedInput.value}\n source={state.source}\n onInsert={insertExpression}\n formatPath={formatPath}\n reference={reference}\n result={{\n view: resultView,\n onViewChange: setResultView,\n evaluator,\n sampleRuns,\n samples,\n expectation,\n onUseInput: (input) => update({ input }),\n }}\n />\n </div>\n );\n}\n\nfunction ExamplePicker({ examples, onPick }: { examples: Example[]; onPick: (example: Example) => void }) {\n if (examples.length === 0) return null;\n return (\n <Combobox\n options={examples.map(({ name }) => ({ value: name, label: name }))}\n value=\"\"\n allowCustomValue={false}\n placeholder=\"Load an example…\"\n ariaLabel=\"Load an example\"\n className=\"w-56\"\n onChange={(name) => {\n const example = examples.find((candidate) => candidate.name === name);\n if (example) onPick(example);\n }}\n />\n );\n}\n\nfunction PlaygroundOutput({\n tab,\n onTabChange,\n language,\n spec,\n document,\n source,\n onInsert,\n formatPath,\n reference,\n result,\n}: {\n tab: string;\n onTabChange: (tab: string) => void;\n language: PlaygroundLanguage;\n spec: GomplateSpec;\n document: unknown;\n source: string;\n onInsert: (expression: string) => void;\n formatPath: FormatPath | undefined;\n reference: ExpressionPlaygroundProps[\"reference\"];\n result: ComponentProps<typeof ResultView>;\n}) {\n const { catalogue, editorLanguage } = language;\n const referenceUrl = catalogue ? reference?.[catalogue] : undefined;\n return (\n <div className=\"flex min-h-0 w-1/2 flex-col\">\n <div className=\"border-b border-border px-4\">\n <Tabs\n tabs={[\n { id: \"result\", label: \"Result\" },\n { id: \"graph\", label: \"Object graph\" },\n { id: \"tokens\", label: \"Tokens\" },\n ...(referenceUrl\n ? [{ id: \"spec\", label: \"Reference\" }]\n : catalogue\n ? [{ id: \"spec\", label: \"Functions\", count: spec[catalogue].functions.length }]\n : []),\n ]}\n value={tab}\n onChange={onTabChange}\n />\n </div>\n\n <div className=\"min-h-0 flex-1\">\n {tab === \"result\" && <ResultView {...result} />}\n {tab === \"graph\" && (\n <GraphPanel\n document={document}\n languageId={editorLanguage}\n onInsert={onInsert}\n {...(formatPath ? { formatPath } : {})}\n />\n )}\n {tab === \"tokens\" && <TokensPanel source={source} languageId={editorLanguage} />}\n {tab === \"spec\" && referenceUrl && <ReferencePanel url={referenceUrl} title={`${language.label} reference`} />}\n {tab === \"spec\" && catalogue && !referenceUrl && <SpecPanel flavour={catalogue} spec={spec} />}\n </div>\n </div>\n );\n}\n\nfunction usePlaygroundState({ value, onChange, defaultValue, offered }: {\n value: PlaygroundState | undefined;\n onChange: ExpressionPlaygroundProps[\"onChange\"];\n defaultValue: PlaygroundState | undefined;\n offered: PlaygroundLanguage[];\n}) {\n const [uncontrolled, setUncontrolled] = useState<PlaygroundState>(\n () => defaultValue ?? { ...EMPTY_STATE, language: offered[0]?.id ?? \"cel\" },\n );\n const state = value ?? uncontrolled;\n const update = useCallback((patch: Partial<PlaygroundState>) => {\n const next = { ...state, ...patch };\n if (!value) setUncontrolled(next);\n onChange?.(next);\n }, [state, value, onChange]);\n return { state, update };\n}\n\nfunction usePlaygroundCatalogue({ apiBase, spec, environment }: {\n apiBase: string;\n spec: GomplateSpec | undefined;\n environment: unknown;\n}) {\n const [served, setServed] = useState<GomplateSpec>();\n const catalogue = spec ?? served;\n const activeSpec = useMemo(() => mergeSpec(packagedSpec, catalogue), [catalogue]);\n const latest = useLatest({ environment, catalogue });\n\n // Monaco registers languages before creating the first model. The catalogue\n // fetch and editor mount can finish in either order.\n const registered = useRef<RegisteredLanguages | null>(null);\n const registerLanguages = useCallback((monaco: Monaco) => {\n const current = latest.current.catalogue;\n registered.current = registerGomplateLanguages(monaco, {\n environment: () => latest.current.environment,\n ...(current ? { spec: current } : {}),\n });\n }, [latest]);\n\n useEffect(() => {\n if (spec) return;\n const controller = new AbortController();\n void fetchSpec(apiBase, controller.signal).then((next) => {\n if (!controller.signal.aborted) setServed(next);\n });\n return () => controller.abort();\n }, [apiBase, spec]);\n\n useEffect(() => {\n if (catalogue) registered.current?.setSpec(catalogue);\n }, [catalogue]);\n\n return { activeSpec, registerLanguages };\n}\n\nfunction usePlaygroundExamples(apiBase: string, examples: Example[] | undefined) {\n const [fetched, setFetched] = useState<Example[]>();\n useEffect(() => {\n if (examples) return;\n const controller = new AbortController();\n void fetchExamples(apiBase, controller.signal).then((next) => {\n if (!controller.signal.aborted && next) setFetched(next);\n });\n return () => controller.abort();\n }, [apiBase, examples]);\n return examples ?? fetched ?? NO_EXAMPLES;\n}\n\nfunction usePlaygroundEditors({ run, pathInsertion }: { run: Evaluator[\"run\"]; pathInsertion: \"caret\" | \"replace\" }) {\n const applyTheme = useEditorTheme();\n const runRef = useLatest(run);\n const sourceEditor = useRef<Parameters<typeof registerRunAction>[0] | null>(null);\n const onEditorMount = useCallback(\n (editor: Parameters<typeof registerRunAction>[0], monaco: Monaco) => {\n applyTheme();\n registerRunAction(editor, monaco, () => runRef.current());\n if (editor.getModel()?.uri.toString() === SOURCE_MODEL_PATH)\n sourceEditor.current = editor;\n },\n [applyTheme, runRef],\n );\n\n const insertExpression = useCallback((expression: string) => {\n const editor = sourceEditor.current;\n if (!editor) return;\n const range = pathInsertion === \"replace\" ? editor.getModel()?.getFullModelRange() : editor.getSelection();\n if (!range) return;\n editor.executeEdits(\"object-graph\", [\n { range, text: expression, forceMoveMarkers: true },\n ]);\n editor.focus();\n }, [pathInsertion]);\n return { onEditorMount, insertExpression };\n}\n\nfunction EditorPane({\n label,\n hint,\n actions,\n children,\n}: {\n label: string;\n hint?: React.ReactNode;\n actions?: React.ReactNode;\n children: React.ReactNode;\n}) {\n return (\n <section className=\"flex h-full min-h-0 flex-col bg-background\">\n <header className=\"flex h-[33px] shrink-0 items-center justify-between gap-2 px-4 py-2\">\n <div className=\"flex items-baseline gap-2\">\n <h2 className=\"text-xs font-medium uppercase tracking-wide text-muted-foreground\">\n {label}\n </h2>\n {hint}\n </div>\n {actions}\n </header>\n <div className=\"min-h-0 flex-1 [&_[data-slot=monaco-editor]]:h-full [&_[data-slot=monaco-editor]]:rounded-none [&_[data-slot=monaco-editor]]:border-0 [&_[data-slot=monaco-editor]]:border-t\">\n {children}\n </div>\n </section>\n );\n}\n\n/**\n * Mirrors a compile error onto the editor as a marker, so the position the\n * server reported is visible where the mistake is rather than only in the\n * result panel.\n */\nfunction useMarkers(response: EvalResponse | null) {\n useEffect(() => {\n const model = monacoEditor.editor\n .getModels()\n .find((candidate) => candidate.uri.toString() === SOURCE_MODEL_PATH);\n if (!model) return;\n\n const error = response?.error;\n if (!error?.line) {\n monacoEditor.editor.setModelMarkers(model, \"expressions\", []);\n return;\n }\n\n const column = error.column ?? 1;\n monacoEditor.editor.setModelMarkers(model, \"expressions\", [\n {\n severity: monacoEditor.MarkerSeverity.Error,\n message: error.message,\n startLineNumber: error.line,\n startColumn: column,\n endLineNumber: error.line,\n endColumn: column + 1,\n },\n ]);\n }, [response]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA,IAAM,oBAAoB;AAC1B,IAAM,mBAAmB;AAEzB,IAAM,cAA+B;CAAE,UAAU;CAAO,QAAQ;CAAI,OAAO;AAAG;AAC9E,IAAM,aAAiC,CAAC;AACxC,IAAM,cAAyB,CAAC;;;;;;;;;;;;;AAchC,SAAgB,qBAAqB,EACnC,UAAUA,YAAAA,kBACV,WAAW,UAAUC,kBAAAA,WACrB,UACA,MACA,WACA,UACA,UAAU,YACV,aACA,eACA,YACA,gBAAgB,SAChB,OACA,UACA,cACA,aAC4B;CAC5B,MAAM,EAAE,OAAO,WAAW,mBAAmB;EAAE;EAAO;EAAU;EAAc;CAAQ,CAAC;CACvF,MAAM,YAAA,GAAWC,MAAAA,QAAAA,OACTC,kBAAAA,aAAa,MAAM,UAAU,OAAO,GAC1C,CAAC,MAAM,UAAU,OAAO,CAC1B;CACA,MAAM,CAAC,aAAa,iBAAA,GAAgBC,MAAAA,SAAAA,CAAS,QAAQ;CACrD,MAAM,YAAY,gBAAgB,UAAU,CAAC,SAAS,YAAY,WAAW;CAC7E,IAAI,cAAc,aAAa,aAAa,SAAS;CAErD,MAAM,YAAYC,qBAAAA,aAAa,SAAS;EACtC,UAAU,SAAS;EACnB,QAAQ,MAAM;EACd,OAAO,MAAM;CACf,GAAG;EACD,GAAI,gBAAgB,EAAE,MAAM,cAAc,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cAAa,OAAO,gBAAgB,OAAO,eAAe,CACxD;GACE,UAAUA,cAAa,eAAe;GACtC,SAAS,MAAM;GACf,iBAAiB,MAAM;GACvB,aAAa;GACb,eAAe,MAAM;GACrB,WAAW,SAAS;EACtB,CACF,CAAC;CACH,GAAG,CAAC,QAAQ,CAAC;AACf"}
|
|
@@ -22,6 +22,12 @@ export interface ExpressionPlaygroundProps {
|
|
|
22
22
|
examples?: Example[];
|
|
23
23
|
/** Host catalogue. When supplied, the playground does not fetch /spec. */
|
|
24
24
|
spec?: GomplateSpec;
|
|
25
|
+
/**
|
|
26
|
+
* The host's reference page per catalogue. A language with one shows it as
|
|
27
|
+
* its Reference tab instead of the Functions table; the page is embedded with
|
|
28
|
+
* `?embed&theme=<light|dark>` so it can drop its own navigation.
|
|
29
|
+
*/
|
|
30
|
+
reference?: Partial<Record<"cel" | "gotemplate", string>>;
|
|
25
31
|
/** Host evaluator for runtimes beyond the packaged playground API. */
|
|
26
32
|
evaluate?: (request: EvalRequest, signal: AbortSignal) => Promise<EvalResponse>;
|
|
27
33
|
/**
|
|
@@ -61,5 +67,5 @@ export interface ExpressionPlaygroundProps {
|
|
|
61
67
|
* reports, so a host's own functions are first-class here without this
|
|
62
68
|
* component knowing anything about them.
|
|
63
69
|
*/
|
|
64
|
-
export declare function ExpressionPlayground({ apiBase, languages: offered, examples, spec, evaluate, samples, expectation, executionMode, formatPath, pathInsertion, value, onChange, defaultValue, className, }: ExpressionPlaygroundProps): import("react").JSX.Element;
|
|
70
|
+
export declare function ExpressionPlayground({ apiBase, languages: offered, examples, spec, reference, evaluate, samples, expectation, executionMode, formatPath, pathInsertion, value, onChange, defaultValue, className, }: ExpressionPlaygroundProps): import("react").JSX.Element;
|
|
65
71
|
//# sourceMappingURL=ExpressionPlayground.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionPlayground.d.ts","sourceRoot":"","sources":["../../../src/expressions/playground/ExpressionPlayground.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,kBAAkB,CAAC;AAE1E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEpH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ExpressionPlayground.d.ts","sourceRoot":"","sources":["../../../src/expressions/playground/ExpressionPlayground.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,kBAAkB,CAAC;AAE1E,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEpH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAezD,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,SAAS,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1D,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IAChF;;;OAGG;IACH,OAAO,CAAC,E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