trickle-observe 0.2.80 → 0.2.81
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
CHANGED
|
@@ -396,9 +396,10 @@ function transformCjsSource(source, filename, moduleName, env) {
|
|
|
396
396
|
// Skip common false positives
|
|
397
397
|
if (name === 'require' || name === 'exports' || name === 'module')
|
|
398
398
|
continue;
|
|
399
|
-
// Find the opening brace of the function body
|
|
399
|
+
// Find the opening brace of the function body, correctly skipping
|
|
400
|
+
// default parameter values like `headers = {}` which contain braces
|
|
400
401
|
const afterMatch = match.index + match[0].length;
|
|
401
|
-
const openBrace =
|
|
402
|
+
const openBrace = (0, vite_plugin_1.findFunctionBodyBrace)(source, afterMatch);
|
|
402
403
|
if (openBrace === -1)
|
|
403
404
|
continue;
|
|
404
405
|
// 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;
|
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)
|
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;
|
|
@@ -370,9 +371,10 @@ function transformCjsSource(source: string, filename: string, moduleName: string
|
|
|
370
371
|
// Skip common false positives
|
|
371
372
|
if (name === 'require' || name === 'exports' || name === 'module') continue;
|
|
372
373
|
|
|
373
|
-
// Find the opening brace of the function body
|
|
374
|
+
// Find the opening brace of the function body, correctly skipping
|
|
375
|
+
// default parameter values like `headers = {}` which contain braces
|
|
374
376
|
const afterMatch = match.index + match[0].length;
|
|
375
|
-
const openBrace = source
|
|
377
|
+
const openBrace = findFunctionBodyBrace(source, afterMatch);
|
|
376
378
|
if (openBrace === -1) continue;
|
|
377
379
|
|
|
378
380
|
// 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)
|