@spcsn/taro-runtime 0.1.1 → 0.1.2

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 (67) hide show
  1. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/assertClassBrand.js +7 -0
  2. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/checkPrivateRedeclaration.js +6 -0
  3. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldGet2.js +7 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldInitSpec.js +7 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateFieldSet2.js +7 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/classPrivateMethodInitSpec.js +7 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/defineProperty.js +12 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/objectSpread2.js +25 -0
  9. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/toPrimitive.js +14 -0
  10. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/toPropertyKey.js +9 -0
  11. package/dist/_virtual/_@oxc-project_runtime@0.130.0/helpers/typeof.js +11 -0
  12. package/dist/bom/URL.d.ts +1 -6
  13. package/dist/bom/URL.js +36 -26
  14. package/dist/bom/URL.js.map +1 -1
  15. package/dist/bom/URLSearchParams.js +18 -14
  16. package/dist/bom/URLSearchParams.js.map +1 -1
  17. package/dist/bom/document.js +3 -2
  18. package/dist/bom/document.js.map +1 -1
  19. package/dist/bom/history.d.ts +1 -5
  20. package/dist/bom/history.js +52 -38
  21. package/dist/bom/history.js.map +1 -1
  22. package/dist/bom/location.d.ts +1 -11
  23. package/dist/bom/location.js +101 -90
  24. package/dist/bom/location.js.map +1 -1
  25. package/dist/bom/window.js +1 -1
  26. package/dist/bom/window.js.map +1 -1
  27. package/dist/dom/anchor-element.js +16 -8
  28. package/dist/dom/anchor-element.js.map +1 -1
  29. package/dist/dom/class-list.js.map +1 -1
  30. package/dist/dom/document.js.map +1 -1
  31. package/dist/dom/element.js +2 -1
  32. package/dist/dom/element.js.map +1 -1
  33. package/dist/dom/event-target.js +2 -4
  34. package/dist/dom/event-target.js.map +1 -1
  35. package/dist/dom/event.js +18 -17
  36. package/dist/dom/event.js.map +1 -1
  37. package/dist/dom/form.js +2 -1
  38. package/dist/dom/form.js.map +1 -1
  39. package/dist/dom/node.js +9 -6
  40. package/dist/dom/node.js.map +1 -1
  41. package/dist/dom/root.js +2 -4
  42. package/dist/dom/root.js.map +1 -1
  43. package/dist/dom/text.js.map +1 -1
  44. package/dist/dom/transfer.js.map +1 -1
  45. package/dist/dom/tree.js +1 -1
  46. package/dist/dom/tree.js.map +1 -1
  47. package/dist/dom-external/mutation-observer/implements.js +1 -1
  48. package/dist/dom-external/mutation-observer/implements.js.map +1 -1
  49. package/dist/dsl/common.js +21 -18
  50. package/dist/dsl/common.js.map +1 -1
  51. package/dist/hydrate.js +10 -7
  52. package/dist/hydrate.js.map +1 -1
  53. package/dist/index.cjs.js +392 -256
  54. package/dist/index.cjs.js.map +1 -1
  55. package/dist/next-tick.js +6 -4
  56. package/dist/next-tick.js.map +1 -1
  57. package/dist/perf.d.ts +1 -1
  58. package/dist/perf.js +10 -6
  59. package/dist/perf.js.map +1 -1
  60. package/dist/runtime.esm.js +392 -256
  61. package/dist/runtime.esm.js.map +1 -1
  62. package/dist/utils/cache.js.map +1 -1
  63. package/dist/utils/index.js +9 -6
  64. package/dist/utils/index.js.map +1 -1
  65. package/dist/utils/router.js +2 -1
  66. package/dist/utils/router.js.map +1 -1
  67. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","names":[],"sources":["../../src/utils/cache.ts"],"sourcesContent":["/**\n * 一个小型缓存池,用于在切换页面时,存储一些上下文信息\n */\n\nexport class RuntimeCache<T> {\n name: string;\n cache = new Map<string, T>();\n\n constructor(name: string) {\n this.name = name;\n }\n\n has(identifier: string) {\n return this.cache.has(identifier);\n }\n\n set(identifier: string, ctx: T) {\n if (identifier && ctx) {\n this.cache.set(identifier, ctx);\n }\n }\n\n get(identifier: string): T | undefined {\n if (this.has(identifier)) return this.cache.get(identifier);\n }\n\n delete(identifier: string) {\n this.cache.delete(identifier);\n }\n}\n"],"mappings":";;;;AAIA,IAAa,eAAb,MAA6B;CAI3B,YAAY,MAAc;+BAFlB,IAAI,IAAe;EAGzB,KAAK,OAAO;CACd;CAEA,IAAI,YAAoB;EACtB,OAAO,KAAK,MAAM,IAAI,UAAU;CAClC;CAEA,IAAI,YAAoB,KAAQ;EAC9B,IAAI,cAAc,KAChB,KAAK,MAAM,IAAI,YAAY,GAAG;CAElC;CAEA,IAAI,YAAmC;EACrC,IAAI,KAAK,IAAI,UAAU,GAAG,OAAO,KAAK,MAAM,IAAI,UAAU;CAC5D;CAEA,OAAO,YAAoB;EACzB,KAAK,MAAM,OAAO,UAAU;CAC9B;AACF"}
