@pixerate/editor 0.19.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -4
- package/dist/agent/index.cjs +625 -2
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +286 -2
- package/dist/agent/index.d.ts +286 -2
- package/dist/agent/index.js +624 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/canvas/index.cjs +1240 -22
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +515 -3
- package/dist/canvas/index.d.ts +515 -3
- package/dist/canvas/index.js +1219 -1
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-3TYMNULT.js +1367 -0
- package/dist/chunk-3TYMNULT.js.map +1 -0
- package/dist/chunk-4QPLEUL2.cjs +4480 -0
- package/dist/chunk-4QPLEUL2.cjs.map +1 -0
- package/dist/chunk-4SUNJZWB.cjs +553 -0
- package/dist/chunk-4SUNJZWB.cjs.map +1 -0
- package/dist/chunk-A7DKIA72.js +2657 -0
- package/dist/chunk-A7DKIA72.js.map +1 -0
- package/dist/chunk-AXV2ZW34.cjs +118 -0
- package/dist/chunk-AXV2ZW34.cjs.map +1 -0
- package/dist/chunk-B2ZRLN4S.js +118 -0
- package/dist/chunk-B2ZRLN4S.js.map +1 -0
- package/dist/chunk-CYFJCKC4.js +4480 -0
- package/dist/chunk-CYFJCKC4.js.map +1 -0
- package/dist/chunk-GVW4P7BG.js +2706 -0
- package/dist/chunk-GVW4P7BG.js.map +1 -0
- package/dist/chunk-JACER6TE.cjs +1 -0
- package/dist/chunk-JACER6TE.cjs.map +1 -0
- package/dist/chunk-JYRIOFEN.cjs +2657 -0
- package/dist/chunk-JYRIOFEN.cjs.map +1 -0
- package/dist/chunk-KYRZDWM4.js +299 -0
- package/dist/chunk-KYRZDWM4.js.map +1 -0
- package/dist/chunk-LA7PEGU3.cjs +299 -0
- package/dist/chunk-LA7PEGU3.cjs.map +1 -0
- package/dist/chunk-N7FG6CBO.js +1 -0
- package/dist/chunk-N7FG6CBO.js.map +1 -0
- package/dist/chunk-OYXSKQFR.js +553 -0
- package/dist/chunk-OYXSKQFR.js.map +1 -0
- package/dist/chunk-TVRC4KVT.cjs +1367 -0
- package/dist/chunk-TVRC4KVT.cjs.map +1 -0
- package/dist/chunk-U6NDQFOK.cjs +2706 -0
- package/dist/chunk-U6NDQFOK.cjs.map +1 -0
- package/dist/controller-OUdxPY-X.d.cts +754 -0
- package/dist/controller-OUdxPY-X.d.ts +754 -0
- package/dist/extensions/index.cjs +144 -3
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +9 -144
- package/dist/extensions/index.d.ts +9 -144
- package/dist/extensions/index.js +145 -4
- package/dist/grammar/index.cjs +31 -3
- package/dist/grammar/index.cjs.map +1 -1
- package/dist/grammar/index.d.cts +239 -19
- package/dist/grammar/index.d.ts +239 -19
- package/dist/grammar/index.js +31 -3
- package/dist/history/index.d.cts +2 -41
- package/dist/history/index.d.ts +2 -41
- package/dist/index-Ng1pG7JE.d.ts +899 -0
- package/dist/index-k3mFbPx_.d.cts +899 -0
- package/dist/index.cjs +457 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +99 -12
- package/dist/index.d.ts +99 -12
- package/dist/index.js +457 -20
- package/dist/index.js.map +1 -1
- package/dist/registry-iAHbqkYt.d.cts +128 -0
- package/dist/registry-iAHbqkYt.d.ts +128 -0
- package/dist/serializers/index.cjs +26 -3
- package/dist/serializers/index.cjs.map +1 -1
- package/dist/serializers/index.d.cts +119 -6
- package/dist/serializers/index.d.ts +119 -6
- package/dist/serializers/index.js +24 -1
- package/dist/spreadsheet/index.cjs +122 -2
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +371 -313
- package/dist/spreadsheet/index.d.ts +371 -313
- package/dist/spreadsheet/index.js +127 -7
- package/dist/tokens-CyLZmIei.d.cts +76 -0
- package/dist/tokens-CyLZmIei.d.ts +76 -0
- package/dist/track-changes-G8JcWB8b.d.cts +306 -0
- package/dist/track-changes-G8JcWB8b.d.ts +306 -0
- package/dist/types-BZgcDsC5.d.cts +42 -0
- package/dist/types-BZgcDsC5.d.ts +42 -0
- package/dist/{types-JV3S8VeR.d.cts → types-DMe0vFB1.d.cts} +1 -1
- package/dist/{types-JV3S8VeR.d.ts → types-DMe0vFB1.d.ts} +1 -1
- package/package.json +11 -4
- package/dist/chunk-7FWEWE6T.js +0 -1888
- package/dist/chunk-7FWEWE6T.js.map +0 -1
- package/dist/chunk-AIZUKWTL.js +0 -1715
- package/dist/chunk-AIZUKWTL.js.map +0 -1
- package/dist/chunk-GLSIZKOX.js +0 -17
- package/dist/chunk-GLSIZKOX.js.map +0 -1
- package/dist/chunk-LDES3EOS.cjs +0 -1888
- package/dist/chunk-LDES3EOS.cjs.map +0 -1
- package/dist/chunk-LLUAKTLW.cjs +0 -532
- package/dist/chunk-LLUAKTLW.cjs.map +0 -1
- package/dist/chunk-MPPXH7U5.cjs +0 -336
- package/dist/chunk-MPPXH7U5.cjs.map +0 -1
- package/dist/chunk-O7LOPQMH.js +0 -336
- package/dist/chunk-O7LOPQMH.js.map +0 -1
- package/dist/chunk-QGVMBCT5.js +0 -532
- package/dist/chunk-QGVMBCT5.js.map +0 -1
- package/dist/chunk-SEDR75VH.cjs +0 -17
- package/dist/chunk-SEDR75VH.cjs.map +0 -1
- package/dist/chunk-YQCI4CCN.cjs +0 -1715
- package/dist/chunk-YQCI4CCN.cjs.map +0 -1
- package/dist/mention-Dcevh3ff.d.cts +0 -32
- package/dist/mention-Dcevh3ff.d.ts +0 -32
- package/dist/tokens-7kRTEtPb.d.cts +0 -39
- package/dist/tokens-7kRTEtPb.d.ts +0 -39
package/dist/grammar/index.d.ts
CHANGED
|
@@ -1,45 +1,64 @@
|
|
|
1
|
-
import { T as Token,
|
|
2
|
-
export { C as ColorGradient, I as INSTRUCTION_REGEX,
|
|
1
|
+
import { T as Token, P as PromptDiagnostic, d as PromptValues, f as Template, g as TemplateVersion, a as ConditionalKind, c as PromptValue } from '../tokens-CyLZmIei.js';
|
|
2
|
+
export { C as ColorGradient, I as INSTRUCTION_REGEX, b as PromptDiagnosticCode, e as TEMPLATE_REGEX, h as TokenType, V as VARIABLE_REGEX, i as instructionRegex, t as templateRegex, v as variableRegex } from '../tokens-CyLZmIei.js';
|
|
3
3
|
|
|
4
|
+
interface TokenizeResult {
|
|
5
|
+
tokens: Token[];
|
|
6
|
+
/** Unbalanced conditional tags, which were emitted as text. */
|
|
7
|
+
diagnostics: PromptDiagnostic[];
|
|
8
|
+
}
|
|
4
9
|
/**
|
|
5
10
|
* Parses any prompt string into an array of typed tokens in linear order.
|
|
6
11
|
* Plain text between tokens is preserved as `{ type: 'text' }`.
|
|
12
|
+
*
|
|
13
|
+
* Conditional section tags (`{?name}`, `{!name}`, `{/name}`) are only emitted
|
|
14
|
+
* as `conditional` tokens when balanced; unbalanced tags become text. Use
|
|
15
|
+
* `tokenizePromptWithDiagnostics` to find out which tags were rejected.
|
|
7
16
|
*/
|
|
8
17
|
declare function tokenizePrompt(text: string): Token[];
|
|
9
|
-
|
|
10
18
|
/**
|
|
11
|
-
*
|
|
19
|
+
* Returns the diagnostics `tokenizePrompt` would report for `text`.
|
|
12
20
|
*/
|
|
13
|
-
declare function
|
|
21
|
+
declare function getPromptDiagnostics(text: string): PromptDiagnostic[];
|
|
22
|
+
/**
|
|
23
|
+
* Like `tokenizePrompt`, but also reports unbalanced conditional tags.
|
|
24
|
+
*/
|
|
25
|
+
declare function tokenizePromptWithDiagnostics(text: string): TokenizeResult;
|
|
26
|
+
|
|
14
27
|
interface ResolveTemplatesOptions {
|
|
15
28
|
bindings?: Record<string, string>;
|
|
16
29
|
maxDepth?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Values for `{variable}` slots and `{?variable}` sections. When omitted,
|
|
32
|
+
* variables, defaults and section tags are left exactly as written.
|
|
33
|
+
*/
|
|
34
|
+
values?: PromptValues;
|
|
17
35
|
}
|
|
18
|
-
/** Marker substituted for a template tag that would recurse into itself. */
|
|
19
|
-
declare const TEMPLATE_LOOP_ERROR = "[Template loop detected]";
|
|
20
|
-
/** Marker substituted for a template tag nested deeper than `maxDepth`. */
|
|
21
|
-
declare const TEMPLATE_DEPTH_ERROR = "[Template max depth exceeded]";
|
|
22
|
-
/**
|
|
23
|
-
* Returns the body a template tag resolves to, honoring version bindings.
|
|
24
|
-
*/
|
|
25
|
-
declare function getTemplateBody(template: Template, bindings?: Record<string, string>): string | undefined;
|
|
26
36
|
/**
|
|
27
37
|
* Recursively resolves template tags `{{template_name}}` in a given text.
|
|
28
38
|
* A tag that would recurse into itself is replaced with `TEMPLATE_LOOP_ERROR`,
|
|
29
39
|
* and a tag nested deeper than `maxDepth` with `TEMPLATE_DEPTH_ERROR`; the rest
|
|
30
40
|
* of the text still resolves normally.
|
|
41
|
+
*
|
|
42
|
+
* Pass `options.values` to also fill variables (falling back to their
|
|
43
|
+
* `{name|default}`) and evaluate `{?name}…{/name}` / `{!name}…{/name}`
|
|
44
|
+
* sections, including those inside template bodies. See `resolvePrompt` for
|
|
45
|
+
* the source map and diagnostics.
|
|
31
46
|
*/
|
|
32
47
|
declare function resolveTemplates(text: string, templates?: Template[], options?: ResolveTemplatesOptions): string;
|
|
33
48
|
/**
|
|
34
|
-
* Replaces `{variableName}` with values from a dictionary
|
|
49
|
+
* Replaces `{variableName}` with values from a dictionary, falling back to a
|
|
50
|
+
* `{variableName|default}` when no value is supplied, and evaluates
|
|
51
|
+
* `{?name}…{/name}` / `{!name}…{/name}` sections. Variables with neither a
|
|
52
|
+
* value nor a default are left as written. Templates are not expanded.
|
|
35
53
|
*/
|
|
36
|
-
declare function resolveVariables(text: string, values:
|
|
54
|
+
declare function resolveVariables(text: string, values: PromptValues): string;
|
|
37
55
|
/**
|
|
38
56
|
* Extracts unique template names referenced in text.
|
|
39
57
|
*/
|
|
40
58
|
declare function extractTemplateNames(text: string): string[];
|
|
41
59
|
/**
|
|
42
|
-
* Extracts unique variable names referenced in text
|
|
60
|
+
* Extracts unique variable names referenced in text, including names used by
|
|
61
|
+
* conditional section tags. Defaults and descriptions are stripped.
|
|
43
62
|
*/
|
|
44
63
|
declare function extractVariableNames(text: string): string[];
|
|
45
64
|
/**
|
|
@@ -47,21 +66,41 @@ declare function extractVariableNames(text: string): string[];
|
|
|
47
66
|
*/
|
|
48
67
|
declare function extractInstructionNames(text: string): string[];
|
|
49
68
|
|
|
69
|
+
/**
|
|
70
|
+
* One contiguous piece of resolved output and the raw range it came from.
|
|
71
|
+
*
|
|
72
|
+
* - `raw`: copied verbatim; offsets map character by character.
|
|
73
|
+
* - `template`: the expansion of a `{{template}}` tag.
|
|
74
|
+
* - `variable`: a substituted value or `|default` for a `{variable}` tag.
|
|
75
|
+
* - `conditional`: a section tag, or a whole removed section. These segments
|
|
76
|
+
* are empty in the resolved text (`resolvedStart === resolvedEnd`).
|
|
77
|
+
*
|
|
78
|
+
* Offsets inside non-raw segments map to the start of their raw range.
|
|
79
|
+
*/
|
|
50
80
|
interface SourceMapSegment {
|
|
51
81
|
resolvedStart: number;
|
|
52
82
|
resolvedEnd: number;
|
|
53
|
-
source: "raw" | "template";
|
|
83
|
+
source: "raw" | "template" | "variable" | "conditional";
|
|
54
84
|
rawStart: number;
|
|
55
85
|
rawEnd: number;
|
|
56
86
|
templateName?: string;
|
|
87
|
+
/** Variable substituted (`variable`) or tested (`conditional`). */
|
|
88
|
+
variableName?: string;
|
|
89
|
+
/** For `variable` segments: whether a supplied value or the default was used. */
|
|
90
|
+
valueSource?: "value" | "default";
|
|
57
91
|
}
|
|
58
92
|
/**
|
|
59
93
|
* Resolves templates in text while tracking character offset mapping
|
|
60
94
|
* between the raw input and the fully resolved output.
|
|
95
|
+
*
|
|
96
|
+
* Pass `options.values` to also substitute variables and evaluate conditional
|
|
97
|
+
* sections (see `resolvePrompt`); without it the output is unchanged from the
|
|
98
|
+
* template-only behavior.
|
|
61
99
|
*/
|
|
62
|
-
declare function resolveTemplatesWithMapping(text: string, templates?: Template[], templateBindings?: Record<string, string>, options?: Pick<ResolveTemplatesOptions, "maxDepth">): {
|
|
100
|
+
declare function resolveTemplatesWithMapping(text: string, templates?: Template[], templateBindings?: Record<string, string>, options?: Pick<ResolveTemplatesOptions, "maxDepth" | "values">): {
|
|
63
101
|
text: string;
|
|
64
102
|
map: SourceMapSegment[];
|
|
103
|
+
diagnostics: PromptDiagnostic[];
|
|
65
104
|
};
|
|
66
105
|
/**
|
|
67
106
|
* Maps an offset in resolved text back to the corresponding offset in raw text.
|
|
@@ -72,4 +111,185 @@ declare function mapResolvedOffsetToRaw(resolvedOffset: number, map: SourceMapSe
|
|
|
72
111
|
*/
|
|
73
112
|
declare function mapRawOffsetToResolved(rawOffset: number, map: SourceMapSegment[]): number;
|
|
74
113
|
|
|
75
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Finds the latest version of a template based on `latestVersion` or last version entry.
|
|
116
|
+
*/
|
|
117
|
+
declare function getLatestVersion(template: Template): TemplateVersion | undefined;
|
|
118
|
+
/** Marker substituted for a template tag that would recurse into itself. */
|
|
119
|
+
declare const TEMPLATE_LOOP_ERROR = "[Template loop detected]";
|
|
120
|
+
/** Marker substituted for a template tag nested deeper than `maxDepth`. */
|
|
121
|
+
declare const TEMPLATE_DEPTH_ERROR = "[Template max depth exceeded]";
|
|
122
|
+
/**
|
|
123
|
+
* Returns the body a template tag resolves to, honoring version bindings.
|
|
124
|
+
*/
|
|
125
|
+
declare function getTemplateBody(template: Template, bindings?: Record<string, string>): string | undefined;
|
|
126
|
+
interface ResolvePromptOptions {
|
|
127
|
+
/** Template version bindings (`{ templateName: versionIdOrVersion }`). */
|
|
128
|
+
bindings?: Record<string, string>;
|
|
129
|
+
/** Maximum template nesting depth (default 10). */
|
|
130
|
+
maxDepth?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Values for `{variable}` slots and `{?variable}` / `{!variable}` sections.
|
|
133
|
+
* When omitted, variables and section tags are left exactly as written.
|
|
134
|
+
*/
|
|
135
|
+
values?: PromptValues;
|
|
136
|
+
}
|
|
137
|
+
interface ResolvePromptResult {
|
|
138
|
+
text: string;
|
|
139
|
+
map: SourceMapSegment[];
|
|
140
|
+
diagnostics: PromptDiagnostic[];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Resolves a prompt: expands `{{templates}}` recursively (with loop and depth
|
|
144
|
+
* protection), and, when `values` are given, substitutes `{variables}` (falling
|
|
145
|
+
* back to their `|default`) and keeps or removes `{?name}…{/name}` sections.
|
|
146
|
+
*
|
|
147
|
+
* Template bodies are parsed on their own, so a section must open and close
|
|
148
|
+
* within the same body. Templates inside a removed section are never expanded
|
|
149
|
+
* and cannot trigger loop or depth errors. Unbalanced section tags are kept as
|
|
150
|
+
* literal text and reported in `diagnostics`.
|
|
151
|
+
*
|
|
152
|
+
* Returns the resolved text, a source map from resolved to raw offsets, and
|
|
153
|
+
* diagnostics. With no `values` the text matches the original template-only
|
|
154
|
+
* resolver exactly.
|
|
155
|
+
*/
|
|
156
|
+
declare function resolvePrompt(text: string, templates?: Template[], options?: ResolvePromptOptions): ResolvePromptResult;
|
|
157
|
+
/** A token annotated with the value it resolves to. */
|
|
158
|
+
interface EvaluatedToken extends Token {
|
|
159
|
+
/** Variables only, when values were given: the substituted text. */
|
|
160
|
+
resolvedValue?: string;
|
|
161
|
+
/** Variables only: whether `resolvedValue` came from `values` or the default. */
|
|
162
|
+
valueSource?: "value" | "default";
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Tokenizes a prompt for display. Without `values` this is `tokenizePrompt`.
|
|
166
|
+
* With `values`, sections whose condition fails are removed (tags included),
|
|
167
|
+
* the tags of kept sections are dropped, and each variable that has a value or
|
|
168
|
+
* a default carries it in `resolvedValue`. Templates are not expanded; resolve
|
|
169
|
+
* them first (without values) if the display should show their bodies.
|
|
170
|
+
*/
|
|
171
|
+
declare function evaluatePromptTokens(text: string, values?: PromptValues): EvaluatedToken[];
|
|
172
|
+
|
|
173
|
+
/** Result of classifying the text between the braces of a `{…}` token. */
|
|
174
|
+
type ParsedVariableBody = {
|
|
175
|
+
kind: "variable";
|
|
176
|
+
name: string;
|
|
177
|
+
defaultValue?: string;
|
|
178
|
+
description?: string;
|
|
179
|
+
} | {
|
|
180
|
+
kind: "conditional";
|
|
181
|
+
conditional: ConditionalKind;
|
|
182
|
+
name: string;
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* Removes grammar escapes: `\|`, `\{`, `\}` and `\\` become the bare character.
|
|
186
|
+
* Any other backslash is kept, so Windows paths and regex-like text survive.
|
|
187
|
+
*/
|
|
188
|
+
declare function unescapeVariableText(text: string): string;
|
|
189
|
+
/**
|
|
190
|
+
* Escapes text so it can be embedded as a variable default or description.
|
|
191
|
+
*/
|
|
192
|
+
declare function escapeVariableText(text: string): string;
|
|
193
|
+
/**
|
|
194
|
+
* Classifies the inner text of a `{…}` token.
|
|
195
|
+
*
|
|
196
|
+
* - `{?name}`, `{!name}`, `{/name}` are conditional section tags. The name may
|
|
197
|
+
* not contain `|`; otherwise the token is an ordinary variable.
|
|
198
|
+
* - `{name|default|description}` is a variable. Each part is trimmed and
|
|
199
|
+
* unescaped. A default is present whenever a `|` is (it may be empty), and
|
|
200
|
+
* anything after the second unescaped `|` belongs to the description.
|
|
201
|
+
*/
|
|
202
|
+
declare function parseVariableBody(inner: string): ParsedVariableBody;
|
|
203
|
+
/**
|
|
204
|
+
* Whether a supplied value counts as "set" for a `{?name}` condition:
|
|
205
|
+
* not `null`/`undefined`/`false`, and not blank once stringified.
|
|
206
|
+
*/
|
|
207
|
+
declare function isPromptValueSet(value: PromptValue): boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Returns the text a supplied value substitutes, or `undefined` when the
|
|
210
|
+
* variable should fall back to its default. An explicit empty string is a
|
|
211
|
+
* value (it renders as nothing); `null`/`undefined` are not.
|
|
212
|
+
*/
|
|
213
|
+
declare function getSuppliedValue(values: PromptValues, name: string): string | undefined;
|
|
214
|
+
/** Whether a section opened by `{?name}` / `{!name}` keeps its body. */
|
|
215
|
+
declare function evaluateCondition(conditional: Exclude<ConditionalKind, "end">, name: string, values: PromptValues): boolean;
|
|
216
|
+
interface ConditionalTagLike {
|
|
217
|
+
conditional: ConditionalKind;
|
|
218
|
+
name: string;
|
|
219
|
+
}
|
|
220
|
+
interface ConditionalTagMatch {
|
|
221
|
+
/** Index of the partner tag, or -1 when the tag is unbalanced. */
|
|
222
|
+
partner: number;
|
|
223
|
+
/** Set when unbalanced. */
|
|
224
|
+
error?: "unclosed-section" | "unexpected-close";
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Pairs conditional tags given in document order. A close tag pairs with the
|
|
228
|
+
* nearest open tag of the same name; open tags skipped over are reported as
|
|
229
|
+
* unclosed, and a close tag with no open partner as unexpected. Unbalanced tags
|
|
230
|
+
* never throw: callers treat them as literal text. The surviving pairs are
|
|
231
|
+
* always properly nested.
|
|
232
|
+
*/
|
|
233
|
+
declare function matchConditionalTags(tags: ConditionalTagLike[]): ConditionalTagMatch[];
|
|
234
|
+
|
|
235
|
+
/** Everything a prompt (and, optionally, its templates) says about one variable. */
|
|
236
|
+
interface VariableDescriptor {
|
|
237
|
+
name: string;
|
|
238
|
+
/** First `{name|default}` found. */
|
|
239
|
+
defaultValue?: string;
|
|
240
|
+
/** First `{name|default|description}` found. */
|
|
241
|
+
description?: string;
|
|
242
|
+
/** Appears as a `{name}` slot. */
|
|
243
|
+
usedAsValue: boolean;
|
|
244
|
+
/** Appears in a `{?name}` / `{!name}` condition. */
|
|
245
|
+
usedInCondition: boolean;
|
|
246
|
+
/** Number of `{name…}` slots and condition tags (closing tags excluded). */
|
|
247
|
+
occurrences: number;
|
|
248
|
+
/** Templates whose bodies mention the variable, in discovery order. */
|
|
249
|
+
templates: string[];
|
|
250
|
+
}
|
|
251
|
+
interface ExtractVariablesOptions {
|
|
252
|
+
/** Templates to search recursively for further variables. */
|
|
253
|
+
templates?: Template[];
|
|
254
|
+
bindings?: Record<string, string>;
|
|
255
|
+
/** Maximum template nesting depth to search (default 10). */
|
|
256
|
+
maxDepth?: number;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Lists every variable a prompt uses, in order of first appearance, with its
|
|
260
|
+
* default and description. Templates referenced by the prompt are searched
|
|
261
|
+
* recursively when `options.templates` is given (loops are skipped). All
|
|
262
|
+
* sections are searched, whatever their condition would evaluate to.
|
|
263
|
+
*/
|
|
264
|
+
declare function extractVariables(text: string, options?: ExtractVariablesOptions): VariableDescriptor[];
|
|
265
|
+
/** A headless description of one input in a variable fill-in form. */
|
|
266
|
+
interface VariableFormField {
|
|
267
|
+
name: string;
|
|
268
|
+
/** The variable's description, or its name. */
|
|
269
|
+
label: string;
|
|
270
|
+
/** The variable's default, or an empty string. */
|
|
271
|
+
placeholder: string;
|
|
272
|
+
defaultValue?: string;
|
|
273
|
+
description?: string;
|
|
274
|
+
/**
|
|
275
|
+
* The variable is used as a slot and has no default, so leaving it blank
|
|
276
|
+
* leaves the `{name}` placeholder in the resolved prompt.
|
|
277
|
+
*/
|
|
278
|
+
required: boolean;
|
|
279
|
+
/** Only used by `{?name}` / `{!name}` conditions, never substituted. */
|
|
280
|
+
conditionOnly: boolean;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Builds field descriptors for a fill-in form (Word's FILLIN analogue): one
|
|
284
|
+
* per variable, labelled with its description and using its default as the
|
|
285
|
+
* placeholder. Feed the entered text through `compactVariableValues` before
|
|
286
|
+
* resolving so blank inputs fall back to defaults.
|
|
287
|
+
*/
|
|
288
|
+
declare function getVariableFormFields(text: string, options?: ExtractVariablesOptions): VariableFormField[];
|
|
289
|
+
/**
|
|
290
|
+
* Drops blank entries from form input so the resolver falls back to each
|
|
291
|
+
* variable's default (an explicit `""` value would otherwise render as empty).
|
|
292
|
+
*/
|
|
293
|
+
declare function compactVariableValues(input: Record<string, string | null | undefined>): PromptValues;
|
|
294
|
+
|
|
295
|
+
export { ConditionalKind, type ConditionalTagLike, type ConditionalTagMatch, type EvaluatedToken, type ExtractVariablesOptions, type ParsedVariableBody, PromptDiagnostic, PromptValue, PromptValues, type ResolvePromptOptions, type ResolvePromptResult, type ResolveTemplatesOptions, type SourceMapSegment, TEMPLATE_DEPTH_ERROR, TEMPLATE_LOOP_ERROR, Template, TemplateVersion, Token, type TokenizeResult, type VariableDescriptor, type VariableFormField, compactVariableValues, escapeVariableText, evaluateCondition, evaluatePromptTokens, extractInstructionNames, extractTemplateNames, extractVariableNames, extractVariables, getLatestVersion, getPromptDiagnostics, getSuppliedValue, getTemplateBody, getVariableFormFields, isPromptValueSet, mapRawOffsetToResolved, mapResolvedOffsetToRaw, matchConditionalTags, parseVariableBody, resolvePrompt, resolveTemplates, resolveTemplatesWithMapping, resolveVariables, tokenizePrompt, tokenizePromptWithDiagnostics, unescapeVariableText };
|
package/dist/grammar/index.js
CHANGED
|
@@ -1,45 +1,73 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TEMPLATE_DEPTH_ERROR,
|
|
3
3
|
TEMPLATE_LOOP_ERROR,
|
|
4
|
+
compactVariableValues,
|
|
5
|
+
evaluatePromptTokens,
|
|
4
6
|
extractInstructionNames,
|
|
5
7
|
extractTemplateNames,
|
|
6
8
|
extractVariableNames,
|
|
9
|
+
extractVariables,
|
|
7
10
|
getLatestVersion,
|
|
11
|
+
getPromptDiagnostics,
|
|
8
12
|
getTemplateBody,
|
|
13
|
+
getVariableFormFields,
|
|
9
14
|
mapRawOffsetToResolved,
|
|
10
15
|
mapResolvedOffsetToRaw,
|
|
16
|
+
resolvePrompt,
|
|
11
17
|
resolveTemplates,
|
|
12
18
|
resolveTemplatesWithMapping,
|
|
13
19
|
resolveVariables,
|
|
14
|
-
tokenizePrompt
|
|
15
|
-
|
|
20
|
+
tokenizePrompt,
|
|
21
|
+
tokenizePromptWithDiagnostics
|
|
22
|
+
} from "../chunk-OYXSKQFR.js";
|
|
16
23
|
import {
|
|
17
24
|
INSTRUCTION_REGEX,
|
|
18
25
|
TEMPLATE_REGEX,
|
|
19
26
|
VARIABLE_REGEX,
|
|
27
|
+
escapeVariableText,
|
|
28
|
+
evaluateCondition,
|
|
29
|
+
getSuppliedValue,
|
|
20
30
|
instructionRegex,
|
|
31
|
+
isPromptValueSet,
|
|
32
|
+
matchConditionalTags,
|
|
33
|
+
parseVariableBody,
|
|
21
34
|
templateRegex,
|
|
35
|
+
unescapeVariableText,
|
|
22
36
|
variableRegex
|
|
23
|
-
} from "../chunk-
|
|
37
|
+
} from "../chunk-B2ZRLN4S.js";
|
|
24
38
|
export {
|
|
25
39
|
INSTRUCTION_REGEX,
|
|
26
40
|
TEMPLATE_DEPTH_ERROR,
|
|
27
41
|
TEMPLATE_LOOP_ERROR,
|
|
28
42
|
TEMPLATE_REGEX,
|
|
29
43
|
VARIABLE_REGEX,
|
|
44
|
+
compactVariableValues,
|
|
45
|
+
escapeVariableText,
|
|
46
|
+
evaluateCondition,
|
|
47
|
+
evaluatePromptTokens,
|
|
30
48
|
extractInstructionNames,
|
|
31
49
|
extractTemplateNames,
|
|
32
50
|
extractVariableNames,
|
|
51
|
+
extractVariables,
|
|
33
52
|
getLatestVersion,
|
|
53
|
+
getPromptDiagnostics,
|
|
54
|
+
getSuppliedValue,
|
|
34
55
|
getTemplateBody,
|
|
56
|
+
getVariableFormFields,
|
|
35
57
|
instructionRegex,
|
|
58
|
+
isPromptValueSet,
|
|
36
59
|
mapRawOffsetToResolved,
|
|
37
60
|
mapResolvedOffsetToRaw,
|
|
61
|
+
matchConditionalTags,
|
|
62
|
+
parseVariableBody,
|
|
63
|
+
resolvePrompt,
|
|
38
64
|
resolveTemplates,
|
|
39
65
|
resolveTemplatesWithMapping,
|
|
40
66
|
resolveVariables,
|
|
41
67
|
templateRegex,
|
|
42
68
|
tokenizePrompt,
|
|
69
|
+
tokenizePromptWithDiagnostics,
|
|
70
|
+
unescapeVariableText,
|
|
43
71
|
variableRegex
|
|
44
72
|
};
|
|
45
73
|
//# sourceMappingURL=index.js.map
|
package/dist/history/index.d.cts
CHANGED
|
@@ -1,43 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
execute: () => void;
|
|
3
|
-
undo: () => void;
|
|
4
|
-
redo?: () => void;
|
|
5
|
-
name: string;
|
|
6
|
-
tag?: string;
|
|
7
|
-
timestamp?: number;
|
|
8
|
-
}
|
|
9
|
-
interface HistoryState {
|
|
10
|
-
canUndo: boolean;
|
|
11
|
-
canRedo: boolean;
|
|
12
|
-
undoName: string;
|
|
13
|
-
redoName: string;
|
|
14
|
-
undoCount: number;
|
|
15
|
-
redoCount: number;
|
|
16
|
-
}
|
|
17
|
-
interface HistoryManagerOptions {
|
|
18
|
-
/**
|
|
19
|
-
* Maximum number of undo states to keep. Defaults to 50.
|
|
20
|
-
*/
|
|
21
|
-
maxDepth?: number;
|
|
22
|
-
/**
|
|
23
|
-
* Optional callback fired whenever the history state changes.
|
|
24
|
-
*/
|
|
25
|
-
onStateChange?: (state: HistoryState) => void;
|
|
26
|
-
}
|
|
27
|
-
interface SnapshotCommandOptions<T> {
|
|
28
|
-
name: string;
|
|
29
|
-
before: T;
|
|
30
|
-
after: T;
|
|
31
|
-
apply: (state: T) => void;
|
|
32
|
-
tag?: string;
|
|
33
|
-
}
|
|
34
|
-
interface MergedExecutionOptions {
|
|
35
|
-
/**
|
|
36
|
-
* Window in milliseconds during which commands with the same tag will be coalesced.
|
|
37
|
-
* Defaults to 300ms.
|
|
38
|
-
*/
|
|
39
|
-
windowMs?: number;
|
|
40
|
-
}
|
|
1
|
+
import { H as HistoryManagerOptions, a as HistoryState, C as Command, M as MergedExecutionOptions, S as SnapshotCommandOptions } from '../types-BZgcDsC5.cjs';
|
|
41
2
|
|
|
42
3
|
/**
|
|
43
4
|
* UI-agnostic History and Undo/Redo manager supporting command closures,
|
|
@@ -111,4 +72,4 @@ declare class HistoryManager {
|
|
|
111
72
|
*/
|
|
112
73
|
declare function createHistoryManager(options?: HistoryManagerOptions): HistoryManager;
|
|
113
74
|
|
|
114
|
-
export {
|
|
75
|
+
export { Command, HistoryManager, HistoryManagerOptions, HistoryState, MergedExecutionOptions, SnapshotCommandOptions, createHistoryManager };
|
package/dist/history/index.d.ts
CHANGED
|
@@ -1,43 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
execute: () => void;
|
|
3
|
-
undo: () => void;
|
|
4
|
-
redo?: () => void;
|
|
5
|
-
name: string;
|
|
6
|
-
tag?: string;
|
|
7
|
-
timestamp?: number;
|
|
8
|
-
}
|
|
9
|
-
interface HistoryState {
|
|
10
|
-
canUndo: boolean;
|
|
11
|
-
canRedo: boolean;
|
|
12
|
-
undoName: string;
|
|
13
|
-
redoName: string;
|
|
14
|
-
undoCount: number;
|
|
15
|
-
redoCount: number;
|
|
16
|
-
}
|
|
17
|
-
interface HistoryManagerOptions {
|
|
18
|
-
/**
|
|
19
|
-
* Maximum number of undo states to keep. Defaults to 50.
|
|
20
|
-
*/
|
|
21
|
-
maxDepth?: number;
|
|
22
|
-
/**
|
|
23
|
-
* Optional callback fired whenever the history state changes.
|
|
24
|
-
*/
|
|
25
|
-
onStateChange?: (state: HistoryState) => void;
|
|
26
|
-
}
|
|
27
|
-
interface SnapshotCommandOptions<T> {
|
|
28
|
-
name: string;
|
|
29
|
-
before: T;
|
|
30
|
-
after: T;
|
|
31
|
-
apply: (state: T) => void;
|
|
32
|
-
tag?: string;
|
|
33
|
-
}
|
|
34
|
-
interface MergedExecutionOptions {
|
|
35
|
-
/**
|
|
36
|
-
* Window in milliseconds during which commands with the same tag will be coalesced.
|
|
37
|
-
* Defaults to 300ms.
|
|
38
|
-
*/
|
|
39
|
-
windowMs?: number;
|
|
40
|
-
}
|
|
1
|
+
import { H as HistoryManagerOptions, a as HistoryState, C as Command, M as MergedExecutionOptions, S as SnapshotCommandOptions } from '../types-BZgcDsC5.js';
|
|
41
2
|
|
|
42
3
|
/**
|
|
43
4
|
* UI-agnostic History and Undo/Redo manager supporting command closures,
|
|
@@ -111,4 +72,4 @@ declare class HistoryManager {
|
|
|
111
72
|
*/
|
|
112
73
|
declare function createHistoryManager(options?: HistoryManagerOptions): HistoryManager;
|
|
113
74
|
|
|
114
|
-
export {
|
|
75
|
+
export { Command, HistoryManager, HistoryManagerOptions, HistoryState, MergedExecutionOptions, SnapshotCommandOptions, createHistoryManager };
|