@lovable.dev/vite-tanstack-config 1.4.1 → 1.4.2

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/dist/index.cjs CHANGED
@@ -148,12 +148,39 @@ function devClientErrorLogger() {
148
148
  return [
149
149
  "if (typeof window !== 'undefined' && import.meta.hot) {",
150
150
  " const send = (d) => { try { import.meta.hot.send('client-runtime-error', d) } catch {} };",
151
+ " const stripTokenFromUrl = (url) => {",
152
+ " try {",
153
+ " const parsed = new URL(url);",
154
+ " parsed.searchParams.delete('__lovable_token');",
155
+ " return parsed.toString();",
156
+ " } catch {",
157
+ " return url;",
158
+ " }",
159
+ " };",
160
+ " const describeResponse = (res) => {",
161
+ " const sanitizedUrl = res.url ? stripTokenFromUrl(res.url) : '';",
162
+ " return `Server responded with ${res.status} ${res.statusText || '(no status text)'}${sanitizedUrl ? ` at ${sanitizedUrl}` : ''}`;",
163
+ " };",
151
164
  " window.addEventListener('error', (e) => {",
152
165
  " send({ type: 'runtime-error', message: e.message, stack: e.error?.stack, filename: e.filename, lineno: e.lineno, colno: e.colno });",
153
166
  " });",
154
167
  " window.addEventListener('unhandledrejection', (e) => {",
155
168
  " const err = e.reason;",
156
- " send({ type: 'unhandled-rejection', message: err?.message || String(err), stack: err?.stack });",
169
+ " if (err instanceof Response) {",
170
+ " const url = err.url ? stripTokenFromUrl(err.url) : undefined;",
171
+ " send({",
172
+ " type: 'unhandled-rejection',",
173
+ " name: 'Response',",
174
+ " message: describeResponse(err),",
175
+ " stack: url ? `Response ${err.status} at ${url}` : `Response ${err.status}`,",
176
+ " filename: url,",
177
+ " url,",
178
+ " status: err.status,",
179
+ " statusText: err.statusText || undefined,",
180
+ " });",
181
+ " return;",
182
+ " }",
183
+ " send({ type: 'unhandled-rejection', name: err?.name, message: err?.message || String(err), stack: err?.stack });",
157
184
  " });",
158
185
  "}"
159
186
  ].join("\n");
@@ -186,7 +213,17 @@ function devClientErrorLogger() {
186
213
  }
187
214
  };
