trickle-observe 0.2.80 → 0.2.82
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/observe-register.js +15 -2
- package/dist/vite-plugin.d.ts +7 -0
- package/dist/vite-plugin.js +11 -1
- package/dist-esm/vite-plugin.js +11 -2
- package/package.json +1 -1
- package/src/observe-register.ts +11 -2
- package/src/vite-plugin.ts +7 -2
package/dist/observe-register.js
CHANGED
|
@@ -182,6 +182,18 @@ function findVarDeclarations(source, lineOffset = 0) {
|
|
|
182
182
|
continue;
|
|
183
183
|
if (varName === '_a' || varName === '_b' || varName === '_c')
|
|
184
184
|
continue; // TS compiled vars
|
|
185
|
+
// Skip TS compiler helpers and module internals
|
|
186
|
+
if (varName === '__createBinding' || varName === '__setModuleDefault' || varName === '__importStar' || varName === '__importDefault')
|
|
187
|
+
continue;
|
|
188
|
+
if (varName === '__decorate' || varName === '__metadata' || varName === '__param' || varName === '__awaiter')
|
|
189
|
+
continue;
|
|
190
|
+
if (varName === 'ownKeys' || varName === 'desc' || varName === '_')
|
|
191
|
+
continue;
|
|
192
|
+
// Skip React Refresh / HMR internals
|
|
193
|
+
if (varName === 'prevRefreshReg' || varName === 'prevRefreshSig' || varName === 'inWebWorker' || varName === 'invalidateMessage')
|
|
194
|
+
continue;
|
|
195
|
+
if (varName === '_s' || varName === '_c2' || varName === '_s2')
|
|
196
|
+
continue;
|
|
185
197
|
// Check if this is a require() call — skip those (they're imports, not interesting values)
|
|
186
198
|
const restOfLine = source.slice(vmatch.index + vmatch[0].length - 1, vmatch.index + vmatch[0].length + 200);
|
|
187
199
|
if (/^\s*require\s*\(/.test(restOfLine))
|
|
@@ -396,9 +408,10 @@ function transformCjsSource(source, filename, moduleName, env) {
|
|
|
396
408
|
// Skip common false positives
|
|
397
409
|
if (name === 'require' || name === 'exports' || name === 'module')
|
|
398
410
|
continue;
|
|
399
|
-
// Find the opening brace of the function body
|
|
411
|
+
// Find the opening brace of the function body, correctly skipping
|
|
412
|
+
// default parameter values like `headers = {}` which contain braces
|
|
400
413
|
const afterMatch = match.index + match[0].length;
|
|
401
|
-
const openBrace =
|
|
414
|
+
const openBrace = (0, vite_plugin_1.findFunctionBodyBrace)(source, afterMatch);
|
|
402
415
|
if (openBrace === -1)
|
|
403
416
|
continue;
|
|
404
417
|
// Extract parameter names from the source between ( and {
|
package/dist/vite-plugin.d.ts
CHANGED
|
@@ -40,6 +40,13 @@ export declare function tricklePlugin(options?: TricklePluginOptions): {
|
|
|
40
40
|
map: null;
|
|
41
41
|
} | null;
|
|
42
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Find the opening brace of a function body, skipping the parameter list.
|
|
45
|
+
* Starting from the character right after the opening `(` of the parameter list,
|
|
46
|
+
* scans forward matching parens to find the closing `)`, then finds the `{` after it.
|
|
47
|
+
* Returns -1 if not found.
|
|
48
|
+
*/
|
|
49
|
+
export declare function findFunctionBodyBrace(source: string, afterOpenParen: number): number;
|
|
43
50
|
/**
|
|
44
51
|
* Find variable reassignments (not declarations) and return insertions for tracing.
|
|
45
52
|
* Handles: x = newValue; x += 1; x ||= fallback; etc.
|
package/dist/vite-plugin.js
CHANGED
|
@@ -23,6 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.tricklePlugin = tricklePlugin;
|
|
26
|
+
exports.findFunctionBodyBrace = findFunctionBodyBrace;
|
|
26
27
|
exports.findReassignments = findReassignments;
|
|
27
28
|
exports.findCatchVars = findCatchVars;
|
|
28
29
|
exports.findForLoopVars = findForLoopVars;
|
|
@@ -262,9 +263,15 @@ function findVarDeclarations(source) {
|
|
|
262
263
|
// Skip trickle internals
|
|
263
264
|
if (varName.startsWith('__trickle'))
|
|
264
265
|
continue;
|
|
265
|
-
// Skip TS compiled vars
|
|
266
|
+
// Skip TS compiled vars and helpers
|
|
266
267
|
if (varName === '_a' || varName === '_b' || varName === '_c')
|
|
267
268
|
continue;
|
|
269
|
+
if (varName === '__createBinding' || varName === '__setModuleDefault' || varName === '__importStar' || varName === '__importDefault')
|
|
270
|
+
continue;
|
|
271
|
+
if (varName === '__decorate' || varName === '__metadata' || varName === '__param' || varName === '__awaiter')
|
|
272
|
+
continue;
|
|
273
|
+
if (varName === 'ownKeys' || varName === 'desc')
|
|
274
|
+
continue;
|
|
268
275
|
// Skip React Refresh / HMR internals (Vite, webpack, Next.js inject these)
|
|
269
276
|
if (varName === 'prevRefreshReg' || varName === 'prevRefreshSig' || varName === 'inWebWorker' || varName === 'invalidateMessage')
|
|
270
277
|
continue;
|
|
@@ -517,6 +524,9 @@ function findReassignments(source) {
|
|
|
517
524
|
// Skip 'this', 'self', 'super' (not reassignable in practice)
|
|
518
525
|
if (varName === 'this' || varName === 'super')
|
|
519
526
|
continue;
|
|
527
|
+
// Skip TS compiler helpers and module internals
|
|
528
|
+
if (varName === 'ownKeys' || varName === 'desc')
|
|
529
|
+
continue;
|
|
520
530
|
// Skip React Refresh / HMR internals and discard variables
|
|
521
531
|
if (varName === 'prevRefreshReg' || varName === 'prevRefreshSig' || varName === 'inWebWorker')
|
|
522
532
|
continue;
|
package/dist-esm/vite-plugin.js
CHANGED
|
@@ -114,7 +114,7 @@ export function tricklePlugin(options = {}) {
|
|
|
114
114
|
* scans forward matching parens to find the closing `)`, then finds the `{` after it.
|
|
115
115
|
* Returns -1 if not found.
|
|
116
116
|
*/
|
|
117
|
-
function findFunctionBodyBrace(source, afterOpenParen) {
|
|
117
|
+
export function findFunctionBodyBrace(source, afterOpenParen) {
|
|
118
118
|
let depth = 1;
|
|
119
119
|
let pos = afterOpenParen;
|
|
120
120
|
// Skip the parameter list (matching parens)
|
|
@@ -251,9 +251,15 @@ function findVarDeclarations(source) {
|
|
|
251
251
|
// Skip trickle internals
|
|
252
252
|
if (varName.startsWith('__trickle'))
|
|
253
253
|
continue;
|
|
254
|
-
// Skip TS compiled vars
|
|
254
|
+
// Skip TS compiled vars and helpers
|
|
255
255
|
if (varName === '_a' || varName === '_b' || varName === '_c')
|
|
256
256
|
continue;
|
|
257
|
+
if (varName === '__createBinding' || varName === '__setModuleDefault' || varName === '__importStar' || varName === '__importDefault')
|
|
258
|
+
continue;
|
|
259
|
+
if (varName === '__decorate' || varName === '__metadata' || varName === '__param' || varName === '__awaiter')
|
|
260
|
+
continue;
|
|
261
|
+
if (varName === 'ownKeys' || varName === 'desc')
|
|
262
|
+
continue;
|
|
257
263
|
// Skip React Refresh / HMR internals (Vite, webpack, Next.js inject these)
|
|
258
264
|
if (varName === 'prevRefreshReg' || varName === 'prevRefreshSig' || varName === 'inWebWorker' || varName === 'invalidateMessage')
|
|
259
265
|
continue;
|
|
@@ -506,6 +512,9 @@ export function findReassignments(source) {
|
|
|
506
512
|
// Skip 'this', 'self', 'super' (not reassignable in practice)
|
|
507
513
|
if (varName === 'this' || varName === 'super')
|
|
508
514
|
continue;
|
|
515
|
+
// Skip TS compiler helpers and module internals
|
|
516
|
+
if (varName === 'ownKeys' || varName === 'desc')
|
|
517
|
+
continue;
|
|
509
518
|
// Skip React Refresh / HMR internals and discard variables
|
|
510
519
|
if (varName === 'prevRefreshReg' || varName === 'prevRefreshSig' || varName === 'inWebWorker')
|
|
511
520
|
continue;
|
package/package.json
CHANGED
package/src/observe-register.ts
CHANGED
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
findReassignments,
|
|
41
41
|
findForLoopVars,
|
|
42
42
|
findCatchVars,
|
|
43
|
+
findFunctionBodyBrace,
|
|
43
44
|
} from './vite-plugin';
|
|
44
45
|
|
|
45
46
|
const M = Module as any;
|
|
@@ -173,6 +174,13 @@ function findVarDeclarations(source: string, lineOffset: number = 0): Array<{ li
|
|
|
173
174
|
if (varName === '__trickle_mod' || varName === '__trickle_wrap' || varName === '__trickle_tv') continue;
|
|
174
175
|
if (varName.startsWith('__trickle')) continue;
|
|
175
176
|
if (varName === '_a' || varName === '_b' || varName === '_c') continue; // TS compiled vars
|
|
177
|
+
// Skip TS compiler helpers and module internals
|
|
178
|
+
if (varName === '__createBinding' || varName === '__setModuleDefault' || varName === '__importStar' || varName === '__importDefault') continue;
|
|
179
|
+
if (varName === '__decorate' || varName === '__metadata' || varName === '__param' || varName === '__awaiter') continue;
|
|
180
|
+
if (varName === 'ownKeys' || varName === 'desc' || varName === '_') continue;
|
|
181
|
+
// Skip React Refresh / HMR internals
|
|
182
|
+
if (varName === 'prevRefreshReg' || varName === 'prevRefreshSig' || varName === 'inWebWorker' || varName === 'invalidateMessage') continue;
|
|
183
|
+
if (varName === '_s' || varName === '_c2' || varName === '_s2') continue;
|
|
176
184
|
|
|
177
185
|
// Check if this is a require() call — skip those (they're imports, not interesting values)
|
|
178
186
|
const restOfLine = source.slice(vmatch.index + vmatch[0].length - 1, vmatch.index + vmatch[0].length + 200);
|
|
@@ -370,9 +378,10 @@ function transformCjsSource(source: string, filename: string, moduleName: string
|
|
|
370
378
|
// Skip common false positives
|
|
371
379
|
if (name === 'require' || name === 'exports' || name === 'module') continue;
|
|
372
380
|
|
|
373
|
-
// Find the opening brace of the function body
|
|
381
|
+
// Find the opening brace of the function body, correctly skipping
|
|
382
|
+
// default parameter values like `headers = {}` which contain braces
|
|
374
383
|
const afterMatch = match.index + match[0].length;
|
|
375
|
-
const openBrace = source
|
|
384
|
+
const openBrace = findFunctionBodyBrace(source, afterMatch);
|
|
376
385
|
if (openBrace === -1) continue;
|
|
377
386
|
|
|
378
387
|
// Extract parameter names from the source between ( and {
|
package/src/vite-plugin.ts
CHANGED
|
@@ -134,7 +134,7 @@ export function tricklePlugin(options: TricklePluginOptions = {}) {
|
|
|
134
134
|
* scans forward matching parens to find the closing `)`, then finds the `{` after it.
|
|
135
135
|
* Returns -1 if not found.
|
|
136
136
|
*/
|
|
137
|
-
function findFunctionBodyBrace(source: string, afterOpenParen: number): number {
|
|
137
|
+
export function findFunctionBodyBrace(source: string, afterOpenParen: number): number {
|
|
138
138
|
let depth = 1;
|
|
139
139
|
let pos = afterOpenParen;
|
|
140
140
|
// Skip the parameter list (matching parens)
|
|
@@ -255,8 +255,11 @@ function findVarDeclarations(source: string): Array<{ lineEnd: number; varName:
|
|
|
255
255
|
|
|
256
256
|
// Skip trickle internals
|
|
257
257
|
if (varName.startsWith('__trickle')) continue;
|
|
258
|
-
// Skip TS compiled vars
|
|
258
|
+
// Skip TS compiled vars and helpers
|
|
259
259
|
if (varName === '_a' || varName === '_b' || varName === '_c') continue;
|
|
260
|
+
if (varName === '__createBinding' || varName === '__setModuleDefault' || varName === '__importStar' || varName === '__importDefault') continue;
|
|
261
|
+
if (varName === '__decorate' || varName === '__metadata' || varName === '__param' || varName === '__awaiter') continue;
|
|
262
|
+
if (varName === 'ownKeys' || varName === 'desc') continue;
|
|
260
263
|
// Skip React Refresh / HMR internals (Vite, webpack, Next.js inject these)
|
|
261
264
|
if (varName === 'prevRefreshReg' || varName === 'prevRefreshSig' || varName === 'inWebWorker' || varName === 'invalidateMessage') continue;
|
|
262
265
|
if (varName === '_s' || varName === '_c2' || varName === '_s2') continue;
|
|
@@ -491,6 +494,8 @@ export function findReassignments(source: string): Array<{ lineEnd: number; varN
|
|
|
491
494
|
if (varName === '_a' || varName === '_b' || varName === '_c') continue;
|
|
492
495
|
// Skip 'this', 'self', 'super' (not reassignable in practice)
|
|
493
496
|
if (varName === 'this' || varName === 'super') continue;
|
|
497
|
+
// Skip TS compiler helpers and module internals
|
|
498
|
+
if (varName === 'ownKeys' || varName === 'desc') continue;
|
|
494
499
|
// Skip React Refresh / HMR internals and discard variables
|
|
495
500
|
if (varName === 'prevRefreshReg' || varName === 'prevRefreshSig' || varName === 'inWebWorker') continue;
|
|
496
501
|
if (varName === '_s' || varName === '_c2' || varName === '_s2' || varName === '_') continue;
|