pome-ui 2.0.0-preview1
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/LICENSE +674 -0
- package/LICENSE-VUEJS +23 -0
- package/package.json +21 -0
- package/pome-cache-query.js +326 -0
- package/pome-cache-query.min.js +1 -0
- package/pome-commonjs.js +152 -0
- package/pome-commonjs.min.js +1 -0
- package/pome-localization.js +83 -0
- package/pome-localization.min.js +1 -0
- package/pome-ui.dev.js +17155 -0
- package/pome-ui.dev.min.js +1 -0
- package/pome-ui.js +5 -0
- package/pome-ui.min.js +1 -0
package/LICENSE-VUEJS
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Original License URL: https://github.com/vuejs/core/blob/main/LICENSE
|
|
2
|
+
|
|
3
|
+
The MIT License (MIT)
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2018-present, Yuxi (Evan) You
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
|
15
|
+
all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
+
THE SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pome-ui",
|
|
3
|
+
"version": "2.0.0-preview1",
|
|
4
|
+
"description": "Front-end MVC library",
|
|
5
|
+
"main": "pome-ui.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"pomelo-vue": "bin/pome-ui.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://git.net/pomesoft/pome-ui.git"
|
|
15
|
+
},
|
|
16
|
+
"author": "Yuko Zheng",
|
|
17
|
+
"license": "GPL v3",
|
|
18
|
+
"bugs": {
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://git.net/pomesoft/pome-ui"
|
|
21
|
+
}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
// Copyright (c) Yuko(Yisheng) Zheng. All rights reserved.
|
|
2
|
+
// Licensed under the GPL v3. See LICENSE in the project root for license information.
|
|
3
|
+
|
|
4
|
+
(function (exports) {
|
|
5
|
+
if (typeof exports != 'undefined' && exports.get) {
|
|
6
|
+
return exports;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function _combineObject(src, dest) {
|
|
10
|
+
if (!src) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
var fields = Object.getOwnPropertyNames(src);
|
|
15
|
+
for (var i = 0; i < fields.length; ++i) {
|
|
16
|
+
dest[fields[i]] = src[fields[i]];
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var _options = {
|
|
21
|
+
isPagedResult(result) {
|
|
22
|
+
if (result.totalRecords == undefined
|
|
23
|
+
|| result.totalPages === undefined
|
|
24
|
+
|| result.currentPage === undefined
|
|
25
|
+
|| result.pageSize === undefined)
|
|
26
|
+
return false;
|
|
27
|
+
else
|
|
28
|
+
return true;
|
|
29
|
+
},
|
|
30
|
+
beforeSend: function (xhr) {
|
|
31
|
+
},
|
|
32
|
+
onError: function (err, xhr) {
|
|
33
|
+
return Promise.resolve(err);
|
|
34
|
+
},
|
|
35
|
+
onSucceeded: function (ret, xhr) {
|
|
36
|
+
return Promise.resolve(ret);
|
|
37
|
+
},
|
|
38
|
+
baseUrl: null,
|
|
39
|
+
batch: null,
|
|
40
|
+
batchInterval: null,
|
|
41
|
+
batchTimeout: 10
|
|
42
|
+
};
|
|
43
|
+
_combineObject(window.CQOptions || {}, _options);
|
|
44
|
+
|
|
45
|
+
var _batchRequests = [];
|
|
46
|
+
|
|
47
|
+
var cloneArray = function (array) {
|
|
48
|
+
var ret = [];
|
|
49
|
+
for (var i = 0; i < array.length; ++i) {
|
|
50
|
+
ret.push(array[i]);
|
|
51
|
+
}
|
|
52
|
+
return ret;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (_options.batch) {
|
|
56
|
+
setInterval(function () {
|
|
57
|
+
if (!_batchRequests.length) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
_options.batch(_batchRequests, _xhrRequest, _options);
|
|
61
|
+
_batchRequests = [];
|
|
62
|
+
}, _options.batchInterval || 50);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function clone(x) {
|
|
66
|
+
var json = JSON.stringify(x);
|
|
67
|
+
return JSON.parse(json);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function getFields(obj) {
|
|
71
|
+
var ret = [];
|
|
72
|
+
if (!obj || typeof obj !== 'object') return ret;
|
|
73
|
+
|
|
74
|
+
for (var x in obj) {
|
|
75
|
+
if (obj[x])
|
|
76
|
+
ret.push(x);
|
|
77
|
+
}
|
|
78
|
+
return ret;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var __cache = {};
|
|
82
|
+
var __cacheDictionary = {};
|
|
83
|
+
var __cacheExpire = {};
|
|
84
|
+
var __cacheFilters = {};
|
|
85
|
+
var __cacheSubscribe = {};
|
|
86
|
+
|
|
87
|
+
function randomString(length, chars = null) {
|
|
88
|
+
chars = chars || '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
|
|
89
|
+
var result = '';
|
|
90
|
+
for (var i = length; i > 0; --i) {
|
|
91
|
+
result += chars[Math.floor(Math.random() * chars.length)]
|
|
92
|
+
};
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function SetOptions(options) {
|
|
97
|
+
_combineObject(options, _options);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function _toUrlString(params, questionMark = true, ignore = null) {
|
|
101
|
+
var keys = Object.keys(params).sort();
|
|
102
|
+
if (!keys.length)
|
|
103
|
+
return '';
|
|
104
|
+
var ret = questionMark ? '?' : '';
|
|
105
|
+
for (var i = 0; i < keys.length; i++) {
|
|
106
|
+
if (ignore) {
|
|
107
|
+
if (ignore.some(x => x == keys[i])) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
ret += keys[i] + '=' + encodeURI(params[keys[i]]) + '&';
|
|
112
|
+
}
|
|
113
|
+
return ret.substr(0, ret.length - 1);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
function _urlStringToObject(str) {
|
|
117
|
+
str = str.substr(str.indexOf('?') + 1);
|
|
118
|
+
var splitedKeyValuePairs = str.split('&');
|
|
119
|
+
var ret = {};
|
|
120
|
+
for (var i = 0; i < splitedKeyValuePairs.length; i++) {
|
|
121
|
+
var splitedKeyValuePair = splitedKeyValuePairs[i].split('=');
|
|
122
|
+
ret[splitedKeyValuePair[0]] = decodeURI(splitedKeyValuePair[1]);
|
|
123
|
+
}
|
|
124
|
+
return ret;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
function _generateCacheKey(endpoint, params, isPaged) {
|
|
128
|
+
var par = clone(params);
|
|
129
|
+
if (isPaged && par.page) delete par.page;
|
|
130
|
+
return endpoint + _toUrlString(par);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
function _isPagedResult(result) {
|
|
134
|
+
return _options.isPagedResult(result);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
function _xhrRequest(options) {
|
|
138
|
+
var xhr = new XMLHttpRequest();
|
|
139
|
+
xhr.open(options.type, options.url);
|
|
140
|
+
xhr.setRequestHeader('Content-Type', options.contentType);
|
|
141
|
+
if (options.beforeSend) {
|
|
142
|
+
options.beforeSend(xhr);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (typeof options.data !== 'string') {
|
|
146
|
+
if (options.contentType.toLocaleLowerCase() == 'application/json') {
|
|
147
|
+
options.data = JSON.stringify(options.data);
|
|
148
|
+
} else if (options.contentType.toLocaleLowerCase() == 'application/octet-stream') {
|
|
149
|
+
} else {
|
|
150
|
+
options.data = _toUrlString(options.data, false);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
xhr.send(options.data);
|
|
155
|
+
xhr.onreadystatechange = function () {
|
|
156
|
+
if (xhr.readyState == 4) {
|
|
157
|
+
var ret = options.dataType == 'json' ? JSON.parse(xhr.responseText) : xhr.responseText;
|
|
158
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
159
|
+
options.success(ret, xhr);
|
|
160
|
+
} else {
|
|
161
|
+
options.error(ret, xhr);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
return xhr;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
function parseUrl(url) {
|
|
170
|
+
if (url.indexOf('//') >= 0) {
|
|
171
|
+
return url;
|
|
172
|
+
} else if (_options.baseUrl) {
|
|
173
|
+
return _options.baseUrl + url
|
|
174
|
+
} else {
|
|
175
|
+
return url;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function request(endpoint, method, params, dataType, contentType) {
|
|
180
|
+
dataType = dataType || 'json';
|
|
181
|
+
contentType = contentType || 'application/json';
|
|
182
|
+
params = method == 'GET' ? null : params;
|
|
183
|
+
endpoint = parseUrl(endpoint);
|
|
184
|
+
|
|
185
|
+
if (!_options.batch || dataType != 'json' || contentType != 'application/json') {
|
|
186
|
+
var self = this;
|
|
187
|
+
return new Promise(function (resolve, reject) {
|
|
188
|
+
var xhr = _xhrRequest({
|
|
189
|
+
url: endpoint,
|
|
190
|
+
type: method,
|
|
191
|
+
dataType: dataType,
|
|
192
|
+
contentType: contentType || 'application/json',
|
|
193
|
+
data: method == 'GET' ? null : params,
|
|
194
|
+
success: function (ret) {
|
|
195
|
+
_options.onSucceeded(ret, xhr).then(function (ret) {
|
|
196
|
+
resolve(ret);
|
|
197
|
+
});
|
|
198
|
+
},
|
|
199
|
+
error: function (err) {
|
|
200
|
+
return _options.onError(err, xhr).then(function (err) {
|
|
201
|
+
reject(err);
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
beforeSend: function (xhr) {
|
|
205
|
+
_options.beforeSend(xhr);
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
} else {
|
|
210
|
+
return new Promise(function (res, rej) {
|
|
211
|
+
_batchRequests.push({
|
|
212
|
+
resolve: res,
|
|
213
|
+
reject: rej,
|
|
214
|
+
request: {
|
|
215
|
+
requestId: randomString(32),
|
|
216
|
+
url: endpoint,
|
|
217
|
+
method: method,
|
|
218
|
+
body: params
|
|
219
|
+
? JSON.stringify(params)
|
|
220
|
+
: null,
|
|
221
|
+
contentType: 'application/json',
|
|
222
|
+
timeout: _options.batchTimeout
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function get(endpoint, params, dataType, contentType) {
|
|
230
|
+
var names = Object.getOwnPropertyNames(params || {});
|
|
231
|
+
if (names.length) {
|
|
232
|
+
if (endpoint.indexOf('?') >= 0) {
|
|
233
|
+
endpoint += '&';
|
|
234
|
+
} else {
|
|
235
|
+
endpoint += '?';
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
for (var i = 0; i < names.length; ++i) {
|
|
240
|
+
var name = names[i];
|
|
241
|
+
endpoint += encodeURIComponent(name) + '=' + encodeURIComponent(params[name] || '') + '&';
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (names.length) {
|
|
245
|
+
endpoint = endpoint.substr(0, endpoint.length - 1);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return request(endpoint, 'GET', params, dataType, contentType);
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
function post(endpoint, params, dataType, contentType) {
|
|
252
|
+
return request(endpoint, 'POST', params, dataType, contentType);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
function patch(endpoint, params, dataType, contentType) {
|
|
256
|
+
return request(endpoint, 'PATCH', params, dataType, contentType);
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
function put(endpoint, params, dataType, contentType) {
|
|
260
|
+
return request(endpoint, 'PUT', params, dataType, contentType);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
function _delete(endpoint, params, dataType) {
|
|
264
|
+
var names = Object.getOwnPropertyNames(params || {});
|
|
265
|
+
if (names.length) {
|
|
266
|
+
if (endpoint.indexOf('?') >= 0) {
|
|
267
|
+
endpoint += '&';
|
|
268
|
+
} else {
|
|
269
|
+
endpoint += '?';
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
for (var i = 0; i < names.length; ++i) {
|
|
274
|
+
var name = names[i];
|
|
275
|
+
endpoint += encodeURIComponent(name) + '=' + encodeURIComponent(params[name] || '') + '&';
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (names.length) {
|
|
279
|
+
endpoint = endpoint.substr(0, endpoint.length - 1);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return request(endpoint, 'DELETE', params, dataType);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
function removeCache(endpoint, params) {
|
|
286
|
+
var fields = getFields(params);
|
|
287
|
+
var key = _generateCacheKey(endpoint, params, fields.some(x => x === 'page'));
|
|
288
|
+
if (__cache[key]) {
|
|
289
|
+
delete __cache[key];
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
function cache(endpoint, params, result, expire) {
|
|
294
|
+
var key;
|
|
295
|
+
if (!__cacheDictionary[endpoint])
|
|
296
|
+
__cacheDictionary[endpoint] = [];
|
|
297
|
+
var isPagedResult = _isPagedResult(result);
|
|
298
|
+
if (!isPagedResult) {
|
|
299
|
+
key = _generateCacheKey(endpoint, params);
|
|
300
|
+
__cache[key] = result;
|
|
301
|
+
} else {
|
|
302
|
+
key = _generateCacheKey(endpoint, params, true);
|
|
303
|
+
if (!__cache[key]) __cache[key] = { isPaged: true };
|
|
304
|
+
__cache[key][result.data.current] = result;
|
|
305
|
+
}
|
|
306
|
+
if (!__cacheDictionary[endpoint].some(x => x == key))
|
|
307
|
+
__cacheDictionary[endpoint].push(key);
|
|
308
|
+
|
|
309
|
+
if (expire)
|
|
310
|
+
__cacheExpire[key] = new Date().getTime() + expire;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
exports.generateQueryStringFromObject = _toUrlString;
|
|
314
|
+
exports.generateObjectFromQueryString = _urlStringToObject;
|
|
315
|
+
exports.xhrRequest = _xhrRequest;
|
|
316
|
+
exports.request = request;
|
|
317
|
+
exports.get = get;
|
|
318
|
+
exports.post = post;
|
|
319
|
+
exports.put = put;
|
|
320
|
+
exports.patch = patch;
|
|
321
|
+
exports.delete = _delete;
|
|
322
|
+
exports.setOptions = SetOptions;
|
|
323
|
+
|
|
324
|
+
return exports;
|
|
325
|
+
|
|
326
|
+
})(typeof exports === 'object' && typeof module !== 'undefined' ? exports : (function () { window.cq = {}; return window.cq })());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e){if(typeof e!="undefined"&&e.get){return e}function n(e,n){if(!e){return}var t=Object.getOwnPropertyNames(e);for(var r=0;r<t.length;++r){n[t[r]]=e[t[r]]}}var f={isPagedResult(e){if(e.totalRecords==undefined||e.totalPages===undefined||e.currentPage===undefined||e.pageSize===undefined)return false;else return true},beforeSend:function(e){},onError:function(e,n){return Promise.resolve(e)},onSucceeded:function(e,n){return Promise.resolve(e)},baseUrl:null,batch:null,batchInterval:null,batchTimeout:10};n(window.CQOptions||{},f);var t=[];var r=function(e){var n=[];for(var t=0;t<e.length;++t){n.push(e[t])}return n};if(f.batch){setInterval(function(){if(!t.length){return}f.batch(t,y,f);t=[]},f.batchInterval||50)}function o(e){var n=JSON.stringify(e);return JSON.parse(n)}function a(e){var n=[];if(!e||typeof e!=="object")return n;for(var t in e){if(e[t])n.push(t)}return n}var i={};var u={};var s={};var c={};var l={};function d(e,n=null){n=n||"1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM";var t="";for(var r=e;r>0;--r){t+=n[Math.floor(Math.random()*n.length)]}return t}function p(e){n(e,f)}function v(e,n=true,t=null){var r=Object.keys(e).sort();if(!r.length)return"";var o=n?"?":"";for(var a=0;a<r.length;a++){if(t){if(t.some(e=>e==r[a])){continue}}o+=r[a]+"="+encodeURI(e[r[a]])+"&"}return o.substr(0,o.length-1)}function g(e){e=e.substr(e.indexOf("?")+1);var n=e.split("&");var t={};for(var r=0;r<n.length;r++){var o=n[r].split("=");t[o[0]]=decodeURI(o[1])}return t}function h(e,n,t){var r=o(n);if(t&&r.page)delete r.page;return e+v(r)}function b(e){return f.isPagedResult(e)}function y(n){var t=new XMLHttpRequest;t.open(n.type,n.url);t.setRequestHeader("Content-Type",n.contentType);if(n.beforeSend){n.beforeSend(t)}if(typeof n.data!=="string"){if(n.contentType.toLocaleLowerCase()=="application/json"){n.data=JSON.stringify(n.data)}else if(n.contentType.toLocaleLowerCase()=="application/octet-stream"){}else{n.data=v(n.data,false)}}t.send(n.data);t.onreadystatechange=function(){if(t.readyState==4){var e=n.dataType=="json"?JSON.parse(t.responseText):t.responseText;if(t.status>=200&&t.status<300){n.success(e,t)}else{n.error(e,t)}}};return t}function m(e){if(e.indexOf("//")>=0){return e}else if(f.baseUrl){return f.baseUrl+e}else{return e}}function O(o,a,i,e,u){e=e||"json";u=u||"application/json";i=a=="GET"?null:i;o=m(o);if(!f.batch||e!="json"||u!="application/json"){var n=this;return new Promise(function(n,t){var r=y({url:o,type:a,dataType:e,contentType:u||"application/json",data:a=="GET"?null:i,success:function(e){f.onSucceeded(e,r).then(function(e){n(e)})},error:function(e){return f.onError(e,r).then(function(e){t(e)})},beforeSend:function(e){f.beforeSend(e)}})})}else{return new Promise(function(e,n){t.push({resolve:e,reject:n,request:{requestId:d(32),url:o,method:a,body:i?JSON.stringify(i):null,contentType:"application/json",timeout:f.batchTimeout}})})}}function T(e,n,t,r){var o=Object.getOwnPropertyNames(n||{});if(o.length){if(e.indexOf("?")>=0){e+="&"}else{e+="?"}}for(var a=0;a<o.length;++a){var i=o[a];e+=encodeURIComponent(i)+"="+encodeURIComponent(n[i]||"")+"&"}if(o.length){e=e.substr(0,e.length-1)}return O(e,"GET",n,t,r)}function j(e,n,t,r){return O(e,"POST",n,t,r)}function S(e,n,t,r){return O(e,"PATCH",n,t,r)}function w(e,n,t,r){return O(e,"PUT",n,t,r)}function P(e,n,t){var r=Object.getOwnPropertyNames(n||{});if(r.length){if(e.indexOf("?")>=0){e+="&"}else{e+="?"}}for(var o=0;o<r.length;++o){var a=r[o];e+=encodeURIComponent(a)+"="+encodeURIComponent(n[a]||"")+"&"}if(r.length){e=e.substr(0,e.length-1)}return O(e,"DELETE",n,t)}function R(e,n){var t=a(n);var r=h(e,n,t.some(e=>e==="page"));if(i[r]){delete i[r]}}function I(e,n,t,r){var o;if(!u[e])u[e]=[];var a=b(t);if(!a){o=h(e,n);i[o]=t}else{o=h(e,n,true);if(!i[o])i[o]={isPaged:true};i[o][t.data.current]=t}if(!u[e].some(e=>e==o))u[e].push(o);if(r)s[o]=(new Date).getTime()+r}e.generateQueryStringFromObject=v;e.generateObjectFromQueryString=g;e.xhrRequest=y;e.request=O;e.get=T;e.post=j;e.put=w;e.patch=S;e.delete=P;e.setOptions=p;return e})(typeof exports==="object"&&typeof module!=="undefined"?exports:function(){window.cq={};return window.cq}());
|
package/pome-commonjs.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// Copyright (c) Yuko(Yisheng) Zheng. All rights reserved.
|
|
2
|
+
// Licensed under the GPL v3. See LICENSE in the project root for license information.
|
|
3
|
+
|
|
4
|
+
if (window.Pomelo) {
|
|
5
|
+
Pomelo.Module = {};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
var PomeloModule = (function (exports) {
|
|
9
|
+
if (exports.module) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
var _cache = {};
|
|
14
|
+
var _alias = {};
|
|
15
|
+
var _singleton = {};
|
|
16
|
+
var useRelativePath = window.location.protocol != 'http:' && window.location.protocol != 'https:'
|
|
17
|
+
|
|
18
|
+
function _httpGetSync(url) {
|
|
19
|
+
if (useRelativePath) {
|
|
20
|
+
if (url.length && url[0] == '/') {
|
|
21
|
+
url = url.substr(1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
var xhr = new XMLHttpRequest();
|
|
25
|
+
xhr.open('get', url, false);
|
|
26
|
+
xhr.send();
|
|
27
|
+
return xhr.responseText;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var validModes = ['singleton', 'transient'];
|
|
31
|
+
|
|
32
|
+
function getContainingFolder(absolutePath) {
|
|
33
|
+
if (!absolutePath) {
|
|
34
|
+
console.warn('getContainingFolder: absolutePath is invalid');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var slashIndex = absolutePath.lastIndexOf('/');
|
|
38
|
+
if (slashIndex < 0) {
|
|
39
|
+
return useRelativePath ? '' : '/';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var ret = absolutePath.substr(0, slashIndex) + '/';
|
|
43
|
+
|
|
44
|
+
if (useRelativePath && ret.length && ret[0] == '/') {
|
|
45
|
+
ret = ret.substr(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return ret;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function resolveRelativePathPlain(url) {
|
|
52
|
+
if (url.indexOf('./') == -1 && url.indexOf('../') == -1) {
|
|
53
|
+
return url;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var index = url.lastIndexOf('../');
|
|
57
|
+
if (index == 0) {
|
|
58
|
+
return url;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
url = url.replaceAll('/./', '/');
|
|
62
|
+
if (url.indexOf('./') == 0) {
|
|
63
|
+
url = url.substr(2);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (index) {
|
|
67
|
+
var w = url.substr(0, index);
|
|
68
|
+
var f = url.substr(index);
|
|
69
|
+
return resolveRelativePath(f, w);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function resolveRelativePath(file, workingDirectory) {
|
|
74
|
+
if (file.length && (file[0] == '/') || file.indexOf('http') == 0) {
|
|
75
|
+
return resolveRelativePathPlain(file);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (file.length && file[0] != '.') {
|
|
79
|
+
return resolveRelativePathPlain(workingDirectory + file);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (file.indexOf('./') == 0) {
|
|
83
|
+
return resolveRelativePath(file.substr(2), workingDirectory);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (file.indexOf('../') == 0) {
|
|
87
|
+
file = file.substr(3);
|
|
88
|
+
workingDirectory = getContainingFolder(workingDirectory.substr(0, workingDirectory.length - 1));
|
|
89
|
+
return resolveRelativePath(file, workingDirectory);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
var module = {
|
|
94
|
+
require(script, workingDirectory, mode) {
|
|
95
|
+
mode = mode || 'singleton';
|
|
96
|
+
workingDirectory = workingDirectory || '/';
|
|
97
|
+
|
|
98
|
+
if (validModes.indexOf(mode) == -1) {
|
|
99
|
+
throw 'Invalid require mode';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
var url = resolveRelativePath(script, workingDirectory);
|
|
103
|
+
if (url.length < 3 || url.substr(url.length - 3) != '.js') {
|
|
104
|
+
url = url + '.js';
|
|
105
|
+
}
|
|
106
|
+
if (_alias[url]) {
|
|
107
|
+
url = _alias[url];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!_cache[url]) {
|
|
111
|
+
_cache[url] = _httpGetSync(url);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
var js = _cache[url];
|
|
115
|
+
|
|
116
|
+
if (mode == 'singleton' && _singleton[url]) {
|
|
117
|
+
return _singleton[url];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
var module = {
|
|
121
|
+
exports: {}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
var self = this;
|
|
125
|
+
|
|
126
|
+
with (module) {
|
|
127
|
+
var require = function (script, _workingDirectory, mode) {
|
|
128
|
+
_workingDirectory = _workingDirectory || getContainingFolder(url);
|
|
129
|
+
return self.require(script, _workingDirectory, mode);
|
|
130
|
+
};
|
|
131
|
+
js = js.replaceAll('export default', 'exports.default =');
|
|
132
|
+
eval(js + '\r\n//# sourceURL=' + url);
|
|
133
|
+
if (mode == 'singleton') {
|
|
134
|
+
_singleton[url] = exports;
|
|
135
|
+
}
|
|
136
|
+
return exports;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return module.exports;
|
|
140
|
+
},
|
|
141
|
+
alias(url, alias) {
|
|
142
|
+
_alias[alias] = url;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
exports.require = module.require;
|
|
147
|
+
exports.alias = module.alias;
|
|
148
|
+
exports.getContainingFolder = getContainingFolder;
|
|
149
|
+
|
|
150
|
+
return exports;
|
|
151
|
+
|
|
152
|
+
})(window);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
if(window.Pomelo){Pomelo.Module={}}var PomeloModule=function(exports){if(exports.module){return}var _cache={};var _alias={};var _singleton={};var useRelativePath=window.location.protocol!="http:"&&window.location.protocol!="https:";function _httpGetSync(e){if(useRelativePath){if(e.length&&e[0]=="/"){e=e.substr(1)}}var r=new XMLHttpRequest;r.open("get",e,false);r.send();return r.responseText}var validModes=["singleton","transient"];function getContainingFolder(e){if(!e){console.warn("getContainingFolder: absolutePath is invalid")}var r=e.lastIndexOf("/");if(r<0){return useRelativePath?"":"/"}var t=e.substr(0,r)+"/";if(useRelativePath&&t.length&&t[0]=="/"){t=t.substr(1)}return t}function resolveRelativePathPlain(e){if(e.indexOf("./")==-1&&e.indexOf("../")==-1){return e}var r=e.lastIndexOf("../");if(r==0){return e}e=e.replaceAll("/./","/");if(e.indexOf("./")==0){e=e.substr(2)}if(r){var t=e.substr(0,r);var i=e.substr(r);return resolveRelativePath(i,t)}}function resolveRelativePath(e,r){if(e.length&&e[0]=="/"||e.indexOf("http")==0){return resolveRelativePathPlain(e)}if(e.length&&e[0]!="."){return resolveRelativePathPlain(r+e)}if(e.indexOf("./")==0){return resolveRelativePath(e.substr(2),r)}if(e.indexOf("../")==0){e=e.substr(3);r=getContainingFolder(r.substr(0,r.length-1));return resolveRelativePath(e,r)}}var module={require(script,workingDirectory,mode){mode=mode||"singleton";workingDirectory=workingDirectory||"/";if(validModes.indexOf(mode)==-1){throw"Invalid require mode"}var url=resolveRelativePath(script,workingDirectory);if(url.length<3||url.substr(url.length-3)!=".js"){url=url+".js"}if(_alias[url]){url=_alias[url]}if(!_cache[url]){_cache[url]=_httpGetSync(url)}var js=_cache[url];if(mode=="singleton"&&_singleton[url]){return _singleton[url]}var module={exports:{}};var self=this;with(module){var require=function(e,r,t){r=r||getContainingFolder(url);return self.require(e,r,t)};js=js.replaceAll("export default","exports.default =");eval(js+"\r\n//# sourceURL="+url);if(mode=="singleton"){_singleton[url]=exports}return exports}return module.exports},alias(e,r){_alias[r]=e}};exports.require=module.require;exports.alias=module.alias;exports.getContainingFolder=getContainingFolder;return exports}(window);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Copyright (c) Yuko(Yisheng) Zheng. All rights reserved.
|
|
2
|
+
// Licensed under the MIT. See LICENSE in the project root for license information.
|
|
3
|
+
|
|
4
|
+
function create() {
|
|
5
|
+
var currentLocale = null;
|
|
6
|
+
return {
|
|
7
|
+
locales: {},
|
|
8
|
+
texts: {},
|
|
9
|
+
getCurrentLocale() {
|
|
10
|
+
return currentLocale;
|
|
11
|
+
},
|
|
12
|
+
addLocale(path, locales, isFallback) {
|
|
13
|
+
if (!locales) {
|
|
14
|
+
var index = path.lastIndexOf('/');
|
|
15
|
+
if (index < 0) {
|
|
16
|
+
locales = path;
|
|
17
|
+
} else {
|
|
18
|
+
locales = path.substr(path, index + 1);
|
|
19
|
+
}
|
|
20
|
+
locales = locales.split('.')[0];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (typeof locales == 'string') {
|
|
24
|
+
this.locales[locales] = path;
|
|
25
|
+
} else if (locales instanceof Array) {
|
|
26
|
+
for (var i = 0; i < locales.length; ++i) {
|
|
27
|
+
this.locales[locales[i]] = path;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isFallback) {
|
|
32
|
+
this.locales['fallback'] = path;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
setLocale(locale) {
|
|
36
|
+
if (!locale) {
|
|
37
|
+
locale = !window.localStorage.locale
|
|
38
|
+
? window.navigator.language
|
|
39
|
+
: window.localStorage.locale;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!this.locales[locale]) {
|
|
43
|
+
locale = 'fallback';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!this.locales[locale]) {
|
|
47
|
+
throw 'No available translations for the locale';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
currentLocale = locale;
|
|
51
|
+
this.texts = require(this.locales[locale]).texts;
|
|
52
|
+
|
|
53
|
+
if (this.locales['fallback']) {
|
|
54
|
+
if (this.locales[locale] != this.locales['fallback']) {
|
|
55
|
+
var texts = require(this.locales['fallback']).texts;
|
|
56
|
+
var keys = Object.getOwnPropertyNames(texts);
|
|
57
|
+
var self = this;
|
|
58
|
+
keys.forEach(function (key) {
|
|
59
|
+
if (!self.texts[key]) {
|
|
60
|
+
self.texts[key] = texts[key];
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
sr() {
|
|
67
|
+
if (arguments.length == 0) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
var key = arguments[0];
|
|
71
|
+
var val = key;
|
|
72
|
+
if (this.texts[key]) {
|
|
73
|
+
val = this.texts[key];
|
|
74
|
+
}
|
|
75
|
+
for (var i = 1; i < arguments.length; ++i) {
|
|
76
|
+
val = val.replaceAll(`{${i - 1}}`, arguments[i]);
|
|
77
|
+
}
|
|
78
|
+
return val;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.create = create;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function create(){var s=null;return{locales:{},texts:{},getCurrentLocale(){return s},addLocale(e,l,t){if(!l){var a=e.lastIndexOf("/");if(a<0){l=e}else{l=e.substr(e,a+1)}l=l.split(".")[0]}if(typeof l=="string"){this.locales[l]=e}else if(l instanceof Array){for(var s=0;s<l.length;++s){this.locales[l[s]]=e}}if(t){this.locales["fallback"]=e}},setLocale(e){if(!e){e=!window.localStorage.locale?window.navigator.language:window.localStorage.locale}if(!this.locales[e]){e="fallback"}if(!this.locales[e]){throw"No available translations for the locale"}s=e;this.texts=require(this.locales[e]).texts;if(this.locales["fallback"]){if(this.locales[e]!=this.locales["fallback"]){var l=require(this.locales["fallback"]).texts;var t=Object.getOwnPropertyNames(l);var a=this;t.forEach(function(e){if(!a.texts[e]){a.texts[e]=l[e]}})}}},sr(){if(arguments.length==0){return null}var e=arguments[0];var l=e;if(this.texts[e]){l=this.texts[e]}for(var t=1;t<arguments.length;++t){l=l.replaceAll(`{${t-1}}`,arguments[t])}return l}}}exports.create=create;
|