assign-gingerly 0.0.53 → 0.0.55

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.
Files changed (114) hide show
  1. package/README.md +847 -5
  2. package/assignFrom.js +229 -9
  3. package/assignFrom.ts +338 -9
  4. package/assignGingerly.js +34 -1
  5. package/assignGingerly.ts +54 -1
  6. package/beVigilant.js +73 -0
  7. package/beVigilant.ts +85 -0
  8. package/enhanceAll.js +106 -0
  9. package/enhanceAll.ts +138 -0
  10. package/handlers/join.js +74 -0
  11. package/handlers/join.ts +80 -0
  12. package/handlers/lazyLoad.js +212 -0
  13. package/handlers/lazyLoad.ts +307 -0
  14. package/handlers/lazyLoadSwitch.js +58 -0
  15. package/handlers/lazyLoadSwitch.ts +63 -0
  16. package/handlers/microDataJoin.js +184 -0
  17. package/handlers/microDataJoin.ts +270 -0
  18. package/inferencer/.gitmodules +3 -0
  19. package/inferencer/.vscode/settings.json +2 -0
  20. package/inferencer/InferencedPropagator.js +230 -0
  21. package/inferencer/InferencedPropagator.ts +269 -0
  22. package/inferencer/LICENSE +21 -0
  23. package/inferencer/README.md +524 -0
  24. package/inferencer/Requirements/SupportForPropagator.md +368 -0
  25. package/inferencer/imports.html +7 -0
  26. package/inferencer/inferencer.js +254 -0
  27. package/inferencer/inferencer.ts +292 -0
  28. package/inferencer/package-lock.json +129 -0
  29. package/inferencer/package.json +60 -0
  30. package/inferencer/playwright-report/data/507ad515125e13390ea07de92f22331c913fa068.md +55 -0
  31. package/inferencer/playwright-report/index.html +90 -0
  32. package/inferencer/playwright.config.ts +54 -0
  33. package/inferencer/test-results/.last-run.json +6 -0
  34. package/inferencer/test-results/inferencer-Inferencer-Enha-535bc-inferencer-tests-in-browser-chromium/error-context.md +55 -0
  35. package/inferencer/tests/inferencedPropagator.html +428 -0
  36. package/inferencer/tests/inferencedPropagator.spec.ts +18 -0
  37. package/inferencer/tests/inferencer.html +355 -0
  38. package/inferencer/tests/inferencer.spec.ts +19 -0
  39. package/inferencer/tsconfig.json +19 -0
  40. package/inferencer/types/.kiro/specs/conversion-template/README.md +128 -0
  41. package/inferencer/types/.kiro/specs/conversion-template/design.md +360 -0
  42. package/inferencer/types/.kiro/specs/conversion-template/requirements.md +191 -0
  43. package/inferencer/types/.kiro/specs/conversion-template/tasks.md +174 -0
  44. package/inferencer/types/.kiro/steering/coding-standards.md +53 -0
  45. package/inferencer/types/.kiro/steering/conversion-guide.md +108 -0
  46. package/inferencer/types/.kiro/steering/declarative-configuration.md +108 -0
  47. package/inferencer/types/.kiro/steering/emc-json-serializability.md +306 -0
  48. package/inferencer/types/EnhancementConversionInstructions.md +1854 -0
  49. package/inferencer/types/LICENSE +21 -0
  50. package/inferencer/types/NewCustomElement.md +388 -0
  51. package/inferencer/types/NewCustomElementFeature.md +683 -0
  52. package/inferencer/types/NewEnhancementInstructions.md +705 -0
  53. package/inferencer/types/README.md +2 -0
  54. package/inferencer/types/agrace/types.d.ts +11 -0
  55. package/inferencer/types/assign-gingerly/types.d.ts +572 -0
  56. package/inferencer/types/be-a-beacon/types.d.ts +17 -0
  57. package/inferencer/types/be-bound/types.d.ts +66 -0
  58. package/inferencer/types/be-buttoned-up/types.d.ts +19 -0
  59. package/inferencer/types/be-calculating/types.d.ts +54 -0
  60. package/inferencer/types/be-clonable/types.d.ts +38 -0
  61. package/inferencer/types/be-committed/types.d.ts +22 -0
  62. package/inferencer/types/be-consoling/types.d.ts +24 -0
  63. package/inferencer/types/be-decked-with/types.d.ts +26 -0
  64. package/inferencer/types/be-delible/types.d.ts +27 -0
  65. package/inferencer/types/be-dispatching/types.d.ts +34 -0
  66. package/inferencer/types/be-evanescent/types.d.ts +20 -0
  67. package/inferencer/types/be-flashy/types.d.ts +21 -0
  68. package/inferencer/types/be-gone/types.d.ts +25 -0
  69. package/inferencer/types/be-observing/types.d.ts +55 -0
  70. package/inferencer/types/be-reflective/types.d.ts +78 -0
  71. package/inferencer/types/be-reformable/types.d.ts +49 -0
  72. package/inferencer/types/be-render-neutral/types.d.ts +32 -0
  73. package/inferencer/types/be-switched/types.d.ts +146 -0
  74. package/inferencer/types/be-typed/types.d.ts +32 -0
  75. package/inferencer/types/be-valued/types.d.ts +22 -0
  76. package/inferencer/types/data-props/types.d.ts +34 -0
  77. package/inferencer/types/do-inc/types.d.ts +56 -0
  78. package/inferencer/types/do-invoke/types.d.ts +38 -0
  79. package/inferencer/types/do-merge/types.d.ts +28 -0
  80. package/inferencer/types/do-toggle/types.d.ts +31 -0
  81. package/inferencer/types/face-up/types.d.ts +100 -0
  82. package/inferencer/types/fetch-for/types.d.ts +36 -0
  83. package/inferencer/types/folder-picker/types.d.ts +21 -0
  84. package/inferencer/types/global.d.ts +29 -0
  85. package/inferencer/types/id-generation/types.d.ts +26 -0
  86. package/inferencer/types/inferencer/types.d.ts +46 -0
  87. package/inferencer/types/mount-observer/types.d.ts +363 -0
  88. package/inferencer/types/nested-regex-groups/types.d.ts +107 -0
  89. package/inferencer/types/pipe-in/types.d.ts +52 -0
  90. package/inferencer/types/roundabout/types.d.ts +268 -0
  91. package/inferencer/types/soak-up/types.d.ts +40 -0
  92. package/inferencer/types/templ-maker/types.d.ts +43 -0
  93. package/inferencer/types/time-ticker/types.d.ts +62 -0
  94. package/inferencer/types/truth-sourcer/types.d.ts +44 -0
  95. package/inferencer/upSearch.js +27 -0
  96. package/inferencer/upSearch.ts +26 -0
  97. package/inferencer/withScopePerimeter.js +27 -0
  98. package/inferencer/withScopePerimeter.ts +33 -0
  99. package/inferredAssignments.js +38 -0
  100. package/inferredAssignments.ts +65 -0
  101. package/isAllowedImportPath.js +42 -0
  102. package/isAllowedImportPath.ts +53 -0
  103. package/package.json +57 -3
  104. package/paths.js +231 -0
  105. package/paths.ts +413 -0
  106. package/processHandlerCommands.js +188 -0
  107. package/processHandlerCommands.ts +217 -0
  108. package/resolveIdRef.js +144 -0
  109. package/resolveIdRef.ts +170 -0
  110. package/resolveValues.js +41 -2
  111. package/resolveValues.ts +41 -1
  112. package/transitionHelper.js +109 -0
  113. package/transitionHelper.ts +132 -0
  114. package/types/assign-gingerly/types.d.ts +89 -0
