@tanstack/devtools-vite 0.6.0 → 0.6.1

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/esm/babel.js CHANGED
@@ -2,18 +2,10 @@ import { parse } from "@babel/parser";
2
2
  import * as t from "@babel/types";
3
3
  import generate from "@babel/generator";
4
4
  import traverse from "@babel/traverse";
5
- const trav = typeof traverse.default !== "undefined" ? (
6
- // eslint-disable-next-line @typescript-eslint/consistent-type-imports
7
- traverse.default
8
- ) : traverse;
9
- const gen = typeof generate.default !== "undefined" ? (
10
- // eslint-disable-next-line @typescript-eslint/consistent-type-imports
11
- generate.default
12
- ) : generate;
13
- export {
14
- gen,
15
- parse,
16
- t,
17
- trav
18
- };
19
- //# sourceMappingURL=babel.js.map
5
+ //#region src/babel.ts
6
+ var trav = typeof traverse.default !== "undefined" ? traverse.default : traverse;
7
+ var gen = typeof generate.default !== "undefined" ? generate.default : generate;
8
+ //#endregion
9
+ export { gen, parse, t, trav };
10
+
11
+ //# sourceMappingURL=babel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"babel.js","sources":["../../src/babel.ts"],"sourcesContent":["import { parse } from '@babel/parser'\nimport * as t from '@babel/types'\nimport generate from '@babel/generator'\nimport traverse from '@babel/traverse'\n\nexport { parse, t }\n\nexport const trav =\n typeof (traverse as any).default !== 'undefined'\n ? // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n ((traverse as any).default as typeof import('@babel/traverse').default)\n : traverse\n\nexport const gen =\n typeof (generate as any).default !== 'undefined'\n ? // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n ((generate as any).default as typeof import('@babel/generator').default)\n : generate\n"],"names":[],"mappings":";;;;AAOO,MAAM,OACX,OAAQ,SAAiB,YAAY;AAAA;AAAA,EAE/B,SAAiB;AAAA,IACnB;AAEC,MAAM,MACX,OAAQ,SAAiB,YAAY;AAAA;AAAA,EAE/B,SAAiB;AAAA,IACnB;"}
1
+ {"version":3,"file":"babel.js","names":[],"sources":["../../src/babel.ts"],"sourcesContent":["import { parse } from '@babel/parser'\nimport * as t from '@babel/types'\nimport generate from '@babel/generator'\nimport traverse from '@babel/traverse'\n\nexport { parse, t }\n\nexport const trav =\n typeof (traverse as any).default !== 'undefined'\n ? // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n ((traverse as any).default as typeof import('@babel/traverse').default)\n : traverse\n\nexport const gen =\n typeof (generate as any).default !== 'undefined'\n ? // eslint-disable-next-line @typescript-eslint/consistent-type-imports\n ((generate as any).default as typeof import('@babel/generator').default)\n : generate\n"],"mappings":";;;;;AAOA,IAAa,OACX,OAAQ,SAAiB,YAAY,cAE/B,SAAiB,UACnB;AAEN,IAAa,MACX,OAAQ,SAAiB,YAAY,cAE/B,SAAiB,UACnB"}
@@ -1,29 +1,20 @@
1
- const DEFAULT_EDITOR_CONFIG = {
2
- name: "VSCode",
3
- open: async (path, lineNumber, columnNumber) => {
4
- const launch = (await import("launch-editor")).default;
5
- launch(
6
- `${path.replaceAll("$", "\\$")}${lineNumber ? `:${lineNumber}` : ""}${columnNumber ? `:${columnNumber}` : ""}`,
7
- void 0,
8
- (filename, err) => {
9
- console.warn(`Failed to open ${filename} in editor: ${err}`);
10
- }
11
- );
12
- }
1
+ //#region src/editor.ts
2
+ var DEFAULT_EDITOR_CONFIG = {
3
+ name: "VSCode",
4
+ open: async (path, lineNumber, columnNumber) => {
5
+ const launch = (await import("launch-editor")).default;
6
+ launch(`${path.replaceAll("$", "\\$")}${lineNumber ? `:${lineNumber}` : ""}${columnNumber ? `:${columnNumber}` : ""}`, void 0, (filename, err) => {
7
+ console.warn(`Failed to open ${filename} in editor: ${err}`);
8
+ });
9
+ }
13
10
  };
14
- const handleOpenSource = async ({
15
- data,
16
- openInEditor
17
- }) => {
18
- const { source, line, column } = data.data;
19
- const lineNum = line ? `${line}` : void 0;
20
- const columnNum = column ? `${column}` : void 0;
21
- if (source) {
22
- return openInEditor(source, lineNum, columnNum);
23
- }
11
+ var handleOpenSource = async ({ data, openInEditor }) => {
12
+ const { source, line, column } = data.data;
13
+ const lineNum = line ? `${line}` : void 0;
14
+ const columnNum = column ? `${column}` : void 0;
15
+ if (source) return openInEditor(source, lineNum, columnNum);
24
16
  };
25
- export {
26
- DEFAULT_EDITOR_CONFIG,
27
- handleOpenSource
28
- };
29
- //# sourceMappingURL=editor.js.map
17
+ //#endregion
18
+ export { DEFAULT_EDITOR_CONFIG, handleOpenSource };
19
+
20
+ //# sourceMappingURL=editor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"editor.js","sources":["../../src/editor.ts"],"sourcesContent":["type OpenSourceData = {\n type: 'open-source'\n data: {\n /** The source file to open */\n source?: string\n /** The react router route ID, usually discovered via the hook useMatches */\n routeID?: string\n /** The line number in the source file */\n line?: number\n /** The column number in the source file */\n column?: number\n }\n}\n\nexport type EditorConfig = {\n /** The name of the editor, used for debugging purposes */\n name: string\n /** Callback to open a file in the editor */\n open: (\n path: string,\n lineNumber: string | undefined,\n columnNumber?: string,\n ) => Promise<void>\n}\n\nexport const DEFAULT_EDITOR_CONFIG: EditorConfig = {\n name: 'VSCode',\n open: async (path, lineNumber, columnNumber) => {\n const launch = (await import('launch-editor')).default\n launch(\n `${path.replaceAll('$', '\\\\$')}${lineNumber ? `:${lineNumber}` : ''}${columnNumber ? `:${columnNumber}` : ''}`,\n undefined,\n (filename, err) => {\n console.warn(`Failed to open ${filename} in editor: ${err}`)\n },\n )\n },\n}\n\nexport const handleOpenSource = async ({\n data,\n openInEditor,\n}: {\n data: OpenSourceData\n openInEditor: EditorConfig['open']\n}) => {\n const { source, line, column } = data.data\n const lineNum = line ? `${line}` : undefined\n const columnNum = column ? `${column}` : undefined\n if (source) {\n return openInEditor(source, lineNum, columnNum)\n }\n}\n"],"names":[],"mappings":"AAyBO,MAAM,wBAAsC;AAAA,EACjD,MAAM;AAAA,EACN,MAAM,OAAO,MAAM,YAAY,iBAAiB;AAC9C,UAAM,UAAU,MAAM,OAAO,eAAe,GAAG;AAC/C;AAAA,MACE,GAAG,KAAK,WAAW,KAAK,KAAK,CAAC,GAAG,aAAa,IAAI,UAAU,KAAK,EAAE,GAAG,eAAe,IAAI,YAAY,KAAK,EAAE;AAAA,MAC5G;AAAA,MACA,CAAC,UAAU,QAAQ;AACjB,gBAAQ,KAAK,kBAAkB,QAAQ,eAAe,GAAG,EAAE;AAAA,MAC7D;AAAA,IAAA;AAAA,EAEJ;AACF;AAEO,MAAM,mBAAmB,OAAO;AAAA,EACrC;AAAA,EACA;AACF,MAGM;AACJ,QAAM,EAAE,QAAQ,MAAM,OAAA,IAAW,KAAK;AACtC,QAAM,UAAU,OAAO,GAAG,IAAI,KAAK;AACnC,QAAM,YAAY,SAAS,GAAG,MAAM,KAAK;AACzC,MAAI,QAAQ;AACV,WAAO,aAAa,QAAQ,SAAS,SAAS;AAAA,EAChD;AACF;"}
1
+ {"version":3,"file":"editor.js","names":[],"sources":["../../src/editor.ts"],"sourcesContent":["type OpenSourceData = {\n type: 'open-source'\n data: {\n /** The source file to open */\n source?: string\n /** The react router route ID, usually discovered via the hook useMatches */\n routeID?: string\n /** The line number in the source file */\n line?: number\n /** The column number in the source file */\n column?: number\n }\n}\n\nexport type EditorConfig = {\n /** The name of the editor, used for debugging purposes */\n name: string\n /** Callback to open a file in the editor */\n open: (\n path: string,\n lineNumber: string | undefined,\n columnNumber?: string,\n ) => Promise<void>\n}\n\nexport const DEFAULT_EDITOR_CONFIG: EditorConfig = {\n name: 'VSCode',\n open: async (path, lineNumber, columnNumber) => {\n const launch = (await import('launch-editor')).default\n launch(\n `${path.replaceAll('$', '\\\\$')}${lineNumber ? `:${lineNumber}` : ''}${columnNumber ? `:${columnNumber}` : ''}`,\n undefined,\n (filename, err) => {\n console.warn(`Failed to open ${filename} in editor: ${err}`)\n },\n )\n },\n}\n\nexport const handleOpenSource = async ({\n data,\n openInEditor,\n}: {\n data: OpenSourceData\n openInEditor: EditorConfig['open']\n}) => {\n const { source, line, column } = data.data\n const lineNum = line ? `${line}` : undefined\n const columnNum = column ? `${column}` : undefined\n if (source) {\n return openInEditor(source, lineNum, columnNum)\n }\n}\n"],"mappings":";AAyBA,IAAa,wBAAsC;CACjD,MAAM;CACN,MAAM,OAAO,MAAM,YAAY,iBAAiB;EAC9C,MAAM,UAAU,MAAM,OAAO,kBAAkB;EAC/C,OACE,GAAG,KAAK,WAAW,KAAK,MAAM,GAAG,aAAa,IAAI,eAAe,KAAK,eAAe,IAAI,iBAAiB,MAC1G,KAAA,IACC,UAAU,QAAQ;GACjB,QAAQ,KAAK,kBAAkB,SAAS,cAAc,MAAM;IAE/D;;CAEJ;AAED,IAAa,mBAAmB,OAAO,EACrC,MACA,mBAII;CACJ,MAAM,EAAE,QAAQ,MAAM,WAAW,KAAK;CACtC,MAAM,UAAU,OAAO,GAAG,SAAS,KAAA;CACnC,MAAM,YAAY,SAAS,GAAG,WAAW,KAAA;CACzC,IAAI,QACF,OAAO,aAAa,QAAQ,SAAS,UAAU"}
@@ -1,84 +1,52 @@
1
- import chalk from "chalk";
1
+ import { gen, parse, t, trav } from "./babel.js";
2
2
  import { normalizePath } from "vite";
3
- import { gen, trav } from "./babel.js";
4
- import { parse } from "@babel/parser";
5
- import * as t from "@babel/types";
6
- const transform = (ast, filePath, port) => {
7
- let didTransform = false;
8
- trav(ast, {
9
- CallExpression(path) {
10
- const callee = path.node.callee;
11
- if (callee.type === "MemberExpression" && callee.object.type === "Identifier" && callee.object.name === "console" && callee.property.type === "Identifier" && (callee.property.name === "log" || callee.property.name === "error")) {
12
- const location = path.node.loc;
13
- if (!location) {
14
- return;
15
- }
16
- const [lineNumber, column] = [
17
- location.start.line,
18
- location.start.column
19
- ];
20
- const finalPath = `${filePath}:${lineNumber}:${column + 1}`;
21
- const logMessage = `${chalk.magenta("LOG")} ${chalk.blueBright(`${finalPath}`)}
22
- → `;
23
- const serverLogMessage = t.arrayExpression([
24
- t.stringLiteral(logMessage)
25
- ]);
26
- const browserLogMessage = t.arrayExpression([
27
- // LOG with css formatting specifiers: %c
28
- t.stringLiteral(
29
- `%c${"LOG"}%c %c${`Go to Source: http://localhost:${port}/__tsd/open-source?source=${encodeURIComponent(finalPath)}`}%c
30
- → `
31
- ),
32
- // magenta
33
- t.stringLiteral("color:#A0A"),
34
- t.stringLiteral("color:#FFF"),
35
- // blueBright
36
- t.stringLiteral("color:#55F"),
37
- t.stringLiteral("color:#FFF")
38
- ]);
39
- const checkServerCondition = t.binaryExpression(
40
- "===",
41
- t.unaryExpression("typeof", t.identifier("window")),
42
- t.stringLiteral("undefined")
43
- );
44
- path.node.arguments.unshift(
45
- t.spreadElement(
46
- t.conditionalExpression(
47
- checkServerCondition,
48
- serverLogMessage,
49
- browserLogMessage
50
- )
51
- )
52
- );
53
- didTransform = true;
54
- }
55
- }
56
- });
57
- return didTransform;
3
+ import chalk from "chalk";
4
+ //#region src/enhance-logs.ts
5
+ var transform = (ast, filePath, port) => {
6
+ let didTransform = false;
7
+ trav(ast, { CallExpression(path) {
8
+ const callee = path.node.callee;
9
+ if (callee.type === "MemberExpression" && callee.object.type === "Identifier" && callee.object.name === "console" && callee.property.type === "Identifier" && (callee.property.name === "log" || callee.property.name === "error")) {
10
+ const location = path.node.loc;
11
+ if (!location) return;
12
+ const [lineNumber, column] = [location.start.line, location.start.column];
13
+ const finalPath = `${filePath}:${lineNumber}:${column + 1}`;
14
+ const logMessage = `${chalk.magenta("LOG")} ${chalk.blueBright(`${finalPath}`)}\n → `;
15
+ const serverLogMessage = t.arrayExpression([t.stringLiteral(logMessage)]);
16
+ const browserLogMessage = t.arrayExpression([
17
+ t.stringLiteral(`%cLOG%c %c${`Go to Source: http://localhost:${port}/__tsd/open-source?source=${encodeURIComponent(finalPath)}`}%c \n → `),
18
+ t.stringLiteral("color:#A0A"),
19
+ t.stringLiteral("color:#FFF"),
20
+ t.stringLiteral("color:#55F"),
21
+ t.stringLiteral("color:#FFF")
22
+ ]);
23
+ const checkServerCondition = t.binaryExpression("===", t.unaryExpression("typeof", t.identifier("window")), t.stringLiteral("undefined"));
24
+ path.node.arguments.unshift(t.spreadElement(t.conditionalExpression(checkServerCondition, serverLogMessage, browserLogMessage)));
25
+ didTransform = true;
26
+ }
27
+ } });
28
+ return didTransform;
58
29
  };
59
30
  function enhanceConsoleLog(code, id, port) {
60
- const [filePath] = id.split("?");
61
- const location = filePath?.replace(normalizePath(process.cwd()), "");
62
- try {
63
- const ast = parse(code, {
64
- sourceType: "module",
65
- plugins: ["jsx", "typescript"]
66
- });
67
- const didTransform = transform(ast, location, port);
68
- if (!didTransform) {
69
- return;
70
- }
71
- return gen(ast, {
72
- sourceMaps: true,
73
- retainLines: true,
74
- filename: id,
75
- sourceFileName: filePath
76
- });
77
- } catch (e) {
78
- return;
79
- }
31
+ const [filePath] = id.split("?");
32
+ const location = filePath?.replace(normalizePath(process.cwd()), "");
33
+ try {
34
+ const ast = parse(code, {
35
+ sourceType: "module",
36
+ plugins: ["jsx", "typescript"]
37
+ });
38
+ if (!transform(ast, location, port)) return;
39
+ return gen(ast, {
40
+ sourceMaps: true,
41
+ retainLines: true,
42
+ filename: id,
43
+ sourceFileName: filePath
44
+ });
45
+ } catch (e) {
46
+ return;
47
+ }
80
48
  }
81
- export {
82
- enhanceConsoleLog
83
- };
84
- //# sourceMappingURL=enhance-logs.js.map
49
+ //#endregion
50
+ export { enhanceConsoleLog };
51
+
52
+ //# sourceMappingURL=enhance-logs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"enhance-logs.js","sources":["../../src/enhance-logs.ts"],"sourcesContent":["import chalk from 'chalk'\nimport { normalizePath } from 'vite'\nimport { gen, parse, t, trav } from './babel'\nimport type { types as Babel } from '@babel/core'\nimport type { ParseResult } from '@babel/parser'\n\nconst transform = (\n ast: ParseResult<Babel.File>,\n filePath: string,\n port: number,\n) => {\n let didTransform = false\n\n trav(ast, {\n CallExpression(path) {\n const callee = path.node.callee\n // Match console.log(...) or console.error(...)\n if (\n callee.type === 'MemberExpression' &&\n callee.object.type === 'Identifier' &&\n callee.object.name === 'console' &&\n callee.property.type === 'Identifier' &&\n (callee.property.name === 'log' || callee.property.name === 'error')\n ) {\n const location = path.node.loc\n if (!location) {\n return\n }\n const [lineNumber, column] = [\n location.start.line,\n location.start.column,\n ]\n const finalPath = `${filePath}:${lineNumber}:${column + 1}`\n const logMessage = `${chalk.magenta('LOG')} ${chalk.blueBright(`${finalPath}`)}\\n → `\n\n const serverLogMessage = t.arrayExpression([\n t.stringLiteral(logMessage),\n ])\n const browserLogMessage = t.arrayExpression([\n // LOG with css formatting specifiers: %c\n t.stringLiteral(\n `%c${'LOG'}%c %c${`Go to Source: http://localhost:${port}/__tsd/open-source?source=${encodeURIComponent(finalPath)}`}%c \\n → `,\n ),\n // magenta\n t.stringLiteral('color:#A0A'),\n t.stringLiteral('color:#FFF'),\n // blueBright\n t.stringLiteral('color:#55F'),\n t.stringLiteral('color:#FFF'),\n ])\n\n // typeof window === \"undefined\"\n const checkServerCondition = t.binaryExpression(\n '===',\n t.unaryExpression('typeof', t.identifier('window')),\n t.stringLiteral('undefined'),\n )\n\n // ...(isServer ? serverLogMessage : browserLogMessage)\n path.node.arguments.unshift(\n t.spreadElement(\n t.conditionalExpression(\n checkServerCondition,\n serverLogMessage,\n browserLogMessage,\n ),\n ),\n )\n\n didTransform = true\n }\n },\n })\n\n return didTransform\n}\n\nexport function enhanceConsoleLog(code: string, id: string, port: number) {\n const [filePath] = id.split('?')\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n const location = filePath?.replace(normalizePath(process.cwd()), '')!\n\n try {\n const ast = parse(code, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript'],\n })\n const didTransform = transform(ast, location, port)\n if (!didTransform) {\n return\n }\n return gen(ast, {\n sourceMaps: true,\n retainLines: true,\n filename: id,\n sourceFileName: filePath,\n })\n } catch (e) {\n return\n }\n}\n"],"names":[],"mappings":";;;;;AAMA,MAAM,YAAY,CAChB,KACA,UACA,SACG;AACH,MAAI,eAAe;AAEnB,OAAK,KAAK;AAAA,IACR,eAAe,MAAM;AACnB,YAAM,SAAS,KAAK,KAAK;AAEzB,UACE,OAAO,SAAS,sBAChB,OAAO,OAAO,SAAS,gBACvB,OAAO,OAAO,SAAS,aACvB,OAAO,SAAS,SAAS,iBACxB,OAAO,SAAS,SAAS,SAAS,OAAO,SAAS,SAAS,UAC5D;AACA,cAAM,WAAW,KAAK,KAAK;AAC3B,YAAI,CAAC,UAAU;AACb;AAAA,QACF;AACA,cAAM,CAAC,YAAY,MAAM,IAAI;AAAA,UAC3B,SAAS,MAAM;AAAA,UACf,SAAS,MAAM;AAAA,QAAA;AAEjB,cAAM,YAAY,GAAG,QAAQ,IAAI,UAAU,IAAI,SAAS,CAAC;AACzD,cAAM,aAAa,GAAG,MAAM,QAAQ,KAAK,CAAC,IAAI,MAAM,WAAW,GAAG,SAAS,EAAE,CAAC;AAAA;AAE9E,cAAM,mBAAmB,EAAE,gBAAgB;AAAA,UACzC,EAAE,cAAc,UAAU;AAAA,QAAA,CAC3B;AACD,cAAM,oBAAoB,EAAE,gBAAgB;AAAA;AAAA,UAE1C,EAAE;AAAA,YACA,KAAK,KAAK,QAAQ,kCAAkC,IAAI,6BAA6B,mBAAmB,SAAS,CAAC,EAAE;AAAA;AAAA,UAAA;AAAA;AAAA,UAGtH,EAAE,cAAc,YAAY;AAAA,UAC5B,EAAE,cAAc,YAAY;AAAA;AAAA,UAE5B,EAAE,cAAc,YAAY;AAAA,UAC5B,EAAE,cAAc,YAAY;AAAA,QAAA,CAC7B;AAGD,cAAM,uBAAuB,EAAE;AAAA,UAC7B;AAAA,UACA,EAAE,gBAAgB,UAAU,EAAE,WAAW,QAAQ,CAAC;AAAA,UAClD,EAAE,cAAc,WAAW;AAAA,QAAA;AAI7B,aAAK,KAAK,UAAU;AAAA,UAClB,EAAE;AAAA,YACA,EAAE;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YAAA;AAAA,UACF;AAAA,QACF;AAGF,uBAAe;AAAA,MACjB;AAAA,IACF;AAAA,EAAA,CACD;AAED,SAAO;AACT;AAEO,SAAS,kBAAkB,MAAc,IAAY,MAAc;AACxE,QAAM,CAAC,QAAQ,IAAI,GAAG,MAAM,GAAG;AAE/B,QAAM,WAAW,UAAU,QAAQ,cAAc,QAAQ,IAAA,CAAK,GAAG,EAAE;AAEnE,MAAI;AACF,UAAM,MAAM,MAAM,MAAM;AAAA,MACtB,YAAY;AAAA,MACZ,SAAS,CAAC,OAAO,YAAY;AAAA,IAAA,CAC9B;AACD,UAAM,eAAe,UAAU,KAAK,UAAU,IAAI;AAClD,QAAI,CAAC,cAAc;AACjB;AAAA,IACF;AACA,WAAO,IAAI,KAAK;AAAA,MACd,YAAY;AAAA,MACZ,aAAa;AAAA,MACb,UAAU;AAAA,MACV,gBAAgB;AAAA,IAAA,CACjB;AAAA,EACH,SAAS,GAAG;AACV;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"enhance-logs.js","names":[],"sources":["../../src/enhance-logs.ts"],"sourcesContent":["import chalk from 'chalk'\nimport { normalizePath } from 'vite'\nimport { gen, parse, t, trav } from './babel'\nimport type { types as Babel } from '@babel/core'\nimport type { ParseResult } from '@babel/parser'\n\nconst transform = (\n ast: ParseResult<Babel.File>,\n filePath: string,\n port: number,\n) => {\n let didTransform = false\n\n trav(ast, {\n CallExpression(path) {\n const callee = path.node.callee\n // Match console.log(...) or console.error(...)\n if (\n callee.type === 'MemberExpression' &&\n callee.object.type === 'Identifier' &&\n callee.object.name === 'console' &&\n callee.property.type === 'Identifier' &&\n (callee.property.name === 'log' || callee.property.name === 'error')\n ) {\n const location = path.node.loc\n if (!location) {\n return\n }\n const [lineNumber, column] = [\n location.start.line,\n location.start.column,\n ]\n const finalPath = `${filePath}:${lineNumber}:${column + 1}`\n const logMessage = `${chalk.magenta('LOG')} ${chalk.blueBright(`${finalPath}`)}\\n → `\n\n const serverLogMessage = t.arrayExpression([\n t.stringLiteral(logMessage),\n ])\n const browserLogMessage = t.arrayExpression([\n // LOG with css formatting specifiers: %c\n t.stringLiteral(\n `%c${'LOG'}%c %c${`Go to Source: http://localhost:${port}/__tsd/open-source?source=${encodeURIComponent(finalPath)}`}%c \\n → `,\n ),\n // magenta\n t.stringLiteral('color:#A0A'),\n t.stringLiteral('color:#FFF'),\n // blueBright\n t.stringLiteral('color:#55F'),\n t.stringLiteral('color:#FFF'),\n ])\n\n // typeof window === \"undefined\"\n const checkServerCondition = t.binaryExpression(\n '===',\n t.unaryExpression('typeof', t.identifier('window')),\n t.stringLiteral('undefined'),\n )\n\n // ...(isServer ? serverLogMessage : browserLogMessage)\n path.node.arguments.unshift(\n t.spreadElement(\n t.conditionalExpression(\n checkServerCondition,\n serverLogMessage,\n browserLogMessage,\n ),\n ),\n )\n\n didTransform = true\n }\n },\n })\n\n return didTransform\n}\n\nexport function enhanceConsoleLog(code: string, id: string, port: number) {\n const [filePath] = id.split('?')\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n const location = filePath?.replace(normalizePath(process.cwd()), '')!\n\n try {\n const ast = parse(code, {\n sourceType: 'module',\n plugins: ['jsx', 'typescript'],\n })\n const didTransform = transform(ast, location, port)\n if (!didTransform) {\n return\n }\n return gen(ast, {\n sourceMaps: true,\n retainLines: true,\n filename: id,\n sourceFileName: filePath,\n })\n } catch (e) {\n return\n }\n}\n"],"mappings":";;;;AAMA,IAAM,aACJ,KACA,UACA,SACG;CACH,IAAI,eAAe;CAEnB,KAAK,KAAK,EACR,eAAe,MAAM;EACnB,MAAM,SAAS,KAAK,KAAK;EAEzB,IACE,OAAO,SAAS,sBAChB,OAAO,OAAO,SAAS,gBACvB,OAAO,OAAO,SAAS,aACvB,OAAO,SAAS,SAAS,iBACxB,OAAO,SAAS,SAAS,SAAS,OAAO,SAAS,SAAS,UAC5D;GACA,MAAM,WAAW,KAAK,KAAK;GAC3B,IAAI,CAAC,UACH;GAEF,MAAM,CAAC,YAAY,UAAU,CAC3B,SAAS,MAAM,MACf,SAAS,MAAM,OAChB;GACD,MAAM,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS;GACxD,MAAM,aAAa,GAAG,MAAM,QAAQ,MAAM,CAAC,GAAG,MAAM,WAAW,GAAG,YAAY,CAAC;GAE/E,MAAM,mBAAmB,EAAE,gBAAgB,CACzC,EAAE,cAAc,WAAW,CAC5B,CAAC;GACF,MAAM,oBAAoB,EAAE,gBAAgB;IAE1C,EAAE,cACA,aAAkB,kCAAkC,KAAK,4BAA4B,mBAAmB,UAAU,GAAG,UACtH;IAED,EAAE,cAAc,aAAa;IAC7B,EAAE,cAAc,aAAa;IAE7B,EAAE,cAAc,aAAa;IAC7B,EAAE,cAAc,aAAa;IAC9B,CAAC;GAGF,MAAM,uBAAuB,EAAE,iBAC7B,OACA,EAAE,gBAAgB,UAAU,EAAE,WAAW,SAAS,CAAC,EACnD,EAAE,cAAc,YAAY,CAC7B;GAGD,KAAK,KAAK,UAAU,QAClB,EAAE,cACA,EAAE,sBACA,sBACA,kBACA,kBACD,CACF,CACF;GAED,eAAe;;IAGpB,CAAC;CAEF,OAAO;;AAGT,SAAgB,kBAAkB,MAAc,IAAY,MAAc;CACxE,MAAM,CAAC,YAAY,GAAG,MAAM,IAAI;CAEhC,MAAM,WAAW,UAAU,QAAQ,cAAc,QAAQ,KAAK,CAAC,EAAE,GAAG;CAEpE,IAAI;EACF,MAAM,MAAM,MAAM,MAAM;GACtB,YAAY;GACZ,SAAS,CAAC,OAAO,aAAa;GAC/B,CAAC;EAEF,IAAI,CADiB,UAAU,KAAK,UAAU,KACzC,EACH;EAEF,OAAO,IAAI,KAAK;GACd,YAAY;GACZ,aAAa;GACb,UAAU;GACV,gBAAgB;GACjB,CAAC;UACK,GAAG;EACV"}
package/dist/esm/index.js CHANGED
@@ -1,6 +1,2 @@
1
1
  import { defineDevtoolsConfig, devtools } from "./plugin.js";
2
- export {
3
- defineDevtoolsConfig,
4
- devtools
5
- };
6
- //# sourceMappingURL=index.js.map
2
+ export { defineDevtoolsConfig, devtools };