Skip to content

Commit f46dfdd

Browse files
authored
5.7 核心上线 (#598)
* mip 核心升级 babel v7 * 去除多余配置和模块 * 删掉多余注释 * 更新 mip-compoenents-webpack-helpers * 将 css-loader 锁在0.28 * fix: 修复核心全量后已知 bugs (#546) * 增加 symbol 的 polyfill * 增加注释 * fix: mip 链接使用默认行为 (#548) * 把 symbol 加上 * lock babel version * add component helper version * 升级 component helpers 版本 * fix: Register built-in components when document interactive (#555) * fix: Fix external resources protocol (#558) * 修改test case * 修改 test case * add sleep * feat: 增强 templates 判断逻辑 (#567) * 新增 mip 前端小流量机制 (#560) * feat: 新增 mip 前端小流量机制 * 修改注释 * 调整变量名和 cookie 的失效时间 * fixed: 无需在 js 中指向 mip cahce url * mip.js 沙盒对象增加 BMap\BMapLib (#577) * 增加 sandbox 白名单 * 将 BMap 改成 readywrite * 升级 mip.js 核心的 sandbox * update * add promise finally polyfill * 挪个位置 * 消除其他影响 * change position * recover test case * readd maintemplate * MIP 核心中移除 Vue 代码 (#357) * mip-img 支持调起手百图片浏览器 (#587) * mip-img 支持调起手百图片浏览器 * fix: Fix base url calculation (#590) * update helper * update helper * 修改 mip-img 手百调起逻辑 (#592) * 修改调起逻辑 * mip-img 修复滑动调起 (#597) * 修复滑动调起
1 parent bc0fca7 commit f46dfdd

17 files changed

+3818
-8472
lines changed

Diff for: packages/mip/.babelrc

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
{
22
"presets": [
33
[
4-
"env",
4+
"@babel/preset-env",
55
{
6-
"modules": false
6+
"modules": false,
7+
"targets": {
8+
"browsers": [
9+
"> 1%",
10+
"last 2 versions",
11+
"not ie <= 8",
12+
"iOS > 7",
13+
"android >= 4.4"
14+
]
15+
}
716
}
8-
],
9-
"vue"
17+
]
1018
],
1119
"plugins": [
12-
"syntax-dynamic-import",
13-
"transform-object-rest-spread",
1420
[
15-
"transform-builtin-classes",
21+
"@babel/plugin-transform-runtime",
1622
{
17-
"globals": ["HTMLElement"]
23+
"corejs": false,
24+
"helpers": true,
25+
"regenerator": true,
26+
"absoluteRuntime": "@babel/runtime"
1827
}
1928
]
2029
],

Diff for: packages/mip/build/alias.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ module.exports = {
1717
web: resolve('src/vue/platforms/web'),
1818
sfc: resolve('src/vue/sfc'),
1919
deps: resolve('deps'),
20-
'script-loader!deps': resolve('deps'),
21-
'script-loader!document-register-element': resolve('node_modules/document-register-element'),
20+
// ,
21+
// 'script-loader!deps': resolve('deps'),
22+
// 'script-loader!document-register-element': resolve('node_modules/document-register-element'),
2223
'mip-vue': resolve('src/vue-custom-element/index.js')
2324
}

Diff for: packages/mip/build/config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ function genConfig (name) {
6464
}
6565
),
6666
babel({
67-
plugins: ['external-helpers']
67+
runtimeHelpers: true,
68+
exclude: 'node_modules/**'
6869
})
70+
// babel({
71+
// plugins: ['external-helpers']
72+
// })
6973
].concat(opts.plugins || []),
7074
output: {
7175
file: opts.dest,

Diff for: packages/mip/deps/README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ deps 目录均为第三方引用的 lib
44

55
有些 lib 有一些业务上的修改无法兼容,因此直接将源代码拷贝至此,而非通过 npm 来管理
66

7-
## fetch
7+
# esl
88

9-
源文件:https://github.com/github/fetch/blob/master/fetch.js
9+
目前 esl 只提供了 源码形式的版本
1010

11-
主要修改点在于增加了 QQ 浏览器的判断,因为 QQ 浏览器的早起版本 fetch 实现有问题,发送请求会漏掉 cookie,因为在 QQ 浏览器中也通过 polyfill 的方式覆盖 fetch
11+
# fetch-jsonp
12+
13+
fetch-jsonp 只提供了 UMD 的版本,造成加载时只会进入 AMD 逻辑,因此需要改成 esm 的形式

Diff for: packages/mip/deps/fetch-jsonp.js

+73-104
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,93 @@
11
/* eslint-disable */
2-
(function (global, factory) {
3-
if (typeof define === 'function' && define.amd) {
4-
define(['exports', 'module'], factory);
5-
} else if (typeof exports !== 'undefined' && typeof module !== 'undefined') {
6-
factory(exports, module);
7-
} else {
8-
var mod = {
9-
exports: {}
10-
};
11-
factory(mod.exports, mod);
12-
global.fetchJsonp = mod.exports;
13-
}
14-
})(window, function (exports, module) {
15-
'use strict';
16-
17-
var defaultOptions = {
18-
timeout: 5000,
19-
jsonpCallback: 'callback',
20-
jsonpCallbackFunction: null
21-
};
22-
23-
function generateCallbackFunction() {
24-
return 'jsonp_' + Date.now() + '_' + Math.ceil(Math.random() * 100000);
25-
}
26-
27-
function clearFunction(functionName) {
28-
// IE8 throws an exception when you try to delete a property on window
29-
// http://stackoverflow.com/a/1824228/751089
30-
try {
31-
delete window[functionName];
32-
} catch (e) {
33-
window[functionName] = undefined;
34-
}
2+
'use strict';
3+
4+
var defaultOptions = {
5+
timeout: 5000,
6+
jsonpCallback: 'callback',
7+
jsonpCallbackFunction: null
8+
};
9+
10+
function generateCallbackFunction() {
11+
return 'jsonp_' + Date.now() + '_' + Math.ceil(Math.random() * 100000);
12+
}
13+
14+
function clearFunction(functionName) {
15+
// IE8 throws an exception when you try to delete a property on window
16+
// http://stackoverflow.com/a/1824228/751089
17+
try {
18+
delete window[functionName];
19+
} catch (e) {
20+
window[functionName] = undefined;
3521
}
22+
}
3623

37-
function removeScript(scriptId) {
38-
var script = document.getElementById(scriptId);
39-
if (script) {
40-
document.getElementsByTagName('head')[0].removeChild(script);
41-
}
24+
function removeScript(scriptId) {
25+
var script = document.getElementById(scriptId);
26+
if (script) {
27+
document.getElementsByTagName('head')[0].removeChild(script);
4228
}
29+
}
4330

44-
function fetchJsonp(_url) {
45-
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
46-
47-
// to avoid param reassign
48-
var url = _url;
49-
var timeout = options.timeout || defaultOptions.timeout;
50-
var jsonpCallback = options.jsonpCallback || defaultOptions.jsonpCallback;
51-
52-
var timeoutId = undefined;
31+
function fetchJsonp(_url) {
32+
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
5333

54-
return new Promise(function (resolve, reject) {
55-
var callbackFunction = options.jsonpCallbackFunction || generateCallbackFunction();
56-
var scriptId = jsonpCallback + '_' + callbackFunction;
34+
// to avoid param reassign
35+
var url = _url;
36+
var timeout = options.timeout || defaultOptions.timeout;
37+
var jsonpCallback = options.jsonpCallback || defaultOptions.jsonpCallback;
5738

58-
window[callbackFunction] = function (response) {
59-
resolve({
60-
ok: true,
61-
// keep consistent with fetch API
62-
json: function json() {
63-
return Promise.resolve(response);
64-
}
65-
});
39+
var timeoutId = undefined;
6640

67-
if (timeoutId) clearTimeout(timeoutId);
41+
return new Promise(function (resolve, reject) {
42+
var callbackFunction = options.jsonpCallbackFunction || generateCallbackFunction();
43+
var scriptId = jsonpCallback + '_' + callbackFunction;
6844

69-
removeScript(scriptId);
45+
window[callbackFunction] = function (response) {
46+
resolve({
47+
ok: true,
48+
// keep consistent with fetch API
49+
json: function json() {
50+
return Promise.resolve(response);
51+
}
52+
});
7053

71-
clearFunction(callbackFunction);
72-
};
54+
if (timeoutId) clearTimeout(timeoutId);
7355

74-
// Check if the user set their own params, and if not add a ? to start a list of params
75-
url += url.indexOf('?') === -1 ? '?' : '&';
56+
removeScript(scriptId);
7657

77-
var jsonpScript = document.createElement('script');
78-
jsonpScript.setAttribute('src', '' + url + jsonpCallback + '=' + callbackFunction);
79-
if (options.charset) {
80-
jsonpScript.setAttribute('charset', options.charset);
81-
}
82-
jsonpScript.id = scriptId;
83-
document.getElementsByTagName('head')[0].appendChild(jsonpScript);
58+
clearFunction(callbackFunction);
59+
};
8460

85-
timeoutId = setTimeout(function () {
86-
reject(new Error('JSONP request to ' + _url + ' timed out'));
61+
// Check if the user set their own params, and if not add a ? to start a list of params
62+
url += url.indexOf('?') === -1 ? '?' : '&';
8763

88-
clearFunction(callbackFunction);
89-
removeScript(scriptId);
90-
window[callbackFunction] = function () {
91-
clearFunction(callbackFunction);
92-
};
93-
}, timeout);
64+
var jsonpScript = document.createElement('script');
65+
jsonpScript.setAttribute('src', '' + url + jsonpCallback + '=' + callbackFunction);
66+
if (options.charset) {
67+
jsonpScript.setAttribute('charset', options.charset);
68+
}
69+
jsonpScript.id = scriptId;
70+
document.getElementsByTagName('head')[0].appendChild(jsonpScript);
9471

95-
// Caught if got 404/500
96-
jsonpScript.onerror = function () {
97-
reject(new Error('JSONP request to ' + _url + ' failed'));
72+
timeoutId = setTimeout(function () {
73+
reject(new Error('JSONP request to ' + _url + ' timed out'));
9874

75+
clearFunction(callbackFunction);
76+
removeScript(scriptId);
77+
window[callbackFunction] = function () {
9978
clearFunction(callbackFunction);
100-
removeScript(scriptId);
101-
if (timeoutId) clearTimeout(timeoutId);
10279
};
103-
});
104-
}
80+
}, timeout);
10581

106-
// export as global function
107-
/*
108-
let local;
109-
if (typeof global !== 'undefined') {
110-
local = global;
111-
} else if (typeof self !== 'undefined') {
112-
local = self;
113-
} else {
114-
try {
115-
local = Function('return this')();
116-
} catch (e) {
117-
throw new Error('polyfill failed because global object is unavailable in this environment');
118-
}
119-
}
120-
local.fetchJsonp = fetchJsonp;
121-
*/
82+
// Caught if got 404/500
83+
jsonpScript.onerror = function () {
84+
reject(new Error('JSONP request to ' + _url + ' failed'));
85+
86+
clearFunction(callbackFunction);
87+
removeScript(scriptId);
88+
if (timeoutId) clearTimeout(timeoutId);
89+
};
90+
});
91+
}
12292

123-
module.exports = fetchJsonp;
124-
});
93+
window.fetchJsonp = fetchJsonp

Diff for: packages/mip/deps/fetch.js

-3
This file was deleted.

0 commit comments

Comments
 (0)