188
215
  server.ws.on("client-runtime-error", (data) => {
189
- const { type, message, stack, filename, lineno, colno } = data;
216
+ const type = typeof data.type === "string" ? data.type : "runtime-error";
217
+ let message = "Unknown error";
218
+ if (typeof data.message === "string") {
219
+ message = data.message;
220
+ } else if (data.message != null) {
221
+ message = JSON.stringify(data.message);
222
+ }
223
+ const stack = typeof data.stack === "string" ? data.stack : void 0;
224
+ const filename = typeof data.filename === "string" ? data.filename : void 0;
225
+ const lineno = typeof data.lineno === "number" ? data.lineno : void 0;
226
+ const colno = typeof data.colno === "number" ? data.colno : void 0;
190
227
  const label = type === "unhandled-rejection" ? "Unhandled Rejection" : "Runtime Error";
191
228
  let loc = "";
192
229
  if (filename) {
@@ -275,8 +312,9 @@ function defineConfig(configOrOptions = {}) {
275
312
  } else if (configOrOptions instanceof Promise) {
276
313
  options = { vite: await configOrOptions };
277
314
  } else {
278
- const hasLovableKey = "vite" in configOrOptions || "clientErrorLogger" in configOrOptions || "serverFnErrorLogger" in configOrOptions || "cloudflare" in configOrOptions || "tanstackStart" in configOrOptions || "react" in configOrOptions || "envDefine" in configOrOptions || "hmrGate" in configOrOptions;
279
- options = hasLovableKey ? configOrOptions : { vite: configOrOptions };
315
+ const optionObject = configOrOptions && typeof configOrOptions === "object" ? configOrOptions : {};
316
+ const hasLovableKey = "vite" in optionObject || "clientErrorLogger" in optionObject || "serverFnErrorLogger" in optionObject || "cloudflare" in optionObject || "tanstackStart" in optionObject || "react" in optionObject || "envDefine" in optionObject || "hmrGate" in optionObject;
317
+ options = hasLovableKey ? optionObject : { vite: optionObject };
280
318
  }
281
319
  const internalPlugins = [];
282
320
  const tailwindcss = (await import("@tailwindcss/vite")).default;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { PluginOption, UserConfig, ConfigEnv, UserConfigFnObject, UserConfigFnPromise, UserConfigFn } from 'vite';
2
- import { HmrGateOptions } from '@lovable.dev/vite-plugin-hmr-gate';
3
2
 
4
3
  interface LovableViteTanstackOptions {
5
4
  plugins?: PluginOption[];
@@ -18,7 +17,7 @@ interface LovableViteTanstackOptions {
18
17
  * Enabled by default in sandbox mode. Set to false to disable, or pass options
19
18
  * to customise behaviour. Set to true or an options object to enable outside sandbox.
20
19
  */
21
- hmrGate?: boolean | HmrGateOptions;
20
+ hmrGate?: boolean | Record<string, unknown>;
22
21
  }
23
22
  declare function defineConfig(config: UserConfig): (env: ConfigEnv) => Promise<UserConfig>;
24
23
  declare function defineConfig(config: Promise<UserConfig>): (env: ConfigEnv) => Promise<UserConfig>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { PluginOption, UserConfig, ConfigEnv, UserConfigFnObject, UserConfigFnPromise, UserConfigFn } from 'vite';
2
- import { HmrGateOptions } from '@lovable.dev/vite-plugin-hmr-gate';
3
2
 
4
3
  interface LovableViteTanstackOptions {
5
4
  plugins?: PluginOption[];
@@ -18,7 +17,7 @@ interface LovableViteTanstackOptions {
18
17
  * Enabled by default in sandbox mode. Set to false to disable, or pass options
19
18
  * to customise behaviour. Set to true or an options object to enable outside sandbox.
20
19
  */
21
- hmrGate?: boolean | HmrGateOptions;
20
+ hmrGate?: boolean | Record<string, unknown>;
22
21
  }
23
22
  declare function defineConfig(config: UserConfig): (env: ConfigEnv) => Promise<UserConfig>;
24
23
  declare function defineConfig(config: Promise<UserConfig>): (env: ConfigEnv) => Promise<UserConfig>;
package/dist/index.js CHANGED
@@ -114,12 +114,39 @@ function devClientErrorLogger() {
114
114
  return [
115
115
  "if (typeof window !== 'undefined' && import.meta.hot) {",
116
116
  " const send = (d) => { try { import.meta.hot.send('client-runtime-error', d) } catch {} };",
117
+ " const stripTokenFromUrl = (url) => {",
118
+ " try {",
119
+ " const parsed = new URL(url);",
120
+ " parsed.searchParams.delete('__lovable_token');",
121
+ " return parsed.toString();",
122
+ " } catch {",
123
+ " return url;",
124
+ " }",
125
+ " };",
126
+ " const describeResponse = (res) => {",
127
+ " const sanitizedUrl = res.url ? stripTokenFromUrl(res.url) : '';",
128
+ " return `Server responded with ${res.status} ${res.statusText || '(no status text)'}${sanitizedUrl ? ` at ${sanitizedUrl}` : ''}`;",
129
+ " };",
117
130
  " window.addEventListener('error', (e) => {",
118
131
  " send({ type: 'runtime-error', message: e.message, stack: e.error?.stack, filename: e.filename, lineno: e.lineno, colno: e.colno });",
119
132
  " });",
120
133
  " window.addEventListener('unhandledrejection', (e) => {",
121
134
  " const err = e.reason;",
122
- " send({ type: 'unhandled-rejection', message: err?.message || String(err), stack: err?.stack });",
135
+ " if (err instanceof Response) {",
136
+ " const url = err.url ? stripTokenFromUrl(err.url) : undefined;",
137
+ " send({",
138
+ " type: 'unhandled-rejection',",
139
+ " name: 'Response',",
140
+ " message: describeResponse(err),",
141
+ " stack: url ? `Response ${err.status} at ${url}` : `Response ${err.status}`,",
142
+ " filename: url,",
143
+ " url,",
144
+ " status: err.status,",
145
+ " statusText: err.statusText || undefined,",
146
+ " });",
147
+ " return;",
148
+ " }",
149
+ " send({ type: 'unhandled-rejection', name: err?.name, message: err?.message || String(err), stack: err?.stack });",
123
150
  " });",
124
151
  "}"
125
152
  ].join("\n");
@@ -152,7 +179,17 @@ function devClientErrorLogger() {
152
179
  }
153
180
  };
154
181
  server.ws.on("client-runtime-error", (data) => {
155
- const { type, message, stack, filename, lineno, colno } = data;
182
+ const type = typeof data.type === "string" ? data.type : "runtime-error";
183
+ let message = "Unknown error";
184
+ if (typeof data.message === "string") {
185
+ message = data.message;
186
+ } else if (data.message != null) {
187
+ message = JSON.stringify(data.message);
188
+ }
189
+ const stack = typeof data.stack === "string" ? data.stack : void 0;
190
+ const filename = typeof data.filename === "string" ? data.filename : void 0;
191
+ const lineno = typeof data.lineno === "number" ? data.lineno : void 0;
192
+ const colno = typeof data.colno === "number" ? data.colno : void 0;
156
193
  const label = type === "unhandled-rejection" ? "Unhandled Rejection" : "Runtime Error";
157
194
  let loc = "";
158
195
  if (filename) {
@@ -241,8 +278,9 @@ function defineConfig(configOrOptions = {}) {
241
278
  } else if (configOrOptions instanceof Promise) {
242
279
  options = { vite: await configOrOptions };
243
280
  } else {
244
- const hasLovableKey = "vite" in configOrOptions || "clientErrorLogger" in configOrOptions || "serverFnErrorLogger" in configOrOptions || "cloudflare" in configOrOptions || "tanstackStart" in configOrOptions || "react" in configOrOptions || "envDefine" in configOrOptions || "hmrGate" in configOrOptions;
245
- options = hasLovableKey ? configOrOptions : { vite: configOrOptions };
281
+ const optionObject = configOrOptions && typeof configOrOptions === "object" ? configOrOptions : {};
282
+ const hasLovableKey = "vite" in optionObject || "clientErrorLogger" in optionObject || "serverFnErrorLogger" in optionObject || "cloudflare" in optionObject || "tanstackStart" in optionObject || "react" in optionObject || "envDefine" in optionObject || "hmrGate" in optionObject;
283
+ options = hasLovableKey ? optionObject : { vite: optionObject };
246
284
  }
247
285
  const internalPlugins = [];
248
286
  const tailwindcss = (await import("@tailwindcss/vite")).default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovable.dev/vite-tanstack-config",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Vite config wrapper for Lovable TanStack Start projects",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",