@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.
- package/README.md +34 -0
- package/changes.json +22 -0
- package/compat/agents.cjs +13 -0
- package/compat/base44Client.cjs +6 -0
- package/compat/entities.cjs +25 -0
- package/compat/functions.cjs +9 -0
- package/compat/integrations.cjs +9 -0
- package/dist/ErrorOverlay.d.ts +12 -0
- package/dist/ErrorOverlay.d.ts.map +1 -0
- package/dist/ErrorOverlay.js +51 -0
- package/dist/ErrorOverlay.js.map +1 -0
- package/dist/bridge.d.ts +8 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +8 -0
- package/dist/bridge.js.map +1 -0
- package/dist/capabilities/inline-edit/controller.d.ts +3 -0
- package/dist/capabilities/inline-edit/controller.d.ts.map +1 -0
- package/dist/capabilities/inline-edit/controller.js +203 -0
- package/dist/capabilities/inline-edit/controller.js.map +1 -0
- package/dist/capabilities/inline-edit/dom-utils.d.ts +7 -0
- package/dist/capabilities/inline-edit/dom-utils.d.ts.map +1 -0
- package/dist/capabilities/inline-edit/dom-utils.js +59 -0
- package/dist/capabilities/inline-edit/dom-utils.js.map +1 -0
- package/dist/capabilities/inline-edit/index.d.ts +3 -0
- package/dist/capabilities/inline-edit/index.d.ts.map +1 -0
- package/dist/capabilities/inline-edit/index.js +2 -0
- package/dist/capabilities/inline-edit/index.js.map +1 -0
- package/dist/capabilities/inline-edit/types.d.ts +29 -0
- package/dist/capabilities/inline-edit/types.d.ts.map +1 -0
- package/dist/capabilities/inline-edit/types.js +2 -0
- package/dist/capabilities/inline-edit/types.js.map +1 -0
- package/dist/consts.d.ts +11 -0
- package/dist/consts.d.ts.map +1 -0
- package/dist/consts.js +11 -0
- package/dist/consts.js.map +1 -0
- package/dist/error-overlay-plugin.d.ts +3 -0
- package/dist/error-overlay-plugin.d.ts.map +1 -0
- package/dist/error-overlay-plugin.js +15 -0
- package/dist/error-overlay-plugin.js.map +1 -0
- package/dist/html-injections-plugin.d.ts +8 -0
- package/dist/html-injections-plugin.d.ts.map +1 -0
- package/dist/html-injections-plugin.js +132 -0
- package/dist/html-injections-plugin.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +158 -0
- package/dist/index.js.map +1 -0
- package/dist/injections/layer-dropdown/consts.d.ts +20 -0
- package/dist/injections/layer-dropdown/consts.d.ts.map +1 -0
- package/dist/injections/layer-dropdown/consts.js +41 -0
- package/dist/injections/layer-dropdown/consts.js.map +1 -0
- package/dist/injections/layer-dropdown/controller.d.ts +4 -0
- package/dist/injections/layer-dropdown/controller.d.ts.map +1 -0
- package/dist/injections/layer-dropdown/controller.js +88 -0
- package/dist/injections/layer-dropdown/controller.js.map +1 -0
- package/dist/injections/layer-dropdown/dropdown-ui.d.ts +13 -0
- package/dist/injections/layer-dropdown/dropdown-ui.d.ts.map +1 -0
- package/dist/injections/layer-dropdown/dropdown-ui.js +186 -0
- package/dist/injections/layer-dropdown/dropdown-ui.js.map +1 -0
- package/dist/injections/layer-dropdown/types.d.ts +26 -0
- package/dist/injections/layer-dropdown/types.d.ts.map +1 -0
- package/dist/injections/layer-dropdown/types.js +3 -0
- package/dist/injections/layer-dropdown/types.js.map +1 -0
- package/dist/injections/layer-dropdown/utils.d.ts +25 -0
- package/dist/injections/layer-dropdown/utils.d.ts.map +1 -0
- package/dist/injections/layer-dropdown/utils.js +143 -0
- package/dist/injections/layer-dropdown/utils.js.map +1 -0
- package/dist/injections/navigation-notifier.d.ts +2 -0
- package/dist/injections/navigation-notifier.d.ts.map +1 -0
- package/dist/injections/navigation-notifier.js +34 -0
- package/dist/injections/navigation-notifier.js.map +1 -0
- package/dist/injections/sandbox-hmr-notifier.d.ts +2 -0
- package/dist/injections/sandbox-hmr-notifier.d.ts.map +1 -0
- package/dist/injections/sandbox-hmr-notifier.js +10 -0
- package/dist/injections/sandbox-hmr-notifier.js.map +1 -0
- package/dist/injections/sandbox-mount-observer.d.ts +2 -0
- package/dist/injections/sandbox-mount-observer.d.ts.map +1 -0
- package/dist/injections/sandbox-mount-observer.js +18 -0
- package/dist/injections/sandbox-mount-observer.js.map +1 -0
- package/dist/injections/unhandled-errors-handlers.d.ts +2 -0
- package/dist/injections/unhandled-errors-handlers.d.ts.map +1 -0
- package/dist/injections/unhandled-errors-handlers.js +93 -0
- package/dist/injections/unhandled-errors-handlers.js.map +1 -0
- package/dist/injections/utils.d.ts +65 -0
- package/dist/injections/utils.d.ts.map +1 -0
- package/dist/injections/utils.js +186 -0
- package/dist/injections/utils.js.map +1 -0
- package/dist/injections/visual-edit-agent.d.ts +2 -0
- package/dist/injections/visual-edit-agent.d.ts.map +1 -0
- package/dist/injections/visual-edit-agent.js +583 -0
- package/dist/injections/visual-edit-agent.js.map +1 -0
- package/dist/jsx-processor.d.ts +17 -0
- package/dist/jsx-processor.d.ts.map +1 -0
- package/dist/jsx-processor.js +129 -0
- package/dist/jsx-processor.js.map +1 -0
- package/dist/jsx-utils.d.ts +16 -0
- package/dist/jsx-utils.d.ts.map +1 -0
- package/dist/jsx-utils.js +98 -0
- package/dist/jsx-utils.js.map +1 -0
- package/dist/processors/collection-id-processor.d.ts +20 -0
- package/dist/processors/collection-id-processor.d.ts.map +1 -0
- package/dist/processors/collection-id-processor.js +182 -0
- package/dist/processors/collection-id-processor.js.map +1 -0
- package/dist/processors/collection-item-field-processor.d.ts +39 -0
- package/dist/processors/collection-item-field-processor.d.ts.map +1 -0
- package/dist/processors/collection-item-field-processor.js +289 -0
- package/dist/processors/collection-item-field-processor.js.map +1 -0
- package/dist/processors/collection-item-id-processor.d.ts +12 -0
- package/dist/processors/collection-item-id-processor.d.ts.map +1 -0
- package/dist/processors/collection-item-id-processor.js +50 -0
- package/dist/processors/collection-item-id-processor.js.map +1 -0
- package/dist/processors/static-array-processor.d.ts +28 -0
- package/dist/processors/static-array-processor.d.ts.map +1 -0
- package/dist/processors/static-array-processor.js +173 -0
- package/dist/processors/static-array-processor.js.map +1 -0
- package/dist/processors/utils/collection-tracing-utils.d.ts +36 -0
- package/dist/processors/utils/collection-tracing-utils.d.ts.map +1 -0
- package/dist/processors/utils/collection-tracing-utils.js +390 -0
- package/dist/processors/utils/collection-tracing-utils.js.map +1 -0
- package/dist/processors/utils/shared-utils.d.ts +96 -0
- package/dist/processors/utils/shared-utils.d.ts.map +1 -0
- package/dist/processors/utils/shared-utils.js +600 -0
- package/dist/processors/utils/shared-utils.js.map +1 -0
- package/dist/statics/index.mjs +16 -0
- package/dist/statics/index.mjs.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +22 -0
- package/dist/utils.js.map +1 -0
- package/dist/visual-edit-plugin.d.ts +3 -0
- package/dist/visual-edit-plugin.d.ts.map +1 -0
- package/dist/visual-edit-plugin.js +100 -0
- package/dist/visual-edit-plugin.js.map +1 -0
- package/package.json +75 -0
- package/src/ErrorOverlay.ts +71 -0
- package/src/bridge.ts +8 -0
- package/src/capabilities/inline-edit/controller.ts +254 -0
- package/src/capabilities/inline-edit/dom-utils.ts +58 -0
- package/src/capabilities/inline-edit/index.ts +2 -0
- package/src/capabilities/inline-edit/types.ts +35 -0
- package/src/consts.ts +11 -0
- package/src/error-overlay-plugin.ts +19 -0
- package/src/html-injections-plugin.ts +166 -0
- package/src/index.ts +225 -0
- package/src/injections/layer-dropdown/LAYERS.md +258 -0
- package/src/injections/layer-dropdown/consts.ts +51 -0
- package/src/injections/layer-dropdown/controller.ts +109 -0
- package/src/injections/layer-dropdown/dropdown-ui.ts +242 -0
- package/src/injections/layer-dropdown/types.ts +30 -0
- package/src/injections/layer-dropdown/utils.ts +175 -0
- package/src/injections/navigation-notifier.ts +43 -0
- package/src/injections/sandbox-hmr-notifier.ts +8 -0
- package/src/injections/sandbox-mount-observer.ts +25 -0
- package/src/injections/unhandled-errors-handlers.ts +114 -0
- package/src/injections/utils.ts +208 -0
- package/src/injections/visual-edit-agent.ts +706 -0
- package/src/jsx-processor.ts +169 -0
- package/src/jsx-utils.ts +131 -0
- package/src/processors/collection-id-processor.ts +261 -0
- package/src/processors/collection-item-field-processor.ts +439 -0
- package/src/processors/collection-item-id-processor.ts +69 -0
- package/src/processors/static-array-processor.ts +260 -0
- package/src/processors/utils/collection-tracing-utils.ts +507 -0
- package/src/processors/utils/shared-utils.ts +785 -0
- package/src/utils.ts +27 -0
- package/src/visual-edit-plugin.md +358 -0
- 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
|
+
}
|