@mikuexe/annotator-effect 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +263 -2
- package/dist/annotator.d.ts +5 -0
- package/dist/annotator.d.ts.map +1 -0
- package/dist/annotator.js +152 -0
- package/dist/annotator.js.map +1 -0
- package/dist/capture.d.ts +27 -0
- package/dist/capture.d.ts.map +1 -0
- package/dist/capture.js +186 -0
- package/dist/capture.js.map +1 -0
- package/dist/clipboard.d.ts +5 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +35 -0
- package/dist/clipboard.js.map +1 -0
- package/dist/constants.d.ts +24 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +24 -0
- package/dist/constants.js.map +1 -0
- package/dist/format.d.ts +9 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +109 -0
- package/dist/format.js.map +1 -0
- package/dist/hotkey.d.ts +13 -0
- package/dist/hotkey.d.ts.map +1 -0
- package/dist/hotkey.js +54 -0
- package/dist/hotkey.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/overlay/machine.d.ts +132 -0
- package/dist/overlay/machine.d.ts.map +1 -0
- package/dist/overlay/machine.js +236 -0
- package/dist/overlay/machine.js.map +1 -0
- package/dist/overlay/overlay.d.ts +26 -0
- package/dist/overlay/overlay.d.ts.map +1 -0
- package/dist/overlay/overlay.js +748 -0
- package/dist/overlay/overlay.js.map +1 -0
- package/dist/overlay/styles.d.ts +8 -0
- package/dist/overlay/styles.d.ts.map +1 -0
- package/dist/overlay/styles.js +386 -0
- package/dist/overlay/styles.js.map +1 -0
- package/dist/runtime/agent.d.ts +37 -0
- package/dist/runtime/agent.d.ts.map +1 -0
- package/dist/runtime/agent.js +142 -0
- package/dist/runtime/agent.js.map +1 -0
- package/dist/runtime/paths.d.ts +13 -0
- package/dist/runtime/paths.d.ts.map +1 -0
- package/dist/runtime/paths.js +64 -0
- package/dist/runtime/paths.js.map +1 -0
- package/dist/types.d.ts +106 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vite/analyze.d.ts +41 -0
- package/dist/vite/analyze.d.ts.map +1 -0
- package/dist/vite/analyze.js +324 -0
- package/dist/vite/analyze.js.map +1 -0
- package/dist/vite/ast.d.ts +38 -0
- package/dist/vite/ast.d.ts.map +1 -0
- package/dist/vite/ast.js +105 -0
- package/dist/vite/ast.js.map +1 -0
- package/dist/vite/index.d.ts +5 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +3 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/vite/plugin.d.ts +34 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +181 -0
- package/dist/vite/plugin.js.map +1 -0
- package/dist/vite/scope.d.ts +39 -0
- package/dist/vite/scope.d.ts.map +1 -0
- package/dist/vite/scope.js +194 -0
- package/dist/vite/scope.js.map +1 -0
- package/dist/vite/tags.d.ts +5 -0
- package/dist/vite/tags.d.ts.map +1 -0
- package/dist/vite/tags.js +151 -0
- package/dist/vite/tags.js.map +1 -0
- package/dist/vite/transform.d.ts +39 -0
- package/dist/vite/transform.d.ts.map +1 -0
- package/dist/vite/transform.js +111 -0
- package/dist/vite/transform.js.map +1 -0
- package/package.json +107 -4
package/dist/vite/ast.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A minimal view of the ESTree (with TypeScript extensions) that Vite's
|
|
3
|
+
* parser returns, and a walker over it. Offsets are UTF-16 indexes into the
|
|
4
|
+
* parsed code.
|
|
5
|
+
*/
|
|
6
|
+
export function isNode(value) {
|
|
7
|
+
return (typeof value === "object" &&
|
|
8
|
+
value !== null &&
|
|
9
|
+
typeof value.type === "string" &&
|
|
10
|
+
typeof value.start === "number");
|
|
11
|
+
}
|
|
12
|
+
export function child(node, key) {
|
|
13
|
+
const value = node[key];
|
|
14
|
+
return isNode(value) ? value : null;
|
|
15
|
+
}
|
|
16
|
+
export function children(node, key) {
|
|
17
|
+
const value = node[key];
|
|
18
|
+
return Array.isArray(value) ? value.filter(isNode) : [];
|
|
19
|
+
}
|
|
20
|
+
export function nameOf(node) {
|
|
21
|
+
return node?.type === "Identifier" && typeof node.name === "string"
|
|
22
|
+
? node.name
|
|
23
|
+
: null;
|
|
24
|
+
}
|
|
25
|
+
/** The value of a string literal, or a template literal without expressions. */
|
|
26
|
+
export function stringValue(node) {
|
|
27
|
+
if (node?.type === "Literal" && typeof node.value === "string") {
|
|
28
|
+
return node.value;
|
|
29
|
+
}
|
|
30
|
+
if (node?.type === "TemplateLiteral" &&
|
|
31
|
+
children(node, "expressions").length === 0) {
|
|
32
|
+
const quasi = children(node, "quasis")[0];
|
|
33
|
+
const cooked = quasi?.value?.cooked;
|
|
34
|
+
return typeof cooked === "string" ? cooked : null;
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
/** Strips parentheses and TypeScript-only wrappers such as `as` and `satisfies`. */
|
|
39
|
+
export function unwrap(node) {
|
|
40
|
+
let current = node;
|
|
41
|
+
while (current &&
|
|
42
|
+
(current.type === "ParenthesizedExpression" ||
|
|
43
|
+
current.type === "TSAsExpression" ||
|
|
44
|
+
current.type === "TSSatisfiesExpression" ||
|
|
45
|
+
current.type === "TSNonNullExpression" ||
|
|
46
|
+
current.type === "TSTypeAssertion" ||
|
|
47
|
+
current.type === "TSInstantiationExpression")) {
|
|
48
|
+
current = child(current, "expression");
|
|
49
|
+
}
|
|
50
|
+
return current;
|
|
51
|
+
}
|
|
52
|
+
export const FUNCTION_TYPES = new Set([
|
|
53
|
+
"FunctionDeclaration",
|
|
54
|
+
"FunctionExpression",
|
|
55
|
+
"ArrowFunctionExpression",
|
|
56
|
+
]);
|
|
57
|
+
export function isFunction(node) {
|
|
58
|
+
return node !== null && FUNCTION_TYPES.has(node.type);
|
|
59
|
+
}
|
|
60
|
+
/** A function's parameters without a TypeScript `this` parameter. */
|
|
61
|
+
export function parametersOf(fn) {
|
|
62
|
+
return children(fn, "params").filter((param) => !(param.type === "Identifier" && param.name === "this"));
|
|
63
|
+
}
|
|
64
|
+
/** The plain identifier a parameter binds, through a default value or a TS parameter property. */
|
|
65
|
+
export function parameterIdentifier(param) {
|
|
66
|
+
if (param.type === "Identifier") {
|
|
67
|
+
return param;
|
|
68
|
+
}
|
|
69
|
+
if (param.type === "AssignmentPattern") {
|
|
70
|
+
const left = child(param, "left");
|
|
71
|
+
return left?.type === "Identifier" ? left : null;
|
|
72
|
+
}
|
|
73
|
+
if (param.type === "TSParameterProperty") {
|
|
74
|
+
const inner = child(param, "parameter");
|
|
75
|
+
return inner ? parameterIdentifier(inner) : null;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const SKIPPED_KEYS = new Set(["type", "start", "end", "range", "loc"]);
|
|
80
|
+
export function walk(root, visitor) {
|
|
81
|
+
const visit = (node, parent) => {
|
|
82
|
+
if (visitor.enter?.(node, parent) === false) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
for (const key of Object.keys(node)) {
|
|
86
|
+
if (SKIPPED_KEYS.has(key)) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const value = node[key];
|
|
90
|
+
if (Array.isArray(value)) {
|
|
91
|
+
for (const item of value) {
|
|
92
|
+
if (isNode(item)) {
|
|
93
|
+
visit(item, node);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else if (isNode(value)) {
|
|
98
|
+
visit(value, node);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
visitor.leave?.(node, parent);
|
|
102
|
+
};
|
|
103
|
+
visit(root, null);
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=ast.js.map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X,CAAC;YACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;YACxB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACzB,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;wBACjB,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBACpB,CAAC;gBACH,CAAC;YACH,CAAC;iBAAM,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzB,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACrB,CAAC;QACH,CAAC;QACD,OAAO,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC,CAAC;IAEF,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { annotatorEffect } from "./plugin.js";
|
|
2
|
+
export type { AnnotatorEffectPluginOptions } from "./plugin.js";
|
|
3
|
+
export { transformModule } from "./transform.js";
|
|
4
|
+
export type { TransformModuleOptions, TransformModuleResult, } from "./transform.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,YAAY,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EACV,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type { AnnotatorOutput, AnnotatorPosition } from "../types.js";
|
|
3
|
+
export type AnnotatorEffectPluginOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Injects the development client into each HTML page: it installs the
|
|
6
|
+
* effect/ui hook before the app mounts and shows the overlay. Default
|
|
7
|
+
* `true`. Pass `false` to set the annotator up in code with
|
|
8
|
+
* `Annotator.start` or `Annotator.layer`; source attributes and the
|
|
9
|
+
* component registry still apply.
|
|
10
|
+
*/
|
|
11
|
+
readonly overlay?: boolean;
|
|
12
|
+
/** Passed to the injected client. Default `"alt+a"`. */
|
|
13
|
+
readonly hotkey?: string;
|
|
14
|
+
/** Passed to the injected client. Default `"markdown"`. */
|
|
15
|
+
readonly output?: AnnotatorOutput;
|
|
16
|
+
/** Passed to the injected client. Default `"bottom-right"`. */
|
|
17
|
+
readonly position?: AnnotatorPosition;
|
|
18
|
+
/** Directory reported paths are relative to. Default: Vite's `root`. */
|
|
19
|
+
readonly sourceRoot?: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The development half of the annotator. In `vite dev` only, it
|
|
23
|
+
*
|
|
24
|
+
* - adds `data-effect-ui-source="<file>:<line>:<column>"` to element builders
|
|
25
|
+
* in view code (resolution layer B),
|
|
26
|
+
* - registers each component definition's location by component name
|
|
27
|
+
* (layer C),
|
|
28
|
+
* - injects a client that installs the effect/ui hook (layer A) and shows
|
|
29
|
+
* the overlay.
|
|
30
|
+
*
|
|
31
|
+
* Builds, previews and Vitest runs are left untouched.
|
|
32
|
+
*/
|
|
33
|
+
export declare function annotatorEffect(options?: AnnotatorEffectPluginOptions): Plugin;
|
|
34
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/vite/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AASnC,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAItE,MAAM,MAAM,4BAA4B,GAAG;IACzC;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAClC,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IACtC,wEAAwE;IACxE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAoDF;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,OAAO,GAAE,4BAAiC,GACzC,MAAM,CA0FR"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { relative, sep } from "node:path";
|
|
3
|
+
import { CLIENT_URL, DEV_CLIENT_KEY, REGISTRY_KEY, SOURCE_ATTRIBUTE, VIRTUAL_RUNTIME_ID, } from "../constants.js";
|
|
4
|
+
import { transformModule } from "./transform.js";
|
|
5
|
+
const PACKAGE_NAME = "@mikuexe/annotator-effect";
|
|
6
|
+
const RESOLVED_RUNTIME_ID = `\0${VIRTUAL_RUNTIME_ID}`;
|
|
7
|
+
const RESOLVED_CLIENT_ID = "\0@mikuexe/annotator-effect/client";
|
|
8
|
+
const SCRIPT_ID = /\.[cm]?[jt]sx?$/;
|
|
9
|
+
const NODE_MODULES = /[/\\]node_modules[/\\]/;
|
|
10
|
+
const runtimeModule = `import * as View from "effect/ui/View";
|
|
11
|
+
|
|
12
|
+
const ATTRIBUTE = ${JSON.stringify(SOURCE_ATTRIBUTE)};
|
|
13
|
+
const registryKey = Symbol.for(${JSON.stringify(REGISTRY_KEY.description)});
|
|
14
|
+
const registry = (globalThis[registryKey] ??= new Map());
|
|
15
|
+
|
|
16
|
+
export function register(file, definitions) {
|
|
17
|
+
registry.set(file, definitions);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function annotate(builder, location) {
|
|
21
|
+
const annotated = builder.attr(ATTRIBUTE, location);
|
|
22
|
+
return typeof builder === "function" ? View.shorthand(annotated) : annotated;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function tag(builder, location) {
|
|
26
|
+
return View.isElementBuilder(builder) ? annotate(builder, location) : builder;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function call(result, location) {
|
|
30
|
+
return View.isElementBuilder(result) && !Object.hasOwn(result.elementAttrs, ATTRIBUTE)
|
|
31
|
+
? annotate(result, location)
|
|
32
|
+
: result;
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
const clientModule = (options) => {
|
|
36
|
+
const settings = {};
|
|
37
|
+
if (options.hotkey) {
|
|
38
|
+
settings.hotkey = options.hotkey;
|
|
39
|
+
}
|
|
40
|
+
if (options.output) {
|
|
41
|
+
settings.output = options.output;
|
|
42
|
+
}
|
|
43
|
+
if (options.position) {
|
|
44
|
+
settings.position = options.position;
|
|
45
|
+
}
|
|
46
|
+
return `import { Annotator } from ${JSON.stringify(PACKAGE_NAME)};
|
|
47
|
+
|
|
48
|
+
globalThis[Symbol.for(${JSON.stringify(DEV_CLIENT_KEY.description)})] = true;
|
|
49
|
+
Annotator.start({ ...${JSON.stringify(settings)}, enabled: true });
|
|
50
|
+
`;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The development half of the annotator. In `vite dev` only, it
|
|
54
|
+
*
|
|
55
|
+
* - adds `data-effect-ui-source="<file>:<line>:<column>"` to element builders
|
|
56
|
+
* in view code (resolution layer B),
|
|
57
|
+
* - registers each component definition's location by component name
|
|
58
|
+
* (layer C),
|
|
59
|
+
* - injects a client that installs the effect/ui hook (layer A) and shows
|
|
60
|
+
* the overlay.
|
|
61
|
+
*
|
|
62
|
+
* Builds, previews and Vitest runs are left untouched.
|
|
63
|
+
*/
|
|
64
|
+
export function annotatorEffect(options = {}) {
|
|
65
|
+
const injectClient = options.overlay !== false;
|
|
66
|
+
let sourceRoot = options.sourceRoot ?? process.cwd();
|
|
67
|
+
let base = "/";
|
|
68
|
+
return {
|
|
69
|
+
name: PACKAGE_NAME,
|
|
70
|
+
enforce: "pre",
|
|
71
|
+
apply: (_config, env) => env.command === "serve" && env.isPreview !== true && !isVitest(),
|
|
72
|
+
// The injected client and the runtime helpers import these; listing
|
|
73
|
+
// them keeps Vite from finding them late and reloading the page. The
|
|
74
|
+
// annotator package itself is left to discovery, so a linked copy is
|
|
75
|
+
// never served from a stale prebundle.
|
|
76
|
+
config: () => ({
|
|
77
|
+
optimizeDeps: {
|
|
78
|
+
include: [
|
|
79
|
+
"effect/ui/View",
|
|
80
|
+
"effect/ui/MessageLog",
|
|
81
|
+
"effect/ui/html/BrowserHost",
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
configResolved: (config) => {
|
|
86
|
+
sourceRoot = options.sourceRoot ?? config.root;
|
|
87
|
+
base = config.base;
|
|
88
|
+
},
|
|
89
|
+
resolveId: (id) => {
|
|
90
|
+
if (id === VIRTUAL_RUNTIME_ID) {
|
|
91
|
+
return RESOLVED_RUNTIME_ID;
|
|
92
|
+
}
|
|
93
|
+
if (injectClient && id === CLIENT_URL) {
|
|
94
|
+
return RESOLVED_CLIENT_ID;
|
|
95
|
+
}
|
|
96
|
+
return undefined;
|
|
97
|
+
},
|
|
98
|
+
load: (id) => {
|
|
99
|
+
if (id === RESOLVED_RUNTIME_ID) {
|
|
100
|
+
return runtimeModule;
|
|
101
|
+
}
|
|
102
|
+
if (injectClient && id === RESOLVED_CLIENT_ID) {
|
|
103
|
+
return clientModule(options);
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
},
|
|
107
|
+
transform: {
|
|
108
|
+
filter: {
|
|
109
|
+
id: { include: SCRIPT_ID, exclude: NODE_MODULES },
|
|
110
|
+
code: "effect/ui",
|
|
111
|
+
},
|
|
112
|
+
handler(code, id) {
|
|
113
|
+
if (id.startsWith("\0") ||
|
|
114
|
+
id.includes("?") ||
|
|
115
|
+
!SCRIPT_ID.test(id) ||
|
|
116
|
+
NODE_MODULES.test(id)) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
return transformModule(code, {
|
|
121
|
+
id,
|
|
122
|
+
filePath: relative(sourceRoot, id).split(sep).join("/"),
|
|
123
|
+
parse: (source) => this.parse(source, {
|
|
124
|
+
lang: languageOf(id),
|
|
125
|
+
}),
|
|
126
|
+
inputMap: inputMapFor(code, id, () => this.getCombinedSourcemap()),
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
this.warn(`skipped source annotation for ${id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
transformIndexHtml: () => injectClient
|
|
136
|
+
? [
|
|
137
|
+
{
|
|
138
|
+
tag: "script",
|
|
139
|
+
// Vite prefixes the page's own URLs with `base`, not a plugin's tags.
|
|
140
|
+
attrs: { type: "module", src: base.slice(0, -1) + CLIENT_URL },
|
|
141
|
+
injectTo: "head-prepend",
|
|
142
|
+
},
|
|
143
|
+
]
|
|
144
|
+
: [],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
// Like @effect/ui-devtools, stay out of test runs: attributes would show up
|
|
148
|
+
// in every component snapshot.
|
|
149
|
+
function isVitest() {
|
|
150
|
+
// eslint-disable-next-line n/no-process-env -- Vitest announces itself only through the environment.
|
|
151
|
+
return "VITEST" in process.env;
|
|
152
|
+
}
|
|
153
|
+
function readSource(id) {
|
|
154
|
+
try {
|
|
155
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- reads the module Vite is transforming.
|
|
156
|
+
return readFileSync(id, "utf8");
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function languageOf(id) {
|
|
163
|
+
if (id.endsWith("x")) {
|
|
164
|
+
return /\.[cm]?tsx$/.test(id) ? "tsx" : "jsx";
|
|
165
|
+
}
|
|
166
|
+
return /\.[cm]?ts$/.test(id) ? "ts" : "js";
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The map back to the original file, or `null` when `code` is the file as
|
|
170
|
+
* written (the plugin runs before Vite's own transforms, so it usually is).
|
|
171
|
+
*/
|
|
172
|
+
function inputMapFor(code, id, combined) {
|
|
173
|
+
if (readSource(id) === code) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
const map = combined();
|
|
177
|
+
return map && typeof map.mappings === "string" && map.mappings !== ""
|
|
178
|
+
? map
|
|
179
|
+
: null;
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/vite/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAK1C,OAAO,EACL,UAAU,EACV,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAqBjD,MAAM,YAAY,GAAG,2BAA2B,CAAC;AACjD,MAAM,mBAAmB,GAAG,KAAK,kBAAkB,EAAE,CAAC;AACtD,MAAM,kBAAkB,GAAG,oCAAoC,CAAC;AAChE,MAA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qGAAqG;IACrG,OAAO,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC;AACjC,CAAC;AAED,SAAS,UAAU,CAAC,EAAU;IAC5B,IAAI,CAAC;QACH,6GAA6G;QAC7G,OAAO,YAAY,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,EAAU;IAC5B,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,OAAO,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IAChD,CAAC;IACD,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAClB,IAAY,EACZ,EAAU,EACV,QAAuB;IAEvB,IAAI,UAAU,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,GAAG,GAAG,QAAQ,EAAmC,CAAC;IACxD,OAAO,GAAG,IAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,EAAE;QACnE,CAAC,CAAE,GAAsB;QACzB,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AstNode } from "./ast.js";
|
|
2
|
+
export type BindingKind = "param" | "var" | "let" | "const" | "function" | "class" | "import" | "catch";
|
|
3
|
+
export type Binding = {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly kind: BindingKind;
|
|
6
|
+
/** The `VariableDeclarator` of a variable bound by a plain identifier. */
|
|
7
|
+
readonly declarator?: AstNode;
|
|
8
|
+
/** The declaration of a function binding. */
|
|
9
|
+
readonly fn?: AstNode;
|
|
10
|
+
/** The function and parameter index of a plain identifier parameter. */
|
|
11
|
+
readonly param?: {
|
|
12
|
+
readonly fn: AstNode;
|
|
13
|
+
readonly index: number;
|
|
14
|
+
};
|
|
15
|
+
readonly importSource?: string;
|
|
16
|
+
/** `"default"`, `"*"` or the exported name. */
|
|
17
|
+
readonly importedName?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare class Scope {
|
|
20
|
+
readonly parent: Scope | null;
|
|
21
|
+
readonly isFunctionScope: boolean;
|
|
22
|
+
readonly bindings: Map<string, Binding>;
|
|
23
|
+
constructor(parent: Scope | null, isFunctionScope: boolean);
|
|
24
|
+
declare(binding: Binding): void;
|
|
25
|
+
functionScope(): Scope;
|
|
26
|
+
lookup(name: string): Binding | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** The lexical scopes of a module, keyed by the node that opens each one. */
|
|
29
|
+
export type ScopeIndex = {
|
|
30
|
+
readonly module: Scope;
|
|
31
|
+
readonly scopeOf: ReadonlyMap<AstNode, Scope>;
|
|
32
|
+
};
|
|
33
|
+
export declare function analyzeScopes(program: AstNode): ScopeIndex;
|
|
34
|
+
/**
|
|
35
|
+
* Walks a module with its scope chain: `scope()` is the innermost scope
|
|
36
|
+
* around the node being visited.
|
|
37
|
+
*/
|
|
38
|
+
export declare function walkWithScope(program: AstNode, index: ScopeIndex, enter: (node: AstNode, parent: AstNode | null, scope: Scope) => void): void;
|
|
39
|
+
//# sourceMappingURL=scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../../src/vite/scope.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAYxC,MAAM,MAAM,WAAW,GACrB,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,OA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EACjB,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,GACnE,IAAI,CAgBN"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { child, children, isFunction, nameOf, parameterIdentifier, parametersOf, stringValue, walk, } from "./ast.js";
|
|
2
|
+
export class Scope {
|
|
3
|
+
parent;
|
|
4
|
+
isFunctionScope;
|
|
5
|
+
bindings = new Map();
|
|
6
|
+
constructor(parent, isFunctionScope) {
|
|
7
|
+
this.parent = parent;
|
|
8
|
+
this.isFunctionScope = isFunctionScope;
|
|
9
|
+
}
|
|
10
|
+
declare(binding) {
|
|
11
|
+
this.bindings.set(binding.name, binding);
|
|
12
|
+
}
|
|
13
|
+
functionScope() {
|
|
14
|
+
return this.isFunctionScope || !this.parent
|
|
15
|
+
? this
|
|
16
|
+
: this.parent.functionScope();
|
|
17
|
+
}
|
|
18
|
+
lookup(name) {
|
|
19
|
+
return this.bindings.get(name) ?? this.parent?.lookup(name);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const BLOCK_SCOPE_TYPES = new Set([
|
|
23
|
+
"BlockStatement",
|
|
24
|
+
"StaticBlock",
|
|
25
|
+
"SwitchStatement",
|
|
26
|
+
"ForStatement",
|
|
27
|
+
"ForInStatement",
|
|
28
|
+
"ForOfStatement",
|
|
29
|
+
"CatchClause",
|
|
30
|
+
"TSModuleBlock",
|
|
31
|
+
]);
|
|
32
|
+
export function analyzeScopes(program) {
|
|
33
|
+
const module = new Scope(null, true);
|
|
34
|
+
const scopeOf = new Map([[program, module]]);
|
|
35
|
+
const stack = [module];
|
|
36
|
+
const current = () => stack[stack.length - 1] ?? module;
|
|
37
|
+
walk(program, {
|
|
38
|
+
enter: (node) => {
|
|
39
|
+
if (node === program) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if (node.type === "ImportDeclaration") {
|
|
43
|
+
declareImports(module, node);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (node.type === "FunctionDeclaration") {
|
|
47
|
+
const name = nameOf(child(node, "id"));
|
|
48
|
+
if (name) {
|
|
49
|
+
current().declare({ name, kind: "function", fn: node });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (node.type === "ClassDeclaration") {
|
|
53
|
+
const name = nameOf(child(node, "id"));
|
|
54
|
+
if (name) {
|
|
55
|
+
current().declare({ name, kind: "class" });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (node.type === "VariableDeclaration") {
|
|
59
|
+
declareVariables(current(), node);
|
|
60
|
+
}
|
|
61
|
+
if (isFunction(node)) {
|
|
62
|
+
const scope = new Scope(current(), true);
|
|
63
|
+
scopeOf.set(node, scope);
|
|
64
|
+
stack.push(scope);
|
|
65
|
+
if (node.type === "FunctionExpression") {
|
|
66
|
+
const name = nameOf(child(node, "id"));
|
|
67
|
+
if (name) {
|
|
68
|
+
scope.declare({ name, kind: "function", fn: node });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
declareParameters(scope, node);
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (BLOCK_SCOPE_TYPES.has(node.type)) {
|
|
75
|
+
const scope = new Scope(current(), false);
|
|
76
|
+
scopeOf.set(node, scope);
|
|
77
|
+
stack.push(scope);
|
|
78
|
+
if (node.type === "CatchClause") {
|
|
79
|
+
const param = child(node, "param");
|
|
80
|
+
for (const name of patternNames(param)) {
|
|
81
|
+
scope.declare({ name, kind: "catch" });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
},
|
|
87
|
+
leave: (node) => {
|
|
88
|
+
if (node !== program && scopeOf.has(node)) {
|
|
89
|
+
stack.pop();
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
return { module, scopeOf };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Walks a module with its scope chain: `scope()` is the innermost scope
|
|
97
|
+
* around the node being visited.
|
|
98
|
+
*/
|
|
99
|
+
export function walkWithScope(program, index, enter) {
|
|
100
|
+
const stack = [];
|
|
101
|
+
walk(program, {
|
|
102
|
+
enter: (node, parent) => {
|
|
103
|
+
const opened = index.scopeOf.get(node);
|
|
104
|
+
if (opened) {
|
|
105
|
+
stack.push(opened);
|
|
106
|
+
}
|
|
107
|
+
enter(node, parent, stack[stack.length - 1] ?? index.module);
|
|
108
|
+
},
|
|
109
|
+
leave: (node) => {
|
|
110
|
+
if (index.scopeOf.has(node)) {
|
|
111
|
+
stack.pop();
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function declareImports(module, node) {
|
|
117
|
+
const source = stringValue(child(node, "source"));
|
|
118
|
+
if (source === null) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
for (const specifier of children(node, "specifiers")) {
|
|
122
|
+
const name = nameOf(child(specifier, "local"));
|
|
123
|
+
if (!name) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const importedName = specifier.type === "ImportNamespaceSpecifier"
|
|
127
|
+
? "*"
|
|
128
|
+
: specifier.type === "ImportDefaultSpecifier"
|
|
129
|
+
? "default"
|
|
130
|
+
: (nameOf(child(specifier, "imported")) ??
|
|
131
|
+
stringValue(child(specifier, "imported")) ??
|
|
132
|
+
name);
|
|
133
|
+
module.declare({
|
|
134
|
+
name,
|
|
135
|
+
kind: "import",
|
|
136
|
+
importSource: source,
|
|
137
|
+
importedName,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function declareVariables(scope, node) {
|
|
142
|
+
const kind = node.kind === "var" ? "var" : node.kind === "const" ? "const" : "let";
|
|
143
|
+
const target = kind === "var" ? scope.functionScope() : scope;
|
|
144
|
+
for (const declarator of children(node, "declarations")) {
|
|
145
|
+
const id = child(declarator, "id");
|
|
146
|
+
if (id?.type === "Identifier") {
|
|
147
|
+
const name = nameOf(id);
|
|
148
|
+
if (name) {
|
|
149
|
+
target.declare({ name, kind, declarator });
|
|
150
|
+
}
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
for (const name of patternNames(id)) {
|
|
154
|
+
target.declare({ name, kind });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function declareParameters(scope, fn) {
|
|
159
|
+
parametersOf(fn).forEach((param, index) => {
|
|
160
|
+
const identifier = parameterIdentifier(param);
|
|
161
|
+
const name = nameOf(identifier);
|
|
162
|
+
if (name) {
|
|
163
|
+
scope.declare({ name, kind: "param", param: { fn, index } });
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
for (const patternName of patternNames(param)) {
|
|
167
|
+
scope.declare({ name: patternName, kind: "param" });
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function patternNames(pattern) {
|
|
172
|
+
if (!pattern) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
switch (pattern.type) {
|
|
176
|
+
case "Identifier":
|
|
177
|
+
return [nameOf(pattern) ?? ""].filter(Boolean);
|
|
178
|
+
case "AssignmentPattern":
|
|
179
|
+
return patternNames(child(pattern, "left"));
|
|
180
|
+
case "RestElement":
|
|
181
|
+
return patternNames(child(pattern, "argument"));
|
|
182
|
+
case "TSParameterProperty":
|
|
183
|
+
return patternNames(child(pattern, "parameter"));
|
|
184
|
+
case "ArrayPattern":
|
|
185
|
+
return children(pattern, "elements").flatMap(patternNames);
|
|
186
|
+
case "ObjectPattern":
|
|
187
|
+
return children(pattern, "properties").flatMap((property) => property.type === "RestElement"
|
|
188
|
+
? patternNames(property)
|
|
189
|
+
: patternNames(child(property, "value")));
|
|
190
|
+
default:
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=scope.js.map
|
|
@@ -0,0 +1 @@
|
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,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;QAClD,KAAK,qBAAqB;YACxB,OAAO,YAAY,CAAC,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;QACnD,KAAK,cAAc;YACjB,OAAO,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC7D,KAAK,eAAe;YAClB,OAAO,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC1D,QAAQ,CAAC,IAAI,KAAK,aAAa;gBAC7B,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;gBACxB,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAC3C,CAAC;QACJ;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const ELEMENT_TAGS: ReadonlySet<string>;
|
|
2
|
+
/** Type names that mark a parameter as an `h`: `Html.H<M>` and the `View` helper types. */
|
|
3
|
+
export declare const HELPER_TYPE_NAMES: ReadonlySet<string>;
|
|
4
|
+
export declare function isEffectUiSource(source: string | undefined): boolean;
|
|
5
|
+
//# sourceMappingURL=tags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../src/vite/tags.ts"],"names":[],"mappings":"AA0IA,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,MAAM,CAI3C,CAAC;AAEH,2FAA2F;AAC3F,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAKhD,CAAC;AAEH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEpE"}
|