@tarojs/runtime 3.3.14 → 3.3.18

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.
@@ -27,7 +27,8 @@ export declare class TaroElement extends TaroNode {
27
27
  set textContent(text: string);
28
28
  hasAttribute(qualifiedName: string): boolean;
29
29
  hasAttributes(): boolean;
30
- focus(): void;
30
+ get focus(): () => void;
31
+ set focus(value: () => void);
31
32
  blur(): void;
32
33
  setAttribute(qualifiedName: string, value: any): void;
33
34
  removeAttribute(qualifiedName: string): void;
@@ -5,7 +5,7 @@ import type { AppInstance, ReactPageComponent, PageProps } from './instance';
5
5
  export declare let R: typeof React;
6
6
  export declare let PageContext: React.Context<string>;
7
7
  export declare function connectReactPage(R: typeof React, id: string): (component: ReactPageComponent) => React.ComponentClass<PageProps>;
8
- export declare function createReactApp(App: React.ComponentClass, react: typeof React, reactdom: any, config: AppConfig): AppInstance;
8
+ export declare function createReactApp(App: React.ComponentClass, react: typeof React, dom: any, config: AppConfig): AppInstance;
9
9
  export declare function createNativeComponentConfig(Component: any, react: typeof React, reactdom: any, componentConfig: any): {
10
10
  properties: {
11
11
  props: {
@@ -1234,7 +1234,6 @@ const TIME_STAMP = 'timeStamp';
1234
1234
  const KEY_CODE = 'keyCode';
1235
1235
  const TOUCHMOVE = 'touchmove';
1236
1236
  const DATE = 'Date';
1237
- const SET_TIMEOUT = 'setTimeout';
1238
1237
  const CATCHMOVE = 'catchMove';
1239
1238
  const CATCH_VIEW = 'catch-view';
1240
1239
  const COMMENT = 'comment';
@@ -2103,8 +2102,14 @@ let TaroElement = class TaroElement extends TaroNode {
2103
2102
  hasAttributes() {
2104
2103
  return this.attributes.length > 0;
2105
2104
  }
2106
- focus() {
2107
- this.setAttribute(FOCUS, true);
2105
+ get focus() {
2106
+ return function () {
2107
+ this.setAttribute(FOCUS, true);
2108
+ };
2109
+ }
2110
+ // 兼容 Vue3,详情请见:https://github.com/NervJS/taro/issues/10579
2111
+ set focus(value) {
2112
+ this.setAttribute(FOCUS, value);
2108
2113
  }
2109
2114
  blur() {
2110
2115
  this.setAttribute(FOCUS, false);
@@ -2136,7 +2141,7 @@ let TaroElement = class TaroElement extends TaroNode {
2136
2141
  qualifiedName = shortcutAttr(qualifiedName);
2137
2142
  const payload = {
2138
2143
  path: `${this._path}.${toCamelCase(qualifiedName)}`,
2139
- value
2144
+ value: isFunction$1(value) ? () => value : value
2140
2145
  };
2141
2146
  (_b = (_a = this.hooks).modifySetAttrPayload) === null || _b === void 0 ? void 0 : _b.call(_a, this, qualifiedName, payload);
2142
2147
  this.enqueueUpdate(payload);
@@ -3966,8 +3971,12 @@ class StyleTagParser {
3966
3971
  // console.log('res this.styles: ', this.styles)
3967
3972
  }
3968
3973
  parseSelector(src) {
3969
- // todo: 属性选择器里可以带空格:[a = "b"],这里的 split(' ') 需要作兼容
3970
- const list = src.trim().replace(/ *([>~+]) */g, ' $1').replace(/ +/g, ' ').split(' ');
3974
+ const list = src
3975
+ .trim()
3976
+ .replace(/ *([>~+]) */g, ' $1')
3977
+ .replace(/ +/g, ' ')
3978
+ .replace(/\[\s*([^[\]=\s]+)\s*=\s*([^[\]=\s]+)\s*\]/g, '[$1=$2]')
3979
+ .split(' ');
3971
3980
  const selectors = list.map(item => {
3972
3981
  const firstChar = item.charAt(0);
3973
3982
  const selector = {
@@ -5013,9 +5022,12 @@ if (process.env.TARO_ENV && process.env.TARO_ENV !== 'h5') {
5013
5022
  if (!(DATE in window$1)) {
5014
5023
  window$1.Date = Date;
5015
5024
  }
5016
- if (!(SET_TIMEOUT in window$1)) {
5017
- window$1.setTimeout = setTimeout;
5018
- }
5025
+ window$1.setTimeout = function (cb, delay) {
5026
+ setTimeout(cb, delay);
5027
+ };
5028
+ window$1.clearTimeout = function (seed) {
5029
+ clearTimeout(seed);
5030
+ };
5019
5031
  }
5020
5032
 
5021
5033
  const Current = {
@@ -5181,7 +5193,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
5181
5193
  let loadResolver;
5182
5194
  let hasLoaded;
5183
5195
  const config = {
5184
- onLoad(options, cb) {
5196
+ onLoad(options = {}, cb) {
5185
5197
  hasLoaded = new Promise(resolve => { loadResolver = resolve; });
5186
5198
  perf.start(PAGE_INIT);
5187
5199
  Current.page = this;
@@ -5499,9 +5511,10 @@ function setReconciler() {
5499
5511
  }
5500
5512
  }
5501
5513
  const pageKeyId = incrementId();
5502
- function createReactApp(App, react, reactdom, config) {
5514
+ function createReactApp(App, react, dom, config) {
5515
+ var _a;
5503
5516
  R = react;
5504
- ReactDOM = reactdom;
5517
+ ReactDOM = dom;
5505
5518
  ensure(!!ReactDOM, '构建 React/Nerv 项目请把 process.env.FRAMEWORK 设置为 \'react\'/\'nerv\' ');
5506
5519
  const ref = R.createRef();
5507
5520
  const isReactComponent = isClassComponent(R, App);
@@ -5543,8 +5556,7 @@ function createReactApp(App, react, reactdom, config) {
5543
5556
  }
5544
5557
  let wrapper;
5545
5558
  if (!isBrowser) {
5546
- // eslint-disable-next-line react/no-render-return-value
5547
- wrapper = ReactDOM.render(R.createElement(AppWrapper), document$2.getElementById('app'));
5559
+ wrapper = (_a = ReactDOM.render) === null || _a === void 0 ? void 0 : _a.call(ReactDOM, R.createElement(AppWrapper), document$2.getElementById('app'));
5548
5560
  }
5549
5561
  const app = Object.create({
5550
5562
  render(cb) {
@@ -5568,11 +5580,11 @@ function createReactApp(App, react, reactdom, config) {
5568
5580
  enumerable: true,
5569
5581
  writable: true,
5570
5582
  value(options) {
5583
+ var _a;
5571
5584
  Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
5572
5585
  if (isBrowser) {
5573
5586
  // 由于 H5 路由初始化的时候会清除 app 下的 dom 元素,所以需要在路由初始化后执行 render
5574
- // eslint-disable-next-line react/no-render-return-value
5575
- wrapper = ReactDOM.render(R.createElement(AppWrapper), document$2.getElementById('app'));
5587
+ wrapper = (_a = ReactDOM.render) === null || _a === void 0 ? void 0 : _a.call(ReactDOM, R.createElement(AppWrapper), document$2.getElementById((config === null || config === void 0 ? void 0 : config.appId) || 'app'));
5576
5588
  }
5577
5589
  const app = ref.current;
5578
5590
  // For taroize
@@ -5927,7 +5939,7 @@ function createVueApp(App, vue, config) {
5927
5939
  Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
5928
5940
  if (isBrowser) {
5929
5941
  // 由于 H5 路由初始化的时候会清除 app 下的 dom 元素,所以需要在路由初始化后再执行 render
5930
- wrapper.$mount(document$2.getElementById('app'));
5942
+ wrapper.$mount(document$2.getElementById((config === null || config === void 0 ? void 0 : config.appId) || 'app'));
5931
5943
  }
5932
5944
  appInstance = wrapper.$refs.app;
5933
5945
  if (appInstance != null && isFunction$1(appInstance.$options.onLaunch)) {
@@ -5968,10 +5980,6 @@ function createVue3Page(h, id) {
5968
5980
  },
5969
5981
  created() {
5970
5982
  injectPageInstance(this, id);
5971
- // vue3 组件 created 时机比小程序页面 onShow 慢,因此在 created 后再手动触发一次 onShow。
5972
- this.$nextTick(() => {
5973
- safeExecute(id, 'onShow');
5974
- });
5975
5983
  }
5976
5984
  };
5977
5985
  if (isArray$1(component.mixins)) {
@@ -6075,7 +6083,7 @@ function createVue3App(app, h, config) {
6075
6083
  var _a;
6076
6084
  Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
6077
6085
  if (isBrowser) {
6078
- appInstance = app.mount('#app');
6086
+ appInstance = app.mount('#' + config.appId || 'app');
6079
6087
  }
6080
6088
  // 把 App Class 上挂载的额外属性同步到全局 app 对象中
6081
6089
  // eslint-disable-next-line dot-notation