@kubb/agent 5.0.0-alpha.70 → 5.0.0-alpha.72
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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +98 -16
- package/.output/server/chunks/routes/api/health.get.mjs +1 -1
- package/.output/server/index.mjs +1 -1
- package/.output/server/node_modules/@rolldown/binding-linux-x64-gnu/package.json +40 -0
- package/.output/server/node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node +0 -0
- package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/composable-filters.js +256 -0
- package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/filter-vite-plugins.js +75 -0
- package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/index.js +3 -0
- package/.output/server/node_modules/@rolldown/pluginutils/dist/filter/simple-filters.js +70 -0
- package/.output/server/node_modules/@rolldown/pluginutils/dist/index.js +1 -0
- package/.output/server/node_modules/@rolldown/pluginutils/dist/utils.js +17 -0
- package/.output/server/node_modules/@rolldown/pluginutils/package.json +37 -0
- package/.output/server/node_modules/remeda/dist/isDeepEqual.js +1 -1
- package/.output/server/node_modules/remeda/package.json +14 -14
- package/.output/server/node_modules/rolldown/dist/index.mjs +50 -0
- package/.output/server/node_modules/rolldown/dist/parse-ast-index.mjs +60 -0
- package/.output/server/node_modules/rolldown/dist/shared/binding-BeU_1iEk.mjs +582 -0
- package/.output/server/node_modules/rolldown/dist/shared/bindingify-input-options-DbbBhzky.mjs +2211 -0
- package/.output/server/node_modules/rolldown/dist/shared/define-config-DJOr6Iwt.mjs +6 -0
- package/.output/server/node_modules/rolldown/dist/shared/error-DL-e8-oE.mjs +85 -0
- package/.output/server/node_modules/rolldown/dist/shared/logs-D80CXhvg.mjs +180 -0
- package/.output/server/node_modules/rolldown/dist/shared/misc-DJYbNKZX.mjs +21 -0
- package/.output/server/node_modules/rolldown/dist/shared/normalize-string-or-regex-CbQQ69gT.mjs +66 -0
- package/.output/server/node_modules/rolldown/dist/shared/parse-B_ZnWxLZ.mjs +74 -0
- package/.output/server/node_modules/rolldown/dist/shared/prompt-U5ajztzG.mjs +847 -0
- package/.output/server/node_modules/rolldown/dist/shared/rolldown-D3JZ9rMt.mjs +40 -0
- package/.output/server/node_modules/rolldown/dist/shared/rolldown-build-DSxL8qiP.mjs +3325 -0
- package/.output/server/node_modules/rolldown/dist/shared/watch-Bd8v9ewv.mjs +374 -0
- package/.output/server/node_modules/rolldown/package.json +153 -0
- package/.output/server/node_modules/unrun/dist/index.mjs +2 -0
- package/.output/server/node_modules/unrun/dist/src-GU5PtktT.mjs +887 -0
- package/.output/server/node_modules/unrun/package.json +125 -0
- package/.output/server/package.json +6 -3
- package/package.json +7 -7
- package/.output/server/node_modules/jiti/dist/jiti.cjs +0 -1
- package/.output/server/node_modules/jiti/lib/jiti.mjs +0 -29
- package/.output/server/node_modules/jiti/package.json +0 -133
package/.output/nitro.json
CHANGED
|
@@ -18,7 +18,7 @@ import { deflateSync } from 'fflate';
|
|
|
18
18
|
import { x } from 'tinyexec';
|
|
19
19
|
import { access, rm, readFile as readFile$1, readdir as readdir$1, mkdir, writeFile as writeFile$1 } from 'node:fs/promises';
|
|
20
20
|
import { styleText } from 'node:util';
|
|
21
|
-
import {
|
|
21
|
+
import { unrun } from 'unrun';
|
|
22
22
|
import { mergeDeep } from 'remeda';
|
|
23
23
|
import WebSocket from 'ws';
|
|
24
24
|
|
|
@@ -5917,13 +5917,92 @@ async function clean(path) {
|
|
|
5917
5917
|
force: true
|
|
5918
5918
|
});
|
|
5919
5919
|
}
|
|
5920
|
+
const reservedWords = /* @__PURE__ */ new Set([
|
|
5921
|
+
"abstract",
|
|
5922
|
+
"arguments",
|
|
5923
|
+
"boolean",
|
|
5924
|
+
"break",
|
|
5925
|
+
"byte",
|
|
5926
|
+
"case",
|
|
5927
|
+
"catch",
|
|
5928
|
+
"char",
|
|
5929
|
+
"class",
|
|
5930
|
+
"const",
|
|
5931
|
+
"continue",
|
|
5932
|
+
"debugger",
|
|
5933
|
+
"default",
|
|
5934
|
+
"delete",
|
|
5935
|
+
"do",
|
|
5936
|
+
"double",
|
|
5937
|
+
"else",
|
|
5938
|
+
"enum",
|
|
5939
|
+
"eval",
|
|
5940
|
+
"export",
|
|
5941
|
+
"extends",
|
|
5942
|
+
"false",
|
|
5943
|
+
"final",
|
|
5944
|
+
"finally",
|
|
5945
|
+
"float",
|
|
5946
|
+
"for",
|
|
5947
|
+
"function",
|
|
5948
|
+
"goto",
|
|
5949
|
+
"if",
|
|
5950
|
+
"implements",
|
|
5951
|
+
"import",
|
|
5952
|
+
"in",
|
|
5953
|
+
"instanceof",
|
|
5954
|
+
"int",
|
|
5955
|
+
"interface",
|
|
5956
|
+
"let",
|
|
5957
|
+
"long",
|
|
5958
|
+
"native",
|
|
5959
|
+
"new",
|
|
5960
|
+
"null",
|
|
5961
|
+
"package",
|
|
5962
|
+
"private",
|
|
5963
|
+
"protected",
|
|
5964
|
+
"public",
|
|
5965
|
+
"return",
|
|
5966
|
+
"short",
|
|
5967
|
+
"static",
|
|
5968
|
+
"super",
|
|
5969
|
+
"switch",
|
|
5970
|
+
"synchronized",
|
|
5971
|
+
"this",
|
|
5972
|
+
"throw",
|
|
5973
|
+
"throws",
|
|
5974
|
+
"transient",
|
|
5975
|
+
"true",
|
|
5976
|
+
"try",
|
|
5977
|
+
"typeof",
|
|
5978
|
+
"var",
|
|
5979
|
+
"void",
|
|
5980
|
+
"volatile",
|
|
5981
|
+
"while",
|
|
5982
|
+
"with",
|
|
5983
|
+
"yield",
|
|
5984
|
+
"Array",
|
|
5985
|
+
"Date",
|
|
5986
|
+
"hasOwnProperty",
|
|
5987
|
+
"Infinity",
|
|
5988
|
+
"isFinite",
|
|
5989
|
+
"isNaN",
|
|
5990
|
+
"isPrototypeOf",
|
|
5991
|
+
"length",
|
|
5992
|
+
"Math",
|
|
5993
|
+
"name",
|
|
5994
|
+
"NaN",
|
|
5995
|
+
"Number",
|
|
5996
|
+
"Object",
|
|
5997
|
+
"prototype",
|
|
5998
|
+
"String",
|
|
5999
|
+
"toString",
|
|
6000
|
+
"undefined",
|
|
6001
|
+
"valueOf"
|
|
6002
|
+
]);
|
|
5920
6003
|
function isValidVarName(name) {
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
} catch {
|
|
5924
|
-
return false;
|
|
5925
|
-
}
|
|
5926
|
-
return true;
|
|
6004
|
+
if (!name || reservedWords.has(name)) return false;
|
|
6005
|
+
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
5927
6006
|
}
|
|
5928
6007
|
var URLPath = (_b = class {
|
|
5929
6008
|
constructor(path, options = {}) {
|
|
@@ -6279,7 +6358,7 @@ const fsStorage = createStorage(() => ({
|
|
|
6279
6358
|
await clean(resolve(base));
|
|
6280
6359
|
}
|
|
6281
6360
|
}));
|
|
6282
|
-
var version$1 = "5.0.0-alpha.
|
|
6361
|
+
var version$1 = "5.0.0-alpha.72";
|
|
6283
6362
|
function getDiagnosticInfo() {
|
|
6284
6363
|
return {
|
|
6285
6364
|
nodeVersion: version$2,
|
|
@@ -6696,7 +6775,7 @@ const memoryStorage = createStorage(() => {
|
|
|
6696
6775
|
};
|
|
6697
6776
|
});
|
|
6698
6777
|
|
|
6699
|
-
var version = "5.0.0-alpha.
|
|
6778
|
+
var version = "5.0.0-alpha.72";
|
|
6700
6779
|
|
|
6701
6780
|
function isCommandMessage(msg) {
|
|
6702
6781
|
return msg.type === "command";
|
|
@@ -6843,17 +6922,20 @@ async function generate({ config, hooks }) {
|
|
|
6843
6922
|
}
|
|
6844
6923
|
}
|
|
6845
6924
|
|
|
6846
|
-
const
|
|
6847
|
-
|
|
6925
|
+
const unrunInputOptions = {
|
|
6926
|
+
transform: {
|
|
6848
6927
|
jsx: {
|
|
6849
6928
|
runtime: "automatic",
|
|
6850
6929
|
importSource: "@kubb/renderer-jsx"
|
|
6851
|
-
}
|
|
6852
|
-
|
|
6853
|
-
|
|
6930
|
+
}
|
|
6931
|
+
}
|
|
6932
|
+
};
|
|
6933
|
+
const tsLoader = async (configFile) => {
|
|
6934
|
+
const { module } = await unrun({
|
|
6935
|
+
path: configFile,
|
|
6936
|
+
inputOptions: unrunInputOptions
|
|
6854
6937
|
});
|
|
6855
|
-
|
|
6856
|
-
return mod;
|
|
6938
|
+
return module;
|
|
6857
6939
|
};
|
|
6858
6940
|
async function getCosmiConfig(configPath) {
|
|
6859
6941
|
var _a;
|
package/.output/server/index.mjs
CHANGED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rolldown/binding-linux-x64-gnu",
|
|
3
|
+
"version": "1.0.0-rc.17",
|
|
4
|
+
"cpu": [
|
|
5
|
+
"x64"
|
|
6
|
+
],
|
|
7
|
+
"main": "rolldown-binding.linux-x64-gnu.node",
|
|
8
|
+
"files": [
|
|
9
|
+
"rolldown-binding.linux-x64-gnu.node"
|
|
10
|
+
],
|
|
11
|
+
"description": "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"bundler",
|
|
14
|
+
"esbuild",
|
|
15
|
+
"parcel",
|
|
16
|
+
"rolldown",
|
|
17
|
+
"rollup",
|
|
18
|
+
"webpack"
|
|
19
|
+
],
|
|
20
|
+
"homepage": "https://rolldown.rs/",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/rolldown/rolldown.git",
|
|
28
|
+
"directory": "packages/rolldown"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"registry": "https://registry.npmjs.org/",
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"os": [
|
|
35
|
+
"linux"
|
|
36
|
+
],
|
|
37
|
+
"libc": [
|
|
38
|
+
"glibc"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { cleanUrl, extractQueryWithoutFragment } from "../utils.js";
|
|
2
|
+
class And {
|
|
3
|
+
kind;
|
|
4
|
+
args;
|
|
5
|
+
constructor(...args) {
|
|
6
|
+
if (args.length === 0) {
|
|
7
|
+
throw new Error('`And` expects at least one operand');
|
|
8
|
+
}
|
|
9
|
+
this.args = args;
|
|
10
|
+
this.kind = 'and';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
class Or {
|
|
14
|
+
kind;
|
|
15
|
+
args;
|
|
16
|
+
constructor(...args) {
|
|
17
|
+
if (args.length === 0) {
|
|
18
|
+
throw new Error('`Or` expects at least one operand');
|
|
19
|
+
}
|
|
20
|
+
this.args = args;
|
|
21
|
+
this.kind = 'or';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class Not {
|
|
25
|
+
kind;
|
|
26
|
+
expr;
|
|
27
|
+
constructor(expr) {
|
|
28
|
+
this.expr = expr;
|
|
29
|
+
this.kind = 'not';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class Id {
|
|
33
|
+
kind;
|
|
34
|
+
pattern;
|
|
35
|
+
params;
|
|
36
|
+
constructor(pattern, params) {
|
|
37
|
+
this.pattern = pattern;
|
|
38
|
+
this.kind = 'id';
|
|
39
|
+
this.params = params ?? {
|
|
40
|
+
cleanUrl: false,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
class ImporterId {
|
|
45
|
+
kind;
|
|
46
|
+
pattern;
|
|
47
|
+
params;
|
|
48
|
+
constructor(pattern, params) {
|
|
49
|
+
this.pattern = pattern;
|
|
50
|
+
this.kind = 'importerId';
|
|
51
|
+
this.params = params ?? {
|
|
52
|
+
cleanUrl: false,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
class ModuleType {
|
|
57
|
+
kind;
|
|
58
|
+
pattern;
|
|
59
|
+
constructor(pattern) {
|
|
60
|
+
this.pattern = pattern;
|
|
61
|
+
this.kind = 'moduleType';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
class Code {
|
|
65
|
+
kind;
|
|
66
|
+
pattern;
|
|
67
|
+
constructor(expr) {
|
|
68
|
+
this.pattern = expr;
|
|
69
|
+
this.kind = 'code';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
class Query {
|
|
73
|
+
kind;
|
|
74
|
+
key;
|
|
75
|
+
pattern;
|
|
76
|
+
constructor(key, pattern) {
|
|
77
|
+
this.pattern = pattern;
|
|
78
|
+
this.key = key;
|
|
79
|
+
this.kind = 'query';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
class Include {
|
|
83
|
+
kind;
|
|
84
|
+
expr;
|
|
85
|
+
constructor(expr) {
|
|
86
|
+
this.expr = expr;
|
|
87
|
+
this.kind = 'include';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
class Exclude {
|
|
91
|
+
kind;
|
|
92
|
+
expr;
|
|
93
|
+
constructor(expr) {
|
|
94
|
+
this.expr = expr;
|
|
95
|
+
this.kind = 'exclude';
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export function and(...args) {
|
|
99
|
+
return new And(...args);
|
|
100
|
+
}
|
|
101
|
+
export function or(...args) {
|
|
102
|
+
return new Or(...args);
|
|
103
|
+
}
|
|
104
|
+
export function not(expr) {
|
|
105
|
+
return new Not(expr);
|
|
106
|
+
}
|
|
107
|
+
export function id(pattern, params) {
|
|
108
|
+
return new Id(pattern, params);
|
|
109
|
+
}
|
|
110
|
+
export function importerId(pattern, params) {
|
|
111
|
+
return new ImporterId(pattern, params);
|
|
112
|
+
}
|
|
113
|
+
export function moduleType(pattern) {
|
|
114
|
+
return new ModuleType(pattern);
|
|
115
|
+
}
|
|
116
|
+
export function code(pattern) {
|
|
117
|
+
return new Code(pattern);
|
|
118
|
+
}
|
|
119
|
+
/*
|
|
120
|
+
* There are three kinds of conditions are supported:
|
|
121
|
+
* 1. `boolean`: if the value is `true`, the key must exist and be truthy. if the value is `false`, the key must not exist or be falsy.
|
|
122
|
+
* 2. `string`: the key must exist and be equal to the value.
|
|
123
|
+
* 3. `RegExp`: the key must exist and match the value.
|
|
124
|
+
*/
|
|
125
|
+
export function query(key, pattern) {
|
|
126
|
+
return new Query(key, pattern);
|
|
127
|
+
}
|
|
128
|
+
export function include(expr) {
|
|
129
|
+
return new Include(expr);
|
|
130
|
+
}
|
|
131
|
+
export function exclude(expr) {
|
|
132
|
+
return new Exclude(expr);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* convert a queryObject to FilterExpression like
|
|
136
|
+
* ```js
|
|
137
|
+
* and(query(k1, v1), query(k2, v2))
|
|
138
|
+
* ```
|
|
139
|
+
* @param queryFilterObject The query filter object needs to be matched.
|
|
140
|
+
* @returns a `And` FilterExpression
|
|
141
|
+
*/
|
|
142
|
+
export function queries(queryFilter) {
|
|
143
|
+
let arr = Object.entries(queryFilter).map(([key, value]) => {
|
|
144
|
+
return new Query(key, value);
|
|
145
|
+
});
|
|
146
|
+
return and(...arr);
|
|
147
|
+
}
|
|
148
|
+
export function interpreter(exprs, code, id, moduleType, importerId) {
|
|
149
|
+
let arr = [];
|
|
150
|
+
if (Array.isArray(exprs)) {
|
|
151
|
+
arr = exprs;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
arr = [exprs];
|
|
155
|
+
}
|
|
156
|
+
return interpreterImpl(arr, code, id, moduleType, importerId);
|
|
157
|
+
}
|
|
158
|
+
export function interpreterImpl(expr, code, id, moduleType, importerId, ctx = {}) {
|
|
159
|
+
let hasInclude = false;
|
|
160
|
+
for (const e of expr) {
|
|
161
|
+
switch (e.kind) {
|
|
162
|
+
case 'include': {
|
|
163
|
+
hasInclude = true;
|
|
164
|
+
if (exprInterpreter(e.expr, code, id, moduleType, importerId, ctx)) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
case 'exclude': {
|
|
170
|
+
if (exprInterpreter(e.expr, code, id, moduleType, importerId, ctx)) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return !hasInclude;
|
|
178
|
+
}
|
|
179
|
+
export function exprInterpreter(expr, code, id, moduleType, importerId, ctx = {}) {
|
|
180
|
+
switch (expr.kind) {
|
|
181
|
+
case 'and': {
|
|
182
|
+
return expr.args.every((e) => exprInterpreter(e, code, id, moduleType, importerId, ctx));
|
|
183
|
+
}
|
|
184
|
+
case 'or': {
|
|
185
|
+
return expr.args.some((e) => exprInterpreter(e, code, id, moduleType, importerId, ctx));
|
|
186
|
+
}
|
|
187
|
+
case 'not': {
|
|
188
|
+
return !exprInterpreter(expr.expr, code, id, moduleType, importerId, ctx);
|
|
189
|
+
}
|
|
190
|
+
case 'id': {
|
|
191
|
+
if (id === undefined) {
|
|
192
|
+
throw new Error('`id` is required for `id` expression');
|
|
193
|
+
}
|
|
194
|
+
let idToMatch = id;
|
|
195
|
+
if (expr.params.cleanUrl) {
|
|
196
|
+
idToMatch = cleanUrl(idToMatch);
|
|
197
|
+
}
|
|
198
|
+
return typeof expr.pattern === 'string'
|
|
199
|
+
? idToMatch === expr.pattern
|
|
200
|
+
: expr.pattern.test(idToMatch);
|
|
201
|
+
}
|
|
202
|
+
case 'importerId': {
|
|
203
|
+
if (importerId === undefined) {
|
|
204
|
+
return false; // Entry files have no importer, so no match
|
|
205
|
+
}
|
|
206
|
+
let importerIdToMatch = importerId;
|
|
207
|
+
if (expr.params.cleanUrl) {
|
|
208
|
+
importerIdToMatch = cleanUrl(importerIdToMatch);
|
|
209
|
+
}
|
|
210
|
+
return typeof expr.pattern === 'string'
|
|
211
|
+
? importerIdToMatch === expr.pattern
|
|
212
|
+
: expr.pattern.test(importerIdToMatch);
|
|
213
|
+
}
|
|
214
|
+
case 'moduleType': {
|
|
215
|
+
if (moduleType === undefined) {
|
|
216
|
+
throw new Error('`moduleType` is required for `moduleType` expression');
|
|
217
|
+
}
|
|
218
|
+
return moduleType === expr.pattern;
|
|
219
|
+
}
|
|
220
|
+
case 'code': {
|
|
221
|
+
if (code === undefined) {
|
|
222
|
+
throw new Error('`code` is required for `code` expression');
|
|
223
|
+
}
|
|
224
|
+
return typeof expr.pattern === 'string'
|
|
225
|
+
? code.includes(expr.pattern)
|
|
226
|
+
: expr.pattern.test(code);
|
|
227
|
+
}
|
|
228
|
+
case 'query': {
|
|
229
|
+
if (id === undefined) {
|
|
230
|
+
throw new Error('`id` is required for `Query` expression');
|
|
231
|
+
}
|
|
232
|
+
if (!ctx.urlSearchParamsCache) {
|
|
233
|
+
let queryString = extractQueryWithoutFragment(id);
|
|
234
|
+
ctx.urlSearchParamsCache = new URLSearchParams(queryString);
|
|
235
|
+
}
|
|
236
|
+
let urlParams = ctx.urlSearchParamsCache;
|
|
237
|
+
if (typeof expr.pattern === 'boolean') {
|
|
238
|
+
if (expr.pattern) {
|
|
239
|
+
return urlParams.has(expr.key);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
return !urlParams.has(expr.key);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
else if (typeof expr.pattern === 'string') {
|
|
246
|
+
return urlParams.get(expr.key) === expr.pattern;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
return expr.pattern.test(urlParams.get(expr.key) ?? '');
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
default: {
|
|
253
|
+
throw new Error(`Expression ${JSON.stringify(expr)} is not expected.`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters out Vite plugins that have `apply: 'serve'` set.
|
|
3
|
+
*
|
|
4
|
+
* Since Rolldown operates in build mode, plugins marked with `apply: 'serve'`
|
|
5
|
+
* are intended only for Vite's dev server and should be excluded from the build process.
|
|
6
|
+
*
|
|
7
|
+
* @param plugins - Array of plugins (can include nested arrays)
|
|
8
|
+
* @returns Filtered array with serve-only plugins removed
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { defineConfig } from 'rolldown';
|
|
13
|
+
* import { filterVitePlugins } from '@rolldown/pluginutils';
|
|
14
|
+
* import viteReact from '@vitejs/plugin-react';
|
|
15
|
+
*
|
|
16
|
+
* export default defineConfig({
|
|
17
|
+
* plugins: filterVitePlugins([
|
|
18
|
+
* viteReact(),
|
|
19
|
+
* {
|
|
20
|
+
* name: 'dev-only',
|
|
21
|
+
* apply: 'serve', // This will be filtered out
|
|
22
|
+
* // ...
|
|
23
|
+
* }
|
|
24
|
+
* ])
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function filterVitePlugins(plugins) {
|
|
29
|
+
if (!plugins) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
const pluginArray = Array.isArray(plugins) ? plugins : [plugins];
|
|
33
|
+
const result = [];
|
|
34
|
+
for (const plugin of pluginArray) {
|
|
35
|
+
// Skip falsy values
|
|
36
|
+
if (!plugin) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
// Handle nested arrays recursively
|
|
40
|
+
if (Array.isArray(plugin)) {
|
|
41
|
+
result.push(...filterVitePlugins(plugin));
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
// Check if plugin has apply property
|
|
45
|
+
const pluginWithApply = plugin;
|
|
46
|
+
if ('apply' in pluginWithApply) {
|
|
47
|
+
const applyValue = pluginWithApply.apply;
|
|
48
|
+
// If apply is a function, call it with build mode
|
|
49
|
+
if (typeof applyValue === 'function') {
|
|
50
|
+
try {
|
|
51
|
+
const shouldApply = applyValue({}, // config object
|
|
52
|
+
{ command: 'build', mode: 'production' });
|
|
53
|
+
if (shouldApply) {
|
|
54
|
+
result.push(plugin);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// If function throws, include the plugin to be safe
|
|
59
|
+
result.push(plugin);
|
|
60
|
+
}
|
|
61
|
+
} // If apply is 'serve', skip this plugin
|
|
62
|
+
else if (applyValue === 'serve') {
|
|
63
|
+
continue;
|
|
64
|
+
} // If apply is 'build' or anything else, include it
|
|
65
|
+
else {
|
|
66
|
+
result.push(plugin);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// No apply property, include the plugin
|
|
71
|
+
result.push(plugin);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructs a RegExp that matches the exact string specified.
|
|
3
|
+
*
|
|
4
|
+
* This is useful for plugin hook filters.
|
|
5
|
+
*
|
|
6
|
+
* @param str the string to match.
|
|
7
|
+
* @param flags flags for the RegExp.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { exactRegex } from '@rolldown/pluginutils';
|
|
12
|
+
* const plugin = {
|
|
13
|
+
* name: 'plugin',
|
|
14
|
+
* resolveId: {
|
|
15
|
+
* filter: { id: exactRegex('foo') },
|
|
16
|
+
* handler(id) {} // will only be called for `foo`
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export function exactRegex(str, flags) {
|
|
22
|
+
return new RegExp(`^${escapeRegex(str)}$`, flags);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Constructs a RegExp that matches a value that has the specified prefix.
|
|
26
|
+
*
|
|
27
|
+
* This is useful for plugin hook filters.
|
|
28
|
+
*
|
|
29
|
+
* @param str the string to match.
|
|
30
|
+
* @param flags flags for the RegExp.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { prefixRegex } from '@rolldown/pluginutils';
|
|
35
|
+
* const plugin = {
|
|
36
|
+
* name: 'plugin',
|
|
37
|
+
* resolveId: {
|
|
38
|
+
* filter: { id: prefixRegex('foo') },
|
|
39
|
+
* handler(id) {} // will only be called for IDs starting with `foo`
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function prefixRegex(str, flags) {
|
|
45
|
+
return new RegExp(`^${escapeRegex(str)}`, flags);
|
|
46
|
+
}
|
|
47
|
+
const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
|
|
48
|
+
function escapeRegex(str) {
|
|
49
|
+
return str.replace(escapeRegexRE, '\\$&');
|
|
50
|
+
}
|
|
51
|
+
export function makeIdFiltersToMatchWithQuery(input) {
|
|
52
|
+
if (!Array.isArray(input)) {
|
|
53
|
+
return makeIdFilterToMatchWithQuery(
|
|
54
|
+
// Array.isArray cannot narrow the type
|
|
55
|
+
// https://github.com/microsoft/TypeScript/issues/17002
|
|
56
|
+
input);
|
|
57
|
+
}
|
|
58
|
+
return input.map((i) => makeIdFilterToMatchWithQuery(i));
|
|
59
|
+
}
|
|
60
|
+
function makeIdFilterToMatchWithQuery(input) {
|
|
61
|
+
if (typeof input === 'string') {
|
|
62
|
+
return `${input}{?*,}`;
|
|
63
|
+
}
|
|
64
|
+
return makeRegexIdFilterToMatchWithQuery(input);
|
|
65
|
+
}
|
|
66
|
+
function makeRegexIdFilterToMatchWithQuery(input) {
|
|
67
|
+
return new RegExp(
|
|
68
|
+
// replace `$` with `(?:\?.*)?$` (ignore `\$`)
|
|
69
|
+
input.source.replace(/(?<!\\)\$/g, '(?:\\?.*)?$'), input.flags);
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./filter/index.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const postfixRE = /[?#].*$/;
|
|
2
|
+
export function cleanUrl(url) {
|
|
3
|
+
return url.replace(postfixRE, '');
|
|
4
|
+
}
|
|
5
|
+
export function extractQueryWithoutFragment(url) {
|
|
6
|
+
const questionMarkIndex = url.indexOf('?');
|
|
7
|
+
if (questionMarkIndex === -1) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
const fragmentIndex = url.indexOf('#', questionMarkIndex); // Search for # after ?
|
|
11
|
+
if (fragmentIndex === -1) {
|
|
12
|
+
return url.substring(questionMarkIndex);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return url.substring(questionMarkIndex, fragmentIndex);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rolldown/pluginutils",
|
|
3
|
+
"version": "1.0.0-rc.17",
|
|
4
|
+
"homepage": "https://rolldown.rs/",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/rolldown/rolldown.git",
|
|
9
|
+
"directory": "packages/pluginutils"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"module": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./dist/index.js",
|
|
20
|
+
"./filter": "./dist/filter/index.js",
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/picomatch": "^4.0.0",
|
|
28
|
+
"picomatch": "^4.0.2",
|
|
29
|
+
"typescript": "^6.0.0",
|
|
30
|
+
"vitest": "^4.0.15"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc",
|
|
34
|
+
"test": "vitest --typecheck",
|
|
35
|
+
"publint": "publint ."
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{purry as e}from"./purry.js";function t(...t){return e(n,t)}function n(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null
|
|
1
|
+
import{purry as e}from"./purry.js";function t(...t){return e(n,t)}function n(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||!r(e,t))return!1;if(Array.isArray(e))return i(e,t);if(e instanceof Map)return a(e,t);if(e instanceof Set)return o(e,t);if(e instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp)return e.toString()===t.toString();if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let[r,i]of Object.entries(e))if(!(r in t)||!n(i,t[r]))return!1;return!0}function r(e,t){let n=Object.getPrototypeOf(e),r=Object.getPrototypeOf(t);return n===r?!0:n===null?r===Object.prototype:n===Object.prototype&&r===null}function i(e,t){if(e.length!==t.length)return!1;for(let[r,i]of e.entries())if(!n(i,t[r]))return!1;return!0}function a(e,t){if(e.size!==t.size)return!1;for(let[r,i]of e.entries())if(!t.has(r)||!n(i,t.get(r)))return!1;return!0}function o(e,t){if(e.size!==t.size)return!1;let r=[...t];for(let t of e){let e=!1;for(let[i,a]of r.entries())if(n(t,a)){e=!0,r.splice(i,1);break}if(!e)return!1}return!0}export{t as isDeepEqual};
|
|
2
2
|
//# sourceMappingURL=isDeepEqual.js.map
|