@xwiki/cristal-sharedworker-impl 0.9.0 → 0.11.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.
@@ -1,5 +1,4 @@
1
1
  import { Container } from 'inversify';
2
-
3
2
  export default class ComponentInit {
4
3
  constructor(container: Container);
5
4
  }
@@ -1,6 +1,5 @@
1
1
  import { QueueWorker } from '@xwiki/cristal-sharedworker-api';
2
2
  import { CristalApp, Logger } from '@xwiki/cristal-api';
3
-
4
3
  export default class DefaultQueueWorker implements QueueWorker {
5
4
  private workerInstance;
6
5
  private cristalApp;
@@ -1,6 +1,5 @@
1
1
  import { MyWorker } from '@xwiki/cristal-sharedworker-api';
2
2
  import { WikiConfig } from '@xwiki/cristal-api';
3
-
4
3
  export declare class Worker implements MyWorker {
5
4
  private currentNumber;
6
5
  private queue;
@@ -2,7 +2,6 @@ import { CristalApp as CristalApp, Logger, LoggerConfig, PageData, SkinManager,
2
2
  import { Container } from 'inversify';
3
3
  import { App, Component } from 'vue';
4
4
  import { Router } from 'vue-router';
5
-
6
5
  export declare class WorkerCristalApp implements CristalApp {
7
6
  private wikiConfig;
8
7
  private container;
@@ -1,5 +1,4 @@
1
1
  import { QueueWorker } from '@xwiki/cristal-sharedworker-api';
2
-
3
2
  export default class WorkerQueueWorker implements QueueWorker {
4
3
  constructor();
5
4
  initialize(): void;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { default as ComponentInit } from './components/componentsInit';
2
2
  import { QueueWorker } from '@xwiki/cristal-sharedworker-api';
3
-
4
3
  export type { QueueWorker };
5
4
  export { ComponentInit };
package/dist/index.es.js CHANGED
@@ -1,19 +1,20 @@
1
1
  import { injectable as d, inject as i } from "inversify";
2
2
  import * as c from "comlink";
3
- function g(e) {
3
+ import { name as g } from "@xwiki/cristal-document-api";
4
+ function h(e) {
4
5
  return new SharedWorker(
5
- "/assets/worker-CSpj1p6r.js",
6
+ "/assets/worker-DhHDiwPg.js",
6
7
  {
7
8
  name: e == null ? void 0 : e.name
8
9
  }
9
10
  );
10
11
  }
11
- var w = Object.defineProperty, h = Object.getOwnPropertyDescriptor, k = (e, r, n, o) => {
12
- for (var t = o > 1 ? void 0 : o ? h(r, n) : r, a = e.length - 1, l; a >= 0; a--)
13
- (l = e[a]) && (t = (o ? l(r, n, t) : l(t)) || t);
14
- return o && t && w(r, n, t), t;
15
- }, u = (e, r) => (n, o) => r(n, o, e);
16
- let s = class {
12
+ var w = Object.defineProperty, k = Object.getOwnPropertyDescriptor, m = (e, r, t, o) => {
13
+ for (var n = o > 1 ? void 0 : o ? k(r, t) : r, a = e.length - 1, s; a >= 0; a--)
14
+ (s = e[a]) && (n = (o ? s(r, t, n) : s(n)) || n);
15
+ return o && n && w(r, t, n), n;
16
+ }, u = (e, r) => (t, o) => r(t, o, e);
17
+ let l = class {
17
18
  constructor(e, r) {
18
19
  this.initialize(), this.logger = e, this.cristalApp = r;
19
20
  }
@@ -22,9 +23,7 @@ let s = class {
22
23
  this.logger.debug(
23
24
  "Received callback that new document has been loaded",
24
25
  e
25
- ), this.cristalApp.loadPage({
26
- requeue: !1
27
- }), this.logger.debug(
26
+ ), this.cristalApp.getContainer().get(g).refreshCurrentDocument(), this.logger.debug(
28
27
  "Done callback that new document has been loaded",
29
28
  e
30
29
  );
@@ -35,12 +34,14 @@ let s = class {
35
34
  initialize() {
36
35
  try {
37
36
  if (this.workerInstance == null) {
38
- const e = new g();
37
+ const e = new h({
38
+ name: "cristal-sharedworker"
39
+ });
39
40
  this.workerInstance = c.wrap(e.port);
40
41
  const r = this;
41
42
  this.workerInstance.setPageLoadedCallback(
42
- c.proxy(function(n) {
43
- r.pageLoaded(n);
43
+ c.proxy(function(t) {
44
+ r.pageLoaded(t);
44
45
  })
45
46
  ), console.debug("Worker initialized", this.workerInstance);
46
47
  } else
@@ -67,17 +68,17 @@ let s = class {
67
68
  return console.log("worker Calling getQueueSize"), this.workerInstance == null ? -1 : await this.workerInstance.getQueueSize();
68
69
  }
69
70
  };
70
- s = k([
71
+ l = m([
71
72
  d(),
72
73
  u(0, i("Logger")),
73
74
  u(1, i("CristalApp"))
74
- ], s);
75
- class p {
75
+ ], l);
76
+ class I {
76
77
  constructor(r) {
77
- r.bind("QueueWorker").to(s);
78
+ r.bind("QueueWorker").to(l);
78
79
  }
79
80
  }
80
81
  export {
81
- p as ComponentInit
82
+ I as ComponentInit
82
83
  };
83
84
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/components/defaultQueueWorker.ts","../src/components/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { inject, injectable } from \"inversify\";\nimport type { MyWorker, QueueWorker } from \"@xwiki/cristal-sharedworker-api\";\nimport * as Comlink from \"comlink\";\nimport Worker from \"./worker?sharedworker\";\nimport { type CristalApp, type Logger } from \"@xwiki/cristal-api\";\n\n@injectable()\nexport default class DefaultQueueWorker implements QueueWorker {\n // TODO remove use of any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private workerInstance: any;\n private cristalApp: CristalApp;\n private logger: Logger;\n\n public constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject<CristalApp>(\"CristalApp\") cristalApp: CristalApp,\n ) {\n this.initialize();\n this.logger = logger;\n this.cristalApp = cristalApp;\n }\n\n public pageLoaded(page: string): void {\n try {\n this.logger.debug(\n \"Received callback that new document has been loaded\",\n page,\n );\n // When reloading the page for the worker, prevents a requeue to avoid\n // an endless re-fetch of the current page.\n this.cristalApp.loadPage({\n requeue: false,\n });\n this.logger.debug(\n \"Done callback that new document has been loaded\",\n page,\n );\n } catch (e) {\n this.logger.error(\"Error calling loadPage\", e);\n }\n }\n\n public initialize(): void {\n try {\n if (this.workerInstance == null) {\n // this.workerInstance = new ComlinkWorker<typeof import('./worker')>(new URL('./worker',\n // import.meta.url), {/* normal Worker options*/})\n const sworker = new Worker();\n this.workerInstance = Comlink.wrap<MyWorker>(sworker.port);\n // TODO get rid of aliasing\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this;\n this.workerInstance.setPageLoadedCallback(\n Comlink.proxy(function (page: string) {\n that.pageLoaded(page);\n }),\n );\n\n console.debug(\"Worker initialized\", this.workerInstance);\n } else {\n console.debug(\"Already initialized\");\n }\n } catch (e) {\n console.error(\"Failed to initialize shared worker\", e);\n }\n }\n\n public getStatus(): boolean {\n if (this.workerInstance != null) {\n console.log(\"workerInstance is ready\");\n return true;\n } else {\n console.log(\"workerInstance is null. Cannot call\");\n return false;\n }\n }\n\n public async increment(): Promise<number> {\n if (this.workerInstance == null) {\n console.log(\"workerInstance is null. Cannot call\");\n return -1;\n } else {\n const result = await this.workerInstance.add(1);\n console.log(\"Results from shared worker: \", result);\n return result;\n }\n }\n\n public async addToQueue(page: string): Promise<void> {\n console.log(\"worker Calling addToQueue\", page);\n if (this.workerInstance != null) {\n await this.workerInstance.addToQueue(page);\n } else {\n console.log(\"workerInstance is null. Cannot call\");\n }\n }\n\n public async getQueueSize(): Promise<number> {\n console.log(\"worker Calling getQueueSize\");\n if (this.workerInstance == null) return -1;\n else return await this.workerInstance.getQueueSize();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport type { Container } from \"inversify\";\nimport type { QueueWorker } from \"@xwiki/cristal-sharedworker-api\";\nimport DefaultQueueWorker from \"./defaultQueueWorker\";\n\nexport default class ComponentInit {\n constructor(container: Container) {\n container.bind<QueueWorker>(\"QueueWorker\").to(DefaultQueueWorker);\n }\n}\n"],"names":["DefaultQueueWorker","logger","cristalApp","page","e","sworker","Worker","Comlink","that","result","__decorateClass","injectable","__decorateParam","ComponentInit","container"],"mappings":";;;;;;;;;;;;;;;AA2BA,IAAqBA,IAArB,MAA+D;AAAA,EAOtD,YACqBC,GACQC,GAClC;AACA,SAAK,WAAW,GAChB,KAAK,SAASD,GACd,KAAK,aAAaC;AAAA,EACpB;AAAA,EAEO,WAAWC,GAAoB;AAChC,QAAA;AACF,WAAK,OAAO;AAAA,QACV;AAAA,QACAA;AAAA,MAAA,GAIF,KAAK,WAAW,SAAS;AAAA,QACvB,SAAS;AAAA,MAAA,CACV,GACD,KAAK,OAAO;AAAA,QACV;AAAA,QACAA;AAAA,MAAA;AAAA,aAEKC,GAAG;AACL,WAAA,OAAO,MAAM,0BAA0BA,CAAC;AAAA,IAC/C;AAAA,EACF;AAAA,EAEO,aAAmB;AACpB,QAAA;AACE,UAAA,KAAK,kBAAkB,MAAM;AAGzB,cAAAC,IAAU,IAAIC;AACpB,aAAK,iBAAiBC,EAAQ,KAAeF,EAAQ,IAAI;AAGzD,cAAMG,IAAO;AACb,aAAK,eAAe;AAAA,UAClBD,EAAQ,MAAM,SAAUJ,GAAc;AACpC,YAAAK,EAAK,WAAWL,CAAI;AAAA,UAAA,CACrB;AAAA,QAAA,GAGK,QAAA,MAAM,sBAAsB,KAAK,cAAc;AAAA,MAAA;AAEvD,gBAAQ,MAAM,qBAAqB;AAAA,aAE9B,GAAG;AACF,cAAA,MAAM,sCAAsC,CAAC;AAAA,IACvD;AAAA,EACF;AAAA,EAEO,YAAqB;AACtB,WAAA,KAAK,kBAAkB,QACzB,QAAQ,IAAI,yBAAyB,GAC9B,OAEP,QAAQ,IAAI,qCAAqC,GAC1C;AAAA,EAEX;AAAA,EAEA,MAAa,YAA6B;AACpC,QAAA,KAAK,kBAAkB;AACzB,qBAAQ,IAAI,qCAAqC,GAC1C;AACF;AACL,YAAMM,IAAS,MAAM,KAAK,eAAe,IAAI,CAAC;AACtC,qBAAA,IAAI,gCAAgCA,CAAM,GAC3CA;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAa,WAAWN,GAA6B;AAC3C,YAAA,IAAI,6BAA6BA,CAAI,GACzC,KAAK,kBAAkB,OACnB,MAAA,KAAK,eAAe,WAAWA,CAAI,IAEzC,QAAQ,IAAI,qCAAqC;AAAA,EAErD;AAAA,EAEA,MAAa,eAAgC;AAEvC,WADJ,QAAQ,IAAI,6BAA6B,GACrC,KAAK,kBAAkB,OAAa,KAC5B,MAAM,KAAK,eAAe;EACxC;AACF;AAhGqBH,IAArBU,EAAA;AAAA,EADCC,EAAW;AAAA,EASPC,OAAe,QAAQ,CAAA;AAAA,EACvBA,OAAmB,YAAY,CAAA;AAAA,GATfZ,CAAA;ACHrB,MAAqBa,EAAc;AAAA,EACjC,YAAYC,GAAsB;AAChC,IAAAA,EAAU,KAAkB,aAAa,EAAE,GAAGd,CAAkB;AAAA,EAClE;AACF;"}
1
+ {"version":3,"file":"index.es.js","sources":["../src/components/defaultQueueWorker.ts","../src/components/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { inject, injectable } from \"inversify\";\nimport type { MyWorker, QueueWorker } from \"@xwiki/cristal-sharedworker-api\";\nimport * as Comlink from \"comlink\";\nimport Worker from \"./worker?sharedworker\";\nimport { type CristalApp, type Logger } from \"@xwiki/cristal-api\";\nimport {\n type DocumentService,\n name as documentServiceName,\n} from \"@xwiki/cristal-document-api\";\n\n@injectable()\nexport default class DefaultQueueWorker implements QueueWorker {\n // TODO remove use of any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private workerInstance: any;\n private cristalApp: CristalApp;\n private logger: Logger;\n\n public constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject<CristalApp>(\"CristalApp\") cristalApp: CristalApp,\n ) {\n this.initialize();\n this.logger = logger;\n this.cristalApp = cristalApp;\n }\n\n public pageLoaded(page: string): void {\n try {\n this.logger.debug(\n \"Received callback that new document has been loaded\",\n page,\n );\n // We need to access the DocumentService lasily as otherwise the\n // internal pinia instance is initialized too early.\n const documentService = this.cristalApp\n .getContainer()\n .get<DocumentService>(documentServiceName);\n documentService.refreshCurrentDocument();\n\n this.logger.debug(\n \"Done callback that new document has been loaded\",\n page,\n );\n } catch (e) {\n this.logger.error(\"Error calling loadPage\", e);\n }\n }\n\n public initialize(): void {\n try {\n if (this.workerInstance == null) {\n // this.workerInstance = new ComlinkWorker<typeof import('./worker')>(new URL('./worker',\n // import.meta.url), {/* normal Worker options*/})\n const sworker = new Worker({\n name: \"cristal-sharedworker\",\n });\n this.workerInstance = Comlink.wrap<MyWorker>(sworker.port);\n // TODO get rid of aliasing\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this;\n this.workerInstance.setPageLoadedCallback(\n Comlink.proxy(function (page: string) {\n that.pageLoaded(page);\n }),\n );\n\n console.debug(\"Worker initialized\", this.workerInstance);\n } else {\n console.debug(\"Already initialized\");\n }\n } catch (e) {\n console.error(\"Failed to initialize shared worker\", e);\n }\n }\n\n public getStatus(): boolean {\n if (this.workerInstance != null) {\n console.log(\"workerInstance is ready\");\n return true;\n } else {\n console.log(\"workerInstance is null. Cannot call\");\n return false;\n }\n }\n\n public async increment(): Promise<number> {\n if (this.workerInstance == null) {\n console.log(\"workerInstance is null. Cannot call\");\n return -1;\n } else {\n const result = await this.workerInstance.add(1);\n console.log(\"Results from shared worker: \", result);\n return result;\n }\n }\n\n public async addToQueue(page: string): Promise<void> {\n console.log(\"worker Calling addToQueue\", page);\n if (this.workerInstance != null) {\n await this.workerInstance.addToQueue(page);\n } else {\n console.log(\"workerInstance is null. Cannot call\");\n }\n }\n\n public async getQueueSize(): Promise<number> {\n console.log(\"worker Calling getQueueSize\");\n if (this.workerInstance == null) return -1;\n else return await this.workerInstance.getQueueSize();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport type { Container } from \"inversify\";\nimport type { QueueWorker } from \"@xwiki/cristal-sharedworker-api\";\nimport DefaultQueueWorker from \"./defaultQueueWorker\";\n\nexport default class ComponentInit {\n constructor(container: Container) {\n container.bind<QueueWorker>(\"QueueWorker\").to(DefaultQueueWorker);\n }\n}\n"],"names":["DefaultQueueWorker","logger","cristalApp","page","documentServiceName","e","sworker","Worker","Comlink","that","result","__decorateClass","injectable","__decorateParam","ComponentInit","container"],"mappings":";;;;;;;;;;;;;;;;AA+BA,IAAqBA,IAArB,MAA+D;AAAA,EAOtD,YACqBC,GACQC,GAClC;AACA,SAAK,WAAW,GAChB,KAAK,SAASD,GACd,KAAK,aAAaC;AAAA,EACpB;AAAA,EAEO,WAAWC,GAAoB;AAChC,QAAA;AACF,WAAK,OAAO;AAAA,QACV;AAAA,QACAA;AAAA,MAAA,GAIsB,KAAK,WAC1B,aAAa,EACb,IAAqBC,CAAmB,EAC3B,uBAAuB,GAEvC,KAAK,OAAO;AAAA,QACV;AAAA,QACAD;AAAA,MAAA;AAAA,aAEKE,GAAG;AACL,WAAA,OAAO,MAAM,0BAA0BA,CAAC;AAAA,IAC/C;AAAA,EACF;AAAA,EAEO,aAAmB;AACpB,QAAA;AACE,UAAA,KAAK,kBAAkB,MAAM;AAGzB,cAAAC,IAAU,IAAIC,EAAO;AAAA,UACzB,MAAM;AAAA,QAAA,CACP;AACD,aAAK,iBAAiBC,EAAQ,KAAeF,EAAQ,IAAI;AAGzD,cAAMG,IAAO;AACb,aAAK,eAAe;AAAA,UAClBD,EAAQ,MAAM,SAAUL,GAAc;AACpC,YAAAM,EAAK,WAAWN,CAAI;AAAA,UAAA,CACrB;AAAA,QAAA,GAGK,QAAA,MAAM,sBAAsB,KAAK,cAAc;AAAA,MAAA;AAEvD,gBAAQ,MAAM,qBAAqB;AAAA,aAE9B,GAAG;AACF,cAAA,MAAM,sCAAsC,CAAC;AAAA,IACvD;AAAA,EACF;AAAA,EAEO,YAAqB;AACtB,WAAA,KAAK,kBAAkB,QACzB,QAAQ,IAAI,yBAAyB,GAC9B,OAEP,QAAQ,IAAI,qCAAqC,GAC1C;AAAA,EAEX;AAAA,EAEA,MAAa,YAA6B;AACpC,QAAA,KAAK,kBAAkB;AACzB,qBAAQ,IAAI,qCAAqC,GAC1C;AACF;AACL,YAAMO,IAAS,MAAM,KAAK,eAAe,IAAI,CAAC;AACtC,qBAAA,IAAI,gCAAgCA,CAAM,GAC3CA;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAa,WAAWP,GAA6B;AAC3C,YAAA,IAAI,6BAA6BA,CAAI,GACzC,KAAK,kBAAkB,OACnB,MAAA,KAAK,eAAe,WAAWA,CAAI,IAEzC,QAAQ,IAAI,qCAAqC;AAAA,EAErD;AAAA,EAEA,MAAa,eAAgC;AAEvC,WADJ,QAAQ,IAAI,6BAA6B,GACrC,KAAK,kBAAkB,OAAa,KAC5B,MAAM,KAAK,eAAe;EACxC;AACF;AApGqBH,IAArBW,EAAA;AAAA,EADCC,EAAW;AAAA,EASPC,OAAe,QAAQ,CAAA;AAAA,EACvBA,OAAmB,YAAY,CAAA;AAAA,GATfb,CAAA;ACPrB,MAAqBc,EAAc;AAAA,EACjC,YAAYC,GAAsB;AAChC,IAAAA,EAAU,KAAkB,aAAa,EAAE,GAAGf,CAAkB;AAAA,EAClE;AACF;"}
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("inversify"),require("comlink")):typeof define=="function"&&define.amd?define(["exports","inversify","comlink"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o.cristal_impl={},o.inversify,o.Comlink))})(this,function(o,a,f){"use strict";function g(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const u=g(f);function h(e){return new SharedWorker("/assets/worker-CSpj1p6r.js",{name:e==null?void 0:e.name})}var w=Object.defineProperty,p=Object.getOwnPropertyDescriptor,k=(e,r,t,n)=>{for(var l=n>1?void 0:n?p(r,t):r,i=e.length-1,c;i>=0;i--)(c=e[i])&&(l=(n?c(r,t,l):c(l))||l);return n&&l&&w(r,t,l),l},d=(e,r)=>(t,n)=>r(t,n,e);let s=class{constructor(e,r){this.initialize(),this.logger=e,this.cristalApp=r}pageLoaded(e){try{this.logger.debug("Received callback that new document has been loaded",e),this.cristalApp.loadPage({requeue:!1}),this.logger.debug("Done callback that new document has been loaded",e)}catch(r){this.logger.error("Error calling loadPage",r)}}initialize(){try{if(this.workerInstance==null){const e=new h;this.workerInstance=u.wrap(e.port);const r=this;this.workerInstance.setPageLoadedCallback(u.proxy(function(t){r.pageLoaded(t)})),console.debug("Worker initialized",this.workerInstance)}else console.debug("Already initialized")}catch(e){console.error("Failed to initialize shared worker",e)}}getStatus(){return this.workerInstance!=null?(console.log("workerInstance is ready"),!0):(console.log("workerInstance is null. Cannot call"),!1)}async increment(){if(this.workerInstance==null)return console.log("workerInstance is null. Cannot call"),-1;{const e=await this.workerInstance.add(1);return console.log("Results from shared worker: ",e),e}}async addToQueue(e){console.log("worker Calling addToQueue",e),this.workerInstance!=null?await this.workerInstance.addToQueue(e):console.log("workerInstance is null. Cannot call")}async getQueueSize(){return console.log("worker Calling getQueueSize"),this.workerInstance==null?-1:await this.workerInstance.getQueueSize()}};s=k([a.injectable(),d(0,a.inject("Logger")),d(1,a.inject("CristalApp"))],s);class m{constructor(r){r.bind("QueueWorker").to(s)}}o.ComponentInit=m,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("inversify"),require("comlink"),require("@xwiki/cristal-document-api")):typeof define=="function"&&define.amd?define(["exports","inversify","comlink","@xwiki/cristal-document-api"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.cristal_impl={},n.inversify,n.Comlink,n.cristalDocumentApi))})(this,function(n,i,f,g){"use strict";function h(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const u=h(f);function w(e){return new SharedWorker("/assets/worker-DhHDiwPg.js",{name:e==null?void 0:e.name})}var k=Object.defineProperty,p=Object.getOwnPropertyDescriptor,m=(e,r,t,o)=>{for(var a=o>1?void 0:o?p(r,t):r,l=e.length-1,c;l>=0;l--)(c=e[l])&&(a=(o?c(r,t,a):c(a))||a);return o&&a&&k(r,t,a),a},d=(e,r)=>(t,o)=>r(t,o,e);let s=class{constructor(e,r){this.initialize(),this.logger=e,this.cristalApp=r}pageLoaded(e){try{this.logger.debug("Received callback that new document has been loaded",e),this.cristalApp.getContainer().get(g.name).refreshCurrentDocument(),this.logger.debug("Done callback that new document has been loaded",e)}catch(r){this.logger.error("Error calling loadPage",r)}}initialize(){try{if(this.workerInstance==null){const e=new w({name:"cristal-sharedworker"});this.workerInstance=u.wrap(e.port);const r=this;this.workerInstance.setPageLoadedCallback(u.proxy(function(t){r.pageLoaded(t)})),console.debug("Worker initialized",this.workerInstance)}else console.debug("Already initialized")}catch(e){console.error("Failed to initialize shared worker",e)}}getStatus(){return this.workerInstance!=null?(console.log("workerInstance is ready"),!0):(console.log("workerInstance is null. Cannot call"),!1)}async increment(){if(this.workerInstance==null)return console.log("workerInstance is null. Cannot call"),-1;{const e=await this.workerInstance.add(1);return console.log("Results from shared worker: ",e),e}}async addToQueue(e){console.log("worker Calling addToQueue",e),this.workerInstance!=null?await this.workerInstance.addToQueue(e):console.log("workerInstance is null. Cannot call")}async getQueueSize(){return console.log("worker Calling getQueueSize"),this.workerInstance==null?-1:await this.workerInstance.getQueueSize()}};s=m([i.injectable(),d(0,i.inject("Logger")),d(1,i.inject("CristalApp"))],s);class b{constructor(r){r.bind("QueueWorker").to(s)}}n.ComponentInit=b,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=index.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/components/defaultQueueWorker.ts","../src/components/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { inject, injectable } from \"inversify\";\nimport type { MyWorker, QueueWorker } from \"@xwiki/cristal-sharedworker-api\";\nimport * as Comlink from \"comlink\";\nimport Worker from \"./worker?sharedworker\";\nimport { type CristalApp, type Logger } from \"@xwiki/cristal-api\";\n\n@injectable()\nexport default class DefaultQueueWorker implements QueueWorker {\n // TODO remove use of any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private workerInstance: any;\n private cristalApp: CristalApp;\n private logger: Logger;\n\n public constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject<CristalApp>(\"CristalApp\") cristalApp: CristalApp,\n ) {\n this.initialize();\n this.logger = logger;\n this.cristalApp = cristalApp;\n }\n\n public pageLoaded(page: string): void {\n try {\n this.logger.debug(\n \"Received callback that new document has been loaded\",\n page,\n );\n // When reloading the page for the worker, prevents a requeue to avoid\n // an endless re-fetch of the current page.\n this.cristalApp.loadPage({\n requeue: false,\n });\n this.logger.debug(\n \"Done callback that new document has been loaded\",\n page,\n );\n } catch (e) {\n this.logger.error(\"Error calling loadPage\", e);\n }\n }\n\n public initialize(): void {\n try {\n if (this.workerInstance == null) {\n // this.workerInstance = new ComlinkWorker<typeof import('./worker')>(new URL('./worker',\n // import.meta.url), {/* normal Worker options*/})\n const sworker = new Worker();\n this.workerInstance = Comlink.wrap<MyWorker>(sworker.port);\n // TODO get rid of aliasing\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this;\n this.workerInstance.setPageLoadedCallback(\n Comlink.proxy(function (page: string) {\n that.pageLoaded(page);\n }),\n );\n\n console.debug(\"Worker initialized\", this.workerInstance);\n } else {\n console.debug(\"Already initialized\");\n }\n } catch (e) {\n console.error(\"Failed to initialize shared worker\", e);\n }\n }\n\n public getStatus(): boolean {\n if (this.workerInstance != null) {\n console.log(\"workerInstance is ready\");\n return true;\n } else {\n console.log(\"workerInstance is null. Cannot call\");\n return false;\n }\n }\n\n public async increment(): Promise<number> {\n if (this.workerInstance == null) {\n console.log(\"workerInstance is null. Cannot call\");\n return -1;\n } else {\n const result = await this.workerInstance.add(1);\n console.log(\"Results from shared worker: \", result);\n return result;\n }\n }\n\n public async addToQueue(page: string): Promise<void> {\n console.log(\"worker Calling addToQueue\", page);\n if (this.workerInstance != null) {\n await this.workerInstance.addToQueue(page);\n } else {\n console.log(\"workerInstance is null. Cannot call\");\n }\n }\n\n public async getQueueSize(): Promise<number> {\n console.log(\"worker Calling getQueueSize\");\n if (this.workerInstance == null) return -1;\n else return await this.workerInstance.getQueueSize();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport type { Container } from \"inversify\";\nimport type { QueueWorker } from \"@xwiki/cristal-sharedworker-api\";\nimport DefaultQueueWorker from \"./defaultQueueWorker\";\n\nexport default class ComponentInit {\n constructor(container: Container) {\n container.bind<QueueWorker>(\"QueueWorker\").to(DefaultQueueWorker);\n }\n}\n"],"names":["DefaultQueueWorker","logger","cristalApp","page","e","sworker","Worker","Comlink","that","result","__decorateClass","injectable","__decorateParam","ComponentInit","container"],"mappings":"g5BA2BA,IAAqBA,EAArB,KAA+D,CAOtD,YACqBC,EACQC,EAClC,CACA,KAAK,WAAW,EAChB,KAAK,OAASD,EACd,KAAK,WAAaC,CACpB,CAEO,WAAWC,EAAoB,CAChC,GAAA,CACF,KAAK,OAAO,MACV,sDACAA,CAAA,EAIF,KAAK,WAAW,SAAS,CACvB,QAAS,EAAA,CACV,EACD,KAAK,OAAO,MACV,kDACAA,CAAA,QAEKC,EAAG,CACL,KAAA,OAAO,MAAM,yBAA0BA,CAAC,CAC/C,CACF,CAEO,YAAmB,CACpB,GAAA,CACE,GAAA,KAAK,gBAAkB,KAAM,CAGzB,MAAAC,EAAU,IAAIC,EACpB,KAAK,eAAiBC,EAAQ,KAAeF,EAAQ,IAAI,EAGzD,MAAMG,EAAO,KACb,KAAK,eAAe,sBAClBD,EAAQ,MAAM,SAAUJ,EAAc,CACpCK,EAAK,WAAWL,CAAI,CAAA,CACrB,CAAA,EAGK,QAAA,MAAM,qBAAsB,KAAK,cAAc,CAAA,MAEvD,QAAQ,MAAM,qBAAqB,QAE9B,EAAG,CACF,QAAA,MAAM,qCAAsC,CAAC,CACvD,CACF,CAEO,WAAqB,CACtB,OAAA,KAAK,gBAAkB,MACzB,QAAQ,IAAI,yBAAyB,EAC9B,KAEP,QAAQ,IAAI,qCAAqC,EAC1C,GAEX,CAEA,MAAa,WAA6B,CACpC,GAAA,KAAK,gBAAkB,KACzB,eAAQ,IAAI,qCAAqC,EAC1C,GACF,CACL,MAAMM,EAAS,MAAM,KAAK,eAAe,IAAI,CAAC,EACtC,eAAA,IAAI,+BAAgCA,CAAM,EAC3CA,CACT,CACF,CAEA,MAAa,WAAWN,EAA6B,CAC3C,QAAA,IAAI,4BAA6BA,CAAI,EACzC,KAAK,gBAAkB,KACnB,MAAA,KAAK,eAAe,WAAWA,CAAI,EAEzC,QAAQ,IAAI,qCAAqC,CAErD,CAEA,MAAa,cAAgC,CAEvC,OADJ,QAAQ,IAAI,6BAA6B,EACrC,KAAK,gBAAkB,KAAa,GAC5B,MAAM,KAAK,eAAe,cACxC,CACF,EAhGqBH,EAArBU,EAAA,CADCC,aAAW,EASPC,aAAe,QAAQ,CAAA,EACvBA,aAAmB,YAAY,CAAA,CAAA,EATfZ,CAAA,ECHrB,MAAqBa,CAAc,CACjC,YAAYC,EAAsB,CAChCA,EAAU,KAAkB,aAAa,EAAE,GAAGd,CAAkB,CAClE,CACF"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/components/defaultQueueWorker.ts","../src/components/componentsInit.ts"],"sourcesContent":["/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport { inject, injectable } from \"inversify\";\nimport type { MyWorker, QueueWorker } from \"@xwiki/cristal-sharedworker-api\";\nimport * as Comlink from \"comlink\";\nimport Worker from \"./worker?sharedworker\";\nimport { type CristalApp, type Logger } from \"@xwiki/cristal-api\";\nimport {\n type DocumentService,\n name as documentServiceName,\n} from \"@xwiki/cristal-document-api\";\n\n@injectable()\nexport default class DefaultQueueWorker implements QueueWorker {\n // TODO remove use of any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private workerInstance: any;\n private cristalApp: CristalApp;\n private logger: Logger;\n\n public constructor(\n @inject<Logger>(\"Logger\") logger: Logger,\n @inject<CristalApp>(\"CristalApp\") cristalApp: CristalApp,\n ) {\n this.initialize();\n this.logger = logger;\n this.cristalApp = cristalApp;\n }\n\n public pageLoaded(page: string): void {\n try {\n this.logger.debug(\n \"Received callback that new document has been loaded\",\n page,\n );\n // We need to access the DocumentService lasily as otherwise the\n // internal pinia instance is initialized too early.\n const documentService = this.cristalApp\n .getContainer()\n .get<DocumentService>(documentServiceName);\n documentService.refreshCurrentDocument();\n\n this.logger.debug(\n \"Done callback that new document has been loaded\",\n page,\n );\n } catch (e) {\n this.logger.error(\"Error calling loadPage\", e);\n }\n }\n\n public initialize(): void {\n try {\n if (this.workerInstance == null) {\n // this.workerInstance = new ComlinkWorker<typeof import('./worker')>(new URL('./worker',\n // import.meta.url), {/* normal Worker options*/})\n const sworker = new Worker({\n name: \"cristal-sharedworker\",\n });\n this.workerInstance = Comlink.wrap<MyWorker>(sworker.port);\n // TODO get rid of aliasing\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const that = this;\n this.workerInstance.setPageLoadedCallback(\n Comlink.proxy(function (page: string) {\n that.pageLoaded(page);\n }),\n );\n\n console.debug(\"Worker initialized\", this.workerInstance);\n } else {\n console.debug(\"Already initialized\");\n }\n } catch (e) {\n console.error(\"Failed to initialize shared worker\", e);\n }\n }\n\n public getStatus(): boolean {\n if (this.workerInstance != null) {\n console.log(\"workerInstance is ready\");\n return true;\n } else {\n console.log(\"workerInstance is null. Cannot call\");\n return false;\n }\n }\n\n public async increment(): Promise<number> {\n if (this.workerInstance == null) {\n console.log(\"workerInstance is null. Cannot call\");\n return -1;\n } else {\n const result = await this.workerInstance.add(1);\n console.log(\"Results from shared worker: \", result);\n return result;\n }\n }\n\n public async addToQueue(page: string): Promise<void> {\n console.log(\"worker Calling addToQueue\", page);\n if (this.workerInstance != null) {\n await this.workerInstance.addToQueue(page);\n } else {\n console.log(\"workerInstance is null. Cannot call\");\n }\n }\n\n public async getQueueSize(): Promise<number> {\n console.log(\"worker Calling getQueueSize\");\n if (this.workerInstance == null) return -1;\n else return await this.workerInstance.getQueueSize();\n }\n}\n","/*\n * See the LICENSE file distributed with this work for additional\n * information regarding copyright ownership.\n *\n * This is free software; you can redistribute it and/or modify it\n * under the terms of the GNU Lesser General Public License as\n * published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This software is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public\n * License along with this software; if not, write to the Free\n * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n * 02110-1301 USA, or see the FSF site: http://www.fsf.org.\n */\n\nimport type { Container } from \"inversify\";\nimport type { QueueWorker } from \"@xwiki/cristal-sharedworker-api\";\nimport DefaultQueueWorker from \"./defaultQueueWorker\";\n\nexport default class ComponentInit {\n constructor(container: Container) {\n container.bind<QueueWorker>(\"QueueWorker\").to(DefaultQueueWorker);\n }\n}\n"],"names":["DefaultQueueWorker","logger","cristalApp","page","documentServiceName","e","sworker","Worker","Comlink","that","result","__decorateClass","injectable","__decorateParam","ComponentInit","container"],"mappings":"4+BA+BA,IAAqBA,EAArB,KAA+D,CAOtD,YACqBC,EACQC,EAClC,CACA,KAAK,WAAW,EAChB,KAAK,OAASD,EACd,KAAK,WAAaC,CACpB,CAEO,WAAWC,EAAoB,CAChC,GAAA,CACF,KAAK,OAAO,MACV,sDACAA,CAAA,EAIsB,KAAK,WAC1B,aAAa,EACb,IAAqBC,EAAAA,IAAmB,EAC3B,uBAAuB,EAEvC,KAAK,OAAO,MACV,kDACAD,CAAA,QAEKE,EAAG,CACL,KAAA,OAAO,MAAM,yBAA0BA,CAAC,CAC/C,CACF,CAEO,YAAmB,CACpB,GAAA,CACE,GAAA,KAAK,gBAAkB,KAAM,CAGzB,MAAAC,EAAU,IAAIC,EAAO,CACzB,KAAM,sBAAA,CACP,EACD,KAAK,eAAiBC,EAAQ,KAAeF,EAAQ,IAAI,EAGzD,MAAMG,EAAO,KACb,KAAK,eAAe,sBAClBD,EAAQ,MAAM,SAAUL,EAAc,CACpCM,EAAK,WAAWN,CAAI,CAAA,CACrB,CAAA,EAGK,QAAA,MAAM,qBAAsB,KAAK,cAAc,CAAA,MAEvD,QAAQ,MAAM,qBAAqB,QAE9B,EAAG,CACF,QAAA,MAAM,qCAAsC,CAAC,CACvD,CACF,CAEO,WAAqB,CACtB,OAAA,KAAK,gBAAkB,MACzB,QAAQ,IAAI,yBAAyB,EAC9B,KAEP,QAAQ,IAAI,qCAAqC,EAC1C,GAEX,CAEA,MAAa,WAA6B,CACpC,GAAA,KAAK,gBAAkB,KACzB,eAAQ,IAAI,qCAAqC,EAC1C,GACF,CACL,MAAMO,EAAS,MAAM,KAAK,eAAe,IAAI,CAAC,EACtC,eAAA,IAAI,+BAAgCA,CAAM,EAC3CA,CACT,CACF,CAEA,MAAa,WAAWP,EAA6B,CAC3C,QAAA,IAAI,4BAA6BA,CAAI,EACzC,KAAK,gBAAkB,KACnB,MAAA,KAAK,eAAe,WAAWA,CAAI,EAEzC,QAAQ,IAAI,qCAAqC,CAErD,CAEA,MAAa,cAAgC,CAEvC,OADJ,QAAQ,IAAI,6BAA6B,EACrC,KAAK,gBAAkB,KAAa,GAC5B,MAAM,KAAK,eAAe,cACxC,CACF,EApGqBH,EAArBW,EAAA,CADCC,aAAW,EASPC,aAAe,QAAQ,CAAA,EACvBA,aAAmB,YAAY,CAAA,CAAA,EATfb,CAAA,ECPrB,MAAqBc,CAAc,CACjC,YAAYC,EAAsB,CAChCA,EAAU,KAAkB,aAAa,EAAE,GAAGf,CAAkB,CAClE,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xwiki/cristal-sharedworker-impl",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "license": "LGPL 2.1",
5
5
  "author": "XWiki Org Community <contact@xwiki.org>",
6
6
  "homepage": "https://cristal.xwiki.org/",
@@ -25,26 +25,26 @@
25
25
  "dependencies": {
26
26
  "comlink": "4.4.1",
27
27
  "inversify": "6.0.2",
28
- "vue": "3.4.29",
29
- "vue-router": "4.3.2",
30
- "@xwiki/cristal-api": "0.9.0",
31
- "@xwiki/cristal-backend-dexie": "0.9.0",
32
- "@xwiki/cristal-backend-github": "0.9.0",
33
- "@xwiki/cristal-backend-xwiki": "0.9.0",
34
- "@xwiki/cristal-backend-nextcloud": "0.9.0",
35
- "@xwiki/cristal-extension-manager": "0.9.0",
36
- "@xwiki/cristal-sharedworker-api": "0.9.0"
28
+ "vue": "3.5.12",
29
+ "vue-router": "4.4.5",
30
+ "@xwiki/cristal-api": "0.11.0",
31
+ "@xwiki/cristal-authentication-api": "0.11.0",
32
+ "@xwiki/cristal-backend-github": "0.11.0",
33
+ "@xwiki/cristal-backend-nextcloud": "0.11.0",
34
+ "@xwiki/cristal-backend-dexie": "0.11.0",
35
+ "@xwiki/cristal-backend-xwiki": "0.11.0",
36
+ "@xwiki/cristal-document-api": "0.11.0",
37
+ "@xwiki/cristal-extension-manager": "0.11.0",
38
+ "@xwiki/cristal-sharedworker-api": "0.11.0"
37
39
  },
38
40
  "devDependencies": {
39
- "rimraf": "5.0.7",
40
- "vite-plugin-comlink": "4.1.0",
41
- "vue-tsc": "2.0.21"
41
+ "vite-plugin-comlink": "5.0.1",
42
+ "vue-tsc": "2.1.6"
42
43
  },
43
44
  "scripts": {
44
45
  "build": "pnpm compile",
45
46
  "clean": "rimraf dist",
46
47
  "compile": "vue-tsc --project tsconfig.json && vite build",
47
- "lint": "eslint \"./src/**/*.{ts,tsx}\" --max-warnings=0",
48
- "test": "echo 'no test'"
48
+ "lint": "eslint \"./src/**/*.{ts,tsx}\" --max-warnings=0"
49
49
  }
50
50
  }
@@ -23,6 +23,10 @@ import type { MyWorker, QueueWorker } from "@xwiki/cristal-sharedworker-api";
23
23
  import * as Comlink from "comlink";
24
24
  import Worker from "./worker?sharedworker";
25
25
  import { type CristalApp, type Logger } from "@xwiki/cristal-api";
26
+ import {
27
+ type DocumentService,
28
+ name as documentServiceName,
29
+ } from "@xwiki/cristal-document-api";
26
30
 
27
31
  @injectable()
28
32
  export default class DefaultQueueWorker implements QueueWorker {
@@ -47,11 +51,13 @@ export default class DefaultQueueWorker implements QueueWorker {
47
51
  "Received callback that new document has been loaded",
48
52
  page,
49
53
  );
50
- // When reloading the page for the worker, prevents a requeue to avoid
51
- // an endless re-fetch of the current page.
52
- this.cristalApp.loadPage({
53
- requeue: false,
54
- });
54
+ // We need to access the DocumentService lasily as otherwise the
55
+ // internal pinia instance is initialized too early.
56
+ const documentService = this.cristalApp
57
+ .getContainer()
58
+ .get<DocumentService>(documentServiceName);
59
+ documentService.refreshCurrentDocument();
60
+
55
61
  this.logger.debug(
56
62
  "Done callback that new document has been loaded",
57
63
  page,
@@ -66,7 +72,9 @@ export default class DefaultQueueWorker implements QueueWorker {
66
72
  if (this.workerInstance == null) {
67
73
  // this.workerInstance = new ComlinkWorker<typeof import('./worker')>(new URL('./worker',
68
74
  // import.meta.url), {/* normal Worker options*/})
69
- const sworker = new Worker();
75
+ const sworker = new Worker({
76
+ name: "cristal-sharedworker",
77
+ });
70
78
  this.workerInstance = Comlink.wrap<MyWorker>(sworker.port);
71
79
  // TODO get rid of aliasing
72
80
  // eslint-disable-next-line @typescript-eslint/no-this-alias
@@ -27,6 +27,7 @@ import { ComponentInit as DexieBackendComponentInit } from "@xwiki/cristal-backe
27
27
  import { ComponentInit as GithubBackendComponentInit } from "@xwiki/cristal-backend-github";
28
28
  import { ComponentInit as NextcloudBackendComponentInit } from "@xwiki/cristal-backend-nextcloud";
29
29
  import { ComponentInit as XWikiBackendComponentInit } from "@xwiki/cristal-backend-xwiki";
30
+ import { ComponentInit as AuthenticationAPIComponentInit } from "@xwiki/cristal-authentication-api";
30
31
  import type { Container } from "inversify";
31
32
  import { WorkerCristalApp } from "./workerCristalApp";
32
33
  import WorkerQueueWorker from "./workerQueueWorker";
@@ -34,10 +35,18 @@ import WorkerQueueWorker from "./workerQueueWorker";
34
35
  export class Worker implements MyWorker {
35
36
  private currentNumber: number = 0;
36
37
  private queue: Array<string> = [];
38
+ // @ts-expect-error container is temporarily undefined during class
39
+ // initialization
37
40
  private container: Container;
41
+ // @ts-expect-error cristal is temporarily undefined during class
42
+ // initialization
38
43
  private cristal: CristalApp;
44
+ // @ts-expect-error configMap is temporarily undefined during class
45
+ // initialization
39
46
  private configMap: Map<string, object>;
40
47
  private initialized: boolean = false;
48
+ // @ts-expect-error fct is temporarily undefined during class
49
+ // initialization
41
50
  private fct: (a: string) => void;
42
51
 
43
52
  /*
@@ -45,11 +54,10 @@ export class Worker implements MyWorker {
45
54
  */
46
55
  public async start(): Promise<void> {
47
56
  console.log("Starting worker thread");
48
- this.initialize();
49
- // eslint-disable-next-line no-constant-condition
57
+ await this.initialize();
50
58
  while (true) {
51
59
  await this.sleep(1000);
52
- this.checkQueue();
60
+ await this.checkQueue();
53
61
  }
54
62
  }
55
63
 
@@ -210,6 +218,7 @@ export class Worker implements MyWorker {
210
218
  new GithubBackendComponentInit(cristalLoader.container);
211
219
  new NextcloudBackendComponentInit(cristalLoader.container);
212
220
  new XWikiBackendComponentInit(cristalLoader.container);
221
+ new AuthenticationAPIComponentInit(cristalLoader.container);
213
222
  console.log("Loading storage components");
214
223
  this.initialized = true;
215
224
  console.log("Finished initialize");
@@ -33,7 +33,11 @@ import type { Router } from "vue-router";
33
33
 
34
34
  @injectable()
35
35
  export class WorkerCristalApp implements CristalApp {
36
+ // @ts-expect-error wikiConfig is temporarily undefined during class
37
+ // initialization
36
38
  private wikiConfig: WikiConfig;
39
+ // @ts-expect-error container is temporarily undefined during class
40
+ // initialization
37
41
  private container: Container;
38
42
  private availableConfigurations: Map<string, WikiConfig>;
39
43