vite-plugin-millennium-skin 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aliasModules.d.ts +2 -4
- package/dist/exports/react-dom.d.ts +17 -0
- package/dist/exports/react.d.ts +41 -0
- package/dist/index.js +222 -246
- package/package.json +1 -1
- package/src/ts/aliasModules.ts +5 -6
- package/src/ts/exports/react-dom.ts +19 -0
- package/src/ts/exports/react.ts +43 -0
- package/src/ts/index.ts +8 -139
package/dist/aliasModules.d.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const _default: any;
|
|
2
|
+
export default _default;
|
|
3
|
+
export declare const __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE: any;
|
|
4
|
+
export declare const createPortal: any;
|
|
5
|
+
export declare const flushSync: any;
|
|
6
|
+
export declare const preconnect: any;
|
|
7
|
+
export declare const prefetchDNS: any;
|
|
8
|
+
export declare const preinit: any;
|
|
9
|
+
export declare const preinitModule: any;
|
|
10
|
+
export declare const preload: any;
|
|
11
|
+
export declare const preloadModule: any;
|
|
12
|
+
export declare const requestFormReset: any;
|
|
13
|
+
export declare const unstable_batchedUpdates: any;
|
|
14
|
+
export declare const useFormState: any;
|
|
15
|
+
export declare const useFormStatus: any;
|
|
16
|
+
export declare const version: any;
|
|
17
|
+
export declare const createRoot: any;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare const _default: any;
|
|
2
|
+
export default _default;
|
|
3
|
+
export declare const Children: any;
|
|
4
|
+
export declare const Component: any;
|
|
5
|
+
export declare const Fragment: any;
|
|
6
|
+
export declare const Profiler: any;
|
|
7
|
+
export declare const PureComponent: any;
|
|
8
|
+
export declare const StrictMode: any;
|
|
9
|
+
export declare const Suspense: any;
|
|
10
|
+
export declare const __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE: any;
|
|
11
|
+
export declare const __COMPILER_RUNTIME: any;
|
|
12
|
+
export declare const cache: any;
|
|
13
|
+
export declare const cloneElement: any;
|
|
14
|
+
export declare const createContext: any;
|
|
15
|
+
export declare const createElement: any;
|
|
16
|
+
export declare const createRef: any;
|
|
17
|
+
export declare const forwardRef: any;
|
|
18
|
+
export declare const isValidElement: any;
|
|
19
|
+
export declare const lazy: any;
|
|
20
|
+
export declare const memo: any;
|
|
21
|
+
export declare const startTransition: any;
|
|
22
|
+
export declare const unstable_useCacheRefresh: any;
|
|
23
|
+
export declare const use: any;
|
|
24
|
+
export declare const useActionState: any;
|
|
25
|
+
export declare const useCallback: any;
|
|
26
|
+
export declare const useContext: any;
|
|
27
|
+
export declare const useDebugValue: any;
|
|
28
|
+
export declare const useDeferredValue: any;
|
|
29
|
+
export declare const useEffect: any;
|
|
30
|
+
export declare const useId: any;
|
|
31
|
+
export declare const useImperativeHandle: any;
|
|
32
|
+
export declare const useInsertionEffect: any;
|
|
33
|
+
export declare const useLayoutEffect: any;
|
|
34
|
+
export declare const useMemo: any;
|
|
35
|
+
export declare const useOptimistic: any;
|
|
36
|
+
export declare const useReducer: any;
|
|
37
|
+
export declare const useRef: any;
|
|
38
|
+
export declare const useState: any;
|
|
39
|
+
export declare const useSyncExternalStore: any;
|
|
40
|
+
export declare const useTransition: any;
|
|
41
|
+
export declare const version: any;
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import l from "
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
import y from "chalk";
|
|
10
|
-
import G from "inquirer";
|
|
11
|
-
import L from "simple-git";
|
|
12
|
-
const U = [
|
|
1
|
+
import f, { join as l } from "path/posix";
|
|
2
|
+
import { readFileSync as j, existsSync as E } from "fs";
|
|
3
|
+
import y from "fs/promises";
|
|
4
|
+
import { loadConfigFromFile as A } from "vite";
|
|
5
|
+
import d from "chalk";
|
|
6
|
+
import R from "inquirer";
|
|
7
|
+
import _ from "simple-git";
|
|
8
|
+
const P = [
|
|
13
9
|
{
|
|
14
10
|
Match: "https://.*.steampowered.com",
|
|
15
11
|
TargetCss: "webkit.css",
|
|
@@ -90,18 +86,18 @@ const U = [
|
|
|
90
86
|
TargetCss: "libraryroot.custom.css",
|
|
91
87
|
TargetJs: "libraryroot.custom.js"
|
|
92
88
|
}
|
|
93
|
-
],
|
|
89
|
+
], k = [
|
|
94
90
|
{
|
|
95
|
-
method: J,
|
|
96
91
|
module: /^react(\/.*)?$/g,
|
|
97
|
-
|
|
92
|
+
code: j("src/ts/exports/react.ts", "utf-8"),
|
|
93
|
+
id: "virtual:react"
|
|
98
94
|
},
|
|
99
95
|
{
|
|
100
|
-
method: J,
|
|
101
96
|
module: /^react-dom(\/.*)?$/g,
|
|
102
|
-
|
|
97
|
+
code: j("src/ts/exports/react-dom.ts", "utf-8"),
|
|
98
|
+
id: "virtual:react-dom"
|
|
103
99
|
}
|
|
104
|
-
],
|
|
100
|
+
], F = {
|
|
105
101
|
type: "auto",
|
|
106
102
|
git: {
|
|
107
103
|
major: { autoCommit: !1 },
|
|
@@ -114,7 +110,7 @@ const U = [
|
|
|
114
110
|
alpha: { autoCommit: !0, needCommitMessage: !1 },
|
|
115
111
|
snapshot: { autoCommit: !0, needCommitMessage: !1 }
|
|
116
112
|
}
|
|
117
|
-
},
|
|
113
|
+
}, H = {
|
|
118
114
|
type: "auto",
|
|
119
115
|
git: {
|
|
120
116
|
major: { autoCommit: !1 },
|
|
@@ -127,10 +123,10 @@ const U = [
|
|
|
127
123
|
alpha: { autoCommit: !1 },
|
|
128
124
|
snapshot: { autoCommit: !1 }
|
|
129
125
|
}
|
|
130
|
-
},
|
|
131
|
-
async function
|
|
126
|
+
}, x = F, b = _();
|
|
127
|
+
async function N(s = !1) {
|
|
132
128
|
if (s) {
|
|
133
|
-
const o = await
|
|
129
|
+
const o = await R.prompt([
|
|
134
130
|
{
|
|
135
131
|
type: "select",
|
|
136
132
|
name: "type",
|
|
@@ -159,55 +155,55 @@ async function q(s = !1) {
|
|
|
159
155
|
}
|
|
160
156
|
]);
|
|
161
157
|
if (!o.confirm) {
|
|
162
|
-
|
|
158
|
+
w("❌ 已取消提交");
|
|
163
159
|
return;
|
|
164
160
|
}
|
|
165
161
|
try {
|
|
166
|
-
await
|
|
162
|
+
await b.add("."), await b.commit(`${o.type}: ${o.message}`), w("✓ git提交成功");
|
|
167
163
|
} catch (t) {
|
|
168
|
-
|
|
164
|
+
J(`❌ git提交失败: ${t.message}`);
|
|
169
165
|
}
|
|
170
166
|
} else
|
|
171
167
|
try {
|
|
172
|
-
await
|
|
168
|
+
await b.add("."), await b.commit("chore: auto commit by MillenniumSkin"), w("✓ git提交成功");
|
|
173
169
|
} catch (o) {
|
|
174
|
-
|
|
170
|
+
J(`❌ git提交失败: ${o.message}`);
|
|
175
171
|
}
|
|
176
172
|
}
|
|
177
|
-
const
|
|
178
|
-
let
|
|
179
|
-
function
|
|
173
|
+
const X = /^SharedJSContext$/, q = /^Steam$/, K = /^View Root Menu$/, Q = /^Steam Root Menu$/, W = /^Friends Root Menu$/, Y = /^Games Root Menu$/, ee = /^Help Root Menu$/, te = /^Notifications Menu$/, se = /^Account Menu$/, O = /(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<preRelease>(?:[a-zA-Z1-9][a-zA-Z\d]*|0\d*[a-zA-Z][a-zA-Z\d]*|0)(?:\.(?:[a-zA-Z1-9][a-zA-Z\d]*|0\d*[a-zA-Z][a-zA-Z\d]*|0))*))?(?:\+(?<metadata>(?:[a-zA-Z\d-]*)(?:\.(?:[a-zA-Z\d-]*))*))?/, I = /(?:\.)?(?<tag>[a-zA-Z]+)\.(?<number>(?:[1-9]\d*|0\d*|0))/g;
|
|
174
|
+
let p;
|
|
175
|
+
function ae() {
|
|
180
176
|
const s = [], o = [];
|
|
181
|
-
let t, e,
|
|
182
|
-
const b = "virtual:millennium-skin", A = "\0" + b;
|
|
177
|
+
let t, e, u, m;
|
|
183
178
|
return {
|
|
184
179
|
name: "vite-plugin-millennium-skin",
|
|
185
180
|
enforce: "pre",
|
|
186
|
-
resolveId(
|
|
187
|
-
|
|
188
|
-
|
|
181
|
+
resolveId(r) {
|
|
182
|
+
for (const i of k)
|
|
183
|
+
if (i.module.test(r))
|
|
184
|
+
return i.id;
|
|
189
185
|
},
|
|
190
|
-
load(
|
|
191
|
-
|
|
192
|
-
|
|
186
|
+
load(r) {
|
|
187
|
+
for (const i of k)
|
|
188
|
+
if (r === i.id) return i.code;
|
|
193
189
|
},
|
|
194
|
-
async config(
|
|
195
|
-
if (t = (await
|
|
190
|
+
async config(r) {
|
|
191
|
+
if (t = (await A(
|
|
196
192
|
{ command: "build", mode: "profuction" },
|
|
197
193
|
"skin.config.ts",
|
|
198
|
-
|
|
194
|
+
r.root
|
|
199
195
|
))?.config, t.Patches === void 0) {
|
|
200
196
|
if (!t.UseDefaultPatches)
|
|
201
197
|
throw new Error("haven't any patch in skin.config.ts");
|
|
202
|
-
t.Patches =
|
|
198
|
+
t.Patches = P;
|
|
203
199
|
}
|
|
204
|
-
return t.Patches.forEach((
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
return t.Patches.forEach((n) => {
|
|
201
|
+
n.TargetJs && s.push(l(t.srcJs, n.TargetJs)), n.TargetCss && o.push(
|
|
202
|
+
S(l(t.srcCss, n.TargetCss))
|
|
207
203
|
);
|
|
208
204
|
}), t.RootColors !== void 0 && o.push(
|
|
209
|
-
|
|
210
|
-
|
|
205
|
+
S(
|
|
206
|
+
l(t.srcCss, t.RootColors)
|
|
211
207
|
)
|
|
212
208
|
), {
|
|
213
209
|
build: {
|
|
@@ -215,11 +211,11 @@ function $e() {
|
|
|
215
211
|
input: [...s, ...o],
|
|
216
212
|
output: {
|
|
217
213
|
entryFileNames: "assets/js/[name].js",
|
|
218
|
-
assetFileNames: (
|
|
219
|
-
const
|
|
220
|
-
return
|
|
221
|
-
|
|
222
|
-
) ? `assets/images/${
|
|
214
|
+
assetFileNames: (n) => {
|
|
215
|
+
const c = n.names[0], a = f.parse(c);
|
|
216
|
+
return a.ext === ".css" ? `assets/css/${c}` : /\.(png|jpg|jpeg|gif|svg|webp|bmp|heic)/i.test(
|
|
217
|
+
a.ext
|
|
218
|
+
) ? `assets/images/${c}` : `assets/css/${c}`;
|
|
223
219
|
}
|
|
224
220
|
}
|
|
225
221
|
},
|
|
@@ -228,227 +224,209 @@ function $e() {
|
|
|
228
224
|
}
|
|
229
225
|
};
|
|
230
226
|
},
|
|
231
|
-
async configResolved(
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
t.version === void 0 && (t.version =
|
|
227
|
+
async configResolved(r) {
|
|
228
|
+
u = r, p = r.logger;
|
|
229
|
+
const i = u.root, n = l(i, "package.json");
|
|
230
|
+
t.version === void 0 && (t.version = x);
|
|
235
231
|
try {
|
|
236
|
-
const
|
|
237
|
-
await
|
|
232
|
+
const c = JSON.parse(
|
|
233
|
+
await y.readFile(n, {
|
|
238
234
|
flag: "r",
|
|
239
235
|
encoding: "utf-8"
|
|
240
236
|
})
|
|
241
237
|
);
|
|
242
238
|
if (t.version.type === "auto") {
|
|
243
|
-
if (
|
|
244
|
-
|
|
239
|
+
if (m = await v(
|
|
240
|
+
c.version,
|
|
245
241
|
process.env.RELEASE
|
|
246
|
-
),
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
JSON.stringify(
|
|
251
|
-
),
|
|
242
|
+
), m) {
|
|
243
|
+
const a = m.newString;
|
|
244
|
+
c.version = a, await y.writeFile(
|
|
245
|
+
n,
|
|
246
|
+
JSON.stringify(c, null, 4)
|
|
247
|
+
), w(`${m.nativeString} -> ${a}`);
|
|
252
248
|
}
|
|
253
|
-
} else t.version.type === "package" && (
|
|
254
|
-
} catch (
|
|
255
|
-
|
|
249
|
+
} else t.version.type === "package" && (m = await v(c.version));
|
|
250
|
+
} catch (c) {
|
|
251
|
+
$(`can't use package.json: ${c}`), m = await v("0.0.0");
|
|
256
252
|
}
|
|
257
253
|
},
|
|
258
|
-
generateBundle(
|
|
254
|
+
generateBundle(r, i) {
|
|
259
255
|
if (t.Patches === void 0)
|
|
260
256
|
throw new Error("haven't any patch in building");
|
|
261
|
-
const
|
|
257
|
+
const n = u.root, c = structuredClone(
|
|
262
258
|
t.Patches
|
|
263
|
-
).map((
|
|
264
|
-
if (
|
|
265
|
-
const g =
|
|
266
|
-
|
|
267
|
-
|
|
259
|
+
).map((a) => {
|
|
260
|
+
if (a.Match instanceof RegExp && (a.Match = a.Match.source), a.TargetJs) {
|
|
261
|
+
const g = f.parse(a.TargetJs);
|
|
262
|
+
a.TargetJs = l(
|
|
263
|
+
n,
|
|
268
264
|
t.srcJs,
|
|
269
265
|
g.dir,
|
|
270
266
|
g.name
|
|
271
267
|
);
|
|
272
268
|
}
|
|
273
|
-
if (
|
|
274
|
-
const g =
|
|
275
|
-
|
|
276
|
-
|
|
269
|
+
if (a.TargetCss) {
|
|
270
|
+
const g = f.parse(a.TargetCss);
|
|
271
|
+
a.TargetCss = l(
|
|
272
|
+
n,
|
|
277
273
|
t.srcCss,
|
|
278
274
|
g.dir,
|
|
279
275
|
g.name
|
|
280
276
|
);
|
|
281
277
|
}
|
|
282
278
|
return {
|
|
283
|
-
MatchRegexString:
|
|
284
|
-
TargetJs:
|
|
285
|
-
TargetCss:
|
|
279
|
+
MatchRegexString: a.Match,
|
|
280
|
+
TargetJs: a.TargetJs,
|
|
281
|
+
TargetCss: a.TargetCss
|
|
286
282
|
};
|
|
287
283
|
});
|
|
288
|
-
Object.entries(
|
|
289
|
-
const { type: g } =
|
|
284
|
+
Object.entries(i).forEach(([, a]) => {
|
|
285
|
+
const { type: g } = a, T = a.fileName;
|
|
290
286
|
if (g === "chunk") {
|
|
291
|
-
if (!
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
287
|
+
if (!a.facadeModuleId) return;
|
|
288
|
+
const h = f.parse(a.facadeModuleId), M = l(
|
|
289
|
+
h.dir,
|
|
290
|
+
h.name
|
|
295
291
|
);
|
|
296
|
-
|
|
297
|
-
|
|
292
|
+
c.forEach((C) => {
|
|
293
|
+
M === C.TargetJs && (C.TargetJs = T);
|
|
298
294
|
});
|
|
299
295
|
} else {
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
),
|
|
303
|
-
|
|
304
|
-
|
|
296
|
+
const h = f.parse(
|
|
297
|
+
l(n, a.originalFileNames[0])
|
|
298
|
+
), M = l(
|
|
299
|
+
h.dir,
|
|
300
|
+
h.name
|
|
305
301
|
);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}), t.RootColors &&
|
|
309
|
-
|
|
302
|
+
c.forEach((C) => {
|
|
303
|
+
M === C.TargetCss && (C.TargetCss = T);
|
|
304
|
+
}), t.RootColors && M === l(
|
|
305
|
+
u.root,
|
|
310
306
|
t.srcCss,
|
|
311
307
|
t.RootColors
|
|
312
|
-
) && (t.RootColors =
|
|
308
|
+
) && (t.RootColors = T);
|
|
313
309
|
return;
|
|
314
310
|
}
|
|
315
311
|
}), e = {
|
|
316
312
|
...t,
|
|
317
|
-
Patches:
|
|
318
|
-
version:
|
|
313
|
+
Patches: c,
|
|
314
|
+
version: m?.newString ?? "0.0.0"
|
|
319
315
|
};
|
|
320
316
|
},
|
|
321
317
|
async writeBundle() {
|
|
322
|
-
const
|
|
318
|
+
const r = u.root;
|
|
323
319
|
try {
|
|
324
|
-
await
|
|
325
|
-
|
|
320
|
+
await y.writeFile(
|
|
321
|
+
l(r, u.build.outDir, "skin.json"),
|
|
326
322
|
JSON.stringify(e, null, 4)
|
|
327
323
|
);
|
|
328
|
-
} catch (
|
|
329
|
-
throw new Error(`can't write skin.json: ${
|
|
324
|
+
} catch (i) {
|
|
325
|
+
throw new Error(`can't write skin.json: ${i}`);
|
|
330
326
|
}
|
|
331
327
|
},
|
|
332
|
-
transform(
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
328
|
+
// transform(code, id) {
|
|
329
|
+
// /**
|
|
330
|
+
// * 别名处理, @see aliasModules
|
|
331
|
+
// */
|
|
332
|
+
// if (!/.+\.(js|ts|tsx|jsx)$/g.test(id)) return;
|
|
333
|
+
// const ast = parse(code, {
|
|
334
|
+
// sourceType: "module",
|
|
335
|
+
// plugins: ["typescript", "jsx"],
|
|
336
|
+
// });
|
|
337
|
+
// traver(ast, {
|
|
338
|
+
// Program(path) {
|
|
339
|
+
// const body = path.node.body;
|
|
340
|
+
// const runtimeLinks: Record<string, string[]> = {};
|
|
341
|
+
// // 处理静态引入别名,收集动态引入别名
|
|
342
|
+
// for (let i = body.length - 1; i >= 0; i--) {
|
|
343
|
+
// let node = body[i];
|
|
344
|
+
// if (!t.isImportDeclaration(node)) continue;
|
|
345
|
+
// const moduleName: string = node.source.value;
|
|
346
|
+
// const match: Statement[] = [];
|
|
347
|
+
// for (const aliasMod of aliasModules) {
|
|
348
|
+
// if (!aliasMod.module.test(moduleName)) continue;
|
|
349
|
+
// const { method } = aliasMod;
|
|
350
|
+
// for (const local of node.specifiers) {
|
|
351
|
+
// const exportLocal = local.local.name;
|
|
352
|
+
// let links: string[];
|
|
353
|
+
// if (local.type === "ImportDefaultSpecifier")
|
|
354
|
+
// // 默认导出
|
|
355
|
+
// links = aliasMod.links;
|
|
356
|
+
// else
|
|
357
|
+
// // 指定导出
|
|
358
|
+
// links = [
|
|
359
|
+
// ...aliasMod.links,
|
|
360
|
+
// (local as any).imported.name,
|
|
361
|
+
// ];
|
|
362
|
+
// switch (method) {
|
|
363
|
+
// case __RUNTIME__:
|
|
364
|
+
// runtimeLinks[exportLocal] =
|
|
365
|
+
// aliasMod.links;
|
|
366
|
+
// break;
|
|
367
|
+
// case __DIRECT__:
|
|
368
|
+
// match.push(
|
|
369
|
+
// generateConstDeclaration(
|
|
370
|
+
// exportLocal,
|
|
371
|
+
// links,
|
|
372
|
+
// ),
|
|
373
|
+
// );
|
|
374
|
+
// break;
|
|
375
|
+
// }
|
|
376
|
+
// }
|
|
377
|
+
// }
|
|
378
|
+
// if (match.length) {
|
|
379
|
+
// body.splice(i, 1, ...match);
|
|
380
|
+
// }
|
|
381
|
+
// }
|
|
382
|
+
// // 处理动态引入
|
|
383
|
+
// Object.entries(runtimeLinks).forEach(
|
|
384
|
+
// ([localName, runtimeLink]) => {
|
|
385
|
+
// const binding = path.scope.getBinding(localName);
|
|
386
|
+
// if (binding === undefined) return;
|
|
387
|
+
// binding.referencePaths.forEach((refPath) => {
|
|
388
|
+
// replaceRef(refPath, localName, runtimeLink);
|
|
389
|
+
// });
|
|
390
|
+
// binding.scope.removeOwnBinding(localName);
|
|
391
|
+
// },
|
|
392
|
+
// );
|
|
393
|
+
// },
|
|
394
|
+
// });
|
|
395
|
+
// const result = generate(ast);
|
|
396
|
+
// return { code: result.code };
|
|
397
|
+
// },
|
|
398
|
+
async closeBundle(r) {
|
|
399
|
+
if (r) {
|
|
400
|
+
console.error("打包失败:", r);
|
|
385
401
|
return;
|
|
386
402
|
}
|
|
387
403
|
if (t.version?.git !== void 0) {
|
|
388
|
-
const
|
|
389
|
-
if (
|
|
390
|
-
const
|
|
391
|
-
|
|
404
|
+
const i = process.env.RELEASE;
|
|
405
|
+
if (i && t.version.git[i]) {
|
|
406
|
+
const n = t.version.git[i];
|
|
407
|
+
n.autoCommit && await N(n.needCommitMessage);
|
|
392
408
|
}
|
|
393
409
|
}
|
|
394
410
|
}
|
|
395
411
|
};
|
|
396
412
|
}
|
|
397
|
-
function
|
|
413
|
+
function oe(s) {
|
|
398
414
|
return s;
|
|
399
415
|
}
|
|
400
|
-
function
|
|
401
|
-
|
|
402
|
-
for (let a = 1; a < o.length; a++)
|
|
403
|
-
t = l.memberExpression(t, l.identifier(o[a]));
|
|
404
|
-
const e = l.variableDeclarator(
|
|
405
|
-
l.identifier(s),
|
|
406
|
-
t
|
|
407
|
-
);
|
|
408
|
-
return l.variableDeclaration("const", [e]);
|
|
409
|
-
}
|
|
410
|
-
function I(s) {
|
|
411
|
-
if (w.parse(s).ext !== "") return s;
|
|
416
|
+
function S(s) {
|
|
417
|
+
if (f.parse(s).ext !== "") return s;
|
|
412
418
|
for (const t of ["scss", "sass", "css"]) {
|
|
413
419
|
const e = `${s}.${t}`;
|
|
414
|
-
if (
|
|
420
|
+
if (E(l(process.cwd(), e)))
|
|
415
421
|
return e;
|
|
416
422
|
}
|
|
417
423
|
throw new Error(`can't find css module: ${s}`);
|
|
418
424
|
}
|
|
419
|
-
function
|
|
420
|
-
const e = s.parent;
|
|
421
|
-
if (l.isMemberExpression(e) && e.object === s.node) {
|
|
422
|
-
const a = e.property;
|
|
423
|
-
if (l.isIdentifier(a)) {
|
|
424
|
-
const n = P(t);
|
|
425
|
-
if (!s.parentPath) return;
|
|
426
|
-
s.parentPath.replaceWith(
|
|
427
|
-
l.memberExpression(n, l.identifier(a.name))
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
if (s.isIdentifier()) {
|
|
433
|
-
const a = P(t);
|
|
434
|
-
s.replaceWith(
|
|
435
|
-
l.memberExpression(a, l.identifier(o))
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
function P(s) {
|
|
440
|
-
if (s.length === 0)
|
|
441
|
-
throw new Error("globalObj must not be empty");
|
|
442
|
-
let o = l.identifier(s[0]);
|
|
443
|
-
for (let t = 1; t < s.length; t++)
|
|
444
|
-
o = l.memberExpression(o, l.identifier(s[t]));
|
|
445
|
-
return o;
|
|
446
|
-
}
|
|
447
|
-
async function _(s, o = null) {
|
|
425
|
+
async function v(s, o = null) {
|
|
448
426
|
try {
|
|
449
|
-
const t =
|
|
427
|
+
const t = O.exec(s);
|
|
450
428
|
if (!t?.groups) {
|
|
451
|
-
|
|
429
|
+
$(`can't understand version: ${s}`);
|
|
452
430
|
return;
|
|
453
431
|
}
|
|
454
432
|
let e = {
|
|
@@ -457,11 +435,11 @@ async function _(s, o = null) {
|
|
|
457
435
|
patch: parseInt(t.groups.patch)
|
|
458
436
|
};
|
|
459
437
|
t.groups.preRelease && [
|
|
460
|
-
...t.groups.preRelease.matchAll(
|
|
461
|
-
].forEach((
|
|
462
|
-
|
|
438
|
+
...t.groups.preRelease.matchAll(I)
|
|
439
|
+
].forEach((r) => {
|
|
440
|
+
r.groups && (e[r.groups.tag] = parseInt(r.groups.number));
|
|
463
441
|
});
|
|
464
|
-
const
|
|
442
|
+
const u = { ...e };
|
|
465
443
|
switch (o) {
|
|
466
444
|
case null:
|
|
467
445
|
break;
|
|
@@ -508,52 +486,50 @@ async function _(s, o = null) {
|
|
|
508
486
|
break;
|
|
509
487
|
}
|
|
510
488
|
return {
|
|
511
|
-
native:
|
|
489
|
+
native: u,
|
|
512
490
|
new: e,
|
|
513
491
|
nativeString: s,
|
|
514
|
-
newString:
|
|
492
|
+
newString: z(e)
|
|
515
493
|
};
|
|
516
494
|
} catch (t) {
|
|
517
|
-
|
|
495
|
+
$(`can't bump version: ${t}`);
|
|
518
496
|
}
|
|
519
497
|
}
|
|
520
|
-
function
|
|
498
|
+
function z(s) {
|
|
521
499
|
let o = `${s.major}.${s.minor}.${s.patch}`;
|
|
522
500
|
const t = ["rc", "gamma", "beta", "preview", "alpha", "snapshot"];
|
|
523
501
|
let e = !1;
|
|
524
|
-
for (const
|
|
525
|
-
const
|
|
526
|
-
|
|
502
|
+
for (const u of t) {
|
|
503
|
+
const m = s[u];
|
|
504
|
+
m != null && (e ? o += `.${u}.${m}` : (o += `-${u}.${m}`, e = !0));
|
|
527
505
|
}
|
|
528
506
|
return o;
|
|
529
507
|
}
|
|
530
|
-
function
|
|
531
|
-
|
|
508
|
+
function $(s, o) {
|
|
509
|
+
p ? p.warn(d.yellow(`[MillenniumSkin] ${s}`), o) : console.warn(d.yellow(`[MillenniumSkin] ${s}`));
|
|
532
510
|
}
|
|
533
|
-
function
|
|
534
|
-
|
|
511
|
+
function w(s, o) {
|
|
512
|
+
p ? p.info(d.greenBright(`[MillenniumSkin] ${s}`), o) : console.log(d.greenBright(`[MillenniumSkin] ${s}`));
|
|
535
513
|
}
|
|
536
|
-
function
|
|
537
|
-
|
|
514
|
+
function J(s, o) {
|
|
515
|
+
p ? p.error(d.redBright(`[MillenniumSkin] ${s}`), o) : console.error(d.redBright(`[MillenniumSkin] ${s}`));
|
|
538
516
|
}
|
|
539
517
|
export {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
k as info,
|
|
558
|
-
R as warn
|
|
518
|
+
q as LibraryRoot,
|
|
519
|
+
se as MenuAccount,
|
|
520
|
+
W as MenuFriends,
|
|
521
|
+
Y as MenuGames,
|
|
522
|
+
ee as MenuHelp,
|
|
523
|
+
te as MenuNotifications,
|
|
524
|
+
Q as MenuSteam,
|
|
525
|
+
K as MenuView,
|
|
526
|
+
X as Root,
|
|
527
|
+
F as __AUTO__,
|
|
528
|
+
x as __DEFAULT__,
|
|
529
|
+
H as __PACKAGE__,
|
|
530
|
+
ae as default,
|
|
531
|
+
oe as defineConfig,
|
|
532
|
+
J as error,
|
|
533
|
+
w as info,
|
|
534
|
+
$ as warn
|
|
559
535
|
};
|
package/package.json
CHANGED
package/src/ts/aliasModules.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
export const __RUNTIME__ = 1;
|
|
1
|
+
import { readFileSync } from "fs";
|
|
3
2
|
|
|
4
3
|
export default [
|
|
5
4
|
{
|
|
6
|
-
method: __DIRECT__,
|
|
7
5
|
module: /^react(\/.*)?$/g,
|
|
8
|
-
|
|
6
|
+
code: readFileSync("src/ts/exports/react.ts", "utf-8"),
|
|
7
|
+
id: "virtual:react",
|
|
9
8
|
},
|
|
10
9
|
{
|
|
11
|
-
method: __DIRECT__,
|
|
12
10
|
module: /^react-dom(\/.*)?$/g,
|
|
13
|
-
|
|
11
|
+
code: readFileSync("src/ts/exports/react-dom.ts", "utf-8"),
|
|
12
|
+
id: "virtual:react-dom",
|
|
14
13
|
},
|
|
15
14
|
];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default window.opener.SP_REACTDOM;
|
|
2
|
+
export const __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
|
|
3
|
+
window.opener.SP_REACTDOM
|
|
4
|
+
.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
5
|
+
export const createPortal = window.opener.SP_REACTDOM.createPortal;
|
|
6
|
+
export const flushSync = window.opener.SP_REACTDOM.flushSync;
|
|
7
|
+
export const preconnect = window.opener.SP_REACTDOM.preconnect;
|
|
8
|
+
export const prefetchDNS = window.opener.SP_REACTDOM.prefetchDNS;
|
|
9
|
+
export const preinit = window.opener.SP_REACTDOM.preinit;
|
|
10
|
+
export const preinitModule = window.opener.SP_REACTDOM.preinitModule;
|
|
11
|
+
export const preload = window.opener.SP_REACTDOM.preload;
|
|
12
|
+
export const preloadModule = window.opener.SP_REACTDOM.preloadModule;
|
|
13
|
+
export const requestFormReset = window.opener.SP_REACTDOM.requestFormReset;
|
|
14
|
+
export const unstable_batchedUpdates =
|
|
15
|
+
window.opener.SP_REACTDOM.unstable_batchedUpdates;
|
|
16
|
+
export const useFormState = window.opener.SP_REACTDOM.useFormState;
|
|
17
|
+
export const useFormStatus = window.opener.SP_REACTDOM.useFormStatus;
|
|
18
|
+
export const version = window.opener.SP_REACTDOM.version;
|
|
19
|
+
export const createRoot = window.opener.SP_REACTDOM.createRoot;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export default window.opener.SP_REACT;
|
|
2
|
+
export const Children = window.opener.SP_REACT.Children;
|
|
3
|
+
export const Component = window.opener.SP_REACT.Component;
|
|
4
|
+
export const Fragment = window.opener.SP_REACT.Fragment;
|
|
5
|
+
export const Profiler = window.opener.SP_REACT.Profiler;
|
|
6
|
+
export const PureComponent = window.opener.SP_REACT.PureComponent;
|
|
7
|
+
export const StrictMode = window.opener.SP_REACT.StrictMode;
|
|
8
|
+
export const Suspense = window.opener.SP_REACT.Suspense;
|
|
9
|
+
export const __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =
|
|
10
|
+
window.opener.SP_REACT
|
|
11
|
+
.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
12
|
+
export const __COMPILER_RUNTIME = window.opener.SP_REACT.__COMPILER_RUNTIME;
|
|
13
|
+
export const cache = window.opener.SP_REACT.cache;
|
|
14
|
+
export const cloneElement = window.opener.SP_REACT.cloneElement;
|
|
15
|
+
export const createContext = window.opener.SP_REACT.createContext;
|
|
16
|
+
export const createElement = window.opener.SP_REACT.createElement;
|
|
17
|
+
export const createRef = window.opener.SP_REACT.createRef;
|
|
18
|
+
export const forwardRef = window.opener.SP_REACT.forwardRef;
|
|
19
|
+
export const isValidElement = window.opener.SP_REACT.isValidElement;
|
|
20
|
+
export const lazy = window.opener.SP_REACT.lazy;
|
|
21
|
+
export const memo = window.opener.SP_REACT.memo;
|
|
22
|
+
export const startTransition = window.opener.SP_REACT.startTransition;
|
|
23
|
+
export const unstable_useCacheRefresh =
|
|
24
|
+
window.opener.SP_REACT.unstable_useCacheRefresh;
|
|
25
|
+
export const use = window.opener.SP_REACT.use;
|
|
26
|
+
export const useActionState = window.opener.SP_REACT.useActionState;
|
|
27
|
+
export const useCallback = window.opener.SP_REACT.useCallback;
|
|
28
|
+
export const useContext = window.opener.SP_REACT.useContext;
|
|
29
|
+
export const useDebugValue = window.opener.SP_REACT.useDebugValue;
|
|
30
|
+
export const useDeferredValue = window.opener.SP_REACT.useDeferredValue;
|
|
31
|
+
export const useEffect = window.opener.SP_REACT.useEffect;
|
|
32
|
+
export const useId = window.opener.SP_REACT.useId;
|
|
33
|
+
export const useImperativeHandle = window.opener.SP_REACT.useImperativeHandle;
|
|
34
|
+
export const useInsertionEffect = window.opener.SP_REACT.useInsertionEffect;
|
|
35
|
+
export const useLayoutEffect = window.opener.SP_REACT.useLayoutEffect;
|
|
36
|
+
export const useMemo = window.opener.SP_REACT.useMemo;
|
|
37
|
+
export const useOptimistic = window.opener.SP_REACT.useOptimistic;
|
|
38
|
+
export const useReducer = window.opener.SP_REACT.useReducer;
|
|
39
|
+
export const useRef = window.opener.SP_REACT.useRef;
|
|
40
|
+
export const useState = window.opener.SP_REACT.useState;
|
|
41
|
+
export const useSyncExternalStore = window.opener.SP_REACT.useSyncExternalStore;
|
|
42
|
+
export const useTransition = window.opener.SP_REACT.useTransition;
|
|
43
|
+
export const version = window.opener.SP_REACT.version;
|
package/src/ts/index.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import type { Plugin, ResolvedConfig, Logger, LogOptions } from "vite";
|
|
2
|
-
import type { Statement, MemberExpression, Identifier } from "@babel/types";
|
|
3
2
|
import type { autoCommitLevel, versionConfig } from "./versionConfig";
|
|
4
|
-
import type { NodePath } from "@babel/traverse";
|
|
5
|
-
import t from "@babel/types";
|
|
6
|
-
import { parse } from "@babel/parser";
|
|
7
|
-
import traverse from "@babel/traverse";
|
|
8
|
-
import { generate } from "@babel/generator";
|
|
9
3
|
import path, { join } from "path/posix";
|
|
10
4
|
import { existsSync } from "fs";
|
|
11
5
|
import fsp from "fs/promises";
|
|
12
6
|
import { loadConfigFromFile } from "vite";
|
|
13
7
|
import chalk from "chalk";
|
|
14
8
|
import defaultPatches from "./defaultPatches";
|
|
15
|
-
import aliasModules
|
|
9
|
+
import aliasModules from "./aliasModules";
|
|
16
10
|
import { __DEFAULT__ } from "./versionConfig";
|
|
17
11
|
import { gitCommit } from "./git";
|
|
18
12
|
|
|
@@ -103,7 +97,7 @@ export type versionObject = {
|
|
|
103
97
|
snapshot?: number;
|
|
104
98
|
};
|
|
105
99
|
|
|
106
|
-
const traver = (traverse as any).default as typeof traverse;
|
|
100
|
+
// const traver = (traverse as any).default as typeof traverse;
|
|
107
101
|
const SEMANTIC_VERSIONING_REGEXP =
|
|
108
102
|
/(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<preRelease>(?:[a-zA-Z1-9][a-zA-Z\d]*|0\d*[a-zA-Z][a-zA-Z\d]*|0)(?:\.(?:[a-zA-Z1-9][a-zA-Z\d]*|0\d*[a-zA-Z][a-zA-Z\d]*|0))*))?(?:\+(?<metadata>(?:[a-zA-Z\d-]*)(?:\.(?:[a-zA-Z\d-]*))*))?/;
|
|
109
103
|
const SEMANTIC_TAGS_REGEXP =
|
|
@@ -117,21 +111,21 @@ export default function millenniumSkin(): Plugin {
|
|
|
117
111
|
let skinConfigResult: SkinConfigResult;
|
|
118
112
|
let viteConfig: ResolvedConfig;
|
|
119
113
|
let versions: bumpResult | undefined;
|
|
120
|
-
const virtualModuleId = "virtual:millennium-skin";
|
|
121
|
-
const resolvedVirtualModuleId = "\0" + virtualModuleId;
|
|
122
114
|
return {
|
|
123
115
|
name: "vite-plugin-millennium-skin",
|
|
124
116
|
enforce: "pre",
|
|
125
117
|
|
|
126
118
|
resolveId(source) {
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
for (const aliasMod of aliasModules) {
|
|
120
|
+
if (aliasMod.module.test(source)) {
|
|
121
|
+
return aliasMod.id;
|
|
122
|
+
}
|
|
129
123
|
}
|
|
130
124
|
},
|
|
131
125
|
|
|
132
126
|
load(id) {
|
|
133
|
-
|
|
134
|
-
|
|
127
|
+
for (const aliasMod of aliasModules) {
|
|
128
|
+
if (id === aliasMod.id) return aliasMod.code;
|
|
135
129
|
}
|
|
136
130
|
},
|
|
137
131
|
|
|
@@ -329,84 +323,6 @@ export default function millenniumSkin(): Plugin {
|
|
|
329
323
|
}
|
|
330
324
|
},
|
|
331
325
|
|
|
332
|
-
transform(code, id) {
|
|
333
|
-
/**
|
|
334
|
-
* 别名处理, @see aliasModules
|
|
335
|
-
*/
|
|
336
|
-
if (!/.+\.(js|ts|tsx)$/g.test(id)) return;
|
|
337
|
-
|
|
338
|
-
const ast = parse(code, {
|
|
339
|
-
sourceType: "module",
|
|
340
|
-
plugins: ["typescript", "jsx"],
|
|
341
|
-
});
|
|
342
|
-
traver(ast, {
|
|
343
|
-
Program(path) {
|
|
344
|
-
const body = path.node.body;
|
|
345
|
-
|
|
346
|
-
const runtimeLinks: Record<string, string[]> = {};
|
|
347
|
-
// 处理静态引入别名,收集动态引入别名
|
|
348
|
-
for (let i = body.length - 1; i >= 0; i--) {
|
|
349
|
-
let node = body[i];
|
|
350
|
-
if (!t.isImportDeclaration(node)) continue;
|
|
351
|
-
|
|
352
|
-
const moduleName: string = node.source.value;
|
|
353
|
-
|
|
354
|
-
const match: Statement[] = [];
|
|
355
|
-
for (const aliasMod of aliasModules) {
|
|
356
|
-
if (!aliasMod.module.test(moduleName)) continue;
|
|
357
|
-
const { method } = aliasMod;
|
|
358
|
-
|
|
359
|
-
for (const local of node.specifiers) {
|
|
360
|
-
const exportLocal = local.local.name;
|
|
361
|
-
let links: string[];
|
|
362
|
-
if (local.type === "ImportDefaultSpecifier")
|
|
363
|
-
// 默认导出
|
|
364
|
-
links = aliasMod.links;
|
|
365
|
-
else
|
|
366
|
-
// 指定导出
|
|
367
|
-
links = [
|
|
368
|
-
...aliasMod.links,
|
|
369
|
-
(local as any).imported.name,
|
|
370
|
-
];
|
|
371
|
-
|
|
372
|
-
switch (method) {
|
|
373
|
-
case __RUNTIME__:
|
|
374
|
-
runtimeLinks[exportLocal] =
|
|
375
|
-
aliasMod.links;
|
|
376
|
-
break;
|
|
377
|
-
case __DIRECT__:
|
|
378
|
-
match.push(
|
|
379
|
-
generateConstDeclaration(
|
|
380
|
-
exportLocal,
|
|
381
|
-
links,
|
|
382
|
-
),
|
|
383
|
-
);
|
|
384
|
-
break;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
if (match.length) {
|
|
389
|
-
body.splice(i, 1, ...match);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
// 处理动态引入
|
|
393
|
-
Object.entries(runtimeLinks).forEach(
|
|
394
|
-
([localName, runtimeLink]) => {
|
|
395
|
-
const binding = path.scope.getBinding(localName);
|
|
396
|
-
if (binding === undefined) return;
|
|
397
|
-
|
|
398
|
-
binding.referencePaths.forEach((refPath) => {
|
|
399
|
-
replaceRef(refPath, localName, runtimeLink);
|
|
400
|
-
});
|
|
401
|
-
binding.scope.removeOwnBinding(localName);
|
|
402
|
-
},
|
|
403
|
-
);
|
|
404
|
-
},
|
|
405
|
-
});
|
|
406
|
-
const result = generate(ast);
|
|
407
|
-
return { code: result.code };
|
|
408
|
-
},
|
|
409
|
-
|
|
410
326
|
async closeBundle(error?: Error) {
|
|
411
327
|
if (error) {
|
|
412
328
|
console.error("打包失败:", error);
|
|
@@ -432,18 +348,6 @@ export function defineConfig(SkinConfig: SkinConfig): SkinConfig {
|
|
|
432
348
|
return SkinConfig;
|
|
433
349
|
}
|
|
434
350
|
|
|
435
|
-
function generateConstDeclaration(moduleName: string, links: string[]) {
|
|
436
|
-
let expression: t.Identifier | t.MemberExpression = t.identifier(links[0]);
|
|
437
|
-
for (let i = 1; i < links.length; i++) {
|
|
438
|
-
expression = t.memberExpression(expression, t.identifier(links[i]));
|
|
439
|
-
}
|
|
440
|
-
const declarator = t.variableDeclarator(
|
|
441
|
-
t.identifier(moduleName),
|
|
442
|
-
expression,
|
|
443
|
-
);
|
|
444
|
-
return t.variableDeclaration("const", [declarator]);
|
|
445
|
-
}
|
|
446
|
-
|
|
447
351
|
function findCssModule(cssPath: string): string {
|
|
448
352
|
const parsed = path.parse(cssPath);
|
|
449
353
|
if (parsed.ext !== "") return cssPath;
|
|
@@ -456,41 +360,6 @@ function findCssModule(cssPath: string): string {
|
|
|
456
360
|
throw new Error(`can't find css module: ${cssPath}`);
|
|
457
361
|
}
|
|
458
362
|
|
|
459
|
-
function replaceRef(refPath: NodePath, localName: string, globalObj: string[]) {
|
|
460
|
-
const parent = refPath.parent;
|
|
461
|
-
|
|
462
|
-
if (t.isMemberExpression(parent) && parent.object === refPath.node) {
|
|
463
|
-
const prop = parent.property;
|
|
464
|
-
if (t.isIdentifier(prop)) {
|
|
465
|
-
const globalMember = createNestedMemberExpression(globalObj);
|
|
466
|
-
if (!refPath.parentPath) return;
|
|
467
|
-
refPath.parentPath.replaceWith(
|
|
468
|
-
t.memberExpression(globalMember, t.identifier(prop.name)),
|
|
469
|
-
);
|
|
470
|
-
}
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
if (refPath.isIdentifier()) {
|
|
475
|
-
const globalMember = createNestedMemberExpression(globalObj);
|
|
476
|
-
refPath.replaceWith(
|
|
477
|
-
t.memberExpression(globalMember, t.identifier(localName)),
|
|
478
|
-
);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
function createNestedMemberExpression(globalObj: string[]): t.MemberExpression {
|
|
483
|
-
if (globalObj.length === 0) {
|
|
484
|
-
throw new Error("globalObj must not be empty");
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
let node: Identifier | MemberExpression = t.identifier(globalObj[0]);
|
|
488
|
-
for (let i = 1; i < globalObj.length; i++) {
|
|
489
|
-
node = t.memberExpression(node, t.identifier(globalObj[i]));
|
|
490
|
-
}
|
|
491
|
-
return node as t.MemberExpression;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
363
|
type bumpResult = {
|
|
495
364
|
native: versionObject;
|
|
496
365
|
new: versionObject;
|