@qwik.dev/mcp 2.0.0-rc.3 → 2.0.0-rc.4
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/README.md +1 -1
- package/dist/cli.js +2 -2
- package/dist/docs.json +1 -1
- package/dist/index.js +94 -39
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -118,6 +118,19 @@ var ALL_HOOK_NAMES = /* @__PURE__ */ new Set([...USE_HOOK_LIST]);
|
|
|
118
118
|
function isAstNodeLike(value) {
|
|
119
119
|
return Boolean(value) && typeof value === "object" && "type" in value;
|
|
120
120
|
}
|
|
121
|
+
function getNodeStart(node) {
|
|
122
|
+
if (node && typeof node === "object") {
|
|
123
|
+
const maybeRange = node.range;
|
|
124
|
+
if (Array.isArray(maybeRange)) {
|
|
125
|
+
return maybeRange[0] ?? 0;
|
|
126
|
+
}
|
|
127
|
+
const maybeStart = node.start;
|
|
128
|
+
if (typeof maybeStart === "number") {
|
|
129
|
+
return maybeStart;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return 0;
|
|
133
|
+
}
|
|
121
134
|
function getVariableIdentifierName(id) {
|
|
122
135
|
if (!isAstNodeLike(id)) {
|
|
123
136
|
return null;
|
|
@@ -244,6 +257,9 @@ function findAllComponentBodyRangesFromProgram(program) {
|
|
|
244
257
|
});
|
|
245
258
|
return deduplicateRanges(ranges);
|
|
246
259
|
}
|
|
260
|
+
function isInsideComponentBody(bodies, position) {
|
|
261
|
+
return bodies.some((body) => body.bodyStart < position && position < body.bodyEnd);
|
|
262
|
+
}
|
|
247
263
|
function getComponentBodyRange(node, parent) {
|
|
248
264
|
if (!isComponentCall(node)) {
|
|
249
265
|
return null;
|
|
@@ -367,12 +383,13 @@ function buildComponentSuffix(baseArg, exportName) {
|
|
|
367
383
|
// ../devtools/plugin/src/parse/hookTracker.ts
|
|
368
384
|
function injectHookTrackers(code) {
|
|
369
385
|
const program = parseProgram(code);
|
|
386
|
+
const componentBodies = findAllComponentBodyRangesFromProgram(program);
|
|
370
387
|
const tasks = [];
|
|
371
388
|
let customHookIndex = 0;
|
|
372
389
|
traverseProgram(program, {
|
|
373
390
|
enter: (path) => {
|
|
374
391
|
const node = path.node;
|
|
375
|
-
if (!node) {
|
|
392
|
+
if (!node || !isInsideComponentBody(componentBodies, getNodeStart(node))) {
|
|
376
393
|
return;
|
|
377
394
|
}
|
|
378
395
|
if (node.type === "VariableDeclarator") {
|
|
@@ -558,12 +575,85 @@ function transformComponentFile(code, id) {
|
|
|
558
575
|
return parseQwikCode(codeWithCollectorImport, { path: id });
|
|
559
576
|
}
|
|
560
577
|
|
|
578
|
+
// ../devtools/plugin/src/runtime/create-runtime-module.ts
|
|
579
|
+
function createRuntimeModule(parts) {
|
|
580
|
+
return parts.filter((part) => typeof part === "string" && part.length > 0).map((part) => part.trim()).join("\n\n") + "\n";
|
|
581
|
+
}
|
|
582
|
+
function createRuntimeInstallerSource(installer) {
|
|
583
|
+
return installer.toString();
|
|
584
|
+
}
|
|
585
|
+
function createRuntimeCall(name, args) {
|
|
586
|
+
return `${name}(${args.map(serializeRuntimeValue).join(", ")});`;
|
|
587
|
+
}
|
|
588
|
+
function runtimeExpression(source) {
|
|
589
|
+
return { __runtimeExpression: source };
|
|
590
|
+
}
|
|
591
|
+
function createRuntimeVar(name, value) {
|
|
592
|
+
return `var ${name} = ${JSON.stringify(value)};`;
|
|
593
|
+
}
|
|
594
|
+
function serializeRuntimeValue(value) {
|
|
595
|
+
if (isRuntimeExpression(value)) {
|
|
596
|
+
return value.__runtimeExpression;
|
|
597
|
+
}
|
|
598
|
+
if (Array.isArray(value)) {
|
|
599
|
+
return `[${value.map(serializeRuntimeValue).join(", ")}]`;
|
|
600
|
+
}
|
|
601
|
+
if (value && typeof value === "object") {
|
|
602
|
+
return `{ ${Object.entries(value).map(([key, item]) => `${JSON.stringify(key)}: ${serializeRuntimeValue(item)}`).join(", ")} }`;
|
|
603
|
+
}
|
|
604
|
+
return JSON.stringify(value);
|
|
605
|
+
}
|
|
606
|
+
function isRuntimeExpression(value) {
|
|
607
|
+
return Boolean(value) && typeof value === "object" && typeof value.__runtimeExpression === "string";
|
|
608
|
+
}
|
|
609
|
+
|
|
561
610
|
// ../devtools/plugin/src/virtualmodules/useCollectHooks.ts
|
|
562
611
|
var globalKey = JSON.stringify(QWIK_DEVTOOLS_GLOBAL.key);
|
|
563
612
|
var globalVersion = JSON.stringify(QWIK_DEVTOOLS_GLOBAL.version);
|
|
564
613
|
var componentStateKey = JSON.stringify(QWIK_DEVTOOLS_GLOBAL.props.componentState);
|
|
565
|
-
|
|
566
|
-
|
|
614
|
+
function __qwik_is_serializable_hook_value__(value, isReactive, seen = /* @__PURE__ */ new Set()) {
|
|
615
|
+
if (typeof value === "function") {
|
|
616
|
+
return typeof value.getSymbol === "function";
|
|
617
|
+
}
|
|
618
|
+
if (typeof value !== "object" || value === null) {
|
|
619
|
+
return typeof value !== "symbol";
|
|
620
|
+
}
|
|
621
|
+
if (isReactive(value) || seen.has(value)) {
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
seen.add(value);
|
|
625
|
+
if (Array.isArray(value)) {
|
|
626
|
+
for (let i = 0; i < value.length; i++) {
|
|
627
|
+
if (!(i in value) || !__qwik_is_serializable_hook_value__(value[i], isReactive, seen)) {
|
|
628
|
+
return false;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
return true;
|
|
632
|
+
}
|
|
633
|
+
if (Object.getPrototypeOf(value) !== Object.prototype) {
|
|
634
|
+
return false;
|
|
635
|
+
}
|
|
636
|
+
for (const item of Object.values(value)) {
|
|
637
|
+
if (!__qwik_is_serializable_hook_value__(item, isReactive, seen)) {
|
|
638
|
+
return false;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return true;
|
|
642
|
+
}
|
|
643
|
+
var useCollectHooks = `import { $, isServer, isSignal, useSignal, useVisibleTask$ } from "@qwik.dev/core"
|
|
644
|
+
import { _getContextContainer, _getContextHostElement, _isStore } from "@qwik.dev/core/internal"
|
|
645
|
+
|
|
646
|
+
${createRuntimeInstallerSource(__qwik_is_serializable_hook_value__)}
|
|
647
|
+
|
|
648
|
+
const isReactive = (value) => isSignal(value) || _isStore(value)
|
|
649
|
+
|
|
650
|
+
// SSR serializes the collected hooks, but custom hook values may not be serializable.
|
|
651
|
+
function stripUnserializableData(args) {
|
|
652
|
+
if (!isServer || args.hookType !== 'customhook') {
|
|
653
|
+
return args
|
|
654
|
+
}
|
|
655
|
+
return __qwik_is_serializable_hook_value__(args.data, isReactive) ? args : { ...args, data: undefined }
|
|
656
|
+
}
|
|
567
657
|
|
|
568
658
|
function initComponentState() {
|
|
569
659
|
return {
|
|
@@ -601,10 +691,7 @@ export const useCollectHooks = (src) => {
|
|
|
601
691
|
}, { strategy: 'document-ready' })
|
|
602
692
|
|
|
603
693
|
return $((args) => {
|
|
604
|
-
|
|
605
|
-
return
|
|
606
|
-
}
|
|
607
|
-
hooksList.value.add(args)
|
|
694
|
+
hooksList.value.add(stripUnserializableData(args))
|
|
608
695
|
if (typeof window !== 'undefined') {
|
|
609
696
|
getOrCreateState(src).hooks = [...hooksList.value]
|
|
610
697
|
window[${globalKey}]?.hook?.refreshVNodeTree?.()
|
|
@@ -614,38 +701,6 @@ export const useCollectHooks = (src) => {
|
|
|
614
701
|
`;
|
|
615
702
|
var useCollectHooks_default = useCollectHooks;
|
|
616
703
|
|
|
617
|
-
// ../devtools/plugin/src/runtime/create-runtime-module.ts
|
|
618
|
-
function createRuntimeModule(parts) {
|
|
619
|
-
return parts.filter((part) => typeof part === "string" && part.length > 0).map((part) => part.trim()).join("\n\n") + "\n";
|
|
620
|
-
}
|
|
621
|
-
function createRuntimeInstallerSource(installer) {
|
|
622
|
-
return installer.toString();
|
|
623
|
-
}
|
|
624
|
-
function createRuntimeCall(name, args) {
|
|
625
|
-
return `${name}(${args.map(serializeRuntimeValue).join(", ")});`;
|
|
626
|
-
}
|
|
627
|
-
function runtimeExpression(source) {
|
|
628
|
-
return { __runtimeExpression: source };
|
|
629
|
-
}
|
|
630
|
-
function createRuntimeVar(name, value) {
|
|
631
|
-
return `var ${name} = ${JSON.stringify(value)};`;
|
|
632
|
-
}
|
|
633
|
-
function serializeRuntimeValue(value) {
|
|
634
|
-
if (isRuntimeExpression(value)) {
|
|
635
|
-
return value.__runtimeExpression;
|
|
636
|
-
}
|
|
637
|
-
if (Array.isArray(value)) {
|
|
638
|
-
return `[${value.map(serializeRuntimeValue).join(", ")}]`;
|
|
639
|
-
}
|
|
640
|
-
if (value && typeof value === "object") {
|
|
641
|
-
return `{ ${Object.entries(value).map(([key, item]) => `${JSON.stringify(key)}: ${serializeRuntimeValue(item)}`).join(", ")} }`;
|
|
642
|
-
}
|
|
643
|
-
return JSON.stringify(value);
|
|
644
|
-
}
|
|
645
|
-
function isRuntimeExpression(value) {
|
|
646
|
-
return Boolean(value) && typeof value === "object" && typeof value.__runtimeExpression === "string";
|
|
647
|
-
}
|
|
648
|
-
|
|
649
704
|
// ../devtools/plugin/src/runtime/installers.ts
|
|
650
705
|
function __qwik_derive_component_name__(path) {
|
|
651
706
|
const lastSeg = path.split("/").pop() || path;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qwik.dev/mcp",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.4",
|
|
4
4
|
"description": "Local MCP tools for Qwik development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,24 +18,24 @@
|
|
|
18
18
|
"README.md"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@modelcontextprotocol/server": "^2.
|
|
21
|
+
"@modelcontextprotocol/server": "^2.3.0",
|
|
22
22
|
"oxc-parser": "^0.144.0",
|
|
23
23
|
"zod": "^4.2.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@modelcontextprotocol/client": "2.
|
|
26
|
+
"@modelcontextprotocol/client": "2.3.0",
|
|
27
27
|
"@playwright/test": "1.61.1",
|
|
28
28
|
"@types/node": "25.6.0",
|
|
29
29
|
"esbuild": "0.28.2",
|
|
30
30
|
"typescript": "5.9.3",
|
|
31
|
-
"vite": "8.2.
|
|
31
|
+
"vite": "8.2.4",
|
|
32
32
|
"vitest": "5.0.0",
|
|
33
|
-
"@qwik.dev/core": "2.0.0-rc.
|
|
34
|
-
"@qwik.dev/router": "2.0.0-rc.
|
|
33
|
+
"@qwik.dev/core": "2.0.0-rc.4",
|
|
34
|
+
"@qwik.dev/router": "2.0.0-rc.4"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"vite": ">=8 <9",
|
|
38
|
-
"@qwik.dev/core": "2.0.0-rc.
|
|
38
|
+
"@qwik.dev/core": "2.0.0-rc.4"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=22.18.0"
|