@xwiki/cristal-sharedworker-impl 0.12.0 → 0.14.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/CHANGELOG.md +41 -0
- package/dist/assets/index-4G1wem5g.js +7 -0
- package/dist/assets/index-4G1wem5g.js.map +1 -0
- package/dist/assets/index-CmyDNOMI.js +7 -0
- package/dist/assets/index-CmyDNOMI.js.map +1 -0
- package/dist/assets/worker-BhIfpacL.js +9530 -0
- package/dist/assets/worker-BhIfpacL.js.map +1 -0
- package/dist/components/workerCristalApp.d.ts +2 -1
- package/dist/index.es.js +6 -5
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +25 -17
- package/src/components/defaultQueueWorker.ts +5 -2
- package/src/components/worker.ts +47 -6
- package/src/components/workerCristalApp.ts +24 -11
- package/tsconfig.json +17 -8
- package/vite.config.ts +2 -1
- package/vitest.config.ts +25 -0
- package/dist/assets/worker-ZwjuRGo7.js +0 -46
- package/dist/assets/worker-ZwjuRGo7.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Configurations } from '@xwiki/cristal-configuration-api';
|
|
1
2
|
import { CristalApp as CristalApp, Logger, LoggerConfig, PageData, SkinManager, WikiConfig } from '@xwiki/cristal-api';
|
|
2
3
|
import { Container } from 'inversify';
|
|
3
4
|
import { App, Component } from 'vue';
|
|
@@ -15,7 +16,7 @@ export declare class WorkerCristalApp implements CristalApp {
|
|
|
15
16
|
setWikiConfig(wikiConfig: WikiConfig): void;
|
|
16
17
|
getSkinManager(): SkinManager;
|
|
17
18
|
switchConfig(): void;
|
|
18
|
-
setAvailableConfigurations(
|
|
19
|
+
setAvailableConfigurations(configs: Configurations): void;
|
|
19
20
|
getAvailableConfigurations(): Map<string, WikiConfig>;
|
|
20
21
|
run(): Promise<void>;
|
|
21
22
|
getUIXTemplates(): Component[];
|
package/dist/index.es.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { name as d } from "@xwiki/cristal-document-api";
|
|
2
2
|
import * as i from "comlink";
|
|
3
|
-
import { injectable as
|
|
3
|
+
import { injectable as h, inject as c } from "inversify";
|
|
4
4
|
function g(e) {
|
|
5
5
|
return new SharedWorker(
|
|
6
|
-
"/assets/worker-
|
|
6
|
+
"/assets/worker-BhIfpacL.js",
|
|
7
7
|
{
|
|
8
|
+
type: "module",
|
|
8
9
|
name: e == null ? void 0 : e.name
|
|
9
10
|
}
|
|
10
11
|
);
|
|
11
12
|
}
|
|
12
|
-
var
|
|
13
|
+
var w = Object.defineProperty, k = Object.getOwnPropertyDescriptor, m = (e, r, t, o) => {
|
|
13
14
|
for (var n = o > 1 ? void 0 : o ? k(r, t) : r, a = e.length - 1, s; a >= 0; a--)
|
|
14
15
|
(s = e[a]) && (n = (o ? s(r, t, n) : s(n)) || n);
|
|
15
|
-
return o && n &&
|
|
16
|
+
return o && n && w(r, t, n), n;
|
|
16
17
|
}, u = (e, r) => (t, o) => r(t, o, e);
|
|
17
18
|
let l = class {
|
|
18
19
|
constructor(e, r) {
|
|
@@ -69,7 +70,7 @@ let l = class {
|
|
|
69
70
|
}
|
|
70
71
|
};
|
|
71
72
|
l = m([
|
|
72
|
-
|
|
73
|
+
h(),
|
|
73
74
|
u(0, c("Logger")),
|
|
74
75
|
u(1, c("CristalApp"))
|
|
75
76
|
], l);
|
package/dist/index.es.js.map
CHANGED
|
@@ -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 Worker from \"./worker?sharedworker\";\nimport { name as documentServiceName } from \"@xwiki/cristal-document-api\";\nimport * as Comlink from \"comlink\";\nimport { inject, injectable } from \"inversify\";\nimport type { CristalApp, Logger } from \"@xwiki/cristal-api\";\nimport type { DocumentService } from \"@xwiki/cristal-document-api\";\nimport type { MyWorker, QueueWorker } from \"@xwiki/cristal-sharedworker-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 DefaultQueueWorker from \"./defaultQueueWorker\";\nimport type { QueueWorker } from \"@xwiki/cristal-sharedworker-api\";\nimport type { Container } from \"inversify\";\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":"
|
|
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 Worker from \"./worker?sharedworker\";\nimport { name as documentServiceName } from \"@xwiki/cristal-document-api\";\nimport * as Comlink from \"comlink\";\nimport { inject, injectable } from \"inversify\";\nimport type { CristalApp, Logger } from \"@xwiki/cristal-api\";\nimport type { DocumentService } from \"@xwiki/cristal-document-api\";\nimport type { MyWorker, QueueWorker } from \"@xwiki/cristal-sharedworker-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) {\n return -1;\n } else {\n return await this.workerInstance.getQueueSize();\n }\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 DefaultQueueWorker from \"./defaultQueueWorker\";\nimport type { QueueWorker } from \"@xwiki/cristal-sharedworker-api\";\nimport type { Container } from \"inversify\";\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":";;;;;;;;;;;;;;;;;AA6BA,IAAqBA,IAArB,MAA+D;AAAA,EAOtD,YACqBC,GACQC,GAClC;AACA,SAAK,WAAW,GAChB,KAAK,SAASD,GACd,KAAK,aAAaC;AAAA,EAAA;AAAA,EAGb,WAAWC,GAAoB;AAChC,QAAA;AACF,WAAK,OAAO;AAAA,QACV;AAAA,QACAA;AAAA,MACF,GAGwB,KAAK,WAC1B,aAAa,EACb,IAAqBC,CAAmB,EAC3B,uBAAuB,GAEvC,KAAK,OAAO;AAAA,QACV;AAAA,QACAD;AAAA,MACF;AAAA,aACOE,GAAG;AACL,WAAA,OAAO,MAAM,0BAA0BA,CAAC;AAAA,IAAA;AAAA,EAC/C;AAAA,EAGK,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,UACrB,CAAA;AAAA,QACH,GAEQ,QAAA,MAAM,sBAAsB,KAAK,cAAc;AAAA,MAAA;AAEvD,gBAAQ,MAAM,qBAAqB;AAAA,aAE9B,GAAG;AACF,cAAA,MAAM,sCAAsC,CAAC;AAAA,IAAA;AAAA,EACvD;AAAA,EAGK,YAAqB;AACtB,WAAA,KAAK,kBAAkB,QACzB,QAAQ,IAAI,yBAAyB,GAC9B,OAEP,QAAQ,IAAI,qCAAqC,GAC1C;AAAA,EACT;AAAA,EAGF,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,IAAA;AAAA,EACT;AAAA,EAGF,MAAa,WAAWP,GAA6B;AAC3C,YAAA,IAAI,6BAA6BA,CAAI,GACzC,KAAK,kBAAkB,OACnB,MAAA,KAAK,eAAe,WAAWA,CAAI,IAEzC,QAAQ,IAAI,qCAAqC;AAAA,EACnD;AAAA,EAGF,MAAa,eAAgC;AAEvC,WADJ,QAAQ,IAAI,6BAA6B,GACrC,KAAK,kBAAkB,OAClB,KAEA,MAAM,KAAK,eAAe,aAAa;AAAA,EAChD;AAEJ;AAvGqBH,IAArBW,EAAA;AAAA,EADCC,EAAW;AAAA,EASPC,OAAe,QAAQ,CAAA;AAAA,EACvBA,OAAmB,YAAY,CAAA;AAAA,GATfb,CAAA;ACLrB,MAAqBc,EAAc;AAAA,EACjC,YAAYC,GAAsB;AAChC,IAAAA,EAAU,KAAkB,aAAa,EAAE,GAAGf,CAAkB;AAAA,EAAA;AAEpE;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(n,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@xwiki/cristal-document-api"),require("comlink"),require("inversify")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-document-api","comlink","inversify"],a):(n=typeof globalThis<"u"?globalThis:n||self,a(n.cristal_impl={},n.cristalDocumentApi,n.Comlink,n.inversify))})(this,function(n,a,g,s){"use strict";function
|
|
1
|
+
(function(n,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("@xwiki/cristal-document-api"),require("comlink"),require("inversify")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-document-api","comlink","inversify"],a):(n=typeof globalThis<"u"?globalThis:n||self,a(n.cristal_impl={},n.cristalDocumentApi,n.Comlink,n.inversify))})(this,function(n,a,g,s){"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 d=h(g);function w(e){return new SharedWorker("/assets/worker-BhIfpacL.js",{type:"module",name:e==null?void 0:e.name})}var p=Object.defineProperty,k=Object.getOwnPropertyDescriptor,m=(e,r,t,o)=>{for(var i=o>1?void 0:o?k(r,t):r,c=e.length-1,u;c>=0;c--)(u=e[c])&&(i=(o?u(r,t,i):u(i))||i);return o&&i&&p(r,t,i),i},f=(e,r)=>(t,o)=>r(t,o,e);let l=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(a.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=d.wrap(e.port);const r=this;this.workerInstance.setPageLoadedCallback(d.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()}};l=m([s.injectable(),f(0,s.inject("Logger")),f(1,s.inject("CristalApp"))],l);class b{constructor(r){r.bind("QueueWorker").to(l)}}n.ComponentInit=b,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -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 Worker from \"./worker?sharedworker\";\nimport { name as documentServiceName } from \"@xwiki/cristal-document-api\";\nimport * as Comlink from \"comlink\";\nimport { inject, injectable } from \"inversify\";\nimport type { CristalApp, Logger } from \"@xwiki/cristal-api\";\nimport type { DocumentService } from \"@xwiki/cristal-document-api\";\nimport type { MyWorker, QueueWorker } from \"@xwiki/cristal-sharedworker-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 DefaultQueueWorker from \"./defaultQueueWorker\";\nimport type { QueueWorker } from \"@xwiki/cristal-sharedworker-api\";\nimport type { Container } from \"inversify\";\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":"
|
|
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 Worker from \"./worker?sharedworker\";\nimport { name as documentServiceName } from \"@xwiki/cristal-document-api\";\nimport * as Comlink from \"comlink\";\nimport { inject, injectable } from \"inversify\";\nimport type { CristalApp, Logger } from \"@xwiki/cristal-api\";\nimport type { DocumentService } from \"@xwiki/cristal-document-api\";\nimport type { MyWorker, QueueWorker } from \"@xwiki/cristal-sharedworker-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) {\n return -1;\n } else {\n return await this.workerInstance.getQueueSize();\n }\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 DefaultQueueWorker from \"./defaultQueueWorker\";\nimport type { QueueWorker } from \"@xwiki/cristal-sharedworker-api\";\nimport type { Container } from \"inversify\";\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":"0/BA6BA,IAAqBA,EAArB,KAA+D,CAOtD,YACqBC,EACQC,EAClC,CACA,KAAK,WAAW,EAChB,KAAK,OAASD,EACd,KAAK,WAAaC,CAAA,CAGb,WAAWC,EAAoB,CAChC,GAAA,CACF,KAAK,OAAO,MACV,sDACAA,CACF,EAGwB,KAAK,WAC1B,aAAa,EACb,IAAqBC,MAAmB,EAC3B,uBAAuB,EAEvC,KAAK,OAAO,MACV,kDACAD,CACF,QACOE,EAAG,CACL,KAAA,OAAO,MAAM,yBAA0BA,CAAC,CAAA,CAC/C,CAGK,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,CACrB,CAAA,CACH,EAEQ,QAAA,MAAM,qBAAsB,KAAK,cAAc,CAAA,MAEvD,QAAQ,MAAM,qBAAqB,QAE9B,EAAG,CACF,QAAA,MAAM,qCAAsC,CAAC,CAAA,CACvD,CAGK,WAAqB,CACtB,OAAA,KAAK,gBAAkB,MACzB,QAAQ,IAAI,yBAAyB,EAC9B,KAEP,QAAQ,IAAI,qCAAqC,EAC1C,GACT,CAGF,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,CAAA,CACT,CAGF,MAAa,WAAWP,EAA6B,CAC3C,QAAA,IAAI,4BAA6BA,CAAI,EACzC,KAAK,gBAAkB,KACnB,MAAA,KAAK,eAAe,WAAWA,CAAI,EAEzC,QAAQ,IAAI,qCAAqC,CACnD,CAGF,MAAa,cAAgC,CAEvC,OADJ,QAAQ,IAAI,6BAA6B,EACrC,KAAK,gBAAkB,KAClB,GAEA,MAAM,KAAK,eAAe,aAAa,CAChD,CAEJ,EAvGqBH,EAArBW,EAAA,CADCC,aAAW,EASPC,aAAe,QAAQ,CAAA,EACvBA,aAAmB,YAAY,CAAA,CAAA,EATfb,CAAA,ECLrB,MAAqBc,CAAc,CACjC,YAAYC,EAAsB,CAChCA,EAAU,KAAkB,aAAa,EAAE,GAAGf,CAAkB,CAAA,CAEpE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xwiki/cristal-sharedworker-impl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"license": "LGPL 2.1",
|
|
5
5
|
"author": "XWiki Org Community <contact@xwiki.org>",
|
|
6
6
|
"homepage": "https://cristal.xwiki.org/",
|
|
@@ -23,28 +23,36 @@
|
|
|
23
23
|
"main": "./dist/index.es.js",
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"comlink": "4.4.
|
|
27
|
-
"inversify": "6.
|
|
28
|
-
"
|
|
29
|
-
"vue
|
|
30
|
-
"
|
|
31
|
-
"@xwiki/cristal-
|
|
32
|
-
"@xwiki/cristal-
|
|
33
|
-
"@xwiki/cristal-
|
|
34
|
-
"@xwiki/cristal-
|
|
35
|
-
"@xwiki/cristal-
|
|
36
|
-
"@xwiki/cristal-
|
|
37
|
-
"@xwiki/cristal-
|
|
38
|
-
"@xwiki/cristal-
|
|
26
|
+
"comlink": "4.4.2",
|
|
27
|
+
"inversify": "6.2.1",
|
|
28
|
+
"reflect-metadata": "0.2.2",
|
|
29
|
+
"vue": "3.5.13",
|
|
30
|
+
"vue-router": "4.5.0",
|
|
31
|
+
"@xwiki/cristal-alerts-default": "0.14.0",
|
|
32
|
+
"@xwiki/cristal-api": "0.14.0",
|
|
33
|
+
"@xwiki/cristal-backend-dexie": "0.14.0",
|
|
34
|
+
"@xwiki/cristal-authentication-default": "0.14.0",
|
|
35
|
+
"@xwiki/cristal-backend-nextcloud": "0.14.0",
|
|
36
|
+
"@xwiki/cristal-configuration-api": "0.14.0",
|
|
37
|
+
"@xwiki/cristal-backend-xwiki": "0.14.0",
|
|
38
|
+
"@xwiki/cristal-configuration-electron-renderer": "0.14.0",
|
|
39
|
+
"@xwiki/cristal-configuration-web": "0.14.0",
|
|
40
|
+
"@xwiki/cristal-document-api": "0.14.0",
|
|
41
|
+
"@xwiki/cristal-sharedworker-api": "0.14.0",
|
|
42
|
+
"@xwiki/cristal-extension-manager": "0.14.0"
|
|
39
43
|
},
|
|
40
44
|
"devDependencies": {
|
|
41
|
-
"
|
|
42
|
-
"
|
|
45
|
+
"typescript": "5.7.3",
|
|
46
|
+
"vite": "6.0.11",
|
|
47
|
+
"vite-plugin-comlink": "5.1.0",
|
|
48
|
+
"vue-tsc": "2.2.0",
|
|
49
|
+
"@xwiki/cristal-dev-config": "0.14.0"
|
|
43
50
|
},
|
|
44
51
|
"scripts": {
|
|
45
52
|
"build": "pnpm compile",
|
|
46
53
|
"clean": "rimraf dist",
|
|
47
54
|
"compile": "vue-tsc --project tsconfig.json && vite build",
|
|
48
|
-
"lint": "eslint \"./src/**/*.{ts,tsx}\" --max-warnings=0"
|
|
55
|
+
"lint": "eslint \"./src/**/*.{ts,tsx,vue}\" --max-warnings=0",
|
|
56
|
+
"test": "vitest --run"
|
|
49
57
|
}
|
|
50
58
|
}
|
|
@@ -124,7 +124,10 @@ export default class DefaultQueueWorker implements QueueWorker {
|
|
|
124
124
|
|
|
125
125
|
public async getQueueSize(): Promise<number> {
|
|
126
126
|
console.log("worker Calling getQueueSize");
|
|
127
|
-
if (this.workerInstance == null)
|
|
128
|
-
|
|
127
|
+
if (this.workerInstance == null) {
|
|
128
|
+
return -1;
|
|
129
|
+
} else {
|
|
130
|
+
return await this.workerInstance.getQueueSize();
|
|
131
|
+
}
|
|
129
132
|
}
|
|
130
133
|
}
|
package/src/components/worker.ts
CHANGED
|
@@ -18,20 +18,56 @@
|
|
|
18
18
|
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
import "reflect-metadata";
|
|
21
22
|
import { WorkerCristalApp } from "./workerCristalApp";
|
|
22
23
|
import WorkerQueueWorker from "./workerQueueWorker";
|
|
24
|
+
import { ComponentInit as AlertsDefaultComponentInit } from "@xwiki/cristal-alerts-default";
|
|
23
25
|
import { CristalApp, WrappingStorage } from "@xwiki/cristal-api";
|
|
24
|
-
import { ComponentInit as
|
|
26
|
+
import { ComponentInit as AuthenticationDefaultComponentInit } from "@xwiki/cristal-authentication-default";
|
|
25
27
|
import { ComponentInit as DexieBackendComponentInit } from "@xwiki/cristal-backend-dexie";
|
|
26
|
-
import { ComponentInit as GithubBackendComponentInit } from "@xwiki/cristal-backend-github";
|
|
27
28
|
import { ComponentInit as NextcloudBackendComponentInit } from "@xwiki/cristal-backend-nextcloud";
|
|
28
29
|
import { ComponentInit as XWikiBackendComponentInit } from "@xwiki/cristal-backend-xwiki";
|
|
30
|
+
import {
|
|
31
|
+
ConfigurationLoader,
|
|
32
|
+
Configurations,
|
|
33
|
+
} from "@xwiki/cristal-configuration-api";
|
|
29
34
|
import { CristalLoader } from "@xwiki/cristal-extension-manager";
|
|
30
35
|
import * as Comlink from "comlink";
|
|
31
36
|
import type { WikiConfig } from "@xwiki/cristal-api";
|
|
32
37
|
import type { MyWorker, QueueWorker } from "@xwiki/cristal-sharedworker-api";
|
|
33
38
|
import type { Container } from "inversify";
|
|
34
39
|
|
|
40
|
+
async function loadConfigElectron() {
|
|
41
|
+
const loadConfig: ConfigurationLoader = (
|
|
42
|
+
await import("@xwiki/cristal-configuration-electron-renderer")
|
|
43
|
+
).loadConfig;
|
|
44
|
+
return await loadConfig();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function loadConfigWeb() {
|
|
48
|
+
const loadConfig: ConfigurationLoader = (
|
|
49
|
+
await import("@xwiki/cristal-configuration-web")
|
|
50
|
+
).loadConfig("/config.json");
|
|
51
|
+
return await loadConfig();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Currently, the best know option is to search for a process value at runtime and to decide how to load the
|
|
56
|
+
* configuration based on this information.
|
|
57
|
+
*/
|
|
58
|
+
async function loadConfig(): Promise<Configurations> {
|
|
59
|
+
try {
|
|
60
|
+
// @ts-expect-error process is not a known variable and might not be defined
|
|
61
|
+
if (process && process.versions && process.versions["electron"]) {
|
|
62
|
+
return await loadConfigElectron();
|
|
63
|
+
} else {
|
|
64
|
+
return await loadConfigWeb();
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
return await loadConfigWeb();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
35
71
|
export class Worker implements MyWorker {
|
|
36
72
|
private currentNumber: number = 0;
|
|
37
73
|
private queue: Array<string> = [];
|
|
@@ -88,6 +124,8 @@ export class Worker implements MyWorker {
|
|
|
88
124
|
}
|
|
89
125
|
}
|
|
90
126
|
|
|
127
|
+
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
|
|
128
|
+
// eslint-disable-next-line max-statements
|
|
91
129
|
public async handleQueueItem(page: string): Promise<void> {
|
|
92
130
|
console.log("Handling queue item code ready to process", page);
|
|
93
131
|
|
|
@@ -141,6 +179,8 @@ export class Worker implements MyWorker {
|
|
|
141
179
|
return this.queue.length;
|
|
142
180
|
}
|
|
143
181
|
|
|
182
|
+
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
|
|
183
|
+
// eslint-disable-next-line max-statements
|
|
144
184
|
public getWikiConfig(configName: string): WikiConfig | undefined {
|
|
145
185
|
const wikiConfigObject = this.configMap.get(configName);
|
|
146
186
|
if (wikiConfigObject == null) {
|
|
@@ -190,11 +230,12 @@ export class Worker implements MyWorker {
|
|
|
190
230
|
}
|
|
191
231
|
}
|
|
192
232
|
|
|
233
|
+
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
|
|
234
|
+
// eslint-disable-next-line max-statements
|
|
193
235
|
public async initialize(): Promise<void> {
|
|
194
236
|
console.log("Starting initialize");
|
|
195
237
|
const extensionList: Array<string> = ["storage"];
|
|
196
|
-
const
|
|
197
|
-
const config = await response.json();
|
|
238
|
+
const config = await loadConfig();
|
|
198
239
|
this.configMap = new Map(Object.entries(config));
|
|
199
240
|
console.log("Loaded json config", this.configMap);
|
|
200
241
|
const cristalLoader = new CristalLoader(extensionList);
|
|
@@ -215,10 +256,10 @@ export class Worker implements MyWorker {
|
|
|
215
256
|
// TODO: find a way to do this loading differently. Here we need to
|
|
216
257
|
// explicitly depend on all required storage and this is not good.
|
|
217
258
|
new DexieBackendComponentInit(cristalLoader.container);
|
|
218
|
-
new GithubBackendComponentInit(cristalLoader.container);
|
|
219
259
|
new NextcloudBackendComponentInit(cristalLoader.container);
|
|
220
260
|
new XWikiBackendComponentInit(cristalLoader.container);
|
|
221
|
-
new
|
|
261
|
+
new AuthenticationDefaultComponentInit(cristalLoader.container);
|
|
262
|
+
new AlertsDefaultComponentInit(cristalLoader.container);
|
|
222
263
|
console.log("Loading storage components");
|
|
223
264
|
this.initialized = true;
|
|
224
265
|
console.log("Finished initialize");
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
import { DefaultLogger } from "@xwiki/cristal-api";
|
|
22
|
+
import { Configurations } from "@xwiki/cristal-configuration-api";
|
|
21
23
|
import { injectable } from "inversify";
|
|
22
24
|
import type {
|
|
23
25
|
CristalApp as CristalApp,
|
|
@@ -48,9 +50,11 @@ export class WorkerCristalApp implements CristalApp {
|
|
|
48
50
|
getApp(): App {
|
|
49
51
|
throw new Error("Method not implemented.");
|
|
50
52
|
}
|
|
53
|
+
|
|
51
54
|
getRouter(): Router {
|
|
52
55
|
throw new Error("Method not implemented.");
|
|
53
56
|
}
|
|
57
|
+
|
|
54
58
|
getContainer(): Container {
|
|
55
59
|
return this.container;
|
|
56
60
|
}
|
|
@@ -62,6 +66,7 @@ export class WorkerCristalApp implements CristalApp {
|
|
|
62
66
|
getWikiConfig(): WikiConfig {
|
|
63
67
|
return this.wikiConfig;
|
|
64
68
|
}
|
|
69
|
+
|
|
65
70
|
setWikiConfig(wikiConfig: WikiConfig): void {
|
|
66
71
|
this.wikiConfig = wikiConfig;
|
|
67
72
|
}
|
|
@@ -72,24 +77,19 @@ export class WorkerCristalApp implements CristalApp {
|
|
|
72
77
|
|
|
73
78
|
switchConfig(): void {}
|
|
74
79
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
console.log(config);
|
|
79
|
-
// TODO remove use of any
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
-
config.forEach((wikiConfigObject: any, key: string) => {
|
|
80
|
+
setAvailableConfigurations(configs: Configurations): void {
|
|
81
|
+
for (const configKey in configs) {
|
|
82
|
+
const wikiConfigObject = configs[configKey];
|
|
82
83
|
const configType = wikiConfigObject?.configType;
|
|
83
|
-
|
|
84
84
|
if (wikiConfigObject) {
|
|
85
85
|
const wikiConfig = this.container.getNamed<WikiConfig>(
|
|
86
86
|
"WikiConfig",
|
|
87
87
|
configType,
|
|
88
88
|
);
|
|
89
89
|
wikiConfig.setConfigFromObject(wikiConfigObject);
|
|
90
|
-
this.availableConfigurations.set(
|
|
90
|
+
this.availableConfigurations.set(configKey, wikiConfig);
|
|
91
91
|
}
|
|
92
|
-
}
|
|
92
|
+
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
getAvailableConfigurations(): Map<string, WikiConfig> {
|
|
@@ -99,42 +99,55 @@ export class WorkerCristalApp implements CristalApp {
|
|
|
99
99
|
run(): Promise<void> {
|
|
100
100
|
throw new Error("Method not implemented.");
|
|
101
101
|
}
|
|
102
|
+
|
|
102
103
|
getUIXTemplates(): Component[] {
|
|
103
104
|
throw new Error("Method not implemented.");
|
|
104
105
|
}
|
|
106
|
+
|
|
105
107
|
getMenuEntries(): string[] {
|
|
106
108
|
throw new Error("Method not implemented.");
|
|
107
109
|
}
|
|
110
|
+
|
|
108
111
|
getCurrentPage(): string {
|
|
109
112
|
throw new Error("Method not implemented.");
|
|
110
113
|
}
|
|
114
|
+
|
|
111
115
|
getCurrentContent(): string {
|
|
112
116
|
throw new Error("Method not implemented.");
|
|
113
117
|
}
|
|
118
|
+
|
|
114
119
|
getCurrentSource(): string {
|
|
115
120
|
throw new Error("Method not implemented.");
|
|
116
121
|
}
|
|
122
|
+
|
|
117
123
|
getCurrentSyntax(): string {
|
|
118
124
|
throw new Error("Method not implemented.");
|
|
119
125
|
}
|
|
126
|
+
|
|
120
127
|
setCurrentPage(): void {
|
|
121
128
|
throw new Error("Method not implemented.");
|
|
122
129
|
}
|
|
130
|
+
|
|
123
131
|
setContentRef(): void {
|
|
124
132
|
throw new Error("Method not implemented.");
|
|
125
133
|
}
|
|
134
|
+
|
|
126
135
|
loadPageFromURL(): Promise<void> {
|
|
127
136
|
throw new Error("Method not implemented.");
|
|
128
137
|
}
|
|
138
|
+
|
|
129
139
|
loadPage(): Promise<void> {
|
|
130
140
|
throw new Error("Method not implemented.");
|
|
131
141
|
}
|
|
142
|
+
|
|
132
143
|
getPage(): Promise<PageData> {
|
|
133
144
|
throw new Error("Method not implemented.");
|
|
134
145
|
}
|
|
146
|
+
|
|
135
147
|
getLogger(): Logger {
|
|
136
|
-
|
|
148
|
+
return new DefaultLogger();
|
|
137
149
|
}
|
|
150
|
+
|
|
138
151
|
getLoggerConfig(): LoggerConfig {
|
|
139
152
|
throw new Error("Method not implemented.");
|
|
140
153
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "src",
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"resolveJsonModule": true,
|
|
6
|
+
"types": [
|
|
7
|
+
"vite/client"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"extends": "./../../tsconfig.json",
|
|
11
|
+
"include": [
|
|
12
|
+
"./src/index.ts",
|
|
13
|
+
"./src/**/*"
|
|
14
|
+
],
|
|
15
|
+
"exclude": [
|
|
16
|
+
"**/*.spec.ts",
|
|
17
|
+
"**/*.test.ts"
|
|
18
|
+
]
|
|
10
19
|
}
|
package/vite.config.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { generateConfig } from "../../vite.config";
|
|
22
|
-
import {
|
|
22
|
+
import { defineConfig, mergeConfig } from "vite";
|
|
23
23
|
import comlink from "vite-plugin-comlink";
|
|
24
24
|
|
|
25
25
|
export default mergeConfig(
|
|
@@ -27,6 +27,7 @@ export default mergeConfig(
|
|
|
27
27
|
defineConfig({
|
|
28
28
|
plugins: [comlink()],
|
|
29
29
|
worker: {
|
|
30
|
+
format: "es",
|
|
30
31
|
plugins: () => [comlink()],
|
|
31
32
|
},
|
|
32
33
|
}),
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
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 Lesser 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 Lesser 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
|
+
|
|
21
|
+
import localConfig from "./vite.config";
|
|
22
|
+
import { mergeConfig } from "vitest/config";
|
|
23
|
+
import defaultConfig from "@xwiki/cristal-dev-config/vitest-vue.config";
|
|
24
|
+
|
|
25
|
+
export default mergeConfig(defaultConfig, localConfig);
|