neo.mjs 9.6.1 → 9.7.1

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.
@@ -1,6 +1,6 @@
1
- import Neo from '../src/Neo.mjs';
2
- import * as core from '../src/core/_export.mjs';
3
- import ServiceBase from '../src/worker/ServiceBase.mjs';
1
+ import Neo from './src/Neo.mjs';
2
+ import * as core from './src/core/_export.mjs';
3
+ import ServiceBase from './src/worker/ServiceBase.mjs';
4
4
 
5
5
  /**
6
6
  * @class Neo.ServiceWorker
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='9.6.1'
23
+ * @member {String} version='9.7.1'
24
24
  */
25
- version: '9.6.1'
25
+ version: '9.7.1'
26
26
  }
27
27
 
28
28
  /**
@@ -1,4 +1,16 @@
1
1
  [{
2
+ "author" : "Tobias Uhlig",
3
+ "authorImage" : "author_TobiasUhlig.jpeg",
4
+ "date" : "Jun 02, 2025",
5
+ "id" : 64,
6
+ "image" : "json-blueprints.png",
7
+ "name" : "How JSON Blueprints & Shared Workers Power Next-Gen AI Interfaces",
8
+ "provider" : "Medium",
9
+ "publisher" : "",
10
+ "selectedInto": [],
11
+ "type" : "Blog Post",
12
+ "url" : "https://tobiasuhlig.medium.com/the-ui-revolution-how-json-blueprints-shared-workers-power-next-gen-ai-interfaces-60a2bf0fc1dc?source=friends_link&sk=1b0b306285e23bb12f31271dd87bebe5"
13
+ }, {
2
14
  "author" : "Tobias Uhlig",
3
15
  "authorImage" : "author_TobiasUhlig.jpeg",
4
16
  "date" : "Feb 12, 2025",
@@ -107,7 +107,7 @@ class FooterContainer extends Container {
107
107
  }, {
108
108
  module: Component,
109
109
  cls : ['neo-version'],
110
- html : 'v9.6.1'
110
+ html : 'v9.7.1'
111
111
  }]
112
112
  }],
113
113
  /**
@@ -15,20 +15,13 @@ const
15
15
  neoPath = insideNeo ? './' : './node_modules/neo.mjs/',
16
16
  programName = `${packageJson.name} inject-package-version`;
17
17
 
18
- let startDate = new Date(),
19
- configPath = path.join(__dirname, 'src/DefaultConfig.mjs'),
20
- contentArray = fs.readFileSync(configPath).toString().split(os.EOL),
21
- i = 0,
22
- len = contentArray.length,
23
- serviceWorkerFolders = ['apps'],
24
- versionString = `'${packageJson.version}'`,
25
- serviceContentArray, serviceWorkerPath
26
-
27
- if (!insideNeo) {
28
- // todo
29
- } else {
30
- serviceWorkerFolders.push('examples');
31
- }
18
+ let startDate = new Date(),
19
+ configPath = path.join(__dirname, 'src/DefaultConfig.mjs'),
20
+ contentArray = fs.readFileSync(configPath).toString().split(os.EOL),
21
+ i = 0,
22
+ len = contentArray.length,
23
+ versionString = `'${packageJson.version}'`,
24
+ serviceContentArray, serviceWorkerPath;
32
25
 
33
26
  for (; i < len; i++) {
34
27
  if (contentArray[i].includes('version:')) {
@@ -41,24 +34,22 @@ for (; i < len; i++) {
41
34
 
42
35
  fs.writeFileSync(configPath, contentArray.join(os.EOL));
43
36
 
44
- serviceWorkerFolders.forEach(folder => {
45
- serviceWorkerPath = path.join(__dirname, folder, 'ServiceWorker.mjs');
46
- serviceContentArray = fs.readFileSync(serviceWorkerPath).toString().split(os.EOL);
37
+ serviceWorkerPath = path.join(__dirname, 'ServiceWorker.mjs');
38
+ serviceContentArray = fs.readFileSync(serviceWorkerPath, 'utf-8').toString().split(os.EOL);
47
39
 
48
- i = 0;
49
- len = serviceContentArray.length;
40
+ i = 0;
41
+ len = serviceContentArray.length;
50
42
 
51
- for (; i < len; i++) {
52
- if (serviceContentArray[i].includes('version:')) {
53
- // we want to update the comment inside ServiceWorker.mjs as well
54
- serviceContentArray[i - 2] = serviceContentArray[i - 2].replace(/'\d.+'/, versionString);
55
- serviceContentArray[i] = serviceContentArray[i] .replace(/'\d.+'/, versionString);
56
- break;
57
- }
43
+ for (; i < len; i++) {
44
+ if (serviceContentArray[i].includes('version:')) {
45
+ // we want to update the comment inside ServiceWorker.mjs as well
46
+ serviceContentArray[i - 2] = serviceContentArray[i - 2].replace(/'\d.+'/, versionString);
47
+ serviceContentArray[i] = serviceContentArray[i] .replace(/'\d.+'/, versionString);
48
+ break;
58
49
  }
50
+ }
59
51
 
60
- fs.writeFileSync(serviceWorkerPath, serviceContentArray.join(os.EOL));
61
- });
52
+ fs.writeFileSync(serviceWorkerPath, serviceContentArray.join(os.EOL));
62
53
 
63
54
  // Update the version inside the Portal App Footer
64
55
  if (insideNeo) {
@@ -15,7 +15,7 @@ export default env => {
15
15
 
16
16
  if (filenameConfig.workers) {
17
17
  Object.entries(filenameConfig.workers).forEach(([key, value]) => {
18
- // Inside a neo workspace, we want to use the SW inside the top level apps folder,
18
+ // Inside a neo workspace, we want to use the SW inside the top level folder,
19
19
  // to allow overriding its logic
20
20
  if (key === env.worker) {
21
21
  entry[key] = path.resolve(key === 'service' && !insideNeo ? cwd : neoPath, value.input);
@@ -15,7 +15,7 @@
15
15
  "output": "dataworker.js"
16
16
  },
17
17
  "service": {
18
- "input": "./apps/ServiceWorker.mjs",
18
+ "input": "./ServiceWorker.mjs",
19
19
  "output": "serviceworker.js"
20
20
  },
21
21
  "vdom": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name" : "neo.mjs",
3
- "version" : "9.6.1",
3
+ "version" : "9.7.1",
4
4
  "description" : "The webworkers driven UI framework",
5
5
  "type" : "module",
6
6
  "repository" : {
@@ -229,7 +229,8 @@ const DefaultConfig = {
229
229
  * True will add the ServiceWorker main thread addon to support caching of assets (PWA)
230
230
  * See: https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
231
231
  *
232
- * You can also use a string to specify the target environment => 'dist/production'
232
+ * You can also use a string to specify the target environment => 'dist/production'.
233
+ * Using 'dist/production' will also use the service worker for 'dist/esm'
233
234
  * @default false
234
235
  * @memberOf! module:Neo
235
236
  * @name config.useServiceWorker
@@ -263,12 +264,12 @@ const DefaultConfig = {
263
264
  useVdomWorker: true,
264
265
  /**
265
266
  * buildScripts/injectPackageVersion.mjs will update this value
266
- * @default '9.6.1'
267
+ * @default '9.7.1'
267
268
  * @memberOf! module:Neo
268
269
  * @name config.version
269
270
  * @type String
270
271
  */
