@gudhub/core 1.2.4-beta.13 → 1.2.4-beta.15

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,4 +1,4 @@
1
- import { IS_WEB } from "../consts.js";
1
+ import { IS_BROWSER, IS_BROWSER_MAIN_THREAD, IS_WEB } from "../consts.js";
2
2
 
3
3
  export class AppProcessor {
4
4
  constructor(
@@ -443,7 +443,7 @@ export class AppProcessor {
443
443
  appsList
444
444
  );
445
445
  });
446
- if (IS_WEB && this.activateSW) {
446
+ if (IS_BROWSER_MAIN_THREAD && this.activateSW) {
447
447
  navigator.serviceWorker.addEventListener("message", async (event) => {
448
448
  if (event.data.type === "refresh app") {
449
449
  const app = await this.getApp(event.data.payload.app_id);
@@ -272,7 +272,7 @@ export class IndexedDBAppService extends AppDataService {
272
272
 
273
273
  // this.appRequestAndProcessWorker = new Worker('./appRequestWorker.js');
274
274
  // this.appRequestAndProcessWorker = new Worker(new URL('./appRequestWorker.js', import.meta.url));
275
- this.appRequestAndProcessWorker = new Worker('node_modules/@gudhub/core/umd/appRequestWorker.js');
275
+ this.appRequestAndProcessWorker = new Worker('./node_modules/@gudhub/core/umd/appRequestWorker.js');
276
276
  // this.appRequestAndProcessWorker = new AppRequestWorker();
277
277
 
278
278
  // new Worker(new URL('./worker.js', import.meta.url));
@@ -1,11 +1,11 @@
1
- import { IS_WEB } from "../../consts.js";
1
+ import { IS_BROWSER, IS_WEB } from "../../consts.js";
2
2
  import { appsConf } from "./appDataConf.js";
3
3
  import { chunksConf } from "./chunkDataConf.js";
4
4
  import { dbName, dbVersion } from "./consts.js";
5
5
 
6
6
 
7
7
  if (
8
- IS_WEB
8
+ IS_BROWSER
9
9
  ) {
10
10
  const request = indexedDB.open(dbName, dbVersion);
11
11
 
@@ -1,5 +1,5 @@
1
1
  import { cache_app_requests, cache_chunk_requests } from "../config.js";
2
- import { IS_WEB } from "../consts.js";
2
+ import { IS_BROWSER, IS_WEB } from "../consts.js";
3
3
  import { IndexedDBAppService } from "./IndexedDB/IndexedDBAppService.js";
4
4
  import { IndexedDBChunkService } from "./IndexedDB/IndexedDBChunkService.js";
5
5
  import { appsConf } from "./IndexedDB/appDataConf.js";
@@ -18,7 +18,7 @@ let chunkDataServiceConf;
18
18
 
19
19
 
20
20
  if (
21
- IS_WEB &&
21
+ IS_BROWSER &&
22
22
  cache_chunk_requests
23
23
  ) {
24
24
  ChunkDataService = IndexedDBChunkService;
@@ -30,7 +30,7 @@ if (
30
30
 
31
31
 
32
32
  if (
33
- IS_WEB &&
33
+ IS_BROWSER &&
34
34
  cache_app_requests
35
35
  ) {
36
36
  AppDataService = IndexedDBAppService;
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import { IS_WEB } from './../consts.js';
2
+ import { IS_BROWSER_MAIN_THREAD, IS_WEB } from './../consts.js';
3
3
 
4
4
  /*************** FAKE ANGULAR $Q ***************/
5
5
  // It's needed when we import angular code.
@@ -80,7 +80,7 @@ export default async function createAngularModuleInstance(gudhub, module_id, mod
80
80
  let angularModule;
81
81
  let importedClass;
82
82
 
83
- if (IS_WEB) {
83
+ if (IS_BROWSER_MAIN_THREAD) {
84
84
 
85
85
  if(window.angular) {
86
86
 
@@ -290,7 +290,7 @@ export default async function createAngularModuleInstance(gudhub, module_id, mod
290
290
 
291
291
  // We need these methods in browser environment only
292
292
 
293
- if (IS_WEB) {
293
+ if (IS_BROWSER_MAIN_THREAD) {
294
294
 
295
295
  //*************** EXTEND CONTROLLER ****************//
296
296
 
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import { IS_WEB } from './../consts.js';
2
+ import { IS_BROWSER_MAIN_THREAD, IS_WEB } from './../consts.js';
3
3
 
4
4
  export default async function createClassInstance(gudhub, module_id, js_url, css_url, nodeWindow) {
5
5
 
@@ -14,7 +14,7 @@ export default async function createClassInstance(gudhub, module_id, js_url, css
14
14
  // Import module using dynamic import
15
15
 
16
16
  let downloadModule = (url) => {
17
- if (!IS_WEB && !global.hasOwnProperty('window')) {
17
+ if (!IS_BROWSER_MAIN_THREAD && !global.hasOwnProperty('window')) {
18
18
  global.window = proxy;
19
19
  global.document = nodeWindow.document;
20
20
  global.Element = nodeWindow.Element;
@@ -67,7 +67,7 @@ export default async function createClassInstance(gudhub, module_id, js_url, css
67
67
  // Check if there is url to css file of module
68
68
  // If true, and there is no css for this data type, than create link tag to this css in head
69
69
 
70
- if (css_url && IS_WEB) {
70
+ if (css_url && IS_BROWSER_MAIN_THREAD) {
71
71
  const linkTag = document.createElement('link');
72
72
  linkTag.href = css_url;
73
73
  linkTag.setAttribute('data-module', module_id);
package/GUDHUB/consts.js CHANGED
@@ -1 +1,21 @@
1
- export const IS_WEB = ![typeof window, typeof document].includes("undefined");
1
+ export const IS_BROWSER_MAIN_THREAD = ![typeof window, typeof document].includes("undefined");
2
+
3
+ export const IS_BROWSER_WORKER =
4
+ typeof self === "object" &&
5
+ typeof WorkerGlobalScope != 'undefined'
6
+
7
+
8
+ export const IS_BROWSER = IS_BROWSER_MAIN_THREAD || IS_BROWSER_WORKER;
9
+
10
+ export const IS_NODE =
11
+ // @ts-expect-error
12
+ typeof process !== "undefined" &&
13
+ // @ts-expect-error
14
+ process.versions != null &&
15
+ // @ts-expect-error
16
+ process.versions.node != null;
17
+
18
+
19
+
20
+
21
+ // IS_WEB
package/GUDHUB/gudhub.js CHANGED
@@ -13,7 +13,7 @@ import { FileManager } from "./FileManager/FileManager.js";
13
13
  // import { ChunksManager } from "./ChunksManager/ChunksManager.js";
14
14
  import { DocumentManager } from "./DocumentManager/DocumentManager.js";
15
15
  import { Interpritate } from './GHConstructor/interpritate.js'
16
- import { IS_WEB } from "./consts.js";
16
+ import { IS_BROWSER, IS_BROWSER_MAIN_THREAD, IS_WEB } from "./consts.js";
17
17
  import { WebsocketHandler } from './WebSocket/WebsocketHandler.js';
18
18
  import { GroupSharing } from './Utils/sharing/GroupSharing.js';
19
19
  import { Sharing } from './Utils/sharing/Sharing.js';
@@ -115,7 +115,7 @@ export class GudHub {
115
115
  }
116
116
 
117
117
  async activateSW(swLink) {
118
- if (IS_WEB && "serviceWorker" in window.navigator) {
118
+ if (IS_BROWSER_MAIN_THREAD && "serviceWorker" in window.navigator) {
119
119
  try {
120
120
  const sw = await window.navigator.serviceWorker.register(swLink);
121
121
  sw.update()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gudhub/core",
3
- "version": "1.2.4-beta.13",
3
+ "version": "1.2.4-beta.15",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {