@tarojs/runtime 4.0.0-beta.11 → 4.0.0-beta.111

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 (66) hide show
  1. package/LICENSE +8 -8
  2. package/dist/bom/URL.js.map +1 -1
  3. package/dist/bom/URLSearchParams.js.map +1 -1
  4. package/dist/bom/history.js.map +1 -1
  5. package/dist/bom/location.js.map +1 -1
  6. package/dist/bom/raf.d.ts +1 -0
  7. package/dist/bom/raf.js.map +1 -1
  8. package/dist/bom/window.d.ts +1 -0
  9. package/dist/bom/window.js.map +1 -1
  10. package/dist/dom/anchor-element.js.map +1 -1
  11. package/dist/dom/class-list.js.map +1 -1
  12. package/dist/dom/document.js.map +1 -1
  13. package/dist/dom/element.js.map +1 -1
  14. package/dist/dom/event-target.js.map +1 -1
  15. package/dist/dom/event.js.map +1 -1
  16. package/dist/dom/form.js +1 -1
  17. package/dist/dom/form.js.map +1 -1
  18. package/dist/dom/node.js +2 -2
  19. package/dist/dom/node.js.map +1 -1
  20. package/dist/dom/root.js.map +1 -1
  21. package/dist/dom/style.js.map +1 -1
  22. package/dist/dom/style_properties.js.map +1 -1
  23. package/dist/dom/tree.js.map +1 -1
  24. package/dist/dom-external/element.js.map +1 -1
  25. package/dist/dom-external/index.js.map +1 -1
  26. package/dist/dom-external/inner-html/html.js.map +1 -1
  27. package/dist/dom-external/inner-html/parser.js.map +1 -1
  28. package/dist/dom-external/inner-html/scaner.js.map +1 -1
  29. package/dist/dom-external/inner-html/style.js.map +1 -1
  30. package/dist/dom-external/inner-html/tags.js +4 -4
  31. package/dist/dom-external/inner-html/tags.js.map +1 -1
  32. package/dist/dom-external/inner-html/utils.js.map +1 -1
  33. package/dist/dom-external/mutation-observer/implements.js.map +1 -1
  34. package/dist/dom-external/mutation-observer/index.js.map +1 -1
  35. package/dist/dom-external/node.js +1 -0
  36. package/dist/dom-external/node.js.map +1 -1
  37. package/dist/dsl/common.d.ts +1 -0
  38. package/dist/dsl/common.js +6 -1
  39. package/dist/dsl/common.js.map +1 -1
  40. package/dist/hydrate.js +9 -2
  41. package/dist/hydrate.js.map +1 -1
  42. package/dist/index.cjs.d.ts +16 -14
  43. package/dist/index.cjs.js +56 -15
  44. package/dist/index.cjs.js.map +1 -1
  45. package/dist/index.d.ts +1 -0
  46. package/dist/index.js +2 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/instance-4c64b022.d.ts +6 -14
  49. package/dist/next-tick.js.map +1 -1
  50. package/dist/perf.d.ts +3 -1
  51. package/dist/perf.js +24 -3
  52. package/dist/perf.js.map +1 -1
  53. package/dist/polyfill/array.js.map +1 -1
  54. package/dist/polyfill/index.js.map +1 -1
  55. package/dist/polyfill/intersection-observer.js +4 -3
  56. package/dist/polyfill/intersection-observer.js.map +1 -1
  57. package/dist/polyfill/object.js.map +1 -1
  58. package/dist/runtime.esm.d.ts +16 -14
  59. package/dist/runtime.esm.js +54 -15
  60. package/dist/runtime.esm.js.map +1 -1
  61. package/dist/utils/cache.js.map +1 -1
  62. package/dist/utils/index.js.map +1 -1
  63. package/dist/utils/lodash.d.ts +2 -1
  64. package/dist/utils/lodash.js +11 -1
  65. package/dist/utils/lodash.js.map +1 -1
  66. package/package.json +15 -23
@@ -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 } from '@tarojs/shared';
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';
2
2
  export { Events, hooks } from '@tarojs/shared';
3
3
  import { __classPrivateFieldSet, __classPrivateFieldGet } from 'tslib';
4
4
 
@@ -218,6 +218,16 @@ function throttle(fn, threshold = 250, scope) {
218
218
  }
219
219
  };
220
220
  }