271
- version: '9.6.1'
272
+ version: '9.7.1'
272
273
  };
273
274
 
274
275
  Object.assign(DefaultConfig, {
package/src/Main.mjs CHANGED
@@ -243,28 +243,29 @@ class Main extends core.Base {
243
243
  *
244
244
  */
245
245
  async onDomContentLoaded() {
246
- let me = this,
247
- {config} = Neo,
248
- {mainThreadAddons} = config,
249
- imports = [],
246
+ let me = this,
247
+ {config} = Neo,
248
+ imports = [],
249
+ {environment, mainThreadAddons, useServiceWorker} = config,
250
250
  modules;
251
251
 
252
252
  DomAccess.onDomContentLoaded();
253
253
 
254
- // we need different publicPath values for the main thread inside the webpack based dist envs,
254
+ // We need different publicPath values for the main thread inside the webpack based dist envs,
255
255
  // depending on the hierarchy level of the app entry point
256
- if (config.environment === 'dist/development' || config.environment === 'dist/production') {
256
+ if (environment === 'dist/development' || environment === 'dist/production') {
257
257
  __webpack_require__.p = config.basePath.substring(6)
258
258
  }
259
259
 
260
- // intended for the online examples where we need an easy way to add GA to every generated app
260
+ // Intended for the online examples where we need an easy way to add GA to every generated app
261
261
  if (config.useGoogleAnalytics && !mainThreadAddons.includes('AnalyticsByGoogle')) {
262
262
  mainThreadAddons.push('AnalyticsByGoogle')
263
263
  }
264
264
 
265
265
  if ((
266
- config.useServiceWorker === true ||
267
- config.useServiceWorker === config.environment
266
+ useServiceWorker === true ||
267
+ useServiceWorker === environment ||
268
+ (useServiceWorker === 'dist/production' && environment === 'dist/esm')
268
269
  ) &&
269
270
  !mainThreadAddons.includes('ServiceWorker')
270
271
  ) {
@@ -30,13 +30,16 @@ class ServiceWorker extends Base {
30
30
  if ('serviceWorker' in navigator) {
31
31
  let me = this,
32
32
  {config} = Neo,
33
- devMode = config.environment === 'development',
34
- fileName = devMode ? 'ServiceWorker.mjs' : 'serviceworker.js',
35
- folder = window.location.pathname.includes('/examples/') ? 'examples/' : 'apps/',
36
- opts = devMode ? {type: 'module'} : {},
37
- path = (devMode ? config.basePath : config.workerBasePath) + (devMode ? folder : '') + fileName,
33
+ {environment} = config,
34
+ devMode = environment === 'development',
35
+ hasJsModules = devMode || environment === 'dist/esm',
36
+ fileName = hasJsModules ? 'ServiceWorker.mjs' : 'serviceworker.js',
37
+ opts = hasJsModules ? {type: 'module'} : {},
38
+ path = (hasJsModules ? config.basePath : config.workerBasePath) + fileName,
38
39
  {serviceWorker} = navigator,
39
- registration = await serviceWorker.register(path, opts);
40
+ registration;
41
+
42
+ registration = await serviceWorker.register(path, opts);
40
43
 
41
44
  window.addEventListener('beforeunload', me.onBeforeUnload.bind(me));
42
45
 
@@ -42,6 +42,7 @@ class ServiceBase extends Base {
42
42
  */
43
43
  cachePaths = [
44
44
  'raw.githubusercontent.com/',
45
+ '/dist/esm/',
45
46
  '/dist/production/',
46
47
  '/fontawesome',
47
48
  '/resources/'
@@ -1,35 +0,0 @@
1
- import Neo from '../src/Neo.mjs';
2
- import * as core from '../src/core/_export.mjs';
3
- import ServiceBase from '../src/worker/ServiceBase.mjs';
4
-
5
- /**
6
- * @class Neo.ServiceWorker
7
- * @extends Neo.worker.ServiceBase
8
- * @singleton
9
- */
10
- class ServiceWorker extends ServiceBase {
11
- static config = {
12
- /**
13
- * @member {String} className='Neo.ServiceWorker'
14
- * @protected
15
- */
16
- className: 'Neo.ServiceWorker',
17
- /**
18
- * @member {Boolean} singleton=true
19
- * @protected
20
- */
21
- singleton: true,
22
- /**
23
- * @member {String} version='9.6.1'
24
- */
25
- version: '9.6.1'
26
- }
27
-
28
- /**
29
- * @member {String} workerId='service'
30
- * @protected
31
- */
32
- workerId = 'service'
33
- }
34
-
35
- export default Neo.setupClass(ServiceWorker);