pome-ui 2.0.0-preview24 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pome-ui",
3
- "version": "2.0.0-preview24",
3
+ "version": "2.0.0-preview26",
4
4
  "description": "Front-end MVC library",
5
5
  "main": "pome-ui.js",
6
6
  "bin": {
package/pome-commonjs.js CHANGED
@@ -107,6 +107,25 @@ var PomeloModule = (function (exports) {
107
107
  }
108
108
  }
109
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
+
110
129
  var module = {
111
130
  require(script, workingDirectory, mode) {
112
131
  mode = mode || 'singleton';
@@ -117,9 +136,7 @@ var PomeloModule = (function (exports) {
117
136
  }
118
137
 
119
138
  var url = resolveRelativePath(script, workingDirectory);
120
- if (url.length < 3 || url.substr(url.length - 3) != '.js') {
121
- url = url + '.js';
122
- }
139
+ var url = ensureRequiredJsPath(url);
123
140
  if (_alias[url]) {
124
141
  url = _alias[url];
125
142
  }
@@ -130,6 +147,13 @@ var PomeloModule = (function (exports) {
130
147
 
131
148
  var js = _cache[url];
132
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
+
133
157
  if (mode == 'singleton' && _singleton[url]) {
134
158
  return _singleton[url];
135
159
  }
@@ -1 +1 @@
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 o=new XMLHttpRequest;o.open("get",e,false);o.send();return o.responseText}var validModes=["singleton","transient"];function getContainingFolder(e){if(!e){console.warn("getContainingFolder: absolutePath is invalid")}var o=e.lastIndexOf("/");if(o<0){return useRelativePath?"":"/"}var r=e.substr(0,o)+"/";if(useRelativePath&&r.length&&r[0]=="/"){r=r.substr(1)}return r}function resolveRelativePathPlain(e){if(e.indexOf("./")==-1&&e.indexOf("../")==-1){return e}var o=e.lastIndexOf("../");if(o==0){return e}e=e.replaceAll("/./","/");if(e.indexOf("./")==0){e=e.substr(2)}if(o){var r=e.substr(0,o);var t=e.substr(o);return resolveRelativePath(t,r)}}function resolveRelativePath(e,o){if(e.length&&e[0]=="/"||e.indexOf("http")==0){return resolveRelativePathPlain(e)}if(e.length&&e[0]!="."){return resolveRelativePathPlain(o+e)}if(e.indexOf("./")==0){return resolveRelativePath(e.substr(2),o)}if(e.indexOf("../")==0){e=e.substr(3);o=getContainingFolder(o.substr(0,o.length-1));return resolveRelativePath(e,o)}}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,o,r){o=o||getContainingFolder(url);return self.require(e,o,r)};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,o){_alias[o]=e}};exports.require=module.require;exports.alias=module.alias;exports.getContainingFolder=getContainingFolder;return exports}(window);
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);