@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
@@ -689,7 +689,7 @@ function parseUrl(url = '') {
689
689
  result.search = matches[10] || '';
690
690
  result.hash = matches[12] || '';
691
691
  result.href = url;
692
- result.origin = result.protocol + '//' + result.hostname;
692
+ result.origin = result.protocol + '//' + result.hostname + (result.port ? `:${result.port}` : '');
693
693
  result.host = result.hostname + (result.port ? `:${result.port}` : '');
694
694
  return result;
695
695
  }
@@ -1342,7 +1342,7 @@ function hydrate(node) {
1342
1342
  data["nn" /* Shortcuts.NodeName */] = PURE_VIEW;
1343
1343
  }
1344
1344
  }
1345
- if (nodeName === VIEW && node.isOnlyClickBinded()) {
1345
+ if (nodeName === VIEW && node.isOnlyClickBinded() && !isHasExtractProp(node)) {
1346
1346
  data["nn" /* Shortcuts.NodeName */] = CLICK_VIEW;
1347
1347
  }
1348
1348
  }
@@ -1763,6 +1763,7 @@ const WEBKIT = 'webkit';
1763
1763
  const styleProperties = [
1764
1764
  'all',
1765
1765
  'appearance',
1766
+ 'backdropFilter',
1766
1767
  'blockOverflow',
1767
1768
  'blockSize',
1768
1769
  'bottom',
@@ -2280,7 +2281,7 @@ class TaroElement extends TaroNode {
2280
2281
  // catchMove = false: view or click-view or static-view
2281
2282
  this.enqueueUpdate({
2282
2283
  path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
2283
- value: value ? catchViewAlias : (this.isOnlyClickBinded() ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias))
2284
+ value: value ? catchViewAlias : (this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias))
2284
2285
  });
2285
2286
  }
2286
2287
  else if (isPureView && isHasExtractProp(this)) {
@@ -2340,7 +2341,7 @@ class TaroElement extends TaroNode {
2340
2341
  // catch-view => view or click-view or static-view or pure-view
2341
2342
  this.enqueueUpdate({
2342
2343
  path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
2343
- value: this.isOnlyClickBinded() ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias))
2344
+ value: this.isOnlyClickBinded() && !isHasExtractProp(this) ? clickViewAlias : (this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias))
2344
2345
  });
2345
2346
  }
