jiek 0.4.1 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/rollup.cjs CHANGED
@@ -1,2 +1,333 @@
1
- "use strict";var e=require("node:path"),t=require("@jiek/utils/getWorkspaceDir"),s=require("@rollup/plugin-json"),r=require("autoprefixer"),n=require("rollup-plugin-dts"),a=require("rollup-plugin-esbuild"),i=require("rollup-plugin-postcss"),u=require("cli-progress"),o=require("@rollup/plugin-terser");function p(e){return e&&e.__esModule?e:{default:e}}var d=p(s),c=p(r),l=p(a),m=p(i),g=p(o);function y(e){return e.startsWith("node:")?e.slice(5):e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase()))}var f=(e={})=>({name:"skip",load(t){if(e.patterns?.some((e=>"string"==typeof e?t.includes(e):e.test(t))))return""}});const j={exports:"named",interop:"auto",sourcemap:!0};function $(e){return[e,{...e,entryFileNames:e.entryFileNames?.replace(/(\.js)$/,".min$1"),plugins:[...e.plugins??[],g.default()]}]}const b=t.getWorkspaceDir();function v(e,t,s,r){return{name:"progress",resolveId(s,r){(e.includes(s)||void 0===r)&&t(s)},transform(e,t){s(t)},writeBundle(e,t){Object.entries(t).forEach((([e,t])=>{void 0!==t.name&&"isEntry"in t&&r(t.name,t.fileName)}))}}}exports.template=({styled:t=!1,plugins:{index:s=[],entry:r=[],dts:a=[]}={}}={},i)=>{const{jiek:{noBrowser:o=!1,outdir:p="dist"}={}}=i,g={...j,dir:p};if(!i.name)throw new Error("pkg.name is required");const x=i.name.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())),O=Object.fromEntries(Object.entries(i.exports??{}).filter((([e])=>!e.startsWith(`./${p}`)&&!e.startsWith(p))).filter((([e])=>!/\.(json|css|scss)$/.test(e))).filter((([,e])=>"object"==typeof e&&e["inner-src"]&&e.import)).map((([e,t])=>[e.replace(/^\.$/,"index").replace(/^\.\//,""),"string"==typeof t?t:t["inner-src"]]))),[h,w]=function(){let e={};const t=new Set([]);return[({external:s}={})=>({name:"globals",resolveId:e=>s?.some((t=>t instanceof RegExp?t.test(e):t===e))?(t.add(e),{id:e,external:!0}):null,outputOptions:s=>(e=[...t].reduce(((e,t)=>({...e,[t]:y(t)})),{}),{...s,globals:e})}),{outputOptions:t=>({...t,globals:e})}]}(),q=function(){const e=process.cwd(),t=require(`${e}/package.json`),{dependencies:s={},peerDependencies:r={},optionalDependencies:n={}}=t;return Object.keys(s).concat(Object.keys(r)).concat(Object.keys(n)).map((e=>new RegExp(`^${e}(/.*)?$`))).concat([/^node:/])}(),k={},N=[d.default()],W=new u.MultiBar({clearOnComplete:!1,hideCursor:!0,format:"- {bar} | {type} | {entry} | {message}"},u.Presets.shades_classic),F=Object.values(O),E={esm:F.reduce(((e,t)=>{const s=W.create(100,0);return s.update(0,{type:"esm",entry:t,message:"waiting"}),{...e,[t]:s}}),{}),umd:F.reduce(((e,t)=>{const s=W.create(100,0);return s.update(0,{type:"umd",entry:t,message:"waiting"}),{...e,[t]:s}}),{}),dts:F.reduce(((e,t)=>{const s=W.create(100,0);return s.update(0,{type:"dts",entry:t,message:"waiting"}),{...e,[t]:s}}),{})},B=F.reduce(((e,t)=>({...e,[t]:!1})),{});return[{...k,input:O,output:[...$({...g,format:"esm",entryFileNames:"[name].esm.js",preserveModules:!0})],plugins:[v(Object.values(O),(e=>{const t=E.esm[e];t&&t.update(0,{type:"esm",entry:e,message:"processing"})}),(e=>{const t=E.esm[e];t&&t.update(50,{type:"esm",entry:e,message:`transforming ${e}`})}),((e,t)=>{const s=O[e],r=E.esm[s];r&&(t.endsWith(".min.js")?r.update(100,{type:"esm",entry:s,message:"finished"}):r.update(95,{type:"esm",entry:s,message:"processed"}))})),N,h({external:q}),t&&f({patterns:[/\.s?css$/]}),l.default(),s]},...Object.entries(O).map((([e,s])=>{const n=x+("index"===e?"":e.replace(/[@|/-](\w)/g,((e,t)=>t.toUpperCase())));return{...k,input:s,output:o?[...$({...g,name:n,format:"cjs",entryFileNames:`${e}.cjs`})]:[...$({...g,name:n,format:"iife",entryFileNames:`${e}.iife.js`}),...$({...g,name:n,format:"umd",entryFileNames:`${e}.umd.js`})],plugins:[v([s],(e=>{const t=E.umd[e];t&&t.update(0,{type:"umd",entry:e,message:"processing"})}),(e=>{const t=E.umd[s];t&&t.update(50,{type:"umd",input:s,message:`transforming ${e}`})}),((e,t)=>{const r=E.umd[s];r&&(t.endsWith(".min.js")?r.update(100,{type:"umd",input:s,message:"finished"}):r.update(95,{type:"umd",input:s,message:"processed"}))})),N,w,t&&m.default({plugins:[c.default],minimize:!0,sourceMap:!0,extract:`${e}.css`}),l.default(),r],external:q}})),{...k,input:O,output:[{dir:"dist"},{dir:"dist",entryFileNames:({name:e})=>`${e.replace(/^src\//,"")}.esm.d.ts`,preserveModules:!0}],plugins:[v(Object.values(O),(e=>{const t=E.dts[e];t&&t.update(0,{type:"dts",entry:e,message:"processing"})}),(e=>{const t=E.dts[e];t&&t.update(50,{type:"dts",entry:e,message:`transforming ${e}`})}),((e,t)=>{const s=O[e],r=E.dts[s];r&&(t.endsWith(".esm.d.ts")?(r.update(100,{type:"dts",entry:s,message:"finished"}),B[s]=!0):r.update(95,{type:"dts",entry:s,message:"processed"}),Object.values(B).every(Boolean)&&setTimeout((()=>{W.stop()}),100))})),N,t&&f({patterns:[/\.s?css$/]}),n.dts({tsconfig:(C="tsconfig.dts.json",e.resolve(b,C))}),{name:"rollup-plugin-declare-module-replacer",generateBundle(e,t){for(const e of Object.values(t))"code"in e&&(e.code=e.code.replace(/declare module ['|"]\..*['|"]/g,`declare module '${i.name}'`))}},a],external:q}];var C};
1
+ 'use strict';
2
+
3
+ var node_path = require('node:path');
4
+ var getWorkspaceDir = require('@jiek/utils/getWorkspaceDir');
5
+ var json = require('@rollup/plugin-json');
6
+ var autoprefixer = require('autoprefixer');
7
+ var cliProgress = require('cli-progress');
8
+ var rollupPluginDts = require('rollup-plugin-dts');
9
+ var esbuild = require('rollup-plugin-esbuild');
10
+ var postcss = require('rollup-plugin-postcss');
11
+ var terser = require('@rollup/plugin-terser');
12
+
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
+
15
+ var json__default = /*#__PURE__*/_interopDefault(json);
16
+ var autoprefixer__default = /*#__PURE__*/_interopDefault(autoprefixer);
17
+ var esbuild__default = /*#__PURE__*/_interopDefault(esbuild);
18
+ var postcss__default = /*#__PURE__*/_interopDefault(postcss);
19
+ var terser__default = /*#__PURE__*/_interopDefault(terser);
20
+
21
+ function globalResolver(external) {
22
+ if (external.startsWith("node:")) {
23
+ return external.slice(5);
24
+ }
25
+ return external.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase());
26
+ }
27
+
28
+ function createGlobalsLinkage() {
29
+ let globals = {};
30
+ const dependencies = /* @__PURE__ */ new Set([]);
31
+ return [
32
+ ({ external } = {}) => {
33
+ return {
34
+ name: "globals",
35
+ resolveId(id) {
36
+ if (external?.some((dep) => dep instanceof RegExp ? dep.test(id) : dep === id)) {
37
+ dependencies.add(id);
38
+ return { id, external: true };
39
+ }
40
+ return null;
41
+ },
42
+ outputOptions(options) {
43
+ globals = [...dependencies].reduce((acc, value) => ({
44
+ ...acc,
45
+ [value]: globalResolver(value)
46
+ }), {});
47
+ return { ...options, globals };
48
+ }
49
+ };
50
+ },
51
+ { outputOptions: (options) => ({ ...options, globals }) }
52
+ ];
53
+ }
54
+
55
+ var skip = (options = {}) => {
56
+ return {
57
+ name: "skip",
58
+ // skip the specified files by `options.patterns`
59
+ load(id) {
60
+ if (options.patterns?.some(
61
+ (pattern) => typeof pattern === "string" ? id.includes(pattern) : pattern.test(id)
62
+ )) {
63
+ return "";
64
+ }
65
+ }
66
+ };
67
+ };
68
+
69
+ const defineOutput = (output) => output;
70
+ const commonOutputOptions = defineOutput({
71
+ exports: "named",
72
+ interop: "auto",
73
+ sourcemap: true
74
+ });
75
+
76
+ function externalResolver() {
77
+ const cwd = process.cwd();
78
+ const pkg = require(`${cwd}/package.json`);
79
+ const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg;
80
+ const external = Object.keys(dependencies).concat(Object.keys(peerDependencies)).concat(Object.keys(optionalDependencies));
81
+ return external.map((dep) => new RegExp(`^${dep}(/.*)?$`)).concat([
82
+ /^node:/
83
+ ]);
84
+ }
85
+
86
+ function withMinify(output) {
87
+ return [
88
+ output,
89
+ {
90
+ ...output,
91
+ entryFileNames: output.entryFileNames?.replace(/(\.c?js)$/, ".min$1"),
92
+ plugins: [...output.plugins ?? [], terser__default.default()]
93
+ }
94
+ ];
95
+ }
96
+
97
+ const {
98
+ JIEK_SILENT,
99
+ JIEK_TARGET,
100
+ JIEK_ROOT
101
+ } = process.env;
102
+ const target = JIEK_TARGET ?? "esm,umd,dts";
103
+ const ACCEPTED_TARGETS = ["esm", "umd", "dts"];
104
+ const targets = target.split(",").filter(Boolean).filter((t) => ACCEPTED_TARGETS.includes(t));
105
+ const workspaceRoot = JIEK_ROOT ?? getWorkspaceDir.getWorkspaceDir();
106
+ function resolveWorkspacePath(p) {
107
+ return node_path.resolve(workspaceRoot, p);
108
+ }
109
+ function watchProgress(entries, onProcessing, onProcessed) {
110
+ return {
111
+ name: "progress",
112
+ resolveId(source, importer) {
113
+ if (entries.includes(source) || importer === void 0)
114
+ onProcessing(source);
115
+ },
116
+ writeBundle(options, bundle) {
117
+ Object.entries(bundle).forEach(([key, value]) => {
118
+ if (value.name === void 0 || !("isEntry" in value))
119
+ return;
120
+ onProcessed(value.name, value.fileName);
121
+ });
122
+ }
123
+ };
124
+ }
125
+ const template = ({
126
+ styled = false,
127
+ plugins: {
128
+ index: indexPlugins = [],
129
+ entry: entryPlugins = [],
130
+ dts: dtsPlugins = []
131
+ } = {}
132
+ } = {}, pkg) => {
133
+ if (targets.length === 0)
134
+ throw new Error("no target specified");
135
+ const { jiek: {
136
+ noBrowser = false,
137
+ outdir = "dist"
138
+ } = {} } = pkg;
139
+ const outputOptions = {
140
+ ...commonOutputOptions,
141
+ dir: outdir
142
+ };
143
+ if (!pkg.name) {
144
+ throw new Error("pkg.name is required");
145
+ }
146
+ const namePrefix = pkg.name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase());
147
+ const exportsEntries = Object.fromEntries(
148
+ Object.entries(pkg.exports ?? {}).filter(([key]) => !key.startsWith(`./${outdir}`) && !key.startsWith(outdir)).filter(([key]) => !/\.(json|css|scss)$/.test(key)).filter(([, value]) => typeof value === "object" && value["inner-src"] && value["import"]).map(([key, value]) => [
149
+ key.replace(/^\.$/, "index").replace(/^\.\//, ""),
150
+ typeof value === "string" ? value : value["inner-src"]
151
+ ])
152
+ );
153
+ const maxLengthEntry = Math.max(...Object.values(exportsEntries).map((v) => v.length));
154
+ function paddingEntry(entry) {
155
+ return entry.padEnd(maxLengthEntry);
156
+ }
157
+ const [globalsRegister, globalsOutput] = createGlobalsLinkage();
158
+ const external = externalResolver();
159
+ const commonOptions = {};
160
+ const commonPlugins = [
161
+ json__default.default()
162
+ ];
163
+ const multiBars = new cliProgress.MultiBar({
164
+ clearOnComplete: false,
165
+ hideCursor: true,
166
+ format: "- {bar} | {type} | {entry} | {message}"
167
+ }, cliProgress.Presets.shades_classic);
168
+ const entries = Object.values(exportsEntries);
169
+ const addBarsByEntries = (type) => entries.reduce((add, entry) => {
170
+ const bar = multiBars.create(100, 0);
171
+ bar.update(0, { type, entry: paddingEntry(entry), message: "waiting" });
172
+ return { ...add, [entry]: bar };
173
+ }, {});
174
+ const progressState = {};
175
+ targets.forEach((target2) => {
176
+ progressState[target2] = addBarsByEntries(target2);
177
+ });
178
+ const resolved = entries.reduce((entries2, entry) => ({ ...entries2, [entry]: false }), {});
179
+ const watchingProgress = (type, isLast = false, defaultEntry) => {
180
+ const group = progressState[type];
181
+ if (!group)
182
+ throw new Error(`target ${type} found`);
183
+ return watchProgress(
184
+ Object.values(exportsEntries),
185
+ (entry) => {
186
+ const e = defaultEntry ?? entry;
187
+ const bar = group[e];
188
+ if (!bar)
189
+ return;
190
+ bar.update(0, { type, entry: paddingEntry(e), message: "processing" });
191
+ },
192
+ (name, fileName) => {
193
+ const e = defaultEntry ?? exportsEntries[name];
194
+ const bar = group[e];
195
+ if (!bar)
196
+ return;
197
+ const endsReg = {
198
+ esm: /\.min\.js$/,
199
+ umd: /\.min\.c?js$/,
200
+ dts: /\.esm\.d\.ts$/
201
+ }[type];
202
+ if (!endsReg.test(fileName)) {
203
+ bar.update(95, { type, entry: paddingEntry(e), message: "processed" });
204
+ } else {
205
+ bar.update(100, { type, entry: paddingEntry(e), message: "finished" });
206
+ }
207
+ if (isLast) {
208
+ resolved[e] = true;
209
+ if (Object.values(resolved).every(Boolean)) {
210
+ setTimeout(() => multiBars.stop(), 200);
211
+ }
212
+ }
213
+ }
214
+ );
215
+ };
216
+ const esmOpts = (isLast) => ({
217
+ ...commonOptions,
218
+ input: exportsEntries,
219
+ output: [
220
+ ...withMinify({
221
+ ...outputOptions,
222
+ format: "esm",
223
+ entryFileNames: "[name].esm.js",
224
+ preserveModules: true
225
+ })
226
+ ],
227
+ plugins: [
228
+ watchingProgress("esm", isLast),
229
+ commonPlugins,
230
+ globalsRegister({ external }),
231
+ styled && skip({ patterns: [/\.s?css$/] }),
232
+ esbuild__default.default(),
233
+ indexPlugins
234
+ ]
235
+ });
236
+ const umdOpts = (isLast) => Object.entries(exportsEntries).map(([name, input]) => {
237
+ const outputName = namePrefix + (name === "index" ? "" : name.replace(/[@|/-](\w)/g, (_, $1) => $1.toUpperCase()));
238
+ return {
239
+ ...commonOptions,
240
+ input,
241
+ output: noBrowser ? [
242
+ ...withMinify({
243
+ ...outputOptions,
244
+ name: outputName,
245
+ format: "cjs",
246
+ entryFileNames: `${name}.cjs`
247
+ })
248
+ ] : [
249
+ ...withMinify({
250
+ ...outputOptions,
251
+ name: outputName,
252
+ format: "iife",
253
+ entryFileNames: `${name}.iife.js`
254
+ }),
255
+ ...withMinify({
256
+ ...outputOptions,
257
+ name: outputName,
258
+ format: "umd",
259
+ entryFileNames: `${name}.umd.js`
260
+ })
261
+ ],
262
+ plugins: [
263
+ watchingProgress("umd", isLast, input),
264
+ commonPlugins,
265
+ globalsOutput,
266
+ styled && postcss__default.default({
267
+ plugins: [autoprefixer__default.default],
268
+ minimize: true,
269
+ sourceMap: true,
270
+ extract: `${name}.css`
271
+ }),
272
+ esbuild__default.default(),
273
+ entryPlugins
274
+ ],
275
+ external
276
+ };
277
+ });
278
+ const dtsOpts = (isLast) => ({
279
+ ...commonOptions,
280
+ input: exportsEntries,
281
+ output: [
282
+ {
283
+ dir: "dist"
284
+ },
285
+ {
286
+ dir: "dist",
287
+ entryFileNames: ({ name }) => `${name.replace(/^src\//, "")}.esm.d.ts`,
288
+ preserveModules: true
289
+ }
290
+ ],
291
+ plugins: [
292
+ watchingProgress("dts", isLast),
293
+ commonPlugins,
294
+ styled && skip({ patterns: [/\.s?css$/] }),
295
+ rollupPluginDts.dts({
296
+ tsconfig: resolveWorkspacePath("tsconfig.dts.json"),
297
+ compilerOptions: { outDir: outdir }
298
+ }),
299
+ {
300
+ name: "rollup-plugin-declare-module-replacer",
301
+ /**
302
+ * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`
303
+ * in output file generated
304
+ */
305
+ generateBundle(_, bundle) {
306
+ for (const file of Object.values(bundle)) {
307
+ if (!("code" in file))
308
+ continue;
309
+ file.code = file.code.replace(
310
+ /declare module ['|"]\..*['|"]/g,
311
+ `declare module '${pkg.name}'`
312
+ );
313
+ }
314
+ }
315
+ },
316
+ dtsPlugins
317
+ ],
318
+ external
319
+ });
320
+ const optionsMap = { esm: esmOpts, umd: umdOpts, dts: dtsOpts };
321
+ return targets.flatMap((target2) => {
322
+ const optsGen = optionsMap[target2];
323
+ if (optsGen === void 0)
324
+ throw new Error(`target ${target2} is not supported`);
325
+ const opts = optsGen(target2 === targets[targets.length - 1]);
326
+ if (Array.isArray(opts))
327
+ return opts;
328
+ return [opts];
329
+ });
330
+ };
331
+
332
+ exports.template = template;
2
333
  //# sourceMappingURL=rollup.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.cjs","sources":["../src/rollup/utils/globalResolver.ts","../src/rollup/plugins/skip.ts","../src/rollup/utils/commonOptions.ts","../src/rollup/utils/withMinify.ts","../src/rollup/index.ts","../src/rollup/plugins/globals.ts","../src/rollup/utils/externalResolver.ts"],"sourcesContent":["export default function (external: string) {\n // a/b => AB\n // a-b => AB\n // a@b => AB\n // a@b/c => ABC\n // node:a => a\n // node:a_b => a_b\n if (external.startsWith('node:')) {\n return external.slice(5)\n }\n return external\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n","import terser from '@rollup/plugin-terser'\nimport type { OutputOptions, OutputPlugin } from 'rollup'\n\nexport default function (output: OutputOptions & {\n entryFileNames?: string\n plugins?: OutputPlugin[]\n}): OutputOptions[] {\n return [\n output,\n {\n ...output,\n entryFileNames: output.entryFileNames?.replace(/(\\.js)$/, '.min$1'),\n plugins: [...(output.plugins ?? []), terser()]\n }\n ]\n}\n","import { resolve } from 'node:path'\n\nimport type { Options } from '@jiek/pkger'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport { InputPluginOption, Plugin, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\nimport { MultiBar, Presets } from 'cli-progress'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst workspaceRoot = getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nfunction progress(\n entries: string[],\n onProcessing: (entry: string) => void,\n onTransforming: (id: string) => void,\n onProcessed: (name: string, fileName: string) => void\n): Plugin {\n return {\n name: 'progress',\n resolveId(source, importer) {\n if (entries.includes(source) || importer === undefined)\n onProcessing(source)\n },\n transform(_, id) {\n onTransforming(id)\n },\n writeBundle(options, bundle) {\n Object.entries(bundle).forEach(([key, value]) => {\n if (value.name === undefined || !('isEntry' in value)) return\n onProcessed(value.name, value.fileName)\n })\n }\n }\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n jiek?: Options\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n const { jiek: {\n noBrowser = false,\n outdir = 'dist'\n } = {} } = pkg\n const outputOptions = {\n ...commonOutputOptions,\n dir: outdir\n }\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter outdir entries\n .filter(([key]) => !key.startsWith(`./${outdir}`) && !key.startsWith(outdir))\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonOptions = {\n } satisfies RollupOptions\n const commonPlugins = [\n json()\n ]\n const multiBars = new MultiBar({\n clearOnComplete: false,\n hideCursor: true,\n format: '- {bar} | {type} | {entry} | {message}'\n }, Presets.shades_classic)\n const entries = Object.values(exportsEntries)\n const progressState = {\n esm: entries.reduce((add, entry) => {\n const bar = multiBars.create(100, 0)\n bar.update(0, { type: 'esm', entry, message: 'waiting' })\n return { ...add, [entry]: bar }\n }, {} as Record<string, ReturnType<typeof multiBars.create>>),\n umd: entries.reduce((add, entry) => {\n const bar = multiBars.create(100, 0)\n bar.update(0, { type: 'umd', entry, message: 'waiting' })\n return { ...add, [entry]: bar }\n }, {} as Record<string, ReturnType<typeof multiBars.create>>),\n dts: entries.reduce((add, entry) => {\n const bar = multiBars.create(100, 0)\n bar.update(0, { type: 'dts', entry, message: 'waiting' })\n return { ...add, [entry]: bar }\n }, {} as Record<string, ReturnType<typeof multiBars.create>>)\n }\n const resolved = entries.reduce((entries, entry) => ({ ...entries, [entry]: false }), {} as Record<string, boolean>)\n return [\n {\n ...commonOptions,\n input: exportsEntries,\n output: [\n ...withMinify({\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n progress(\n Object.values(exportsEntries),\n entry => {\n const bar = progressState.esm[entry]\n if (!bar) return\n bar.update(0, { type: 'esm', entry, message: 'processing' })\n },\n id => {\n const bar = progressState.esm[id]\n if (!bar) return\n bar.update(50, { type: 'esm', entry: id, message: `transforming ${id}` })\n },\n (name, fileName) => {\n const entry = exportsEntries[name]\n const bar = progressState.esm[entry]\n if (!bar) return\n if (!fileName.endsWith('.min.js')) {\n bar.update(95, { type: 'esm', entry, message: `processed` })\n } else {\n bar.update(100, { type: 'esm', entry, message: `finished` })\n }\n }\n ),\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n },\n ...Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n ...commonOptions,\n input: input,\n output: noBrowser ? [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs`\n })\n ] : [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n progress(\n [input],\n entry => {\n const bar = progressState.umd[entry]\n if (!bar) return\n bar.update(0, { type: 'umd', entry, message: 'processing' })\n },\n id => {\n const bar = progressState.umd[input]\n if (!bar) return\n bar.update(50, { type: 'umd', input, message: `transforming ${id}` })\n },\n (name, fileName) => {\n const bar = progressState.umd[input]\n if (!bar) return\n if (!fileName.endsWith('.min.js')) {\n bar.update(95, { type: 'umd', input, message: `processed` })\n } else {\n bar.update(100, { type: 'umd', input, message: `finished` })\n }\n }\n ),\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n }),\n {\n ...commonOptions,\n input: exportsEntries,\n output: [\n {\n dir: 'dist'\n },\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n }\n ],\n plugins: [\n progress(\n Object.values(exportsEntries),\n entry => {\n const bar = progressState.dts[entry]\n if (!bar) return\n bar.update(0, { type: 'dts', entry, message: 'processing' })\n },\n id => {\n const bar = progressState.dts[id]\n if (!bar) return\n bar.update(50, { type: 'dts', entry: id, message: `transforming ${id}` })\n },\n (name, fileName) => {\n const entry = exportsEntries[name]\n const bar = progressState.dts[entry]\n if (!bar) return\n if (!fileName.endsWith('.esm.d.ts')) {\n bar.update(95, { type: 'dts', entry, message: `processed` })\n } else {\n bar.update(100, { type: 'dts', entry, message: `finished` })\n resolved[entry] = true\n }\n if (Object.values(resolved).every(Boolean)) {\n setTimeout(() => {\n multiBars.stop()\n }, 100)\n }\n }\n ),\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({ tsconfig: resolveWorkspacePath('tsconfig.dts.json') }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n }\n ] as RollupOptions[]\n}\n","import type { Plugin, PluginImpl } from 'rollup'\n\nimport globalResolver from '../utils/globalResolver'\n\ninterface GlobalsOptions {\n external?: (string | RegExp)[]\n}\n\nexport function createGlobalsLinkage() {\n let globals = {}\n const dependencies = new Set<string>([])\n return [\n (({ external } = {}) => {\n return {\n name: 'globals',\n resolveId(id) {\n if (external?.some(dep => dep instanceof RegExp ? dep.test(id) : dep === id)) {\n dependencies.add(id)\n return { id, external: true }\n }\n return null\n },\n outputOptions(options) {\n globals = [...dependencies].reduce((acc, value) => ({\n ...acc,\n [value]: globalResolver(value)\n }), {})\n return { ...options, globals }\n }\n }\n }) as PluginImpl<GlobalsOptions>,\n { outputOptions: options => ({ ...options, globals }) } as Plugin\n ] as const\n}\n","export default function () {\n const cwd = process.cwd()\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkg = require(`${cwd}/package.json`)\n const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg\n const external = <(string | RegExp)[]>Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n .concat(Object.keys(optionalDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n .concat([\n /^node:/\n ])\n}\n"],"names":["globalResolver","external","startsWith","slice","replace","_","$1","toUpperCase","skip","options","name","load","id","patterns","some","pattern","includes","test","commonOutputOptions","exports","interop","sourcemap","withMinify","output","entryFileNames","plugins","terser","workspaceRoot","getWorkspaceDir","progress","entries","onProcessing","onTransforming","onProcessed","resolveId","source","importer","transform","writeBundle","bundle","Object","forEach","key","value","fileName","styled","index","indexPlugins","entry","entryPlugins","dts","dtsPlugins","pkg","jiek","noBrowser","outdir","outputOptions","dir","Error","namePrefix","exportsEntries","fromEntries","filter","map","globalsRegister","globalsOutput","globals","dependencies","Set","dep","RegExp","add","reduce","acc","createGlobalsLinkage","cwd","process","require","peerDependencies","optionalDependencies","keys","concat","externalResolver","commonOptions","commonPlugins","json","multiBars","MultiBar","clearOnComplete","hideCursor","format","Presets","shades_classic","values","progressState","esm","bar","create","update","type","message","umd","resolved","input","preserveModules","endsWith","esbuild","outputName","postcss","autoprefixer","minimize","sourceMap","extract","every","Boolean","setTimeout","stop","tsconfig","p","resolve","generateBundle","file","code"],"mappings":"wYAAA,SAAAA,EAAyBC,GAOnB,OAAAA,EAASC,WAAW,SACfD,EAASE,MAAM,GAEjBF,EACJG,QAAQ,eAAe,CAACC,EAAGC,IAAOA,EAAGC,eAC1C,CCNA,IAAAC,EAAgB,CAACC,EAAU,CAAA,KAClB,CACLC,KAAM,OAEN,IAAAC,CAAKC,GACH,GACEH,EAAQI,UAAUC,MAAMC,GACH,iBAAZA,EACHH,EAAGI,SAASD,GACZA,EAAQE,KAAKL,KAGZ,MAAA,EAEX,IClBJ,MAEaM,EAAmC,CAC9CC,QAAS,QACTC,QAAS,OACTC,WAAW,GCJb,SAAAC,EAAyBC,GAIhB,MAAA,CACLA,EACA,IACKA,EACHC,eAAgBD,EAAOC,gBAAgBpB,QAAQ,UAAW,UAC1DqB,QAAS,IAAKF,EAAOE,SAAW,GAAKC,cAG3C,CCGA,MAAMC,EAA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AE,OAAO,EAAG,CAAEC,KAAM,MAAOnD,QAAOoD,QAAS,cAAc,IAEvDxF,IACE,MAAAoF,EAAMF,EAAc5C,IAAItC,GACzBoF,GACDA,EAAAE,OAAO,GAAI,CAAEC,KAAM,MAAOnD,MAAOpC,EAAIwF,QAAS,gBAAgBxF,KAAM,IAE1E,CAACF,EAAMkC,KACC,MAAAI,EAAQY,EAAelD,GACvBsF,EAAMF,EAAc5C,IAAIF,GACzBgD,IACApD,EAAS6D,SAAS,cAGjBT,EAAAE,OAAO,IAAK,CAAEC,KAAM,MAAOnD,QAAOoD,QAAS,aAC/CE,EAAStD,IAAS,GAHdgD,EAAAE,OAAO,GAAI,CAAEC,KAAM,MAAOnD,QAAOoD,QAAS,cAK5C5D,OAAOqD,OAAOS,GAAUW,MAAMC,UAChCC,YAAW,KACT7B,EAAU8B,MAAK,GACd,KACL,IAGJhC,EACAvC,GAAUrC,EAAK,CAAEK,SAAU,CAAC,cAC5BqC,EAAAA,IAAI,CAAEmE,UAjRgBC,EAiRe,oBAhRpCC,EAAAA,QAAQ5F,EAAe2F,MAiRxB,CACE5G,KAAM,wCAKN,cAAA8G,CAAenH,EAAGkC,GAChB,IAAA,MAAWkF,KAAQjF,OAAOqD,OAAOtD,GACzB,SAAUkF,IAEXA,EAAAC,KAAOD,EAAKC,KAAKtH,QACpB,iCACA,mBAAmBgD,EAAI1C,SAG7B,GAEFyC,GAEFlD,aArSN,IAA8BqH,CAuS5B"}
1
+ {"version":3,"file":"rollup.cjs","sources":["../src/rollup/utils/globalResolver.ts","../src/rollup/plugins/globals.ts","../src/rollup/plugins/skip.ts","../src/rollup/utils/commonOptions.ts","../src/rollup/utils/externalResolver.ts","../src/rollup/utils/withMinify.ts","../src/rollup/index.ts"],"sourcesContent":["export default function (external: string) {\n // a/b => AB\n // a-b => AB\n // a@b => AB\n // a@b/c => ABC\n // node:a => a\n // node:a_b => a_b\n if (external.startsWith('node:')) {\n return external.slice(5)\n }\n return external\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n}\n","import type { Plugin, PluginImpl } from 'rollup'\n\nimport globalResolver from '../utils/globalResolver'\n\ninterface GlobalsOptions {\n external?: (string | RegExp)[]\n}\n\nexport function createGlobalsLinkage() {\n let globals = {}\n const dependencies = new Set<string>([])\n return [\n (({ external } = {}) => {\n return {\n name: 'globals',\n resolveId(id) {\n if (external?.some(dep => dep instanceof RegExp ? dep.test(id) : dep === id)) {\n dependencies.add(id)\n return { id, external: true }\n }\n return null\n },\n outputOptions(options) {\n globals = [...dependencies].reduce((acc, value) => ({\n ...acc,\n [value]: globalResolver(value)\n }), {})\n return { ...options, globals }\n }\n }\n }) as PluginImpl<GlobalsOptions>,\n { outputOptions: options => ({ ...options, globals }) } as Plugin\n ] as const\n}\n","import type { PluginImpl } from 'rollup'\n\ninterface Options {\n patterns?: (string | RegExp)[]\n}\n\nexport default ((options = {}) => {\n return {\n name: 'skip',\n // skip the specified files by `options.patterns`\n load(id) {\n if (\n options.patterns?.some((pattern) =>\n typeof pattern === 'string'\n ? id.includes(pattern)\n : pattern.test(id)\n )\n ) {\n return ''\n }\n }\n }\n}) as PluginImpl<Options>\n","import type { OutputOptions } from 'rollup'\n\nconst defineOutput = <O extends OutputOptions>(output: O) => output\n\nexport const commonOutputOptions = defineOutput({\n exports: 'named',\n interop: 'auto',\n sourcemap: true\n})\n","export default function () {\n const cwd = process.cwd()\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const pkg = require(`${cwd}/package.json`)\n const { dependencies = {}, peerDependencies = {}, optionalDependencies = {} } = pkg\n const external = <(string | RegExp)[]>Object\n .keys(dependencies)\n .concat(Object.keys(peerDependencies))\n .concat(Object.keys(optionalDependencies))\n return external\n .map(dep => new RegExp(`^${dep}(/.*)?$`))\n .concat([\n /^node:/\n ])\n}\n","import terser from '@rollup/plugin-terser'\nimport type { OutputOptions, OutputPlugin } from 'rollup'\n\nexport default function (output: OutputOptions & {\n entryFileNames?: string\n plugins?: OutputPlugin[]\n}): OutputOptions[] {\n return [\n output,\n {\n ...output,\n entryFileNames: output.entryFileNames?.replace(/(\\.c?js)$/, '.min$1'),\n plugins: [...(output.plugins ?? []), terser()]\n }\n ]\n}\n","import { resolve } from 'node:path'\n\nimport type { Options } from '@jiek/pkger'\nimport { getWorkspaceDir } from '@jiek/utils/getWorkspaceDir'\nimport json from '@rollup/plugin-json'\nimport autoprefixer from 'autoprefixer'\nimport { MultiBar, Presets } from 'cli-progress'\nimport type { InputPluginOption, Plugin, RollupOptions } from 'rollup'\nimport { dts } from 'rollup-plugin-dts'\nimport esbuild from 'rollup-plugin-esbuild'\nimport postcss from 'rollup-plugin-postcss'\n\nimport { createGlobalsLinkage } from './plugins/globals'\nimport skip from './plugins/skip'\nimport { commonOutputOptions } from './utils/commonOptions'\nimport externalResolver from './utils/externalResolver'\nimport withMinify from './utils/withMinify'\n\nconst {\n JIEK_SILENT,\n JIEK_TARGET,\n JIEK_ROOT\n} = process.env\nconst silent = JIEK_SILENT === 'true'\nconst target = JIEK_TARGET ?? 'esm,umd,dts'\nconst ACCEPTED_TARGETS = ['esm', 'umd', 'dts']\nconst targets = (\n target\n .split(',')\n .filter(Boolean)\n .filter(t => ACCEPTED_TARGETS.includes(t))\n) as ('esm' | 'umd' | 'dts')[]\nconst workspaceRoot = JIEK_ROOT ?? getWorkspaceDir()\nfunction resolveWorkspacePath(p: string) {\n return resolve(workspaceRoot, p)\n}\n\nfunction watchProgress(\n entries: string[],\n onProcessing: (entry: string) => void,\n onProcessed: (name: string, fileName: string) => void\n): Plugin {\n return {\n name: 'progress',\n resolveId(source, importer) {\n if (entries.includes(source) || importer === undefined)\n onProcessing(source)\n },\n writeBundle(options, bundle) {\n Object.entries(bundle).forEach(([key, value]) => {\n if (value.name === undefined || !('isEntry' in value)) return\n onProcessed(value.name, value.fileName)\n })\n }\n }\n}\n\nexport const template = (\n {\n styled = false,\n plugins: {\n index: indexPlugins = [],\n entry: entryPlugins = [],\n dts: dtsPlugins = []\n } = {}\n }: {\n /**\n * include styles files\n */\n styled?: boolean\n plugins?: {\n index?: InputPluginOption\n entry?: InputPluginOption\n dts?: InputPluginOption\n }\n } = {},\n pkg: {\n name?: string\n jiek?: Options\n exports?: Record<string, string | {\n import: string\n 'inner-src': string\n }>\n }\n) => {\n if (targets.length === 0)\n throw new Error('no target specified')\n\n const { jiek: {\n noBrowser = false,\n outdir = 'dist'\n } = {} } = pkg\n const outputOptions = {\n ...commonOutputOptions,\n dir: outdir\n }\n if (!pkg.name) {\n throw new Error('pkg.name is required')\n }\n const namePrefix = pkg\n .name\n .replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n const exportsEntries = Object.fromEntries(\n Object.entries(pkg.exports ?? {})\n // filter outdir entries\n .filter(([key]) => !key.startsWith(`./${outdir}`) && !key.startsWith(outdir))\n // filter static files\n .filter(([key]) => !/\\.(json|css|scss)$/.test(key))\n // filter no `inner-src` or `import` field entries\n .filter(([, value]) => typeof value === 'object' && value['inner-src'] && value['import'])\n .map(([key, value]) => [\n key\n .replace(/^\\.$/, 'index')\n .replace(/^\\.\\//, ''),\n typeof value === 'string' ? value : value['inner-src']\n ])\n )\n const maxLengthEntry = Math.max(...Object.values(exportsEntries).map(v => v.length))\n function paddingEntry(entry: string) {\n return entry.padEnd(maxLengthEntry)\n }\n\n const [globalsRegister, globalsOutput] = createGlobalsLinkage()\n const external = externalResolver()\n\n const commonOptions = {\n } satisfies RollupOptions\n const commonPlugins = [\n json()\n ]\n const multiBars = new MultiBar({\n clearOnComplete: false,\n hideCursor: true,\n format: '- {bar} | {type} | {entry} | {message}'\n }, Presets.shades_classic)\n const entries = Object.values(exportsEntries)\n const addBarsByEntries = (type: 'esm' | 'umd' | 'dts') => entries\n .reduce((add, entry) => {\n const bar = multiBars.create(100, 0)\n bar.update(0, { type, entry: paddingEntry(entry), message: 'waiting' })\n return { ...add, [entry]: bar }\n }, {} as Record<string, ReturnType<typeof multiBars.create>>)\n const progressState: Partial<Record<'esm' | 'umd' | 'dts', ReturnType<typeof addBarsByEntries>>> = {}\n targets.forEach(target => {\n progressState[target] = addBarsByEntries(target)\n })\n const resolved = entries.reduce((entries, entry) => ({ ...entries, [entry]: false }), {} as Record<string, boolean>)\n const watchingProgress = (\n type: 'esm' | 'umd' | 'dts',\n isLast = false,\n defaultEntry?: string\n ) => {\n const group = progressState[type]\n if (!group) throw new Error(`target ${type} found`)\n return watchProgress(\n Object.values(exportsEntries),\n entry => {\n const e = defaultEntry ?? entry\n const bar = group[e]\n if (!bar) return\n bar.update(0, { type, entry: paddingEntry(e), message: 'processing' })\n },\n (name, fileName) => {\n const e = defaultEntry ?? exportsEntries[name]\n const bar = group[e]\n if (!bar) return\n const endsReg = {\n esm: /\\.min\\.js$/,\n umd: /\\.min\\.c?js$/,\n dts: /\\.esm\\.d\\.ts$/\n }[type]\n if (!endsReg.test(fileName)) {\n bar.update(95, { type, entry: paddingEntry(e), message: 'processed' })\n } else {\n bar.update(100, { type, entry: paddingEntry(e), message: 'finished' })\n }\n if (isLast) {\n resolved[e] = true\n if (Object.values(resolved).every(Boolean)) {\n setTimeout(() => multiBars.stop(), 200)\n }\n }\n }\n )\n }\n const esmOpts: (isLast: boolean) => RollupOptions = isLast => ({\n ...commonOptions,\n input: exportsEntries,\n output: [\n ...withMinify({\n ...outputOptions,\n format: 'esm',\n entryFileNames: '[name].esm.js',\n preserveModules: true\n })\n ],\n plugins: [\n watchingProgress('esm', isLast),\n commonPlugins,\n globalsRegister({ external }),\n styled && skip({ patterns: [/\\.s?css$/] }),\n esbuild(),\n indexPlugins\n ]\n })\n const umdOpts: (isLast: boolean) => RollupOptions[] = isLast => Object.entries(exportsEntries).map(([name, input]) => {\n const outputName = namePrefix + (\n name === 'index' ? '' : (\n name.replace(/[@|/-](\\w)/g, (_, $1) => $1.toUpperCase())\n )\n )\n return {\n ...commonOptions,\n input: input,\n output: noBrowser ? [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'cjs',\n entryFileNames: `${name}.cjs`\n })\n ] : [\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'iife',\n entryFileNames: `${name}.iife.js`\n }),\n ...withMinify({\n ...outputOptions,\n name: outputName,\n format: 'umd',\n entryFileNames: `${name}.umd.js`\n })\n ],\n plugins: [\n watchingProgress('umd', isLast, input),\n commonPlugins,\n globalsOutput,\n styled && postcss({\n plugins: [autoprefixer],\n minimize: true,\n sourceMap: true,\n extract: `${name}.css`\n }),\n esbuild(),\n entryPlugins\n ],\n external\n }\n })\n const dtsOpts: (isLast: boolean) => RollupOptions = isLast => ({\n ...commonOptions,\n input: exportsEntries,\n output: [\n {\n dir: 'dist'\n },\n {\n dir: 'dist',\n entryFileNames: ({ name }) => `${name.replace(/^src\\//, '')}.esm.d.ts`,\n preserveModules: true\n }\n ],\n plugins: [\n watchingProgress('dts', isLast),\n commonPlugins,\n styled && skip({ patterns: [/\\.s?css$/] }),\n dts({\n tsconfig: resolveWorkspacePath('tsconfig.dts.json'),\n compilerOptions: { outDir: outdir }\n }),\n {\n name: 'rollup-plugin-declare-module-replacer',\n /**\n * replace relative path `declare module './xxx'` to `declare module '{{package name}}'`\n * in output file generated\n */\n generateBundle(_, bundle) {\n for (const file of Object.values(bundle)) {\n if (!('code' in file)) continue\n\n file.code = file.code.replace(\n /declare module ['|\"]\\..*['|\"]/g,\n `declare module '${pkg.name}'`\n )\n }\n }\n },\n dtsPlugins\n ],\n external\n })\n const optionsMap = { esm: esmOpts, umd: umdOpts, dts: dtsOpts }\n return targets.flatMap(target => {\n const optsGen = optionsMap[target as 'esm' | 'umd' | 'dts']\n if (optsGen === undefined)\n throw new Error(`target ${target} is not supported`)\n const opts = optsGen(target === targets[targets.length - 1])\n if (Array.isArray(opts)) return opts\n return [opts]\n })\n}\n"],"names":["terser","getWorkspaceDir","resolve","json","MultiBar","Presets","target","entries","esbuild","postcss","autoprefixer","dts"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,uBAAA,CAAyB,QAAkB,EAAA;AAOzC,EA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