@timber-js/app 0.2.0-alpha.86 → 0.2.0-alpha.87

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.
@@ -70,6 +70,7 @@ export interface RscDebugComponentInfo {
70
70
  * Returns an empty string if no components are provided.
71
71
  */
72
72
  export declare function formatRscDebugContext(components: RscDebugComponentInfo[]): string;
73
+ export declare function calculateModuleRunnerOffset(): number;
73
74
  /**
74
75
  * Source-map an error's stack trace using the Vite dev server's module graph.
75
76
  *
@@ -1 +1 @@
1
- {"version":3,"file":"dev-error-overlay.d.ts","sourceRoot":"","sources":["../../src/plugins/dev-error-overlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,MAAM,CAAC;AAoC1D,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAClB,kBAAkB,GAClB,OAAO,GACP,YAAY,GACZ,QAAQ,GACR,QAAQ,GACR,SAAS,CAAC;AAEd,kCAAkC;AAClC,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAOnD,CAAC;AAIF,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,WAAW,GAAG,UAAU,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,CAU/E;AAID;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAUnE;AAID,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAqB5F;AAID;;;GAGG;AACH,wB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nB,kBAAkB,CAAC,EAAE,qBAAqB,EAAE,GAC3C,IAAI,CA0CN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timber-js/app",
3
- "version": "0.2.0-alpha.86",
3
+ "version": "0.2.0-alpha.87",
4
4
  "description": "Vite-native React framework built for Servers and Serverless Platforms — correct HTTP semantics, real status codes, pages that work without JavaScript",
5
5
  "keywords": [
6
6
  "cloudflare-workers",
@@ -110,6 +110,11 @@
110
110
  "publishConfig": {
111
111
  "access": "public"
112
112
  },
113
+ "scripts": {
114
+ "build": "vite build --config vite.lib.config.ts && tsc --emitDeclarationOnly --project tsconfig.json --outDir dist",
115
+ "typecheck": "tsgo --noEmit",
116
+ "prepublishOnly": "pnpm run build"
117
+ },
113
118
  "dependencies": {
114
119
  "@opentelemetry/api": "^1.9.1",
115
120
  "@opentelemetry/context-async-hooks": "^2.6.1",
@@ -152,9 +157,5 @@
152
157
  },
153
158
  "engines": {
154
159
  "node": ">=22.12.0"
155
- },
156
- "scripts": {
157
- "build": "vite build --config vite.lib.config.ts && tsc --emitDeclarationOnly --project tsconfig.json --outDir dist",
158
- "typecheck": "tsgo --noEmit"
159
160
  }
160
- }
161
+ }
package/src/cli.ts CHANGED
File without changes
@@ -234,6 +234,49 @@ export function formatRscDebugContext(components: RscDebugComponentInfo[]): stri
234
234
  return lines.join('\n');
235
235
  }
236
236
 
237
+ // ─── Module Runner Offset ───────────────────────────────────────────────────
238
+
239
+ /**
240
+ * Dynamically compute the line offset that Vite's module runner adds
241
+ * when wrapping modules in an async function.
242
+ *
243
+ * Vite's `calculateOffsetOnce()` uses the same technique: create a new
244
+ * AsyncFunction, throw from line 1, and check where the engine reports
245
+ * the error. The difference between the reported line and 1 is the offset.
246
+ *
247
+ * This is engine-dependent (currently 2 on Node 18-22) and could change
248
+ * in future Node.js or V8 versions. Computing it at runtime ensures we
249
+ * always match the actual behavior.
250
+ */
251
+ let _cachedOffset: number | null = null;
252
+
253
+ export function calculateModuleRunnerOffset(): number {
254
+ if (_cachedOffset !== null) return _cachedOffset;
255
+
256
+ try {
257
+ // Parse the AsyncFunction source to count wrapper lines before the body.
258
+ // AsyncFunction.toString() returns something like:
259
+ // "async function anonymous(\n) {\nBODY\n}"
260
+ // The number of newlines before BODY is the offset Vite's module runner adds.
261
+ // eslint-disable-next-line no-new-func -- intentional: mirrors Vite's technique
262
+ const AsyncFunction = async function () {}.constructor as typeof Function;
263
+ const wrapper = new AsyncFunction('BODY');
264
+ const src = wrapper.toString();
265
+ const bodyIndex = src.indexOf('BODY');
266
+ if (bodyIndex === -1) {
267
+ _cachedOffset = 2; // fallback
268
+ return _cachedOffset;
269
+ }
270
+ const beforeBody = src.slice(0, bodyIndex);
271
+ const newlineCount = (beforeBody.match(/\n/g) || []).length;
272
+ _cachedOffset = newlineCount;
273
+ } catch {
274
+ _cachedOffset = 2; // fallback to known-good value
275
+ }
276
+
277
+ return _cachedOffset;
278
+ }
279
+
237
280
  // ─── Stack Trace Source-Mapping ──────────────────────────────────────────────
238
281
 
239
282
  /**
@@ -310,9 +353,10 @@ function rewriteStacktrace(
310
353
  const rawSourceMap = mod?.transformResult?.map;
311
354
  if (!rawSourceMap) return input;
312
355
 
313
- // Vite's module runner adds a 2-line offset for the async wrapper.
314
- // This matches Vite's internal `calculateOffsetOnce()` behavior.
315
- const OFFSET = 2;
356
+ // Vite's module runner wraps each module in an async function,
357
+ // adding N lines before the module body. The offset is computed
358
+ // dynamically to match the actual engine behavior (see TIM-783).
359
+ const OFFSET = calculateModuleRunnerOffset();
316
360
  const origLine = Number(lineStr) - OFFSET;
317
361
  const origCol = Number(colStr) - 1;
318
362
  if (origLine <= 0 || origCol < 0) return input;
package/LICENSE DELETED
@@ -1,8 +0,0 @@
1
- DONTFUCKINGUSE LICENSE
2
-
3
- Copyright (c) 2025 Daniel Saewitz
4
-
5
- This software may not be used, copied, modified, merged, published,
6
- distributed, sublicensed, or sold by anyone other than the copyright holder.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.