mount-observer 0.1.37 → 0.1.38
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/handlers/EMCScript.js +8 -1
- package/handlers/EMCScript.ts +9 -1
- package/handlers/ScriptExport.js +0 -1
- package/handlers/ScriptExport.ts +0 -1
- package/index.js +2 -0
- package/package.json +2 -2
- package/types/assign-gingerly/types.d.ts +154 -1
- package/types/be-reflective/types.d.ts +80 -0
- package/types/do-inc/types.d.ts +2 -2
- package/types/do-merge/types.d.ts +28 -0
- package/types/do-toggle/types.d.ts +6 -2
- package/types/face-up/types.d.ts +102 -0
- package/types/roundabout/types.d.ts +41 -9
- package/types/templ-maker/types.d.ts +45 -0
- package/types/time-ticker/types.d.ts +62 -0
- package/types/truth-sourcer/types.d.ts +46 -0
package/handlers/EMCScript.js
CHANGED
|
@@ -130,12 +130,19 @@ export class EMCScriptHandler extends EvtRt {
|
|
|
130
130
|
*/
|
|
131
131
|
async handleMount(mountedElement, emcConfig, synthesizerElement) {
|
|
132
132
|
const enhKey = emcConfig.enhConfig.enhKey;
|
|
133
|
-
// Step 1: Check if element already has this enhancement
|
|
133
|
+
// Step 1: Check if element already has this enhancement or is currently being enhanced
|
|
134
134
|
const enh = mountedElement.enh;
|
|
135
135
|
if (enh && enh[enhKey]) {
|
|
136
136
|
// Already enhanced, do nothing
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
|
+
// Check for in-flight enhancement to prevent duplicate spawns
|
|
140
|
+
// when multiple observers match the same element concurrently
|
|
141
|
+
const inflightKey = `__enhInFlight_${String(enhKey)}`;
|
|
142
|
+
if (mountedElement[inflightKey]) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
mountedElement[inflightKey] = true;
|
|
139
146
|
// Step 2: Get enhancement registry from the element's custom element registry
|
|
140
147
|
const customElementRegistry = mountedElement.customElementRegistry || customElements;
|
|
141
148
|
const enhancementRegistry = customElementRegistry.enhancementRegistry;
|
package/handlers/EMCScript.ts
CHANGED
|
@@ -152,13 +152,21 @@ export class EMCScriptHandler extends EvtRt {
|
|
|
152
152
|
private async handleMount(mountedElement: Element, emcConfig: EMC, synthesizerElement?: Element): Promise<void> {
|
|
153
153
|
const enhKey = emcConfig.enhConfig.enhKey;
|
|
154
154
|
|
|
155
|
-
// Step 1: Check if element already has this enhancement
|
|
155
|
+
// Step 1: Check if element already has this enhancement or is currently being enhanced
|
|
156
156
|
const enh = (mountedElement as any).enh;
|
|
157
157
|
if (enh && enh[enhKey]) {
|
|
158
158
|
// Already enhanced, do nothing
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
// Check for in-flight enhancement to prevent duplicate spawns
|
|
163
|
+
// when multiple observers match the same element concurrently
|
|
164
|
+
const inflightKey = `__enhInFlight_${String(enhKey)}`;
|
|
165
|
+
if ((mountedElement as any)[inflightKey]) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
(mountedElement as any)[inflightKey] = true;
|
|
169
|
+
|
|
162
170
|
// Step 2: Get enhancement registry from the element's custom element registry
|
|
163
171
|
const customElementRegistry = (mountedElement as any).customElementRegistry || customElements;
|
|
164
172
|
const enhancementRegistry = (customElementRegistry as any).enhancementRegistry;
|
package/handlers/ScriptExport.js
CHANGED
|
@@ -33,7 +33,6 @@ export class ScriptExportHandler extends EvtRt {
|
|
|
33
33
|
const scriptElement = mountedElement;
|
|
34
34
|
// Optimization 3: Skip if already processed (export property exists)
|
|
35
35
|
if (scriptElement.export !== undefined) {
|
|
36
|
-
console.log('ScriptExport: Skipping already processed script element');
|
|
37
36
|
return;
|
|
38
37
|
}
|
|
39
38
|
// Skip if this is a module script (browser handles these)
|
package/handlers/ScriptExport.ts
CHANGED
|
@@ -38,7 +38,6 @@ export class ScriptExportHandler extends EvtRt {
|
|
|
38
38
|
|
|
39
39
|
// Optimization 3: Skip if already processed (export property exists)
|
|
40
40
|
if ((scriptElement as any).export !== undefined) {
|
|
41
|
-
console.log('ScriptExport: Skipping already processed script element');
|
|
42
41
|
return;
|
|
43
42
|
}
|
|
44
43
|
|
package/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export { MountObserverScriptHandler } from './handlers/MountObserverScript.js';
|
|
|
12
12
|
export { EMCScriptHandler } from './handlers/EMCScript.js';
|
|
13
13
|
export { HoistTemplateHandler } from './handlers/HoistTemplate.js';
|
|
14
14
|
export { HTMLIncludeHandler } from './handlers/HTMLInclude.js';
|
|
15
|
+
export { CedeScriptHandler } from './handlers/CedeScript.js';
|
|
15
16
|
export { upShadowSearch } from './upShadowSearch.js';
|
|
16
17
|
export { mountEventName, dismountEventName, disconnectEventName, loadEventName, mediamatchEventName, mediaunmatchEventName, addedScriptElementEventName } from './Events.js';
|
|
17
18
|
// Register built-in handlers
|
|
@@ -24,3 +25,4 @@ import './handlers/MountObserverScript.js';
|
|
|
24
25
|
import './handlers/EMCScript.js';
|
|
25
26
|
import './handlers/HoistTemplate.js';
|
|
26
27
|
import './handlers/HTMLInclude.js';
|
|
28
|
+
import './handlers/CedeScript.js';
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mount-observer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
4
4
|
"description": "Observe and act on css matches.",
|
|
5
5
|
"main": "MountObserver.js",
|
|
6
6
|
"module": "MountObserver.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"assign-gingerly": "0.0.
|
|
8
|
+
"assign-gingerly": "0.0.51",
|
|
9
9
|
"id-generation": "0.0.4"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
@@ -179,13 +179,18 @@ export interface AttrConfig<T = unknown, TParserConfig = unknown> {
|
|
|
179
179
|
// * Defaults to true (initial read only)
|
|
180
180
|
// */
|
|
181
181
|
// initialOnly?: boolean;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Should make sure it is added to static observedAttribrutes
|
|
185
|
+
*/
|
|
186
|
+
sourceOfTruth?: boolean;
|
|
182
187
|
}
|
|
183
188
|
|
|
184
189
|
export type AttrPatterns<T = any> = {
|
|
185
190
|
/**
|
|
186
191
|
* Base prefix for attribute names
|
|
187
192
|
*/
|
|
188
|
-
base
|
|
193
|
+
base?: string;
|
|
189
194
|
|
|
190
195
|
/**
|
|
191
196
|
* Configuration for the base pattern
|
|
@@ -321,3 +326,151 @@ export interface ElementEnhancement{
|
|
|
321
326
|
dispose(registryItem: EnhancementConfig | string | symbol): void;
|
|
322
327
|
whenResolved(registryItem: EnhancementConfig | string | symbol, mountCtx?: any): Promise<any>;
|
|
323
328
|
}
|
|
329
|
+
|
|
330
|
+
// =============================================================================
|
|
331
|
+
// Custom Element Features types
|
|
332
|
+
// =============================================================================
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Context passed to feature spawn constructors
|
|
336
|
+
*/
|
|
337
|
+
export interface FeatureSpawnContext {
|
|
338
|
+
/** The feature key (e.g., 'photoTaker') */
|
|
339
|
+
key: string;
|
|
340
|
+
/** The SupportedFeatureConfig from static supportedFeatures */
|
|
341
|
+
optIn: SupportedFeatureConfig;
|
|
342
|
+
/** The FeatureConfig from assignFeatures */
|
|
343
|
+
injection: FeatureConfig;
|
|
344
|
+
/** The features registry reference */
|
|
345
|
+
featuresRegistry: FeaturesRegistry;
|
|
346
|
+
/** Shared context from the host element (via getSharedContext callback) */
|
|
347
|
+
shared?: any;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Configuration for a supported feature slot declared via static supportedFeatures
|
|
352
|
+
*/
|
|
353
|
+
export interface SupportedFeatureConfig {
|
|
354
|
+
/**
|
|
355
|
+
* Optional fallback class (or async spawner) to use if no implementation is injected.
|
|
356
|
+
*/
|
|
357
|
+
fallbackSpawn?:
|
|
358
|
+
| { new(hostElement: any, ctx: FeatureSpawnContext, initVals?: any): any }
|
|
359
|
+
| (() => Promise<{ new(hostElement: any, ctx: FeatureSpawnContext, initVals?: any): any }>);
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Optional runtime shape validation for the spawned instance.
|
|
363
|
+
* Return true if the instance is valid, false to throw.
|
|
364
|
+
*/
|
|
365
|
+
validateShape?: (spawnedInstance: any) => boolean;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Optional callback to provide shared context (e.g., ElementInternals, private state)
|
|
369
|
+
* to the feature at construction time.
|
|
370
|
+
*/
|
|
371
|
+
getSharedContext?: (instance: any) => any;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Lifecycle callbacks that this feature requires.
|
|
375
|
+
* Serves as the default — the consumer can add more via FeatureConfig.callbackForwarding.
|
|
376
|
+
*/
|
|
377
|
+
callbackForwarding?: string[];
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Class-level configuration for the features system.
|
|
382
|
+
* Declared as `static featuresConfig` on the class.
|
|
383
|
+
*/
|
|
384
|
+
export interface FeaturesClassConfig {
|
|
385
|
+
/**
|
|
386
|
+
* Lifecycle method configuration.
|
|
387
|
+
* true = install 'whenFeatureReady' method.
|
|
388
|
+
* Object = custom method name.
|
|
389
|
+
*/
|
|
390
|
+
lifecycleKeys?: true | {
|
|
391
|
+
whenFeatureReady?: string;
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Configuration for a feature passed to assignFeatures.
|
|
397
|
+
*/
|
|
398
|
+
export interface FeatureConfig {
|
|
399
|
+
/**
|
|
400
|
+
* The class to instantiate, or an async function returning one.
|
|
401
|
+
*/
|
|
402
|
+
spawn?:
|
|
403
|
+
| { new(hostElement: any, ctx: FeatureSpawnContext, initVals?: any): any }
|
|
404
|
+
| (() => Promise<{ new(hostElement: any, ctx: FeatureSpawnContext, initVals?: any): any }>);
|
|
405
|
+
|
|
406
|
+
/** Attribute patterns for parsing element attributes into initVals. */
|
|
407
|
+
withAttrs?: AttrPatterns<any>;
|
|
408
|
+
|
|
409
|
+
/** Pass-through custom configuration data (accessible via ctx.injection.customData). */
|
|
410
|
+
customData?: any;
|
|
411
|
+
|
|
412
|
+
/** Lifecycle callbacks to forward to this feature. */
|
|
413
|
+
callbackForwarding?: string[];
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export type SupportedFeaturesMap = Record<string, SupportedFeatureConfig>;
|
|
417
|
+
export type FeatureConfigsMap = Record<string, FeatureConfig>;
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Registry for feature configs, keyed by constructor.
|
|
421
|
+
*/
|
|
422
|
+
export declare class FeaturesRegistry {
|
|
423
|
+
has(ctr: Function): boolean;
|
|
424
|
+
get(ctr: Function): Map<string, FeatureConfig> | undefined;
|
|
425
|
+
set(ctr: Function, key: string, config: FeatureConfig): void;
|
|
426
|
+
hasKey(ctr: Function, key: string): boolean;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* A suggestion from one feature to another.
|
|
431
|
+
*/
|
|
432
|
+
export interface FeatureInfoSuggestion {
|
|
433
|
+
from: Function;
|
|
434
|
+
withAttrs?: any;
|
|
435
|
+
customData?: any;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Core assignFeatures function.
|
|
440
|
+
*/
|
|
441
|
+
export declare function assignFeatures(
|
|
442
|
+
ctr: Function,
|
|
443
|
+
features: FeatureConfigsMap,
|
|
444
|
+
featuresRegistry: FeaturesRegistry
|
|
445
|
+
): Promise<void> | undefined;
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Captures own-properties that shadow feature getters.
|
|
449
|
+
*/
|
|
450
|
+
export declare function captureFeatureInitVals(instance: any): void;
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Suggest configuration to another feature during registration.
|
|
454
|
+
*/
|
|
455
|
+
export declare function suggestFeatureInfo(
|
|
456
|
+
fromFeatureCtr: Function,
|
|
457
|
+
toFeatureSymbol: symbol,
|
|
458
|
+
featureInfo: { withAttrs?: any; customData?: any },
|
|
459
|
+
targetClass: Function
|
|
460
|
+
): void;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Retrieve suggestions made to a feature by other features.
|
|
464
|
+
*/
|
|
465
|
+
export declare function getFeatureInfoSuggestions(
|
|
466
|
+
toFeatureSymbol: symbol,
|
|
467
|
+
targetClass: Function
|
|
468
|
+
): FeatureInfoSuggestion[];
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Base class for nested feature containers.
|
|
472
|
+
*/
|
|
473
|
+
export declare class PropertyBag {
|
|
474
|
+
customElementRegistry: any;
|
|
475
|
+
constructor(hostElement: any, ctx?: FeatureSpawnContext, initVals?: any);
|
|
476
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { SpawnContext } from "../assign-gingerly/types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared context passed via getSharedContext — contains everything
|
|
5
|
+
* the Reflector needs to self-activate on spawn.
|
|
6
|
+
*/
|
|
7
|
+
export interface ReflectorSharedContext {
|
|
8
|
+
/** The ElementInternals instance for custom state manipulation */
|
|
9
|
+
internals: ElementInternals;
|
|
10
|
+
/** The EventTarget the host dispatches property change events on */
|
|
11
|
+
hostPropagator: EventTarget;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Context passed to the Reflector feature constructor
|
|
16
|
+
*/
|
|
17
|
+
export interface FeatureSpawnContext extends SpawnContext {
|
|
18
|
+
key: string;
|
|
19
|
+
optIn: any;
|
|
20
|
+
injection: any;
|
|
21
|
+
featuresRegistry: any;
|
|
22
|
+
shared?: ReflectorSharedContext;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A single custom state export rule parsed from --custom-state-exports
|
|
27
|
+
*/
|
|
28
|
+
export interface CustomStateRule {
|
|
29
|
+
/** The custom state name to toggle (e.g. "disabled", "alertTypeIndicatesSuccess") */
|
|
30
|
+
stateName: string;
|
|
31
|
+
/** The property name to observe */
|
|
32
|
+
propName: string;
|
|
33
|
+
/** The condition type */
|
|
34
|
+
conditionType: 'boolean' | 'equals' | 'contains' | 'endsWith' | 'modulo' | 'lessThan' | 'greaterThan' | 'lessThanOrEqual' | 'greaterThanOrEqual';
|
|
35
|
+
/** The comparison value (for non-boolean conditions) */
|
|
36
|
+
compareValue?: string | number;
|
|
37
|
+
/** The modulo divisor (for modulo conditions) */
|
|
38
|
+
moduloDivisor?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Properties that the Reflector feature exposes.
|
|
43
|
+
* With callbackForwarding, hostPropagator is provided via getSharedContext
|
|
44
|
+
* and the feature self-activates — but the setter remains for manual use cases.
|
|
45
|
+
*/
|
|
46
|
+
export interface ReflectorProps {
|
|
47
|
+
/**
|
|
48
|
+
* The EventTarget that the host element uses to propagate property change events.
|
|
49
|
+
* Provided via getSharedContext. Also settable post-spawn for reconnection.
|
|
50
|
+
*/
|
|
51
|
+
hostPropagator: EventTarget | null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Internal state
|
|
56
|
+
*/
|
|
57
|
+
export interface AllProps extends ReflectorProps {
|
|
58
|
+
/**
|
|
59
|
+
* WeakRef to the host custom element
|
|
60
|
+
*/
|
|
61
|
+
hostRef: WeakRef<HTMLElement> | null;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The ElementInternals instance from the host (for custom state manipulation)
|
|
65
|
+
*/
|
|
66
|
+
internals: ElementInternals | null;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Parsed custom state rules from --custom-state-exports CSS property
|
|
70
|
+
*/
|
|
71
|
+
rules: CustomStateRule[];
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* AbortController for cleaning up event listeners
|
|
75
|
+
*/
|
|
76
|
+
abortController: AbortController | null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type AP = AllProps;
|
|
80
|
+
export type PAP = Partial<AP>;
|
package/types/do-inc/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementEnhancementGateway } from "../assign-gingerly/types";
|
|
1
|
+
import { ElementEnhancementGateway, SpawnContext } from "../assign-gingerly/types";
|
|
2
2
|
import { StatementsResult } from "../nested-regex-groups/types";
|
|
3
3
|
|
|
4
4
|
export interface EndUserProps{
|
|
@@ -19,7 +19,7 @@ export type ProPAP = Promise<PAP>
|
|
|
19
19
|
export interface Actions{
|
|
20
20
|
hydrate(self: AP & Actions): ProPAP;
|
|
21
21
|
handleEvent(self: AP, event: Event, incParameters: IncParameters): void;
|
|
22
|
-
init(self: AP, enhancedElement: Element, initVals: PAP): Promise<void
|
|
22
|
+
init(self: AP, enhancedElement: Element, ctx: SpawnContext, initVals: PAP): Promise<void>;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export type asOptions =
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ElementEnhancementGateway, SpawnContext, IAssignGingerlyOptions } from "../assign-gingerly/types";
|
|
2
|
+
|
|
3
|
+
export interface MergeParameters {
|
|
4
|
+
assign: Record<string, any>;
|
|
5
|
+
on?: string;
|
|
6
|
+
options?: IAssignGingerlyOptions;
|
|
7
|
+
targetElementId?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface EndUserProps {
|
|
11
|
+
mergeParamSets: MergeParameters | MergeParameters[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AllProps extends EndUserProps {
|
|
15
|
+
enhancedElement: Element & ElementEnhancementGateway;
|
|
16
|
+
resolved: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type AP = AllProps;
|
|
20
|
+
|
|
21
|
+
export type PAP = Partial<AP>;
|
|
22
|
+
|
|
23
|
+
export type ProPAP = Promise<PAP>;
|
|
24
|
+
|
|
25
|
+
export interface Actions {
|
|
26
|
+
init(self: AP, enhancedElement: Element, ctx: SpawnContext, initVals: PAP): Promise<void>;
|
|
27
|
+
hydrate(self: AP): ProPAP;
|
|
28
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementEnhancementGateway } from "../assign-gingerly/types";
|
|
1
|
+
import { ElementEnhancementGateway, SpawnContext } from "../assign-gingerly/types";
|
|
2
2
|
import { StatementsResult } from "../nested-regex-groups/types";
|
|
3
3
|
|
|
4
4
|
export interface EndUserProps{}
|
|
@@ -16,7 +16,7 @@ export type PAP = Partial<AP>;
|
|
|
16
16
|
export type ProPAP = Promise<PAP>
|
|
17
17
|
|
|
18
18
|
export interface Actions{
|
|
19
|
-
init(self: AllProps, enhancedElement: Element, initVals: PAP): void
|
|
19
|
+
init(self: AllProps, enhancedElement: Element, ctx: SpawnContext, initVals: PAP): Promise<void>;
|
|
20
20
|
hydrate(self: AP): ProPAP;
|
|
21
21
|
handleEvent(self: AP, e: Event, parsedStatement: TogglingParameters): void;
|
|
22
22
|
}
|
|
@@ -24,4 +24,8 @@ export interface Actions{
|
|
|
24
24
|
export interface TogglingParameters {
|
|
25
25
|
prop?: string | null;
|
|
26
26
|
localEventType?: string;
|
|
27
|
+
targetSpecifier: {
|
|
28
|
+
prop?: string;
|
|
29
|
+
targetElementId?: string;
|
|
30
|
+
};
|
|
27
31
|
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { SpawnContext } from "../assign-gingerly/types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared context passed via getSharedContext — contains the
|
|
5
|
+
* ElementInternals instance needed for form control APIs.
|
|
6
|
+
*/
|
|
7
|
+
export interface FaceUpSharedContext {
|
|
8
|
+
/** The ElementInternals instance for form control APIs */
|
|
9
|
+
internals: ElementInternals;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Context passed to the FaceUp feature constructor
|
|
14
|
+
*/
|
|
15
|
+
export interface FeatureSpawnContext extends SpawnContext {
|
|
16
|
+
key: string;
|
|
17
|
+
optIn: any;
|
|
18
|
+
injection: any;
|
|
19
|
+
featuresRegistry: any;
|
|
20
|
+
shared?: FaceUpSharedContext;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Validation flags matching the ValidityStateFlags interface.
|
|
25
|
+
* Used with setValidity() to indicate the type of validation error.
|
|
26
|
+
*/
|
|
27
|
+
export interface ValidationFlags {
|
|
28
|
+
valueMissing?: boolean;
|
|
29
|
+
typeMismatch?: boolean;
|
|
30
|
+
patternMismatch?: boolean;
|
|
31
|
+
tooLong?: boolean;
|
|
32
|
+
tooShort?: boolean;
|
|
33
|
+
rangeUnderflow?: boolean;
|
|
34
|
+
rangeOverflow?: boolean;
|
|
35
|
+
stepMismatch?: boolean;
|
|
36
|
+
badInput?: boolean;
|
|
37
|
+
customError?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Properties that the FaceUp feature exposes.
|
|
42
|
+
* These allow the host custom element to participate in HTML forms
|
|
43
|
+
* via the ElementInternals API.
|
|
44
|
+
*
|
|
45
|
+
* Because the feature is installed as a getter-only property,
|
|
46
|
+
* assignGingerly merges directly into the instance. The consumer
|
|
47
|
+
* simply sets properties (e.g., el.faceUp.value = x) and the
|
|
48
|
+
* setters handle syncing to ElementInternals automatically.
|
|
49
|
+
*/
|
|
50
|
+
export interface FaceUpProps {
|
|
51
|
+
/**
|
|
52
|
+
* The current form value of the control.
|
|
53
|
+
* Setting this calls setFormValue() on the internals.
|
|
54
|
+
*/
|
|
55
|
+
value: string | File | FormData | null;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Internal state for form restoration (optional).
|
|
59
|
+
* If provided, passed as the second argument to setFormValue().
|
|
60
|
+
*/
|
|
61
|
+
state: string | File | FormData | null;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Whether the control is currently disabled.
|
|
65
|
+
*/
|
|
66
|
+
disabled: boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Whether the control requires a value for form submission.
|
|
70
|
+
*/
|
|
71
|
+
required: boolean;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Custom validation message. Setting a non-empty string
|
|
75
|
+
* marks the control as invalid with customError.
|
|
76
|
+
*/
|
|
77
|
+
validationMessage: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Internal state
|
|
82
|
+
*/
|
|
83
|
+
export interface AllProps extends FaceUpProps {
|
|
84
|
+
/**
|
|
85
|
+
* WeakRef to the host custom element
|
|
86
|
+
*/
|
|
87
|
+
hostRef: WeakRef<HTMLElement> | null;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The ElementInternals instance from the host (for form control APIs)
|
|
91
|
+
*/
|
|
92
|
+
internals: ElementInternals | null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export type AP = AllProps;
|
|
96
|
+
export type PAP = Partial<AP>;
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
export interface CustomData {
|
|
101
|
+
integrateWithRoundabout: boolean;
|
|
102
|
+
}
|
|
@@ -42,18 +42,17 @@ export type Actions<TProps = any, TActions = TProps> =
|
|
|
42
42
|
//& Partial<{[key in `do_${keyof TActions & string}_on`]: Key<TActions> | Array<Key<TActions>> }>
|
|
43
43
|
;
|
|
44
44
|
|
|
45
|
-
export type Compacts<TProps = any, TActions = TProps> =
|
|
46
|
-
|
|
47
|
-
| Partial<{[key in `negate_${keyof TProps & string}_to_${keyof TProps & string}`]: number}>
|
|
45
|
+
export type Compacts<TProps = any, TActions = TProps, TEvents extends string = string> =
|
|
46
|
+
Partial<{[key in `negate_${keyof TProps & string}_to_${keyof TProps & string}`]: number}>
|
|
48
47
|
| Partial<{[key in `pass_length_of_${keyof TProps & string}_to_${keyof TProps & string}`]: number}>
|
|
49
48
|
| Partial<{[key in `echo_${keyof TProps & string}_to_${keyof TProps & string}`]: number}>
|
|
50
49
|
| Partial<{[key in `echo_${keyof TProps & string}_to_${keyof TProps & string}_after`]: keyof TProps}>
|
|
51
50
|
| Partial<{[key in `when_${keyof TProps & string}_changes_call_${keyof TActions & string}`]: number}>
|
|
52
51
|
| Partial<{[key in `when_${keyof TProps & string}_changes_toggle_${keyof TProps & string}`]: number}>
|
|
53
52
|
| Partial<{[key in `when_${keyof TProps & string}_changes_inc_${keyof TProps & string}_by`]: number}>
|
|
54
|
-
| Partial<{[key in `when_${keyof TProps & string}_changes_dispatch`]: string}>
|
|
55
|
-
| Partial<{[key in `on_${
|
|
56
|
-
| Partial<{[key in `on_${
|
|
53
|
+
| Partial<{[key in `when_${keyof TProps & string}_changes_dispatch`]: string}>
|
|
54
|
+
| Partial<{[key in `on_${TEvents}_of_${keyof TProps & string}_inc_${keyof TProps & string}_by`]: number}>
|
|
55
|
+
| Partial<{[key in `on_${TEvents}_of_${keyof TProps & string}_set_${keyof TProps & string}_to`]: any}>
|
|
57
56
|
;
|
|
58
57
|
|
|
59
58
|
export type Hitches<TProps = any, TActions = TProps> =
|
|
@@ -95,14 +94,48 @@ export interface Merge<TProps = any> extends LogicOp<TProps> {
|
|
|
95
94
|
|
|
96
95
|
export type Merges<TProps = any> = Array<Merge<TProps>>;
|
|
97
96
|
|
|
98
|
-
|
|
97
|
+
/**
|
|
98
|
+
* A yield derives a value from a collection using an index or key.
|
|
99
|
+
* Scenario I: Single selection by index — when the source array or index changes,
|
|
100
|
+
* the target property is set to source[index].
|
|
101
|
+
*/
|
|
102
|
+
export interface YieldConfig<TProps = any> {
|
|
103
|
+
/** The source array/collection property name */
|
|
104
|
+
from: keyof TProps & string;
|
|
105
|
+
/** The index property name (for array index lookup) */
|
|
106
|
+
atIndex?: keyof TProps & string;
|
|
107
|
+
/**
|
|
108
|
+
* Behavior when the index is out of bounds.
|
|
109
|
+
* - 'undefined' (default): set target to undefined
|
|
110
|
+
* - 'clamp': reset the index to 0 (selects first item)
|
|
111
|
+
*/
|
|
112
|
+
outOfBounds?: 'undefined' | 'clamp';
|
|
113
|
+
// Future: atKey, atIndices, keyProp, etc.
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type Yields<TProps = any> = {
|
|
117
|
+
[K in keyof TProps & string]?: YieldConfig<TProps>;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export interface RAConfig<
|
|
121
|
+
TProps = unknown, TActions = TProps, ETProps = TProps,
|
|
122
|
+
TCustomData = unknown, TEvents extends string = string > {
|
|
99
123
|
actions?: Actions<TProps,TActions>,
|
|
100
|
-
compacts?: Compacts<TProps, TActions>,
|
|
124
|
+
compacts?: Compacts<TProps, TActions, TEvents>,
|
|
101
125
|
//onsets?: Onsets<TProps, TActions>,
|
|
102
126
|
handlers?: Handlers<ETProps, TActions>,
|
|
103
127
|
hitches?: Hitches<TProps, TActions>,
|
|
104
128
|
positractions?: Positractions<TProps>,
|
|
105
129
|
merges?: Merges<TProps>,
|
|
130
|
+
yields?: Yields<TProps>,
|
|
131
|
+
/**
|
|
132
|
+
* Properties to explicitly monitor and propagate changes for.
|
|
133
|
+
* Use this to ensure getter/setters are installed for properties
|
|
134
|
+
* that aren't referenced by actions, compacts, merges, etc.
|
|
135
|
+
* but still need to fire propagator events (e.g., attribute-parsed
|
|
136
|
+
* properties that other features subscribe to).
|
|
137
|
+
*/
|
|
138
|
+
propagate?: keyof TProps & string | Array<keyof TProps & string>,
|
|
106
139
|
/**
|
|
107
140
|
* Configure automatic WeakRef wrapping for properties
|
|
108
141
|
*
|
|
@@ -130,7 +163,6 @@ export interface RoundaboutOptions<TProps = unknown, TActions = TProps, ETProps
|
|
|
130
163
|
vm?: TProps & TActions & RoundaboutReady,
|
|
131
164
|
//for enhanced elements, pass in the container, referenced via $0.
|
|
132
165
|
container?: EventTarget,
|
|
133
|
-
propagate?: keyof TProps & string | Array<keyof TProps & string>,
|
|
134
166
|
|
|
135
167
|
//mountObservers?: Set<IMountObserver>
|
|
136
168
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SpawnContext } from "../assign-gingerly/types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Context passed to the TemplateMaker feature constructor
|
|
5
|
+
*/
|
|
6
|
+
export interface FeatureSpawnContext extends SpawnContext {
|
|
7
|
+
key: string;
|
|
8
|
+
optIn: any;
|
|
9
|
+
injection: any;
|
|
10
|
+
featuresRegistry: any;
|
|
11
|
+
shared?: any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Tracks whether the seed DOM fragment came from a shadow root or light DOM children.
|
|
16
|
+
*/
|
|
17
|
+
export type TemplateSource = 'shadow' | 'light';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Properties that the TemplateMaker feature exposes.
|
|
21
|
+
*/
|
|
22
|
+
export interface TemplateMakerProps {
|
|
23
|
+
/**
|
|
24
|
+
* The cloned DocumentFragment from the stored template.
|
|
25
|
+
*/
|
|
26
|
+
clone: DocumentFragment | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Internal state
|
|
31
|
+
*/
|
|
32
|
+
export interface AllProps extends TemplateMakerProps {
|
|
33
|
+
/**
|
|
34
|
+
* WeakRef to the host custom element
|
|
35
|
+
*/
|
|
36
|
+
hostRef: WeakRef<Element> | null;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Whether the template source was shadow DOM or light DOM.
|
|
40
|
+
*/
|
|
41
|
+
templateSource: TemplateSource | null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type AP = AllProps;
|
|
45
|
+
export type PAP = Partial<AP>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { SpawnContext } from "../assign-gingerly/types";
|
|
2
|
+
import {FaceUpProps} from "../face-up/types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration/properties that the TimeTicker feature exposes
|
|
6
|
+
*/
|
|
7
|
+
export interface FeatureProps {
|
|
8
|
+
/**
|
|
9
|
+
* Duration in milliseconds between ticks
|
|
10
|
+
*/
|
|
11
|
+
duration: number;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Whether the ticker is disabled (stops ticking when true)
|
|
15
|
+
*/
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Internal state (not exposed to consumers)
|
|
21
|
+
*/
|
|
22
|
+
export interface AllFeatureProps extends FeatureProps {
|
|
23
|
+
host: WeakRef<Element>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type AFP = AllFeatureProps;
|
|
27
|
+
export type PAFP = Partial<AFP>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Context passed to the feature constructor
|
|
31
|
+
*/
|
|
32
|
+
export interface FeatureSpawnContext extends SpawnContext {
|
|
33
|
+
key: string;
|
|
34
|
+
optIn: any;
|
|
35
|
+
injection: any;
|
|
36
|
+
featuresRegistry: any;
|
|
37
|
+
shared?: any;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface TimeTickerElementEndUserProps<T = any> extends FaceUpProps {
|
|
41
|
+
/**
|
|
42
|
+
* Duration in milliseconds between ticks
|
|
43
|
+
*/
|
|
44
|
+
duration: number;
|
|
45
|
+
|
|
46
|
+
items: T[];
|
|
47
|
+
|
|
48
|
+
name: string;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface TimeTickerElementAllProps<T = any> extends TimeTickerElementEndUserProps{
|
|
53
|
+
item: T;
|
|
54
|
+
|
|
55
|
+
idx: number;
|
|
56
|
+
|
|
57
|
+
timeTicker: EventTarget;
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type T = TimeTickerElementAllProps;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { SpawnContext } from "../assign-gingerly/types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Context passed to the TruthSourcer feature constructor
|
|
5
|
+
*/
|
|
6
|
+
export interface FeatureSpawnContext extends SpawnContext {
|
|
7
|
+
key: string;
|
|
8
|
+
optIn: any;
|
|
9
|
+
injection: any;
|
|
10
|
+
featuresRegistry: any;
|
|
11
|
+
shared?: any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Properties that the TruthSourcer feature manages
|
|
16
|
+
*/
|
|
17
|
+
export interface TruthSourcerProps {
|
|
18
|
+
/**
|
|
19
|
+
* The EventTarget that the host element uses to propagate property change events.
|
|
20
|
+
* TruthSourcer listens for events matching attribute names to sync property -> attribute.
|
|
21
|
+
*/
|
|
22
|
+
hostPropagator: EventTarget | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Internal state
|
|
27
|
+
*/
|
|
28
|
+
export interface AllProps extends TruthSourcerProps {
|
|
29
|
+
/**
|
|
30
|
+
* WeakRef to the host custom element
|
|
31
|
+
*/
|
|
32
|
+
hostRef: WeakRef<HTMLElement> | null;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The list of observed attribute names (from static observedAttributes)
|
|
36
|
+
*/
|
|
37
|
+
observedAttributes: string[];
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* AbortController for cleaning up event listeners
|
|
41
|
+
*/
|
|
42
|
+
abortController: AbortController | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type AP = AllProps;
|
|
46
|
+
export type PAP = Partial<AP>;
|