@tarojs/runtime 3.7.0-alpha.25 → 3.7.0-alpha.27
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/runtime.cjs.d.ts +21 -2
- package/dist/runtime.cjs.js +72 -37
- package/dist/runtime.esm.d.ts +21 -2
- package/dist/runtime.esm.js +52 -38
- package/dist/runtime.esm.js.map +1 -1
- package/dist/runtime.h5.d.ts +21 -2
- package/dist/runtime.h5.js +58 -33
- package/package.json +4 -4
package/dist/runtime.cjs.d.ts
CHANGED
|
@@ -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.
|
|
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;
|
|
@@ -626,6 +626,7 @@ declare const KEY_CODE = "keyCode";
|
|
|
626
626
|
declare const TOUCHMOVE = "touchmove";
|
|
627
627
|
declare const DATE = "Date";
|
|
628
628
|
declare const SET_TIMEOUT = "setTimeout";
|
|
629
|
+
declare const COMPILE_MODE = "compileMode";
|
|
629
630
|
declare const CATCHMOVE = "catchMove";
|
|
630
631
|
declare const CATCH_VIEW = "catch-view";
|
|
631
632
|
declare const COMMENT = "comment";
|
|
@@ -776,5 +777,23 @@ declare function hydrate(node: TaroElement | TaroText): MiniData;
|
|
|
776
777
|
declare const nextTick: (cb: Func, ctx?: Record<string, any>) => void;
|
|
777
778
|
declare const options: Options;
|
|
778
779
|
declare const incrementId: () => () => string;
|
|
780
|
+
declare function isElement(node: TaroNode): node is TaroElement;
|
|
781
|
+
declare function isText(node: TaroNode): node is TaroText;
|
|
782
|
+
declare function isComment(node: TaroNode): boolean;
|
|
783
|
+
declare function isHasExtractProp(el: TaroElement): boolean;
|
|
784
|
+
/**
|
|
785
|
+
* 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
|
|
786
|
+
* @param node 当前组件
|
|
787
|
+
* @param type 事件类型
|
|
788
|
+
*/
|
|
789
|
+
declare function isParentBinded(node: TaroElement | null, type: string): boolean;
|
|
790
|
+
declare function shortcutAttr(key: string): string;
|
|
791
|
+
declare const customWrapperCache: Map<string, Record<string, any>>;
|
|
792
|
+
interface Ctor {
|
|
793
|
+
new (...args: any[]): any;
|
|
794
|
+
}
|
|
795
|
+
declare function extend(ctor: Ctor, methodName: string, options: Func | Record<string, any>): void;
|
|
796
|
+
declare function getComponentsAlias(): any;
|
|
797
|
+
declare function convertNumber2PX(value: number): string;
|
|
779
798
|
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 };
|
|
799
|
+
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, COMPILE_MODE, 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, isElement, isText, isComment, isHasExtractProp, isParentBinded, shortcutAttr, customWrapperCache, extend, getComponentsAlias, convertNumber2PX, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniTextData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };
|
package/dist/runtime.cjs.js
CHANGED
|
@@ -39,6 +39,7 @@ var KEY_CODE = 'keyCode';
|
|
|
39
39
|
var TOUCHMOVE = 'touchmove';
|
|
40
40
|
var DATE = 'Date';
|
|
41
41
|
var SET_TIMEOUT = 'setTimeout';
|
|
42
|
+
var COMPILE_MODE = 'compileMode';
|
|
42
43
|
var CATCHMOVE = 'catchMove';
|
|
43
44
|
var CATCH_VIEW = 'catch-view';
|
|
44
45
|
var COMMENT = 'comment';
|
|
@@ -176,7 +177,7 @@ var MutationObserver = function MutationObserver(callback) {
|
|
|
176
177
|
}
|
|
177
178
|
else {
|
|
178
179
|
if (process.env.NODE_ENV !== 'production') {
|
|
179
|
-
console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \'mini.enableMutationObserver: true\'');
|
|
180
|
+
console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \'mini.runtime.enableMutationObserver: true\'');
|
|
180
181
|
}
|
|
181
182
|
this.core = {
|
|
182
183
|
observe: shared.noop,
|
|
@@ -253,15 +254,15 @@ function isHasExtractProp(el) {
|
|
|
253
254
|
*/
|
|
254
255
|
function isParentBinded(node, type) {
|
|
255
256
|
var _a;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
257
|
+
while ((node = (node === null || node === void 0 ? void 0 : node.parentElement) || null)) {
|
|
258
|
+
if (!node || node.nodeName === ROOT_STR || node.nodeName === 'root-portal') {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
else if ((_a = node.__handlers[type]) === null || _a === void 0 ? void 0 : _a.length) {
|
|
262
|
+
return true;
|
|
261
263
|
}
|
|
262
|
-
node = node.parentElement;
|
|
263
264
|
}
|
|
264
|
-
return
|
|
265
|
+
return false;
|
|
265
266
|
}
|
|
266
267
|
function shortcutAttr(key) {
|
|
267
268
|
switch (key) {
|
|
@@ -291,6 +292,9 @@ function getComponentsAlias() {
|
|
|
291
292
|
}
|
|
292
293
|
return componentsAlias$1;
|
|
293
294
|
}
|
|
295
|
+
function convertNumber2PX(value) {
|
|
296
|
+
return value + 'px';
|
|
297
|
+
}
|
|
294
298
|
|
|
295
299
|
var ClassList = function ClassList(className, el) {
|
|
296
300
|
var this$1$1 = this;
|
|
@@ -414,10 +418,10 @@ var EventSource = /*@__PURE__*/(function (Map) {
|
|
|
414
418
|
}(Map));
|
|
415
419
|
var eventSource = new EventSource();
|
|
416
420
|
|
|
417
|
-
var isWeb$
|
|
421
|
+
var isWeb$2 = shared.isWebPlatform();
|
|
418
422
|
var env = {
|
|
419
|
-
window: isWeb$
|
|
420
|
-
document: isWeb$
|
|
423
|
+
window: isWeb$2 ? window : shared.EMPTY_OBJ,
|
|
424
|
+
document: isWeb$2 ? document : shared.EMPTY_OBJ
|
|
421
425
|
};
|
|
422
426
|
|
|
423
427
|
var SPECIAL_NODES;
|
|
@@ -432,14 +436,10 @@ function hydrate(node) {
|
|
|
432
436
|
var obj;
|
|
433
437
|
|
|
434
438
|
var _a;
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
if (!SPECIAL_NODES) {
|
|
440
|
-
// 初始化 SPECIAL_NODES
|
|
441
|
-
SPECIAL_NODES = shared.hooks.call('getSpecialNodes');
|
|
442
|
-
}
|
|
439
|
+
// 初始化 componentsAlias
|
|
440
|
+
componentsAlias || (componentsAlias = getComponentsAlias());
|
|
441
|
+
// 初始化 SPECIAL_NODES
|
|
442
|
+
SPECIAL_NODES || (SPECIAL_NODES = shared.hooks.call('getSpecialNodes'));
|
|
443
443
|
var nodeName = node.nodeName;
|
|
444
444
|
if (isText(node)) {
|
|
445
445
|
return ( obj = {
|
|
@@ -465,22 +465,19 @@ function hydrate(node) {
|
|
|
465
465
|
prop !== CLASS &&
|
|
466
466
|
prop !== STYLE &&
|
|
467
467
|
prop !== ID &&
|
|
468
|
-
propInCamelCase !== CATCHMOVE
|
|
468
|
+
propInCamelCase !== CATCHMOVE &&
|
|
469
|
+
propInCamelCase !== COMPILE_MODE) {
|
|
469
470
|
data[propInCamelCase] = props[prop];
|
|
470
471
|
}
|
|
471
472
|
if (nodeName === VIEW && propInCamelCase === CATCHMOVE && props[prop] !== false) {
|
|
472
473
|
data["nn" /* Shortcuts.NodeName */] = CATCH_VIEW;
|
|
473
474
|
}
|
|
475
|
+
if (propInCamelCase === COMPILE_MODE) {
|
|
476
|
+
data["nn" /* Shortcuts.NodeName */] = props[prop];
|
|
477
|
+
}
|
|
474
478
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
childNodes = childNodes.filter(function (node) { return !isComment(node); });
|
|
478
|
-
if (childNodes.length > 0) {
|
|
479
|
-
data["cn" /* Shortcuts.Childnodes */] = childNodes.map(hydrate);
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
data["cn" /* Shortcuts.Childnodes */] = [];
|
|
483
|
-
}
|
|
479
|
+
// Children
|
|
480
|
+
data["cn" /* Shortcuts.Childnodes */] = node.childNodes.filter(function (node) { return !isComment(node); }).map(hydrate);
|
|
484
481
|
if (node.className !== '') {
|
|
485
482
|
data["cl" /* Shortcuts.Class */] = node.className;
|
|
486
483
|
}
|
|
@@ -488,7 +485,7 @@ function hydrate(node) {
|
|
|
488
485
|
if (cssText !== '' && nodeName !== 'swiper-item') {
|
|
489
486
|
data["st" /* Shortcuts.Style */] = cssText;
|
|
490
487
|
}
|
|
491
|
-
shared.hooks.call('modifyHydrateData', data);
|
|
488
|
+
shared.hooks.call('modifyHydrateData', data, node);
|
|
492
489
|
var nn = data["nn" /* Shortcuts.NodeName */];
|
|
493
490
|
var componentAlias = componentsAlias[nn];
|
|
494
491
|
if (componentAlias) {
|
|
@@ -500,7 +497,8 @@ function hydrate(node) {
|
|
|
500
497
|
}
|
|
501
498
|
}
|
|
502
499
|
}
|
|
503
|
-
|
|
500
|
+
var resData = shared.hooks.call('transferHydrateData', data, node, componentAlias);
|
|
501
|
+
return resData || data;
|
|
504
502
|
}
|
|
505
503
|
|
|
506
504
|
var TaroEventTarget = function TaroEventTarget() {
|
|
@@ -1509,9 +1507,6 @@ var TaroElement = /*@__PURE__*/(function (TaroNode) {
|
|
|
1509
1507
|
if (event._stop) {
|
|
1510
1508
|
this._stopPropagation(event);
|
|
1511
1509
|
}
|
|
1512
|
-
else {
|
|
1513
|
-
event._stop = true;
|
|
1514
|
-
}
|
|
1515
1510
|
return listeners != null;
|
|
1516
1511
|
};
|
|
1517
1512
|
TaroElement.prototype.addEventListener = function addEventListener (type, handler, options) {
|
|
@@ -1522,6 +1517,7 @@ var TaroElement = /*@__PURE__*/(function (TaroNode) {
|
|
|
1522
1517
|
sideEffect = false;
|
|
1523
1518
|
delete options.sideEffect;
|
|
1524
1519
|
}
|
|
1520
|
+
shared.hooks.call('modifyAddEventListener', this, sideEffect, getComponentsAlias);
|
|
1525
1521
|
if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
|
|
1526
1522
|
var componentsAlias = getComponentsAlias();
|
|
1527
1523
|
var alias = componentsAlias[name]._num;
|
|
@@ -1538,6 +1534,7 @@ var TaroElement = /*@__PURE__*/(function (TaroNode) {
|
|
|
1538
1534
|
TaroNode.prototype.removeEventListener.call(this, type, handler);
|
|
1539
1535
|
var name = this.nodeName;
|
|
1540
1536
|
var SPECIAL_NODES = shared.hooks.call('getSpecialNodes');
|
|
1537
|
+
shared.hooks.call('modifyRemoveEventListener', this, sideEffect, getComponentsAlias);
|
|
1541
1538
|
if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
|
|
1542
1539
|
var componentsAlias = getComponentsAlias();
|
|
1543
1540
|
var value = isHasExtractProp(this) ? ("static-" + name) : ("pure-" + name);
|
|
@@ -2485,7 +2482,9 @@ function contains(node) {
|
|
|
2485
2482
|
return isContains;
|
|
2486
2483
|
}
|
|
2487
2484
|
|
|
2488
|
-
|
|
2485
|
+
var isWeb$1 = shared.isWebPlatform();
|
|
2486
|
+
var isHarmony = process.env.TARO_PLATFORM === 'harmony' || process.env.TARO_ENV === 'harmony';
|
|
2487
|
+
if (!isWeb$1 && !isHarmony) {
|
|
2489
2488
|
if (ENABLE_INNER_HTML) {
|
|
2490
2489
|
TaroNode.extend('innerHTML', {
|
|
2491
2490
|
set: function set(html) {
|
|
@@ -3401,6 +3400,27 @@ var AnchorElement = /*@__PURE__*/(function (TaroElement) {
|
|
|
3401
3400
|
return AnchorElement;
|
|
3402
3401
|
}(TaroElement));
|
|
3403
3402
|
|
|
3403
|
+
var TransferElement = /*@__PURE__*/(function (TaroElement) {
|
|
3404
|
+
function TransferElement(dataName) {
|
|
3405
|
+
TaroElement.call(this);
|
|
3406
|
+
this.dataName = dataName;
|
|
3407
|
+
this.isTransferElement = true;
|
|
3408
|
+
}
|
|
3409
|
+
|
|
3410
|
+
if ( TaroElement ) TransferElement.__proto__ = TaroElement;
|
|
3411
|
+
TransferElement.prototype = Object.create( TaroElement && TaroElement.prototype );
|
|
3412
|
+
TransferElement.prototype.constructor = TransferElement;
|
|
3413
|
+
|
|
3414
|
+
var prototypeAccessors = { _path: { configurable: true } };
|
|
3415
|
+
prototypeAccessors._path.get = function () {
|
|
3416
|
+
return this.dataName;
|
|
3417
|
+
};
|
|
3418
|
+
|
|
3419
|
+
Object.defineProperties( TransferElement.prototype, prototypeAccessors );
|
|
3420
|
+
|
|
3421
|
+
return TransferElement;
|
|
3422
|
+
}(TaroElement));
|
|
3423
|
+
|
|
3404
3424
|
var TaroDocument = /*@__PURE__*/(function (TaroElement) {
|
|
3405
3425
|
function TaroDocument() {
|
|
3406
3426
|
TaroElement.call(this);
|
|
@@ -3427,6 +3447,10 @@ var TaroDocument = /*@__PURE__*/(function (TaroElement) {
|
|
|
3427
3447
|
case nodeName === A:
|
|
3428
3448
|
element = new AnchorElement();
|
|
3429
3449
|
break;
|
|
3450
|
+
case nodeName === 'page-meta':
|
|
3451
|
+
case nodeName === 'navigation-bar':
|
|
3452
|
+
element = new TransferElement(shared.toCamelCase(nodeName));
|
|
3453
|
+
break;
|
|
3430
3454
|
default:
|
|
3431
3455
|
element = new TaroElement();
|
|
3432
3456
|
break;
|
|
@@ -4423,7 +4447,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4423
4447
|
}
|
|
4424
4448
|
}, obj )
|
|
4425
4449
|
: shared.EMPTY_OBJ;
|
|
4426
|
-
return Object.assign({ properties: {
|
|
4450
|
+
return shared.hooks.call('modifyRecursiveComponentConfig', Object.assign({ properties: {
|
|
4427
4451
|
i: {
|
|
4428
4452
|
type: Object,
|
|
4429
4453
|
value: ( obj$1 = {}, obj$1["nn" /* Shortcuts.NodeName */] = shared.getComponentsAlias(shared.internalComponents)[VIEW]._num, obj$1 )
|
|
@@ -4437,7 +4461,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4437
4461
|
virtualHost: !isCustomWrapper
|
|
4438
4462
|
}, methods: {
|
|
4439
4463
|
eh: eventHandler
|
|
4440
|
-
} }, lifeCycles);
|
|
4464
|
+
} }, lifeCycles), { isCustomWrapper: isCustomWrapper });
|
|
4441
4465
|
}
|
|
4442
4466
|
|
|
4443
4467
|
var TIMEOUT = 100;
|
|
@@ -4499,6 +4523,7 @@ exports.CATCH_VIEW = CATCH_VIEW;
|
|
|
4499
4523
|
exports.CHANGE = CHANGE;
|
|
4500
4524
|
exports.CLASS = CLASS;
|
|
4501
4525
|
exports.COMMENT = COMMENT;
|
|
4526
|
+
exports.COMPILE_MODE = COMPILE_MODE;
|
|
4502
4527
|
exports.CONFIRM = CONFIRM;
|
|
4503
4528
|
exports.CONTAINER = CONTAINER;
|
|
4504
4529
|
exports.CURRENT_TARGET = CURRENT_TARGET;
|
|
@@ -4555,14 +4580,18 @@ exports.VALUE = VALUE;
|
|
|
4555
4580
|
exports.VIEW = VIEW;
|
|
4556
4581
|
exports.addLeadingSlash = addLeadingSlash;
|
|
4557
4582
|
exports.cancelAnimationFrame = _caf;
|
|
4583
|
+
exports.convertNumber2PX = convertNumber2PX;
|
|
4558
4584
|
exports.createComponentConfig = createComponentConfig;
|
|
4559
4585
|
exports.createEvent = createEvent;
|
|
4560
4586
|
exports.createPageConfig = createPageConfig;
|
|
4561
4587
|
exports.createRecursiveComponentConfig = createRecursiveComponentConfig;
|
|
4588
|
+
exports.customWrapperCache = customWrapperCache;
|
|
4562
4589
|
exports.env = env;
|
|
4563
4590
|
exports.eventCenter = eventCenter;
|
|
4564
4591
|
exports.eventHandler = eventHandler;
|
|
4565
4592
|
exports.eventSource = eventSource;
|
|
4593
|
+
exports.extend = extend;
|
|
4594
|
+
exports.getComponentsAlias = getComponentsAlias;
|
|
4566
4595
|
exports.getComputedStyle = getComputedStyle;
|
|
4567
4596
|
exports.getCurrentInstance = getCurrentInstance;
|
|
4568
4597
|
exports.getOnHideEventKey = getOnHideEventKey;
|
|
@@ -4574,6 +4603,11 @@ exports.history = history;
|
|
|
4574
4603
|
exports.hydrate = hydrate;
|
|
4575
4604
|
exports.incrementId = incrementId;
|
|
4576
4605
|
exports.injectPageInstance = injectPageInstance;
|
|
4606
|
+
exports.isComment = isComment;
|
|
4607
|
+
exports.isElement = isElement;
|
|
4608
|
+
exports.isHasExtractProp = isHasExtractProp;
|
|
4609
|
+
exports.isParentBinded = isParentBinded;
|
|
4610
|
+
exports.isText = isText;
|
|
4577
4611
|
exports.location = location;
|
|
4578
4612
|
exports.navigator = nav;
|
|
4579
4613
|
exports.nextTick = nextTick;
|
|
@@ -4582,4 +4616,5 @@ exports.parseUrl = parseUrl;
|
|
|
4582
4616
|
exports.removePageInstance = removePageInstance;
|
|
4583
4617
|
exports.requestAnimationFrame = _raf;
|
|
4584
4618
|
exports.safeExecute = safeExecute;
|
|
4619
|
+
exports.shortcutAttr = shortcutAttr;
|
|
4585
4620
|
exports.stringify = stringify;
|
package/dist/runtime.esm.d.ts
CHANGED
|
@@ -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.
|
|
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;
|
|
@@ -626,6 +626,7 @@ declare const KEY_CODE = "keyCode";
|
|
|
626
626
|
declare const TOUCHMOVE = "touchmove";
|
|
627
627
|
declare const DATE = "Date";
|
|
628
628
|
declare const SET_TIMEOUT = "setTimeout";
|
|
629
|
+
declare const COMPILE_MODE = "compileMode";
|
|
629
630
|
declare const CATCHMOVE = "catchMove";
|
|
630
631
|
declare const CATCH_VIEW = "catch-view";
|
|
631
632
|
declare const COMMENT = "comment";
|
|
@@ -776,5 +777,23 @@ declare function hydrate(node: TaroElement | TaroText): MiniData;
|
|
|
776
777
|
declare const nextTick: (cb: Func, ctx?: Record<string, any>) => void;
|
|
777
778
|
declare const options: Options;
|
|
778
779
|
declare const incrementId: () => () => string;
|
|
780
|
+
declare function isElement(node: TaroNode): node is TaroElement;
|
|
781
|
+
declare function isText(node: TaroNode): node is TaroText;
|
|
782
|
+
declare function isComment(node: TaroNode): boolean;
|
|
783
|
+
declare function isHasExtractProp(el: TaroElement): boolean;
|
|
784
|
+
/**
|
|
785
|
+
* 往上寻找组件树直到 root,寻找是否有祖先组件绑定了同类型的事件
|
|
786
|
+
* @param node 当前组件
|
|
787
|
+
* @param type 事件类型
|
|
788
|
+
*/
|
|
789
|
+
declare function isParentBinded(node: TaroElement | null, type: string): boolean;
|
|
790
|
+
declare function shortcutAttr(key: string): string;
|
|
791
|
+
declare const customWrapperCache: Map<string, Record<string, any>>;
|
|
792
|
+
interface Ctor {
|
|
793
|
+
new (...args: any[]): any;
|
|
794
|
+
}
|
|
795
|
+
declare function extend(ctor: Ctor, methodName: string, options: Func | Record<string, any>): void;
|
|
796
|
+
declare function getComponentsAlias(): any;
|
|
797
|
+
declare function convertNumber2PX(value: number): string;
|
|
779
798
|
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 };
|
|
799
|
+
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, COMPILE_MODE, 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, isElement, isText, isComment, isHasExtractProp, isParentBinded, shortcutAttr, customWrapperCache, extend, getComponentsAlias, convertNumber2PX, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniTextData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };
|
package/dist/runtime.esm.js
CHANGED
|
@@ -38,6 +38,7 @@ const KEY_CODE = 'keyCode';
|
|
|
38
38
|
const TOUCHMOVE = 'touchmove';
|
|
39
39
|
const DATE = 'Date';
|
|
40
40
|
const SET_TIMEOUT = 'setTimeout';
|
|
41
|
+
const COMPILE_MODE = 'compileMode';
|
|
41
42
|
const CATCHMOVE = 'catchMove';
|
|
42
43
|
const CATCH_VIEW = 'catch-view';
|
|
43
44
|
const COMMENT = 'comment';
|
|
@@ -174,7 +175,7 @@ class MutationObserver {
|
|
|
174
175
|
}
|
|
175
176
|
else {
|
|
176
177
|
if (process.env.NODE_ENV !== 'production') {
|
|
177
|
-
console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \'mini.enableMutationObserver: true\'');
|
|
178
|
+
console.warn('[Taro Warning] 若要使用 MutationObserver,请在 Taro 编译配置中设置 \'mini.runtime.enableMutationObserver: true\'');
|
|
178
179
|
}
|
|
179
180
|
this.core = {
|
|
180
181
|
observe: noop,
|
|
@@ -248,15 +249,15 @@ function isHasExtractProp(el) {
|
|
|
248
249
|
*/
|
|
249
250
|
function isParentBinded(node, type) {
|
|
250
251
|
var _a;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
252
|
+
while ((node = (node === null || node === void 0 ? void 0 : node.parentElement) || null)) {
|
|
253
|
+
if (!node || node.nodeName === ROOT_STR || node.nodeName === 'root-portal') {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
256
|
+
else if ((_a = node.__handlers[type]) === null || _a === void 0 ? void 0 : _a.length) {
|
|
257
|
+
return true;
|
|
256
258
|
}
|
|
257
|
-
node = node.parentElement;
|
|
258
259
|
}
|
|
259
|
-
return
|
|
260
|
+
return false;
|
|
260
261
|
}
|
|
261
262
|
function shortcutAttr(key) {
|
|
262
263
|
switch (key) {
|
|
@@ -286,6 +287,9 @@ function getComponentsAlias() {
|
|
|
286
287
|
}
|
|
287
288
|
return componentsAlias$1;
|
|
288
289
|
}
|
|
290
|
+
function convertNumber2PX(value) {
|
|
291
|
+
return value + 'px';
|
|
292
|
+
}
|
|
289
293
|
|
|
290
294
|
class ClassList {
|
|
291
295
|
constructor(className, el) {
|
|
@@ -392,10 +396,10 @@ class EventSource extends Map {
|
|
|
392
396
|
}
|
|
393
397
|
const eventSource = new EventSource();
|
|
394
398
|
|
|
395
|
-
const isWeb$
|
|
399
|
+
const isWeb$2 = isWebPlatform();
|
|
396
400
|
const env = {
|
|
397
|
-
window: isWeb$
|
|
398
|
-
document: isWeb$
|
|
401
|
+
window: isWeb$2 ? window : EMPTY_OBJ,
|
|
402
|
+
document: isWeb$2 ? document : EMPTY_OBJ
|
|
399
403
|
};
|
|
400
404
|
|
|
401
405
|
let SPECIAL_NODES;
|
|
@@ -408,14 +412,10 @@ let componentsAlias;
|
|
|
408
412
|
*/
|
|
409
413
|
function hydrate(node) {
|
|
410
414
|
var _a;
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
if (!SPECIAL_NODES) {
|
|
416
|
-
// 初始化 SPECIAL_NODES
|
|
417
|
-
SPECIAL_NODES = hooks.call('getSpecialNodes');
|
|
418
|
-
}
|
|
415
|
+
// 初始化 componentsAlias
|
|
416
|
+
componentsAlias || (componentsAlias = getComponentsAlias());
|
|
417
|
+
// 初始化 SPECIAL_NODES
|
|
418
|
+
SPECIAL_NODES || (SPECIAL_NODES = hooks.call('getSpecialNodes'));
|
|
419
419
|
const nodeName = node.nodeName;
|
|
420
420
|
if (isText(node)) {
|
|
421
421
|
return {
|
|
@@ -444,22 +444,19 @@ function hydrate(node) {
|
|
|
444
444
|
prop !== CLASS &&
|
|
445
445
|
prop !== STYLE &&
|
|
446
446
|
prop !== ID &&
|
|
447
|
-
propInCamelCase !== CATCHMOVE
|
|
447
|
+
propInCamelCase !== CATCHMOVE &&
|
|
448
|
+
propInCamelCase !== COMPILE_MODE) {
|
|
448
449
|
data[propInCamelCase] = props[prop];
|
|
449
450
|
}
|
|
450
451
|
if (nodeName === VIEW && propInCamelCase === CATCHMOVE && props[prop] !== false) {
|
|
451
452
|
data["nn" /* Shortcuts.NodeName */] = CATCH_VIEW;
|
|
452
453
|
}
|
|
454
|
+
if (propInCamelCase === COMPILE_MODE) {
|
|
455
|
+
data["nn" /* Shortcuts.NodeName */] = props[prop];
|
|
456
|
+
}
|
|
453
457
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
childNodes = childNodes.filter(node => !isComment(node));
|
|
457
|
-
if (childNodes.length > 0) {
|
|
458
|
-
data["cn" /* Shortcuts.Childnodes */] = childNodes.map(hydrate);
|
|
459
|
-
}
|
|
460
|
-
else {
|
|
461
|
-
data["cn" /* Shortcuts.Childnodes */] = [];
|
|
462
|
-
}
|
|
458
|
+
// Children
|
|
459
|
+
data["cn" /* Shortcuts.Childnodes */] = node.childNodes.filter(node => !isComment(node)).map(hydrate);
|
|
463
460
|
if (node.className !== '') {
|
|
464
461
|
data["cl" /* Shortcuts.Class */] = node.className;
|
|
465
462
|
}
|
|
@@ -467,7 +464,7 @@ function hydrate(node) {
|
|
|
467
464
|
if (cssText !== '' && nodeName !== 'swiper-item') {
|
|
468
465
|
data["st" /* Shortcuts.Style */] = cssText;
|
|
469
466
|
}
|
|
470
|
-
hooks.call('modifyHydrateData', data);
|
|
467
|
+
hooks.call('modifyHydrateData', data, node);
|
|
471
468
|
const nn = data["nn" /* Shortcuts.NodeName */];
|
|
472
469
|
const componentAlias = componentsAlias[nn];
|
|
473
470
|
if (componentAlias) {
|
|
@@ -479,7 +476,8 @@ function hydrate(node) {
|
|
|
479
476
|
}
|
|
480
477
|
}
|
|
481
478
|
}
|
|
482
|
-
|
|
479
|
+
const resData = hooks.call('transferHydrateData', data, node, componentAlias);
|
|
480
|
+
return resData || data;
|
|
483
481
|
}
|
|
484
482
|
|
|
485
483
|
class TaroEventTarget {
|
|
@@ -1477,9 +1475,6 @@ class TaroElement extends TaroNode {
|
|
|
1477
1475
|
if (event._stop) {
|
|
1478
1476
|
this._stopPropagation(event);
|
|
1479
1477
|
}
|
|
1480
|
-
else {
|
|
1481
|
-
event._stop = true;
|
|
1482
|
-
}
|
|
1483
1478
|
return listeners != null;
|
|
1484
1479
|
}
|
|
1485
1480
|
addEventListener(type, handler, options) {
|
|
@@ -1490,6 +1485,7 @@ class TaroElement extends TaroNode {
|
|
|
1490
1485
|
sideEffect = false;
|
|
1491
1486
|
delete options.sideEffect;
|
|
1492
1487
|
}
|
|
1488
|
+
hooks.call('modifyAddEventListener', this, sideEffect, getComponentsAlias);
|
|
1493
1489
|
if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
|
|
1494
1490
|
const componentsAlias = getComponentsAlias();
|
|
1495
1491
|
const alias = componentsAlias[name]._num;
|
|
@@ -1504,6 +1500,7 @@ class TaroElement extends TaroNode {
|
|
|
1504
1500
|
super.removeEventListener(type, handler);
|
|
1505
1501
|
const name = this.nodeName;
|
|
1506
1502
|
const SPECIAL_NODES = hooks.call('getSpecialNodes');
|
|
1503
|
+
hooks.call('modifyRemoveEventListener', this, sideEffect, getComponentsAlias);
|
|
1507
1504
|
if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
|
|
1508
1505
|
const componentsAlias = getComponentsAlias();
|
|
1509
1506
|
const value = isHasExtractProp(this) ? `static-${name}` : `pure-${name}`;
|
|
@@ -2410,7 +2407,9 @@ function contains(node) {
|
|
|
2410
2407
|
return isContains;
|
|
2411
2408
|
}
|
|
2412
2409
|
|
|
2413
|
-
|
|
2410
|
+
const isWeb$1 = isWebPlatform();
|
|
2411
|
+
const isHarmony = process.env.TARO_PLATFORM === 'harmony' || process.env.TARO_ENV === 'harmony';
|
|
2412
|
+
if (!isWeb$1 && !isHarmony) {
|
|
2414
2413
|
if (ENABLE_INNER_HTML) {
|
|
2415
2414
|
TaroNode.extend('innerHTML', {
|
|
2416
2415
|
set(html) {
|
|
@@ -3247,6 +3246,17 @@ class AnchorElement extends TaroElement {
|
|
|
3247
3246
|
}
|
|
3248
3247
|
}
|
|
3249
3248
|
|
|
3249
|
+
class TransferElement extends TaroElement {
|
|
3250
|
+
constructor(dataName) {
|
|
3251
|
+
super();
|
|
3252
|
+
this.dataName = dataName;
|
|
3253
|
+
this.isTransferElement = true;
|
|
3254
|
+
}
|
|
3255
|
+
get _path() {
|
|
3256
|
+
return this.dataName;
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3250
3260
|
class TaroDocument extends TaroElement {
|
|
3251
3261
|
constructor() {
|
|
3252
3262
|
super();
|
|
@@ -3267,6 +3277,10 @@ class TaroDocument extends TaroElement {
|
|
|
3267
3277
|
case nodeName === A:
|
|
3268
3278
|
element = new AnchorElement();
|
|
3269
3279
|
break;
|
|
3280
|
+
case nodeName === 'page-meta':
|
|
3281
|
+
case nodeName === 'navigation-bar':
|
|
3282
|
+
element = new TransferElement(toCamelCase(nodeName));
|
|
3283
|
+
break;
|
|
3270
3284
|
default:
|
|
3271
3285
|
element = new TaroElement();
|
|
3272
3286
|
break;
|
|
@@ -4172,7 +4186,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4172
4186
|
}
|
|
4173
4187
|
}
|
|
4174
4188
|
: EMPTY_OBJ;
|
|
4175
|
-
return Object.assign({ properties: {
|
|
4189
|
+
return hooks.call('modifyRecursiveComponentConfig', Object.assign({ properties: {
|
|
4176
4190
|
i: {
|
|
4177
4191
|
type: Object,
|
|
4178
4192
|
value: {
|
|
@@ -4188,7 +4202,7 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4188
4202
|
virtualHost: !isCustomWrapper
|
|
4189
4203
|
}, methods: {
|
|
4190
4204
|
eh: eventHandler
|
|
4191
|
-
} }, lifeCycles);
|
|
4205
|
+
} }, lifeCycles), { isCustomWrapper });
|
|
4192
4206
|
}
|
|
4193
4207
|
|
|
4194
4208
|
const TIMEOUT = 100;
|
|
@@ -4233,5 +4247,5 @@ const nextTick = (cb, ctx) => {
|
|
|
4233
4247
|
next();
|
|
4234
4248
|
};
|
|
4235
4249
|
|
|
4236
|
-
export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, COMMENT, 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, 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, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, env, eventCenter, eventHandler, eventSource, getComputedStyle, getCurrentInstance, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, history, hydrate, incrementId, injectPageInstance, location, nav as navigator, nextTick, now, options, parseUrl, removePageInstance, _raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
|
|
4250
|
+
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, 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, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, history, hydrate, incrementId, injectPageInstance, isComment, isElement, isHasExtractProp, isParentBinded, isText, location, nav as navigator, nextTick, now, options, parseUrl, removePageInstance, _raf as requestAnimationFrame, safeExecute, shortcutAttr, stringify, window$1 as window };
|
|
4237
4251
|
//# sourceMappingURL=runtime.esm.js.map
|