@context-action/core 1.2.6 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +31 -1
  3. package/dist/element-BRlY61kW.cjs +631 -0
  4. package/dist/element-BTaXgo7n.js +597 -0
  5. package/dist/element-BTaXgo7n.js.map +1 -0
  6. package/dist/element-DPioFL7C.d.cts +163 -0
  7. package/dist/element-DPioFL7C.d.cts.map +1 -0
  8. package/dist/element-DPioFL7C.d.ts +163 -0
  9. package/dist/element-DPioFL7C.d.ts.map +1 -0
  10. package/dist/element-react.cjs +91 -0
  11. package/dist/element-react.d.cts +11 -0
  12. package/dist/element-react.d.cts.map +1 -0
  13. package/dist/element-react.d.ts +11 -0
  14. package/dist/element-react.d.ts.map +1 -0
  15. package/dist/element-react.js +85 -0
  16. package/dist/element-react.js.map +1 -0
  17. package/dist/element.cjs +9 -0
  18. package/dist/element.d.cts +3 -0
  19. package/dist/element.d.ts +3 -0
  20. package/dist/element.js +3 -0
  21. package/dist/index.cjs +154 -47
  22. package/dist/index.d.cts +2 -1
  23. package/dist/index.d.cts.map +1 -1
  24. package/dist/index.d.ts +2 -1
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +154 -47
  27. package/dist/index.js.map +1 -1
  28. package/dist/public-action-methods-C_ppItRr.d.cts +5 -0
  29. package/dist/public-action-methods-C_ppItRr.d.cts.map +1 -0
  30. package/dist/public-action-methods-C_ppItRr.d.ts +5 -0
  31. package/dist/public-action-methods-C_ppItRr.d.ts.map +1 -0
  32. package/docs/action-contracts.md +78 -0
  33. package/docs/element-host-patterns.en.md +129 -0
  34. package/docs/element-host-patterns.ko.md +116 -0
  35. package/docs/element-interop.md +138 -0
  36. package/docs/interop-review.en.md +55 -0
  37. package/docs/interop-review.ko.md +51 -0
  38. package/package.json +35 -4