221
+ function debounce(fn, ms = 250, scope) {
222
+ let timer;
223
+ return function (...args) {
224
+ const context = scope || this;
225
+ clearTimeout(timer);
226
+ timer = setTimeout(function () {
227
+ fn.apply(context, args);
228
+ }, ms);
229
+ };
230
+ }
221
231
 
222
232
  const eventCenter = hooks.call('getEventCenter', Events);
223
233
 
@@ -1298,6 +1308,7 @@ function hydrate(node) {
1298
1308
  // 初始化 SPECIAL_NODES
1299
1309
  SPECIAL_NODES || (SPECIAL_NODES = hooks.call('getSpecialNodes'));
1300
1310
  const nodeName = node.nodeName;
1311
+ let compileModeName = null;
1301
1312
  if (isText(node)) {
1302
1313
  return {
1303
1314
  sid: node.sid,
@@ -1329,11 +1340,14 @@ function hydrate(node) {
1329
1340
  propInCamelCase !== COMPILE_MODE) {
1330
1341
  data[propInCamelCase] = props[prop];
1331
1342
  }
1332
- if (nodeName === VIEW && propInCamelCase === CATCHMOVE && props[prop] !== false) {
1343
+ if (process.env.TARO_ENV !== 'swan' &&
1344
+ nodeName === VIEW &&
1345
+ propInCamelCase === CATCHMOVE &&
1346
+ props[prop] !== false) {
1333
1347
  data["nn" /* Shortcuts.NodeName */] = CATCH_VIEW;
1334
1348
  }
1335
1349
  if (propInCamelCase === COMPILE_MODE) {
1336
- data["nn" /* Shortcuts.NodeName */] = props[prop];
1350
+ compileModeName = props[prop];
1337
1351
  }
1338
1352
  }
1339
1353
  // Children
@@ -1357,6 +1371,9 @@ function hydrate(node) {
1357
1371
  }
1358
1372
  }
1359
1373
  }
1374
+ if (compileModeName !== null) {
1375
+ data["nn" /* Shortcuts.NodeName */] = compileModeName;
1376
+ }
1360
1377
  const resData = hooks.call('transferHydrateData', data, node, componentAlias);
1361
1378
  return resData || data;
1362
1379
  }
@@ -1628,7 +1645,7 @@ class TaroNode extends TaroEventTarget {
1628
1645
  : [],
1629
1646
  nextSibling: isReplace
1630
1647
  ? refChild.nextSibling /** replaceChild */
1631
- : (refChild || null),
1648
+ : (refChild || null), /** insertBefore & appendChild */
1632
1649
  previousSibling: newChild.previousSibling
1633
1650
  });
1634
1651
  return newChild;
@@ -2952,7 +2969,7 @@ function makeMap(str, expectsLowerCase) {
2952
2969
  for (let i = 0; i < list.length; i++) {
2953
2970
  map[list[i]] = true;
2954
2971
  }
2955
- return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
2972
+ return val => !!map[val.toLowerCase()] ;
2956
2973
  }
