face-up 0.0.0 → 0.0.2
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/.gitmodules +3 -0
- package/.kiro/steering/project-context.md +17 -0
- package/.vscode/settings.json +3 -0
- package/FaceUp.js +305 -0
- package/README.md +162 -2
- package/imports.html +8 -0
- package/package.json +30 -20
- package/tests/test1.html +115 -0
- package/types/.kiro/specs/conversion-template/README.md +128 -0
- package/types/.kiro/specs/conversion-template/design.md +360 -0
- package/types/.kiro/specs/conversion-template/requirements.md +191 -0
- package/types/.kiro/specs/conversion-template/tasks.md +174 -0
- package/types/.kiro/steering/coding-standards.md +17 -0
- package/types/.kiro/steering/conversion-guide.md +103 -0
- package/types/.kiro/steering/declarative-configuration.md +108 -0
- package/types/.kiro/steering/emc-json-serializability.md +306 -0
- package/types/EnhancementConversionInstructions.md +1626 -0
- package/types/LICENSE +21 -0
- package/types/NewCustomElementFeature.md +673 -0
- package/types/NewEnhancementInstructions.md +395 -0
- package/types/README.md +2 -0
- package/types/agrace/types.d.ts +11 -0
- package/types/assign-gingerly/types.d.ts +328 -0
- package/types/be-a-beacon/types.d.ts +17 -0
- package/types/be-bound/types.d.ts +61 -0
- package/types/be-buttoned-up/types.d.ts +19 -0
- package/types/be-clonable/types.d.ts +36 -0
- package/types/be-committed/types.d.ts +22 -0
- package/types/be-decked-with/types.d.ts +26 -0
- package/types/be-delible/types.d.ts +25 -0
- package/types/be-reflective/types.d.ts +80 -0
- package/types/be-render-neutral/types.d.ts +29 -0
- package/types/be-typed/types.d.ts +31 -0
- package/types/do-inc/types.d.ts +56 -0
- package/types/do-invoke/types.d.ts +38 -0
- package/types/do-merge/types.d.ts +28 -0
- package/types/do-toggle/types.d.ts +31 -0
- package/types/face-up/types.d.ts +104 -0
- package/types/global.d.ts +29 -0
- package/types/id-generation/types.d.ts +26 -0
- package/types/inferencer/types.d.ts +46 -0
- package/types/mount-observer/types.d.ts +363 -0
- package/types/nested-regex-groups/types.d.ts +101 -0
- package/types/roundabout/types.d.ts +255 -0
- package/types/time-ticker/types.d.ts +66 -0
- package/types/truth-sourcer/types.d.ts +46 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
// Core types for MountObserver v2 - Polyfill Supported Scenario I
|
|
2
|
+
|
|
3
|
+
import {EnhancementConfigBase, EnhKey, AttrPatterns} from '../assign-gingerly/types';
|
|
4
|
+
|
|
5
|
+
export type Constructor = new (...args: any[]) => any;
|
|
6
|
+
|
|
7
|
+
export type EventConstructor = {new(...args: any[]): Event};
|
|
8
|
+
|
|
9
|
+
export interface EventConfig {
|
|
10
|
+
event: string | EventConstructor;
|
|
11
|
+
args?: any | any[];
|
|
12
|
+
eventProps?: Record<string, any>;
|
|
13
|
+
oncePerMountedElement?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type DismountReason =
|
|
17
|
+
| 'media-query-failed'
|
|
18
|
+
| 'root-size-failed'
|
|
19
|
+
| 'intersection-failed'
|
|
20
|
+
| 'connection-failed'
|
|
21
|
+
| 'with-matching-failed';
|
|
22
|
+
|
|
23
|
+
export interface ConnectionCondition {
|
|
24
|
+
effectiveTypeIn?: string[];
|
|
25
|
+
downlinkMin?: number;
|
|
26
|
+
downlinkMax?: number;
|
|
27
|
+
rttMax?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Configuration for enhancing elements with class instances
|
|
32
|
+
* Defines how to spawn and initialize enhancement classes
|
|
33
|
+
*/
|
|
34
|
+
export interface EnhConfig<T = any, Obj = Element> extends EnhancementConfigBase<T, Obj> {
|
|
35
|
+
|
|
36
|
+
// bare import specifier path
|
|
37
|
+
spawn: string;
|
|
38
|
+
|
|
39
|
+
enhKey: EnhKey;
|
|
40
|
+
|
|
41
|
+
//Applicable to passing in the initVals during the spawn lifecycle event
|
|
42
|
+
withAttrs?: AttrPatterns<T>;
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Configuration object for MountObserver that defines what elements to observe and how to handle them.
|
|
52
|
+
* All `where*` properties form an AND condition - elements must satisfy ALL specified conditions to mount.
|
|
53
|
+
*
|
|
54
|
+
* @template TKeys - String literal type for sub-observer keys when using the `with` property
|
|
55
|
+
*/
|
|
56
|
+
export interface MountConfig<TKeys extends string = string, TCustomData = unknown> {
|
|
57
|
+
/**
|
|
58
|
+
* CSS selector string to match elements.
|
|
59
|
+
* Only elements matching this selector will be considered for mounting.
|
|
60
|
+
* @example 'button.fancy' or 'div > p.highlight'
|
|
61
|
+
*/
|
|
62
|
+
matching?: string;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Custom element tag name(s) that must be defined before mounting occurs.
|
|
66
|
+
* Waits for customElements.whenDefined() to resolve for each specified tag.
|
|
67
|
+
* Uses the customElementRegistry of the observed root node.
|
|
68
|
+
* This check happens first, before any other where* conditions.
|
|
69
|
+
* @example 'my-button' or ['my-button', 'my-input']
|
|
70
|
+
*/
|
|
71
|
+
whenDefined?: string | string[];
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Constructor or array of constructors to filter elements by instance type.
|
|
75
|
+
* Elements must be instances of at least one of the specified constructors (OR logic for arrays).
|
|
76
|
+
* @example HTMLButtonElement or [HTMLInputElement, HTMLTextAreaElement]
|
|
77
|
+
*/
|
|
78
|
+
whereInstanceOf?: Constructor | Constructor[];
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Media query string or MediaQueryList for conditional mounting based on viewport/media conditions.
|
|
82
|
+
* Elements only mount when the media query matches.
|
|
83
|
+
* @example '(min-width: 768px)' or '(prefers-color-scheme: dark)'
|
|
84
|
+
*/
|
|
85
|
+
withMediaMatching?: string | MediaQueryList;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* CSS selector defining a "donut hole" scope perimeter.
|
|
89
|
+
* Excludes elements that are descendants of elements matching this selector.
|
|
90
|
+
* Useful for preventing observation of nested scopes.
|
|
91
|
+
* @example '.no-observe' to exclude elements inside .no-observe containers
|
|
92
|
+
*/
|
|
93
|
+
withScopePerimeter?: string;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Container query string for conditional mounting based on observed root element size.
|
|
97
|
+
* Elements only mount when the root node matches this size condition.
|
|
98
|
+
* @example '(min-width: 500px)' to only mount when root is at least 500px wide
|
|
99
|
+
*/
|
|
100
|
+
whereObservedRootSizeMatches?: string;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* IntersectionObserver configuration for conditional mounting based on element visibility.
|
|
104
|
+
* Elements only mount when they intersect with the viewport according to these options.
|
|
105
|
+
* @example { rootMargin: '50px', threshold: 0.5 }
|
|
106
|
+
*/
|
|
107
|
+
whereElementIntersectsWith?: IntersectionObserverInit;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Network connection conditions for conditional mounting.
|
|
111
|
+
* Elements only mount when network conditions match the specified criteria.
|
|
112
|
+
* Useful for adaptive loading based on connection quality.
|
|
113
|
+
*/
|
|
114
|
+
whereConnectionHas?: ConnectionCondition;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* When true, inverts the default registry matching behavior.
|
|
118
|
+
* Default (false): Only mount elements with the SAME customElementRegistry as the root node.
|
|
119
|
+
* When true: Only mount elements with a DIFFERENT customElementRegistry than the root node.
|
|
120
|
+
* Useful for cross-registry observation scenarios.
|
|
121
|
+
* @example true to observe elements from other shadow DOM scopes
|
|
122
|
+
*/
|
|
123
|
+
whereDifferentCustomElementRegistry?: boolean;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Regular expression or string pattern to match against element's localName.
|
|
127
|
+
* Only elements whose localName matches this pattern will mount.
|
|
128
|
+
* String values are converted to RegExp.
|
|
129
|
+
* @example /^my-/ to match elements starting with 'my-'
|
|
130
|
+
* @example 'button|input' to match button or input elements
|
|
131
|
+
*/
|
|
132
|
+
whereLocalNameMatches?: string | RegExp;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Module(s) to import before mounting elements.
|
|
136
|
+
* Can be a URL string, ImportSpec object, or array of either.
|
|
137
|
+
* Modules are loaded based on loadingEagerness setting.
|
|
138
|
+
* @example './my-component.js' or [{ url: './styles.css', type: 'css' }]
|
|
139
|
+
*/
|
|
140
|
+
import?: string | ImportSpec | Array<string | ImportSpec>;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Handler(s) to execute when elements mount.
|
|
144
|
+
* Can be:
|
|
145
|
+
* - String: Name of a registered handler (e.g., 'builtIns.defineCustomElement')
|
|
146
|
+
* - Function: Inline callback function
|
|
147
|
+
* - Array: Multiple handlers to execute in order
|
|
148
|
+
* @example 'builtIns.defineCustomElement' or (el, ctx) => { el.classList.add('mounted') }
|
|
149
|
+
*/
|
|
150
|
+
do?: string | DoCallback | (string | DoCallback)[];
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Custom JavaScript check that runs after all declarative where* conditions pass.
|
|
154
|
+
* This is the final gate before mounting occurs.
|
|
155
|
+
*
|
|
156
|
+
* If shouldMount returns false, the element is not mounted (no do callback, no mount event).
|
|
157
|
+
* If shouldMount throws an error, it is treated as returning false and the error is logged.
|
|
158
|
+
*
|
|
159
|
+
* @example (el) => currentUser.hasRole('admin')
|
|
160
|
+
* @example (el) => el.dataset.apiKey && el.dataset.apiEndpoint
|
|
161
|
+
*/
|
|
162
|
+
shouldMount?: ShouldMountCallback;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Controls when imports are loaded.
|
|
166
|
+
* - 'eager': Load imports immediately when MountObserver is created
|
|
167
|
+
* - 'lazy': Load imports only when first matching element is found (default)
|
|
168
|
+
*/
|
|
169
|
+
loadingEagerness?: 'eager' | 'lazy';
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Properties to assign to elements when they mount.
|
|
173
|
+
* Uses assign-gingerly for safe property assignment.
|
|
174
|
+
* @example { disabled: false, tabIndex: 0 }
|
|
175
|
+
*/
|
|
176
|
+
assignOnMount?: Record<string, any>;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Properties to assign to elements when they dismount.
|
|
180
|
+
* Uses assign-gingerly for safe property assignment.
|
|
181
|
+
* @example { disabled: true }
|
|
182
|
+
*/
|
|
183
|
+
assignOnDismount?: Record<string, any>;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Properties to tentatively assign on mount with automatic reversal on dismount.
|
|
187
|
+
* Original values are saved and restored when element dismounts.
|
|
188
|
+
* @example { hidden: false } - will restore original hidden value on dismount
|
|
189
|
+
*/
|
|
190
|
+
stageOnMount?: Record<string, any>;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* When true, enables detailed event dispatching for debugging and monitoring.
|
|
194
|
+
* Provides granular lifecycle events for observation.
|
|
195
|
+
*/
|
|
196
|
+
getPlayByPlay?: boolean;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Event(s) to emit from mounted elements.
|
|
200
|
+
* Can be a single EventConfig or array of EventConfigs.
|
|
201
|
+
* Allows elements to dispatch custom events when mounted.
|
|
202
|
+
* @example { event: 'ready', args: { detail: 'mounted' } }
|
|
203
|
+
*/
|
|
204
|
+
mountedElemEmits?: EventConfig | EventConfig[];
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* External module(s) to import MountConfig from.
|
|
208
|
+
* Allows separating JSON-serializable config from non-serializable handlers.
|
|
209
|
+
* Loaded configs are merged left-to-right, with inline config taking final precedence.
|
|
210
|
+
* @example './config.js' or ['./base-config.js', './override-config.js']
|
|
211
|
+
*/
|
|
212
|
+
configFrom?: string | string[];
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Custom data to pass to handler classes or functions.
|
|
216
|
+
* Allows handlers to receive additional context-specific information.
|
|
217
|
+
* Not used by MountObserver itself, but available in MountContext.
|
|
218
|
+
*/
|
|
219
|
+
customData?: TCustomData;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Sub-observer configurations for hierarchical composition.
|
|
223
|
+
* Each key-value pair defines a sub-observer that will observe the same root node as the parent.
|
|
224
|
+
* Sub-observers are created when the parent's observe() method is called and automatically
|
|
225
|
+
* disconnected when the parent disconnects.
|
|
226
|
+
*
|
|
227
|
+
* Sub-observers operate independently with their own configurations and do not inherit
|
|
228
|
+
* properties from the parent observer. Each sub-observer can have its own `with` property
|
|
229
|
+
* for unlimited nesting depth.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* const observer = new MountObserver({
|
|
234
|
+
* matching: '.parent',
|
|
235
|
+
* with: {
|
|
236
|
+
* registry: { matching: 'my-element', do: 'builtIns.defineCustomElement' },
|
|
237
|
+
* styles: { import: './styles.css' }
|
|
238
|
+
* }
|
|
239
|
+
* });
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
with?: {[K in TKeys]: MountConfig};
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export interface EMC<
|
|
248
|
+
TKeys extends string = string,
|
|
249
|
+
T = unknown, Obj = Element, TCustomData = unknown
|
|
250
|
+
> extends MountConfig<TKeys, TCustomData>{
|
|
251
|
+
enhConfig: EnhConfig<T, Obj>
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
export interface ImportSpec {
|
|
257
|
+
url: string;
|
|
258
|
+
type?: 'js' | 'css' | 'json' | 'html';
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Context object passed to mount handlers containing information about the mounted element and observer state.
|
|
263
|
+
*
|
|
264
|
+
* @template TKeys - String literal type for sub-observer keys when using the `with` property
|
|
265
|
+
*/
|
|
266
|
+
export interface MountContext<TKeys extends string = string> {
|
|
267
|
+
modules: any[];
|
|
268
|
+
observer: IMountObserver;
|
|
269
|
+
rootNode: Node;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* The configuration object for this observer.
|
|
273
|
+
* Contains all the settings that define what elements to observe and how to handle them.
|
|
274
|
+
*/
|
|
275
|
+
mountConfig: MountConfig<TKeys>;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Map of sub-observers created from the `with` property in mountConfig.
|
|
279
|
+
* Only present when the parent observer has sub-observers defined.
|
|
280
|
+
* Keys match the keys from the `with` property, providing type-safe access to sub-observers.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```typescript
|
|
284
|
+
* do: (el, ctx) => {
|
|
285
|
+
* // Access sub-observers with type safety
|
|
286
|
+
* const registryObserver = ctx.withObservers?.registry;
|
|
287
|
+
* if (registryObserver) {
|
|
288
|
+
* console.log('Registry observer:', registryObserver);
|
|
289
|
+
* }
|
|
290
|
+
* }
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
withObservers?: {[K in TKeys]: IMountObserver};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
export type DoCallback<TKeys extends string = string> = (mountedElement: Element, context: MountContext<TKeys>) => void;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Callback function that performs a final check before mounting an element.
|
|
302
|
+
* Called after all declarative where* conditions have passed.
|
|
303
|
+
*
|
|
304
|
+
* @param mountedElement - The element being considered for mounting
|
|
305
|
+
* @param context - The mount context containing modules, observer, config, etc.
|
|
306
|
+
* @returns true to allow mounting, false to prevent it
|
|
307
|
+
*/
|
|
308
|
+
export type ShouldMountCallback<TKeys extends string = string> = (mountedElement: Element, context: MountContext<TKeys>) => boolean;
|
|
309
|
+
|
|
310
|
+
// export interface DoCallbacks {
|
|
311
|
+
// mount?: (mountedElement: Element, context: MountContext) => void;
|
|
312
|
+
// dismount?: (mountedElement: Element, context: MountContext) => void;
|
|
313
|
+
// disconnect?: (mountedElement: Element, context: MountContext) => void;
|
|
314
|
+
// reconnect?: (mountedElement: Element, context: MountContext) => void;
|
|
315
|
+
// }
|
|
316
|
+
|
|
317
|
+
export type MountScope =
|
|
318
|
+
| 'registry' // Observe all scopes with matching registry (new default)
|
|
319
|
+
| 'registryRoot' // getRegistryRoot - finds highest node with matching customElementRegistry
|
|
320
|
+
| 'self' // this element
|
|
321
|
+
| 'root' // getRootNode()
|
|
322
|
+
| 'shadow' // shadowRoot (throws if none)
|
|
323
|
+
| Element; // custom element to observe
|
|
324
|
+
|
|
325
|
+
export interface MountObserverOptions {
|
|
326
|
+
disconnectedSignal?: AbortSignal;
|
|
327
|
+
scope?: MountScope;
|
|
328
|
+
mose?: WeakRef<HTMLScriptElement>;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export interface WeakDual<T extends Object>{
|
|
332
|
+
weakSet: WeakSet<T>,
|
|
333
|
+
setWeak: Set<WeakRef<T>>
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export interface WeakMapDual<T extends Object, R extends Object>{
|
|
337
|
+
weakMap: WeakMap<T, R>,
|
|
338
|
+
setWeak: Set<WeakRef<T>>
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export interface IMountObserver extends EventTarget {
|
|
342
|
+
observe(observedNode: Node): Promise<void>;
|
|
343
|
+
disconnect(): void;
|
|
344
|
+
disconnectedSignal: AbortSignal;
|
|
345
|
+
assignGingerly(config: Record<string, any> | undefined): Promise<void>;
|
|
346
|
+
getNotifier(element: Element): EventTarget;
|
|
347
|
+
readonly options: MountObserverOptions;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
export interface IMountEvent extends Event {
|
|
351
|
+
mountedElement: Element;
|
|
352
|
+
modules: any[];
|
|
353
|
+
mountConfig: MountConfig;
|
|
354
|
+
mountContext: MountContext;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export interface IDismountEvent extends Event {
|
|
358
|
+
mountedElement: Element;
|
|
359
|
+
reason: DismountReason;
|
|
360
|
+
mountConfig: MountConfig;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for nested-regex-groups
|
|
3
|
+
*
|
|
4
|
+
* These types can be imported in JavaScript files using JSDoc:
|
|
5
|
+
* @example
|
|
6
|
+
* // In JavaScript:
|
|
7
|
+
* /** @type {import('nested-regex-groups').ParseResult} *\/
|
|
8
|
+
* const result = parser('input');
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Result of a successful parse operation
|
|
13
|
+
*/
|
|
14
|
+
export interface ParseSuccess<T = any> {
|
|
15
|
+
success: true;
|
|
16
|
+
value: T;
|
|
17
|
+
matched: string;
|
|
18
|
+
rest: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Result of a failed parse operation
|
|
23
|
+
*/
|
|
24
|
+
export interface ParseFailure {
|
|
25
|
+
success: false;
|
|
26
|
+
error: string;
|
|
27
|
+
position?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Union type for parse results
|
|
32
|
+
*/
|
|
33
|
+
export type ParseResult<T = any> = ParseSuccess<T> | ParseFailure;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A pattern definition with metadata (internal use with compiled RegExp)
|
|
37
|
+
*/
|
|
38
|
+
export interface ParsePattern {
|
|
39
|
+
name: string;
|
|
40
|
+
regex: RegExp;
|
|
41
|
+
description?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Optional mapping from regex group names to dot-notation paths
|
|
44
|
+
* Example: { user_name: 'user.name', user_domain: 'user.domain' }
|
|
45
|
+
*/
|
|
46
|
+
groupMap?: Record<string, string>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Pattern configuration for parsePatterns and parsePattern functions
|
|
51
|
+
* Used when loading patterns from JSON or defining patterns as strings
|
|
52
|
+
*/
|
|
53
|
+
export interface PatternConfig {
|
|
54
|
+
name: string;
|
|
55
|
+
pattern: string;
|
|
56
|
+
description?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Default values to merge into the parsed result
|
|
59
|
+
* Keys can use dot notation for nested values
|
|
60
|
+
* Example: { trigger: 'on', 'lhs.id': '#lhs' }
|
|
61
|
+
*/
|
|
62
|
+
defaultVals?: Record<string, string>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Options for nestedRegex function
|
|
67
|
+
*/
|
|
68
|
+
export interface NestedRegexOptions {
|
|
69
|
+
/**
|
|
70
|
+
* Optional name for the pattern (used in error messages)
|
|
71
|
+
*/
|
|
72
|
+
name?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Optional mapping from regex group names to dot-notation paths
|
|
75
|
+
* Example: { user_name: 'user.name', user_domain: 'user.domain' }
|
|
76
|
+
*/
|
|
77
|
+
groupMap?: Record<string, string>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Options for creating a parser
|
|
82
|
+
*/
|
|
83
|
+
export interface ParserOptions {
|
|
84
|
+
/**
|
|
85
|
+
* If true, returns detailed error information when no pattern matches
|
|
86
|
+
*/
|
|
87
|
+
verbose?: boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Result type for parsing multiple statements
|
|
92
|
+
*/
|
|
93
|
+
export interface StatementsResult<T = any> {
|
|
94
|
+
success: boolean;
|
|
95
|
+
statements: Array<{
|
|
96
|
+
pattern?: string;
|
|
97
|
+
value?: T;
|
|
98
|
+
error?: string;
|
|
99
|
+
matched?: string;
|
|
100
|
+
}>;
|
|
101
|
+
}
|