-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
432d80a
commit 51b5586
Showing
3,244 changed files
with
41,519 additions
and
53,535 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.REG_BTOU = exports.REG_UTOB = exports.REG_BTOA = exports.REG_ATOB = exports.B64TAB = exports.CHARS = void 0; | ||
var CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | ||
exports.CHARS = CHARS; | ||
|
||
var B64TAB = function (bin) { | ||
var t = {}; | ||
var l = bin.length; | ||
|
||
for (var i = 0; i < l; i++) { | ||
t[bin.charAt(i)] = i; | ||
} | ||
|
||
return t; | ||
}(CHARS); | ||
|
||
exports.B64TAB = B64TAB; | ||
var REG_ATOB = /[\s\S]{1,4}/g; | ||
exports.REG_ATOB = REG_ATOB; | ||
var REG_BTOA = /[\s\S]{1,3}/g; | ||
exports.REG_BTOA = REG_BTOA; | ||
var REG_UTOB = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g; // eslint-disable-line no-control-regex | ||
|
||
exports.REG_UTOB = REG_UTOB; | ||
var REG_BTOU = new RegExp(['[\xC0-\xDF][\x80-\xBF]', '[\xE0-\xEF][\x80-\xBF]{2}', '[\xF0-\xF7][\x80-\xBF]{3}'].join('|'), 'g'); | ||
exports.REG_BTOU = REG_BTOU; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict"; | ||
|
||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "encode", { | ||
enumerable: true, | ||
get: function get() { | ||
return _encode.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "decode", { | ||
enumerable: true, | ||
get: function get() { | ||
return _decode.default; | ||
} | ||
}); | ||
|
||
var _encode = _interopRequireDefault(require("./util/encode")); | ||
|
||
var _decode = _interopRequireDefault(require("./util/decode")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
|
||
var _const = require("../const"); | ||
|
||
/* eslint-disable no-bitwise */ | ||
var fromCharCode = String.fromCharCode; | ||
/** | ||
* window 自带的 atob 和 btoa https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding | ||
* | ||
* - atob base64 解码 | ||
* - btoa base64 编码 | ||
* | ||
* 注意: | ||
* | ||
* - 不支持 unicode,`btoa/atob` 对汉字(或汉字标点)等会报错 | ||
* + FF → DOMException: String contains an invalid character | ||
* + CH → DOMException: Failed to execute 'atob' on 'Window': The string to be decoded contains characters outside of the Latin1 range. | ||
* + SF → InvalidCharacterError: The string contains invalid characters. | ||
* - 这两个方法有些奇怪,可以把它从 window 上脱离出来调用,但不能把它挂到某对象下面调用,否则会报错 | ||
* + FF → TypeError: 'atob' called on an object that does not implement interface Window | ||
* + CH → TypeError: Illegal invocation | ||
* + SF → TypeError: Can only call Window.btoa on instances of Window | ||
*/ | ||
|
||
function atobPolyfill(a) { | ||
return a.replace(_const.REG_ATOB, function (cccc) { | ||
var len = cccc.length; | ||
var padLen = len % 4; | ||
var n = (len > 0 ? _const.B64TAB[cccc.charAt(0)] << 18 : 0) | (len > 1 ? _const.B64TAB[cccc.charAt(1)] << 12 : 0) | (len > 2 ? _const.B64TAB[cccc.charAt(2)] << 6 : 0) | (len > 3 ? _const.B64TAB[cccc.charAt(3)] : 0); | ||
var chars = [fromCharCode(n >>> 16), fromCharCode(n >>> 8 & 0xff), fromCharCode(n & 0xff)]; | ||
chars.length -= [0, 0, 2, 1][padLen]; | ||
return chars.join(''); | ||
}); | ||
} | ||
|
||
var _default = typeof window !== 'undefined' && window.atob ? window.atob : atobPolyfill; | ||
|
||
exports.default = _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
|
||
var _const = require("../const"); | ||
|
||
/* eslint-disable no-bitwise */ | ||
function btoaPolyfill(b) { | ||
return b.replace(_const.REG_BTOA, function (ccc) { | ||
var padLen = [0, 2, 1][ccc.length % 3]; | ||
var ord = ccc.charCodeAt(0) << 16 | (ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8 | (ccc.length > 2 ? ccc.charCodeAt(2) : 0); | ||
return [_const.CHARS.charAt(ord >>> 18), _const.CHARS.charAt(ord >>> 12 & 63), padLen >= 2 ? '=' : _const.CHARS.charAt(ord >>> 6 & 63), padLen >= 1 ? '=' : _const.CHARS.charAt(ord & 63)].join(''); | ||
}); | ||
} | ||
|
||
var _default = typeof window !== 'undefined' && window.btoa ? window.btoa : btoaPolyfill; | ||
|
||
exports.default = _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = btou; | ||
|
||
var _const = require("../const"); | ||
|
||
/* eslint-disable no-bitwise */ | ||
var fromCharCode = String.fromCharCode; | ||
/** | ||
* unicode 版编码 | ||
*/ | ||
|
||
function btou(b) { | ||
return b.replace(_const.REG_BTOU, function (cccc) { | ||
switch (cccc.length) { | ||
case 4: | ||
{ | ||
var cp = (0x07 & cccc.charCodeAt(0)) << 18 | (0x3f & cccc.charCodeAt(1)) << 12 | (0x3f & cccc.charCodeAt(2)) << 6 | 0x3f & cccc.charCodeAt(3); | ||
var offset = cp - 0x10000; | ||
return fromCharCode((offset >>> 10) + 0xD800) + fromCharCode((offset & 0x3FF) + 0xDC00); | ||
} | ||
|
||
case 3: | ||
return fromCharCode((0x0f & cccc.charCodeAt(0)) << 12 | (0x3f & cccc.charCodeAt(1)) << 6 | 0x3f & cccc.charCodeAt(2)); | ||
|
||
default: | ||
return fromCharCode((0x1f & cccc.charCodeAt(0)) << 6 | 0x3f & cccc.charCodeAt(1)); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"use strict"; | ||
|
||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = decode; | ||
|
||
var _atob = _interopRequireDefault(require("./atob")); | ||
|
||
var _btou = _interopRequireDefault(require("./btou")); | ||
|
||
function _decode(a) { | ||
return (0, _btou.default)((0, _atob.default)(a)); | ||
} | ||
/** | ||
* 支持 unicode 的 base64 解码 | ||
*/ | ||
|
||
|
||
function decode(str) { | ||
return _decode(String(str).replace(/[-_]/g, function (m0) { | ||
return m0 === '-' ? '+' : '/'; | ||
}).replace(/[^A-Za-z0-9+/]/g, '')); | ||
} |
Oops, something went wrong.