@@ -0,0 +1,597 @@
1
+ //#region src/facade/create-public-facade.ts
2
+ function findDescriptor(target, key) {
3
+ let current = target;
4
+ while (current) {
5
+ const descriptor = Object.getOwnPropertyDescriptor(current, key);
6
+ if (descriptor) return descriptor;
7
+ current = Object.getPrototypeOf(current);
8
+ }
9
+ }
10
+ /** Allow-list projection, not a sandbox or revocable command capability. */
11
+ function createPublicFacade(keys, detachedMessage = "Public handle target is not available") {
12
+ const uniqueKeys = Array.from(new Set(keys));
13
+ return (getElement) => {
14
+ const requireElement = () => {
15
+ const element = getElement();
16
+ if (!element) throw new Error(detachedMessage);
17
+ return element;
18
+ };
19
+ const methods = /* @__PURE__ */ new WeakMap();
20
+ const facade = {};
21
+ for (const key of uniqueKeys) Object.defineProperty(facade, key, {
22
+ configurable: false,
23
+ enumerable: true,
24
+ get() {
25
+ const element = requireElement();
26
+ const value = Reflect.get(element, key, element);
27
+ if (typeof value !== "function") return value;
28
+ let cache = methods.get(element);
29
+ if (!cache) {
30
+ cache = /* @__PURE__ */ new Map();
31
+ methods.set(element, cache);
32
+ }
33
+ const cached = cache.get(key);
34
+ if (cached?.source === value) return cached.bound;
35
+ const bound = value.bind(element);
36
+ cache.set(key, {
37
+ source: value,
38
+ bound
39
+ });
40
+ return bound;
41
+ },
42
+ set(value) {
43
+ const element = requireElement();
44
+ const descriptor = findDescriptor(element, key);
45
+ if (descriptor && !descriptor.set && !descriptor.writable || !Reflect.set(element, key, value, element)) throw new TypeError(`Cannot assign to read-only property '${String(key)}'`);
46
+ }
47
+ });
48
+ return Object.freeze(facade);
49
+ };
50
+ }
51
+
52
+ //#endregion
53
+ //#region src/element/create-element-facade.ts
54
+ /** DOM specialization of the internal object projection; not a revocable capability. */
55
+ function createElementFacade(keys) {
56
+ return createPublicFacade(keys, "Custom element handle is not mounted");
57
+ }
58
+
59
+ //#endregion
60
+ //#region src/element/attribute-bindings.ts
61
+ /** Only attempted attribute writes are owned. Omission releases ownership once via removeAttribute. */
62
+ function createAttributeBindings(element, attributes, active) {
63
+ const applied = /* @__PURE__ */ new Set();
64
+ return (input) => {
65
+ for (const [key, attrName] of attributes) {
66
+ if (!active()) return;
67
+ if (key in input) {
68
+ const value = input[key];
69
+ if (!active()) return;
70
+ applied.add(key);
71
+ if (value === null || value === void 0 || value === false) element.removeAttribute(attrName);
72
+ else if (value === true) element.setAttribute(attrName, "");
73
+ else element.setAttribute(attrName, String(value));
74
+ } else if (applied.delete(key)) element.removeAttribute(attrName);
75
+ }
76
+ };
77
+ }
78
+
79
+ //#endregion
80
+ //#region src/element/event-bindings.ts
81
+ function isHandler(value) {
82
+ return typeof value === "function" || typeof value === "object" && value !== null && typeof value.handleEvent === "function";
83
+ }
84
+ function createEventBindings(element, events, active) {
85
+ const bindings = /* @__PURE__ */ new Map();
86
+ function remove(key, binding) {
87
+ binding.active = false;
88
+ bindings.delete(key);
89
+ element.removeEventListener(binding.eventName, binding.listener);
90
+ }
91
+ return {
92
+ update(input) {
93
+ const handlers = input;
94
+ for (const [key, eventName] of events) {
95
+ if (!active()) return;
96
+ const handler = handlers[key];
97
+ const old = bindings.get(key);
98
+ if (old?.handler === handler) continue;
99
+ if (old) remove(key, old);
100
+ if (!active()) return;
101
+ if (!isHandler(handler)) continue;
102
+ const binding = {
103
+ handler,
104
+ eventName,
105
+ active: true,
106
+ listener(event) {
107
+ if (!active() || !binding.active) return;
108
+ if (typeof handler === "function") handler(event);
109
+ else handler.handleEvent(event);
110
+ }
111
+ };
112
+ bindings.set(key, binding);
113
+ try {
114
+ element.addEventListener(eventName, binding.listener);
115
+ } catch (error) {
116
+ remove(key, binding);
117
+ throw error;
118
+ }
119
+ if (!active()) remove(key, binding);
120
+ }
121
+ },
122
+ disconnect() {
123
+ for (const [key, binding] of bindings) remove(key, binding);
124
+ }
125
+ };
126
+ }
127
+
128
+ //#endregion
129
+ //#region src/element/property-bindings.ts
130
+ /** Only attempted bridge writes are owned. Omission releases ownership even if reset is rejected. */
131
+ function createPropertyBindings(element, properties, active, assignmentErrors) {
132
+ const applied = /* @__PURE__ */ new Set();
133
+ const host = element;
134
+ return (input) => {
135
+ for (const key of properties) {
136
+ if (!active()) return;
137
+ if (key in input) {
138
+ const value = input[key];
139
+ if (!active()) return;
140
+ applied.add(key);
141
+ try {
142
+ host[key] = value;
143
+ } catch (error) {
144
+ if (assignmentErrors === "throw") throw error;
145
+ }
146
+ } else if (applied.delete(key)) try {
147
+ host[key] = void 0;
148
+ } catch {}
149
+ }
150
+ };
151
+ }
152
+
153
+ //#endregion
154
+ //#region src/element/style-bindings.ts
155
+ /** Only attempted style writes are owned. Omission releases ownership once via removeProperty. */
156
+ function createStyleBindings(element, styles, active) {
157
+ const applied = /* @__PURE__ */ new Set();
158
+ return (input) => {
159
+ for (const [key, cssProperty] of styles) {
160
+ if (!active()) return;
161
+ if (key in input) {
162
+ const value = input[key];
163
+ if (!active()) return;
164
+ applied.add(key);
165
+ if (value === null || value === void 0 || value === "") element.style.removeProperty(cssProperty);
166
+ else element.style.setProperty(cssProperty, String(value));
167
+ } else if (applied.delete(key)) element.style.removeProperty(cssProperty);
168
+ }
169
+ };
170
+ }
171
+
172
+ //#endregion
173
+ //#region src/element/create-element-binding.ts
174
+ /** Framework-neutral DOM transport. Lifecycle adapters supply complete snapshots, not patches. */
175
+ function createElementBinding(element, config, options = {}) {
176
+ let disposed = false;
177
+ let updating = false;
178
+ const active = () => !disposed;
179
+ const properties = createPropertyBindings(element, Array.from(new Set(config.properties ?? [])), active, options.assignmentErrors ?? "ignore");
180
+ const attributes = createAttributeBindings(element, Object.entries(config.attributes ?? {}), active);
181
+ const styles = createStyleBindings(element, Object.entries(config.styles ?? {}), active);
182
+ const events = createEventBindings(element, Object.entries(config.events ?? {}), active);
183
+ function run(update) {
184
+ if (disposed) throw new Error("Element binding is disposed");
185
+ if (updating) throw new Error("Element binding update is already in progress");
186
+ updating = true;
187
+ try {
188
+ update();
189
+ } finally {
190
+ updating = false;
191
+ }
192
+ }
193
+ return {
194
+ get disposed() {
195
+ return disposed;
196
+ },
197
+ update(input) {
198
+ run(() => {
199
+ events.update(input);
200
+ if (active()) attributes(input);
201
+ if (active()) styles(input);
202
+ if (active()) properties(input);
203
+ });
204
+ },
205
+ updateProperties(input) {
206
+ run(() => properties(input));
207
+ },
208
+ updateAttributes(input) {
209
+ run(() => attributes(input));
210
+ },
211
+ updateStyles(input) {
212
+ run(() => styles(input));
213
+ },
214
+ updateEvents(input) {
215
+ run(() => events.update(input));
216
+ },
217
+ disconnectEvents() {
218
+ events.disconnect();
219
+ },
220
+ dispose() {
221
+ disposed = true;
222
+ events.disconnect();
223
+ }
224
+ };
225
+ }
226
+
227
+ //#endregion
228
+ //#region src/element/pointer-gesture-session.ts
229
+ const DEFAULT_MODIFIERS = {
230
+ shiftKey: false,
231
+ altKey: false,
232
+ ctrlKey: false,
233
+ metaKey: false
234
+ };
235
+ function readModifiers(event) {
236
+ return {
237
+ shiftKey: Boolean(event.shiftKey),
238
+ altKey: Boolean(event.altKey),
239
+ ctrlKey: Boolean(event.ctrlKey),
240
+ metaKey: Boolean(event.metaKey)
241
+ };
242
+ }
243
+ function createIdleSnapshot() {
244
+ return {
245
+ active: false,
246
+ pointerId: null,
247
+ startX: 0,
248
+ startY: 0,
249
+ currentX: 0,
250
+ currentY: 0,
251
+ deltaX: 0,
252
+ deltaY: 0,
253
+ modifiers: { ...DEFAULT_MODIFIERS }
254
+ };
255
+ }
256
+ function cloneSnapshot(snapshot) {
257
+ return {
258
+ ...snapshot,
259
+ modifiers: { ...snapshot.modifiers }
260
+ };
261
+ }
262
+ function createPointerGestureSession(options = {}) {
263
+ let disposed = false;
264
+ let snapshot = createIdleSnapshot();
265
+ let captureTarget = null;
266
+ const releaseCapture = () => {
267
+ if (captureTarget && snapshot.pointerId !== null) try {
268
+ captureTarget.releasePointerCapture?.(snapshot.pointerId);
269
+ } catch {}
270
+ captureTarget = null;
271
+ };
272
+ return {
273
+ start(event) {
274
+ if (disposed || snapshot.active) return false;
275
+ if (event.button !== void 0 && event.button !== 0) return false;
276
+ const pointerId = event.pointerId ?? 0;
277
+ const next = {
278
+ active: true,
279
+ pointerId,
280
+ startX: event.clientX,
281
+ startY: event.clientY,
282
+ currentX: event.clientX,
283
+ currentY: event.clientY,
284
+ deltaX: 0,
285
+ deltaY: 0,
286
+ modifiers: readModifiers(event)
287
+ };
288
+ if (options.onStart?.(cloneSnapshot(next)) === false || disposed) return false;
289
+ snapshot = next;
290
+ captureTarget = event.currentTarget ?? null;
291
+ if (captureTarget) try {
292
+ captureTarget.setPointerCapture?.(pointerId);
293
+ } catch {}
294
+ return true;
295
+ },
296
+ move(event) {
297
+ if (disposed || !snapshot.active) return false;
298
+ if (event.pointerId !== void 0 && event.pointerId !== snapshot.pointerId) return false;
299
+ snapshot = {
300
+ ...snapshot,
301
+ currentX: event.clientX,
302
+ currentY: event.clientY,
303
+ deltaX: event.clientX - snapshot.startX,
304
+ deltaY: event.clientY - snapshot.startY,
305
+ modifiers: readModifiers(event)
306
+ };
307
+ options.onMove?.(cloneSnapshot(snapshot));
308
+ return true;
309
+ },
310
+ commit(event) {
311
+ if (disposed || !snapshot.active) return false;
312
+ if (event?.pointerId !== void 0 && event.pointerId !== snapshot.pointerId) return false;
313
+ if (event && Number.isFinite(event.clientX) && Number.isFinite(event.clientY)) snapshot = {
314
+ ...snapshot,
315
+ currentX: event.clientX,
316
+ currentY: event.clientY,
317
+ deltaX: event.clientX - snapshot.startX,
318
+ deltaY: event.clientY - snapshot.startY,
319
+ modifiers: readModifiers(event)
320
+ };
321
+ releaseCapture();
322
+ snapshot = {
323
+ ...snapshot,
324
+ active: false
325
+ };
326
+ options.onCommit?.(cloneSnapshot(snapshot));
327
+ return true;
328
+ },
329
+ cancel(reason) {
330
+ if (disposed || !snapshot.active) return false;
331
+ releaseCapture();
332
+ snapshot = {
333
+ ...snapshot,
334
+ active: false
335
+ };
336
+ options.onCancel?.(cloneSnapshot(snapshot), reason);
337
+ return true;
338
+ },
339
+ handleKeyDown(event) {
340
+ if (disposed || !snapshot.active || event.key !== "Escape") return false;
341
+ event.preventDefault?.();
342
+ this.cancel("escape");
343
+ return true;
344
+ },
345
+ isActive() {
346
+ return !disposed && snapshot.active;
347
+ },
348
+ getSnapshot() {
349
+ return cloneSnapshot(snapshot);
350
+ },
351
+ dispose() {
352
+ if (disposed) return;
353
+ disposed = true;
354
+ releaseCapture();
355
+ snapshot = {
356
+ ...snapshot,
357
+ active: false
358
+ };
359
+ }
360
+ };
361
+ }
362
+
363
+ //#endregion
364
+ //#region src/element/roving-focus.ts
365
+ function isForwardKey(key, orientation) {
366
+ if (orientation === "horizontal") return key === "ArrowRight";
367
+ if (orientation === "vertical") return key === "ArrowDown";
368
+ return key === "ArrowRight" || key === "ArrowDown";
369
+ }
370
+ function isBackwardKey(key, orientation) {
371
+ if (orientation === "horizontal") return key === "ArrowLeft";
372
+ if (orientation === "vertical") return key === "ArrowUp";
373
+ return key === "ArrowLeft" || key === "ArrowUp";
374
+ }
375
+ function createRovingFocusController(options) {
376
+ const orientation = options.orientation ?? "horizontal";
377
+ const loop = options.loop ?? true;
378
+ const getEnabledItems = () => options.getItems().filter((item) => !item.disabled);
379
+ const resolveEffectiveActiveId = (enabled) => {
380
+ if (enabled.length === 0) return null;
381
+ const requested = options.getActiveId();
382
+ if (requested && enabled.some((item) => item.id === requested)) return requested;
383
+ return enabled[0]?.id ?? null;
384
+ };
385
+ return {
386
+ getTabIndex(itemId) {
387
+ const enabled = getEnabledItems();
388
+ const effectiveId = resolveEffectiveActiveId(enabled);
389
+ return effectiveId !== null && itemId === effectiveId ? 0 : -1;
390
+ },
391
+ handleKeyDown(currentId, event) {
392
+ const enabled = getEnabledItems();
393
+ if (enabled.length === 0) return null;
394
+ let target;
395
+ if (event.key === "Home") target = enabled[0];
396
+ else if (event.key === "End") target = enabled[enabled.length - 1];
397
+ else if (isForwardKey(event.key, orientation) || isBackwardKey(event.key, orientation)) {
398
+ const step = isForwardKey(event.key, orientation) ? 1 : -1;
399
+ const effectiveId = resolveEffectiveActiveId(enabled);
400
+ let idx = enabled.findIndex((item) => item.id === currentId);
401
+ if (idx < 0 && effectiveId !== null) idx = enabled.findIndex((item) => item.id === effectiveId);
402
+ if (idx < 0) idx = 0;
403
+ target = enabled[loop ? (idx + step + enabled.length) % enabled.length : Math.max(0, Math.min(enabled.length - 1, idx + step))];
404
+ } else return null;
405
+ if (!target) return null;
406
+ event.preventDefault?.();
407
+ options.onFocusChange?.(target.id);
408
+ return target.id;
409
+ }
410
+ };
411
+ }
412
+
413
+ //#endregion
414
+ //#region src/element/sync-action-pipeline.ts
415
+ function createSyncActionPipeline(name) {
416
+ const guards = /* @__PURE__ */ new Map();
417
+ const handlers = /* @__PURE__ */ new Map();
418
+ const observers = /* @__PURE__ */ new Map();
419
+ let nextSeq = 1;
420
+ let destroyed = false;
421
+ function addEntry(phaseMap, action, handler, config = {}) {
422
+ if (destroyed) throw new Error(`SyncActionPipeline '${name}' is destroyed`);
423
+ if (typeof handler !== "function") throw new TypeError("Handler must be a function");
424
+ const bucket = phaseMap.get(action) ?? [];
425
+ const entry = {
426
+ id: config.id ?? `${action}-${nextSeq}`,
427
+ seq: nextSeq++,
428
+ priority: config.priority ?? 0,
429
+ when: config.when ?? "success",
430
+ once: Boolean(config.once),
431
+ handler
432
+ };
433
+ const next = [...bucket, entry].sort((a, b) => b.priority - a.priority || a.seq - b.seq);
434
+ phaseMap.set(action, next);
435
+ return () => {
436
+ const current = phaseMap.get(action);
437
+ if (!current) return;
438
+ phaseMap.set(action, current.filter((item) => item !== entry));
439
+ };
440
+ }
441
+ function consumeOnce(phaseMap, action, entry) {
442
+ if (!entry.once) return;
443
+ const list = phaseMap.get(action);
444
+ if (list) phaseMap.set(action, list.filter((item) => item !== entry));
445
+ }
446
+ return {
447
+ name,
448
+ registerGuard(action, handler, config) {
449
+ return addEntry(guards, action, handler, config);
450
+ },
451
+ register(action, handler, config) {
452
+ return addEntry(handlers, action, handler, config);
453
+ },
454
+ registerObserver(action, handler, config) {
455
+ return addEntry(observers, action, handler, config);
456
+ },
457
+ dispatch(action, initialPayload) {
458
+ if (destroyed) throw new Error(`SyncActionPipeline '${name}' is destroyed`);
459
+ let currentPayload = initialPayload;
460
+ let aborted = false;
461
+ let abortReason;
462
+ let result;
463
+ const errors = [];
464
+ for (const entry of [...guards.get(action) ?? []]) {
465
+ consumeOnce(guards, action, entry);
466
+ let entryAborted = false;
467
+ const guardController = {
468
+ abort(reason) {
469
+ aborted = true;
470
+ entryAborted = true;
471
+ abortReason = reason;
472
+ },
473
+ modifyPayload(updater) {
474
+ currentPayload = typeof updater === "function" ? updater(currentPayload) : updater;
475
+ },
476
+ getPayload() {
477
+ return currentPayload;
478
+ }
479
+ };
480
+ try {
481
+ entry.handler(currentPayload, guardController);
482
+ } catch (error) {
483
+ aborted = true;
484
+ abortReason = error instanceof Error ? error.message : String(error);
485
+ errors.push(error);
486
+ }
487
+ if (aborted || entryAborted) break;
488
+ }
489
+ if (!aborted) for (const entry of [...handlers.get(action) ?? []]) {
490
+ consumeOnce(handlers, action, entry);
491
+ const execController = {
492
+ abort(reason) {
493
+ aborted = true;
494
+ abortReason = reason;
495
+ },
496
+ modifyPayload(updater) {
497
+ currentPayload = typeof updater === "function" ? updater(currentPayload) : updater;
498
+ },
499
+ getPayload() {
500
+ return currentPayload;
501
+ },
502
+ setResult(value) {
503
+ result = value;
504
+ },
505
+ getResult() {
506
+ return result;
507
+ }
508
+ };
509
+ try {
510
+ const ret = entry.handler(currentPayload, execController);
511
+ if (ret !== void 0) result = ret;
512
+ } catch (error) {
513
+ errors.push(error);
514
+ break;
515
+ }
516
+ if (aborted) break;
517
+ }
518
+ const success = !aborted && errors.length === 0;
519
+ for (const entry of [...observers.get(action) ?? []]) {
520
+ consumeOnce(observers, action, entry);
521
+ if (entry.when === "success" && !success) continue;
522
+ if (entry.when === "failure" && success) continue;
523
+ try {
524
+ entry.handler(currentPayload, {
525
+ success,
526
+ aborted,
527
+ abortReason,
528
+ result,
529
+ errors: [...errors]
530
+ });
531
+ } catch {}
532
+ }
533
+ return {
534
+ success,
535
+ aborted,
536
+ abortReason,
537
+ payload: currentPayload,
538
+ result,
539
+ errors
540
+ };
541
+ },
542
+ destroy() {
543
+ destroyed = true;
544
+ guards.clear();
545
+ handlers.clear();
546
+ observers.clear();
547
+ }
548
+ };
549
+ }
550
+
551
+ //#endregion
552
+ //#region src/element/to-react-part-props.ts
553
+ const ATTR_TO_REACT_PROP = {
554
+ class: "className",
555
+ for: "htmlFor",
556
+ tabindex: "tabIndex"
557
+ };
558
+ function toReactStyleProperty(cssProperty) {
559
+ if (cssProperty.startsWith("--")) return cssProperty;
560
+ return cssProperty.replace(/-([a-z])/g, (_, ch) => ch.toUpperCase());
561
+ }
562
+ /**
563
+ * Projects a headless part snapshot into React 19 JSX props using an ElementBindingConfig.
564
+ */
565
+ function toReactPartProps(snapshot, config = {}) {
566
+ const reactProps = {};
567
+ const attrEntries = Object.entries(config.attributes ?? {});
568
+ const styleEntries = Object.entries(config.styles ?? {});
569
+ const eventMap = config.events ?? {};
570
+ const record = snapshot;
571
+ for (const [propKey, attrName] of attrEntries) {
572
+ if (!attrName) continue;
573
+ const value = record[propKey];
574
+ if (value === void 0 || value === null || value === false) continue;
575
+ const reactKey = ATTR_TO_REACT_PROP[attrName] ?? attrName;
576
+ reactProps[reactKey] = value === true ? "" : value;
577
+ }
578
+ const styleObj = {};
579
+ let hasStyle = false;
580
+ for (const [propKey, cssProperty] of styleEntries) {
581
+ if (!cssProperty) continue;
582
+ const value = record[propKey];
583
+ if (value === void 0 || value === null || value === "") continue;
584
+ styleObj[toReactStyleProperty(cssProperty)] = String(value);
585
+ hasStyle = true;
586
+ }
587
+ if (hasStyle) reactProps.style = styleObj;
588
+ for (const propKey of Object.keys(eventMap)) {
589
+ const candidate = record[propKey];
590
+ if (typeof candidate === "function") reactProps[propKey] = candidate;
591
+ }
592
+ return reactProps;
593
+ }
594
+
595
+ //#endregion
596
+ export { createElementBinding as a, createPointerGestureSession as i, createSyncActionPipeline as n, createElementFacade as o, createRovingFocusController as r, toReactPartProps as t };
597
+ //# sourceMappingURL=element-BTaXgo7n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element-BTaXgo7n.js","names":[],"sources":["../src/facade/create-public-facade.ts","../src/element/create-element-facade.ts","../src/element/attribute-bindings.ts","../src/element/event-bindings.ts","../src/element/property-bindings.ts","../src/element/style-bindings.ts","../src/element/create-element-binding.ts","../src/element/pointer-gesture-session.ts","../src/element/roving-focus.ts","../src/element/sync-action-pipeline.ts","../src/element/to-react-part-props.ts"],"sourcesContent":["import type { PublicHandleFactory } from './types.js';\n\nfunction findDescriptor(target: object, key: PropertyKey): PropertyDescriptor | undefined {\n let current: object | null = target;\n while (current) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key);\n if (descriptor) return descriptor;\n current = Object.getPrototypeOf(current);\n }\n return undefined;\n}\n\n/** Allow-list projection, not a sandbox or revocable command capability. */\nexport function createPublicFacade<Element extends object, const Keys extends readonly (keyof Element)[]>(\n keys: Keys,\n detachedMessage = 'Public handle target is not available',\n): PublicHandleFactory<Element, Pick<Element, Keys[number]>> {\n const uniqueKeys = Array.from(new Set(keys));\n return getElement => {\n const requireElement = (): Element => {\n const element = getElement();\n if (!element) throw new Error(detachedMessage);\n return element;\n };\n const methods = new WeakMap<Element, Map<PropertyKey, { source: unknown; bound: unknown }>>();\n const facade = {} as Pick<Element, Keys[number]>;\n for (const key of uniqueKeys) {\n Object.defineProperty(facade, key, {\n configurable: false,\n enumerable: true,\n get() {\n const element = requireElement();\n const value: unknown = Reflect.get(element, key, element);\n if (typeof value !== 'function') return value;\n let cache = methods.get(element);\n if (!cache) { cache = new Map(); methods.set(element, cache); }\n const cached = cache.get(key);\n if (cached?.source === value) return cached.bound;\n const bound = value.bind(element);\n cache.set(key, { source: value, bound });\n return bound;\n },\n set(value: unknown) {\n const element = requireElement();\n const descriptor = findDescriptor(element, key);\n if ((descriptor && !descriptor.set && !descriptor.writable) || !Reflect.set(element, key, value, element)) {\n throw new TypeError(`Cannot assign to read-only property '${String(key)}'`);\n }\n },\n });\n }\n return Object.freeze(facade);\n };\n}\n","import { createPublicFacade } from '../facade/create-public-facade.js';\nimport type { ImperativeHandleFactory } from './contracts.js';\n\n/** DOM specialization of the internal object projection; not a revocable capability. */\nexport function createElementFacade<Element extends HTMLElement, const Keys extends readonly (keyof Element)[]>(\n keys: Keys,\n): ImperativeHandleFactory<Element, Pick<Element, Keys[number]>> {\n return createPublicFacade<Element, Keys>(keys, 'Custom element handle is not mounted');\n}\n","/** Only attempted attribute writes are owned. Omission releases ownership once via removeAttribute. */\nexport function createAttributeBindings<Props extends object>(\n element: HTMLElement,\n attributes: readonly (readonly [keyof Props, string])[],\n active: () => boolean,\n) {\n const applied = new Set<keyof Props>();\n return (input: Props): void => {\n for (const [key, attrName] of attributes) {\n if (!active()) return;\n if (key in input) {\n const value = input[key];\n if (!active()) return;\n applied.add(key);\n if (value === null || value === undefined || value === false) {\n element.removeAttribute(attrName);\n } else if (value === true) {\n element.setAttribute(attrName, '');\n } else {\n element.setAttribute(attrName, String(value));\n }\n } else if (applied.delete(key)) {\n element.removeAttribute(attrName);\n }\n }\n };\n}\n","type Handler = ((event: Event) => void) | { handleEvent(event: Event): void };\ninterface Binding {\n handler: Handler;\n eventName: string;\n listener: EventListener;\n active: boolean;\n}\n\nfunction isHandler(value: unknown): value is Handler {\n return typeof value === 'function' || (typeof value === 'object' && value !== null\n && typeof (value as { handleEvent?: unknown }).handleEvent === 'function');\n}\n\nexport function createEventBindings(element: HTMLElement, events: readonly (readonly [string, string])[], active: () => boolean) {\n const bindings = new Map<string, Binding>();\n function remove(key: string, binding: Binding): void {\n binding.active = false;\n bindings.delete(key);\n element.removeEventListener(binding.eventName, binding.listener);\n }\n return {\n update(input: object): void {\n const handlers = input as Record<string, unknown>;\n for (const [key, eventName] of events) {\n if (!active()) return;\n const handler = handlers[key];\n const old = bindings.get(key);\n if (old?.handler === handler) continue;\n if (old) remove(key, old);\n if (!active()) return;\n if (!isHandler(handler)) continue;\n const binding: Binding = {\n handler, eventName, active: true,\n listener(event) {\n if (!active() || !binding.active) return;\n if (typeof handler === 'function') handler(event);\n else handler.handleEvent(event);\n },\n };\n bindings.set(key, binding);\n try { element.addEventListener(eventName, binding.listener); }\n catch (error) { remove(key, binding); throw error; }\n // Defensive against a host overriding addEventListener and disposing reentrantly.\n if (!active()) remove(key, binding);\n }\n },\n disconnect(): void {\n for (const [key, binding] of bindings) remove(key, binding);\n },\n };\n}\n","/** Only attempted bridge writes are owned. Omission releases ownership even if reset is rejected. */\nexport function createPropertyBindings<Props extends object>(\n element: HTMLElement,\n properties: readonly (keyof Props)[],\n active: () => boolean,\n assignmentErrors: 'ignore' | 'throw',\n) {\n const applied = new Set<keyof Props>();\n const host = element as unknown as Record<keyof Props, unknown>;\n return (input: Props): void => {\n for (const key of properties) {\n if (!active()) return;\n if (key in input) {\n const value = input[key];\n if (!active()) return;\n applied.add(key);\n try { host[key] = value; }\n catch (error) { if (assignmentErrors === 'throw') throw error; }\n } else if (applied.delete(key)) {\n try { host[key] = undefined; } catch { /* Omission cleanup is always best-effort. */ }\n }\n }\n };\n}\n","/** Only attempted style writes are owned. Omission releases ownership once via removeProperty. */\nexport function createStyleBindings<Props extends object>(\n element: HTMLElement,\n styles: readonly (readonly [keyof Props, string])[],\n active: () => boolean,\n) {\n const applied = new Set<keyof Props>();\n return (input: Props): void => {\n for (const [key, cssProperty] of styles) {\n if (!active()) return;\n if (key in input) {\n const value = input[key];\n if (!active()) return;\n applied.add(key);\n if (value === null || value === undefined || value === '') {\n element.style.removeProperty(cssProperty);\n } else {\n element.style.setProperty(cssProperty, String(value));\n }\n } else if (applied.delete(key)) {\n element.style.removeProperty(cssProperty);\n }\n }\n };\n}\n","import { createAttributeBindings } from './attribute-bindings.js';\nimport type { ElementBinding, ElementBindingConfig, ElementBindingOptions } from './contracts.js';\nimport { createEventBindings } from './event-bindings.js';\nimport { createPropertyBindings } from './property-bindings.js';\nimport { createStyleBindings } from './style-bindings.js';\n\n/** Framework-neutral DOM transport. Lifecycle adapters supply complete snapshots, not patches. */\nexport function createElementBinding<Props extends object>(\n element: HTMLElement,\n config: ElementBindingConfig<Props>,\n options: ElementBindingOptions = {},\n): ElementBinding<Props> {\n let disposed = false;\n let updating = false;\n const active = () => !disposed;\n const properties = createPropertyBindings(element, Array.from(new Set(config.properties ?? [])), active, options.assignmentErrors ?? 'ignore');\n const attributes = createAttributeBindings(element, Object.entries(config.attributes ?? {}) as [keyof Props, string][], active);\n const styles = createStyleBindings(element, Object.entries(config.styles ?? {}) as [keyof Props, string][], active);\n const events = createEventBindings(element, Object.entries(config.events ?? {}), active);\n function run(update: () => void): void {\n if (disposed) throw new Error('Element binding is disposed');\n if (updating) throw new Error('Element binding update is already in progress');\n updating = true;\n try { update(); } finally { updating = false; }\n }\n return {\n get disposed() { return disposed; },\n update(input) {\n run(() => {\n events.update(input);\n if (active()) attributes(input);\n if (active()) styles(input);\n if (active()) properties(input);\n });\n },\n updateProperties(input) { run(() => properties(input)); },\n updateAttributes(input) { run(() => attributes(input)); },\n updateStyles(input) { run(() => styles(input)); },\n updateEvents(input) { run(() => events.update(input)); },\n disconnectEvents() { events.disconnect(); },\n dispose() { disposed = true; events.disconnect(); },\n };\n}\n","export interface PointerGestureModifiers {\n readonly shiftKey: boolean;\n readonly altKey: boolean;\n readonly ctrlKey: boolean;\n readonly metaKey: boolean;\n}\n\nexport interface PointerGestureSnapshot {\n readonly active: boolean;\n readonly pointerId: number | null;\n readonly startX: number;\n readonly startY: number;\n readonly currentX: number;\n readonly currentY: number;\n readonly deltaX: number;\n readonly deltaY: number;\n readonly modifiers: PointerGestureModifiers;\n}\n\nexport interface PointerCaptureTargetLike {\n setPointerCapture?(pointerId: number): void;\n releasePointerCapture?(pointerId: number): void;\n}\n\nexport interface PointerGestureEventLike {\n readonly pointerId?: number | undefined;\n readonly button?: number | undefined;\n readonly clientX: number;\n readonly clientY: number;\n readonly shiftKey?: boolean | undefined;\n readonly altKey?: boolean | undefined;\n readonly ctrlKey?: boolean | undefined;\n readonly metaKey?: boolean | undefined;\n readonly currentTarget?: PointerCaptureTargetLike | null | undefined;\n}\n\nexport interface PointerGestureKeyEventLike {\n readonly key: string;\n preventDefault?(): void;\n}\n\nexport interface PointerGestureOptions {\n // biome-ignore lint/suspicious/noConfusingVoidType: callback intentionally allows boolean or void.\n onStart?: ((snapshot: PointerGestureSnapshot) => boolean | void) | undefined;\n onMove?: ((snapshot: PointerGestureSnapshot) => void) | undefined;\n onCommit?: ((snapshot: PointerGestureSnapshot) => void) | undefined;\n onCancel?: ((snapshot: PointerGestureSnapshot, reason?: string) => void) | undefined;\n}\n\nexport interface PointerGestureSession {\n start(event: PointerGestureEventLike): boolean;\n move(event: PointerGestureEventLike): boolean;\n commit(event?: PointerGestureEventLike): boolean;\n cancel(reason?: string): boolean;\n handleKeyDown(event: PointerGestureKeyEventLike): boolean;\n isActive(): boolean;\n getSnapshot(): PointerGestureSnapshot;\n dispose(): void;\n}\n\nconst DEFAULT_MODIFIERS: PointerGestureModifiers = {\n shiftKey: false,\n altKey: false,\n ctrlKey: false,\n metaKey: false,\n};\n\nfunction readModifiers(event: Partial<PointerGestureEventLike>): PointerGestureModifiers {\n return {\n shiftKey: Boolean(event.shiftKey),\n altKey: Boolean(event.altKey),\n ctrlKey: Boolean(event.ctrlKey),\n metaKey: Boolean(event.metaKey),\n };\n}\n\nfunction createIdleSnapshot(): PointerGestureSnapshot {\n return {\n active: false,\n pointerId: null,\n startX: 0,\n startY: 0,\n currentX: 0,\n currentY: 0,\n deltaX: 0,\n deltaY: 0,\n modifiers: { ...DEFAULT_MODIFIERS },\n };\n}\n\nfunction cloneSnapshot(snapshot: PointerGestureSnapshot): PointerGestureSnapshot {\n return {\n ...snapshot,\n modifiers: { ...snapshot.modifiers },\n };\n}\n\nexport function createPointerGestureSession(\n options: PointerGestureOptions = {},\n): PointerGestureSession {\n let disposed = false;\n let snapshot = createIdleSnapshot();\n let captureTarget: PointerCaptureTargetLike | null = null;\n\n const releaseCapture = (): void => {\n if (captureTarget && snapshot.pointerId !== null) {\n try {\n captureTarget.releasePointerCapture?.(snapshot.pointerId);\n } catch {\n // Ignore capture release errors when target is detached or synthetic.\n }\n }\n captureTarget = null;\n };\n\n return {\n start(event) {\n if (disposed || snapshot.active) return false;\n if (event.button !== undefined && event.button !== 0) return false;\n\n const pointerId = event.pointerId ?? 0;\n const next: PointerGestureSnapshot = {\n active: true,\n pointerId,\n startX: event.clientX,\n startY: event.clientY,\n currentX: event.clientX,\n currentY: event.clientY,\n deltaX: 0,\n deltaY: 0,\n modifiers: readModifiers(event),\n };\n\n const verdict = options.onStart?.(cloneSnapshot(next));\n if (verdict === false || disposed) return false;\n\n snapshot = next;\n captureTarget = event.currentTarget ?? null;\n if (captureTarget) {\n try {\n captureTarget.setPointerCapture?.(pointerId);\n } catch {\n // Ignore synthetic DOM pointer capture errors.\n }\n }\n return true;\n },\n move(event) {\n if (disposed || !snapshot.active) return false;\n if (event.pointerId !== undefined && event.pointerId !== snapshot.pointerId) return false;\n\n snapshot = {\n ...snapshot,\n currentX: event.clientX,\n currentY: event.clientY,\n deltaX: event.clientX - snapshot.startX,\n deltaY: event.clientY - snapshot.startY,\n modifiers: readModifiers(event),\n };\n options.onMove?.(cloneSnapshot(snapshot));\n return true;\n },\n commit(event) {\n if (disposed || !snapshot.active) return false;\n if (event?.pointerId !== undefined && event.pointerId !== snapshot.pointerId) return false;\n\n if (event && Number.isFinite(event.clientX) && Number.isFinite(event.clientY)) {\n snapshot = {\n ...snapshot,\n currentX: event.clientX,\n currentY: event.clientY,\n deltaX: event.clientX - snapshot.startX,\n deltaY: event.clientY - snapshot.startY,\n modifiers: readModifiers(event),\n };\n }\n\n releaseCapture();\n snapshot = { ...snapshot, active: false };\n options.onCommit?.(cloneSnapshot(snapshot));\n return true;\n },\n cancel(reason) {\n if (disposed || !snapshot.active) return false;\n releaseCapture();\n snapshot = { ...snapshot, active: false };\n options.onCancel?.(cloneSnapshot(snapshot), reason);\n return true;\n },\n handleKeyDown(event) {\n if (disposed || !snapshot.active || event.key !== 'Escape') return false;\n event.preventDefault?.();\n this.cancel('escape');\n return true;\n },\n isActive() {\n return !disposed && snapshot.active;\n },\n getSnapshot() {\n return cloneSnapshot(snapshot);\n },\n dispose() {\n if (disposed) return;\n disposed = true;\n releaseCapture();\n snapshot = { ...snapshot, active: false };\n },\n };\n}\n","export type RovingFocusOrientation = 'horizontal' | 'vertical' | 'both';\n\nexport interface RovingFocusItem {\n readonly id: string;\n readonly disabled?: boolean | undefined;\n}\n\nexport interface RovingFocusKeyEventLike {\n readonly key: string;\n preventDefault?(): void;\n}\n\nexport interface RovingFocusOptions {\n readonly orientation?: RovingFocusOrientation | undefined;\n readonly loop?: boolean | undefined;\n getItems(): readonly RovingFocusItem[];\n getActiveId(): string | null | undefined;\n onFocusChange?: ((nextId: string) => void) | undefined;\n}\n\nexport interface RovingFocusController {\n getTabIndex(itemId: string): 0 | -1;\n handleKeyDown(currentId: string, event: RovingFocusKeyEventLike): string | null;\n}\n\nfunction isForwardKey(key: string, orientation: RovingFocusOrientation): boolean {\n if (orientation === 'horizontal') return key === 'ArrowRight';\n if (orientation === 'vertical') return key === 'ArrowDown';\n return key === 'ArrowRight' || key === 'ArrowDown';\n}\n\nfunction isBackwardKey(key: string, orientation: RovingFocusOrientation): boolean {\n if (orientation === 'horizontal') return key === 'ArrowLeft';\n if (orientation === 'vertical') return key === 'ArrowUp';\n return key === 'ArrowLeft' || key === 'ArrowUp';\n}\n\nexport function createRovingFocusController(options: RovingFocusOptions): RovingFocusController {\n const orientation: RovingFocusOrientation = options.orientation ?? 'horizontal';\n const loop = options.loop ?? true;\n\n const getEnabledItems = (): readonly RovingFocusItem[] =>\n options.getItems().filter(item => !item.disabled);\n\n const resolveEffectiveActiveId = (enabled: readonly RovingFocusItem[]): string | null => {\n if (enabled.length === 0) return null;\n const requested = options.getActiveId();\n if (requested && enabled.some(item => item.id === requested)) return requested;\n return enabled[0]?.id ?? null;\n };\n\n return {\n getTabIndex(itemId) {\n const enabled = getEnabledItems();\n const effectiveId = resolveEffectiveActiveId(enabled);\n return effectiveId !== null && itemId === effectiveId ? 0 : -1;\n },\n handleKeyDown(currentId, event) {\n const enabled = getEnabledItems();\n if (enabled.length === 0) return null;\n\n let target: RovingFocusItem | undefined;\n if (event.key === 'Home') {\n target = enabled[0];\n } else if (event.key === 'End') {\n target = enabled[enabled.length - 1];\n } else if (isForwardKey(event.key, orientation) || isBackwardKey(event.key, orientation)) {\n const step = isForwardKey(event.key, orientation) ? 1 : -1;\n const effectiveId = resolveEffectiveActiveId(enabled);\n let idx = enabled.findIndex(item => item.id === currentId);\n if (idx < 0 && effectiveId !== null) {\n idx = enabled.findIndex(item => item.id === effectiveId);\n }\n if (idx < 0) idx = 0;\n const nextIdx = loop\n ? (idx + step + enabled.length) % enabled.length\n : Math.max(0, Math.min(enabled.length - 1, idx + step));\n target = enabled[nextIdx];\n } else {\n return null;\n }\n\n if (!target) return null;\n event.preventDefault?.();\n options.onFocusChange?.(target.id);\n return target.id;\n },\n };\n}\n","export interface SyncGuardController<TPayload = unknown> {\n abort(reason?: string): void;\n modifyPayload(updater: TPayload | ((prev: TPayload) => TPayload)): void;\n getPayload(): TPayload;\n}\n\nexport interface SyncResultController<TPayload = unknown, TResult = unknown>\n extends SyncGuardController<TPayload> {\n setResult(value: TResult): void;\n getResult(): TResult | undefined;\n}\n\nexport interface SyncObserverMeta<TResult = unknown> {\n readonly success: boolean;\n readonly aborted: boolean;\n readonly abortReason?: string | undefined;\n readonly result: TResult | undefined;\n readonly errors: readonly unknown[];\n}\n\nexport interface SyncDispatchOutcome<TPayload = unknown, TResult = unknown> {\n readonly success: boolean;\n readonly aborted: boolean;\n readonly abortReason?: string | undefined;\n readonly payload: TPayload;\n readonly result: TResult | undefined;\n readonly errors: readonly unknown[];\n}\n\nexport interface SyncHandlerConfig {\n readonly priority?: number;\n readonly id?: string;\n readonly once?: boolean;\n}\n\nexport interface SyncObserverConfig extends SyncHandlerConfig {\n readonly when?: 'success' | 'failure' | 'always';\n}\n\nexport interface SyncActionPipeline<\n TActions extends Record<string, unknown> = Record<string, unknown>,\n> {\n readonly name: string;\n registerGuard<K extends keyof TActions & string>(\n action: K,\n handler: (payload: TActions[K], controller: SyncGuardController<TActions[K]>) => void,\n config?: SyncHandlerConfig,\n ): () => void;\n register<K extends keyof TActions & string, TResult = unknown>(\n action: K,\n handler: (\n payload: TActions[K],\n controller: SyncResultController<TActions[K], TResult>,\n ) => TResult | undefined,\n config?: SyncHandlerConfig,\n ): () => void;\n registerObserver<K extends keyof TActions & string, TResult = unknown>(\n action: K,\n handler: (payload: TActions[K], meta: SyncObserverMeta<TResult>) => void,\n config?: SyncObserverConfig,\n ): () => void;\n dispatch<K extends keyof TActions & string, TResult = unknown>(\n action: K,\n payload?: TActions[K],\n ): SyncDispatchOutcome<TActions[K], TResult>;\n destroy(): void;\n}\n\ninterface InternalEntry {\n readonly id: string;\n readonly seq: number;\n readonly priority: number;\n readonly when: 'success' | 'failure' | 'always';\n readonly once: boolean;\n // biome-ignore lint/suspicious/noExplicitAny: heterogeneous typed handler registry.\n readonly handler: (...args: any[]) => unknown;\n}\n\nexport function createSyncActionPipeline<\n TActions extends Record<string, unknown> = Record<string, unknown>,\n>(name: string): SyncActionPipeline<TActions> {\n const guards = new Map<string, InternalEntry[]>();\n const handlers = new Map<string, InternalEntry[]>();\n const observers = new Map<string, InternalEntry[]>();\n let nextSeq = 1;\n let destroyed = false;\n\n function addEntry(\n phaseMap: Map<string, InternalEntry[]>,\n action: string,\n // biome-ignore lint/suspicious/noExplicitAny: heterogeneous typed handler registry.\n handler: (...args: any[]) => unknown,\n config: SyncObserverConfig = {},\n ): () => void {\n if (destroyed) throw new Error(`SyncActionPipeline '${name}' is destroyed`);\n if (typeof handler !== 'function') throw new TypeError('Handler must be a function');\n const bucket = phaseMap.get(action) ?? [];\n const entry: InternalEntry = {\n id: config.id ?? `${action}-${nextSeq}`,\n seq: nextSeq++,\n priority: config.priority ?? 0,\n when: config.when ?? 'success',\n once: Boolean(config.once),\n handler,\n };\n const next = [...bucket, entry].sort(\n (a, b) => b.priority - a.priority || a.seq - b.seq,\n );\n phaseMap.set(action, next);\n return () => {\n const current = phaseMap.get(action);\n if (!current) return;\n phaseMap.set(\n action,\n current.filter(item => item !== entry),\n );\n };\n }\n\n function consumeOnce(\n phaseMap: Map<string, InternalEntry[]>,\n action: string,\n entry: InternalEntry,\n ): void {\n if (!entry.once) return;\n const list = phaseMap.get(action);\n if (list) {\n phaseMap.set(\n action,\n list.filter(item => item !== entry),\n );\n }\n }\n\n return {\n name,\n registerGuard(action, handler, config) {\n return addEntry(guards, action, handler, config);\n },\n register(action, handler, config) {\n return addEntry(handlers, action, handler, config);\n },\n registerObserver(action, handler, config) {\n return addEntry(observers, action, handler, config);\n },\n dispatch<K extends keyof TActions & string, TResult = unknown>(\n action: K,\n initialPayload?: TActions[K],\n ): SyncDispatchOutcome<TActions[K], TResult> {\n if (destroyed) throw new Error(`SyncActionPipeline '${name}' is destroyed`);\n let currentPayload = initialPayload as TActions[K];\n let aborted = false;\n let abortReason: string | undefined;\n let result: TResult | undefined;\n const errors: unknown[] = [];\n\n // Phase 1: Guards (admission checks & payload modifiers)\n for (const entry of [...(guards.get(action) ?? [])]) {\n consumeOnce(guards, action, entry);\n let entryAborted = false;\n const guardController: SyncGuardController<TActions[K]> = {\n abort(reason?: string) {\n aborted = true;\n entryAborted = true;\n abortReason = reason;\n },\n modifyPayload(updater) {\n currentPayload =\n typeof updater === 'function'\n ? (updater as (prev: TActions[K]) => TActions[K])(currentPayload)\n : updater;\n },\n getPayload() {\n return currentPayload;\n },\n };\n try {\n entry.handler(currentPayload, guardController);\n } catch (error) {\n aborted = true;\n abortReason = error instanceof Error ? error.message : String(error);\n errors.push(error);\n }\n if (aborted || entryAborted) break;\n }\n\n // Phase 2: Execution handlers\n if (!aborted) {\n for (const entry of [...(handlers.get(action) ?? [])]) {\n consumeOnce(handlers, action, entry);\n const execController: SyncResultController<TActions[K], TResult> = {\n abort(reason?: string) {\n aborted = true;\n abortReason = reason;\n },\n modifyPayload(updater) {\n currentPayload =\n typeof updater === 'function'\n ? (updater as (prev: TActions[K]) => TActions[K])(currentPayload)\n : updater;\n },\n getPayload() {\n return currentPayload;\n },\n setResult(value: TResult) {\n result = value;\n },\n getResult() {\n return result;\n },\n };\n try {\n const ret = entry.handler(currentPayload, execController);\n if (ret !== undefined) result = ret as TResult;\n } catch (error) {\n errors.push(error);\n break;\n }\n if (aborted) break;\n }\n }\n\n const success = !aborted && errors.length === 0;\n\n // Phase 3: Observers\n for (const entry of [...(observers.get(action) ?? [])]) {\n consumeOnce(observers, action, entry);\n if (entry.when === 'success' && !success) continue;\n if (entry.when === 'failure' && success) continue;\n try {\n entry.handler(currentPayload, {\n success,\n aborted,\n abortReason,\n result,\n errors: [...errors],\n });\n } catch {\n // Observer errors do not invalidate prior committed results.\n }\n }\n\n return {\n success,\n aborted,\n abortReason,\n payload: currentPayload,\n result,\n errors,\n };\n },\n destroy() {\n destroyed = true;\n guards.clear();\n handlers.clear();\n observers.clear();\n },\n };\n}\n","import type { ElementBindingConfig } from './contracts.js';\n\nconst ATTR_TO_REACT_PROP: Record<string, string> = {\n class: 'className',\n for: 'htmlFor',\n tabindex: 'tabIndex',\n};\n\nfunction toReactStyleProperty(cssProperty: string): string {\n if (cssProperty.startsWith('--')) return cssProperty;\n return cssProperty.replace(/-([a-z])/g, (_, ch: string) => ch.toUpperCase());\n}\n\n/**\n * Projects a headless part snapshot into React 19 JSX props using an ElementBindingConfig.\n */\nexport function toReactPartProps<Props extends object>(\n snapshot: Props,\n config: ElementBindingConfig<Props> = {},\n): Record<string, unknown> {\n const reactProps: Record<string, unknown> = {};\n const attrEntries = Object.entries(config.attributes ?? {}) as [string, string | undefined][];\n const styleEntries = Object.entries(config.styles ?? {}) as [string, string | undefined][];\n const eventMap = config.events ?? {};\n const record = snapshot as Record<string, unknown>;\n\n for (const [propKey, attrName] of attrEntries) {\n if (!attrName) continue;\n const value = record[propKey];\n if (value === undefined || value === null || value === false) continue;\n const reactKey = ATTR_TO_REACT_PROP[attrName] ?? attrName;\n reactProps[reactKey] = value === true ? '' : value;\n }\n\n const styleObj: Record<string, string> = {};\n let hasStyle = false;\n for (const [propKey, cssProperty] of styleEntries) {\n if (!cssProperty) continue;\n const value = record[propKey];\n if (value === undefined || value === null || value === '') continue;\n styleObj[toReactStyleProperty(cssProperty)] = String(value);\n hasStyle = true;\n }\n if (hasStyle) reactProps.style = styleObj;\n\n for (const propKey of Object.keys(eventMap)) {\n const candidate = record[propKey];\n if (typeof candidate === 'function') {\n reactProps[propKey] = candidate;\n }\n }\n\n return reactProps;\n}\n"],"mappings":";AAEA,SAAS,eAAe,QAAgB,KAAkD;CACxF,IAAI,UAAyB;CAC7B,OAAO,SAAS;EACd,MAAM,aAAa,OAAO,yBAAyB,SAAS,GAAG;EAC/D,IAAI,YAAY,OAAO;EACvB,UAAU,OAAO,eAAe,OAAO;CACzC;AAEF;;AAGA,SAAgB,mBACd,MACA,kBAAkB,yCACyC;CAC3D,MAAM,aAAa,MAAM,KAAK,IAAI,IAAI,IAAI,CAAC;CAC3C,QAAO,eAAc;EACnB,MAAM,uBAAgC;GACpC,MAAM,UAAU,WAAW;GAC3B,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,eAAe;GAC7C,OAAO;EACT;EACA,MAAM,0BAAU,IAAI,QAAwE;EAC5F,MAAM,SAAS,CAAC;EAChB,KAAK,MAAM,OAAO,YAChB,OAAO,eAAe,QAAQ,KAAK;GACjC,cAAc;GACd,YAAY;GACZ,MAAM;IACJ,MAAM,UAAU,eAAe;IAC/B,MAAM,QAAiB,QAAQ,IAAI,SAAS,KAAK,OAAO;IACxD,IAAI,OAAO,UAAU,YAAY,OAAO;IACxC,IAAI,QAAQ,QAAQ,IAAI,OAAO;IAC/B,IAAI,CAAC,OAAO;KAAE,wBAAQ,IAAI,IAAI;KAAG,QAAQ,IAAI,SAAS,KAAK;IAAG;I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