@tarojs/runtime 4.0.8-beta.1 → 4.0.8-beta.3

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.
Files changed (136) hide show
  1. package/dist/bom/URL.d.ts +3 -4
  2. package/dist/bom/URL.js +1 -1
  3. package/dist/bom/URL.js.map +1 -1
  4. package/dist/bom/URLSearchParams.d.ts +1 -0
  5. package/dist/bom/URLSearchParams.js.map +1 -1
  6. package/dist/bom/document.d.ts +3 -1
  7. package/dist/bom/document.js.map +1 -1
  8. package/dist/bom/getComputedStyle.d.ts +6 -3
  9. package/dist/bom/getComputedStyle.js.map +1 -1
  10. package/dist/bom/history.d.ts +8 -6
  11. package/dist/bom/history.js.map +1 -1
  12. package/dist/bom/location.d.ts +6 -5
  13. package/dist/bom/location.js.map +1 -1
  14. package/dist/bom/navigator.d.ts +1 -0
  15. package/dist/bom/navigator.js.map +1 -1
  16. package/dist/bom/raf.d.ts +2 -2
  17. package/dist/bom/raf.js.map +1 -1
  18. package/dist/bom/window.d.ts +11 -8
  19. package/dist/bom/window.js.map +1 -1
  20. package/dist/constants/index.d.ts +2 -1
  21. package/dist/constants/index.js.map +1 -1
  22. package/dist/current.d.ts +5 -2
  23. package/dist/current.js.map +1 -1
  24. package/dist/dom/anchor-element.js.map +1 -1
  25. package/dist/dom/class-list.d.ts +3 -1
  26. package/dist/dom/class-list.js.map +1 -1
  27. package/dist/dom/document.d.ts +7 -8
  28. package/dist/dom/document.js.map +1 -1
  29. package/dist/dom/element.d.ts +8 -5
  30. package/dist/dom/element.js +2 -2
  31. package/dist/dom/element.js.map +1 -1
  32. package/dist/dom/event-source.d.ts +3 -1
  33. package/dist/dom/event-source.js.map +1 -1
  34. package/dist/dom/event-target.d.ts +3 -1
  35. package/dist/dom/event-target.js.map +1 -1
  36. package/dist/dom/event.d.ts +4 -2
  37. package/dist/dom/event.js.map +1 -1
  38. package/dist/dom/form.d.ts +4 -2
  39. package/dist/dom/form.js.map +1 -1
  40. package/dist/dom/node.d.ts +9 -37
  41. package/dist/dom/node.js.map +1 -1
  42. package/dist/{node_types-9ac5b4dd.d.ts → dom/node_types.d.ts} +1 -0
  43. package/dist/dom/root.d.ts +6 -2
  44. package/dist/dom/root.js +1 -1
  45. package/dist/dom/root.js.map +1 -1
  46. package/dist/dom/style.d.ts +3 -1
  47. package/dist/dom/style.js.map +1 -1
  48. package/dist/dom/style_properties.js +1 -0
  49. package/dist/dom/style_properties.js.map +1 -1
  50. package/dist/dom/svg.d.ts +3 -1
  51. package/dist/dom/svg.js.map +1 -1
  52. package/dist/dom/text.d.ts +4 -2
  53. package/dist/dom/text.js.map +1 -1
  54. package/dist/dom/transfer.js.map +1 -1
  55. package/dist/dom/tree.js.map +1 -1
  56. package/dist/dom-external/element.js +7 -0
  57. package/dist/dom-external/element.js.map +1 -1
  58. package/dist/dom-external/index.js.map +1 -1
  59. package/dist/dom-external/inner-html/html.js.map +1 -1
  60. package/dist/dom-external/inner-html/parser.d.ts +2 -7
  61. package/dist/dom-external/inner-html/parser.js +1 -1
  62. package/dist/dom-external/inner-html/parser.js.map +1 -1
  63. package/dist/dom-external/inner-html/scaner.js.map +1 -1
  64. package/dist/dom-external/inner-html/style.js.map +1 -1
  65. package/dist/dom-external/inner-html/tags.js.map +1 -1
  66. package/dist/dom-external/inner-html/utils.js.map +1 -1
  67. package/dist/dom-external/mutation-observer/implements.d.ts +6 -22
  68. package/dist/dom-external/mutation-observer/implements.js.map +1 -1
  69. package/dist/dom-external/mutation-observer/index.d.ts +7 -4
  70. package/dist/dom-external/mutation-observer/index.js.map +1 -1
  71. package/dist/{record-32b054d8.d.ts → dom-external/mutation-observer/record.d.ts} +5 -2
  72. package/dist/dom-external/node.js.map +1 -1
  73. package/dist/dsl/common.d.ts +5 -4
  74. package/dist/dsl/common.js +32 -14
  75. package/dist/dsl/common.js.map +1 -1
  76. package/dist/{instance-4007cff2.d.ts → dsl/instance.d.ts} +23 -11
  77. package/dist/emitter/emitter.d.ts +5 -1
  78. package/dist/emitter/emitter.js.map +1 -1
  79. package/dist/env.d.ts +3 -1
  80. package/dist/env.js.map +1 -1
  81. package/dist/hydrate.d.ts +5 -3
  82. package/dist/hydrate.js +1 -1
  83. package/dist/hydrate.js.map +1 -1
  84. package/dist/index.cjs.d.ts +178 -70
  85. package/dist/index.cjs.js +50 -27
  86. package/dist/index.cjs.js.map +1 -1
  87. package/dist/index.d.ts +42 -34
  88. package/dist/interface/animate.d.ts +83 -0
  89. package/dist/interface/element.d.ts +6 -0
  90. package/dist/interface/event-target.d.ts +13 -0
  91. package/dist/interface/event.d.ts +16 -0
  92. package/dist/interface/hydrate.d.ts +32 -0
  93. package/dist/interface/node.d.ts +10 -0
  94. package/dist/{options-4007cff2.d.ts → interface/options.d.ts} +6 -4
  95. package/dist/interface/utils.d.ts +4 -0
  96. package/dist/next-tick.d.ts +3 -1
  97. package/dist/next-tick.js.map +1 -1
  98. package/dist/options.d.ts +3 -1
  99. package/dist/options.js.map +1 -1
  100. package/dist/perf.d.ts +1 -0
  101. package/dist/perf.js.map +1 -1
  102. package/dist/polyfill/array.js.map +1 -1
  103. package/dist/polyfill/index.d.ts +1 -0
  104. package/dist/polyfill/index.js.map +1 -1
  105. package/dist/polyfill/intersection-observer.js +3 -6
  106. package/dist/polyfill/intersection-observer.js.map +1 -1
  107. package/dist/polyfill/object.js.map +1 -1
  108. package/dist/runtime.esm.d.ts +178 -70
  109. package/dist/runtime.esm.js +46 -23
  110. package/dist/runtime.esm.js.map +1 -1
  111. package/dist/utils/cache.d.ts +1 -0
  112. package/dist/utils/cache.js.map +1 -1
  113. package/dist/utils/index.d.ts +7 -7
  114. package/dist/utils/index.js +1 -1
  115. package/dist/utils/index.js.map +1 -1
  116. package/dist/utils/lodash.d.ts +2 -1
  117. package/dist/utils/lodash.js.map +1 -1
  118. package/dist/utils/router.d.ts +2 -1
  119. package/dist/utils/router.js.map +1 -1
  120. package/package.json +10 -7
  121. package/dist/dom/anchor-element.d.ts +0 -14
  122. package/dist/dom/style_properties.d.ts +0 -3
  123. package/dist/dom/transfer.d.ts +0 -8
  124. package/dist/dom/tree.d.ts +0 -4
  125. package/dist/dom-external/element.d.ts +0 -4
  126. package/dist/dom-external/index.d.ts +0 -1
  127. package/dist/dom-external/inner-html/html.d.ts +0 -3
  128. package/dist/dom-external/inner-html/scaner.d.ts +0 -30
  129. package/dist/dom-external/inner-html/style.d.ts +0 -27
  130. package/dist/dom-external/inner-html/tags.d.ts +0 -9
  131. package/dist/dom-external/inner-html/utils.d.ts +0 -2
  132. package/dist/dom-external/node.d.ts +0 -12
  133. package/dist/index-26658829.d.ts +0 -23
  134. package/dist/polyfill/array.d.ts +0 -3
  135. package/dist/polyfill/intersection-observer.d.ts +0 -2
  136. package/dist/polyfill/object.d.ts +0 -4
