@tanstack/devtools-vite 0.8.0 → 0.8.2

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.
Files changed (73) hide show
  1. package/dist/esm/plugin.d.ts +4 -74
  2. package/dist/esm/plugin.js +2 -12
  3. package/dist/esm/plugin.js.map +1 -1
  4. package/package.json +6 -7
  5. package/src/plugin.ts +25 -97
  6. package/dist/esm/ast-utils.d.ts +0 -11
  7. package/dist/esm/ast-utils.js +0 -44
  8. package/dist/esm/ast-utils.js.map +0 -1
  9. package/dist/esm/devtools-packages.d.ts +0 -2
  10. package/dist/esm/devtools-packages.js +0 -15
  11. package/dist/esm/devtools-packages.js.map +0 -1
  12. package/dist/esm/editor.d.ts +0 -25
  13. package/dist/esm/editor.js +0 -20
  14. package/dist/esm/editor.js.map +0 -1
  15. package/dist/esm/enhance-logs.d.ts +0 -4
  16. package/dist/esm/enhance-logs.js +0 -51
  17. package/dist/esm/enhance-logs.js.map +0 -1
  18. package/dist/esm/enhance-logs.test.d.ts +0 -1
  19. package/dist/esm/inject-plugin.d.ts +0 -22
  20. package/dist/esm/inject-plugin.js +0 -179
  21. package/dist/esm/inject-plugin.js.map +0 -1
  22. package/dist/esm/inject-plugin.test.d.ts +0 -1
  23. package/dist/esm/inject-source.d.ts +0 -7
  24. package/dist/esm/inject-source.js +0 -114
  25. package/dist/esm/inject-source.js.map +0 -1
  26. package/dist/esm/inject-source.test.d.ts +0 -1
  27. package/dist/esm/matcher.d.ts +0 -1
  28. package/dist/esm/matcher.js +0 -13
  29. package/dist/esm/matcher.js.map +0 -1
  30. package/dist/esm/matcher.test.d.ts +0 -1
  31. package/dist/esm/offset-to-loc.d.ts +0 -14
  32. package/dist/esm/offset-to-loc.js +0 -29
  33. package/dist/esm/offset-to-loc.js.map +0 -1
  34. package/dist/esm/package-manager.d.ts +0 -16
  35. package/dist/esm/package-manager.js +0 -98
  36. package/dist/esm/package-manager.js.map +0 -1
  37. package/dist/esm/remove-devtools.d.ts +0 -4
  38. package/dist/esm/remove-devtools.js +0 -96
  39. package/dist/esm/remove-devtools.js.map +0 -1
  40. package/dist/esm/remove-devtools.test.d.ts +0 -1
  41. package/dist/esm/runtime-bridge.d.ts +0 -31
  42. package/dist/esm/runtime-bridge.js +0 -75
  43. package/dist/esm/runtime-bridge.js.map +0 -1
  44. package/dist/esm/runtime-bridge.test.d.ts +0 -1
  45. package/dist/esm/utils.d.ts +0 -31
  46. package/dist/esm/utils.js +0 -155
  47. package/dist/esm/utils.js.map +0 -1
  48. package/dist/esm/utils.test.d.ts +0 -1
  49. package/dist/esm/virtual-console.d.ts +0 -19
  50. package/dist/esm/virtual-console.js +0 -336
  51. package/dist/esm/virtual-console.js.map +0 -1
  52. package/dist/esm/virtual-console.test.d.ts +0 -1
  53. package/src/ast-utils.ts +0 -58
  54. package/src/devtools-packages.ts +0 -12
  55. package/src/editor.ts +0 -53
  56. package/src/enhance-logs.test.ts +0 -132
  57. package/src/enhance-logs.ts +0 -71
  58. package/src/inject-plugin.test.ts +0 -1139
  59. package/src/inject-plugin.ts +0 -300
  60. package/src/inject-source.test.ts +0 -939
  61. package/src/inject-source.ts +0 -235
  62. package/src/matcher.test.ts +0 -33
  63. package/src/matcher.ts +0 -19
  64. package/src/offset-to-loc.ts +0 -39
  65. package/src/package-manager.ts +0 -181
  66. package/src/remove-devtools.test.ts +0 -607
  67. package/src/remove-devtools.ts +0 -190
  68. package/src/runtime-bridge.test.ts +0 -179
  69. package/src/runtime-bridge.ts +0 -113
  70. package/src/utils.test.ts +0 -184
  71. package/src/utils.ts +0 -247
  72. package/src/virtual-console.test.ts +0 -244
  73. package/src/virtual-console.ts +0 -341
