@base44-preview/vite-plugin 0.2.16-pr.25.c6d6e08 → 0.2.16-pr.25.cc5a39c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-injections-plugin.d.ts","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"html-injections-plugin.d.ts","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAyCnC,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,GAiCM,MAAM,CACZ"}
|
|
@@ -1,73 +1,62 @@
|
|
|
1
|
+
const INJECTIONS = {
|
|
2
|
+
unhandledErrors: {
|
|
3
|
+
src: "/node_modules/@base44/vite-plugin/dist/injections/unhandled-errors-handlers.js",
|
|
4
|
+
injectTo: "head",
|
|
5
|
+
mode: "dev",
|
|
6
|
+
},
|
|
7
|
+
sandboxMount: {
|
|
8
|
+
src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-mount-observer.js",
|
|
9
|
+
injectTo: "body",
|
|
10
|
+
mode: "dev",
|
|
11
|
+
},
|
|
12
|
+
hmrNotifier: {
|
|
13
|
+
src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-hmr-notifier.js",
|
|
14
|
+
injectTo: "head",
|
|
15
|
+
mode: "dev",
|
|
16
|
+
},
|
|
17
|
+
navigationNotifier: {
|
|
18
|
+
src: "/node_modules/@base44/vite-plugin/dist/injections/navigation-notifier.js",
|
|
19
|
+
injectTo: "head",
|
|
20
|
+
mode: "dev",
|
|
21
|
+
},
|
|
22
|
+
visualEditAgent: {
|
|
23
|
+
src: "/node_modules/@base44/vite-plugin/dist/injections/visual-edit-agent.js",
|
|
24
|
+
injectTo: "body",
|
|
25
|
+
mode: "dev",
|
|
26
|
+
},
|
|
27
|
+
analyticsTracker: {
|
|
28
|
+
src: "/node_modules/@base44/vite-plugin/dist/injections/analytics-tracker.js",
|
|
29
|
+
injectTo: "head",
|
|
30
|
+
mode: "production",
|
|
31
|
+
},
|
|
32
|
+
};
|
|
1
33
|
export function htmlInjectionsPlugin({ hmrNotifier, navigationNotifier, visualEditAgent, analyticsTracker, }) {
|
|
34
|
+
// Always-on injections in dev mode
|
|
35
|
+
const enabledInjections = {
|
|
36
|
+
unhandledErrors: true,
|
|
37
|
+
sandboxMount: true,
|
|
38
|
+
hmrNotifier,
|
|
39
|
+
navigationNotifier,
|
|
40
|
+
visualEditAgent,
|
|
41
|
+
analyticsTracker,
|
|
42
|
+
};
|
|
2
43
|
return {
|
|
3
44
|
name: "html-injections",
|
|
4
45
|
transformIndexHtml: {
|
|
5
46
|
order: "pre",
|
|
6
|
-
handler(
|
|
7
|
-
const isProductionBuild = ctx.bundle !== undefined;
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
injectTo: "head",
|
|
20
|
-
}, {
|
|
21
|
-
tag: "script",
|
|
22
|
-
attrs: {
|
|
23
|
-
src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-mount-observer.js",
|
|
24
|
-
type: "module",
|
|
25
|
-
},
|
|
26
|
-
injectTo: "body",
|
|
27
|
-
});
|
|
28
|
-
if (hmrNotifier) {
|
|
29
|
-
tags.push({
|
|
30
|
-
tag: "script",
|
|
31
|
-
attrs: {
|
|
32
|
-
src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-hmr-notifier.js",
|
|
33
|
-
type: "module",
|
|
34
|
-
},
|
|
35
|
-
injectTo: "head",
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
if (navigationNotifier) {
|
|
39
|
-
tags.push({
|
|
40
|
-
tag: "script",
|
|
41
|
-
attrs: {
|
|
42
|
-
src: "/node_modules/@base44/vite-plugin/dist/injections/navigation-notifier.js",
|
|
43
|
-
type: "module",
|
|
44
|
-
},
|
|
45
|
-
injectTo: "head",
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
if (visualEditAgent) {
|
|
49
|
-
tags.push({
|
|
50
|
-
tag: "script",
|
|
51
|
-
attrs: {
|
|
52
|
-
src: "/node_modules/@base44/vite-plugin/dist/injections/visual-edit-agent.js",
|
|
53
|
-
type: "module",
|
|
54
|
-
},
|
|
55
|
-
injectTo: "body",
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
// Analytics tracker - only in production builds
|
|
60
|
-
if (isProductionBuild && analyticsTracker) {
|
|
61
|
-
tags.push({
|
|
62
|
-
tag: "script",
|
|
63
|
-
attrs: {
|
|
64
|
-
src: "/node_modules/@base44/vite-plugin/dist/injections/analytics-tracker.js",
|
|
65
|
-
type: "module",
|
|
66
|
-
},
|
|
67
|
-
injectTo: "head",
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return tags;
|
|
47
|
+
handler(_html, ctx) {
|
|
48
|
+
const isProductionBuild = ctx.bundle !== undefined;
|
|
49
|
+
const currentMode = isProductionBuild ? "production" : "dev";
|
|
50
|
+
return Object.entries(INJECTIONS)
|
|
51
|
+
.filter(([key, injection]) => enabledInjections[key] && injection.mode === currentMode)
|
|
52
|
+
.map(([, injection]) => ({
|
|
53
|
+
tag: "script",
|
|
54
|
+
attrs: {
|
|
55
|
+
src: injection.src,
|
|
56
|
+
type: "module",
|
|
57
|
+
},
|
|
58
|
+
injectTo: injection.injectTo,
|
|
59
|
+
}));
|
|
71
60
|
},
|
|
72
61
|
},
|
|
73
62
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-injections-plugin.js","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"html-injections-plugin.js","sourceRoot":"","sources":["../src/html-injections-plugin.ts"],"names":[],"mappings":"AAQA,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,eAAe,EAAE;QACf,GAAG,EAAE,wEAAwE;QAC7E,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,KAAK;KACZ;IACD,gBAAgB,EAAE;QAChB,GAAG,EAAE,wEAAwE;QAC7E,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,YAAY;KACnB;CACF,CAAC;AAEF,MAAM,UAAU,oBAAoB,CAAC,EACnC,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GAMjB;IACC,mCAAmC;IACnC,MAAM,iBAAiB,GAA4B;QACjD,eAAe,EAAE,IAAI;QACrB,YAAY,EAAE,IAAI;QAClB,WAAW;QACX,kBAAkB;QAClB,eAAe;QACf,gBAAgB;KACjB,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,kBAAkB,EAAE;YAClB,KAAK,EAAE,KAAK;YACZ,OAAO,CAAC,KAAK,EAAE,GAAG;gBAChB,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC;gBACnD,MAAM,WAAW,GAAG,iBAAiB,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC;gBAE7D,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;qBAC9B,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,CAC3B,iBAAiB,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,IAAI,KAAK,WAAW,CACzD;qBACA,GAAG,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;oBACvB,GAAG,EAAE,QAAQ;oBACb,KAAK,EAAE;wBACL,GAAG,EAAE,SAAS,CAAC,GAAG;wBAClB,IAAI,EAAE,QAAQ;qBACf;oBACD,QAAQ,EAAE,SAAS,CAAC,QAAQ;iBAC7B,CAAC,CAAC,CAAC;YACR,CAAC;SACF;KACQ,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
|
|
3
|
+
type Injection = {
|
|
4
|
+
src: string;
|
|
5
|
+
injectTo: "head" | "body";
|
|
6
|
+
mode: "dev" | "production";
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const INJECTIONS: Record<string, Injection> = {
|
|
10
|
+
unhandledErrors: {
|
|
11
|
+
src: "/node_modules/@base44/vite-plugin/dist/injections/unhandled-errors-handlers.js",
|
|
12
|
+
injectTo: "head",
|
|
13
|
+
mode: "dev",
|
|
14
|
+
},
|
|
15
|
+
sandboxMount: {
|
|
16
|
+
src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-mount-observer.js",
|
|
17
|
+
injectTo: "body",
|
|
18
|
+
mode: "dev",
|
|
19
|
+
},
|
|
20
|
+
hmrNotifier: {
|
|
21
|
+
src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-hmr-notifier.js",
|
|
22
|
+
injectTo: "head",
|
|
23
|
+
mode: "dev",
|
|
24
|
+
},
|
|
25
|
+
navigationNotifier: {
|
|
26
|
+
src: "/node_modules/@base44/vite-plugin/dist/injections/navigation-notifier.js",
|
|
27
|
+
injectTo: "head",
|
|
28
|
+
mode: "dev",
|
|
29
|
+
},
|
|
30
|
+
visualEditAgent: {
|
|
31
|
+
src: "/node_modules/@base44/vite-plugin/dist/injections/visual-edit-agent.js",
|
|
32
|
+
injectTo: "body",
|
|
33
|
+
mode: "dev",
|
|
34
|
+
},
|
|
35
|
+
analyticsTracker: {
|
|
36
|
+
src: "/node_modules/@base44/vite-plugin/dist/injections/analytics-tracker.js",
|
|
37
|
+
injectTo: "head",
|
|
38
|
+
mode: "production",
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
3
42
|
export function htmlInjectionsPlugin({
|
|
4
43
|
hmrNotifier,
|
|
5
44
|
navigationNotifier,
|
|
@@ -11,89 +50,36 @@ export function htmlInjectionsPlugin({
|
|
|
11
50
|
visualEditAgent: boolean;
|
|
12
51
|
analyticsTracker: boolean;
|
|
13
52
|
}) {
|
|
53
|
+
// Always-on injections in dev mode
|
|
54
|
+
const enabledInjections: Record<string, boolean> = {
|
|
55
|
+
unhandledErrors: true,
|
|
56
|
+
sandboxMount: true,
|
|
57
|
+
hmrNotifier,
|
|
58
|
+
navigationNotifier,
|
|
59
|
+
visualEditAgent,
|
|
60
|
+
analyticsTracker,
|
|
61
|
+
};
|
|
62
|
+
|
|
14
63
|
return {
|
|
15
64
|
name: "html-injections",
|
|
16
65
|
transformIndexHtml: {
|
|
17
66
|
order: "pre",
|
|
18
|
-
handler(
|
|
19
|
-
const isProductionBuild = ctx.bundle !== undefined;
|
|
20
|
-
const
|
|
21
|
-
const isDev = mode !== "production";
|
|
22
|
-
|
|
23
|
-
const tags: Array<{
|
|
24
|
-
tag: string;
|
|
25
|
-
attrs: Record<string, string>;
|
|
26
|
-
injectTo: "head" | "body";
|
|
27
|
-
}> = [];
|
|
28
|
-
|
|
29
|
-
// Sandbox/dev injections - only in dev mode
|
|
30
|
-
if (isDev) {
|
|
31
|
-
tags.push(
|
|
32
|
-
{
|
|
33
|
-
tag: "script",
|
|
34
|
-
attrs: {
|
|
35
|
-
src: "/node_modules/@base44/vite-plugin/dist/injections/unhandled-errors-handlers.js",
|
|
36
|
-
type: "module",
|
|
37
|
-
},
|
|
38
|
-
injectTo: "head",
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
tag: "script",
|
|
42
|
-
attrs: {
|
|
43
|
-
src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-mount-observer.js",
|
|
44
|
-
type: "module",
|
|
45
|
-
},
|
|
46
|
-
injectTo: "body",
|
|
47
|
-
}
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
if (hmrNotifier) {
|
|
51
|
-
tags.push({
|
|
52
|
-
tag: "script",
|
|
53
|
-
attrs: {
|
|
54
|
-
src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-hmr-notifier.js",
|
|
55
|
-
type: "module",
|
|
56
|
-
},
|
|
57
|
-
injectTo: "head",
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (navigationNotifier) {
|
|
62
|
-
tags.push({
|
|
63
|
-
tag: "script",
|
|
64
|
-
attrs: {
|
|
65
|
-
src: "/node_modules/@base44/vite-plugin/dist/injections/navigation-notifier.js",
|
|
66
|
-
type: "module",
|
|
67
|
-
},
|
|
68
|
-
injectTo: "head",
|
|
69
|
-
});
|
|
70
|
-
}
|
|
67
|
+
handler(_html, ctx) {
|
|
68
|
+
const isProductionBuild = ctx.bundle !== undefined;
|
|
69
|
+
const currentMode = isProductionBuild ? "production" : "dev";
|
|
71
70
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
type: "module",
|
|
78
|
-
},
|
|
79
|
-
injectTo: "body",
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Analytics tracker - only in production builds
|
|
85
|
-
if (isProductionBuild && analyticsTracker) {
|
|
86
|
-
tags.push({
|
|
71
|
+
return Object.entries(INJECTIONS)
|
|
72
|
+
.filter(([key, injection]) =>
|
|
73
|
+
enabledInjections[key] && injection.mode === currentMode
|
|
74
|
+
)
|
|
75
|
+
.map(([, injection]) => ({
|
|
87
76
|
tag: "script",
|
|
88
77
|
attrs: {
|
|
89
|
-
src:
|
|
78
|
+
src: injection.src,
|
|
90
79
|
type: "module",
|
|
91
80
|
},
|
|
92
|
-
injectTo:
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return tags;
|
|
81
|
+
injectTo: injection.injectTo,
|
|
82
|
+
}));
|
|
97
83
|
},
|
|
98
84
|
},
|
|
99
85
|
} as Plugin;
|