@mikuexe/annotator-effect 0.0.0-stage → 0.1.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/CHANGELOG.md +7 -0
- 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 +104 -3
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The element builders `h` carries in effect/ui 4.2: `Html.containerTags`,
|
|
3
|
+
* `Html.voidTags` and the SVG tags, where `text` is installed as `svgText`
|
|
4
|
+
* because `h.text` makes a text node (effect/ui/html/Html.ts, `makeTags`).
|
|
5
|
+
* Mirrored here because the plugin runs in Node and must not load effect's
|
|
6
|
+
* browser vocabulary; the peer range stays on 4.2.x so the list holds.
|
|
7
|
+
*/
|
|
8
|
+
const CONTAINER_TAGS = [
|
|
9
|
+
"a",
|
|
10
|
+
"abbr",
|
|
11
|
+
"address",
|
|
12
|
+
"article",
|
|
13
|
+
"aside",
|
|
14
|
+
"audio",
|
|
15
|
+
"b",
|
|
16
|
+
"bdi",
|
|
17
|
+
"bdo",
|
|
18
|
+
"blockquote",
|
|
19
|
+
"button",
|
|
20
|
+
"canvas",
|
|
21
|
+
"caption",
|
|
22
|
+
"cite",
|
|
23
|
+
"code",
|
|
24
|
+
"colgroup",
|
|
25
|
+
"data",
|
|
26
|
+
"datalist",
|
|
27
|
+
"dd",
|
|
28
|
+
"del",
|
|
29
|
+
"details",
|
|
30
|
+
"dfn",
|
|
31
|
+
"dialog",
|
|
32
|
+
"div",
|
|
33
|
+
"dl",
|
|
34
|
+
"dt",
|
|
35
|
+
"em",
|
|
36
|
+
"fieldset",
|
|
37
|
+
"figcaption",
|
|
38
|
+
"figure",
|
|
39
|
+
"footer",
|
|
40
|
+
"form",
|
|
41
|
+
"h1",
|
|
42
|
+
"h2",
|
|
43
|
+
"h3",
|
|
44
|
+
"h4",
|
|
45
|
+
"h5",
|
|
46
|
+
"h6",
|
|
47
|
+
"header",
|
|
48
|
+
"hgroup",
|
|
49
|
+
"i",
|
|
50
|
+
"iframe",
|
|
51
|
+
"ins",
|
|
52
|
+
"kbd",
|
|
53
|
+
"label",
|
|
54
|
+
"legend",
|
|
55
|
+
"li",
|
|
56
|
+
"main",
|
|
57
|
+
"mark",
|
|
58
|
+
"menu",
|
|
59
|
+
"meter",
|
|
60
|
+
"nav",
|
|
61
|
+
"ol",
|
|
62
|
+
"optgroup",
|
|
63
|
+
"option",
|
|
64
|
+
"output",
|
|
65
|
+
"p",
|
|
66
|
+
"picture",
|
|
67
|
+
"pre",
|
|
68
|
+
"progress",
|
|
69
|
+
"q",
|
|
70
|
+
"rp",
|
|
71
|
+
"rt",
|
|
72
|
+
"ruby",
|
|
73
|
+
"s",
|
|
74
|
+
"samp",
|
|
75
|
+
"search",
|
|
76
|
+
"section",
|
|
77
|
+
"select",
|
|
78
|
+
"slot",
|
|
79
|
+
"small",
|
|
80
|
+
"span",
|
|
81
|
+
"strong",
|
|
82
|
+
"sub",
|
|
83
|
+
"summary",
|
|
84
|
+
"sup",
|
|
85
|
+
"table",
|
|
86
|
+
"tbody",
|
|
87
|
+
"td",
|
|
88
|
+
"tfoot",
|
|
89
|
+
"th",
|
|
90
|
+
"thead",
|
|
91
|
+
"time",
|
|
92
|
+
"tr",
|
|
93
|
+
"u",
|
|
94
|
+
"ul",
|
|
95
|
+
"var",
|
|
96
|
+
"video",
|
|
97
|
+
];
|
|
98
|
+
const VOID_TAGS = [
|
|
99
|
+
"br",
|
|
100
|
+
"col",
|
|
101
|
+
"hr",
|
|
102
|
+
"img",
|
|
103
|
+
"input",
|
|
104
|
+
"source",
|
|
105
|
+
"textarea",
|
|
106
|
+
"track",
|
|
107
|
+
"wbr",
|
|
108
|
+
];
|
|
109
|
+
const SVG_TAGS = [
|
|
110
|
+
"svg",
|
|
111
|
+
"g",
|
|
112
|
+
"path",
|
|
113
|
+
"circle",
|
|
114
|
+
"ellipse",
|
|
115
|
+
"line",
|
|
116
|
+
"polyline",
|
|
117
|
+
"polygon",
|
|
118
|
+
"rect",
|
|
119
|
+
"svgText",
|
|
120
|
+
"tspan",
|
|
121
|
+
"textPath",
|
|
122
|
+
"defs",
|
|
123
|
+
"use",
|
|
124
|
+
"symbol",
|
|
125
|
+
"clipPath",
|
|
126
|
+
"mask",
|
|
127
|
+
"pattern",
|
|
128
|
+
"marker",
|
|
129
|
+
"linearGradient",
|
|
130
|
+
"radialGradient",
|
|
131
|
+
"stop",
|
|
132
|
+
"filter",
|
|
133
|
+
"image",
|
|
134
|
+
"foreignObject",
|
|
135
|
+
];
|
|
136
|
+
export const ELEMENT_TAGS = new Set([
|
|
137
|
+
...CONTAINER_TAGS,
|
|
138
|
+
...VOID_TAGS,
|
|
139
|
+
...SVG_TAGS,
|
|
140
|
+
]);
|
|
141
|
+
/** Type names that mark a parameter as an `h`: `Html.H<M>` and the `View` helper types. */
|
|
142
|
+
export const HELPER_TYPE_NAMES = new Set([
|
|
143
|
+
"H",
|
|
144
|
+
"Helper",
|
|
145
|
+
"HelperBase",
|
|
146
|
+
"WithTags",
|
|
147
|
+
]);
|
|
148
|
+
export function isEffectUiSource(source) {
|
|
149
|
+
return source === "effect/ui" || (source?.startsWith("effect/ui/") ?? false);
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../src/vite/tags.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,cAAc,GAAG;IACrB,GAAG;IACH,MAAM;IACN,SAAS;IACT,SAAS;IACT,OAAO;IACP,OAAO;IACP,GAAG;IACH,KAAK;IACL,KAAK;IACL,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,MAAM;IACN,MAAM;IACN,UAAU;IACV,MAAM;IACN,UAAU;IACV,IAAI;IACJ,KAAK;IACL,SAAS;IACT,KAAK;IACL,QAAQ;IACR,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,QAAQ;IACR,GAAG;IACH,QAAQ;IACR,KAAK;IACL,KAAK;IACL,OAAO;IACP,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,KAAK;IACL,IAAI;IACJ,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,GAAG;IACH,SAAS;IACT,KAAK;IACL,UAAU;IACV,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,GAAG;IACH,MAAM;IACN,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,KAAK;IACL,SAAS;IACT,KAAK;IACL,OAAO;IACP,OAAO;IACP,IAAI;IACJ,OAAO;IACP,IAAI;IACJ,OAAO;IACP,MAAM;IACN,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,KAAK;IACL,OAAO;CACR,CAAC;AAEF,MAAM,SAAS,GAAG;IAChB,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,OAAO;IACP,QAAQ;IACR,UAAU;IACV,OAAO;IACP,KAAK;CACN,CAAC;AAEF,MAAM,QAAQ,GAAG;IACf,KAAK;IACL,GAAG;IACH,MAAM;IACN,QAAQ;IACR,SAAS;IACT,MAAM;IACN,UAAU;IACV,SAAS;IACT,MAAM;IACN,SAAS;IACT,OAAO;IACP,UAAU;IACV,MAAM;IACN,KAAK;IACL,QAAQ;IACR,UAAU;IACV,MAAM;IACN,SAAS;IACT,QAAQ;IACR,gBAAgB;IAChB,gBAAgB;IAChB,MAAM;IACN,QAAQ;IACR,OAAO;IACP,eAAe;CAChB,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC;IACvD,GAAG,cAAc;IACjB,GAAG,SAAS;IACZ,GAAG,QAAQ;CACZ,CAAC,CAAC;AAEH,2FAA2F;AAC3F,MAAM,CAAC,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC;IAC5D,GAAG;IACH,QAAQ;IACR,YAAY;IACZ,UAAU;CACX,CAAC,CAAC;AAEH,MAAM,UAAU,gBAAgB,CAAC,MAA0B;IACzD,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SourceMapInput } from "@jridgewell/trace-mapping";
|
|
2
|
+
import type { SourceMap } from "magic-string";
|
|
3
|
+
import type { ModuleAnalysis } from "./analyze.js";
|
|
4
|
+
import type { AstNode } from "./ast.js";
|
|
5
|
+
export declare const TAG_HELPER = "__annotatorEffectTag";
|
|
6
|
+
export declare const CALL_HELPER = "__annotatorEffectCall";
|
|
7
|
+
export declare const REGISTER_HELPER = "__annotatorEffectRegister";
|
|
8
|
+
export type TransformModuleOptions = {
|
|
9
|
+
/** The module id, used as the source map's source. */
|
|
10
|
+
readonly id: string;
|
|
11
|
+
/** The path reported in locations, such as `src/App.ts`. */
|
|
12
|
+
readonly filePath: string;
|
|
13
|
+
readonly parse: (code: string) => AstNode;
|
|
14
|
+
/**
|
|
15
|
+
* The map from `code` back to the original file, when earlier transforms
|
|
16
|
+
* changed it. Locations are traced through it; without it they are read
|
|
17
|
+
* from `code` directly.
|
|
18
|
+
*/
|
|
19
|
+
readonly inputMap?: SourceMapInput | null;
|
|
20
|
+
};
|
|
21
|
+
export type TransformModuleResult = {
|
|
22
|
+
readonly code: string;
|
|
23
|
+
readonly map: SourceMap;
|
|
24
|
+
readonly analysis: ModuleAnalysis;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Adds source attributes to the element builders of one module and
|
|
28
|
+
* registers its component definitions. Returns `null` when the module has
|
|
29
|
+
* nothing to change.
|
|
30
|
+
*/
|
|
31
|
+
export declare function transformModule(code: string, options: TransformModuleOptions): TransformModuleResult | null;
|
|
32
|
+
type Position = {
|
|
33
|
+
readonly line: number;
|
|
34
|
+
readonly column: number;
|
|
35
|
+
};
|
|
36
|
+
/** Maps an offset in `code` to a 1-based line and column in the original file. */
|
|
37
|
+
export declare function createLocator(code: string, inputMap: SourceMapInput | null): (offset: number) => Position | null;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/vite/transform.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,E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0,0 +1,111 @@
|
|
|
1
|
+
import { GREATEST_LOWER_BOUND, originalPositionFor, TraceMap, } from "@jridgewell/trace-mapping";
|
|
2
|
+
import MagicString from "magic-string";
|
|
3
|
+
import { SOURCE_ATTRIBUTE, VIRTUAL_RUNTIME_ID } from "../constants.js";
|
|
4
|
+
import { analyzeModule } from "./analyze.js";
|
|
5
|
+
export const TAG_HELPER = "__annotatorEffectTag";
|
|
6
|
+
export const CALL_HELPER = "__annotatorEffectCall";
|
|
7
|
+
export const REGISTER_HELPER = "__annotatorEffectRegister";
|
|
8
|
+
/**
|
|
9
|
+
* Adds source attributes to the element builders of one module and
|
|
10
|
+
* registers its component definitions. Returns `null` when the module has
|
|
11
|
+
* nothing to change.
|
|
12
|
+
*/
|
|
13
|
+
export function transformModule(code, options) {
|
|
14
|
+
const analysis = analyzeModule(options.parse(code));
|
|
15
|
+
if (analysis.sites.length === 0 && analysis.definitions.length === 0) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const locate = createLocator(code, options.inputMap ?? null);
|
|
19
|
+
const output = new MagicString(code);
|
|
20
|
+
const attribute = JSON.stringify(SOURCE_ATTRIBUTE);
|
|
21
|
+
const used = { tag: false, call: false };
|
|
22
|
+
for (const site of analysis.sites) {
|
|
23
|
+
const position = locate(site.position);
|
|
24
|
+
if (!position) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const location = JSON.stringify(`${options.filePath}:${position.line}:${position.column}`);
|
|
28
|
+
switch (site.kind) {
|
|
29
|
+
case "chain":
|
|
30
|
+
case "el":
|
|
31
|
+
output.appendLeft(site.at, `.attr(${attribute}, ${location})`);
|
|
32
|
+
break;
|
|
33
|
+
case "call":
|
|
34
|
+
output.appendLeft(site.at, `.attr(${attribute}, ${location}).children`);
|
|
35
|
+
break;
|
|
36
|
+
case "value":
|
|
37
|
+
used.tag = true;
|
|
38
|
+
output.appendRight(site.start, `${TAG_HELPER}(`);
|
|
39
|
+
output.prependLeft(site.end, `, ${location})`);
|
|
40
|
+
break;
|
|
41
|
+
case "external":
|
|
42
|
+
used.call = true;
|
|
43
|
+
output.appendRight(site.start, `${CALL_HELPER}(`);
|
|
44
|
+
output.prependLeft(site.end, `, ${location})`);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const definitions = analysis.definitions.flatMap((definition) => {
|
|
49
|
+
const position = locate(definition.position);
|
|
50
|
+
return position
|
|
51
|
+
? [[definition.name, position.line, position.column]]
|
|
52
|
+
: [];
|
|
53
|
+
});
|
|
54
|
+
const imports = [
|
|
55
|
+
used.tag && `tag as ${TAG_HELPER}`,
|
|
56
|
+
used.call && `call as ${CALL_HELPER}`,
|
|
57
|
+
definitions.length > 0 && `register as ${REGISTER_HELPER}`,
|
|
58
|
+
].filter((entry) => typeof entry === "string");
|
|
59
|
+
if (imports.length > 0) {
|
|
60
|
+
output.append(`\nimport { ${imports.join(", ")} } from ${JSON.stringify(VIRTUAL_RUNTIME_ID)};\n`);
|
|
61
|
+
}
|
|
62
|
+
if (definitions.length > 0) {
|
|
63
|
+
output.append(`${REGISTER_HELPER}(${JSON.stringify(options.filePath)}, ${JSON.stringify(definitions)});\n`);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
code: output.toString(),
|
|
67
|
+
map: output.generateMap({
|
|
68
|
+
hires: "boundary",
|
|
69
|
+
source: options.id,
|
|
70
|
+
includeContent: true,
|
|
71
|
+
}),
|
|
72
|
+
analysis,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** Maps an offset in `code` to a 1-based line and column in the original file. */
|
|
76
|
+
export function createLocator(code, inputMap) {
|
|
77
|
+
const lineStarts = [0];
|
|
78
|
+
for (let index = 0; index < code.length; index++) {
|
|
79
|
+
if (code.charCodeAt(index) === 10) {
|
|
80
|
+
lineStarts.push(index + 1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const traced = inputMap ? new TraceMap(inputMap) : null;
|
|
84
|
+
return (offset) => {
|
|
85
|
+
let low = 0;
|
|
86
|
+
let high = lineStarts.length - 1;
|
|
87
|
+
while (low < high) {
|
|
88
|
+
const middle = (low + high + 1) >> 1;
|
|
89
|
+
if ((lineStarts[middle] ?? 0) <= offset) {
|
|
90
|
+
low = middle;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
high = middle - 1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const line = low + 1;
|
|
97
|
+
const column = offset - (lineStarts[low] ?? 0);
|
|
98
|
+
if (!traced) {
|
|
99
|
+
return { line, column: column + 1 };
|
|
100
|
+
}
|
|
101
|
+
const original = originalPositionFor(traced, {
|
|
102
|
+
line,
|
|
103
|
+
column,
|
|
104
|
+
bias: GREATEST_LOWER_BOUND,
|
|
105
|
+
});
|
|
106
|
+
return original.line === null || original.column === null
|
|
107
|
+
? null
|
|
108
|
+
: { line: original.line, column: original.column + 1 };
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/vite/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,QAAQ,GACT,MAAM,2BAA2B,CAAC;AAEnC,OAAO,WAAW,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC;AACjD,MAAM,CAAC,MAAM,WAAW,GAAG,uBAAuB,CAAC;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAsB3D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,OAA+B;IAE/B,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO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,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,MAAM,EAAE,CAAC;gBACxC,GAAG,GAAG,MAAM,CAAC;YACf,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,MAAM,GAAG,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QACD,MAAM,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC;QACrB,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QAE/C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,CAAC;QAED,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,EAAE;YAC3C,IAAI;YACJ,MAAM;YACN,IAAI,EAAE,oBAAoB;SAC3B,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC,MAAM,KAAK,IAAI;YACvD,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;IAC3D,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,107 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikuexe/annotator-effect",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Effect UI overlay for source-aware UI annotations copied into coding agents.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "mikuexe",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/benjaminmodayil/annotator-effect.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/benjaminmodayil/annotator-effect#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/benjaminmodayil/annotator-effect/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"effect",
|
|
18
|
+
"effect-ui",
|
|
19
|
+
"vite",
|
|
20
|
+
"annotations",
|
|
21
|
+
"developer-tools",
|
|
22
|
+
"source-map",
|
|
23
|
+
"ai-agents"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20.19"
|
|
27
|
+
},
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md",
|
|
32
|
+
"CHANGELOG.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/index.d.ts",
|
|
39
|
+
"default": "./dist/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./vite": {
|
|
42
|
+
"types": "./dist/vite/index.d.ts",
|
|
43
|
+
"default": "./dist/vite/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./package.json": "./package.json"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"access": "public"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"effect": "~4.2.0",
|
|
52
|
+
"vite": "^8.0.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"vite": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@jridgewell/trace-mapping": "0.3.31",
|
|
61
|
+
"magic-string": "1.4.5"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@changesets/cli": "3.1.0",
|
|
65
|
+
"@eslint/js": "10.0.1",
|
|
66
|
+
"@types/estree": "1.0.11",
|
|
67
|
+
"@types/node": "26.6.11",
|
|
68
|
+
"@vitest/eslint-plugin": "1.6.28",
|
|
69
|
+
"effect": "4.2.0",
|
|
70
|
+
"eslint": "10.16.0",
|
|
71
|
+
"eslint-config-prettier": "10.1.9",
|
|
72
|
+
"eslint-plugin-n": "18.6.0",
|
|
73
|
+
"eslint-plugin-no-secrets": "2.3.3",
|
|
74
|
+
"eslint-plugin-no-unsanitized": "4.1.5",
|
|
75
|
+
"eslint-plugin-perfectionist": "5.14.0",
|
|
76
|
+
"eslint-plugin-regexp": "3.3.3",
|
|
77
|
+
"eslint-plugin-security": "4.2.1",
|
|
78
|
+
"eslint-plugin-sonarjs": "4.2.3",
|
|
79
|
+
"eslint-plugin-unicorn": "80.0.0",
|
|
80
|
+
"globals": "17.15.0",
|
|
81
|
+
"happy-dom": "21.0.4",
|
|
82
|
+
"jsonc-eslint-parser": "3.3.2",
|
|
83
|
+
"prettier": "3.10.1",
|
|
84
|
+
"publint": "0.3.25",
|
|
85
|
+
"typescript": "6.0.3",
|
|
86
|
+
"typescript-eslint": "8.74.0",
|
|
87
|
+
"typescript-native": "npm:typescript@7.0.2",
|
|
88
|
+
"vite": "8.4.1",
|
|
89
|
+
"vitest": "5.1.2",
|
|
90
|
+
"yaml-eslint-parser": "2.1.0"
|
|
91
|
+
},
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build": "node scripts/clean-dist.mjs && node node_modules/typescript-native/bin/tsc -p tsconfig.build.json",
|
|
94
|
+
"changeset": "changeset",
|
|
95
|
+
"check:ci": "pnpm run test && pnpm run typecheck && pnpm run lint && pnpm run build && pnpm run example:build && pnpm run example:check-build && pnpm run package:check",
|
|
96
|
+
"example:build": "pnpm --dir examples/basic run build",
|
|
97
|
+
"example:check-build": "node scripts/check-example-build.mjs",
|
|
98
|
+
"example:dev": "pnpm --dir examples/basic run dev",
|
|
99
|
+
"format": "prettier --write .",
|
|
100
|
+
"lint": "eslint . --max-warnings=0 && prettier --check .",
|
|
101
|
+
"package:check": "publint",
|
|
102
|
+
"release": "pnpm run check:ci && changeset publish",
|
|
103
|
+
"test": "vitest run",
|
|
104
|
+
"typecheck": "node node_modules/typescript-native/bin/tsc --noEmit && node node_modules/typescript-native/bin/tsc --noEmit -p examples/basic",
|
|
105
|
+
"version-packages": "changeset version"
|
|
106
|
+
}
|
|
6
107
|
}
|