@@ -1,96 +0,0 @@
1
- import { walk } from "./ast-utils.js";
2
- import { isTanStackDevtoolsImport } from "./devtools-packages.js";
3
- import MagicString from "magic-string";
4
- import { parseSync } from "oxc-parser";
5
- //#region src/remove-devtools.ts
6
- /**
7
- * Extract component names referenced in the `plugins` prop of a devtools element.
8
- */
9
- function getPluginReferences(opening) {
10
- const refs = [];
11
- for (const attr of opening.attributes) {
12
- if (attr.type !== "JSXAttribute") continue;
13
- if (attr.name.type !== "JSXIdentifier" || attr.name.name !== "plugins") continue;
14
- if (!attr.value || attr.value.type !== "JSXExpressionContainer" || attr.value.expression.type !== "ArrayExpression") continue;
15
- for (const el of attr.value.expression.elements) {
16
- if (!el || el.type !== "ObjectExpression") continue;
17
- for (const prop of el.properties) {
18
- if (prop.type !== "Property" || prop.key.type !== "Identifier" || prop.key.name !== "render") continue;
19
- const value = prop.value;
20
- if (value.type === "JSXElement" && value.openingElement.name.type === "JSXIdentifier") refs.push(value.openingElement.name.name);
21
- else if (value.type === "ArrowFunctionExpression" || value.type === "FunctionExpression") {
22
- const body = value.body;
23
- if (body && body.type === "JSXElement" && body.openingElement.name.type === "JSXIdentifier") refs.push(body.openingElement.name.name);
24
- } else if (value.type === "Identifier") refs.push(value.name);
25
- else if (value.type === "CallExpression" && value.callee.type === "Identifier") refs.push(value.callee.name);
26
- }
27
- }
28
- }
29
- return refs;
30
- }
31
- function removeDevtools(code, id) {
32
- const filePath = id.split("?")[0];
33
- try {
34
- const result = parseSync(filePath, code, {
35
- sourceType: "module",
36
- lang: "tsx"
37
- });
38
- if (result.errors.length > 0) return;
39
- const s = new MagicString(code);
40
- const devtoolsNames = /* @__PURE__ */ new Set();
41
- const pluginRefs = [];
42
- walk(result.program, (node) => {
43
- if (node.type === "ImportDeclaration" && isTanStackDevtoolsImport(node.source.value)) {
44
- for (const spec of node.specifiers) devtoolsNames.add(spec.local.name);
45
- let end = node.end;
46
- if (code[end] === "\n") end++;
47
- s.remove(node.start, end);
48
- }
49
- });
50
- if (devtoolsNames.size === 0) return;
51
- walk(result.program, (node, parentNode) => {
52
- if (node.type !== "JSXElement") return;
53
- const opening = node.openingElement;
54
- let matches = false;
55
- if (opening.name.type === "JSXIdentifier" && devtoolsNames.has(opening.name.name)) matches = true;
56
- else if (opening.name.type === "JSXMemberExpression" && opening.name.object.type === "JSXIdentifier" && devtoolsNames.has(opening.name.object.name)) matches = true;
57
- if (!matches) return;
58
- pluginRefs.push(...getPluginReferences(opening));
59
- let end = node.end;
60
- if (code[end] === "\n") end++;
61
- if (parentNode?.type === "ParenthesizedExpression") s.overwrite(node.start, end, "null");
62
- else s.remove(node.start, end);
63
- });
64
- if (pluginRefs.length > 0) walk(result.program, (node) => {
65
- if (node.type !== "ImportDeclaration") return;
66
- if (isTanStackDevtoolsImport(node.source.value)) return;
67
- const toRemove = node.specifiers.filter((spec) => spec.type === "ImportSpecifier" && pluginRefs.includes(spec.local.name));
68
- if (toRemove.length === 0) return;
69
- const remaining = node.specifiers.filter((spec) => !toRemove.includes(spec));
70
- if (remaining.length === 0) {
71
- let end = node.end;
72
- if (code[end] === "\n") end++;
73
- s.remove(node.start, end);
74
- } else {
75
- const specTexts = remaining.map((spec) => code.slice(spec.start, spec.end));
76
- const sourceText = code.slice(node.source.start, node.source.end);
77
- s.overwrite(node.start, node.end, `import { ${specTexts.join(", ")} } from ${sourceText}`);
78
- }
79
- });
80
- if (!s.hasChanged()) return;
81
- return {
82
- code: s.toString(),
83
- map: s.generateMap({
84
- source: filePath,
85
- file: id,
86
- includeContent: true
87
- })
88
- };
89
- } catch (e) {
90
- return;
91
- }
92
- }
93
- //#endregion
94
- export { removeDevtools };
95
-
96
- //# sourceMappingURL=remove-devtools.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove-devtools.js","names":[],"sources":["../../src/remove-devtools.ts"],"sourcesContent":["import MagicString from 'magic-string'\nimport { parseSync } from 'oxc-parser'\nimport { walk } from './ast-utils'\nimport { isTanStackDevtoolsImport } from './devtools-packages'\nimport type { JSXOpeningElement } from 'oxc-parser'\n\n/**\n * Extract component names referenced in the `plugins` prop of a devtools element.\n */\nfunction getPluginReferences(opening: JSXOpeningElement): Array<string> {\n const refs: Array<string> = []\n\n for (const attr of opening.attributes) {\n if (attr.type !== 'JSXAttribute') continue\n if (attr.name.type !== 'JSXIdentifier' || attr.name.name !== 'plugins')\n continue\n if (\n !attr.value ||\n attr.value.type !== 'JSXExpressionContainer' ||\n attr.value.expression.type !== 'ArrayExpression'\n )\n continue\n\n for (const el of attr.value.expression.elements) {\n if (!el || el.type !== 'ObjectExpression') continue\n\n for (const prop of el.properties) {\n if (\n prop.type !== 'Property' ||\n prop.key.type !== 'Identifier' ||\n prop.key.name !== 'render'\n )\n continue\n\n const value = prop.value\n\n // handle <ReactRouterPanel />\n if (\n value.type === 'JSXElement' &&\n value.openingElement.name.type === 'JSXIdentifier'\n ) {\n refs.push(value.openingElement.name.name)\n }\n // handle () => <ReactRouterPanel />\n else if (\n value.type === 'ArrowFunctionExpression' ||\n value.type === 'FunctionExpression'\n ) {\n const body = value.body\n if (\n body &&\n body.type === 'JSXElement' &&\n body.openingElement.name.type === 'JSXIdentifier'\n ) {\n refs.push(body.openingElement.name.name)\n }\n }\n // handle render: SomeComponent\n else if (value.type === 'Identifier') {\n refs.push(value.name)\n }\n // handle render: someFunction()\n else if (\n value.type === 'CallExpression' &&\n value.callee.type === 'Identifier'\n ) {\n refs.push(value.callee.name)\n }\n }\n }\n }\n\n return refs\n}\n\nexport function removeDevtools(code: string, id: string) {\n const filePath = id.split('?')[0]!\n\n try {\n const result = parseSync(filePath, code, {\n sourceType: 'module',\n lang: 'tsx',\n })\n if (result.errors.length > 0) return\n\n const s = new MagicString(code)\n const devtoolsNames = new Set<string>()\n const pluginRefs: Array<string> = []\n\n // Pass 1: Collect devtools import names and mark for removal\n walk(result.program, (node) => {\n if (\n node.type === 'ImportDeclaration' &&\n isTanStackDevtoolsImport(node.source.value)\n ) {\n for (const spec of node.specifiers) {\n devtoolsNames.add(spec.local.name)\n }\n let end = node.end\n if (code[end] === '\\n') end++\n s.remove(node.start, end)\n }\n })\n\n if (devtoolsNames.size === 0) return\n\n // Pass 2: Find and remove devtools JSX elements, collect plugin references\n walk(result.program, (node, parentNode) => {\n if (node.type !== 'JSXElement') return\n\n const opening = node.openingElement\n let matches = false\n\n if (\n opening.name.type === 'JSXIdentifier' &&\n devtoolsNames.has(opening.name.name)\n ) {\n matches = true\n } else if (\n opening.name.type === 'JSXMemberExpression' &&\n opening.name.object.type === 'JSXIdentifier' &&\n devtoolsNames.has(opening.name.object.name)\n ) {\n matches = true\n }\n\n if (!matches) return\n\n pluginRefs.push(...getPluginReferences(opening))\n\n let end = node.end\n if (code[end] === '\\n') end++\n if (parentNode?.type === 'ParenthesizedExpression') {\n s.overwrite(node.start, end, 'null')\n } else {\n s.remove(node.start, end)\n }\n })\n\n // Pass 3: Remove plugin imports that are no longer referenced\n if (pluginRefs.length > 0) {\n walk(result.program, (node) => {\n if (node.type !== 'ImportDeclaration') return\n if (isTanStackDevtoolsImport(node.source.value)) return\n\n const toRemove = node.specifiers.filter(\n (spec) =>\n spec.type === 'ImportSpecifier' &&\n pluginRefs.includes(spec.local.name),\n )\n\n if (toRemove.length === 0) return\n\n const remaining = node.specifiers.filter(\n (spec) => !toRemove.includes(spec),\n )\n\n if (remaining.length === 0) {\n let end = node.end\n if (code[end] === '\\n') end++\n s.remove(node.start, end)\n } else {\n // Rebuild import with remaining specifiers\n const specTexts = remaining.map((spec) =>\n code.slice(spec.start, spec.end),\n )\n const sourceText = code.slice(node.source.start, node.source.end)\n s.overwrite(\n node.start,\n node.end,\n `import { ${specTexts.join(', ')} } from ${sourceText}`,\n )\n }\n })\n }\n\n if (!s.hasChanged()) return\n\n return {\n code: s.toString(),\n map: s.generateMap({\n source: filePath,\n file: id,\n includeContent: true,\n }),\n }\n } catch (e) {\n return\n }\n}\n"],"mappings":";;;;;;;;AASA,SAAS,oBAAoB,SAA2C;CACtE,MAAM,OAAsB,EAAE;CAE9B,KAAK,MAAM,QAAQ,QAAQ,YAAY;EACrC,IAAI,KAAK,SAAS,gBAAgB;EAClC,IAAI,KAAK,KAAK,SAAS,mBAAmB,KAAK,KAAK,SAAS,WAC3D;EACF,IACE,CAAC,KAAK,SACN,KAAK,MAAM,SAAS,4B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,KACL,YAAY,UAAU,KAAK,KAAK,CAAC,UAAU,aAC5C;;IAEH;EAGJ,IAAI,CAAC,EAAE,YAAY,EAAE;EAErB,OAAO;GACL,MAAM,EAAE,UAAU;GAClB,KAAK,EAAE,YAAY;IACjB,QAAQ;IACR,MAAM;IACN,gBAAgB;IACjB,CAAC;GACH;UACM,GAAG;EACV"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,31 +0,0 @@
1
- /**
2
- * Worker-side bridge for isolated server runtimes (Nitro v3 worker, Cloudflare workerd).
3
- *
4
- * Injected into the `@tanstack/devtools-event-client` module ONLY in non-client
5
- * (server) environments during dev. At module-eval time it gives the isolated
6
- * runtime a real `globalThis.__TANSTACK_EVENT_TARGET__` (so the unchanged
7
- * `EventClient` uses it instead of a throwaway target) and bridges that target to
8
- * the Vite dev process over the framework plugin's existing HMR HotChannel.
9
- *
10
- * Guards:
11
- * - `import.meta.hot` falsy (production / no HMR) -> tree-shaken / no-op.
12
- * - global target already set (in-process RunnableDevEnvironment, where
13
- * ServerEventBus lives) -> no-op, so existing behavior is unchanged.
14
- *
15
- * The bridge replicates ServerEventBus's in-process responsibilities so the
16
- * EventClient protocol is identical across the wire (see design doc).
17
- */
18
- export declare function generateRuntimeBridgeCode(): string;
19
- export declare function injectRuntimeBridge(code: string, id: string, environmentName: string | undefined): string | undefined;
20
- interface BridgeHotChannel {
21
- on?: (event: string, cb: (data: any) => void) => void;
22
- off?: (event: string, cb: (data: any) => void) => void;
23
- send?: (event: string, data: any) => void;
24
- }
25
- interface BridgeServerLike {
26
- environments: Record<string, {
27
- hot?: BridgeHotChannel | null;
28
- } | undefined>;
29
- }
30
- export declare function wireRuntimeBridgeChannels(server: BridgeServerLike, getTarget: () => EventTarget | null | undefined): () => void;
31
- export {};
@@ -1,75 +0,0 @@
1
- //#region src/runtime-bridge.ts
2
- /**
3
- * Worker-side bridge for isolated server runtimes (Nitro v3 worker, Cloudflare workerd).
4
- *
5
- * Injected into the `@tanstack/devtools-event-client` module ONLY in non-client
6
- * (server) environments during dev. At module-eval time it gives the isolated
7
- * runtime a real `globalThis.__TANSTACK_EVENT_TARGET__` (so the unchanged
8
- * `EventClient` uses it instead of a throwaway target) and bridges that target to
9
- * the Vite dev process over the framework plugin's existing HMR HotChannel.
10
- *
11
- * Guards:
12
- * - `import.meta.hot` falsy (production / no HMR) -> tree-shaken / no-op.
13
- * - global target already set (in-process RunnableDevEnvironment, where
14
- * ServerEventBus lives) -> no-op, so existing behavior is unchanged.
15
- *
16
- * The bridge replicates ServerEventBus's in-process responsibilities so the
17
- * EventClient protocol is identical across the wire (see design doc).
18
- */
19
- function generateRuntimeBridgeCode() {
20
- return `
21
- ;(function __tsdRuntimeBridge() {
22
- if (typeof import.meta === 'undefined' || !import.meta.hot) return;
23
- if (!globalThis.__TANSTACK_EVENT_TARGET__) {
24
- var target = new EventTarget();
25
- globalThis.__TANSTACK_EVENT_TARGET__ = target;
26
-
27
- // Complete EventClient's connect handshake locally so queued events flush.
28
- target.addEventListener('tanstack-connect', function () {
29
- target.dispatchEvent(new CustomEvent('tanstack-connect-success'));
30
- });
31
-
32
- // Worker -> Vite dev server.
33
- target.addEventListener('tanstack-dispatch-event', function (e) {
34
- import.meta.hot.send('tsd:to-server', e.detail);
35
- });
36
-
37
- // Vite dev server -> worker listeners.
38
- import.meta.hot.on('tsd:to-client', function (event) {
39
- target.dispatchEvent(new CustomEvent(event.type, { detail: event }));
40
- target.dispatchEvent(new CustomEvent('tanstack-devtools-global', { detail: event }));
41
- });
42
- }
43
- })();
44
- `;
45
- }
46
- function isEventClientModule(id, code) {
47
- return (id.includes("devtools-event-client") || id.includes("event-bus-client")) && code.includes("EventClient");
48
- }
49
- function injectRuntimeBridge(code, id, environmentName) {
50
- if (!environmentName || environmentName === "client") return void 0;
51
- if (!isEventClientModule(id, code)) return void 0;
52
- return `${code}\n${generateRuntimeBridgeCode()}`;
53
- }
54
- function wireRuntimeBridgeChannels(server, getTarget) {
55
- const teardowns = [];
56
- for (const [name, env] of Object.entries(server.environments)) {
57
- if (name === "client") continue;
58
- const hot = env?.hot;
59
- if (!hot || typeof hot.on !== "function" || typeof hot.send !== "function") continue;
60
- const onToServer = (event) => {
61
- getTarget()?.dispatchEvent(new CustomEvent("tanstack-dispatch-event", { detail: event }));
62
- };
63
- hot.on("tsd:to-server", onToServer);
64
- teardowns.push(() => hot.off?.("tsd:to-server", onToServer));
65
- const target = getTarget();
66
- const forward = (e) => hot.send("tsd:to-client", e.detail);
67
- target?.addEventListener("tanstack-devtools-global", forward);
68
- teardowns.push(() => target?.removeEventListener("tanstack-devtools-global", forward));
69
- }
70
- return () => teardowns.forEach((off) => off());
71
- }
72
- //#endregion
73
- export { injectRuntimeBridge, wireRuntimeBridgeChannels };
74
-
75
- //# sourceMappingURL=runtime-bridge.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-bridge.js","names":[],"sources":["../../src/runtime-bridge.ts"],"sourcesContent":["/**\n * Worker-side bridge for isolated server runtimes (Nitro v3 worker, Cloudflare workerd).\n *\n * Injected into the `@tanstack/devtools-event-client` module ONLY in non-client\n * (server) environments during dev. At module-eval time it gives the isolated\n * runtime a real `globalThis.__TANSTACK_EVENT_TARGET__` (so the unchanged\n * `EventClient` uses it instead of a throwaway target) and bridges that target to\n * the Vite dev process over the framework plugin's existing HMR HotChannel.\n *\n * Guards:\n * - `import.meta.hot` falsy (production / no HMR) -> tree-shaken / no-op.\n * - global target already set (in-process RunnableDevEnvironment, where\n * ServerEventBus lives) -> no-op, so existing behavior is unchanged.\n *\n * The bridge replicates ServerEventBus's in-process responsibilities so the\n * EventClient protocol is identical across the wire (see design doc).\n */\nexport function generateRuntimeBridgeCode(): string {\n return `\n;(function __tsdRuntimeBridge() {\n if (typeof import.meta === 'undefined' || !import.meta.hot) return;\n if (!globalThis.__TANSTACK_EVENT_TARGET__) {\n var target = new EventTarget();\n globalThis.__TANSTACK_EVENT_TARGET__ = target;\n\n // Complete EventClient's connect handshake locally so queued events flush.\n target.addEventListener('tanstack-connect', function () {\n target.dispatchEvent(new CustomEvent('tanstack-connect-success'));\n });\n\n // Worker -> Vite dev server.\n target.addEventListener('tanstack-dispatch-event', function (e) {\n import.meta.hot.send('tsd:to-server', e.detail);\n });\n\n // Vite dev server -> worker listeners.\n import.meta.hot.on('tsd:to-client', function (event) {\n target.dispatchEvent(new CustomEvent(event.type, { detail: event }));\n target.dispatchEvent(new CustomEvent('tanstack-devtools-global', { detail: event }));\n });\n }\n})();\n`\n}\n\nfunction isEventClientModule(id: string, code: string): boolean {\n const isEventClientPath =\n id.includes('devtools-event-client') || id.includes('event-bus-client')\n // Only the module that actually defines the class — avoids re-export shims\n // and unrelated files inside the package.\n return isEventClientPath && code.includes('EventClient')\n}\n\nexport function injectRuntimeBridge(\n code: string,\n id: string,\n environmentName: string | undefined,\n): string | undefined {\n // Only isolated server environments need the bridge. The client environment\n // has `window`; the in-process RunnableDevEnvironment is handled by the\n // runtime global guard inside the injected code.\n if (!environmentName || environmentName === 'client') return undefined\n if (!isEventClientModule(id, code)) return undefined\n return `${code}\\n${generateRuntimeBridgeCode()}`\n}\n\ninterface BridgeHotChannel {\n on?: (event: string, cb: (data: any) => void) => void\n off?: (event: string, cb: (data: any) => void) => void\n send?: (event: string, data: any) => void\n}\ninterface BridgeServerLike {\n environments: Record<string, { hot?: BridgeHotChannel | null } | undefined>\n}\n\nexport function wireRuntimeBridgeChannels(\n server: BridgeServerLike,\n getTarget: () => EventTarget | null | undefined,\n): () => void {\n const teardowns: Array<() => void> = []\n\n for (const [name, env] of Object.entries(server.environments)) {\n if (name === 'client') continue\n const hot = env?.hot\n if (\n !hot ||\n typeof hot.on !== 'function' ||\n typeof hot.send !== 'function'\n ) {\n continue\n }\n\n // Worker -> ServerEventBus (broadcasts to browser + in-process listeners).\n const onToServer = (event: any) => {\n getTarget()?.dispatchEvent(\n new CustomEvent('tanstack-dispatch-event', { detail: event }),\n )\n }\n hot.on('tsd:to-server', onToServer)\n teardowns.push(() => hot.off?.('tsd:to-server', onToServer))\n\n // ServerEventBus output -> worker listeners.\n const target = getTarget()\n const forward = (e: Event) =>\n hot.send!('tsd:to-client', (e as CustomEvent).detail)\n target?.addEventListener('tanstack-devtools-global', forward)\n teardowns.push(() =>\n target?.removeEventListener('tanstack-devtools-global', forward),\n )\n }\n\n return () => teardowns.forEach((off) => off())\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAgB,4BAAoC;CAClD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BT,SAAS,oBAAoB,IAAY,MAAuB;CAK9D,QAHE,GAAG,SAAS,wBAAwB,IAAI,GAAG,SAAS,mBAAmB,KAG7C,KAAK,SAAS,cAAc;;AAG1D,SAAgB,oBACd,MACA,IACA,iBACoB;CAIpB,IAAI,CAAC,mBAAmB,oBAAoB,UAAU,OAAO,KAAA;CAC7D,IAAI,CAAC,oBAAoB,IAAI,KAAK,EAAE,OAAO,KAAA;CAC3C,OAAO,GAAG,KAAK,IAAI,2BAA2B;;AAYhD,SAAgB,0BACd,QACA,WACY;CACZ,MAAM,YAA+B,EAAE;CAEvC,KAAK,MAAM,CAAC,MAAM,QAAQ,OAAO,QAAQ,OAAO,aAAa,EAAE;EAC7D,IAAI,SAAS,UAAU;EACvB,MAAM,MAAM,KAAK;EACjB,IACE,CAAC,OACD,OAAO,IAAI,OAAO,cAClB,OAAO,IAAI,SAAS,YAEpB;EAIF,MAAM,cAAc,UAAe;GACjC,WAAW,EAAE,cACX,IAAI,YAAY,2BAA2B,EAAE,QAAQ,OAAO,CAAC,CAC9D;;EAEH,IAAI,GAAG,iBAAiB,WAAW;EACnC,UAAU,WAAW,IAAI,MAAM,iBAAiB,WAAW,CAAC;EAG5D,MAAM,SAAS,WAAW;EAC1B,MAAM,WAAW,MACf,IAAI,KAAM,iBAAkB,EAAkB,OAAO;EACvD,QAAQ,iBAAiB,4BAA4B,QAAQ;EAC7D,UAAU,WACR,QAAQ,oBAAoB,4BAA4B,QAAQ,CACjE;;CAGH,aAAa,UAAU,SAAS,QAAQ,KAAK,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,31 +0,0 @@
1
- import { Connect } from 'vite';
2
- import { IncomingMessage, ServerResponse } from 'node:http';
3
- import { PackageJson } from '@tanstack/devtools-client';
4
- type DevToolsRequestHandler = (data: any) => void;
5
- type DevToolsViteRequestOptions = {
6
- onOpenSource?: DevToolsRequestHandler;
7
- onConsolePipe?: (entries: Array<any>) => void;
8
- onServerConsolePipe?: (entries: Array<any>) => void;
9
- onConsolePipeSSE?: (res: ServerResponse<IncomingMessage>, req: Connect.IncomingMessage) => void;
10
- };
11
- export declare const handleDevToolsViteRequest: (req: Connect.IncomingMessage, res: ServerResponse<IncomingMessage>, next: Connect.NextFunction, cbOrOptions: DevToolsRequestHandler | DevToolsViteRequestOptions) => void;
12
- export declare const parseOpenSourceParam: (source: string) => {
13
- file: string | undefined;
14
- line: string | undefined;
15
- column: string | undefined;
16
- } | null;
17
- export declare const tryParseJson: <T extends any>(jsonString: string | null | undefined) => T | null;
18
- export declare const readPackageJson: () => Promise<PackageJson | null>;
19
- /**
20
- * Extracts and formats the source location from enhanced client console logs.
21
- * Instead of stripping the prefix entirely, we extract the file:line:column
22
- * from the "Go to Source" URL and use that as a prefix.
23
- *
24
- * Enhanced logs format (two variants):
25
- * 1. ['%cLOG%c %cGo to Source: http://...?source=%2Fsrc%2F...%c \n → ', 'color:...', 'color:...', 'color:...', 'color:...', 'message']
26
- * 2. ['\x1b[...]%s\x1b[...]', '%cLOG%c %cGo to Source: ...%c \n → ', 'color:...', 'color:...', 'color:...', 'color:...', 'message']
27
- *
28
- * Output: ['src/components/Header.tsx:26:13', 'message']
29
- */
30
- export declare const stripEnhancedLogPrefix: (args: Array<unknown>, formatSourceLocation?: (location: string) => unknown) => Array<unknown>;
31
- export {};
package/dist/esm/utils.js DELETED
@@ -1,155 +0,0 @@
1
- import { normalizePath } from "vite";
2
- import fs from "node:fs/promises";
3
- //#region src/utils.ts
4
- var handleDevToolsViteRequest = (req, res, next, cbOrOptions) => {
5
- const options = typeof cbOrOptions === "function" ? { onOpenSource: cbOrOptions } : cbOrOptions;
6
- if (req.url?.includes("__tsd/open-source")) {
7
- const source = new URLSearchParams(req.url.split("?")[1]).get("source");
8
- if (!source) return;
9
- const parsed = parseOpenSourceParam(source);
10
- if (!parsed) return;
11
- const { file, line, column } = parsed;
12
- options.onOpenSource?.({
13
- type: "open-source",
14
- routine: "open-source",
15
- data: {
16
- source: file ? normalizePath(`${process.cwd()}/${file}`) : void 0,
17
- line,
18
- column
19
- }
20
- });
21
- res.setHeader("Content-Type", "text/html");
22
- res.write(`<script> window.close(); <\/script>`);
23
- res.end();
24
- return;
25
- }
26
- if (req.url?.includes("__tsd/console-pipe/sse") && req.method === "GET") {
27
- if (options.onConsolePipeSSE) {
28
- options.onConsolePipeSSE(res, req);
29
- return;
30
- }
31
- return next();
32
- }
33
- if (req.url?.includes("__tsd/console-pipe/server") && req.method === "POST") {
34
- if (options.onServerConsolePipe) {
35
- let body = "";
36
- req.on("data", (chunk) => {
37
- body += chunk.toString();
38
- });
39
- req.on("end", () => {
40
- try {
41
- const { entries } = JSON.parse(body);
42
- options.onServerConsolePipe(entries);
43
- res.statusCode = 200;
44
- res.end("OK");
45
- } catch {
46
- res.statusCode = 400;
47
- res.end("Bad Request");
48
- }
49
- });
50
- return;
51
- }
52
- return next();
53
- }
54
- if (req.url?.includes("__tsd/console-pipe") && req.method === "POST") {
55
- if (options.onConsolePipe) {
56
- let body = "";
57
- req.on("data", (chunk) => {
58
- body += chunk.toString();
59
- });
60
- req.on("end", () => {
61
- try {
62
- const { entries } = JSON.parse(body);
63
- options.onConsolePipe(entries);
64
- res.statusCode = 200;
65
- res.end("OK");
66
- } catch {
67
- res.statusCode = 400;
68
- res.end("Bad Request");
69
- }
70
- });
71
- return;
72
- }
73
- return next();
74
- }
75
- if (!req.url?.includes("__tsd")) return next();
76
- const chunks = [];
77
- req.on("data", (chunk) => {
78
- chunks.push(chunk);
79
- });
80
- req.on("end", () => {
81
- const dataToParse = Buffer.concat(chunks);
82
- try {
83
- const parsedData = JSON.parse(dataToParse.toString());
84
- options.onOpenSource?.(parsedData);
85
- } catch (e) {}
86
- res.write("OK");
87
- res.end();
88
- });
89
- };
90
- var parseOpenSourceParam = (source) => {
91
- const parts = source.match(/^(.+):(\d+):(\d+)$/);
92
- if (!parts) return null;
93
- const [, file, line, column] = parts;
94
- return {
95
- file,
96
- line,
97
- column
98
- };
99
- };
100
- var tryReadFile = async (filePath) => {
101
- try {
102
- return await fs.readFile(filePath, "utf-8");
103
- } catch (error) {
104
- return null;
105
- }
106
- };
107
- var tryParseJson = (jsonString) => {
108
- if (!jsonString) return null;
109
- try {
110
- return JSON.parse(jsonString);
111
- } catch (error) {
112
- return null;
113
- }
114
- };
115
- var readPackageJson = async () => tryParseJson(await tryReadFile(process.cwd() + "/package.json"));
116
- /**
117
- * Extracts and formats the source location from enhanced client console logs.
118
- * Instead of stripping the prefix entirely, we extract the file:line:column
119
- * from the "Go to Source" URL and use that as a prefix.
120
- *
121
- * Enhanced logs format (two variants):
122
- * 1. ['%cLOG%c %cGo to Source: http://...?source=%2Fsrc%2F...%c \n → ', 'color:...', 'color:...', 'color:...', 'color:...', 'message']
123
- * 2. ['\x1b[...]%s\x1b[...]', '%cLOG%c %cGo to Source: ...%c \n → ', 'color:...', 'color:...', 'color:...', 'color:...', 'message']
124
- *
125
- * Output: ['src/components/Header.tsx:26:13', 'message']
126
- */
127
- var stripEnhancedLogPrefix = (args, formatSourceLocation) => {
128
- if (args.length === 0) return args;
129
- let sourceArgIndex = -1;
130
- for (let i = 0; i < args.length; i++) {
131
- const arg = args[i];
132
- if (typeof arg === "string" && arg.includes("__tsd/open-source?source=")) {
133
- sourceArgIndex = i;
134
- break;
135
- }
136
- }
137
- if (sourceArgIndex === -1) return args;
138
- const sourceArg = args[sourceArgIndex];
139
- let sourceLocation = "";
140
- const sourceMatch = sourceArg.match(/source=([^&\s]+?)%c/);
141
- if (sourceMatch?.[1]) try {
142
- sourceLocation = decodeURIComponent(sourceMatch[1]);
143
- if (sourceLocation.startsWith("/")) sourceLocation = sourceLocation.slice(1);
144
- } catch {}
145
- const styleCount = (sourceArg.match(/%c/g) || []).length;
146
- const userArgsStart = sourceArgIndex + 1 + styleCount;
147
- const result = [];
148
- if (sourceLocation) result.push(formatSourceLocation ? formatSourceLocation(sourceLocation) : sourceLocation);
149
- for (let i = userArgsStart; i < args.length; i++) result.push(args[i]);
150
- return result.length > 0 ? result : args;
151
- };
152
- //#endregion
153
- export { handleDevToolsViteRequest, readPackageJson, stripEnhancedLogPrefix, tryParseJson };
154
-
155
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import fs from 'node:fs/promises'\nimport { normalizePath } from 'vite'\nimport type { Connect } from 'vite'\nimport type { IncomingMessage, ServerResponse } from 'node:http'\nimport type { PackageJson } from '@tanstack/devtools-client'\n\ntype DevToolsRequestHandler = (data: any) => void\n\ntype DevToolsViteRequestOptions = {\n onOpenSource?: DevToolsRequestHandler\n onConsolePipe?: (entries: Array<any>) => void\n onServerConsolePipe?: (entries: Array<any>) => void\n onConsolePipeSSE?: (\n res: ServerResponse<IncomingMessage>,\n req: Connect.IncomingMessage,\n ) => void\n}\n\nexport const handleDevToolsViteRequest = (\n req: Connect.IncomingMessage,\n res: ServerResponse<IncomingMessage>,\n next: Connect.NextFunction,\n cbOrOptions: DevToolsRequestHandler | DevToolsViteRequestOptions,\n) => {\n // Normalize to options object for backward compatibility\n const options: DevToolsViteRequestOptions =\n typeof cbOrOptions === 'function'\n ? { onOpenSource: cbOrOptions }\n : cbOrOptions\n\n // Handle open-source requests\n if (req.url?.includes('__tsd/open-source')) {\n const searchParams = new URLSearchParams(req.url.split('?')[1])\n\n const source = searchParams.get('source')\n if (!source) {\n return\n }\n\n const parsed = parseOpenSourceParam(source)\n if (!parsed) {\n return\n }\n const { file, line, column } = parsed\n\n options.onOpenSource?.({\n type: 'open-source',\n routine: 'open-source',\n data: {\n source: file ? normalizePath(`${process.cwd()}/${file}`) : undefined,\n line,\n column,\n },\n })\n res.setHeader('Content-Type', 'text/html')\n res.write(`<script> window.close(); </script>`)\n res.end()\n return\n }\n\n // Handle console-pipe SSE endpoint (browser subscribes to server logs)\n if (req.url?.includes('__tsd/console-pipe/sse') && req.method === 'GET') {\n if (options.onConsolePipeSSE) {\n options.onConsolePipeSSE(res, req)\n return\n }\n return next()\n }\n\n // Handle server console-pipe POST endpoint (from app server runtime)\n if (req.url?.includes('__tsd/console-pipe/server') && req.method === 'POST') {\n if (options.onServerConsolePipe) {\n let body = ''\n req.on('data', (chunk: Buffer) => {\n body += chunk.toString()\n })\n req.on('end', () => {\n try {\n const { entries } = JSON.parse(body)\n options.onServerConsolePipe!(entries)\n res.statusCode = 200\n res.end('OK')\n } catch {\n res.statusCode = 400\n res.end('Bad Request')\n }\n })\n return\n }\n return next()\n }\n\n // Handle console-pipe POST endpoint (from client)\n if (req.url?.includes('__tsd/console-pipe') && req.method === 'POST') {\n if (options.onConsolePipe) {\n let body = ''\n req.on('data', (chunk: Buffer) => {\n body += chunk.toString()\n })\n req.on('end', () => {\n try {\n const { entries } = JSON.parse(body)\n options.onConsolePipe!(entries)\n res.statusCode = 200\n res.end('OK')\n } catch {\n res.statusCode = 400\n res.end('Bad Request')\n }\n })\n return\n }\n return next()\n }\n\n if (!req.url?.includes('__tsd')) {\n return next()\n }\n\n const chunks: Array<any> = []\n req.on('data', (chunk) => {\n chunks.push(chunk)\n })\n req.on('end', () => {\n const dataToParse = Buffer.concat(chunks)\n try {\n const parsedData = JSON.parse(dataToParse.toString())\n options.onOpenSource?.(parsedData)\n } catch (e) {}\n res.write('OK')\n res.end()\n })\n}\n\nexport const parseOpenSourceParam = (source: string) => {\n // Capture everything up to the last two colon-separated numeric parts as the file.\n // This supports filenames that may themselves contain colons.\n const parts = source.match(/^(.+):(\\d+):(\\d+)$/)\n\n if (!parts) return null\n\n const [, file, line, column] = parts\n return { file, line, column }\n}\n\nconst tryReadFile = async (filePath: string) => {\n try {\n const data = await fs.readFile(filePath, 'utf-8')\n return data\n } catch (error) {\n return null\n }\n}\n\nexport const tryParseJson = <T extends any>(\n jsonString: string | null | undefined,\n) => {\n if (!jsonString) {\n return null\n }\n try {\n const result = JSON.parse(jsonString)\n return result as T\n } catch (error) {\n return null\n }\n}\n\nexport const readPackageJson = async () =>\n tryParseJson<PackageJson>(await tryReadFile(process.cwd() + '/package.json'))\n\n/**\n * Extracts and formats the source location from enhanced client console logs.\n * Instead of stripping the prefix entirely, we extract the file:line:column\n * from the \"Go to Source\" URL and use that as a prefix.\n *\n * Enhanced logs format (two variants):\n * 1. ['%cLOG%c %cGo to Source: http://...?source=%2Fsrc%2F...%c \\n → ', 'color:...', 'color:...', 'color:...', 'color:...', 'message']\n * 2. ['\\x1b[...]%s\\x1b[...]', '%cLOG%c %cGo to Source: ...%c \\n → ', 'color:...', 'color:...', 'color:...', 'color:...', 'message']\n *\n * Output: ['src/components/Header.tsx:26:13', 'message']\n */\nexport const stripEnhancedLogPrefix = (\n args: Array<unknown>,\n formatSourceLocation?: (location: string) => unknown,\n): Array<unknown> => {\n if (args.length === 0) return args\n\n // Find the arg that contains the Go to Source URL\n let sourceArgIndex = -1\n for (let i = 0; i < args.length; i++) {\n const arg = args[i]\n if (typeof arg === 'string' && arg.includes('__tsd/open-source?source=')) {\n sourceArgIndex = i\n break\n }\n }\n\n // If no source URL found, return args as-is (not an enhanced log)\n if (sourceArgIndex === -1) {\n return args\n }\n\n const sourceArg = args[sourceArgIndex] as string\n\n // Extract the source from the \"Go to Source\" URL\n // URL format: http://localhost:3000/__tsd/open-source?source=%2Fsrc%2Ffile.tsx%3A26%3A13%c\n // Note: The URL ends with %c which is a console format specifier, not URL encoding\n let sourceLocation = ''\n const sourceMatch = sourceArg.match(/source=([^&\\s]+?)%c/)\n if (sourceMatch?.[1]) {\n try {\n sourceLocation = decodeURIComponent(sourceMatch[1])\n // Remove leading slash if present\n if (sourceLocation.startsWith('/')) {\n sourceLocation = sourceLocation.slice(1)\n }\n } catch {\n // If decoding fails, leave it empty\n }\n }\n\n // Count %c markers in the source arg to know how many style args follow it\n const styleCount = (sourceArg.match(/%c/g) || []).length\n\n // The actual user args start after the source arg and all its style args\n const userArgsStart = sourceArgIndex + 1 + styleCount\n\n // Build the result: source location prefix + remaining args (the actual user data)\n const result: Array<unknown> = []\n\n // Add source location as prefix if we found one\n if (sourceLocation) {\n result.push(\n formatSourceLocation\n ? formatSourceLocation(sourceLocation)\n : sourceLocation,\n )\n }\n\n // Add remaining args (the actual user data)\n for (let i = userArgsStart; i < args.length; i++) {\n result.push(args[i])\n }\n\n return result.length > 0 ? result : args\n}\n"],"mappings":";;;AAkBA,IAAa,6BACX,KACA,KACA,MACA,gBACG;CAEH,MAAM,UACJ,OAAO,gBAAgB,aACnB,EAAE,cAAc,aAAa,GAC7B;CAGN,IAAI,IAAI,KAAK,SAAS,oBAAoB,EAAE;EAG1C,MAAM,SAAS,IAFU,gBAAgB,IAAI,IAAI,MAAM,IAAI,CAAC,GAE7C,CAAa,IAAI,SAAS;EACzC,IAAI,CAAC,QACH;EAGF,MAAM,SAAS,qBAAqB,OAAO;EAC3C,IAAI,CAAC,QACH;EAEF,MAAM,EAAE,MAAM,MAAM,WAAW;EAE/B,QAAQ,eAAe;GACrB,MAAM;GACN,SAAS;GACT,MAAM;IACJ,QAAQ,OAAO,cAAc,GAAG,QAAQ,KAAK,CAAC,GAAG,OAAO,GAAG,KAAA;IAC3D;IACA;IACD;GACF,CAAC;EACF,IAAI,UAAU,gBAAgB,YAAY;EAC1C,IAAI,MAAM,sCAAqC;EAC/C,IAAI,KAAK;EACT;;CAIF,IAAI,IAAI,KAAK,SAAS,yBAAyB,IAAI,IAAI,WAAW,OAAO;EACvE,IAAI,QAAQ,kBAAkB;GAC5B,QAAQ,iBAAiB,KAAK,IAAI;GAClC;;EAEF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1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import { ConsoleLevel } from './plugin.js';
2
- /**
3
- * Generates inline code to inject into entry files (both client and server).
4
- * This code detects the environment at runtime and:
5
- *
6
- * CLIENT:
7
- * 1. Store original console methods
8
- * 2. Create batched wrappers that POST to server via fetch
9
- * 3. Override global console with the wrapped methods
10
- * 4. Listen for server console logs via SSE
11
- *
12
- * SERVER (Nitro/Vinxi runtime):
13
- * 1. Store original console methods
14
- * 2. Create batched wrappers that POST to Vite dev server
15
- * 3. Override global console - original logging still happens, just also pipes to Vite
16
- *
17
- * Returns the inline code as a string - no imports needed since we use fetch.
18
- */
19
- export declare function generateConsolePipeCode(levels: Array<ConsoleLevel>, viteServerUrl: string): string;