unplugin-atscript 0.1.75 → 0.1.76
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/esbuild.cjs +17 -4
- package/dist/esbuild.mjs +17 -4
- package/dist/farm.cjs +17 -4
- package/dist/farm.mjs +17 -4
- package/dist/index.cjs +17 -4
- package/dist/index.mjs +17 -4
- package/dist/rolldown.cjs +17 -4
- package/dist/rolldown.mjs +17 -4
- package/dist/rollup.cjs +17 -4
- package/dist/rollup.mjs +17 -4
- package/dist/rspack.cjs +17 -4
- package/dist/rspack.mjs +17 -4
- package/dist/vite.cjs +17 -4
- package/dist/vite.mjs +17 -4
- package/dist/webpack.cjs +17 -4
- package/dist/webpack.mjs +17 -4
- package/package.json +5 -3
package/dist/esbuild.cjs
CHANGED
|
@@ -29,6 +29,7 @@ const __atscript_core = __toESM(require("@atscript/core"));
|
|
|
29
29
|
const __atscript_typescript = __toESM(require("@atscript/typescript"));
|
|
30
30
|
|
|
31
31
|
//#region packages/unplugin/src/index.ts
|
|
32
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
32
33
|
const unpluginFactory = (opts) => {
|
|
33
34
|
const root = process.cwd();
|
|
34
35
|
const strict = opts?.strict ?? true;
|
|
@@ -43,18 +44,22 @@ const unpluginFactory = (opts) => {
|
|
|
43
44
|
resolveId(id, importer) {
|
|
44
45
|
if (importer && id.endsWith(".as")) {
|
|
45
46
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
46
|
-
|
|
47
|
+
const resolved = path.default.join(path.default.dirname(importer), id);
|
|
48
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
49
|
+
return resolved;
|
|
47
50
|
}
|
|
48
51
|
},
|
|
49
52
|
async load(id) {
|
|
50
|
-
|
|
53
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
55
|
+
if (sourceId.endsWith(".as")) {
|
|
51
56
|
if (!repo) {
|
|
52
57
|
const config = await getConfig();
|
|
53
58
|
if (!config.plugins) config.plugins = [(0, __atscript_typescript.tsPlugin)()];
|
|
54
59
|
repo = new __atscript_core.AtscriptRepo(root, config);
|
|
55
60
|
}
|
|
56
|
-
const code = (await (0, fs_promises.readFile)(
|
|
57
|
-
const doc = await repo.openDocument(`file://${
|
|
61
|
+
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
58
63
|
await repo.checkDoc(doc);
|
|
59
64
|
const messages = doc.getDiagMessages().reverse();
|
|
60
65
|
let error = "";
|
|
@@ -63,6 +68,14 @@ const unpluginFactory = (opts) => {
|
|
|
63
68
|
if (strict && !error) error = m.message;
|
|
64
69
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
65
70
|
if (error) throw new Error(error);
|
|
71
|
+
if (isDts) {
|
|
72
|
+
const out$1 = await doc.render("dts");
|
|
73
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
74
|
+
return {
|
|
75
|
+
code: content,
|
|
76
|
+
map: null
|
|
77
|
+
};
|
|
78
|
+
}
|
|
66
79
|
const out = await doc.render("js");
|
|
67
80
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, __atscript_core.isAnnotate)(n) && n.isMutating);
|
|
68
81
|
return {
|
package/dist/esbuild.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscri
|
|
|
5
5
|
import { tsPlugin } from "@atscript/typescript";
|
|
6
6
|
|
|
7
7
|
//#region packages/unplugin/src/index.ts
|
|
8
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
8
9
|
const unpluginFactory = (opts) => {
|
|
9
10
|
const root = process.cwd();
|
|
10
11
|
const strict = opts?.strict ?? true;
|
|
@@ -19,18 +20,22 @@ const unpluginFactory = (opts) => {
|
|
|
19
20
|
resolveId(id, importer) {
|
|
20
21
|
if (importer && id.endsWith(".as")) {
|
|
21
22
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
22
|
-
|
|
23
|
+
const resolved = path.join(path.dirname(importer), id);
|
|
24
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
25
|
+
return resolved;
|
|
23
26
|
}
|
|
24
27
|
},
|
|
25
28
|
async load(id) {
|
|
26
|
-
|
|
29
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
31
|
+
if (sourceId.endsWith(".as")) {
|
|
27
32
|
if (!repo) {
|
|
28
33
|
const config = await getConfig();
|
|
29
34
|
if (!config.plugins) config.plugins = [tsPlugin()];
|
|
30
35
|
repo = new AtscriptRepo(root, config);
|
|
31
36
|
}
|
|
32
|
-
const code = (await readFile(
|
|
33
|
-
const doc = await repo.openDocument(`file://${
|
|
37
|
+
const code = (await readFile(sourceId, "utf8")).toString();
|
|
38
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
34
39
|
await repo.checkDoc(doc);
|
|
35
40
|
const messages = doc.getDiagMessages().reverse();
|
|
36
41
|
let error = "";
|
|
@@ -39,6 +44,14 @@ const unpluginFactory = (opts) => {
|
|
|
39
44
|
if (strict && !error) error = m.message;
|
|
40
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
41
46
|
if (error) throw new Error(error);
|
|
47
|
+
if (isDts) {
|
|
48
|
+
const out$1 = await doc.render("dts");
|
|
49
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
50
|
+
return {
|
|
51
|
+
code: content,
|
|
52
|
+
map: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
42
55
|
const out = await doc.render("js");
|
|
43
56
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
44
57
|
return {
|
package/dist/farm.cjs
CHANGED
|
@@ -29,6 +29,7 @@ const __atscript_core = __toESM(require("@atscript/core"));
|
|
|
29
29
|
const __atscript_typescript = __toESM(require("@atscript/typescript"));
|
|
30
30
|
|
|
31
31
|
//#region packages/unplugin/src/index.ts
|
|
32
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
32
33
|
const unpluginFactory = (opts) => {
|
|
33
34
|
const root = process.cwd();
|
|
34
35
|
const strict = opts?.strict ?? true;
|
|
@@ -43,18 +44,22 @@ const unpluginFactory = (opts) => {
|
|
|
43
44
|
resolveId(id, importer) {
|
|
44
45
|
if (importer && id.endsWith(".as")) {
|
|
45
46
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
46
|
-
|
|
47
|
+
const resolved = path.default.join(path.default.dirname(importer), id);
|
|
48
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
49
|
+
return resolved;
|
|
47
50
|
}
|
|
48
51
|
},
|
|
49
52
|
async load(id) {
|
|
50
|
-
|
|
53
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
55
|
+
if (sourceId.endsWith(".as")) {
|
|
51
56
|
if (!repo) {
|
|
52
57
|
const config = await getConfig();
|
|
53
58
|
if (!config.plugins) config.plugins = [(0, __atscript_typescript.tsPlugin)()];
|
|
54
59
|
repo = new __atscript_core.AtscriptRepo(root, config);
|
|
55
60
|
}
|
|
56
|
-
const code = (await (0, fs_promises.readFile)(
|
|
57
|
-
const doc = await repo.openDocument(`file://${
|
|
61
|
+
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
58
63
|
await repo.checkDoc(doc);
|
|
59
64
|
const messages = doc.getDiagMessages().reverse();
|
|
60
65
|
let error = "";
|
|
@@ -63,6 +68,14 @@ const unpluginFactory = (opts) => {
|
|
|
63
68
|
if (strict && !error) error = m.message;
|
|
64
69
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
65
70
|
if (error) throw new Error(error);
|
|
71
|
+
if (isDts) {
|
|
72
|
+
const out$1 = await doc.render("dts");
|
|
73
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
74
|
+
return {
|
|
75
|
+
code: content,
|
|
76
|
+
map: null
|
|
77
|
+
};
|
|
78
|
+
}
|
|
66
79
|
const out = await doc.render("js");
|
|
67
80
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, __atscript_core.isAnnotate)(n) && n.isMutating);
|
|
68
81
|
return {
|
package/dist/farm.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscri
|
|
|
5
5
|
import { tsPlugin } from "@atscript/typescript";
|
|
6
6
|
|
|
7
7
|
//#region packages/unplugin/src/index.ts
|
|
8
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
8
9
|
const unpluginFactory = (opts) => {
|
|
9
10
|
const root = process.cwd();
|
|
10
11
|
const strict = opts?.strict ?? true;
|
|
@@ -19,18 +20,22 @@ const unpluginFactory = (opts) => {
|
|
|
19
20
|
resolveId(id, importer) {
|
|
20
21
|
if (importer && id.endsWith(".as")) {
|
|
21
22
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
22
|
-
|
|
23
|
+
const resolved = path.join(path.dirname(importer), id);
|
|
24
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
25
|
+
return resolved;
|
|
23
26
|
}
|
|
24
27
|
},
|
|
25
28
|
async load(id) {
|
|
26
|
-
|
|
29
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
31
|
+
if (sourceId.endsWith(".as")) {
|
|
27
32
|
if (!repo) {
|
|
28
33
|
const config = await getConfig();
|
|
29
34
|
if (!config.plugins) config.plugins = [tsPlugin()];
|
|
30
35
|
repo = new AtscriptRepo(root, config);
|
|
31
36
|
}
|
|
32
|
-
const code = (await readFile(
|
|
33
|
-
const doc = await repo.openDocument(`file://${
|
|
37
|
+
const code = (await readFile(sourceId, "utf8")).toString();
|
|
38
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
34
39
|
await repo.checkDoc(doc);
|
|
35
40
|
const messages = doc.getDiagMessages().reverse();
|
|
36
41
|
let error = "";
|
|
@@ -39,6 +44,14 @@ const unpluginFactory = (opts) => {
|
|
|
39
44
|
if (strict && !error) error = m.message;
|
|
40
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
41
46
|
if (error) throw new Error(error);
|
|
47
|
+
if (isDts) {
|
|
48
|
+
const out$1 = await doc.render("dts");
|
|
49
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
50
|
+
return {
|
|
51
|
+
code: content,
|
|
52
|
+
map: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
42
55
|
const out = await doc.render("js");
|
|
43
56
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
44
57
|
return {
|
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ const __atscript_typescript = __toESM(require("@atscript/typescript"));
|
|
|
30
30
|
const unplugin = __toESM(require("unplugin"));
|
|
31
31
|
|
|
32
32
|
//#region packages/unplugin/src/index.ts
|
|
33
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
33
34
|
const unpluginFactory = (opts) => {
|
|
34
35
|
const root = process.cwd();
|
|
35
36
|
const strict = opts?.strict ?? true;
|
|
@@ -44,18 +45,22 @@ const unpluginFactory = (opts) => {
|
|
|
44
45
|
resolveId(id, importer) {
|
|
45
46
|
if (importer && id.endsWith(".as")) {
|
|
46
47
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
47
|
-
|
|
48
|
+
const resolved = path.default.join(path.default.dirname(importer), id);
|
|
49
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
50
|
+
return resolved;
|
|
48
51
|
}
|
|
49
52
|
},
|
|
50
53
|
async load(id) {
|
|
51
|
-
|
|
54
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
55
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
56
|
+
if (sourceId.endsWith(".as")) {
|
|
52
57
|
if (!repo) {
|
|
53
58
|
const config = await getConfig();
|
|
54
59
|
if (!config.plugins) config.plugins = [(0, __atscript_typescript.tsPlugin)()];
|
|
55
60
|
repo = new __atscript_core.AtscriptRepo(root, config);
|
|
56
61
|
}
|
|
57
|
-
const code = (await (0, fs_promises.readFile)(
|
|
58
|
-
const doc = await repo.openDocument(`file://${
|
|
62
|
+
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
63
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
59
64
|
await repo.checkDoc(doc);
|
|
60
65
|
const messages = doc.getDiagMessages().reverse();
|
|
61
66
|
let error = "";
|
|
@@ -64,6 +69,14 @@ const unpluginFactory = (opts) => {
|
|
|
64
69
|
if (strict && !error) error = m.message;
|
|
65
70
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
66
71
|
if (error) throw new Error(error);
|
|
72
|
+
if (isDts) {
|
|
73
|
+
const out$1 = await doc.render("dts");
|
|
74
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
75
|
+
return {
|
|
76
|
+
code: content,
|
|
77
|
+
map: null
|
|
78
|
+
};
|
|
79
|
+
}
|
|
67
80
|
const out = await doc.render("js");
|
|
68
81
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, __atscript_core.isAnnotate)(n) && n.isMutating);
|
|
69
82
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { tsPlugin } from "@atscript/typescript";
|
|
|
5
5
|
import { createUnplugin } from "unplugin";
|
|
6
6
|
|
|
7
7
|
//#region packages/unplugin/src/index.ts
|
|
8
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
8
9
|
const unpluginFactory = (opts) => {
|
|
9
10
|
const root = process.cwd();
|
|
10
11
|
const strict = opts?.strict ?? true;
|
|
@@ -19,18 +20,22 @@ const unpluginFactory = (opts) => {
|
|
|
19
20
|
resolveId(id, importer) {
|
|
20
21
|
if (importer && id.endsWith(".as")) {
|
|
21
22
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
22
|
-
|
|
23
|
+
const resolved = path.join(path.dirname(importer), id);
|
|
24
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
25
|
+
return resolved;
|
|
23
26
|
}
|
|
24
27
|
},
|
|
25
28
|
async load(id) {
|
|
26
|
-
|
|
29
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
31
|
+
if (sourceId.endsWith(".as")) {
|
|
27
32
|
if (!repo) {
|
|
28
33
|
const config = await getConfig();
|
|
29
34
|
if (!config.plugins) config.plugins = [tsPlugin()];
|
|
30
35
|
repo = new AtscriptRepo(root, config);
|
|
31
36
|
}
|
|
32
|
-
const code = (await readFile(
|
|
33
|
-
const doc = await repo.openDocument(`file://${
|
|
37
|
+
const code = (await readFile(sourceId, "utf8")).toString();
|
|
38
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
34
39
|
await repo.checkDoc(doc);
|
|
35
40
|
const messages = doc.getDiagMessages().reverse();
|
|
36
41
|
let error = "";
|
|
@@ -39,6 +44,14 @@ const unpluginFactory = (opts) => {
|
|
|
39
44
|
if (strict && !error) error = m.message;
|
|
40
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
41
46
|
if (error) throw new Error(error);
|
|
47
|
+
if (isDts) {
|
|
48
|
+
const out$1 = await doc.render("dts");
|
|
49
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
50
|
+
return {
|
|
51
|
+
code: content,
|
|
52
|
+
map: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
42
55
|
const out = await doc.render("js");
|
|
43
56
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
44
57
|
return {
|
package/dist/rolldown.cjs
CHANGED
|
@@ -29,6 +29,7 @@ const __atscript_core = __toESM(require("@atscript/core"));
|
|
|
29
29
|
const __atscript_typescript = __toESM(require("@atscript/typescript"));
|
|
30
30
|
|
|
31
31
|
//#region packages/unplugin/src/index.ts
|
|
32
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
32
33
|
const unpluginFactory = (opts) => {
|
|
33
34
|
const root = process.cwd();
|
|
34
35
|
const strict = opts?.strict ?? true;
|
|
@@ -43,18 +44,22 @@ const unpluginFactory = (opts) => {
|
|
|
43
44
|
resolveId(id, importer) {
|
|
44
45
|
if (importer && id.endsWith(".as")) {
|
|
45
46
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
46
|
-
|
|
47
|
+
const resolved = path.default.join(path.default.dirname(importer), id);
|
|
48
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
49
|
+
return resolved;
|
|
47
50
|
}
|
|
48
51
|
},
|
|
49
52
|
async load(id) {
|
|
50
|
-
|
|
53
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
55
|
+
if (sourceId.endsWith(".as")) {
|
|
51
56
|
if (!repo) {
|
|
52
57
|
const config = await getConfig();
|
|
53
58
|
if (!config.plugins) config.plugins = [(0, __atscript_typescript.tsPlugin)()];
|
|
54
59
|
repo = new __atscript_core.AtscriptRepo(root, config);
|
|
55
60
|
}
|
|
56
|
-
const code = (await (0, fs_promises.readFile)(
|
|
57
|
-
const doc = await repo.openDocument(`file://${
|
|
61
|
+
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
58
63
|
await repo.checkDoc(doc);
|
|
59
64
|
const messages = doc.getDiagMessages().reverse();
|
|
60
65
|
let error = "";
|
|
@@ -63,6 +68,14 @@ const unpluginFactory = (opts) => {
|
|
|
63
68
|
if (strict && !error) error = m.message;
|
|
64
69
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
65
70
|
if (error) throw new Error(error);
|
|
71
|
+
if (isDts) {
|
|
72
|
+
const out$1 = await doc.render("dts");
|
|
73
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
74
|
+
return {
|
|
75
|
+
code: content,
|
|
76
|
+
map: null
|
|
77
|
+
};
|
|
78
|
+
}
|
|
66
79
|
const out = await doc.render("js");
|
|
67
80
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, __atscript_core.isAnnotate)(n) && n.isMutating);
|
|
68
81
|
return {
|
package/dist/rolldown.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscri
|
|
|
5
5
|
import { tsPlugin } from "@atscript/typescript";
|
|
6
6
|
|
|
7
7
|
//#region packages/unplugin/src/index.ts
|
|
8
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
8
9
|
const unpluginFactory = (opts) => {
|
|
9
10
|
const root = process.cwd();
|
|
10
11
|
const strict = opts?.strict ?? true;
|
|
@@ -19,18 +20,22 @@ const unpluginFactory = (opts) => {
|
|
|
19
20
|
resolveId(id, importer) {
|
|
20
21
|
if (importer && id.endsWith(".as")) {
|
|
21
22
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
22
|
-
|
|
23
|
+
const resolved = path.join(path.dirname(importer), id);
|
|
24
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
25
|
+
return resolved;
|
|
23
26
|
}
|
|
24
27
|
},
|
|
25
28
|
async load(id) {
|
|
26
|
-
|
|
29
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
31
|
+
if (sourceId.endsWith(".as")) {
|
|
27
32
|
if (!repo) {
|
|
28
33
|
const config = await getConfig();
|
|
29
34
|
if (!config.plugins) config.plugins = [tsPlugin()];
|
|
30
35
|
repo = new AtscriptRepo(root, config);
|
|
31
36
|
}
|
|
32
|
-
const code = (await readFile(
|
|
33
|
-
const doc = await repo.openDocument(`file://${
|
|
37
|
+
const code = (await readFile(sourceId, "utf8")).toString();
|
|
38
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
34
39
|
await repo.checkDoc(doc);
|
|
35
40
|
const messages = doc.getDiagMessages().reverse();
|
|
36
41
|
let error = "";
|
|
@@ -39,6 +44,14 @@ const unpluginFactory = (opts) => {
|
|
|
39
44
|
if (strict && !error) error = m.message;
|
|
40
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
41
46
|
if (error) throw new Error(error);
|
|
47
|
+
if (isDts) {
|
|
48
|
+
const out$1 = await doc.render("dts");
|
|
49
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
50
|
+
return {
|
|
51
|
+
code: content,
|
|
52
|
+
map: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
42
55
|
const out = await doc.render("js");
|
|
43
56
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
44
57
|
return {
|
package/dist/rollup.cjs
CHANGED
|
@@ -29,6 +29,7 @@ const __atscript_core = __toESM(require("@atscript/core"));
|
|
|
29
29
|
const __atscript_typescript = __toESM(require("@atscript/typescript"));
|
|
30
30
|
|
|
31
31
|
//#region packages/unplugin/src/index.ts
|
|
32
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
32
33
|
const unpluginFactory = (opts) => {
|
|
33
34
|
const root = process.cwd();
|
|
34
35
|
const strict = opts?.strict ?? true;
|
|
@@ -43,18 +44,22 @@ const unpluginFactory = (opts) => {
|
|
|
43
44
|
resolveId(id, importer) {
|
|
44
45
|
if (importer && id.endsWith(".as")) {
|
|
45
46
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
46
|
-
|
|
47
|
+
const resolved = path.default.join(path.default.dirname(importer), id);
|
|
48
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
49
|
+
return resolved;
|
|
47
50
|
}
|
|
48
51
|
},
|
|
49
52
|
async load(id) {
|
|
50
|
-
|
|
53
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
55
|
+
if (sourceId.endsWith(".as")) {
|
|
51
56
|
if (!repo) {
|
|
52
57
|
const config = await getConfig();
|
|
53
58
|
if (!config.plugins) config.plugins = [(0, __atscript_typescript.tsPlugin)()];
|
|
54
59
|
repo = new __atscript_core.AtscriptRepo(root, config);
|
|
55
60
|
}
|
|
56
|
-
const code = (await (0, fs_promises.readFile)(
|
|
57
|
-
const doc = await repo.openDocument(`file://${
|
|
61
|
+
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
58
63
|
await repo.checkDoc(doc);
|
|
59
64
|
const messages = doc.getDiagMessages().reverse();
|
|
60
65
|
let error = "";
|
|
@@ -63,6 +68,14 @@ const unpluginFactory = (opts) => {
|
|
|
63
68
|
if (strict && !error) error = m.message;
|
|
64
69
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
65
70
|
if (error) throw new Error(error);
|
|
71
|
+
if (isDts) {
|
|
72
|
+
const out$1 = await doc.render("dts");
|
|
73
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
74
|
+
return {
|
|
75
|
+
code: content,
|
|
76
|
+
map: null
|
|
77
|
+
};
|
|
78
|
+
}
|
|
66
79
|
const out = await doc.render("js");
|
|
67
80
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, __atscript_core.isAnnotate)(n) && n.isMutating);
|
|
68
81
|
return {
|
package/dist/rollup.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscri
|
|
|
5
5
|
import { tsPlugin } from "@atscript/typescript";
|
|
6
6
|
|
|
7
7
|
//#region packages/unplugin/src/index.ts
|
|
8
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
8
9
|
const unpluginFactory = (opts) => {
|
|
9
10
|
const root = process.cwd();
|
|
10
11
|
const strict = opts?.strict ?? true;
|
|
@@ -19,18 +20,22 @@ const unpluginFactory = (opts) => {
|
|
|
19
20
|
resolveId(id, importer) {
|
|
20
21
|
if (importer && id.endsWith(".as")) {
|
|
21
22
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
22
|
-
|
|
23
|
+
const resolved = path.join(path.dirname(importer), id);
|
|
24
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
25
|
+
return resolved;
|
|
23
26
|
}
|
|
24
27
|
},
|
|
25
28
|
async load(id) {
|
|
26
|
-
|
|
29
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
31
|
+
if (sourceId.endsWith(".as")) {
|
|
27
32
|
if (!repo) {
|
|
28
33
|
const config = await getConfig();
|
|
29
34
|
if (!config.plugins) config.plugins = [tsPlugin()];
|
|
30
35
|
repo = new AtscriptRepo(root, config);
|
|
31
36
|
}
|
|
32
|
-
const code = (await readFile(
|
|
33
|
-
const doc = await repo.openDocument(`file://${
|
|
37
|
+
const code = (await readFile(sourceId, "utf8")).toString();
|
|
38
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
34
39
|
await repo.checkDoc(doc);
|
|
35
40
|
const messages = doc.getDiagMessages().reverse();
|
|
36
41
|
let error = "";
|
|
@@ -39,6 +44,14 @@ const unpluginFactory = (opts) => {
|
|
|
39
44
|
if (strict && !error) error = m.message;
|
|
40
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
41
46
|
if (error) throw new Error(error);
|
|
47
|
+
if (isDts) {
|
|
48
|
+
const out$1 = await doc.render("dts");
|
|
49
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
50
|
+
return {
|
|
51
|
+
code: content,
|
|
52
|
+
map: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
42
55
|
const out = await doc.render("js");
|
|
43
56
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
44
57
|
return {
|
package/dist/rspack.cjs
CHANGED
|
@@ -29,6 +29,7 @@ const __atscript_core = __toESM(require("@atscript/core"));
|
|
|
29
29
|
const __atscript_typescript = __toESM(require("@atscript/typescript"));
|
|
30
30
|
|
|
31
31
|
//#region packages/unplugin/src/index.ts
|
|
32
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
32
33
|
const unpluginFactory = (opts) => {
|
|
33
34
|
const root = process.cwd();
|
|
34
35
|
const strict = opts?.strict ?? true;
|
|
@@ -43,18 +44,22 @@ const unpluginFactory = (opts) => {
|
|
|
43
44
|
resolveId(id, importer) {
|
|
44
45
|
if (importer && id.endsWith(".as")) {
|
|
45
46
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
46
|
-
|
|
47
|
+
const resolved = path.default.join(path.default.dirname(importer), id);
|
|
48
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
49
|
+
return resolved;
|
|
47
50
|
}
|
|
48
51
|
},
|
|
49
52
|
async load(id) {
|
|
50
|
-
|
|
53
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
55
|
+
if (sourceId.endsWith(".as")) {
|
|
51
56
|
if (!repo) {
|
|
52
57
|
const config = await getConfig();
|
|
53
58
|
if (!config.plugins) config.plugins = [(0, __atscript_typescript.tsPlugin)()];
|
|
54
59
|
repo = new __atscript_core.AtscriptRepo(root, config);
|
|
55
60
|
}
|
|
56
|
-
const code = (await (0, fs_promises.readFile)(
|
|
57
|
-
const doc = await repo.openDocument(`file://${
|
|
61
|
+
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
58
63
|
await repo.checkDoc(doc);
|
|
59
64
|
const messages = doc.getDiagMessages().reverse();
|
|
60
65
|
let error = "";
|
|
@@ -63,6 +68,14 @@ const unpluginFactory = (opts) => {
|
|
|
63
68
|
if (strict && !error) error = m.message;
|
|
64
69
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
65
70
|
if (error) throw new Error(error);
|
|
71
|
+
if (isDts) {
|
|
72
|
+
const out$1 = await doc.render("dts");
|
|
73
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
74
|
+
return {
|
|
75
|
+
code: content,
|
|
76
|
+
map: null
|
|
77
|
+
};
|
|
78
|
+
}
|
|
66
79
|
const out = await doc.render("js");
|
|
67
80
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, __atscript_core.isAnnotate)(n) && n.isMutating);
|
|
68
81
|
return {
|
package/dist/rspack.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscri
|
|
|
5
5
|
import { tsPlugin } from "@atscript/typescript";
|
|
6
6
|
|
|
7
7
|
//#region packages/unplugin/src/index.ts
|
|
8
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
8
9
|
const unpluginFactory = (opts) => {
|
|
9
10
|
const root = process.cwd();
|
|
10
11
|
const strict = opts?.strict ?? true;
|
|
@@ -19,18 +20,22 @@ const unpluginFactory = (opts) => {
|
|
|
19
20
|
resolveId(id, importer) {
|
|
20
21
|
if (importer && id.endsWith(".as")) {
|
|
21
22
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
22
|
-
|
|
23
|
+
const resolved = path.join(path.dirname(importer), id);
|
|
24
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
25
|
+
return resolved;
|
|
23
26
|
}
|
|
24
27
|
},
|
|
25
28
|
async load(id) {
|
|
26
|
-
|
|
29
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
31
|
+
if (sourceId.endsWith(".as")) {
|
|
27
32
|
if (!repo) {
|
|
28
33
|
const config = await getConfig();
|
|
29
34
|
if (!config.plugins) config.plugins = [tsPlugin()];
|
|
30
35
|
repo = new AtscriptRepo(root, config);
|
|
31
36
|
}
|
|
32
|
-
const code = (await readFile(
|
|
33
|
-
const doc = await repo.openDocument(`file://${
|
|
37
|
+
const code = (await readFile(sourceId, "utf8")).toString();
|
|
38
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
34
39
|
await repo.checkDoc(doc);
|
|
35
40
|
const messages = doc.getDiagMessages().reverse();
|
|
36
41
|
let error = "";
|
|
@@ -39,6 +44,14 @@ const unpluginFactory = (opts) => {
|
|
|
39
44
|
if (strict && !error) error = m.message;
|
|
40
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
41
46
|
if (error) throw new Error(error);
|
|
47
|
+
if (isDts) {
|
|
48
|
+
const out$1 = await doc.render("dts");
|
|
49
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
50
|
+
return {
|
|
51
|
+
code: content,
|
|
52
|
+
map: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
42
55
|
const out = await doc.render("js");
|
|
43
56
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
44
57
|
return {
|
package/dist/vite.cjs
CHANGED
|
@@ -29,6 +29,7 @@ const __atscript_core = __toESM(require("@atscript/core"));
|
|
|
29
29
|
const __atscript_typescript = __toESM(require("@atscript/typescript"));
|
|
30
30
|
|
|
31
31
|
//#region packages/unplugin/src/index.ts
|
|
32
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
32
33
|
const unpluginFactory = (opts) => {
|
|
33
34
|
const root = process.cwd();
|
|
34
35
|
const strict = opts?.strict ?? true;
|
|
@@ -43,18 +44,22 @@ const unpluginFactory = (opts) => {
|
|
|
43
44
|
resolveId(id, importer) {
|
|
44
45
|
if (importer && id.endsWith(".as")) {
|
|
45
46
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
46
|
-
|
|
47
|
+
const resolved = path.default.join(path.default.dirname(importer), id);
|
|
48
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
49
|
+
return resolved;
|
|
47
50
|
}
|
|
48
51
|
},
|
|
49
52
|
async load(id) {
|
|
50
|
-
|
|
53
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
55
|
+
if (sourceId.endsWith(".as")) {
|
|
51
56
|
if (!repo) {
|
|
52
57
|
const config = await getConfig();
|
|
53
58
|
if (!config.plugins) config.plugins = [(0, __atscript_typescript.tsPlugin)()];
|
|
54
59
|
repo = new __atscript_core.AtscriptRepo(root, config);
|
|
55
60
|
}
|
|
56
|
-
const code = (await (0, fs_promises.readFile)(
|
|
57
|
-
const doc = await repo.openDocument(`file://${
|
|
61
|
+
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
58
63
|
await repo.checkDoc(doc);
|
|
59
64
|
const messages = doc.getDiagMessages().reverse();
|
|
60
65
|
let error = "";
|
|
@@ -63,6 +68,14 @@ const unpluginFactory = (opts) => {
|
|
|
63
68
|
if (strict && !error) error = m.message;
|
|
64
69
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
65
70
|
if (error) throw new Error(error);
|
|
71
|
+
if (isDts) {
|
|
72
|
+
const out$1 = await doc.render("dts");
|
|
73
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
74
|
+
return {
|
|
75
|
+
code: content,
|
|
76
|
+
map: null
|
|
77
|
+
};
|
|
78
|
+
}
|
|
66
79
|
const out = await doc.render("js");
|
|
67
80
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, __atscript_core.isAnnotate)(n) && n.isMutating);
|
|
68
81
|
return {
|
package/dist/vite.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscri
|
|
|
5
5
|
import { tsPlugin } from "@atscript/typescript";
|
|
6
6
|
|
|
7
7
|
//#region packages/unplugin/src/index.ts
|
|
8
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
8
9
|
const unpluginFactory = (opts) => {
|
|
9
10
|
const root = process.cwd();
|
|
10
11
|
const strict = opts?.strict ?? true;
|
|
@@ -19,18 +20,22 @@ const unpluginFactory = (opts) => {
|
|
|
19
20
|
resolveId(id, importer) {
|
|
20
21
|
if (importer && id.endsWith(".as")) {
|
|
21
22
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
22
|
-
|
|
23
|
+
const resolved = path.join(path.dirname(importer), id);
|
|
24
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
25
|
+
return resolved;
|
|
23
26
|
}
|
|
24
27
|
},
|
|
25
28
|
async load(id) {
|
|
26
|
-
|
|
29
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
31
|
+
if (sourceId.endsWith(".as")) {
|
|
27
32
|
if (!repo) {
|
|
28
33
|
const config = await getConfig();
|
|
29
34
|
if (!config.plugins) config.plugins = [tsPlugin()];
|
|
30
35
|
repo = new AtscriptRepo(root, config);
|
|
31
36
|
}
|
|
32
|
-
const code = (await readFile(
|
|
33
|
-
const doc = await repo.openDocument(`file://${
|
|
37
|
+
const code = (await readFile(sourceId, "utf8")).toString();
|
|
38
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
34
39
|
await repo.checkDoc(doc);
|
|
35
40
|
const messages = doc.getDiagMessages().reverse();
|
|
36
41
|
let error = "";
|
|
@@ -39,6 +44,14 @@ const unpluginFactory = (opts) => {
|
|
|
39
44
|
if (strict && !error) error = m.message;
|
|
40
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
41
46
|
if (error) throw new Error(error);
|
|
47
|
+
if (isDts) {
|
|
48
|
+
const out$1 = await doc.render("dts");
|
|
49
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
50
|
+
return {
|
|
51
|
+
code: content,
|
|
52
|
+
map: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
42
55
|
const out = await doc.render("js");
|
|
43
56
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
44
57
|
return {
|
package/dist/webpack.cjs
CHANGED
|
@@ -29,6 +29,7 @@ const __atscript_core = __toESM(require("@atscript/core"));
|
|
|
29
29
|
const __atscript_typescript = __toESM(require("@atscript/typescript"));
|
|
30
30
|
|
|
31
31
|
//#region packages/unplugin/src/index.ts
|
|
32
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
32
33
|
const unpluginFactory = (opts) => {
|
|
33
34
|
const root = process.cwd();
|
|
34
35
|
const strict = opts?.strict ?? true;
|
|
@@ -43,18 +44,22 @@ const unpluginFactory = (opts) => {
|
|
|
43
44
|
resolveId(id, importer) {
|
|
44
45
|
if (importer && id.endsWith(".as")) {
|
|
45
46
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
46
|
-
|
|
47
|
+
const resolved = path.default.join(path.default.dirname(importer), id);
|
|
48
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
49
|
+
return resolved;
|
|
47
50
|
}
|
|
48
51
|
},
|
|
49
52
|
async load(id) {
|
|
50
|
-
|
|
53
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
55
|
+
if (sourceId.endsWith(".as")) {
|
|
51
56
|
if (!repo) {
|
|
52
57
|
const config = await getConfig();
|
|
53
58
|
if (!config.plugins) config.plugins = [(0, __atscript_typescript.tsPlugin)()];
|
|
54
59
|
repo = new __atscript_core.AtscriptRepo(root, config);
|
|
55
60
|
}
|
|
56
|
-
const code = (await (0, fs_promises.readFile)(
|
|
57
|
-
const doc = await repo.openDocument(`file://${
|
|
61
|
+
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
58
63
|
await repo.checkDoc(doc);
|
|
59
64
|
const messages = doc.getDiagMessages().reverse();
|
|
60
65
|
let error = "";
|
|
@@ -63,6 +68,14 @@ const unpluginFactory = (opts) => {
|
|
|
63
68
|
if (strict && !error) error = m.message;
|
|
64
69
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
65
70
|
if (error) throw new Error(error);
|
|
71
|
+
if (isDts) {
|
|
72
|
+
const out$1 = await doc.render("dts");
|
|
73
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
74
|
+
return {
|
|
75
|
+
code: content,
|
|
76
|
+
map: null
|
|
77
|
+
};
|
|
78
|
+
}
|
|
66
79
|
const out = await doc.render("js");
|
|
67
80
|
const hasMutatingAnnotates = doc.nodes.some((n) => (0, __atscript_core.isAnnotate)(n) && n.isMutating);
|
|
68
81
|
return {
|
package/dist/webpack.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscri
|
|
|
5
5
|
import { tsPlugin } from "@atscript/typescript";
|
|
6
6
|
|
|
7
7
|
//#region packages/unplugin/src/index.ts
|
|
8
|
+
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
8
9
|
const unpluginFactory = (opts) => {
|
|
9
10
|
const root = process.cwd();
|
|
10
11
|
const strict = opts?.strict ?? true;
|
|
@@ -19,18 +20,22 @@ const unpluginFactory = (opts) => {
|
|
|
19
20
|
resolveId(id, importer) {
|
|
20
21
|
if (importer && id.endsWith(".as")) {
|
|
21
22
|
if (!id.startsWith(".") && !id.startsWith("/")) return null;
|
|
22
|
-
|
|
23
|
+
const resolved = path.join(path.dirname(importer), id);
|
|
24
|
+
if (RE_DTS.test(importer)) return `${resolved}.d.ts`;
|
|
25
|
+
return resolved;
|
|
23
26
|
}
|
|
24
27
|
},
|
|
25
28
|
async load(id) {
|
|
26
|
-
|
|
29
|
+
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -".d.ts".length) : id;
|
|
31
|
+
if (sourceId.endsWith(".as")) {
|
|
27
32
|
if (!repo) {
|
|
28
33
|
const config = await getConfig();
|
|
29
34
|
if (!config.plugins) config.plugins = [tsPlugin()];
|
|
30
35
|
repo = new AtscriptRepo(root, config);
|
|
31
36
|
}
|
|
32
|
-
const code = (await readFile(
|
|
33
|
-
const doc = await repo.openDocument(`file://${
|
|
37
|
+
const code = (await readFile(sourceId, "utf8")).toString();
|
|
38
|
+
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
34
39
|
await repo.checkDoc(doc);
|
|
35
40
|
const messages = doc.getDiagMessages().reverse();
|
|
36
41
|
let error = "";
|
|
@@ -39,6 +44,14 @@ const unpluginFactory = (opts) => {
|
|
|
39
44
|
if (strict && !error) error = m.message;
|
|
40
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
41
46
|
if (error) throw new Error(error);
|
|
47
|
+
if (isDts) {
|
|
48
|
+
const out$1 = await doc.render("dts");
|
|
49
|
+
const content = (out$1?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, "");
|
|
50
|
+
return {
|
|
51
|
+
code: content,
|
|
52
|
+
map: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
42
55
|
const out = await doc.render("js");
|
|
43
56
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
44
57
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-atscript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.76",
|
|
4
4
|
"description": "Atscript: Configuration and build plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -77,11 +77,13 @@
|
|
|
77
77
|
"unplugin": "^2.1.2"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
+
"rolldown": "^1.0.0-rc.9",
|
|
81
|
+
"rolldown-plugin-dts": "^0.22.5",
|
|
80
82
|
"vitest": "3.2.4"
|
|
81
83
|
},
|
|
82
84
|
"peerDependencies": {
|
|
83
|
-
"@atscript/core": "^0.1.
|
|
84
|
-
"@atscript/typescript": "^0.1.
|
|
85
|
+
"@atscript/core": "^0.1.76",
|
|
86
|
+
"@atscript/typescript": "^0.1.76"
|
|
85
87
|
},
|
|
86
88
|
"build": [
|
|
87
89
|
{},
|