@tarojs/runtime 4.0.7-alpha.0 → 4.0.7-alpha.2

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.
package/dist/index.d.ts CHANGED
@@ -29,6 +29,6 @@ export { nextTick } from "./next-tick.js";
29
29
  export { options } from "./options.js";
30
30
  export * from "./perf.js";
31
31
  export * from "./utils/index.js";
32
- export * from "./instance-3211dc5e.js";
32
+ export * from "./instance-4c64b022.js";
33
33
  export * from "./index-26658829.js";
34
34
  export * from "./polyfill/index.js";
@@ -68,7 +68,7 @@ interface MiniElementData {
68
68
  [Shortcuts.Class]?: string;
69
69
  [Shortcuts.Style]?: string;
70
70
  uid?: string;
71
- [Shortcuts.Sid]: string;
71
+ sid: string;
72
72
  [key: string]: unknown;
73
73
  }
74
74
  interface MiniTextData {
@@ -163,7 +163,7 @@ interface RemoveChildOptions {
163
163
  }
164
164
  declare class TaroNode extends TaroEventTarget {
165
165
  uid: string;
166
- [Shortcuts.Sid]: string;
166
+ sid: string;
167
167
  nodeType: NodeType;
168
168
  nodeName: string;
169
169
  parentNode: TaroNode | null;
@@ -113,9 +113,9 @@ class MutationObserverImpl {
113
113
  return this.records.splice(0, this.records.length);
114
114
  }
115
115
  }
116
- /** Match two TaroNodes by [Shortcuts.Sid]. */
116
+ /** Match two TaroNodes by sid. */
117
117
  const sidMatches = (observerTarget, target) => {
118
- return !!observerTarget && observerTarget["s" /* Shortcuts.Sid */] === (target === null || target === void 0 ? void 0 : target["s" /* Shortcuts.Sid */]);
118
+ return !!observerTarget && observerTarget.sid === (target === null || target === void 0 ? void 0 : target.sid);
119
119
  };
120
120
  const isConcerned = (record, options) => {
121
121
  const { characterData, characterDataOldValue, attributes, attributeOldValue, childList } = options;
@@ -1175,7 +1175,7 @@ function shortcutAttr(key) {
1175
1175
  case ID:
1176
1176
  return UID;
1177
1177
  case CLASS:
1178
- return "l" /* Shortcuts.Class */;
1178
+ return "cl" /* Shortcuts.Class */;
1179
1179
  default:
1180
1180
  return key;
1181
1181
  }
@@ -1292,7 +1292,7 @@ class ClassList {
1292
1292
 
1293
1293
  class EventSource extends Map {
1294
1294
  removeNode(child) {
1295
- const { ["s" /* Shortcuts.Sid */]: sid, uid } = child;
1295
+ const { sid, uid } = child;
1296
1296
  this.delete(sid);
1297
1297
  if (uid !== sid && uid)
1298
1298
  this.delete(uid);
@@ -1323,26 +1323,26 @@ function hydrate(node) {
1323
1323
  let compileModeName = null;
1324
1324
  if (isText(node)) {
1325
1325
  return {
1326
- ["s" /* Shortcuts.Sid */]: node["s" /* Shortcuts.Sid */],
1326
+ sid: node.sid,
1327
1327
  ["v" /* Shortcuts.Text */]: node.nodeValue,
1328
- ["n" /* Shortcuts.NodeName */]: ((_a = componentsAlias[nodeName]) === null || _a === void 0 ? void 0 : _a._num) || '8'
1328
+ ["nn" /* Shortcuts.NodeName */]: ((_a = componentsAlias[nodeName]) === null || _a === void 0 ? void 0 : _a._num) || '8'
1329
1329
  };
1330
1330
  }
1331
1331
  const data = {
1332
- ["n" /* Shortcuts.NodeName */]: nodeName,
1333
- ["s" /* Shortcuts.Sid */]: node["s" /* Shortcuts.Sid */]
1332
+ ["nn" /* Shortcuts.NodeName */]: nodeName,
1333
+ sid: node.sid
1334
1334
  };
1335
- if (node.uid !== node["s" /* Shortcuts.Sid */]) {
1335
+ if (node.uid !== node.sid) {
1336
1336
  data.uid = node.uid;
1337
1337
  }
1338
1338
  if (!node.isAnyEventBinded() && SPECIAL_NODES.indexOf(nodeName) > -1) {
1339
- data["n" /* Shortcuts.NodeName */] = `static-${nodeName}`;
1339
+ data["nn" /* Shortcuts.NodeName */] = `static-${nodeName}`;
1340
1340
  if (nodeName === VIEW && !isHasExtractProp(node)) {
1341
- data["n" /* Shortcuts.NodeName */] = PURE_VIEW;
1341
+ data["nn" /* Shortcuts.NodeName */] = PURE_VIEW;
1342
1342
  }
1343
1343
  }
1344
1344
  if (nodeName === VIEW && node.isOnlyClickBinded()) {
1345
- data["n" /* Shortcuts.NodeName */] = CLICK_VIEW;
1345
+ data["nn" /* Shortcuts.NodeName */] = CLICK_VIEW;
1346
1346
  }
1347
1347
  const { props } = node;
1348
1348
  for (const prop in props) {
@@ -1359,26 +1359,26 @@ function hydrate(node) {
1359
1359
  nodeName === VIEW &&
1360
1360
  propInCamelCase === CATCHMOVE &&
1361
1361
  props[prop] !== false) {
1362
- data["n" /* Shortcuts.NodeName */] = CATCH_VIEW;
1362
+ data["nn" /* Shortcuts.NodeName */] = CATCH_VIEW;
1363
1363
  }
1364
1364
  if (propInCamelCase === COMPILE_MODE) {
1365
1365
  compileModeName = props[prop];
1366
1366
  }
1367
1367
  }
1368
1368
  // Children
1369
- data["c" /* Shortcuts.Childnodes */] = node.childNodes.filter(node => !isComment(node)).map(hydrate);
1369
+ data["cn" /* Shortcuts.Childnodes */] = node.childNodes.filter(node => !isComment(node)).map(hydrate);
1370
1370
  if (node.className !== '') {
1371
- data["l" /* Shortcuts.Class */] = node.className;
1371
+ data["cl" /* Shortcuts.Class */] = node.className;
1372
1372
  }
1373
1373
  const cssText = node.cssText;
1374
1374
  if (cssText !== '' && nodeName !== 'swiper-item') {
1375
1375
  data["st" /* Shortcuts.Style */] = cssText;
1376
1376
  }
1377
1377
  hooks.call('modifyHydrateData', data, node);
1378
- const n = data["n" /* Shortcuts.NodeName */];
1379
- const componentAlias = componentsAlias[n];
1378
+ const nn = data["nn" /* Shortcuts.NodeName */];
1379
+ const componentAlias = componentsAlias[nn];
1380
1380
  if (componentAlias) {
1381
- data["n" /* Shortcuts.NodeName */] = componentAlias._num;
1381
+ data["nn" /* Shortcuts.NodeName */] = componentAlias._num;
1382
1382
  for (const prop in data) {
1383
1383
  if (prop in componentAlias) {
1384
1384
  data[componentAlias[prop]] = data[prop];
@@ -1387,7 +1387,7 @@ function hydrate(node) {
1387
1387
  }
1388
1388
  }
1389
1389
  if (compileModeName !== null) {
1390
- data["n" /* Shortcuts.NodeName */] = compileModeName;
1390
+ data["nn" /* Shortcuts.NodeName */] = compileModeName;
1391
1391
  }
1392
1392
  const resData = hooks.call('transferHydrateData', data, node, componentAlias);
1393
1393
  return resData || data;
@@ -1472,7 +1472,7 @@ class TaroEventTarget {
1472
1472
  }
1473
1473
  }
1474
1474
 
1475
- const CHILDNODES = "c" /* Shortcuts.Childnodes */;
1475
+ const CHILDNODES = "cn" /* Shortcuts.Childnodes */;
1476
1476
  const nodeId = incrementId();
1477
1477
  class TaroNode extends TaroEventTarget {
1478
1478
  constructor() {
@@ -1481,8 +1481,8 @@ class TaroNode extends TaroEventTarget {
1481
1481
  this.childNodes = [];
1482
1482
  this.hydrate = (node) => () => hydrate(node);
1483
1483
  this.uid = '_' + nodeId(); // dom 节点 id,开发者可修改
1484
- this["s" /* Shortcuts.Sid */] = this.uid; // dom 节点全局唯一 id,不可被修改
1485
- eventSource.set(this["s" /* Shortcuts.Sid */], this);
1484
+ this.sid = this.uid; // dom 节点全局唯一 id,不可被修改
1485
+ eventSource.set(this.sid, this);
1486
1486
  }
1487
1487
  updateChildNodes(isClean) {
1488
1488
  const cleanChildNodes = () => [];
@@ -1637,13 +1637,13 @@ class TaroNode extends TaroEventTarget {
1637
1637
  // insertBefore 有两种更新模式
1638
1638
  // 比方说有 A B C 三个节点,现在要在 C 前插入 D
1639
1639
  // 1. 插入 D,然后更新整个父节点的 childNodes 数组
1640
- // setData({ c: [A, B, D, C] })
1640
+ // setData({ cn: [A, B, D, C] })
1641
1641
  // 2. 插入 D,然后更新 D 以及 D 之后每个节点的数据
1642
1642
  // setData ({
1643
- // c.[2]: D,
1644
- // c.[3]: C,
1643
+ // cn.[2]: D,
1644
+ // cn.[3]: C,
1645
1645
  // })
1646
- // 由于微信解析 ’c.[2]‘ 这些路径的时候也需要消耗时间,
1646
+ // 由于微信解析 ’cn.[2]‘ 这些路径的时候也需要消耗时间,
1647
1647
  // 所以根据 insertBefore 插入的位置来做不同的处理
1648
1648
  const mark = childNodesLength * 2 / 3;
1649
1649
  if (mark > index) {
@@ -2231,8 +2231,8 @@ class TaroElement extends TaroNode {
2231
2231
  this.style.cssText = value;
2232
2232
  break;
2233
2233
  case ID:
2234
- if (this.uid !== this["s" /* Shortcuts.Sid */]) {
2235
- // eventSource[Shortcuts.Sid] 永远保留,直到组件卸载
2234
+ if (this.uid !== this.sid) {
2235
+ // eventSource[sid] 永远保留,直到组件卸载
2236
2236
  // eventSource[uid] 可变
2237
2237
  eventSource.delete(this.uid);
2238
2238
  }
@@ -2276,14 +2276,14 @@ class TaroElement extends TaroNode {
2276
2276
  // catchMove = true: catch-view
2277
2277
  // catchMove = false: view or static-view
2278
2278
  this.enqueueUpdate({
2279
- path: `${_path}.${"n" /* Shortcuts.NodeName */}`,
2279
+ path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
2280
2280
  value: value ? catchViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias)
2281
2281
  });
2282
2282
  }
2283
2283
  else if (isPureView && isHasExtractProp(this)) {
2284
2284
  // pure-view => static-view
2285
2285
  this.enqueueUpdate({
2286
- path: `${_path}.${"n" /* Shortcuts.NodeName */}`,
2286
+ path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
2287
2287
  value: staticViewAlias
2288
2288
  });
2289
2289
  }
@@ -2335,14 +2335,14 @@ class TaroElement extends TaroNode {
2335
2335
  if (qualifiedNameInCamelCase === CATCHMOVE) {
2336
2336
  // catch-view => view or static-view or pure-view
2337
2337
  this.enqueueUpdate({
2338
- path: `${_path}.${"n" /* Shortcuts.NodeName */}`,
2338
+ path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
2339
2339
  value: this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias)
2340
2340
  });
2341
2341
  }
2342
2342
  else if (isStaticView && !isHasExtractProp(this)) {
2343
2343
  // static-view => pure-view
2344
2344
  this.enqueueUpdate({
2345
- path: `${_path}.${"n" /* Shortcuts.NodeName */}`,
2345
+ path: `${_path}.${"nn" /* Shortcuts.NodeName */}`,
2346
2346
  value: pureViewAlias
2347
2347
  });
2348
2348
  }
@@ -2411,7 +2411,7 @@ class TaroElement extends TaroNode {
2411
2411
  const componentsAlias = getComponentsAlias();
2412
2412
  const alias = componentsAlias[name]._num;
2413
2413
  this.enqueueUpdate({
2414
- path: `${this._path}.${"n" /* Shortcuts.NodeName */}`,
2414
+ path: `${this._path}.${"nn" /* Shortcuts.NodeName */}`,
2415
2415
  value: alias
2416
2416
  });
2417
2417
  }
@@ -2427,7 +2427,7 @@ class TaroElement extends TaroNode {
2427
2427
  const value = isHasExtractProp(this) ? `static-${name}` : `pure-${name}`;
2428
2428
  const valueAlias = componentsAlias[value]._num;
2429
2429
  this.enqueueUpdate({
2430
- path: `${this._path}.${"n" /* Shortcuts.NodeName */}`,
2430
+ path: `${this._path}.${"nn" /* Shortcuts.NodeName */}`,
2431
2431
  value: valueAlias
2432
2432
  });
2433
2433
  }
@@ -3391,9 +3391,9 @@ class TaroEvent {
3391
3391
  const cacheTarget = this.cacheTarget;
3392
3392
  if (!cacheTarget) {
3393
3393
  const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
3394
- const currentEle = env.document.getElementById(((_b = target.dataset) === null || _b === void 0 ? void 0 : _b["s" /* Shortcuts.Sid */]) || target.id || null);
3394
+ const currentEle = env.document.getElementById(((_b = target.dataset) === null || _b === void 0 ? void 0 : _b.sid) || target.id || null);
3395
3395
  // Note:优先判断冒泡场景alipay的targetDataset的sid, 不然冒泡场景target属性吐出不对,其余拿取当前绑定id
3396
- const element = env.document.getElementById(((_c = target.targetDataset) === null || _c === void 0 ? void 0 : _c["s" /* Shortcuts.Sid */]) || ((_d = target.dataset) === null || _d === void 0 ? void 0 : _d["s" /* Shortcuts.Sid */]) || target.id || null);
3396
+ const element = env.document.getElementById(((_c = target.targetDataset) === null || _c === void 0 ? void 0 : _c.sid) || ((_d = target.dataset) === null || _d === void 0 ? void 0 : _d.sid) || target.id || null);
3397
3397
  target.dataset = Object.assign(Object.assign({}, (currentEle !== null ? currentEle.dataset : EMPTY_OBJ)), (element !== null ? element.dataset : EMPTY_OBJ));
3398
3398
  for (const key in (_e = this.mpEvent) === null || _e === void 0 ? void 0 : _e.detail) {
3399
3399
  target[key] = this.mpEvent.detail[key];
@@ -3411,8 +3411,8 @@ class TaroEvent {
3411
3411
  if (!cacheCurrentTarget) {
3412
3412
  const doc = env.document;
3413
3413
  const currentTarget = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget) || null);
3414
- const element = doc.getElementById(((_b = currentTarget.dataset) === null || _b === void 0 ? void 0 : _b["s" /* Shortcuts.Sid */]) || currentTarget.id || null);
3415
- const targetElement = doc.getElementById(((_e = (_d = (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.target) === null || _d === void 0 ? void 0 : _d.dataset) === null || _e === void 0 ? void 0 : _e["s" /* Shortcuts.Sid */]) || ((_g = (_f = this.mpEvent) === null || _f === void 0 ? void 0 : _f.target) === null || _g === void 0 ? void 0 : _g.id) || null);
3414
+ const element = doc.getElementById(((_b = currentTarget.dataset) === null || _b === void 0 ? void 0 : _b.sid) || currentTarget.id || null);
3415
+ const targetElement = doc.getElementById(((_e = (_d = (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.target) === null || _d === void 0 ? void 0 : _d.dataset) === null || _e === void 0 ? void 0 : _e.sid) || ((_g = (_f = this.mpEvent) === null || _f === void 0 ? void 0 : _f.target) === null || _g === void 0 ? void 0 : _g.id) || null);
3416
3416
  if (element === null || (element && element === targetElement)) {
3417
3417
  this.cacheCurrentTarget = this.target;
3418
3418
  return this.target;
@@ -3470,7 +3470,7 @@ function eventHandler(event) {
3470
3470
  event.currentTarget = event.currentTarget || event.target || Object.assign({}, event);
3471
3471
  hooks.call('modifyMpEventImpl', event);
3472
3472
  const currentTarget = event.currentTarget;
3473
- const id = ((_a = currentTarget.dataset) === null || _a === void 0 ? void 0 : _a["s" /* Shortcuts.Sid */] /** sid */) || currentTarget.id /** uid */ || ((_b = event.detail) === null || _b === void 0 ? void 0 : _b.id) || '';
3473
+ const id = ((_a = currentTarget.dataset) === null || _a === void 0 ? void 0 : _a.sid /** sid */) || currentTarget.id /** uid */ || ((_b = event.detail) === null || _b === void 0 ? void 0 : _b.id) || '';
3474
3474
  const node = env.document.getElementById(id);
3475
3475
  if (node) {
3476
3476
  const dispatch = () => {
@@ -3580,7 +3580,7 @@ _Performance_instances = new WeakSet(), _Performance_parseTime = function _Perfo
3580
3580
  const perf = new Performance();
3581
3581
 
3582
3582
  function findCustomWrapper(root, dataPathArr) {
3583
- // ['root', 'c', '[0]'] remove 'root' => ['c', '[0]']
3583
+ // ['root', 'cn', '[0]'] remove 'root' => ['cn', '[0]']
3584
3584
  const list = dataPathArr.slice(1);
3585
3585
  let currentData = root;
3586
3586
  let customWrapper;
@@ -3589,8 +3589,8 @@ function findCustomWrapper(root, dataPathArr) {
3589
3589
  const key = item
3590
3590
  // '[0]' => '0'
3591
3591
  .replace(/^\[(.+)\]$/, '$1')
3592
- // 'c' => 'Shortcuts.Childnodes'
3593
- .replace(/\bc\b/g, 'childNodes');
3592
+ // 'cn' => 'childNodes'
3593
+ .replace(/\bcn\b/g, 'childNodes');
3594
3594
  currentData = currentData[key];
3595
3595
  if (isArray(currentData)) {
3596
3596
  currentData = currentData.filter(el => !isComment(el));
@@ -3598,7 +3598,7 @@ function findCustomWrapper(root, dataPathArr) {
3598
3598
  if (isUndefined(currentData))
3599
3599
  return true;
3600
3600
  if (currentData.nodeName === CUSTOM_WRAPPER) {
3601
- const res = customWrapperCache.get(currentData["s" /* Shortcuts.Sid */]);
3601
+ const res = customWrapperCache.get(currentData.sid);
3602
3602
  if (res) {
3603
3603
  customWrapper = res;
3604
3604
  splitedPath = dataPathArr.slice(i + 2).join('.');
@@ -3656,11 +3656,11 @@ class TaroRootElement extends TaroElement {
3656
3656
  perf.start(setDataMark);
3657
3657
  const data = Object.create(null);
3658
3658
  const resetPaths = new Set(initRender
3659
- ? [`root.${"c" /* Shortcuts.Childnodes */}.[0]`, `root.${"c" /* Shortcuts.Childnodes */}[0]`]
3659
+ ? ['root.cn.[0]', 'root.cn[0]']
3660
3660
  : []);
3661
3661
  while (this.updatePayloads.length > 0) {
3662
3662
  const { path, value } = this.updatePayloads.shift();
3663
- if (path.endsWith("c" /* Shortcuts.Childnodes */)) {
3663
+ if (path.endsWith("cn" /* Shortcuts.Childnodes */)) {
3664
3664
  resetPaths.add(path);
3665
3665
  }
3666
3666
  data[path] = value;
@@ -4235,7 +4235,7 @@ function createRecursiveComponentConfig(componentName) {
4235
4235
  ? {
4236
4236
  [ATTACHED]() {
4237
4237
  var _a, _b;
4238
- const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a["s" /* Shortcuts.Sid */]) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b["s" /* Shortcuts.Sid */]);
4238
+ const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b.sid);
4239
4239
  if (isString(componentId)) {
4240
4240
  customWrapperCache.set(componentId, this);
4241
4241
  const el = env.document.getElementById(componentId);
@@ -4246,7 +4246,7 @@ function createRecursiveComponentConfig(componentName) {
4246
4246
  },
4247
4247
  [DETACHED]() {
4248
4248
  var _a, _b;
4249
- const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a["s" /* Shortcuts.Sid */]) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b["s" /* Shortcuts.Sid */]);
4249
+ const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b.sid);
4250
4250
  if (isString(componentId)) {
4251
4251
  customWrapperCache.delete(componentId);
4252
4252
  const el = env.document.getElementById(componentId);
@@ -4261,7 +4261,7 @@ function createRecursiveComponentConfig(componentName) {
4261
4261
  i: {
4262
4262
  type: Object,
4263
4263
  value: {
4264
- ["n" /* Shortcuts.NodeName */]: getComponentsAlias$1(internalComponents)[VIEW]._num
4264
+ ["nn" /* Shortcuts.NodeName */]: getComponentsAlias$1(internalComponents)[VIEW]._num
4265
4265
  }
4266
4266
  },
4267
4267
  l: {