@weapp-core/shared 3.0.3 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/dist/fs/index.d.ts +93 -0
- package/dist/fs/index.js +198 -0
- package/dist/index.d.ts +320 -129
- package/dist/index.js +582 -231
- package/dist/node.d.ts +9 -0
- package/dist/node.js +61 -0
- package/package.json +17 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import { Buffer as Buffer$1 } from "node:buffer";
|
|
2
|
-
import { createHash } from "node:crypto";
|
|
3
|
-
import path, { extname } from "node:path";
|
|
4
|
-
import { Dirent, Stats, close, closeSync, constants, existsSync, mkdirSync, openSync, promises, readFileSync, unlinkSync, utimesSync, watch, writeFileSync } from "node:fs";
|
|
5
1
|
//#region \0rolldown/runtime.js
|
|
6
2
|
var __create = Object.create;
|
|
7
3
|
var __defProp$1 = Object.defineProperty;
|
|
@@ -9,7 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
9
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
11
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
13
9
|
var __copyProps = (to, from, except, desc) => {
|
|
14
10
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
11
|
key = keys[i];
|
|
@@ -25,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
21
|
enumerable: true
|
|
26
22
|
}) : target, mod));
|
|
27
23
|
//#endregion
|
|
28
|
-
//#region ../../node_modules/.pnpm/defu@6.1.
|
|
24
|
+
//#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
|
|
29
25
|
function isPlainObject(value) {
|
|
30
26
|
if (value === null || typeof value !== "object") return false;
|
|
31
27
|
const prototype = Object.getPrototypeOf(value);
|
|
@@ -52,212 +48,585 @@ function createDefu(merger) {
|
|
|
52
48
|
return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
|
|
53
49
|
}
|
|
54
50
|
const defu = createDefu();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/layoutHostRegistry.ts
|
|
53
|
+
/**
|
|
54
|
+
* @description 对 layout host key 去重并过滤空字符串。
|
|
55
|
+
*/
|
|
56
|
+
function normalizeMiniProgramLayoutHostKeys(keys) {
|
|
57
|
+
return Array.from(new Set(Array.isArray(keys) ? keys : [keys])).filter((key) => typeof key === "string" && key.length > 0);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @description 创建小程序 layout host 注册表。
|
|
61
|
+
*/
|
|
62
|
+
function createMiniProgramLayoutHostRegistry() {
|
|
63
|
+
const registries = /* @__PURE__ */ new Map();
|
|
64
|
+
function register(keys, bridge, pageKeys) {
|
|
65
|
+
const normalizedKeys = normalizeMiniProgramLayoutHostKeys(keys);
|
|
66
|
+
if (normalizedKeys.length === 0 || pageKeys.length === 0) return null;
|
|
67
|
+
for (const pageKey of pageKeys) {
|
|
68
|
+
const registry = registries.get(pageKey) ?? /* @__PURE__ */ new Map();
|
|
69
|
+
for (const key of normalizedKeys) registry.set(key, bridge);
|
|
70
|
+
registries.set(pageKey, registry);
|
|
71
|
+
}
|
|
72
|
+
return normalizedKeys;
|
|
59
73
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
74
|
+
function unregister(keys, bridge, pageKeys) {
|
|
75
|
+
const normalizedKeys = normalizeMiniProgramLayoutHostKeys(keys);
|
|
76
|
+
if (normalizedKeys.length === 0 || pageKeys.length === 0) return false;
|
|
77
|
+
let removed = false;
|
|
78
|
+
for (const pageKey of pageKeys) {
|
|
79
|
+
const registry = registries.get(pageKey);
|
|
80
|
+
if (!registry) continue;
|
|
81
|
+
for (const key of normalizedKeys) if (registry.get(key) === bridge) {
|
|
82
|
+
registry.delete(key);
|
|
83
|
+
removed = true;
|
|
84
|
+
}
|
|
85
|
+
if (registry.size === 0) registries.delete(pageKey);
|
|
86
|
+
}
|
|
87
|
+
return removed;
|
|
88
|
+
}
|
|
89
|
+
function unregisterBridge(bridge) {
|
|
90
|
+
let removed = false;
|
|
91
|
+
for (const registry of registries.values()) for (const [key, currentBridge] of registry) if (currentBridge === bridge) {
|
|
92
|
+
registry.delete(key);
|
|
93
|
+
removed = true;
|
|
94
|
+
}
|
|
95
|
+
for (const [pageKey, registry] of registries) if (registry.size === 0) registries.delete(pageKey);
|
|
96
|
+
return removed;
|
|
65
97
|
}
|
|
98
|
+
function resolveBridge(key, pageKeys) {
|
|
99
|
+
return pageKeys.map((pageKey) => registries.get(pageKey)?.get(key)).find(Boolean);
|
|
100
|
+
}
|
|
101
|
+
function resolveHost(key, pageKeys, resolver) {
|
|
102
|
+
const bridge = resolveBridge(key, pageKeys);
|
|
103
|
+
if (!bridge) return null;
|
|
104
|
+
return resolver(bridge, key) ?? null;
|
|
105
|
+
}
|
|
106
|
+
function waitForHost(key, resolvePageKeys, resolver, options = {}) {
|
|
107
|
+
const retries = options.retries ?? 20;
|
|
108
|
+
const interval = options.interval ?? 16;
|
|
109
|
+
const host = resolveHost(key, resolvePageKeys(), resolver);
|
|
110
|
+
if (host || retries <= 0) return Promise.resolve(host);
|
|
111
|
+
return new Promise((resolve) => {
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
resolve(waitForHost(key, resolvePageKeys, resolver, {
|
|
114
|
+
...options,
|
|
115
|
+
retries: retries - 1
|
|
116
|
+
}));
|
|
117
|
+
}, interval);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
register,
|
|
122
|
+
resolveBridge,
|
|
123
|
+
resolveHost,
|
|
124
|
+
unregister,
|
|
125
|
+
unregisterBridge,
|
|
126
|
+
waitForHost
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/platforms/descriptors.ts
|
|
131
|
+
const DEFAULT_PROJECT_CONFIG_ROOT_KEYS = ["miniprogramRoot", "srcMiniprogramRoot"];
|
|
132
|
+
const DEFAULT_RUNTIME_CAPABILITIES = Object.freeze({
|
|
133
|
+
globalPageStack: true,
|
|
134
|
+
globalCreateSelectorQuery: true,
|
|
135
|
+
selectorQueryScopeByIn: true,
|
|
136
|
+
globalCreateIntersectionObserver: true,
|
|
137
|
+
intersectionObserverScopeByParameter: true,
|
|
138
|
+
pageShareMenu: true,
|
|
139
|
+
shareTimelineRequiresShareAppMessage: true,
|
|
140
|
+
pageScrollApi: true,
|
|
141
|
+
pullDownRefreshApi: true,
|
|
142
|
+
globalRouterApi: true,
|
|
143
|
+
appErrorListener: true,
|
|
144
|
+
appPageNotFoundListener: true,
|
|
145
|
+
appUnhandledRejectionListener: true,
|
|
146
|
+
appThemeChangeListener: true,
|
|
147
|
+
appMemoryWarningListener: true
|
|
66
148
|
});
|
|
149
|
+
const DEFAULT_PAGE_IDENTITY_RULES = [{
|
|
150
|
+
prefix: "route",
|
|
151
|
+
source: "route"
|
|
152
|
+
}];
|
|
153
|
+
/**
|
|
154
|
+
* @description 全仓库统一的小程序平台描述表。
|
|
155
|
+
*/
|
|
156
|
+
const MINI_PROGRAM_PLATFORM_DESCRIPTORS = [
|
|
157
|
+
{
|
|
158
|
+
id: "weapp",
|
|
159
|
+
displayName: "WeChat Mini Program",
|
|
160
|
+
family: "wechat",
|
|
161
|
+
aliases: [
|
|
162
|
+
"weapp",
|
|
163
|
+
"wechat",
|
|
164
|
+
"weixin",
|
|
165
|
+
"wx"
|
|
166
|
+
],
|
|
167
|
+
outputExtensions: {
|
|
168
|
+
js: "js",
|
|
169
|
+
json: "json",
|
|
170
|
+
wxml: "wxml",
|
|
171
|
+
wxss: "wxss",
|
|
172
|
+
wxs: "wxs"
|
|
173
|
+
},
|
|
174
|
+
projectConfigFileName: "project.config.json",
|
|
175
|
+
projectConfigRootKeys: DEFAULT_PROJECT_CONFIG_ROOT_KEYS,
|
|
176
|
+
ide: {},
|
|
177
|
+
build: {
|
|
178
|
+
autoTouchAppStyle: true,
|
|
179
|
+
defaultBuildTarget: "es2020"
|
|
180
|
+
},
|
|
181
|
+
resolvePreservedNpmDirNames: () => ["miniprogram_npm"],
|
|
182
|
+
json: {},
|
|
183
|
+
npm: { distDirName: () => "miniprogram_npm" },
|
|
184
|
+
wxml: {
|
|
185
|
+
eventBindingStyle: "default",
|
|
186
|
+
directivePrefix: "wx"
|
|
187
|
+
},
|
|
188
|
+
compiler: { templatePreset: "wechat" },
|
|
189
|
+
typescript: { appTypesPackage: "miniprogram-api-typings" },
|
|
190
|
+
runtime: {
|
|
191
|
+
globalObjectKey: "wx",
|
|
192
|
+
hostConfigKey: "__wxConfig",
|
|
193
|
+
globalResolvePriority: 1,
|
|
194
|
+
routeGlobalResolvePriority: 0,
|
|
195
|
+
capabilities: DEFAULT_RUNTIME_CAPABILITIES,
|
|
196
|
+
pageIdentityRules: [
|
|
197
|
+
{
|
|
198
|
+
prefix: "webview",
|
|
199
|
+
source: "field",
|
|
200
|
+
field: "__wxWebviewId__"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
prefix: "exparser",
|
|
204
|
+
source: "field",
|
|
205
|
+
field: "__wxExparserNodeId__"
|
|
206
|
+
},
|
|
207
|
+
...DEFAULT_PAGE_IDENTITY_RULES
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
id: "alipay",
|
|
213
|
+
displayName: "Alipay Mini Program",
|
|
214
|
+
family: "alipay",
|
|
215
|
+
aliases: [
|
|
216
|
+
"alipay",
|
|
217
|
+
"ali",
|
|
218
|
+
"my"
|
|
219
|
+
],
|
|
220
|
+
outputExtensions: {
|
|
221
|
+
js: "js",
|
|
222
|
+
json: "json",
|
|
223
|
+
wxml: "axml",
|
|
224
|
+
wxss: "acss",
|
|
225
|
+
wxs: "sjs"
|
|
226
|
+
},
|
|
227
|
+
projectConfigFileName: "mini.project.json",
|
|
228
|
+
projectConfigRootKeys: DEFAULT_PROJECT_CONFIG_ROOT_KEYS,
|
|
229
|
+
scriptModuleTagByExtension: { sjs: "import-sjs" },
|
|
230
|
+
usesProjectRootNpmDir: true,
|
|
231
|
+
ide: {
|
|
232
|
+
requiresOpenPlatformArg: true,
|
|
233
|
+
defaultProjectRoot: "dist/alipay/dist"
|
|
234
|
+
},
|
|
235
|
+
build: {
|
|
236
|
+
autoTouchAppStyle: false,
|
|
237
|
+
defaultBuildTarget: "es2015"
|
|
238
|
+
},
|
|
239
|
+
resolvePreservedNpmDirNames: (options) => [options?.alipayNpmMode === "miniprogram_npm" ? "miniprogram_npm" : "node_modules"],
|
|
240
|
+
json: {
|
|
241
|
+
normalizeUsingComponents: true,
|
|
242
|
+
fillComponentGenericsDefault: true,
|
|
243
|
+
rewriteBundleNpmImports: true
|
|
244
|
+
},
|
|
245
|
+
npm: {
|
|
246
|
+
distDirName: (options) => options?.alipayNpmMode === "miniprogram_npm" ? "miniprogram_npm" : "node_modules",
|
|
247
|
+
normalizeImportPath: true,
|
|
248
|
+
normalizeMiniprogramPackage: true,
|
|
249
|
+
copyEsModuleDirectory: true,
|
|
250
|
+
hoistNestedDependencies: true,
|
|
251
|
+
shouldRebuildCachedPackage: true
|
|
252
|
+
},
|
|
253
|
+
wxml: {
|
|
254
|
+
eventBindingStyle: "alipay",
|
|
255
|
+
directivePrefix: "a",
|
|
256
|
+
normalizeComponentTagName: true,
|
|
257
|
+
normalizeVueTemplate: true,
|
|
258
|
+
emitGenericPlaceholder: true
|
|
259
|
+
},
|
|
260
|
+
compiler: { templatePreset: "alipay" },
|
|
261
|
+
typescript: { appTypesPackage: "@mini-types/alipay" },
|
|
262
|
+
runtime: {
|
|
263
|
+
globalObjectKey: "my",
|
|
264
|
+
hostConfigKey: "__wxConfig",
|
|
265
|
+
globalResolvePriority: 0,
|
|
266
|
+
routeGlobalResolvePriority: 2,
|
|
267
|
+
capabilities: {
|
|
268
|
+
...DEFAULT_RUNTIME_CAPABILITIES,
|
|
269
|
+
pageShareMenu: false,
|
|
270
|
+
appThemeChangeListener: false
|
|
271
|
+
},
|
|
272
|
+
pageIdentityRules: DEFAULT_PAGE_IDENTITY_RULES
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
id: "swan",
|
|
277
|
+
displayName: "Baidu Smart Program",
|
|
278
|
+
family: "swan",
|
|
279
|
+
aliases: [
|
|
280
|
+
"swan",
|
|
281
|
+
"baidu",
|
|
282
|
+
"bd"
|
|
283
|
+
],
|
|
284
|
+
outputExtensions: {
|
|
285
|
+
js: "js",
|
|
286
|
+
json: "json",
|
|
287
|
+
wxml: "swan",
|
|
288
|
+
wxss: "css",
|
|
289
|
+
wxs: "sjs"
|
|
290
|
+
},
|
|
291
|
+
projectConfigFileName: "project.swan.json",
|
|
292
|
+
projectConfigRootKeys: ["smartProgramRoot", ...DEFAULT_PROJECT_CONFIG_ROOT_KEYS],
|
|
293
|
+
ide: {},
|
|
294
|
+
build: { autoTouchAppStyle: false },
|
|
295
|
+
resolvePreservedNpmDirNames: () => ["miniprogram_npm"],
|
|
296
|
+
json: {},
|
|
297
|
+
npm: { distDirName: () => "miniprogram_npm" },
|
|
298
|
+
wxml: {
|
|
299
|
+
eventBindingStyle: "default",
|
|
300
|
+
directivePrefix: "s"
|
|
301
|
+
},
|
|
302
|
+
compiler: { templatePreset: "swan" },
|
|
303
|
+
typescript: { appTypesPackage: "miniprogram-api-typings" },
|
|
304
|
+
runtime: {
|
|
305
|
+
globalObjectKey: "swan",
|
|
306
|
+
hostConfigKey: "__wxConfig",
|
|
307
|
+
capabilities: DEFAULT_RUNTIME_CAPABILITIES,
|
|
308
|
+
pageIdentityRules: DEFAULT_PAGE_IDENTITY_RULES
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
id: "tt",
|
|
313
|
+
displayName: "ByteDance / Douyin Mini Program",
|
|
314
|
+
family: "tt",
|
|
315
|
+
aliases: [
|
|
316
|
+
"tt",
|
|
317
|
+
"toutiao",
|
|
318
|
+
"bytedance",
|
|
319
|
+
"douyin"
|
|
320
|
+
],
|
|
321
|
+
outputExtensions: {
|
|
322
|
+
js: "js",
|
|
323
|
+
json: "json",
|
|
324
|
+
wxml: "ttml",
|
|
325
|
+
wxss: "ttss"
|
|
326
|
+
},
|
|
327
|
+
projectConfigFileName: "project.config.json",
|
|
328
|
+
projectConfigRootKeys: DEFAULT_PROJECT_CONFIG_ROOT_KEYS,
|
|
329
|
+
ide: {},
|
|
330
|
+
build: { autoTouchAppStyle: false },
|
|
331
|
+
resolvePreservedNpmDirNames: () => ["miniprogram_npm"],
|
|
332
|
+
json: {},
|
|
333
|
+
npm: { distDirName: () => "miniprogram_npm" },
|
|
334
|
+
wxml: {
|
|
335
|
+
eventBindingStyle: "default",
|
|
336
|
+
directivePrefix: "tt"
|
|
337
|
+
},
|
|
338
|
+
compiler: { templatePreset: "tt" },
|
|
339
|
+
typescript: { appTypesPackage: "@douyin-microapp/typings" },
|
|
340
|
+
runtime: {
|
|
341
|
+
globalObjectKey: "tt",
|
|
342
|
+
hostConfigKey: "__wxConfig",
|
|
343
|
+
globalResolvePriority: 2,
|
|
344
|
+
routeGlobalResolvePriority: 1,
|
|
345
|
+
capabilities: {
|
|
346
|
+
...DEFAULT_RUNTIME_CAPABILITIES,
|
|
347
|
+
appThemeChangeListener: false
|
|
348
|
+
},
|
|
349
|
+
pageIdentityRules: DEFAULT_PAGE_IDENTITY_RULES
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
id: "jd",
|
|
354
|
+
displayName: "JD Mini Program",
|
|
355
|
+
family: "wechat",
|
|
356
|
+
aliases: ["jd", "jingdong"],
|
|
357
|
+
outputExtensions: {
|
|
358
|
+
js: "js",
|
|
359
|
+
json: "json",
|
|
360
|
+
wxml: "jxml",
|
|
361
|
+
wxss: "jxss",
|
|
362
|
+
wxs: "wxs"
|
|
363
|
+
},
|
|
364
|
+
projectConfigFileName: "project.config.json",
|
|
365
|
+
projectConfigRootKeys: DEFAULT_PROJECT_CONFIG_ROOT_KEYS,
|
|
366
|
+
ide: {},
|
|
367
|
+
build: { autoTouchAppStyle: false },
|
|
368
|
+
resolvePreservedNpmDirNames: () => ["miniprogram_npm"],
|
|
369
|
+
json: {},
|
|
370
|
+
npm: { distDirName: () => "miniprogram_npm" },
|
|
371
|
+
wxml: {
|
|
372
|
+
eventBindingStyle: "default",
|
|
373
|
+
directivePrefix: "wx"
|
|
374
|
+
},
|
|
375
|
+
compiler: { templatePreset: "wechat" },
|
|
376
|
+
typescript: { appTypesPackage: "miniprogram-api-typings" },
|
|
377
|
+
runtime: {
|
|
378
|
+
globalObjectKey: "jd",
|
|
379
|
+
hostConfigKey: "__wxConfig",
|
|
380
|
+
capabilities: DEFAULT_RUNTIME_CAPABILITIES,
|
|
381
|
+
pageIdentityRules: DEFAULT_PAGE_IDENTITY_RULES
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
id: "xhs",
|
|
386
|
+
displayName: "Xiaohongshu Mini Program",
|
|
387
|
+
family: "wechat",
|
|
388
|
+
aliases: [
|
|
389
|
+
"xhs",
|
|
390
|
+
"xiaohongshu",
|
|
391
|
+
"little-red-book",
|
|
392
|
+
"red"
|
|
393
|
+
],
|
|
394
|
+
outputExtensions: {
|
|
395
|
+
js: "js",
|
|
396
|
+
json: "json",
|
|
397
|
+
wxml: "xhsml",
|
|
398
|
+
wxss: "css",
|
|
399
|
+
wxs: "wxs"
|
|
400
|
+
},
|
|
401
|
+
projectConfigFileName: "project.config.json",
|
|
402
|
+
projectConfigRootKeys: DEFAULT_PROJECT_CONFIG_ROOT_KEYS,
|
|
403
|
+
ide: {},
|
|
404
|
+
build: { autoTouchAppStyle: false },
|
|
405
|
+
resolvePreservedNpmDirNames: () => ["miniprogram_npm"],
|
|
406
|
+
json: {},
|
|
407
|
+
npm: { distDirName: () => "miniprogram_npm" },
|
|
408
|
+
wxml: {
|
|
409
|
+
eventBindingStyle: "default",
|
|
410
|
+
directivePrefix: "wx"
|
|
411
|
+
},
|
|
412
|
+
compiler: { templatePreset: "wechat" },
|
|
413
|
+
typescript: { appTypesPackage: "miniprogram-api-typings" },
|
|
414
|
+
runtime: {
|
|
415
|
+
globalObjectKey: "xhs",
|
|
416
|
+
hostConfigKey: "__wxConfig",
|
|
417
|
+
capabilities: DEFAULT_RUNTIME_CAPABILITIES,
|
|
418
|
+
pageIdentityRules: DEFAULT_PAGE_IDENTITY_RULES
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
];
|
|
67
422
|
//#endregion
|
|
68
|
-
//#region src/
|
|
69
|
-
|
|
70
|
-
|
|
423
|
+
//#region src/platforms/helpers.ts
|
|
424
|
+
const LEADING_SLASH_RE = /^\/+/;
|
|
425
|
+
function createMiniProgramPlatformRegistry(descriptors) {
|
|
426
|
+
const descriptorById = /* @__PURE__ */ new Map();
|
|
427
|
+
const aliasToId = /* @__PURE__ */ new Map();
|
|
428
|
+
const runtimeGlobalKeyToId = /* @__PURE__ */ new Map();
|
|
429
|
+
for (const descriptor of descriptors) {
|
|
430
|
+
descriptorById.set(descriptor.id, descriptor);
|
|
431
|
+
runtimeGlobalKeyToId.set(descriptor.runtime.globalObjectKey, descriptor.id);
|
|
432
|
+
aliasToId.set(descriptor.id, descriptor.id);
|
|
433
|
+
for (const alias of descriptor.aliases) {
|
|
434
|
+
const normalized = alias.trim().toLowerCase();
|
|
435
|
+
if (!normalized) continue;
|
|
436
|
+
aliasToId.set(normalized, descriptor.id);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return {
|
|
440
|
+
aliasToId,
|
|
441
|
+
descriptorById,
|
|
442
|
+
runtimeGlobalKeyToId
|
|
443
|
+
};
|
|
71
444
|
}
|
|
72
|
-
|
|
73
|
-
|
|
445
|
+
const { aliasToId: MINI_PROGRAM_PLATFORM_ALIAS_TO_ID, descriptorById: MINI_PROGRAM_PLATFORM_DESCRIPTOR_BY_ID, runtimeGlobalKeyToId: MINI_PROGRAM_RUNTIME_GLOBAL_KEY_TO_ID } = createMiniProgramPlatformRegistry(MINI_PROGRAM_PLATFORM_DESCRIPTORS);
|
|
446
|
+
const SUPPORTED_MINI_PROGRAM_PLATFORMS = Object.freeze(MINI_PROGRAM_PLATFORM_DESCRIPTORS.map((descriptor) => descriptor.id));
|
|
447
|
+
const SUPPORTED_MINI_PROGRAM_DIRECTIVE_PREFIXES = Object.freeze(Array.from(new Set(MINI_PROGRAM_PLATFORM_DESCRIPTORS.map((descriptor) => descriptor.wxml?.directivePrefix).filter((prefix) => Boolean(prefix)))));
|
|
448
|
+
const ORDERED_RUNTIME_GLOBAL_KEYS = Object.freeze(Array.from(new Set(MINI_PROGRAM_PLATFORM_DESCRIPTORS.map((descriptor) => descriptor.runtime.globalObjectKey))));
|
|
449
|
+
const MAX_RUNTIME_RESOLVE_PRIORITY = Number.MAX_SAFE_INTEGER;
|
|
450
|
+
function getOrderedRuntimeGlobalKeysByPriority(priorityKey) {
|
|
451
|
+
const ordered = [...MINI_PROGRAM_PLATFORM_DESCRIPTORS].sort((left, right) => {
|
|
452
|
+
const leftPriority = left.runtime[priorityKey] ?? MAX_RUNTIME_RESOLVE_PRIORITY;
|
|
453
|
+
const rightPriority = right.runtime[priorityKey] ?? MAX_RUNTIME_RESOLVE_PRIORITY;
|
|
454
|
+
if (leftPriority !== rightPriority) return leftPriority - rightPriority;
|
|
455
|
+
return MINI_PROGRAM_PLATFORM_DESCRIPTORS.indexOf(left) - MINI_PROGRAM_PLATFORM_DESCRIPTORS.indexOf(right);
|
|
456
|
+
});
|
|
457
|
+
return Object.freeze(Array.from(new Set(ordered.map((descriptor) => descriptor.runtime.globalObjectKey))));
|
|
74
458
|
}
|
|
75
|
-
|
|
76
|
-
|
|
459
|
+
const ORDERED_RUNTIME_GLOBAL_KEYS_BY_RESOLVE_PRIORITY = getOrderedRuntimeGlobalKeysByPriority("globalResolvePriority");
|
|
460
|
+
const ORDERED_RUNTIME_GLOBAL_KEYS_BY_ROUTE_PRIORITY = getOrderedRuntimeGlobalKeysByPriority("routeGlobalResolvePriority");
|
|
461
|
+
/**
|
|
462
|
+
* @description 小程序平台别名映射表。
|
|
463
|
+
*/
|
|
464
|
+
const MINI_PROGRAM_PLATFORM_ALIASES = Object.freeze(Object.fromEntries(MINI_PROGRAM_PLATFORM_ALIAS_TO_ID.entries()));
|
|
465
|
+
/**
|
|
466
|
+
* @description 标准化平台输入。
|
|
467
|
+
*/
|
|
468
|
+
function normalizeMiniProgramPlatform(input) {
|
|
469
|
+
return input?.trim().toLowerCase() || void 0;
|
|
77
470
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
471
|
+
/**
|
|
472
|
+
* @description 解析平台输入到标准平台标识。
|
|
473
|
+
*/
|
|
474
|
+
function resolveMiniProgramPlatform(input) {
|
|
475
|
+
const normalized = normalizeMiniProgramPlatform(input);
|
|
476
|
+
if (!normalized) return;
|
|
477
|
+
return MINI_PROGRAM_PLATFORM_ALIAS_TO_ID.get(normalized);
|
|
85
478
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
479
|
+
/**
|
|
480
|
+
* @description 返回所有受支持的小程序平台。
|
|
481
|
+
*/
|
|
482
|
+
function getSupportedMiniProgramPlatforms() {
|
|
483
|
+
return SUPPORTED_MINI_PROGRAM_PLATFORMS;
|
|
92
484
|
}
|
|
93
|
-
|
|
94
|
-
|
|
485
|
+
/**
|
|
486
|
+
* @description 返回所有受支持的小程序模板指令前缀。
|
|
487
|
+
*/
|
|
488
|
+
function getSupportedMiniProgramDirectivePrefixes() {
|
|
489
|
+
return SUPPORTED_MINI_PROGRAM_DIRECTIVE_PREFIXES;
|
|
95
490
|
}
|
|
96
|
-
|
|
97
|
-
|
|
491
|
+
/**
|
|
492
|
+
* @description 返回默认小程序平台。
|
|
493
|
+
*/
|
|
494
|
+
function getDefaultMiniProgramPlatform() {
|
|
495
|
+
return SUPPORTED_MINI_PROGRAM_PLATFORMS[0] ?? "weapp";
|
|
98
496
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
497
|
+
/**
|
|
498
|
+
* @description 获取平台描述。
|
|
499
|
+
*/
|
|
500
|
+
function getMiniProgramPlatformDescriptor(platform) {
|
|
501
|
+
const descriptor = MINI_PROGRAM_PLATFORM_DESCRIPTOR_BY_ID.get(platform);
|
|
502
|
+
if (!descriptor) throw new Error(`不支持的小程序平台 "${platform}"。`);
|
|
503
|
+
return descriptor;
|
|
102
504
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
505
|
+
/**
|
|
506
|
+
* @description 获取模板编译预设。
|
|
507
|
+
*/
|
|
508
|
+
function getMiniProgramTemplatePreset(platform) {
|
|
509
|
+
if (!platform) return "wechat";
|
|
510
|
+
return getMiniProgramPlatformDescriptor(platform).compiler?.templatePreset ?? "wechat";
|
|
108
511
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (error?.code !== "ENOENT") throw error;
|
|
116
|
-
}
|
|
117
|
-
await promises.symlink(target, file);
|
|
118
|
-
}
|
|
119
|
-
async function emptyDir(dir) {
|
|
120
|
-
await ensureDir(dir);
|
|
121
|
-
const entries = await promises.readdir(dir, { withFileTypes: true });
|
|
122
|
-
await Promise.all(entries.map((entry) => {
|
|
123
|
-
return remove(path.join(dir, entry.name));
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
async function outputFile(file, data, options) {
|
|
127
|
-
await ensureDir(path.dirname(file));
|
|
128
|
-
await promises.writeFile(file, data, options);
|
|
129
|
-
}
|
|
130
|
-
async function appendFile(file, data, options) {
|
|
131
|
-
await ensureDir(path.dirname(file));
|
|
132
|
-
await promises.appendFile(file, data, options);
|
|
133
|
-
}
|
|
134
|
-
async function writeJson(file, data, options) {
|
|
135
|
-
const source = serializeJson(data, options);
|
|
136
|
-
await promises.writeFile(file, source, normalizeJsonEncoding(options?.encoding));
|
|
137
|
-
}
|
|
138
|
-
async function writeJSON(file, data, options) {
|
|
139
|
-
await writeJson(file, data, options);
|
|
140
|
-
}
|
|
141
|
-
async function outputJson(file, data, options) {
|
|
142
|
-
await ensureDir(path.dirname(file));
|
|
143
|
-
await writeJson(file, data, options);
|
|
144
|
-
}
|
|
145
|
-
async function outputJSON(file, data, options) {
|
|
146
|
-
await outputJson(file, data, options);
|
|
147
|
-
}
|
|
148
|
-
async function readJson(file, options) {
|
|
149
|
-
try {
|
|
150
|
-
const source = await promises.readFile(file, normalizeJsonEncoding(options?.encoding));
|
|
151
|
-
return JSON.parse(normalizeJsonText(source));
|
|
152
|
-
} catch (error) {
|
|
153
|
-
if (options?.throws === false && error instanceof SyntaxError) return null;
|
|
154
|
-
throw error;
|
|
155
|
-
}
|
|
512
|
+
/**
|
|
513
|
+
* @description 判断平台是否允许自动补齐 app 样式入口。
|
|
514
|
+
*/
|
|
515
|
+
function supportsMiniProgramAutoTouchAppStyle(platform) {
|
|
516
|
+
if (!platform) return false;
|
|
517
|
+
return getMiniProgramPlatformDescriptor(platform).build?.autoTouchAppStyle === true;
|
|
156
518
|
}
|
|
157
|
-
|
|
158
|
-
|
|
519
|
+
/**
|
|
520
|
+
* @description 获取平台默认构建目标。
|
|
521
|
+
*/
|
|
522
|
+
function getMiniProgramDefaultBuildTarget(platform) {
|
|
523
|
+
if (!platform) return;
|
|
524
|
+
return getMiniProgramPlatformDescriptor(platform).build?.defaultBuildTarget;
|
|
159
525
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (options?.throws === false && error instanceof SyntaxError) return null;
|
|
166
|
-
throw error;
|
|
167
|
-
}
|
|
526
|
+
/**
|
|
527
|
+
* @description 获取平台默认使用的类型包。
|
|
528
|
+
*/
|
|
529
|
+
function getMiniProgramAppTypesPackage(platform) {
|
|
530
|
+
return getMiniProgramPlatformDescriptor(platform ?? getDefaultMiniProgramPlatform()).typescript?.appTypesPackage ?? "miniprogram-api-typings";
|
|
168
531
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
532
|
+
/**
|
|
533
|
+
* @description 获取平台模板指令前缀。
|
|
534
|
+
*/
|
|
535
|
+
function getMiniProgramDirectivePrefix(platform) {
|
|
536
|
+
if (!platform) return "wx";
|
|
537
|
+
return getMiniProgramPlatformDescriptor(platform).wxml?.directivePrefix ?? "wx";
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* @description 获取宿主全局对象 key。
|
|
541
|
+
*/
|
|
542
|
+
function getMiniProgramRuntimeGlobalKey(platform) {
|
|
543
|
+
return getMiniProgramPlatformDescriptor(platform).runtime.globalObjectKey;
|
|
179
544
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
545
|
+
/**
|
|
546
|
+
* @description 获取默认宿主全局对象 key。
|
|
547
|
+
*/
|
|
548
|
+
function getDefaultMiniProgramRuntimeGlobalKey() {
|
|
549
|
+
return ORDERED_RUNTIME_GLOBAL_KEYS[0] ?? "wx";
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* @description 解析宿主全局对象 key 对应的平台。
|
|
553
|
+
*/
|
|
554
|
+
function getMiniProgramPlatformByRuntimeGlobalKey(globalObjectKey) {
|
|
555
|
+
const normalized = globalObjectKey?.trim();
|
|
556
|
+
if (!normalized) return;
|
|
557
|
+
return MINI_PROGRAM_RUNTIME_GLOBAL_KEY_TO_ID.get(normalized);
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* @description 返回 runtime 全局对象 key 的扫描优先级。
|
|
561
|
+
*/
|
|
562
|
+
function getMiniProgramRuntimeGlobalKeys(platform) {
|
|
563
|
+
if (platform) return [getMiniProgramRuntimeGlobalKey(platform)];
|
|
564
|
+
return ORDERED_RUNTIME_GLOBAL_KEYS;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* @description 返回按通用解析优先级排序的 runtime 全局对象 key。
|
|
568
|
+
*/
|
|
569
|
+
function getMiniProgramRuntimeGlobalKeysByResolvePriority(platform) {
|
|
570
|
+
if (platform) return [getMiniProgramRuntimeGlobalKey(platform)];
|
|
571
|
+
return ORDERED_RUNTIME_GLOBAL_KEYS_BY_RESOLVE_PRIORITY;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* @description 返回按路由解析优先级排序的 runtime 全局对象 key。
|
|
575
|
+
*/
|
|
576
|
+
function getMiniProgramRouteRuntimeGlobalKeys(platform) {
|
|
577
|
+
if (platform) return [getMiniProgramRuntimeGlobalKey(platform)];
|
|
578
|
+
return ORDERED_RUNTIME_GLOBAL_KEYS_BY_ROUTE_PRIORITY;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* @description 获取平台 runtime 宿主配置 key。
|
|
582
|
+
*/
|
|
583
|
+
function getMiniProgramRuntimeHostConfigKey(platform) {
|
|
584
|
+
if (!platform) return "__wxConfig";
|
|
585
|
+
return getMiniProgramPlatformDescriptor(platform).runtime.hostConfigKey;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* @description 获取平台 runtime 能力描述。
|
|
589
|
+
*/
|
|
590
|
+
function getMiniProgramRuntimeCapabilities(platform) {
|
|
591
|
+
if (!platform) return DEFAULT_RUNTIME_CAPABILITIES;
|
|
592
|
+
return getMiniProgramPlatformDescriptor(platform).runtime.capabilities;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* @description 判断平台是否支持指定 runtime 能力。
|
|
596
|
+
*/
|
|
597
|
+
function supportsMiniProgramRuntimeCapability(platform, capabilityName) {
|
|
598
|
+
return getMiniProgramRuntimeCapabilities(platform)[capabilityName] === true;
|
|
599
|
+
}
|
|
600
|
+
function serializeMiniProgramPageIdentityRule(rule) {
|
|
601
|
+
return rule.source === "field" ? `${rule.prefix}:${rule.field ?? ""}` : `${rule.prefix}:route`;
|
|
602
|
+
}
|
|
603
|
+
function getMiniProgramPageIdentityRules(platform) {
|
|
604
|
+
if (platform) return getMiniProgramPlatformDescriptor(platform).runtime.pageIdentityRules;
|
|
605
|
+
const merged = /* @__PURE__ */ new Map();
|
|
606
|
+
for (const descriptor of MINI_PROGRAM_PLATFORM_DESCRIPTORS) for (const rule of descriptor.runtime.pageIdentityRules) merged.set(serializeMiniProgramPageIdentityRule(rule), rule);
|
|
607
|
+
return [...merged.values()];
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* @description 根据平台描述解析页面身份 key。
|
|
611
|
+
*/
|
|
612
|
+
function resolveMiniProgramPageKeys(page, platform) {
|
|
613
|
+
if (!page || typeof page !== "object") return [];
|
|
614
|
+
const keys = [];
|
|
615
|
+
for (const rule of getMiniProgramPageIdentityRules(platform)) {
|
|
616
|
+
if (rule.source === "route") {
|
|
617
|
+
const route = typeof page.route === "string" ? page.route.replace(LEADING_SLASH_RE, "") : "";
|
|
618
|
+
if (route) keys.push(`${rule.prefix}:${route}`);
|
|
619
|
+
continue;
|
|
187
620
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
await promises.rename(src, dest);
|
|
193
|
-
} catch (error) {
|
|
194
|
-
if (error?.code !== "EXDEV") throw error;
|
|
195
|
-
await copy(src, dest, { overwrite: options?.overwrite ?? true });
|
|
196
|
-
await remove(src);
|
|
621
|
+
const field = rule.field;
|
|
622
|
+
if (!field) continue;
|
|
623
|
+
const value = page[field];
|
|
624
|
+
if (typeof value === "number" || typeof value === "string") keys.push(`${rule.prefix}:${String(value)}`);
|
|
197
625
|
}
|
|
626
|
+
return Array.from(new Set(keys));
|
|
198
627
|
}
|
|
199
|
-
async function close$1(handle) {
|
|
200
|
-
if (typeof handle === "number") {
|
|
201
|
-
await new Promise((resolve, reject) => {
|
|
202
|
-
close(handle, (error) => {
|
|
203
|
-
if (error) {
|
|
204
|
-
reject(error);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
resolve();
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
await handle.close();
|
|
213
|
-
}
|
|
214
|
-
const fs = {
|
|
215
|
-
Dirent,
|
|
216
|
-
Stats,
|
|
217
|
-
access: promises.access,
|
|
218
|
-
appendFile,
|
|
219
|
-
close: close$1,
|
|
220
|
-
closeSync,
|
|
221
|
-
constants,
|
|
222
|
-
copy,
|
|
223
|
-
emptyDir,
|
|
224
|
-
ensureDir,
|
|
225
|
-
ensureFile,
|
|
226
|
-
ensureSymlink,
|
|
227
|
-
exists,
|
|
228
|
-
existsSync,
|
|
229
|
-
mkdir: promises.mkdir,
|
|
230
|
-
mkdirSync,
|
|
231
|
-
mkdtemp: promises.mkdtemp,
|
|
232
|
-
move,
|
|
233
|
-
open: (file, flags) => promises.open(file, flags),
|
|
234
|
-
openSync,
|
|
235
|
-
outputFile,
|
|
236
|
-
outputJSON,
|
|
237
|
-
outputJson,
|
|
238
|
-
pathExists,
|
|
239
|
-
pathExistsSync,
|
|
240
|
-
readFile: promises.readFile,
|
|
241
|
-
readFileSync,
|
|
242
|
-
readJSON,
|
|
243
|
-
readJson,
|
|
244
|
-
readJsonSync,
|
|
245
|
-
readdir: promises.readdir,
|
|
246
|
-
rm: promises.rm,
|
|
247
|
-
remove,
|
|
248
|
-
stat: promises.stat,
|
|
249
|
-
symlink: promises.symlink,
|
|
250
|
-
unlinkSync,
|
|
251
|
-
utimes: promises.utimes,
|
|
252
|
-
utimesSync,
|
|
253
|
-
watch,
|
|
254
|
-
writeFile: promises.writeFile,
|
|
255
|
-
writeFileSync,
|
|
256
|
-
writeJSON,
|
|
257
|
-
writeJson
|
|
258
|
-
};
|
|
259
628
|
//#endregion
|
|
260
|
-
//#region ../../node_modules/.pnpm/get-value@4.0
|
|
629
|
+
//#region ../../node_modules/.pnpm/get-value@4.1.0/node_modules/get-value/dist/index.mjs
|
|
261
630
|
var __defProp = Object.defineProperty;
|
|
262
631
|
var __name = (target, value) => __defProp(target, "name", {
|
|
263
632
|
value,
|
|
@@ -288,7 +657,9 @@ var index_default = /* @__PURE__ */ __name((target, path, options = {}) => {
|
|
|
288
657
|
const splitChar = options.separator || ".";
|
|
289
658
|
const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
|
|
290
659
|
if (!pathIsString && !pathIsArray) return target;
|
|
291
|
-
|
|
660
|
+
let value = target[path];
|
|
661
|
+
if (value === void 0 && typeof target.get === "function") value = target.get(path);
|
|
662
|
+
if (value !== void 0) return isValid(path, target, options) ? value : options.default;
|
|
292
663
|
const segs = pathIsArray ? path : split(path, splitChar, options);
|
|
293
664
|
const len = segs.length;
|
|
294
665
|
let idx = 0;
|
|
@@ -296,17 +667,21 @@ var index_default = /* @__PURE__ */ __name((target, path, options = {}) => {
|
|
|
296
667
|
let prop = segs[idx];
|
|
297
668
|
if (typeof prop !== "string") prop = String(prop);
|
|
298
669
|
while (prop && prop.slice(-1) === "\\") prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
|
|
299
|
-
|
|
670
|
+
value = target[prop];
|
|
671
|
+
if (value === void 0 && typeof target.get === "function") value = target.get(prop);
|
|
672
|
+
if (value !== void 0) {
|
|
300
673
|
if (!isValid(prop, target, options)) return options.default;
|
|
301
|
-
target =
|
|
674
|
+
target = value;
|
|
302
675
|
} else {
|
|
303
676
|
let hasProp = false;
|
|
304
677
|
let n = idx + 1;
|
|
305
678
|
while (n < len) {
|
|
306
679
|
prop = join([prop, segs[n++]], joinChar, options);
|
|
307
|
-
|
|
680
|
+
value = target[prop];
|
|
681
|
+
if (value === void 0 && typeof target.get === "function") value = target.get(prop);
|
|
682
|
+
if (hasProp = value !== void 0) {
|
|
308
683
|
if (!isValid(prop, target, options)) return options.default;
|
|
309
|
-
target =
|
|
684
|
+
target = value;
|
|
310
685
|
idx = n - 1;
|
|
311
686
|
break;
|
|
312
687
|
}
|
|
@@ -374,6 +749,12 @@ var require_is_plain_object = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
374
749
|
return true;
|
|
375
750
|
};
|
|
376
751
|
}));
|
|
752
|
+
/*!
|
|
753
|
+
* set-value <https://github.com/jonschlinkert/set-value>
|
|
754
|
+
*
|
|
755
|
+
* Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
|
|
756
|
+
* Released under the MIT License.
|
|
757
|
+
*/
|
|
377
758
|
//#endregion
|
|
378
759
|
//#region src/index.ts
|
|
379
760
|
var import_set_value = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -485,33 +866,9 @@ const SPECIAL_CHARS_RE = /[|\\{}()[\]^$+*?.]/g;
|
|
|
485
866
|
const HYPHEN_RE = /-/g;
|
|
486
867
|
const LAST_EXT_RE = /\.[^/.]+$/;
|
|
487
868
|
const ALL_EXT_RE = /(\.[^/.]+)+$/;
|
|
488
|
-
function
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
case "undefined": return "undefined";
|
|
492
|
-
case "string": return JSON.stringify(value);
|
|
493
|
-
case "number":
|
|
494
|
-
if (Number.isNaN(value)) return "number:NaN";
|
|
495
|
-
if (!Number.isFinite(value)) return `number:${value > 0 ? "Infinity" : "-Infinity"}`;
|
|
496
|
-
if (Object.is(value, -0)) return "number:-0";
|
|
497
|
-
return `number:${value}`;
|
|
498
|
-
case "bigint": return `bigint:${value.toString()}`;
|
|
499
|
-
case "boolean": return `boolean:${value}`;
|
|
500
|
-
case "symbol": return `symbol:${String(value)}`;
|
|
501
|
-
case "function": return `function:${value.toString()}`;
|
|
502
|
-
}
|
|
503
|
-
if (value instanceof Date) return `date:${value.toISOString()}`;
|
|
504
|
-
if (value instanceof RegExp) return `regexp:${value.toString()}`;
|
|
505
|
-
if (ArrayBuffer.isView(value)) return `${value.constructor.name}:${Buffer$1.from(value.buffer, value.byteOffset, value.byteLength).toString("hex")}`;
|
|
506
|
-
if (value instanceof ArrayBuffer) return `ArrayBuffer:${Buffer$1.from(value).toString("hex")}`;
|
|
507
|
-
if (seen.has(value)) return `circular:${seen.get(value)}`;
|
|
508
|
-
seen.set(value, seen.size);
|
|
509
|
-
if (Array.isArray(value)) return `[${value.map((item) => stableSerialize(item, seen)).join(",")}]`;
|
|
510
|
-
if (value instanceof Set) return `Set(${Array.from(value, (item) => stableSerialize(item, seen)).join(",")})`;
|
|
511
|
-
if (value instanceof Map) return `Map(${Array.from(value.entries(), ([key, item]) => [stableSerialize(key, seen), stableSerialize(item, seen)]).sort(([left], [right]) => left.localeCompare(right)).map(([key, item]) => `${key}=>${item}`).join(",")})`;
|
|
512
|
-
return `{${Reflect.ownKeys(value).sort((left, right) => String(left).localeCompare(String(right))).map((key) => {
|
|
513
|
-
return `${stableSerialize(key, seen)}:${stableSerialize(value[key], seen)}`;
|
|
514
|
-
}).join(",")}}`;
|
|
869
|
+
function hasExtension(filename) {
|
|
870
|
+
const lastSlashIndex = Math.max(filename.lastIndexOf("/"), filename.lastIndexOf("\\"));
|
|
871
|
+
return (lastSlashIndex >= 0 ? filename.slice(lastSlashIndex + 1) : filename).lastIndexOf(".") > 0;
|
|
515
872
|
}
|
|
516
873
|
/**
|
|
517
874
|
* @description 转义字符串中的正则特殊字符
|
|
@@ -536,7 +893,7 @@ function removeExtensionDeep(file) {
|
|
|
536
893
|
*/
|
|
537
894
|
function addExtension(filename, ext = ".js") {
|
|
538
895
|
let result = `${filename}`;
|
|
539
|
-
if (!
|
|
896
|
+
if (!hasExtension(filename)) result += ext;
|
|
540
897
|
return result;
|
|
541
898
|
}
|
|
542
899
|
/**
|
|
@@ -572,12 +929,6 @@ function isEmptyObject(obj) {
|
|
|
572
929
|
}
|
|
573
930
|
return false;
|
|
574
931
|
}
|
|
575
|
-
/**
|
|
576
|
-
* @description 生成稳定对象哈希,避免依赖已被禁用的 object-hash 包
|
|
577
|
-
*/
|
|
578
|
-
function objectHash(value) {
|
|
579
|
-
return createHash("sha256").update(stableSerialize(value)).digest("hex");
|
|
580
|
-
}
|
|
581
932
|
//#endregion
|
|
582
933
|
var set = import_set_value.default;
|
|
583
|
-
export { addExtension, arrify, defu, defuOverrideArray, escapeStringRegexp,
|
|
934
|
+
export { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, addExtension, arrify, createMiniProgramLayoutHostRegistry, defu, defuOverrideArray, escapeStringRegexp, index_default as get, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramDirectivePrefix, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramPlatformDescriptor, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getMiniProgramTemplatePreset, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, isEmptyObject, isObject, normalizeMiniProgramLayoutHostKeys, normalizeMiniProgramPlatform, removeExtension, removeExtensionDeep, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, set, supportsMiniProgramAutoTouchAppStyle, supportsMiniProgramRuntimeCapability };
|