@weapp-core/shared 3.2.5 → 3.2.7

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.
Files changed (32) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +24 -0
  2. package/dist/index.d.ts +10 -96
  3. package/dist/index.js +11 -390
  4. package/dist/layoutHostRegistry.d.ts +22 -0
  5. package/dist/layoutHostRegistry.js +79 -0
  6. package/dist/node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.d.ts +19 -0
  7. package/dist/node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.js +29 -0
  8. package/dist/node_modules/.pnpm/get-value@4.1.0/node_modules/get-value/dist/index.js +75 -0
  9. package/dist/node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js +28 -0
  10. package/dist/node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js +17 -0
  11. package/dist/node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js +16 -0
  12. package/dist/node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js +118 -0
  13. package/dist/platforms/descriptors.d.ts +7 -0
  14. package/dist/platforms/descriptors.js +204 -0
  15. package/dist/platforms/helpers.d.ts +26 -0
  16. package/dist/platforms/helpers.js +42 -0
  17. package/dist/platforms/index.d.ts +5 -1
  18. package/dist/platforms/index.js +4 -1
  19. package/dist/platforms/runtime/descriptors.d.ts +13 -0
  20. package/dist/platforms/runtime/descriptors.js +141 -0
  21. package/dist/platforms/runtime/helpers.d.ts +65 -0
  22. package/dist/platforms/runtime/helpers.js +169 -0
  23. package/dist/platforms/runtime/index.d.ts +5 -0
  24. package/dist/platforms/runtime/index.js +4 -0
  25. package/dist/platforms/runtime/template.d.ts +7 -0
  26. package/dist/platforms/runtime/template.js +22 -0
  27. package/dist/{index-BxC5D0Iz.d.ts → platforms/types.d.ts} +9 -103
  28. package/dist/runtimeProviders.d.ts +44 -0
  29. package/dist/wxml.d.ts +10 -0
  30. package/dist/wxml.js +26 -0
  31. package/package.json +16 -1
  32. package/dist/platforms-DeV7WlYI.js +0 -509