2346
2347
  else if (isStaticView && !isHasExtractProp(this)) {
@@ -3124,7 +3125,7 @@ function parser(html, document) {
3124
3125
  html = styleTagParser.extractStyle(html);
3125
3126
  const tokens = new Scaner(html).scan();
3126
3127
  const root = { tagName: '', children: [], type: 'element', attributes: [] };
3127
- const state = { tokens, options, cursor: 0, stack: [root] };
3128
+ const state = { tokens, cursor: 0, stack: [root] };
3128
3129
  parse(state);
3129
3130
  return format(root.children, document, {
3130
3131
  styleTagParser,
@@ -3244,6 +3245,13 @@ function getBoundingClientRectImpl() {
3244
3245
  return Promise.resolve(null);
3245
3246
  return new Promise(resolve => {
3246
3247
  const query = options.miniGlobal.createSelectorQuery();
3248
+ // ref: https://opendocs.alipay.com/mini/api/na4yun
3249
+ if (process.env.TARO_ENV === 'alipay') {
3250
+ query.select(`#${this.uid}`).boundingClientRect().exec(res => {
3251
+ resolve(res);
3252
+ });
3253
+ return;
3254
+ }
3247
3255
  query.select(`#${this.uid}`).boundingClientRect(res => {
3248
3256
  resolve(res);
3249
3257
  }).exec();
@@ -4137,19 +4145,34 @@ function createPageConfig(component, pageName, data, pageConfig) {
4137
4145
  }
4138
4146
  LIFECYCLES.forEach((lifecycle) => {
4139
4147
  let isDefer = false;
4148
+ let isEvent = false;
4140
4149
  lifecycle = lifecycle.replace(/^defer:/, () => {
4141
4150
  isDefer = true;
4142
4151
  return '';
4143
4152
  });
4144
- config[lifecycle] = function () {
4145
- const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
4146
- if (isDefer) {
4147
- hasLoaded.then(exec);
4148
- }
4149
- else {
4150
- return exec();
4151
- }
4152
- };
4153
+ lifecycle = lifecycle.replace(/^events:/, () => {
4154
+ isEvent = true;
4155
+ return '';
4156
+ });
4157
+ if (isEvent && process.env.TARO_ENV === 'alipay') {
4158
+ // 初始化 config.events 对象
4159
+ if (!config.events)
4160
+ config.events = {};
4161
+ config.events[lifecycle] = function () {
4162
+ return safeExecute(this.$taroPath, lifecycle, ...arguments);
4163
+ };
4164
+ }
4165
+ else {
4166
+ config[lifecycle] = function () {
4167
+ const exec = () => safeExecute(this.$taroPath, lifecycle, ...arguments);
4168
+ if (isDefer) {
4169
+ hasLoaded.then(exec);
4170
+ }
4171
+ else {
4172
+ return exec();
4173
+ }
4174
+ };
4175
+ }
4153
4176
  });
4154
4177
  // onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
4155
4178
  SIDE_EFFECT_LIFECYCLES.forEach(lifecycle => {
@@ -4251,6 +4274,11 @@ function createRecursiveComponentConfig(componentName) {
4251
4274
  }
4252
4275
  }
4253
4276
  : EMPTY_OBJ;
4277
+ // 不同平台的个性化配置
4278
+ const extraOptions = {};
4279
+ if (process.env.TARO_ENV === 'jd') {
4280
+ extraOptions.addGlobalClass = true;
4281
+ }
4254
4282
  return hooks.call('modifyRecursiveComponentConfig', Object.assign({ properties: {
4255
4283
  i: {
4256
4284
  type: Object,
@@ -4262,9 +4290,7 @@ function createRecursiveComponentConfig(componentName) {
4262
4290
  type: String,
4263
4291
  value: ''
4264
4292
  }
4265
- }, options: {
4266
- virtualHost: !isCustomWrapper
4267
- }, methods: {
4293
+ }, options: Object.assign(Object.assign({}, extraOptions), { virtualHost: !isCustomWrapper }), methods: {
4268
4294
  eh: eventHandler
4269
4295
  } }, lifeCycles), { isCustomWrapper });
4270
4296
  }
@@ -4625,10 +4651,7 @@ function handleIntersectionObserverObjectPolyfill() {
4625
4651
  target: target,
4626
4652
  boundingClientRect: targetRect,
4627
4653
  rootBounds: rootRect,
4628
- intersectionRect: intersectionRect,
4629
- intersectionRatio: -1,
4630
- isIntersecting: false,
4631
- });
4654
+ intersectionRect: intersectionRect});
4632
4655
  if (!oldEntry) {
4633
4656
  this._queuedEntries.push(newEntry);
4634
4657
  }
@@ -4828,7 +4851,7 @@ function handleIntersectionObserverObjectPolyfill() {
4828
4851
  */
4829
4852
  function addEvent(node, event, fn, opt_useCapture) {
4830
4853
  if (isFunction(node.addEventListener)) {
4831
- node.addEventListener(event, fn, opt_useCapture );
4854
+ node.addEventListener(event, fn, opt_useCapture);
4832
4855
  }
4833
4856
  else if (isFunction(node.attachEvent)) {
4834
4857
  node.attachEvent('on' + event, fn);
@@ -4844,7 +4867,7 @@ function handleIntersectionObserverObjectPolyfill() {
4844
4867
  */
4845
4868
  function removeEvent(node, event, fn, opt_useCapture) {
4846
4869
  if (isFunction(node.removeEventListener)) {
4847
- node.removeEventListener(event, fn, opt_useCapture );
4870
+ node.removeEventListener(event, fn, opt_useCapture);
4848
4871
  }
4849
4872
  else if (isFunction(node.detatchEvent)) {
4850
4873
  node.detatchEvent('on' + event, fn);