@wiajs/core 0.1.12 → 0.1.16
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/build.js +11 -6
- package/dist/core.common.js +200 -120
- package/dist/core.common.min.js +3 -3
- package/dist/core.esm.js +198 -119
- package/dist/core.esm.min.js +3 -3
- package/dist/core.js +202 -122
- package/dist/core.min.js +3 -3
- package/lib/bmap.js +12 -12
- package/package.json +1 -2
- package/util/tool.js +50 -2
- package/util/wiafile.js +41 -26
- package/util/wiapage.js +27 -20
package/build.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const zlib = require('zlib');
|
|
4
|
-
const
|
|
4
|
+
const { minify } = require('terser');
|
|
5
5
|
const rollup = require('rollup');
|
|
6
6
|
|
|
7
7
|
const env = process.env.NODE_ENV || 'development';
|
|
@@ -29,15 +29,20 @@ function buildEntry({input, output}) {
|
|
|
29
29
|
return rollup
|
|
30
30
|
.rollup(input)
|
|
31
31
|
.then(bundle => bundle.write(output)) // bundle.generate(output))
|
|
32
|
-
.then(bundle => {
|
|
32
|
+
.then(async bundle => {
|
|
33
33
|
// console.log(bundle)
|
|
34
34
|
const {code} = bundle.output[0];
|
|
35
35
|
report(code, file);
|
|
36
36
|
|
|
37
37
|
if (isProd) {
|
|
38
|
-
const
|
|
38
|
+
const minCode =
|
|
39
39
|
// (banner ? banner + '\n' : '') +
|
|
40
|
-
|
|
40
|
+
/* await minify(code, {
|
|
41
|
+
sourceMap: false,
|
|
42
|
+
});
|
|
43
|
+
*/
|
|
44
|
+
await minify(code, {
|
|
45
|
+
sourceMap: false,
|
|
41
46
|
toplevel: true,
|
|
42
47
|
output: {
|
|
43
48
|
ascii_only: true,
|
|
@@ -45,9 +50,9 @@ function buildEntry({input, output}) {
|
|
|
45
50
|
compress: {
|
|
46
51
|
pure_funcs: ['makeMap'],
|
|
47
52
|
},
|
|
48
|
-
})
|
|
53
|
+
});
|
|
49
54
|
|
|
50
|
-
|
|
55
|
+
return write(file.replace('.js', '.min.js'), minCode.code, true);
|
|
51
56
|
}
|
|
52
57
|
// else {
|
|
53
58
|
// return write(file, code);
|
package/dist/core.common.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wia core v0.1.
|
|
3
|
-
* (c)
|
|
2
|
+
* wia core v0.1.16
|
|
3
|
+
* (c) 2021 Sibyl Yu
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
@@ -12,9 +12,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
12
12
|
* return Promise objext.
|
|
13
13
|
* get move to base.js
|
|
14
14
|
*/
|
|
15
|
-
var Ajax =
|
|
16
|
-
/*#__PURE__*/
|
|
17
|
-
function () {
|
|
15
|
+
var Ajax = /*#__PURE__*/function () {
|
|
18
16
|
function Ajax() {}
|
|
19
17
|
|
|
20
18
|
var _proto = Ajax.prototype;
|
|
@@ -120,7 +118,8 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
120
118
|
function _inheritsLoose(subClass, superClass) {
|
|
121
119
|
subClass.prototype = Object.create(superClass.prototype);
|
|
122
120
|
subClass.prototype.constructor = subClass;
|
|
123
|
-
|
|
121
|
+
|
|
122
|
+
_setPrototypeOf(subClass, superClass);
|
|
124
123
|
}
|
|
125
124
|
|
|
126
125
|
function _setPrototypeOf(o, p) {
|
|
@@ -132,13 +131,13 @@ function _setPrototypeOf(o, p) {
|
|
|
132
131
|
return _setPrototypeOf(o, p);
|
|
133
132
|
}
|
|
134
133
|
|
|
135
|
-
function
|
|
134
|
+
function _isNativeReflectConstruct() {
|
|
136
135
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
137
136
|
if (Reflect.construct.sham) return false;
|
|
138
137
|
if (typeof Proxy === "function") return true;
|
|
139
138
|
|
|
140
139
|
try {
|
|
141
|
-
|
|
140
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
142
141
|
return true;
|
|
143
142
|
} catch (e) {
|
|
144
143
|
return false;
|
|
@@ -146,7 +145,7 @@ function isNativeReflectConstruct() {
|
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
function _construct(Parent, args, Class) {
|
|
149
|
-
if (
|
|
148
|
+
if (_isNativeReflectConstruct()) {
|
|
150
149
|
_construct = Reflect.construct;
|
|
151
150
|
} else {
|
|
152
151
|
_construct = function _construct(Parent, args, Class) {
|
|
@@ -188,8 +187,8 @@ var Utils = {
|
|
|
188
187
|
|
|
189
188
|
return $.uid(mask, map);
|
|
190
189
|
},
|
|
191
|
-
mdPreloaderContent: "\n <span class=\"preloader-inner\">\n
|
|
192
|
-
iosPreloaderContent: ("\n <span class=\"preloader-inner\">\n
|
|
190
|
+
mdPreloaderContent: "\n <span class=\"preloader-inner\">\n\t\t\t<svg viewBox=\"0 0 36 36\">\n\t\t\t\t<circle cx=\"18\" cy=\"18\" r=\"16\"></circle>\n\t\t\t</svg>\n </span>\n ".trim(),
|
|
191
|
+
iosPreloaderContent: ("\n <span class=\"preloader-inner\">\n\t\t\t" + [0, 1, 2, 3, 4, 5, 6, 7].map(function () {
|
|
193
192
|
return '<span class="preloader-inner-line"></span>';
|
|
194
193
|
}).join('') + "\n </span>\n ").trim(),
|
|
195
194
|
auroraPreloaderContent: "\n <span class=\"preloader-inner\">\n <span class=\"preloader-inner-circle\"></span>\n </span>\n ",
|
|
@@ -316,6 +315,22 @@ var Utils = {
|
|
|
316
315
|
args.splice(0, 1);
|
|
317
316
|
return (_$2 = $).assign.apply(_$2, [to].concat(args));
|
|
318
317
|
},
|
|
318
|
+
// ���������ʵ�������������ԡ���������
|
|
319
|
+
bindMethods: function bindMethods(instance, obj) {
|
|
320
|
+
var _this = this;
|
|
321
|
+
|
|
322
|
+
Object.keys(obj).forEach(function (key) {
|
|
323
|
+
if (_this.isObject(obj[key])) {
|
|
324
|
+
Object.keys(obj[key]).forEach(function (subKey) {
|
|
325
|
+
if (typeof obj[key][subKey] === 'function') {
|
|
326
|
+
obj[key][subKey] = obj[key][subKey].bind(instance);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
instance[key] = obj[key];
|
|
332
|
+
});
|
|
333
|
+
},
|
|
319
334
|
colorHexToRgb: function colorHexToRgb(hex) {
|
|
320
335
|
var h = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) {
|
|
321
336
|
return r + r + g + g + b + b;
|
|
@@ -431,9 +446,7 @@ var Utils = {
|
|
|
431
446
|
* 需要支持事件的对象,可以从这个类继承,则类实例具备事件功能。
|
|
432
447
|
* Fork from Framework7,
|
|
433
448
|
*/
|
|
434
|
-
var Event =
|
|
435
|
-
/*#__PURE__*/
|
|
436
|
-
function () {
|
|
449
|
+
var Event = /*#__PURE__*/function () {
|
|
437
450
|
function Event(params, parents) {
|
|
438
451
|
if (params === void 0) {
|
|
439
452
|
params = {};
|
|
@@ -562,9 +575,7 @@ function () {
|
|
|
562
575
|
return Event;
|
|
563
576
|
}();
|
|
564
577
|
|
|
565
|
-
var Module =
|
|
566
|
-
/*#__PURE__*/
|
|
567
|
-
function (_Event) {
|
|
578
|
+
var Module = /*#__PURE__*/function (_Event) {
|
|
568
579
|
_inheritsLoose(Module, _Event);
|
|
569
580
|
|
|
570
581
|
function Module(params, parents) {
|
|
@@ -608,7 +619,7 @@ function (_Event) {
|
|
|
608
619
|
});
|
|
609
620
|
}
|
|
610
621
|
/**
|
|
611
|
-
*
|
|
622
|
+
* 将扩展模块的相关方法、事件加载到类实例
|
|
612
623
|
* @param {*} moduleName 扩展模块名称
|
|
613
624
|
* @param {*} moduleParams
|
|
614
625
|
*/
|
|
@@ -639,7 +650,7 @@ function (_Event) {
|
|
|
639
650
|
instance[modulePropName] = moduleProp;
|
|
640
651
|
}
|
|
641
652
|
});
|
|
642
|
-
} // 将扩展模块中的on
|
|
653
|
+
} // 将扩展模块中的on加载到实例的事件侦听中,比如 init 在实例初始化时被调用
|
|
643
654
|
|
|
644
655
|
|
|
645
656
|
if (module.on && instance.on) {
|
|
@@ -659,7 +670,7 @@ function (_Event) {
|
|
|
659
670
|
instance.vnodeHooks[hookName][vnodeId].push(handler.bind(instance));
|
|
660
671
|
});
|
|
661
672
|
});
|
|
662
|
-
} //
|
|
673
|
+
} // 执行模块的create方法,模块实例化回调,Module create callback
|
|
663
674
|
|
|
664
675
|
|
|
665
676
|
if (module.create) {
|
|
@@ -667,7 +678,7 @@ function (_Event) {
|
|
|
667
678
|
}
|
|
668
679
|
}
|
|
669
680
|
/**
|
|
670
|
-
*
|
|
681
|
+
* 实例创建初始化时,执行扩展模块中定义的相关回调
|
|
671
682
|
* @param {*} modulesParams
|
|
672
683
|
*/
|
|
673
684
|
;
|
|
@@ -686,7 +697,7 @@ function (_Event) {
|
|
|
686
697
|
};
|
|
687
698
|
|
|
688
699
|
/**
|
|
689
|
-
*
|
|
700
|
+
* 将模块类装配到指定类的modules属性,用于扩展类
|
|
690
701
|
* @param {*} module 模块类
|
|
691
702
|
* @param {...any} params 参数
|
|
692
703
|
*/
|
|
@@ -768,7 +779,7 @@ function Constructors (parameters) {
|
|
|
768
779
|
|
|
769
780
|
var _parameters = parameters,
|
|
770
781
|
defaultSelector = _parameters.defaultSelector,
|
|
771
|
-
|
|
782
|
+
Constructor = _parameters.constructor,
|
|
772
783
|
domProp = _parameters.domProp,
|
|
773
784
|
app = _parameters.app,
|
|
774
785
|
addMethods = _parameters.addMethods;
|
|
@@ -778,15 +789,15 @@ function Constructors (parameters) {
|
|
|
778
789
|
args[_key] = arguments[_key];
|
|
779
790
|
}
|
|
780
791
|
|
|
781
|
-
if (app) return _construct(
|
|
782
|
-
return _construct(
|
|
792
|
+
if (app) return _construct(Constructor, [app].concat(args));
|
|
793
|
+
return _construct(Constructor, args);
|
|
783
794
|
},
|
|
784
795
|
get: function get(el) {
|
|
785
796
|
if (el === void 0) {
|
|
786
797
|
el = defaultSelector;
|
|
787
798
|
}
|
|
788
799
|
|
|
789
|
-
if (el instanceof
|
|
800
|
+
if (el instanceof Constructor) return el;
|
|
790
801
|
var $el = $(el);
|
|
791
802
|
if ($el.length === 0) return undefined;
|
|
792
803
|
return $el[0][domProp];
|
|
@@ -1115,7 +1126,7 @@ function initClicks(app) {
|
|
|
1115
1126
|
var $clickedEl = $(e.target);
|
|
1116
1127
|
var $clickedLinkEl = $clickedEl.closest('a');
|
|
1117
1128
|
var isLink = $clickedLinkEl.length > 0;
|
|
1118
|
-
|
|
1129
|
+
isLink && $clickedLinkEl.attr('href'); // call Modules Clicks
|
|
1119
1130
|
|
|
1120
1131
|
Object.keys(app.modules).forEach(function (moduleName) {
|
|
1121
1132
|
var moduleClicks = app.modules[moduleName].clicks;
|
|
@@ -1241,44 +1252,35 @@ var SW$1 = {
|
|
|
1241
1252
|
}
|
|
1242
1253
|
};
|
|
1243
1254
|
|
|
1244
|
-
var Support = $.support;
|
|
1245
|
-
var Device = $.device;
|
|
1255
|
+
var Support$1 = $.support;
|
|
1256
|
+
var Device$1 = $.device;
|
|
1257
|
+
/**
|
|
1258
|
+
* 应用类,每个wia应用从该类继承,由 首页加载创建或者路由创建
|
|
1259
|
+
*/
|
|
1246
1260
|
|
|
1247
|
-
var App =
|
|
1248
|
-
/*#__PURE__*/
|
|
1249
|
-
function (_Module) {
|
|
1261
|
+
var App = /*#__PURE__*/function (_Module) {
|
|
1250
1262
|
_inheritsLoose(App, _Module);
|
|
1251
1263
|
|
|
1252
|
-
function App(
|
|
1264
|
+
function App(opt) {
|
|
1253
1265
|
var _this;
|
|
1254
1266
|
|
|
1255
|
-
_this = _Module.call(this,
|
|
1256
|
-
|
|
1257
|
-
if (App.instance) {
|
|
1258
|
-
throw new Error("App is already initialized and can't be initialized more than once");
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
var passedParams = $.extend({}, params); // App Instance
|
|
1267
|
+
_this = _Module.call(this, opt) || this;
|
|
1268
|
+
var passedParams = $.extend({}, opt);
|
|
1262
1269
|
|
|
1263
1270
|
var app = _assertThisInitialized(_this);
|
|
1264
1271
|
|
|
1265
|
-
app.device = Device;
|
|
1266
|
-
app.support = Support;
|
|
1267
|
-
App.instance = app;
|
|
1268
|
-
$.app = app;
|
|
1269
|
-
$.App = App; // Default
|
|
1272
|
+
app.device = Device$1;
|
|
1273
|
+
app.support = Support$1; // Default
|
|
1270
1274
|
|
|
1271
|
-
var
|
|
1272
|
-
version: '
|
|
1273
|
-
id: 'pub.wia.testapp',
|
|
1275
|
+
var def = {
|
|
1276
|
+
version: '0.0.1',
|
|
1274
1277
|
root: 'body',
|
|
1275
1278
|
theme: 'auto',
|
|
1276
1279
|
language: window.navigator.language,
|
|
1277
1280
|
routes: [],
|
|
1278
|
-
name: 'wia',
|
|
1279
1281
|
lazyModulesPath: null,
|
|
1280
1282
|
initOnDeviceReady: true,
|
|
1281
|
-
init: true,
|
|
1283
|
+
// init: true, // 路由加载时,为 false,,为true
|
|
1282
1284
|
autoDarkTheme: false,
|
|
1283
1285
|
iosTranslucentBars: true,
|
|
1284
1286
|
iosTranslucentModals: true,
|
|
@@ -1286,15 +1288,14 @@ function (_Module) {
|
|
|
1286
1288
|
componentUrl: undefined
|
|
1287
1289
|
}; // Extend defaults with modules params
|
|
1288
1290
|
|
|
1289
|
-
app.useModulesParams(
|
|
1291
|
+
app.useModulesParams(def); // Extend defaults with passed params
|
|
1290
1292
|
|
|
1291
|
-
app.params = $.extend(
|
|
1293
|
+
app.params = $.extend(def, opt);
|
|
1292
1294
|
var $rootEl = $(app.params.root);
|
|
1293
1295
|
$.extend(app, {
|
|
1294
|
-
|
|
1295
|
-
id: app.params.id,
|
|
1296
|
-
// App Name
|
|
1296
|
+
owner: app.params.owner,
|
|
1297
1297
|
name: app.params.name,
|
|
1298
|
+
id: app.params.owner + "." + app.params.name,
|
|
1298
1299
|
// App version
|
|
1299
1300
|
version: app.params.version,
|
|
1300
1301
|
// Routes
|
|
@@ -1303,6 +1304,7 @@ function (_Module) {
|
|
|
1303
1304
|
language: app.params.language,
|
|
1304
1305
|
// Root
|
|
1305
1306
|
root: $rootEl,
|
|
1307
|
+
$el: $rootEl,
|
|
1306
1308
|
cfg: app.params.cfg,
|
|
1307
1309
|
// app config
|
|
1308
1310
|
api: app.params.api,
|
|
@@ -1312,8 +1314,8 @@ function (_Module) {
|
|
|
1312
1314
|
// Theme
|
|
1313
1315
|
theme: function getTheme() {
|
|
1314
1316
|
if (app.params.theme === 'auto') {
|
|
1315
|
-
if (Device.ios) return 'ios';
|
|
1316
|
-
if (Device.desktop
|
|
1317
|
+
if (Device$1.ios) return 'ios';
|
|
1318
|
+
if (Device$1.desktop) return 'aurora';
|
|
1317
1319
|
return 'md';
|
|
1318
1320
|
}
|
|
1319
1321
|
|
|
@@ -1328,16 +1330,13 @@ function (_Module) {
|
|
|
1328
1330
|
app.root[0].wia = app;
|
|
1329
1331
|
}
|
|
1330
1332
|
|
|
1331
|
-
if (Device.ios && Device.webView) {
|
|
1332
|
-
// Strange hack required for iOS 8 webview to work on inputs
|
|
1333
|
-
window.addEventListener('touchstart', function () {});
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
1333
|
app.touchEvents = {
|
|
1337
|
-
start: Support.touch ? 'touchstart' : Support.pointerEvents ? 'pointerdown' : 'mousedown',
|
|
1338
|
-
move: Support.touch ? 'touchmove' : Support.pointerEvents ? 'pointermove' : 'mousemove',
|
|
1339
|
-
end: Support.touch ? 'touchend' : Support.pointerEvents ? 'pointerup' : 'mouseup'
|
|
1340
|
-
}; // 加载use
|
|
1334
|
+
start: Support$1.touch ? 'touchstart' : Support$1.pointerEvents ? 'pointerdown' : 'mousedown',
|
|
1335
|
+
move: Support$1.touch ? 'touchmove' : Support$1.pointerEvents ? 'pointermove' : 'mousemove',
|
|
1336
|
+
end: Support$1.touch ? 'touchend' : Support$1.pointerEvents ? 'pointerup' : 'mouseup'
|
|
1337
|
+
}; // 加载use插入的模块类,每个模块作为app的一个属性,合并到实例。
|
|
1338
|
+
// 模块包括相关属性及方法(如:create、get、destroy)
|
|
1339
|
+
// 调用每个模块的 create 方法
|
|
1341
1340
|
|
|
1342
1341
|
app.useModules(); // 初始化数据,Init Data & Methods
|
|
1343
1342
|
|
|
@@ -1371,39 +1370,46 @@ function (_Module) {
|
|
|
1371
1370
|
|
|
1372
1371
|
|
|
1373
1372
|
function init() {
|
|
1374
|
-
if (Device.cordova && app.params.initOnDeviceReady) {
|
|
1373
|
+
if (Device$1.cordova && app.params.initOnDeviceReady) {
|
|
1375
1374
|
$(document).on('deviceready', function () {
|
|
1376
1375
|
app.init();
|
|
1377
1376
|
});
|
|
1378
1377
|
} else {
|
|
1379
1378
|
app.init();
|
|
1380
1379
|
}
|
|
1381
|
-
}
|
|
1380
|
+
} // 应用初始化,路由跳转时不执行初始化
|
|
1382
1381
|
|
|
1383
|
-
if (app.params.component || app.params.componentUrl) {
|
|
1384
|
-
app.router.componentLoader(app.params.component, app.params.componentUrl, {
|
|
1385
|
-
componentOptions: {
|
|
1386
|
-
el: app.root[0]
|
|
1387
|
-
}
|
|
1388
|
-
}, function (el) {
|
|
1389
|
-
app.root = $(el);
|
|
1390
|
-
app.root[0].f7 = app;
|
|
1391
|
-
app.rootComponent = el.f7Component;
|
|
1392
|
-
if (app.params.init) init();
|
|
1393
|
-
});
|
|
1394
|
-
} else if (app.params.init) {
|
|
1395
|
-
init();
|
|
1396
|
-
} // Return app instance
|
|
1397
1382
|
|
|
1383
|
+
if (app.params.init) init(); // Return app instance
|
|
1398
1384
|
|
|
1399
1385
|
return app || _assertThisInitialized(_this);
|
|
1386
|
+
} // 首次加载事件,全局只触发一次
|
|
1387
|
+
|
|
1388
|
+
|
|
1389
|
+
var _proto = App.prototype;
|
|
1390
|
+
|
|
1391
|
+
_proto.load = function load(param) {
|
|
1392
|
+
this.emit('local::load appLoad', param);
|
|
1393
|
+
} // 从后台切换到前台显示事件
|
|
1394
|
+
;
|
|
1395
|
+
|
|
1396
|
+
_proto.show = function show(url, data) {
|
|
1397
|
+
this.emit('local::show appShow', url, data);
|
|
1398
|
+
} // 从前台显示切换到后台事件
|
|
1399
|
+
;
|
|
1400
|
+
|
|
1401
|
+
_proto.hide = function hide() {
|
|
1402
|
+
this.emit('local::hide appHide');
|
|
1403
|
+
} // 卸载应用事件
|
|
1404
|
+
;
|
|
1405
|
+
|
|
1406
|
+
_proto.unload = function unload() {
|
|
1407
|
+
this.emit('local::unload appUnload');
|
|
1400
1408
|
}
|
|
1401
1409
|
/**
|
|
1402
1410
|
* 初始化数据
|
|
1403
1411
|
*/
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
var _proto = App.prototype;
|
|
1412
|
+
;
|
|
1407
1413
|
|
|
1408
1414
|
_proto.initData = function initData() {
|
|
1409
1415
|
var app = this; // Data
|
|
@@ -1452,12 +1458,19 @@ function (_Module) {
|
|
|
1452
1458
|
var app = this;
|
|
1453
1459
|
if (app.mq.dark) app.mq.dark.removeListener(app.colorSchemeListener);
|
|
1454
1460
|
if (app.mq.light) app.mq.light.removeListener(app.colorSchemeListener);
|
|
1455
|
-
} //
|
|
1461
|
+
} // 初始化,包括控制 html 样式,wia app 启动时需要执行,切换app时,不需要
|
|
1456
1462
|
;
|
|
1457
1463
|
|
|
1458
1464
|
_proto.init = function init() {
|
|
1459
1465
|
var app = this;
|
|
1460
1466
|
if (app.initialized) return app;
|
|
1467
|
+
$.App = App;
|
|
1468
|
+
|
|
1469
|
+
if (Device$1.ios && Device$1.webView) {
|
|
1470
|
+
// Strange hack required for iOS 8 webview to work on inputs
|
|
1471
|
+
window.addEventListener('touchstart', function () {});
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1461
1474
|
app.root.addClass('framework7-initializing'); // RTL attr
|
|
1462
1475
|
|
|
1463
1476
|
if (app.rtl) {
|
|
@@ -1485,11 +1498,11 @@ function (_Module) {
|
|
|
1485
1498
|
|
|
1486
1499
|
$('html').removeClass('ios md aurora').addClass(app.theme); // iOS Translucent
|
|
1487
1500
|
|
|
1488
|
-
if (app.params.iosTranslucentBars && app.theme === 'ios' && Device.ios) {
|
|
1501
|
+
if (app.params.iosTranslucentBars && app.theme === 'ios' && Device$1.ios) {
|
|
1489
1502
|
$('html').addClass('ios-translucent-bars');
|
|
1490
1503
|
}
|
|
1491
1504
|
|
|
1492
|
-
if (app.params.iosTranslucentModals && app.theme === 'ios' && Device.ios) {
|
|
1505
|
+
if (app.params.iosTranslucentModals && app.theme === 'ios' && Device$1.ios) {
|
|
1493
1506
|
$('html').addClass('ios-translucent-modals');
|
|
1494
1507
|
} // Init class
|
|
1495
1508
|
|
|
@@ -1499,7 +1512,8 @@ function (_Module) {
|
|
|
1499
1512
|
});
|
|
1500
1513
|
initStyle(); // Emit, init other modules
|
|
1501
1514
|
|
|
1502
|
-
app.initialized = true;
|
|
1515
|
+
app.initialized = true; // 发起init 事件,模块 on 里面有 init方法的会被触发
|
|
1516
|
+
|
|
1503
1517
|
app.emit('init');
|
|
1504
1518
|
return app;
|
|
1505
1519
|
} // eslint-disable-next-line
|
|
@@ -1558,53 +1572,56 @@ function (_Module) {
|
|
|
1558
1572
|
*/
|
|
1559
1573
|
|
|
1560
1574
|
|
|
1575
|
+
App.apps = {};
|
|
1576
|
+
|
|
1561
1577
|
function initStyle() {
|
|
1562
1578
|
var classNames = [];
|
|
1563
1579
|
var html = document.querySelector('html');
|
|
1564
1580
|
var metaStatusbar = document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]');
|
|
1565
1581
|
if (!html) return;
|
|
1566
1582
|
|
|
1567
|
-
if (Device.standalone && Device.ios && metaStatusbar && metaStatusbar.content === 'black-translucent') {
|
|
1583
|
+
if (Device$1.standalone && Device$1.ios && metaStatusbar && metaStatusbar.content === 'black-translucent') {
|
|
1568
1584
|
classNames.push('device-full-viewport');
|
|
1569
1585
|
} // Pixel Ratio
|
|
1570
1586
|
|
|
1571
1587
|
|
|
1572
|
-
classNames.push("device-pixel-ratio-" + Math.floor(Device.pixelRatio)); // OS classes
|
|
1588
|
+
classNames.push("device-pixel-ratio-" + Math.floor(Device$1.pixelRatio)); // OS classes
|
|
1573
1589
|
|
|
1574
|
-
if (Device.os && !Device.desktop) {
|
|
1575
|
-
classNames.push("device-" + Device.os);
|
|
1576
|
-
} else if (Device.desktop) {
|
|
1590
|
+
if (Device$1.os && !Device$1.desktop) {
|
|
1591
|
+
classNames.push("device-" + Device$1.os);
|
|
1592
|
+
} else if (Device$1.desktop) {
|
|
1577
1593
|
classNames.push('device-desktop');
|
|
1578
1594
|
|
|
1579
|
-
if (Device.os) {
|
|
1580
|
-
classNames.push("device-" + Device.os);
|
|
1595
|
+
if (Device$1.os) {
|
|
1596
|
+
classNames.push("device-" + Device$1.os);
|
|
1581
1597
|
}
|
|
1582
1598
|
}
|
|
1583
1599
|
|
|
1584
|
-
if (Device.cordova || Device.phonegap) {
|
|
1600
|
+
if (Device$1.cordova || Device$1.phonegap) {
|
|
1585
1601
|
classNames.push('device-cordova');
|
|
1586
1602
|
} // Add html classes
|
|
1587
1603
|
|
|
1588
1604
|
|
|
1589
1605
|
classNames.forEach(function (className) {
|
|
1590
|
-
html.classList.add(className);
|
|
1606
|
+
html.classList.add(className); // console.log({className});
|
|
1591
1607
|
});
|
|
1592
|
-
}
|
|
1608
|
+
} // App 类 静态方法、属性
|
|
1609
|
+
|
|
1593
1610
|
|
|
1594
1611
|
App.ModalMethods = Modals;
|
|
1595
1612
|
App.ConstructorMethods = Constructors; // 动态加载模块(base里面已经内置动态加载,这个方法应该用不上)
|
|
1596
1613
|
|
|
1597
1614
|
App.loadModule = loadModule;
|
|
1598
1615
|
|
|
1599
|
-
App.loadModules = function
|
|
1616
|
+
App.loadModules = function (modules) {
|
|
1600
1617
|
return Promise.all(modules.map(function (module) {
|
|
1601
1618
|
return App.loadModule(module);
|
|
1602
1619
|
}));
|
|
1603
1620
|
}; // app 加载到 app实例的一些扩展模块
|
|
1604
1621
|
|
|
1605
1622
|
|
|
1606
|
-
App.support = Support;
|
|
1607
|
-
App.device = Device;
|
|
1623
|
+
App.support = Support$1;
|
|
1624
|
+
App.device = Device$1;
|
|
1608
1625
|
App.utils = Utils; // 添加应用缺省模块
|
|
1609
1626
|
|
|
1610
1627
|
App.use([Resize, // 控制屏幕大小
|
|
@@ -1664,9 +1681,7 @@ var _dpr = window.devicePixelRatio || window.screen.deviceXDPI / window.screen.l
|
|
|
1664
1681
|
*/
|
|
1665
1682
|
|
|
1666
1683
|
|
|
1667
|
-
var Lazy =
|
|
1668
|
-
/*#__PURE__*/
|
|
1669
|
-
function () {
|
|
1684
|
+
var Lazy = /*#__PURE__*/function () {
|
|
1670
1685
|
// 实例属性
|
|
1671
1686
|
function Lazy(opt) {
|
|
1672
1687
|
_opt = $.assign({}, _opts, opt);
|
|
@@ -1825,9 +1840,7 @@ function _update(root) {
|
|
|
1825
1840
|
return this;
|
|
1826
1841
|
}
|
|
1827
1842
|
|
|
1828
|
-
var Page =
|
|
1829
|
-
/*#__PURE__*/
|
|
1830
|
-
function (_Event) {
|
|
1843
|
+
var Page = /*#__PURE__*/function (_Event) {
|
|
1831
1844
|
_inheritsLoose(Page, _Event);
|
|
1832
1845
|
|
|
1833
1846
|
function Page(app, name, title, style) {
|
|
@@ -1843,7 +1856,11 @@ function (_Event) {
|
|
|
1843
1856
|
_this.style = style || "./page/" + name + ".css";
|
|
1844
1857
|
_this.path = "" + name; // url 路径,不使用正则,直接查找
|
|
1845
1858
|
|
|
1846
|
-
_this.view = null; // 页面的div
|
|
1859
|
+
_this.view = null; // 页面的div层$Dom对象,router创建实例时赋值
|
|
1860
|
+
|
|
1861
|
+
_this.el = null; // $dom
|
|
1862
|
+
|
|
1863
|
+
_this.$el = null; // $dom
|
|
1847
1864
|
|
|
1848
1865
|
_this.html = ''; // 页面html文本,router创建实例时赋值
|
|
1849
1866
|
|
|
@@ -1883,15 +1900,43 @@ function (_Event) {
|
|
|
1883
1900
|
// $.assign(this, {page, param, back});
|
|
1884
1901
|
// $.assign(this.data, param);
|
|
1885
1902
|
// 隐藏所有模板
|
|
1903
|
+
this.init();
|
|
1886
1904
|
this.emit('local::ready pageReady', view, param, back);
|
|
1887
|
-
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* 对页面进行初始化处理,或页面内容动态变更时,对局部页面容器进行初始化
|
|
1908
|
+
* 具备name属性的dom节点直接赋值给页面view
|
|
1909
|
+
* 只挂载一个,多个同名name,最后一个起作用,因此一个页面内,name不要重复
|
|
1910
|
+
* 同节点多次调用不覆盖,同名不同dom节点,覆盖
|
|
1911
|
+
* 覆盖后,原直接节点属性的 bind 会失效,需真的新的$dom重新bind
|
|
1912
|
+
* @param {*} v dom 容器,默认为页面实例的view
|
|
1913
|
+
*/
|
|
1914
|
+
;
|
|
1915
|
+
|
|
1916
|
+
_proto.init = function init(v) {
|
|
1917
|
+
var view = this.view;
|
|
1918
|
+
v = v ? $(v) : view; // 页面上带name属性节点,直接作为page.view的属性,方便页面代码直接调用
|
|
1919
|
+
|
|
1920
|
+
var ns = v.qus('[name]');
|
|
1921
|
+
ns === null || ns === void 0 ? void 0 : ns.forEach(function (n) {
|
|
1922
|
+
var $n = $(n);
|
|
1923
|
+
var name = $n.attr('name');
|
|
1924
|
+
if (!view[name] || view[name].dom !== n) view[name] = $n;
|
|
1925
|
+
}); // 隐藏所有模板
|
|
1926
|
+
|
|
1927
|
+
v.qus('[name$=-tp]').hide(); // 防止空链接,刷新页面
|
|
1928
|
+
|
|
1929
|
+
v.qus('a[href=""]').attr('href', 'javascript:;');
|
|
1888
1930
|
} // 显示已加载的页面
|
|
1889
1931
|
// view:页面Dom层,param:参数
|
|
1890
1932
|
;
|
|
1891
1933
|
|
|
1892
1934
|
_proto.show = function show(view, param) {
|
|
1893
|
-
//
|
|
1894
|
-
view.qus('
|
|
1935
|
+
// 隐藏所有模板
|
|
1936
|
+
view.qus('[name$=-tp]').hide(); // 防止空链接,刷新页面
|
|
1937
|
+
|
|
1938
|
+
view.qus('a[href=""]').attr('href', 'javascript:;'); // this.init();
|
|
1939
|
+
|
|
1895
1940
|
if (this.reset) this.reset();
|
|
1896
1941
|
this.emit('local::show pageShow', view, param);
|
|
1897
1942
|
} // 回退显示已加载的页面
|
|
@@ -1899,7 +1944,9 @@ function (_Event) {
|
|
|
1899
1944
|
;
|
|
1900
1945
|
|
|
1901
1946
|
_proto.back = function back(view, param) {
|
|
1902
|
-
//
|
|
1947
|
+
// 隐藏所有模板
|
|
1948
|
+
view.qus('[name$=-tp]').hide(); // 防止空链接,刷新页面
|
|
1949
|
+
|
|
1903
1950
|
view.qus('a[href=""]').attr('href', 'javascript:;');
|
|
1904
1951
|
this.emit('local::back pageBack', view, param);
|
|
1905
1952
|
};
|
|
@@ -1920,9 +1967,7 @@ function clearDialogsQueue() {
|
|
|
1920
1967
|
dialog.open();
|
|
1921
1968
|
}
|
|
1922
1969
|
|
|
1923
|
-
var Modal =
|
|
1924
|
-
/*#__PURE__*/
|
|
1925
|
-
function (_Event) {
|
|
1970
|
+
var Modal = /*#__PURE__*/function (_Event) {
|
|
1926
1971
|
_inheritsLoose(Modal, _Event);
|
|
1927
1972
|
|
|
1928
1973
|
function Modal(app, params) {
|
|
@@ -2155,15 +2200,49 @@ function (_Event) {
|
|
|
2155
2200
|
return Modal;
|
|
2156
2201
|
}(Event);
|
|
2157
2202
|
|
|
2203
|
+
// replace react, use by @babel/plugin-transform-react-jsx
|
|
2204
|
+
|
|
2205
|
+
/* eslint-disable prefer-rest-params */
|
|
2206
|
+
function jsx(tag, props) {
|
|
2207
|
+
var attrs = props || {};
|
|
2208
|
+
|
|
2209
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
2210
|
+
args[_key - 2] = arguments[_key];
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
var children = args || [];
|
|
2214
|
+
var attrsString = Object.keys(attrs).map(function (attr) {
|
|
2215
|
+
if (attr[0] === '_') {
|
|
2216
|
+
if (attrs[attr]) return attr.replace('_', '');
|
|
2217
|
+
return '';
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
return attr + "=\"" + attrs[attr] + "\"";
|
|
2221
|
+
}).filter(function (attr) {
|
|
2222
|
+
return !!attr;
|
|
2223
|
+
}).join(' ');
|
|
2224
|
+
|
|
2225
|
+
if (['path', 'img', 'circle', 'polygon', 'line', 'input'].indexOf(tag) >= 0) {
|
|
2226
|
+
return ("<" + tag + " " + attrsString + " />").trim();
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
var childrenContent = children.filter(function (c) {
|
|
2230
|
+
return !!c;
|
|
2231
|
+
}).map(function (c) {
|
|
2232
|
+
return Array.isArray(c) ? c.join('') : c;
|
|
2233
|
+
}).join('');
|
|
2234
|
+
return ("<" + tag + " " + attrsString + ">" + childrenContent + "</" + tag + ">").trim();
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2158
2237
|
// export {default as Device} from './device';
|
|
2159
2238
|
|
|
2160
|
-
var Support
|
|
2161
|
-
var Device
|
|
2239
|
+
var Support = $.support;
|
|
2240
|
+
var Device = $.device;
|
|
2162
2241
|
|
|
2163
2242
|
exports.Ajax = Ajax;
|
|
2164
2243
|
exports.App = App;
|
|
2165
2244
|
exports.Constructors = Constructors;
|
|
2166
|
-
exports.Device = Device
|
|
2245
|
+
exports.Device = Device;
|
|
2167
2246
|
exports.Event = Event;
|
|
2168
2247
|
exports.Lazy = Lazy;
|
|
2169
2248
|
exports.Modal = Modal;
|
|
@@ -2172,6 +2251,7 @@ exports.Module = Module;
|
|
|
2172
2251
|
exports.Page = Page;
|
|
2173
2252
|
exports.Resize = Resize;
|
|
2174
2253
|
exports.SW = SW$1;
|
|
2175
|
-
exports.Support = Support
|
|
2254
|
+
exports.Support = Support;
|
|
2176
2255
|
exports.Utils = Utils;
|
|
2256
|
+
exports.jsx = jsx;
|
|
2177
2257
|
exports.loadModule = loadModule;
|