2957
2974
  const specialMiniElements = {
2958
2975
  img: 'image',
@@ -2962,11 +2979,11 @@ const internalCompsList = Object.keys(internalComponents)
2962
2979
  .map(i => i.toLowerCase())
2963
2980
  .join(',');
2964
2981
  // https://developers.weixin.qq.com/miniprogram/dev/component
2965
- const isMiniElements = makeMap(internalCompsList, true);
2982
+ const isMiniElements = makeMap(internalCompsList);
2966
2983
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
2967
- const isInlineElements = makeMap('a,i,abbr,iframe,select,acronym,slot,small,span,bdi,kbd,strong,big,map,sub,sup,br,mark,mark,meter,template,canvas,textarea,cite,object,time,code,output,u,data,picture,tt,datalist,var,dfn,del,q,em,s,embed,samp,b', true);
2984
+ const isInlineElements = makeMap('a,i,abbr,iframe,select,acronym,slot,small,span,bdi,kbd,strong,big,map,sub,sup,br,mark,mark,meter,template,canvas,textarea,cite,object,time,code,output,u,data,picture,tt,datalist,var,dfn,del,q,em,s,embed,samp,b');
2968
2985
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
2969
- const isBlockElements = makeMap('address,fieldset,li,article,figcaption,main,aside,figure,nav,blockquote,footer,ol,details,form,p,dialog,h1,h2,h3,h4,h5,h6,pre,dd,header,section,div,hgroup,table,dl,hr,ul,dt', true);
2986
+ const isBlockElements = makeMap('address,fieldset,li,article,figcaption,main,aside,figure,nav,blockquote,footer,ol,details,form,p,dialog,h1,h2,h3,h4,h5,h6,pre,dd,header,section,div,hgroup,table,dl,hr,ul,dt');
2970
2987
 
2971
2988
  const closingTagAncestorBreakers = {
2972
2989
  li: ['ul', 'ol', 'menu'],
@@ -3263,6 +3280,7 @@ function cloneNode(isDeep = false) {
3263
3280
  }
3264
3281
  for (const key in this) {
3265
3282
  const value = this[key];
3283
+ // eslint-disable-next-line valid-typeof
3266
3284
  if ([PROPS, DATASET].includes(key) && typeof value === OBJECT) {
3267
3285
  newNode[key] = Object.assign({}, value);
3268
3286
  }
@@ -3494,7 +3512,7 @@ class FormElement extends TaroElement {
3494
3512
  else if (event.type === INPUT) {
3495
3513
  // Web 规范中表单组件的 value 应该跟着输入改变
3496
3514
  // 只是改 this.props.value 的话不会进行 setData,因此这里修改 this.value。
3497
- // 只测试了 React、Vue、Vue3 input 组件的 onInput 事件,onChange 事件不确定有没有副作用,所以暂不修改。
3515
+ // 只测试了 React、Vue3 input 组件的 onInput 事件,onChange 事件不确定有没有副作用,所以暂不修改。
3498
3516
  this.value = val;
3499
3517
  }
3500
3518
  }
@@ -3502,8 +3520,10 @@ class FormElement extends TaroElement {
3502
3520
  }
3503
3521
  }
3504
3522
 
3523
+ var _Performance_instances, _Performance_parseTime;
3505
3524
  class Performance {
3506
3525
  constructor() {
3526
+ _Performance_instances.add(this);
3507
3527
  this.recorder = new Map();
3508
3528
  }
3509
3529
  start(id) {
@@ -3512,18 +3532,32 @@ class Performance {
3512
3532
  }
3513
3533
  this.recorder.set(id, Date.now());
3514
3534
  }
3515
- stop(id) {
3535
+ stop(id, now = Date.now()) {
3516
3536
  if (!options.debug) {
3517
3537
  return;
3518
3538
  }
3519
- const now = Date.now();
3520
3539
  const prev = this.recorder.get(id);
3540
+ if (!(prev >= 0))
3541
+ return;
3521
3542
  this.recorder.delete(id);
3522
3543
  const time = now - prev;
3523
3544
  // eslint-disable-next-line no-console
3524
- console.log(`${id} 时长: ${time}ms`);
3545
+ console.log(`${id} 时长: ${time}ms 开始时间:${__classPrivateFieldGet(this, _Performance_instances, "m", _Performance_parseTime).call(this, prev)} 结束时间:${__classPrivateFieldGet(this, _Performance_instances, "m", _Performance_parseTime).call(this, now)}`);
3546
+ }
3547
+ delayStop(id, delay = 500) {
3548
+ if (!options.debug) {
3549
+ return;
3550
+ }
3551
+ return debounce((now = Date.now(), cb) => {
3552
+ this.stop(id, now);
3553
+ cb === null || cb === void 0 ? void 0 : cb();
3554
+ }, delay);
3525
3555
  }
3526
3556
  }
3557
+ _Performance_instances = new WeakSet(), _Performance_parseTime = function _Performance_parseTime(time) {
3558
+ const d = new Date(time);
3559
+ return `${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${`${d.getMilliseconds()}`.padStart(3, '0')}`;
3560
+ };
3527
3561
  const perf = new Performance();
3528
3562
 
3529
3563
  function findCustomWrapper(root, dataPathArr) {
@@ -4068,6 +4102,11 @@ function createPageConfig(component, pageName, data, pageConfig) {
4068
4102
  eventCenter.trigger(getOnHideEventKey(id));
4069
4103
  }
4070
4104
  };
4105
+ if (process.env.TARO_PLATFORM === 'web') {
4106
+ config.getOpenerEventChannel = () => {
4107
+ return EventChannel.pageChannel;
4108
+ };
4109
+ }
4071
4110
  LIFECYCLES.forEach((lifecycle) => {
4072
4111
  let isDefer = false;
4073
4112
  lifecycle = lifecycle.replace(/^defer:/, () => {
@@ -4762,7 +4801,7 @@ function handleIntersectionObserverObjectPolyfill() {
4762
4801
  */
4763
4802
  function addEvent(node, event, fn, opt_useCapture) {
4764
4803
  if (isFunction(node.addEventListener)) {
4765
- node.addEventListener(event, fn, opt_useCapture || false);
4804
+ node.addEventListener(event, fn, opt_useCapture );
4766
4805
  }
4767
4806
  else if (isFunction(node.attachEvent)) {
4768
4807
  node.attachEvent('on' + event, fn);
@@ -4778,7 +4817,7 @@ function handleIntersectionObserverObjectPolyfill() {
4778
4817
  */
4779
4818
  function removeEvent(node, event, fn, opt_useCapture) {
4780
4819
  if (isFunction(node.removeEventListener)) {
4781
- node.removeEventListener(event, fn, opt_useCapture || false);
4820
+ node.removeEventListener(event, fn, opt_useCapture );
4782
4821
  }
4783
4822
  else if (isFunction(node.detatchEvent)) {
4784
4823
  node.detatchEvent('on' + event, fn);
@@ -5015,5 +5054,5 @@ if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFOR
5015
5054
  handlePolyfill();
5016
5055
  }
5017
5056
 
5018
- export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, COMMENT, COMPILE_MODE, CONFIRM, CONTAINER, CONTEXT_ACTIONS, CURRENT_TARGET, CUSTOM_WRAPPER, Current, DATASET, DATE, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, EVENT_CALLBACK_RESULT, EXTERNAL_CLASSES, FOCUS, FormElement, HEAD, HOOKS_APP_ID, HTML, History, ID, INPUT, KEY_CODE, Location, MutationObserver$1 as MutationObserver, OBJECT, ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, OPTIONS, PAGE_INIT, PROPERTY_THRESHOLD, PROPS, PURE_VIEW, ROOT_STR, SET_DATA, SET_TIMEOUT, STATIC_VIEW, STYLE, SVGElement, Style, TARGET, TARO_RUNTIME, TIME_STAMP, TOUCHMOVE, TYPE, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, UID, URL, URLSearchParams, VALUE, VIEW, addLeadingSlash, _caf as cancelAnimationFrame, convertNumber2PX, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, customWrapperCache, document$1 as document, env, eventCenter, eventHandler, eventSource, extend, getComponentsAlias, getComputedStyle, getCurrentInstance, getCurrentPage, getHomePage, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, history, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp, isParentBinded, isText, location, nav as navigator, nextTick, now, options, parseUrl, removePageInstance, _raf as requestAnimationFrame, safeExecute, shortcutAttr, stringify, stripBasename, stripSuffix, stripTrailing, throttle, window$1 as window };
5057
+ export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, COMMENT, COMPILE_MODE, CONFIRM, CONTAINER, CONTEXT_ACTIONS, CURRENT_TARGET, CUSTOM_WRAPPER, Current, DATASET, DATE, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, EVENT_CALLBACK_RESULT, EXTERNAL_CLASSES, FOCUS, FormElement, HEAD, HOOKS_APP_ID, HTML, History, ID, INPUT, KEY_CODE, Location, MutationObserver$1 as MutationObserver, OBJECT, ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, OPTIONS, PAGE_INIT, PROPERTY_THRESHOLD, PROPS, PURE_VIEW, ROOT_STR, SET_DATA, SET_TIMEOUT, STATIC_VIEW, STYLE, SVGElement, Style, TARGET, TARO_RUNTIME, TIME_STAMP, TOUCHMOVE, TYPE, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, UID, URL, URLSearchParams, VALUE, VIEW, addLeadingSlash, _caf as cancelAnimationFrame, convertNumber2PX, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, customWrapperCache, debounce, document$1 as document, env, eventCenter, eventHandler, eventSource, extend, getComponentsAlias, getComputedStyle, getCurrentInstance, getCurrentPage, getHomePage, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, history, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp, isParentBinded, isText, location, nav as navigator, nextTick, now, options, parseUrl, perf, removePageInstance, _raf as requestAnimationFrame, safeExecute, shortcutAttr, stringify, stripBasename, stripSuffix, stripTrailing, throttle, window$1 as window };
5019
5058
  //# sourceMappingURL=runtime.esm.js.map