@tarojs/runtime 3.7.0-beta.1 → 3.7.0-beta.4

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.
@@ -431,7 +431,7 @@ declare const nav: any;
431
431
  declare let now: () => number;
432
432
  // https://gist.github.com/paulirish/1579671
433
433
  // https://gist.github.com/jalbam/5fe05443270fa6d8136238ec72accbc0
434
- declare const _raf: typeof requestAnimationFrame | ((callback: any) => NodeJS.Timeout);
434
+ declare const _raf: typeof requestAnimationFrame | ((callback: any) => NodeJS.Timer);
435
435
  declare const _caf: typeof cancelAnimationFrame;
436
436
  declare class URLSearchParams {
437
437
  #private;
@@ -776,5 +776,6 @@ declare function hydrate(node: TaroElement | TaroText): MiniData;
776
776
  declare const nextTick: (cb: Func, ctx?: Record<string, any>) => void;
777
777
  declare const options: Options;
778
778
  declare const incrementId: () => () => string;
779
+ declare function isHasExtractProp(el: TaroElement): boolean;
779
780
  export { hooks } from '@tarojs/shared';
780
- export { document, getComputedStyle, History, Location, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, parseUrl, URL, URLSearchParams, history, location, window, TaroElement, createEvent, eventHandler, TaroEvent, FormElement, TaroNode, TaroRootElement, Style, SVGElement, TaroText, MutationObserver, env, PROPERTY_THRESHOLD, TARO_RUNTIME, HOOKS_APP_ID, SET_DATA, PAGE_INIT, ROOT_STR, HTML, HEAD, BODY, APP, CONTAINER, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, ID, UID, CLASS, STYLE, FOCUS, VIEW, STATIC_VIEW, PURE_VIEW, PROPS, DATASET, OBJECT, VALUE, INPUT, CHANGE, CUSTOM_WRAPPER, TARGET, CURRENT_TARGET, TYPE, CONFIRM, TIME_STAMP, KEY_CODE, TOUCHMOVE, DATE, SET_TIMEOUT, CATCHMOVE, CATCH_VIEW, COMMENT, ON_LOAD, ON_READY, ON_SHOW, ON_HIDE, OPTIONS, EXTERNAL_CLASSES, EVENT_CALLBACK_RESULT, BEHAVIORS, A, CONTEXT_ACTIONS, Current, getCurrentInstance, eventSource, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };
781
+ export { document, getComputedStyle, History, Location, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, parseUrl, URL, URLSearchParams, history, location, window, TaroElement, createEvent, eventHandler, TaroEvent, FormElement, TaroNode, TaroRootElement, Style, SVGElement, TaroText, MutationObserver, env, PROPERTY_THRESHOLD, TARO_RUNTIME, HOOKS_APP_ID, SET_DATA, PAGE_INIT, ROOT_STR, HTML, HEAD, BODY, APP, CONTAINER, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, ID, UID, CLASS, STYLE, FOCUS, VIEW, STATIC_VIEW, PURE_VIEW, PROPS, DATASET, OBJECT, VALUE, INPUT, CHANGE, CUSTOM_WRAPPER, TARGET, CURRENT_TARGET, TYPE, CONFIRM, TIME_STAMP, KEY_CODE, TOUCHMOVE, DATE, SET_TIMEOUT, CATCHMOVE, CATCH_VIEW, COMMENT, ON_LOAD, ON_READY, ON_SHOW, ON_HIDE, OPTIONS, EXTERNAL_CLASSES, EVENT_CALLBACK_RESULT, BEHAVIORS, A, CONTEXT_ACTIONS, Current, getCurrentInstance, eventSource, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, isHasExtractProp, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };
@@ -124,7 +124,7 @@ class MutationObserver {
124
124
  constructor(callback) {
125
125
  {
126
126
  if (process.env.NODE_ENV !== 'production') {
127
- console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \'mini.enableMutationObserver: true\'');
127
+ console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \'mini.runtime.enableMutationObserver: true\'');
128
128
  }
129
129
  this.core = {
130
130
  observe: shared.noop,
@@ -198,15 +198,15 @@ function isHasExtractProp(el) {
198
198
  */
199
199
  function isParentBinded(node, type) {
200
200
  var _a;
201
- let res = false;
202
- while ((node === null || node === void 0 ? void 0 : node.parentElement) && node.parentElement._path !== ROOT_STR) {
203
- if ((_a = node.parentElement.__handlers[type]) === null || _a === void 0 ? void 0 : _a.length) {
204
- res = true;
205
- break;
201
+ while ((node = (node === null || node === void 0 ? void 0 : node.parentElement) || null)) {
202
+ if (!node || node.nodeName === ROOT_STR || node.nodeName === 'root-portal') {
203
+ return false;
204
+ }
205
+ else if ((_a = node.__handlers[type]) === null || _a === void 0 ? void 0 : _a.length) {
206
+ return true;
206
207
  }
207
- node = node.parentElement;
208
208
  }
209
- return res;
209
+ return false;
210
210
  }
211
211
  function shortcutAttr(key) {
212
212
  switch (key) {
@@ -368,6 +368,7 @@ function hydrate(node) {
368
368
  const nodeName = node.nodeName;
369
369
  if (isText(node)) {
370
370
  return {
371
+ sid: node.sid,
371
372
  ["v" /* Shortcuts.Text */]: node.nodeValue,
372
373
  ["nn" /* Shortcuts.NodeName */]: ((_a = componentsAlias[nodeName]) === null || _a === void 0 ? void 0 : _a._num) || '8'
373
374
  };
@@ -415,7 +416,7 @@ function hydrate(node) {
415
416
  if (cssText !== '' && nodeName !== 'swiper-item') {
416
417
  data["st" /* Shortcuts.Style */] = cssText;
417
418
  }
418
- shared.hooks.call('modifyHydrateData', data);
419
+ shared.hooks.call('modifyHydrateData', data, node);
419
420
  const nn = data["nn" /* Shortcuts.NodeName */];
420
421
  const componentAlias = componentsAlias[nn];
421
422
  if (componentAlias) {
@@ -427,7 +428,8 @@ function hydrate(node) {
427
428
  }
428
429
  }
429
430
  }
430
- return data;
431
+ const resData = shared.hooks.call('transferHydrateData', data, node, componentAlias);
432
+ return resData || data;
431
433
  }
432
434
 
433
435
  class TaroEventTarget {
@@ -992,7 +994,7 @@ function setStyle(newVal, styleKey) {
992
994
  if (old === newVal)
993
995
  return;
994
996
  !this._pending && recordCss(this);
995
- if (shared.isNull(newVal) || shared.isUndefined(newVal)) {
997
+ if (shared.isNull(newVal) || shared.isUndefined(newVal) || newVal === '') {
996
998
  this._usedStyleProp.delete(styleKey);
997
999
  delete this._value[styleKey];
998
1000
  }
@@ -1438,6 +1440,7 @@ class TaroElement extends TaroNode {
1438
1440
  sideEffect = false;
1439
1441
  delete options.sideEffect;
1440
1442
  }
1443
+ shared.hooks.call('modifyAddEventListener', this, sideEffect, getComponentsAlias);
1441
1444
  if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
1442
1445
  const componentsAlias = getComponentsAlias();
1443
1446
  const alias = componentsAlias[name]._num;
@@ -1452,6 +1455,7 @@ class TaroElement extends TaroNode {
1452
1455
  super.removeEventListener(type, handler);
1453
1456
  const name = this.nodeName;
1454
1457
  const SPECIAL_NODES = shared.hooks.call('getSpecialNodes');
1458
+ shared.hooks.call('modifyRemoveEventListener', this, sideEffect, getComponentsAlias);
1455
1459
  if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
1456
1460
  const componentsAlias = getComponentsAlias();
1457
1461
  const value = isHasExtractProp(this) ? `static-${name}` : `pure-${name}`;
@@ -1530,13 +1534,14 @@ class TaroEvent {
1530
1534
  this.defaultPrevented = true;
1531
1535
  }
1532
1536
  get target() {
1533
- var _a, _b, _c;
1537
+ var _a, _b, _c, _d;
1534
1538
  const cacheTarget = this.cacheTarget;
1535
1539
  if (!cacheTarget) {
1536
1540
  const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
1537
- const element = env.document.getElementById(((_b = target.dataset) === null || _b === void 0 ? void 0 : _b.sid) || target.id || null);
1541
+ // Note:优先判断冒泡场景alipay的targetDataset的sid, 不然冒泡场景target属性吐出不对,其余拿取当前绑定id
1542
+ const element = env.document.getElementById(((_b = target.targetDataset) === null || _b === void 0 ? void 0 : _b.sid) || ((_c = target.dataset) === null || _c === void 0 ? void 0 : _c.sid) || target.id || null);
1538
1543
  target.dataset = element !== null ? element.dataset : shared.EMPTY_OBJ;
1539
- for (const key in (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.detail) {
1544
+ for (const key in (_d = this.mpEvent) === null || _d === void 0 ? void 0 : _d.detail) {
1540
1545
  target[key] = this.mpEvent.detail[key];
1541
1546
  }
1542
1547
  this.cacheTarget = target;
@@ -2308,6 +2313,17 @@ class AnchorElement extends TaroElement {
2308
2313
  }
2309
2314
  }
2310
2315
 
2316
+ class TransferElement extends TaroElement {
2317
+ constructor(dataName) {
2318
+ super();
2319
+ this.dataName = dataName;
2320
+ this.isTransferElement = true;
2321
+ }
2322
+ get _path() {
2323
+ return this.dataName;
2324
+ }
2325
+ }
2326
+
2311
2327
  class TaroDocument extends TaroElement {
2312
2328
  constructor() {
2313
2329
  super();
@@ -2328,6 +2344,10 @@ class TaroDocument extends TaroElement {
2328
2344
  case nodeName === A:
2329
2345
  element = new AnchorElement();
2330
2346
  break;
2347
+ case nodeName === 'page-meta':
2348
+ case nodeName === 'navigation-bar':
2349
+ element = new TransferElement(shared.toCamelCase(nodeName));
2350
+ break;
2331
2351
  default:
2332
2352
  element = new TaroElement();
2333
2353
  break;
@@ -3187,7 +3207,7 @@ function createRecursiveComponentConfig(componentName) {
3187
3207
  }
3188
3208
  }
3189
3209
  : shared.EMPTY_OBJ;
3190
- return Object.assign({ properties: {
3210
+ return shared.hooks.call('modifyRecursiveComponentConfig', Object.assign({ properties: {
3191
3211
  i: {
3192
3212
  type: Object,
3193
3213
  value: {
@@ -3203,7 +3223,7 @@ function createRecursiveComponentConfig(componentName) {
3203
3223
  virtualHost: !isCustomWrapper
3204
3224
  }, methods: {
3205
3225
  eh: eventHandler
3206
- } }, lifeCycles);
3226
+ } }, lifeCycles), { isCustomWrapper });
3207
3227
  }
3208
3228
 
3209
3229
  const TIMEOUT = 100;
@@ -3337,6 +3357,7 @@ exports.history = history;
3337
3357
  exports.hydrate = hydrate;
3338
3358
  exports.incrementId = incrementId;
3339
3359
  exports.injectPageInstance = injectPageInstance;
3360
+ exports.isHasExtractProp = isHasExtractProp;
3340
3361
  exports.location = location;
3341
3362
  exports.navigator = nav;
3342
3363
  exports.nextTick = nextTick;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/runtime",
3
- "version": "3.7.0-beta.1",
3
+ "version": "3.7.0-beta.4",
4
4
  "description": "taro runtime for mini apps.",
5
5
  "main:h5": "dist/runtime.h5.js",
6
6
  "main": "dist/runtime.esm.js",
@@ -20,10 +20,10 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "lodash-es": "4.17.21",
23
- "@tarojs/shared": "3.7.0-beta.1"
23
+ "@tarojs/shared": "3.7.0-beta.4"
24
24
  },
25
25
  "devDependencies": {
26
- "@rollup/plugin-buble": "^0.21.3",
26
+ "@rollup/plugin-buble": "^1.0.3",
27
27
  "@rollup/plugin-replace": "^5.0.2",
28
28
  "@rollup/plugin-typescript": "^11.1.0",
29
29
  "@vue/runtime-core": "3.2.41",
@@ -37,7 +37,7 @@
37
37
  "typescript": "^4.7.4"
38
38
  },
39
39
  "scripts": {
40
- "prebuild": "rimraf ./dist",
40
+ "prebuild": "rimraf --impl=move-remove ./dist",
41
41
  "build": "pnpm run rollup",
42
42
  "dev": "pnpm run rollup --environment TARGET:esm -w",
43
43
  "rollup": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript --bundleConfigAsCjs",