@@ -0,0 +1,19 @@
1
+ //#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.d.mts
2
+ type Input = Record<string | number | symbol, any>;
3
+ type IgnoredInput = boolean | number | null | any[] | Record<never, any> | undefined;
4
+ type Merger = <T extends Input, K extends keyof T>(object: T, key: keyof T, value: T[K], namespace: string) => any;
5
+ type nullish = null | undefined | void;
6
+ type MergeObjects<Destination extends Input, Defaults extends Input> = Destination extends Defaults ? Destination : Omit<Destination, keyof Destination & keyof Defaults> & Omit<Defaults, keyof Destination & keyof Defaults> & { -readonly [Key in keyof Destination & keyof Defaults]: Destination[Key] extends nullish ? Defaults[Key] extends nullish ? nullish : Defaults[Key] : Defaults[Key] extends nullish ? Destination[Key] : Merge<Destination[Key], Defaults[Key]>; };
7
+ type Defu<S extends Input, D extends Array<Input | IgnoredInput>> = D extends [infer F, ...infer Rest] ? F extends Input ? Rest extends Array<Input | IgnoredInput> ? Defu<MergeObjects<S, F>, Rest> : MergeObjects<S, F> : F extends IgnoredInput ? Rest extends Array<Input | IgnoredInput> ? Defu<S, Rest> : S : S : S;
8
+ type DefuFn = <Source extends Input, Defaults extends Array<Input | IgnoredInput>>(source: Source, ...defaults: Defaults) => Defu<Source, Defaults>;
9
+ interface DefuInstance {
10
+ <Source extends Input, Defaults extends Array<Input | IgnoredInput>>(source: Source | IgnoredInput, ...defaults: Defaults): Defu<Source, Defaults>;
11
+ fn: DefuFn;
12
+ arrayFn: DefuFn;
13
+ extend(merger?: Merger): DefuFn;
14
+ }
15
+ type MergeArrays<Destination, Source> = Destination extends Array<infer DestinationType> ? Source extends Array<infer SourceType> ? Array<DestinationType | SourceType> : Source | Array<DestinationType> : Source | Destination;
16
+ type Merge<Destination extends Input, Defaults extends Input> = Destination extends nullish ? Defaults extends nullish ? nullish : Defaults : Defaults extends nullish ? Destination : Destination extends Array<any> ? Defaults extends Array<any> ? MergeArrays<Destination, Defaults> : Destination | Defaults : Destination extends Function ? Destination | Defaults : Destination extends RegExp ? Destination | Defaults : Destination extends Promise<any> ? Destination | Defaults : Defaults extends Function ? Destination | Defaults : Defaults extends RegExp ? Destination | Defaults : Defaults extends Promise<any> ? Destination | Defaults : Destination extends Input ? Defaults extends Input ? MergeObjects<Destination, Defaults> : Destination | Defaults : Destination | Defaults;
17
+ declare const defu: DefuInstance;
18
+ //#endregion
19
+ export { type Defu, type DefuFn, type DefuInstance, defu as default, defu };
@@ -0,0 +1,29 @@
1
+ //#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
2
+ function isPlainObject(value) {
3
+ if (value === null || typeof value !== "object") return false;
4
+ const prototype = Object.getPrototypeOf(value);
5
+ if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
6
+ if (Symbol.iterator in value) return false;
7
+ if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
8
+ return true;
9
+ }
10
+ function _defu(baseObject, defaults, namespace = ".", merger) {
11
+ if (!isPlainObject(defaults)) return _defu(baseObject, {}, namespace, merger);
12
+ const object = { ...defaults };
13
+ for (const key of Object.keys(baseObject)) {
14
+ if (key === "__proto__" || key === "constructor") continue;
15
+ const value = baseObject[key];
16
+ if (value === null || value === void 0) continue;
17
+ if (merger && merger(object, key, value, namespace)) continue;
18
+ if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
19
+ else if (isPlainObject(value) && isPlainObject(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
20
+ else object[key] = value;
21
+ }
22
+ return object;
23
+ }
24
+ function createDefu(merger) {
25
+ return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
26
+ }
27
+ const defu = createDefu();
28
+ //#endregion
29
+ export { createDefu, defu as default, defu };
@@ -0,0 +1,75 @@
1
+ //#region ../../node_modules/.pnpm/get-value@4.1.0/node_modules/get-value/dist/index.mjs
2
+ var __defProp = Object.defineProperty;
3
+ var __name = (target, value) => __defProp(target, "name", {
4
+ value,
5
+ configurable: true
6
+ });
7
+ var isObject = /* @__PURE__ */ __name((v) => v !== null && typeof v === "object", "isObject");
8
+ var join = /* @__PURE__ */ __name((segs, joinChar, options) => {
9
+ if (typeof options.join === "function") return options.join(segs);
10
+ return segs[0] + joinChar + segs[1];
11
+ }, "join");
12
+ var split = /* @__PURE__ */ __name((path, splitChar, options) => {
13
+ if (typeof options.split === "function") return options.split(path);
14
+ return path.split(splitChar);
15
+ }, "split");
16
+ var isValid = /* @__PURE__ */ __name((key, target = {}, options) => {
17
+ if (typeof options?.isValid === "function") return options.isValid(key, target);
18
+ return true;
19
+ }, "isValid");
20
+ var isValidObject = /* @__PURE__ */ __name((v) => {
21
+ return isObject(v) || typeof v === "function";
22
+ }, "isValidObject");
23
+ var getValue = /* @__PURE__ */ __name((target, path, options = {}) => {
24
+ if (!isObject(options)) options = { default: options };
25
+ if (!isValidObject(target)) return typeof options.default !== "undefined" ? options.default : target;
26
+ if (typeof path === "number") path = String(path);
27
+ const pathIsArray = Array.isArray(path);
28
+ const pathIsString = typeof path === "string";
29
+ const splitChar = options.separator || ".";
30
+ const joinChar = options.joinChar || (typeof splitChar === "string" ? splitChar : ".");
31
+ if (!pathIsString && !pathIsArray) return target;
32
+ let value = target[path];
33
+ if (value === void 0 && typeof target.get === "function") value = target.get(path);
34
+ if (value !== void 0) return isValid(path, target, options) ? value : options.default;
35
+ const segs = pathIsArray ? path : split(path, splitChar, options);
36
+ const len = segs.length;
37
+ let idx = 0;
38
+ do {
39
+ let prop = segs[idx];
40
+ if (typeof prop !== "string") prop = String(prop);
41
+ while (prop && prop.slice(-1) === "\\") prop = join([prop.slice(0, -1), segs[++idx] || ""], joinChar, options);
42
+ value = target[prop];
43
+ if (value === void 0 && typeof target.get === "function") value = target.get(prop);
44
+ if (value !== void 0) {
45
+ if (!isValid(prop, target, options)) return options.default;
46
+ target = value;
47
+ } else {
48
+ let hasProp = false;
49
+ let n = idx + 1;
50
+ while (n < len) {
51
+ prop = join([prop, segs[n++]], joinChar, options);
52
+ value = target[prop];
53
+ if (value === void 0 && typeof target.get === "function") value = target.get(prop);
54
+ if (hasProp = value !== void 0) {
55
+ if (!isValid(prop, target, options)) return options.default;
56
+ target = value;
57
+ idx = n - 1;
58
+ break;
59
+ }
60
+ }
61
+ if (!hasProp) return options.default;
62
+ }
63
+ } while (++idx < len && isValidObject(target));
64
+ if (idx === len) return target;
65
+ return options.default;
66
+ }, "getValue");
67
+ var index_default = getValue;
68
+ /*!
69
+ * get-value <https://github.com/jonschlinkert/get-value>
70
+ *
71
+ * Copyright (c) 2014-present, Jon Schlinkert.
72
+ * Released under the MIT License.
73
+ */
74
+ //#endregion
75
+ export { index_default as default, getValue };
@@ -0,0 +1,28 @@
1
+ import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
2
+ import { require_isobject } from "../../../isobject@3.0.1/node_modules/isobject/index.js";
3
+ //#region ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
4
+ /*!
5
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
6
+ *
7
+ * Copyright (c) 2014-2017, Jon Schlinkert.
8
+ * Released under the MIT License.
9
+ */
10
+ var require_is_plain_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11
+ var isObject = require_isobject();
12
+ function isObjectObject(o) {
13
+ return isObject(o) === true && Object.prototype.toString.call(o) === "[object Object]";
14
+ }
15
+ module.exports = function isPlainObject(o) {
16
+ var ctor, prot;
17
+ if (isObjectObject(o) === false) return false;
18
+ ctor = o.constructor;
19
+ if (typeof ctor !== "function") return false;
20
+ prot = ctor.prototype;
21
+ if (isObjectObject(prot) === false) return false;
22
+ if (prot.hasOwnProperty("isPrototypeOf") === false) return false;
23
+ return true;
24
+ };
25
+ }));
26
+ //#endregion
27
+ export default require_is_plain_object();
28
+ export { require_is_plain_object };
@@ -0,0 +1,17 @@
1
+ import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
2
+ //#region ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
3
+ /*!
4
+ * is-primitive <https://github.com/jonschlinkert/is-primitive>
5
+ *
6
+ * Copyright (c) 2014-present, Jon Schlinkert.
7
+ * Released under the MIT License.
8
+ */
9
+ var require_is_primitive = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10
+ module.exports = function isPrimitive(val) {
11
+ if (typeof val === "object") return val === null;
12
+ return typeof val !== "function";
13
+ };
14
+ }));
15
+ //#endregion
16
+ export default require_is_primitive();
17
+ export { require_is_primitive };
@@ -0,0 +1,16 @@
1
+ import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
2
+ //#region ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
3
+ /*!
4
+ * isobject <https://github.com/jonschlinkert/isobject>
5
+ *
6
+ * Copyright (c) 2014-2017, Jon Schlinkert.
7
+ * Released under the MIT License.
8
+ */
9
+ var require_isobject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
10
+ module.exports = function isObject(val) {
11
+ return val != null && typeof val === "object" && Array.isArray(val) === false;
12
+ };
13
+ }));
14
+ //#endregion
15
+ export default require_isobject();
16
+ export { require_isobject };
@@ -0,0 +1,118 @@
1
+ import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
2
+ import { require_is_primitive } from "../../../is-primitive@3.0.1/node_modules/is-primitive/index.js";
3
+ import { require_is_plain_object } from "../../../is-plain-object@2.0.4/node_modules/is-plain-object/index.js";
4
+ //#region ../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js
5
+ /*!
6
+ * set-value <https://github.com/jonschlinkert/set-value>
7
+ *
8
+ * Copyright (c) Jon Schlinkert (https://github.com/jonschlinkert).
9
+ * Released under the MIT License.
10
+ */
11
+ var require_set_value = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12
+ const { deleteProperty } = Reflect;
13
+ const isPrimitive = require_is_primitive();
14
+ const isPlainObject = require_is_plain_object();
15
+ const isObject = (value) => {
16
+ return typeof value === "object" && value !== null || typeof value === "function";
17
+ };
18
+ const isUnsafeKey = (key) => {
19
+ return key === "__proto__" || key === "constructor" || key === "prototype";
20
+ };
21
+ const validateKey = (key) => {
22
+ if (!isPrimitive(key)) throw new TypeError("Object keys must be strings or symbols");
23
+ if (isUnsafeKey(key)) throw new Error(`Cannot set unsafe key: "${key}"`);
24
+ };
25
+ const toStringKey = (input) => {
26
+ return Array.isArray(input) ? input.flat().map(String).join(",") : input;
27
+ };
28
+ const createMemoKey = (input, options) => {
29
+ if (typeof input !== "string" || !options) return input;
30
+ let key = input + ";";
31
+ if (options.arrays !== void 0) key += `arrays=${options.arrays};`;
32
+ if (options.separator !== void 0) key += `separator=${options.separator};`;
33
+ if (options.split !== void 0) key += `split=${options.split};`;
34
+ if (options.merge !== void 0) key += `merge=${options.merge};`;
35
+ if (options.preservePaths !== void 0) key += `preservePaths=${options.preservePaths};`;
36
+ return key;
37
+ };
38
+ const memoize = (input, options, fn) => {
39
+ const key = toStringKey(options ? createMemoKey(input, options) : input);
40
+ validateKey(key);
41
+ const value = setValue.cache.get(key) || fn();
42
+ setValue.cache.set(key, value);
43
+ return value;
44
+ };
45
+ const splitString = (input, options = {}) => {
46
+ const sep = options.separator || ".";
47
+ const preserve = sep === "/" ? false : options.preservePaths;
48
+ if (typeof input === "string" && preserve !== false && /\//.test(input)) return [input];
49
+ const parts = [];
50
+ let part = "";
51
+ const push = (part) => {
52
+ let number;
53
+ if (part.trim() !== "" && Number.isInteger(number = Number(part))) parts.push(number);
54
+ else parts.push(part);
55
+ };
56
+ for (let i = 0; i < input.length; i++) {
57
+ const value = input[i];
58
+ if (value === "\\") {
59
+ part += input[++i];
60
+ continue;
61
+ }
62
+ if (value === sep) {
63
+ push(part);
64
+ part = "";
65
+ continue;
66
+ }
67
+ part += value;
68
+ }
69
+ if (part) push(part);
70
+ return parts;
71
+ };
72
+ const split = (input, options) => {
73
+ if (options && typeof options.split === "function") return options.split(input);
74
+ if (typeof input === "symbol") return [input];
75
+ if (Array.isArray(input)) return input;
76
+ return memoize(input, options, () => splitString(input, options));
77
+ };
78
+ const assignProp = (obj, prop, value, options) => {
79
+ validateKey(prop);
80
+ if (value === void 0) deleteProperty(obj, prop);
81
+ else if (options && options.merge) {
82
+ const merge = options.merge === "function" ? options.merge : Object.assign;
83
+ if (merge && isPlainObject(obj[prop]) && isPlainObject(value)) obj[prop] = merge(obj[prop], value);
84
+ else obj[prop] = value;
85
+ } else obj[prop] = value;
86
+ return obj;
87
+ };
88
+ const setValue = (target, path, value, options) => {
89
+ if (!path || !isObject(target)) return target;
90
+ const keys = split(path, options);
91
+ let obj = target;
92
+ for (let i = 0; i < keys.length; i++) {
93
+ const key = keys[i];
94
+ const next = keys[i + 1];
95
+ validateKey(key);
96
+ if (next === void 0) {
97
+ assignProp(obj, key, value, options);
98
+ break;
99
+ }
100
+ if (typeof next === "number" && !Array.isArray(obj[key])) {
101
+ obj = obj[key] = [];
102
+ continue;
103
+ }
104
+ if (!isObject(obj[key])) obj[key] = {};
105
+ obj = obj[key];
106
+ }
107
+ return target;
108
+ };
109
+ setValue.split = split;
110
+ setValue.cache = /* @__PURE__ */ new Map();
111
+ setValue.clear = () => {
112
+ setValue.cache = /* @__PURE__ */ new Map();
113
+ };
114
+ module.exports = setValue;
115
+ }));
116
+ //#endregion
117
+ export default require_set_value();
118
+ export { require_set_value };
@@ -0,0 +1,7 @@
1
+ import { MiniProgramPlatformDescriptor } from "./types.js";
2
+ //#region src/platforms/descriptors.d.ts
3
+ /**
4
+ * @description 全仓库统一的小程序平台描述表。
5
+ */
6
+ export declare const MINI_PROGRAM_PLATFORM_DESCRIPTORS: readonly MiniProgramPlatformDescriptor[];
7
+ //#endregion
@@ -0,0 +1,204 @@
1
+ import { ALIPAY_RUNTIME_DESCRIPTOR, JD_RUNTIME_DESCRIPTOR, SWAN_RUNTIME_DESCRIPTOR, TT_RUNTIME_DESCRIPTOR, WEAPP_RUNTIME_DESCRIPTOR, XHS_RUNTIME_DESCRIPTOR } from "./runtime/descriptors.js";
2
+ import { MINI_PROGRAM_DIRECTIVE_PREFIXES } from "./runtime/template.js";
3
+ //#region src/platforms/descriptors.ts
4
+ const DEFAULT_PROJECT_CONFIG_ROOT_KEYS = ["miniprogramRoot", "srcMiniprogramRoot"];
5
+ /**
6
+ * @description 全仓库统一的小程序平台描述表。
7
+ */
8
+ const MINI_PROGRAM_PLATFORM_DESCRIPTORS = [
9
+ {
10
+ id: "weapp",
11
+ displayName: "WeChat Mini Program",
12
+ family: "wechat",
13
+ aliases: WEAPP_RUNTIME_DESCRIPTOR.aliases,
14
+ outputExtensions: {
15
+ js: "js",
16
+ json: "json",
17
+ wxml: "wxml",
18
+ wxss: "wxss",
19
+ wxs: "wxs"
20
+ },
21
+ projectConfigFileName: "project.config.json",
22
+ projectConfigRootKeys: DEFAULT_PROJECT_CONFIG_ROOT_KEYS,
23
+ ide: {},
24
+ build: {
25
+ autoTouchAppStyle: true,
26
+ defaultBuildTarget: "es2020"
27
+ },
28
+ resolvePreservedNpmDirNames: () => ["miniprogram_npm"],
29
+ json: {},
30
+ npm: { distDirName: () => "miniprogram_npm" },
31
+ wxml: {
32
+ eventBindingStyle: "default",
33
+ directivePrefix: MINI_PROGRAM_DIRECTIVE_PREFIXES.weapp
34
+ },
35
+ compiler: { templatePreset: "wechat" },
36
+ typescript: { appTypesPackage: "miniprogram-api-typings" },
37
+ runtime: WEAPP_RUNTIME_DESCRIPTOR.runtime
38
+ },
39
+ {
40
+ id: "alipay",
41
+ displayName: "Alipay Mini Program",
42
+ family: "alipay",
43
+ aliases: ALIPAY_RUNTIME_DESCRIPTOR.aliases,
44
+ outputExtensions: {
45
+ js: "js",
46
+ json: "json",
47
+ wxml: "axml",
48
+ wxss: "acss",
49
+ wxs: "sjs"
50
+ },
51
+ projectConfigFileName: "mini.project.json",
52
+ projectConfigRootKeys: DEFAULT_PROJECT_CONFIG_ROOT_KEYS,
53
+ scriptModuleTagByExtension: { sjs: "import-sjs" },
54
+ usesProjectRootNpmDir: true,
55
+ ide: {
56
+ requiresOpenPlatformArg: true,
57
+ defaultProjectRoot: "dist/alipay/dist"
58
+ },
59
+ build: {
60
+ autoTouchAppStyle: false,
61
+ defaultBuildTarget: "es2015"
62
+ },
63
+ resolvePreservedNpmDirNames: (options) => [options?.alipayNpmMode === "miniprogram_npm" ? "miniprogram_npm" : "node_modules"],
64
+ json: {
65
+ normalizeUsingComponents: true,
66
+ fillComponentGenericsDefault: true,
67
+ rewriteBundleNpmImports: true
68
+ },
69
+ npm: {
70
+ distDirName: (options) => options?.alipayNpmMode === "miniprogram_npm" ? "miniprogram_npm" : "node_modules",
71
+ normalizeImportPath: true,
72
+ normalizeMiniprogramPackage: true,
73
+ copyEsModuleDirectory: true,
74
+ hoistNestedDependencies: true,
75
+ shouldRebuildCachedPackage: true
76
+ },
77
+ wxml: {
78
+ eventBindingStyle: "alipay",
79
+ directivePrefix: MINI_PROGRAM_DIRECTIVE_PREFIXES.alipay,
80
+ normalizeComponentTagName: true,
81
+ normalizeVueTemplate: true,
82
+ emitGenericPlaceholder: true
83
+ },
84
+ compiler: { templatePreset: "alipay" },
85
+ typescript: { appTypesPackage: "@mini-types/alipay" },
86
+ runtime: ALIPAY_RUNTIME_DESCRIPTOR.runtime
87
+ },
88
+ {
89
+ id: "swan",
90
+ displayName: "Baidu Smart Program",
91
+ family: "swan",
92
+ aliases: SWAN_RUNTIME_DESCRIPTOR.aliases,
93
+ outputExtensions: {
94
+ js: "js",
95
+ json: "json",
96
+ wxml: "swan",
97
+ wxss: "css",
98
+ wxs: "sjs"
99
+ },
100
+ projectConfigFileName: "project.swan.json",
101
+ projectConfigRootKeys: ["smartProgramRoot", ...DEFAULT_PROJECT_CONFIG_ROOT_KEYS],
102
+ ide: {},
103
+ build: { autoTouchAppStyle: false },
104
+ resolvePreservedNpmDirNames: () => ["miniprogram_npm"],
105
+ json: {},
106
+ npm: { distDirName: () => "miniprogram_npm" },
107
+ wxml: {
108
+ eventBindingStyle: "default",
109
+ directivePrefix: MINI_PROGRAM_DIRECTIVE_PREFIXES.swan
110
+ },
111
+ compiler: { templatePreset: "swan" },
112
+ typescript: { appTypesPackage: "miniprogram-api-typings" },
113
+ runtime: SWAN_RUNTIME_DESCRIPTOR.runtime
114
+ },
115
+ {
116
+ id: "tt",
117
+ displayName: "ByteDance / Douyin Mini Program",
118
+ family: "tt",
119
+ aliases: TT_RUNTIME_DESCRIPTOR.aliases,
120
+ outputExtensions: {
121
+ js: "js",
122
+ json: "json",
123
+ wxml: "ttml",
124
+ wxss: "ttss"
125
+ },
126
+ projectConfigFileName: "project.config.json",
127
+ projectConfigRootKeys: DEFAULT_PROJECT_CONFIG_ROOT_KEYS,
128
+ ide: {},
129
+ build: { autoTouchAppStyle: false },
130
+ resolvePreservedNpmDirNames: () => ["miniprogram_npm"],
131
+ json: {
132
+ normalizeUsingComponents: true,
133
+ rewriteBundleNpmImports: true
134
+ },
135
+ npm: {
136
+ distDirName: () => "miniprogram_npm",
137
+ normalizeImportPath: true
138
+ },
139
+ wxml: {
140
+ eventBindingStyle: "default",
141
+ directivePrefix: MINI_PROGRAM_DIRECTIVE_PREFIXES.tt,
142
+ normalizeComponentTagName: true
143
+ },
144
+ compiler: { templatePreset: "tt" },
145
+ typescript: { appTypesPackage: "@douyin-microapp/typings" },
146
+ runtime: TT_RUNTIME_DESCRIPTOR.runtime
147
+ },
148
+ {
149
+ id: "jd",
150
+ displayName: "JD Mini Program",
151
+ family: "wechat",
152
+ aliases: JD_RUNTIME_DESCRIPTOR.aliases,
153
+ outputExtensions: {
154
+ js: "js",
155
+ json: "json",
156
+ wxml: "jxml",
157
+ wxss: "jxss",
158
+ wxs: "wxs"
159
+ },
160
+ projectConfigFileName: "project.config.json",
161
+ projectConfigRootKeys: DEFAULT_PROJECT_CONFIG_ROOT_KEYS,
162
+ ide: {},
163
+ build: { autoTouchAppStyle: false },
164
+ resolvePreservedNpmDirNames: () => ["miniprogram_npm"],
165
+ json: {},
166
+ npm: { distDirName: () => "miniprogram_npm" },
167
+ wxml: {
168
+ eventBindingStyle: "default",
169
+ directivePrefix: MINI_PROGRAM_DIRECTIVE_PREFIXES.jd
170
+ },
171
+ compiler: { templatePreset: "wechat" },
172
+ typescript: { appTypesPackage: "miniprogram-api-typings" },
173
+ runtime: JD_RUNTIME_DESCRIPTOR.runtime
174
+ },
175
+ {
176
+ id: "xhs",
177
+ displayName: "Xiaohongshu Mini Program",
178
+ family: "wechat",
179
+ aliases: XHS_RUNTIME_DESCRIPTOR.aliases,
180
+ outputExtensions: {
181
+ js: "js",
182
+ json: "json",
183
+ wxml: "xhsml",
184
+ wxss: "css",
185
+ wxs: "wxs"
186
+ },
187
+ projectConfigFileName: "project.config.json",
188
+ projectConfigRootKeys: DEFAULT_PROJECT_CONFIG_ROOT_KEYS,
189
+ ide: {},
190
+ build: { autoTouchAppStyle: false },
191
+ resolvePreservedNpmDirNames: () => ["miniprogram_npm"],
192
+ json: {},
193
+ npm: { distDirName: () => "miniprogram_npm" },
194
+ wxml: {
195
+ eventBindingStyle: "default",
196
+ directivePrefix: MINI_PROGRAM_DIRECTIVE_PREFIXES.xhs
197
+ },
198
+ compiler: { templatePreset: "wechat" },
199
+ typescript: { appTypesPackage: "miniprogram-api-typings" },
200
+ runtime: XHS_RUNTIME_DESCRIPTOR.runtime
201
+ }
202
+ ];
203
+ //#endregion
204
+ export { MINI_PROGRAM_PLATFORM_DESCRIPTORS };
@@ -0,0 +1,26 @@
1
+ import { MiniProgramPlatformDescriptor, MiniProgramTemplatePreset, MpPlatform } from "./types.js";
2
+ import { MINI_PROGRAM_PLATFORM_ALIASES, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeDescriptor, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getSupportedMiniProgramPlatforms, normalizeMiniProgramPlatform, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, supportsMiniProgramRuntimeCapability } from "./runtime/helpers.js";
3
+ import { getMiniProgramDirectivePrefix, getSupportedMiniProgramDirectivePrefixes } from "./runtime/template.js";
4
+ //#region src/platforms/helpers.d.ts
5
+ /**
6
+ * @description 获取平台描述。
7
+ */
8
+ export declare function getMiniProgramPlatformDescriptor(platform: MpPlatform): MiniProgramPlatformDescriptor;
9
+ /**
10
+ * @description 获取模板编译预设。
11
+ */
12
+ export declare function getMiniProgramTemplatePreset(platform?: MpPlatform): MiniProgramTemplatePreset;
13
+ /**
14
+ * @description 判断平台是否允许自动补齐 app 样式入口。
15
+ */
16
+ export declare function supportsMiniProgramAutoTouchAppStyle(platform?: MpPlatform): boolean;
17
+ /**
18
+ * @description 获取平台默认构建目标。
19
+ */
20
+ export declare function getMiniProgramDefaultBuildTarget(platform?: MpPlatform): string | undefined;
21
+ /**
22
+ * @description 获取平台默认使用的类型包。
23
+ */
24
+ export declare function getMiniProgramAppTypesPackage(platform?: MpPlatform): string;
25
+ //#endregion
26
+ export { MINI_PROGRAM_PLATFORM_ALIASES, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramDirectivePrefix, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeDescriptor, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, normalizeMiniProgramPlatform, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, supportsMiniProgramRuntimeCapability };
@@ -0,0 +1,42 @@
1
+ import { getMiniProgramDirectivePrefix, getSupportedMiniProgramDirectivePrefixes } from "./runtime/template.js";
2
+ import { MINI_PROGRAM_PLATFORM_DESCRIPTORS } from "./descriptors.js";
3
+ import { MINI_PROGRAM_PLATFORM_ALIASES, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeDescriptor, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getSupportedMiniProgramPlatforms, normalizeMiniProgramPlatform, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, supportsMiniProgramRuntimeCapability } from "./runtime/helpers.js";
4
+ //#region src/platforms/helpers.ts
5
+ const MINI_PROGRAM_PLATFORM_DESCRIPTOR_BY_ID = new Map(MINI_PROGRAM_PLATFORM_DESCRIPTORS.map((descriptor) => [descriptor.id, descriptor]));
6
+ /**
7
+ * @description 获取平台描述。
8
+ */
9
+ function getMiniProgramPlatformDescriptor(platform) {
10
+ const descriptor = MINI_PROGRAM_PLATFORM_DESCRIPTOR_BY_ID.get(platform);
11
+ if (!descriptor) throw new Error(`不支持的小程序平台 "${platform}"。`);
12
+ return descriptor;
13
+ }
14
+ /**
15
+ * @description 获取模板编译预设。
16
+ */
17
+ function getMiniProgramTemplatePreset(platform) {
18
+ if (!platform) return "wechat";
19
+ return getMiniProgramPlatformDescriptor(platform).compiler?.templatePreset ?? "wechat";
20
+ }
21
+ /**
22
+ * @description 判断平台是否允许自动补齐 app 样式入口。
23
+ */
24
+ function supportsMiniProgramAutoTouchAppStyle(platform) {
25
+ if (!platform) return false;
26
+ return getMiniProgramPlatformDescriptor(platform).build?.autoTouchAppStyle === true;
27
+ }
28
+ /**
29
+ * @description 获取平台默认构建目标。
30
+ */
31
+ function getMiniProgramDefaultBuildTarget(platform) {
32
+ if (!platform) return;
33
+ return getMiniProgramPlatformDescriptor(platform).build?.defaultBuildTarget;
34
+ }
35
+ /**
36
+ * @description 获取平台默认使用的类型包。
37
+ */
38
+ function getMiniProgramAppTypesPackage(platform) {
39
+ return getMiniProgramPlatformDescriptor(platform ?? getDefaultMiniProgramPlatform()).typescript?.appTypesPackage ?? "miniprogram-api-typings";
40
+ }
41
+ //#endregion
42
+ export { MINI_PROGRAM_PLATFORM_ALIASES, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramDirectivePrefix, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramPlatformDescriptor, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeDescriptor, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getMiniProgramTemplatePreset, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, normalizeMiniProgramPlatform, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, supportsMiniProgramAutoTouchAppStyle, supportsMiniProgramRuntimeCapability };
@@ -1,2 +1,6 @@
1
- import { A as MpPlatform, C as MINI_PROGRAM_PLATFORM_DESCRIPTORS, D as MiniProgramRuntimeCapabilities, E as MiniProgramPlatformFamily, O as MiniProgramRuntimeCapabilityName, S as supportsMiniProgramRuntimeCapability, T as MiniProgramPlatformDescriptor, _ as getSupportedMiniProgramPlatforms, a as getMiniProgramDefaultBuildTarget, b as resolveMiniProgramPlatform, c as getMiniProgramPlatformDescriptor, d as getMiniProgramRuntimeGlobalKey, f as getMiniProgramRuntimeGlobalKeys, g as getSupportedMiniProgramDirectivePrefixes, h as getMiniProgramTemplatePreset, i as getMiniProgramAppTypesPackage, j as OutputExtensions, k as MiniProgramTemplatePreset, l as getMiniProgramRouteRuntimeGlobalKeys, m as getMiniProgramRuntimeHostConfigKey, n as getDefaultMiniProgramPlatform, o as getMiniProgramDirectivePrefix, p as getMiniProgramRuntimeGlobalKeysByResolvePriority, r as getDefaultMiniProgramRuntimeGlobalKey, s as getMiniProgramPlatformByRuntimeGlobalKey, t as MINI_PROGRAM_PLATFORM_ALIASES, u as getMiniProgramRuntimeCapabilities, v as normalizeMiniProgramPlatform, w as MiniProgramPageIdentityRule, x as supportsMiniProgramAutoTouchAppStyle, y as resolveMiniProgramPageKeys } from "../index-BxC5D0Iz.js";
1
+ import { MiniProgramPageIdentityRule, MiniProgramPlatformDescriptor, MiniProgramPlatformFamily, MiniProgramRuntimeCapabilities, MiniProgramRuntimeCapabilityName, MiniProgramTemplatePreset, MpPlatform, OutputExtensions } from "./types.js";
2
+ import { MINI_PROGRAM_PLATFORM_DESCRIPTORS } from "./descriptors.js";
3
+ import { MINI_PROGRAM_PLATFORM_ALIASES, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getSupportedMiniProgramPlatforms, normalizeMiniProgramPlatform, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, supportsMiniProgramRuntimeCapability } from "./runtime/helpers.js";
4
+ import { getMiniProgramDirectivePrefix, getSupportedMiniProgramDirectivePrefixes } from "./runtime/template.js";
5
+ import { getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramPlatformDescriptor, getMiniProgramTemplatePreset, supportsMiniProgramAutoTouchAppStyle } from "./helpers.js";
2
6
  export { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, type MiniProgramPageIdentityRule, type MiniProgramPlatformDescriptor, type MiniProgramPlatformFamily, type MiniProgramRuntimeCapabilities, type MiniProgramRuntimeCapabilityName, type MiniProgramTemplatePreset, type MpPlatform, type OutputExtensions, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramDirectivePrefix, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramPlatformDescriptor, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getMiniProgramTemplatePreset, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, normalizeMiniProgramPlatform, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, supportsMiniProgramAutoTouchAppStyle, supportsMiniProgramRuntimeCapability };
