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