@weapp-core/shared 3.2.8 → 3.4.0

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 (34) hide show
  1. package/README.md +11 -0
  2. package/dist/_virtual/_rolldown/runtime.js +2 -3
  3. package/dist/fs/index.d.ts +1 -2
  4. package/dist/fs/index.js +1 -2
  5. package/dist/index.d.ts +0 -2
  6. package/dist/index.js +3 -4
  7. package/dist/layoutHostRegistry.d.ts +1 -3
  8. package/dist/layoutHostRegistry.js +1 -2
  9. package/dist/node.d.ts +0 -2
  10. package/dist/node.js +1 -2
  11. package/dist/node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.d.ts +0 -2
  12. package/dist/node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.js +1 -2
  13. package/dist/node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js +1 -2
  14. package/dist/node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js +1 -2
  15. package/dist/node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js +1 -2
  16. package/dist/node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js +1 -2
  17. package/dist/platforms/descriptors.d.ts +1 -3
  18. package/dist/platforms/descriptors.js +1 -2
  19. package/dist/platforms/helpers.d.ts +0 -2
  20. package/dist/platforms/helpers.js +1 -2
  21. package/dist/platforms/runtime/descriptors.d.ts +1 -3
  22. package/dist/platforms/runtime/descriptors.js +1 -2
  23. package/dist/platforms/runtime/helpers.d.ts +1 -3
  24. package/dist/platforms/runtime/helpers.js +1 -2
  25. package/dist/platforms/runtime/template.d.ts +1 -3
  26. package/dist/platforms/runtime/template.js +1 -2
  27. package/dist/platforms/types.d.ts +1 -3
  28. package/dist/rich-text.d.ts +19 -0
  29. package/dist/rich-text.js +226 -0
  30. package/dist/runtimeProviders.d.ts +1 -3
  31. package/dist/wxml.d.ts +1 -3
  32. package/dist/wxml.js +1 -2
  33. package/package.json +16 -2
  34. package/dist/node_modules/.pnpm/get-value@4.1.0/node_modules/get-value/dist/index.js +0 -75
package/README.md CHANGED
@@ -11,6 +11,7 @@
11
11
  - 对象合并与判定工具
12
12
  - 统一导出常用第三方工具(`defu`、`get`、`set`)
13
13
  - 通过 `@weapp-core/shared/node` 提供 Node 专用哈希与文件系统能力
14
+ - 通过独立、浏览器安全的 `@weapp-core/shared/rich-text` 子入口提供富文本安全树规范化,根入口不加载 HTML 解析器
14
15
 
15
16
  ## 安装
16
17
 
@@ -35,6 +36,16 @@ const hash = objectHash({ foo: 'bar' })
35
36
  const exists = await fs.pathExists('app.json')
