@tarojs/runtime 4.0.0-beta.1 → 4.0.0-beta.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.
- package/LICENSE +14 -0
- package/dist/bom/URL.d.ts +54 -0
- package/dist/bom/URL.js +221 -0
- package/dist/bom/URL.js.map +1 -0
- package/dist/bom/URLSearchParams.d.ts +2 -0
- package/dist/bom/URLSearchParams.js +123 -0
- package/dist/bom/URLSearchParams.js.map +1 -0
- package/dist/bom/document.d.ts +3 -0
- package/dist/bom/document.js +39 -0
- package/dist/bom/document.js.map +1 -0
- package/dist/bom/getComputedStyle.d.ts +5 -0
- package/dist/bom/getComputedStyle.js +8 -0
- package/dist/bom/getComputedStyle.js.map +1 -0
- package/dist/bom/history.d.ts +32 -0
- package/dist/bom/history.js +121 -0
- package/dist/bom/history.js.map +1 -0
- package/dist/bom/location.d.ts +39 -0
- package/dist/bom/location.js +240 -0
- package/dist/bom/location.js.map +1 -0
- package/dist/bom/navigator.d.ts +2 -0
- package/dist/bom/navigator.js +24 -0
- package/dist/bom/navigator.js.map +1 -0
- package/dist/bom/raf.d.ts +4 -0
- package/dist/bom/raf.js +33 -0
- package/dist/bom/raf.js.map +1 -0
- package/dist/bom/window.d.ts +25 -0
- package/dist/bom/window.js +92 -0
- package/dist/bom/window.js.map +1 -0
- package/dist/constants/index.d.ts +60 -0
- package/dist/constants/index.js +63 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/current.d.ts +19 -0
- package/dist/current.js +9 -0
- package/dist/current.js.map +1 -0
- package/dist/dom/anchor-element.d.ts +14 -0
- package/dist/dom/anchor-element.js +54 -0
- package/dist/dom/anchor-element.js.map +1 -0
- package/dist/dom/class-list.d.ts +17 -0
- package/dist/dom/class-list.js +92 -0
- package/dist/dom/class-list.js.map +1 -0
- package/dist/dom/document.d.ts +25 -0
- package/dist/dom/document.js +80 -0
- package/dist/dom/document.js.map +1 -0
- package/dist/dom/element.d.ts +40 -0
- package/dist/dom/element.js +315 -0
- package/dist/dom/element.js.map +1 -0
- package/dist/dom/event-source.d.ts +7 -0
- package/dist/dom/event-source.js +17 -0
- package/dist/dom/event-source.js.map +1 -0
- package/dist/dom/event-target.d.ts +8 -0
- package/dist/dom/event-target.js +78 -0
- package/dist/dom/event-target.js.map +1 -0
- package/dist/dom/event.d.ts +24 -0
- package/dist/dom/event.js +151 -0
- package/dist/dom/event.js.map +1 -0
- package/dist/dom/form.d.ts +10 -0
- package/dist/dom/form.js +38 -0
- package/dist/dom/form.js.map +1 -0
- package/dist/dom/node.d.ts +107 -0
- package/dist/dom/node.js +292 -0
- package/dist/dom/node.js.map +1 -0
- package/dist/dom/root.d.ts +16 -0
- package/dist/dom/root.js +169 -0
- package/dist/dom/root.js.map +1 -0
- package/dist/dom/style.d.ts +15 -0
- package/dist/dom/style.js +168 -0
- package/dist/dom/style.js.map +1 -0
- package/dist/dom/style_properties.d.ts +3 -0
- package/dist/dom/style_properties.js +186 -0
- package/dist/dom/style_properties.js.map +1 -0
- package/dist/dom/svg.d.ts +4 -0
- package/dist/dom/svg.js +8 -0
- package/dist/dom/svg.js.map +1 -0
- package/dist/dom/text.d.ts +15 -0
- package/dist/dom/text.js +41 -0
- package/dist/dom/text.js.map +1 -0
- package/dist/dom/transfer.d.ts +8 -0
- package/dist/dom/transfer.js +15 -0
- package/dist/dom/transfer.js.map +1 -0
- package/dist/dom/tree.d.ts +4 -0
- package/dist/dom/tree.js +38 -0
- package/dist/dom/tree.js.map +1 -0
- package/dist/dom-external/element.d.ts +4 -0
- package/dist/dom-external/element.js +29 -0
- package/dist/dom-external/element.js.map +1 -0
- package/dist/dom-external/index.d.ts +1 -0
- package/dist/dom-external/index.js +40 -0
- package/dist/dom-external/index.js.map +1 -0
- package/dist/dom-external/inner-html/html.d.ts +3 -0
- package/dist/dom-external/inner-html/html.js +28 -0
- package/dist/dom-external/inner-html/html.js.map +1 -0
- package/dist/dom-external/inner-html/parser.d.ts +25 -0
- package/dist/dom-external/inner-html/parser.js +216 -0
- package/dist/dom-external/inner-html/parser.js.map +1 -0
- package/dist/dom-external/inner-html/scaner.d.ts +30 -0
- package/dist/dom-external/inner-html/scaner.js +304 -0
- package/dist/dom-external/inner-html/scaner.js.map +1 -0
- package/dist/dom-external/inner-html/style.d.ts +27 -0
- package/dist/dom-external/inner-html/style.js +235 -0
- package/dist/dom-external/inner-html/style.js.map +1 -0
- package/dist/dom-external/inner-html/tags.d.ts +9 -0
- package/dist/dom-external/inner-html/tags.js +26 -0
- package/dist/dom-external/inner-html/tags.js.map +1 -0
- package/dist/dom-external/inner-html/utils.d.ts +2 -0
- package/dist/dom-external/inner-html/utils.js +12 -0
- package/dist/dom-external/inner-html/utils.js.map +1 -0
- package/dist/dom-external/mutation-observer/implements.d.ts +71 -0
- package/dist/dom-external/mutation-observer/implements.js +108 -0
- package/dist/dom-external/mutation-observer/implements.js.map +1 -0
- package/dist/dom-external/mutation-observer/index.d.ts +12 -0
- package/dist/dom-external/mutation-observer/index.js +35 -0
- package/dist/dom-external/mutation-observer/index.js.map +1 -0
- package/dist/dom-external/node.d.ts +12 -0
- package/dist/dom-external/node.js +74 -0
- package/dist/dom-external/node.js.map +1 -0
- package/dist/dsl/common.d.ts +15 -0
- package/dist/dsl/common.js +332 -0
- package/dist/dsl/common.js.map +1 -0
- package/dist/emitter/emitter.d.ts +4 -0
- package/dist/emitter/emitter.js +7 -0
- package/dist/emitter/emitter.js.map +1 -0
- package/dist/env.d.ts +7 -0
- package/dist/env.js +9 -0
- package/dist/env.js.map +1 -0
- package/dist/hydrate.d.ts +11 -0
- package/dist/hydrate.js +84 -0
- package/dist/hydrate.js.map +1 -0
- package/dist/index-26658829.d.ts +23 -0
- package/dist/{runtime.cjs.d.ts → index.cjs.d.ts} +92 -89
- package/dist/{runtime.h5.js → index.cjs.js} +4251 -2493
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/instance-4c64b022.d.ts +92 -0
- package/dist/next-tick.d.ts +3 -0
- package/dist/next-tick.js +47 -0
- package/dist/next-tick.js.map +1 -0
- package/dist/node_types-9ac5b4dd.d.ts +11 -0
- package/dist/options-4c64b022.d.ts +17 -0
- package/dist/options.d.ts +3 -0
- package/dist/options.js +7 -0
- package/dist/options.js.map +1 -0
- package/dist/perf.d.ts +7 -0
- package/dist/perf.js +28 -0
- package/dist/perf.js.map +1 -0
- package/dist/polyfill/array.d.ts +3 -0
- package/dist/polyfill/array.js +56 -0
- package/dist/polyfill/array.js.map +1 -0
- package/dist/polyfill/index.d.ts +2 -0
- package/dist/polyfill/index.js +34 -0
- package/dist/polyfill/index.js.map +1 -0
- package/dist/polyfill/intersection-observer.d.ts +2 -0
- package/dist/polyfill/intersection-observer.js +599 -0
- package/dist/polyfill/intersection-observer.js.map +1 -0
- package/dist/polyfill/object.d.ts +4 -0
- package/dist/polyfill/object.js +102 -0
- package/dist/polyfill/object.js.map +1 -0
- package/dist/record-32b054d8.d.ts +25 -0
- package/dist/runtime.esm.d.ts +92 -89
- package/dist/runtime.esm.js +4077 -3317
- package/dist/runtime.esm.js.map +1 -1
- package/dist/utils/cache.d.ts +13 -0
- package/dist/utils/cache.js +27 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/index.d.ts +26 -0
- package/dist/utils/index.js +99 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/lodash.d.ts +2 -0
- package/dist/utils/lodash.js +22 -0
- package/dist/utils/lodash.js.map +1 -0
- package/dist/utils/router.d.ts +8 -0
- package/dist/utils/router.js +24 -0
- package/dist/utils/router.js.map +1 -0
- package/package.json +16 -11
- package/dist/runtime.cjs.js +0 -4628
- package/dist/runtime.h5.d.ts +0 -800
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 一个小型缓存池,用于在切换页面时,存储一些上下文信息
|
|
3
|
+
*/
|
|
4
|
+
declare class RuntimeCache<T> {
|
|
5
|
+
name: string;
|
|
6
|
+
cache: Map<string, T>;
|
|
7
|
+
constructor(name: string);
|
|
8
|
+
has(identifier: string): boolean;
|
|
9
|
+
set(identifier: string, ctx: T): void;
|
|
10
|
+
get(identifier: string): T | undefined;
|
|
11
|
+
delete(identifier: string): void;
|
|
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;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
/**
|
|
11
|
+
* 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
|
|
12
|
+
* @param node 当前组件
|
|
13
|
+
* @param type 事件类型
|
|
14
|
+
*/
|
|
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
|
+
interface Ctor {
|
|
19
|
+
new (...args: any[]): any;
|
|
20
|
+
}
|
|
21
|
+
declare function extend(ctor: Ctor, methodName: string, options: TFunc | Record<string, any>): void;
|
|
22
|
+
declare function getComponentsAlias(): any;
|
|
23
|
+
declare function convertNumber2PX(value: number): string;
|
|
24
|
+
export { incrementId, isElement, isText, isComment, isHasExtractProp, isParentBinded, shortcutAttr, customWrapperCache, extend, getComponentsAlias, convertNumber2PX };
|
|
25
|
+
export * from "./lodash.js";
|
|
26
|
+
export * from "./router.js";
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
import '../bom/window.js';
|
|
4
|
+
|
|
5
|
+
const incrementId = () => {
|
|
6
|
+
const chatCodes = [];
|
|
7
|
+
// A-Z
|
|
8
|
+
for (let i = 65; i <= 90; i++) {
|
|
9
|
+
chatCodes.push(i);
|
|
10
|
+
}
|
|
11
|
+
// a-z
|
|
12
|
+
for (let i = 97; i <= 122; i++) {
|
|
13
|
+
chatCodes.push(i);
|
|
14
|
+
}
|
|
15
|
+
const chatCodesLen = chatCodes.length - 1;
|
|
16
|
+
const list = [0, 0];
|
|
17
|
+
return () => {
|
|
18
|
+
const target = list.map(item => chatCodes[item]);
|
|
19
|
+
const res = String.fromCharCode(...target);
|
|
20
|
+
let tailIdx = list.length - 1;
|
|
21
|
+
list[tailIdx]++;
|
|
22
|
+
while (list[tailIdx] > chatCodesLen) {
|
|
23
|
+
list[tailIdx] = 0;
|
|
24
|
+
tailIdx = tailIdx - 1;
|
|
25
|
+
if (tailIdx < 0) {
|
|
26
|
+
list.push(0);
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
list[tailIdx]++;
|
|
30
|
+
}
|
|
31
|
+
return res;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
function isElement(node) {
|
|
35
|
+
return node.nodeType === 1 /* NodeType.ELEMENT_NODE */;
|
|
36
|
+
}
|
|
37
|
+
function isText(node) {
|
|
38
|
+
return node.nodeType === 3 /* NodeType.TEXT_NODE */;
|
|
39
|
+
}
|
|
40
|
+
function isComment(node) {
|
|
41
|
+
return node.nodeName === COMMENT;
|
|
42
|
+
}
|
|
43
|
+
function isHasExtractProp(el) {
|
|
44
|
+
const res = Object.keys(el.props).find(prop => {
|
|
45
|
+
return !(/^(class|style|id)$/.test(prop) || prop.startsWith('data-'));
|
|
46
|
+
});
|
|
47
|
+
return Boolean(res);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
|
|
51
|
+
* @param node 当前组件
|
|
52
|
+
* @param type 事件类型
|
|
53
|
+
*/
|
|
54
|
+
function isParentBinded(node, type) {
|
|
55
|
+
var _a;
|
|
56
|
+
while ((node = (node === null || node === void 0 ? void 0 : node.parentElement) || null)) {
|
|
57
|
+
if (!node || node.nodeName === ROOT_STR || node.nodeName === 'root-portal') {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
else if ((_a = node.__handlers[type]) === null || _a === void 0 ? void 0 : _a.length) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
function shortcutAttr(key) {
|
|
67
|
+
switch (key) {
|
|
68
|
+
case STYLE:
|
|
69
|
+
return "st" /* Shortcuts.Style */;
|
|
70
|
+
case ID:
|
|
71
|
+
return UID;
|
|
72
|
+
case CLASS:
|
|
73
|
+
return "cl" /* Shortcuts.Class */;
|
|
74
|
+
default:
|
|
75
|
+
return key;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const customWrapperCache = new Map();
|
|
79
|
+
function extend(ctor, methodName, options) {
|
|
80
|
+
if (isFunction(options)) {
|
|
81
|
+
options = {
|
|
82
|
+
value: options
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
Object.defineProperty(ctor.prototype, methodName, Object.assign({ configurable: true, enumerable: true }, options));
|
|
86
|
+
}
|
|
87
|
+
let componentsAlias;
|
|
88
|
+
function getComponentsAlias() {
|
|
89
|
+
if (!componentsAlias) {
|
|
90
|
+
componentsAlias = getComponentsAlias$1(internalComponents);
|
|
91
|
+
}
|
|
92
|
+
return componentsAlias;
|
|
93
|
+
}
|
|
94
|
+
function convertNumber2PX(value) {
|
|
95
|
+
return value + 'px';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { convertNumber2PX, customWrapperCache, extend, getComponentsAlias, incrementId, isComment, isElement, isHasExtractProp, isParentBinded, isText, shortcutAttr };
|
|
99
|
+
//# 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 function convertNumber2PX (value: number) {\n return value + 'px'\n}\n\nexport * from './lodash'\nexport * from './router'\n"],"names":["_getComponentsAlias"],"mappings":";;;;AAsBO,MAAM,WAAW,GAAG,M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AC;AAEK,SAAU,YAAY,CAAE,GAAW,EAAA;AACvC,IAAA,QAAQ,GAAG;AACT,QAAA,KAAK,KAAK;YACR,OAAsB,IAAA,uBAAA;AACxB,QAAA,KAAK,EAAE;AACL,YAAA,OAAO,GAAG,CAAA;AACZ,QAAA,KAAK,KAAK;YACR,OAAsB,IAAA,uBAAA;AACxB,QAAA;AACE,YAAA,OAAO,GAAG,CAAA;AACb,KAAA;AACH,CAAC;AAEY,MAAA,kBAAkB,GAAG,IAAI,GAAG,GAA+B;SAMxD,MAAM,CAAE,IAAU,EAAE,UAAkB,EAAE,OAAoC,EAAA;AAC1F,IAAA,IAAI,UAAU,CAAC,OAAO,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,CAAC;AAEK,SAAU,gBAAgB,CAAE,KAAa,EAAA;IAC7C,OAAO,KAAK,GAAG,IAAI,CAAA;AACrB;;;;"}
|
|
@@ -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 addL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G,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,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/runtime",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.2",
|
|
4
4
|
"description": "taro runtime for mini apps.",
|
|
5
|
-
"
|
|
5
|
+
"browser": "dist/index.js",
|
|
6
|
+
"main:h5": "dist/runtime.esm.js",
|
|
6
7
|
"main": "dist/runtime.esm.js",
|
|
7
8
|
"module": "dist/runtime.esm.js",
|
|
8
9
|
"types": "./dist/runtime.esm.d.ts",
|
|
9
10
|
"files": [
|
|
10
11
|
"dist"
|
|
11
12
|
],
|
|
13
|
+
"sideEffects": [],
|
|
12
14
|
"repository": {
|
|
13
15
|
"type": "git",
|
|
14
16
|
"url": "https://github.com/NervJS/taro/tree/master/packages/taro-runtime"
|
|
@@ -20,28 +22,31 @@
|
|
|
20
22
|
},
|
|
21
23
|
"dependencies": {
|
|
22
24
|
"lodash-es": "4.17.21",
|
|
23
|
-
"
|
|
25
|
+
"tslib": "^2.6.2"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
|
26
|
-
"@rollup/plugin-buble": "^1.0.3",
|
|
27
|
-
"@rollup/plugin-replace": "^5.0.2",
|
|
28
28
|
"@rollup/plugin-typescript": "^11.1.0",
|
|
29
29
|
"@vue/runtime-core": "3.2.47",
|
|
30
30
|
"jest": "^29.3.1",
|
|
31
31
|
"jest-cli": "^29.3.1",
|
|
32
32
|
"jest-environment-node": "^29.5.0",
|
|
33
33
|
"rollup": "^3.8.1",
|
|
34
|
+
"rollup-plugin-node-externals": "^5.0.0",
|
|
34
35
|
"rollup-plugin-ts": "^3.0.2",
|
|
35
36
|
"ts-jest": "^29.0.5",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
37
|
+
"typescript": "^4.7.4",
|
|
38
|
+
"@tarojs/shared": "4.0.0-beta.2"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@tarojs/shared": "~4.0.0-beta.2"
|
|
38
42
|
},
|
|
39
43
|
"scripts": {
|
|
40
|
-
"prebuild": "
|
|
41
|
-
"build": "pnpm run rollup",
|
|
42
|
-
"
|
|
44
|
+
"prebuild": "pnpm run clean",
|
|
45
|
+
"build": "pnpm run rollup --environment NODE_ENV:production",
|
|
46
|
+
"clean": "rimraf --impl=move-remove ./dist",
|
|
47
|
+
"dev": "pnpm run rollup --environment NODE_ENV:development -w",
|
|
43
48
|
"rollup": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript --bundleConfigAsCjs",
|
|
44
49
|
"test": "jest",
|
|
45
|
-
"test:ci": "jest --ci -i --coverage
|
|
50
|
+
"test:ci": "jest --ci -i --coverage --silent"
|
|
46
51
|
}
|
|
47
52
|
}
|