neo.mjs 8.1.3 → 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.
- package/apps/ServiceWorker.mjs +2 -2
- package/apps/portal/view/home/FooterContainer.mjs +1 -1
- package/examples/ServiceWorker.mjs +2 -2
- package/package.json +1 -1
- package/src/DefaultConfig.mjs +2 -2
- package/src/component/Base.mjs +12 -4
- package/src/main/addon/Stylesheet.mjs +27 -18
- package/src/worker/App.mjs +20 -0
package/apps/ServiceWorker.mjs
CHANGED
package/package.json
CHANGED
package/src/DefaultConfig.mjs
CHANGED
@@ -262,12 +262,12 @@ const DefaultConfig = {
|
|
262
262
|
useVdomWorker: true,
|
263
263
|
/**
|
264
264
|
* buildScripts/injectPackageVersion.mjs will update this value
|
265
|
-
* @default '8.
|
265
|
+
* @default '8.2.0'
|
266
266
|
* @memberOf! module:Neo
|
267
267
|
* @name config.version
|
268
268
|
* @type String
|
269
269
|
*/
|
270
|
-
version: '8.
|
270
|
+
version: '8.2.0'
|
271
271
|
};
|
272
272
|
|
273
273
|
Object.assign(DefaultConfig, {
|
package/src/component/Base.mjs
CHANGED
@@ -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
|
2286
|
-
autoMount
|
2287
|
-
app = me
|
2288
|
-
useVdomWorker = Neo.config
|
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
|
|
@@ -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
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
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
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
+
Object.assign(link, {
|
141
|
+
href: url,
|
142
|
+
rel : 'stylesheet',
|
143
|
+
type: 'text/css'
|
144
|
+
});
|
140
145
|
|
141
|
-
|
142
|
-
|
143
|
-
|
146
|
+
if (id) {
|
147
|
+
link.id = id
|
148
|
+
}
|
144
149
|
|
145
|
-
|
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
|
/**
|
package/src/worker/App.mjs
CHANGED
@@ -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
|
@@ -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
|
}
|