web-component-gallery 1.3.12 → 2.0.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/923.umd.js +1 -0
- package/dist/index.umd.js +1 -12252
- package/dist/js.umd.js +1 -0
- package/dist/style.css +17 -0
- package/dist/style.umd.js +1 -0
- package/{method → extensions}/AMap.js +1 -5
- package/{plugins/method → extensions}/Dialog.js +2 -2
- package/{lib/lazy_use.js → extensions/index.js} +16 -2
- package/lib/{amap/components/AmapSearch/index.jsx → amap-comp/AmapSearch.jsx} +3 -5
- package/lib/amap-comp/index.js +18 -0
- package/{plugins/lib/amap/components/AmapSearch/index.less → lib/amap-comp/style/AmapSearch.less} +5 -3
- package/lib/amap-comp/style/index.js +1 -0
- package/lib/amap-comp/style/index.less +1 -0
- package/lib/{amap/AmapDraw.jsx → amap-draw/index.jsx} +2 -4
- package/lib/amap-draw/style/index.js +1 -0
- package/lib/{amap/AmapDraw.less → amap-draw/style/index.less} +6 -3
- package/lib/browse/index.jsx +0 -2
- package/lib/browse/style/index.js +1 -0
- package/lib/button/Button.js +1 -3
- package/lib/button/style/index.js +1 -0
- package/{plugins/lib/dateTime → lib/date-time}/index.vue +3 -13
- package/lib/date-time/style/index.js +1 -0
- package/lib/date-time/style/index.less +7 -0
- package/lib/{descriptions → descriptions-list}/index.jsx +1 -3
- package/lib/descriptions-list/style/index.js +1 -0
- package/{plugins/lib/tree → lib/directory}/Directory.js +4 -21
- package/lib/directory/index.js +8 -0
- package/lib/directory/style/index.js +1 -0
- package/lib/{tree/style/Directory.less → directory/style/index.less} +3 -4
- package/{plugins/lib/form/components → lib/form-comp}/ACascaderMultiple.vue +1 -106
- package/lib/form-comp/ARadio.vue +70 -0
- package/lib/{form/components → form-comp}/ARangePicker.vue +9 -20
- package/lib/{form/components → form-comp}/ASelectCustom.vue +1 -8
- package/lib/form-comp/ATagsInput.vue +88 -0
- package/lib/form-comp/ATimePicker.vue +127 -0
- package/lib/{form/components → form-comp}/AUpload.vue +2 -17
- package/lib/form-comp/index.js +37 -0
- package/lib/form-comp/style/ACascaderMultiple.less +117 -0
- package/lib/form-comp/style/ARadio.less +0 -0
- package/lib/form-comp/style/ARangePicker.less +11 -0
- package/lib/form-comp/style/ASelectCustom.less +4 -0
- package/lib/form-comp/style/ATagsInput.less +24 -0
- package/lib/form-comp/style/ATimePicker.less +8 -0
- package/lib/form-comp/style/AUpload.less +15 -0
- package/lib/form-comp/style/index.js +1 -0
- package/lib/form-comp/style/index.less +7 -0
- package/lib/index.js +60 -45
- package/lib/modal/index.jsx +4 -6
- package/lib/modal/style/index.js +1 -0
- package/lib/modal/{index.less → style/index.less} +6 -7
- package/{plugins/lib/form → lib/model}/Model.js +1 -3
- package/lib/model/index.js +7 -0
- package/lib/model/style/index.js +1 -0
- package/lib/{form/style/Model.less → model/style/index.less} +10 -10
- package/{plugins/lib/form → lib/model}/utils/render.js +1 -1
- package/lib/{form → model}/utils/resetFields.js +1 -1
- package/lib/no-data/directive.js +65 -0
- package/lib/no-data/index.js +21 -0
- package/lib/no-data/index.vue +35 -0
- package/lib/no-data/style/index.js +1 -0
- package/lib/no-data/style/index.less +15 -0
- package/lib/search/index.js +7 -0
- package/{plugins/lib/form/Search.vue → lib/search/index.vue} +3 -6
- package/lib/search/style/index.js +1 -0
- package/{plugins/lib/form/style/Search.less → lib/search/style/index.less} +7 -8
- package/lib/style/mixins.less +1 -1
- package/lib/{svgIcon → svg-icon}/index.vue +1 -17
- package/lib/svg-icon/style/index.js +1 -0
- package/lib/svg-icon/style/index.less +15 -0
- package/lib/table/index.vue +4 -8
- package/lib/table/style/index.js +1 -0
- package/lib/table/style/index.less +12 -13
- package/lib/tree/index.js +2 -11
- package/{plugins/lib/tree/Tree.vue → lib/tree/index.vue} +2 -5
- package/lib/tree/style/index.js +1 -0
- package/{plugins/lib/tree/style/Tree.less → lib/tree/style/index.less} +4 -4
- package/lib/weather/index.vue +1 -9
- package/lib/weather/style/index.js +1 -0
- package/lib/weather/style/index.less +7 -0
- package/package.json +16 -34
- package/utils/Axios.js +91 -82
- package/utils/Postcss.js +12 -8
- package/README.md +0 -24
- package/dist/amap.umd.js +0 -12252
- package/dist/avatar.umd.js +0 -5337
- package/dist/button.umd.js +0 -5845
- package/dist/dateTime.umd.js +0 -1287
- package/dist/form.umd.js +0 -9981
- package/dist/multiTab.umd.js +0 -5556
- package/dist/svgIcon.umd.js +0 -1167
- package/dist/table.umd.js +0 -6306
- package/dist/tree.umd.js +0 -5393
- package/dist/weather.umd.js +0 -1167
- package/lib/amap/components/AmapSearch/index.less +0 -16
- package/lib/amap/index.js +0 -13
- package/lib/avatar/index.js +0 -7
- package/lib/avatar/index.vue +0 -47
- package/lib/basic/404.vue +0 -24
- package/lib/dateTime/index.vue +0 -43
- package/lib/form/Model.js +0 -153
- package/lib/form/Search.vue +0 -159
- package/lib/form/components/ACascaderMultiple.vue +0 -766
- package/lib/form/components/ARadio.vue +0 -74
- package/lib/form/components/ATagsInput.vue +0 -93
- package/lib/form/components/ATimePicker.vue +0 -73
- package/lib/form/index.js +0 -55
- package/lib/form/style/Search.less +0 -34
- package/lib/form/utils/render.js +0 -85
- package/lib/iframe/events.js +0 -2
- package/lib/iframe/index.jsx +0 -234
- package/lib/iframe/index.less +0 -19
- package/lib/multiTab/APIEnums.js +0 -17
- package/lib/multiTab/MultiTab.jsx +0 -237
- package/lib/multiTab/RouteAPI.js +0 -71
- package/lib/multiTab/RouteContent.jsx +0 -90
- package/lib/multiTab/RouteKeepAlive.js +0 -183
- package/lib/multiTab/events.js +0 -2
- package/lib/multiTab/index.js +0 -15
- package/lib/multiTab/index.less +0 -73
- package/lib/style/index.less +0 -2
- package/lib/tree/Directory.js +0 -428
- package/lib/tree/Tree.vue +0 -181
- package/lib/tree/style/Tree.less +0 -52
- package/method/Dialog.js +0 -134
- package/method/index.js +0 -12
- package/plugins/lib/amap/AmapDraw.jsx +0 -349
- package/plugins/lib/amap/AmapDraw.less +0 -45
- package/plugins/lib/amap/components/AmapSearch/index.jsx +0 -73
- package/plugins/lib/amap/index.js +0 -13
- package/plugins/lib/avatar/index.js +0 -7
- package/plugins/lib/avatar/index.vue +0 -47
- package/plugins/lib/basic/404.vue +0 -24
- package/plugins/lib/browse/index.jsx +0 -76
- package/plugins/lib/browse/index.less +0 -4
- package/plugins/lib/button/Button.js +0 -89
- package/plugins/lib/button/index.js +0 -7
- package/plugins/lib/dateTime/index.js +0 -7
- package/plugins/lib/descriptions/index.jsx +0 -108
- package/plugins/lib/descriptions/index.less +0 -15
- package/plugins/lib/form/components/ARadio.vue +0 -74
- package/plugins/lib/form/components/ARangePicker.vue +0 -129
- package/plugins/lib/form/components/ASelectCustom.vue +0 -226
- package/plugins/lib/form/components/ATagsInput.vue +0 -93
- package/plugins/lib/form/components/ATimePicker.vue +0 -73
- package/plugins/lib/form/components/AUpload.vue +0 -183
- package/plugins/lib/form/components/RenderComp.vue +0 -69
- package/plugins/lib/form/index.js +0 -55
- package/plugins/lib/form/style/Model.less +0 -53
- package/plugins/lib/form/utils/resetFields.js +0 -16
- package/plugins/lib/iframe/events.js +0 -2
- package/plugins/lib/iframe/index.jsx +0 -234
- package/plugins/lib/iframe/index.less +0 -19
- package/plugins/lib/index.js +0 -72
- package/plugins/lib/lazy_use.js +0 -40
- package/plugins/lib/modal/index.jsx +0 -53
- package/plugins/lib/modal/index.less +0 -50
- package/plugins/lib/multiTab/APIEnums.js +0 -17
- package/plugins/lib/multiTab/MultiTab.jsx +0 -237
- package/plugins/lib/multiTab/RouteAPI.js +0 -71
- package/plugins/lib/multiTab/RouteContent.jsx +0 -90
- package/plugins/lib/multiTab/RouteKeepAlive.js +0 -183
- package/plugins/lib/multiTab/events.js +0 -2
- package/plugins/lib/multiTab/index.js +0 -15
- package/plugins/lib/multiTab/index.less +0 -73
- package/plugins/lib/style/index.less +0 -2
- package/plugins/lib/style/mixins.less +0 -79
- package/plugins/lib/svgIcon/index.js +0 -7
- package/plugins/lib/svgIcon/index.vue +0 -77
- package/plugins/lib/table/index.js +0 -7
- package/plugins/lib/table/index.vue +0 -217
- package/plugins/lib/table/style/index.less +0 -50
- package/plugins/lib/tree/index.js +0 -17
- package/plugins/lib/tree/style/Directory.less +0 -119
- package/plugins/lib/weather/index.js +0 -7
- package/plugins/lib/weather/index.vue +0 -58
- package/plugins/method/AMap.js +0 -368
- package/plugins/method/PageLoading.jsx +0 -106
- package/plugins/method/Theme.js +0 -88
- package/plugins/method/index.js +0 -12
- package/plugins/store/auth.js +0 -31
- package/plugins/store/cache.js +0 -56
- package/plugins/store/chat.js +0 -74
- package/plugins/store/project.js +0 -46
- package/plugins/utils/Axios.js +0 -105
- package/plugins/utils/Base64.js +0 -314
- package/plugins/utils/Filter.js +0 -249
- package/plugins/utils/PostMessage.js +0 -16
- package/plugins/utils/Postcss.js +0 -9
- package/plugins/utils/Rem.js +0 -24
- package/plugins/utils/Request.js +0 -38
- package/plugins/utils/Storage.js +0 -73
- package/plugins/utils/Tree.js +0 -169
- package/plugins/utils/Utils.js +0 -51
- package/plugins/utils/Validate.js +0 -33
- package/plugins/utils/Websocket.js +0 -186
- package/utils/PostMessage.js +0 -16
- package/utils/Request.js +0 -38
- /package/{method → extensions}/PageLoading.jsx +0 -0
- /package/{method → extensions}/Theme.js +0 -0
- /package/{plugins/font → font}/DS-DIGI-1.ttf +0 -0
- /package/{plugins/font → font}/DS-DIGIB-2.ttf +0 -0
- /package/{plugins/font → font}/DS-DIGII-3.ttf +0 -0
- /package/{plugins/font → font}/DS-DIGIT-4.ttf +0 -0
- /package/{plugins/font → font}/Orbitron-Black.ttf +0 -0
- /package/{plugins/font → font}/Orbitron-Bold.ttf +0 -0
- /package/{plugins/font → font}/Orbitron-Medium.ttf +0 -0
- /package/{plugins/font → font}/Orbitron-Regular.ttf +0 -0
- /package/{plugins/font → font}/PANGMENZHENGDAOBIAOTITI-1.TTF +0 -0
- /package/{plugins/font → font}/PingFang SC.ttf +0 -0
- /package/{plugins/font → font}/YouSheBiaoTiHei.ttf +0 -0
- /package/{plugins/font → font}/font.css +0 -0
- /package/{plugins/font → font}//345/255/227/351/255/20235/345/217/267-/347/273/217/345/205/270/351/233/205/351/273/221.ttf" +0 -0
- /package/lib/browse/{index.less → style/index.less} +0 -0
- /package/{dist/css/index.css → lib/button/style/index.less} +0 -0
- /package/lib/{dateTime → date-time}/index.js +0 -0
- /package/lib/{descriptions → descriptions-list/style}/index.less +0 -0
- /package/lib/{form/components → form-comp}/RenderComp.vue +0 -0
- /package/lib/{svgIcon → svg-icon}/index.js +0 -0
package/plugins/store/chat.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { DateTime } from "luxon"
|
|
2
|
-
|
|
3
|
-
const state = {
|
|
4
|
-
messages: [],
|
|
5
|
-
myself: {},
|
|
6
|
-
participants: [],
|
|
7
|
-
chatTitle: '',
|
|
8
|
-
chatDescription: '',
|
|
9
|
-
placeholder: ''
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const mutations = {
|
|
13
|
-
newMessage: (state, message) => {
|
|
14
|
-
message.timestamp = message.timestamp.toISO()
|
|
15
|
-
message.myself = message.participantId === state.myself.id
|
|
16
|
-
state.messages = [...state.messages, message]
|
|
17
|
-
},
|
|
18
|
-
setParticipants: (state, participants) => {
|
|
19
|
-
state.participants = participants
|
|
20
|
-
},
|
|
21
|
-
setMyself: (state, myself) => {
|
|
22
|
-
state.myself = myself
|
|
23
|
-
},
|
|
24
|
-
setMessages: (state, messages) => {
|
|
25
|
-
state.messages = messages.map(message => {
|
|
26
|
-
if(message.timestamp) (typeof message.timestamp == 'object') && (message.timestamp = DateTime.fromObject(message.timestamp).toISO())
|
|
27
|
-
else message.timestamp = DateTime.local().toISO()
|
|
28
|
-
|
|
29
|
-
if (!("myself" in message))
|
|
30
|
-
message.myself = message.participantId === state.myself.id
|
|
31
|
-
return message
|
|
32
|
-
})
|
|
33
|
-
},
|
|
34
|
-
setChatTitle: (state, title) => {
|
|
35
|
-
state.chatTitle = title
|
|
36
|
-
},
|
|
37
|
-
setChatDescription: (state, description) => {
|
|
38
|
-
state.chatDescription = description
|
|
39
|
-
},
|
|
40
|
-
setPlaceholder: (state, placeholder) => {
|
|
41
|
-
state.placeholder = placeholder
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const getters = {
|
|
46
|
-
getParticipantById: (state) => (id) => {
|
|
47
|
-
let curr_participant
|
|
48
|
-
state.participants.forEach(participant => {
|
|
49
|
-
if (participant.id === id) {
|
|
50
|
-
curr_participant = participant
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
return curr_participant
|
|
55
|
-
},
|
|
56
|
-
messages: (state) => {
|
|
57
|
-
let messages = []
|
|
58
|
-
state.messages.forEach(message => {
|
|
59
|
-
let newMessage = {...message}
|
|
60
|
-
newMessage.timestamp = DateTime.fromISO(newMessage.timestamp)
|
|
61
|
-
messages.push(newMessage)
|
|
62
|
-
});
|
|
63
|
-
return messages
|
|
64
|
-
},
|
|
65
|
-
myself: (state) => {
|
|
66
|
-
return state.myself
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default {
|
|
71
|
-
state,
|
|
72
|
-
mutations,
|
|
73
|
-
getters
|
|
74
|
-
}
|
package/plugins/store/project.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import storage from '../utils/Storage.js'
|
|
2
|
-
/** 存储方式 */
|
|
3
|
-
const storageMode = process.env.NODE_ENV === 'development' ? 'cookies' : 'local'
|
|
4
|
-
|
|
5
|
-
const state = {
|
|
6
|
-
/** 当前项目菜单code */
|
|
7
|
-
code: null,
|
|
8
|
-
/** 当前项目菜单code获取到的项目名称 */
|
|
9
|
-
systemName: '系统名称',
|
|
10
|
-
/** 整体项目编码 根据此编码获取项目信息(登录、门户、主题换肤等信息) */
|
|
11
|
-
projectIdent: storage[storageMode].get('projectIdent'),
|
|
12
|
-
/** 整体项目的主题风格 */
|
|
13
|
-
projectTheme: storage[storageMode].get('projectTheme'),
|
|
14
|
-
/** 整体项目配置登录、门户等跳转地址 */
|
|
15
|
-
projectConfig: storage[storageMode].getJson('projectConfig') || {}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const mutations = {
|
|
19
|
-
SET_CODE(state, code) {
|
|
20
|
-
state.code = code
|
|
21
|
-
},
|
|
22
|
-
SET_SYSTEMNAME(state, systemName) {
|
|
23
|
-
state.systemName = systemName
|
|
24
|
-
},
|
|
25
|
-
SET_IDENT(state, projectIdent) {
|
|
26
|
-
state.projectIdent = projectIdent
|
|
27
|
-
storage[storageMode].set('projectIdent', projectIdent)
|
|
28
|
-
},
|
|
29
|
-
SET_THEME(state, projectTheme) {
|
|
30
|
-
state.projectTheme = projectTheme
|
|
31
|
-
storage[storageMode].set('projectTheme', projectTheme)
|
|
32
|
-
},
|
|
33
|
-
SET_CONFIG(state, projectConfig) {
|
|
34
|
-
state.projectConfig = projectConfig
|
|
35
|
-
storage[storageMode].setJson('projectConfig', projectConfig)
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const actions = {
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default {
|
|
43
|
-
state,
|
|
44
|
-
mutations,
|
|
45
|
-
actions
|
|
46
|
-
}
|
package/plugins/utils/Axios.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// src/utils/http.js
|
|
2
|
-
import axios from 'axios'
|
|
3
|
-
|
|
4
|
-
// 创建 Axios 实例
|
|
5
|
-
const createAxiosService = (options) => {
|
|
6
|
-
const service = axios.create({
|
|
7
|
-
baseURL: options.baseURL,
|
|
8
|
-
timeout: 15000
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
// 请求拦截器
|
|
12
|
-
service.interceptors.request.use(
|
|
13
|
-
config => {
|
|
14
|
-
// 这里添加请求前的逻辑
|
|
15
|
-
const token = options.token
|
|
16
|
-
token && (config.headers['token'] = token)
|
|
17
|
-
|
|
18
|
-
// 取消重复请求处理
|
|
19
|
-
const requestKey = `${config.url}-${config.method}`
|
|
20
|
-
cancelPendingRequest(requestKey)
|
|
21
|
-
const controller = new AbortController()
|
|
22
|
-
config.signal = controller.signal
|
|
23
|
-
addPendingRequest(requestKey, controller)
|
|
24
|
-
|
|
25
|
-
return config
|
|
26
|
-
},
|
|
27
|
-
error => {
|
|
28
|
-
return Promise.reject(error)
|
|
29
|
-
}
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
// 响应拦截器
|
|
33
|
-
service.interceptors.response.use(
|
|
34
|
-
response => {
|
|
35
|
-
// 请求完成后移除pending状态
|
|
36
|
-
const requestKey = `${response.config.url}-${response.config.method}`
|
|
37
|
-
removePendingRequest(requestKey)
|
|
38
|
-
|
|
39
|
-
// 处理业务逻辑
|
|
40
|
-
const { data, config, headers } = response
|
|
41
|
-
if (config.responseType == 'blob') return { response: data, headers }
|
|
42
|
-
if (data && data.code !== 200) {
|
|
43
|
-
return Promise.reject(response.data.message || '请求错误')
|
|
44
|
-
}
|
|
45
|
-
return response.data.data
|
|
46
|
-
},
|
|
47
|
-
error => {
|
|
48
|
-
// 处理HTTP错误
|
|
49
|
-
if (error.response) {
|
|
50
|
-
options.requestErrorHandler(error.response.status)
|
|
51
|
-
switch (error.response.status) {
|
|
52
|
-
case 401:
|
|
53
|
-
console.error('认证失效,请重新登录')
|
|
54
|
-
break
|
|
55
|
-
case 403:
|
|
56
|
-
console.error('无权限访问该资源')
|
|
57
|
-
break
|
|
58
|
-
case 500:
|
|
59
|
-
console.error('服务器内部错误,请稍后重试')
|
|
60
|
-
break
|
|
61
|
-
default:
|
|
62
|
-
handleNetworkError(error)
|
|
63
|
-
}
|
|
64
|
-
} else if (error.message.includes('timeout')) {
|
|
65
|
-
console.error('请求超时,请检查网络后重试')
|
|
66
|
-
} else {
|
|
67
|
-
console.error('未知错误,请联系管理员')
|
|
68
|
-
}
|
|
69
|
-
return Promise.reject(error)
|
|
70
|
-
}
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
return service
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// 请求管理相关函数
|
|
77
|
-
const pendingRequests = new Map()
|
|
78
|
-
|
|
79
|
-
function addPendingRequest(key, controller) {
|
|
80
|
-
pendingRequests.set(key, controller)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function removePendingRequest(key) {
|
|
84
|
-
if (pendingRequests.has(key)) {
|
|
85
|
-
pendingRequests.delete(key)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function cancelPendingRequest(key) {
|
|
90
|
-
if (pendingRequests.has(key)) {
|
|
91
|
-
pendingRequests.get(key).abort()
|
|
92
|
-
pendingRequests.delete(key)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function handleNetworkError(error) {
|
|
97
|
-
// 处理常规网络错误
|
|
98
|
-
console.error('网络连接异常:', error.message)
|
|
99
|
-
// 可根据不同错误码细化处理
|
|
100
|
-
if (navigator.onLine === false) {
|
|
101
|
-
console.error('当前网络不可用')
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export default createAxiosService
|
package/plugins/utils/Base64.js
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// THIS FILE IS AUTOMATICALLY GENERATED! DO NOT EDIT BY HAND!
|
|
3
|
-
//
|
|
4
|
-
;
|
|
5
|
-
(function (global, factory) {
|
|
6
|
-
typeof exports === 'object' && typeof module !== 'undefined'
|
|
7
|
-
? module.exports = factory()
|
|
8
|
-
: typeof define === 'function' && define.amd
|
|
9
|
-
? define(factory) :
|
|
10
|
-
// cf. https://github.com/dankogai/js-base64/issues/119
|
|
11
|
-
(function () {
|
|
12
|
-
// existing version for noConflict()
|
|
13
|
-
var _Base64 = global.Base64;
|
|
14
|
-
var gBase64 = factory();
|
|
15
|
-
gBase64.noConflict = function () {
|
|
16
|
-
global.Base64 = _Base64;
|
|
17
|
-
return gBase64;
|
|
18
|
-
};
|
|
19
|
-
if (global.Meteor) { // Meteor.js
|
|
20
|
-
Base64 = gBase64;
|
|
21
|
-
}
|
|
22
|
-
global.Base64 = gBase64;
|
|
23
|
-
})();
|
|
24
|
-
}((typeof self !== 'undefined' ? self
|
|
25
|
-
: typeof window !== 'undefined' ? window
|
|
26
|
-
: typeof global !== 'undefined' ? global
|
|
27
|
-
: this), function () {
|
|
28
|
-
'use strict';
|
|
29
|
-
/**
|
|
30
|
-
* base64.ts
|
|
31
|
-
*
|
|
32
|
-
* Licensed under the BSD 3-Clause License.
|
|
33
|
-
* http://opensource.org/licenses/BSD-3-Clause
|
|
34
|
-
*
|
|
35
|
-
* References:
|
|
36
|
-
* http://en.wikipedia.org/wiki/Base64
|
|
37
|
-
*
|
|
38
|
-
* @author Dan Kogai (https://github.com/dankogai)
|
|
39
|
-
*/
|
|
40
|
-
var version = '3.7.7';
|
|
41
|
-
/**
|
|
42
|
-
* @deprecated use lowercase `version`.
|
|
43
|
-
*/
|
|
44
|
-
var VERSION = version;
|
|
45
|
-
var _hasBuffer = typeof Buffer === 'function';
|
|
46
|
-
var _TD = typeof TextDecoder === 'function' ? new TextDecoder() : undefined;
|
|
47
|
-
var _TE = typeof TextEncoder === 'function' ? new TextEncoder() : undefined;
|
|
48
|
-
var b64ch = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
49
|
-
var b64chs = Array.prototype.slice.call(b64ch);
|
|
50
|
-
var b64tab = (function (a) {
|
|
51
|
-
var tab = {};
|
|
52
|
-
a.forEach(function (c, i) { return tab[c] = i; });
|
|
53
|
-
return tab;
|
|
54
|
-
})(b64chs);
|
|
55
|
-
var b64re = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
|
|
56
|
-
var _fromCC = String.fromCharCode.bind(String);
|
|
57
|
-
var _U8Afrom = typeof Uint8Array.from === 'function'
|
|
58
|
-
? Uint8Array.from.bind(Uint8Array)
|
|
59
|
-
: function (it) { return new Uint8Array(Array.prototype.slice.call(it, 0)); };
|
|
60
|
-
var _mkUriSafe = function (src) { return src
|
|
61
|
-
.replace(/=/g, '').replace(/[+\/]/g, function (m0) { return m0 == '+' ? '-' : '_'; }); };
|
|
62
|
-
var _tidyB64 = function (s) { return s.replace(/[^A-Za-z0-9\+\/]/g, ''); };
|
|
63
|
-
/**
|
|
64
|
-
* polyfill version of `btoa`
|
|
65
|
-
*/
|
|
66
|
-
var btoaPolyfill = function (bin) {
|
|
67
|
-
// console.log('polyfilled');
|
|
68
|
-
var u32, c0, c1, c2, asc = '';
|
|
69
|
-
var pad = bin.length % 3;
|
|
70
|
-
for (var i = 0; i < bin.length;) {
|
|
71
|
-
if ((c0 = bin.charCodeAt(i++)) > 255 ||
|
|
72
|
-
(c1 = bin.charCodeAt(i++)) > 255 ||
|
|
73
|
-
(c2 = bin.charCodeAt(i++)) > 255)
|
|
74
|
-
throw new TypeError('invalid character found');
|
|
75
|
-
u32 = (c0 << 16) | (c1 << 8) | c2;
|
|
76
|
-
asc += b64chs[u32 >> 18 & 63]
|
|
77
|
-
+ b64chs[u32 >> 12 & 63]
|
|
78
|
-
+ b64chs[u32 >> 6 & 63]
|
|
79
|
-
+ b64chs[u32 & 63];
|
|
80
|
-
}
|
|
81
|
-
return pad ? asc.slice(0, pad - 3) + "===".substring(pad) : asc;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* does what `window.btoa` of web browsers do.
|
|
85
|
-
* @param {String} bin binary string
|
|
86
|
-
* @returns {string} Base64-encoded string
|
|
87
|
-
*/
|
|
88
|
-
var _btoa = typeof btoa === 'function' ? function (bin) { return btoa(bin); }
|
|
89
|
-
: _hasBuffer ? function (bin) { return Buffer.from(bin, 'binary').toString('base64'); }
|
|
90
|
-
: btoaPolyfill;
|
|
91
|
-
var _fromUint8Array = _hasBuffer
|
|
92
|
-
? function (u8a) { return Buffer.from(u8a).toString('base64'); }
|
|
93
|
-
: function (u8a) {
|
|
94
|
-
// cf. https://stackoverflow.com/questions/12710001/how-to-convert-uint8-array-to-base64-encoded-string/12713326#12713326
|
|
95
|
-
var maxargs = 0x1000;
|
|
96
|
-
var strs = [];
|
|
97
|
-
for (var i = 0, l = u8a.length; i < l; i += maxargs) {
|
|
98
|
-
strs.push(_fromCC.apply(null, u8a.subarray(i, i + maxargs)));
|
|
99
|
-
}
|
|
100
|
-
return _btoa(strs.join(''));
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* converts a Uint8Array to a Base64 string.
|
|
104
|
-
* @param {boolean} [urlsafe] URL-and-filename-safe a la RFC4648 §5
|
|
105
|
-
* @returns {string} Base64 string
|
|
106
|
-
*/
|
|
107
|
-
var fromUint8Array = function (u8a, urlsafe) {
|
|
108
|
-
if (urlsafe === void 0) { urlsafe = false; }
|
|
109
|
-
return urlsafe ? _mkUriSafe(_fromUint8Array(u8a)) : _fromUint8Array(u8a);
|
|
110
|
-
};
|
|
111
|
-
// This trick is found broken https://github.com/dankogai/js-base64/issues/130
|
|
112
|
-
// const utob = (src: string) => unescape(encodeURIComponent(src));
|
|
113
|
-
// reverting good old fationed regexp
|
|
114
|
-
var cb_utob = function (c) {
|
|
115
|
-
if (c.length < 2) {
|
|
116
|
-
var cc = c.charCodeAt(0);
|
|
117
|
-
return cc < 0x80 ? c
|
|
118
|
-
: cc < 0x800 ? (_fromCC(0xc0 | (cc >>> 6))
|
|
119
|
-
+ _fromCC(0x80 | (cc & 0x3f)))
|
|
120
|
-
: (_fromCC(0xe0 | ((cc >>> 12) & 0x0f))
|
|
121
|
-
+ _fromCC(0x80 | ((cc >>> 6) & 0x3f))
|
|
122
|
-
+ _fromCC(0x80 | (cc & 0x3f)));
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
var cc = 0x10000
|
|
126
|
-
+ (c.charCodeAt(0) - 0xD800) * 0x400
|
|
127
|
-
+ (c.charCodeAt(1) - 0xDC00);
|
|
128
|
-
return (_fromCC(0xf0 | ((cc >>> 18) & 0x07))
|
|
129
|
-
+ _fromCC(0x80 | ((cc >>> 12) & 0x3f))
|
|
130
|
-
+ _fromCC(0x80 | ((cc >>> 6) & 0x3f))
|
|
131
|
-
+ _fromCC(0x80 | (cc & 0x3f)));
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
|
|
135
|
-
/**
|
|
136
|
-
* @deprecated should have been internal use only.
|
|
137
|
-
* @param {string} src UTF-8 string
|
|
138
|
-
* @returns {string} UTF-16 string
|
|
139
|
-
*/
|
|
140
|
-
var utob = function (u) { return u.replace(re_utob, cb_utob); };
|
|
141
|
-
//
|
|
142
|
-
var _encode = _hasBuffer
|
|
143
|
-
? function (s) { return Buffer.from(s, 'utf8').toString('base64'); }
|
|
144
|
-
: _TE
|
|
145
|
-
? function (s) { return _fromUint8Array(_TE.encode(s)); }
|
|
146
|
-
: function (s) { return _btoa(utob(s)); };
|
|
147
|
-
/**
|
|
148
|
-
* converts a UTF-8-encoded string to a Base64 string.
|
|
149
|
-
* @param {boolean} [urlsafe] if `true` make the result URL-safe
|
|
150
|
-
* @returns {string} Base64 string
|
|
151
|
-
*/
|
|
152
|
-
var encode = function (src, urlsafe) {
|
|
153
|
-
if (urlsafe === void 0) { urlsafe = false; }
|
|
154
|
-
return urlsafe
|
|
155
|
-
? _mkUriSafe(_encode(src))
|
|
156
|
-
: _encode(src);
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* converts a UTF-8-encoded string to URL-safe Base64 RFC4648 §5.
|
|
160
|
-
* @returns {string} Base64 string
|
|
161
|
-
*/
|
|
162
|
-
var encodeURI = function (src) { return encode(src, true); };
|
|
163
|
-
// This trick is found broken https://github.com/dankogai/js-base64/issues/130
|
|
164
|
-
// const btou = (src: string) => decodeURIComponent(escape(src));
|
|
165
|
-
// reverting good old fationed regexp
|
|
166
|
-
var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
|
|
167
|
-
var cb_btou = function (cccc) {
|
|
168
|
-
switch (cccc.length) {
|
|
169
|
-
case 4:
|
|
170
|
-
var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
|
|
171
|
-
| ((0x3f & cccc.charCodeAt(1)) << 12)
|
|
172
|
-
| ((0x3f & cccc.charCodeAt(2)) << 6)
|
|
173
|
-
| (0x3f & cccc.charCodeAt(3)), offset = cp - 0x10000;
|
|
174
|
-
return (_fromCC((offset >>> 10) + 0xD800)
|
|
175
|
-
+ _fromCC((offset & 0x3FF) + 0xDC00));
|
|
176
|
-
case 3:
|
|
177
|
-
return _fromCC(((0x0f & cccc.charCodeAt(0)) << 12)
|
|
178
|
-
| ((0x3f & cccc.charCodeAt(1)) << 6)
|
|
179
|
-
| (0x3f & cccc.charCodeAt(2)));
|
|
180
|
-
default:
|
|
181
|
-
return _fromCC(((0x1f & cccc.charCodeAt(0)) << 6)
|
|
182
|
-
| (0x3f & cccc.charCodeAt(1)));
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* @deprecated should have been internal use only.
|
|
187
|
-
* @param {string} src UTF-16 string
|
|
188
|
-
* @returns {string} UTF-8 string
|
|
189
|
-
*/
|
|
190
|
-
var btou = function (b) { return b.replace(re_btou, cb_btou); };
|
|
191
|
-
/**
|
|
192
|
-
* polyfill version of `atob`
|
|
193
|
-
*/
|
|
194
|
-
var atobPolyfill = function (asc) {
|
|
195
|
-
// console.log('polyfilled');
|
|
196
|
-
asc = asc.replace(/\s+/g, '');
|
|
197
|
-
if (!b64re.test(asc))
|
|
198
|
-
throw new TypeError('malformed base64.');
|
|
199
|
-
asc += '=='.slice(2 - (asc.length & 3));
|
|
200
|
-
var u24, bin = '', r1, r2;
|
|
201
|
-
for (var i = 0; i < asc.length;) {
|
|
202
|
-
u24 = b64tab[asc.charAt(i++)] << 18
|
|
203
|
-
| b64tab[asc.charAt(i++)] << 12
|
|
204
|
-
| (r1 = b64tab[asc.charAt(i++)]) << 6
|
|
205
|
-
| (r2 = b64tab[asc.charAt(i++)]);
|
|
206
|
-
bin += r1 === 64 ? _fromCC(u24 >> 16 & 255)
|
|
207
|
-
: r2 === 64 ? _fromCC(u24 >> 16 & 255, u24 >> 8 & 255)
|
|
208
|
-
: _fromCC(u24 >> 16 & 255, u24 >> 8 & 255, u24 & 255);
|
|
209
|
-
}
|
|
210
|
-
return bin;
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* does what `window.atob` of web browsers do.
|
|
214
|
-
* @param {String} asc Base64-encoded string
|
|
215
|
-
* @returns {string} binary string
|
|
216
|
-
*/
|
|
217
|
-
var _atob = typeof atob === 'function' ? function (asc) { return atob(_tidyB64(asc)); }
|
|
218
|
-
: _hasBuffer ? function (asc) { return Buffer.from(asc, 'base64').toString('binary'); }
|
|
219
|
-
: atobPolyfill;
|
|
220
|
-
//
|
|
221
|
-
var _toUint8Array = _hasBuffer
|
|
222
|
-
? function (a) { return _U8Afrom(Buffer.from(a, 'base64')); }
|
|
223
|
-
: function (a) { return _U8Afrom(_atob(a).split('').map(function (c) { return c.charCodeAt(0); })); };
|
|
224
|
-
/**
|
|
225
|
-
* converts a Base64 string to a Uint8Array.
|
|
226
|
-
*/
|
|
227
|
-
var toUint8Array = function (a) { return _toUint8Array(_unURI(a)); };
|
|
228
|
-
//
|
|
229
|
-
var _decode = _hasBuffer
|
|
230
|
-
? function (a) { return Buffer.from(a, 'base64').toString('utf8'); }
|
|
231
|
-
: _TD
|
|
232
|
-
? function (a) { return _TD.decode(_toUint8Array(a)); }
|
|
233
|
-
: function (a) { return btou(_atob(a)); };
|
|
234
|
-
var _unURI = function (a) { return _tidyB64(a.replace(/[-_]/g, function (m0) { return m0 == '-' ? '+' : '/'; })); };
|
|
235
|
-
/**
|
|
236
|
-
* converts a Base64 string to a UTF-8 string.
|
|
237
|
-
* @param {String} src Base64 string. Both normal and URL-safe are supported
|
|
238
|
-
* @returns {string} UTF-8 string
|
|
239
|
-
*/
|
|
240
|
-
var decode = function (src) { return _decode(_unURI(src)); };
|
|
241
|
-
/**
|
|
242
|
-
* check if a value is a valid Base64 string
|
|
243
|
-
* @param {String} src a value to check
|
|
244
|
-
*/
|
|
245
|
-
var isValid = function (src) {
|
|
246
|
-
if (typeof src !== 'string')
|
|
247
|
-
return false;
|
|
248
|
-
var s = src.replace(/\s+/g, '').replace(/={0,2}$/, '');
|
|
249
|
-
return !/[^\s0-9a-zA-Z\+/]/.test(s) || !/[^\s0-9a-zA-Z\-_]/.test(s);
|
|
250
|
-
};
|
|
251
|
-
//
|
|
252
|
-
var _noEnum = function (v) {
|
|
253
|
-
return {
|
|
254
|
-
value: v, enumerable: false, writable: true, configurable: true
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
/**
|
|
258
|
-
* extend String.prototype with relevant methods
|
|
259
|
-
*/
|
|
260
|
-
var extendString = function () {
|
|
261
|
-
var _add = function (name, body) { return Object.defineProperty(String.prototype, name, _noEnum(body)); };
|
|
262
|
-
_add('fromBase64', function () { return decode(this); });
|
|
263
|
-
_add('toBase64', function (urlsafe) { return encode(this, urlsafe); });
|
|
264
|
-
_add('toBase64URI', function () { return encode(this, true); });
|
|
265
|
-
_add('toBase64URL', function () { return encode(this, true); });
|
|
266
|
-
_add('toUint8Array', function () { return toUint8Array(this); });
|
|
267
|
-
};
|
|
268
|
-
/**
|
|
269
|
-
* extend Uint8Array.prototype with relevant methods
|
|
270
|
-
*/
|
|
271
|
-
var extendUint8Array = function () {
|
|
272
|
-
var _add = function (name, body) { return Object.defineProperty(Uint8Array.prototype, name, _noEnum(body)); };
|
|
273
|
-
_add('toBase64', function (urlsafe) { return fromUint8Array(this, urlsafe); });
|
|
274
|
-
_add('toBase64URI', function () { return fromUint8Array(this, true); });
|
|
275
|
-
_add('toBase64URL', function () { return fromUint8Array(this, true); });
|
|
276
|
-
};
|
|
277
|
-
/**
|
|
278
|
-
* extend Builtin prototypes with relevant methods
|
|
279
|
-
*/
|
|
280
|
-
var extendBuiltins = function () {
|
|
281
|
-
extendString();
|
|
282
|
-
extendUint8Array();
|
|
283
|
-
};
|
|
284
|
-
var gBase64 = {
|
|
285
|
-
version: version,
|
|
286
|
-
VERSION: VERSION,
|
|
287
|
-
atob: _atob,
|
|
288
|
-
atobPolyfill: atobPolyfill,
|
|
289
|
-
btoa: _btoa,
|
|
290
|
-
btoaPolyfill: btoaPolyfill,
|
|
291
|
-
fromBase64: decode,
|
|
292
|
-
toBase64: encode,
|
|
293
|
-
encode: encode,
|
|
294
|
-
encodeURI: encodeURI,
|
|
295
|
-
encodeURL: encodeURI,
|
|
296
|
-
utob: utob,
|
|
297
|
-
btou: btou,
|
|
298
|
-
decode: decode,
|
|
299
|
-
isValid: isValid,
|
|
300
|
-
fromUint8Array: fromUint8Array,
|
|
301
|
-
toUint8Array: toUint8Array,
|
|
302
|
-
extendString: extendString,
|
|
303
|
-
extendUint8Array: extendUint8Array,
|
|
304
|
-
extendBuiltins: extendBuiltins
|
|
305
|
-
};
|
|
306
|
-
//
|
|
307
|
-
// export Base64 to the namespace
|
|
308
|
-
//
|
|
309
|
-
// ES5 is yet to have Object.assign() that may make transpilers unhappy.
|
|
310
|
-
// gBase64.Base64 = Object.assign({}, gBase64);
|
|
311
|
-
gBase64.Base64 = {};
|
|
312
|
-
Object.keys(gBase64).forEach(function (k) { return gBase64.Base64[k] = gBase64[k]; });
|
|
313
|
-
return gBase64;
|
|
314
|
-
}));
|