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,255 @@
|
|
|
1
|
+
export type Key<T = any> = keyof T & string;
|
|
2
|
+
|
|
3
|
+
export type Keysh<T = any> = Key<T> | Array<Key<T>>;
|
|
4
|
+
|
|
5
|
+
type PropsToProps<Props> = (x: Props) => (Promise<Partial<Props>> | Partial<Props>)
|
|
6
|
+
|
|
7
|
+
export interface LogicOp<Props = any, TActions = Props>{
|
|
8
|
+
/**
|
|
9
|
+
* Supported by trans-render
|
|
10
|
+
*/
|
|
11
|
+
ifAllOf?: Keysh<Props>,
|
|
12
|
+
|
|
13
|
+
ifKeyIn?: Keysh<Props>,
|
|
14
|
+
|
|
15
|
+
ifNoneOf?: Keysh<Props>,
|
|
16
|
+
|
|
17
|
+
ifEquals?: Array<Key<Props>>,
|
|
18
|
+
|
|
19
|
+
ifAtLeastOneOf?: Keysh<Props>,
|
|
20
|
+
|
|
21
|
+
ifNotAllOf?: Keysh<Props>,
|
|
22
|
+
|
|
23
|
+
debug?: boolean,
|
|
24
|
+
|
|
25
|
+
delay?: number,
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Extends LogicOp with a `do` property for specifying which function to call.
|
|
31
|
+
* Used by positractions where the function is generic and view-model-neutral.
|
|
32
|
+
*/
|
|
33
|
+
export interface LogicOpWithDo<Props = any, TActions = Props> extends LogicOp<Props, TActions>{
|
|
34
|
+
do?:
|
|
35
|
+
| Function
|
|
36
|
+
| (keyof TActions & string)
|
|
37
|
+
| PropsToProps<Props>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type Actions<TProps = any, TActions = TProps> =
|
|
41
|
+
Partial<{[key in keyof TActions & string]: LogicOp<TProps>}>
|
|
42
|
+
//& Partial<{[key in `do_${keyof TActions & string}_on`]: Key<TActions> | Array<Key<TActions>> }>
|
|
43
|
+
;
|
|
44
|
+
|
|
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}>
|
|
47
|
+
| Partial<{[key in `pass_length_of_${keyof TProps & string}_to_${keyof TProps & string}`]: number}>
|
|
48
|
+
| Partial<{[key in `echo_${keyof TProps & string}_to_${keyof TProps & string}`]: number}>
|
|
49
|
+
| Partial<{[key in `echo_${keyof TProps & string}_to_${keyof TProps & string}_after`]: keyof TProps}>
|
|
50
|
+
| Partial<{[key in `when_${keyof TProps & string}_changes_call_${keyof TActions & string}`]: number}>
|
|
51
|
+
| Partial<{[key in `when_${keyof TProps & string}_changes_toggle_${keyof TProps & string}`]: number}>
|
|
52
|
+
| Partial<{[key in `when_${keyof TProps & string}_changes_inc_${keyof TProps & string}_by`]: number}>
|
|
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}>
|
|
56
|
+
;
|
|
57
|
+
|
|
58
|
+
export type Hitches<TProps = any, TActions = TProps> =
|
|
59
|
+
| Partial<{[key in `when_${keyof TProps & string}_emits_${keyof TProps & string}_inc_${keyof TProps & string}_by`]: number}>
|
|
60
|
+
;
|
|
61
|
+
|
|
62
|
+
export type Handlers<ETProps = any, TActions = ETProps> =
|
|
63
|
+
| Partial<{[key in `${keyof ETProps & string}_to_${keyof TActions & string}_on` & string]: string }>;
|
|
64
|
+
|
|
65
|
+
export type Positractions<TProps = any, TActions = TProps> =
|
|
66
|
+
| Array<Positraction<TProps, TActions>>;
|
|
67
|
+
|
|
68
|
+
export interface Positraction<TProps = any, TActions = TProps> extends LogicOpWithDo<TProps, TActions> {
|
|
69
|
+
do:
|
|
70
|
+
| Function
|
|
71
|
+
| (keyof TActions & string)
|
|
72
|
+
| PropsToProps<TProps>
|
|
73
|
+
ifKeyIn?: Array<keyof TProps & string>,
|
|
74
|
+
ifAllOf?: Array<keyof TProps & string>,
|
|
75
|
+
//ifNoneOf: Array<keyof TProps & string>,
|
|
76
|
+
|
|
77
|
+
pass?: Array<(keyof TProps & string) | number | boolean | '$0' | '$0+' | `\`${string}\``>,
|
|
78
|
+
assignTo?: Array<null | (keyof TProps & string)>
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A merge is a fully JSON-serializable reactive rule.
|
|
83
|
+
* When its conditions are met, it calls assignFrom(vm, assignFrom, { from: vm })
|
|
84
|
+
* to resolve RHS path strings against the vm and assign the results into the vm.
|
|
85
|
+
* No method or code is required.
|
|
86
|
+
*/
|
|
87
|
+
export interface Merge<TProps = any> extends LogicOp<TProps> {
|
|
88
|
+
/**
|
|
89
|
+
* Pattern object whose keys are LHS assignGingerly paths and whose
|
|
90
|
+
* values are RHS `?.`-prefixed path strings resolved against the vm.
|
|
91
|
+
*/
|
|
92
|
+
assign: Record<string, any>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export type Merges<TProps = any> = Array<Merge<TProps>>;
|
|
96
|
+
|
|
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 > {
|
|
123
|
+
actions?: Actions<TProps,TActions>,
|
|
124
|
+
compacts?: Compacts<TProps, TActions, TEvents>,
|
|
125
|
+
//onsets?: Onsets<TProps, TActions>,
|
|
126
|
+
handlers?: Handlers<ETProps, TActions>,
|
|
127
|
+
hitches?: Hitches<TProps, TActions>,
|
|
128
|
+
positractions?: Positractions<TProps>,
|
|
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>,
|
|
139
|
+
/**
|
|
140
|
+
* Configure automatic WeakRef wrapping for properties
|
|
141
|
+
*
|
|
142
|
+
* Properties listed here will automatically wrap values in WeakRef when set,
|
|
143
|
+
* and automatically deref when accessed. This prevents memory leaks for
|
|
144
|
+
* DOM elements and other objects that should be garbage collected.
|
|
145
|
+
*
|
|
146
|
+
* Options:
|
|
147
|
+
* - Array of property names: ['trigger', 'enhancedElement']
|
|
148
|
+
* - Object with configuration: { properties: ['trigger'], logIfCollected: 'warn' }
|
|
149
|
+
*
|
|
150
|
+
* When a WeakRef'd value is garbage collected, the getter returns undefined.
|
|
151
|
+
* Use logIfCollected to get notified when this happens.
|
|
152
|
+
*/
|
|
153
|
+
weakRef?: WeakRefConfig<TProps>,
|
|
154
|
+
|
|
155
|
+
defaultPropVals?: Partial<{[key in keyof TProps & string]: unknown}>,
|
|
156
|
+
|
|
157
|
+
customData?: TCustomData,
|
|
158
|
+
|
|
159
|
+
initialPropVals?: Partial<{[key in keyof TProps & string]: unknown}>,
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface RoundaboutOptions<TProps = unknown, TActions = TProps, ETProps = TProps> extends RAConfig<TProps, TActions, ETProps> {
|
|
163
|
+
vm?: TProps & TActions & RoundaboutReady,
|
|
164
|
+
//for enhanced elements, pass in the container, referenced via $0.
|
|
165
|
+
container?: EventTarget,
|
|
166
|
+
|
|
167
|
+
//mountObservers?: Set<IMountObserver>
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Enable internal routing optimization for actions (default: false)
|
|
171
|
+
*
|
|
172
|
+
* When true: Action results are batched and cascaded before firing events.
|
|
173
|
+
* - Eliminates redundant action calls in diamond dependency patterns
|
|
174
|
+
* - More predictable: actions run once per logical change
|
|
175
|
+
* - Best for: Complex cascades, multiple properties returned from actions
|
|
176
|
+
*
|
|
177
|
+
* When false: Uses traditional approach with immediate event firing.
|
|
178
|
+
* - Simpler execution model, easier to debug
|
|
179
|
+
* - Slightly faster for simple linear cascades
|
|
180
|
+
* - Best for: Simple cascades, performance-critical paths
|
|
181
|
+
*
|
|
182
|
+
* Enable if you have:
|
|
183
|
+
* - Actions that return multiple properties
|
|
184
|
+
* - Multiple actions monitoring the same properties
|
|
185
|
+
* - Diamond dependencies (A→B, A→C, B→D, C→D)
|
|
186
|
+
*/
|
|
187
|
+
internalRouting?: boolean,
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Options passed to every internal assignGingerly call.
|
|
191
|
+
* See IAssignGingerlyOptions in assign-gingerly for details.
|
|
192
|
+
*/
|
|
193
|
+
assignGingerlyOptions?: import('../assign-gingerly/types.js').IAssignGingerlyOptions,
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Configuration for automatic WeakRef wrapping
|
|
200
|
+
*/
|
|
201
|
+
export interface WeakRefConfig<TProps = any> {
|
|
202
|
+
/**
|
|
203
|
+
* Properties to automatically wrap in WeakRef
|
|
204
|
+
*/
|
|
205
|
+
properties: Array<keyof TProps & string>;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Logging behavior when deref returns null/undefined
|
|
209
|
+
* - 'error': console.error (default)
|
|
210
|
+
* - 'warn': console.warn
|
|
211
|
+
* - 'silent': no logging
|
|
212
|
+
* - function: custom logging function
|
|
213
|
+
*/
|
|
214
|
+
logIfCollected?: 'error' | 'warn' | 'silent' | ((propName: string) => void);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface RoundaboutReady{
|
|
218
|
+
/**
|
|
219
|
+
* Allow for assigning to read only props via the "backdoor"
|
|
220
|
+
* Bypasses getters / setters, sets directly to (private) memory slots
|
|
221
|
+
* Doesn't do any notification
|
|
222
|
+
* Allows for nested property setting
|
|
223
|
+
*/
|
|
224
|
+
covertAssignment(obj: any): Promise<void>;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* fires event with name matching the name of the property when the value changes (but not via covertAssignment)
|
|
228
|
+
* when property is set via public interface, not (immediately) via an action method's return object
|
|
229
|
+
*/
|
|
230
|
+
readonly propagator : EventTarget | undefined;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
* https://github.com/whatwg/dom/issues/1296
|
|
235
|
+
*/
|
|
236
|
+
//readonly disconnectedSignal: AbortSignal
|
|
237
|
+
|
|
238
|
+
RAController: AbortController;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* During this time, queues/buses continue to perform "bookkeeping"
|
|
242
|
+
* but doesn't process the queue until sleep property becomes falsy.
|
|
243
|
+
* If truthy, can call await awake() before processing should resume
|
|
244
|
+
* [TODO]
|
|
245
|
+
*/
|
|
246
|
+
readonly sleep?: number | undefined;
|
|
247
|
+
|
|
248
|
+
awake(): Promise<void>;
|
|
249
|
+
|
|
250
|
+
//make the value sleep 1 step closer to be falsy
|
|
251
|
+
nudge(): void;
|
|
252
|
+
|
|
253
|
+
//make the value of sleep 1 step further away from being falsy
|
|
254
|
+
rock(): void;
|
|
255
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { SpawnContext } from "../assign-gingerly/types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration/properties that the TimeTicker feature exposes
|
|
5
|
+
*/
|
|
6
|
+
export interface FeatureProps {
|
|
7
|
+
/**
|
|
8
|
+
* Duration in milliseconds between ticks
|
|
9
|
+
*/
|
|
10
|
+
duration: number;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Whether the ticker is disabled (stops ticking when true)
|
|
14
|
+
*/
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal state (not exposed to consumers)
|
|
20
|
+
*/
|
|
21
|
+
export interface AllFeatureProps extends FeatureProps {
|
|
22
|
+
host: WeakRef<Element>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type AFP = AllFeatureProps;
|
|
26
|
+
export type PAFP = Partial<AFP>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Context passed to the feature constructor
|
|
30
|
+
*/
|
|
31
|
+
export interface FeatureSpawnContext extends SpawnContext {
|
|
32
|
+
key: string;
|
|
33
|
+
optIn: any;
|
|
34
|
+
injection: any;
|
|
35
|
+
featuresRegistry: any;
|
|
36
|
+
shared?: any;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface TimeTickerElementEndUserProps<T = any> {
|
|
40
|
+
/**
|
|
41
|
+
* Duration in milliseconds between ticks
|
|
42
|
+
*/
|
|
43
|
+
duration: number;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Whether the ticker is disabled (stops ticking when true)
|
|
47
|
+
*/
|
|
48
|
+
disabled: boolean;
|
|
49
|
+
|
|
50
|
+
items: T[];
|
|
51
|
+
|
|
52
|
+
name: string;
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface TimeTickerElementAllProps<T = any> extends TimeTickerElementEndUserProps{
|
|
57
|
+
item: T;
|
|
58
|
+
|
|
59
|
+
idx: number;
|
|
60
|
+
|
|
61
|
+
timeTicker: EventTarget;
|
|
62
|
+
|
|
63
|
+
value: any;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
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>;
|