pome-ui 2.0.0-preview23 → 2.0.0-preview26
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/package.json +1 -1
- package/pome-commonjs.js +44 -3
- package/pome-commonjs.min.js +1 -1
package/package.json
CHANGED
package/pome-commonjs.js
CHANGED
|
@@ -5,6 +5,14 @@ if (window.Pomelo) {
|
|
|
5
5
|
Pomelo.Module = {};
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
if (!window.PomeloCommonJsConfig) {
|
|
9
|
+
window.PomeloCommonJsConfig = {};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function SetPomeloCommonJsConfig(options) {
|
|
13
|
+
window.PomeloCommonJsConfig = options;
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
var PomeloModule = (function (exports) {
|
|
9
17
|
if (exports.module) {
|
|
10
18
|
return;
|
|
@@ -21,6 +29,15 @@ var PomeloModule = (function (exports) {
|
|
|
21
29
|
url = url.substr(1);
|
|
22
30
|
}
|
|
23
31
|
}
|
|
32
|
+
|
|
33
|
+
if (window.PomeloCommonJsConfig.version) {
|
|
34
|
+
if (url.indexOf('?') > 0) {
|
|
35
|
+
url += '&v=' + window.PomeloCommonJsConfig.version;
|
|
36
|
+
} else {
|
|
37
|
+
url += '?v=' + window.PomeloCommonJsConfig.version;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
24
41
|
var xhr = new XMLHttpRequest();
|
|
25
42
|
xhr.open('get', url, false);
|
|
26
43
|
xhr.send();
|
|
@@ -90,6 +107,25 @@ var PomeloModule = (function (exports) {
|
|
|
90
107
|
}
|
|
91
108
|
}
|
|
92
109
|
|
|
110
|
+
var supportedExtensions = ['.js', '.json', '.cjs'];
|
|
111
|
+
|
|
112
|
+
function ensureRequiredJsPath(path) {
|
|
113
|
+
var slashIdx = path.lastIndexOf('/');
|
|
114
|
+
var subPath = slashIdx < 0 ? path : path.substr(slashIdx + 1);
|
|
115
|
+
|
|
116
|
+
var dotIdx = subPath.lastIndexOf('.');
|
|
117
|
+
var ext = subPath.substr(dotIdx);
|
|
118
|
+
if (dotIdx < 0) {
|
|
119
|
+
return path + '.js';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (supportedExtensions.some(x => x == ext.toLowerCase())) {
|
|
123
|
+
return path;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return path + '.js';
|
|
127
|
+
}
|
|
128
|
+
|
|
93
129
|
var module = {
|
|
94
130
|
require(script, workingDirectory, mode) {
|
|
95
131
|
mode = mode || 'singleton';
|
|
@@ -100,9 +136,7 @@ var PomeloModule = (function (exports) {
|
|
|
100
136
|
}
|
|
101
137
|
|
|
102
138
|
var url = resolveRelativePath(script, workingDirectory);
|
|
103
|
-
|
|
104
|
-
url = url + '.js';
|
|
105
|
-
}
|
|
139
|
+
var url = ensureRequiredJsPath(url);
|
|
106
140
|
if (_alias[url]) {
|
|
107
141
|
url = _alias[url];
|
|
108
142
|
}
|
|
@@ -113,6 +147,13 @@ var PomeloModule = (function (exports) {
|
|
|
113
147
|
|
|
114
148
|
var js = _cache[url];
|
|
115
149
|
|
|
150
|
+
if (url.length >= '.json'.length) {
|
|
151
|
+
var jsonExt = url.substr(url.length - '.json'.length);
|
|
152
|
+
if (jsonExt == '.json') {
|
|
153
|
+
return JSON.parse(js);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
116
157
|
if (mode == 'singleton' && _singleton[url]) {
|
|
117
158
|
return _singleton[url];
|
|
118
159
|
}
|
package/pome-commonjs.min.js
CHANGED
|
@@ -1 +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
|
|
1
|
+
if(window.Pomelo){Pomelo.Module={}}if(!window.PomeloCommonJsConfig){window.PomeloCommonJsConfig={}}function SetPomeloCommonJsConfig(e){window.PomeloCommonJsConfig=e}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)}}if(window.PomeloCommonJsConfig.version){if(e.indexOf("?")>0){e+="&v="+window.PomeloCommonJsConfig.version}else{e+="?v="+window.PomeloCommonJsConfig.version}}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 o=e.substr(0,r)+"/";if(useRelativePath&&o.length&&o[0]=="/"){o=o.substr(1)}return o}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 o=e.substr(0,r);var t=e.substr(r);return resolveRelativePath(t,o)}}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 supportedExtensions=[".js",".json",".cjs"];function ensureRequiredJsPath(e){var r=e.lastIndexOf("/");var o=r<0?e:e.substr(r+1);var t=o.lastIndexOf(".");var n=o.substr(t);if(t<0){return e+".js"}if(supportedExtensions.some(e=>e==n.toLowerCase())){return e}return e+".js"}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);var url=ensureRequiredJsPath(url);if(_alias[url]){url=_alias[url]}if(!_cache[url]){_cache[url]=_httpGetSync(url)}var js=_cache[url];if(url.length>=".json".length){var jsonExt=url.substr(url.length-".json".length);if(jsonExt==".json"){return JSON.parse(js)}}if(mode=="singleton"&&_singleton[url]){return _singleton[url]}var module={exports:{}};var self=this;with(module){var require=function(e,r,o){r=r||getContainingFolder(url);return self.require(e,r,o)};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);
|