@tarojs/runtime 4.2.1-beta.2 → 4.2.1
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/dist/bom/document.js +7 -2
- package/dist/bom/document.js.map +1 -1
- package/dist/dom/node.d.ts +1 -3
- package/dist/dom/node.js +0 -10
- package/dist/dom/node.js.map +1 -1
- package/dist/dom/root.d.ts +0 -2
- package/dist/dom/root.js +0 -4
- package/dist/dom/root.js.map +1 -1
- package/dist/dsl/common.d.ts +1 -1
- package/dist/dsl/common.js +5 -13
- package/dist/dsl/common.js.map +1 -1
- package/dist/index.cjs.d.ts +2 -9
- package/dist/index.cjs.js +12 -77
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime.esm.d.ts +2 -9
- package/dist/runtime.esm.js +13 -75
- package/dist/runtime.esm.js.map +1 -1
- package/package.json +2 -2
- package/dist/dom/nearest-ctx.d.ts +0 -9
- package/dist/dom/nearest-ctx.js +0 -49
- package/dist/dom/nearest-ctx.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/runtime",
|
|
3
|
-
"version": "4.2.1
|
|
3
|
+
"version": "4.2.1",
|
|
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
|
-
"@tarojs/shared": "4.2.1
|
|
27
|
+
"@tarojs/shared": "4.2.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MpInstance } from '../interface/hydrate.js';
|
|
2
|
-
import { TaroNode } from './node.js';
|
|
3
|
-
import { TaroRootElement } from './root.js';
|
|
4
|
-
|
|
5
|
-
declare function isNearestCtxEnv(): boolean;
|
|
6
|
-
declare function getNearestCtx(node: TaroNode): MpInstance | null | undefined;
|
|
7
|
-
declare function bumpNearestCtxEpochForRoot(root: TaroRootElement | null | undefined): void;
|
|
8
|
-
|
|
9
|
-
export { bumpNearestCtxEpochForRoot, getNearestCtx, isNearestCtxEnv };
|
package/dist/dom/nearest-ctx.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const nearestCtxCache = new WeakMap();
|
|
2
|
-
function isNearestCtxEnv() {
|
|
3
|
-
return process.env.TARO_ENV === 'weapp' || process.env.TARO_ENV === 'jd';
|
|
4
|
-
}
|
|
5
|
-
function getNearestCtx(node) {
|
|
6
|
-
if (!isNearestCtxEnv()) {
|
|
7
|
-
return undefined;
|
|
8
|
-
}
|
|
9
|
-
const root = node._root;
|
|
10
|
-
if (root == null) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const cached = nearestCtxCache.get(node);
|
|
14
|
-
if (cached && cached.nearestCtxEpoch === root.nearestCtxEpoch) {
|
|
15
|
-
return cached.value;
|
|
16
|
-
}
|
|
17
|
-
const value = resolveNearestCtxValue(node, root);
|
|
18
|
-
nearestCtxCache.set(node, { value, nearestCtxEpoch: root.nearestCtxEpoch });
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
function resolveNearestCtxValue(node, root) {
|
|
22
|
-
var _a;
|
|
23
|
-
if (node.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
|
|
24
|
-
const ctx = node.ctx;
|
|
25
|
-
if (ctx != null)
|
|
26
|
-
return ctx;
|
|
27
|
-
}
|
|
28
|
-
let current = node.parentNode;
|
|
29
|
-
while (current) {
|
|
30
|
-
if (current.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
|
|
31
|
-
const ctx = current.ctx;
|
|
32
|
-
if (ctx != null)
|
|
33
|
-
return ctx;
|
|
34
|
-
}
|
|
35
|
-
current = current.parentNode;
|
|
36
|
-
}
|
|
37
|
-
return (_a = root.ctx) !== null && _a !== void 0 ? _a : null;
|
|
38
|
-
}
|
|
39
|
-
function bumpNearestCtxEpochForRoot(root) {
|
|
40
|
-
if (!isNearestCtxEnv() || root == null) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (typeof root.bumpNearestCtxEpoch === 'function') {
|
|
44
|
-
root.bumpNearestCtxEpoch();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export { bumpNearestCtxEpochForRoot, getNearestCtx, isNearestCtxEnv };
|
|
49
|
-
//# sourceMappingURL=nearest-ctx.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nearest-ctx.js","sources":["../../../src/dom/nearest-ctx.ts"],"sourcesContent":["import { NodeType } from './node_types'\n\nimport type { MpInstance } from '../interface'\nimport type { TaroElement } from './element'\nimport type { TaroNode } from './node'\nimport type { TaroRootElement } from './root'\n\nconst nearestCtxCache = new WeakMap<TaroNode, { value: MpInstance | null, nearestCtxEpoch: number }>()\n\nexport function isNearestCtxEnv (): boolean {\n return process.env.TARO_ENV === 'weapp' || process.env.TARO_ENV === 'jd'\n}\n\nexport function getNearestCtx (node: TaroNode): MpInstance | null | undefined {\n if (!isNearestCtxEnv()) {\n return undefined\n }\n const root = node._root\n if (root == null) {\n return null\n }\n const cached = nearestCtxCache.get(node)\n if (cached && cached.nearestCtxEpoch === root.nearestCtxEpoch) {\n return cached.value\n }\n const value = resolveNearestCtxValue(node, root)\n nearestCtxCache.set(node, { value, nearestCtxEpoch: root.nearestCtxEpoch })\n return value\n}\n\nfunction resolveNearestCtxValue (node: TaroNode, root: TaroRootElement): MpInstance | null {\n if (node.nodeType === NodeType.ELEMENT_NODE) {\n const ctx = (node as TaroElement).ctx\n if (ctx != null) return ctx as MpInstance\n }\n let current: TaroNode | null = node.parentNode\n while (current) {\n if (current.nodeType === NodeType.ELEMENT_NODE) {\n const ctx = (current as TaroElement).ctx\n if (ctx != null) return ctx as MpInstance\n }\n current = current.parentNode\n }\n return root.ctx ?? null\n}\n\nexport function bumpNearestCtxEpochForRoot (root: TaroRootElement | null | undefined): void {\n if (!isNearestCtxEnv() || root == null) {\n return\n }\n if (typeof root.bumpNearestCtxEpoch === 'function') {\n root.bumpNearestCtxEpoch()\n }\n}\n"],"names":[],"mappings":"AAOA,MAAM,eAAe,GAAG,IAAI,OAAO,EAAmE;SAEtF,eAAe,GAAA;AAC7B,IAAA,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,IAAI;AAC1E;AAEM,SAAU,aAAa,CAAE,IAAc,EAAA;AAC3C,IAAA,IAAI,CAAC,eAAe,EAAE,EAAE;AACtB,QAAA,OAAO,SAAS;;AAElB,IAAA,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK;AACvB,IAAA,IAAI,IAAI,IAAI,IAAI,EAAE;AAChB,QAAA,OAAO,IAAI;;IAEb,MAAM,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC;IACxC,IAAI,MAAM,IAAI,MAAM,CAAC,eAAe,KAAK,IAAI,CAAC,eAAe,EAAE;QAC7D,OAAO,MAAM,CAAC,KAAK;;IAErB,MAAM,KAAK,GAAG,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC;AAChD,IAAA,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC;AAC3E,IAAA,OAAO,KAAK;AACd;AAEA,SAAS,sBAAsB,CAAE,IAAc,EAAE,IAAqB,EAAA;;AACpE,IAAA,IAAI,IAAI,CAAC,QAAQ,KAAA,CAAA,8BAA4B;AAC3C,QAAA,MAAM,GAAG,GAAI,IAAoB,CAAC,GAAG;QACrC,IAAI,GAAG,IAAI,IAAI;AAAE,Y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