@@ -1,2 +1,5 @@
1
- import { C as MINI_PROGRAM_PLATFORM_DESCRIPTORS, S as supportsMiniProgramRuntimeCapability, _ as getSupportedMiniProgramPlatforms, a as getMiniProgramDefaultBuildTarget, b as resolveMiniProgramPlatform, c as getMiniProgramPlatformDescriptor, d as getMiniProgramRuntimeGlobalKey, f as getMiniProgramRuntimeGlobalKeys, g as getSupportedMiniProgramDirectivePrefixes, h as getMiniProgramTemplatePreset, i as getMiniProgramAppTypesPackage, l as getMiniProgramRouteRuntimeGlobalKeys, m as getMiniProgramRuntimeHostConfigKey, n as getDefaultMiniProgramPlatform, o as getMiniProgramDirectivePrefix, p as getMiniProgramRuntimeGlobalKeysByResolvePriority, r as getDefaultMiniProgramRuntimeGlobalKey, s as getMiniProgramPlatformByRuntimeGlobalKey, t as MINI_PROGRAM_PLATFORM_ALIASES, u as getMiniProgramRuntimeCapabilities, v as normalizeMiniProgramPlatform, x as supportsMiniProgramAutoTouchAppStyle, y as resolveMiniProgramPageKeys } from "../platforms-DeV7WlYI.js";
1
+ import { getMiniProgramDirectivePrefix, getSupportedMiniProgramDirectivePrefixes } from "./runtime/template.js";
2
+ import { MINI_PROGRAM_PLATFORM_DESCRIPTORS } from "./descriptors.js";
3
+ import { MINI_PROGRAM_PLATFORM_ALIASES, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getSupportedMiniProgramPlatforms, normalizeMiniProgramPlatform, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, supportsMiniProgramRuntimeCapability } from "./runtime/helpers.js";
4
+ import { getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramPlatformDescriptor, getMiniProgramTemplatePreset, supportsMiniProgramAutoTouchAppStyle } from "./helpers.js";
2
5
  export { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramDirectivePrefix, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramPlatformDescriptor, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getMiniProgramTemplatePreset, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, normalizeMiniProgramPlatform, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, supportsMiniProgramAutoTouchAppStyle, supportsMiniProgramRuntimeCapability };