1
+ {"version":3,"file":"cache.js","names":[],"sources":["../../src/utils/cache.ts"],"sourcesContent":["/**\n * 一个小型缓存池,用于在切换页面时,存储一些上下文信息\n */\n\nexport class RuntimeCache<T> {\n name: string;\n cache = new Map<string, T>();\n\n constructor(name: string) {\n this.name = name;\n }\n\n has(identifier: string) {\n return this.cache.has(identifier);\n }\n\n set(identifier: string, ctx: T) {\n if (identifier && ctx) {\n this.cache.set(identifier, ctx);\n }\n }\n\n get(identifier: string): T | undefined {\n if (this.has(identifier)) return this.cache.get(identifier);\n }\n\n delete(identifier: string) {\n this.cache.delete(identifier);\n }\n}\n"],"mappings":";;;;AAIA,IAAa,eAAb,MAA6B;CAI3B,YAAY,MAAc;EAF1B,KAAA,wBAAQ,IAAI,IAAe;EAGzB,KAAK,OAAO;CACd;CAEA,IAAI,YAAoB;EACtB,OAAO,KAAK,MAAM,IAAI,UAAU;CAClC;CAEA,IAAI,YAAoB,KAAQ;EAC9B,IAAI,cAAc,KAChB,KAAK,MAAM,IAAI,YAAY,GAAG;CAElC;CAEA,IAAI,YAAmC;EACrC,IAAI,KAAK,IAAI,UAAU,GAAG,OAAO,KAAK,MAAM,IAAI,UAAU;CAC5D;CAEA,OAAO,YAAoB;EACzB,KAAK,MAAM,OAAO,UAAU;CAC9B;AACF"}
@@ -1,4 +1,5 @@
1
1
  import { CLASS, COMMENT, STYLE } from "../constants/index.js";
2
+ import { _objectSpread2 } from "../_virtual/_@oxc-project_runtime@0.130.0/helpers/objectSpread2.js";
2
3
  import "./lodash.js";
3
4
  import "./router.js";
4
5
  import { Shortcuts, getComponentsAlias, internalComponents, isFunction } from "@spcsn/taro-shared";
