@rohal12/spindle 0.61.7 → 0.62.1

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.
@@ -120,7 +120,7 @@ export interface VariableSchema extends FieldSchema {
120
120
  * Parse the content of a `StoryVariables` (`$name = value`) or
121
121
  * `StoryTransients` (`%name = value`, pass `sigil: '%'`) passage into a
122
122
  * schema map, exactly as Spindle does at boot.
123
- * Throws on invalid declarations or unsupported value types (e.g. `null`).
123
+ * Throws on invalid declarations or unsupported value types (e.g. `undefined`).
124
124
  */
125
125
  export declare function parseStoryVariables(
126
126
  content: string,
@@ -534,10 +534,12 @@ export declare function splitTopLevel(
534
534
  * Read the `"…"` or `'…'` string whose opening quote is at `start`: its
535
535
  * unescaped value (`\"`, `\'` and `\\` only) and the index just past it, or
536
536
  * `null` if there is none or it is unterminated.
537
+ * With `tolerant`, an unterminated string instead extends to its scanned end.
537
538
  */
538
539
  export declare function readQuoted(
539
540
  src: string,
540
541
  start: number,
542
+ tolerant?: boolean,
541
543
  ): { value: string; end: number } | null;
542
544
 
543
545
  /** Undo `\"`, `\'` and `\\` in the body of a quoted macro argument. */
@@ -653,6 +655,8 @@ export interface ToolingMacro {
653
655
  name: string;
654
656
  block: boolean;
655
657
  subMacros: string[];
658
+ /** A widget's parameters and their argument contracts. */
659
+ widget?: Pick<WidgetDef, 'params' | 'holds'>;
656
660
  /**
657
661
  * Its declared parameters: their types tell which arguments are code, and
658
662
  * what a `string` or `text` argument holds (see `ParameterDef.holds`).
@@ -777,6 +781,8 @@ export interface WidgetDef {
777
781
  name: string;
778
782
  /** The `@` parameters. */
779
783
  params: string[];
784
+ holds?: Record<string, StringHolds>;
785
+ badHolds?: { param: string; written: string }[];
780
786
  }
781
787
 
782
788
  /**
@@ -1186,3 +1192,52 @@ export declare function formatPassage(
1186
1192
  body: string,
1187
1193
  options?: PassageFormatOptions,
1188
1194
  ): Promise<string>;
1195
+
1196
+ /** The runtime's selected closed widgets, preserving input object identities.
1197
+ * Tagged passages register before StoryInit; later names replace earlier ones
1198
+ * case-insensitively. Map definitions to documents before calling this function.
1199
+ */
1200
+ export declare function effectiveWidgetDefinitions(
1201
+ definitions: readonly WidgetDefinition[],
1202
+ ): WidgetDefinition[];
1203
+
1204
+ /** One executable sigil reference, with UTF-16 offsets into the code. */
1205
+ export interface VariableRef {
1206
+ sigil: Sigil;
1207
+ name: string;
1208
+ start: number;
1209
+ end: number;
1210
+ shorthand: boolean;
1211
+ read: boolean;
1212
+ write: boolean;
1213
+ }
1214
+
1215
+ export interface ParsedCode {
1216
+ refs: VariableRef[];
1217
+ strings: string[];
1218
+ }
1219
+
1220
+ /** Parse executable code using the runtime grammar. Throws for malformed code
1221
+ * (including sigil declarations); lexJs remains available for tolerant scanning.
1222
+ * Member assignments read their root binding; only direct targets write it.
1223
+ */
1224
+ export declare function parseCode(src: string, goal?: JsGoal): ParsedCode;
1225
+
1226
+ /** A consumed argument and its original parameter (including option keywords). */
1227
+ export interface MacroArgumentSpan {
1228
+ parameter: ParameterDef;
1229
+ parameterIndex: number;
1230
+ parameterPath: number[];
1231
+ start: number;
1232
+ end: number;
1233
+ }
1234
+
1235
+ /** Runtime argument grouping, tolerant of missing/unclosed strings. UTF-16
1236
+ * offsets include quotes, flags, separators and option keywords. Absent
1237
+ * arguments have no span. Options also have an enclosing parameter span.
1238
+ * No expressions are evaluated; parameter object identities are preserved.
1239
+ */
1240
+ export declare function macroArgumentSpans(
1241
+ rawArgs: string,
1242
+ parameters: readonly ParameterDef[],
1243
+ ): MacroArgumentSpan[];