@adobe/data-lit 0.9.11

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 (128) hide show
  1. package/LICENSE +21 -0
  2. package/dist/decorators/apply-decorator.d.ts +1 -0
  3. package/dist/decorators/apply-decorator.js +19 -0
  4. package/dist/decorators/apply-decorator.js.map +1 -0
  5. package/dist/decorators/apply-service-decorators.d.ts +1 -0
  6. package/dist/decorators/apply-service-decorators.js +13 -0
  7. package/dist/decorators/apply-service-decorators.js.map +1 -0
  8. package/dist/decorators/index.d.ts +3 -0
  9. package/dist/decorators/index.js +5 -0
  10. package/dist/decorators/index.js.map +1 -0
  11. package/dist/decorators/require-service.d.ts +1 -0
  12. package/dist/decorators/require-service.js +14 -0
  13. package/dist/decorators/require-service.js.map +1 -0
  14. package/dist/elements/application-element.d.ts +9 -0
  15. package/dist/elements/application-element.js +42 -0
  16. package/dist/elements/application-element.js.map +1 -0
  17. package/dist/elements/application-host.d.ts +16 -0
  18. package/dist/elements/application-host.js +39 -0
  19. package/dist/elements/application-host.js.map +1 -0
  20. package/dist/elements/database-element.d.ts +10 -0
  21. package/dist/elements/database-element.js +40 -0
  22. package/dist/elements/database-element.js.map +1 -0
  23. package/dist/elements/index.d.ts +3 -0
  24. package/dist/elements/index.js +5 -0
  25. package/dist/elements/index.js.map +1 -0
  26. package/dist/functions/index.d.ts +1 -0
  27. package/dist/functions/index.js +3 -0
  28. package/dist/functions/index.js.map +1 -0
  29. package/dist/functions/iterate-self-and-ancestors.d.ts +1 -0
  30. package/dist/functions/iterate-self-and-ancestors.js +24 -0
  31. package/dist/functions/iterate-self-and-ancestors.js.map +1 -0
  32. package/dist/hooks/attach-decorator.d.ts +4 -0
  33. package/dist/hooks/attach-decorator.js +26 -0
  34. package/dist/hooks/attach-decorator.js.map +1 -0
  35. package/dist/hooks/component/component.d.ts +10 -0
  36. package/dist/hooks/component/component.js +3 -0
  37. package/dist/hooks/component/component.js.map +1 -0
  38. package/dist/hooks/component/stack.d.ts +6 -0
  39. package/dist/hooks/component/stack.js +16 -0
  40. package/dist/hooks/component/stack.js.map +1 -0
  41. package/dist/hooks/index.d.ts +19 -0
  42. package/dist/hooks/index.js +21 -0
  43. package/dist/hooks/index.js.map +1 -0
  44. package/dist/hooks/use-connected.d.ts +2 -0
  45. package/dist/hooks/use-connected.js +32 -0
  46. package/dist/hooks/use-connected.js.map +1 -0
  47. package/dist/hooks/use-debounce.d.ts +8 -0
  48. package/dist/hooks/use-debounce.js +21 -0
  49. package/dist/hooks/use-debounce.js.map +1 -0
  50. package/dist/hooks/use-drag-observe.d.ts +25 -0
  51. package/dist/hooks/use-drag-observe.js +35 -0
  52. package/dist/hooks/use-drag-observe.js.map +1 -0
  53. package/dist/hooks/use-drag-transaction.d.ts +7 -0
  54. package/dist/hooks/use-drag-transaction.js +35 -0
  55. package/dist/hooks/use-drag-transaction.js.map +1 -0
  56. package/dist/hooks/use-draggable.d.ts +15 -0
  57. package/dist/hooks/use-draggable.js +96 -0
  58. package/dist/hooks/use-draggable.js.map +1 -0
  59. package/dist/hooks/use-effect.d.ts +3 -0
  60. package/dist/hooks/use-effect.js +14 -0
  61. package/dist/hooks/use-effect.js.map +1 -0
  62. package/dist/hooks/use-element.d.ts +7 -0
  63. package/dist/hooks/use-element.js +67 -0
  64. package/dist/hooks/use-element.js.map +1 -0
  65. package/dist/hooks/use-memo.d.ts +1 -0
  66. package/dist/hooks/use-memo.js +13 -0
  67. package/dist/hooks/use-memo.js.map +1 -0
  68. package/dist/hooks/use-observable-values.d.ts +4 -0
  69. package/dist/hooks/use-observable-values.js +9 -0
  70. package/dist/hooks/use-observable-values.js.map +1 -0
  71. package/dist/hooks/use-observable.d.ts +2 -0
  72. package/dist/hooks/use-observable.js +13 -0
  73. package/dist/hooks/use-observable.js.map +1 -0
  74. package/dist/hooks/use-ref.d.ts +3 -0
  75. package/dist/hooks/use-ref.js +7 -0
  76. package/dist/hooks/use-ref.js.map +1 -0
  77. package/dist/hooks/use-resize-observer.d.ts +12 -0
  78. package/dist/hooks/use-resize-observer.js +23 -0
  79. package/dist/hooks/use-resize-observer.js.map +1 -0
  80. package/dist/hooks/use-state.d.ts +2 -0
  81. package/dist/hooks/use-state.js +15 -0
  82. package/dist/hooks/use-state.js.map +1 -0
  83. package/dist/hooks/use-updated.d.ts +4 -0
  84. package/dist/hooks/use-updated.js +40 -0
  85. package/dist/hooks/use-updated.js.map +1 -0
  86. package/dist/hooks/use-window-event.d.ts +1 -0
  87. package/dist/hooks/use-window-event.js +11 -0
  88. package/dist/hooks/use-window-event.js.map +1 -0
  89. package/dist/hooks/with-hooks.d.ts +2 -0
  90. package/dist/hooks/with-hooks.js +16 -0
  91. package/dist/hooks/with-hooks.js.map +1 -0
  92. package/dist/index.d.ts +4 -0
  93. package/dist/index.js +5 -0
  94. package/dist/index.js.map +1 -0
  95. package/package.json +30 -0
  96. package/src/decorators/apply-decorator.ts +26 -0
  97. package/src/decorators/apply-service-decorators.ts +15 -0
  98. package/src/decorators/index.ts +4 -0
  99. package/src/decorators/require-service.ts +20 -0
  100. package/src/elements/application-element.ts +42 -0
  101. package/src/elements/application-host.ts +43 -0
  102. package/src/elements/database-element.ts +42 -0
  103. package/src/elements/index.ts +5 -0
  104. package/src/functions/index.ts +3 -0
  105. package/src/functions/iterate-self-and-ancestors.ts +23 -0
  106. package/src/hooks/attach-decorator.ts +32 -0
  107. package/src/hooks/component/component.ts +12 -0
  108. package/src/hooks/component/stack.ts +19 -0
  109. package/src/hooks/index.ts +21 -0
  110. package/src/hooks/use-connected.ts +41 -0
  111. package/src/hooks/use-debounce.ts +26 -0
  112. package/src/hooks/use-drag-observe.ts +59 -0
  113. package/src/hooks/use-drag-transaction.ts +46 -0
  114. package/src/hooks/use-draggable.ts +112 -0
  115. package/src/hooks/use-effect.ts +19 -0
  116. package/src/hooks/use-element.ts +83 -0
  117. package/src/hooks/use-memo.ts +16 -0
  118. package/src/hooks/use-observable-values.ts +10 -0
  119. package/src/hooks/use-observable.ts +15 -0
  120. package/src/hooks/use-ref.ts +8 -0
  121. package/src/hooks/use-resize-observer.ts +31 -0
  122. package/src/hooks/use-state.ts +19 -0
  123. package/src/hooks/use-updated.ts +56 -0
  124. package/src/hooks/use-window-event.ts +16 -0
  125. package/src/hooks/with-hooks.ts +22 -0
  126. package/src/index.ts +6 -0
  127. package/tsconfig.json +11 -0
  128. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-drag-observe.js","sourceRoot":"","sources":["../../src/hooks/use-drag-observe.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAkB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAsB9C;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,KAAuB,EAAE,YAAuB;IAC3E,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,OAAO,CAAC,WAAW,EAAa,CAAC;IACnE,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAC7B,YAAY,CAAC,OAAO,EAChB;QACI,GAAG,KAAK;QACR,WAAW,EAAE,EAAE,CAAC,EAAE;YACd,YAAY,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QACpC,CAAC;QACD,MAAM,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;YAC5B,YAAY,CAAC;gBACT,IAAI,EAAE,MAAM;gBACZ,QAAQ;gBACR,KAAK;aACR,CAAC,CAAC;QACP,CAAC;QACD,SAAS,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;YAC/B,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QACnD,CAAC;QACD,YAAY,EAAE,GAAG,EAAE;YACf,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrC,CAAC;KACJ,EACD,YAAY,CACf,CAAC;IACF,OAAO,SAAS,CAAC;AACrB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { DragEnd, DragMove, DragObserveProps } from './use-drag-observe.js';