@@ -47,8 +48,11 @@ function isHasExtractProp(el) {
47
48
  * @param type 事件类型
48
49
  */
49
50
  function isParentBound(node, type) {
50
- while (node = node?.parentElement || null) if (!node || node.nodeName === "root" || node.nodeName === "root-portal") return false;
51
- else if (node.__handlers[type]?.length) return true;
51
+ while (node = (node === null || node === void 0 ? void 0 : node.parentElement) || null) {
52
+ var _node$__handlers$type;
53
+ if (!node || node.nodeName === "root" || node.nodeName === "root-portal") return false;
54
+ else if ((_node$__handlers$type = node.__handlers[type]) === null || _node$__handlers$type === void 0 ? void 0 : _node$__handlers$type.length) return true;
55
+ }
52
56
  return false;
53
57
  }
54
58
  function shortcutAttr(key) {
@@ -62,11 +66,10 @@ function shortcutAttr(key) {
62
66
  const customWrapperCache = /* @__PURE__ */ new Map();
63
67
  function extend(ctor, methodName, options) {
64
68
  if (isFunction(options)) options = { value: options };
65
- Object.defineProperty(ctor.prototype, methodName, {
69
+ Object.defineProperty(ctor.prototype, methodName, _objectSpread2({
66
70
  configurable: true,
67
- enumerable: true,
68
- ...options
69
- });
71
+ enumerable: true
72
+ }, options));
70
73
  }
71
74
  let componentsAlias;
72
75
  function getComponentsAlias$1() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getComponentsAlias","_getComponentsAlias"],"sources":["../../src/utils/index.ts"],"sourcesContent":["import {\n getComponentsAlias as _getComponentsAlias,\n internalComponents,\n isFunction,\n Shortcuts,\n} from '@spcsn/taro-shared';\n\nimport { CLASS, COMMENT, ID, ROOT_STR, STYLE, UID } from '../constants';\nimport { NodeType } from '../dom/node_types';\n\nimport type { TaroElement } from '../dom/element';\nimport type { TaroNode } from '../dom/node';\nimport type { TaroText } from '../dom/text';\nimport type { TFunc } from '../interface';\n\nexport const incrementId = () => {\n const chatCodes: number[] = [];\n // A-Z\n for (let i = 65; i <= 90; i++) {\n chatCodes.push(i);\n }\n // a-z\n for (let i = 97; i <= 122; i++) {\n chatCodes.push(i);\n }\n const chatCodesLen = chatCodes.length - 1;\n const list = [0, 0];\n return () => {\n const target = list.map((item) => chatCodes[item]);\n const res = String.fromCharCode(...target);\n\n let tailIdx = list.length - 1;\n\n list[tailIdx]++;\n\n while (list[tailIdx] > chatCodesLen) {\n list[tailIdx] = 0;\n tailIdx = tailIdx - 1;\n if (tailIdx < 0) {\n list.push(0);\n break;\n }\n list[tailIdx]++;\n }\n\n return res;\n };\n};\n\nexport function isElement(node: TaroNode): node is TaroElement {\n return node.nodeType === NodeType.ELEMENT_NODE;\n}\n\nexport function isText(node: TaroNode): node is TaroText {\n return node.nodeType === NodeType.TEXT_NODE;\n}\n\nexport function isComment(node: TaroNode): boolean {\n return node.nodeName === COMMENT;\n}\n\nexport function isHasExtractProp(el: TaroElement): boolean {\n const res = Object.keys(el.props).find((prop) => {\n return !(/^(class|style|id)$/.test(prop) || prop.startsWith('data-'));\n });\n return Boolean(res);\n}\n\n/**\n * 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件\n * @param node 当前组件\n * @param type 事件类型\n */\nexport function isParentBound(node: TaroElement | null, type: string): boolean {\n while ((node = node?.parentElement || null)) {\n if (!node || node.nodeName === ROOT_STR || node.nodeName === 'root-portal') {\n return false;\n } else if (node.__handlers[type]?.length) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function shortcutAttr(key: string): string {\n switch (key) {\n case STYLE:\n return Shortcuts.Style;\n case ID:\n return UID;\n case CLASS:\n return Shortcuts.Class;\n default:\n return key;\n }\n}\n\nexport const customWrapperCache = new Map<string, Record<string, any>>();\n\ninterface Ctor {\n new (...args: any[]): any;\n}\n\nexport function extend(ctor: Ctor, methodName: string, options: TFunc | Record<string, any>) {\n if (isFunction(options)) {\n options = {\n value: options,\n };\n }\n Object.defineProperty(ctor.prototype, methodName, {\n configurable: true,\n enumerable: true,\n ...options,\n });\n}\n\nlet componentsAlias;\nexport function getComponentsAlias() {\n if (!componentsAlias) {\n componentsAlias = _getComponentsAlias(internalComponents);\n }\n return componentsAlias;\n}\n\nexport function convertNumber2PX(value: number) {\n return value + 'px';\n}\n\nexport * from './lodash';\nexport * from './router';\n"],"mappings":";;;;;AAeA,MAAa,oBAAoB;CAC/B,MAAM,YAAsB,CAAC;CAE7B,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,KACxB,UAAU,KAAK,CAAC;CAGlB,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,KACzB,UAAU,KAAK,CAAC;CAElB,MAAM,eAAe,UAAU,SAAS;CACxC,MAAM,OAAO,CAAC,GAAG,CAAC;CAClB,aAAa;EACX,MAAM,SAAS,KAAK,KAAK,SAAS,UAAU,KAAK;EACjD,MAAM,MAAM,OAAO,aAAa,GAAG,MAAM;EAEzC,IAAI,UAAU,KAAK,SAAS;EAE5B,KAAK;EAEL,OAAO,KAAK,WAAW,cAAc;GACnC,KAAK,WAAW;GAChB,UAAU,UAAU;GACpB,IAAI,UAAU,GAAG;IACf,KAAK,KAAK,CAAC;IACX;GACF;GACA,KAAK;EACP;EAEA,OAAO;CACT;AACF;AAEA,SAAgB,UAAU,MAAqC;CAC7D,OAAO,KAAK,aAAA;AACd;AAEA,SAAgB,OAAO,MAAkC;CACvD,OAAO,KAAK,aAAA;AACd;AAEA,SAAgB,UAAU,MAAyB;CACjD,OAAO,KAAK,aAAa;AAC3B;AAEA,SAAgB,iBAAiB,IAA0B;CACzD,MAAM,MAAM,OAAO,KAAK,GAAG,KAAK,EAAE,MAAM,SAAS;EAC/C,OAAO,EAAE,qBAAqB,KAAK,IAAI,KAAK,KAAK,WAAW,OAAO;CACrE,CAAC;CACD,OAAO,QAAQ,GAAG;AACpB;;;;;;AAOA,SAAgB,cAAc,MAA0B,MAAuB;CAC7E,OAAQ,OAAO,MAAM,iBAAiB,MACpC,IAAI,CAAC,QAAQ,KAAK,aAAA,UAAyB,KAAK,aAAa,eAC3D,OAAO;MACF,IAAI,KAAK,WAAW,OAAO,QAChC,OAAO;CAIX,OAAO;AACT;AAEA,SAAgB,aAAa,KAAqB;CAChD,QAAQ,KAAR;EACE,KAAK,OACH,OAAO,UAAU;EACnB,KAAA,MACE,OAAA;EACF,KAAK,OACH,OAAO,UAAU;EACnB,SACE,OAAO;CACX;AACF;AAEA,MAAa,qCAAqB,IAAI,IAAiC;AAMvE,SAAgB,OAAO,MAAY,YAAoB,SAAsC;CAC3F,IAAI,WAAW,OAAO,GACpB,UAAU,EACR,OAAO,QACT;CAEF,OAAO,eAAe,KAAK,WAAW,YAAY;EAChD,cAAc;EACd,YAAY;EACZ,GAAG;CACL,CAAC;AACH;AAEA,IAAI;AACJ,SAAgBA,uBAAqB;CACnC,IAAI,CAAC,iBACH,kBAAkBC,mBAAoB,kBAAkB;CAE1D,OAAO;AACT;AAEA,SAAgB,iBAAiB,OAAe;CAC9C,OAAO,QAAQ;AACjB"}
1
+ {"version":3,"file":"index.js","names":["getComponentsAlias","_getComponentsAlias"],"sources":["../../src/utils/index.ts"],"sourcesContent":["import {\n getComponentsAlias as _getComponentsAlias,\n internalComponents,\n isFunction,\n Shortcuts,\n} from '@spcsn/taro-shared';\n\nimport { CLASS, COMMENT, ID, ROOT_STR, STYLE, UID } from '../constants';\nimport { NodeType } from '../dom/node_types';\n\nimport type { TaroElement } from '../dom/element';\nimport type { TaroNode } from '../dom/node';\nimport type { TaroText } from '../dom/text';\nimport type { TFunc } from '../interface';\n\nexport const incrementId = () => {\n const chatCodes: number[] = [];\n // A-Z\n for (let i = 65; i <= 90; i++) {\n chatCodes.push(i);\n }\n // a-z\n for (let i = 97; i <= 122; i++) {\n chatCodes.push(i);\n }\n const chatCodesLen = chatCodes.length - 1;\n const list = [0, 0];\n return () => {\n const target = list.map((item) => chatCodes[item]);\n const res = String.fromCharCode(...target);\n\n let tailIdx = list.length - 1;\n\n list[tailIdx]++;\n\n while (list[tailIdx] > chatCodesLen) {\n list[tailIdx] = 0;\n tailIdx = tailIdx - 1;\n if (tailIdx < 0) {\n list.push(0);\n break;\n }\n list[tailIdx]++;\n }\n\n return res;\n };\n};\n\nexport function isElement(node: TaroNode): node is TaroElement {\n return node.nodeType === NodeType.ELEMENT_NODE;\n}\n\nexport function isText(node: TaroNode): node is TaroText {\n return node.nodeType === NodeType.TEXT_NODE;\n}\n\nexport function isComment(node: TaroNode): boolean {\n return node.nodeName === COMMENT;\n}\n\nexport function isHasExtractProp(el: TaroElement): boolean {\n const res = Object.keys(el.props).find((prop) => {\n return !(/^(class|style|id)$/.test(prop) || prop.startsWith('data-'));\n });\n return Boolean(res);\n}\n\n/**\n * 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件\n * @param node 当前组件\n * @param type 事件类型\n */\nexport function isParentBound(node: TaroElement | null, type: string): boolean {\n while ((node = node?.parentElement || null)) {\n if (!node || node.nodeName === ROOT_STR || node.nodeName === 'root-portal') {\n return false;\n } else if (node.__handlers[type]?.length) {\n return true;\n }\n }\n\n return false;\n}\n\nexport function shortcutAttr(key: string): string {\n switch (key) {\n case STYLE:\n return Shortcuts.Style;\n case ID:\n return UID;\n case CLASS:\n return Shortcuts.Class;\n default:\n return key;\n }\n}\n\nexport const customWrapperCache = new Map<string, Record<string, any>>();\n\ninterface Ctor {\n new (...args: any[]): any;\n}\n\nexport function extend(ctor: Ctor, methodName: string, options: TFunc | Record<string, any>) {\n if (isFunction(options)) {\n options = {\n value: options,\n };\n }\n Object.defineProperty(ctor.prototype, methodName, {\n configurable: true,\n enumerable: true,\n ...options,\n });\n}\n\nlet componentsAlias;\nexport function getComponentsAlias() {\n if (!componentsAlias) {\n componentsAlias = _getComponentsAlias(internalComponents);\n }\n return componentsAlias;\n}\n\nexport function convertNumber2PX(value: number) {\n return value + 'px';\n}\n\nexport * from './lodash';\nexport * from './router';\n"],"mappings":";;;;;;AAeA,MAAa,oBAAoB;CAC/B,MAAM,YAAsB,CAAC;CAE7B,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,KACxB,UAAU,KAAK,CAAC;CAGlB,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,KACzB,UAAU,KAAK,CAAC;CAElB,MAAM,eAAe,UAAU,SAAS;CACxC,MAAM,OAAO,CAAC,GAAG,CAAC;CAClB,aAAa;EACX,MAAM,SAAS,KAAK,KAAK,SAAS,UAAU,KAAK;EACjD,MAAM,MAAM,OAAO,aAAa,GAAG,MAAM;EAEzC,IAAI,UAAU,KAAK,SAAS;EAE5B,KAAK;EAEL,OAAO,KAAK,WAAW,cAAc;GACnC,KAAK,WAAW;GAChB,UAAU,UAAU;GACpB,IAAI,UAAU,GAAG;IACf,KAAK,KAAK,CAAC;IACX;GACF;GACA,KAAK;EACP;EAEA,OAAO;CACT;AACF;AAEA,SAAgB,UAAU,MAAqC;CAC7D,OAAO,KAAK,aAAA;AACd;AAEA,SAAgB,OAAO,MAAkC;CACvD,OAAO,KAAK,aAAA;AACd;AAEA,SAAgB,UAAU,MAAyB;CACjD,OAAO,KAAK,aAAa;AAC3B;AAEA,SAAgB,iBAAiB,IAA0B;CACzD,MAAM,MAAM,OAAO,KAAK,GAAG,KAAK,EAAE,MAAM,SAAS;EAC/C,OAAO,EAAE,qBAAqB,KAAK,IAAI,KAAK,KAAK,WAAW,OAAO;CACrE,CAAC;CACD,OAAO,QAAQ,GAAG;AACpB;;;;;;AAOA,SAAgB,cAAc,MAA0B,MAAuB;CAC7E,OAAQ,QAAA,SAAA,QAAA,SAAA,KAAA,IAAA,KAAA,IAAO,KAAM,kBAAiB,MAAO;;EAC3C,IAAI,CAAC,QAAQ,KAAK,aAAA,UAAyB,KAAK,aAAa,eAC3D,OAAO;OACF,KAAA,wBAAI,KAAK,WAAW,WAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAO,QAChC,OAAO;CAEX;CAEA,OAAO;AACT;AAEA,SAAgB,aAAa,KAAqB;CAChD,QAAQ,KAAR;EACE,KAAK,OACH,OAAO,UAAU;EACnB,KAAA,MACE,OAAA;EACF,KAAK,OACH,OAAO,UAAU;EACnB,SACE,OAAO;CACX;AACF;AAEA,MAAa,qCAAqB,IAAI,IAAiC;AAMvE,SAAgB,OAAO,MAAY,YAAoB,SAAsC;CAC3F,IAAI,WAAW,OAAO,GACpB,UAAU,EACR,OAAO,QACT;CAEF,OAAO,eAAe,KAAK,WAAW,YAAA,eAAA;EACpC,cAAc;EACd,YAAY;IACT,OACL,CAAC;AACH;AAEA,IAAI;AACJ,SAAgBA,uBAAqB;CACnC,IAAI,CAAC,iBACH,kBAAkBC,mBAAoB,kBAAkB;CAE1D,OAAO;AACT;AAEA,SAAgB,iBAAiB,OAAe;CAC9C,OAAO,QAAQ;AACjB"}
@@ -6,8 +6,9 @@ const stripBasename = (path = "", prefix = "") => hasBasename(path, prefix) ? pa
6
6
  const stripTrailing = (str = "") => str.replace(/[?#][\s\S]*$/, "");
7
7
  const stripSuffix = (path = "", suffix = "") => path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;
8
8
  const getHomePage = (path = "", basename = "", customRoutes = {}, entryPagePath = "") => {
9
+ var _Object$entries$find;
9
10
  const routePath = addLeadingSlash(stripBasename(path, basename));
10
- const alias = Object.entries(customRoutes).find(([key]) => key === routePath)?.[1] || routePath;
11
+ const alias = ((_Object$entries$find = Object.entries(customRoutes).find(([key]) => key === routePath)) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[1]) || routePath;
11
12
  return entryPagePath || (typeof alias === "string" ? alias : alias[0]) || basename;
12
13
  };
13
14
  const getCurrentPage = (routerMode = "hash", basename = "/") => {
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","names":["location"],"sources":["../../src/utils/router.ts"],"sourcesContent":["import { taroLocationProvider as location } from '../bom/window';\n\n// export const removeLeadingSlash = (str = '') => str.replace(/^\\.?\\//, '')\n// export const removeTrailingSearch = (str = '') => str.replace(/\\?[\\s\\S]*$/, '')\nexport const addLeadingSlash = (url = '') => (url.charAt(0) === '/' ? url : '/' + url);\n\nexport const hasBasename = (path = '', prefix = '') =>\n new RegExp('^' + prefix + '(\\\\/|\\\\?|#|$)', 'i').test(path) || path === prefix;\n\nexport const stripBasename = (path = '', prefix = '') =>\n hasBasename(path, prefix) ? path.substring(prefix.length) : path;\n\nexport const stripTrailing = (str = '') => str.replace(/[?#][\\s\\S]*$/, '');\n\nexport const stripSuffix = (path = '', suffix = '') =>\n path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;\n\nexport const getHomePage = (\n path = '',\n basename = '',\n customRoutes: Record<string, string | string[]> = {},\n entryPagePath = '',\n) => {\n const routePath = addLeadingSlash(stripBasename(path, basename));\n const alias = Object.entries(customRoutes).find(([key]) => key === routePath)?.[1] || routePath;\n return entryPagePath || (typeof alias === 'string' ? alias : alias[0]) || basename;\n};\n\nexport const getCurrentPage = (routerMode = 'hash', basename = '/') => {\n const pagePath = routerMode === 'hash' ? location.hash.slice(1).split('?')[0] : location.pathname;\n return addLeadingSlash(stripBasename(pagePath, basename));\n};\n"],"mappings":";;AAIA,MAAa,mBAAmB,MAAM,OAAQ,IAAI,OAAO,CAAC,MAAM,MAAM,MAAM,MAAM;AAElF,MAAa,eAAe,OAAO,IAAI,SAAS,OAC9C,IAAI,OAAO,MAAM,SAAS,iBAAiB,GAAG,EAAE,KAAK,IAAI,KAAK,SAAS;AAEzE,MAAa,iBAAiB,OAAO,IAAI,SAAS,OAChD,YAAY,MAAM,MAAM,IAAI,KAAK,UAAU,OAAO,MAAM,IAAI;AAE9D,MAAa,iBAAiB,MAAM,OAAO,IAAI,QAAQ,gBAAgB,EAAE;AAEzE,MAAa,eAAe,OAAO,IAAI,SAAS,OAC9C,KAAK,SAAS,MAAM,IAAI,KAAK,UAAU,GAAG,KAAK,SAAS,OAAO,MAAM,IAAI;AAE3E,MAAa,eACX,OAAO,IACP,WAAW,IACX,eAAkD,CAAC,GACnD,gBAAgB,OACb;CACH,MAAM,YAAY,gBAAgB,cAAc,MAAM,QAAQ,CAAC;CAC/D,MAAM,QAAQ,OAAO,QAAQ,YAAY,EAAE,MAAM,CAAC,SAAS,QAAQ,SAAS,IAAI,MAAM;CACtF,OAAO,kBAAkB,OAAO,UAAU,WAAW,QAAQ,MAAM,OAAO;AAC5E;AAEA,MAAa,kBAAkB,aAAa,QAAQ,WAAW,QAAQ;CAErE,OAAO,gBAAgB,cADN,eAAe,SAASA,qBAAS,KAAK,MAAM,CAAC,EAAE,MAAM,GAAG,EAAE,KAAKA,qBAAS,UAC1C,QAAQ,CAAC;AAC1D"}
1
+ {"version":3,"file":"router.js","names":["location"],"sources":["../../src/utils/router.ts"],"sourcesContent":["import { taroLocationProvider as location } from '../bom/window';\n\n// export const removeLeadingSlash = (str = '') => str.replace(/^\\.?\\//, '')\n// export const removeTrailingSearch = (str = '') => str.replace(/\\?[\\s\\S]*$/, '')\nexport const addLeadingSlash = (url = '') => (url.charAt(0) === '/' ? url : '/' + url);\n\nexport const hasBasename = (path = '', prefix = '') =>\n new RegExp('^' + prefix + '(\\\\/|\\\\?|#|$)', 'i').test(path) || path === prefix;\n\nexport const stripBasename = (path = '', prefix = '') =>\n hasBasename(path, prefix) ? path.substring(prefix.length) : path;\n\nexport const stripTrailing = (str = '') => str.replace(/[?#][\\s\\S]*$/, '');\n\nexport const stripSuffix = (path = '', suffix = '') =>\n path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;\n\nexport const getHomePage = (\n path = '',\n basename = '',\n customRoutes: Record<string, string | string[]> = {},\n entryPagePath = '',\n) => {\n const routePath = addLeadingSlash(stripBasename(path, basename));\n const alias = Object.entries(customRoutes).find(([key]) => key === routePath)?.[1] || routePath;\n return entryPagePath || (typeof alias === 'string' ? alias : alias[0]) || basename;\n};\n\nexport const getCurrentPage = (routerMode = 'hash', basename = '/') => {\n const pagePath = routerMode === 'hash' ? location.hash.slice(1).split('?')[0] : location.pathname;\n return addLeadingSlash(stripBasename(pagePath, basename));\n};\n"],"mappings":";;AAIA,MAAa,mBAAmB,MAAM,OAAQ,IAAI,OAAO,CAAC,MAAM,MAAM,MAAM,MAAM;AAElF,MAAa,eAAe,OAAO,IAAI,SAAS,OAC9C,IAAI,OAAO,MAAM,SAAS,iBAAiB,GAAG,EAAE,KAAK,IAAI,KAAK,SAAS;AAEzE,MAAa,iBAAiB,OAAO,IAAI,SAAS,OAChD,YAAY,MAAM,MAAM,IAAI,KAAK,UAAU,OAAO,MAAM,IAAI;AAE9D,MAAa,iBAAiB,MAAM,OAAO,IAAI,QAAQ,gBAAgB,EAAE;AAEzE,MAAa,eAAe,OAAO,IAAI,SAAS,OAC9C,KAAK,SAAS,MAAM,IAAI,KAAK,UAAU,GAAG,KAAK,SAAS,OAAO,MAAM,IAAI;AAE3E,MAAa,eACX,OAAO,IACP,WAAW,IACX,eAAkD,CAAC,GACnD,gBAAgB,OACb;;CACH,MAAM,YAAY,gBAAgB,cAAc,MAAM,QAAQ,CAAC;CAC/D,MAAM,UAAA,uBAAQ,OAAO,QAAQ,YAAY,EAAE,MAAM,CAAC,SAAS,QAAQ,SAAS,OAAA,QAAA,yBAAA,KAAA,IAAA,KAAA,IAAA,qBAAI,OAAM;CACtF,OAAO,kBAAkB,OAAO,UAAU,WAAW,QAAQ,MAAM,OAAO;AAC5E;AAEA,MAAa,kBAAkB,aAAa,QAAQ,WAAW,QAAQ;CAErE,OAAO,gBAAgB,cADN,eAAe,SAASA,qBAAS,KAAK,MAAM,CAAC,EAAE,MAAM,GAAG,EAAE,KAAKA,qBAAS,UAC1C,QAAQ,CAAC;AAC1D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spcsn/taro-runtime",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "taro runtime for mini apps.",
5
5
  "author": "O2Team",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "tslib": "^2.6.2",
27
- "@spcsn/taro-shared": "0.1.1"
27
+ "@spcsn/taro-shared": "0.1.2"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "^22.19.19",