unplugin-atscript 0.1.22 → 0.1.24
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/README.md +21 -10
- package/dist/esbuild.cjs +81 -0
- package/dist/esbuild.d.ts +13 -0
- package/dist/esbuild.mjs +57 -0
- package/dist/farm.cjs +81 -0
- package/dist/farm.d.ts +11 -0
- package/dist/farm.mjs +57 -0
- package/dist/index.cjs +8 -5
- package/dist/index.d.ts +7 -3
- package/dist/index.mjs +6 -5
- package/dist/rolldown.cjs +81 -0
- package/dist/rolldown.d.ts +13 -0
- package/dist/rolldown.mjs +57 -0
- package/dist/rollup.cjs +81 -0
- package/dist/rollup.d.ts +13 -0
- package/dist/rollup.mjs +57 -0
- package/dist/rspack.cjs +81 -0
- package/dist/rspack.d.ts +11 -0
- package/dist/rspack.mjs +57 -0
- package/dist/vite.cjs +81 -0
- package/dist/vite.d.ts +13 -0
- package/dist/vite.mjs +57 -0
- package/dist/webpack.cjs +81 -0
- package/dist/webpack.d.ts +11 -0
- package/dist/webpack.mjs +57 -0
- package/package.json +82 -6
package/dist/rollup.cjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//#region rolldown:runtime
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") 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) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
const unplugin = __toESM(require("unplugin"));
|
|
26
|
+
const fs_promises = __toESM(require("fs/promises"));
|
|
27
|
+
const path = __toESM(require("path"));
|
|
28
|
+
const __atscript_core = __toESM(require("@atscript/core"));
|
|
29
|
+
const __atscript_typescript = __toESM(require("@atscript/typescript"));
|
|
30
|
+
|
|
31
|
+
//#region packages/unplugin/src/index.ts
|
|
32
|
+
const unpluginFactory = (opts) => {
|
|
33
|
+
const root = process.cwd();
|
|
34
|
+
const atscriptConfig = new Promise((resolve) => {
|
|
35
|
+
(0, __atscript_core.resolveConfigFile)(root).then((p) => {
|
|
36
|
+
(0, __atscript_core.loadConfig)(p).then(resolve);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
const strict = opts?.strict ?? true;
|
|
40
|
+
let repo;
|
|
41
|
+
return {
|
|
42
|
+
name: "unplugin-atscript",
|
|
43
|
+
resolveId(id, importer) {
|
|
44
|
+
if (importer && id.endsWith(".as")) return path.default.join(path.default.dirname(importer), id);
|
|
45
|
+
},
|
|
46
|
+
async load(id) {
|
|
47
|
+
if (id.endsWith(".as")) {
|
|
48
|
+
if (!repo) {
|
|
49
|
+
const config = await atscriptConfig;
|
|
50
|
+
if (!config.plugins) config.plugins = [(0, __atscript_typescript.default)()];
|
|
51
|
+
repo = new __atscript_core.AtscriptRepo(root, config);
|
|
52
|
+
}
|
|
53
|
+
const code = (await (0, fs_promises.readFile)(id, "utf8")).toString();
|
|
54
|
+
const doc = await repo.openDocument(`file://${id}`, code);
|
|
55
|
+
await repo.checkDoc(doc);
|
|
56
|
+
const messages = doc.getDiagMessages().reverse();
|
|
57
|
+
let error = "";
|
|
58
|
+
for (const m of messages) if (m.severity === 1) {
|
|
59
|
+
console.log(doc.renderDiagMessage(m, true, true));
|
|
60
|
+
if (strict && !error) error = m.message;
|
|
61
|
+
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
62
|
+
if (error) throw new Error(error);
|
|
63
|
+
const out = await doc.render("js");
|
|
64
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => (0, __atscript_core.isAnnotate)(n) && n.isMutating);
|
|
65
|
+
return {
|
|
66
|
+
code: out?.[0]?.content || "",
|
|
67
|
+
moduleType: "js",
|
|
68
|
+
map: null,
|
|
69
|
+
moduleSideEffects: hasMutatingAnnotates ? undefined : false
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region packages/unplugin/src/rollup.ts
|
|
78
|
+
var rollup_default = (0, unplugin.createRollupPlugin)(unpluginFactory);
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
module.exports = rollup_default;
|
package/dist/rollup.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as rollup from 'rollup';
|
|
2
|
+
|
|
3
|
+
interface atscriptPluginOptions {
|
|
4
|
+
/**
|
|
5
|
+
* When strict: true, atscript will throw an error if any document is not valid.
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
strict?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare const _default: (options?: atscriptPluginOptions | undefined) => rollup.Plugin<any> | rollup.Plugin<any>[];
|
|
12
|
+
|
|
13
|
+
export { _default as default };
|
package/dist/rollup.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createRollupPlugin } from "unplugin";
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
|
+
import ts from "@atscript/typescript";
|
|
6
|
+
|
|
7
|
+
//#region packages/unplugin/src/index.ts
|
|
8
|
+
const unpluginFactory = (opts) => {
|
|
9
|
+
const root = process.cwd();
|
|
10
|
+
const atscriptConfig = new Promise((resolve) => {
|
|
11
|
+
resolveConfigFile(root).then((p) => {
|
|
12
|
+
loadConfig(p).then(resolve);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
const strict = opts?.strict ?? true;
|
|
16
|
+
let repo;
|
|
17
|
+
return {
|
|
18
|
+
name: "unplugin-atscript",
|
|
19
|
+
resolveId(id, importer) {
|
|
20
|
+
if (importer && id.endsWith(".as")) return path.join(path.dirname(importer), id);
|
|
21
|
+
},
|
|
22
|
+
async load(id) {
|
|
23
|
+
if (id.endsWith(".as")) {
|
|
24
|
+
if (!repo) {
|
|
25
|
+
const config = await atscriptConfig;
|
|
26
|
+
if (!config.plugins) config.plugins = [ts()];
|
|
27
|
+
repo = new AtscriptRepo(root, config);
|
|
28
|
+
}
|
|
29
|
+
const code = (await readFile(id, "utf8")).toString();
|
|
30
|
+
const doc = await repo.openDocument(`file://${id}`, code);
|
|
31
|
+
await repo.checkDoc(doc);
|
|
32
|
+
const messages = doc.getDiagMessages().reverse();
|
|
33
|
+
let error = "";
|
|
34
|
+
for (const m of messages) if (m.severity === 1) {
|
|
35
|
+
console.log(doc.renderDiagMessage(m, true, true));
|
|
36
|
+
if (strict && !error) error = m.message;
|
|
37
|
+
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
38
|
+
if (error) throw new Error(error);
|
|
39
|
+
const out = await doc.render("js");
|
|
40
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
41
|
+
return {
|
|
42
|
+
code: out?.[0]?.content || "",
|
|
43
|
+
moduleType: "js",
|
|
44
|
+
map: null,
|
|
45
|
+
moduleSideEffects: hasMutatingAnnotates ? undefined : false
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region packages/unplugin/src/rollup.ts
|
|
54
|
+
var rollup_default = createRollupPlugin(unpluginFactory);
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { rollup_default as default };
|
package/dist/rspack.cjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//#region rolldown:runtime
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") 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) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
const unplugin = __toESM(require("unplugin"));
|
|
26
|
+
const fs_promises = __toESM(require("fs/promises"));
|
|
27
|
+
const path = __toESM(require("path"));
|
|
28
|
+
const __atscript_core = __toESM(require("@atscript/core"));
|
|
29
|
+
const __atscript_typescript = __toESM(require("@atscript/typescript"));
|
|
30
|
+
|
|
31
|
+
//#region packages/unplugin/src/index.ts
|
|
32
|
+
const unpluginFactory = (opts) => {
|
|
33
|
+
const root = process.cwd();
|
|
34
|
+
const atscriptConfig = new Promise((resolve) => {
|
|
35
|
+
(0, __atscript_core.resolveConfigFile)(root).then((p) => {
|
|
36
|
+
(0, __atscript_core.loadConfig)(p).then(resolve);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
const strict = opts?.strict ?? true;
|
|
40
|
+
let repo;
|
|
41
|
+
return {
|
|
42
|
+
name: "unplugin-atscript",
|
|
43
|
+
resolveId(id, importer) {
|
|
44
|
+
if (importer && id.endsWith(".as")) return path.default.join(path.default.dirname(importer), id);
|
|
45
|
+
},
|
|
46
|
+
async load(id) {
|
|
47
|
+
if (id.endsWith(".as")) {
|
|
48
|
+
if (!repo) {
|
|
49
|
+
const config = await atscriptConfig;
|
|
50
|
+
if (!config.plugins) config.plugins = [(0, __atscript_typescript.default)()];
|
|
51
|
+
repo = new __atscript_core.AtscriptRepo(root, config);
|
|
52
|
+
}
|
|
53
|
+
const code = (await (0, fs_promises.readFile)(id, "utf8")).toString();
|
|
54
|
+
const doc = await repo.openDocument(`file://${id}`, code);
|
|
55
|
+
await repo.checkDoc(doc);
|
|
56
|
+
const messages = doc.getDiagMessages().reverse();
|
|
57
|
+
let error = "";
|
|
58
|
+
for (const m of messages) if (m.severity === 1) {
|
|
59
|
+
console.log(doc.renderDiagMessage(m, true, true));
|
|
60
|
+
if (strict && !error) error = m.message;
|
|
61
|
+
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
62
|
+
if (error) throw new Error(error);
|
|
63
|
+
const out = await doc.render("js");
|
|
64
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => (0, __atscript_core.isAnnotate)(n) && n.isMutating);
|
|
65
|
+
return {
|
|
66
|
+
code: out?.[0]?.content || "",
|
|
67
|
+
moduleType: "js",
|
|
68
|
+
map: null,
|
|
69
|
+
moduleSideEffects: hasMutatingAnnotates ? undefined : false
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region packages/unplugin/src/rspack.ts
|
|
78
|
+
var rspack_default = (0, unplugin.createRspackPlugin)(unpluginFactory);
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
module.exports = rspack_default;
|
package/dist/rspack.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface atscriptPluginOptions {
|
|
2
|
+
/**
|
|
3
|
+
* When strict: true, atscript will throw an error if any document is not valid.
|
|
4
|
+
* @default true
|
|
5
|
+
*/
|
|
6
|
+
strict?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare const _default: (options?: atscriptPluginOptions | undefined) => RspackPluginInstance;
|
|
10
|
+
|
|
11
|
+
export { _default as default };
|
package/dist/rspack.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createRspackPlugin } from "unplugin";
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
|
+
import ts from "@atscript/typescript";
|
|
6
|
+
|
|
7
|
+
//#region packages/unplugin/src/index.ts
|
|
8
|
+
const unpluginFactory = (opts) => {
|
|
9
|
+
const root = process.cwd();
|
|
10
|
+
const atscriptConfig = new Promise((resolve) => {
|
|
11
|
+
resolveConfigFile(root).then((p) => {
|
|
12
|
+
loadConfig(p).then(resolve);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
const strict = opts?.strict ?? true;
|
|
16
|
+
let repo;
|
|
17
|
+
return {
|
|
18
|
+
name: "unplugin-atscript",
|
|
19
|
+
resolveId(id, importer) {
|
|
20
|
+
if (importer && id.endsWith(".as")) return path.join(path.dirname(importer), id);
|
|
21
|
+
},
|
|
22
|
+
async load(id) {
|
|
23
|
+
if (id.endsWith(".as")) {
|
|
24
|
+
if (!repo) {
|
|
25
|
+
const config = await atscriptConfig;
|
|
26
|
+
if (!config.plugins) config.plugins = [ts()];
|
|
27
|
+
repo = new AtscriptRepo(root, config);
|
|
28
|
+
}
|
|
29
|
+
const code = (await readFile(id, "utf8")).toString();
|
|
30
|
+
const doc = await repo.openDocument(`file://${id}`, code);
|
|
31
|
+
await repo.checkDoc(doc);
|
|
32
|
+
const messages = doc.getDiagMessages().reverse();
|
|
33
|
+
let error = "";
|
|
34
|
+
for (const m of messages) if (m.severity === 1) {
|
|
35
|
+
console.log(doc.renderDiagMessage(m, true, true));
|
|
36
|
+
if (strict && !error) error = m.message;
|
|
37
|
+
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
38
|
+
if (error) throw new Error(error);
|
|
39
|
+
const out = await doc.render("js");
|
|
40
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
41
|
+
return {
|
|
42
|
+
code: out?.[0]?.content || "",
|
|
43
|
+
moduleType: "js",
|
|
44
|
+
map: null,
|
|
45
|
+
moduleSideEffects: hasMutatingAnnotates ? undefined : false
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region packages/unplugin/src/rspack.ts
|
|
54
|
+
var rspack_default = createRspackPlugin(unpluginFactory);
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { rspack_default as default };
|
package/dist/vite.cjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//#region rolldown:runtime
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") 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) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
const unplugin = __toESM(require("unplugin"));
|
|
26
|
+
const fs_promises = __toESM(require("fs/promises"));
|
|
27
|
+
const path = __toESM(require("path"));
|
|
28
|
+
const __atscript_core = __toESM(require("@atscript/core"));
|
|
29
|
+
const __atscript_typescript = __toESM(require("@atscript/typescript"));
|
|
30
|
+
|
|
31
|
+
//#region packages/unplugin/src/index.ts
|
|
32
|
+
const unpluginFactory = (opts) => {
|
|
33
|
+
const root = process.cwd();
|
|
34
|
+
const atscriptConfig = new Promise((resolve) => {
|
|
35
|
+
(0, __atscript_core.resolveConfigFile)(root).then((p) => {
|
|
36
|
+
(0, __atscript_core.loadConfig)(p).then(resolve);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
const strict = opts?.strict ?? true;
|
|
40
|
+
let repo;
|
|
41
|
+
return {
|
|
42
|
+
name: "unplugin-atscript",
|
|
43
|
+
resolveId(id, importer) {
|
|
44
|
+
if (importer && id.endsWith(".as")) return path.default.join(path.default.dirname(importer), id);
|
|
45
|
+
},
|
|
46
|
+
async load(id) {
|
|
47
|
+
if (id.endsWith(".as")) {
|
|
48
|
+
if (!repo) {
|
|
49
|
+
const config = await atscriptConfig;
|
|
50
|
+
if (!config.plugins) config.plugins = [(0, __atscript_typescript.default)()];
|
|
51
|
+
repo = new __atscript_core.AtscriptRepo(root, config);
|
|
52
|
+
}
|
|
53
|
+
const code = (await (0, fs_promises.readFile)(id, "utf8")).toString();
|
|
54
|
+
const doc = await repo.openDocument(`file://${id}`, code);
|
|
55
|
+
await repo.checkDoc(doc);
|
|
56
|
+
const messages = doc.getDiagMessages().reverse();
|
|
57
|
+
let error = "";
|
|
58
|
+
for (const m of messages) if (m.severity === 1) {
|
|
59
|
+
console.log(doc.renderDiagMessage(m, true, true));
|
|
60
|
+
if (strict && !error) error = m.message;
|
|
61
|
+
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
62
|
+
if (error) throw new Error(error);
|
|
63
|
+
const out = await doc.render("js");
|
|
64
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => (0, __atscript_core.isAnnotate)(n) && n.isMutating);
|
|
65
|
+
return {
|
|
66
|
+
code: out?.[0]?.content || "",
|
|
67
|
+
moduleType: "js",
|
|
68
|
+
map: null,
|
|
69
|
+
moduleSideEffects: hasMutatingAnnotates ? undefined : false
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region packages/unplugin/src/vite.ts
|
|
78
|
+
var vite_default = (0, unplugin.createVitePlugin)(unpluginFactory);
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
module.exports = vite_default;
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as _unplugin from 'unplugin';
|
|
2
|
+
|
|
3
|
+
interface atscriptPluginOptions {
|
|
4
|
+
/**
|
|
5
|
+
* When strict: true, atscript will throw an error if any document is not valid.
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
strict?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare const _default: (options?: atscriptPluginOptions | undefined) => _unplugin.VitePlugin<any> | _unplugin.VitePlugin<any>[];
|
|
12
|
+
|
|
13
|
+
export { _default as default };
|
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createVitePlugin } from "unplugin";
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
|
+
import ts from "@atscript/typescript";
|
|
6
|
+
|
|
7
|
+
//#region packages/unplugin/src/index.ts
|
|
8
|
+
const unpluginFactory = (opts) => {
|
|
9
|
+
const root = process.cwd();
|
|
10
|
+
const atscriptConfig = new Promise((resolve) => {
|
|
11
|
+
resolveConfigFile(root).then((p) => {
|
|
12
|
+
loadConfig(p).then(resolve);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
const strict = opts?.strict ?? true;
|
|
16
|
+
let repo;
|
|
17
|
+
return {
|
|
18
|
+
name: "unplugin-atscript",
|
|
19
|
+
resolveId(id, importer) {
|
|
20
|
+
if (importer && id.endsWith(".as")) return path.join(path.dirname(importer), id);
|
|
21
|
+
},
|
|
22
|
+
async load(id) {
|
|
23
|
+
if (id.endsWith(".as")) {
|
|
24
|
+
if (!repo) {
|
|
25
|
+
const config = await atscriptConfig;
|
|
26
|
+
if (!config.plugins) config.plugins = [ts()];
|
|
27
|
+
repo = new AtscriptRepo(root, config);
|
|
28
|
+
}
|
|
29
|
+
const code = (await readFile(id, "utf8")).toString();
|
|
30
|
+
const doc = await repo.openDocument(`file://${id}`, code);
|
|
31
|
+
await repo.checkDoc(doc);
|
|
32
|
+
const messages = doc.getDiagMessages().reverse();
|
|
33
|
+
let error = "";
|
|
34
|
+
for (const m of messages) if (m.severity === 1) {
|
|
35
|
+
console.log(doc.renderDiagMessage(m, true, true));
|
|
36
|
+
if (strict && !error) error = m.message;
|
|
37
|
+
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
38
|
+
if (error) throw new Error(error);
|
|
39
|
+
const out = await doc.render("js");
|
|
40
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
41
|
+
return {
|
|
42
|
+
code: out?.[0]?.content || "",
|
|
43
|
+
moduleType: "js",
|
|
44
|
+
map: null,
|
|
45
|
+
moduleSideEffects: hasMutatingAnnotates ? undefined : false
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region packages/unplugin/src/vite.ts
|
|
54
|
+
var vite_default = createVitePlugin(unpluginFactory);
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { vite_default as default };
|
package/dist/webpack.cjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//#region rolldown:runtime
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") 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) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
const unplugin = __toESM(require("unplugin"));
|
|
26
|
+
const fs_promises = __toESM(require("fs/promises"));
|
|
27
|
+
const path = __toESM(require("path"));
|
|
28
|
+
const __atscript_core = __toESM(require("@atscript/core"));
|
|
29
|
+
const __atscript_typescript = __toESM(require("@atscript/typescript"));
|
|
30
|
+
|
|
31
|
+
//#region packages/unplugin/src/index.ts
|
|
32
|
+
const unpluginFactory = (opts) => {
|
|
33
|
+
const root = process.cwd();
|
|
34
|
+
const atscriptConfig = new Promise((resolve) => {
|
|
35
|
+
(0, __atscript_core.resolveConfigFile)(root).then((p) => {
|
|
36
|
+
(0, __atscript_core.loadConfig)(p).then(resolve);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
const strict = opts?.strict ?? true;
|
|
40
|
+
let repo;
|
|
41
|
+
return {
|
|
42
|
+
name: "unplugin-atscript",
|
|
43
|
+
resolveId(id, importer) {
|
|
44
|
+
if (importer && id.endsWith(".as")) return path.default.join(path.default.dirname(importer), id);
|
|
45
|
+
},
|
|
46
|
+
async load(id) {
|
|
47
|
+
if (id.endsWith(".as")) {
|
|
48
|
+
if (!repo) {
|
|
49
|
+
const config = await atscriptConfig;
|
|
50
|
+
if (!config.plugins) config.plugins = [(0, __atscript_typescript.default)()];
|
|
51
|
+
repo = new __atscript_core.AtscriptRepo(root, config);
|
|
52
|
+
}
|
|
53
|
+
const code = (await (0, fs_promises.readFile)(id, "utf8")).toString();
|
|
54
|
+
const doc = await repo.openDocument(`file://${id}`, code);
|
|
55
|
+
await repo.checkDoc(doc);
|
|
56
|
+
const messages = doc.getDiagMessages().reverse();
|
|
57
|
+
let error = "";
|
|
58
|
+
for (const m of messages) if (m.severity === 1) {
|
|
59
|
+
console.log(doc.renderDiagMessage(m, true, true));
|
|
60
|
+
if (strict && !error) error = m.message;
|
|
61
|
+
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
62
|
+
if (error) throw new Error(error);
|
|
63
|
+
const out = await doc.render("js");
|
|
64
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => (0, __atscript_core.isAnnotate)(n) && n.isMutating);
|
|
65
|
+
return {
|
|
66
|
+
code: out?.[0]?.content || "",
|
|
67
|
+
moduleType: "js",
|
|
68
|
+
map: null,
|
|
69
|
+
moduleSideEffects: hasMutatingAnnotates ? undefined : false
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region packages/unplugin/src/webpack.ts
|
|
78
|
+
var webpack_default = (0, unplugin.createWebpackPlugin)(unpluginFactory);
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
module.exports = webpack_default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface atscriptPluginOptions {
|
|
2
|
+
/**
|
|
3
|
+
* When strict: true, atscript will throw an error if any document is not valid.
|
|
4
|
+
* @default true
|
|
5
|
+
*/
|
|
6
|
+
strict?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare const _default: (options?: atscriptPluginOptions | undefined) => WebpackPluginInstance;
|
|
10
|
+
|
|
11
|
+
export { _default as default };
|
package/dist/webpack.mjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { createWebpackPlugin } from "unplugin";
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { AtscriptRepo, isAnnotate, loadConfig, resolveConfigFile } from "@atscript/core";
|
|
5
|
+
import ts from "@atscript/typescript";
|
|
6
|
+
|
|
7
|
+
//#region packages/unplugin/src/index.ts
|
|
8
|
+
const unpluginFactory = (opts) => {
|
|
9
|
+
const root = process.cwd();
|
|
10
|
+
const atscriptConfig = new Promise((resolve) => {
|
|
11
|
+
resolveConfigFile(root).then((p) => {
|
|
12
|
+
loadConfig(p).then(resolve);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
const strict = opts?.strict ?? true;
|
|
16
|
+
let repo;
|
|
17
|
+
return {
|
|
18
|
+
name: "unplugin-atscript",
|
|
19
|
+
resolveId(id, importer) {
|
|
20
|
+
if (importer && id.endsWith(".as")) return path.join(path.dirname(importer), id);
|
|
21
|
+
},
|
|
22
|
+
async load(id) {
|
|
23
|
+
if (id.endsWith(".as")) {
|
|
24
|
+
if (!repo) {
|
|
25
|
+
const config = await atscriptConfig;
|
|
26
|
+
if (!config.plugins) config.plugins = [ts()];
|
|
27
|
+
repo = new AtscriptRepo(root, config);
|
|
28
|
+
}
|
|
29
|
+
const code = (await readFile(id, "utf8")).toString();
|
|
30
|
+
const doc = await repo.openDocument(`file://${id}`, code);
|
|
31
|
+
await repo.checkDoc(doc);
|
|
32
|
+
const messages = doc.getDiagMessages().reverse();
|
|
33
|
+
let error = "";
|
|
34
|
+
for (const m of messages) if (m.severity === 1) {
|
|
35
|
+
console.log(doc.renderDiagMessage(m, true, true));
|
|
36
|
+
if (strict && !error) error = m.message;
|
|
37
|
+
} else if (m.severity === 2) console.log(doc.renderDiagMessage(m, false, true));
|
|
38
|
+
if (error) throw new Error(error);
|
|
39
|
+
const out = await doc.render("js");
|
|
40
|
+
const hasMutatingAnnotates = doc.nodes.some((n) => isAnnotate(n) && n.isMutating);
|
|
41
|
+
return {
|
|
42
|
+
code: out?.[0]?.content || "",
|
|
43
|
+
moduleType: "js",
|
|
44
|
+
map: null,
|
|
45
|
+
moduleSideEffects: hasMutatingAnnotates ? undefined : false
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region packages/unplugin/src/webpack.ts
|
|
54
|
+
var webpack_default = createWebpackPlugin(unpluginFactory);
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { webpack_default as default };
|