@depup/base44__vite-plugin 1.0.4-depup.0

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 (167) hide show
  1. package/README.md +34 -0
  2. package/changes.json +22 -0
  3. package/compat/agents.cjs +13 -0
  4. package/compat/base44Client.cjs +6 -0
  5. package/compat/entities.cjs +25 -0
  6. package/compat/functions.cjs +9 -0
  7. package/compat/integrations.cjs +9 -0
  8. package/dist/ErrorOverlay.d.ts +12 -0
  9. package/dist/ErrorOverlay.d.ts.map +1 -0
  10. package/dist/ErrorOverlay.js +51 -0
  11. package/dist/ErrorOverlay.js.map +1 -0
  12. package/dist/bridge.d.ts +8 -0
  13. package/dist/bridge.d.ts.map +1 -0
  14. package/dist/bridge.js +8 -0
  15. package/dist/bridge.js.map +1 -0
  16. package/dist/capabilities/inline-edit/controller.d.ts +3 -0
  17. package/dist/capabilities/inline-edit/controller.d.ts.map +1 -0
  18. package/dist/capabilities/inline-edit/controller.js +203 -0
  19. package/dist/capabilities/inline-edit/controller.js.map +1 -0
  20. package/dist/capabilities/inline-edit/dom-utils.d.ts +7 -0
  21. package/dist/capabilities/inline-edit/dom-utils.d.ts.map +1 -0
  22. package/dist/capabilities/inline-edit/dom-utils.js +59 -0
  23. package/dist/capabilities/inline-edit/dom-utils.js.map +1 -0
  24. package/dist/capabilities/inline-edit/index.d.ts +3 -0
  25. package/dist/capabilities/inline-edit/index.d.ts.map +1 -0
  26. package/dist/capabilities/inline-edit/index.js +2 -0
  27. package/dist/capabilities/inline-edit/index.js.map +1 -0
  28. package/dist/capabilities/inline-edit/types.d.ts +29 -0
  29. package/dist/capabilities/inline-edit/types.d.ts.map +1 -0
  30. package/dist/capabilities/inline-edit/types.js +2 -0
  31. package/dist/capabilities/inline-edit/types.js.map +1 -0
  32. package/dist/consts.d.ts +11 -0
  33. package/dist/consts.d.ts.map +1 -0
  34. package/dist/consts.js +11 -0
  35. package/dist/consts.js.map +1 -0
  36. package/dist/error-overlay-plugin.d.ts +3 -0
  37. package/dist/error-overlay-plugin.d.ts.map +1 -0
  38. package/dist/error-overlay-plugin.js +15 -0
  39. package/dist/error-overlay-plugin.js.map +1 -0
  40. package/dist/html-injections-plugin.d.ts +8 -0
  41. package/dist/html-injections-plugin.d.ts.map +1 -0
  42. package/dist/html-injections-plugin.js +132 -0
  43. package/dist/html-injections-plugin.js.map +1 -0
  44. package/dist/index.d.ts +9 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +158 -0
  47. package/dist/index.js.map +1 -0
  48. package/dist/injections/layer-dropdown/consts.d.ts +20 -0
  49. package/dist/injections/layer-dropdown/consts.d.ts.map +1 -0
  50. package/dist/injections/layer-dropdown/consts.js +41 -0
  51. package/dist/injections/layer-dropdown/consts.js.map +1 -0
  52. package/dist/injections/layer-dropdown/controller.d.ts +4 -0
  53. package/dist/injections/layer-dropdown/controller.d.ts.map +1 -0
  54. package/dist/injections/layer-dropdown/controller.js +88 -0
  55. package/dist/injections/layer-dropdown/controller.js.map +1 -0
  56. package/dist/injections/layer-dropdown/dropdown-ui.d.ts +13 -0
  57. package/dist/injections/layer-dropdown/dropdown-ui.d.ts.map +1 -0
  58. package/dist/injections/layer-dropdown/dropdown-ui.js +186 -0
  59. package/dist/injections/layer-dropdown/dropdown-ui.js.map +1 -0
  60. package/dist/injections/layer-dropdown/types.d.ts +26 -0
  61. package/dist/injections/layer-dropdown/types.d.ts.map +1 -0
  62. package/dist/injections/layer-dropdown/types.js +3 -0
  63. package/dist/injections/layer-dropdown/types.js.map +1 -0
  64. package/dist/injections/layer-dropdown/utils.d.ts +25 -0
  65. package/dist/injections/layer-dropdown/utils.d.ts.map +1 -0
  66. package/dist/injections/layer-dropdown/utils.js +143 -0
  67. package/dist/injections/layer-dropdown/utils.js.map +1 -0
  68. package/dist/injections/navigation-notifier.d.ts +2 -0
  69. package/dist/injections/navigation-notifier.d.ts.map +1 -0
  70. package/dist/injections/navigation-notifier.js +34 -0
  71. package/dist/injections/navigation-notifier.js.map +1 -0
  72. package/dist/injections/sandbox-hmr-notifier.d.ts +2 -0
  73. package/dist/injections/sandbox-hmr-notifier.d.ts.map +1 -0
  74. package/dist/injections/sandbox-hmr-notifier.js +10 -0
  75. package/dist/injections/sandbox-hmr-notifier.js.map +1 -0
  76. package/dist/injections/sandbox-mount-observer.d.ts +2 -0
  77. package/dist/injections/sandbox-mount-observer.d.ts.map +1 -0
  78. package/dist/injections/sandbox-mount-observer.js +18 -0
  79. package/dist/injections/sandbox-mount-observer.js.map +1 -0
  80. package/dist/injections/unhandled-errors-handlers.d.ts +2 -0
  81. package/dist/injections/unhandled-errors-handlers.d.ts.map +1 -0
  82. package/dist/injections/unhandled-errors-handlers.js +93 -0
  83. package/dist/injections/unhandled-errors-handlers.js.map +1 -0
  84. package/dist/injections/utils.d.ts +65 -0
  85. package/dist/injections/utils.d.ts.map +1 -0
  86. package/dist/injections/utils.js +186 -0
  87. package/dist/injections/utils.js.map +1 -0
  88. package/dist/injections/visual-edit-agent.d.ts +2 -0
  89. package/dist/injections/visual-edit-agent.d.ts.map +1 -0
  90. package/dist/injections/visual-edit-agent.js +583 -0
  91. package/dist/injections/visual-edit-agent.js.map +1 -0
  92. package/dist/jsx-processor.d.ts +17 -0
  93. package/dist/jsx-processor.d.ts.map +1 -0
  94. package/dist/jsx-processor.js +129 -0
  95. package/dist/jsx-processor.js.map +1 -0
  96. package/dist/jsx-utils.d.ts +16 -0
  97. package/dist/jsx-utils.d.ts.map +1 -0
  98. package/dist/jsx-utils.js +98 -0
  99. package/dist/jsx-utils.js.map +1 -0
  100. package/dist/processors/collection-id-processor.d.ts +20 -0
  101. package/dist/processors/collection-id-processor.d.ts.map +1 -0
  102. package/dist/processors/collection-id-processor.js +182 -0
  103. package/dist/processors/collection-id-processor.js.map +1 -0
  104. package/dist/processors/collection-item-field-processor.d.ts +39 -0
  105. package/dist/processors/collection-item-field-processor.d.ts.map +1 -0
  106. package/dist/processors/collection-item-field-processor.js +289 -0
  107. package/dist/processors/collection-item-field-processor.js.map +1 -0
  108. package/dist/processors/collection-item-id-processor.d.ts +12 -0
  109. package/dist/processors/collection-item-id-processor.d.ts.map +1 -0
  110. package/dist/processors/collection-item-id-processor.js +50 -0
  111. package/dist/processors/collection-item-id-processor.js.map +1 -0
  112. package/dist/processors/static-array-processor.d.ts +28 -0
  113. package/dist/processors/static-array-processor.d.ts.map +1 -0
  114. package/dist/processors/static-array-processor.js +173 -0
  115. package/dist/processors/static-array-processor.js.map +1 -0
  116. package/dist/processors/utils/collection-tracing-utils.d.ts +36 -0
  117. package/dist/processors/utils/collection-tracing-utils.d.ts.map +1 -0
  118. package/dist/processors/utils/collection-tracing-utils.js +390 -0
  119. package/dist/processors/utils/collection-tracing-utils.js.map +1 -0
  120. package/dist/processors/utils/shared-utils.d.ts +96 -0
  121. package/dist/processors/utils/shared-utils.d.ts.map +1 -0
  122. package/dist/processors/utils/shared-utils.js +600 -0
  123. package/dist/processors/utils/shared-utils.js.map +1 -0
  124. package/dist/statics/index.mjs +16 -0
  125. package/dist/statics/index.mjs.map +1 -0
  126. package/dist/utils.d.ts +2 -0
  127. package/dist/utils.d.ts.map +1 -0
  128. package/dist/utils.js +22 -0
  129. package/dist/utils.js.map +1 -0
  130. package/dist/visual-edit-plugin.d.ts +3 -0
  131. package/dist/visual-edit-plugin.d.ts.map +1 -0
  132. package/dist/visual-edit-plugin.js +100 -0
  133. package/dist/visual-edit-plugin.js.map +1 -0
  134. package/package.json +75 -0
  135. package/src/ErrorOverlay.ts +71 -0
  136. package/src/bridge.ts +8 -0
  137. package/src/capabilities/inline-edit/controller.ts +254 -0
  138. package/src/capabilities/inline-edit/dom-utils.ts +58 -0
  139. package/src/capabilities/inline-edit/index.ts +2 -0
  140. package/src/capabilities/inline-edit/types.ts +35 -0
  141. package/src/consts.ts +11 -0
  142. package/src/error-overlay-plugin.ts +19 -0
  143. package/src/html-injections-plugin.ts +166 -0
  144. package/src/index.ts +225 -0
  145. package/src/injections/layer-dropdown/LAYERS.md +258 -0
  146. package/src/injections/layer-dropdown/consts.ts +51 -0
  147. package/src/injections/layer-dropdown/controller.ts +109 -0
  148. package/src/injections/layer-dropdown/dropdown-ui.ts +242 -0
  149. package/src/injections/layer-dropdown/types.ts +30 -0
  150. package/src/injections/layer-dropdown/utils.ts +175 -0
  151. package/src/injections/navigation-notifier.ts +43 -0
  152. package/src/injections/sandbox-hmr-notifier.ts +8 -0
  153. package/src/injections/sandbox-mount-observer.ts +25 -0
  154. package/src/injections/unhandled-errors-handlers.ts +114 -0
  155. package/src/injections/utils.ts +208 -0
  156. package/src/injections/visual-edit-agent.ts +706 -0
  157. package/src/jsx-processor.ts +169 -0
  158. package/src/jsx-utils.ts +131 -0
  159. package/src/processors/collection-id-processor.ts +261 -0
  160. package/src/processors/collection-item-field-processor.ts +439 -0
  161. package/src/processors/collection-item-id-processor.ts +69 -0
  162. package/src/processors/static-array-processor.ts +260 -0
  163. package/src/processors/utils/collection-tracing-utils.ts +507 -0
  164. package/src/processors/utils/shared-utils.ts +785 -0
  165. package/src/utils.ts +27 -0
  166. package/src/visual-edit-plugin.md +358 -0
  167. package/src/visual-edit-plugin.ts +110 -0
