pome-ui 2.0.0-preview60 → 2.0.0-preview62

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-preview60",
3
+ "version": "2.0.0-preview62",
4
4
  "description": "Front-end MVC library",
5
5
  "main": "pome-ui.js",
6
6
  "bin": {
package/pome-commonjs.js CHANGED
@@ -21,7 +21,36 @@ var PomeloModule = (function (exports) {
21
21
  var _cache = {};
22
22
  var _alias = {};
23
23
  var _singleton = {};
24
- var useRelativePath = window.location.protocol != 'http:' && window.location.protocol != 'https:'
24
+ var useRelativePath = window.location.protocol != 'http:' && window.location.protocol != 'https:';
25
+
26
+ function normalizePath(url) {
27
+ if (!url) return url;
28
+ var prefix = '';
29
+ var protocolIdx = url.indexOf('://');
30
+ if (protocolIdx >= 0) {
31
+ prefix = url.substring(0, protocolIdx + 3);
32
+ url = url.substring(protocolIdx + 3);
33
+ }
34
+
35
+ var segments = url.split('/');
36
+ var result = [];
37
+
38
+ for (var i = 0; i < segments.length; i++) {
39
+ if (segments[i] === '.') {
40
+ continue;
41
+ } else if (segments[i] === '..') {
42
+ if (result.length > 0 && result[result.length - 1] !== '' && result[result.length - 1] !== '..') {
43
+ result.pop();
44
+ } else if (result.length === 0) {
45
+ result.push('..');
46
+ }
47
+ } else {
48
+ result.push(segments[i]);
49
+ }
50
+ }
51
+
52
+ return prefix + result.join('/');
53
+ }
25
54
 
26
55
  function _httpGetSync(url) {
27
56
  if (useRelativePath) {
@@ -41,6 +70,9 @@ var PomeloModule = (function (exports) {
41
70
  var xhr = new XMLHttpRequest();
42
71
  xhr.open('get', url, false);
43
72
  xhr.send();
73
+ if (xhr.status !== 0 && xhr.status !== 200) {
74
+ throw new Error('Failed to load module: ' + url + ' (HTTP ' + xhr.status + ')');
75
+ }
44
76
  return xhr.responseText;
45
77
  }
46
78
 
@@ -65,46 +97,16 @@ var PomeloModule = (function (exports) {
65
97
  return ret;
66
98
  }
67
99
 
68
- function resolveRelativePathPlain(url) {
69
- if (url.indexOf('./') == -1 && url.indexOf('../') == -1) {
70
- return url;
71
- }
72
-
73
- var index = url.lastIndexOf('../');
74
- if (index == 0) {
75
- return url;
76
- }
77
-
78
- url = url.replaceAll('/./', '/');
79
- if (url.indexOf('./') == 0) {
80
- url = url.substr(2);
81
- }
82
-
83
- if (index) {
84
- var w = url.substr(0, index);
85
- var f = url.substr(index);
86
- return resolveRelativePath(f, w);
87
- }
88
- }
89
-
90
100
  function resolveRelativePath(file, workingDirectory) {
91
- if (file.length && (file[0] == '/') || file.indexOf('http') == 0) {
92
- return resolveRelativePathPlain(file);
93
- }
94
-
95
- if (file.length && file[0] != '.') {
96
- return resolveRelativePathPlain(workingDirectory + file);
97
- }
101
+ if (!file) return normalizePath(workingDirectory);
98
102
 
99
- if (file.indexOf('./') == 0) {
100
- return resolveRelativePath(file.substr(2), workingDirectory);
103
+ // Absolute path or full URL
104
+ if (file[0] === '/' || file.indexOf('http') === 0) {
105
+ return normalizePath(file);
101
106
  }
102
107
 
103
- if (file.indexOf('../') == 0) {
104
- file = file.substr(3);
105
- workingDirectory = getContainingFolder(workingDirectory.substr(0, workingDirectory.length - 1));
106
- return resolveRelativePath(file, workingDirectory);
107
- }
108
+ // Relative path (./xxx, ../xxx, or plain name)
109
+ return normalizePath(workingDirectory + file);
108
110
  }
109
111
 
110
112
  var supportedExtensions = ['.js', '.json', '.cjs'];
@@ -136,7 +138,7 @@ var PomeloModule = (function (exports) {
136
138
  }
137
139
 
138
140
  var url = resolveRelativePath(script, workingDirectory);
139
- var url = ensureRequiredJsPath(url);
141
+ url = ensureRequiredJsPath(url);
140
142
  if (_alias[url]) {
141
143
  url = _alias[url];
142
144
  }
@@ -147,11 +149,8 @@ var PomeloModule = (function (exports) {
147
149
 
148
150
  var js = _cache[url];
149
151
 
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
- }
152
+ if (url.length >= '.json'.length && url.substring(url.length - '.json'.length) === '.json') {
153
+ return JSON.parse(js);
155
154
  }
156
155
 
157
156
  if (mode == 'singleton' && _singleton[url]) {
@@ -162,6 +161,13 @@ var PomeloModule = (function (exports) {
162
161
  exports: {}
163
162
  };
164
163
 
164
+ // Pre-register singleton to handle circular dependencies
165
+ if (mode == 'singleton') {
166
+ _singleton[url] = module.exports;
167
+ }
168
+
169
+ var __filename = url;
170
+ var __dirname = getContainingFolder(url);
165
171
  var self = this;
166
172
 
167
173
  with (module) {
@@ -169,15 +175,14 @@ var PomeloModule = (function (exports) {
169
175
  _workingDirectory = _workingDirectory || getContainingFolder(url);
170
176
  return self.require(script, _workingDirectory, mode);
171
177
  };
172
- js = js.replaceAll('export default', 'exports.default =');
178
+ js = js.replace(/\bexport\s+default\b/g, 'exports.default =');
173
179
  eval(js + '\r\n//# sourceURL=' + url);
180
+ // Update singleton with final exports (handles module.exports reassignment)
174
181
  if (mode == 'singleton') {
175
182
  _singleton[url] = exports;
176
183
  }
177
184
  return exports;
178
185
  }
179
-
180
- return module.exports;
181
186
  },
182
187
  alias(url, alias) {
183
188
  _alias[alias] = url;
@@ -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 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);
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 normalizePath(e){if(!e)return e;var o="";var r=e.indexOf("://");if(r>=0){o=e.substring(0,r+3);e=e.substring(r+3)}var n=e.split("/");var t=[];for(var i=0;i<n.length;i++){if(n[i]==="."){continue}else if(n[i]===".."){if(t.length>0&&t[t.length-1]!==""&&t[t.length-1]!==".."){t.pop()}else if(t.length===0){t.push("..")}}else{t.push(n[i])}}return o+t.join("/")}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();if(o.status!==0&&o.status!==200){throw new Error("Failed to load module: "+e+" (HTTP "+o.status+")")}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 resolveRelativePath(e,o){if(!e)return normalizePath(o);if(e[0]==="/"||e.indexOf("http")===0){return normalizePath(e)}return normalizePath(o+e)}var supportedExtensions=[".js",".json",".cjs"];function ensureRequiredJsPath(e){var o=e.lastIndexOf("/");var r=o<0?e:e.substr(o+1);var n=r.lastIndexOf(".");var t=r.substr(n);if(n<0){return e+".js"}if(supportedExtensions.some(e=>e==t.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);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&&url.substring(url.length-".json".length)===".json"){return JSON.parse(js)}if(mode=="singleton"&&_singleton[url]){return _singleton[url]}var module={exports:{}};if(mode=="singleton"){_singleton[url]=module.exports}var __filename=url;var __dirname=getContainingFolder(url);var self=this;with(module){var require=function(e,o,r){o=o||getContainingFolder(url);return self.require(e,o,r)};js=js.replace(/\bexport\s+default\b/g,"exports.default =");eval(js+"\r\n//# sourceURL="+url);if(mode=="singleton"){_singleton[url]=exports}return exports}},alias(e,o){_alias[o]=e}};exports.require=module.require;exports.alias=module.alias;exports.getContainingFolder=getContainingFolder;return exports}(window);
@@ -28,10 +28,10 @@ function create() {
28
28
  this.localesGroups.push(locales);
29
29
 
30
30
  if (typeof locales == 'string') {
31
- this.locales[locales] = path;
31
+ this.locales[locales.toLowerCase()] = path;
32
32
  } else if (locales instanceof Array) {
33
33
  for (var i = 0; i < locales.length; ++i) {
34
- this.locales[locales[i]] = path;
34
+ this.locales[locales[i].toLowerCase()] = path;
35
35
  }
36
36
  }
37
37
 
@@ -46,6 +46,8 @@ function create() {
46
46
  : window.localStorage.locale;
47
47
  }
48
48
 
49
+ locale = locale.toLowerCase();
50
+
49
51
  if (!this.locales[locale]) {
50
52
  locale = 'fallback';
51
53
  }
@@ -96,6 +98,7 @@ function create() {
96
98
  setLocalizedString(locales, key, val) {
97
99
  var self = this;
98
100
  locales.forEach(function (locale) {
101
+ locale = locale.toLowerCase();
99
102
  if (!self.overrides[locale]) {
100
103
  self.overrides[locale] = {};
101
104
  }
@@ -1 +1 @@
1
- function create(){var s=null;return{localesGroups:[],locales:{},texts:{},overrides:{},getCurrentLocale(){return s},getLocalesGroups(){return this.localesGroups},addLocale(e,t,l){if(!t){var r=e.lastIndexOf("/");if(r<0){t=e}else{t=e.substr(e,r+1)}t=t.split(".")[0]}this.localesGroups.push(t);if(typeof t=="string"){this.locales[t]=e}else if(t instanceof Array){for(var s=0;s<t.length;++s){this.locales[t[s]]=e}}if(l){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 t=require(this.locales["fallback"]).texts;var l=Object.getOwnPropertyNames(t);var r=this;l.forEach(function(e){if(!r.texts[e]){r.texts[e]=t[e]}})}}},sr(){if(arguments.length==0){return null}var e=arguments[0];var t=e;var l=false;if(this.overrides[this.getCurrentLocale()]&&this.overrides[this.getCurrentLocale()][e]){t=this.overrides[this.getCurrentLocale()][e];l=true}if(!l&&this.texts[e]){t=this.texts[e]}for(var r=1;r<arguments.length;++r){t=t.replaceAll(`{${r-1}}`,arguments[r])}return t},setLocalizedString(e,t,l){var r=this;e.forEach(function(e){if(!r.overrides[e]){r.overrides[e]={}}r.overrides[e][t]=l})}}}exports.create=create;
1
+ function create(){var a=null;return{localesGroups:[],locales:{},texts:{},overrides:{},getCurrentLocale(){return a},getLocalesGroups(){return this.localesGroups},addLocale(e,t,r){if(!t){var s=e.lastIndexOf("/");if(s<0){t=e}else{t=e.substr(e,s+1)}t=t.split(".")[0]}this.localesGroups.push(t);if(typeof t=="string"){this.locales[t.toLowerCase()]=e}else if(t instanceof Array){for(var a=0;a<t.length;++a){this.locales[t[a].toLowerCase()]=e}}if(r){this.locales["fallback"]=e}},setLocale(e){if(!e){e=!window.localStorage.locale?window.navigator.language:window.localStorage.locale}e=e.toLowerCase();if(!this.locales[e]){e="fallback"}if(!this.locales[e]){throw"No available translations for the locale"}a=e;this.texts=require(this.locales[e]).texts;if(this.locales["fallback"]){if(this.locales[e]!=this.locales["fallback"]){var t=require(this.locales["fallback"]).texts;var r=Object.getOwnPropertyNames(t);var s=this;r.forEach(function(e){if(!s.texts[e]){s.texts[e]=t[e]}})}}},sr(){if(arguments.length==0){return null}var e=arguments[0];var t=e;var r=false;if(this.overrides[this.getCurrentLocale()]&&this.overrides[this.getCurrentLocale()][e]){t=this.overrides[this.getCurrentLocale()][e];r=true}if(!r&&this.texts[e]){t=this.texts[e]}for(var s=1;s<arguments.length;++s){t=t.replaceAll(`{${s-1}}`,arguments[s])}return t},setLocalizedString(e,t,r){var s=this;e.forEach(function(e){e=e.toLowerCase();if(!s.overrides[e]){s.overrides[e]={}}s.overrides[e][t]=r})}}}exports.create=create;
package/pome-ui.dev.js CHANGED
@@ -18514,15 +18514,26 @@ function build(options, exports) {
18514
18514
  // routes that return the app entry page (status 200) for any URL:
18515
18515
  // if the response body starts with "<!DOCTYPE" or "<html" it is treated
18516
18516
  // as a missing file and null is returned.
18517
+ // Caches "not found" results so that repeated requests for the same
18518
+ // missing skeleton file do not produce additional network round-trips.
18519
+ var _skeletonNotFoundCache = {};
18517
18520
  function _httpGetSkeletonFile(url) {
18521
+ if (_skeletonNotFoundCache[url]) {
18522
+ return Promise.resolve(null);
18523
+ }
18518
18524
  return _httpGet(url).then(function (text) {
18519
- if (!text) return null;
18525
+ if (!text) {
18526
+ _skeletonNotFoundCache[url] = true;
18527
+ return null;
18528
+ }
18520
18529
  var trimmed = text.replace(/^[\s\uFEFF]+/, ''); // strip BOM / whitespace
18521
18530
  if (/^<!DOCTYPE/i.test(trimmed) || /^<html/i.test(trimmed)) {
18531
+ _skeletonNotFoundCache[url] = true;
18522
18532
  return null; // SPA fallback page, not a real skeleton file
18523
18533
  }
18524
18534
  return text;
18525
18535
  }).catch(function () {
18536
+ _skeletonNotFoundCache[url] = true;
18526
18537
  return null;
18527
18538
  });
18528
18539
  };
@@ -18876,6 +18887,16 @@ function build(options, exports) {
18876
18887
  ret.component(com.name, com.options);
18877
18888
  }
18878
18889
 
18890
+ // Inherit parent's registered components
18891
+ if (parent && parent.$ && parent.$.appContext && parent.$.appContext.components) {
18892
+ var parentComps = parent.$.appContext.components;
18893
+ for (var pName in parentComps) {
18894
+ if (!ret._context.components[pName]) {
18895
+ ret.component(pName, parentComps[pName]);
18896
+ }
18897
+ }
18898
+ }
18899
+
18879
18900
  var originalMountFunc = ret.mount || function () { };
18880
18901
  ret.mount = function (el) {
18881
18902
  ret.proxy = originalMountFunc(el);