@tarojs/runtime 3.6.22 → 3.6.23

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 (180) hide show
  1. package/LICENSE +14 -0
  2. package/dist/bom/URL.d.ts +7 -14
  3. package/dist/bom/URL.js +221 -0
  4. package/dist/bom/URL.js.map +1 -0
  5. package/dist/bom/URLSearchParams.d.ts +2 -14
  6. package/dist/bom/URLSearchParams.js +123 -0
  7. package/dist/bom/URLSearchParams.js.map +1 -0
  8. package/dist/bom/document.d.ts +2 -1
  9. package/dist/bom/document.js +39 -0
  10. package/dist/bom/document.js.map +1 -0
  11. package/dist/bom/getComputedStyle.d.ts +5 -3
  12. package/dist/bom/getComputedStyle.js +8 -0
  13. package/dist/bom/getComputedStyle.js.map +1 -0
  14. package/dist/bom/history.d.ts +11 -8
  15. package/dist/bom/history.js +121 -0
  16. package/dist/bom/history.js.map +1 -0
  17. package/dist/bom/location.d.ts +7 -4
  18. package/dist/bom/location.js +240 -0
  19. package/dist/bom/location.js.map +1 -0
  20. package/dist/bom/navigator.d.ts +2 -1
  21. package/dist/bom/navigator.js +24 -0
  22. package/dist/bom/navigator.js.map +1 -0
  23. package/dist/bom/raf.d.ts +3 -4
  24. package/dist/bom/raf.js +33 -0
  25. package/dist/bom/raf.js.map +1 -0
  26. package/dist/bom/window.d.ts +25 -4
  27. package/dist/bom/window.js +92 -0
  28. package/dist/bom/window.js.map +1 -0
  29. package/dist/constants/index.d.ts +52 -51
  30. package/dist/constants/index.js +63 -0
  31. package/dist/constants/index.js.map +1 -0
  32. package/dist/current.d.ts +5 -5
  33. package/dist/current.js +9 -0
  34. package/dist/current.js.map +1 -0
  35. package/dist/dom/anchor-element.d.ts +3 -2
  36. package/dist/dom/anchor-element.js +54 -0
  37. package/dist/dom/anchor-element.js.map +1 -0
  38. package/dist/dom/class-list.d.ts +3 -2
  39. package/dist/dom/class-list.js +92 -0
  40. package/dist/dom/class-list.js.map +1 -0
  41. package/dist/dom/document.d.ts +11 -6
  42. package/dist/dom/document.js +80 -0
  43. package/dist/dom/document.js.map +1 -0
  44. package/dist/dom/element.d.ts +8 -7
  45. package/dist/dom/element.js +318 -0
  46. package/dist/dom/element.js.map +1 -0
  47. package/dist/dom/event-source.d.ts +3 -3
  48. package/dist/dom/event-source.js +17 -0
  49. package/dist/dom/event-source.js.map +1 -0
  50. package/dist/dom/event-target.d.ts +3 -2
  51. package/dist/dom/event-target.js +78 -0
  52. package/dist/dom/event-target.js.map +1 -0
  53. package/dist/dom/event.d.ts +6 -5
  54. package/dist/dom/event.js +151 -0
  55. package/dist/dom/event.js.map +1 -0
  56. package/dist/dom/form.d.ts +4 -3
  57. package/dist/dom/form.js +38 -0
  58. package/dist/dom/form.js.map +1 -0
  59. package/dist/dom/node.d.ts +40 -9
  60. package/dist/dom/node.js +292 -0
  61. package/dist/dom/node.js.map +1 -0
  62. package/dist/dom/root.d.ts +6 -5
  63. package/dist/dom/root.js +169 -0
  64. package/dist/dom/root.js.map +1 -0
  65. package/dist/dom/style.d.ts +3 -2
  66. package/dist/dom/style.js +168 -0
  67. package/dist/dom/style.js.map +1 -0
  68. package/dist/dom/style_properties.js +186 -0
  69. package/dist/dom/style_properties.js.map +1 -0
  70. package/dist/dom/svg.d.ts +3 -2
  71. package/dist/dom/svg.js +8 -0
  72. package/dist/dom/svg.js.map +1 -0
  73. package/dist/dom/text.d.ts +4 -3
  74. package/dist/dom/text.js +41 -0
  75. package/dist/dom/text.js.map +1 -0
  76. package/dist/dom/transfer.d.ts +3 -2
  77. package/dist/dom/transfer.js +15 -0
  78. package/dist/dom/transfer.js.map +1 -0
  79. package/dist/dom/tree.d.ts +3 -3
  80. package/dist/dom/tree.js +38 -0
  81. package/dist/dom/tree.js.map +1 -0
  82. package/dist/dom-external/element.d.ts +4 -3
  83. package/dist/dom-external/element.js +29 -0
  84. package/dist/dom-external/element.js.map +1 -0
  85. package/dist/dom-external/index.js +38 -0
  86. package/dist/dom-external/index.js.map +1 -0
  87. package/dist/dom-external/inner-html/html.d.ts +3 -2
  88. package/dist/dom-external/inner-html/html.js +28 -0
  89. package/dist/dom-external/inner-html/html.js.map +1 -0
  90. package/dist/dom-external/inner-html/parser.d.ts +7 -7
  91. package/dist/dom-external/inner-html/parser.js +216 -0
  92. package/dist/dom-external/inner-html/parser.js.map +1 -0
  93. package/dist/dom-external/inner-html/scaner.d.ts +3 -3
  94. package/dist/dom-external/inner-html/scaner.js +304 -0
  95. package/dist/dom-external/inner-html/scaner.js.map +1 -0
  96. package/dist/dom-external/inner-html/style.d.ts +3 -3
  97. package/dist/dom-external/inner-html/style.js +235 -0
  98. package/dist/dom-external/inner-html/style.js.map +1 -0
  99. package/dist/dom-external/inner-html/tags.d.ts +6 -5
  100. package/dist/dom-external/inner-html/tags.js +26 -0
  101. package/dist/dom-external/inner-html/tags.js.map +1 -0
  102. package/dist/dom-external/inner-html/utils.d.ts +2 -1
  103. package/dist/dom-external/inner-html/utils.js +12 -0
  104. package/dist/dom-external/inner-html/utils.js.map +1 -0
  105. package/dist/dom-external/mutation-observer/implements.d.ts +25 -6
  106. package/dist/dom-external/mutation-observer/implements.js +108 -0
  107. package/dist/dom-external/mutation-observer/implements.js.map +1 -0
  108. package/dist/dom-external/mutation-observer/index.d.ts +5 -6
  109. package/dist/dom-external/mutation-observer/index.js +35 -0
  110. package/dist/dom-external/mutation-observer/index.js.map +1 -0
  111. package/dist/dom-external/node.d.ts +6 -5
  112. package/dist/dom-external/node.js +74 -0
  113. package/dist/dom-external/node.js.map +1 -0
  114. package/dist/dsl/common.d.ts +15 -16
  115. package/dist/dsl/common.js +332 -0
  116. package/dist/dsl/common.js.map +1 -0
  117. package/dist/emitter/emitter.d.ts +2 -2
  118. package/dist/emitter/emitter.js +7 -0
  119. package/dist/emitter/emitter.js.map +1 -0
  120. package/dist/env.d.ts +2 -2
  121. package/dist/env.js +9 -0
  122. package/dist/env.js.map +1 -0
  123. package/dist/hydrate.d.ts +5 -4
  124. package/dist/hydrate.js +84 -0
  125. package/dist/hydrate.js.map +1 -0
  126. package/dist/index-26658829.d.ts +23 -0
  127. package/dist/index.cjs.d.ts +784 -0
  128. package/dist/index.cjs.js +5129 -0
  129. package/dist/index.cjs.js.map +1 -0
  130. package/dist/index.d.ts +32 -31
  131. package/dist/index.js +33 -0
  132. package/dist/index.js.map +1 -0
  133. package/dist/{dsl/instance.d.ts → instance-0f017c6e.d.ts} +19 -18
  134. package/dist/next-tick.d.ts +3 -2
  135. package/dist/next-tick.js +47 -0
  136. package/dist/next-tick.js.map +1 -0
  137. package/dist/{dom/node_types.d.ts → node_types-9ac5b4dd.d.ts} +2 -1
  138. package/dist/{interface/options.d.ts → options-0f017c6e.d.ts} +5 -4
  139. package/dist/options.d.ts +3 -2
  140. package/dist/options.js +7 -0
  141. package/dist/options.js.map +1 -0
  142. package/dist/perf.d.ts +2 -2
  143. package/dist/perf.js +28 -0
  144. package/dist/perf.js.map +1 -0
  145. package/dist/polyfill/array.d.ts +3 -0
  146. package/dist/polyfill/array.js +56 -0
  147. package/dist/polyfill/array.js.map +1 -0
  148. package/dist/polyfill/index.d.ts +2 -0
  149. package/dist/polyfill/index.js +34 -0
  150. package/dist/polyfill/index.js.map +1 -0
  151. package/dist/polyfill/intersection-observer.d.ts +2 -0
  152. package/dist/polyfill/intersection-observer.js +599 -0
  153. package/dist/polyfill/intersection-observer.js.map +1 -0
  154. package/dist/polyfill/object.d.ts +4 -0
  155. package/dist/polyfill/object.js +102 -0
  156. package/dist/polyfill/object.js.map +1 -0
  157. package/dist/{dom-external/mutation-observer/record.d.ts → record-32b054d8.d.ts} +4 -3
  158. package/dist/runtime.esm.d.ts +91 -89
  159. package/dist/runtime.esm.js +1165 -398
  160. package/dist/runtime.esm.js.map +1 -1
  161. package/dist/utils/cache.d.ts +2 -1
  162. package/dist/utils/cache.js +27 -0
  163. package/dist/utils/cache.js.map +1 -0
  164. package/dist/utils/index.d.ts +16 -15
  165. package/dist/utils/index.js +95 -0
  166. package/dist/utils/index.js.map +1 -0
  167. package/dist/utils/lodash.d.ts +2 -0
  168. package/dist/utils/lodash.js +22 -0
  169. package/dist/utils/lodash.js.map +1 -0
  170. package/dist/utils/router.d.ts +8 -0
  171. package/dist/utils/router.js +24 -0
  172. package/dist/utils/router.js.map +1 -0
  173. package/package.json +20 -10
  174. package/dist/interface/element.d.ts +0 -4
  175. package/dist/interface/event-target.d.ts +0 -10
  176. package/dist/interface/event.d.ts +0 -15
  177. package/dist/interface/hydrate.d.ts +0 -29
  178. package/dist/interface/index.d.ts +0 -7
  179. package/dist/interface/node.d.ts +0 -7
  180. package/dist/interface/utils.d.ts +0 -2
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 一个小型缓存池,用于在切换页面时,存储一些上下文信息
3
3
  */