2
+ import type { AsyncArgsProvider } from '@adobe/data/ecs';
3
+ export type DragTransactionProps<T> = DragObserveProps & {
4
+ transaction: (asyncArgs: AsyncArgsProvider<T>) => void;
5
+ update: (drag: DragMove | DragEnd) => T | void;
6
+ };
7
+ export declare function useDragTransaction<T>(props: DragTransactionProps<T>, dependencies: unknown[]): void;
@@ -0,0 +1,35 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { useDragObserve } from './use-drag-observe.js';
3
+ import { useEffect } from "./use-effect.js";
4
+ import { Observe } from '@adobe/data/observe';
5
+ export function useDragTransaction(props, dependencies) {
6
+ const { transaction, update } = props;
7
+ const dragObserve = useDragObserve(props, dependencies);
8
+ const startDragTransaction = () => {
9
+ let done = false;
10
+ // we start the transaction by calling it with an async generator that will yield the args asynchronously
11
+ transaction(
12
+ // we create the async generator by mapping the dragObserve state changes to transaction args
13
+ () => Observe.toAsyncGenerator(
14
+ // this uses the withMap function and the provided update and finish functions
15
+ // any type 'start' will just be ignored and filtered out
16
+ Observe.withFilter(dragObserve, value => {
17
+ if (value.type === 'end') {
18
+ done = true;
19
+ return update(value);
20
+ }
21
+ if (value.type === 'move') {
22
+ return update(value);
23
+ }
24
+ }), _value => done));
25
+ };
26
+ // now we will observe the drag state and start a new transaction whenever a drag starts
27
+ useEffect(() => {
28
+ return dragObserve(value => {
29
+ if (value.type === 'start') {
30
+ startDragTransaction();
31
+ }
32
+ });
33
+ }, dependencies);
34
+ }
35
+ //# sourceMappingURL=use-drag-transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-drag-transaction.js","sourceRoot":"","sources":["../../src/hooks/use-drag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
+ import { Vec2 } from '@adobe/data/math';
2
+ export interface DraggableProps {
3
+ onDragStart: (e: PointerEvent) => Vec2 | void;
4
+ onDrag: (e: PointerEvent, newPosition: Vec2, delta: Vec2) => void;
5
+ onDragEnd?: (e: PointerEvent, newPosition: Vec2, delta: Vec2) => void;
6
+ /**
7
+ * Called if this hook is destroyed before the drag is completed.
8
+ */
9
+ onDragCancel?: () => void;
10
+ minDragDistance?: number;
11
+ dragCursor?: string;
12
+ addPlaceholder?: boolean;
13
+ stopPropagation?: boolean;
14
+ }
15
+ export declare function useDraggable(element: HTMLElement, props: DraggableProps, dependencies: unknown[]): void;
@@ -0,0 +1,96 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { Vec2 } from '@adobe/data/math';
3
+ import { useEffect } from './use-effect.js';
4
+ function toCssUnitString(value) {
5
+ return `${value}px`;
6
+ }
7
+ export function useDraggable(element, props, dependencies) {
8
+ const { minDragDistance = 10, dragCursor = 'grab', addPlaceholder = false, stopPropagation = false } = props;
9
+ useEffect(() => {
10
+ let downPosition = null;
11
+ // the bounds of the element when the pointer was first pressed down.
12
+ let dragStartOffset = null;
13
+ let originalCursor = '';
14
+ let placeholder = null;
15
+ let movePosition = [0, 0];
16
+ function notify(e, dragListener) {
17
+ const delta = Vec2.subtract(movePosition, downPosition);
18
+ dragListener(e, Vec2.add(dragStartOffset, delta), delta);
19
+ }
20
+ function onPointerMove(e) {
21
+ movePosition = [e.clientX, e.clientY];
22
+ if (Vec2.length(Vec2.subtract(movePosition, downPosition)) >= minDragDistance) {
23
+ if (!dragStartOffset) {
24
+ dragStartOffset = [element.offsetLeft, element.offsetTop];
25
+ props.onDragStart(e);
26
+ if (dragCursor) {
27
+ originalCursor = element.style.cursor;
28
+ element.style.cursor = dragCursor;
29
+ }
30
+ // add a placeholder so the parent element doesn't change size when the element is dragged.
31
+ if (addPlaceholder) {
32
+ placeholder = document.createElement('div');
33
+ Object.assign(placeholder.style, {
34
+ position: 'absolute',
35
+ backgroundColor: 'pink',
36
+ left: toCssUnitString(element.offsetLeft),
37
+ top: toCssUnitString(element.offsetTop),
38
+ width: toCssUnitString(element.offsetWidth),
39
+ height: toCssUnitString(element.offsetHeight),
40
+ visibility: 'hidden',
41
+ });
42
+ element.parentElement?.appendChild(placeholder);
43
+ }
44
+ }
45
+ }
46
+ if (dragStartOffset) {
47
+ notify(e, props.onDrag);
48
+ }
49
+ if (stopPropagation)
50
+ e.stopPropagation();
51
+ }
52
+ function cleanup() {
53
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
54
+ window.removeEventListener('pointerup', onPointerUp);
55
+ window.removeEventListener('pointermove', onPointerMove);
56
+ if (dragCursor) {
57
+ element.style.cursor = originalCursor;
58
+ }
59
+ if (placeholder) {
60
+ placeholder.remove();
61
+ placeholder = null;
62
+ }
63
+ }
64
+ function onPointerUp(e) {
65
+ cleanup();
66
+ if (dragStartOffset && props.onDragEnd) {
67
+ notify(e, props.onDragEnd);
68
+ }
69
+ if (stopPropagation)
70
+ e.stopPropagation();
71
+ downPosition = null;
72
+ dragStartOffset = null;
73
+ }
74
+ function onPointerDown(e) {
75
+ // Only start drag transaction for left mouse button clicks
76
+ if (e.button !== 0)
77
+ return;
78
+ window.addEventListener('pointermove', onPointerMove);
79
+ window.addEventListener('pointerup', onPointerUp);
80
+ downPosition = [e.clientX, e.clientY];
81
+ if (stopPropagation)
82
+ e.stopPropagation();
83
+ }
84
+ element?.addEventListener('pointerdown', onPointerDown);
85
+ return () => {
86
+ element?.removeEventListener('pointerdown', onPointerDown);
87
+ if (downPosition) {
88
+ cleanup();
89
+ }
90
+ if (dragStartOffset) {
91
+ props.onDragCancel?.();
92
+ }
93
+ };
94
+ }, [element, ...(dependencies ?? [])]);
95
+ }
96
+ //# sourceMappingURL=use-draggable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-draggable.js","sourceRoot":"","sources":["../../src/hooks/use-draggable.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OA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= () => (void | (() => void));
3
+ export declare function useEffect<T extends Component>(callback: EffectCallback, dependencies?: unknown[]): void;
@@ -0,0 +1,14 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { equalsShallow } from "@adobe/data/equals-shallow";
3
+ import { Component_stack } from "./component/stack.js";
4
+ export function useEffect(callback, dependencies = []) {
5
+ const component = Component_stack.active();
6
+ const hookIndex = component.hookIndex++;
7
+ const oldHookState = component.hooks[hookIndex];
8
+ const rerunEffect = !oldHookState || !equalsShallow(dependencies, oldHookState.dependencies);
9
+ if (rerunEffect) {
10
+ oldHookState?.dispose?.();
11
+ component.hooks[hookIndex] = { dispose: callback.call(component) ?? undefined, dependencies };
12
+ }
13
+ }
14
+ //# sourceMappingURL=use-effect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-effect.js","sourceRoot":"","sources":["../../src/hooks/use-effect.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAKvD,MAAM,UAAU,SAAS,CAAsB,QAAwB,EAAE,eAA0B,EAAE;IACjG,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,EAAO,CAAC;IAChD,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;IACxC,MAAM,YAAY,GAAG,SAAS,CAAC,KAAK,CAAC,SAAS,CAAgC,CAAC;IAC/E,MAAM,WAAW,GAAG,CAAC,YAAY,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;IAC7F,IAAI,WAAW,EAAE,CAAC;QACd,YAAY,EAAE,OAAO,EAAE,EAAE,CAAC;QAC1B,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,SAAS,EAAE,YAAY,EAAE,CAAC;IAClG,CAAC;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Hook that returns the currently active component.
3
+ * If a querySelector is provided, it dynamically observes for child elements
4
+ * matching the selector and triggers rerender when found.
5
+ */
6
+ export declare function useElement<K extends keyof HTMLElementTagNameMap>(querySelector: K): HTMLElementTagNameMap[K] | null;
7
+ export declare function useElement<T = HTMLElement>(): T;
@@ -0,0 +1,67 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { Component_stack } from "./component/stack.js";
3
+ import { useEffect } from "./use-effect.js";
4
+ import { useState } from "./use-state.js";
5
+ export function useElement(querySelector) {
6
+ const component = Component_stack.active();
7
+ // If no querySelector provided, return the active component
8
+ if (!querySelector) {
9
+ return component;
10
+ }
11
+ // Use state to track the found element
12
+ const [foundElement, setFoundElement] = useState(null);
13
+ useEffect(() => {
14
+ const element = component;
15
+ // Check if element already exists
16
+ const existingElement = element.querySelector(querySelector);
17
+ if (existingElement) {
18
+ setFoundElement(existingElement);
19
+ return;
20
+ }
21
+ // Set up MutationObserver to watch for new child elements
22
+ const observer = new MutationObserver((mutations) => {
23
+ for (const mutation of mutations) {
24
+ if (mutation.type === 'childList') {
25
+ // Check if any added nodes match the selector
26
+ for (const node of mutation.addedNodes) {
27
+ if (node.nodeType === Node.ELEMENT_NODE) {
28
+ const element = node;
29
+ // Check if the added node itself matches
30
+ if (element.matches(querySelector)) {
31
+ setFoundElement(element);
32
+ observer.disconnect();
33
+ return;
34
+ }
35
+ // Check if any descendant matches
36
+ const descendant = element.querySelector(querySelector);
37
+ if (descendant) {
38
+ setFoundElement(descendant);
39
+ observer.disconnect();
40
+ return;
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ });
47
+ // Start observing both element and shadowRoot
48
+ for (const observe of [element.shadowRoot, element]) {
49
+ if (observe) {
50
+ observer.observe(observe, {
51
+ childList: true,
52
+ subtree: true
53
+ });
54
+ }
55
+ }
56
+ observer.observe(element.shadowRoot ?? element, {
57
+ childList: true,
58
+ subtree: true
59
+ });
60
+ // Cleanup function
61
+ return () => {
62
+ observer.disconnect();
63
+ };
64
+ }, [querySelector]);
65
+ return foundElement;
66
+ }
67
+ //# sourceMappingURL=use-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-element.js","sourceRoot":"","sources":["../../src/hooks/use-element.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAS1C,MAAM,UAAU,UAAU,CAAkB,aAAsB;IAC9D,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC;IAE3C,4DAA4D;IAC5D,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,OAAO,SAAyB,CAAC;IACrC,CAAC;IAED,uCAAuC;IACvC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAW,IAAI,CAAC,CAAC;IAEjE,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,OAAO,GAAG,SAAmC,CAAC;QAEpD,kCAAkC;QAClC,MAAM,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,aAAa,CAAa,CAAC;QACzE,IAAI,eAAe,EAAE,CAAC;YAClB,eAAe,CAAC,eAAe,CAAC,CAAC;YACjC,OAAO;QACX,CAAC;QAED,0DAA0D;QAC1D,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,CAAC,SAAS,EAAE,EAAE;YAChD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBAC/B,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;oBAChC,8CAA8C;oBAC9C,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;wBACrC,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC;4BACtC,MAAM,OAAO,GAAG,IAAe,CAAC;4BAChC,yCAAyC;4BACzC,IAAI,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;gCACjC,eAAe,CAAC,OAAY,CAAC,CAAC;gCAC9B,QAAQ,CAAC,UAAU,EAAE,CAAC;gCACtB,OAAO;4BACX,CAAC;4BACD,kCAAkC;4BAClC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,aAAa,CAAa,CAAC;4BACpE,IAAI,UAAU,EAAE,CAAC;gCACb,eAAe,CAAC,UAAU,CAAC,CAAC;gCAC5B,QAAQ,CAAC,UAAU,EAAE,CAAC;gCACtB,OAAO;4BACX,CAAC;wBACL,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,8CAA8C;QAC9C,KAAK,MAAM,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC;YAClD,IAAI,OAAO,EAAE,CAAC;gBACV,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE;oBACtB,SAAS,EAAE,IAAI;oBACf,OAAO,EAAE,IAAI;iBAChB,CAAC,CAAC;YACP,CAAC;QACL,CAAC;QACD,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,EAAE;YAC5C,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,IAAI;SAChB,CAAC,CAAC;QAEH,mBAAmB;QACnB,OAAO,GAAG,EAAE;YACR,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC1B,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,YAAY,CAAC;AACxB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function useMemo<T>(calculateValue: () => T, dependencies?: unknown[]): T;
@@ -0,0 +1,13 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { useEffect } from "./use-effect.js";
3
+ import { useState } from "./use-state.js";
4
+ export function useMemo(calculateValue, dependencies = []) {
5
+ const [state, setState] = useState(undefined);
6
+ let currentValue = state;
7
+ useEffect(() => {
8
+ currentValue = calculateValue();
9
+ setState(currentValue);
10
+ }, dependencies);
11
+ return currentValue;
12
+ }
13
+ //# sourceMappingURL=use-memo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-memo.js","sourceRoot":"","sources":["../../src/hooks/use-memo.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,UAAU,OAAO,CAAI,cAAuB,EAAE,eAA0B,EAAE;IAC5E,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,SAAS,CAAC,CAAC;IAC7D,IAAI,YAAY,GAAG,KAAK,CAAC;IAEzB,SAAS,CAAC,GAAG,EAAE;QACX,YAAY,GAAG,cAAc,EAAE,CAAC;QAChC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC3B,CAAC,EAAE,YAAY,CAAC,CAAC;IAEjB,OAAO,YAAa,CAAC;AACzB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Observe } from "@adobe/data/observe";
2
+ export declare function useObservableValues<T extends Record<string, Observe<unknown>>>(factory: () => T, deps?: unknown[]): {
3
+ [K in keyof T]: T[K] extends Observe<infer U> ? U : never;
4
+ } | undefined;
@@ -0,0 +1,9 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { Observe } from "@adobe/data/observe";
3
+ import { useMemo } from "./use-memo.js";
4
+ import { useObservable } from "./use-observable.js";
5
+ export function useObservableValues(factory, deps = []) {
6
+ const observable = useMemo(() => Observe.fromProperties(factory()), deps);
7
+ return useObservable(observable);
8
+ }
9
+ //# sourceMappingURL=use-observable-values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-observable-values.js","sourceRoot":"","sources":["../../src/hooks/use-observable-values.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,UAAU,mBAAmB,CAA6C,OAAgB,EAAE,OAAkB,EAAE;IAClH,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAC1E,OAAO,aAAa,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Observe } from "@adobe/data/observe";
2
+ export declare function useObservable<T>(observable: Observe<T>): T | undefined;
@@ -0,0 +1,13 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { useState } from "./use-state.js";
3
+ import { useEffect } from "./use-effect.js";
4
+ export function useObservable(observable) {
5
+ let [value, setValue] = useState(undefined);
6
+ useEffect(() => {
7
+ return observable(newValue => {
8
+ setValue(value = newValue);
9
+ });
10
+ }, [observable]);
11
+ return value;
12
+ }
13
+ //# sourceMappingURL=use-observable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-observable.js","sourceRoot":"","sources":["../../src/hooks/use-observable.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,MAAM,UAAU,aAAa,CAAI,UAAsB;IACnD,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,SAAS,CAAC,CAAC;IAC3D,SAAS,CAAC,GAAG,EAAE;QACX,OAAO,UAAU,CAAC,QAAQ,CAAC,EAAE;YACzB,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACjB,OAAO,KAAK,CAAC;AACjB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function useRef<T>(initialValue: T): {
2
+ current: T;
3
+ };
@@ -0,0 +1,7 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { useState } from "./use-state.js";
3
+ export function useRef(initialValue) {
4
+ const [state] = useState({ current: initialValue });
5
+ return state;
6
+ }
7
+ //# sourceMappingURL=use-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-ref.js","sourceRoot":"","sources":["../../src/hooks/use-ref.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,UAAU,MAAM,CAAI,YAAe;IACrC,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;IACpD,OAAO,KAAK,CAAC;AACjB,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface ResizeInfo {
2
+ width: number;
3
+ height: number;
4
+ entry: ResizeObserverEntry;
5
+ }
6
+ /**
7
+ * Hook to observe element resizes. Calls callback with width, height, and the original entry
8
+ * when the element's size changes.
9
+ *
10
+ * @param onResize - Callback invoked when element size changes
11
+ */
12
+ export declare function useResizeObserver(onResize: (info: ResizeInfo) => void): void;
@@ -0,0 +1,23 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { useEffect } from "./use-effect.js";
3
+ import { useElement } from "./use-element.js";
4
+ /**
5
+ * Hook to observe element resizes. Calls callback with width, height, and the original entry
6
+ * when the element's size changes.
7
+ *
8
+ * @param onResize - Callback invoked when element size changes
9
+ */
10
+ export function useResizeObserver(onResize) {
11
+ const element = useElement();
12
+ useEffect(() => {
13
+ const observer = new ResizeObserver(entries => {
14
+ for (const entry of entries) {
15
+ const { width, height } = entry.contentRect;
16
+ onResize({ width, height, entry });
17
+ }
18
+ });
19
+ observer.observe(element);
20
+ return () => observer.disconnect();
21
+ }, [element, onResize]);
22
+ }
23
+ //# sourceMappingURL=use-resize-observer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-resize-observer.js","sourceRoot":"","sources":["../../src/hooks/use-resize-observer.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAQ9C;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAoC;IAClE,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE;YAC1C,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC1B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC;gBAC5C,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;YACvC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACvC,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function useState<T>(initializer: () => T): [T, (value: T) => void];
2
+ export declare function useState<T>(initialValue: T): [T, (value: T) => void];
@@ -0,0 +1,15 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { Component_stack } from "./component/stack.js";
3
+ export function useState(initial) {
4
+ const component = Component_stack.active();
5
+ const hookIndex = component.hookIndex++;
6
+ const value = component.hooks[hookIndex] ??= (typeof initial === "function" ? initial() : initial);
7
+ return [
8
+ value,
9
+ (newValue) => {
10
+ component.hooks[hookIndex] = newValue;
11
+ component.requestUpdate();
12
+ }
13
+ ];
14
+ }
15
+ //# sourceMappingURL=use-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-state.js","sourceRoot":"","sources":["../../src/hooks/use-state.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIvD,MAAM,UAAU,QAAQ,CAAI,OAAgB;IACxC,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC;IAC3C,MAAM,SAAS,GAAG,SAAS,CAAC,SAAS,EAAE,CAAC;IACxC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACnG,OAAO;QACH,KAAK;QACL,CAAC,QAAW,EAAE,EAAE;YACZ,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC;YACtC,SAAS,CAAC,aAAa,EAAE,CAAC;QAC9B,CAAC;KACJ,CAAC;AAEN,CAAC"}
@@ -0,0 +1,4 @@
1
+ export interface UpdateEventHost {
2
+ updateListeners: Set<() => void>;
3
+ }
4
+ export declare function useUpdated(listener: () => void, dependencies?: unknown[]): void;
@@ -0,0 +1,40 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { useElement } from "./use-element.js";
3
+ import { useEffect } from "./use-effect.js";
4
+ function hasUpdateListeners(el) {
5
+ return (typeof el === 'object' &&
6
+ el !== null &&
7
+ 'updateListeners' in el &&
8
+ el['updateListeners'] instanceof Set);
9
+ }
10
+ function makeUpdateEventHost(el) {
11
+ if (hasUpdateListeners(el))
12
+ return el;
13
+ const updateListeners = new Set();
14
+ Object.defineProperty(el, 'updateListeners', {
15
+ value: updateListeners,
16
+ writable: false,
17
+ enumerable: false,
18
+ });
19
+ if (!('updated' in el)) {
20
+ throw new Error('Element does not have an updated method');
21
+ }
22
+ const element = el;
23
+ const orig = element.updated.bind(el);
24
+ element.updated = (changedProps) => {
25
+ orig(changedProps);
26
+ for (const fn of updateListeners)
27
+ fn();
28
+ };
29
+ return element;
30
+ }
31
+ export function useUpdated(listener, dependencies = []) {
32
+ const element = makeUpdateEventHost(useElement());
33
+ useEffect(() => {
34
+ element.updateListeners.add(listener);
35
+ return () => {
36
+ element.updateListeners.delete(listener);
37
+ };
38
+ }, dependencies);
39
+ }
40
+ //# sourceMappingURL=use-updated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-updated.js","sourceRoot":"","sources":["../../src/hooks/use-updated.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAM5C,SAAS,kBAAkB,CAAC,EAAW;IACnC,OAAO,CACH,OAAO,EAAE,KAAK,QAAQ;QACtB,EAAE,KAAK,IAAI;QACX,iBAAiB,IAAI,EAAE;QACvB,EAAE,CAAC,iBAAiB,CAAC,YAAY,GAAG,CACvC,CAAC;AACN,CAAC;AAED,SAAS,mBAAmB,CACxB,EAAK;IAEL,IAAI,kBAAkB,CAAC,EAAE,CAAC;QAAE,OAAO,EAAyB,CAAC;IAE7D,MAAM,eAAe,GAAG,IAAI,GAAG,EAAc,CAAC;IAC9C,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,iBAAiB,EAAE;QACzC,KAAK,EAAE,eAAe;QACtB,QAAQ,EAAE,KAAK;QACf,UAAU,EAAE,KAAK;KACpB,CAAC,CAAC;IAEH,IAAI,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC/D,CAAC;IAED,MAAM,OAAO,GAAG,EAEG,CAAC;IACpB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEtC,OAAO,CAAC,OAAO,GAAG,CAAC,YAAY,EAAE,EAAE;QAC/B,IAAI,CAAC,YAAY,CAAC,CAAC;QACnB,KAAK,MAAM,EAAE,IAAI,eAAe;YAAE,EAAE,EAAE,CAAC;IAC3C,CAAC,CAAC;IAEF,OAAO,OAAO,CAAC;AACnB,CAAC;AAGD,MAAM,UAAU,UAAU,CAAC,QAAoB,EAAE,eAA0B,EAAE;IACzE,MAAM,OAAO,GAAG,mBAAmB,CAAC,UAAU,EAAE,CAAC,CAAC;IAClD,SAAS,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACtC,OAAO,GAAG,EAAE;YACR,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAA;IACL,CAAC,EAAE,YAAY,CAAC,CAAC;AACrB,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function useWindowEvent<K extends keyof WindowEventMap>(event: K, callbackFactory: () => (e: WindowEventMap[K]) => void, deps?: any[]): void;
@@ -0,0 +1,11 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { useEffect } from "./use-effect.js";
3
+ import { useMemo } from "./use-memo.js";
4
+ export function useWindowEvent(event, callbackFactory, deps = []) {
5
+ const callback = useMemo(callbackFactory, deps);
6
+ useEffect(() => {
7
+ window.addEventListener(event, callback);
8
+ return () => window.removeEventListener(event, callback);
9
+ }, [callback]);
10
+ }
11
+ //# sourceMappingURL=use-window-event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-window-event.js","sourceRoot":"","sources":["../../src/hooks/use-window-event.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,UAAU,cAAc,CAC1B,KAAQ,EACR,eAAqD,EACrD,OAAc,EAAE;IAEhB,MAAM,QAAQ,GAAG,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;IAChD,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACzC,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7D,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;AACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { Component } from "./component/component.js";
2
+ export declare function withHooks<This extends Component, Args extends any[], Return>(target: object, propertyKey: string, descriptor: TypedPropertyDescriptor<(this: This, ...args: Args) => Return>): TypedPropertyDescriptor<(this: This, ...args: Args) => Return>;
@@ -0,0 +1,16 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ import { Component_stack } from "./component/stack.js";
3
+ export function withHooks(target, propertyKey, descriptor) {
4
+ const originalMethod = descriptor.value;
5
+ descriptor.value = function (...args) {
6
+ Component_stack.push(this);
7
+ try {
8
+ return originalMethod.apply(this, args);
9
+ }
10
+ finally {
11
+ Component_stack.pop();
12
+ }
13
+ };
14
+ return descriptor;
15
+ }
16
+ //# sourceMappingURL=with-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-hooks.js","sourceRoot":"","sources":["../../src/hooks/with-hooks.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAGvD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,UAAU,SAAS,CACrB,MAAc,EACd,WAAmB,EACnB,UAA0E;IAE1E,MAAM,cAAc,GAAG,UAAU,CAAC,KAAM,CAAC;IACzC,UAAU,CAAC,KAAK,GAAG,UAAsB,GAAG,IAAU;QAClD,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC;YACD,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5C,CAAC;gBACO,CAAC;YACL,eAAe,CAAC,GAAG,EAAE,CAAC;QAC1B,CAAC;IACL,CAAC,CAAA;IACD,OAAO,UAAU,CAAC;AACtB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./hooks/index.js";
2
+ export * from "./elements/index.js";
3
+ export * from "./decorators/index.js";
4
+ export type { Vec2 } from "@adobe/data/math";
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ export * from "./hooks/index.js";
3
+ export * from "./elements/index.js";
4
+ export * from "./decorators/index.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@adobe/data-lit",
3
+ "version": "0.9.11",
4
+ "description": "Adobe data Lit bindings - hooks, elements, decorators",
5
+ "type": "module",
6
+ "private": false,
7
+ "dependencies": {
8
+ "@adobe/data": "0.9.11"
9
+ },
10
+ "peerDependencies": {
11
+ "lit": "^3.3.1"
12
+ },
13
+ "devDependencies": {
14
+ "lit": "^3.3.1",
15
+ "typescript": "^5.8.3",
16
+ "vitest": "^1.6.0"
17
+ },
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/index.js",
21
+ "types": "./dist/index.d.ts"
22
+ }
23
+ },
24
+ "scripts": {
25
+ "build": "tsc -b",
26
+ "dev": "tsc -b -w",
27
+ "test": "vitest --run --passWithNoTests",
28
+ "publish-public": "pnpm build && pnpm publish --no-git-checks --access public"
29
+ }
30
+ }
@@ -0,0 +1,26 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+
3
+ export function applyDecorator(
4
+ target: any,
5
+ propertyKey: string,
6
+ decorator: (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor
7
+ ) {
8
+ // Get the prototype chain
9
+ let currentPrototype = target;
10
+ let descriptor: PropertyDescriptor | undefined;
11
+
12
+ // Walk up the prototype chain until we find the property
13
+ while (currentPrototype && !descriptor) {
14
+ descriptor = Object.getOwnPropertyDescriptor(currentPrototype, propertyKey);
15
+ if (!descriptor) {
16
+ currentPrototype = Object.getPrototypeOf(currentPrototype);
17
+ }
18
+ }
19
+
20
+ if (!descriptor) {
21
+ throw new Error(`Property ${propertyKey} not found in prototype chain`);
22
+ }
23
+
24
+ const newDescriptor = decorator(target, propertyKey, descriptor);
25
+ Object.defineProperty(target, propertyKey, newDescriptor);
26
+ }
@@ -0,0 +1,15 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+
3
+ import { withHooks } from "../hooks/with-hooks.js";
4
+ import { requireService } from "./require-service.js";
5
+ import { TemplateResult } from "lit";
6
+
7
+ export function applyServiceDecorators(target: any) {
8
+ const prototype = Object.getPrototypeOf(target);
9
+ const originalRender = target.render ?? prototype.render;
10
+ const withService = requireService()(target, 'render', {
11
+ value: originalRender
12
+ });
13
+ const withHooksAndService = withHooks(target, 'render', withService);
14
+ target.render = withHooksAndService.value as () => TemplateResult | null;
15
+ }
@@ -0,0 +1,4 @@
1
+ // © 2026 Adobe. MIT License. See /LICENSE for details.
2
+ export * from "./apply-decorator.js";
3
+ export * from "./apply-service-decorators.js";
4
+ export * from "./require-service.js";