@base44-preview/vite-plugin 0.2.16-pr.25.4154914 → 0.2.16-pr.25.c6d6e08

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;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
+ {"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;AAEnC,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,GAsFM,MAAM,CACZ"}
@@ -1,62 +1,73 @@
1
- const INJECTIONS = {
2
- unhandledErrors: {
3
- src: "/node_modules/@base44/vite-plugin/dist/injections/unhandled-errors-handlers.js",
4
- injectTo: "head",
5
- when: "dev",
6
- },
7
- sandboxMount: {
8
- src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-mount-observer.js",
9
- injectTo: "body",
10
- when: "dev",
11
- },
12
- hmrNotifier: {
13
- src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-hmr-notifier.js",
14
- injectTo: "head",
15
- when: "dev",
16
- },
17
- navigationNotifier: {
18
- src: "/node_modules/@base44/vite-plugin/dist/injections/navigation-notifier.js",
19
- injectTo: "head",
20
- when: "dev",
21
- },
22
- visualEditAgent: {
23
- src: "/node_modules/@base44/vite-plugin/dist/injections/visual-edit-agent.js",
24
- injectTo: "body",
25
- when: "dev",
26
- },
27
- analyticsTracker: {
28
- src: "/node_modules/@base44/vite-plugin/dist/injections/analytics-tracker.js",
29
- injectTo: "head",
30
- when: "production",
31
- },
32
- };
33
1
  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
- };
43
2
  return {
44
3
  name: "html-injections",
45
4
  transformIndexHtml: {
46
5
  order: "pre",
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.when === currentMode)
52
- .map(([, injection]) => ({
53
- tag: "script",
54
- attrs: {
55
- src: injection.src,
56
- type: "module",
57
- },
58
- injectTo: injection.injectTo,
59
- }));
6
+ handler(html, ctx) {
7
+ const isProductionBuild = ctx.bundle !== undefined; // bundle exists only during build
8
+ const mode = ctx.server?.config.mode ?? "production";
9
+ const isDev = mode !== "production";
10
+ const tags = [];
11
+ // Sandbox/dev injections - only in dev mode
12
+ if (isDev) {
13
+ tags.push({
14
+ tag: "script",
15
+ attrs: {
16
+ src: "/node_modules/@base44/vite-plugin/dist/injections/unhandled-errors-handlers.js",
17
+ type: "module",
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;
60
71
  },
61
72
  },
62
73
  };
@@ -1 +1 @@
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,KA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AA0E;gCAC/E,IAAI,EAAE,QAAQ;6BACf;4BACD,QAAQ,EAAE,MAAM;yBACjB,CAAC,CAAC;oBACL,CAAC;oBAED,IAAI,eAAe,EAAE,CAAC;wBACpB,IAAI,CAAC,IAAI,CAAC;4BACR,GAAG,EAAE,QAAQ;4BACb,KAAK,EAAE;gCACL,GAAG,EAAE,wEAAwE;gCAC7E,IAAI,EAAE,QAAQ;6BACf;4BACD,QAAQ,EAAE,MAAM;yBACjB,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;gBAED,gDAAgD;gBAChD,IAAI,iBAAiB,IAAI,gBAAgB,EAAE,CAAC;oBAC1C,IAAI,CAAC,IAAI,CAAC;wBACR,GAAG,EAAE,QAAQ;wBACb,KAAK,EAAE;4BACL,GAAG,EAAE,wEAAwE;4BAC7E,IAAI,EAAE,QAAQ;yBACf;wBACD,QAAQ,EAAE,MAAM;qBACjB,CAAC,CAAC;gBACL,CAAC;gBAED,OAAO,IAAI,CAAC;YACd,CAAC;SACF;KACQ,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/vite-plugin",
3
- "version": "0.2.16-pr.25.4154914",
3
+ "version": "0.2.16-pr.25.c6d6e08",
4
4
  "description": "The Vite plugin for base44 based applications",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,44 +1,5 @@
1
1
  import type { Plugin } from "vite";
2
2
 
3
- type Injection = {
4
- src: string;
5
- injectTo: "head" | "body";
6
- when: "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
- when: "dev",
14
- },
15
- sandboxMount: {
16
- src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-mount-observer.js",
17
- injectTo: "body",
18
- when: "dev",
19
- },
20
- hmrNotifier: {
21
- src: "/node_modules/@base44/vite-plugin/dist/injections/sandbox-hmr-notifier.js",
22
- injectTo: "head",
23
- when: "dev",
24
- },
25
- navigationNotifier: {
26
- src: "/node_modules/@base44/vite-plugin/dist/injections/navigation-notifier.js",
27
- injectTo: "head",
28
- when: "dev",
29
- },
30
- visualEditAgent: {
31
- src: "/node_modules/@base44/vite-plugin/dist/injections/visual-edit-agent.js",
32
- injectTo: "body",
33
- when: "dev",
34
- },
35
- analyticsTracker: {
36
- src: "/node_modules/@base44/vite-plugin/dist/injections/analytics-tracker.js",
37
- injectTo: "head",
38
- when: "production",
39
- },
40
- };
41
-
42
3
  export function htmlInjectionsPlugin({
43
4
  hmrNotifier,
44
5
  navigationNotifier,
@@ -50,36 +11,89 @@ export function htmlInjectionsPlugin({
50
11
  visualEditAgent: boolean;
51
12
  analyticsTracker: boolean;
52
13
  }) {
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
-
63
14
  return {
64
15
  name: "html-injections",
65
16
  transformIndexHtml: {
66
17
  order: "pre",
67
- handler(_html, ctx) {
68
- const isProductionBuild = ctx.bundle !== undefined;
69
- const currentMode = isProductionBuild ? "production" : "dev";
18
+ handler(html, ctx) {
19
+ const isProductionBuild = ctx.bundle !== undefined; // bundle exists only during build
20
+ const mode = ctx.server?.config.mode ?? "production";
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
+ }
70
71
 
71
- return Object.entries(INJECTIONS)
72
- .filter(([key, injection]) =>
73
- enabledInjections[key] && injection.when === currentMode
74
- )
75
- .map(([, injection]) => ({
72
+ if (visualEditAgent) {
73
+ tags.push({
74
+ tag: "script",
75
+ attrs: {
76
+ src: "/node_modules/@base44/vite-plugin/dist/injections/visual-edit-agent.js",
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({
76
87
  tag: "script",
77
88
  attrs: {
78
- src: injection.src,
89
+ src: "/node_modules/@base44/vite-plugin/dist/injections/analytics-tracker.js",
79
90
  type: "module",
80
91
  },
81
- injectTo: injection.injectTo,
82
- }));
92
+ injectTo: "head",
93
+ });
94
+ }
95
+
96
+ return tags;
83
97
  },
84
98
  },
85
99
  } as Plugin;