4
- export declare class RuntimeCache<T> {
4
+ declare class RuntimeCache<T> {
5
5
  name: string;
6
6
  cache: Map<string, T>;
7
7
  constructor(name: string);
@@ -10,3 +10,4 @@ export declare class RuntimeCache<T> {
10
10
  get(identifier: string): T | undefined;
11
11
  delete(identifier: string): void;
12
12
  }
13
+ export { RuntimeCache };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 一个小型缓存池,用于在切换页面时,存储一些上下文信息
3
+ */
4
+ class RuntimeCache {
5
+ constructor(name) {
6
+ this.cache = new Map();
7
+ this.name = name;
8
+ }
9
+ has(identifier) {
10
+ return this.cache.has(identifier);
11
+ }
12
+ set(identifier, ctx) {
13
+ if (identifier && ctx) {
14
+ this.cache.set(identifier, ctx);
15
+ }
16
+ }
17
+ get(identifier) {
18
+ if (this.has(identifier))
19
+ return this.cache.get(identifier);
20
+ }
21
+ delete(identifier) {
22
+ this.cache.delete(identifier);
23
+ }
24
+ }
25
+
26
+ export { RuntimeCache };
27
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","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"],"names":[],"mappings":"AAAA;;AAEG;MAEU,YAAY,CAAA;AAIvB,IAAA,WAAA,CAAa,IAAY,EAAA;AAFzB,QAAA,IAAA,CAAA,KAAK,GAAG,IAAI,GAAG,EAAa,CAAA;AAG1B,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;KACjB;AAED,IAAA,GAAG,CAAE,UAAkB,EAAA;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;KAClC;IAED,GAAG,CAAE,UAAkB,EAAE,GAAM,EAAA;QAC7B,IAAI,UAAU,IAAI,GAAG,EAAE;YACrB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;AAChC,SAAA;KACF;AAED,IAAA,GAAG,CAAE,UAAkB,EAAA;AACrB,QAAA,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;KAC5D;AAED,IAAA,MAAM,CAAE,UAAkB,EAAA;AACxB,QAAA,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;KAC9B;AACF;;;;"}
@@ -1,23 +1,24 @@
1
- import { Func } from '../interface';
2
- import type { TaroElement } from '../dom/element';
3
- import type { TaroNode } from '../dom/node';
4
- import type { TaroText } from '../dom/text';
5
- export declare const incrementId: () => () => string;
6
- export declare function isElement(node: TaroNode): node is TaroElement;
7
- export declare function isText(node: TaroNode): node is TaroText;
8
- export declare function isComment(node: TaroNode): boolean;
9
- export declare function isHasExtractProp(el: TaroElement): boolean;
1
+ import { TaroElement } from "../dom/element.js";
2
+ import { TaroNode } from "../dom/node.js";
3
+ import { TaroText } from "../dom/text.js";
4
+ import { TFunc } from "../index-26658829.js";
5
+ declare const incrementId: () => () => string;
6
+ declare function isElement(node: TaroNode): node is TaroElement;
7
+ declare function isText(node: TaroNode): node is TaroText;
8
+ declare function isComment(node: TaroNode): boolean;
9
+ declare function isHasExtractProp(el: TaroElement): boolean;
10
10
  /**
11
11
  * 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
12
12
  * @param node 当前组件
13
13
  * @param type 事件类型
14
14
  */
15
- export declare function isParentBinded(node: TaroElement | null, type: string): boolean;
16
- export declare function shortcutAttr(key: string): string;
17
- export declare const customWrapperCache: Map<string, Record<string, any>>;
15
+ declare function isParentBinded(node: TaroElement | null, type: string): boolean;
16
+ declare function shortcutAttr(key: string): string;
17
+ declare const customWrapperCache: Map<string, Record<string, any>>;
18
18
  interface Ctor {
19
19
  new (...args: any[]): any;
20
20
  }
21
- export declare function extend(ctor: Ctor, methodName: string, options: Func | Record<string, any>): void;
22
- export declare function getComponentsAlias(): any;
23
- export {};
21
+ declare function extend(ctor: Ctor, methodName: string, options: TFunc | Record<string, any>): void;
22
+ declare function getComponentsAlias(): any;
23
+ export { incrementId, isElement, isText, isComment, isHasExtractProp, isParentBinded, shortcutAttr, customWrapperCache, extend, getComponentsAlias };
24
+ export * from "./lodash.js";
@@ -0,0 +1,95 @@
1
+ import { isFunction, getComponentsAlias as getComponentsAlias$1, internalComponents } from '@tarojs/shared';
2
+ import { COMMENT, ROOT_STR, CLASS, ID, UID, STYLE } from '../constants/index.js';
3
+
4
+ const incrementId = () => {
5
+ const chatCodes = [];
6
+ // A-Z
7
+ for (let i = 65; i <= 90; i++) {
8
+ chatCodes.push(i);
9
+ }
10
+ // a-z
11
+ for (let i = 97; i <= 122; i++) {
12
+ chatCodes.push(i);
13
+ }
14
+ const chatCodesLen = chatCodes.length - 1;
15
+ const list = [0, 0];
16
+ return () => {
17
+ const target = list.map(item => chatCodes[item]);
18
+ const res = String.fromCharCode(...target);
19
+ let tailIdx = list.length - 1;
20
+ list[tailIdx]++;
21
+ while (list[tailIdx] > chatCodesLen) {
22
+ list[tailIdx] = 0;
23
+ tailIdx = tailIdx - 1;
24
+ if (tailIdx < 0) {
25
+ list.push(0);
26
+ break;
27
+ }
28
+ list[tailIdx]++;
29
+ }
30
+ return res;
31
+ };
32
+ };
33
+ function isElement(node) {
34
+ return node.nodeType === 1 /* NodeType.ELEMENT_NODE */;
35
+ }
36
+ function isText(node) {
37
+ return node.nodeType === 3 /* NodeType.TEXT_NODE */;
38
+ }
39
+ function isComment(node) {
40
+ return node.nodeName === COMMENT;
41
+ }
42
+ function isHasExtractProp(el) {
43
+ const res = Object.keys(el.props).find(prop => {
44
+ return !(/^(class|style|id)$/.test(prop) || prop.startsWith('data-'));
45
+ });
46
+ return Boolean(res);
47
+ }
48
+ /**
49
+ * 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
50
+ * @param node 当前组件
51
+ * @param type 事件类型
52
+ */
53
+ function isParentBinded(node, type) {
54
+ var _a;
55
+ while ((node = (node === null || node === void 0 ? void 0 : node.parentElement) || null)) {
56
+ if (!node || node.nodeName === ROOT_STR || node.nodeName === 'root-portal') {
57
+ return false;
58
+ }
59
+ else if ((_a = node.__handlers[type]) === null || _a === void 0 ? void 0 : _a.length) {
60
+ return true;
61
+ }
62
+ }
63
+ return false;
64
+ }
65
+ function shortcutAttr(key) {
66
+ switch (key) {
67
+ case STYLE:
68
+ return "st" /* Shortcuts.Style */;
69
+ case ID:
70
+ return UID;
71
+ case CLASS:
72
+ return "cl" /* Shortcuts.Class */;
73
+ default:
74
+ return key;
75
+ }
76
+ }
77
+ const customWrapperCache = new Map();
78
+ function extend(ctor, methodName, options) {
79
+ if (isFunction(options)) {
80
+ options = {
81
+ value: options
82
+ };
83
+ }
84
+ Object.defineProperty(ctor.prototype, methodName, Object.assign({ configurable: true, enumerable: true }, options));
85
+ }
86
+ let componentsAlias;
87
+ function getComponentsAlias() {
88
+ if (!componentsAlias) {
89
+ componentsAlias = getComponentsAlias$1(internalComponents);
90
+ }
91
+ return componentsAlias;
92
+ }
93
+
94
+ export { customWrapperCache, extend, getComponentsAlias, incrementId, isComment, isElement, isHasExtractProp, isParentBinded, isText, shortcutAttr };
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourcesContent":["import {\n getComponentsAlias as _getComponentsAlias,\n internalComponents,\n isFunction,\n Shortcuts\n} from '@tarojs/shared'\n\nimport {\n CLASS,\n COMMENT,\n ID,\n ROOT_STR,\n STYLE,\n UID\n} 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 isParentBinded (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 * from './lodash'\n"],"names":["_getComponentsAlias"],"mappings":";;;AAsBO,MAAM,WAAW,GAAG,MAAK;IAC9B,MAAM,SAAS,GAAa,EAAE,CAAA;;IAE9B,KAAK,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;AAC7B,QAAA,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAClB,KAAA;;IAED,KAAK,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,EAAE,EAAE;AAC9B,QAAA,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AAClB,KAAA;AACD,IAAA,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAA;AACz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O,CAAC,EAAE;AACvB,QAAA,OAAO,GAAG;AACR,YAAA,KAAK,EAAE,OAAO;SACf,CAAA;AACF,KAAA;AACD,IAAA,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAA,MAAA,CAAA,MAAA,CAAA,EAC9C,YAAY,EAAE,IAAI,EAClB,UAAU,EAAE,IAAI,EACb,EAAA,OAAO,EACV,CAAA;AACJ,CAAC;AAED,IAAI,eAAe,CAAA;SACH,kBAAkB,GAAA;IAChC,IAAI,CAAC,eAAe,EAAE;AACpB,QAAA,eAAe,GAAGA,oBAAmB,CAAC,kBAAkB,CAAC,CAAA;AAC1D,KAAA;AACD,IAAA,OAAO,eAAe,CAAA;AACxB;;;;"}
@@ -0,0 +1,2 @@
1
+ declare function throttle(fn: any, threshold?: number, scope?: any): (...args: any[]) => void;
2
+ export { throttle };
@@ -0,0 +1,22 @@
1
+ function throttle(fn, threshold = 250, scope) {
2
+ let lastTime = 0;
3
+ let deferTimer;
4
+ return function (...args) {
5
+ const context = scope || this;
6
+ const now = Date.now();
7
+ if (now - lastTime > threshold) {
8
+ fn.apply(this, args);
9
+ lastTime = now;
10
+ }
11
+ else {
12
+ clearTimeout(deferTimer);
13
+ deferTimer = setTimeout(() => {
14
+ lastTime = now;
15
+ fn.apply(context, args);
16
+ }, threshold);
17
+ }
18
+ };
19
+ }
20
+
21
+ export { throttle };
22
+ //# sourceMappingURL=lodash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lodash.js","sources":["../../src/utils/lodash.ts"],"sourcesContent":["export function throttle (fn, threshold = 250, scope?) {\n let lastTime = 0\n let deferTimer: ReturnType<typeof setTimeout>\n return function (...args) {\n const context = scope || this\n const now = Date.now()\n if (now - lastTime > threshold) {\n fn.apply(this, args)\n lastTime = now\n } else {\n clearTimeout(deferTimer)\n deferTimer = setTimeout(() => {\n lastTime = now\n fn.apply(context, args)\n }, threshold)\n }\n }\n}\n"],"names":[],"mappings":"AAAM,SAAU,QAAQ,CAAE,EAAE,EAAE,SAAS,GAAG,GAAG,EAAE,KAAM,EAAA;IACnD,IAAI,QAAQ,GAAG,CAAC,CAAA;AAChB,IAAA,IAAI,UAAyC,CAAA;IAC7C,OAAO,UAAU,GAAG,IAAI,EAAA;AACtB,QAAA,MAAM,OAAO,GAAG,KAAK,IAAI,IAAI,CAAA;AAC7B,QAAA,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;AACtB,QAAA,IAAI,GAAG,GAAG,QAAQ,GAAG,SAAS,EAAE;AAC9B,YAAA,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YACpB,QAAQ,GAAG,GAAG,CAAA;AACf,SAAA;AAAM,aAAA;YACL,YAAY,CAAC,UAAU,CAAC,CAAA;AACxB,YAAA,UAAU,GAAG,UAAU,CAAC,MAAK;gBAC3B,QAAQ,GAAG,GAAG,CAAA;AACd,gBAAA,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;aACxB,EAAE,SAAS,CAAC,CAAA;AACd,SAAA;AACH,KAAC,CAAA;AACH;;;;"}
@@ -0,0 +1,8 @@
1
+ declare const addLeadingSlash: (url?: string) => string;
2
+ declare const hasBasename: (path?: string, prefix?: string) => boolean;
3
+ declare const stripBasename: (path?: string, prefix?: string) => string;
4
+ declare const stripTrailing: (str?: string) => string;
5
+ declare const stripSuffix: (path?: string, suffix?: string) => string;
6
+ declare const getHomePage: (path?: string, basename?: string, customRoutes?: Record<string, string | string[]>, entryPagePath?: string) => string;
7
+ declare const getCurrentPage: (routerMode?: string, basename?: string) => string;
8
+ export { addLeadingSlash, hasBasename, stripBasename, stripTrailing, stripSuffix, getHomePage, getCurrentPage };
@@ -0,0 +1,24 @@
1
+ import { location } from '../bom/window.js';
2
+
3
+ // export const removeLeadingSlash = (str = '') => str.replace(/^\.?\//, '')
4
+ // export const removeTrailingSearch = (str = '') => str.replace(/\?[\s\S]*$/, '')
5
+ const addLeadingSlash = (url = '') => (url.charAt(0) === '/' ? url : '/' + url);
6
+ const hasBasename = (path = '', prefix = '') => new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path) || path === prefix;
7
+ const stripBasename = (path = '', prefix = '') => hasBasename(path, prefix) ? path.substring(prefix.length) : path;
8
+ const stripTrailing = (str = '') => str.replace(/[?#][\s\S]*$/, '');
9
+ const stripSuffix = (path = '', suffix = '') => path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;
10
+ const getHomePage = (path = '', basename = '', customRoutes = {}, entryPagePath = '') => {
11
+ var _a;
12
+ const routePath = addLeadingSlash(stripBasename(path, basename));
13
+ const alias = ((_a = Object.entries(customRoutes).find(([key]) => key === routePath)) === null || _a === void 0 ? void 0 : _a[1]) || routePath;
14
+ return entryPagePath || (typeof alias === 'string' ? alias : alias[0]) || basename;
15
+ };
16
+ const getCurrentPage = (routerMode = 'hash', basename = '/') => {
17
+ const pagePath = routerMode === 'hash'
18
+ ? location.hash.slice(1).split('?')[0]
19
+ : location.pathname;
20
+ return addLeadingSlash(stripBasename(pagePath, basename));
21
+ };
22
+
23
+ export { addLeadingSlash, getCurrentPage, getHomePage, hasBasename, stripBasename, stripSuffix, stripTrailing };
24
+ //# sourceMappingURL=router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sources":["../../src/utils/router.ts"],"sourcesContent":["import { 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 = (path = '', basename = '', customRoutes: Record<string, string | string[]> = {}, entryPagePath = '') => {\n const routePath = addLeadingSlash(stripBasename(path, basename))\n const alias = Object.entries(customRoutes).find(\n ([key]) => key === routePath\n )?.[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'\n ? location.hash.slice(1).split('?')[0]\n : location.pathname\n return addLeadingSlash(stripBasename(pagePath, basename))\n}\n"],"names":[],"mappings":";;AAEA;AACA;AACO,MAAM,eAAe,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,EAAC;AAE/E,MAAM,WAAW,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,KAChD,IAAI,MAAM,CAAC,GAAG,GAAG,MAAM,GAAG,eAAe,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,OAAM;AAElE,MAAA,aAAa,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,KAClD,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,KAAI;AAErD,MAAA,aAAa,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,EAAC;AAE7D,MAAA,WAAW,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,KAChD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,KAAI;MAElE,WAAW,GAAG,CAAC,IAAI,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAE,eAAkD,EAAE,EAAE,aAAa,GAAG,EAAE,KAAI;;IAChI,MAAM,SAAS,GAAG,eAAe,CAAC,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;AAChE,IAAA,MAAM,KAAK,GAAG,CAAA,CAAA,EAAA,GAAA,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CAC7C,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,SAAS,CAC7B,MAAG,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,CAAC,CAAC,KAAI,SAAS,CAAA;IACnB,OAAO,aAAa,KAAK,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAA;AACpF,EAAC;AAEM,MAAM,cAAc,GAAG,CAAC,UAAU,GAAG,MAAM,EAAE,QAAQ,GAAG,GAAG,KAAI;AACpE,IAAA,MAAM,QAAQ,GAAG,UAAU,KAAK,MAAM;AACpC,UAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACtC,UAAE,QAAQ,CAAC,QAAQ,CAAA;IACrB,OAAO,eAAe,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;AAC3D;;;;"}
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "@tarojs/runtime",
3
- "version": "3.6.22",
3
+ "version": "3.6.23",
4
4
  "description": "taro runtime for mini apps.",
5
+ "browser": "dist/index.js",
6
+ "main:h5": "dist/runtime.esm.js",
5
7
  "main": "dist/runtime.esm.js",
6
8
  "module": "dist/runtime.esm.js",
7
- "types": "./dist/index.d.ts",
9
+ "types": "./dist/runtime.esm.d.ts",
8
10
  "files": [
9
11
  "dist"
10
12
  ],
13
+ "sideEffects": [],
11
14
  "repository": {
12
15
  "type": "git",
13
16
  "url": "https://github.com/NervJS/taro/tree/master/packages/taro-runtime"
@@ -19,24 +22,31 @@
19
22
  },
20
23
  "dependencies": {
21
24
  "lodash-es": "4.17.21",
22
- "@tarojs/shared": "3.6.22"
25
+ "tslib": "^2.6.2"
23
26
  },
24
27
  "devDependencies": {
25
- "@rollup/plugin-buble": "^0.21.3",
28
+ "@rollup/plugin-typescript": "^11.1.0",
26
29
  "@vue/runtime-core": "3.2.41",
27
30
  "jest": "^29.3.1",
28
31
  "jest-cli": "^29.3.1",
29
32
  "jest-environment-node": "^29.5.0",
30
- "rollup": "^2.79.0",
33
+ "rollup": "^3.8.1",
34
+ "rollup-plugin-node-externals": "^5.0.0",
31
35
  "rollup-plugin-ts": "^3.0.2",
32
36
  "ts-jest": "^29.0.5",
33
- "tslib": "^2.5.0",
34
- "typescript": "^4.7.4"
37
+ "typescript": "^4.7.4",
38
+ "@tarojs/shared": "3.6.23"
39
+ },
40
+ "peerDependencies": {
41
+ "@tarojs/shared": "~3.6.23"
35
42
  },
36
43
  "scripts": {
37
- "build": "rimraf ./dist && tsc -emitDeclarationOnly && rollup -c",
38
- "dev": "rollup -c -w",
44
+ "prebuild": "pnpm run clean",
45
+ "build": "pnpm run rollup --environment NODE_ENV:production",
46
+ "clean": "rimraf ./dist",
47
+ "dev": "pnpm run rollup --environment NODE_ENV:development -w",
48
+ "rollup": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript --bundleConfigAsCjs",
39
49
  "test": "jest",
40
- "test:ci": "jest --ci -i --coverage"
50
+ "test:ci": "jest --ci -i --coverage --silent"
41
51
  }
42
52
  }
@@ -1,4 +0,0 @@
1
- export interface Attributes {
2
- name: string;
3
- value: string;
4
- }
@@ -1,10 +0,0 @@
1
- export interface EventListenerOptions {
2
- capture?: boolean;
3
- }
4
- export interface AddEventListenerOptions extends EventListenerOptions {
5
- once?: boolean;
6
- passive?: boolean;
7
- }
8
- export interface EventHandler extends Function {
9
- _stop?: boolean;
10
- }
@@ -1,15 +0,0 @@
1
- export interface EventOptions {
2
- bubbles: boolean;
3
- cancelable: boolean;
4
- }
5
- type Target = Record<string, unknown> & {
6
- dataset: Record<string, unknown>;
7
- id: string;
8
- };
9
- export interface MpEvent {
10
- type: string;
11
- detail: Record<string, unknown>;
12
- target: Target;
13
- currentTarget: Target;
14
- }
15
- export {};
@@ -1,29 +0,0 @@
1
- import type { Shortcuts } from '@tarojs/shared';
2
- import type { PageConfig } from '@tarojs/taro';
3
- export interface MpInstance {
4
- config: PageConfig;
5
- setData: (data: unknown, cb: () => void) => void;
6
- route?: string;
7
- __route__: string;
8
- $taroParams?: Record<string, unknown>;
9
- $taroPath: string;
10
- __data__: any;
11
- data: any;
12
- exitState?: any;
13
- selectComponent: (selector: string) => any;
14
- }
15
- export interface MiniElementData {
16
- [Shortcuts.Childnodes]?: MiniData[];
17
- [Shortcuts.NodeName]: string;
18
- [Shortcuts.Class]?: string;
19
- [Shortcuts.Style]?: string;
20
- uid?: string;
21
- sid: string;
22
- [key: string]: unknown;
23
- }
24
- export interface MiniTextData {
25
- [Shortcuts.Text]: string;
26
- [Shortcuts.NodeName]: string;
27
- }
28
- export type MiniData = MiniElementData | MiniTextData;
29
- export type HydratedData = () => MiniData | MiniData[];
@@ -1,7 +0,0 @@
1
- export * from './element';
2
- export * from './event';
3
- export * from './event-target';
4
- export * from './hydrate';
5
- export * from './node';
6
- export * from './options';
7
- export * from './utils';
@@ -1,7 +0,0 @@
1
- import { HydratedData } from './index';
2
- export type UpdatePayloadValue = string | boolean | HydratedData;
3
- export type DataTree = Record<string, UpdatePayloadValue | ReturnType<HydratedData>>;
4
- export interface UpdatePayload {
5
- path: string;
6
- value: UpdatePayloadValue;
7
- }
@@ -1,2 +0,0 @@
1
- export type Func = (...args: any[]) => any;
2
- export type Ctx = Record<string, any>;