neo.mjs 8.1.2 → 8.2.0

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.
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='8.1.2'
23
+ * @member {String} version='8.2.0'
24
24
  */
25
- version: '8.1.2'
25
+ version: '8.2.0'
26
26
  }
27
27
 
28
28
  /**
@@ -107,7 +107,7 @@ class FooterContainer extends Container {
107
107
  }, {
108
108
  module: Component,
109
109
  cls : ['neo-version'],
110
- html : 'v8.1.2'
110
+ html : 'v8.2.0'
111
111
  }]
112
112
  }],
113
113
  /**
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='8.1.2'
23
+ * @member {String} version='8.2.0'
24
24
  */
25
- version: '8.1.2'
25
+ version: '8.2.0'
26
26
  }
27
27
 
28
28
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "8.1.2",
3
+ "version": "8.2.0",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -7,16 +7,17 @@
7
7
  }
8
8
 
9
9
  .neo-grid-container {
10
- border : 1px solid var(--grid-container-border-color);
11
- border-spacing: 0;
12
- color : var(--grid-container-color);
13
- font-size : 13px;
14
- font-weight : 400;
15
- height : 100%;
16
- line-height : 19px;
17
- overflow-y : hidden;
18
- position : absolute;
19
- width : 100%;
10
+ border : 1px solid var(--grid-container-border-color);
11
+ border-spacing : 0;
12
+ color : var(--grid-container-color);
13
+ font-size : 13px;
14
+ font-weight : 400;
15
+ height : 100%;
16
+ line-height : 19px;
17
+ overscroll-behavior: none;
18
+ overflow-y : hidden;
19
+ position : absolute;
20
+ width : 100%;
20
21
 
21
22
  .neo-grid-row {
22
23
  display: flex;
@@ -262,12 +262,12 @@ const DefaultConfig = {
262
262
  useVdomWorker: true,
263
263
  /**
264
264
  * buildScripts/injectPackageVersion.mjs will update this value
265
- * @default '8.1.2'
265
+ * @default '8.2.0'
266
266
  * @memberOf! module:Neo
267
267
  * @name config.version
268
268
  * @type String
269
269
  */
270
- version: '8.1.2'
270
+ version: '8.2.0'
271
271
  };
272
272
 
273
273
  Object.assign(DefaultConfig, {
@@ -2282,10 +2282,18 @@ class Component extends Base {
2282
2282
  * @param {Boolean} [mount] Mount the DOM after the vnode got created
2283
2283
  */
2284
2284
  async render(mount) {
2285
- let me = this,
2286
- autoMount = mount || me.autoMount,
2287
- app = me.app,
2288
- useVdomWorker = Neo.config.useVdomWorker;
2285
+ let me = this,
2286
+ autoMount = mount || me.autoMount,
2287
+ {app} = me,
2288
+ {useVdomWorker} = Neo.config;
2289
+
2290
+ if (Neo.currentWorker.countLoadingThemeFiles !== 0) {
2291
+ Neo.currentWorker.on('themeFilesLoaded', function() {
2292
+ me.render(mount)
2293
+ }, me, {once: true});
2294
+
2295
+ return
2296
+ }
2289
2297
 
2290
2298
  me.rendering = true;
2291
2299
 
@@ -235,6 +235,30 @@ class GridContainer extends BaseContainer {
235
235
  }
236
236
  }
237
237
 
238
+ /**
239
+ * @param {Boolean} mounted
240
+ * @protected
241
+ */
242
+ async addResizeObserver(mounted) {
243
+ let me = this,
244
+ ResizeObserver = Neo.main?.addon?.ResizeObserver,
245
+ resizeParams = {id: me.id, windowId: me.windowId};
246
+
247
+ // Check if the remotes api is ready for slow network connections & dist/prod
248
+ if (!ResizeObserver) {
249
+ await me.timeout(100);
250
+ await me.addResizeObserver(mounted)
251
+ } else {
252
+ if (mounted) {
253
+ ResizeObserver.register(resizeParams);
254
+ await me.passSizeToView()
255
+ } else {
256
+ me.initialResizeEvent = true;
257
+ ResizeObserver.unregister(resizeParams)
258
+ }
259
+ }
260
+ }
261
+
238
262
  /**
239
263
  * Triggered after the mounted config got changed
240
264
  * @param {Boolean} value
@@ -243,18 +267,7 @@ class GridContainer extends BaseContainer {
243
267
  */
244
268
  afterSetMounted(value, oldValue) {
245
269
  super.afterSetMounted(value, oldValue);
246
-
247
- let me = this,
248
- {ResizeObserver} = Neo.main.addon,
249
- resizeParams = {id: me.id, windowId: me.windowId};
250
-
251
- if (value) {
252
- ResizeObserver.register(resizeParams);
253
- me.passSizeToView()
254
- } else if (!value && oldValue) { // unmount
255
- me.initialResizeEvent = true;
256
- ResizeObserver.unregister(resizeParams)
257
- }
270
+ oldValue !== undefined && this.addResizeObserver(value)
258
271
  }
259
272
 
260
273
  /**
@@ -92,11 +92,12 @@ class Stylesheet extends Base {
92
92
  * @param {String} data.className
93
93
  * @param {String[]} data.folders
94
94
  */
95
- addThemeFiles(data) {
95
+ async addThemeFiles(data) {
96
96
  let {className} = data,
97
97
  {config} = Neo,
98
98
  env = config.environment,
99
99
  path = env.startsWith('dist/') ? '' : config.appPath.includes('docs') ? `../dist/${env}/` : `../../dist/${env}/`,
100
+ promises = [],
100
101
  rootPath = config.basePath.substring(6);
101
102
 
102
103
  if (className.startsWith('Neo.')) {
@@ -107,13 +108,15 @@ class Stylesheet extends Base {
107
108
 
108
109
  data.folders.forEach(folder => {
109
110
  if (folder === 'src' || folder.includes('theme-') && config.themes.includes(`neo-${folder}`)) {
110
- this.createStyleSheet(
111
+ promises.push(this.createStyleSheet(
111
112
  null,
112
113
  null,
113
114
  `${rootPath}${path}css/${folder}/${className}.css`
114
- )
115
+ ))
115
116
  }
116
- })
117
+ });
118
+
119
+ await Promise.all(promises)
117
120
  }
118
121
 
119
122
  /**
@@ -121,28 +124,34 @@ class Stylesheet extends Base {
121
124
  * @param {String} [name]
122
125
  * @param {String} [id]
123
126
  * @param {String} [href]
127
+ * @returns {Promise<void>}
124
128
  */
125
- createStyleSheet(name, id, href) {
129
+ async createStyleSheet(name, id, href) {
126
130
  if (!name && !href) {
127
131
  throw new Error('createStyleSheet: you need to either pass a name or a href')
128
132
  }
129
133
 
130
- let link = document.createElement('link'),
131
- env = Neo.config.environment,
132
- path = env.startsWith('dist/') ? env : ('dist/' + env),
133
- url = href ? href : Neo.config.basePath + path + '/' + name;
134
+ return new Promise((resolve, reject) => {
135
+ let link = document.createElement('link'),
136
+ env = Neo.config.environment,
137
+ path = env.startsWith('dist/') ? env : ('dist/' + env),
138
+ url = href ? href : Neo.config.basePath + path + '/' + name;
134
139
 
135
- Object.assign(link, {
136
- href: url,
137
- rel : 'stylesheet',
138
- type: 'text/css'
139
- });
140
+ Object.assign(link, {
141
+ href: url,
142
+ rel : 'stylesheet',
143
+ type: 'text/css'
144
+ });
140
145
 
141
- if (id) {
142
- link.id = id
143
- }
146
+ if (id) {
147
+ link.id = id
148
+ }
144
149
 
145
- document.head.appendChild(link)
150
+ link.addEventListener('error', function() {reject()})
151
+ link.addEventListener('load', function() {resolve()})
152
+
153
+ document.head.appendChild(link)
154
+ })
146
155
  }
147
156
 
148
157
  /**
@@ -20,6 +20,10 @@ class App extends Base {
20
20
  * @protected
21
21
  */
22
22
  className: 'Neo.worker.App',
23
+ /**
24
+ * @member {Number} countLoadingThemeFiles_=0
25
+ */
26
+ countLoadingThemeFiles_: 0,
23
27
  /**
24
28
  * Remote method access for other workers
25
29
  * @member {Object} remote
@@ -77,6 +81,18 @@ class App extends Base {
77
81
  Neo.setCssVariable = me.setCssVariable.bind(me)
78
82
  }
79
83
 
84
+ /**
85
+ * Triggered after the countLoadingThemeFiles config got changed
86
+ * @param {Number} value
87
+ * @param {Number} oldValue
88
+ * @protected
89
+ */
90
+ afterSetCountLoadingThemeFiles(value, oldValue) {
91
+ if (value === 0 && oldValue !== undefined) {
92
+ this.fire('themeFilesLoaded')
93
+ }
94
+ }
95
+
80
96
  /**
81
97
  * @param {String} appName
82
98
  * @param {Array|Object} deltas
@@ -282,7 +298,7 @@ class App extends Base {
282
298
  insertThemeFiles(windowId, proto, className) {
283
299
  if (Neo.config.themes.length > 0) {
284
300
  className = className || proto.className;
285
- //console.log(windowId, className);
301
+
286
302
  let me = this,
287
303
  cssMap = Neo.cssMap,
288
304
  parent = proto?.__proto__,
@@ -310,7 +326,7 @@ class App extends Base {
310
326
  }
311
327
 
312
328
  themeFolders = Neo.ns(mapClassName || className, false, cssMap.fileInfo);
313
- //console.log(cssMap);
329
+
314
330
  if (themeFolders && !Neo.ns(`${windowId}.${className}`, false, cssMap)) {
315
331
  classPath = className.split('.');
316
332
  fileName = classPath.pop();
@@ -319,10 +335,14 @@ class App extends Base {
319
335
 
320
336
  ns[fileName] = true;
321
337
 
338
+ me.countLoadingThemeFiles++;
339
+
322
340
  Neo.main.addon.Stylesheet.addThemeFiles({
323
341
  className: mapClassName || className,
324
342
  folders : themeFolders,
325
343
  windowId
344
+ }).then(() => {
345
+ me.countLoadingThemeFiles--
326
346
  })
327
347
  }
328
348
  }