@tarojs/runtime 4.0.0 → 4.0.1-alpha.0
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.d.ts +2 -2
- package/dist/bom/URL.js +3 -2
- package/dist/bom/URL.js.map +1 -1
- package/dist/bom/document.d.ts +2 -2
- package/dist/bom/document.js +3 -2
- package/dist/bom/document.js.map +1 -1
- package/dist/bom/getComputedStyle.d.ts +2 -2
- package/dist/bom/getComputedStyle.js +3 -2
- package/dist/bom/getComputedStyle.js.map +1 -1
- package/dist/bom/location.js +3 -3
- package/dist/bom/location.js.map +1 -1
- package/dist/bom/window.d.ts +4 -4
- package/dist/bom/window.js +7 -6
- package/dist/bom/window.js.map +1 -1
- package/dist/dsl/common.js +5 -5
- package/dist/dsl/common.js.map +1 -1
- package/dist/index.cjs.d.ts +11 -7
- package/dist/index.cjs.js +25 -21
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/runtime.esm.d.ts +11 -7
- package/dist/runtime.esm.js +20 -16
- package/dist/runtime.esm.js.map +1 -1
- package/dist/utils/router.js +3 -3
- package/dist/utils/router.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -237,7 +237,8 @@ const env = {
|
|
|
237
237
|
document: process.env.TARO_PLATFORM === 'web' ? document : shared.EMPTY_OBJ
|
|
238
238
|
};
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
// Note: 小程序端 vite 打包成 commonjs,const getComputedStyle = xxx 会报错,所以把 GetComputedStyle 改为 taroGetComputedStyleProvider
|
|
241
|
+
const taroGetComputedStyleProvider = process.env.TARO_PLATFORM === 'web' ? env.window.getComputedStyle : function (element) {
|
|
241
242
|
return element.style;
|
|
242
243
|
};
|
|
243
244
|
|
|
@@ -659,7 +660,8 @@ class TaroURL {
|
|
|
659
660
|
}
|
|
660
661
|
}
|
|
661
662
|
_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
|
-
const URL =
|
|
663
|
+
// Note: 小程序端 vite 打包成 commonjs,const URL = xxx 会报错,所以把 URL 改为 TaroURLProvider
|
|
664
|
+
const TaroURLProvider = process.env.TARO_PLATFORM === 'web' ? env.window.URL : TaroURL;
|
|
663
665
|
function parseUrl(url = '') {
|
|
664
666
|
const result = {
|
|
665
667
|
href: '',
|
|
@@ -732,7 +734,7 @@ class TaroLocation extends shared.Events {
|
|
|
732
734
|
super();
|
|
733
735
|
_TaroLocation_instances.add(this);
|
|
734
736
|
/* private property */
|
|
735
|
-
_TaroLocation_url.set(this, new
|
|
737
|
+
_TaroLocation_url.set(this, new TaroURLProvider(INIT_URL));
|
|
736
738
|
_TaroLocation_noCheckUrl.set(this, false);
|
|
737
739
|
_TaroLocation_window.set(this, void 0);
|
|
738
740
|
tslib.__classPrivateFieldSet(this, _TaroLocation_window, options.window, "f");
|
|
@@ -909,7 +911,7 @@ _TaroLocation_url = new WeakMap(), _TaroLocation_noCheckUrl = new WeakMap(), _Ta
|
|
|
909
911
|
});
|
|
910
912
|
const searchStr = searchArr.length > 0 ? '?' + searchArr.join('&') : '';
|
|
911
913
|
const url = `${INIT_URL}${path.startsWith('/') ? path : '/' + path}${searchStr}`;
|
|
912
|
-
tslib.__classPrivateFieldSet(this, _TaroLocation_url, new
|
|
914
|
+
tslib.__classPrivateFieldSet(this, _TaroLocation_url, new TaroURLProvider(url), "f");
|
|
913
915
|
this.trigger('__reset_history__', this.href);
|
|
914
916
|
}
|
|
915
917
|
}, _TaroLocation_getPreValue = function _TaroLocation_getPreValue() {
|
|
@@ -1010,7 +1012,7 @@ class TaroWindow extends shared.Events {
|
|
|
1010
1012
|
this.navigator = nav;
|
|
1011
1013
|
this.requestAnimationFrame = _raf;
|
|
1012
1014
|
this.cancelAnimationFrame = _caf;
|
|
1013
|
-
this.getComputedStyle =
|
|
1015
|
+
this.getComputedStyle = taroGetComputedStyleProvider;
|
|
1014
1016
|
const globalProperties = [
|
|
1015
1017
|
...Object.getOwnPropertyNames(global || {}),
|
|
1016
1018
|
...Object.getOwnPropertySymbols(global || {})
|
|
@@ -1080,9 +1082,10 @@ class TaroWindow extends shared.Events {
|
|
|
1080
1082
|
return clearTimeout(...args);
|
|
1081
1083
|
}
|
|
1082
1084
|
}
|
|
1083
|
-
const window
|
|
1084
|
-
const
|
|
1085
|
-
const
|
|
1085
|
+
// Note: 小程序端 vite 打包成 commonjs,const window = xxx 会报错,所以把 window 改为 taroWindowProvider,location 和 history 同理
|
|
1086
|
+
const taroWindowProvider = process.env.TARO_PLATFORM === 'web' ? env.window : (env.window = new TaroWindow());
|
|
1087
|
+
const taroLocationProvider = taroWindowProvider.location;
|
|
1088
|
+
const taroHistoryProvider = taroWindowProvider.history;
|
|
1086
1089
|
|
|
1087
1090
|
// export const removeLeadingSlash = (str = '') => str.replace(/^\.?\//, '')
|
|
1088
1091
|
// export const removeTrailingSearch = (str = '') => str.replace(/\?[\s\S]*$/, '')
|
|
@@ -1099,8 +1102,8 @@ const getHomePage = (path = '', basename = '', customRoutes = {}, entryPagePath
|
|
|
1099
1102
|
};
|
|
1100
1103
|
const getCurrentPage = (routerMode = 'hash', basename = '/') => {
|
|
1101
1104
|
const pagePath = routerMode === 'hash'
|
|
1102
|
-
?
|
|
1103
|
-
:
|
|
1105
|
+
? taroLocationProvider.hash.slice(1).split('?')[0]
|
|
1106
|
+
: taroLocationProvider.pathname;
|
|
1104
1107
|
return addLeadingSlash(stripBasename(pagePath, basename));
|
|
1105
1108
|
};
|
|
1106
1109
|
|
|
@@ -3921,7 +3924,8 @@ function createDocument() {
|
|
|
3921
3924
|
doc.body = body;
|
|
3922
3925
|
return doc;
|
|
3923
3926
|
}
|
|
3924
|
-
|
|
3927
|
+
// Note: 小程序端 vite 打包成 commonjs,const document = xxx 会报错,所以把 document 改为 taroDocumentProvider
|
|
3928
|
+
const taroDocumentProvider = process.env.TARO_PLATFORM === 'web' ? env.document : (env.document = createDocument());
|
|
3925
3929
|
|
|
3926
3930
|
// for Vue3
|
|
3927
3931
|
class SVGElement extends TaroElement {
|
|
@@ -4024,7 +4028,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4024
4028
|
setCurrentRouter(this);
|
|
4025
4029
|
// 初始化当前页面的上下文信息
|
|
4026
4030
|
if (process.env.TARO_PLATFORM !== 'web') {
|
|
4027
|
-
|
|
4031
|
+
taroWindowProvider.trigger(exports.CONTEXT_ACTIONS.INIT, $taroPath);
|
|
4028
4032
|
}
|
|
4029
4033
|
const mount = () => {
|
|
4030
4034
|
Current.app.mount(component, $taroPath, () => {
|
|
@@ -4052,7 +4056,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4052
4056
|
const $taroPath = this.$taroPath;
|
|
4053
4057
|
// 销毁当前页面的上下文信息
|
|
4054
4058
|
if (process.env.TARO_PLATFORM !== 'web') {
|
|
4055
|
-
|
|
4059
|
+
taroWindowProvider.trigger(exports.CONTEXT_ACTIONS.DESTORY, $taroPath);
|
|
4056
4060
|
}
|
|
4057
4061
|
// 触发onUnload生命周期
|
|
4058
4062
|
safeExecute($taroPath, ONUNLOAD);
|
|
@@ -4086,7 +4090,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4086
4090
|
setCurrentRouter(this);
|
|
4087
4091
|
// 恢复上下文信息
|
|
4088
4092
|
if (process.env.TARO_PLATFORM !== 'web') {
|
|
4089
|
-
|
|
4093
|
+
taroWindowProvider.trigger(exports.CONTEXT_ACTIONS.RECOVER, this.$taroPath);
|
|
4090
4094
|
}
|
|
4091
4095
|
// 触发生命周期
|
|
4092
4096
|
safeExecute(this.$taroPath, ON_SHOW, options);
|
|
@@ -4097,7 +4101,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4097
4101
|
[ONHIDE]() {
|
|
4098
4102
|
// 缓存当前页面上下文信息
|
|
4099
4103
|
if (process.env.TARO_PLATFORM !== 'web') {
|
|
4100
|
-
|
|
4104
|
+
taroWindowProvider.trigger(exports.CONTEXT_ACTIONS.RESTORE, this.$taroPath);
|
|
4101
4105
|
}
|
|
4102
4106
|
// 设置 Current 的 page 和 router
|
|
4103
4107
|
if (Current.page === this) {
|
|
@@ -5130,7 +5134,7 @@ exports.TaroNode = TaroNode;
|
|
|
5130
5134
|
exports.TaroRootElement = TaroRootElement;
|
|
5131
5135
|
exports.TaroText = TaroText;
|
|
5132
5136
|
exports.UID = UID;
|
|
5133
|
-
exports.URL =
|
|
5137
|
+
exports.URL = TaroURLProvider;
|
|
5134
5138
|
exports.URLSearchParams = URLSearchParams;
|
|
5135
5139
|
exports.VALUE = VALUE;
|
|
5136
5140
|
exports.VIEW = VIEW;
|
|
@@ -5143,14 +5147,14 @@ exports.createPageConfig = createPageConfig;
|
|
|
5143
5147
|
exports.createRecursiveComponentConfig = createRecursiveComponentConfig;
|
|
5144
5148
|
exports.customWrapperCache = customWrapperCache;
|
|
5145
5149
|
exports.debounce = debounce;
|
|
5146
|
-
exports.document =
|
|
5150
|
+
exports.document = taroDocumentProvider;
|
|
5147
5151
|
exports.env = env;
|
|
5148
5152
|
exports.eventCenter = eventCenter;
|
|
5149
5153
|
exports.eventHandler = eventHandler;
|
|
5150
5154
|
exports.eventSource = eventSource;
|
|
5151
5155
|
exports.extend = extend;
|
|
5152
5156
|
exports.getComponentsAlias = getComponentsAlias;
|
|
5153
|
-
exports.getComputedStyle =
|
|
5157
|
+
exports.getComputedStyle = taroGetComputedStyleProvider;
|
|
5154
5158
|
exports.getCurrentInstance = getCurrentInstance;
|
|
5155
5159
|
exports.getCurrentPage = getCurrentPage;
|
|
5156
5160
|
exports.getHomePage = getHomePage;
|
|
@@ -5161,7 +5165,7 @@ exports.getPageInstance = getPageInstance;
|
|
|
5161
5165
|
exports.getPath = getPath;
|
|
5162
5166
|
exports.handlePolyfill = handlePolyfill;
|
|
5163
5167
|
exports.hasBasename = hasBasename;
|
|
5164
|
-
exports.history =
|
|
5168
|
+
exports.history = taroHistoryProvider;
|
|
5165
5169
|
exports.hydrate = hydrate;
|
|
5166
5170
|
exports.incrementId = incrementId;
|
|
5167
5171
|
exports.injectPageInstance = injectPageInstance;
|
|
@@ -5170,7 +5174,7 @@ exports.isElement = isElement;
|
|
|
5170
5174
|
exports.isHasExtractProp = isHasExtractProp;
|
|
5171
5175
|
exports.isParentBinded = isParentBinded;
|
|
5172
5176
|
exports.isText = isText;
|
|
5173
|
-
exports.location =
|
|
5177
|
+
exports.location = taroLocationProvider;
|
|
5174
5178
|
exports.navigator = nav;
|
|
5175
5179
|
exports.nextTick = nextTick;
|
|
5176
5180
|
exports.options = options;
|
|
@@ -5185,5 +5189,5 @@ exports.stripBasename = stripBasename;
|
|
|
5185
5189
|
exports.stripSuffix = stripSuffix;
|
|
5186
5190
|
exports.stripTrailing = stripTrailing;
|
|
5187
5191
|
exports.throttle = throttle;
|
|
5188
|
-
exports.window =
|
|
5192
|
+
exports.window = taroWindowProvider;
|
|
5189
5193
|
//# sourceMappingURL=index.cjs.js.map
|