@@ -0,0 +1,13 @@
1
+ import { MiniProgramPlatformDescriptor, MiniProgramRuntimeCapabilities } from "../types.js";
2
+ //#region src/platforms/runtime/descriptors.d.ts
3
+ export type MiniProgramRuntimeDescriptor = Pick<MiniProgramPlatformDescriptor, 'id' | 'aliases' | 'runtime'>;
4
+ export declare const DEFAULT_RUNTIME_HOST_CONFIG_KEY = "__wxConfig";
5
+ export declare const DEFAULT_RUNTIME_CAPABILITIES: MiniProgramRuntimeCapabilities;
6
+ export declare const WEAPP_RUNTIME_DESCRIPTOR: MiniProgramRuntimeDescriptor;
7
+ export declare const ALIPAY_RUNTIME_DESCRIPTOR: MiniProgramRuntimeDescriptor;
8
+ export declare const SWAN_RUNTIME_DESCRIPTOR: MiniProgramRuntimeDescriptor;
9
+ export declare const TT_RUNTIME_DESCRIPTOR: MiniProgramRuntimeDescriptor;
10
+ export declare const JD_RUNTIME_DESCRIPTOR: MiniProgramRuntimeDescriptor;
11
+ export declare const XHS_RUNTIME_DESCRIPTOR: MiniProgramRuntimeDescriptor;
12
+ export declare const MINI_PROGRAM_RUNTIME_DESCRIPTORS: readonly MiniProgramRuntimeDescriptor[];
13
+ //#endregion