@tarojs/runtime 4.0.3-alpha.4 → 4.0.3-alpha.5
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/URL.js +2 -2
- package/dist/bom/URL.js.map +1 -1
- package/dist/bom/URLSearchParams.js +2 -2
- package/dist/bom/URLSearchParams.js.map +1 -1
- package/dist/bom/document.js +2 -1
- package/dist/bom/document.js.map +1 -1
- package/dist/bom/getComputedStyle.js +2 -1
- package/dist/bom/getComputedStyle.js.map +1 -1
- package/dist/bom/history.js +2 -2
- package/dist/bom/history.js.map +1 -1
- package/dist/bom/location.js +2 -2
- package/dist/bom/location.js.map +1 -1
- package/dist/bom/navigator.js +2 -1
- package/dist/bom/navigator.js.map +1 -1
- package/dist/bom/raf.js +4 -2
- package/dist/bom/raf.js.map +1 -1
- package/dist/bom/window.js +2 -2
- package/dist/bom/window.js.map +1 -1
- package/dist/dom-external/index.js +2 -1
- package/dist/dom-external/index.js.map +1 -1
- package/dist/dsl/common.js +11 -11
- package/dist/dsl/common.js.map +1 -1
- package/dist/env.js +3 -3
- package/dist/env.js.map +1 -1
- package/dist/index.cjs.js +26 -26
- package/dist/index.cjs.js.map +1 -1
- package/dist/next-tick.js +2 -1
- package/dist/next-tick.js.map +1 -1
- package/dist/polyfill/index.js +3 -3
- package/dist/polyfill/index.js.map +1 -1
- package/dist/runtime.esm.js +27 -27
- package/dist/runtime.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/next-tick.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PLATFORM_TYPE } from '@tarojs/shared';
|
|
1
2
|
import { Current } from './current.js';
|
|
2
3
|
import env from './env.js';
|
|
3
4
|
|
|
@@ -23,7 +24,7 @@ const nextTick = (cb, ctx) => {
|
|
|
23
24
|
var _a, _b, _c;
|
|
24
25
|
const pageElement = env.document.getElementById(path);
|
|
25
26
|
if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) {
|
|
26
|
-
if (process.env.TARO_PLATFORM ===
|
|
27
|
+
if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB) {
|
|
27
28
|
// eslint-disable-next-line dot-notation
|
|
28
29
|
(_c = (_b = (_a = pageElement.firstChild) === null || _a === void 0 ? void 0 : _a['componentOnReady']) === null || _b === void 0 ? void 0 : _b.call(_a).then(() => {
|
|
29
30
|
timerFunc();
|
package/dist/next-tick.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-tick.js","sources":["../src/next-tick.ts"],"sourcesContent":["import { Current } from './current'\nimport { TaroRootElement } from './dom/root'\nimport env from './env'\n\nimport type { TFunc } from './interface'\n\nconst TIMEOUT = 100\n\nexport const nextTick = (cb: TFunc, ctx?: Record<string, any>) => {\n const beginTime = Date.now()\n const router = Current.router\n\n const timerFunc = () => {\n setTimeout(function () {\n ctx ? cb.call(ctx) : cb()\n }, 1)\n }\n\n if (router === null) return timerFunc()\n\n const path = router.$taroPath\n\n /**\n * 三种情况\n * 1. 调用 nextTick 时,pendingUpdate 已经从 true 变为 false(即已更新完成),那么需要光等 100ms\n * 2. 调用 nextTick 时,pendingUpdate 为 true,那么刚好可以搭上便车\n * 3. 调用 nextTick 时,pendingUpdate 还是 false,框架仍未启动更新逻辑,这时最多轮询 100ms,等待 pendingUpdate 变为 true。\n */\n function next () {\n const pageElement: TaroRootElement | null = env.document.getElementById<TaroRootElement>(path)\n if (pageElement?.pendingUpdate) {\n if (process.env.TARO_PLATFORM ===
|
|
1
|
+
{"version":3,"file":"next-tick.js","sources":["../src/next-tick.ts"],"sourcesContent":["import { PLATFORM_TYPE } from '@tarojs/shared'\n\nimport { Current } from './current'\nimport { TaroRootElement } from './dom/root'\nimport env from './env'\n\nimport type { TFunc } from './interface'\n\nconst TIMEOUT = 100\n\nexport const nextTick = (cb: TFunc, ctx?: Record<string, any>) => {\n const beginTime = Date.now()\n const router = Current.router\n\n const timerFunc = () => {\n setTimeout(function () {\n ctx ? cb.call(ctx) : cb()\n }, 1)\n }\n\n if (router === null) return timerFunc()\n\n const path = router.$taroPath\n\n /**\n * 三种情况\n * 1. 调用 nextTick 时,pendingUpdate 已经从 true 变为 false(即已更新完成),那么需要光等 100ms\n * 2. 调用 nextTick 时,pendingUpdate 为 true,那么刚好可以搭上便车\n * 3. 调用 nextTick 时,pendingUpdate 还是 false,框架仍未启动更新逻辑,这时最多轮询 100ms,等待 pendingUpdate 变为 true。\n */\n function next () {\n const pageElement: TaroRootElement | null = env.document.getElementById<TaroRootElement>(path)\n if (pageElement?.pendingUpdate) {\n if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB) {\n // eslint-disable-next-line dot-notation\n pageElement.firstChild?.['componentOnReady']?.().then(() => {\n timerFunc()\n }) ?? timerFunc()\n } else {\n pageElement.enqueueUpdateCallback(cb, ctx)\n }\n } else if (Date.now() - beginTime > TIMEOUT) {\n timerFunc()\n } else {\n setTimeout(() => next(), 20)\n }\n }\n\n next()\n}\n"],"names":[],"mappings":";;;;AAQA,MAAM,OAAO,GAAG,GAAG,CAAA;MAEN,QAAQ,GAAG,CAAC,EAAS,EAAE,GAAyB,KAAI;AAC/D,IAAA,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;AAC5B,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;IAE7B,MAAM,SAAS,GAAG,MAAK;AACrB,QAAA,UAAU,CAAC,YAAA;AACT,YAAA,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAA;SAC1B,EAAE,CAAC,CAAC,CAAA;AACP,KAAC,CAAA;IAED,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,SAAS,EAAE,CAAA;AAEvC,IAAA,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAA;AAE7B;;;;;AAKG;AACH,IAAA,SAAS,IAAI,GAAA;;QACX,MAAM,WAAW,GAA2B,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAkB,IAAI,CAAC,CAAA;QAC9F,IAAI,WAAW,aAAX,WAAW,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAX,WAAW,CAAE,aAAa,EAAE;YAC9B,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,aAAa,CAAC,GAAG,EAAE;;AAEnD,gBAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,WAAW,CAAC,UAAU,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAG,kBAAkB,CAAC,MAAK,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,EAAA,CAAA,CAAA,IAAI,CAAC,MAAK;AACzD,oBAAA,SAAS,EAAE,CAAA;AACb,iBAAC,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,SAAS,EAAE,CAAA;aAClB;iBAAM;AACL,gBAAA,WAAW,CAAC,qBAAqB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAA;aAC3C;SACF;aAAM,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,OAAO,EAAE;AAC3C,YAAA,SAAS,EAAE,CAAA;SACZ;aAAM;YACL,UAAU,CAAC,MAAM,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;SAC7B;KACF;AAED,IAAA,IAAI,EAAE,CAAA;AACR;;;;"}
|
package/dist/polyfill/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isObject } from '@tarojs/shared';
|
|
1
|
+
import { PLATFORM_TYPE, isObject } from '@tarojs/shared';
|
|
2
2
|
import { handleArrayFindPolyfill, handleArrayIncludesPolyfill } from './array.js';
|
|
3
3
|
import { handleIntersectionObserverPolyfill } from './intersection-observer.js';
|
|
4
4
|
import { handleObjectAssignPolyfill, handleObjectEntriesPolyfill, handleObjectDefinePropertyPolyfill } from './object.js';
|
|
@@ -20,13 +20,13 @@ function handlePolyfill() {
|
|
|
20
20
|
handleArrayIncludesPolyfill();
|
|
21
21
|
}
|
|
22
22
|
// Exit early if we're not running in a browser.
|
|
23
|
-
if (process.env.TARO_PLATFORM ===
|
|
23
|
+
if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB && isObject(window)) {
|
|
24
24
|
if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'IntersectionObserver') {
|
|
25
25
|
handleIntersectionObserverPolyfill();
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFORM !==
|
|
29
|
+
if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) {
|
|
30
30
|
handlePolyfill();
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/polyfill/index.ts"],"sourcesContent":["import { isObject } from '@tarojs/shared'\n\nimport { handleArrayFindPolyfill, handleArrayIncludesPolyfill } from './array'\nimport { handleIntersectionObserverPolyfill } from './intersection-observer'\nimport { handleObjectAssignPolyfill, handleObjectDefinePropertyPolyfill, handleObjectEntriesPolyfill } from './object'\n\nfunction handlePolyfill () {\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.assign') {\n handleObjectAssignPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.entries') {\n handleObjectEntriesPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.defineProperty') {\n handleObjectDefinePropertyPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.find') {\n handleArrayFindPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.includes') {\n handleArrayIncludesPolyfill()\n }\n // Exit early if we're not running in a browser.\n if (process.env.TARO_PLATFORM ===
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/polyfill/index.ts"],"sourcesContent":["import { isObject, PLATFORM_TYPE } from '@tarojs/shared'\n\nimport { handleArrayFindPolyfill, handleArrayIncludesPolyfill } from './array'\nimport { handleIntersectionObserverPolyfill } from './intersection-observer'\nimport { handleObjectAssignPolyfill, handleObjectDefinePropertyPolyfill, handleObjectEntriesPolyfill } from './object'\n\nfunction handlePolyfill () {\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.assign') {\n handleObjectAssignPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.entries') {\n handleObjectEntriesPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.defineProperty') {\n handleObjectDefinePropertyPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.find') {\n handleArrayFindPolyfill()\n }\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.includes') {\n handleArrayIncludesPolyfill()\n }\n // Exit early if we're not running in a browser.\n if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB && isObject(window)) {\n if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'IntersectionObserver') {\n handleIntersectionObserverPolyfill()\n }\n }\n}\n\nif (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) {\n handlePolyfill()\n}\n\nexport { handlePolyfill }\n\n"],"names":[],"mappings":";;;;;AAMA,SAAS,cAAc,GAAA;IACrB,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,eAAe,EAAE;AAC9J,QAAA,0BAA0B,EAAE,CAAA;KAC7B;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,gBAAgB,EAAE;AAC/J,QAAA,2BAA2B,EAAE,CAAA;KAC9B;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,uBAAuB,EAAE;AACtK,QAAA,kCAAkC,EAAE,CAAA;KACrC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,YAAY,EAAE;AAC1J,QAAA,uBAAuB,EAAE,CAAA;KAC1B;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,gBAAgB,EAAE;AAC9J,QAAA,2BAA2B,EAAE,CAAA;KAC9B;;AAED,IAAA,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,aAAa,CAAC,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE;AACvE,QAAA,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,sBAAsB,EAAE;AACnH,YAAA,kCAAkC,EAAE,CAAA;SACrC;KACF;AACH,CAAC;AAED,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,aAAa,CAAC,GAAG,EAAE;AACvG,IAAA,cAAc,EAAE,CAAA;AAClB;;;;"}
|
package/dist/runtime.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { noop, hooks, Events, EMPTY_OBJ, isNumber, isString, isArray, isUndefined, warn, isFunction, getComponentsAlias as getComponentsAlias$1, internalComponents, toCamelCase, isObject, ensure, isNull, toDashed, controlledComponent, EventChannel } from '@tarojs/shared';
|
|
1
|
+
import { noop, hooks, Events, PLATFORM_TYPE, EMPTY_OBJ, isNumber, isString, isArray, isUndefined, warn, isFunction, getComponentsAlias as getComponentsAlias$1, internalComponents, toCamelCase, isObject, ensure, isNull, toDashed, controlledComponent, EventChannel } from '@tarojs/shared';
|
|
2
2
|
export { Events, hooks } from '@tarojs/shared';
|
|
3
3
|
import { __classPrivateFieldSet, __classPrivateFieldGet } from 'tslib';
|
|
4
4
|
|
|
@@ -232,12 +232,12 @@ function debounce(fn, ms = 250, scope) {
|
|
|
232
232
|
const eventCenter = hooks.call('getEventCenter', Events);
|
|
233
233
|
|
|
234
234
|
const env = {
|
|
235
|
-
window: process.env.TARO_PLATFORM ===
|
|
236
|
-
document: process.env.TARO_PLATFORM ===
|
|
235
|
+
window: process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? window : EMPTY_OBJ,
|
|
236
|
+
document: process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? document : EMPTY_OBJ
|
|
237
237
|
};
|
|
238
238
|
|
|
239
239
|
// Note: 小程序端 vite 打包成 commonjs,const getComputedStyle = xxx 会报错,所以把 GetComputedStyle 改为 taroGetComputedStyleProvider
|
|
240
|
-
const taroGetComputedStyleProvider = process.env.TARO_PLATFORM ===
|
|
240
|
+
const taroGetComputedStyleProvider = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window.getComputedStyle : function (element) {
|
|
241
241
|
return element.style;
|
|
242
242
|
};
|
|
243
243
|
|
|
@@ -376,7 +376,7 @@ _TaroHistory_location = new WeakMap(), _TaroHistory_stack = new WeakMap(), _Taro
|
|
|
376
376
|
], "f");
|
|
377
377
|
__classPrivateFieldSet(this, _TaroHistory_cur, 0, "f");
|
|
378
378
|
};
|
|
379
|
-
const History = process.env.TARO_PLATFORM ===
|
|
379
|
+
const History = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window.History : TaroHistory;
|
|
380
380
|
|
|
381
381
|
const Current = {
|
|
382
382
|
app: null,
|
|
@@ -416,7 +416,7 @@ function decode(str) {
|
|
|
416
416
|
function encode(str) {
|
|
417
417
|
return encodeURIComponent(str).replace(findReg, replacer);
|
|
418
418
|
}
|
|
419
|
-
const URLSearchParams = process.env.TARO_PLATFORM ===
|
|
419
|
+
const URLSearchParams = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window.URLSearchParams : (_a = class {
|
|
420
420
|
constructor(query) {
|
|
421
421
|
_dict.set(this, Object.create(null));
|
|
422
422
|
query !== null && query !== void 0 ? query : (query = '');
|
|
@@ -660,7 +660,7 @@ class TaroURL {
|
|
|
660
660
|
}
|
|
661
661
|
_TaroURL_hash = new WeakMap(), _TaroURL_hostname = new WeakMap(), _TaroURL_pathname = new WeakMap(), _TaroURL_port = new WeakMap(), _TaroURL_protocol = new WeakMap(), _TaroURL_search = new WeakMap();
|
|
662
662
|
// Note: 小程序端 vite 打包成 commonjs,const URL = xxx 会报错,所以把 URL 改为 TaroURLProvider
|
|
663
|
-
const TaroURLProvider = process.env.TARO_PLATFORM ===
|
|
663
|
+
const TaroURLProvider = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window.URL : TaroURL;
|
|
664
664
|
function parseUrl(url = '') {
|
|
665
665
|
const result = {
|
|
666
666
|
href: '',
|
|
@@ -945,7 +945,7 @@ _TaroLocation_url = new WeakMap(), _TaroLocation_noCheckUrl = new WeakMap(), _Ta
|
|
|
945
945
|
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_rollBack).call(this, preValue.href);
|
|
946
946
|
return false;
|
|
947
947
|
};
|
|
948
|
-
const Location = process.env.TARO_PLATFORM ===
|
|
948
|
+
const Location = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window.Location : TaroLocation;
|
|
949
949
|
function generateFullUrl(val = '') {
|
|
950
950
|
const origin = INIT_URL;
|
|
951
951
|
if (/^[/?#]/.test(val)) {
|
|
@@ -958,7 +958,7 @@ const machine = 'Macintosh';
|
|
|
958
958
|
const arch = 'Intel Mac OS X 10_14_5';
|
|
959
959
|
const engine = 'AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0.3809.132 Safari/534.36';
|
|
960
960
|
const msg = '(' + machine + '; ' + arch + ') ' + engine;
|
|
961
|
-
const nav = process.env.TARO_PLATFORM ===
|
|
961
|
+
const nav = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window.navigator : {
|
|
962
962
|
appCodeName: 'Mozilla',
|
|
963
963
|
appName: 'Netscape',
|
|
964
964
|
appVersion: '5.0 ' + msg,
|
|
@@ -993,12 +993,12 @@ let now;
|
|
|
993
993
|
let lastTime = 0;
|
|
994
994
|
// https://gist.github.com/paulirish/1579671
|
|
995
995
|
// https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0
|
|
996
|
-
const _raf = process.env.TARO_PLATFORM ===
|
|
996
|
+
const _raf = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? requestAnimationFrame : function (callback) {
|
|
997
997
|
const _now = now();
|
|
998
998
|
const nextTime = Math.max(lastTime + 16, _now); // First time will execute it immediately but barely noticeable and performance is gained.
|
|
999
999
|
return setTimeout(function () { callback(lastTime = nextTime); }, nextTime - _now);
|
|
1000
1000
|
};
|
|
1001
|
-
const _caf = process.env.TARO_PLATFORM ===
|
|
1001
|
+
const _caf = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB
|
|
1002
1002
|
? cancelAnimationFrame
|
|
1003
1003
|
: function (seed) {
|
|
1004
1004
|
// fix https://github.com/NervJS/taro/issues/7749
|
|
@@ -1082,7 +1082,7 @@ class TaroWindow extends Events {
|
|
|
1082
1082
|
}
|
|
1083
1083
|
}
|
|
1084
1084
|
// Note: 小程序端 vite 打包成 commonjs,const window = xxx 会报错,所以把 window 改为 taroWindowProvider,location 和 history 同理
|
|
1085
|
-
const taroWindowProvider = process.env.TARO_PLATFORM ===
|
|
1085
|
+
const taroWindowProvider = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.window : (env.window = new TaroWindow());
|
|
1086
1086
|
const taroLocationProvider = taroWindowProvider.location;
|
|
1087
1087
|
const taroHistoryProvider = taroWindowProvider.history;
|
|
1088
1088
|
|
|
@@ -3320,7 +3320,7 @@ function contains(node) {
|
|
|
3320
3320
|
return isContains;
|
|
3321
3321
|
}
|
|
3322
3322
|
|
|
3323
|
-
if (process.env.TARO_PLATFORM !==
|
|
3323
|
+
if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB && process.env.TARO_PLATFORM !== PLATFORM_TYPE.HARMONY) {
|
|
3324
3324
|
if (ENABLE_INNER_HTML) {
|
|
3325
3325
|
TaroNode.extend('innerHTML', {
|
|
3326
3326
|
set(html) {
|
|
@@ -3924,7 +3924,7 @@ function createDocument() {
|
|
|
3924
3924
|
return doc;
|
|
3925
3925
|
}
|
|
3926
3926
|
// Note: 小程序端 vite 打包成 commonjs,const document = xxx 会报错,所以把 document 改为 taroDocumentProvider
|
|
3927
|
-
const taroDocumentProvider = process.env.TARO_PLATFORM ===
|
|
3927
|
+
const taroDocumentProvider = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? env.document : (env.document = createDocument());
|
|
3928
3928
|
|
|
3929
3929
|
// for Vue3
|
|
3930
3930
|
class SVGElement extends TaroElement {
|
|
@@ -3969,7 +3969,7 @@ function stringify(obj) {
|
|
|
3969
3969
|
}
|
|
3970
3970
|
function getPath(id, options) {
|
|
3971
3971
|
const idx = id.indexOf('?');
|
|
3972
|
-
if (process.env.TARO_PLATFORM ===
|
|
3972
|
+
if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB) {
|
|
3973
3973
|
return `${idx > -1 ? id.substring(0, idx) : id}${stringify((options === null || options === void 0 ? void 0 : options.stamp) ? { stamp: options.stamp } : {})}`;
|
|
3974
3974
|
}
|
|
3975
3975
|
else {
|
|
@@ -3993,7 +3993,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3993
3993
|
let unmounting = false;
|
|
3994
3994
|
let prepareMountList = [];
|
|
3995
3995
|
function setCurrentRouter(page) {
|
|
3996
|
-
const router = process.env.TARO_PLATFORM ===
|
|
3996
|
+
const router = process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB ? page.$taroPath : page.route || page.__route__ || page.$taroPath;
|
|
3997
3997
|
Current.router = {
|
|
3998
3998
|
params: page.$taroParams,
|
|
3999
3999
|
path: addLeadingSlash(router),
|
|
@@ -4017,7 +4017,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4017
4017
|
// this.$taroPath 是页面唯一标识
|
|
4018
4018
|
const uniqueOptions = Object.assign({}, options, { $taroTimestamp: Date.now() });
|
|
4019
4019
|
const $taroPath = this.$taroPath = getPath(id, uniqueOptions);
|
|
4020
|
-
if (process.env.TARO_PLATFORM ===
|
|
4020
|
+
if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB) {
|
|
4021
4021
|
config.path = $taroPath;
|
|
4022
4022
|
}
|
|
4023
4023
|
// this.$taroParams 作为暴露给开发者的页面参数对象,可以被随意修改
|
|
@@ -4026,7 +4026,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4026
4026
|
}
|
|
4027
4027
|
setCurrentRouter(this);
|
|
4028
4028
|
// 初始化当前页面的上下文信息
|
|
4029
|
-
if (process.env.TARO_PLATFORM !==
|
|
4029
|
+
if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) {
|
|
4030
4030
|
taroWindowProvider.trigger(CONTEXT_ACTIONS.INIT, $taroPath);
|
|
4031
4031
|
}
|
|
4032
4032
|
const mount = () => {
|
|
@@ -4035,7 +4035,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4035
4035
|
ensure(pageElement !== null, '没有找到页面实例。');
|
|
4036
4036
|
safeExecute($taroPath, ON_LOAD, this.$taroParams);
|
|
4037
4037
|
loadResolver();
|
|
4038
|
-
if (process.env.TARO_PLATFORM !==
|
|
4038
|
+
if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) {
|
|
4039
4039
|
pageElement.ctx = this;
|
|
4040
4040
|
pageElement.performUpdate(true, cb);
|
|
4041
4041
|
}
|
|
@@ -4054,7 +4054,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4054
4054
|
[ONUNLOAD]() {
|
|
4055
4055
|
const $taroPath = this.$taroPath;
|
|
4056
4056
|
// 销毁当前页面的上下文信息
|
|
4057
|
-
if (process.env.TARO_PLATFORM !==
|
|
4057
|
+
if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) {
|
|
4058
4058
|
taroWindowProvider.trigger(CONTEXT_ACTIONS.DESTORY, $taroPath);
|
|
4059
4059
|
}
|
|
4060
4060
|
// 触发onUnload生命周期
|
|
@@ -4088,7 +4088,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4088
4088
|
Current.page = this;
|
|
4089
4089
|
setCurrentRouter(this);
|
|
4090
4090
|
// 恢复上下文信息
|
|
4091
|
-
if (process.env.TARO_PLATFORM !==
|
|
4091
|
+
if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) {
|
|
4092
4092
|
taroWindowProvider.trigger(CONTEXT_ACTIONS.RECOVER, this.$taroPath);
|
|
4093
4093
|
}
|
|
4094
4094
|
// 触发生命周期
|
|
@@ -4099,7 +4099,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4099
4099
|
},
|
|
4100
4100
|
[ONHIDE]() {
|
|
4101
4101
|
// 缓存当前页面上下文信息
|
|
4102
|
-
if (process.env.TARO_PLATFORM !==
|
|
4102
|
+
if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) {
|
|
4103
4103
|
taroWindowProvider.trigger(CONTEXT_ACTIONS.RESTORE, this.$taroPath);
|
|
4104
4104
|
}
|
|
4105
4105
|
// 设置 Current 的 page 和 router
|
|
@@ -4113,7 +4113,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4113
4113
|
eventCenter.trigger(getOnHideEventKey(id));
|
|
4114
4114
|
}
|
|
4115
4115
|
};
|
|
4116
|
-
if (process.env.TARO_PLATFORM ===
|
|
4116
|
+
if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB) {
|
|
4117
4117
|
config.getOpenerEventChannel = () => {
|
|
4118
4118
|
return EventChannel.pageChannel;
|
|
4119
4119
|
};
|
|
@@ -4177,7 +4177,7 @@ function createComponentConfig(component, componentName, data) {
|
|
|
4177
4177
|
ensure(componentElement !== null, '没有找到组件实例。');
|
|
4178
4178
|
this.$taroInstances = instances.get(path);
|
|
4179
4179
|
safeExecute(path, ON_LOAD);
|
|
4180
|
-
if (process.env.TARO_PLATFORM !==
|
|
4180
|
+
if (process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) {
|
|
4181
4181
|
componentElement.ctx = this;
|
|
4182
4182
|
componentElement.performUpdate(true);
|
|
4183
4183
|
}
|
|
@@ -4275,7 +4275,7 @@ const nextTick = (cb, ctx) => {
|
|
|
4275
4275
|
var _a, _b, _c;
|
|
4276
4276
|
const pageElement = env.document.getElementById(path);
|
|
4277
4277
|
if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) {
|
|
4278
|
-
if (process.env.TARO_PLATFORM ===
|
|
4278
|
+
if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB) {
|
|
4279
4279
|
// eslint-disable-next-line dot-notation
|
|
4280
4280
|
(_c = (_b = (_a = pageElement.firstChild) === null || _a === void 0 ? void 0 : _a['componentOnReady']) === null || _b === void 0 ? void 0 : _b.call(_a).then(() => {
|
|
4281
4281
|
timerFunc();
|
|
@@ -5055,13 +5055,13 @@ function handlePolyfill() {
|
|
|
5055
5055
|
handleArrayIncludesPolyfill();
|
|
5056
5056
|
}
|
|
5057
5057
|
// Exit early if we're not running in a browser.
|
|
5058
|
-
if (process.env.TARO_PLATFORM ===
|
|
5058
|
+
if (process.env.TARO_PLATFORM === PLATFORM_TYPE.WEB && isObject(window)) {
|
|
5059
5059
|
if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'IntersectionObserver') {
|
|
5060
5060
|
handleIntersectionObserverPolyfill();
|
|
5061
5061
|
}
|
|
5062
5062
|
}
|
|
5063
5063
|
}
|
|
5064
|
-
if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFORM !==
|
|
5064
|
+
if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFORM !== PLATFORM_TYPE.WEB) {
|
|
5065
5065
|
handlePolyfill();
|
|
5066
5066
|
}
|
|
5067
5067
|
|