@qwik.dev/devtools 2.0.0-rc.0 → 2.0.0-rc.3
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/kit/index.d.mts
CHANGED
|
@@ -564,6 +564,7 @@ declare const QWIK_ATTR: {
|
|
|
564
564
|
readonly BASE: "q:base";
|
|
565
565
|
readonly CONTAINER: "q:container";
|
|
566
566
|
readonly ID: "q:id";
|
|
567
|
+
readonly INSPECTOR: "data-qwik-inspector";
|
|
567
568
|
readonly KEY: "q:key";
|
|
568
569
|
readonly MANIFEST_HASH: "q:manifest-hash";
|
|
569
570
|
readonly RENDER: "q:render";
|
package/dist/kit/index.mjs
CHANGED
|
@@ -172,7 +172,8 @@ function createSerializedRpc(functions, channel) {
|
|
|
172
172
|
return createBirpc(functions, {
|
|
173
173
|
post: (data) => channel.post(SuperJSON.stringify(data)),
|
|
174
174
|
on: (handler) => channel.on((data) => handler(parseRpcPayload(data))),
|
|
175
|
-
timeout: RPC_TIMEOUT
|
|
175
|
+
timeout: RPC_TIMEOUT,
|
|
176
|
+
resolver: channel.resolver
|
|
176
177
|
});
|
|
177
178
|
}
|
|
178
179
|
//#endregion
|
|
@@ -263,11 +264,18 @@ function runWithServerRpcRequestContext(context, fn) {
|
|
|
263
264
|
const previous = currentServerRpcRequestContext;
|
|
264
265
|
currentServerRpcRequestContext = context;
|
|
265
266
|
try {
|
|
266
|
-
fn();
|
|
267
|
+
return fn();
|
|
267
268
|
} finally {
|
|
268
269
|
currentServerRpcRequestContext = previous;
|
|
269
270
|
}
|
|
270
271
|
}
|
|
272
|
+
function bindServerRpcRequestContext(_method, fn) {
|
|
273
|
+
const context = currentServerRpcRequestContext;
|
|
274
|
+
if (!context || !fn) return fn;
|
|
275
|
+
return function(...args) {
|
|
276
|
+
return runWithServerRpcRequestContext(context, () => fn.apply(this, args));
|
|
277
|
+
};
|
|
278
|
+
}
|
|
271
279
|
function createServerRpc(functions) {
|
|
272
280
|
const server = getViteServerContext();
|
|
273
281
|
setViteServerRpc(createSerializedRpc(functions, {
|
|
@@ -276,7 +284,8 @@ function createServerRpc(functions) {
|
|
|
276
284
|
runWithServerRpcRequestContext({ client }, () => {
|
|
277
285
|
handler(data);
|
|
278
286
|
});
|
|
279
|
-
})
|
|
287
|
+
}),
|
|
288
|
+
resolver: bindServerRpcRequestContext
|
|
280
289
|
}));
|
|
281
290
|
}
|
|
282
291
|
//#endregion
|
|
@@ -310,6 +319,7 @@ const QWIK_ATTR = {
|
|
|
310
319
|
BASE: "q:base",
|
|
311
320
|
CONTAINER: "q:container",
|
|
312
321
|
ID: "q:id",
|
|
322
|
+
INSPECTOR: "data-qwik-inspector",
|
|
313
323
|
KEY: "q:key",
|
|
314
324
|
MANIFEST_HASH: "q:manifest-hash",
|
|
315
325
|
RENDER: "q:render",
|
package/dist/plugin/index.mjs
CHANGED
|
@@ -49,6 +49,13 @@ function toPnpmSelectorPath(workspaceRoot, projectRoot) {
|
|
|
49
49
|
if (!relativePath || relativePath === ".") return null;
|
|
50
50
|
return `./${relativePath}`;
|
|
51
51
|
}
|
|
52
|
+
function pnpmFilterArgs(selector) {
|
|
53
|
+
return [
|
|
54
|
+
"--filter",
|
|
55
|
+
selector,
|
|
56
|
+
"--fail-if-no-match"
|
|
57
|
+
];
|
|
58
|
+
}
|
|
52
59
|
function isValidPackageName(packageName) {
|
|
53
60
|
if (!packageName || packageName.length > 214) return false;
|
|
54
61
|
return /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/.test(packageName);
|
|
@@ -109,8 +116,7 @@ function buildInstallCommand(context, packageName, dependencyType) {
|
|
|
109
116
|
return {
|
|
110
117
|
command: "pnpm",
|
|
111
118
|
args: context.workspacePackageSelector ? [
|
|
112
|
-
|
|
113
|
-
context.workspacePackageSelector,
|
|
119
|
+
...pnpmFilterArgs(context.workspacePackageSelector),
|
|
114
120
|
"add",
|
|
115
121
|
"--ignore-scripts",
|
|
116
122
|
...saveArgs,
|
|
@@ -192,8 +198,7 @@ function buildUpdateCommand(context, packageName, dependencyType) {
|
|
|
192
198
|
return {
|
|
193
199
|
command: "pnpm",
|
|
194
200
|
args: context.workspacePackageSelector ? [
|
|
195
|
-
|
|
196
|
-
context.workspacePackageSelector,
|
|
201
|
+
...pnpmFilterArgs(context.workspacePackageSelector),
|
|
197
202
|
"add",
|
|
198
203
|
"--ignore-scripts",
|
|
199
204
|
...saveArgs,
|
|
@@ -434,6 +439,64 @@ async function verifyDependencySync(input) {
|
|
|
434
439
|
};
|
|
435
440
|
}
|
|
436
441
|
//#endregion
|
|
442
|
+
//#region src/rpc/security.ts
|
|
443
|
+
const REMOTE_BUILD_ANALYSIS_ENV = "QWIK_DEVTOOLS_ALLOW_REMOTE_BUILD_ANALYSIS";
|
|
444
|
+
const REMOTE_PACKAGE_MANAGEMENT_ENV = "QWIK_DEVTOOLS_ALLOW_REMOTE_PACKAGE_MANAGEMENT";
|
|
445
|
+
const TRUTHY_ENV_VALUES = /* @__PURE__ */ new Set([
|
|
446
|
+
"1",
|
|
447
|
+
"true",
|
|
448
|
+
"yes",
|
|
449
|
+
"on"
|
|
450
|
+
]);
|
|
451
|
+
function isEnvFlagEnabled(name, env) {
|
|
452
|
+
const rawValue = env[name];
|
|
453
|
+
if (!rawValue) return false;
|
|
454
|
+
return TRUTHY_ENV_VALUES.has(rawValue.trim().toLowerCase());
|
|
455
|
+
}
|
|
456
|
+
function getRpcClientRemoteAddress(client) {
|
|
457
|
+
if (!client || typeof client !== "object") return;
|
|
458
|
+
const candidate = client;
|
|
459
|
+
return getSocketRemoteAddress(candidate.socket) ?? getSocketRemoteAddress(candidate._socket);
|
|
460
|
+
}
|
|
461
|
+
function getSocketRemoteAddress(socket) {
|
|
462
|
+
if (!socket || typeof socket !== "object") return;
|
|
463
|
+
const queue = [socket];
|
|
464
|
+
const seen = /* @__PURE__ */ new Set();
|
|
465
|
+
while (queue.length > 0) {
|
|
466
|
+
const current = queue.shift();
|
|
467
|
+
if (!current || seen.has(current)) continue;
|
|
468
|
+
seen.add(current);
|
|
469
|
+
if (typeof current.remoteAddress === "string" && current.remoteAddress.length > 0) return current.remoteAddress;
|
|
470
|
+
if (current.socket && typeof current.socket === "object") queue.push(current.socket);
|
|
471
|
+
if (current._socket && typeof current._socket === "object") queue.push(current._socket);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
function isLoopbackAddress(address) {
|
|
475
|
+
if (!address) return false;
|
|
476
|
+
if (address === "127.0.0.1" || address === "::1") return true;
|
|
477
|
+
if (address.startsWith("::ffff:")) return isLoopbackAddress(address.slice(7));
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
function isRpcClientAllowed(client, remoteOptInEnv, env) {
|
|
481
|
+
if (isEnvFlagEnabled(remoteOptInEnv, env)) return true;
|
|
482
|
+
return isLoopbackAddress(getRpcClientRemoteAddress(client));
|
|
483
|
+
}
|
|
484
|
+
function isBuildAnalysisRpcAllowed(client, env = process.env) {
|
|
485
|
+
return isRpcClientAllowed(client, REMOTE_BUILD_ANALYSIS_ENV, env);
|
|
486
|
+
}
|
|
487
|
+
function isPackageManagementRpcAllowed(client, env = process.env) {
|
|
488
|
+
return isRpcClientAllowed(client, REMOTE_PACKAGE_MANAGEMENT_ENV, env);
|
|
489
|
+
}
|
|
490
|
+
function getPackageManagementRpcGuardError() {
|
|
491
|
+
return `Refusing to change project dependencies from a non-local DevTools RPC client. Reconnect from localhost or set ${REMOTE_PACKAGE_MANAGEMENT_ENV}=1 to opt in to remote package management.`;
|
|
492
|
+
}
|
|
493
|
+
function getBuildAnalysisRpcGuardError() {
|
|
494
|
+
return `Refusing to run the project build from a non-local DevTools RPC client. Reconnect from localhost or set ${REMOTE_BUILD_ANALYSIS_ENV}=1 to opt in to remote build-analysis execution.`;
|
|
495
|
+
}
|
|
496
|
+
function getBuildAnalysisRpcGuardHint() {
|
|
497
|
+
return `Automatic rebuild is unavailable from this DevTools client. Reconnect from localhost or set ${REMOTE_BUILD_ANALYSIS_ENV}=1 to opt in to remote build-analysis execution.`;
|
|
498
|
+
}
|
|
499
|
+
//#endregion
|
|
437
500
|
//#region src/npm/index.ts
|
|
438
501
|
const log$3 = createDebug("qwik:devtools:npm");
|
|
439
502
|
let preloadedDependencies = null;
|
|
@@ -600,6 +663,15 @@ async function startPreloading({ config }) {
|
|
|
600
663
|
});
|
|
601
664
|
return Promise.resolve();
|
|
602
665
|
}
|
|
666
|
+
function refuseNonLocalClient(action, packageName) {
|
|
667
|
+
if (isPackageManagementRpcAllowed(getServerRpcRequestContext()?.client)) return;
|
|
668
|
+
return {
|
|
669
|
+
success: false,
|
|
670
|
+
action,
|
|
671
|
+
packageName,
|
|
672
|
+
error: getPackageManagementRpcGuardError()
|
|
673
|
+
};
|
|
674
|
+
}
|
|
603
675
|
function getNpmFunctions({ config }) {
|
|
604
676
|
const refreshDependencyCache = async () => {
|
|
605
677
|
preloadedDependencies = null;
|
|
@@ -658,6 +730,8 @@ function getNpmFunctions({ config }) {
|
|
|
658
730
|
}
|
|
659
731
|
},
|
|
660
732
|
async installPackage(packageName, dependencyType = "devDependencies") {
|
|
733
|
+
const refusal = refuseNonLocalClient("install", packageName);
|
|
734
|
+
if (refusal) return refusal;
|
|
661
735
|
try {
|
|
662
736
|
if (!isValidPackageName(packageName)) return {
|
|
663
737
|
success: false,
|
|
@@ -682,6 +756,8 @@ function getNpmFunctions({ config }) {
|
|
|
682
756
|
}
|
|
683
757
|
},
|
|
684
758
|
async updatePackage(packageName) {
|
|
759
|
+
const refusal = refuseNonLocalClient("update", packageName);
|
|
760
|
+
if (refusal) return refusal;
|
|
685
761
|
try {
|
|
686
762
|
if (!isValidPackageName(packageName)) return {
|
|
687
763
|
success: false,
|
|
@@ -735,54 +811,6 @@ function getNpmFunctions({ config }) {
|
|
|
735
811
|
};
|
|
736
812
|
}
|
|
737
813
|
//#endregion
|
|
738
|
-
//#region src/build-analysis/security.ts
|
|
739
|
-
const REMOTE_BUILD_ANALYSIS_ENV = "QWIK_DEVTOOLS_ALLOW_REMOTE_BUILD_ANALYSIS";
|
|
740
|
-
const TRUTHY_ENV_VALUES = /* @__PURE__ */ new Set([
|
|
741
|
-
"1",
|
|
742
|
-
"true",
|
|
743
|
-
"yes",
|
|
744
|
-
"on"
|
|
745
|
-
]);
|
|
746
|
-
function isRemoteBuildAnalysisEnabled(env = process.env) {
|
|
747
|
-
const rawValue = env[REMOTE_BUILD_ANALYSIS_ENV];
|
|
748
|
-
if (!rawValue) return false;
|
|
749
|
-
return TRUTHY_ENV_VALUES.has(rawValue.trim().toLowerCase());
|
|
750
|
-
}
|
|
751
|
-
function getRpcClientRemoteAddress(client) {
|
|
752
|
-
if (!client || typeof client !== "object") return;
|
|
753
|
-
const candidate = client;
|
|
754
|
-
return getSocketRemoteAddress(candidate.socket) ?? getSocketRemoteAddress(candidate._socket);
|
|
755
|
-
}
|
|
756
|
-
function getSocketRemoteAddress(socket) {
|
|
757
|
-
if (!socket || typeof socket !== "object") return;
|
|
758
|
-
const queue = [socket];
|
|
759
|
-
const seen = /* @__PURE__ */ new Set();
|
|
760
|
-
while (queue.length > 0) {
|
|
761
|
-
const current = queue.shift();
|
|
762
|
-
if (!current || seen.has(current)) continue;
|
|
763
|
-
seen.add(current);
|
|
764
|
-
if (typeof current.remoteAddress === "string" && current.remoteAddress.length > 0) return current.remoteAddress;
|
|
765
|
-
if (current.socket && typeof current.socket === "object") queue.push(current.socket);
|
|
766
|
-
if (current._socket && typeof current._socket === "object") queue.push(current._socket);
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
function isLoopbackAddress(address) {
|
|
770
|
-
if (!address) return false;
|
|
771
|
-
if (address === "127.0.0.1" || address === "::1") return true;
|
|
772
|
-
if (address.startsWith("::ffff:")) return isLoopbackAddress(address.slice(7));
|
|
773
|
-
return false;
|
|
774
|
-
}
|
|
775
|
-
function isBuildAnalysisRpcAllowed(client, env = process.env) {
|
|
776
|
-
if (isRemoteBuildAnalysisEnabled(env)) return true;
|
|
777
|
-
return isLoopbackAddress(getRpcClientRemoteAddress(client));
|
|
778
|
-
}
|
|
779
|
-
function getBuildAnalysisRpcGuardError() {
|
|
780
|
-
return `Refusing to run the project build from a non-local DevTools RPC client. Reconnect from localhost or set ${REMOTE_BUILD_ANALYSIS_ENV}=1 to opt in to remote build-analysis execution.`;
|
|
781
|
-
}
|
|
782
|
-
function getBuildAnalysisRpcGuardHint() {
|
|
783
|
-
return `Automatic rebuild is unavailable from this DevTools client. Reconnect from localhost or set ${REMOTE_BUILD_ANALYSIS_ENV}=1 to opt in to remote build-analysis execution.`;
|
|
784
|
-
}
|
|
785
|
-
//#endregion
|
|
786
814
|
//#region src/build-analysis/index.ts
|
|
787
815
|
const BUILD_ANALYSIS_VIEW_PATH = "/__qwik_devtools/build-analysis/report";
|
|
788
816
|
const BUILD_ANALYSIS_DIR = path.join(".qwik-devtools", "build-analysis");
|
|
@@ -980,10 +1008,9 @@ async function runBuildScript(rootDir) {
|
|
|
980
1008
|
function getBuildAnalysisFunctions(ctx) {
|
|
981
1009
|
return {
|
|
982
1010
|
async getBuildAnalysisStatus() {
|
|
1011
|
+
const canTriggerBuild = isBuildAnalysisRpcAllowed(getServerRpcRequestContext()?.client);
|
|
983
1012
|
const reportPath = resolveBuildAnalysisHtmlPath(ctx.config.root);
|
|
984
1013
|
const { command } = await resolveBuildScript(ctx.config.root);
|
|
985
|
-
const rpcClient = getServerRpcRequestContext()?.client;
|
|
986
|
-
const canTriggerBuild = isBuildAnalysisRpcAllowed(rpcClient);
|
|
987
1014
|
return {
|
|
988
1015
|
exists: await fileExists(reportPath),
|
|
989
1016
|
reportPath,
|
|
@@ -1148,39 +1175,13 @@ function isKnownHook(name) {
|
|
|
1148
1175
|
function isCustomHook(hookName) {
|
|
1149
1176
|
return !USE_HOOK_LIST.some((item) => item.startsWith(hookName)) && /^use[A-Z_]/.test(hookName);
|
|
1150
1177
|
}
|
|
1151
|
-
/** Finds the start position of the line containing the given index */
|
|
1152
|
-
function findLineStart$1(code, index) {
|
|
1153
|
-
for (let i = index - 1; i >= 0; i--) {
|
|
1154
|
-
const ch = code[i];
|
|
1155
|
-
if (ch === "\n" || ch === "\r") return i + 1;
|
|
1156
|
-
}
|
|
1157
|
-
return 0;
|
|
1158
|
-
}
|
|
1159
|
-
/** Reads the indentation (spaces/tabs) starting from a given position */
|
|
1160
|
-
function readIndent(code, indexFrom) {
|
|
1161
|
-
let indent = "";
|
|
1162
|
-
let i = indexFrom;
|
|
1163
|
-
while (i < code.length) {
|
|
1164
|
-
const ch = code[i];
|
|
1165
|
-
if (ch === " " || ch === " ") {
|
|
1166
|
-
indent += ch;
|
|
1167
|
-
i++;
|
|
1168
|
-
} else break;
|
|
1169
|
-
}
|
|
1170
|
-
return indent;
|
|
1171
|
-
}
|
|
1172
1178
|
/** Removes trailing semicolon and whitespace from a code segment */
|
|
1173
1179
|
function trimStatementSemicolon(segment) {
|
|
1174
1180
|
return segment.trim().replace(/;?\s*$/, "");
|
|
1175
1181
|
}
|
|
1176
|
-
/** Builds
|
|
1177
|
-
function buildCollecthookPayload(
|
|
1178
|
-
return
|
|
1179
|
-
${indent} variableName: '${variableName}',
|
|
1180
|
-
${indent} hookType: '${hookType}',
|
|
1181
|
-
${indent} category: '${category}',
|
|
1182
|
-
${indent} data: ${hookExpression === "undefined" ? "undefined" : hookExpression}
|
|
1183
|
-
${indent}});\n`;
|
|
1182
|
+
/** Builds a single-line collecthook() call so injected tracking never adds source lines */
|
|
1183
|
+
function buildCollecthookPayload(variableName, hookType, category, hookExpression) {
|
|
1184
|
+
return `collecthook({ variableName: '${variableName}', hookType: '${hookType}', category: '${category}', data: ${hookExpression} });`;
|
|
1184
1185
|
}
|
|
1185
1186
|
/** Checks if a collecthook call already exists after the given position (by variable ID) */
|
|
1186
1187
|
function hasCollecthookAfterByVariableId(code, fromIndex, variableId, maxLookahead = 600) {
|
|
@@ -1331,31 +1332,16 @@ function injectInitHooks(code, bodies, options) {
|
|
|
1331
1332
|
function createInitTask(code, body, options) {
|
|
1332
1333
|
const { insertPos, exportName } = body;
|
|
1333
1334
|
if (hasExistingCollecthook(code, insertPos)) return null;
|
|
1334
|
-
const { insertIndex, prefixNewline } = calculateInsertPosition(code, insertPos);
|
|
1335
1335
|
return {
|
|
1336
1336
|
kind: "insert",
|
|
1337
|
-
pos:
|
|
1338
|
-
text:
|
|
1337
|
+
pos: insertPos,
|
|
1338
|
+
text: ` const collecthook = ${INNER_USE_HOOK}(${buildComponentArg(options?.path, exportName)});`
|
|
1339
1339
|
};
|
|
1340
1340
|
}
|
|
1341
1341
|
function hasExistingCollecthook(code, insertPos) {
|
|
1342
1342
|
const lookahead = code.slice(insertPos, insertPos + 200);
|
|
1343
1343
|
return /const\s+collecthook\s*=\s*useCollectHooks\s*\(/.test(lookahead);
|
|
1344
1344
|
}
|
|
1345
|
-
function calculateInsertPosition(code, insertPos) {
|
|
1346
|
-
if (code[insertPos] === "\r" && code[insertPos + 1] === "\n") return {
|
|
1347
|
-
insertIndex: insertPos + 2,
|
|
1348
|
-
prefixNewline: ""
|
|
1349
|
-
};
|
|
1350
|
-
if (code[insertPos] === "\n") return {
|
|
1351
|
-
insertIndex: insertPos + 1,
|
|
1352
|
-
prefixNewline: ""
|
|
1353
|
-
};
|
|
1354
|
-
return {
|
|
1355
|
-
insertIndex: insertPos,
|
|
1356
|
-
prefixNewline: "\n"
|
|
1357
|
-
};
|
|
1358
|
-
}
|
|
1359
1345
|
/** Builds the component argument string for collecthook initialization */
|
|
1360
1346
|
function buildComponentArg(path, exportName) {
|
|
1361
1347
|
const baseArg = String(path ?? "").split("?")[0].split("#")[0];
|
|
@@ -1408,22 +1394,14 @@ function processVariableDeclarator(code, node, path) {
|
|
|
1408
1394
|
if (hookName === INNER_USE_HOOK) return null;
|
|
1409
1395
|
const range = getParentRange(path.parent);
|
|
1410
1396
|
if (!range) return null;
|
|
1411
|
-
const
|
|
1397
|
+
const [, declEnd] = range;
|
|
1412
1398
|
if (isCustomHook(normalizedName)) {
|
|
1413
1399
|
if (hasCollecthookAfterByVariableId(code, declEnd, variableId)) return null;
|
|
1414
|
-
return
|
|
1415
|
-
kind: "insert",
|
|
1416
|
-
pos: declEnd,
|
|
1417
|
-
text: "\n" + buildCollecthookPayload(indent, variableId, "customhook", "VariableDeclarator", variableId)
|
|
1418
|
-
};
|
|
1400
|
+
return insertAfterStatement(code, declEnd, buildCollecthookPayload(variableId, "customhook", "VariableDeclarator", variableId));
|
|
1419
1401
|
}
|
|
1420
1402
|
if (!isKnownHook(normalizedName)) return null;
|
|
1421
1403
|
if (hasCollecthookAfterByVariableId(code, declEnd, variableId)) return null;
|
|
1422
|
-
return
|
|
1423
|
-
kind: "insert",
|
|
1424
|
-
pos: declEnd,
|
|
1425
|
-
text: "\n" + buildCollecthookPayload(indent, variableId, normalizedName, "VariableDeclarator", variableId)
|
|
1426
|
-
};
|
|
1404
|
+
return insertAfterStatement(code, declEnd, buildCollecthookPayload(variableId, normalizedName, "VariableDeclarator", variableId));
|
|
1427
1405
|
}
|
|
1428
1406
|
/** Processes: useTask$(() => {}), useCustomHook() */
|
|
1429
1407
|
function processExpressionStatement(code, node, currentIndex) {
|
|
@@ -1434,31 +1412,27 @@ function processExpressionStatement(code, node, currentIndex) {
|
|
|
1434
1412
|
const stmtRange = node.range;
|
|
1435
1413
|
if (!stmtRange) return null;
|
|
1436
1414
|
const [stmtStart, stmtEnd] = stmtRange;
|
|
1437
|
-
const indent = readIndent(code, findLineStart$1(code, stmtStart));
|
|
1438
1415
|
if (isKnownHook(normalizedName)) {
|
|
1439
1416
|
if (hasCollecthookAfterByVariableName(code, stmtEnd, normalizedName)) return null;
|
|
1440
1417
|
return {
|
|
1441
|
-
task:
|
|
1442
|
-
kind: "insert",
|
|
1443
|
-
pos: stmtEnd,
|
|
1444
|
-
text: "\n" + buildCollecthookPayload(indent, normalizedName, normalizedName, "expressionStatement", "undefined")
|
|
1445
|
-
},
|
|
1418
|
+
task: insertAfterStatement(code, stmtEnd, buildCollecthookPayload(normalizedName, normalizedName, "expressionStatement", "undefined")),
|
|
1446
1419
|
newIndex: currentIndex
|
|
1447
1420
|
};
|
|
1448
1421
|
}
|
|
1449
|
-
if (isCustomHook(normalizedName)) return convertToVariableDeclaration(code, stmtStart, stmtEnd,
|
|
1422
|
+
if (isCustomHook(normalizedName)) return convertToVariableDeclaration(code, stmtStart, stmtEnd, currentIndex);
|
|
1450
1423
|
return null;
|
|
1451
1424
|
}
|
|
1452
1425
|
/** Converts a custom hook expression to a variable declaration with tracking */
|
|
1453
|
-
function convertToVariableDeclaration(code, stmtStart, stmtEnd,
|
|
1426
|
+
function convertToVariableDeclaration(code, stmtStart, stmtEnd, currentIndex) {
|
|
1454
1427
|
const callSource = code.slice(stmtStart, stmtEnd);
|
|
1455
1428
|
const variableName = `_customhook_${currentIndex}`;
|
|
1429
|
+
const payload = buildCollecthookPayload(variableName, "customhook", "VariableDeclarator", variableName);
|
|
1456
1430
|
return {
|
|
1457
1431
|
task: {
|
|
1458
1432
|
kind: "replace",
|
|
1459
1433
|
start: stmtStart,
|
|
1460
1434
|
end: stmtEnd,
|
|
1461
|
-
text:
|
|
1435
|
+
text: `let ${variableName} = ${trimStatementSemicolon(callSource)}; ${payload}`
|
|
1462
1436
|
},
|
|
1463
1437
|
newIndex: currentIndex + 1
|
|
1464
1438
|
};
|
|
@@ -1486,19 +1460,19 @@ function extractHookCall(node) {
|
|
|
1486
1460
|
normalizedName: normalizeQrlHookName(hookName)
|
|
1487
1461
|
};
|
|
1488
1462
|
}
|
|
1463
|
+
/** Inserts on the statement's own line, adding the `;` it may lack because of ASI */
|
|
1464
|
+
function insertAfterStatement(code, statementEnd, statement) {
|
|
1465
|
+
return {
|
|
1466
|
+
kind: "insert",
|
|
1467
|
+
pos: statementEnd,
|
|
1468
|
+
text: (code[statementEnd - 1] === ";" ? " " : "; ") + statement
|
|
1469
|
+
};
|
|
1470
|
+
}
|
|
1489
1471
|
function getParentRange(parent) {
|
|
1490
1472
|
const range = parent?.range;
|
|
1491
1473
|
if (!range) return null;
|
|
1492
1474
|
return [range[0], range[1]];
|
|
1493
1475
|
}
|
|
1494
|
-
function getPositionInfo(code, range) {
|
|
1495
|
-
const [declStart, declEnd] = range;
|
|
1496
|
-
return {
|
|
1497
|
-
declStart,
|
|
1498
|
-
declEnd,
|
|
1499
|
-
indent: readIndent(code, findLineStart$1(code, declStart))
|
|
1500
|
-
};
|
|
1501
|
-
}
|
|
1502
1476
|
//#endregion
|
|
1503
1477
|
//#region src/parse/parse.ts
|
|
1504
1478
|
/** Qwik Code Parser Transforms Qwik component code by injecting devtools hooks */
|
|
@@ -1842,9 +1816,13 @@ function assertUniqueVirtualModuleIds(modules) {
|
|
|
1842
1816
|
}
|
|
1843
1817
|
//#endregion
|
|
1844
1818
|
//#region src/transforms/source-utils.ts
|
|
1819
|
+
/** Prepends on line 1 so the optimizer still sees every source line where it was */
|
|
1820
|
+
function prependImportIfMissing(code, importStatement) {
|
|
1821
|
+
return code.includes(importStatement) ? code : `${importStatement}${code}`;
|
|
1822
|
+
}
|
|
1845
1823
|
function injectNamedImportIfMissing(code, key, name) {
|
|
1846
1824
|
if (code.includes(key)) return code;
|
|
1847
|
-
return `import { ${name} } from '${key}'
|
|
1825
|
+
return prependImportIfMissing(code, `import { ${name} } from '${key}';`);
|
|
1848
1826
|
}
|
|
1849
1827
|
//#endregion
|
|
1850
1828
|
//#region src/transforms/component-transform.ts
|
|
@@ -1869,47 +1847,30 @@ const DEVTOOLS_IMPORT = `import { QwikDevtools } from '@qwik.dev/devtools/ui';`;
|
|
|
1869
1847
|
const STYLES_IMPORT = `import '@qwik.dev/devtools/ui/styles.css';`;
|
|
1870
1848
|
function transformRootFile(code, opts = {}) {
|
|
1871
1849
|
const excludePathnames = normalizeExcludePathnames(opts.overlay?.excludePathnames);
|
|
1872
|
-
const
|
|
1873
|
-
if (
|
|
1850
|
+
const bodyClosingStart = findBodyClosingStart(code);
|
|
1851
|
+
if (bodyClosingStart !== null) {
|
|
1874
1852
|
const devtoolsElement = excludePathnames.length > 0 ? `<QwikDevtools excludePathnames={${JSON.stringify(excludePathnames)}} />` : "<QwikDevtools />";
|
|
1875
1853
|
code = applySourceEdits(code, [{
|
|
1876
1854
|
kind: "insert",
|
|
1877
|
-
pos:
|
|
1878
|
-
text:
|
|
1855
|
+
pos: bodyClosingStart,
|
|
1856
|
+
text: devtoolsElement
|
|
1879
1857
|
}]);
|
|
1880
1858
|
}
|
|
1881
|
-
|
|
1882
|
-
if (!code.includes(STYLES_IMPORT)) code = `${STYLES_IMPORT}\n${code}`;
|
|
1883
|
-
return code;
|
|
1859
|
+
return prependImportIfMissing(prependImportIfMissing(code, DEVTOOLS_IMPORT), STYLES_IMPORT);
|
|
1884
1860
|
}
|
|
1885
|
-
function
|
|
1886
|
-
|
|
1861
|
+
function findBodyClosingStart(code) {
|
|
1862
|
+
let closingStart = null;
|
|
1887
1863
|
try {
|
|
1888
1864
|
traverseProgram(parseProgram(code), { JSXElement(path) {
|
|
1889
1865
|
const node = path.node;
|
|
1890
1866
|
if (getJsxName(node.openingElement?.name) !== "body" || !node.closingElement) return;
|
|
1891
|
-
|
|
1892
|
-
const lineStart = findLineStart(code, closingStart);
|
|
1893
|
-
const closingIndent = readIndent(code, lineStart);
|
|
1894
|
-
const hasOnlyIndentBeforeClosing = code.slice(lineStart, closingStart).trim() === "";
|
|
1895
|
-
edits.push({
|
|
1896
|
-
pos: hasOnlyIndentBeforeClosing ? lineStart : closingStart,
|
|
1897
|
-
prefix: hasOnlyIndentBeforeClosing ? `${closingIndent} ` : `\n${closingIndent} `,
|
|
1898
|
-
suffix: hasOnlyIndentBeforeClosing ? "\n" : ""
|
|
1899
|
-
});
|
|
1867
|
+
closingStart = node.closingElement.start;
|
|
1900
1868
|
path.stop();
|
|
1901
1869
|
} });
|
|
1902
1870
|
} catch (_) {
|
|
1903
1871
|
return null;
|
|
1904
1872
|
}
|
|
1905
|
-
return
|
|
1906
|
-
}
|
|
1907
|
-
function findLineStart(code, index) {
|
|
1908
|
-
for (let i = index - 1; i >= 0; i--) {
|
|
1909
|
-
const ch = code[i];
|
|
1910
|
-
if (ch === "\n" || ch === "\r") return i + 1;
|
|
1911
|
-
}
|
|
1912
|
-
return 0;
|
|
1873
|
+
return closingStart;
|
|
1913
1874
|
}
|
|
1914
1875
|
function getJsxName(name) {
|
|
1915
1876
|
if (!name || typeof name !== "object") return;
|
|
@@ -535,7 +535,7 @@ var QwikLogo = /*#__PURE__*/ componentQrl(/*#__PURE__*/ inlinedQrl((props) => {
|
|
|
535
535
|
xmlns: "http://www.w3.org/2000/svg",
|
|
536
536
|
viewBox: "0 0 500 506"
|
|
537
537
|
}, [
|
|
538
|
-
props.title ? /*#__PURE__*/ _jsxSorted(
|
|
538
|
+
props.title ? /*#__PURE__*/ _jsxSorted("title", null, null, props.title, 1, "4J_46") : null,
|
|
539
539
|
/*#__PURE__*/ _jsxSorted("path", null, {
|
|
540
540
|
fill: "white",
|
|
541
541
|
d: "M370.826 224.859 156.157 16.117l23.021 158.743-50.004 49.999 213.863 198.793-12.209-158.792 39.998-40.001Z"
|
package/dist/ui/q-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "1",
|
|
3
|
-
"manifestHash": "
|
|
3
|
+
"manifestHash": "kx6ytp",
|
|
4
4
|
"options": {
|
|
5
5
|
"target": "lib",
|
|
6
6
|
"buildMode": "development",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"../entry.extension.qwik.mjs": {
|
|
60
60
|
"size": 984,
|
|
61
|
-
"total":
|
|
61
|
+
"total": 2827353,
|
|
62
62
|
"imports": [
|
|
63
63
|
"../packages/devtools/ui/src/devtools/QwikDevtoolsExtension.qwik.mjs"
|
|
64
64
|
],
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"../index.qwik.mjs": {
|
|
71
71
|
"size": 224,
|
|
72
|
-
"total":
|
|
72
|
+
"total": 5938531,
|
|
73
73
|
"imports": [
|
|
74
74
|
"../entry.extension.qwik.mjs",
|
|
75
75
|
"../packages/devtools/ui/src/devtools/QwikDevtools.qwik.mjs"
|
|
@@ -3984,7 +3984,7 @@
|
|
|
3984
3984
|
},
|
|
3985
3985
|
"../packages/devtools/ui/src/components/DevtoolsButton/DevtoolsButton.qwik.mjs": {
|
|
3986
3986
|
"size": 4939,
|
|
3987
|
-
"total":
|
|
3987
|
+
"total": 28723,
|
|
3988
3988
|
"imports": [
|
|
3989
3989
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs"
|
|
3990
3990
|
],
|
|
@@ -4003,7 +4003,7 @@
|
|
|
4003
4003
|
},
|
|
4004
4004
|
"../packages/devtools/ui/src/components/DevtoolsPanel/DevtoolsPanel.qwik.mjs": {
|
|
4005
4005
|
"size": 19259,
|
|
4006
|
-
"total":
|
|
4006
|
+
"total": 43043,
|
|
4007
4007
|
"imports": [
|
|
4008
4008
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs"
|
|
4009
4009
|
],
|
|
@@ -4021,8 +4021,8 @@
|
|
|
4021
4021
|
"interactivity": 0
|
|
4022
4022
|
},
|
|
4023
4023
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs": {
|
|
4024
|
-
"size":
|
|
4025
|
-
"total":
|
|
4024
|
+
"size": 23784,
|
|
4025
|
+
"total": 23784,
|
|
4026
4026
|
"origins": [
|
|
4027
4027
|
"src/components/Icons/Icons.tsx"
|
|
4028
4028
|
],
|
|
@@ -4030,7 +4030,7 @@
|
|
|
4030
4030
|
},
|
|
4031
4031
|
"../packages/devtools/ui/src/components/InfoBanner/InfoBanner.qwik.mjs": {
|
|
4032
4032
|
"size": 1050,
|
|
4033
|
-
"total":
|
|
4033
|
+
"total": 24834,
|
|
4034
4034
|
"imports": [
|
|
4035
4035
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs"
|
|
4036
4036
|
],
|
|
@@ -4073,7 +4073,7 @@
|
|
|
4073
4073
|
},
|
|
4074
4074
|
"../packages/devtools/ui/src/components/ThemeToggle/QwikThemeToggle.qwik.mjs": {
|
|
4075
4075
|
"size": 2093,
|
|
4076
|
-
"total":
|
|
4076
|
+
"total": 25950,
|
|
4077
4077
|
"imports": [
|
|
4078
4078
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs",
|
|
4079
4079
|
"../packages/devtools/ui/src/components/router-head/theme-script.qwik.mjs"
|
|
@@ -4096,7 +4096,7 @@
|
|
|
4096
4096
|
},
|
|
4097
4097
|
"../packages/devtools/ui/src/components/Tree/Tree.qwik.mjs": {
|
|
4098
4098
|
"size": 8028,
|
|
4099
|
-
"total":
|
|
4099
|
+
"total": 31812,
|
|
4100
4100
|
"imports": [
|
|
4101
4101
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs"
|
|
4102
4102
|
],
|
|
@@ -4107,7 +4107,7 @@
|
|
|
4107
4107
|
},
|
|
4108
4108
|
"../packages/devtools/ui/src/devtools/command-palette.qwik.mjs": {
|
|
4109
4109
|
"size": 4976,
|
|
4110
|
-
"total":
|
|
4110
|
+
"total": 30733,
|
|
4111
4111
|
"imports": [
|
|
4112
4112
|
"../packages/devtools/ui/src/devtools/tabs.qwik.mjs"
|
|
4113
4113
|
],
|
|
@@ -4118,7 +4118,7 @@
|
|
|
4118
4118
|
},
|
|
4119
4119
|
"../packages/devtools/ui/src/devtools/CommandPalette.qwik.mjs": {
|
|
4120
4120
|
"size": 10646,
|
|
4121
|
-
"total":
|
|
4121
|
+
"total": 91113,
|
|
4122
4122
|
"imports": [
|
|
4123
4123
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs",
|
|
4124
4124
|
"../packages/devtools/ui/src/components/ThemeToggle/QwikThemeToggle.qwik.mjs",
|
|
@@ -4131,7 +4131,7 @@
|
|
|
4131
4131
|
},
|
|
4132
4132
|
"../packages/devtools/ui/src/devtools/CustomizeTabsPanel.qwik.mjs": {
|
|
4133
4133
|
"size": 8321,
|
|
4134
|
-
"total":
|
|
4134
|
+
"total": 62156,
|
|
4135
4135
|
"imports": [
|
|
4136
4136
|
"../packages/devtools/ui/src/components/IconButton/IconButton.qwik.mjs",
|
|
4137
4137
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs",
|
|
@@ -4144,7 +4144,7 @@
|
|
|
4144
4144
|
},
|
|
4145
4145
|
"../packages/devtools/ui/src/devtools/DevtoolsContent.qwik.mjs": {
|
|
4146
4146
|
"size": 7071,
|
|
4147
|
-
"total":
|
|
4147
|
+
"total": 2685656,
|
|
4148
4148
|
"imports": [
|
|
4149
4149
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs",
|
|
4150
4150
|
"../packages/devtools/ui/src/components/TabContent/TabContent.qwik.mjs",
|
|
@@ -4168,7 +4168,7 @@
|
|
|
4168
4168
|
},
|
|
4169
4169
|
"../packages/devtools/ui/src/devtools/DevtoolsSidebar.qwik.mjs": {
|
|
4170
4170
|
"size": 4790,
|
|
4171
|
-
"total":
|
|
4171
|
+
"total": 84748,
|
|
4172
4172
|
"imports": [
|
|
4173
4173
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs",
|
|
4174
4174
|
"../packages/devtools/ui/src/components/Tab/Tab.qwik.mjs",
|
|
@@ -4190,7 +4190,7 @@
|
|
|
4190
4190
|
},
|
|
4191
4191
|
"../packages/devtools/ui/src/devtools/QwikDevtools.qwik.mjs": {
|
|
4192
4192
|
"size": 3926,
|
|
4193
|
-
"total":
|
|
4193
|
+
"total": 3110954,
|
|
4194
4194
|
"imports": [
|
|
4195
4195
|
"../packages/devtools/kit/src/overlay-paths.qwik.mjs",
|
|
4196
4196
|
"../packages/devtools/ui/src/components/DevtoolsButton/DevtoolsButton.qwik.mjs",
|
|
@@ -4213,7 +4213,7 @@
|
|
|
4213
4213
|
},
|
|
4214
4214
|
"../packages/devtools/ui/src/devtools/QwikDevtoolsExtension.qwik.mjs": {
|
|
4215
4215
|
"size": 1804,
|
|
4216
|
-
"total":
|
|
4216
|
+
"total": 2826369,
|
|
4217
4217
|
"imports": [
|
|
4218
4218
|
"../packages/devtools/ui/src/devtools/DevtoolsContent.qwik.mjs",
|
|
4219
4219
|
"../packages/devtools/ui/src/devtools/DevtoolsSidebar.qwik.mjs",
|
|
@@ -4240,7 +4240,7 @@
|
|
|
4240
4240
|
},
|
|
4241
4241
|
"../packages/devtools/ui/src/devtools/sidebar-tabs.qwik.mjs": {
|
|
4242
4242
|
"size": 3471,
|
|
4243
|
-
"total":
|
|
4243
|
+
"total": 29228,
|
|
4244
4244
|
"imports": [
|
|
4245
4245
|
"../packages/devtools/ui/src/devtools/tabs.qwik.mjs"
|
|
4246
4246
|
],
|
|
@@ -4251,7 +4251,7 @@
|
|
|
4251
4251
|
},
|
|
4252
4252
|
"../packages/devtools/ui/src/devtools/state.qwik.mjs": {
|
|
4253
4253
|
"size": 634,
|
|
4254
|
-
"total":
|
|
4254
|
+
"total": 29862,
|
|
4255
4255
|
"imports": [
|
|
4256
4256
|
"../packages/devtools/ui/src/devtools/sidebar-tabs.qwik.mjs"
|
|
4257
4257
|
],
|
|
@@ -4262,7 +4262,7 @@
|
|
|
4262
4262
|
},
|
|
4263
4263
|
"../packages/devtools/ui/src/devtools/tabs.qwik.mjs": {
|
|
4264
4264
|
"size": 1973,
|
|
4265
|
-
"total":
|
|
4265
|
+
"total": 25757,
|
|
4266
4266
|
"imports": [
|
|
4267
4267
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs"
|
|
4268
4268
|
],
|
|
@@ -4326,7 +4326,7 @@
|
|
|
4326
4326
|
},
|
|
4327
4327
|
"../packages/devtools/ui/src/features/HookTree/HookTree.qwik.mjs": {
|
|
4328
4328
|
"size": 23114,
|
|
4329
|
-
"total":
|
|
4329
|
+
"total": 114980,
|
|
4330
4330
|
"imports": [
|
|
4331
4331
|
"../packages/devtools/ui/src/components/IconButton/IconButton.qwik.mjs",
|
|
4332
4332
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs",
|
|
@@ -4380,7 +4380,7 @@
|
|
|
4380
4380
|
},
|
|
4381
4381
|
"../packages/devtools/ui/src/features/Overview/Overview.qwik.mjs": {
|
|
4382
4382
|
"size": 6930,
|
|
4383
|
-
"total":
|
|
4383
|
+
"total": 55548,
|
|
4384
4384
|
"imports": [
|
|
4385
4385
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs",
|
|
4386
4386
|
"../packages/devtools/ui/src/components/InfoBanner/InfoBanner.qwik.mjs"
|
|
@@ -4681,7 +4681,7 @@
|
|
|
4681
4681
|
},
|
|
4682
4682
|
"../packages/devtools/ui/src/features/RenderTree/components/HookFiltersCard.qwik.mjs": {
|
|
4683
4683
|
"size": 3002,
|
|
4684
|
-
"total":
|
|
4684
|
+
"total": 26786,
|
|
4685
4685
|
"imports": [
|
|
4686
4686
|
"../packages/devtools/ui/src/components/Icons/Icons.qwik.mjs"
|
|
4687
4687
|
],
|
|
@@ -4711,7 +4711,7 @@
|
|
|
4711
4711
|
},
|
|
4712
4712
|
"../packages/devtools/ui/src/features/RenderTree/RenderTree.qwik.mjs": {
|
|
4713
4713
|
"size": 9741,
|
|
4714
|
-
"total":
|
|
4714
|
+
"total": 813702,
|
|
4715
4715
|
"imports": [
|
|
4716
4716
|
"../_virtual/_rolldown/runtime.qwik.mjs",
|
|
4717
4717
|
"../node_modules/.pnpm/debug@4.4.3_supports-color@11.0.0/node_modules/debug/src/browser.qwik.mjs",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwik.dev/devtools",
|
|
3
3
|
"description": "Qwik devtools package",
|
|
4
|
-
"version": "2.0.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.3",
|
|
5
5
|
"bugs": "https://github.com/QwikDev/devtools/issues",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"birpc": "^4.0.0",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"vite": "8.2.1",
|
|
48
48
|
"vite-tsconfig-paths": "6.1.1",
|
|
49
49
|
"vitest": "5.0.0",
|
|
50
|
-
"@qwik.dev/core": "2.0.0-rc.
|
|
51
|
-
"eslint-plugin-qwik": "2.0.0-rc.
|
|
50
|
+
"@qwik.dev/core": "2.0.0-rc.3",
|
|
51
|
+
"eslint-plugin-qwik": "2.0.0-rc.3"
|
|
52
52
|
},
|
|
53
53
|
"exports": {
|
|
54
54
|
".": {
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@tailwindcss/vite": "^4.2.1",
|
|
89
89
|
"tailwindcss": "^4.2.1",
|
|
90
90
|
"vite": ">=8 <9",
|
|
91
|
-
"@qwik.dev/core": "2.0.0-rc.
|
|
91
|
+
"@qwik.dev/core": "2.0.0-rc.3"
|
|
92
92
|
},
|
|
93
93
|
"private": false,
|
|
94
94
|
"publishConfig": {
|