@@ -0,0 +1,208 @@
1
+ const LABEL_HEIGHT = 27;
2
+
3
+ /**
4
+ * Positions an element-tag label relative to its highlighted overlay.
5
+ *
6
+ * Strategy (in priority order):
7
+ * 1. If the element is near the viewport top AND tall enough (>= 2x label height),
8
+ * place the label **inside** the element at the top-left.
9
+ * 2. If the element is near the viewport top but too short, place the label
10
+ * **below** the element.
11
+ * 3. Otherwise, place the label **above** the element (default).
12
+ *
13
+ * For full-width elements (spanning nearly the entire viewport), the left offset
14
+ * is nudged inward (6px) to prevent clipping against the viewport edge.
15
+ *
16
+ * @param label - The label div to position (style.top and style.left are set).
17
+ * @param rect - The bounding client rect of the highlighted element.
18
+ */
19
+ export function positionLabel(label: HTMLDivElement, rect: DOMRect): void {
20
+ const nearTop = rect.top < LABEL_HEIGHT;
21
+ const tallEnough = rect.height >= LABEL_HEIGHT * 2;
22
+ const isFullWidth = rect.width >= window.innerWidth - 4;
23
+ const edgeLeft = isFullWidth ? "8px" : "-2px";
24
+ const insideLeft = isFullWidth ? "8px" : "4px";
25
+
26
+ if (nearTop && tallEnough) {
27
+ label.style.top = "2px";
28
+ label.style.left = insideLeft;
29
+ } else if (nearTop) {
30
+ label.style.top = `${rect.height + 2}px`;
31
+ label.style.left = edgeLeft;
32
+ } else {
33
+ label.style.top = `-${LABEL_HEIGHT}px`;
34
+ label.style.left = edgeLeft;
35
+ }
36
+ }
37
+
38
+ /** Check if an element has instrumentation attributes */
39
+ export function isInstrumentedElement(element: Element): boolean {
40
+ const htmlEl = element as HTMLElement;
41
+ return !!(
42
+ htmlEl.dataset?.sourceLocation || htmlEl.dataset?.visualSelectorId
43
+ );
44
+ }
45
+
46
+ /** Get the selector ID from an element's data attributes (prefers source-location) */
47
+ export function getElementSelectorId(element: Element): string | null {
48
+ const htmlEl = element as HTMLElement;
49
+ return (
50
+ htmlEl.dataset?.sourceLocation ||
51
+ htmlEl.dataset?.visualSelectorId ||
52
+ null
53
+ );
54
+ }
55
+
56
+ export const ALLOWED_ATTRIBUTES: string[] = ["src"];
57
+
58
+ export const PLUGIN_ELEMENT_ATTR = "data-vite-plugin-element";
59
+
60
+ /** Find elements by ID - first try data-source-location, fallback to data-visual-selector-id */
61
+ export function findElementsById(id: string | null): Element[] {
62
+ if (!id) return [];
63
+ const sourceElements = Array.from(
64
+ document.querySelectorAll(`[data-source-location="${id}"]`)
65
+ );
66
+ if (sourceElements.length > 0) {
67
+ return sourceElements;
68
+ }
69
+ return Array.from(
70
+ document.querySelectorAll(`[data-visual-selector-id="${id}"]`)
71
+ );
72
+ }
73
+
74
+ /**
75
+ * Update element classes by visual selector ID.
76
+ * Uses setAttribute instead of className to support both HTML and SVG elements.
77
+ */
78
+ export function updateElementClasses(elements: Element[], classes: string): void {
79
+ elements.forEach((element) => {
80
+ element.setAttribute("class", classes);
81
+ });
82
+ }
83
+
84
+ /** Set a single attribute on all provided elements. */
85
+ export function updateElementAttribute(elements: Element[], attribute: string, value: string): void {
86
+ if (!ALLOWED_ATTRIBUTES.includes(attribute)) {
87
+ return;
88
+ }
89
+
90
+ elements.forEach((element) => {
91
+ element.setAttribute(attribute, value);
92
+ });
93
+ }
94
+
95
+ /** Collect attribute values from an element for a given allowlist. */
96
+ export function collectAllowedAttributes(element: Element, allowedAttributes: string[]): Record<string, string> {
97
+ const attributes: Record<string, string> = {};
98
+ for (const attr of allowedAttributes) {
99
+ const val = element.getAttribute(attr);
100
+ if (val !== null) {
101
+ attributes[attr] = val;
102
+ }
103
+ }
104
+ return attributes;
105
+ }
106
+
107
+ /**
108
+ * Freeze all CSS animations and transitions on the page by injecting
109
+ * scoped styles under `[data-visual-edit-active]` and programmatically
110
+ * finishing (or pausing) every running animation.
111
+ *
112
+ * Plugin-owned elements (`[data-vite-plugin-element]`) are excluded so
113
+ * the plugin UI stays animated.
114
+ */
115
+ export function stopAnimations(): void {
116
+ if (document.getElementById('freeze-animations')) return;
117
+
118
+ document.documentElement.setAttribute('data-visual-edit-active', '');
119
+
120
+ const animStyle = document.createElement('style');
121
+ animStyle.id = 'freeze-animations';
122
+ animStyle.textContent = `
123
+ [data-visual-edit-active] *:not([${PLUGIN_ELEMENT_ATTR}]):not([${PLUGIN_ELEMENT_ATTR}] *),
124
+ [data-visual-edit-active] *:not([${PLUGIN_ELEMENT_ATTR}]):not([${PLUGIN_ELEMENT_ATTR}] *)::before,
125
+ [data-visual-edit-active] *:not([${PLUGIN_ELEMENT_ATTR}]):not([${PLUGIN_ELEMENT_ATTR}] *)::after {
126
+ animation-play-state: paused !important;
127
+ transition: none !important;
128
+ }
129
+ `;
130
+
131
+ const pointerStyle = document.createElement('style');
132
+ pointerStyle.id = 'freeze-pointer-events';
133
+ pointerStyle.textContent = `
134
+ [data-visual-edit-active] * { pointer-events: none !important; }
135
+ [${PLUGIN_ELEMENT_ATTR}], [${PLUGIN_ELEMENT_ATTR}] * { pointer-events: auto !important; }
136
+ `;
137
+
138
+ const target = document.head || document.documentElement;
139
+ target.appendChild(animStyle);
140
+ target.appendChild(pointerStyle);
141
+
142
+ document.getAnimations().forEach((a) => {
143
+ // Skip animations on plugin UI elements
144
+ const animTarget = (a.effect as KeyframeEffect)?.target;
145
+ if (animTarget instanceof Element && animTarget.closest(`[${PLUGIN_ELEMENT_ATTR}]`)) return;
146
+
147
+ try {
148
+ a.finish(); // fast-forward to end state
149
+ } catch {
150
+ a.pause(); // finish() throws on infinite animations — pause instead
151
+ }
152
+ });
153
+ }
154
+
155
+ /**
156
+ * Resume all previously frozen animations and remove the injected
157
+ * freeze styles. Cleans up the `data-visual-edit-active` attribute
158
+ * from `<html>` so scoped selectors no longer match.
159
+ */
160
+ export function resumeAnimations(): void {
161
+ const animStyle = document.getElementById('freeze-animations');
162
+ if (!animStyle) return;
163
+
164
+ animStyle.remove();
165
+ document.getElementById('freeze-pointer-events')?.remove();
166
+ document.documentElement.removeAttribute('data-visual-edit-active');
167
+
168
+ document.getAnimations().forEach((a) => {
169
+ if (a.playState === 'paused') {
170
+ try { a.play(); } catch { /* animation target may have been removed */ }
171
+ }
172
+ });
173
+ }
174
+
175
+ /**
176
+ * Hit-test the page at (`x`, `y`) and walk up the DOM to find the
177
+ * nearest ancestor that carries instrumentation attributes
178
+ * (`data-source-location` or `data-visual-selector-id`).
179
+ *
180
+ * Temporarily disables the pointer-events freeze sheet so the
181
+ * browser's native `elementFromPoint` can reach the real target.
182
+ */
183
+ export function findInstrumentedElement(x: number, y: number): Element | null {
184
+ const pointerStyle = document.getElementById('freeze-pointer-events') as HTMLStyleElement | null;
185
+ if (pointerStyle) pointerStyle.disabled = true;
186
+
187
+ const el = document.elementFromPoint(x, y);
188
+
189
+ if (pointerStyle) pointerStyle.disabled = false;
190
+
191
+ return el?.closest('[data-source-location], [data-visual-selector-id]') ?? null;
192
+ }
193
+
194
+ /**
195
+ * Resolve which element should be hovered at (`x`, `y`), skipping the
196
+ * currently selected element. Returns the selector ID of the hovered
197
+ * element, or `null` if the point is empty or hits the selected element.
198
+ */
199
+ export function resolveHoverTarget(x: number, y: number, selectedElementId: string | null): string | null {
200
+ const element = findInstrumentedElement(x, y);
201
+ if (!element) return null;
202
+
203
+ const selectorId = getElementSelectorId(element);
204
+
205
+ if (selectorId === selectedElementId) return null;
206
+
207
+ return selectorId;
208
+ }