@context-action/core 1.3.0 → 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.
@@ -1,35 +0,0 @@
1
- //#region src/facade/types.d.ts
2
- type PublicHandleFactory<Target extends object, Handle> = (getTarget: () => Target | null) => Handle;
3
- //#endregion
4
- //#region src/element/contracts.d.ts
5
- type ImperativeHandleFactory<Element extends HTMLElement, Handle> = PublicHandleFactory<Element, Handle>;
6
- interface ElementBindingConfig<Props extends object> {
7
- properties?: readonly (keyof Props)[];
8
- events?: Record<string, string>;
9
- }
10
- interface ElementBridgeConfig<Props extends object, Element extends HTMLElement = HTMLElement, Handle = Element> extends ElementBindingConfig<Props> {
11
- createHandle?: ImperativeHandleFactory<Element, Handle>;
12
- }
13
- interface ElementBridgeContract<Props extends object, Element extends HTMLElement = HTMLElement, Handle = Element> extends ElementBridgeConfig<Props, Element, Handle> {
14
- tagName: string;
15
- }
16
- interface ElementBindingOptions {
17
- assignmentErrors?: 'ignore' | 'throw';
18
- }
19
- interface ElementBinding<Props extends object> {
20
- readonly disposed: boolean;
21
- update(input: Props): void;
22
- updateProperties(input: Props): void;
23
- updateEvents(input: Props): void;
24
- disconnectEvents(): void;
25
- dispose(): void;
26
- }
27
- //#endregion
28
- //#region src/element/create-element-facade.d.ts
29
- declare function createElementFacade<Element extends HTMLElement, const Keys extends readonly (keyof Element)[]>(keys: Keys): ImperativeHandleFactory<Element, Pick<Element, Keys[number]>>;
30
- //#endregion
31
- //#region src/element/create-element-binding.d.ts
32
- declare function createElementBinding<Props extends object>(element: HTMLElement, config: ElementBindingConfig<Props>, options?: ElementBindingOptions): ElementBinding<Props>;
33
- //#endregion
34
- export { ElementBindingOptions as a, ImperativeHandleFactory as c, ElementBindingConfig as i, createElementFacade as n, ElementBridgeConfig as o, ElementBinding as r, ElementBridgeContract as s, createElementBinding as t };
35
- //# sourceMappingURL=element-BJpk34By.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"element-BJpk34By.d.cts","names":[],"sources":["../src/facade/types.ts","../src/element/contracts.ts","../src/element/create-element-facade.ts","../src/element/create-element-binding.ts"],"mappings":";KACY,oBAAoB,uBAAuB,WACpD,iBAAiB,kBAAkB;;;KCA1B,wBAAwB,gBAAgB,aAAa,UAAU,oBAAoB,SAAS;UAGvF,qBAAqB;EACpC,6BAA6B;EAC7B,SAAS;;UAGM,oBAAoB,sBAAsB,gBAAgB,cAAc,aAAa,SAAS,iBACrG,qBAAqB;EAC7B,eAAe,wBAAwB,SAAS;;UAGjC,sBAAsB,sBAAsB,gBAAgB,cAAc,aAAa,SAAS,iBACvG,oBAAoB,OAAO,SAAS;EAC5C;;UAGe;EACf;;UAIe,eAAe;WACrB;EAET,OAAO,OAAO;EACd,iBAAiB,OAAO;EACxB,aAAa,OAAO;EAEpB;EAEA;;;;iBC9Bc,oBAAoB,gBAAgB,mBAAmB,6BAA6B,YAClG,MAAM,OACL,wBAAwB,SAAS,KAAK,SAAS;;;iBCDlC,qBAAqB,sBACnC,SAAS,aACT,QAAQ,qBAAqB,QAC7B,UAAS,wBACR,eAAe"}
@@ -1,35 +0,0 @@
1
- //#region src/facade/types.d.ts
2
- type PublicHandleFactory<Target extends object, Handle> = (getTarget: () => Target | null) => Handle;
3
- //#endregion
4
- //#region src/element/contracts.d.ts
5
- type ImperativeHandleFactory<Element extends HTMLElement, Handle> = PublicHandleFactory<Element, Handle>;
6
- interface ElementBindingConfig<Props extends object> {
7
- properties?: readonly (keyof Props)[];
8
- events?: Record<string, string>;
9
- }
10
- interface ElementBridgeConfig<Props extends object, Element extends HTMLElement = HTMLElement, Handle = Element> extends ElementBindingConfig<Props> {
11
- createHandle?: ImperativeHandleFactory<Element, Handle>;
12
- }
13
- interface ElementBridgeContract<Props extends object, Element extends HTMLElement = HTMLElement, Handle = Element> extends ElementBridgeConfig<Props, Element, Handle> {
14
- tagName: string;
15
- }
16
- interface ElementBindingOptions {
17
- assignmentErrors?: 'ignore' | 'throw';
18
- }
19
- interface ElementBinding<Props extends object> {
20
- readonly disposed: boolean;
21
- update(input: Props): void;
22
- updateProperties(input: Props): void;
23
- updateEvents(input: Props): void;
24
- disconnectEvents(): void;
25
- dispose(): void;
26
- }
27
- //#endregion
28
- //#region src/element/create-element-facade.d.ts
29
- declare function createElementFacade<Element extends HTMLElement, const Keys extends readonly (keyof Element)[]>(keys: Keys): ImperativeHandleFactory<Element, Pick<Element, Keys[number]>>;
30
- //#endregion
31
- //#region src/element/create-element-binding.d.ts
32
- declare function createElementBinding<Props extends object>(element: HTMLElement, config: ElementBindingConfig<Props>, options?: ElementBindingOptions): ElementBinding<Props>;
33
- //#endregion
34
- export { ElementBindingOptions as a, ImperativeHandleFactory as c, ElementBindingConfig as i, createElementFacade as n, ElementBridgeConfig as o, ElementBinding as r, ElementBridgeContract as s, createElementBinding as t };
35
- //# sourceMappingURL=element-BJpk34By.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"element-BJpk34By.d.ts","names":[],"sources":["../src/facade/types.ts","../src/element/contracts.ts","../src/element/create-element-facade.ts","../src/element/create-element-binding.ts"],"mappings":";KACY,oBAAoB,uBAAuB,WACpD,iBAAiB,kBAAkB;;;KCA1B,wBAAwB,gBAAgB,aAAa,UAAU,oBAAoB,SAAS;UAGvF,qBAAqB;EACpC,6BAA6B;EAC7B,SAAS;;UAGM,oBAAoB,sBAAsB,gBAAgB,cAAc,aAAa,SAAS,iBACrG,qBAAqB;EAC7B,eAAe,wBAAwB,SAAS;;UAGjC,sBAAsB,sBAAsB,gBAAgB,cAAc,aAAa,SAAS,iBACvG,oBAAoB,OAAO,SAAS;EAC5C;;UAGe;EACf;;UAIe,eAAe;WACrB;EAET,OAAO,OAAO;EACd,iBAAiB,OAAO;EACxB,aAAa,OAAO;EAEpB;EAEA;;;;iBC9Bc,oBAAoB,gBAAgB,mBAAmB,6BAA6B,YAClG,MAAM,OACL,wBAAwB,SAAS,KAAK,SAAS;;;iBCDlC,qBAAqB,sBACnC,SAAS,aACT,QAAQ,qBAAqB,QAC7B,UAAS,wBACR,eAAe"}
@@ -1,190 +0,0 @@
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/event-bindings.ts
61
- function isHandler(value) {
62
- return typeof value === "function" || typeof value === "object" && value !== null && typeof value.handleEvent === "function";
63
- }
64
- function createEventBindings(element, events, active) {
65
- const bindings = /* @__PURE__ */ new Map();
66
- function remove(key, binding) {
67
- binding.active = false;
68
- bindings.delete(key);
69
- element.removeEventListener(binding.eventName, binding.listener);
70
- }
71
- return {
72
- update(input) {
73
- const handlers = input;
74
- for (const [key, eventName] of events) {
75
- if (!active()) return;
76
- const handler = handlers[key];
77
- const old = bindings.get(key);
78
- if (old?.handler === handler) continue;
79
- if (old) remove(key, old);
80
- if (!active()) return;
81
- if (!isHandler(handler)) continue;
82
- const binding = {
83
- handler,
84
- eventName,
85
- active: true,
86
- listener(event) {
87
- if (!active() || !binding.active) return;
88
- if (typeof handler === "function") handler(event);
89
- else handler.handleEvent(event);
90
- }
91
- };
92
- bindings.set(key, binding);
93
- try {
94
- element.addEventListener(eventName, binding.listener);
95
- } catch (error) {
96
- remove(key, binding);
97
- throw error;
98
- }
99
- if (!active()) remove(key, binding);
100
- }
101
- },
102
- disconnect() {
103
- for (const [key, binding] of bindings) remove(key, binding);
104
- }
105
- };
106
- }
107
-
108
- //#endregion
109
- //#region src/element/property-bindings.ts
110
- /** Only attempted bridge writes are owned. Omission releases ownership even if reset is rejected. */
111
- function createPropertyBindings(element, properties, active, assignmentErrors) {
112
- const applied = /* @__PURE__ */ new Set();
113
- const host = element;
114
- return (input) => {
115
- for (const key of properties) {
116
- if (!active()) return;
117
- if (key in input) {
118
- const value = input[key];
119
- if (!active()) return;
120
- applied.add(key);
121
- try {
122
- host[key] = value;
123
- } catch (error) {
124
- if (assignmentErrors === "throw") throw error;
125
- }
126
- } else if (applied.delete(key)) try {
127
- host[key] = void 0;
128
- } catch {}
129
- }
130
- };
131
- }
132
-
133
- //#endregion
134
- //#region src/element/create-element-binding.ts
135
- /** Framework-neutral DOM transport. Lifecycle adapters supply complete snapshots, not patches. */
136
- function createElementBinding(element, config, options = {}) {
137
- let disposed = false;
138
- let updating = false;
139
- const active = () => !disposed;
140
- const properties = createPropertyBindings(element, Array.from(new Set(config.properties ?? [])), active, options.assignmentErrors ?? "ignore");
141
- const events = createEventBindings(element, Object.entries(config.events ?? {}), active);
142
- function run(update) {
143
- if (disposed) throw new Error("Element binding is disposed");
144
- if (updating) throw new Error("Element binding update is already in progress");
145
- updating = true;
146
- try {
147
- update();
148
- } finally {
149
- updating = false;
150
- }
151
- }
152
- return {
153
- get disposed() {
154
- return disposed;
155
- },
156
- update(input) {
157
- run(() => {
158
- events.update(input);
159
- if (active()) properties(input);
160
- });
161
- },
162
- updateProperties(input) {
163
- run(() => properties(input));
164
- },
165
- updateEvents(input) {
166
- run(() => events.update(input));
167
- },
168
- disconnectEvents() {
169
- events.disconnect();
170
- },
171
- dispose() {
172
- disposed = true;
173
- events.disconnect();
174
- }
175
- };
176
- }
177
-
178
- //#endregion
179
- Object.defineProperty(exports, 'createElementBinding', {
180
- enumerable: true,
181
- get: function () {
182
- return createElementBinding;
183
- }
184
- });
185
- Object.defineProperty(exports, 'createElementFacade', {
186
- enumerable: true,
187
- get: function () {
188
- return createElementFacade;
189
- }
190
- });
@@ -1,180 +0,0 @@
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/event-bindings.ts
61
- function isHandler(value) {
62
- return typeof value === "function" || typeof value === "object" && value !== null && typeof value.handleEvent === "function";
63
- }
64
- function createEventBindings(element, events, active) {
65
- const bindings = /* @__PURE__ */ new Map();
66
- function remove(key, binding) {
67
- binding.active = false;
68
- bindings.delete(key);
69
- element.removeEventListener(binding.eventName, binding.listener);
70
- }
71
- return {
72
- update(input) {
73
- const handlers = input;
74
- for (const [key, eventName] of events) {
75
- if (!active()) return;
76
- const handler = handlers[key];
77
- const old = bindings.get(key);
78
- if (old?.handler === handler) continue;
79
- if (old) remove(key, old);
80
- if (!active()) return;
81
- if (!isHandler(handler)) continue;
82
- const binding = {
83
- handler,
84
- eventName,
85
- active: true,
86
- listener(event) {
87
- if (!active() || !binding.active) return;
88
- if (typeof handler === "function") handler(event);
89
- else handler.handleEvent(event);
90
- }
91
- };
92
- bindings.set(key, binding);
93
- try {
94
- element.addEventListener(eventName, binding.listener);
95
- } catch (error) {
96
- remove(key, binding);
97
- throw error;
98
- }
99
- if (!active()) remove(key, binding);
100
- }
101
- },
102
- disconnect() {
103
- for (const [key, binding] of bindings) remove(key, binding);
104
- }
105
- };
106
- }
107
-
108
- //#endregion
109
- //#region src/element/property-bindings.ts
110
- /** Only attempted bridge writes are owned. Omission releases ownership even if reset is rejected. */
111
- function createPropertyBindings(element, properties, active, assignmentErrors) {
112
- const applied = /* @__PURE__ */ new Set();
113
- const host = element;
114
- return (input) => {
115
- for (const key of properties) {
116
- if (!active()) return;
117
- if (key in input) {
118
- const value = input[key];
119
- if (!active()) return;
120
- applied.add(key);
121
- try {
122
- host[key] = value;
123
- } catch (error) {
124
- if (assignmentErrors === "throw") throw error;
125
- }
126
- } else if (applied.delete(key)) try {
127
- host[key] = void 0;
128
- } catch {}
129
- }
130
- };
131
- }
132
-
133
- //#endregion
134
- //#region src/element/create-element-binding.ts
135
- /** Framework-neutral DOM transport. Lifecycle adapters supply complete snapshots, not patches. */
136
- function createElementBinding(element, config, options = {}) {
137
- let disposed = false;
138
- let updating = false;
139
- const active = () => !disposed;
140
- const properties = createPropertyBindings(element, Array.from(new Set(config.properties ?? [])), active, options.assignmentErrors ?? "ignore");
141
- const events = createEventBindings(element, Object.entries(config.events ?? {}), active);
142
- function run(update) {
143
- if (disposed) throw new Error("Element binding is disposed");
144
- if (updating) throw new Error("Element binding update is already in progress");
145
- updating = true;
146
- try {
147
- update();
148
- } finally {
149
- updating = false;
150
- }
151
- }
152
- return {
153
- get disposed() {
154
- return disposed;
155
- },
156
- update(input) {
157
- run(() => {
158
- events.update(input);
159
- if (active()) properties(input);
160
- });
161
- },
162
- updateProperties(input) {
163
- run(() => properties(input));
164
- },
165
- updateEvents(input) {
166
- run(() => events.update(input));
167
- },
168
- disconnectEvents() {
169
- events.disconnect();
170
- },
171
- dispose() {
172
- disposed = true;
173
- events.disconnect();
174
- }
175
- };
176
- }
177
-
178
- //#endregion
179
- export { createElementFacade as n, createElementBinding as t };
180
- //# sourceMappingURL=element-DSSLaFmw.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"element-DSSLaFmw.js","names":[],"sources":["../src/facade/create-public-facade.ts","../src/element/create-element-facade.ts","../src/element/event-bindings.ts","../src/element/property-bindings.ts","../src/element/create-element-binding.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","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","import type { ElementBinding, ElementBindingConfig, ElementBindingOptions } from './contracts.js';\nimport { createEventBindings } from './event-bindings.js';\nimport { createPropertyBindings } from './property-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 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) { run(() => { events.update(input); if (active()) properties(input); }); },\n updateProperties(input) { run(() => properties(input)); },\n updateEvents(input) { run(() => events.update(input)); },\n disconnectEvents() { events.disconnect(); },\n dispose() { disposed = true; events.disconnect(); },\n };\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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