@powerlines/plugin-plugin 0.11.55 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +11 -0
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +9 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.cjs +69 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.js +67 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.cjs +110 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.js +107 -0
- package/dist/src/index.cjs +23 -43
- package/dist/src/index.js +26 -46
- package/dist/src/types/plugin.d.ts +2 -2
- package/package.json +13 -16
- package/dist/node_modules/.pnpm/esbuild-plugin-babel@0.2.3_@babel_core@7.28.5/node_modules/esbuild-plugin-babel/src/index.cjs +0 -46
- package/dist/node_modules/.pnpm/esbuild-plugin-babel@0.2.3_@babel_core@7.28.5/node_modules/esbuild-plugin-babel/src/index.js +0 -44
package/README.md
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
<!-- markdownlint-disable -->
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
<div align="center"
|
|
6
|
+
<div align="center">
|
|
7
|
+
<picture>
|
|
8
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/powerlines/banner-1280x640-dark-optimized.gif">
|
|
9
|
+
<source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/powerlines/banner-1280x640-light-optimized.gif">
|
|
10
|
+
<img src="https://public.storm-cdn.com/powerlines/banner-1280x640-dark-optimized.gif" width="100%" alt="Powerlines" />
|
|
11
|
+
</picture>
|
|
12
|
+
</div>
|
|
7
13
|
<br />
|
|
8
14
|
|
|
9
15
|
<div align="center">
|
|
@@ -16,7 +22,7 @@
|
|
|
16
22
|
</div>
|
|
17
23
|
|
|
18
24
|
<br />
|
|
19
|
-
This package is part of the
|
|
25
|
+
This package is part of the 🔌 <b>Powerlines</b> monorepo. Powerlines packages include CLI utility applications, tools, and various libraries used to create modern, scalable web applications.
|
|
20
26
|
<br />
|
|
21
27
|
|
|
22
28
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/vlq.ts
|
|
4
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
5
|
+
var intToChar = new Uint8Array(64);
|
|
6
|
+
var charToInt = new Uint8Array(128);
|
|
7
|
+
for (let i = 0; i < chars.length; i++) {
|
|
8
|
+
const c = chars.charCodeAt(i);
|
|
9
|
+
intToChar[i] = c;
|
|
10
|
+
charToInt[c] = i;
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/vlq.ts
|
|
2
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
3
|
+
var intToChar = new Uint8Array(64);
|
|
4
|
+
var charToInt = new Uint8Array(128);
|
|
5
|
+
for (let i = 0; i < chars.length; i++) {
|
|
6
|
+
const c = chars.charCodeAt(i);
|
|
7
|
+
intToChar[i] = c;
|
|
8
|
+
charToInt[c] = i;
|
|
9
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var parseCRORloGP = require('./parse-CRORloGP.cjs');
|
|
4
|
+
var path = require('node:path');
|
|
5
|
+
require('node:fs');
|
|
6
|
+
require('node:buffer');
|
|
7
|
+
require('../../../../@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs');
|
|
8
|
+
require('node:querystring');
|
|
9
|
+
require('node:process');
|
|
10
|
+
require('webpack-virtual-modules');
|
|
11
|
+
|
|
12
|
+
function toRollupPlugin(plugin, key) {
|
|
13
|
+
if (plugin.resolveId && false) ;
|
|
14
|
+
if (plugin.load && (plugin.loadInclude || false)) {
|
|
15
|
+
const loadHook = plugin.load;
|
|
16
|
+
const { handler, filter } = parseCRORloGP.r("load", loadHook);
|
|
17
|
+
replaceHookHandler("load", loadHook, function(...args) {
|
|
18
|
+
const [id] = args;
|
|
19
|
+
if (plugin.loadInclude && !plugin.loadInclude(id)) return;
|
|
20
|
+
if (!supportNativeFilter() && !filter(id)) return;
|
|
21
|
+
return handler.apply(this, args);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (plugin.transform && (plugin.transformInclude || false)) {
|
|
25
|
+
const transformHook = plugin.transform;
|
|
26
|
+
const { handler, filter } = parseCRORloGP.r("transform", transformHook);
|
|
27
|
+
replaceHookHandler("transform", transformHook, function(...args) {
|
|
28
|
+
const [code, id] = args;
|
|
29
|
+
if (plugin.transformInclude && !plugin.transformInclude(id)) return;
|
|
30
|
+
if (!supportNativeFilter() && !filter(id, code)) return;
|
|
31
|
+
return handler.apply(this, args);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (plugin[key]) Object.assign(plugin, plugin[key]);
|
|
35
|
+
return plugin;
|
|
36
|
+
function replaceHookHandler(name, hook, handler) {
|
|
37
|
+
if (typeof hook === "function") plugin[name] = handler;
|
|
38
|
+
else hook.handler = handler;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function supportNativeFilter(context, framework) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/rolldown/index.ts
|
|
47
|
+
function getRolldownPlugin(factory) {
|
|
48
|
+
return ((userOptions) => {
|
|
49
|
+
const plugins = parseCRORloGP.i(factory(userOptions, { framework: "rolldown" })).map((rawPlugin) => {
|
|
50
|
+
return toRollupPlugin(rawPlugin, "rolldown");
|
|
51
|
+
});
|
|
52
|
+
return plugins.length === 1 ? plugins[0] : plugins;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/rspack/index.ts
|
|
58
|
+
path.resolve(undefined, "rspack/loaders/transform.mjs");
|
|
59
|
+
path.resolve(undefined, "rspack/loaders/load.mjs");
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/webpack/index.ts
|
|
63
|
+
path.resolve(undefined, "webpack/loaders/transform.mjs");
|
|
64
|
+
path.resolve(undefined, "webpack/loaders/load.mjs");
|
|
65
|
+
function createRolldownPlugin(factory) {
|
|
66
|
+
return getRolldownPlugin(factory);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
exports.createRolldownPlugin = createRolldownPlugin;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { i as toArray, r as normalizeObjectHook } from './parse-CRORloGP.js';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import 'node:fs';
|
|
4
|
+
import 'node:buffer';
|
|
5
|
+
import '../../../../@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js';
|
|
6
|
+
import 'node:querystring';
|
|
7
|
+
import 'node:process';
|
|
8
|
+
import 'webpack-virtual-modules';
|
|
9
|
+
|
|
10
|
+
function toRollupPlugin(plugin, key) {
|
|
11
|
+
if (plugin.resolveId && false) ;
|
|
12
|
+
if (plugin.load && (plugin.loadInclude || false)) {
|
|
13
|
+
const loadHook = plugin.load;
|
|
14
|
+
const { handler, filter } = normalizeObjectHook("load", loadHook);
|
|
15
|
+
replaceHookHandler("load", loadHook, function(...args) {
|
|
16
|
+
const [id] = args;
|
|
17
|
+
if (plugin.loadInclude && !plugin.loadInclude(id)) return;
|
|
18
|
+
if (!supportNativeFilter() && !filter(id)) return;
|
|
19
|
+
return handler.apply(this, args);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (plugin.transform && (plugin.transformInclude || false)) {
|
|
23
|
+
const transformHook = plugin.transform;
|
|
24
|
+
const { handler, filter } = normalizeObjectHook("transform", transformHook);
|
|
25
|
+
replaceHookHandler("transform", transformHook, function(...args) {
|
|
26
|
+
const [code, id] = args;
|
|
27
|
+
if (plugin.transformInclude && !plugin.transformInclude(id)) return;
|
|
28
|
+
if (!supportNativeFilter() && !filter(id, code)) return;
|
|
29
|
+
return handler.apply(this, args);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (plugin[key]) Object.assign(plugin, plugin[key]);
|
|
33
|
+
return plugin;
|
|
34
|
+
function replaceHookHandler(name, hook, handler) {
|
|
35
|
+
if (typeof hook === "function") plugin[name] = handler;
|
|
36
|
+
else hook.handler = handler;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function supportNativeFilter(context, framework) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/rolldown/index.ts
|
|
45
|
+
function getRolldownPlugin(factory) {
|
|
46
|
+
return ((userOptions) => {
|
|
47
|
+
const plugins = toArray(factory(userOptions, { framework: "rolldown" })).map((rawPlugin) => {
|
|
48
|
+
return toRollupPlugin(rawPlugin, "rolldown");
|
|
49
|
+
});
|
|
50
|
+
return plugins.length === 1 ? plugins[0] : plugins;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/rspack/index.ts
|
|
56
|
+
resolve(import.meta.dirname, "rspack/loaders/transform.mjs");
|
|
57
|
+
resolve(import.meta.dirname, "rspack/loaders/load.mjs");
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/webpack/index.ts
|
|
61
|
+
resolve(import.meta.dirname, "webpack/loaders/transform.mjs");
|
|
62
|
+
resolve(import.meta.dirname, "webpack/loaders/load.mjs");
|
|
63
|
+
function createRolldownPlugin(factory) {
|
|
64
|
+
return getRolldownPlugin(factory);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { createRolldownPlugin };
|
package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.cjs
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('node:path');
|
|
4
|
+
var picomatch = require('picomatch');
|
|
5
|
+
|
|
6
|
+
//#region src/utils/general.ts
|
|
7
|
+
function toArray(array) {
|
|
8
|
+
array = array || [];
|
|
9
|
+
if (Array.isArray(array)) return array;
|
|
10
|
+
return [array];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/utils/filter.ts
|
|
15
|
+
const BACKSLASH_REGEX = /\\/g;
|
|
16
|
+
function normalize$1(path$1) {
|
|
17
|
+
return path$1.replace(BACKSLASH_REGEX, "/");
|
|
18
|
+
}
|
|
19
|
+
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
|
|
20
|
+
function isAbsolute$1(path$1) {
|
|
21
|
+
return ABSOLUTE_PATH_REGEX.test(path$1);
|
|
22
|
+
}
|
|
23
|
+
function getMatcherString(glob, cwd) {
|
|
24
|
+
if (glob.startsWith("**") || isAbsolute$1(glob)) return normalize$1(glob);
|
|
25
|
+
return normalize$1(path.resolve(cwd, glob));
|
|
26
|
+
}
|
|
27
|
+
function patternToIdFilter(pattern) {
|
|
28
|
+
if (pattern instanceof RegExp) return (id) => {
|
|
29
|
+
const normalizedId = normalize$1(id);
|
|
30
|
+
const result = pattern.test(normalizedId);
|
|
31
|
+
pattern.lastIndex = 0;
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
const matcher = picomatch(getMatcherString(pattern, process.cwd()), { dot: true });
|
|
35
|
+
return (id) => {
|
|
36
|
+
return matcher(normalize$1(id));
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function patternToCodeFilter(pattern) {
|
|
40
|
+
if (pattern instanceof RegExp) return (code) => {
|
|
41
|
+
const result = pattern.test(code);
|
|
42
|
+
pattern.lastIndex = 0;
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
return (code) => code.includes(pattern);
|
|
46
|
+
}
|
|
47
|
+
function createFilter(exclude, include) {
|
|
48
|
+
if (!exclude && !include) return;
|
|
49
|
+
return (input) => {
|
|
50
|
+
if (exclude?.some((filter) => filter(input))) return false;
|
|
51
|
+
if (include?.some((filter) => filter(input))) return true;
|
|
52
|
+
return !(include && include.length > 0);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function normalizeFilter(filter) {
|
|
56
|
+
if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
|
|
57
|
+
if (Array.isArray(filter)) return { include: filter };
|
|
58
|
+
return {
|
|
59
|
+
exclude: filter.exclude ? toArray(filter.exclude) : void 0,
|
|
60
|
+
include: filter.include ? toArray(filter.include) : void 0
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function createIdFilter(filter) {
|
|
64
|
+
if (!filter) return;
|
|
65
|
+
const { exclude, include } = normalizeFilter(filter);
|
|
66
|
+
const excludeFilter = exclude?.map(patternToIdFilter);
|
|
67
|
+
const includeFilter = include?.map(patternToIdFilter);
|
|
68
|
+
return createFilter(excludeFilter, includeFilter);
|
|
69
|
+
}
|
|
70
|
+
function createCodeFilter(filter) {
|
|
71
|
+
if (!filter) return;
|
|
72
|
+
const { exclude, include } = normalizeFilter(filter);
|
|
73
|
+
const excludeFilter = exclude?.map(patternToCodeFilter);
|
|
74
|
+
const includeFilter = include?.map(patternToCodeFilter);
|
|
75
|
+
return createFilter(excludeFilter, includeFilter);
|
|
76
|
+
}
|
|
77
|
+
function createFilterForId(filter) {
|
|
78
|
+
const filterFunction = createIdFilter(filter);
|
|
79
|
+
return filterFunction ? (id) => !!filterFunction(id) : void 0;
|
|
80
|
+
}
|
|
81
|
+
function createFilterForTransform(idFilter, codeFilter) {
|
|
82
|
+
if (!idFilter && !codeFilter) return;
|
|
83
|
+
const idFilterFunction = createIdFilter(idFilter);
|
|
84
|
+
const codeFilterFunction = createCodeFilter(codeFilter);
|
|
85
|
+
return (id, code) => {
|
|
86
|
+
let fallback = true;
|
|
87
|
+
if (idFilterFunction) fallback &&= idFilterFunction(id);
|
|
88
|
+
if (!fallback) return false;
|
|
89
|
+
if (codeFilterFunction) fallback &&= codeFilterFunction(code);
|
|
90
|
+
return fallback;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function normalizeObjectHook(name, hook) {
|
|
94
|
+
let handler;
|
|
95
|
+
let filter;
|
|
96
|
+
if (typeof hook === "function") handler = hook;
|
|
97
|
+
else {
|
|
98
|
+
handler = hook.handler;
|
|
99
|
+
const hookFilter = hook.filter;
|
|
100
|
+
if (name === "resolveId" || name === "load") filter = createFilterForId(hookFilter?.id);
|
|
101
|
+
else filter = createFilterForTransform(hookFilter?.id, hookFilter?.code);
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
handler,
|
|
105
|
+
filter: filter || (() => true)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
exports.i = toArray;
|
|
110
|
+
exports.r = normalizeObjectHook;
|
package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import picomatch from 'picomatch';
|
|
3
|
+
|
|
4
|
+
//#region src/utils/general.ts
|
|
5
|
+
function toArray(array) {
|
|
6
|
+
array = array || [];
|
|
7
|
+
if (Array.isArray(array)) return array;
|
|
8
|
+
return [array];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/utils/filter.ts
|
|
13
|
+
const BACKSLASH_REGEX = /\\/g;
|
|
14
|
+
function normalize$1(path$1) {
|
|
15
|
+
return path$1.replace(BACKSLASH_REGEX, "/");
|
|
16
|
+
}
|
|
17
|
+
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
|
|
18
|
+
function isAbsolute$1(path$1) {
|
|
19
|
+
return ABSOLUTE_PATH_REGEX.test(path$1);
|
|
20
|
+
}
|
|
21
|
+
function getMatcherString(glob, cwd) {
|
|
22
|
+
if (glob.startsWith("**") || isAbsolute$1(glob)) return normalize$1(glob);
|
|
23
|
+
return normalize$1(resolve(cwd, glob));
|
|
24
|
+
}
|
|
25
|
+
function patternToIdFilter(pattern) {
|
|
26
|
+
if (pattern instanceof RegExp) return (id) => {
|
|
27
|
+
const normalizedId = normalize$1(id);
|
|
28
|
+
const result = pattern.test(normalizedId);
|
|
29
|
+
pattern.lastIndex = 0;
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
const matcher = picomatch(getMatcherString(pattern, process.cwd()), { dot: true });
|
|
33
|
+
return (id) => {
|
|
34
|
+
return matcher(normalize$1(id));
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function patternToCodeFilter(pattern) {
|
|
38
|
+
if (pattern instanceof RegExp) return (code) => {
|
|
39
|
+
const result = pattern.test(code);
|
|
40
|
+
pattern.lastIndex = 0;
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
return (code) => code.includes(pattern);
|
|
44
|
+
}
|
|
45
|
+
function createFilter(exclude, include) {
|
|
46
|
+
if (!exclude && !include) return;
|
|
47
|
+
return (input) => {
|
|
48
|
+
if (exclude?.some((filter) => filter(input))) return false;
|
|
49
|
+
if (include?.some((filter) => filter(input))) return true;
|
|
50
|
+
return !(include && include.length > 0);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function normalizeFilter(filter) {
|
|
54
|
+
if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
|
|
55
|
+
if (Array.isArray(filter)) return { include: filter };
|
|
56
|
+
return {
|
|
57
|
+
exclude: filter.exclude ? toArray(filter.exclude) : void 0,
|
|
58
|
+
include: filter.include ? toArray(filter.include) : void 0
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function createIdFilter(filter) {
|
|
62
|
+
if (!filter) return;
|
|
63
|
+
const { exclude, include } = normalizeFilter(filter);
|
|
64
|
+
const excludeFilter = exclude?.map(patternToIdFilter);
|
|
65
|
+
const includeFilter = include?.map(patternToIdFilter);
|
|
66
|
+
return createFilter(excludeFilter, includeFilter);
|
|
67
|
+
}
|
|
68
|
+
function createCodeFilter(filter) {
|
|
69
|
+
if (!filter) return;
|
|
70
|
+
const { exclude, include } = normalizeFilter(filter);
|
|
71
|
+
const excludeFilter = exclude?.map(patternToCodeFilter);
|
|
72
|
+
const includeFilter = include?.map(patternToCodeFilter);
|
|
73
|
+
return createFilter(excludeFilter, includeFilter);
|
|
74
|
+
}
|
|
75
|
+
function createFilterForId(filter) {
|
|
76
|
+
const filterFunction = createIdFilter(filter);
|
|
77
|
+
return filterFunction ? (id) => !!filterFunction(id) : void 0;
|
|
78
|
+
}
|
|
79
|
+
function createFilterForTransform(idFilter, codeFilter) {
|
|
80
|
+
if (!idFilter && !codeFilter) return;
|
|
81
|
+
const idFilterFunction = createIdFilter(idFilter);
|
|
82
|
+
const codeFilterFunction = createCodeFilter(codeFilter);
|
|
83
|
+
return (id, code) => {
|
|
84
|
+
let fallback = true;
|
|
85
|
+
if (idFilterFunction) fallback &&= idFilterFunction(id);
|
|
86
|
+
if (!fallback) return false;
|
|
87
|
+
if (codeFilterFunction) fallback &&= codeFilterFunction(code);
|
|
88
|
+
return fallback;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function normalizeObjectHook(name, hook) {
|
|
92
|
+
let handler;
|
|
93
|
+
let filter;
|
|
94
|
+
if (typeof hook === "function") handler = hook;
|
|
95
|
+
else {
|
|
96
|
+
handler = hook.handler;
|
|
97
|
+
const hookFilter = hook.filter;
|
|
98
|
+
if (name === "resolveId" || name === "load") filter = createFilterForId(hookFilter?.id);
|
|
99
|
+
else filter = createFilterForTransform(hookFilter?.id, hookFilter?.code);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
handler,
|
|
103
|
+
filter: filter || (() => true)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { toArray as i, normalizeObjectHook as r };
|
package/dist/src/index.cjs
CHANGED
|
@@ -3,25 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var src_types_plugin = require('./types/plugin.cjs');
|
|
6
|
-
var
|
|
7
|
-
var typescriptBabelPreset = require('@babel/preset-typescript');
|
|
6
|
+
var alloyPlugin = require('@alloy-js/rollup-plugin');
|
|
8
7
|
var types = require('@storm-software/config-tools/types');
|
|
9
|
-
var tsup = require('@storm-software/tsup');
|
|
10
8
|
var parseTypeDefinition = require('@stryke/convert/parse-type-definition');
|
|
11
9
|
var stormJson = require('@stryke/json/storm-json');
|
|
12
|
-
var isParentPath = require('@stryke/path/is-parent-path');
|
|
13
|
-
var join = require('@stryke/path/join');
|
|
14
10
|
var titleCase = require('@stryke/string-format/title-case');
|
|
15
|
-
var
|
|
11
|
+
var isSetString = require('@stryke/type-checks/is-set-string');
|
|
16
12
|
var defu = require('defu');
|
|
17
|
-
var
|
|
18
|
-
var
|
|
13
|
+
var tsdown$1 = require('powerlines/lib/build/tsdown');
|
|
14
|
+
var unplugin = require('powerlines/lib/unplugin');
|
|
15
|
+
var tsdown = require('tsdown');
|
|
16
|
+
var index = require('../node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.cjs');
|
|
19
17
|
|
|
20
18
|
/*@ts-ignore*/
|
|
21
19
|
function __assignType(fn, args) {
|
|
22
20
|
fn.__type = args;
|
|
23
21
|
return fn;
|
|
24
22
|
}
|
|
23
|
+
function createPlugin(context) {
|
|
24
|
+
return index.createRolldownPlugin(unplugin.createUnplugin(context))({});
|
|
25
|
+
}
|
|
26
|
+
createPlugin.__type = ['context', 'createPlugin', 'P"2!"/"'];
|
|
25
27
|
/**
|
|
26
28
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
27
29
|
*/
|
|
@@ -37,9 +39,9 @@ const plugin = __assignType((options = {}) => {
|
|
|
37
39
|
format: ["cjs", "esm"]
|
|
38
40
|
},
|
|
39
41
|
build: {
|
|
40
|
-
variant: "
|
|
42
|
+
variant: "tsdown",
|
|
43
|
+
unbundle: false,
|
|
41
44
|
external: ["powerlines"],
|
|
42
|
-
bundle: false,
|
|
43
45
|
skipNodeModulesBundle: true,
|
|
44
46
|
platform: "node"
|
|
45
47
|
}
|
|
@@ -54,12 +56,12 @@ const plugin = __assignType((options = {}) => {
|
|
|
54
56
|
await this.fs.write(this.tsconfig.tsconfigFilePath, stormJson.StormJSON.stringify(this.tsconfig.tsconfigJson));
|
|
55
57
|
}
|
|
56
58
|
}, ['configResolved', 'P"/!']),
|
|
57
|
-
|
|
59
|
+
types: __assignType(async function types(code) {
|
|
58
60
|
if (!options.types?.userConfig) {
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
61
63
|
let typeDef;
|
|
62
|
-
if (
|
|
64
|
+
if (isSetString.isSetString(options.types.userConfig) &&
|
|
63
65
|
!options.types.userConfig.includes("#") &&
|
|
64
66
|
this.packageJson?.name) {
|
|
65
67
|
const pluginRoot = await this.resolve(this.packageJson.name);
|
|
@@ -78,44 +80,22 @@ const plugin = __assignType((options = {}) => {
|
|
|
78
80
|
return;
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
|
-
return `${code}
|
|
83
|
+
return `${code || ""}
|
|
82
84
|
|
|
83
85
|
// Extend \`UserConfig\` with the ${titleCase.titleCase(this.config.name)} plugin's type definition
|
|
84
86
|
declare module "powerlines" {
|
|
85
87
|
export interface UserConfig extends import("${typeDef.file}").${typeDef.name || "default"}
|
|
86
88
|
}
|
|
87
|
-
|
|
88
|
-
}, ['code', '
|
|
89
|
+
`.trim();
|
|
90
|
+
}, ['code', 'types', 'P&2!"/"']),
|
|
89
91
|
async build() {
|
|
90
|
-
await
|
|
92
|
+
await tsdown.build(defu.defu({
|
|
91
93
|
config: false,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
], ['param0', '', 'P"2!"/"'])))
|
|
98
|
-
}, tsup$1.extractTsupConfig(this), {
|
|
99
|
-
esbuildPlugins: options.alloy
|
|
100
|
-
? [
|
|
101
|
-
index({
|
|
102
|
-
filter: /\.tsx$/,
|
|
103
|
-
config: {
|
|
104
|
-
presets: [
|
|
105
|
-
[
|
|
106
|
-
typescriptBabelPreset,
|
|
107
|
-
{
|
|
108
|
-
allExtensions: true,
|
|
109
|
-
allowDeclareFields: true,
|
|
110
|
-
isTSX: true
|
|
111
|
-
}
|
|
112
|
-
],
|
|
113
|
-
alloyBabelPreset
|
|
114
|
-
]
|
|
115
|
-
}})
|
|
116
|
-
]
|
|
117
|
-
: []
|
|
118
|
-
})));
|
|
94
|
+
plugins: [
|
|
95
|
+
(createPlugin.Ω = [[() => src_types_plugin.__ΩPluginPluginContext, 'n!']], createPlugin(this)),
|
|
96
|
+
options.alloy && alloyPlugin()
|
|
97
|
+
].filter(Boolean)
|
|
98
|
+
}, tsdown$1.extractTsdownConfig(this)));
|
|
119
99
|
}
|
|
120
100
|
};
|
|
121
101
|
}, [() => src_types_plugin.__ΩPluginPluginOptions, 'options', () => ({}), '', 'Pn!2">#!/$']);
|
package/dist/src/index.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import { __ΩPluginPluginOptions as ___PluginPluginOptions } from './types/plugin.js';
|
|
2
|
-
export { __ΩPluginPluginAlloyOptions, __Ω
|
|
3
|
-
import
|
|
4
|
-
import typescriptBabelPreset from '@babel/preset-typescript';
|
|
1
|
+
import { __ΩPluginPluginOptions as ___PluginPluginOptions, __ΩPluginPluginContext as ___PluginPluginContext } from './types/plugin.js';
|
|
2
|
+
export { __ΩPluginPluginAlloyOptions, __ΩPluginPluginResolvedConfig, __ΩPluginPluginTypesOptions, __ΩPluginPluginUserConfig } from './types/plugin.js';
|
|
3
|
+
import alloyPlugin from '@alloy-js/rollup-plugin';
|
|
5
4
|
import { LogLevelLabel } from '@storm-software/config-tools/types';
|
|
6
|
-
import { build, resolveOptions } from '@storm-software/tsup';
|
|
7
5
|
import { parseTypeDefinition } from '@stryke/convert/parse-type-definition';
|
|
8
6
|
import { StormJSON } from '@stryke/json/storm-json';
|
|
9
|
-
import { isParentPath } from '@stryke/path/is-parent-path';
|
|
10
|
-
import { joinPaths } from '@stryke/path/join';
|
|
11
7
|
import { titleCase } from '@stryke/string-format/title-case';
|
|
12
|
-
import {
|
|
8
|
+
import { isSetString } from '@stryke/type-checks/is-set-string';
|
|
13
9
|
import { defu } from 'defu';
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
10
|
+
import { extractTsdownConfig } from 'powerlines/lib/build/tsdown';
|
|
11
|
+
import { createUnplugin } from 'powerlines/lib/unplugin';
|
|
12
|
+
import { build } from 'tsdown';
|
|
13
|
+
import { createRolldownPlugin } from '../node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.js';
|
|
16
14
|
|
|
17
15
|
/*@ts-ignore*/
|
|
18
16
|
function __assignType(fn, args) {
|
|
19
17
|
fn.__type = args;
|
|
20
18
|
return fn;
|
|
21
19
|
}
|
|
20
|
+
function createPlugin(context) {
|
|
21
|
+
return createRolldownPlugin(createUnplugin(context))({});
|
|
22
|
+
}
|
|
23
|
+
createPlugin.__type = ['context', 'createPlugin', 'P"2!"/"'];
|
|
22
24
|
/**
|
|
23
25
|
* A Powerlines plugin to assist in developing other Powerlines plugins.
|
|
24
26
|
*/
|
|
@@ -34,9 +36,9 @@ const plugin = __assignType((options = {}) => {
|
|
|
34
36
|
format: ["cjs", "esm"]
|
|
35
37
|
},
|
|
36
38
|
build: {
|
|
37
|
-
variant: "
|
|
39
|
+
variant: "tsdown",
|
|
40
|
+
unbundle: false,
|
|
38
41
|
external: ["powerlines"],
|
|
39
|
-
bundle: false,
|
|
40
42
|
skipNodeModulesBundle: true,
|
|
41
43
|
platform: "node"
|
|
42
44
|
}
|
|
@@ -51,12 +53,12 @@ const plugin = __assignType((options = {}) => {
|
|
|
51
53
|
await this.fs.write(this.tsconfig.tsconfigFilePath, StormJSON.stringify(this.tsconfig.tsconfigJson));
|
|
52
54
|
}
|
|
53
55
|
}, ['configResolved', 'P"/!']),
|
|
54
|
-
|
|
56
|
+
types: __assignType(async function types(code) {
|
|
55
57
|
if (!options.types?.userConfig) {
|
|
56
58
|
return;
|
|
57
59
|
}
|
|
58
60
|
let typeDef;
|
|
59
|
-
if (
|
|
61
|
+
if (isSetString(options.types.userConfig) &&
|
|
60
62
|
!options.types.userConfig.includes("#") &&
|
|
61
63
|
this.packageJson?.name) {
|
|
62
64
|
const pluginRoot = await this.resolve(this.packageJson.name);
|
|
@@ -75,46 +77,24 @@ const plugin = __assignType((options = {}) => {
|
|
|
75
77
|
return;
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
|
-
return `${code}
|
|
80
|
+
return `${code || ""}
|
|
79
81
|
|
|
80
82
|
// Extend \`UserConfig\` with the ${titleCase(this.config.name)} plugin's type definition
|
|
81
83
|
declare module "powerlines" {
|
|
82
84
|
export interface UserConfig extends import("${typeDef.file}").${typeDef.name || "default"}
|
|
83
85
|
}
|
|
84
|
-
|
|
85
|
-
}, ['code', '
|
|
86
|
+
`.trim();
|
|
87
|
+
}, ['code', 'types', 'P&2!"/"']),
|
|
86
88
|
async build() {
|
|
87
|
-
await build(
|
|
89
|
+
await build(defu({
|
|
88
90
|
config: false,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
], ['param0', '', 'P"2!"/"'])))
|
|
95
|
-
}, extractTsupConfig(this), {
|
|
96
|
-
esbuildPlugins: options.alloy
|
|
97
|
-
? [
|
|
98
|
-
pluginBabel({
|
|
99
|
-
filter: /\.tsx$/,
|
|
100
|
-
config: {
|
|
101
|
-
presets: [
|
|
102
|
-
[
|
|
103
|
-
typescriptBabelPreset,
|
|
104
|
-
{
|
|
105
|
-
allExtensions: true,
|
|
106
|
-
allowDeclareFields: true,
|
|
107
|
-
isTSX: true
|
|
108
|
-
}
|
|
109
|
-
],
|
|
110
|
-
alloyBabelPreset
|
|
111
|
-
]
|
|
112
|
-
}})
|
|
113
|
-
]
|
|
114
|
-
: []
|
|
115
|
-
})));
|
|
91
|
+
plugins: [
|
|
92
|
+
(createPlugin.Ω = [[() => ___PluginPluginContext, 'n!']], createPlugin(this)),
|
|
93
|
+
options.alloy && alloyPlugin()
|
|
94
|
+
].filter(Boolean)
|
|
95
|
+
}, extractTsdownConfig(this)));
|
|
116
96
|
}
|
|
117
97
|
};
|
|
118
98
|
}, [() => ___PluginPluginOptions, 'options', () => ({}), '', 'Pn!2">#!/$']);
|
|
119
99
|
|
|
120
|
-
export { ___PluginPluginOptions as __ΩPluginPluginOptions, plugin as default, plugin };
|
|
100
|
+
export { ___PluginPluginContext as __ΩPluginPluginContext, ___PluginPluginOptions as __ΩPluginPluginOptions, plugin as default, plugin };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PrintTreeOptions } from "@alloy-js/core";
|
|
2
2
|
import { TypeDefinitionParameter } from "@stryke/types/configuration";
|
|
3
|
-
import type {
|
|
3
|
+
import type { TsdownBuildConfig, TsdownResolvedBuildConfig } from "powerlines/types/build";
|
|
4
4
|
import type { UserConfig } from "powerlines/types/config";
|
|
5
5
|
import type { PluginContext } from "powerlines/types/context";
|
|
6
6
|
import type { ResolvedConfig } from "powerlines/types/resolved";
|
|
@@ -43,7 +43,7 @@ export interface PluginPluginOptions {
|
|
|
43
43
|
*/
|
|
44
44
|
types?: PluginPluginTypesOptions;
|
|
45
45
|
}
|
|
46
|
-
export type PluginPluginUserConfig = UserConfig<
|
|
46
|
+
export type PluginPluginUserConfig = UserConfig<TsdownBuildConfig, TsdownResolvedBuildConfig, "tsdown"> & {
|
|
47
47
|
plugin: PluginPluginOptions;
|
|
48
48
|
};
|
|
49
49
|
export type PluginPluginResolvedConfig = ResolvedConfig<PluginPluginUserConfig> & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing a Powerlines plugin to assist in developing other Powerlines plugins.",
|
|
6
6
|
"repository": {
|
|
@@ -117,35 +117,32 @@
|
|
|
117
117
|
"files": ["dist/**/*"],
|
|
118
118
|
"keywords": ["powerlines", "storm-software", "powerlines-plugin"],
|
|
119
119
|
"dependencies": {
|
|
120
|
-
"@alloy-js/
|
|
120
|
+
"@alloy-js/rollup-plugin": "^0.1.0",
|
|
121
121
|
"@alloy-js/core": "^0.20.0",
|
|
122
122
|
"@alloy-js/json": "^0.20.0",
|
|
123
123
|
"@alloy-js/markdown": "^0.20.0",
|
|
124
124
|
"@alloy-js/typescript": "^0.20.0",
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
"@stryke/fs": "^0.33.
|
|
128
|
-
"@stryke/json": "^0.9.
|
|
129
|
-
"@stryke/path": "^0.
|
|
130
|
-
"@stryke/string-format": "^0.12.
|
|
131
|
-
"@stryke/type-checks": "^0.4.
|
|
132
|
-
"@stryke/types": "^0.10.
|
|
125
|
+
"tsdown": "0.17.0-beta.5",
|
|
126
|
+
"unplugin": "3.0.0-beta.3",
|
|
127
|
+
"@stryke/fs": "^0.33.9",
|
|
128
|
+
"@stryke/json": "^0.9.16",
|
|
129
|
+
"@stryke/path": "^0.22.0",
|
|
130
|
+
"@stryke/string-format": "^0.12.13",
|
|
131
|
+
"@stryke/type-checks": "^0.4.4",
|
|
132
|
+
"@stryke/types": "^0.10.13",
|
|
133
133
|
"defu": "^6.1.4",
|
|
134
|
-
"esbuild-plugin-babel": "^0.2.3",
|
|
135
134
|
"jiti": "^2.6.1",
|
|
136
|
-
"powerlines": "^0.
|
|
135
|
+
"powerlines": "^0.30.0"
|
|
137
136
|
},
|
|
138
137
|
"devDependencies": {
|
|
139
|
-
"@
|
|
140
|
-
"@powerlines/nx": "^0.10.47",
|
|
138
|
+
"@powerlines/nx": "^0.10.49",
|
|
141
139
|
"@rollup/plugin-commonjs": "^28.0.9",
|
|
142
140
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
143
141
|
"@types/babel__helper-plugin-utils": "^7.10.3",
|
|
144
142
|
"@types/node": "^24.10.1",
|
|
145
|
-
"esbuild": "^0.25.12",
|
|
146
143
|
"rollup": "^4.53.3",
|
|
147
144
|
"rollup-plugin-typescript2": "^0.36.0"
|
|
148
145
|
},
|
|
149
146
|
"publishConfig": { "access": "public" },
|
|
150
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "f0a4e1526773f5d4bfb63fd5ba1d02d5aa9bc771"
|
|
151
148
|
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var babel = require('@babel/core');
|
|
4
|
-
var fs = require('fs');
|
|
5
|
-
var path = require('path');
|
|
6
|
-
|
|
7
|
-
const pluginBabel = (options = {}) => ({
|
|
8
|
-
name: 'babel',
|
|
9
|
-
setup(build, { transform } = {}) {
|
|
10
|
-
const { filter = /.*/, namespace = '', config = {} } = options;
|
|
11
|
-
|
|
12
|
-
const transformContents = ({ args, contents }) => {
|
|
13
|
-
const babelOptions = babel.loadOptions({
|
|
14
|
-
...config,
|
|
15
|
-
filename: args.path,
|
|
16
|
-
caller: {
|
|
17
|
-
name: 'esbuild-plugin-babel',
|
|
18
|
-
supportsStaticESM: true
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
if (!babelOptions) return { contents };
|
|
22
|
-
|
|
23
|
-
if (babelOptions.sourceMaps) {
|
|
24
|
-
const filename = path.relative(process.cwd(), args.path);
|
|
25
|
-
|
|
26
|
-
babelOptions.sourceFileName = filename;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return new Promise((resolve, reject) => {
|
|
30
|
-
babel.transform(contents, babelOptions, (error, result) => {
|
|
31
|
-
error ? reject(error) : resolve({ contents: result.code });
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
if (transform) return transformContents(transform);
|
|
37
|
-
|
|
38
|
-
build.onLoad({ filter, namespace }, async args => {
|
|
39
|
-
const contents = await fs.promises.readFile(args.path, 'utf8');
|
|
40
|
-
|
|
41
|
-
return transformContents({ args, contents });
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
module.exports = pluginBabel;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import babel from '@babel/core';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
|
|
5
|
-
const pluginBabel = (options = {}) => ({
|
|
6
|
-
name: 'babel',
|
|
7
|
-
setup(build, { transform } = {}) {
|
|
8
|
-
const { filter = /.*/, namespace = '', config = {} } = options;
|
|
9
|
-
|
|
10
|
-
const transformContents = ({ args, contents }) => {
|
|
11
|
-
const babelOptions = babel.loadOptions({
|
|
12
|
-
...config,
|
|
13
|
-
filename: args.path,
|
|
14
|
-
caller: {
|
|
15
|
-
name: 'esbuild-plugin-babel',
|
|
16
|
-
supportsStaticESM: true
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
if (!babelOptions) return { contents };
|
|
20
|
-
|
|
21
|
-
if (babelOptions.sourceMaps) {
|
|
22
|
-
const filename = path.relative(process.cwd(), args.path);
|
|
23
|
-
|
|
24
|
-
babelOptions.sourceFileName = filename;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return new Promise((resolve, reject) => {
|
|
28
|
-
babel.transform(contents, babelOptions, (error, result) => {
|
|
29
|
-
error ? reject(error) : resolve({ contents: result.code });
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
if (transform) return transformContents(transform);
|
|
35
|
-
|
|
36
|
-
build.onLoad({ filter, namespace }, async args => {
|
|
37
|
-
const contents = await fs.promises.readFile(args.path, 'utf8');
|
|
38
|
-
|
|
39
|
-
return transformContents({ args, contents });
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
export { pluginBabel as default };
|