@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,15 @@
1
+ import { errorOverlayCode } from "./ErrorOverlay.js";
2
+ export function errorOverlayPlugin() {
3
+ return {
4
+ name: "error-overlay",
5
+ apply: (config) => config.mode === "development",
6
+ transform(code, id, opts = {}) {
7
+ if (opts?.ssr)
8
+ return;
9
+ if (!id.includes("vite/dist/client/client.mjs"))
10
+ return;
11
+ return code.replace("class ErrorOverlay", errorOverlayCode + "\nclass OldErrorOverlay");
12
+ },
13
+ };
14
+ }
15
+ //# sourceMappingURL=error-overlay-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-overlay-plugin.js","sourceRoot":"","sources":["../src/error-overlay-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,aAAa;QAChD,SAAS,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,GAAG,EAAE;YAC3B,IAAI,IAAI,EAAE,GAAG;gBAAE,OAAO;YAEtB,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;gBAAE,OAAO;YAExD,OAAO,IAAI,CAAC,OAAO,CACjB,oBAAoB,EACpB,gBAAgB,GAAG,yBAAyB,CAC7C,CAAC;QACJ,CAAC;KACQ,CAAC;AACd,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Plugin } from "vite";
2
+ export declare function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEditAgent, analyticsTracker, }: {
3
+ hmrNotifier: boolean;
4
+ navigationNotifier: boolean;
5
+ visualEditAgent: boolean;
6
+ analyticsTracker: boolean;
7
+ }): Plugin;
8
+ //# sourceMappingURL=html-injections-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-injections-plugin.d.ts","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAqB,MAAM,MAAM,CAAC;AAyEtD,wBAAgB,oBAAoB,CAAC,EACnC,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,EAAE;IACD,WAAW,EAAE,OAAO,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,GAiFM,MAAM,CACZ"}
@@ -0,0 +1,132 @@
1
+ import { loadEnv } from "vite";
2
+ const ANALYTICS_TRACKER_SCRIPT = `
3
+ if (window.self === window.top) {
4
+ let lastPath = "";
5
+ function getPageNameFromPath(path) {
6
+ const segments = path.split("/").filter(Boolean);
7
+ return segments[0] || null;
8
+ }
9
+ function trackPageView() {
10
+ const path = window.location.pathname;
11
+ if (path === lastPath) return;
12
+ lastPath = path;
13
+ const pageName = getPageNameFromPath(path) || "home";
14
+ const appId = import.meta.env.VITE_BASE44_APP_ID;
15
+ if (!appId) return;
16
+ fetch(\`/app-logs/\${appId}/log-user-in-app/\${pageName}\`, {
17
+ method: "POST",
18
+ }).catch(() => {});
19
+ }
20
+ const originalPushState = history.pushState.bind(history);
21
+ history.pushState = function (...args) {
22
+ originalPushState(...args);
23
+ trackPageView();
24
+ };
25
+ const originalReplaceState = history.replaceState.bind(history);
26
+ history.replaceState = function (...args) {
27
+ originalReplaceState(...args);
28
+ trackPageView();
29
+ };
30
+ window.addEventListener("popstate", trackPageView);
31
+ trackPageView();
32
+ }
33
+ `;
34
+ const INJECTIONS = {
35
+ unhandledErrors: {
36
+ src: "/node_modules/@base44/vite-plugin/dist/injections/unhandled-errors-handlers.js",
37
+ injectTo: "head",
38
+ mode: "dev",
39
+ },
40
+ sandboxMount: {
41
+ src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-mount-observer.js",
42
+ injectTo: "body",
43
+ mode: "dev",
44
+ },
45
+ hmrNotifier: {
46
+ src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-hmr-notifier.js",
47
+ injectTo: "head",
48
+ mode: "dev",
49
+ },
50
+ navigationNotifier: {
51
+ src: "/node_modules/@base44/vite-plugin/dist/injections/navigation-notifier.js",
52
+ injectTo: "head",
53
+ mode: "dev",
54
+ },
55
+ analyticsTracker: {
56
+ injectTo: "head",
57
+ mode: "production",
58
+ inlineContent: ANALYTICS_TRACKER_SCRIPT,
59
+ },
60
+ };
61
+ export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEditAgent, analyticsTracker, }) {
62
+ const enabledInjections = {
63
+ unhandledErrors: true,
64
+ sandboxMount: true,
65
+ hmrNotifier,
66
+ navigationNotifier,
67
+ analyticsTracker,
68
+ };
69
+ let resolvedEnv = {};
70
+ return {
71
+ name: "html-injections",
72
+ configResolved(config) {
73
+ // Capture env vars for use in transformIndexHtml
74
+ // loadEnv gets all env vars including VITE_ prefixed ones
75
+ resolvedEnv = loadEnv(config.mode, config.root, "");
76
+ },
77
+ transformIndexHtml: {
78
+ handler(_html, ctx) {
79
+ const currentMode = ctx.server ? "dev" : "production";
80
+ const tags = Object.entries(INJECTIONS)
81
+ .filter(([key, injection]) => enabledInjections[key] && injection.mode === currentMode)
82
+ .map(([, injection]) => {
83
+ // Production injections use inline content (src paths don't work in built output)
84
+ if (injection.inlineContent) {
85
+ // Replace import.meta.env references with actual values
86
+ // Vite doesn't replace these in inline script content
87
+ let content = injection.inlineContent;
88
+ content = content.replace(/import\.meta\.env\.(\w+)/g, (_, envKey) => JSON.stringify(resolvedEnv[envKey] ?? ""));
89
+ return {
90
+ tag: "script",
91
+ attrs: { type: "module" },
92
+ children: content,
93
+ injectTo: injection.injectTo,
94
+ };
95
+ }
96
+ // Dev injections use src path (served from node_modules)
97
+ return {
98
+ tag: "script",
99
+ attrs: {
100
+ src: injection.src,
101
+ type: "module",
102
+ },
103
+ injectTo: injection.injectTo,
104
+ };
105
+ });
106
+ // Visual edit agent — loaded via dynamic import to support
107
+ // local dev iteration with ?sandbox-bridge=local
108
+ if (currentMode === "dev" && visualEditAgent) {
109
+ const dist = "/node_modules/@base44/vite-plugin/dist";
110
+ tags.push({
111
+ tag: "script",
112
+ attrs: { type: "module" },
113
+ children: [
114
+ `if (window.self !== window.top) {`,
115
+ ` const mode = new URLSearchParams(location.search).get("sandbox-bridge");`,
116
+ ` const url = mode === "local"`,
117
+ ` ? "https://localhost:3201/index.mjs"`,
118
+ ` : "${dist}/statics/index.mjs";`,
119
+ ` import(url)`,
120
+ ` .then(mod => { if (typeof mod.setupVisualEditAgent === "function") mod.setupVisualEditAgent(); })`,
121
+ ` .catch(e => console.error("[visual-edit-agent] Failed to load:", e));`,
122
+ `}`,
123
+ ].join("\n"),
124
+ injectTo: "body",
125
+ });
126
+ }
127
+ return tags;
128
+ },
129
+ },
130
+ };
131
+ }
132
+ //# sourceMappingURL=html-injections-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-injections-plugin.js","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAW/B,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BhC,CAAC;AAEF,MAAM,UAAU,GAA8B;IAC5C,eAAe,EAAE;QACf,GAAG,EAAE,gFAAgF;QACrF,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,YAAY,EAAE;QACZ,GAAG,EAAE,6EAA6E;QAClF,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,WAAW,EAAE;QACX,GAAG,EAAE,2EAA2E;QAChF,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,kBAAkB,EAAE;QAClB,GAAG,EAAE,0EAA0E;QAC/E,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,gBAAgB,EAAE;QAChB,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,YAAY;QAClB,aAAa,EAAE,wBAAwB;KACxC;CACF,CAAC;AAEF,MAAM,UAAU,oBAAoB,CAAC,EACnC,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GAMjB;IACC,MAAM,iBAAiB,GAA4B;QACjD,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE,IAAI;QAClB,WAAW;QACX,kBAAkB;QAClB,gBAAgB;KACjB,CAAC;IAEF,IAAI,WAAW,GAA2B,EAAE,CAAC;IAE7C,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,cAAc,CAAC,MAAM;YACnB,iDAAiD;YACjD,0DAA0D;YAC1D,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI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gBACjD,IAAI,WAAW,KAAK,KAAK,IAAI,eAAe,EAAE,CAAC;oBAC7C,MAAM,IAAI,GAAG,wCAAwC,CAAC;oBACtD,IAAI,CAAC,IAAI,CAAC;wBACR,GAAG,EAAE,QAAQ;wBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;wBACzB,QAAQ,EAAE;4BACR,mCAAmC;4BACnC,4EAA4E;4BAC5E,gCAAgC;4BAChC,0CAA0C;4BAC1C,UAAU,IAAI,sBAAsB;4BACpC,eAAe;4BACf,uGAAuG;4BACvG,2EAA2E;4BAC3E,GAAG;yBACJ,CAAC,IAAI,CAAC,IAAI,CAAC;wBACZ,QAAQ,EAAE,MAAM;qBACjB,CAAC,CAAC;gBACL,CAAC;gBAED,OAAO,IAAI,CAAC;YACd,CAAC;SACF;KACQ,CAAC;AACd,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Plugin } from "vite";
2
+ export default function vitePlugin(opts?: {
3
+ legacySDKImports?: boolean;
4
+ hmrNotifier?: boolean;
5
+ navigationNotifier?: boolean;
6
+ visualEditAgent?: boolean;
7
+ analyticsTracker?: boolean;
8
+ }): Plugin<any>[];
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;AAS/C,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,IAAI,GAAE;IACJ,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACvB,iBAgNP"}
package/dist/index.js ADDED
@@ -0,0 +1,158 @@
1
+ import { loadEnv } from "vite";
2
+ import { errorOverlayPlugin } from "./error-overlay-plugin.js";
3
+ import { visualEditPlugin } from "./visual-edit-plugin.js";
4
+ import { filterPackagesInProject } from "./utils.js";
5
+ import { htmlInjectionsPlugin } from "./html-injections-plugin.js";
6
+ const isRunningInSandbox = !!process.env.MODAL_SANDBOX_ID;
7
+ export default function vitePlugin(opts = {}) {
8
+ const { legacySDKImports = false, hmrNotifier = false, navigationNotifier = false, visualEditAgent = false, analyticsTracker = false, } = opts;
9
+ return [
10
+ {
11
+ name: "base44",
12
+ config: ({ mode, root = process.cwd() }) => {
13
+ const env = loadEnv(mode ?? "development", root, "");
14
+ return {
15
+ resolve: {
16
+ alias: {
17
+ "@/": "/src/",
18
+ },
19
+ },
20
+ ...(legacySDKImports
21
+ ? {
22
+ define: {
23
+ "process.env.VITE_BASE44_APP_ID": JSON.stringify(env.VITE_BASE44_APP_ID),
24
+ "process.env.VITE_BASE44_BACKEND_URL": JSON.stringify(env.VITE_BASE44_BACKEND_URL),
25
+ },
26
+ }
27
+ : {}),
28
+ ...(isRunningInSandbox
29
+ ? {
30
+ server: {
31
+ cors: true,
32
+ host: "0.0.0.0", // Bind to all interfaces for container access
33
+ port: 5173,
34
+ strictPort: true,
35
+ // Allow all hosts - essential for Modal tunnel URLs
36
+ allowedHosts: true,
37
+ watch: {
38
+ // Enable polling for better file change detection in containers
39
+ usePolling: true,
40
+ interval: 100, // Check every 100ms for responsive HMR
41
+ // Wait for file writes to complete before triggering HMR
42
+ awaitWriteFinish: {
43
+ stabilityThreshold: 150,
44
+ pollInterval: 50,
45
+ },
46
+ },
47
+ },
48
+ build: {
49
+ rollupOptions: {
50
+ onwarn(warning, warn) {
51
+ // Treat import errors as fatal errors
52
+ if (warning.code === "UNRESOLVED_IMPORT" ||
53
+ warning.code === "MISSING_EXPORT") {
54
+ throw new Error(`Build failed: ${warning.message}`);
55
+ }
56
+ // Use default for other warnings
57
+ warn(warning);
58
+ },
59
+ },
60
+ },
61
+ }
62
+ : (() => {
63
+ if (env.VITE_BASE44_APP_BASE_URL) {
64
+ console.log(`[base44] Proxy enabled: /api -> ${env.VITE_BASE44_APP_BASE_URL}`);
65
+ return {
66
+ server: {
67
+ proxy: {
68
+ "/api": {
69
+ target: env.VITE_BASE44_APP_BASE_URL,
70
+ changeOrigin: true,
71
+ },
72
+ },
73
+ },
74
+ };
75
+ }
76
+ console.log("[base44] Proxy not enabled (VITE_BASE44_APP_BASE_URL not set)");
77
+ return {};
78
+ })()),
79
+ optimizeDeps: {
80
+ ...(isRunningInSandbox
81
+ ? {
82
+ include: filterPackagesInProject([
83
+ "react",
84
+ "react-dom",
85
+ "framer-motion",
86
+ "lodash",
87
+ "moment",
88
+ "react-quill",
89
+ ], root),
90
+ }
91
+ : {}),
92
+ esbuildOptions: {
93
+ loader: {
94
+ ".js": "jsx",
95
+ },
96
+ },
97
+ },
98
+ };
99
+ },
100
+ async resolveId(source, importer, options) {
101
+ // only resolve imports in the legacy SDK if they are not in an HTML file
102
+ // because we might have pages that include /integrations, /functions, etc.
103
+ if (legacySDKImports && !importer?.endsWith(".html")) {
104
+ const existingResolution = await this.resolve(source, importer, options);
105
+ if (existingResolution) {
106
+ return existingResolution;
107
+ }
108
+ // in legacy apps, the AI sometimes imports components from the Layout with `../`
109
+ // which breaks when monving to the vite template, so this solved it by
110
+ // resolving the path to the components folder
111
+ if (importer?.endsWith("/src/Layout.jsx") &&
112
+ source.startsWith("../components")) {
113
+ return this.resolve(source.replace(/^..\/components/, "@/components"), importer, options);
114
+ }
115
+ // Handle imports of Layout.js or Layout.jsx from pages directory
116
+ if (importer?.includes("/pages") &&
117
+ (source.toLowerCase().endsWith("layout.jsx") ||
118
+ source.toLowerCase().endsWith("layout.js"))) {
119
+ return this.resolve("@/Layout.jsx", importer, options);
120
+ }
121
+ if (source.includes("/entities")) {
122
+ return this.resolve("@base44/vite-plugin/compat/entities.cjs", importer, options);
123
+ }
124
+ if (source.includes("/functions")) {
125
+ return this.resolve("@base44/vite-plugin/compat/functions.cjs", importer, options);
126
+ }
127
+ if (source.includes("/integrations")) {
128
+ return this.resolve("@base44/vite-plugin/compat/integrations.cjs", importer, options);
129
+ }
130
+ if (source.includes("/agents")) {
131
+ return this.resolve("@base44/vite-plugin/compat/agents.cjs", importer, options);
132
+ }
133
+ }
134
+ return null;
135
+ },
136
+ },
137
+ ...(isRunningInSandbox
138
+ ? [
139
+ {
140
+ name: "iframe-hmr",
141
+ configureServer(server) {
142
+ server.middlewares.use((req, res, next) => {
143
+ // Allow iframe embedding
144
+ res.setHeader("X-Frame-Options", "ALLOWALL");
145
+ res.setHeader("Content-Security-Policy", "frame-ancestors *;");
146
+ next();
147
+ });
148
+ },
149
+ },
150
+ errorOverlayPlugin(),
151
+ visualEditPlugin(),
152
+ ]
153
+ : []),
154
+ // HTML injections - handles both dev (sandbox) and production injections
155
+ htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEditAgent, analyticsTracker }),
156
+ ];
157
+ }
158
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,kBAAkB,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;AAE1D,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,OAMI,EAAE;IAEN,MAAM,EACJ,gBAAgB,GAAG,KAAK,EACxB,WAAW,GAAG,KAAK,EACnB,kBAAkB,GAAG,KAAK,EAC1B,eAAe,GAAG,KAAK,EACvB,gBAAgB,GAAG,KAAK,GACzB,GAAG,IAAI,CAAC;IAET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H,CAAC;gBAED,OAAO,IAAI,CAAC;YACd,CAAC;SACQ;QACX,GAAG,CAAC,kBAAkB;YACpB,CAAC,CAAC;gBACE;oBACE,IAAI,EAAE,YAAY;oBAClB,eAAe,CAAC,MAAM;wBACpB,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;4BACxC,yBAAyB;4BACzB,GAAG,CAAC,SAAS,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;4BAC7C,GAAG,CAAC,SAAS,CAAC,yBAAyB,EAAE,oBAAoB,CAAC,CAAC;4BAC/D,IAAI,EAAE,CAAC;wBACT,CAAC,CAAC,CAAC;oBACL,CAAC;iBACQ;gBACX,kBAAkB,EAAE;gBACpB,gBAAgB,EAAE;aACnB;YACH,CAAC,CAAC,EAAE,CAAC;QACP,yEAAyE;QACzE,oBAAoB,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC;KAC7F,CAAC;AACJ,CAAC"}
@@ -0,0 +1,20 @@
1
+ /** Style constants for the layer dropdown UI */
2
+ export declare const DROPDOWN_CONTAINER_STYLES: Record<string, string>;
3
+ export declare const DROPDOWN_ITEM_BASE_STYLES: Record<string, string>;
4
+ export declare const DROPDOWN_ITEM_ACTIVE_COLOR = "#526cff";
5
+ export declare const DROPDOWN_ITEM_ACTIVE_BG = "#DBEAFE";
6
+ export declare const DROPDOWN_ITEM_ACTIVE_FONT_WEIGHT = "600";
7
+ export declare const DROPDOWN_ITEM_HOVER_BG = "#f1f5f9";
8
+ export declare const DEPTH_INDENT_PX = 10;
9
+ /** SVG chevron shown when dropdown is collapsed (click to expand) */
10
+ export declare const CHEVRON_COLLAPSED = "<svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" style=\"vertical-align:middle;margin-left:4px\"><path d=\"M6 9l6 6 6-6\" stroke=\"currentColor\" stroke-width=\"2\" fill=\"none\"/></svg>";
11
+ /** SVG chevron shown when dropdown is expanded (click to collapse) */
12
+ export declare const CHEVRON_EXPANDED = "<svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" style=\"vertical-align:middle;margin-left:4px\"><path d=\"M18 15l-6-6-6 6\" stroke=\"currentColor\" stroke-width=\"2\" fill=\"none\"/></svg>";
13
+ export declare const CHEVRON_ATTR = "data-chevron";
14
+ export declare const BASE_PADDING_PX = 12;
15
+ export declare const LAYER_DROPDOWN_ATTR = "data-layer-dropdown";
16
+ /** Max instrumented ancestors to show above the selected element */
17
+ export declare const MAX_PARENT_DEPTH = 2;
18
+ /** Max instrumented depth levels to show below the selected element */
19
+ export declare const MAX_CHILD_DEPTH = 2;
20
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/consts.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAa5D,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAQ5D,CAAC;AAEF,eAAO,MAAM,0BAA0B,YAAY,CAAC;AACpD,eAAO,MAAM,uBAAuB,YAAY,CAAC;AACjD,eAAO,MAAM,gCAAgC,QAAQ,CAAC;AAEtD,eAAO,MAAM,sBAAsB,YAAY,CAAC;AAEhD,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,qEAAqE;AACrE,eAAO,MAAM,iBAAiB,oMAAoL,CAAC;AACnN,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,uMAAuL,CAAC;AAErN,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD,oEAAoE;AACpE,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,uEAAuE;AACvE,eAAO,MAAM,eAAe,IAAI,CAAC"}
@@ -0,0 +1,41 @@
1
+ /** Style constants for the layer dropdown UI */
2
+ export const DROPDOWN_CONTAINER_STYLES = {
3
+ position: "absolute",
4
+ backgroundColor: "#ffffff",
5
+ border: "1px solid #e2e8f0",
6
+ borderRadius: "6px",
7
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
8
+ fontSize: "12px",
9
+ minWidth: "120px",
10
+ maxHeight: "200px",
11
+ overflowY: "auto",
12
+ zIndex: "10001",
13
+ padding: "4px 0",
14
+ pointerEvents: "auto",
15
+ };
16
+ export const DROPDOWN_ITEM_BASE_STYLES = {
17
+ padding: "4px 12px",
18
+ cursor: "pointer",
19
+ color: "#334155",
20
+ backgroundColor: "transparent",
21
+ whiteSpace: "nowrap",
22
+ lineHeight: "1.5",
23
+ fontWeight: "400",
24
+ };
25
+ export const DROPDOWN_ITEM_ACTIVE_COLOR = "#526cff";
26
+ export const DROPDOWN_ITEM_ACTIVE_BG = "#DBEAFE";
27
+ export const DROPDOWN_ITEM_ACTIVE_FONT_WEIGHT = "600";
28
+ export const DROPDOWN_ITEM_HOVER_BG = "#f1f5f9";
29
+ export const DEPTH_INDENT_PX = 10;
30
+ /** SVG chevron shown when dropdown is collapsed (click to expand) */
31
+ export const CHEVRON_COLLAPSED = `<svg width="12" height="12" viewBox="0 0 24 24" style="vertical-align:middle;margin-left:4px"><path d="M6 9l6 6 6-6" stroke="currentColor" stroke-width="2" fill="none"/></svg>`;
32
+ /** SVG chevron shown when dropdown is expanded (click to collapse) */
33
+ export const CHEVRON_EXPANDED = `<svg width="12" height="12" viewBox="0 0 24 24" style="vertical-align:middle;margin-left:4px"><path d="M18 15l-6-6-6 6" stroke="currentColor" stroke-width="2" fill="none"/></svg>`;
34
+ export const CHEVRON_ATTR = "data-chevron";
35
+ export const BASE_PADDING_PX = 12;
36
+ export const LAYER_DROPDOWN_ATTR = "data-layer-dropdown";
37
+ /** Max instrumented ancestors to show above the selected element */
38
+ export const MAX_PARENT_DEPTH = 2;
39
+ /** Max instrumented depth levels to show below the selected element */
40
+ export const MAX_CHILD_DEPTH = 2;
41
+ //# sourceMappingURL=consts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/consts.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,MAAM,CAAC,MAAM,yBAAyB,GAA2B;IAC/D,QAAQ,EAAE,UAAU;IACpB,eAAe,EAAE,SAAS;IAC1B,MAAM,EAAE,mBAAmB;IAC3B,YAAY,EAAE,KAAK;IACnB,SAAS,EAAE,gCAAgC;IAC3C,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,OAAO;IACjB,SAAS,EAAE,OAAO;IAClB,SAAS,EAAE,MAAM;IACjB,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,OAAO;IAChB,aAAa,EAAE,MAAM;CACtB,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAA2B;IAC/D,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,eAAe,EAAE,aAAa;IAC9B,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,KAAK;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAC;AACpD,MAAM,CAAC,MAAM,uBAAuB,GAAG,SAAS,CAAC;AACjD,MAAM,CAAC,MAAM,gCAAgC,GAAG,KAAK,CAAC;AAEtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC,qEAAqE;AACrE,MAAM,CAAC,MAAM,iBAAiB,GAAG,iLAAiL,CAAC;AACnN,sEAAsE;AACtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,oLAAoL,CAAC;AAErN,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAEzD,oEAAoE;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC,uEAAuE;AACvE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** Controller that encapsulates layer-dropdown integration logic */
2
+ import type { LayerControllerConfig, LayerController } from "./types.js";
3
+ export declare function createLayerController(config: LayerControllerConfig): LayerController;
4
+ //# sourceMappingURL=controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/controller.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAUpE,OAAO,KAAK,EAAa,qBAAqB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEpF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,GAAG,eAAe,CAgGpF"}
@@ -0,0 +1,88 @@
1
+ /** Controller that encapsulates layer-dropdown integration logic */
2
+ import { getElementSelectorId } from "../utils.js";
3
+ import { buildLayerChain } from "./utils.js";
4
+ import { enhanceLabelWithChevron, showDropdown, closeDropdown, isDropdownOpen, } from "./dropdown-ui.js";
5
+ export function createLayerController(config) {
6
+ let layerPreviewOverlay = null;
7
+ let escapeHandler = null;
8
+ let dropdownSourceLayer = null;
9
+ const clearLayerPreview = () => {
10
+ if (layerPreviewOverlay && layerPreviewOverlay.parentNode) {
11
+ layerPreviewOverlay.remove();
12
+ }
13
+ layerPreviewOverlay = null;
14
+ };
15
+ const showLayerPreview = (layer) => {
16
+ clearLayerPreview();
17
+ if (getElementSelectorId(layer.element) === config.getSelectedElementId())
18
+ return;
19
+ layerPreviewOverlay = config.createPreviewOverlay(layer.element);
20
+ };
21
+ const selectLayer = (layer) => {
22
+ clearLayerPreview();
23
+ closeDropdown();
24
+ if (escapeHandler) {
25
+ document.removeEventListener("keydown", escapeHandler, true);
26
+ escapeHandler = null;
27
+ }
28
+ dropdownSourceLayer = null;
29
+ const firstOverlay = config.selectElement(layer.element);
30
+ attachToOverlay(firstOverlay, layer.element);
31
+ };
32
+ const restoreSelection = () => {
33
+ if (escapeHandler) {
34
+ document.removeEventListener("keydown", escapeHandler, true);
35
+ escapeHandler = null;
36
+ }
37
+ if (dropdownSourceLayer) {
38
+ selectLayer(dropdownSourceLayer);
39
+ dropdownSourceLayer = null;
40
+ }
41
+ };
42
+ const handleLabelClick = (e, label, element, layers, currentId) => {
43
+ e.stopPropagation();
44
+ e.preventDefault();
45
+ if (isDropdownOpen()) {
46
+ closeDropdown();
47
+ restoreSelection();
48
+ }
49
+ else {
50
+ dropdownSourceLayer = {
51
+ element,
52
+ tagName: element.tagName.toLowerCase(),
53
+ selectorId: currentId,
54
+ };
55
+ config.onDeselect();
56
+ escapeHandler = (ev) => {
57
+ if (ev.key === "Escape") {
58
+ ev.stopPropagation();
59
+ closeDropdown();
60
+ restoreSelection();
61
+ }
62
+ };
63
+ document.addEventListener("keydown", escapeHandler, true);
64
+ showDropdown(label, layers, element, { onSelect: selectLayer, onHover: showLayerPreview, onHoverEnd: clearLayerPreview });
65
+ }
66
+ };
67
+ const attachToOverlay = (overlay, element) => {
68
+ if (!overlay)
69
+ return;
70
+ const label = overlay.querySelector("div");
71
+ if (!label)
72
+ return;
73
+ const layers = buildLayerChain(element);
74
+ if (layers.length <= 1)
75
+ return;
76
+ const currentId = getElementSelectorId(element);
77
+ enhanceLabelWithChevron(label);
78
+ label.addEventListener("click", (e) => {
79
+ handleLabelClick(e, label, element, layers, currentId);
80
+ });
81
+ };
82
+ const cleanup = () => {
83
+ clearLayerPreview();
84
+ closeDropdown();
85
+ };
86
+ return { attachToOverlay, cleanup };
87
+ }
88
+ //# sourceMappingURL=controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/injections/layer-dropdown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EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC,CAAC;QAC5H,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,eAAe,GAAG,CACtB,OAAmC,EACnC,OAAgB,EAChB,EAAE;QACF,IAAI,CAAC,OAAO;YAAE,OAAO;QAErB,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,KAAK,CAA0B,CAAC;QACpE,IAAI,CAAC,KAAK;YAAE,OAAO;QAEnB,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,MAAM,CAAC,MAAM,IAAI,CAAC;YAAE,OAAO;QAE/B,MAAM,SAAS,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAChD,uBAAuB,CAAC,KAAK,CAAC,CAAC;QAE/B,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAa,EAAE,EAAE;YAChD,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,iBAAiB,EAAE,CAAC;QACpB,aAAa,EAAE,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** Dropdown UI component for layer navigation */
2
+ import type { LayerInfo, DropdownCallbacks } from "./types.js";
3
+ /** Create the dropdown DOM element with layer items */
4
+ export declare function createDropdownElement(layers: LayerInfo[], currentElement: Element | null, callbacks: DropdownCallbacks): HTMLDivElement;
5
+ /** Add chevron indicator and pointer-events to the label */
6
+ export declare function enhanceLabelWithChevron(label: HTMLDivElement): void;
7
+ /** Show the dropdown below the label element */
8
+ export declare function showDropdown(label: HTMLDivElement, layers: LayerInfo[], currentElement: Element | null, callbacks: DropdownCallbacks): void;
9
+ /** Close the active dropdown and clean up listeners */
10
+ export declare function closeDropdown(): void;
11
+ /** Check if a dropdown is currently visible */
12
+ export declare function isDropdownOpen(): boolean;
13
+ //# sourceMappingURL=dropdown-ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdown-ui.d.ts","sourceRoot":"","sources":["../../../src/injections/layer-dropdown/dropdown-ui.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAiBjD,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAgD/D,uDAAuD;AACvD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EAAE,EACnB,cAAc,EAAE,OAAO,GAAG,IAAI,EAC9B,SAAS,EAAE,iBAAiB,GAC3B,cAAc,CAYhB;AAED,4DAA4D;AAC5D,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAiBnE;AAkED,gDAAgD;AAChD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,SAAS,EAAE,EACnB,cAAc,EAAE,OAAO,GAAG,IAAI,EAC9B,SAAS,EAAE,iBAAiB,GAC3B,IAAI,CAiCN;AAED,uDAAuD;AACvD,wBAAgB,aAAa,IAAI,IAAI,CA0BpC;AAED,+CAA+C;AAC/C,wBAAgB,cAAc,IAAI,OAAO,CAExC"}