package/dist/index.cjs.js CHANGED
@@ -690,7 +690,7 @@ function parseUrl(url = '') {
690
690
  result.search = matches[10] || '';
691
691
  result.hash = matches[12] || '';
692
692
  result.href = url;
693
- result.origin = result.protocol + '//' + result.hostname;
693
+ result.origin = result.protocol + '//' + result.hostname + (result.port ? `:${result.port}` : '');
694
694
  result.host = result.hostname + (result.port ? `:${result.port}` : '');
695
695
  return result;
696
696
  }
@@ -1343,7 +1343,7 @@ function hydrate(node) {
1343
1343
  data["nn" /* Shortcuts.NodeName */] = PURE_VIEW;
1344
1344
  }
1345
1345
  }
1346
- if (nodeName === VIEW && node.isOnlyClickBinded()) {
1346
+ if (nodeName === VIEW && node.isOnlyClickBinded() && !isHasExtractProp(node)) {
1347
1347
  data["nn" /* Shortcuts.NodeName */] = CLICK_VIEW;
1348
1348
  }
1349
1349
  }
@@ -1764,6 +1764,7 @@ const WEBKIT = 'webkit';
1764
1764
  const styleProperties = [
1765
1765
  'all',
1766
1766
  'appearance',
1767
+ 'backdropFilter',
1767
1768
  'blockOverflow',
1768
1769
  'blockSize',
1769
1770
  'bottom',
@@ -2281,7 +2282,7 @@ class TaroElement extends TaroNode {
2281
2282
  // catchMove = false: view or click-view or static-view
2282
2283
  this.enqueueUpdate({
2283
2284
  path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
2284
- value: value ? catchViewAlias : (this.isOnlyClickBinded() ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias))
2285
+ value: value ? catchViewAlias : (this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias))
2285
2286
  });
