@xwiki/cristal-sharedworker-impl 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,7 @@
1
1
  import { Container } from 'inversify';
2
+ /**
3
+ * @beta
4
+ */
2
5
  export default class ComponentInit {
3
6
  constructor(container: Container);
4
7
  }
@@ -1,5 +1,5 @@
1
+ import { CristalApp, Logger, LoggerConfig, PageData, SkinManager, WikiConfig } from '@xwiki/cristal-api';
1
2
  import { Configurations } from '@xwiki/cristal-configuration-api';
2
- import { CristalApp as CristalApp, Logger, LoggerConfig, PageData, SkinManager, WikiConfig } from '@xwiki/cristal-api';
3
3
  import { Container } from 'inversify';
4
4
  import { App, Component } from 'vue';
5
5
  import { Router } from 'vue-router';
@@ -33,5 +33,4 @@ export declare class WorkerCristalApp implements CristalApp {
33
33
  getPage(): Promise<PageData>;
34
34
  getLogger(): Logger;
35
35
  getLoggerConfig(): LoggerConfig;
36
- renderContent(): Promise<string>;
37
36
  }
package/dist/index.es.js CHANGED
@@ -1,232 +1,59 @@
1
- import { name as Q } from "@xwiki/cristal-document-api";
2
- import * as $ from "comlink";
3
- function T(n) {
1
+ import { name as d } from "@xwiki/cristal-document-api";
2
+ import * as i from "comlink";
3
+ import { injectable as g, inject as c } from "inversify";
4
+ function w(e) {
4
5
  return new SharedWorker(
5
- "/assets/worker-D5o17ttR.js",
6
+ "/assets/worker-Cd03GOHu.js",
6
7
  {
7
8
  type: "module",
8
- name: n?.name
9
+ name: e?.name
9
10
  }
10
11
  );
11
12
  }
12
- function b(n, e, t) {
13
- return Reflect.getOwnMetadata(e, n, t);
14
- }
15
- function E(n, e, t, r) {
16
- Reflect.defineMetadata(e, t, n, r);
17
- }
18
- function g(n, e, t, r, i) {
19
- const o = r(b(n, e, i) ?? t());
20
- Reflect.defineMetadata(e, o, n, i);
21
- }
22
- var S, M, x;
23
- (function(n) {
24
- n.moduleId = "moduleId", n.serviceId = "serviceId";
25
- })(S || (S = {}));
26
- (function(n) {
27
- n.id = "id", n.moduleId = "moduleId", n.serviceId = "serviceId";
28
- })(M || (M = {}));
29
- (function(n) {
30
- n.moduleId = "moduleId", n.serviceId = "serviceId";
31
- })(x || (x = {}));
32
- const w = "@inversifyjs/core/classMetadataReflectKey";
33
- function k() {
34
- return { constructorArguments: [], lifecycle: { postConstructMethodName: void 0, preDestroyMethodName: void 0 }, properties: /* @__PURE__ */ new Map(), scope: void 0 };
35
- }
36
- const K = "@inversifyjs/core/pendingClassMetadataCountReflectKey", y = Symbol.for("@inversifyjs/core/InversifyCoreError");
37
- class u extends Error {
38
- [y];
39
- kind;
40
- constructor(e, t, r) {
41
- super(t, r), this[y] = !0, this.kind = e;
42
- }
43
- static is(e) {
44
- return typeof e == "object" && e !== null && e[y] === !0;
45
- }
46
- static isErrorOfKind(e, t) {
47
- return u.is(e) && e.kind === t;
48
- }
49
- }
50
- var l, v, p;
51
- function W() {
52
- return 0;
53
- }
54
- function _(n) {
55
- return (e) => {
56
- e !== void 0 && e.kind === v.unknown && g(n, K, W, (t) => t - 1);
57
- };
58
- }
59
- function L(n, e) {
60
- return (...t) => (r) => {
61
- if (r === void 0) return n(...t);
62
- if (r.kind === p.unmanaged) throw new u(l.injectionDecoratorConflict, "Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found");
63
- return e(r, ...t);
64
- };
65
- }
66
- function U(n) {
67
- if (n.kind !== v.unknown && n.isFromTypescriptParamType !== !0) throw new u(l.injectionDecoratorConflict, "Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found");
68
- }
69
- (function(n) {
70
- n[n.injectionDecoratorConflict = 0] = "injectionDecoratorConflict", n[n.missingInjectionDecorator = 1] = "missingInjectionDecorator", n[n.planning = 2] = "planning", n[n.resolution = 3] = "resolution", n[n.unknown = 4] = "unknown";
71
- })(l || (l = {})), function(n) {
72
- n[n.unknown = 32] = "unknown";
73
- }(v || (v = {})), function(n) {
74
- n[n.multipleInjection = 0] = "multipleInjection", n[n.singleInjection = 1] = "singleInjection", n[n.unmanaged = 2] = "unmanaged";
75
- }(p || (p = {}));
76
- const N = L(function(n, e, t) {
77
- return n === p.multipleInjection ? { chained: t?.chained ?? !1, kind: n, name: void 0, optional: !1, tags: /* @__PURE__ */ new Map(), value: e } : { kind: n, name: void 0, optional: !1, tags: /* @__PURE__ */ new Map(), value: e };
78
- }, function(n, e, t, r) {
79
- return U(n), e === p.multipleInjection ? { ...n, chained: r?.chained ?? !1, kind: e, value: t } : { ...n, kind: e, value: t };
80
- });
81
- function A(n, e) {
82
- return (t) => {
83
- const r = t.properties.get(e);
84
- return t.properties.set(e, n(r)), t;
85
- };
86
- }
87
- var d;
88
- function B(n, e, t, r) {
89
- if (u.isErrorOfKind(r, l.injectionDecoratorConflict)) {
90
- const i = function(o, c, a) {
91
- if (a === void 0) {
92
- if (c === void 0) throw new u(l.unknown, "Unexpected undefined property and index values");
93
- return { kind: d.property, property: c, targetClass: o.constructor };
94
- }
95
- return typeof a == "number" ? { index: a, kind: d.parameter, targetClass: o } : { kind: d.method, method: c, targetClass: o };
96
- }(n, e, t);
97
- throw new u(l.injectionDecoratorConflict, `Unexpected injection error.
98
-
99
- Cause:
100
-
101
- ${r.message}
102
-
103
- Details
104
-
105
- ${function(o) {
106
- switch (o.kind) {
107
- case d.method:
108
- return `[class: "${o.targetClass.name}", method: "${o.method.toString()}"]`;
109
- case d.parameter:
110
- return `[class: "${o.targetClass.name}", index: "${o.index.toString()}"]`;
111
- case d.property:
112
- return `[class: "${o.targetClass.name}", property: "${o.property.toString()}"]`;
113
- }
114
- }(i)}`, { cause: r });
115
- }
116
- throw r;
117
- }
118
- function q(n, e) {
119
- return (t, r, i) => {
120
- try {
121
- i === void 0 ? function(o, c) {
122
- const a = C(o, c);
123
- return (s, f) => {
124
- g(s.constructor, w, k, A(a(s), f));
125
- };
126
- }(n, e)(t, r) : typeof i == "number" ? function(o, c) {
127
- const a = C(o, c);
128
- return (s, f, I) => {
129
- if (!/* @__PURE__ */ function(m, h) {
130
- return typeof m == "function" && h === void 0;
131
- }(s, f)) throw new u(l.injectionDecoratorConflict, `Found an @inject decorator in a non constructor parameter.
132
- Found @inject decorator at method "${f?.toString() ?? ""}" at class "${s.constructor.name}"`);
133
- g(s, w, k, /* @__PURE__ */ function(m, h) {
134
- return (j) => {
135
- const P = j.constructorArguments[h];
136
- return j.constructorArguments[h] = m(P), j;
137
- };
138
- }(a(s), I));
139
- };
140
- }(n, e)(t, r, i) : function(o, c) {
141
- const a = C(o, c);
142
- return (s, f, I) => {
143
- if (!function(m) {
144
- return m.set !== void 0;
145
- }(I)) throw new u(l.injectionDecoratorConflict, `Found an @inject decorator in a non setter property method.
146
- Found @inject decorator at method "${f.toString()}" at class "${s.constructor.name}"`);
147
- g(s.constructor, w, k, A(a(s), f));
148
- };
149
- }(n, e)(t, r, i);
150
- } catch (o) {
151
- B(t, r, i, o);
152
- }
153
- };
154
- }
155
- function C(n, e) {
156
- return (t) => {
157
- const r = e(t);
158
- return (i) => (r(i), n(i));
159
- };
160
- }
161
- function F(n) {
162
- return q(N(p.singleInjection, n), _);
163
- }
164
- (function(n) {
165
- n[n.method = 0] = "method", n[n.parameter = 1] = "parameter", n[n.property = 2] = "property";
166
- })(d || (d = {}));
167
- const R = "@inversifyjs/core/classIsInjectableFlagReflectKey", G = [Array, BigInt, Boolean, Function, Number, Object, String];
168
- function V(n) {
169
- const e = b(n, "design:paramtypes");
170
- e !== void 0 && g(n, w, k, /* @__PURE__ */ function(t) {
171
- return (r) => (t.forEach((i, o) => {
172
- var c;
173
- r.constructorArguments[o] !== void 0 || (c = i, G.includes(c)) || (r.constructorArguments[o] = function(a) {
174
- return { isFromTypescriptParamType: !0, kind: p.singleInjection, name: void 0, optional: !1, tags: /* @__PURE__ */ new Map(), value: a };
175
- }(i));
176
- }), r);
177
- }(e));
178
- }
179
- function H(n) {
180
- return (e) => {
181
- (function(t) {
182
- if (b(t, R) !== void 0) throw new u(l.injectionDecoratorConflict, `Cannot apply @injectable decorator multiple times at class "${t.name}"`);
183
- E(t, R, !0);
184
- })(e), V(e);
185
- };
186
- }
187
- var z;
188
- (function(n) {
189
- n[n.multipleInjection = 0] = "multipleInjection", n[n.singleInjection = 1] = "singleInjection";
190
- })(z || (z = {}));
191
- var J = Object.getOwnPropertyDescriptor, X = (n, e, t, r) => {
192
- for (var i = r > 1 ? void 0 : r ? J(e, t) : e, o = n.length - 1, c; o >= 0; o--)
193
- (c = n[o]) && (i = c(i) || i);
194
- return i;
195
- }, O = (n, e) => (t, r) => e(t, r, n);
196
- let D = class {
197
- constructor(n, e) {
198
- this.initialize(), this.logger = n, this.cristalApp = e;
13
+ var h = Object.getOwnPropertyDescriptor, k = (e, r, t, n) => {
14
+ for (var o = n > 1 ? void 0 : n ? h(r, t) : r, a = e.length - 1, l; a >= 0; a--)
15
+ (l = e[a]) && (o = l(o) || o);
16
+ return o;
17
+ }, u = (e, r) => (t, n) => r(t, n, e);
18
+ let s = class {
19
+ // TODO remove use of any
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ workerInstance;
22
+ cristalApp;
23
+ logger;
24
+ constructor(e, r) {
25
+ this.initialize(), this.logger = e, this.cristalApp = r;
199
26
  }
200
- async pageLoaded(n) {
27
+ async pageLoaded(e) {
201
28
  try {
202
29
  this.logger.debug(
203
30
  "Received callback that new document has been loaded",
204
- n
205
- ), await this.cristalApp.getContainer().get(Q).refreshCurrentDocument(), this.logger.debug(
31
+ e
32
+ ), await this.cristalApp.getContainer().get(d).refreshCurrentDocument(), this.logger.debug(
206
33
  "Done callback that new document has been loaded",
207
- n
34
+ e
208
35
  );
209
- } catch (e) {
210
- this.logger.error("Error calling loadPage", e);
36
+ } catch (r) {
37
+ this.logger.error("Error calling loadPage", r);
211
38
  }
212
39
  }
213
40
  initialize() {
214
41
  try {
215
42
  if (this.workerInstance == null) {
216
- const n = new T({
43
+ const e = new w({
217
44
  name: "cristal-sharedworker"
218
45
  });
219
- this.workerInstance = $.wrap(n.port);
220
- const e = this;
46
+ this.workerInstance = i.wrap(e.port);
47
+ const r = this;
221
48
  this.workerInstance.setPageLoadedCallback(
222
- $.proxy(async (t) => {
223
- await e.pageLoaded(t);
49
+ i.proxy(async (t) => {
50
+ await r.pageLoaded(t);
224
51
  })
225
52
  ), console.debug("Worker initialized", this.workerInstance);
226
53
  } else
227
54
  console.debug("Already initialized");
228
- } catch (n) {
229
- console.error("Failed to initialize shared worker", n);
55
+ } catch (e) {
56
+ console.error("Failed to initialize shared worker", e);
230
57
  }
231
58
  }
232
59
  getStatus() {
@@ -236,28 +63,28 @@ let D = class {
236
63
  if (this.workerInstance == null)
237
64
  return console.log("workerInstance is null. Cannot call"), -1;
238
65
  {
239
- const n = await this.workerInstance.add(1);
240
- return console.log("Results from shared worker: ", n), n;
66
+ const e = await this.workerInstance.add(1);
67
+ return console.log("Results from shared worker: ", e), e;
241
68
  }
242
69
  }
243
- async addToQueue(n) {
244
- console.log("worker Calling addToQueue", n), this.workerInstance != null ? await this.workerInstance.addToQueue(n) : console.log("workerInstance is null. Cannot call");
70
+ async addToQueue(e) {
71
+ console.log("worker Calling addToQueue", e), this.workerInstance != null ? await this.workerInstance.addToQueue(e) : console.log("workerInstance is null. Cannot call");
245
72
  }
246
73
  async getQueueSize() {
247
74
  return console.log("worker Calling getQueueSize"), this.workerInstance == null ? -1 : await this.workerInstance.getQueueSize();
248
75
  }
249
76
  };
250
- D = X([
251
- H(),
252
- O(0, F("Logger")),
253
- O(1, F("CristalApp"))
254
- ], D);
255
- class Z {
256
- constructor(e) {
257
- e.bind("QueueWorker").to(D);
77
+ s = k([
78
+ g(),
79
+ u(0, c("Logger")),
80
+ u(1, c("CristalApp"))
81
+ ], s);
82
+ class I {
83
+ constructor(r) {
84
+ r.bind("QueueWorker").to(s);
258
85
  }
259
86
  }
260
87
  export {
261
- Z as ComponentInit
88
+ I as ComponentInit
262
89
  };
263
90
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../../../node_modules/.pnpm/@inversifyjs+reflect-metadata-utils@1.3.0_reflect-metadata@0.2.2/node_modules/@inversifyjs/reflect-metadata-utils/lib/esm/index.js","../../../node_modules/.pnpm/@inversifyjs+core@6.0.1_reflect-metadata@0.2.2/node_modules/@inversifyjs/core/lib/esm/index.js","../src/components/defaultQueueWorker.ts","../src/components/componentsInit.ts"],"sourcesContent":["function t(t){return n=>(n.push(...t),n)}function n(t){return n=>(n.push(t),n)}function e(t,n){return e=>(e[n]=t,e)}function u(){return[]}function f(){return new Map}function c(t,n,e){return Reflect.getOwnMetadata(n,t,e)}function a(t,n,e){return Reflect.getMetadata(n,t,e)}function r(t,n,e,u){Reflect.defineMetadata(n,e,t,u)}function i(t,n,e,u,f){const a=u(c(t,n,f)??e());Reflect.defineMetadata(n,a,t,f)}function o(t,n,e,u,f){const c=u(a(t,n,f)??e());Reflect.defineMetadata(n,c,t,f)}export{t as buildArrayMetadataWithArray,n as buildArrayMetadataWithElement,e as buildArrayMetadataWithIndex,u as buildEmptyArrayMetadata,f as buildEmptyMapMetadata,c as getOwnReflectMetadata,a as getReflectMetadata,r as setReflectMetadata,i as updateOwnReflectMetadata,o as updateReflectMetadata};\n//# sourceMappingURL=index.js.map\n","import{getOwnReflectMetadata as e,setReflectMetadata as t,updateOwnReflectMetadata as n}from\"@inversifyjs/reflect-metadata-utils\";import{getBaseType as i}from\"@inversifyjs/prototype-utils\";import{stringifyServiceIdentifier as o,LazyServiceIdentifier as r,isPromise as s}from\"@inversifyjs/common\";const a=\"@inversifyjs/container/bindingId\";function c(){const i=e(Object,a)??0;return i===Number.MAX_SAFE_INTEGER?t(Object,a,Number.MIN_SAFE_INTEGER):n(Object,a,()=>i,e=>e+1),i}const d={Request:\"Request\",Singleton:\"Singleton\",Transient:\"Transient\"},u={ConstantValue:\"ConstantValue\",DynamicValue:\"DynamicValue\",Factory:\"Factory\",Instance:\"Instance\",Provider:\"Provider\",ResolvedValue:\"ResolvedValue\",ServiceRedirection:\"ServiceRedirection\"};function*l(...e){for(const t of e)yield*t}class p{#e;#t;#n;constructor(e){this.#e=new Map,this.#t={};for(const t of Reflect.ownKeys(e))this.#t[t]=new Map;this.#n=e}add(e,t){this.#i(e).push(t);for(const n of Reflect.ownKeys(t))this.#o(n,t[n]).push(e)}clone(){const e=this.#r(),t=this.#s(),n=Reflect.ownKeys(this.#n),i=this._buildNewInstance(this.#n);this.#a(this.#e,i.#e,e,t);for(const t of n)this.#c(this.#t[t],i.#t[t],e);return i}get(e,t){return this.#t[e].get(t)}getAllKeys(e){return this.#t[e].keys()}removeByRelation(e,t){const n=this.get(e,t);if(void 0===n)return;const i=new Set(n);for(const n of i){const i=this.#e.get(n);if(void 0===i)throw new Error(\"Expecting model relation, none found\");for(const o of i)o[e]===t&&this.#d(n,o);this.#e.delete(n)}}_buildNewInstance(e){return new p(e)}_cloneModel(e){return e}_cloneRelation(e){return e}#r(){const e=new Map;for(const t of this.#e.keys()){const n=this._cloneModel(t);e.set(t,n)}return e}#s(){const e=new Map;for(const t of this.#e.values())for(const n of t){const t=this._cloneRelation(n);e.set(n,t)}return e}#i(e){let t=this.#e.get(e);return void 0===t&&(t=[],this.#e.set(e,t)),t}#o(e,t){let n=this.#t[e].get(t);return void 0===n&&(n=[],this.#t[e].set(t,n)),n}#u(e,t){const n=t.get(e);if(void 0===n)throw new Error(\"Expecting model to be cloned, none found\");return n}#l(e,t){const n=t.get(e);if(void 0===n)throw new Error(\"Expecting relation to be cloned, none found\");return n}#c(e,t,n){for(const[i,o]of e){const e=new Array;for(const t of o)e.push(this.#u(t,n));t.set(i,e)}}#a(e,t,n,i){for(const[o,r]of e){const e=new Array;for(const t of r)e.push(this.#l(t,i));t.set(this.#u(o,n),e)}}#d(e,t){for(const n of Reflect.ownKeys(t))this.#p(e,n,t[n])}#p(e,t,n){const i=this.#t[t].get(n);if(void 0!==i){const o=i.indexOf(e);-1!==o&&i.splice(o,1),0===i.length&&this.#t[t].delete(n)}}}var f,v,h;!function(e){e.moduleId=\"moduleId\",e.serviceId=\"serviceId\"}(f||(f={}));class g{#f;#v;constructor(e,t){this.#f=t??new p({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#v=e}static build(e){return new g(e)}add(e,t){this.#f.add(e,t)}clone(){return new g(this.#v,this.#f.clone())}get(e){const t=[],n=this.#f.get(f.serviceId,e);void 0!==n&&t.push(n);const i=this.#v()?.get(e);if(void 0!==i&&t.push(i),0!==t.length)return l(...t)}removeAllByModuleId(e){this.#f.removeByRelation(f.moduleId,e)}removeAllByServiceId(e){this.#f.removeByRelation(f.serviceId,e)}}function m(e){return e.isRight?{isRight:!0,value:e.value}:e}function y(e){switch(e.type){case u.ConstantValue:case u.DynamicValue:return function(e){return{cache:m(e.cache),id:e.id,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type,value:e.value}}(e);case u.Factory:return function(e){return{cache:m(e.cache),factory:e.factory,id:e.id,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type}}(e);case u.Instance:return function(e){return{cache:m(e.cache),id:e.id,implementationType:e.implementationType,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type}}(e);case u.Provider:return function(e){return{cache:m(e.cache),id:e.id,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,provider:e.provider,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type}}(e);case u.ResolvedValue:return function(e){return{cache:m(e.cache),factory:e.factory,id:e.id,isSatisfiedBy:e.isSatisfiedBy,metadata:e.metadata,moduleId:e.moduleId,onActivation:e.onActivation,onDeactivation:e.onDeactivation,scope:e.scope,serviceIdentifier:e.serviceIdentifier,type:e.type}}(e);case u.ServiceRedirection:return function(e){return{id:e.id,isSatisfiedBy:e.isSatisfiedBy,moduleId:e.moduleId,serviceIdentifier:e.serviceIdentifier,targetServiceIdentifier:e.targetServiceIdentifier,type:e.type}}(e)}}!function(e){e.id=\"id\",e.moduleId=\"moduleId\",e.serviceId=\"serviceId\"}(v||(v={}));class M extends p{_buildNewInstance(e){return new M(e)}_cloneModel(e){return y(e)}}class I{#h;#v;constructor(e,t){this.#h=t??new M({id:{isOptional:!1},moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#v=e}static build(e){return new I(e)}clone(){return new I(this.#v,this.#h.clone())}get(e){return this.getNonParentBindings(e)??this.#v()?.get(e)}*getChained(e){const t=this.getNonParentBindings(e);void 0!==t&&(yield*t);const n=this.#v();void 0!==n&&(yield*n.getChained(e))}getBoundServices(){const e=new Set(this.#h.getAllKeys(v.serviceId)),t=this.#v();if(void 0!==t)for(const n of t.getBoundServices())e.add(n);return e}getById(e){return this.#h.get(v.id,e)??this.#v()?.getById(e)}getByModuleId(e){return this.#h.get(v.moduleId,e)??this.#v()?.getByModuleId(e)}getNonParentBindings(e){return this.#h.get(v.serviceId,e)}getNonParentBoundServices(){return this.#h.getAllKeys(v.serviceId)}removeById(e){this.#h.removeByRelation(v.id,e)}removeAllByModuleId(e){this.#h.removeByRelation(v.moduleId,e)}removeAllByServiceId(e){this.#h.removeByRelation(v.serviceId,e)}set(e){const t={[v.id]:e.id,[v.serviceId]:e.serviceIdentifier};void 0!==e.moduleId&&(t[v.moduleId]=e.moduleId),this.#h.add(e,t)}}!function(e){e.moduleId=\"moduleId\",e.serviceId=\"serviceId\"}(h||(h={}));class w{#g;#v;constructor(e,t){this.#g=t??new p({moduleId:{isOptional:!0},serviceId:{isOptional:!1}}),this.#v=e}static build(e){return new w(e)}add(e,t){this.#g.add(e,t)}clone(){return new w(this.#v,this.#g.clone())}get(e){const t=[],n=this.#g.get(h.serviceId,e);void 0!==n&&t.push(n);const i=this.#v()?.get(e);if(void 0!==i&&t.push(i),0!==t.length)return l(...t)}removeAllByModuleId(e){this.#g.removeByRelation(h.moduleId,e)}removeAllByServiceId(e){this.#g.removeByRelation(h.serviceId,e)}}function b(e,t,n){const i=Array.isArray(e)?e:[e];if(void 0!==n)if(\"number\"!=typeof n)Reflect.decorate(i,t.prototype,n);else for(const e of i)e(t,void 0,n);else Reflect.decorate(i,t)}const S=\"@inversifyjs/core/classMetadataReflectKey\";function C(){return{constructorArguments:[],lifecycle:{postConstructMethodName:void 0,preDestroyMethodName:void 0},properties:new Map,scope:void 0}}const N=\"@inversifyjs/core/pendingClassMetadataCountReflectKey\";const T=Symbol.for(\"@inversifyjs/core/InversifyCoreError\");class j extends Error{[T];kind;constructor(e,t,n){super(t,n),this[T]=!0,this.kind=e}static is(e){return\"object\"==typeof e&&null!==e&&!0===e[T]}static isErrorOfKind(e,t){return j.is(e)&&e.kind===t}}var P,A,R;function x(t){const n=e(t,S)??C();if(!function(t){const n=e(t,N);return void 0!==n&&0!==n}(t))return function(e,t){const n=[];if(t.length<e.length)throw new j(P.missingInjectionDecorator,`Found unexpected missing metadata on type \"${e.name}\". \"${e.name}\" constructor requires at least ${e.length.toString()} arguments, found ${t.length.toString()} instead.\\nAre you using @inject, @multiInject or @unmanaged decorators in every non optional constructor argument?\\n\\nIf you're using typescript and want to rely on auto injection, set \"emitDecoratorMetadata\" compiler option to true`);for(let e=0;e<t.length;++e)void 0===t[e]&&n.push(e);if(n.length>0)throw new j(P.missingInjectionDecorator,`Found unexpected missing metadata on type \"${e.name}\" at constructor indexes \"${n.join('\", \"')}\".\\n\\nAre you using @inject, @multiInject or @unmanaged decorators at those indexes?\\n\\nIf you're using typescript and want to rely on auto injection, set \"emitDecoratorMetadata\" compiler option to true`)}(t,n.constructorArguments),n;!function(e,t){const n=[];for(let i=0;i<t.constructorArguments.length;++i){const o=t.constructorArguments[i];void 0!==o&&o.kind!==A.unknown||n.push(` - Missing or incomplete metadata for type \"${e.name}\" at constructor argument with index ${i.toString()}.\\nEvery constructor parameter must be decorated either with @inject, @multiInject or @unmanaged decorator.`)}for(const[i,o]of t.properties)o.kind===A.unknown&&n.push(` - Missing or incomplete metadata for type \"${e.name}\" at property \"${i.toString()}\".\\nThis property must be decorated either with @inject or @multiInject decorator.`);if(0===n.length)throw new j(P.unknown,`Unexpected class metadata for type \"${e.name}\" with uncompletion traces.\\nThis might be caused by one of the following reasons:\\n\\n1. A third party library is targeting inversify reflection metadata.\\n2. A bug is causing the issue. Consider submiting an issue to fix it.`);throw new j(P.missingInjectionDecorator,`Invalid class metadata at type ${e.name}:\\n\\n${n.join(\"\\n\\n\")}`)}(t,n)}function B(){return 0}function $(e){return t=>{void 0!==t&&t.kind===A.unknown&&n(e,N,B,e=>e-1)}}function D(e,t){return(...n)=>i=>{if(void 0===i)return e(...n);if(i.kind===R.unmanaged)throw new j(P.injectionDecoratorConflict,\"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found\");return t(i,...n)}}function k(e){if(e.kind!==A.unknown&&!0!==e.isFromTypescriptParamType)throw new j(P.injectionDecoratorConflict,\"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found\")}!function(e){e[e.injectionDecoratorConflict=0]=\"injectionDecoratorConflict\",e[e.missingInjectionDecorator=1]=\"missingInjectionDecorator\",e[e.planning=2]=\"planning\",e[e.resolution=3]=\"resolution\",e[e.unknown=4]=\"unknown\"}(P||(P={})),function(e){e[e.unknown=32]=\"unknown\"}(A||(A={})),function(e){e[e.multipleInjection=0]=\"multipleInjection\",e[e.singleInjection=1]=\"singleInjection\",e[e.unmanaged=2]=\"unmanaged\"}(R||(R={}));const F=D(function(e,t,n){return e===R.multipleInjection?{chained:n?.chained??!1,kind:e,name:void 0,optional:!1,tags:new Map,value:t}:{kind:e,name:void 0,optional:!1,tags:new Map,value:t}},function(e,t,n,i){return k(e),t===R.multipleInjection?{...e,chained:i?.chained??!1,kind:t,value:n}:{...e,kind:t,value:n}});function V(e,t){return n=>{const i=n.properties.get(t);return n.properties.set(t,e(i)),n}}var O;function E(e,t,n,i){if(j.isErrorOfKind(i,P.injectionDecoratorConflict)){const o=function(e,t,n){if(void 0===n){if(void 0===t)throw new j(P.unknown,\"Unexpected undefined property and index values\");return{kind:O.property,property:t,targetClass:e.constructor}}return\"number\"==typeof n?{index:n,kind:O.parameter,targetClass:e}:{kind:O.method,method:t,targetClass:e}}(e,t,n);throw new j(P.injectionDecoratorConflict,`Unexpected injection error.\\n\\nCause:\\n\\n${i.message}\\n\\nDetails\\n\\n${function(e){switch(e.kind){case O.method:return`[class: \"${e.targetClass.name}\", method: \"${e.method.toString()}\"]`;case O.parameter:return`[class: \"${e.targetClass.name}\", index: \"${e.index.toString()}\"]`;case O.property:return`[class: \"${e.targetClass.name}\", property: \"${e.property.toString()}\"]`}}(o)}`,{cause:i})}throw i}function _(e,t){return(i,o,r)=>{try{void 0===r?function(e,t){const i=U(e,t);return(e,t)=>{n(e.constructor,S,C,V(i(e),t))}}(e,t)(i,o):\"number\"==typeof r?function(e,t){const i=U(e,t);return(e,t,o)=>{if(!function(e,t){return\"function\"==typeof e&&void 0===t}(e,t))throw new j(P.injectionDecoratorConflict,`Found an @inject decorator in a non constructor parameter.\\nFound @inject decorator at method \"${t?.toString()??\"\"}\" at class \"${e.constructor.name}\"`);n(e,S,C,function(e,t){return n=>{const i=n.constructorArguments[t];return n.constructorArguments[t]=e(i),n}}(i(e),o))}}(e,t)(i,o,r):function(e,t){const i=U(e,t);return(e,t,o)=>{if(!function(e){return void 0!==e.set}(o))throw new j(P.injectionDecoratorConflict,`Found an @inject decorator in a non setter property method.\\nFound @inject decorator at method \"${t.toString()}\" at class \"${e.constructor.name}\"`);n(e.constructor,S,C,V(i(e),t))}}(e,t)(i,o,r)}catch(e){E(i,o,r,e)}}}function U(e,t){return n=>{const i=t(n);return t=>(i(t),e(t))}}function z(e){return _(F(R.singleInjection,e),$)}!function(e){e[e.method=0]=\"method\",e[e.parameter=1]=\"parameter\",e[e.property=2]=\"property\"}(O||(O={}));const K=\"@inversifyjs/core/classIsInjectableFlagReflectKey\";const L=[Array,BigInt,Boolean,Function,Number,Object,String];function q(t){const i=e(t,\"design:paramtypes\");void 0!==i&&n(t,S,C,function(e){return t=>(e.forEach((e,n)=>{var i;void 0!==t.constructorArguments[n]||(i=e,L.includes(i))||(t.constructorArguments[n]=function(e){return{isFromTypescriptParamType:!0,kind:R.singleInjection,name:void 0,optional:!1,tags:new Map,value:e}}(e))}),t)}(i))}function G(i){return o=>{!function(n){if(void 0!==e(n,K))throw new j(P.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class \"${n.name}\"`);t(n,K,!0)}(o),q(o),void 0!==i&&n(o,S,C,e=>({...e,scope:i}))}}function W(e,t,n){let i;return e.extendConstructorArguments??!0?(i=[...t.constructorArguments],n.constructorArguments.map((e,t)=>{i[t]=e})):i=n.constructorArguments,i}function X(e,t,n){let i;return i=e.extendProperties??!0?new Map(l(t.properties,n.properties)):n.properties,i}function H(e){return t=>{const i=x(e.type);n(t,S,C,function(e,t){const n=n=>({constructorArguments:W(e,t,n),lifecycle:n.lifecycle,properties:X(e,t,n),scope:n.scope});return n}(e,i))}}function J(e){return t=>{const n=i(t);if(void 0===n)throw new j(P.injectionDecoratorConflict,`Expected base type for type \"${t.name}\", none found.`);H({...e,type:n})(t)}}function Q(e,t){return _(F(R.multipleInjection,e,t),$)}function Y(e){return t=>{void 0===t&&n(e,N,B,e=>e+1)}}function Z(e){return t=>{const n=t??{kind:A.unknown,name:void 0,optional:!1,tags:new Map};if(n.kind===R.unmanaged)throw new j(P.injectionDecoratorConflict,\"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections\");return e(n)}}function ee(e){const t=Z(function(e){return t=>{if(void 0!==t.name)throw new j(P.injectionDecoratorConflict,\"Unexpected duplicated named decorator\");return t.name=e,t}}(e));return _(t,Y)}function te(e){if(e.optional)throw new j(P.injectionDecoratorConflict,\"Unexpected duplicated optional decorator\");return e.optional=!0,e}function ne(){return _(Z(te),Y)}function ie(){return(e,t,i)=>{try{n(e.constructor,S,C,(o=t,e=>{if(void 0!==e.lifecycle.postConstructMethodName)throw new j(P.injectionDecoratorConflict,\"Unexpected duplicated postConstruct decorator\");return e.lifecycle.postConstructMethodName=o,e}))}catch(n){E(e,t,void 0,n)}var o}}function oe(){return(e,t,i)=>{try{n(e.constructor,S,C,(o=t,e=>{if(void 0!==e.lifecycle.preDestroyMethodName)throw new j(P.injectionDecoratorConflict,\"Unexpected duplicated preDestroy decorator\");return e.lifecycle.preDestroyMethodName=o,e}))}catch(n){E(e,t,void 0,n)}var o}}function re(e,t){const n=Z(function(e,t){return n=>{if(n.tags.has(e))throw new j(P.injectionDecoratorConflict,\"Unexpected duplicated tag decorator with existing tag\");return n.tags.set(e,t),n}}(e,t));return _(n,Y)}function se(){return{kind:R.unmanaged}}const ae=D(se,function(e){if(k(e),function(e){return void 0!==e.name||e.optional||e.tags.size>0}(e))throw new j(P.injectionDecoratorConflict,\"Unexpected injection found. Found @unmanaged injection with additional @named, @optional, @tagged or @targetName injections\");return se()});function ce(){return _(ae(),$)}var de;!function(e){e[e.multipleInjection=0]=\"multipleInjection\",e[e.singleInjection=1]=\"singleInjection\"}(de||(de={}));class ue{#m;constructor(e){this.#m=e}get name(){return this.#m.elem.name}get serviceIdentifier(){return this.#m.elem.serviceIdentifier}get tags(){return this.#m.elem.tags}getAncestor(){if(this.#m.elem.getAncestorsCalled=!0,void 0!==this.#m.previous)return new ue(this.#m.previous)}}function le(e,t,n){const i=n?.customServiceIdentifier??t.serviceIdentifier,o=(!0===n?.chained?[...e.operations.getBindingsChained(i)]:[...e.operations.getBindings(i)??[]]).filter(e=>e.isSatisfiedBy(t));if(0===o.length&&void 0!==e.autobindOptions&&\"function\"==typeof i){const t=function(e,t){const n=x(t),i=n.scope??e.scope;return{cache:{isRight:!1,value:void 0},id:c(),implementationType:t,isSatisfiedBy:()=>!0,moduleId:void 0,onActivation:void 0,onDeactivation:void 0,scope:i,serviceIdentifier:t,type:u.Instance}}(e.autobindOptions,i);e.operations.setBinding(t),o.push(t)}return o}class pe{last;constructor(e){this.last=e}concat(e){return new pe({elem:e,previous:this.last})}[Symbol.iterator](){let e=this.last;return{next:()=>{if(void 0===e)return{done:!0,value:void 0};const t=e.elem;return e=e.previous,{done:!1,value:t}}}}}function fe(e){return void 0!==e.redirections}function ve(e,t,n,i){const r=n.elem.serviceIdentifier,s=n.previous?.elem.serviceIdentifier;Array.isArray(e)?function(e,t,n,i,r,s){if(0!==e.length){const t=s[s.length-1]??n,a=`Ambiguous bindings found for service: \"${o(t)}\".${ye(s)}\\n\\nRegistered bindings:\\n\\n${e.map(e=>function(e){switch(e.type){case u.Instance:return`[ type: \"${e.type}\", serviceIdentifier: \"${o(e.serviceIdentifier)}\", scope: \"${e.scope}\", implementationType: \"${e.implementationType.name}\" ]`;case u.ServiceRedirection:return`[ type: \"${e.type}\", serviceIdentifier: \"${o(e.serviceIdentifier)}\", redirection: \"${o(e.targetServiceIdentifier)}\" ]`;default:return`[ type: \"${e.type}\", serviceIdentifier: \"${o(e.serviceIdentifier)}\", scope: \"${e.scope}\" ]`}}(e.binding)).join(\"\\n\")}\\n\\nTrying to resolve bindings for \"${ge(n,i)}\".${me(r)}`;throw new j(P.planning,a)}t||he(n,i,r,s)}(e,t,r,s,n.elem,i):function(e,t,n,i,o,r){void 0!==e||t||he(n,i,o,r)}(e,t,r,s,n.elem,i)}function he(e,t,n,i){const r=i[i.length-1]??e,s=`No bindings found for service: \"${o(r)}\".\\n\\nTrying to resolve bindings for \"${ge(e,t)}\".${ye(i)}${me(n)}`;throw new j(P.planning,s)}function ge(e,t){return void 0===t?`${o(e)} (Root service)`:o(t)}function me(e){const t=0===e.tags.size?\"\":`\\n- tags:\\n - ${[...e.tags.keys()].map(e=>e.toString()).join(\"\\n - \")}`;return`\\n\\nBinding constraints:\\n- service identifier: ${o(e.serviceIdentifier)}\\n- name: ${e.name?.toString()??\"-\"}${t}`}function ye(e){return 0===e.length?\"\":`\\n\\n- service redirections:\\n - ${e.map(e=>o(e)).join(\"\\n - \")}`}function Me(e,t,n,i){if(1===e.redirections.length){const[o]=e.redirections;return void(fe(o)&&Me(o,t,n,[...i,o.binding.targetServiceIdentifier]))}ve(e.redirections,t,n,i)}function Ie(e,t,n){if(Array.isArray(e.bindings)&&1===e.bindings.length){const[i]=e.bindings;return void(fe(i)&&Me(i,t,n,[i.binding.targetServiceIdentifier]))}ve(e.bindings,t,n,[])}function we(e){return r.is(e)?e.unwrap():e}function be(e,t){if(function(e){return e instanceof Error&&(e instanceof RangeError&&/stack space|call stack|too much recursion/i.test(e.message)||\"InternalError\"===e.name&&/too much recursion/.test(e.message))}(t)){const n=function(e){const t=[...e];if(0===t.length)return\"(No dependency trace)\";return t.map(o).join(\" -> \")}(function(e){const t=new Set;for(const n of e.servicesBranch){if(t.has(n))return[...t,n];t.add(n)}return[...t]}(e));throw new j(P.planning,`Circular dependency found: ${n}`,{cause:t})}throw t}const Se=Symbol.for(\"@inversifyjs/core/LazyPlanServiceNode\");class Ce{[Se];_serviceIdentifier;_serviceNode;constructor(e){this[Se]=!0,this._serviceIdentifier=e.serviceIdentifier,this._serviceNode=e}get bindings(){return this._getNode().bindings}get isContextFree(){return this._getNode().isContextFree}get serviceIdentifier(){return this._serviceIdentifier}set bindings(e){this._getNode().bindings=e}set isContextFree(e){this._getNode().isContextFree=e}static is(e){return\"object\"==typeof e&&null!==e&&!0===e[Se]}invalidate(){this._serviceNode=void 0}_getNode(){return void 0===this._serviceNode&&(this._serviceNode=this._buildPlanServiceNode()),this._serviceNode}}function Ne(e,t,n){if(void 0!==e&&n.isContextFree){const i={tree:{root:n}};t.setPlan(e,i)}else t.setNonCachedServiceNode(n)}class Te extends Ce{#y;constructor(e,t){super(t),this.#y=e}_buildPlanServiceNode(){return Ae(this.#y)}}class je extends Ce{#y;#M;#I;constructor(e,t,n,i){super(i),this.#y=e,this.#M=t,this.#I=n}_buildPlanServiceNode(){return Be(this.#y,this.#M,this.#I)}}class Pe extends Ce{#y;#M;#w;constructor(e,t,n,i){super(i),this.#y=e,this.#M=t,this.#w=n}_buildPlanServiceNode(){return $e(this.#y,this.#M,this.#w)}}function Ae(e){const t=function(e){const t=new Map;return void 0!==e.rootConstraints.tag&&t.set(e.rootConstraints.tag.key,e.rootConstraints.tag.value),new pe({elem:{getAncestorsCalled:!1,name:e.rootConstraints.name,serviceIdentifier:e.rootConstraints.serviceIdentifier,tags:t},previous:void 0})}(e),n=new ue(t.last),i=!!e.rootConstraints.isMultiple&&e.rootConstraints.chained,o=le(e,n,{chained:i}),r=[],s={bindings:r,isContextFree:!0,serviceIdentifier:e.rootConstraints.serviceIdentifier};if(r.push(...ke(e,t,o,s,i)),s.isContextFree=!t.last.elem.getAncestorsCalled,!e.rootConstraints.isMultiple){Ie(s,e.rootConstraints.isOptional??!1,t.last);const[n]=r;s.bindings=n}return s}function Re(e){try{const t=function(e){return e.rootConstraints.isMultiple?{chained:e.rootConstraints.chained,isMultiple:!0,name:e.rootConstraints.name,optional:e.rootConstraints.isOptional??!1,serviceIdentifier:e.rootConstraints.serviceIdentifier,tag:e.rootConstraints.tag}:{isMultiple:!1,name:e.rootConstraints.name,optional:e.rootConstraints.isOptional??!1,serviceIdentifier:e.rootConstraints.serviceIdentifier,tag:e.rootConstraints.tag}}(e),n=e.operations.getPlan(t);if(void 0!==n)return n;const i=Ae(e),o={tree:{root:new Te(e,i)}};return e.operations.setPlan(t,o),o}catch(t){be(e,t)}}function xe(e,t,n){const i={binding:t,classMetadata:e.operations.getClassMetadata(t.implementationType),constructorParams:[],propertyParams:new Map};return Ee({autobindOptions:e.autobindOptions,node:i,operations:e.operations,servicesBranch:e.servicesBranch},n)}function Be(e,t,n){const i=we(n.value),o=t.concat({getAncestorsCalled:!1,name:n.name,serviceIdentifier:i,tags:n.tags}),r=new ue(o.last),s=n.kind===R.multipleInjection&&n.chained,a=le(e,r,{chained:s}),c=[],d={bindings:c,isContextFree:!0,serviceIdentifier:i};if(c.push(...ke(e,o,a,d,s)),d.isContextFree=!o.last.elem.getAncestorsCalled,n.kind===R.singleInjection){Ie(d,n.optional,o.last);const[e]=c;d.bindings=e}return d}function $e(e,t,n){const i=we(n.value),o=t.concat({getAncestorsCalled:!1,name:n.name,serviceIdentifier:i,tags:n.tags}),r=new ue(o.last),s=n.kind===de.multipleInjection&&n.chained,a=le(e,r,{chained:s}),c=[],d={bindings:c,isContextFree:!0,serviceIdentifier:i};if(c.push(...ke(e,o,a,d,s)),d.isContextFree=!o.last.elem.getAncestorsCalled,n.kind===de.singleInjection){Ie(d,n.optional,o.last);const[e]=c;d.bindings=e}return d}function De(e,t,n){const i={binding:t,params:[]};return Ee({autobindOptions:e.autobindOptions,node:i,operations:e.operations,servicesBranch:e.servicesBranch},n)}function ke(e,t,n,i,o){const r=fe(i)?i.binding.targetServiceIdentifier:i.serviceIdentifier;e.servicesBranch.push(r);const s=[];for(const i of n)switch(i.type){case u.Instance:s.push(xe(e,i,t));break;case u.ResolvedValue:s.push(De(e,i,t));break;case u.ServiceRedirection:{const n=Fe(e,t,i,o);s.push(n);break}default:s.push({binding:i})}return e.servicesBranch.pop(),s}function Fe(e,t,n,i){const o={binding:n,redirections:[]},r=le(e,new ue(t.last),{chained:i,customServiceIdentifier:n.targetServiceIdentifier});return o.redirections.push(...ke(e,t,r,o,i)),o}function Ve(e,t,n){if(n.kind===R.unmanaged)return;const i=function(e){let t;if(0===e.tags.size)t=void 0;else{if(1!==e.tags.size)return;{const[n,i]=e.tags.entries().next().value;t={key:n,value:i}}}const n=r.is(e.value)?e.value.unwrap():e.value;return e.kind===R.multipleInjection?{chained:e.chained,isMultiple:!0,name:e.name,optional:e.optional,serviceIdentifier:n,tag:t}:{isMultiple:!1,name:e.name,optional:e.optional,serviceIdentifier:n,tag:t}}(n);if(void 0!==i){const t=e.operations.getPlan(i);if(void 0!==t&&t.tree.root.isContextFree)return t.tree.root}const o=Be(e,t,n),s=new je(e,t,n,o);return Ne(i,e.operations,s),s}function Oe(e,t,n){const i=function(e){let t;if(0===e.tags.size)t=void 0;else{if(1!==e.tags.size)return;{const[n,i]=e.tags.entries().next().value;t={key:n,value:i}}}const n=r.is(e.value)?e.value.unwrap():e.value;return e.kind===de.multipleInjection?{chained:e.chained,isMultiple:!0,name:e.name,optional:e.optional,serviceIdentifier:n,tag:t}:{isMultiple:!1,name:e.name,optional:e.optional,serviceIdentifier:n,tag:t}}(n);if(void 0!==i){const t=e.operations.getPlan(i);if(void 0!==t&&t.tree.root.isContextFree)return t.tree.root}const o=$e(e,t,n),s=new Pe(e,t,n,o);return Ne(i,e.operations,s),s}function Ee(e,t){return e.node.binding.type===u.Instance?function(e,t,n){const i=t.classMetadata;for(const[o,r]of i.constructorArguments.entries())t.constructorParams[o]=Ve(e,n,r);for(const[o,r]of i.properties){const i=Ve(e,n,r);void 0!==i&&t.propertyParams.set(o,i)}return e.node}(e,e.node,t):function(e,t,n){const i=t.binding.metadata;for(const[o,r]of i.arguments.entries())t.params[o]=Oe(e,n,r);return e.node}(e,e.node,t)}class _e{#b;#S;#C;constructor(){this.#b=[],this.#S=8,this.#C=1024}*[Symbol.iterator](){let e=0;for(const t of this.#b){const n=t.deref();void 0===n?++e:yield n}this.#b.length>=this.#S&&this.#N(e)&&this.#T(e)}push(e){const t=new WeakRef(e);if(this.#b.push(t),this.#b.length>=this.#S&&this.#b.length%this.#C===0){let e=0;for(const t of this.#b)void 0===t.deref()&&++e;this.#N(e)&&this.#T(e)}}#T(e){const t=new Array(this.#b.length-e);let n=0;for(const e of this.#b)e.deref()&&(t[n++]=e);this.#b=t}#N(e){return e>=.5*this.#b.length}}class Ue{#j;#P;#A;#R;#x;#B;constructor(){this.#j=new Map,this.#P=this.#$(),this.#A=this.#$(),this.#R=this.#$(),this.#x=this.#$(),this.#B=new _e}clearCache(){for(const e of this.#D())e.clear();for(const e of this.#B)e.clearCache()}get(e){return void 0===e.name?void 0===e.tag?this.#k(this.#P,e).get(e.serviceIdentifier):this.#k(this.#x,e).get(e.serviceIdentifier)?.get(e.tag.key)?.get(e.tag.value):void 0===e.tag?this.#k(this.#A,e).get(e.serviceIdentifier)?.get(e.name):this.#k(this.#R,e).get(e.serviceIdentifier)?.get(e.name)?.get(e.tag.key)?.get(e.tag.value)}invalidateService(e){this.#F(e),this.#V(e),this.#O(e),this.#E(e),this.#_(e);for(const t of this.#B)t.invalidateService(e)}set(e,t){void 0===e.name?void 0===e.tag?this.#k(this.#P,e).set(e.serviceIdentifier,t):this.#U(this.#U(this.#k(this.#x,e),e.serviceIdentifier),e.tag.key).set(e.tag.value,t):void 0===e.tag?this.#U(this.#k(this.#A,e),e.serviceIdentifier).set(e.name,t):this.#U(this.#U(this.#U(this.#k(this.#R,e),e.serviceIdentifier),e.name),e.tag.key).set(e.tag.value,t)}setNonCachedServiceNode(e){let t=this.#j.get(e.serviceIdentifier);void 0===t&&(t=new Set,this.#j.set(e.serviceIdentifier,t)),t.add(e)}subscribe(e){this.#B.push(e)}#$(){const e=new Array(8);for(let t=0;t<e.length;++t)e[t]=new Map;return e}#U(e,t){let n=e.get(t);return void 0===n&&(n=new Map,e.set(t,n)),n}#k(e,t){return e[this.#z(t)]}#D(){return[this.#j,...this.#P,...this.#A,...this.#R,...this.#x]}#z(e){return e.isMultiple?(e.chained?4:0)|(e.optional?1:0)|2:e.optional?1:0}#V(e){for(const t of this.#A){const n=t.get(e);if(void 0!==n)for(const e of n.values())Ce.is(e.tree.root)&&(this.#K(e.tree.root),e.tree.root.invalidate())}}#O(e){for(const t of this.#R){const n=t.get(e);if(void 0!==n)for(const e of n.values())for(const t of e.values())for(const e of t.values())Ce.is(e.tree.root)&&(this.#K(e.tree.root),e.tree.root.invalidate())}}#L(e){switch(e.binding.type){case u.ServiceRedirection:for(const t of e.redirections)this.#L(t);break;case u.Instance:for(const t of e.constructorParams)void 0!==t&&this.#q(t);for(const t of e.propertyParams.values())this.#q(t);break;case u.ResolvedValue:for(const t of e.params)this.#q(t)}}#q(e){const t=this.#j.get(e.serviceIdentifier);void 0!==t&&t.has(e)&&(t.delete(e),this.#K(e))}#K(e){if(void 0!==e.bindings)if(Array.isArray(e.bindings))for(const t of e.bindings)this.#L(t);else this.#L(e.bindings)}#_(e){const t=this.#j.get(e);if(void 0!==t)for(const e of t)Ce.is(e)&&(this.#K(e),e.invalidate())}#F(e){for(const t of this.#P){const n=t.get(e);void 0!==n&&Ce.is(n.tree.root)&&(this.#K(n.tree.root),n.tree.root.invalidate())}}#E(e){for(const t of this.#x){const n=t.get(e);if(void 0!==n)for(const e of n.values())for(const t of e.values())Ce.is(t.tree.root)&&(this.#K(t.tree.root),t.tree.root.invalidate())}}}function ze(e,t){return s(t)?(e.cache={isRight:!0,value:t},t.then(t=>Ke(e,t))):Ke(e,t)}function Ke(e,t){return e.cache={isRight:!0,value:t},t}function Le(e,t,n){const i=e.getActivations(t);return void 0===i?n:s(n)?qe(e,n,i[Symbol.iterator]()):function(e,t,n){let i=t,o=n.next();for(;!0!==o.done;){const t=o.value(e.context,i);if(s(t))return qe(e,t,n);i=t,o=n.next()}return i}(e,n,i[Symbol.iterator]())}async function qe(e,t,n){let i=await t,o=n.next();for(;!0!==o.done;)i=await o.value(e.context,i),o=n.next();return i}function Ge(e,t,n){let i=n;if(void 0!==t.onActivation){const n=t.onActivation;i=s(i)?i.then(t=>n(e.context,t)):n(e.context,i)}return Le(e,t.serviceIdentifier,i)}function We(e){return(t,n)=>{if(n.cache.isRight)return n.cache.value;return ze(n,Ge(t,n,e(t,n)))}}const Xe=We(function(e,t){return t.value});function He(e){return e}function Je(e,t){return(n,i)=>{const o=e(i);switch(o.scope){case d.Singleton:if(o.cache.isRight)return o.cache.value;return ze(o,Ge(n,o,t(n,i)));case d.Request:{if(n.requestScopeCache.has(o.id))return n.requestScopeCache.get(o.id);const e=Ge(n,o,t(n,i));return n.requestScopeCache.set(o.id,e),e}case d.Transient:return Ge(n,o,t(n,i))}}}const Qe=(e=>Je(He,e))(function(e,t){return t.value(e.context)});const Ye=We(function(e,t){return t.factory(e.context)});function Ze(e,t,n){const i=function(e,t,n){if(void 0===n)return;if(!(n in e))throw new j(P.resolution,`Expecting a \"${n.toString()}\" property when resolving \"${t.implementationType.name}\" class @postConstruct decorated method, none found.`);if(\"function\"!=typeof e[n])throw new j(P.resolution,`Expecting a \"${n.toString()}\" method when resolving \"${t.implementationType.name}\" class @postConstruct decorated method, a non function property was found instead.`);{let i;try{i=e[n]()}catch(e){throw new j(P.resolution,`Unexpected error found when calling \"${n.toString()}\" @postConstruct decorated method on class \"${t.implementationType.name}\"`,{cause:e})}if(s(i))return async function(e,t,n){try{await n}catch(n){throw new j(P.resolution,`Unexpected error found when calling \"${t.toString()}\" @postConstruct decorated method on class \"${e.implementationType.name}\"`,{cause:n})}}(t,n,i)}}(e,t,n);return s(i)?i.then(()=>e):e}function et(e){return(t,n,i)=>{const o=new i.binding.implementationType(...t),r=e(n,o,i);return s(r)?r.then(()=>Ze(o,i.binding,i.classMetadata.lifecycle.postConstructMethodName)):Ze(o,i.binding,i.classMetadata.lifecycle.postConstructMethodName)}}const tt=We(function(e,t){return t.provider(e.context)});function nt(e){return e.binding}function it(e){return e.binding}const ot=function(e){return(t,n,i)=>{const o=[];for(const[r,a]of i.propertyParams){const c=i.classMetadata.properties.get(r);if(void 0===c)throw new j(P.resolution,`Expecting metadata at property \"${r.toString()}\", none found`);c.kind!==R.unmanaged&&void 0!==a.bindings&&(n[r]=e(t,a),s(n[r])&&o.push((async()=>{n[r]=await n[r]})()))}if(o.length>0)return Promise.all(o).then(()=>{})}}(pt),rt=function(e){return function t(n,i){const o=[];for(const r of i.redirections)fe(r)?o.push(...t(n,r)):o.push(e(n,r));return o}}(lt),st=function(e,t,n){return(i,o)=>{const r=e(i,o);return s(r)?t(r,i,o):n(r,i,o)}}(function(e){return(t,n)=>{const i=[];for(const o of n.constructorParams)void 0===o?i.push(void 0):i.push(e(t,o));return i.some(s)?Promise.all(i):i}}(pt),function(e){return async(t,n,i)=>{const o=await t;return e(o,n,i)}}(et(ot)),et(ot)),at=function(e){return(t,n)=>{const i=e(t,n);return s(i)?i.then(e=>n.binding.factory(...e)):n.binding.factory(...i)}}(function(e){return(t,n)=>{const i=[];for(const o of n.params)i.push(e(t,o));return i.some(s)?Promise.all(i):i}}(pt)),ct=(e=>Je(nt,e))(st),dt=(e=>Je(it,e))(at);function ut(e){return pt(e,e.planResult.tree.root)}function lt(e,t){switch(t.binding.type){case u.ConstantValue:return Xe(e,t.binding);case u.DynamicValue:return Qe(e,t.binding);case u.Factory:return Ye(e,t.binding);case u.Instance:return ct(e,t);case u.Provider:return tt(e,t.binding);case u.ResolvedValue:return dt(e,t)}}function pt(e,t){if(void 0!==t.bindings)return Array.isArray(t.bindings)?function(e,t){const n=[];for(const i of t)fe(i)?n.push(...rt(e,i)):n.push(lt(e,i));if(n.some(s))return Promise.all(n);return n}(e,t.bindings):function(e,t){if(fe(t)){const n=rt(e,t);if(1===n.length)return n[0];throw new j(P.resolution,\"Unexpected multiple resolved values on single injection\")}return lt(e,t)}(e,t.bindings)}function ft(e){return void 0!==e.scope}function vt(e,t){if(void 0!==e.lifecycle.preDestroyMethodName&&\"function\"==typeof t[e.lifecycle.preDestroyMethodName])return t[e.lifecycle.preDestroyMethodName]()}function ht(e,t,n){const i=e.getDeactivations(t);if(void 0!==i)return s(n)?gt(n,i[Symbol.iterator]()):function(e,t){let n=t.next();for(;!0!==n.done;){const i=n.value(e);if(s(i))return gt(e,t);n=t.next()}}(n,i[Symbol.iterator]())}async function gt(e,t){const n=await e;let i=t.next();for(;!0!==i.done;)await i.value(n),i=t.next()}function mt(e,t){const n=function(e,t){if(t.type===u.Instance){const n=e.getClassMetadata(t.implementationType),i=t.cache.value;return s(i)?i.then(e=>vt(n,e)):vt(n,i)}}(e,t);return void 0===n?yt(e,t):n.then(()=>yt(e,t))}function yt(e,t){const n=t.cache;return s(n.value)?n.value.then(n=>Mt(e,t,n)):Mt(e,t,n.value)}function Mt(e,t,n){let i;if(void 0!==t.onDeactivation){i=(0,t.onDeactivation)(n)}return void 0===i?ht(e,t.serviceIdentifier,n):i.then(()=>ht(e,t.serviceIdentifier,n))}function It(e,t){if(void 0===t)return;const n=function(e){const t=[];for(const n of e)ft(n)&&n.scope===d.Singleton&&n.cache.isRight&&t.push(n);return t}(t),i=[];for(const t of n){const n=mt(e,t);void 0!==n&&i.push(n)}return i.length>0?Promise.all(i).then(()=>{}):void 0}function wt(e,t){const n=e.getBindingsFromModule(t);return It(e,n)}function bt(e,t){const n=e.getBindings(t);return It(e,n)}export{g as ActivationsService,I as BindingService,R as ClassElementMetadataKind,w as DeactivationsService,Ue as PlanResultCacheService,de as ResolvedValueElementMetadataKind,d as bindingScopeValues,u as bindingTypeValues,b as decorate,c as getBindingId,x as getClassMetadata,z as inject,J as injectFromBase,G as injectable,Q as multiInject,ee as named,ne as optional,Re as plan,ie as postConstruct,oe as preDestroy,ut as resolve,It as resolveBindingsDeactivations,wt as resolveModuleDeactivations,bt as resolveServiceDeactivations,re as tagged,ce as unmanaged};\n//# sourceMappingURL=index.js.map\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 { default as 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,\n @inject(\"CristalApp\") cristalApp: CristalApp,\n ) {\n this.initialize();\n this.logger = logger;\n this.cristalApp = cristalApp;\n }\n\n async pageLoaded(page: string): Promise<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\n await 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\n this.workerInstance.setPageLoadedCallback(\n Comlink.proxy(async (page: string) => {\n await 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":["c","t","n","e","r","u","i","f","a","v","h","S","C","N","T","j","P","A","R","B","$","D","k","F","V","O","E","o","_","U","z","K","L","q","G","de","DefaultQueueWorker","logger","cristalApp","page","documentServiceName","sworker","Worker","Comlink","that","result","__decorateClass","injectable","__decorateParam","ComponentInit","container"],"mappings":";;;;;;;;;;;AAAsK,SAASA,EAAEC,GAAEC,GAAEC,GAAE;AAAC,SAAO,QAA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M,KAAK,eAAe,IAAI,CAAC;AAC9C,qBAAQ,IAAI,gCAAgCA,CAAM,GAC3CA;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAa,WAAWN,GAA6B;AACnD,YAAQ,IAAI,6BAA6BA,CAAI,GACzC,KAAK,kBAAkB,OACzB,MAAM,KAAK,eAAe,WAAWA,CAAI,IAEzC,QAAQ,IAAI,qCAAqC;AAAA,EAErD;AAAA,EAEA,MAAa,eAAgC;AAE3C,WADA,QAAQ,IAAI,6BAA6B,GACrC,KAAK,kBAAkB,OAClB,KAEA,MAAM,KAAK,eAAe,aAAA;AAAA,EAErC;AACF;AAzGqBH,IAArBU,EAAA;AAAA,EADCC,EAAA;AAAA,EASIC,OAAO,QAAQ,CAAA;AAAA,EACfA,OAAO,YAAY,CAAA;AAAA,GATHZ,CAAA;ACLrB,MAAqBa,EAAc;AAAA,EACjC,YAAYC,GAAsB;AAChC,IAAAA,EAAU,KAAkB,aAAa,EAAE,GAAGd,CAAkB;AAAA,EAClE;AACF;","x_google_ignoreList":[0,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 { default as 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,\n @inject(\"CristalApp\") cristalApp: CristalApp,\n ) {\n this.initialize();\n this.logger = logger;\n this.cristalApp = cristalApp;\n }\n\n async pageLoaded(page: string): Promise<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\n await 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\n this.workerInstance.setPageLoadedCallback(\n Comlink.proxy(async (page: string) => {\n await 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\n/**\n * @beta\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;AAAA;AAAA,EAGrD;AAAA,EACA;AAAA,EACA;AAAA,EAED,YACaC,GACIC,GAC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YAAQ,IAAI,6BAA6BA,CAAI,GACzC,KAAK,kBAAkB,OACzB,MAAM,KAAK,eAAe,WAAWA,CAAI,IAEzC,QAAQ,IAAI,qCAAqC;AAAA,EAErD;AAAA,EAEA,MAAa,eAAgC;AAE3C,WADA,QAAQ,IAAI,6BAA6B,GACrC,KAAK,kBAAkB,OAClB,KAEA,MAAM,KAAK,eAAe,aAAA;AAAA,EAErC;AACF;AAzGqBH,IAArBW,EAAA;AAAA,EADCC,EAAA;AAAA,EASIC,OAAO,QAAQ,CAAA;AAAA,EACfA,OAAO,YAAY,CAAA;AAAA,GATHb,CAAA;ACFrB,MAAqBc,EAAc;AAAA,EACjC,YAAYC,GAAsB;AAChC,IAAAA,EAAU,KAAkB,aAAa,EAAE,GAAGf,CAAkB;AAAA,EAClE;AACF;"}
package/dist/index.umd.js CHANGED
@@ -1,12 +1,2 @@
1
- (function(d,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("@xwiki/cristal-document-api"),require("comlink")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-document-api","comlink"],g):(d=typeof globalThis<"u"?globalThis:d||self,g(d.cristal_impl={},d.cristalDocumentApi,d.Comlink))})(this,function(d,g,_){"use strict";function Q(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const M=Q(_);function E(n){return new SharedWorker("/assets/worker-D5o17ttR.js",{type:"module",name:n?.name})}function I(n,e,t){return Reflect.getOwnMetadata(e,n,t)}function K(n,e,t,r){Reflect.defineMetadata(e,t,n,r)}function h(n,e,t,r,i){const o=r(I(n,e,i)??t());Reflect.defineMetadata(e,o,n,i)}var x,O,A;(function(n){n.moduleId="moduleId",n.serviceId="serviceId"})(x||(x={})),function(n){n.id="id",n.moduleId="moduleId",n.serviceId="serviceId"}(O||(O={})),function(n){n.moduleId="moduleId",n.serviceId="serviceId"}(A||(A={}));const k="@inversifyjs/core/classMetadataReflectKey";function y(){return{constructorArguments:[],lifecycle:{postConstructMethodName:void 0,preDestroyMethodName:void 0},properties:new Map,scope:void 0}}const W="@inversifyjs/core/pendingClassMetadataCountReflectKey",C=Symbol.for("@inversifyjs/core/InversifyCoreError");class u extends Error{[C];kind;constructor(e,t,r){super(t,r),this[C]=!0,this.kind=e}static is(e){return typeof e=="object"&&e!==null&&e[C]===!0}static isErrorOfKind(e,t){return u.is(e)&&e.kind===t}}var l,j,p;function L(){return 0}function N(n){return e=>{e!==void 0&&e.kind===j.unknown&&h(n,W,L,t=>t-1)}}function U(n,e){return(...t)=>r=>{if(r===void 0)return n(...t);if(r.kind===p.unmanaged)throw new u(l.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found");return e(r,...t)}}function q(n){if(n.kind!==j.unknown&&n.isFromTypescriptParamType!==!0)throw new u(l.injectionDecoratorConflict,"Unexpected injection found. Multiple @inject, @multiInject or @unmanaged decorators found")}(function(n){n[n.injectionDecoratorConflict=0]="injectionDecoratorConflict",n[n.missingInjectionDecorator=1]="missingInjectionDecorator",n[n.planning=2]="planning",n[n.resolution=3]="resolution",n[n.unknown=4]="unknown"})(l||(l={})),function(n){n[n.unknown=32]="unknown"}(j||(j={})),function(n){n[n.multipleInjection=0]="multipleInjection",n[n.singleInjection=1]="singleInjection",n[n.unmanaged=2]="unmanaged"}(p||(p={}));const B=U(function(n,e,t){return n===p.multipleInjection?{chained:t?.chained??!1,kind:n,name:void 0,optional:!1,tags:new Map,value:e}:{kind:n,name:void 0,optional:!1,tags:new Map,value:e}},function(n,e,t,r){return q(n),e===p.multipleInjection?{...n,chained:r?.chained??!1,kind:e,value:t}:{...n,kind:e,value:t}});function T(n,e){return t=>{const r=t.properties.get(e);return t.properties.set(e,n(r)),t}}var f;function G(n,e,t,r){if(u.isErrorOfKind(r,l.injectionDecoratorConflict)){const i=function(o,c,a){if(a===void 0){if(c===void 0)throw new u(l.unknown,"Unexpected undefined property and index values");return{kind:f.property,property:c,targetClass:o.constructor}}return typeof a=="number"?{index:a,kind:f.parameter,targetClass:o}:{kind:f.method,method:c,targetClass:o}}(n,e,t);throw new u(l.injectionDecoratorConflict,`Unexpected injection error.
2
-
3
- Cause:
4
-
5
- ${r.message}
6
-
7
- Details
8
-
9
- ${function(o){switch(o.kind){case f.method:return`[class: "${o.targetClass.name}", method: "${o.method.toString()}"]`;case f.parameter:return`[class: "${o.targetClass.name}", index: "${o.index.toString()}"]`;case f.property:return`[class: "${o.targetClass.name}", property: "${o.property.toString()}"]`}}(i)}`,{cause:r})}throw r}function V(n,e){return(t,r,i)=>{try{i===void 0?function(o,c){const a=b(o,c);return(s,m)=>{h(s.constructor,k,y,T(a(s),m))}}(n,e)(t,r):typeof i=="number"?function(o,c){const a=b(o,c);return(s,m,S)=>{if(!function(w,v){return typeof w=="function"&&v===void 0}(s,m))throw new u(l.injectionDecoratorConflict,`Found an @inject decorator in a non constructor parameter.
10
- Found @inject decorator at method "${m?.toString()??""}" at class "${s.constructor.name}"`);h(s,k,y,function(w,v){return $=>{const en=$.constructorArguments[v];return $.constructorArguments[v]=w(en),$}}(a(s),S))}}(n,e)(t,r,i):function(o,c){const a=b(o,c);return(s,m,S)=>{if(!function(w){return w.set!==void 0}(S))throw new u(l.injectionDecoratorConflict,`Found an @inject decorator in a non setter property method.
11
- Found @inject decorator at method "${m.toString()}" at class "${s.constructor.name}"`);h(s.constructor,k,y,T(a(s),m))}}(n,e)(t,r,i)}catch(o){G(t,r,i,o)}}}function b(n,e){return t=>{const r=e(t);return i=>(r(i),n(i))}}function P(n){return V(B(p.singleInjection,n),N)}(function(n){n[n.method=0]="method",n[n.parameter=1]="parameter",n[n.property=2]="property"})(f||(f={}));const z="@inversifyjs/core/classIsInjectableFlagReflectKey",H=[Array,BigInt,Boolean,Function,Number,Object,String];function J(n){const e=I(n,"design:paramtypes");e!==void 0&&h(n,k,y,function(t){return r=>(t.forEach((i,o)=>{var c;r.constructorArguments[o]!==void 0||(c=i,H.includes(c))||(r.constructorArguments[o]=function(a){return{isFromTypescriptParamType:!0,kind:p.singleInjection,name:void 0,optional:!1,tags:new Map,value:a}}(i))}),r)}(e))}function X(n){return e=>{(function(t){if(I(t,z)!==void 0)throw new u(l.injectionDecoratorConflict,`Cannot apply @injectable decorator multiple times at class "${t.name}"`);K(t,z,!0)})(e),J(e)}}var F;(function(n){n[n.multipleInjection=0]="multipleInjection",n[n.singleInjection=1]="singleInjection"})(F||(F={}));var Y=Object.getOwnPropertyDescriptor,Z=(n,e,t,r)=>{for(var i=r>1?void 0:r?Y(e,t):e,o=n.length-1,c;o>=0;o--)(c=n[o])&&(i=c(i)||i);return i},R=(n,e)=>(t,r)=>e(t,r,n);let D=class{constructor(n,e){this.initialize(),this.logger=n,this.cristalApp=e}async pageLoaded(n){try{this.logger.debug("Received callback that new document has been loaded",n),await this.cristalApp.getContainer().get(g.name).refreshCurrentDocument(),this.logger.debug("Done callback that new document has been loaded",n)}catch(e){this.logger.error("Error calling loadPage",e)}}initialize(){try{if(this.workerInstance==null){const n=new E({name:"cristal-sharedworker"});this.workerInstance=M.wrap(n.port);const e=this;this.workerInstance.setPageLoadedCallback(M.proxy(async t=>{await e.pageLoaded(t)})),console.debug("Worker initialized",this.workerInstance)}else console.debug("Already initialized")}catch(n){console.error("Failed to initialize shared worker",n)}}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 n=await this.workerInstance.add(1);return console.log("Results from shared worker: ",n),n}}async addToQueue(n){console.log("worker Calling addToQueue",n),this.workerInstance!=null?await this.workerInstance.addToQueue(n):console.log("workerInstance is null. Cannot call")}async getQueueSize(){return console.log("worker Calling getQueueSize"),this.workerInstance==null?-1:await this.workerInstance.getQueueSize()}};D=Z([X(),R(0,P("Logger")),R(1,P("CristalApp"))],D);class nn{constructor(e){e.bind("QueueWorker").to(D)}}d.ComponentInit=nn,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1
+ (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@xwiki/cristal-document-api"),require("comlink"),require("inversify")):typeof define=="function"&&define.amd?define(["exports","@xwiki/cristal-document-api","comlink","inversify"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.cristal_impl={},n.cristalDocumentApi,n.Comlink,n.inversify))})(this,(function(n,i,w,s){"use strict";function k(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const u=k(w);function p(e){return new SharedWorker("/assets/worker-Cd03GOHu.js",{type:"module",name:e?.name})}var h=Object.getOwnPropertyDescriptor,f=(e,t,r,o)=>{for(var a=o>1?void 0:o?h(t,r):t,c=e.length-1,g;c>=0;c--)(g=e[c])&&(a=g(a)||a);return a},d=(e,t)=>(r,o)=>t(r,o,e);let l=class{workerInstance;cristalApp;logger;constructor(e,t){this.initialize(),this.logger=e,this.cristalApp=t}async pageLoaded(e){try{this.logger.debug("Received callback that new document has been loaded",e),await this.cristalApp.getContainer().get(i.name).refreshCurrentDocument(),this.logger.debug("Done callback that new document has been loaded",e)}catch(t){this.logger.error("Error calling loadPage",t)}}initialize(){try{if(this.workerInstance==null){const e=new p({name:"cristal-sharedworker"});this.workerInstance=u.wrap(e.port);const t=this;this.workerInstance.setPageLoadedCallback(u.proxy(async r=>{await t.pageLoaded(r)})),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=f([s.injectable(),d(0,s.inject("Logger")),d(1,s.inject("CristalApp"))],l);class m{constructor(t){t.bind("QueueWorker").to(l)}}n.ComponentInit=m,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
12
2
  //# sourceMappingURL=index.umd.js.map