36
37
  ```
37
38
 
39
+ ### 富文本安全树
40
+
41
+ ```ts
42
+ import { normalizeRichTextNodes } from '@weapp-core/shared/rich-text'
43
+
44
+ const nodes = normalizeRichTextNodes('<p>Hello <strong>world</strong></p>')
45
+ ```
46
+
47
+ 该子入口接受 HTML 字符串或结构化节点,返回命名的 `SafeRichTextNode` 文本/元素联合类型。Web 原生组件与 headless 模拟器共用同一份标签、属性、URL 和样式规则;输出是惰性的内容树,不执行脚本或模板。宿主保留自己的元数据边界,例如模拟器另外拒绝外部 `data-sim-*` 属性。
48
+
38
49
  ## 配置
39
50
 
40
51
  暂无额外配置。
@@ -1,11 +1,11 @@
1
- //#region \0rolldown/runtime.js
1
+ // \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
8
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
9
9
  var __copyProps = (to, from, except, desc) => {
10
10
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
11
  key = keys[i];
@@ -20,5 +20,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
20
20
  value: mod,
21
21
  enumerable: true
22
22
  }) : target, mod));
23
- //#endregion
24
23
  export { __commonJSMin, __toESM };
@@ -1,6 +1,5 @@
1
1
  import { Dirent, OpenMode, PathLike, Stats, closeSync, constants, existsSync, mkdirSync, openSync, promises, readFileSync, unlinkSync, utimesSync, watch, writeFileSync } from "node:fs";
2
2
  import { FileHandle } from "node:fs/promises";
3
- //#region src/fs/index.d.ts
4
3
  export interface JsonReadOptions {
5
4
  encoding?: BufferEncoding;
6
5
  throws?: boolean;
@@ -88,4 +87,4 @@ export declare const fs: {
88
87
  };
89
88
  export type FsDirent = Dirent;
90
89
  export type FsStats = Stats;
91
- //#endregion
90
+ export {};
package/dist/fs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Dirent, Stats, close, closeSync, constants, existsSync, mkdirSync, openSync, promises, readFileSync, unlinkSync, utimesSync, watch, writeFileSync } from "node:fs";
2
2
  import path from "node:path";
3
- //#region src/fs/index.ts
3
+ // src/fs/index.ts
4
4
  function normalizeJsonEncoding(encoding) {
5
5
  return encoding ?? "utf8";
6
6
  }
@@ -194,5 +194,4 @@ const fs = {
194
194
  writeJSON,
195
195
  writeJson
196
196
  };
197
- //#endregion
198
197
  export { fs };
package/dist/index.d.ts CHANGED
@@ -9,7 +9,6 @@ import { RuntimeProviderBackend, RuntimeProviderCapabilities, RuntimeProviderCom
9
9
  import { escapeWxmlAttribute, escapeWxmlText } from "./wxml.js";
10
10
  import get from "get-value";
11
11
  import set from "set-value";
12
- //#region src/index.d.ts
13
12
  /**
14
13
  * @description 转义字符串中的正则特殊字符
15
14
  */
@@ -42,5 +41,4 @@ export declare function isObject(x: unknown): x is Record<string | symbol | numb
42
41
  * @description 判断对象是否为空对象
43
42
  */
44
43
  export declare function isEmptyObject(obj: unknown): boolean;
45
- //#endregion
46
44
  export { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, MiniProgramLayoutHostResolver, MiniProgramLayoutHostWaitOptions, type MiniProgramPageIdentityRule, type MiniProgramPlatformDescriptor, type MiniProgramPlatformFamily, type MiniProgramRuntimeCapabilities, type MiniProgramRuntimeCapabilityName, type MiniProgramTemplatePreset, type MpPlatform, type OutputExtensions, RuntimeProviderBackend, RuntimeProviderCapabilities, RuntimeProviderCompilation, RuntimeProviderDescriptorContract, RuntimeProviderEntry, RuntimeProviderHmrDescriptor, RuntimeProviderHmrMode, RuntimeProviderInjectionMode, RuntimeProviderModuleKind, RuntimeProviderVariant, createMiniProgramLayoutHostRegistry, defu, escapeWxmlAttribute, escapeWxmlText, get, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramDirectivePrefix, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramPlatformDescriptor, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getMiniProgramTemplatePreset, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, normalizeMiniProgramLayoutHostKeys, normalizeMiniProgramPlatform, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, set, supportsMiniProgramAutoTouchAppStyle, supportsMiniProgramRuntimeCapability };
package/dist/index.js CHANGED
@@ -6,9 +6,9 @@ import { MINI_PROGRAM_PLATFORM_DESCRIPTORS } from "./platforms/descriptors.js";
6
6
  import { MINI_PROGRAM_PLATFORM_ALIASES, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getSupportedMiniProgramPlatforms, normalizeMiniProgramPlatform, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, supportsMiniProgramRuntimeCapability } from "./platforms/runtime/helpers.js";
7
7
  import { getMiniProgramAppTypesPackage, getMiniProgramDefaultBuildTarget, getMiniProgramPlatformDescriptor, getMiniProgramTemplatePreset, supportsMiniProgramAutoTouchAppStyle } from "./platforms/helpers.js";
8
8
  import { escapeWxmlAttribute, escapeWxmlText } from "./wxml.js";
9
- import index_default from "./node_modules/.pnpm/get-value@4.1.0/node_modules/get-value/dist/index.js";
10
9
  import { require_set_value } from "./node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js";
11
- //#region src/index.ts
10
+ import get from "get-value";
11
+ // src/index.ts
12
12
  var import_set_value = /* @__PURE__ */ __toESM(require_set_value(), 1);
13
13
  const SPECIAL_CHARS_RE = /[|\\{}()[\]^$+*?.]/g;
14
14
  const HYPHEN_RE = /-/g;
@@ -77,6 +77,5 @@ function isEmptyObject(obj) {
77
77
  }
78
78
  return false;
79
79
  }
80
- //#endregion
81
80
  var set = import_set_value.default;
82
- export { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, addExtension, arrify, createMiniProgramLayoutHostRegistry, defu, defuOverrideArray, escapeStringRegexp, escapeWxmlAttribute, escapeWxmlText, 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 };
81
+ export { MINI_PROGRAM_PLATFORM_ALIASES, MINI_PROGRAM_PLATFORM_DESCRIPTORS, addExtension, arrify, createMiniProgramLayoutHostRegistry, defu, defuOverrideArray, escapeStringRegexp, escapeWxmlAttribute, escapeWxmlText, 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 };
@@ -1,4 +1,3 @@
1
- //#region src/layoutHostRegistry.d.ts
2
1
  export interface MiniProgramLayoutHostWaitOptions {
3
2
  interval?: number;
4
3
  retries?: number;
@@ -18,5 +17,4 @@ export declare function createMiniProgramLayoutHostRegistry<TBridge>(): {
18
17
  unregister: (keys: string | string[], bridge: TBridge, pageKeys: string[]) => boolean;
19
18
  unregisterBridge: (bridge: TBridge) => boolean;
20
19
  waitForHost: <THost>(key: string, resolvePageKeys: () => string[], resolver: MiniProgramLayoutHostResolver<TBridge, THost>, options?: MiniProgramLayoutHostWaitOptions) => Promise<THost | null>;
21
- };
22
- //#endregion
20
+ };
@@ -1,4 +1,4 @@
1
- //#region src/layoutHostRegistry.ts
1
+ // src/layoutHostRegistry.ts
2
2
  /**
3
3
  * @description 对 layout host key 去重并过滤空字符串。
4
4
  */
@@ -75,5 +75,4 @@ function createMiniProgramLayoutHostRegistry() {
75
75
  waitForHost
76
76
  };
77
77
  }
78
- //#endregion
79
78
  export { createMiniProgramLayoutHostRegistry, normalizeMiniProgramLayoutHostKeys };
package/dist/node.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import { CopyOptions, FsDirent, FsStats, JsonReadOptions, JsonWriteOptions, MoveOptions, fs } from "./fs/index.js";
2
- //#region src/node.d.ts
3
2
  /**
4
3
  * @description 生成稳定对象哈希,避免依赖已被禁用的 object-hash 包。
5
4
  */
6
5
  export declare function objectHash(value: unknown): string;
7
- //#endregion
8
6
  export { type CopyOptions, type FsDirent, type FsStats, type JsonReadOptions, type JsonWriteOptions, type MoveOptions, fs };
package/dist/node.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { fs } from "./fs/index.js";
2
- //#region src/node.ts
2
+ // src/node.ts
3
3
  const UTF8_ENCODER = new TextEncoder();
4
4
  const HASH_SEEDS = [
5
5
  0,
@@ -57,5 +57,4 @@ function objectHash(value) {
57
57
  const bytes = UTF8_ENCODER.encode(stableSerialize(value));
58
58
  return HASH_SEEDS.map((seed) => xmur3(bytes, seed).toString(16).padStart(8, "0")).join("");
59
59
  }
60
- //#endregion
61
60
  export { fs, objectHash };
@@ -1,4 +1,3 @@
1
- //#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.d.mts
2
1
  type Input = Record<string | number | symbol, any>;
3
2
  type IgnoredInput = boolean | number | null | any[] | Record<never, any> | undefined;
4
3
  type Merger = <T extends Input, K extends keyof T>(object: T, key: keyof T, value: T[K], namespace: string) => any;
@@ -15,5 +14,4 @@ interface DefuInstance {
15
14
  type MergeArrays<Destination, Source> = Destination extends Array<infer DestinationType> ? Source extends Array<infer SourceType> ? Array<DestinationType | SourceType> : Source | Array<DestinationType> : Source | Destination;
16
15
  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
16
  declare const defu: DefuInstance;
18
- //#endregion
19
17
  export { type Defu, type DefuFn, type DefuInstance, defu as default, defu };
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
1
+ // ../../node_modules/.pnpm/defu@6.1.7/node_modules/defu/dist/defu.mjs
2
2
  function isPlainObject(value) {
3
3
  if (value === null || typeof value !== "object") return false;
4
4
  const prototype = Object.getPrototypeOf(value);
@@ -25,5 +25,4 @@ function createDefu(merger) {
25
25
  return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
26
26
  }
27
27
  const defu = createDefu();
28
- //#endregion
29
28
  export { createDefu, defu as default, defu };
@@ -1,6 +1,6 @@
1
1
  import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
2
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
3
+ // ../../node_modules/.pnpm/is-plain-object@2.0.4/node_modules/is-plain-object/index.js
4
4
  /*!
5
5
  * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
6
6
  *
@@ -23,6 +23,5 @@ var require_is_plain_object = /* @__PURE__ */ __commonJSMin(((exports, module) =
23
23
  return true;
24
24
  };
25
25
  }));
26
- //#endregion
27
26
  export default require_is_plain_object();
28
27
  export { require_is_plain_object };
@@ -1,5 +1,5 @@
1
1
  import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
2
- //#region ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
2
+ // ../../node_modules/.pnpm/is-primitive@3.0.1/node_modules/is-primitive/index.js
3
3
  /*!
4
4
  * is-primitive <https://github.com/jonschlinkert/is-primitive>
5
5
  *
@@ -12,6 +12,5 @@ var require_is_primitive = /* @__PURE__ */ __commonJSMin(((exports, module) => {
12
12
  return typeof val !== "function";
13
13
  };
14
14
  }));
15
- //#endregion
16
15
  export default require_is_primitive();
17
16
  export { require_is_primitive };
@@ -1,5 +1,5 @@
1
1
  import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
2
- //#region ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
2
+ // ../../node_modules/.pnpm/isobject@3.0.1/node_modules/isobject/index.js
3
3
  /*!
4
4
  * isobject <https://github.com/jonschlinkert/isobject>
5
5
  *
@@ -11,6 +11,5 @@ var require_isobject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
11
11
  return val != null && typeof val === "object" && Array.isArray(val) === false;
12
12
  };
13
13
  }));
14
- //#endregion
15
14
  export default require_isobject();
16
15
  export { require_isobject };
@@ -1,7 +1,7 @@
1
1
  import { __commonJSMin } from "../../../../../_virtual/_rolldown/runtime.js";
2
2
  import { require_is_primitive } from "../../../is-primitive@3.0.1/node_modules/is-primitive/index.js";
3
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
4
+ // ../../node_modules/.pnpm/set-value@4.1.0/node_modules/set-value/index.js
5
5
  /*!
6
6
  * set-value <https://github.com/jonschlinkert/set-value>
7
7
  *
@@ -113,6 +113,5 @@ var require_set_value = /* @__PURE__ */ __commonJSMin(((exports, module) => {
113
113
  };
114
114
  module.exports = setValue;
115
115
  }));
116
- //#endregion
117
116
  export default require_set_value();
118
117
  export { require_set_value };
@@ -1,7 +1,5 @@
1
1
  import { MiniProgramPlatformDescriptor } from "./types.js";
2
- //#region src/platforms/descriptors.d.ts
3
2
  /**
4
3
  * @description 全仓库统一的小程序平台描述表。
5
4
  */
6
- export declare const MINI_PROGRAM_PLATFORM_DESCRIPTORS: readonly MiniProgramPlatformDescriptor[];
7
- //#endregion
5
+ export declare const MINI_PROGRAM_PLATFORM_DESCRIPTORS: readonly MiniProgramPlatformDescriptor[];
@@ -1,6 +1,6 @@
1
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
2
  import { MINI_PROGRAM_DIRECTIVE_PREFIXES } from "./runtime/template.js";
3
- //#region src/platforms/descriptors.ts
3
+ // src/platforms/descriptors.ts
4
4
  const DEFAULT_PROJECT_CONFIG_ROOT_KEYS = ["miniprogramRoot", "srcMiniprogramRoot"];
5
5
  /**
6
6
  * @description 全仓库统一的小程序平台描述表。
@@ -200,5 +200,4 @@ const MINI_PROGRAM_PLATFORM_DESCRIPTORS = [
200
200
  runtime: XHS_RUNTIME_DESCRIPTOR.runtime
201
201
  }
202
202
  ];
203
- //#endregion
204
203
  export { MINI_PROGRAM_PLATFORM_DESCRIPTORS };
@@ -1,7 +1,6 @@
1
1
  import { MiniProgramPlatformDescriptor, MiniProgramTemplatePreset, MpPlatform } from "./types.js";
2
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
3
  import { getMiniProgramDirectivePrefix, getSupportedMiniProgramDirectivePrefixes } from "./runtime/template.js";
4
- //#region src/platforms/helpers.d.ts
5
4
  /**
6
5
  * @description 获取平台描述。
7
6
  */
@@ -22,5 +21,4 @@ export declare function getMiniProgramDefaultBuildTarget(platform?: MpPlatform):
22
21
  * @description 获取平台默认使用的类型包。
23
22
  */
24
23
  export declare function getMiniProgramAppTypesPackage(platform?: MpPlatform): string;
25
- //#endregion
26
24
  export { MINI_PROGRAM_PLATFORM_ALIASES, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramDirectivePrefix, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeDescriptor, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getSupportedMiniProgramDirectivePrefixes, getSupportedMiniProgramPlatforms, normalizeMiniProgramPlatform, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, supportsMiniProgramRuntimeCapability };
@@ -1,7 +1,7 @@
1
1
  import { getMiniProgramDirectivePrefix, getSupportedMiniProgramDirectivePrefixes } from "./runtime/template.js";
2
2
  import { MINI_PROGRAM_PLATFORM_DESCRIPTORS } from "./descriptors.js";
3
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
4
+ // src/platforms/helpers.ts
5
5
  const MINI_PROGRAM_PLATFORM_DESCRIPTOR_BY_ID = new Map(MINI_PROGRAM_PLATFORM_DESCRIPTORS.map((descriptor) => [descriptor.id, descriptor]));
6
6
  /**
7
7
  * @description 获取平台描述。
@@ -38,5 +38,4 @@ function getMiniProgramDefaultBuildTarget(platform) {
38
38
  function getMiniProgramAppTypesPackage(platform) {
39
39
  return getMiniProgramPlatformDescriptor(platform ?? getDefaultMiniProgramPlatform()).typescript?.appTypesPackage ?? "miniprogram-api-typings";
40
40
  }
41
- //#endregion
42
41
  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,5 +1,4 @@
1
1
  import { MiniProgramPlatformDescriptor, MiniProgramRuntimeCapabilities } from "../types.js";
2
- //#region src/platforms/runtime/descriptors.d.ts
3
2
  export type MiniProgramRuntimeDescriptor = Pick<MiniProgramPlatformDescriptor, 'id' | 'aliases' | 'runtime'>;
4
3
  export declare const DEFAULT_RUNTIME_HOST_CONFIG_KEY = "__wxConfig";
5
4
  export declare const DEFAULT_RUNTIME_CAPABILITIES: MiniProgramRuntimeCapabilities;
@@ -9,5 +8,4 @@ export declare const SWAN_RUNTIME_DESCRIPTOR: MiniProgramRuntimeDescriptor;
9
8
  export declare const TT_RUNTIME_DESCRIPTOR: MiniProgramRuntimeDescriptor;
10
9
  export declare const JD_RUNTIME_DESCRIPTOR: MiniProgramRuntimeDescriptor;
11
10
  export declare const XHS_RUNTIME_DESCRIPTOR: MiniProgramRuntimeDescriptor;
12
- export declare const MINI_PROGRAM_RUNTIME_DESCRIPTORS: readonly MiniProgramRuntimeDescriptor[];
13
- //#endregion
11
+ export declare const MINI_PROGRAM_RUNTIME_DESCRIPTORS: readonly MiniProgramRuntimeDescriptor[];
@@ -1,4 +1,4 @@
1
- //#region src/platforms/runtime/descriptors.ts
1
+ // src/platforms/runtime/descriptors.ts
2
2
  const DEFAULT_RUNTIME_HOST_CONFIG_KEY = "__wxConfig";
3
3
  const DEFAULT_RUNTIME_CAPABILITIES = Object.freeze({
4
4
  globalPageStack: true,
@@ -137,5 +137,4 @@ const MINI_PROGRAM_RUNTIME_DESCRIPTORS = [
137
137
  JD_RUNTIME_DESCRIPTOR,
138
138
  XHS_RUNTIME_DESCRIPTOR
139
139
  ];
140
- //#endregion
141
140
  export { ALIPAY_RUNTIME_DESCRIPTOR, DEFAULT_RUNTIME_CAPABILITIES, DEFAULT_RUNTIME_HOST_CONFIG_KEY, JD_RUNTIME_DESCRIPTOR, MINI_PROGRAM_RUNTIME_DESCRIPTORS, SWAN_RUNTIME_DESCRIPTOR, TT_RUNTIME_DESCRIPTOR, WEAPP_RUNTIME_DESCRIPTOR, XHS_RUNTIME_DESCRIPTOR };
@@ -1,6 +1,5 @@
1
1
  import { MiniProgramRuntimeCapabilities, MiniProgramRuntimeCapabilityName, MpPlatform } from "../types.js";
2
2
  import { MiniProgramRuntimeDescriptor } from "./descriptors.js";
3
- //#region src/platforms/runtime/helpers.d.ts
4
3
  export declare const MINI_PROGRAM_PLATFORM_ALIASES: Readonly<Record<string, MpPlatform>>;
5
4
  /**
6
5
  * @description 标准化平台输入。
@@ -61,5 +60,4 @@ export declare function supportsMiniProgramRuntimeCapability(platform: MpPlatfor
61
60
  /**
62
61
  * @description 根据平台描述解析页面身份 key。
63
62
  */
64
- export declare function resolveMiniProgramPageKeys(page?: Record<string, any>, platform?: MpPlatform): string[];
65
- //#endregion
63
+ export declare function resolveMiniProgramPageKeys(page?: Record<string, any>, platform?: MpPlatform): string[];
@@ -1,5 +1,5 @@
1
1
  import { DEFAULT_RUNTIME_CAPABILITIES, MINI_PROGRAM_RUNTIME_DESCRIPTORS } from "./descriptors.js";
2
- //#region src/platforms/runtime/helpers.ts
2
+ // src/platforms/runtime/helpers.ts
3
3
  const LEADING_SLASH_RE = /^\/+/;
4
4
  function createMiniProgramPlatformRegistry(descriptors) {
5
5
  const descriptorById = /* @__PURE__ */ new Map();
@@ -165,5 +165,4 @@ function resolveMiniProgramPageKeys(page, platform) {
165
165
  }
166
166
  return Array.from(new Set(keys));
167
167
  }
168
- //#endregion
169
168
  export { MINI_PROGRAM_PLATFORM_ALIASES, getDefaultMiniProgramPlatform, getDefaultMiniProgramRuntimeGlobalKey, getMiniProgramPlatformByRuntimeGlobalKey, getMiniProgramRouteRuntimeGlobalKeys, getMiniProgramRuntimeCapabilities, getMiniProgramRuntimeDescriptor, getMiniProgramRuntimeGlobalKey, getMiniProgramRuntimeGlobalKeys, getMiniProgramRuntimeGlobalKeysByResolvePriority, getMiniProgramRuntimeHostConfigKey, getSupportedMiniProgramPlatforms, normalizeMiniProgramPlatform, resolveMiniProgramPageKeys, resolveMiniProgramPlatform, supportsMiniProgramRuntimeCapability };
@@ -1,7 +1,5 @@
1
1
  import { MpPlatform } from "../types.js";
2
- //#region src/platforms/runtime/template.d.ts
3
2
  /** 返回所有受支持的小程序模板指令前缀。 */
4
3
  export declare function getSupportedMiniProgramDirectivePrefixes(): readonly string[];
5
4
  /** 获取平台模板指令前缀,兼容未指定平台时的微信默认值。 */
6
- export declare function getMiniProgramDirectivePrefix(platform?: MpPlatform): string;
7
- //#endregion
5
+ export declare function getMiniProgramDirectivePrefix(platform?: MpPlatform): string;
@@ -1,4 +1,4 @@
1
- //#region src/platforms/runtime/template.ts
1
+ // src/platforms/runtime/template.ts
2
2
  const MINI_PROGRAM_DIRECTIVE_PREFIXES = Object.freeze({
3
3
  weapp: "wx",
4
4
  alipay: "a",
@@ -18,5 +18,4 @@ function getMiniProgramDirectivePrefix(platform) {
18
18
  if (!prefix) throw new Error(`不支持的小程序平台 "${platform}"。`);
19
19
  return prefix;
20
20
  }
21
- //#endregion
22
21
  export { MINI_PROGRAM_DIRECTIVE_PREFIXES, getMiniProgramDirectivePrefix, getSupportedMiniProgramDirectivePrefixes };
@@ -1,4 +1,3 @@
1
- //#region src/platforms/types.d.ts
2
1
  export type MpPlatform = 'weapp' | 'alipay' | 'tt' | 'swan' | 'jd' | 'xhs';
3
2
  export type MiniProgramTemplatePreset = 'wechat' | 'alipay' | 'tt' | 'swan';
4
3
  export type MiniProgramPlatformFamily = 'wechat' | 'alipay' | 'tt' | 'swan';
@@ -209,5 +208,4 @@ export interface MiniProgramPlatformDescriptor {
209
208
  pageIdentityRules: readonly MiniProgramPageIdentityRule[];
210
209
  capabilities: MiniProgramRuntimeCapabilities;
211
210
  };
212
- }
213
- //#endregion
211
+ }
@@ -0,0 +1,19 @@
1
+ export interface RichTextSourceNode {
2
+ type?: string;
3
+ name?: string;
4
+ attrs?: Record<string, unknown>;
5
+ children?: RichTextSourceNode[];
6
+ text?: string;
7
+ }
8
+ export type SafeRichTextNode = {
9
+ type: 'text';
10
+ text: string;
11
+ } | {
12
+ type: 'element';
13
+ name: string;
14
+ attrs: Record<string, string>;
15
+ children: SafeRichTextNode[];
16
+ };
17
+ export declare function sanitizeRichTextStyle(value: unknown): string;
18
+ export declare function sanitizeRichTextAttributes(value: unknown, tagName: string): Record<string, string>;
19
+ export declare function normalizeRichTextNodes(value: unknown): SafeRichTextNode[];
@@ -0,0 +1,226 @@
1
+ import { parseDocument } from "htmlparser2";
2
+ // src/rich-text.ts
3
+ const ALLOWED_TAGS = /* @__PURE__ */ new Set([
4
+ "a",
5
+ "abbr",
6
+ "address",
7
+ "article",
8
+ "aside",
9
+ "b",
10
+ "bdi",
11
+ "bdo",
12
+ "big",
13
+ "blockquote",
14
+ "br",
15
+ "caption",
16
+ "center",
17
+ "cite",
18
+ "code",
19
+ "col",
20
+ "colgroup",
21
+ "dd",
22
+ "del",
23
+ "div",
24
+ "dl",
25
+ "dt",
26
+ "em",
27
+ "fieldset",
28
+ "font",
29
+ "h1",
30
+ "h2",
31
+ "h3",
32
+ "h4",
33
+ "h5",
34
+ "h6",
35
+ "header",
36
+ "hr",
37
+ "i",
38
+ "img",
39
+ "ins",
40
+ "label",
41
+ "legend",
42
+ "li",
43
+ "mark",
44
+ "ol",
45
+ "p",
46
+ "pre",
47
+ "q",
48
+ "rt",
49
+ "ruby",
50
+ "s",
51
+ "section",
52
+ "small",
53
+ "span",
54
+ "strong",
55
+ "sub",
56
+ "sup",
57
+ "table",
58
+ "tbody",
59
+ "td",
60
+ "tfoot",
61
+ "th",
62
+ "thead",
63
+ "tr",
64
+ "tt",
65
+ "u",
66
+ "ul"
67
+ ]);
68
+ const ALLOWED_ATTRIBUTES = /* @__PURE__ */ new Set([
69
+ "abbr",
70
+ "align",
71
+ "alt",
72
+ "axis",
73
+ "bgcolor",
74
+ "border",
75
+ "cellpadding",
76
+ "cellspacing",
77
+ "class",
78
+ "colspan",
79
+ "dir",
80
+ "height",
81
+ "href",
82
+ "id",
83
+ "lang",
84
+ "rowspan",
85
+ "scope",
86
+ "span",
87
+ "start",
88
+ "style",
89
+ "summary",
90
+ "target",
91
+ "title",
92
+ "type",
93
+ "valign",
94
+ "width"
95
+ ]);
96
+ const URL_ATTRIBUTES = /* @__PURE__ */ new Set(["href", "src"]);
97
+ const ALLOWED_STYLE_PROPERTIES = /* @__PURE__ */ new Set([
98
+ "background",
99
+ "background-color",
100
+ "border",
101
+ "border-bottom",
102
+ "border-color",
103
+ "border-left",
104
+ "border-radius",
105
+ "border-right",
106
+ "border-style",
107
+ "border-top",
108
+ "border-width",
109
+ "color",
110
+ "display",
111
+ "font-family",
112
+ "font-size",
113
+ "font-style",
114
+ "font-weight",
115
+ "height",
116
+ "letter-spacing",
117
+ "line-height",
118
+ "margin",
119
+ "margin-bottom",
120
+ "margin-left",
121
+ "margin-right",
122
+ "margin-top",
123
+ "max-height",
124
+ "max-width",
125
+ "min-height",
126
+ "min-width",
127
+ "opacity",
128
+ "overflow",
129
+ "padding",
130
+ "padding-bottom",
131
+ "padding-left",
132
+ "padding-right",
133
+ "padding-top",
134
+ "text-align",
135
+ "text-decoration",
136
+ "text-indent",
137
+ "text-overflow",
138
+ "text-transform",
139
+ "vertical-align",
140
+ "white-space",
141
+ "width",
142
+ "word-break",
143
+ "word-wrap"
144
+ ]);
145
+ function isRecord(value) {
146
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
147
+ }
148
+ function isSafeUrl(value, attribute) {
149
+ const normalized = Array.from(value).filter((character) => character.charCodeAt(0) > 32).join("").toLowerCase();
150
+ if (!normalized || normalized.startsWith("#") || normalized.startsWith("/") || normalized.startsWith("./") || normalized.startsWith("../")) return true;
151
+ if (/^(?:https?:|mailto:|tel:)/.test(normalized)) return true;
152
+ return attribute === "src" && /^data:image\/(?:gif|jpe?g|png|webp);base64,/.test(normalized);
153
+ }
154
+ function isSafeStyleValue(value) {
155
+ const normalized = value.toLowerCase().replace(/\s+/g, "");
156
+ return !normalized.includes("url(") && !normalized.includes("expression(") && !normalized.includes("javascript:") && !normalized.includes("behavior:") && !normalized.includes("-moz-binding");
157
+ }
158
+ function sanitizeRichTextStyle(value) {
159
+ const source = isRecord(value) ? Object.entries(value).map(([property, propertyValue]) => `${property}:${String(propertyValue)}`).join(";") : String(value ?? "");
160
+ const declarations = [];
161
+ for (const declaration of source.split(";")) {
162
+ const separator = declaration.indexOf(":");
163
+ if (separator <= 0) continue;
164
+ const property = declaration.slice(0, separator).trim().toLowerCase();
165
+ const propertyValue = declaration.slice(separator + 1).trim();
166
+ if (ALLOWED_STYLE_PROPERTIES.has(property) && propertyValue && isSafeStyleValue(propertyValue)) declarations.push(`${property}: ${propertyValue}`);
167
+ }
168
+ return declarations.join("; ");
169
+ }
170
+ function sanitizeRichTextAttributes(value, tagName) {
171
+ if (!isRecord(value)) return {};
172
+ const attributes = {};
173
+ for (const [rawName, rawValue] of Object.entries(value)) {
174
+ const name = rawName.trim().toLowerCase();
175
+ if (name.startsWith("on") || name === "srcdoc") continue;
176
+ if (!ALLOWED_ATTRIBUTES.has(name) && name !== "src" && !name.startsWith("aria-") && !name.startsWith("data-")) continue;
177
+ if (name === "src" && tagName !== "img") continue;
178
+ const serialized = name === "style" ? sanitizeRichTextStyle(rawValue) : String(rawValue ?? "");
179
+ if (!serialized || URL_ATTRIBUTES.has(name) && !isSafeUrl(serialized, name)) continue;
180
+ attributes[name] = serialized;
181
+ }
182
+ if (tagName === "a") attributes.rel = "noopener noreferrer";
183
+ return attributes;
184
+ }
185
+ function convertSourceNode(value) {
186
+ if (!isRecord(value)) return [];
187
+ if (value.type === "text" || !value.name && typeof value.text === "string") return [{
188
+ type: "text",
189
+ text: String(value.text ?? "")
190
+ }];
191
+ const children = Array.isArray(value.children) ? value.children.flatMap(convertSourceNode) : [];
192
+ const name = String(value.name ?? "").toLowerCase();
193
+ if (!ALLOWED_TAGS.has(name)) return children;
194
+ return [{
195
+ type: "element",
196
+ name,
197
+ attrs: sanitizeRichTextAttributes(value.attrs, name),
198
+ children
199
+ }];
200
+ }
201
+ function convertParsedNode(node) {
202
+ if (node.type === "text") return [{
203
+ type: "text",
204
+ text: node.data
205
+ }];
206
+ if (node.type !== "tag") return [];
207
+ const element = node;
208
+ const children = element.children.flatMap(convertParsedNode);
209
+ const name = element.name.toLowerCase();
210
+ if (!ALLOWED_TAGS.has(name)) return children;
211
+ return [{
212
+ type: "element",
213
+ name,
214
+ attrs: sanitizeRichTextAttributes(element.attribs, name),
215
+ children
216
+ }];
217
+ }
218
+ function normalizeRichTextNodes(value) {
219
+ if (typeof value === "string") return parseDocument(value, {
220
+ decodeEntities: true,
221
+ lowerCaseAttributeNames: true,
222
+ lowerCaseTags: true
223
+ }).children.flatMap(convertParsedNode);
224
+ return (Array.isArray(value) ? value : [value]).flatMap(convertSourceNode);
225
+ }
226
+ export { normalizeRichTextNodes, sanitizeRichTextAttributes, sanitizeRichTextStyle };
@@ -1,4 +1,3 @@
1
- //#region src/runtimeProviders.d.ts
2
1
  export type RuntimeProviderBackend = 'miniprogram' | 'web';
3
2
  export type RuntimeProviderCompilation = 'native' | 'vue' | 'web';
4
3
  export type RuntimeProviderModuleKind = 'runtime' | 'reactivity' | 'template';
@@ -40,5 +39,4 @@ export interface RuntimeProviderDescriptorContract {
40
39
  capabilities: Readonly<RuntimeProviderCapabilities>;
41
40
  hmr: Readonly<RuntimeProviderHmrDescriptor>;
42
41
  contractVersion: number;
43
- }
44
- //#endregion
42
+ }
package/dist/wxml.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- //#region src/wxml.d.ts
2
1
  /**
3
2
  * @description 按 exparser 与 glass-easel 的共同规则序列化 WXML 静态文本。
4
3
  */
@@ -6,5 +5,4 @@ export declare function escapeWxmlText(value: string): string;
6
5
  /**
7
6
  * @description 按 exparser 与 glass-easel 的共同规则序列化双引号 WXML 属性值。
8
7
  */
9
- export declare function escapeWxmlAttribute(value: string): string;
10
- //#endregion
8
+ export declare function escapeWxmlAttribute(value: string): string;
package/dist/wxml.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/wxml.ts
1
+ // src/wxml.ts
2
2
  const WXML_TEXT_ESCAPE_RE = /[&<>]/g;
3
3
  const WXML_ATTRIBUTE_ESCAPE_RE = /[&"<]/g;
4
4
  const WXML_TEXT_ESCAPE_MAP = {
@@ -22,5 +22,4 @@ function escapeWxmlText(value) {
22
22
  function escapeWxmlAttribute(value) {
23
23
  return value.replace(WXML_ATTRIBUTE_ESCAPE_RE, (char) => WXML_ATTRIBUTE_ESCAPE_MAP[char] ?? char);
24
24
  }
25
- //#endregion
26
25
  export { escapeWxmlAttribute, escapeWxmlText };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-core/shared",
3
3
  "type": "module",
4
- "version": "3.2.8",
4
+ "version": "3.4.0",
5
5
  "description": "Shared runtime-safe utilities and platform contracts for the weapp-vite ecosystem.",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -36,6 +36,10 @@
36
36
  "types": "./src/index.ts",
37
37
  "default": "./src/index.ts"
38
38
  },
39
+ "./rich-text": {
40
+ "types": "./src/rich-text.ts",
41
+ "default": "./src/rich-text.ts"
42
+ },
39
43
  "./node": {
40
44
  "types": "./src/node.ts",
41
45
  "default": "./src/node.ts"
@@ -62,6 +66,10 @@
62
66
  "types": "./dist/index.d.ts",
63
67
  "import": "./dist/index.js"
64
68
  },
69
+ "./rich-text": {
70
+ "types": "./dist/rich-text.d.ts",
71
+ "import": "./dist/rich-text.js"
72
+ },
65
73
  "./node": {
66
74
  "types": "./dist/node.d.ts",
67
75
  "import": "./dist/node.js"
@@ -86,7 +94,13 @@
86
94
  "dist"
87
95
  ],
88
96
  "engines": {
89
- "node": "^20.19.0 || >=22.12.0"
97
+ "node": "^22.23.4 || ^24.22.1 || >=26.12.1"
98
+ },
99
+ "dependencies": {
100
+ "@types/set-value": "^4.0.3",
101
+ "domhandler": "^6.0.1",
102
+ "get-value": "^4.1.0",
103
+ "htmlparser2": "^12.0.0"
90
104
  },
91
105
  "publishConfig": {
92
106
  "access": "public",
@@ -1,75 +0,0 @@
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 };