2286
2287
  }
2287
2288
  else if (isPureView && isHasExtractProp(this)) {
@@ -2341,7 +2342,7 @@ class TaroElement extends TaroNode {
2341
2342
  // catch-view => view or click-view or static-view or pure-view
2342
2343
  this.enqueueUpdate({
2343
2344
  path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
2344
- value: this.isOnlyClickBinded() ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias))
2345
+ value: this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias))
2345
2346
  });
2346
2347
  }
2347
2348
  else if (isStaticView && !isHasExtractProp(this)) {
@@ -3125,7 +3126,7 @@ function parser(html, document) {
3125
3126
  html = styleTagParser.extractStyle(html);
3126
3127
  const tokens = new Scaner(html).scan();
3127
3128
  const root = { tagName: '', children: [], type: 'element', attributes: [] };
3128
- const state = { tokens, options, cursor: 0, stack: [root] };
3129
+ const state = { tokens, cursor: 0, stack: [root] };
3129
3130
  parse(state);
3130
3131
  return format(root.children, document, {
3131
3132
  styleTagParser,
@@ -3245,6 +3246,13 @@ function getBoundingClientRectImpl() {
3245
3246
  return Promise.resolve(null);
3246
3247
  return new Promise(resolve => {
3247
3248
  const query = options.miniGlobal.createSelectorQuery();
3249
+ // ref: https://opendocs.alipay.com/mini/api/na4yun
3250
+ if (process.env.TARO_ENV === 'alipay') {
3251
+ query.select(`#${this.uid}`).boundingClientRect().exec(res => {
3252
+ resolve(res);
3253
+ });
3254
+ return;
3255
+ }
3248
3256
  query.select(`#${this.uid}`).boundingClientRect(res => {
3249
3257
  resolve(res);
3250
3258
  }).exec();
@@ -4138,19 +4146,34 @@ function createPageConfig(component, pageName, data, pageConfig) {
4138
4146
  }
4139
4147
  LIFECYCLES.forEach((lifecycle) => {
4140
4148
  let isDefer = false;
4149
+ let isEvent = false;
4141
4150
  lifecycle = lifecycle.replace(/^defer:/, () => {
4142
4151
  isDefer = true;
4143
4152
  return '';
4144
4153
  });
4145
- config[lifecycle] = function () {
4146
- const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
4147
- if (isDefer) {
4148
- hasLoaded.then(exec);
4149
- }
4150
- else {
4151
- return exec();
4152
- }
4153
- };
4154
+ lifecycle = lifecycle.replace(/^events:/, () => {
4155
+ isEvent = true;
4156
+ return '';
4157
+ });
4158
+ if (isEvent && process.env.TARO_ENV === 'alipay') {
4159
+ // 初始化 config.events 对象
4160
+ if (!config.events)
4161
+ config.events = {};
4162
+ config.events[lifecycle] = function () {
4163
+ return safeExecute(this.$taroPath, lifecycle, ...arguments);
4164
+ };
4165
+ }
4166
+ else {
4167
+ config[lifecycle] = function () {
4168
+ const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
4169
+ if (isDefer) {
4170
+ hasLoaded.then(exec);
4171
+ }
4172
+ else {
4173
+ return exec();
4174
+ }
4175
+ };
4176
+ }
4154
4177
  });
4155
4178
  // onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
4156
4179
  SIDE_EFFECT_LIFECYCLES.forEach(lifecycle => {
@@ -4252,6 +4275,11 @@ function createRecursiveComponentConfig(componentName) {
4252
4275
  }
4253
4276
  }
4254
4277
  : shared.EMPTY_OBJ;
4278
+ // 不同平台的个性化配置
4279
+ const extraOptions = {};
4280
+ if (process.env.TARO_ENV === 'jd') {
4281
+ extraOptions.addGlobalClass = true;
4282
+ }
4255
4283
  return shared.hooks.call('modifyRecursiveComponentConfig', Object.assign({ properties: {
4256
4284
  i: {
4257
4285
  type: Object,
@@ -4263,9 +4291,7 @@ function createRecursiveComponentConfig(componentName) {
4263
4291
  type: String,
4264
4292
  value: ''
4265
4293
  }
4266
- }, options: {
4267
- virtualHost: !isCustomWrapper
4268
- }, methods: {
4294
+ }, options: Object.assign(Object.assign({}, extraOptions), { virtualHost: !isCustomWrapper }), methods: {
4269
4295
  eh: eventHandler
4270
4296
  } }, lifeCycles), { isCustomWrapper });
4271
4297
  }
@@ -4626,10 +4652,7 @@ function handleIntersectionObserverObjectPolyfill() {
4626
4652
  target: target,
4627
4653
  boundingClientRect: targetRect,
4628
4654
  rootBounds: rootRect,
4629
- intersectionRect: intersectionRect,
4630
- intersectionRatio: -1,
4631
- isIntersecting: false,
4632
- });
4655
+ intersectionRect: intersectionRect});
4633
4656
  if (!oldEntry) {
4634
4657
  this._queuedEntries.push(newEntry);
4635
4658
  }
@@ -4829,7 +4852,7 @@ function handleIntersectionObserverObjectPolyfill() {
4829
4852
  */
4830
4853
  function addEvent(node, event, fn, opt_useCapture) {
4831
4854
  if (shared.isFunction(node.addEventListener)) {
4832
- node.addEventListener(event, fn, opt_useCapture );
4855
+ node.addEventListener(event, fn, opt_useCapture);
4833
4856
  }
4834
4857
  else if (shared.isFunction(node.attachEvent)) {
4835
4858
  node.attachEvent('on' + event, fn);
@@ -4845,7 +4868,7 @@ function handleIntersectionObserverObjectPolyfill() {
4845
4868
  */
4846
4869
  function removeEvent(node, event, fn, opt_useCapture) {
4847
4870
  if (shared.isFunction(node.removeEventListener)) {
4848
- node.removeEventListener(event, fn, opt_useCapture );
4871
+ node.removeEventListener(event, fn, opt_useCapture);
4849
4872
  }
4850
4873
  else if (shared.isFunction(node.detatchEvent)) {
4851
4874
  node.detatchEvent('on' + event, fn);
@@ -5083,12 +5106,12 @@ if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFOR
5083
5106
  }
5084
5107
 
5085
5108
  Object.defineProperty(exports, "Events", {
5086
- enumerable: true,
5087
- get: function () { return shared.Events; }
5109
+ enumerable: true,
5110
+ get: function () { return shared.Events; }
5088
5111
  });
5089
5112
  Object.defineProperty(exports, "hooks", {
5090
- enumerable: true,
5091
- get: function () { return shared.hooks; }
5113
+ enumerable: true,
5114
+ get: function () { return shared.hooks; }
5092
5115
  });
5093
5116
  exports.A = A;
5094
5117
  exports.APP = APP;