@xwiki/cristal-sharedworker-impl 0.8.0 → 0.9.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/dist/index.es.js CHANGED
@@ -2,16 +2,16 @@ import { injectable as d, inject as i } from "inversify";
2
2
  import * as c from "comlink";
3
3
  function g(e) {
4
4
  return new SharedWorker(
5
- "/assets/worker-D2exZhnK.js",
5
+ "/assets/worker-CSpj1p6r.js",
6
6
  {
7
7
  name: e == null ? void 0 : e.name
8
8
  }
9
9
  );
10
10
  }
11
- var h = Object.defineProperty, w = Object.getOwnPropertyDescriptor, k = (e, r, n, o) => {
12
- for (var t = o > 1 ? void 0 : o ? w(r, n) : r, a = e.length - 1, l; a >= 0; a--)
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
13
  (l = e[a]) && (t = (o ? l(r, n, t) : l(t)) || t);
14
- return o && t && h(r, n, t), t;
14
+ return o && t && w(r, n, t), t;
15
15
  }, u = (e, r) => (n, o) => r(n, o, e);
16
16
  let s = class {
17
17
  constructor(e, r) {
@@ -72,30 +72,6 @@ s = k([
72
72
  u(0, i("Logger")),
73
73
  u(1, i("CristalApp"))
74
74
  ], s);
75
- /**
76
- * See the LICENSE file distributed with this work for additional
77
- * information regarding copyright ownership.
78
- *
79
- * This is free software; you can redistribute it and/or modify it
80
- * under the terms of the GNU Affero General Public License as
81
- * published by the Free Software Foundation; either version 2.1 of
82
- * the License, or (at your option) any later version.
83
- *
84
- * This software is distributed in the hope that it will be useful,
85
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
86
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
87
- * Lesser General Public License for more details.
88
- *
89
- * You should have received a copy of the GNU Affero General Public
90
- * License along with this software; if not, write to the Free
91
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
92
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
93
- *
94
- * This file is part of the Cristal Wiki software prototype
95
- * @copyright Copyright (c) 2023 XWiki SAS
96
- * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
97
- *
98
- **/
99
75
  class p {
100
76
  constructor(r) {
101
77
  r.bind("QueueWorker").to(s);
@@ -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 Affero 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 Affero 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 * This file is part of the Cristal Wiki software prototype\n * @copyright Copyright (c) 2023 XWiki SAS\n * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0\n *\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) {\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() {\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 Affero 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 Affero 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 * This file is part of the Cristal Wiki software prototype\n * @copyright Copyright (c) 2023 XWiki SAS\n * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0\n *\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":";;;;;;;;;;;;;;;AAgCA,IAAqBA,IAArB,MAA+D;AAAA,EAOtD,YACqBC,GACQC,GAClC;AACA,SAAK,WAAW,GAChB,KAAK,SAASD,GACd,KAAK,aAAaC;AAAA,EACpB;AAAA,EAEO,WAAWC,GAAc;AAC1B,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,aAAa;AACd,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;AAE3C,WADA,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;AChCrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,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\";\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;"}
package/dist/index.umd.js CHANGED
@@ -1,25 +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 n in e)if(n!=="default"){const t=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,t.get?t:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const u=g(f);function h(e){return new SharedWorker("/assets/worker-D2exZhnK.js",{name:e==null?void 0:e.name})}var w=Object.defineProperty,k=Object.getOwnPropertyDescriptor,p=(e,r,n,t)=>{for(var l=t>1?void 0:t?k(r,n):r,i=e.length-1,c;i>=0;i--)(c=e[i])&&(l=(t?c(r,n,l):c(l))||l);return t&&l&&w(r,n,l),l},d=(e,r)=>(n,t)=>r(n,t,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(n){r.pageLoaded(n)})),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=p([a.injectable(),d(0,a.inject("Logger")),d(1,a.inject("CristalApp"))],s);/**
2
- * See the LICENSE file distributed with this work for additional
3
- * information regarding copyright ownership.
4
- *
5
- * This is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU Affero General Public License as
7
- * published by the Free Software Foundation; either version 2.1 of
8
- * the License, or (at your option) any later version.
9
- *
10
- * This software is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
- * Lesser General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU Affero General Public
16
- * License along with this software; if not, write to the Free
17
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
- *
20
- * This file is part of the Cristal Wiki software prototype
21
- * @copyright Copyright (c) 2023 XWiki SAS
22
- * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
23
- *
24
- **/class m{constructor(r){r.bind("QueueWorker").to(s)}}o.ComponentInit=m,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
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"})});
25
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 Affero 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 Affero 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 * This file is part of the Cristal Wiki software prototype\n * @copyright Copyright (c) 2023 XWiki SAS\n * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0\n *\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) {\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() {\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 Affero 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 Affero 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 * This file is part of the Cristal Wiki software prototype\n * @copyright Copyright (c) 2023 XWiki SAS\n * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0\n *\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":"g5BAgCA,IAAqBA,EAArB,KAA+D,CAOtD,YACqBC,EACQC,EAClC,CACA,KAAK,WAAW,EAChB,KAAK,OAASD,EACd,KAAK,WAAaC,CACpB,CAEO,WAAWC,EAAc,CAC1B,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,YAAa,CACd,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,CAE3C,OADA,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,EChCrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA6BA,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\";\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"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xwiki/cristal-sharedworker-impl",
3
- "version": "0.8.0",
4
- "license": "AGPL-3.0",
3
+ "version": "0.9.0",
4
+ "license": "LGPL 2.1",
5
5
  "author": "XWiki Org Community <contact@xwiki.org>",
6
6
  "homepage": "https://cristal.xwiki.org/",
7
7
  "repository": {
@@ -25,24 +25,25 @@
25
25
  "dependencies": {
26
26
  "comlink": "4.4.1",
27
27
  "inversify": "6.0.2",
28
- "vue": "3.4.27",
29
- "vue-i18n": "9.13.1",
28
+ "vue": "3.4.29",
30
29
  "vue-router": "4.3.2",
31
- "@xwiki/cristal-api": "0.8.0",
32
- "@xwiki/cristal-sharedworker-api": "0.8.0",
33
- "@xwiki/cristal-storage": "0.8.0",
34
- "@xwiki/cristal-extension-manager": "0.8.0"
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"
35
37
  },
36
38
  "devDependencies": {
37
39
  "rimraf": "5.0.7",
38
- "vite": "5.2.11",
39
- "vite-plugin-comlink": "4.0.2",
40
- "vue-tsc": "2.0.19"
40
+ "vite-plugin-comlink": "4.1.0",
41
+ "vue-tsc": "2.0.21"
41
42
  },
42
43
  "scripts": {
43
44
  "build": "pnpm compile",
44
45
  "clean": "rimraf dist",
45
- "compile": "vue-tsc --project tsconfig.json --noEmit && vite build",
46
+ "compile": "vue-tsc --project tsconfig.json && vite build",
46
47
  "lint": "eslint \"./src/**/*.{ts,tsx}\" --max-warnings=0",
47
48
  "test": "echo 'no test'"
48
49
  }
@@ -1,9 +1,9 @@
1
- /**
1
+ /*
2
2
  * See the LICENSE file distributed with this work for additional
3
3
  * information regarding copyright ownership.
4
4
  *
5
5
  * This is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU Affero General Public License as
6
+ * under the terms of the GNU Lesser General Public License as
7
7
  * published by the Free Software Foundation; either version 2.1 of
8
8
  * the License, or (at your option) any later version.
9
9
  *
@@ -12,16 +12,11 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * You should have received a copy of the GNU Affero General Public
15
+ * You should have received a copy of the GNU Lesser General Public
16
16
  * License along with this software; if not, write to the Free
17
17
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
18
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
- *
20
- * This file is part of the Cristal Wiki software prototype
21
- * @copyright Copyright (c) 2023 XWiki SAS
22
- * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
23
- *
24
- **/
19
+ */
25
20
 
26
21
  import type { Container } from "inversify";
27
22
  import type { QueueWorker } from "@xwiki/cristal-sharedworker-api";
@@ -1,9 +1,9 @@
1
- /**
1
+ /*
2
2
  * See the LICENSE file distributed with this work for additional
3
3
  * information regarding copyright ownership.
4
4
  *
5
5
  * This is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU Affero General Public License as
6
+ * under the terms of the GNU Lesser General Public License as
7
7
  * published by the Free Software Foundation; either version 2.1 of
8
8
  * the License, or (at your option) any later version.
9
9
  *
@@ -12,16 +12,11 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * You should have received a copy of the GNU Affero General Public
15
+ * You should have received a copy of the GNU Lesser General Public
16
16
  * License along with this software; if not, write to the Free
17
17
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
18
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
- *
20
- * This file is part of the Cristal Wiki software prototype
21
- * @copyright Copyright (c) 2023 XWiki SAS
22
- * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
23
- *
24
- **/
19
+ */
25
20
 
26
21
  import { inject, injectable } from "inversify";
27
22
  import type { MyWorker, QueueWorker } from "@xwiki/cristal-sharedworker-api";
@@ -46,7 +41,7 @@ export default class DefaultQueueWorker implements QueueWorker {
46
41
  this.cristalApp = cristalApp;
47
42
  }
48
43
 
49
- public pageLoaded(page: string) {
44
+ public pageLoaded(page: string): void {
50
45
  try {
51
46
  this.logger.debug(
52
47
  "Received callback that new document has been loaded",
@@ -66,7 +61,7 @@ export default class DefaultQueueWorker implements QueueWorker {
66
61
  }
67
62
  }
68
63
 
69
- public initialize() {
64
+ public initialize(): void {
70
65
  try {
71
66
  if (this.workerInstance == null) {
72
67
  // this.workerInstance = new ComlinkWorker<typeof import('./worker')>(new URL('./worker',
@@ -1,9 +1,9 @@
1
- /**
1
+ /*
2
2
  * See the LICENSE file distributed with this work for additional
3
3
  * information regarding copyright ownership.
4
4
  *
5
5
  * This is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU Affero General Public License as
6
+ * under the terms of the GNU Lesser General Public License as
7
7
  * published by the Free Software Foundation; either version 2.1 of
8
8
  * the License, or (at your option) any later version.
9
9
  *
@@ -12,23 +12,21 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * You should have received a copy of the GNU Affero General Public
15
+ * You should have received a copy of the GNU Lesser General Public
16
16
  * License along with this software; if not, write to the Free
17
17
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
18
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
- *
20
- * This file is part of the Cristal Wiki software prototype
21
- * @copyright Copyright (c) 2023 XWiki SAS
22
- * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
23
- *
24
- **/
19
+ */
25
20
 
26
21
  import * as Comlink from "comlink";
27
22
  import type { MyWorker, QueueWorker } from "@xwiki/cristal-sharedworker-api";
28
23
  import type { CristalApp, WrappingStorage } from "@xwiki/cristal-api";
29
24
  import { type WikiConfig } from "@xwiki/cristal-api";
30
25
  import { CristalLoader } from "@xwiki/cristal-extension-manager";
31
- import { ComponentInit as StorageComponentInit } from "@xwiki/cristal-storage";
26
+ import { ComponentInit as DexieBackendComponentInit } from "@xwiki/cristal-backend-dexie";
27
+ import { ComponentInit as GithubBackendComponentInit } from "@xwiki/cristal-backend-github";
28
+ import { ComponentInit as NextcloudBackendComponentInit } from "@xwiki/cristal-backend-nextcloud";
29
+ import { ComponentInit as XWikiBackendComponentInit } from "@xwiki/cristal-backend-xwiki";
32
30
  import type { Container } from "inversify";
33
31
  import { WorkerCristalApp } from "./workerCristalApp";
34
32
  import WorkerQueueWorker from "./workerQueueWorker";
@@ -43,9 +41,9 @@ export class Worker implements MyWorker {
43
41
  private fct: (a: string) => void;
44
42
 
45
43
  /*
46
- Start worker thread
44
+ Start worker thread
47
45
  */
48
- public async start() {
46
+ public async start(): Promise<void> {
49
47
  console.log("Starting worker thread");
50
48
  this.initialize();
51
49
  // eslint-disable-next-line no-constant-condition
@@ -59,7 +57,7 @@ export class Worker implements MyWorker {
59
57
  this.fct = fct;
60
58
  }
61
59
 
62
- public sleep(ms: number) {
60
+ public sleep(ms: number): Promise<unknown> {
63
61
  return new Promise((resolve) => setTimeout(resolve, ms));
64
62
  }
65
63
 
@@ -184,7 +182,7 @@ export class Worker implements MyWorker {
184
182
  }
185
183
  }
186
184
 
187
- public async initialize() {
185
+ public async initialize(): Promise<void> {
188
186
  console.log("Starting initialize");
189
187
  const extensionList: Array<string> = ["storage"];
190
188
  const response = await fetch("/config.json");
@@ -206,7 +204,12 @@ export class Worker implements MyWorker {
206
204
  this.cristal = this.container.get<CristalApp>("CristalApp");
207
205
  this.cristal.setContainer(this.container);
208
206
  console.log("Container status", this.container);
209
- new StorageComponentInit(cristalLoader.container);
207
+ // TODO: find a way to do this loading differently. Here we need to
208
+ // explicitly depend on all required storage and this is not good.
209
+ new DexieBackendComponentInit(cristalLoader.container);
210
+ new GithubBackendComponentInit(cristalLoader.container);
211
+ new NextcloudBackendComponentInit(cristalLoader.container);
212
+ new XWikiBackendComponentInit(cristalLoader.container);
210
213
  console.log("Loading storage components");
211
214
  this.initialized = true;
212
215
  console.log("Finished initialize");
@@ -1,9 +1,9 @@
1
- /**
1
+ /*
2
2
  * See the LICENSE file distributed with this work for additional
3
3
  * information regarding copyright ownership.
4
4
  *
5
5
  * This is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU Affero General Public License as
6
+ * under the terms of the GNU Lesser General Public License as
7
7
  * published by the Free Software Foundation; either version 2.1 of
8
8
  * the License, or (at your option) any later version.
9
9
  *
@@ -12,16 +12,11 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * You should have received a copy of the GNU Affero General Public
15
+ * You should have received a copy of the GNU Lesser General Public
16
16
  * License along with this software; if not, write to the Free
17
17
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
18
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
- *
20
- * This file is part of the Cristal Wiki software prototype
21
- * @copyright Copyright (c) 2023 XWiki SAS
22
- * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
23
- *
24
- **/
19
+ */
25
20
 
26
21
  import type {
27
22
  CristalApp as CristalApp,
@@ -75,7 +70,7 @@ export class WorkerCristalApp implements CristalApp {
75
70
 
76
71
  // TODO remove use of any
77
72
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
- setAvailableConfigurations(config: Map<string, any>) {
73
+ setAvailableConfigurations(config: Map<string, any>): void {
79
74
  console.log(config);
80
75
  // TODO remove use of any
81
76
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -1,9 +1,9 @@
1
- /**
1
+ /*
2
2
  * See the LICENSE file distributed with this work for additional
3
3
  * information regarding copyright ownership.
4
4
  *
5
5
  * This is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU Affero General Public License as
6
+ * under the terms of the GNU Lesser General Public License as
7
7
  * published by the Free Software Foundation; either version 2.1 of
8
8
  * the License, or (at your option) any later version.
9
9
  *
@@ -12,16 +12,11 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * You should have received a copy of the GNU Affero General Public
15
+ * You should have received a copy of the GNU Lesser General Public
16
16
  * License along with this software; if not, write to the Free
17
17
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
18
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
- *
20
- * This file is part of the Cristal Wiki software prototype
21
- * @copyright Copyright (c) 2023 XWiki SAS
22
- * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
23
- *
24
- **/
19
+ */
25
20
 
26
21
  import { injectable } from "inversify";
27
22
  import type { QueueWorker } from "@xwiki/cristal-sharedworker-api";
@@ -32,7 +27,7 @@ export default class WorkerQueueWorker implements QueueWorker {
32
27
  this.initialize();
33
28
  }
34
29
 
35
- public initialize() {}
30
+ public initialize(): void {}
36
31
 
37
32
  public getStatus(): boolean {
38
33
  return true;
package/src/index.ts CHANGED
@@ -1,9 +1,9 @@
1
- /**
1
+ /*
2
2
  * See the LICENSE file distributed with this work for additional
3
3
  * information regarding copyright ownership.
4
4
  *
5
5
  * This is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU Affero General Public License as
6
+ * under the terms of the GNU Lesser General Public License as
7
7
  * published by the Free Software Foundation; either version 2.1 of
8
8
  * the License, or (at your option) any later version.
9
9
  *
@@ -12,16 +12,11 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * You should have received a copy of the GNU Affero General Public
15
+ * You should have received a copy of the GNU Lesser General Public
16
16
  * License along with this software; if not, write to the Free
17
17
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
18
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
- *
20
- * This file is part of the Cristal Wiki software prototype
21
- * @copyright Copyright (c) 2023 XWiki SAS
22
- * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
23
- *
24
- **/
19
+ */
25
20
 
26
21
  import ComponentInit from "./components/componentsInit";
27
22
  import type { QueueWorker } from "@xwiki/cristal-sharedworker-api";
package/src/vite-env.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- /**
1
+ /*
2
2
  * See the LICENSE file distributed with this work for additional
3
3
  * information regarding copyright ownership.
4
4
  *
5
5
  * This is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU Affero General Public License as
6
+ * under the terms of the GNU Lesser General Public License as
7
7
  * published by the Free Software Foundation; either version 2.1 of
8
8
  * the License, or (at your option) any later version.
9
9
  *
@@ -12,16 +12,11 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * You should have received a copy of the GNU Affero General Public
15
+ * You should have received a copy of the GNU Lesser General Public
16
16
  * License along with this software; if not, write to the Free
17
17
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
18
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
- *
20
- * This file is part of the Cristal Wiki software prototype
21
- * @copyright Copyright (c) 2023 XWiki SAS
22
- * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
23
- *
24
- **/
19
+ */
25
20
 
26
21
  /// <reference types="vite-plugin-comlink/client" />
27
- // eslint-disable-line
22
+ // eslint-disable-line
package/src/vue.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- /**
1
+ /*
2
2
  * See the LICENSE file distributed with this work for additional
3
3
  * information regarding copyright ownership.
4
4
  *
5
5
  * This is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU Affero General Public License as
6
+ * under the terms of the GNU Lesser General Public License as
7
7
  * published by the Free Software Foundation; either version 2.1 of
8
8
  * the License, or (at your option) any later version.
9
9
  *
@@ -12,16 +12,11 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * You should have received a copy of the GNU Affero General Public
15
+ * You should have received a copy of the GNU Lesser General Public
16
16
  * License along with this software; if not, write to the Free
17
17
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
18
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
- *
20
- * This file is part of the Cristal Wiki software prototype
21
- * @copyright Copyright (c) 2023 XWiki SAS
22
- * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
23
- *
24
- **/
19
+ */
25
20
 
26
21
  // vue.d.ts
27
22
  declare module "*.vue" {
package/vite-env.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- /**
1
+ /*
2
2
  * See the LICENSE file distributed with this work for additional
3
3
  * information regarding copyright ownership.
4
4
  *
5
5
  * This is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU Affero General Public License as
6
+ * under the terms of the GNU Lesser General Public License as
7
7
  * published by the Free Software Foundation; either version 2.1 of
8
8
  * the License, or (at your option) any later version.
9
9
  *
@@ -12,15 +12,10 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * You should have received a copy of the GNU Affero General Public
15
+ * You should have received a copy of the GNU Lesser General Public
16
16
  * License along with this software; if not, write to the Free
17
17
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
18
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
- *
20
- * This file is part of the Cristal Wiki software prototype
21
- * @copyright Copyright (c) 2023 XWiki SAS
22
- * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
23
- *
24
- **/
19
+ */
25
20
 
26
21
  /// <reference types="vite-plugin-comlink/client" />
package/vite.config.ts CHANGED
@@ -1,9 +1,9 @@
1
- /**
1
+ /*
2
2
  * See the LICENSE file distributed with this work for additional
3
3
  * information regarding copyright ownership.
4
4
  *
5
5
  * This is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU Affero General Public License as
6
+ * under the terms of the GNU Lesser General Public License as
7
7
  * published by the Free Software Foundation; either version 2.1 of
8
8
  * the License, or (at your option) any later version.
9
9
  *
@@ -12,16 +12,11 @@
12
12
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
  * Lesser General Public License for more details.
14
14
  *
15
- * You should have received a copy of the GNU Affero General Public
15
+ * You should have received a copy of the GNU Lesser General Public
16
16
  * License along with this software; if not, write to the Free
17
17
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18
18
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19
- *
20
- * This file is part of the Cristal Wiki software prototype
21
- * @copyright Copyright (c) 2023 XWiki SAS
22
- * @license http://opensource.org/licenses/AGPL-3.0 AGPL-3.0
23
- *
24
- **/
19
+ */
25
20
 
26
21
  import { generateConfig } from "../../vite.config";
27
22
  import { mergeConfig, defineConfig } from "vite";