unplugin-atscript 0.1.87 → 0.1.89
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 +28 -28
- package/dist/esbuild.mjs +6 -10
- package/dist/farm.cjs +28 -28
- package/dist/farm.mjs +6 -10
- package/dist/index.cjs +35 -36
- package/dist/index.mjs +9 -14
- package/dist/rolldown.cjs +28 -28
- package/dist/rolldown.mjs +6 -10
- package/dist/rollup.cjs +28 -28
- package/dist/rollup.mjs +6 -10
- package/dist/rspack.cjs +28 -28
- package/dist/rspack.mjs +6 -10
- package/dist/vite.cjs +28 -28
- package/dist/vite.mjs +6 -10
- package/dist/webpack.cjs +28 -28
- package/dist/webpack.mjs +6 -10
- package/package.json +3 -3
package/dist/esbuild.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//#region rolldown:runtime
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
8
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
return to;
|
|
18
21
|
};
|
|
@@ -22,11 +25,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
25
|
}) : target, mod));
|
|
23
26
|
|
|
24
27
|
//#endregion
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
let unplugin = require("unplugin");
|
|
29
|
+
let fs_promises = require("fs/promises");
|
|
30
|
+
let path = require("path");
|
|
31
|
+
path = __toESM(path);
|
|
32
|
+
let _atscript_core = require("@atscript/core");
|
|
33
|
+
let _atscript_typescript = require("@atscript/typescript");
|
|
30
34
|
|
|
31
35
|
//#region packages/unplugin/src/index.ts
|
|
32
36
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
@@ -36,8 +40,8 @@ const unpluginFactory = (opts) => {
|
|
|
36
40
|
let repo;
|
|
37
41
|
let configPromise;
|
|
38
42
|
const getConfig = () => configPromise ?? (configPromise = (async () => {
|
|
39
|
-
const p = await (0,
|
|
40
|
-
return p ? (0,
|
|
43
|
+
const p = await (0, _atscript_core.resolveConfigFile)(root);
|
|
44
|
+
return p ? (0, _atscript_core.loadConfig)(p) : {};
|
|
41
45
|
})());
|
|
42
46
|
return {
|
|
43
47
|
name: "unplugin-atscript",
|
|
@@ -51,12 +55,12 @@ const unpluginFactory = (opts) => {
|
|
|
51
55
|
},
|
|
52
56
|
async load(id) {
|
|
53
57
|
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
-
const sourceId = isDts ? id.slice(0, -
|
|
58
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
55
59
|
if (sourceId.endsWith(".as")) {
|
|
56
60
|
if (!repo) {
|
|
57
61
|
const config = await getConfig();
|
|
58
|
-
if (!config.plugins) config.plugins = [(0,
|
|
59
|
-
repo = new
|
|
62
|
+
if (!config.plugins) config.plugins = [(0, _atscript_typescript.tsPlugin)()];
|
|
63
|
+
repo = new _atscript_core.AtscriptRepo(root, config);
|
|
60
64
|
}
|
|
61
65
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
66
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
@@ -68,21 +72,17 @@ const unpluginFactory = (opts) => {
|
|
|
68
72
|
if (strict && !error) error = m.message;
|
|
69
73
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
70
74
|
if (error) throw new Error(error);
|
|
71
|
-
if (isDts) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
code: content,
|
|
76
|
-
map: null
|
|
77
|
-
};
|
|
78
|
-
}
|
|
75
|
+
if (isDts) return {
|
|
76
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
77
|
+
map: null
|
|
78
|
+
};
|
|
79
79
|
const out = await doc.render("js");
|
|
80
|
-
const hasMutatingAnnotates = doc.nodes.some((n) => (0,
|
|
80
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
81
81
|
return {
|
|
82
82
|
code: out?.[0]?.content || "",
|
|
83
83
|
moduleType: "js",
|
|
84
84
|
map: null,
|
|
85
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
85
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
}
|
package/dist/esbuild.mjs
CHANGED
|
@@ -27,7 +27,7 @@ const unpluginFactory = (opts) => {
|
|
|
27
27
|
},
|
|
28
28
|
async load(id) {
|
|
29
29
|
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
-
const sourceId = isDts ? id.slice(0, -
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
31
31
|
if (sourceId.endsWith(".as")) {
|
|
32
32
|
if (!repo) {
|
|
33
33
|
const config = await getConfig();
|
|
@@ -44,21 +44,17 @@ const unpluginFactory = (opts) => {
|
|
|
44
44
|
if (strict && !error) error = m.message;
|
|
45
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
46
46
|
if (error) throw new Error(error);
|
|
47
|
-
if (isDts) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
code: content,
|
|
52
|
-
map: null
|
|
53
|
-
};
|
|
54
|
-
}
|
|
47
|
+
if (isDts) return {
|
|
48
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
49
|
+
map: null
|
|
50
|
+
};
|
|
55
51
|
const out = await doc.render("js");
|
|
56
52
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
57
53
|
return {
|
|
58
54
|
code: out?.[0]?.content || "",
|
|
59
55
|
moduleType: "js",
|
|
60
56
|
map: null,
|
|
61
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
57
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
60
|
}
|
package/dist/farm.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//#region rolldown:runtime
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
8
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
return to;
|
|
18
21
|
};
|
|
@@ -22,11 +25,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
25
|
}) : target, mod));
|
|
23
26
|
|
|
24
27
|
//#endregion
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
let unplugin = require("unplugin");
|
|
29
|
+
let fs_promises = require("fs/promises");
|
|
30
|
+
let path = require("path");
|
|
31
|
+
path = __toESM(path);
|
|
32
|
+
let _atscript_core = require("@atscript/core");
|
|
33
|
+
let _atscript_typescript = require("@atscript/typescript");
|
|
30
34
|
|
|
31
35
|
//#region packages/unplugin/src/index.ts
|
|
32
36
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
@@ -36,8 +40,8 @@ const unpluginFactory = (opts) => {
|
|
|
36
40
|
let repo;
|
|
37
41
|
let configPromise;
|
|
38
42
|
const getConfig = () => configPromise ?? (configPromise = (async () => {
|
|
39
|
-
const p = await (0,
|
|
40
|
-
return p ? (0,
|
|
43
|
+
const p = await (0, _atscript_core.resolveConfigFile)(root);
|
|
44
|
+
return p ? (0, _atscript_core.loadConfig)(p) : {};
|
|
41
45
|
})());
|
|
42
46
|
return {
|
|
43
47
|
name: "unplugin-atscript",
|
|
@@ -51,12 +55,12 @@ const unpluginFactory = (opts) => {
|
|
|
51
55
|
},
|
|
52
56
|
async load(id) {
|
|
53
57
|
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
-
const sourceId = isDts ? id.slice(0, -
|
|
58
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
55
59
|
if (sourceId.endsWith(".as")) {
|
|
56
60
|
if (!repo) {
|
|
57
61
|
const config = await getConfig();
|
|
58
|
-
if (!config.plugins) config.plugins = [(0,
|
|
59
|
-
repo = new
|
|
62
|
+
if (!config.plugins) config.plugins = [(0, _atscript_typescript.tsPlugin)()];
|
|
63
|
+
repo = new _atscript_core.AtscriptRepo(root, config);
|
|
60
64
|
}
|
|
61
65
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
66
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
@@ -68,21 +72,17 @@ const unpluginFactory = (opts) => {
|
|
|
68
72
|
if (strict && !error) error = m.message;
|
|
69
73
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
70
74
|
if (error) throw new Error(error);
|
|
71
|
-
if (isDts) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
code: content,
|
|
76
|
-
map: null
|
|
77
|
-
};
|
|
78
|
-
}
|
|
75
|
+
if (isDts) return {
|
|
76
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
77
|
+
map: null
|
|
78
|
+
};
|
|
79
79
|
const out = await doc.render("js");
|
|
80
|
-
const hasMutatingAnnotates = doc.nodes.some((n) => (0,
|
|
80
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
81
81
|
return {
|
|
82
82
|
code: out?.[0]?.content || "",
|
|
83
83
|
moduleType: "js",
|
|
84
84
|
map: null,
|
|
85
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
85
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
}
|
package/dist/farm.mjs
CHANGED
|
@@ -27,7 +27,7 @@ const unpluginFactory = (opts) => {
|
|
|
27
27
|
},
|
|
28
28
|
async load(id) {
|
|
29
29
|
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
-
const sourceId = isDts ? id.slice(0, -
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
31
31
|
if (sourceId.endsWith(".as")) {
|
|
32
32
|
if (!repo) {
|
|
33
33
|
const config = await getConfig();
|
|
@@ -44,21 +44,17 @@ const unpluginFactory = (opts) => {
|
|
|
44
44
|
if (strict && !error) error = m.message;
|
|
45
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
46
46
|
if (error) throw new Error(error);
|
|
47
|
-
if (isDts) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
code: content,
|
|
52
|
-
map: null
|
|
53
|
-
};
|
|
54
|
-
}
|
|
47
|
+
if (isDts) return {
|
|
48
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
49
|
+
map: null
|
|
50
|
+
};
|
|
55
51
|
const out = await doc.render("js");
|
|
56
52
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
57
53
|
return {
|
|
58
54
|
code: out?.[0]?.content || "",
|
|
59
55
|
moduleType: "js",
|
|
60
56
|
map: null,
|
|
61
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
57
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
60
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//#region rolldown:runtime
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
4
3
|
var __create = Object.create;
|
|
5
4
|
var __defProp = Object.defineProperty;
|
|
6
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -8,12 +7,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
8
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
9
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: ((k) => from[k]).bind(null, key),
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
return to;
|
|
19
22
|
};
|
|
@@ -23,11 +26,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
26
|
}) : target, mod));
|
|
24
27
|
|
|
25
28
|
//#endregion
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
let fs_promises = require("fs/promises");
|
|
30
|
+
let path = require("path");
|
|
31
|
+
path = __toESM(path);
|
|
32
|
+
let _atscript_core = require("@atscript/core");
|
|
33
|
+
let _atscript_typescript = require("@atscript/typescript");
|
|
34
|
+
let unplugin = require("unplugin");
|
|
31
35
|
|
|
32
36
|
//#region packages/unplugin/src/index.ts
|
|
33
37
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
@@ -37,8 +41,8 @@ const unpluginFactory = (opts) => {
|
|
|
37
41
|
let repo;
|
|
38
42
|
let configPromise;
|
|
39
43
|
const getConfig = () => configPromise ?? (configPromise = (async () => {
|
|
40
|
-
const p = await (0,
|
|
41
|
-
return p ? (0,
|
|
44
|
+
const p = await (0, _atscript_core.resolveConfigFile)(root);
|
|
45
|
+
return p ? (0, _atscript_core.loadConfig)(p) : {};
|
|
42
46
|
})());
|
|
43
47
|
return {
|
|
44
48
|
name: "unplugin-atscript",
|
|
@@ -52,12 +56,12 @@ const unpluginFactory = (opts) => {
|
|
|
52
56
|
},
|
|
53
57
|
async load(id) {
|
|
54
58
|
const isDts = id.endsWith(".as.d.ts");
|
|
55
|
-
const sourceId = isDts ? id.slice(0, -
|
|
59
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
56
60
|
if (sourceId.endsWith(".as")) {
|
|
57
61
|
if (!repo) {
|
|
58
62
|
const config = await getConfig();
|
|
59
|
-
if (!config.plugins) config.plugins = [(0,
|
|
60
|
-
repo = new
|
|
63
|
+
if (!config.plugins) config.plugins = [(0, _atscript_typescript.tsPlugin)()];
|
|
64
|
+
repo = new _atscript_core.AtscriptRepo(root, config);
|
|
61
65
|
}
|
|
62
66
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
63
67
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
@@ -69,32 +73,27 @@ const unpluginFactory = (opts) => {
|
|
|
69
73
|
if (strict && !error) error = m.message;
|
|
70
74
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
71
75
|
if (error) throw new Error(error);
|
|
72
|
-
if (isDts) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
code: content,
|
|
77
|
-
map: null
|
|
78
|
-
};
|
|
79
|
-
}
|
|
76
|
+
if (isDts) return {
|
|
77
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
78
|
+
map: null
|
|
79
|
+
};
|
|
80
80
|
const out = await doc.render("js");
|
|
81
|
-
const hasMutatingAnnotates = doc.nodes.some((n) => (0,
|
|
81
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
82
82
|
return {
|
|
83
83
|
code: out?.[0]?.content || "",
|
|
84
84
|
moduleType: "js",
|
|
85
85
|
map: null,
|
|
86
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
86
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
|
-
const unplugin$1 = /*
|
|
93
|
-
const asPlugin = unplugin$1;
|
|
94
|
-
var src_default = unplugin$1;
|
|
92
|
+
const unplugin$1 = /* @__PURE__ */ (0, unplugin.createUnplugin)(unpluginFactory);
|
|
93
|
+
/** @deprecated Use `import atscript from 'unplugin-atscript/vite'` (or /rollup, /webpack, etc.) instead */ const asPlugin = unplugin$1;
|
|
95
94
|
|
|
96
95
|
//#endregion
|
|
97
|
-
exports.asPlugin = asPlugin
|
|
98
|
-
exports.default =
|
|
99
|
-
exports.unplugin = unplugin$1
|
|
100
|
-
exports.unpluginFactory = unpluginFactory
|
|
96
|
+
exports.asPlugin = asPlugin;
|
|
97
|
+
exports.default = unplugin$1;
|
|
98
|
+
exports.unplugin = unplugin$1;
|
|
99
|
+
exports.unpluginFactory = unpluginFactory;
|
package/dist/index.mjs
CHANGED
|
@@ -27,7 +27,7 @@ const unpluginFactory = (opts) => {
|
|
|
27
27
|
},
|
|
28
28
|
async load(id) {
|
|
29
29
|
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
-
const sourceId = isDts ? id.slice(0, -
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
31
31
|
if (sourceId.endsWith(".as")) {
|
|
32
32
|
if (!repo) {
|
|
33
33
|
const config = await getConfig();
|
|
@@ -44,29 +44,24 @@ const unpluginFactory = (opts) => {
|
|
|
44
44
|
if (strict && !error) error = m.message;
|
|
45
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
46
46
|
if (error) throw new Error(error);
|
|
47
|
-
if (isDts) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
code: content,
|
|
52
|
-
map: null
|
|
53
|
-
};
|
|
54
|
-
}
|
|
47
|
+
if (isDts) return {
|
|
48
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
49
|
+
map: null
|
|
50
|
+
};
|
|
55
51
|
const out = await doc.render("js");
|
|
56
52
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
57
53
|
return {
|
|
58
54
|
code: out?.[0]?.content || "",
|
|
59
55
|
moduleType: "js",
|
|
60
56
|
map: null,
|
|
61
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
57
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
60
|
}
|
|
65
61
|
};
|
|
66
62
|
};
|
|
67
|
-
const unplugin = /*
|
|
68
|
-
const asPlugin = unplugin;
|
|
69
|
-
var src_default = unplugin;
|
|
63
|
+
const unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
|
|
64
|
+
/** @deprecated Use `import atscript from 'unplugin-atscript/vite'` (or /rollup, /webpack, etc.) instead */ const asPlugin = unplugin;
|
|
70
65
|
|
|
71
66
|
//#endregion
|
|
72
|
-
export { asPlugin,
|
|
67
|
+
export { asPlugin, unplugin as default, unplugin, unpluginFactory };
|
package/dist/rolldown.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//#region rolldown:runtime
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
8
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
return to;
|
|
18
21
|
};
|
|
@@ -22,11 +25,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
25
|
}) : target, mod));
|
|
23
26
|
|
|
24
27
|
//#endregion
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
let unplugin = require("unplugin");
|
|
29
|
+
let fs_promises = require("fs/promises");
|
|
30
|
+
let path = require("path");
|
|
31
|
+
path = __toESM(path);
|
|
32
|
+
let _atscript_core = require("@atscript/core");
|
|
33
|
+
let _atscript_typescript = require("@atscript/typescript");
|
|
30
34
|
|
|
31
35
|
//#region packages/unplugin/src/index.ts
|
|
32
36
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
@@ -36,8 +40,8 @@ const unpluginFactory = (opts) => {
|
|
|
36
40
|
let repo;
|
|
37
41
|
let configPromise;
|
|
38
42
|
const getConfig = () => configPromise ?? (configPromise = (async () => {
|
|
39
|
-
const p = await (0,
|
|
40
|
-
return p ? (0,
|
|
43
|
+
const p = await (0, _atscript_core.resolveConfigFile)(root);
|
|
44
|
+
return p ? (0, _atscript_core.loadConfig)(p) : {};
|
|
41
45
|
})());
|
|
42
46
|
return {
|
|
43
47
|
name: "unplugin-atscript",
|
|
@@ -51,12 +55,12 @@ const unpluginFactory = (opts) => {
|
|
|
51
55
|
},
|
|
52
56
|
async load(id) {
|
|
53
57
|
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
-
const sourceId = isDts ? id.slice(0, -
|
|
58
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
55
59
|
if (sourceId.endsWith(".as")) {
|
|
56
60
|
if (!repo) {
|
|
57
61
|
const config = await getConfig();
|
|
58
|
-
if (!config.plugins) config.plugins = [(0,
|
|
59
|
-
repo = new
|
|
62
|
+
if (!config.plugins) config.plugins = [(0, _atscript_typescript.tsPlugin)()];
|
|
63
|
+
repo = new _atscript_core.AtscriptRepo(root, config);
|
|
60
64
|
}
|
|
61
65
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
66
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
@@ -68,21 +72,17 @@ const unpluginFactory = (opts) => {
|
|
|
68
72
|
if (strict && !error) error = m.message;
|
|
69
73
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
70
74
|
if (error) throw new Error(error);
|
|
71
|
-
if (isDts) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
code: content,
|
|
76
|
-
map: null
|
|
77
|
-
};
|
|
78
|
-
}
|
|
75
|
+
if (isDts) return {
|
|
76
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
77
|
+
map: null
|
|
78
|
+
};
|
|
79
79
|
const out = await doc.render("js");
|
|
80
|
-
const hasMutatingAnnotates = doc.nodes.some((n) => (0,
|
|
80
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
81
81
|
return {
|
|
82
82
|
code: out?.[0]?.content || "",
|
|
83
83
|
moduleType: "js",
|
|
84
84
|
map: null,
|
|
85
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
85
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
}
|
package/dist/rolldown.mjs
CHANGED
|
@@ -27,7 +27,7 @@ const unpluginFactory = (opts) => {
|
|
|
27
27
|
},
|
|
28
28
|
async load(id) {
|
|
29
29
|
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
-
const sourceId = isDts ? id.slice(0, -
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
31
31
|
if (sourceId.endsWith(".as")) {
|
|
32
32
|
if (!repo) {
|
|
33
33
|
const config = await getConfig();
|
|
@@ -44,21 +44,17 @@ const unpluginFactory = (opts) => {
|
|
|
44
44
|
if (strict && !error) error = m.message;
|
|
45
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
46
46
|
if (error) throw new Error(error);
|
|
47
|
-
if (isDts) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
code: content,
|
|
52
|
-
map: null
|
|
53
|
-
};
|
|
54
|
-
}
|
|
47
|
+
if (isDts) return {
|
|
48
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
49
|
+
map: null
|
|
50
|
+
};
|
|
55
51
|
const out = await doc.render("js");
|
|
56
52
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
57
53
|
return {
|
|
58
54
|
code: out?.[0]?.content || "",
|
|
59
55
|
moduleType: "js",
|
|
60
56
|
map: null,
|
|
61
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
57
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
60
|
}
|
package/dist/rollup.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//#region rolldown:runtime
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
8
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
return to;
|
|
18
21
|
};
|
|
@@ -22,11 +25,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
25
|
}) : target, mod));
|
|
23
26
|
|
|
24
27
|
//#endregion
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
let unplugin = require("unplugin");
|
|
29
|
+
let fs_promises = require("fs/promises");
|
|
30
|
+
let path = require("path");
|
|
31
|
+
path = __toESM(path);
|
|
32
|
+
let _atscript_core = require("@atscript/core");
|
|
33
|
+
let _atscript_typescript = require("@atscript/typescript");
|
|
30
34
|
|
|
31
35
|
//#region packages/unplugin/src/index.ts
|
|
32
36
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
@@ -36,8 +40,8 @@ const unpluginFactory = (opts) => {
|
|
|
36
40
|
let repo;
|
|
37
41
|
let configPromise;
|
|
38
42
|
const getConfig = () => configPromise ?? (configPromise = (async () => {
|
|
39
|
-
const p = await (0,
|
|
40
|
-
return p ? (0,
|
|
43
|
+
const p = await (0, _atscript_core.resolveConfigFile)(root);
|
|
44
|
+
return p ? (0, _atscript_core.loadConfig)(p) : {};
|
|
41
45
|
})());
|
|
42
46
|
return {
|
|
43
47
|
name: "unplugin-atscript",
|
|
@@ -51,12 +55,12 @@ const unpluginFactory = (opts) => {
|
|
|
51
55
|
},
|
|
52
56
|
async load(id) {
|
|
53
57
|
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
-
const sourceId = isDts ? id.slice(0, -
|
|
58
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
55
59
|
if (sourceId.endsWith(".as")) {
|
|
56
60
|
if (!repo) {
|
|
57
61
|
const config = await getConfig();
|
|
58
|
-
if (!config.plugins) config.plugins = [(0,
|
|
59
|
-
repo = new
|
|
62
|
+
if (!config.plugins) config.plugins = [(0, _atscript_typescript.tsPlugin)()];
|
|
63
|
+
repo = new _atscript_core.AtscriptRepo(root, config);
|
|
60
64
|
}
|
|
61
65
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
66
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
@@ -68,21 +72,17 @@ const unpluginFactory = (opts) => {
|
|
|
68
72
|
if (strict && !error) error = m.message;
|
|
69
73
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
70
74
|
if (error) throw new Error(error);
|
|
71
|
-
if (isDts) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
code: content,
|
|
76
|
-
map: null
|
|
77
|
-
};
|
|
78
|
-
}
|
|
75
|
+
if (isDts) return {
|
|
76
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
77
|
+
map: null
|
|
78
|
+
};
|
|
79
79
|
const out = await doc.render("js");
|
|
80
|
-
const hasMutatingAnnotates = doc.nodes.some((n) => (0,
|
|
80
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
81
81
|
return {
|
|
82
82
|
code: out?.[0]?.content || "",
|
|
83
83
|
moduleType: "js",
|
|
84
84
|
map: null,
|
|
85
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
85
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
}
|
package/dist/rollup.mjs
CHANGED
|
@@ -27,7 +27,7 @@ const unpluginFactory = (opts) => {
|
|
|
27
27
|
},
|
|
28
28
|
async load(id) {
|
|
29
29
|
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
-
const sourceId = isDts ? id.slice(0, -
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
31
31
|
if (sourceId.endsWith(".as")) {
|
|
32
32
|
if (!repo) {
|
|
33
33
|
const config = await getConfig();
|
|
@@ -44,21 +44,17 @@ const unpluginFactory = (opts) => {
|
|
|
44
44
|
if (strict && !error) error = m.message;
|
|
45
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
46
46
|
if (error) throw new Error(error);
|
|
47
|
-
if (isDts) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
code: content,
|
|
52
|
-
map: null
|
|
53
|
-
};
|
|
54
|
-
}
|
|
47
|
+
if (isDts) return {
|
|
48
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
49
|
+
map: null
|
|
50
|
+
};
|
|
55
51
|
const out = await doc.render("js");
|
|
56
52
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
57
53
|
return {
|
|
58
54
|
code: out?.[0]?.content || "",
|
|
59
55
|
moduleType: "js",
|
|
60
56
|
map: null,
|
|
61
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
57
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
60
|
}
|
package/dist/rspack.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//#region rolldown:runtime
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
8
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
return to;
|
|
18
21
|
};
|
|
@@ -22,11 +25,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
25
|
}) : target, mod));
|
|
23
26
|
|
|
24
27
|
//#endregion
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
let unplugin = require("unplugin");
|
|
29
|
+
let fs_promises = require("fs/promises");
|
|
30
|
+
let path = require("path");
|
|
31
|
+
path = __toESM(path);
|
|
32
|
+
let _atscript_core = require("@atscript/core");
|
|
33
|
+
let _atscript_typescript = require("@atscript/typescript");
|
|
30
34
|
|
|
31
35
|
//#region packages/unplugin/src/index.ts
|
|
32
36
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
@@ -36,8 +40,8 @@ const unpluginFactory = (opts) => {
|
|
|
36
40
|
let repo;
|
|
37
41
|
let configPromise;
|
|
38
42
|
const getConfig = () => configPromise ?? (configPromise = (async () => {
|
|
39
|
-
const p = await (0,
|
|
40
|
-
return p ? (0,
|
|
43
|
+
const p = await (0, _atscript_core.resolveConfigFile)(root);
|
|
44
|
+
return p ? (0, _atscript_core.loadConfig)(p) : {};
|
|
41
45
|
})());
|
|
42
46
|
return {
|
|
43
47
|
name: "unplugin-atscript",
|
|
@@ -51,12 +55,12 @@ const unpluginFactory = (opts) => {
|
|
|
51
55
|
},
|
|
52
56
|
async load(id) {
|
|
53
57
|
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
-
const sourceId = isDts ? id.slice(0, -
|
|
58
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
55
59
|
if (sourceId.endsWith(".as")) {
|
|
56
60
|
if (!repo) {
|
|
57
61
|
const config = await getConfig();
|
|
58
|
-
if (!config.plugins) config.plugins = [(0,
|
|
59
|
-
repo = new
|
|
62
|
+
if (!config.plugins) config.plugins = [(0, _atscript_typescript.tsPlugin)()];
|
|
63
|
+
repo = new _atscript_core.AtscriptRepo(root, config);
|
|
60
64
|
}
|
|
61
65
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
66
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
@@ -68,21 +72,17 @@ const unpluginFactory = (opts) => {
|
|
|
68
72
|
if (strict && !error) error = m.message;
|
|
69
73
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
70
74
|
if (error) throw new Error(error);
|
|
71
|
-
if (isDts) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
code: content,
|
|
76
|
-
map: null
|
|
77
|
-
};
|
|
78
|
-
}
|
|
75
|
+
if (isDts) return {
|
|
76
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
77
|
+
map: null
|
|
78
|
+
};
|
|
79
79
|
const out = await doc.render("js");
|
|
80
|
-
const hasMutatingAnnotates = doc.nodes.some((n) => (0,
|
|
80
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
81
81
|
return {
|
|
82
82
|
code: out?.[0]?.content || "",
|
|
83
83
|
moduleType: "js",
|
|
84
84
|
map: null,
|
|
85
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
85
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
}
|
package/dist/rspack.mjs
CHANGED
|
@@ -27,7 +27,7 @@ const unpluginFactory = (opts) => {
|
|
|
27
27
|
},
|
|
28
28
|
async load(id) {
|
|
29
29
|
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
-
const sourceId = isDts ? id.slice(0, -
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
31
31
|
if (sourceId.endsWith(".as")) {
|
|
32
32
|
if (!repo) {
|
|
33
33
|
const config = await getConfig();
|
|
@@ -44,21 +44,17 @@ const unpluginFactory = (opts) => {
|
|
|
44
44
|
if (strict && !error) error = m.message;
|
|
45
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
46
46
|
if (error) throw new Error(error);
|
|
47
|
-
if (isDts) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
code: content,
|
|
52
|
-
map: null
|
|
53
|
-
};
|
|
54
|
-
}
|
|
47
|
+
if (isDts) return {
|
|
48
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
49
|
+
map: null
|
|
50
|
+
};
|
|
55
51
|
const out = await doc.render("js");
|
|
56
52
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
57
53
|
return {
|
|
58
54
|
code: out?.[0]?.content || "",
|
|
59
55
|
moduleType: "js",
|
|
60
56
|
map: null,
|
|
61
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
57
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
60
|
}
|
package/dist/vite.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//#region rolldown:runtime
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
8
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
return to;
|
|
18
21
|
};
|
|
@@ -22,11 +25,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
25
|
}) : target, mod));
|
|
23
26
|
|
|
24
27
|
//#endregion
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
let unplugin = require("unplugin");
|
|
29
|
+
let fs_promises = require("fs/promises");
|
|
30
|
+
let path = require("path");
|
|
31
|
+
path = __toESM(path);
|
|
32
|
+
let _atscript_core = require("@atscript/core");
|
|
33
|
+
let _atscript_typescript = require("@atscript/typescript");
|
|
30
34
|
|
|
31
35
|
//#region packages/unplugin/src/index.ts
|
|
32
36
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
@@ -36,8 +40,8 @@ const unpluginFactory = (opts) => {
|
|
|
36
40
|
let repo;
|
|
37
41
|
let configPromise;
|
|
38
42
|
const getConfig = () => configPromise ?? (configPromise = (async () => {
|
|
39
|
-
const p = await (0,
|
|
40
|
-
return p ? (0,
|
|
43
|
+
const p = await (0, _atscript_core.resolveConfigFile)(root);
|
|
44
|
+
return p ? (0, _atscript_core.loadConfig)(p) : {};
|
|
41
45
|
})());
|
|
42
46
|
return {
|
|
43
47
|
name: "unplugin-atscript",
|
|
@@ -51,12 +55,12 @@ const unpluginFactory = (opts) => {
|
|
|
51
55
|
},
|
|
52
56
|
async load(id) {
|
|
53
57
|
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
-
const sourceId = isDts ? id.slice(0, -
|
|
58
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
55
59
|
if (sourceId.endsWith(".as")) {
|
|
56
60
|
if (!repo) {
|
|
57
61
|
const config = await getConfig();
|
|
58
|
-
if (!config.plugins) config.plugins = [(0,
|
|
59
|
-
repo = new
|
|
62
|
+
if (!config.plugins) config.plugins = [(0, _atscript_typescript.tsPlugin)()];
|
|
63
|
+
repo = new _atscript_core.AtscriptRepo(root, config);
|
|
60
64
|
}
|
|
61
65
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
66
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
@@ -68,21 +72,17 @@ const unpluginFactory = (opts) => {
|
|
|
68
72
|
if (strict && !error) error = m.message;
|
|
69
73
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
70
74
|
if (error) throw new Error(error);
|
|
71
|
-
if (isDts) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
code: content,
|
|
76
|
-
map: null
|
|
77
|
-
};
|
|
78
|
-
}
|
|
75
|
+
if (isDts) return {
|
|
76
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
77
|
+
map: null
|
|
78
|
+
};
|
|
79
79
|
const out = await doc.render("js");
|
|
80
|
-
const hasMutatingAnnotates = doc.nodes.some((n) => (0,
|
|
80
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
81
81
|
return {
|
|
82
82
|
code: out?.[0]?.content || "",
|
|
83
83
|
moduleType: "js",
|
|
84
84
|
map: null,
|
|
85
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
85
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
}
|
package/dist/vite.mjs
CHANGED
|
@@ -27,7 +27,7 @@ const unpluginFactory = (opts) => {
|
|
|
27
27
|
},
|
|
28
28
|
async load(id) {
|
|
29
29
|
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
-
const sourceId = isDts ? id.slice(0, -
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
31
31
|
if (sourceId.endsWith(".as")) {
|
|
32
32
|
if (!repo) {
|
|
33
33
|
const config = await getConfig();
|
|
@@ -44,21 +44,17 @@ const unpluginFactory = (opts) => {
|
|
|
44
44
|
if (strict && !error) error = m.message;
|
|
45
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
46
46
|
if (error) throw new Error(error);
|
|
47
|
-
if (isDts) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
code: content,
|
|
52
|
-
map: null
|
|
53
|
-
};
|
|
54
|
-
}
|
|
47
|
+
if (isDts) return {
|
|
48
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
49
|
+
map: null
|
|
50
|
+
};
|
|
55
51
|
const out = await doc.render("js");
|
|
56
52
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
57
53
|
return {
|
|
58
54
|
code: out?.[0]?.content || "",
|
|
59
55
|
moduleType: "js",
|
|
60
56
|
map: null,
|
|
61
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
57
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
60
|
}
|
package/dist/webpack.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//#region rolldown:runtime
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,12 +6,16 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
8
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
return to;
|
|
18
21
|
};
|
|
@@ -22,11 +25,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
25
|
}) : target, mod));
|
|
23
26
|
|
|
24
27
|
//#endregion
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
let unplugin = require("unplugin");
|
|
29
|
+
let fs_promises = require("fs/promises");
|
|
30
|
+
let path = require("path");
|
|
31
|
+
path = __toESM(path);
|
|
32
|
+
let _atscript_core = require("@atscript/core");
|
|
33
|
+
let _atscript_typescript = require("@atscript/typescript");
|
|
30
34
|
|
|
31
35
|
//#region packages/unplugin/src/index.ts
|
|
32
36
|
const RE_DTS = /\.d\.[cm]?ts$/;
|
|
@@ -36,8 +40,8 @@ const unpluginFactory = (opts) => {
|
|
|
36
40
|
let repo;
|
|
37
41
|
let configPromise;
|
|
38
42
|
const getConfig = () => configPromise ?? (configPromise = (async () => {
|
|
39
|
-
const p = await (0,
|
|
40
|
-
return p ? (0,
|
|
43
|
+
const p = await (0, _atscript_core.resolveConfigFile)(root);
|
|
44
|
+
return p ? (0, _atscript_core.loadConfig)(p) : {};
|
|
41
45
|
})());
|
|
42
46
|
return {
|
|
43
47
|
name: "unplugin-atscript",
|
|
@@ -51,12 +55,12 @@ const unpluginFactory = (opts) => {
|
|
|
51
55
|
},
|
|
52
56
|
async load(id) {
|
|
53
57
|
const isDts = id.endsWith(".as.d.ts");
|
|
54
|
-
const sourceId = isDts ? id.slice(0, -
|
|
58
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
55
59
|
if (sourceId.endsWith(".as")) {
|
|
56
60
|
if (!repo) {
|
|
57
61
|
const config = await getConfig();
|
|
58
|
-
if (!config.plugins) config.plugins = [(0,
|
|
59
|
-
repo = new
|
|
62
|
+
if (!config.plugins) config.plugins = [(0, _atscript_typescript.tsPlugin)()];
|
|
63
|
+
repo = new _atscript_core.AtscriptRepo(root, config);
|
|
60
64
|
}
|
|
61
65
|
const code = (await (0, fs_promises.readFile)(sourceId, "utf8")).toString();
|
|
62
66
|
const doc = await repo.openDocument(`file://${sourceId}`, code);
|
|
@@ -68,21 +72,17 @@ const unpluginFactory = (opts) => {
|
|
|
68
72
|
if (strict && !error) error = m.message;
|
|
69
73
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
70
74
|
if (error) throw new Error(error);
|
|
71
|
-
if (isDts) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
code: content,
|
|
76
|
-
map: null
|
|
77
|
-
};
|
|
78
|
-
}
|
|
75
|
+
if (isDts) return {
|
|
76
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
77
|
+
map: null
|
|
78
|
+
};
|
|
79
79
|
const out = await doc.render("js");
|
|
80
|
-
const hasMutatingAnnotates = doc.nodes.some((n) => (0,
|
|
80
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => (0, _atscript_core.isAnnotate)(n) && n.isMutating);
|
|
81
81
|
return {
|
|
82
82
|
code: out?.[0]?.content || "",
|
|
83
83
|
moduleType: "js",
|
|
84
84
|
map: null,
|
|
85
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
85
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
}
|
package/dist/webpack.mjs
CHANGED
|
@@ -27,7 +27,7 @@ const unpluginFactory = (opts) => {
|
|
|
27
27
|
},
|
|
28
28
|
async load(id) {
|
|
29
29
|
const isDts = id.endsWith(".as.d.ts");
|
|
30
|
-
const sourceId = isDts ? id.slice(0, -
|
|
30
|
+
const sourceId = isDts ? id.slice(0, -5) : id;
|
|
31
31
|
if (sourceId.endsWith(".as")) {
|
|
32
32
|
if (!repo) {
|
|
33
33
|
const config = await getConfig();
|
|
@@ -44,21 +44,17 @@ const unpluginFactory = (opts) => {
|
|
|
44
44
|
if (strict && !error) error = m.message;
|
|
45
45
|
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
46
46
|
if (error) throw new Error(error);
|
|
47
|
-
if (isDts) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
code: content,
|
|
52
|
-
map: null
|
|
53
|
-
};
|
|
54
|
-
}
|
|
47
|
+
if (isDts) return {
|
|
48
|
+
code: ((await doc.render("dts"))?.[0]?.content || "").replace(/^\/{3}\s*<reference\s+path=[^\n]*\n/m, ""),
|
|
49
|
+
map: null
|
|
50
|
+
};
|
|
55
51
|
const out = await doc.render("js");
|
|
56
52
|
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
57
53
|
return {
|
|
58
54
|
code: out?.[0]?.content || "",
|
|
59
55
|
moduleType: "js",
|
|
60
56
|
map: null,
|
|
61
|
-
moduleSideEffects: hasMutatingAnnotates ?
|
|
57
|
+
moduleSideEffects: hasMutatingAnnotates ? void 0 : false
|
|
62
58
|
};
|
|
63
59
|
}
|
|
64
60
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-atscript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.89",
|
|
4
4
|
"description": "Atscript: Configuration and build plugins.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"vitest": "3.2.7"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
|
-
"@atscript/core": "^0.1.
|
|
86
|
-
"@atscript/typescript": "^0.1.
|
|
85
|
+
"@atscript/core": "^0.1.89",
|
|
86
|
+
"@atscript/typescript": "^0.1.89"
|
|
87
87
|
},
|
|
88
88
|
"build": [
|
|
89
89
|
{},
|