@@ -0,0 +1,11 @@
1
+ import {RAConfig} from '../roundabout/types';
2
+ import {AttrPatterns} from '../assign-gingerly/types';
3
+
4
+ /**
5
+ * Assign Gingerly Roundabout Config
6
+ */
7
+ export interface AgraceConfig<TProps = unknown, TActions = TProps, ETProps = TProps, TCustomData = unknown> {
8
+ raConfig: RAConfig<TProps, TActions, ETProps, TCustomData>,
9
+ withAttrs?: AttrPatterns<TProps>,
10
+ template?: string | HTMLTemplateElement,
11
+ }
@@ -0,0 +1,572 @@
1
+ export type EnhKey = string | symbol;
2
+
3
+ // type NoUnderscore<T extends string> = T extends `_${string}` ? never : T;
4
+
5
+ // type YesUnderscore = `_${string}`;
6
+
7
+ // export type StringWithAutocompleteOptions<TOptions> =
8
+ // | (string & {})
9
+ // | TOptions;
10
+
11
+ // export type StringNotStartWithUnderscoreAutocompleteOptions<TOptions> =
12
+ // | (NoUnderscore<string> & {})
13
+ // | TOptions;
14
+
15
+ // export type StringStartWithUnderscoreAutocompleteOptions<TOptions> =
16
+ // | (YesUnderscore & {})
17
+ // | TOptions;
18
+
19
+ //used by mount-observer, not by assign-gingerly
20
+ type DisposeEvent =
21
+ | 'disconnect'
22
+ | 'dismount'
23
+ // cannot polyfill
24
+ | 'exit' // element moved outside customElementRegistry
25
+ //reference count outside any enhancements goes to zero
26
+ | 'dispose'
27
+
28
+ export type Spawner<T = any, Obj = Element> = {
29
+ new (obj?: Obj, ctx?: SpawnContext<T>, initVals?: Partial<T>): T;
30
+ canSpawn?: (obj: any, ctx?: SpawnContext<T>) => boolean;
31
+ }
32
+
33
+ export interface EnhancementConfigBase<T = any> {
34
+ //Allow unprefixed attributes for custom elements and SVG when element tag name matches pattern
35
+ allowUnprefixed?: string | RegExp;
36
+
37
+ //keys of type symbol are used for dependency injection
38
+ //and are used by assign-gingerly
39
+ symlinks?: { [key: symbol]: keyof T };
40
+
41
+ lifecycleKeys?:
42
+ | true // Use standard names: "dispose" method, "resolved" property/event
43
+ | {
44
+ dispose?: string | symbol,
45
+ resolved?: string | symbol
46
+ }
47
+ //used by mount-observer, not by assign-gingerly
48
+ //impossible to polyfill, but will always be disposed
49
+ //when oElement's reference count goes to zero
50
+ disposeOn?: DisposeEvent | DisposeEvent[]
51
+ }
52
+
53
+ /**
54
+ * Configuration for enhancing elements with class instances
55
+ * Defines how to spawn and initialize enhancement classes
56
+ */
57
+ export interface EnhancementConfig<T = any, Obj = Element> extends EnhancementConfigBase<T> {
58
+
59
+ spawn: Spawner<T, Obj>;
60
+
61
+ //Applicable to passing in the initVals during the spawn lifecycle event
62
+ withAttrs?: AttrPatterns<T>;
63
+
64
+
65
+ //only applicable when spawning from a DOM Element reference
66
+ enhKey?: EnhKey;
67
+
68
+ /**
69
+ * Optional features to associate with the spawn class.
70
+ * Calls assignFeatures(spawn, features) automatically on registration.
71
+ */
72
+ features?: FeatureConfigsMap;
73
+
74
+ }
75
+
76
+ export type Constructor = new (...args: any[]) => any;
77
+
78
+ export type pathString = `?.${string}`;
79
+
80
+ export type CustomElementName = string;
81
+ export type CustomElementConstructorStaticMethodName = string;
82
+
83
+ /**
84
+ * Context passed to parser functions
85
+ * Provides access to configuration and spawn context for advanced parsing scenarios
86
+ */
87
+ export interface ParserContext<T = any> {
88
+ /**
89
+ * The attribute configuration that matched this attribute
90
+ * Useful for parsers that need to access additional config properties
91
+ */
92
+ attrConfig: AttrConfig<T>;
93
+
94
+ /**
95
+ * The spawn context containing enhancement config and synthesizer element
96
+ * Useful for parsers that need access to the enhancement or synthesizer context
97
+ */
98
+ spawnContext?: SpawnContext<T>;
99
+
100
+ /**
101
+ * The element being enhanced
102
+ * Useful for parsers that need to read other attributes or element properties
103
+ */
104
+ element: Element;
105
+
106
+ /**
107
+ * The attribute name that was matched (resolved from template)
108
+ * Useful for parsers that handle multiple attributes
109
+ */
110
+ attrName: string;
111
+ }
112
+
113
+ /**
114
+ * Parser function signature
115
+ * Can accept just the attribute value (simple form) or value + context (advanced form)
116
+ */
117
+ export type ParserFunction<T = any> =
118
+ | ((attrValue: string | null) => any)
119
+ | ((attrValue: string | null, context?: ParserContext<T>) => any);
120
+
121
+ export interface AttrConfig<T = unknown, TParserConfig = unknown> {
122
+ /**
123
+ * Type of the property value (JSON-serializable string format)
124
+ */
125
+ instanceOf?: 'Object' | 'String' | 'Number' | 'Boolean' | 'Array'
126
+ | typeof Object | typeof String | typeof Number | typeof Boolean | typeof Array;
127
+
128
+
129
+ /**
130
+ * Property name on the spawned class instance to map to
131
+ * Use '.' to map to the root object using assignGingerly
132
+ * Is optional.
133
+ * If not specified, we assume it is the key without the underscore first
134
+ * character, unless the key is _base in which case it assume mapsTo = "."
135
+ */
136
+ mapsTo?:
137
+ | '.'
138
+ | keyof T
139
+ | pathString
140
+ | `${pathString} +=`
141
+ | `${pathString} =!`
142
+ | `${pathString} -=`
143
+
144
+ /**
145
+ * Parser to transform attribute string value
146
+ * - Function: Inline parser function (not JSON serializable)
147
+ * - Simple form: (attrValue: string | null) => any
148
+ * - Advanced form: (attrValue: string | null, context: ParserContext) => any
149
+ * - String: Named parser reference (JSON serializable) - looks up in scoped registry (if available) then global parser registry (e.g., 'timestamp', 'csv')
150
+ *
151
+ * Parser functions can optionally accept a second parameter (ParserContext) which provides:
152
+ * - attrConfig: The full AttrConfig object for this attribute
153
+ * - spawnContext: The SpawnContext with enhancement config and synthesizer element
154
+ * - element: The element being enhanced
155
+ * - attrName: The resolved attribute name
156
+ */
157
+ parser?:
158
+ | ParserFunction<T>
159
+ | string
160
+ ;
161
+
162
+ /**
163
+ * configuration information needed by a custom parser to properly
164
+ * parse the attribute.
165
+ */
166
+ parserConfig?: TParserConfig;
167
+
168
+ /**
169
+ * Default value to use when attribute is missing
170
+ * If defined, bypasses parser when attribute is not present
171
+ * If undefined, property is not added to initVals when attribute is missing
172
+ */
173
+ valIfNull?: any;
174
+
175
+ /**
176
+ * Enable caching of parsed attribute values
177
+ * - 'shared': Cache and reuse the same parsed object (fast, but enhancements must not mutate)
178
+ * - 'cloned': Cache and return a structural clone (safer, but slower)
179
+ * Note: Parsers should be pure functions when using caching
180
+ */
181
+ parseCache?: 'shared' | 'cloned';
182
+
183
+ // /**
184
+ // * Whether to only read the initial value (true) or continue observing changes (false)
185
+ // * Defaults to true (initial read only)
186
+ // */
187
+ // initialOnly?: boolean;
188
+
189
+ /**
190
+ * Should make sure it is added to static observedAttribrutes
191
+ */
192
+ sourceOfTruth?: boolean;
193
+
194
+ /**
195
+ * Options to pass to the parser function (e.g., splitStatements behavior).
196
+ * For named parsers like 'parse-pattern-statements', this is forwarded
197
+ * as the options argument to the underlying parse function.
198
+ */
199
+ parserOptions?: any;
200
+ }
201
+
202
+ export type AttrPatterns<T = any> = {
203
+ /**
204
+ * Base prefix for attribute names
205
+ */
206
+ base?: string;
207
+
208
+ /**
209
+ * Configuration for the base pattern
210
+ */
211
+ _base?: AttrConfig<T>;
212
+ } & {
213
+ // Provide autocomplete for all properties of T (optional)
214
+ [K in keyof T]?: string | AttrConfig<T>;
215
+ } & {
216
+ // Provide autocomplete for underscore-prefixed config keys
217
+ [K in keyof T as `_${string & K}`]?: AttrConfig<T>;
218
+ } & {
219
+ // Allow any other string keys for custom patterns
220
+ [key: string]: string | AttrConfig<T>;
221
+ };
222
+
223
+
224
+ export interface SpawnContext<T = any, TMountContext = any> {
225
+ config: EnhancementConfig<T>;
226
+ mountCtx?: TMountContext;
227
+ /**
228
+ * Reference to the synthesizer element (be-hive, htmx-container, alpine-scope, etc.)
229
+ * that contains the EMC script defining this enhancement.
230
+ * Used for scoped parser registry access during attribute parsing.
231
+ */
232
+ synthesizerElement?: Element;
233
+ /**
234
+ * The full EMC configuration object that triggered this spawn.
235
+ * Passed through so enhancement classes can access their full configuration
236
+ * (including customData) without needing to separately import the JSON file.
237
+ * This avoids duplicate JSON imports when using emoji shorthand aliases.
238
+ */
239
+ emc?: any;
240
+ }
241
+
242
+ /**
243
+ * @deprecated Use EnhancementConfig instead
244
+ */
245
+ export type IEnhancementRegistryItem<T = any> = EnhancementConfig<T>;
246
+
247
+ /**
248
+ * Interface for the options passed to assignGingerly
249
+ */
250
+ export interface IAssignGingerlyOptions {
251
+ registry?: typeof EnhancementRegistry | EnhancementRegistry;
252
+ bypassChecks?: boolean;
253
+ withMethods?: string[] | Set<string>;
254
+ aka?: Record<string, string>;
255
+
256
+ /**
257
+ * AbortSignal for cleaning up reactive subscriptions (@eachTime)
258
+ * Required when using @eachTime symbol for reactive iteration
259
+ * When the signal is aborted, all event listeners are automatically removed
260
+ */
261
+ signal?: AbortSignal;
262
+ }
263
+
264
+ /**
265
+ * Event dispatched when enhancement configs are registered
266
+ */
267
+ export declare class EnhancementRegisteredEvent extends Event {
268
+ static eventName: string;
269
+ config: EnhancementConfig | EnhancementConfig[];
270
+ constructor(config: EnhancementConfig | EnhancementConfig[]);
271
+ }
272
+
273
+ /**
274
+ * Base registry class for managing enhancement configurations
275
+ * Extends EventTarget to dispatch events when configs are registered
276
+ */
277
+ export declare class EnhancementRegistry extends EventTarget {
278
+ push(items: EnhancementConfig | EnhancementConfig[]): void;
279
+ getItems(): EnhancementConfig[];
280
+ findBySymbol(symbol: symbol | string): EnhancementConfig | undefined;
281
+ findByEnhKey(enhKey: string | symbol): EnhancementConfig | undefined;
282
+ }
283
+
284
+ /**
285
+ * Constructor signature for ItemScope Manager classes
286
+ */
287
+ export type ItemscopeManager<T = any> = {
288
+ new (element: HTMLElement, initVals?: Partial<T>): T;
289
+ }
290
+
291
+ /**
292
+ * Configuration for ItemScope Manager registration
293
+ */
294
+ export interface ItemscopeManagerConfig<T = any> {
295
+ /**
296
+ * Manager class constructor
297
+ */
298
+ manager: ItemscopeManager<T>;
299
+
300
+ /**
301
+ * Optional lifecycle method keys
302
+ * - dispose: Method name to call when manager is disposed
303
+ * - resolved: Property/event name indicating manager is ready
304
+ */
305
+ lifecycleKeys?: {
306
+ dispose?: string | symbol;
307
+ resolved?: string | symbol;
308
+ };
309
+
310
+ /**
311
+ * Optional features to associate with the manager class.
312
+ * Calls assignFeatures(manager, features) automatically on registration.
313
+ */
314
+ features?: FeatureConfigsMap;
315
+ }
316
+
317
+ /**
318
+ * Registry for ItemScope Manager configurations
319
+ * Extends EventTarget to support lazy registration via events
320
+ */
321
+ export declare class ItemscopeRegistry extends EventTarget {
322
+ define(name: string, config: ItemscopeManagerConfig): void;
323
+ get(name: string): ItemscopeManagerConfig | undefined;
324
+ whenDefined(name: string): Promise<void>;
325
+ }
326
+
327
+ /**
328
+ * Main assignGingerly function
329
+ */
330
+ export declare function assignGingerly(
331
+ target: any,
332
+ source: Record<string | symbol, any>,
333
+ options?: IAssignGingerlyOptions
334
+ ): any;
335
+
336
+ export default assignGingerly;
337
+
338
+ export declare class ElementEnhancementGateway{
339
+ //TODO: this isn't right
340
+ enh: ElementEnhancement;
341
+ }
342
+
343
+ export interface ElementEnhancement{
344
+ get(registryItem: EnhancementConfig | string | symbol, mountCtx?: any): any;
345
+ dispose(registryItem: EnhancementConfig | string | symbol): void;
346
+ whenResolved(registryItem: EnhancementConfig | string | symbol, mountCtx?: any): Promise<any>;
347
+ }
348
+
349
+ // =============================================================================
350
+ // Custom Element Features types
351
+ // =============================================================================
352
+
353
+ /**
354
+ * Context passed to feature spawn constructors
355
+ */
356
+ export interface FeatureSpawnContext {
357
+ /** The feature key (e.g., 'photoTaker') */
358
+ key: string;
359
+ /** The SupportedFeatureConfig from static supportedFeatures */
360
+ optIn: SupportedFeatureConfig;
361
+ /** The FeatureConfig from assignFeatures */
362
+ injection: FeatureConfig;
363
+ /** The features registry reference */
364
+ featuresRegistry: FeaturesRegistry;
365
+ /** Shared context from the host element (via getSharedContext callback) */
366
+ shared?: any;
367
+ }
368
+
369
+ /**
370
+ * Configuration for a supported feature slot declared via static supportedFeatures
371
+ */
372
+ export interface SupportedFeatureConfig {
373
+ /**
374
+ * Optional fallback class (or async spawner) to use if no implementation is injected.
375
+ */
376
+ fallbackSpawn?:
377
+ | { new(hostElement: any, ctx: FeatureSpawnContext, initVals?: any): any }
378
+ | (() => Promise<{ new(hostElement: any, ctx: FeatureSpawnContext, initVals?: any): any }>);
379
+
380
+ /**
381
+ * Optional runtime shape validation for the spawned instance.
382
+ * Return true if the instance is valid, false to throw.
383
+ */
384
+ validateShape?: (spawnedInstance: any) => boolean;
385
+
386
+ /**
387
+ * Optional callback to provide shared context (e.g., ElementInternals, private state)
388
+ * to the feature at construction time.
389
+ */
390
+ getSharedContext?: (instance: any) => any;
391
+
392
+ /**
393
+ * Lifecycle callbacks that this feature requires.
394
+ * Serves as the default — the consumer can add more via FeatureConfig.callbackForwarding.
395
+ */
396
+ callbackForwarding?: string[];
397
+ }
398
+
399
+ /**
400
+ * Class-level configuration for the features system.
401
+ * Declared as `static featuresConfig` on the class.
402
+ */
403
+ export interface FeaturesClassConfig {
404
+ /**
405
+ * Lifecycle method configuration.
406
+ * true = install 'whenFeatureReady' method.
407
+ * Object = custom method name.
408
+ */
409
+ lifecycleKeys?: true | {
410
+ whenFeatureReady?: string;
411
+ };
412
+ }
413
+
414
+ /**
415
+ * Configuration for a feature passed to assignFeatures.
416
+ */
417
+ export interface FeatureConfig {
418
+ /**
419
+ * The class to instantiate, or an async function returning one.
420
+ */
421
+ spawn?:
422
+ | { new(hostElement: any, ctx: FeatureSpawnContext, initVals?: any): any }
423
+ | (() => Promise<{ new(hostElement: any, ctx: FeatureSpawnContext, initVals?: any): any }>);
424
+
425
+ /** Attribute patterns for parsing element attributes into initVals. */
426
+ withAttrs?: AttrPatterns<any>;
427
+
428
+ /** Pass-through custom configuration data (accessible via ctx.injection.customData). */
429
+ customData?: any;
430
+
431
+ /** Lifecycle callbacks to forward to this feature. */
432
+ callbackForwarding?: string[];
433
+ }
434
+
435
+ export type SupportedFeaturesMap = Record<string, SupportedFeatureConfig>;
436
+ export type FeatureConfigsMap = Record<string, FeatureConfig>;
437
+
438
+ /**
439
+ * Registry for feature configs, keyed by constructor.
440
+ */
441
+ export declare class FeaturesRegistry {
442
+ has(ctr: Function): boolean;
443
+ get(ctr: Function): Map<string, FeatureConfig> | undefined;
444
+ set(ctr: Function, key: string, config: FeatureConfig): void;
445
+ hasKey(ctr: Function, key: string): boolean;
446
+ }
447
+
448
+ /**
449
+ * A suggestion from one feature to another.
450
+ */
451
+ export interface FeatureInfoSuggestion {
452
+ from: Function;
453
+ withAttrs?: any;
454
+ customData?: any;
455
+ }
456
+
457
+ /**
458
+ * Core assignFeatures function.
459
+ */
460
+ export declare function assignFeatures(
461
+ ctr: Function,
462
+ features: FeatureConfigsMap,
463
+ featuresRegistry: FeaturesRegistry
464
+ ): Promise<void> | undefined;
465
+
466
+ /**
467
+ * Captures own-properties that shadow feature getters.
468
+ */
469
+ export declare function captureFeatureInitVals(instance: any): void;
470
+
471
+ /**
472
+ * Suggest configuration to another feature during registration.
473
+ */
474
+ export declare function suggestFeatureInfo(
475
+ fromFeatureCtr: Function,
476
+ toFeatureSymbol: symbol,
477
+ featureInfo: { withAttrs?: any; customData?: any },
478
+ targetClass: Function
479
+ ): void;
480
+
481
+ /**
482
+ * Retrieve suggestions made to a feature by other features.
483
+ */
484
+ export declare function getFeatureInfoSuggestions(
485
+ toFeatureSymbol: symbol,
486
+ targetClass: Function
487
+ ): FeatureInfoSuggestion[];
488
+
489
+ /**
490
+ * Base class for nested feature containers.
491
+ */
492
+ export declare class PropertyBag {
493
+ customElementRegistry: any;
494
+ constructor(hostElement: any, ctx?: FeatureSpawnContext, initVals?: any);
495
+ }
496
+
497
+ // =============================================================================
498
+ // assignFrom handler types
499
+ // =============================================================================
500
+
501
+ /**
502
+ * Base configuration for an assignFrom handler invocation.
503
+ * The `do` field identifies the handler; `resolve` maps named parameters to path strings.
504
+ */
505
+ export interface HandlerConfig {
506
+ /** The registered handler name */
507
+ do: string;
508
+ /** Named parameters to resolve against the `from` source before passing to the handler */
509
+ resolve?: Record<string, string>;
510
+ }
511
+
512
+ /**
513
+ * Interface for assignFrom handler classes.
514
+ * Handlers are invoked when a LHS key ends with ' =>'.
515
+ */
516
+ export interface AssignFromHandler {
517
+ assign(lhsTarget: any, resolvedParams: Record<string, any>, options: any): Promise<void> | void;
518
+ }
519
+
520
+ /**
521
+ * Constructor signature for assignFrom handler classes.
522
+ */
523
+ export interface AssignFromHandlerConstructor {
524
+ new (config: HandlerConfig): AssignFromHandler;
525
+ }
526
+
527
+ // =============================================================================
528
+ // Built-in handler config types
529
+ // =============================================================================
530
+
531
+ /**
532
+ * Configuration for the builtIns.lazyLoad handler.
533
+ */
534
+ export interface LazyLoadConfig extends HandlerConfig {
535
+ do: 'builtIns.lazyLoad';
536
+ resolve: {
537
+ /** Condition to show/hide (resolved from VM) */
538
+ if: string;
539
+ /** Template element to clone (resolved via protocol or path) */
540
+ instantiate: string;
541
+ /** Insert method: 'appendChild' (default) or 'prepend' */
542
+ method?: string;
543
+ /** If true, removes nodes when hiding instead of adding hidden attribute */
544
+ forget?: boolean | string;
545
+ /** Optional async callback invoked after cloning, resolved from the VM */
546
+ onInstantiated?: string;
547
+ };
548
+ }
549
+
550
+ /**
551
+ * Context passed to onInstantiated callbacks after template cloning.
552
+ */
553
+ export interface LazyLoadInstantiatedContext {
554
+ /** The inserted child nodes */
555
+ nodes: Node[];
556
+ /** The target element containing the markers */
557
+ target: Element;
558
+ /** The full handler config */
559
+ config: any;
560
+ /** The resolved parameters */
561
+ resolvedParams: Record<string, any>;
562
+ }
563
+
564
+ /**
565
+ * The LazyLoadHandler class (exported for subclassing).
566
+ */
567
+ export declare class LazyLoadHandler implements AssignFromHandler {
568
+ config: any;
569
+ constructor(config: any);
570
+ assign(lhsTarget: any, resolvedParams: Record<string, any>, options?: any): Promise<void>;
571
+ protected onCloneInserted(nodes: Node[], lhsTarget: Element, resolvedParams: Record<string, any>): Promise<void>;
572
+ }
@@ -0,0 +1,17 @@
1
+ export interface EndUserProps {
2
+ eventName: string;
3
+ }
4
+
5
+ export interface AllProps extends EndUserProps {
6
+ enhancedElement: Element;
7
+ }
8
+
9
+ export type AP = AllProps;
10
+
11
+ export type PAP = Partial<AP>;
12
+
13
+ export type ProPAP = Promise<PAP>;
14
+
15
+ export interface Actions {
16
+ hydrate(self: AP): PAP;
17
+ }
@@ -0,0 +1,66 @@
1
+ import { ElementEnhancementGateway, SpawnContext } from "../assign-gingerly/types";
2
+ //import { Specifier } from "../trans-render/dss/types";
3
+ //import { AbsorbingObject, SharingObject} from '../trans-render/asmr/types';
4
+ import { StatementsResult } from "../nested-regex-groups/types";
5
+
6
+ export interface EndUserProps{
7
+ bindingRules: StatementsResult<BindingRule>;
8
+ }
9
+
10
+ export interface AllProps extends EndUserProps{
11
+ enhancedElement: Element & ElementEnhancementGateway;
12
+ //bindings: Array<Binding>,
13
+ isParsed?: boolean,
14
+ rawStatements?: Array<string>
15
+ }
16
+
17
+ export type SignalEnhancement = 'be-value-added' | 'be-propagating' | undefined;
18
+
19
+ export interface BindingRule {
20
+
21
+ localProp: string,
22
+ localEvent?: string,
23
+ remoteId?: string,
24
+ remoteProp: string,
25
+ //remoteSpecifier?: Specifier,
26
+
27
+
28
+ }
29
+
30
+ // export interface Binding {
31
+ // //new and improved
32
+ // localAbsObj: AbsorbingObject;
33
+ // localShareObj: SharingObject;
34
+ // remoteAbsObj: AbsorbingObject;
35
+ // remoteShareObj: SharingObject;
36
+ // //remoteRef: WeakRef<Element>;
37
+ // }
38
+
39
+ export type AP = AllProps;
40
+
41
+ export type PAP = Partial<AP>;
42
+
43
+ export type ProPAP = Promise<PAP>;
44
+
45
+ export type Directions = 'rToL' | 'lToR' | 'tie';
46
+
47
+
48
+ export interface Actions{
49
+ init(self: AllProps, enhancedElement: Element, ctx: SpawnContext, initVals: PAP): Promise<void>;
50
+ //noAttrs(self: AP): ProPAP;
51
+ getBindings(self: AP): ProPAP;
52
+ hydrate(self: AP): ProPAP;
53
+ onRawStatements(self: AP): void;
54
+ reconcileValues(self: AP, rule: BindingRule, direction: Directions): void;
55
+ }
56
+
57
+ export type WithStatement = string;
58
+
59
+ export type BetweenStatement = string;
60
+
61
+ export type TriggerSource = 'local' | 'remote' | 'tie';
62
+
63
+ export interface SpecificityResult {
64
+ val?: any,
65
+ winner?: TriggerSource;
66
+ }
@@ -0,0 +1,19 @@
1
+ export interface EndUserProps{
2
+ closeOnSelect: boolean;
3
+ eventName: string;
4
+ }
5
+
6
+ export interface AllProps extends EndUserProps {
7
+ enhancedElement: Element;
8
+ }
9
+
10
+ export type AP = AllProps;
11
+
12
+ export type PAP = Partial<AP>;
13
+
14
+ export type ProPAP = Promise<PAP>;
15
+
16
+ export interface Actions{
17
+ init(self: AllProps, enhancedElement: Element, initVals: PAP): void;
18
+ hydrate(self: AP): PAP | void
19
+ }