@alwaysmeticulous/backend-recorder-workerd 2.339.0 → 2.342.0
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/version.js +1 -1
- package/dist/vite/index.js +84 -3
- package/dist/vite/index.js.map +1 -1
- package/package.json +2 -1
package/dist/version.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Replaced by tsdown's `define`. The guard keeps a direct source import
|
|
9
9
|
* (vitest, typecheck) working, where no bundler has substituted the value.
|
|
10
10
|
*/
|
|
11
|
-
const WORKERD_SHIM_VERSION = "2.
|
|
11
|
+
const WORKERD_SHIM_VERSION = "2.342.0";
|
|
12
12
|
//#endregion
|
|
13
13
|
export { WORKERD_SHIM_VERSION };
|
|
14
14
|
|
package/dist/vite/index.js
CHANGED
|
@@ -6117,6 +6117,79 @@ var MagicString = class MagicString {
|
|
|
6117
6117
|
}
|
|
6118
6118
|
};
|
|
6119
6119
|
//#endregion
|
|
6120
|
+
//#region src/vite/annotations.ts
|
|
6121
|
+
/**
|
|
6122
|
+
* Keeps a build annotation attached to the node it was written for when the
|
|
6123
|
+
* instrumenter inserts code in front of that node.
|
|
6124
|
+
*
|
|
6125
|
+
* Bundlers read `/* @__PURE__ *\/` and its family off the comment immediately
|
|
6126
|
+
* preceding an expression. A marker inserted at the node's own start goes
|
|
6127
|
+
* *between* the two, leaving the annotation on the marker — a shape every
|
|
6128
|
+
* bundler reports as `INVALID_ANNOTATION` and then ignores, so a JSX-heavy
|
|
6129
|
+
* build both fills with warnings (esbuild's JSX transform annotates every
|
|
6130
|
+
* `jsx(...)` call, and the instrumenter runs after it) and silently loses the
|
|
6131
|
+
* hint. Opening the insertion before the annotation instead keeps it adjacent
|
|
6132
|
+
* to its own expression.
|
|
6133
|
+
*
|
|
6134
|
+
* Comment positions come from the parse rather than a backwards scan of the
|
|
6135
|
+
* text: `jsx("*\/", p)` puts a comment terminator inside a string literal, and
|
|
6136
|
+
* a scanner would read it as the end of a comment that never existed.
|
|
6137
|
+
*/
|
|
6138
|
+
/**
|
|
6139
|
+
* `@__PURE__`, `#__PURE__`, `@__NO_SIDE_EFFECTS__`, and whatever a bundler adds
|
|
6140
|
+
* next. Matching the family rather than a fixed list only risks moving an
|
|
6141
|
+
* insertion a few bytes earlier than it had to be, which is always valid.
|
|
6142
|
+
*/
|
|
6143
|
+
const ANNOTATION = /[@#]__[A-Z\d_]+__/;
|
|
6144
|
+
/** Whitespace between a comment and what it annotates. */
|
|
6145
|
+
const WHITESPACE = new Set([
|
|
6146
|
+
" ",
|
|
6147
|
+
" ",
|
|
6148
|
+
"\n",
|
|
6149
|
+
"\r",
|
|
6150
|
+
"\f",
|
|
6151
|
+
"\v"
|
|
6152
|
+
]);
|
|
6153
|
+
const createAnnotationIndex = (code) => {
|
|
6154
|
+
const commentsByEnd = /* @__PURE__ */ new Map();
|
|
6155
|
+
const annotationRunStart = (start, crossOpenParens) => {
|
|
6156
|
+
let index = start;
|
|
6157
|
+
let earliest = start;
|
|
6158
|
+
let sawAnnotation = false;
|
|
6159
|
+
for (;;) {
|
|
6160
|
+
index = skipBackwards(code, index, crossOpenParens);
|
|
6161
|
+
const comment = commentsByEnd.get(index);
|
|
6162
|
+
if (comment === void 0) break;
|
|
6163
|
+
sawAnnotation = sawAnnotation || comment.isAnnotation;
|
|
6164
|
+
index = comment.start;
|
|
6165
|
+
earliest = comment.start;
|
|
6166
|
+
}
|
|
6167
|
+
return sawAnnotation ? earliest : start;
|
|
6168
|
+
};
|
|
6169
|
+
return {
|
|
6170
|
+
record: (_isBlock, text, start, end) => {
|
|
6171
|
+
commentsByEnd.set(end, {
|
|
6172
|
+
start,
|
|
6173
|
+
isAnnotation: ANNOTATION.test(text)
|
|
6174
|
+
});
|
|
6175
|
+
},
|
|
6176
|
+
beforeStatement: (start) => annotationRunStart(start, false),
|
|
6177
|
+
beforeWrappedExpression: (start) => annotationRunStart(start, true)
|
|
6178
|
+
};
|
|
6179
|
+
};
|
|
6180
|
+
const skipBackwards = (code, index, crossOpenParens) => {
|
|
6181
|
+
let i = index;
|
|
6182
|
+
while (i > 0) {
|
|
6183
|
+
const char = code[i - 1];
|
|
6184
|
+
if (WHITESPACE.has(char) || crossOpenParens && char === "(") {
|
|
6185
|
+
i--;
|
|
6186
|
+
continue;
|
|
6187
|
+
}
|
|
6188
|
+
return i;
|
|
6189
|
+
}
|
|
6190
|
+
return i;
|
|
6191
|
+
};
|
|
6192
|
+
//#endregion
|
|
6120
6193
|
//#region src/vite/instrument.ts
|
|
6121
6194
|
/**
|
|
6122
6195
|
* Inserts per-line coverage markers into an ES module.
|
|
@@ -6184,6 +6257,7 @@ const SKIPPED_KEYS = new Set([
|
|
|
6184
6257
|
* worth breaking it for.
|
|
6185
6258
|
*/
|
|
6186
6259
|
const instrumentModule = ({ code, fileName, firstId, runtimeModuleId, resolveOriginalLine = (line) => line }) => {
|
|
6260
|
+
const annotations = createAnnotationIndex(code);
|
|
6187
6261
|
let program;
|
|
6188
6262
|
try {
|
|
6189
6263
|
program = parse(code, {
|
|
@@ -6192,7 +6266,8 @@ const instrumentModule = ({ code, fileName, firstId, runtimeModuleId, resolveOri
|
|
|
6192
6266
|
locations: true,
|
|
6193
6267
|
allowAwaitOutsideFunction: true,
|
|
6194
6268
|
allowReturnOutsideFunction: true,
|
|
6195
|
-
allowHashBang: true
|
|
6269
|
+
allowHashBang: true,
|
|
6270
|
+
onComment: annotations.record
|
|
6196
6271
|
});
|
|
6197
6272
|
} catch {
|
|
6198
6273
|
return null;
|
|
@@ -6213,7 +6288,13 @@ const instrumentModule = ({ code, fileName, firstId, runtimeModuleId, resolveOri
|
|
|
6213
6288
|
const markStatement = (node) => {
|
|
6214
6289
|
const id = nextId(node);
|
|
6215
6290
|
if (id === null) return;
|
|
6216
|
-
|
|
6291
|
+
const marker = `${SINK}&&(${SINK}[${id}]=1);`;
|
|
6292
|
+
const at = annotations.beforeStatement(node.start);
|
|
6293
|
+
if (at === node.start) {
|
|
6294
|
+
magic.appendLeft(at, marker);
|
|
6295
|
+
return;
|
|
6296
|
+
}
|
|
6297
|
+
magic.appendLeft(at, `;${marker}`);
|
|
6217
6298
|
};
|
|
6218
6299
|
const openFunctionBody = (body) => {
|
|
6219
6300
|
magic.appendLeft(body.start + 1, `const ${SINK}=typeof ${ENTER}==="function"?${ENTER}():undefined;`);
|
|
@@ -6221,7 +6302,7 @@ const instrumentModule = ({ code, fileName, firstId, runtimeModuleId, resolveOri
|
|
|
6221
6302
|
const markConciseArrowBody = (body) => {
|
|
6222
6303
|
const id = nextId(body);
|
|
6223
6304
|
if (id === null) return;
|
|
6224
|
-
magic.appendLeft(body.start, `(typeof ${HIT}==="function"&&${HIT}(${id}),`);
|
|
6305
|
+
magic.appendLeft(annotations.beforeWrappedExpression(body.start), `(typeof ${HIT}==="function"&&${HIT}(${id}),`);
|
|
6225
6306
|
magic.appendRight(body.end, ")");
|
|
6226
6307
|
};
|
|
6227
6308
|
visitProgram(program, {
|