@capytale/iframe-react 1.1.15 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { jsx as Q, jsxs as gt, Fragment as pt } from "react/jsx-runtime";
2
- import L, { useCallback as A, useEffect as w, useMemo as U } from "react";
1
+ import { jsx as Q, jsxs as ft, Fragment as pt } from "react/jsx-runtime";
2
+ import L, { useCallback as h, useEffect as w, useMemo as U } from "react";
3
3
  const et = Symbol("Comlink.proxy"), mt = Symbol("Comlink.endpoint"), yt = Symbol("Comlink.releaseProxy"), q = Symbol("Comlink.finalizer"), I = Symbol("Comlink.thrown"), nt = (t) => typeof t == "object" && t !== null || typeof t == "function", vt = {
4
4
  canHandle: (t) => nt(t) && t[et],
5
5
  serialize(t) {
@@ -43,30 +43,30 @@ function _(t, e = globalThis, n = ["*"]) {
43
43
  console.warn(`Invalid origin '${o.origin}' for comlink proxy`);
44
44
  return;
45
45
  }
46
- const { id: s, type: g, path: l } = Object.assign({ path: [] }, o.data), f = (o.data.argumentList || []).map(k);
46
+ const { id: s, type: f, path: c } = Object.assign({ path: [] }, o.data), g = (o.data.argumentList || []).map(x);
47
47
  let d;
48
48
  try {
49
- const u = l.slice(0, -1).reduce((y, C) => y[C], t), p = l.reduce((y, C) => y[C], t);
50
- switch (g) {
49
+ const u = c.slice(0, -1).reduce((y, C) => y[C], t), p = c.reduce((y, C) => y[C], t);
50
+ switch (f) {
51
51
  case "GET":
52
52
  d = p;
53
53
  break;
54
54
  case "SET":
55
- u[l.slice(-1)[0]] = k(o.data.value), d = !0;
55
+ u[c.slice(-1)[0]] = x(o.data.value), d = !0;
56
56
  break;
57
57
  case "APPLY":
58
- d = p.apply(u, f);
58
+ d = p.apply(u, g);
59
59
  break;
60
60
  case "CONSTRUCT":
61
61
  {
62
- const y = new p(...f);
63
- d = lt(y);
62
+ const y = new p(...g);
63
+ d = ct(y);
64
64
  }
65
65
  break;
66
66
  case "ENDPOINT":
67
67
  {
68
68
  const { port1: y, port2: C } = new MessageChannel();
69
- _(t, C), d = Et(y, [y]);
69
+ _(t, C), d = Rt(y, [y]);
70
70
  }
71
71
  break;
72
72
  case "RELEASE":
@@ -80,7 +80,7 @@ function _(t, e = globalThis, n = ["*"]) {
80
80
  }
81
81
  Promise.resolve(d).catch((u) => ({ value: u, [I]: 0 })).then((u) => {
82
82
  const [p, y] = O(u);
83
- e.postMessage(Object.assign(Object.assign({}, p), { id: s }), y), g === "RELEASE" && (e.removeEventListener("message", r), rt(e), q in t && typeof t[q] == "function" && t[q]());
83
+ e.postMessage(Object.assign(Object.assign({}, p), { id: s }), y), f === "RELEASE" && (e.removeEventListener("message", r), rt(e), q in t && typeof t[q] == "function" && t[q]());
84
84
  }).catch((u) => {
85
85
  const [p, y] = O({
86
86
  value: new TypeError("Unserializable return value"),
@@ -102,10 +102,10 @@ function st(t, e) {
102
102
  const { data: s } = o;
103
103
  if (!s || !s.id)
104
104
  return;
105
- const g = n.get(s.id);
106
- if (g)
105
+ const f = n.get(s.id);
106
+ if (f)
107
107
  try {
108
- g(s);
108
+ f(s);
109
109
  } finally {
110
110
  n.delete(s.id);
111
111
  }
@@ -115,8 +115,8 @@ function G(t) {
115
115
  if (t)
116
116
  throw new Error("Proxy has been released and is not useable");
117
117
  }
118
- function at(t) {
119
- return T(t, /* @__PURE__ */ new Map(), {
118
+ function it(t) {
119
+ return M(t, /* @__PURE__ */ new Map(), {
120
120
  type: "RELEASE"
121
121
  }).then(() => {
122
122
  rt(t);
@@ -124,87 +124,87 @@ function at(t) {
124
124
  }
125
125
  const j = /* @__PURE__ */ new WeakMap(), $ = "FinalizationRegistry" in globalThis && new FinalizationRegistry((t) => {
126
126
  const e = (j.get(t) || 0) - 1;
127
- j.set(t, e), e === 0 && at(t);
127
+ j.set(t, e), e === 0 && it(t);
128
128
  });
129
- function ht(t, e) {
129
+ function bt(t, e) {
130
130
  const n = (j.get(e) || 0) + 1;
131
131
  j.set(e, n), $ && $.register(t, e, t);
132
132
  }
133
- function At(t) {
133
+ function ht(t) {
134
134
  $ && $.unregister(t);
135
135
  }
136
136
  function z(t, e, n = [], r = function() {
137
137
  }) {
138
138
  let o = !1;
139
139
  const s = new Proxy(r, {
140
- get(g, l) {
141
- if (G(o), l === yt)
140
+ get(f, c) {
141
+ if (G(o), c === yt)
142
142
  return () => {
143
- At(s), at(t), e.clear(), o = !0;
143
+ ht(s), it(t), e.clear(), o = !0;
144
144
  };
145
- if (l === "then") {
145
+ if (c === "then") {
146
146
  if (n.length === 0)
147
147
  return { then: () => s };
148
- const f = T(t, e, {
148
+ const g = M(t, e, {
149
149
  type: "GET",
150
150
  path: n.map((d) => d.toString())
151
- }).then(k);
152
- return f.then.bind(f);
151
+ }).then(x);
152
+ return g.then.bind(g);
153
153
  }
154
- return z(t, e, [...n, l]);
154
+ return z(t, e, [...n, c]);
155
155
  },
156
- set(g, l, f) {
156
+ set(f, c, g) {
157
157
  G(o);
158
- const [d, u] = O(f);
159
- return T(t, e, {
158
+ const [d, u] = O(g);
159
+ return M(t, e, {
160
160
  type: "SET",
161
- path: [...n, l].map((p) => p.toString()),
161
+ path: [...n, c].map((p) => p.toString()),
162
162
  value: d
163
- }, u).then(k);
163
+ }, u).then(x);
164
164
  },
165
- apply(g, l, f) {
165
+ apply(f, c, g) {
166
166
  G(o);
167
167
  const d = n[n.length - 1];
168
168
  if (d === mt)
169
- return T(t, e, {
169
+ return M(t, e, {
170
170
  type: "ENDPOINT"
171
- }).then(k);
171
+ }).then(x);
172
172
  if (d === "bind")
173
173
  return z(t, e, n.slice(0, -1));
174
- const [u, p] = Y(f);
175
- return T(t, e, {
174
+ const [u, p] = Y(g);
175
+ return M(t, e, {
176
176
  type: "APPLY",
177
177
  path: n.map((y) => y.toString()),
178
178
  argumentList: u
179
- }, p).then(k);
179
+ }, p).then(x);
180
180
  },
181
- construct(g, l) {
181
+ construct(f, c) {
182
182
  G(o);
183
- const [f, d] = Y(l);
184
- return T(t, e, {
183
+ const [g, d] = Y(c);
184
+ return M(t, e, {
185
185
  type: "CONSTRUCT",
186
186
  path: n.map((u) => u.toString()),
187
- argumentList: f
188
- }, d).then(k);
187
+ argumentList: g
188
+ }, d).then(x);
189
189
  }
190
190
  });
191
- return ht(s, t), s;
191
+ return bt(s, t), s;
192
192
  }
193
- function bt(t) {
193
+ function At(t) {
194
194
  return Array.prototype.concat.apply([], t);
195
195
  }
196
196
  function Y(t) {
197
197
  const e = t.map(O);
198
- return [e.map((n) => n[0]), bt(e.map((n) => n[1]))];
198
+ return [e.map((n) => n[0]), At(e.map((n) => n[1]))];
199
199
  }
200
- const it = /* @__PURE__ */ new WeakMap();
201
- function Et(t, e) {
202
- return it.set(t, e), t;
200
+ const at = /* @__PURE__ */ new WeakMap();
201
+ function Rt(t, e) {
202
+ return at.set(t, e), t;
203
203
  }
204
- function lt(t) {
204
+ function ct(t) {
205
205
  return Object.assign(t, { [et]: !0 });
206
206
  }
207
- function Ft(t, e = globalThis, n = "*") {
207
+ function Et(t, e = globalThis, n = "*") {
208
208
  return {
209
209
  postMessage: (r, o) => t.postMessage(r, n, o),
210
210
  addEventListener: e.addEventListener.bind(e),
@@ -229,10 +229,10 @@ function O(t) {
229
229
  type: "RAW",
230
230
  value: t
231
231
  },
232
- it.get(t) || []
232
+ at.get(t) || []
233
233
  ];
234
234
  }
235
- function k(t) {
235
+ function x(t) {
236
236
  switch (t.type) {
237
237
  case "HANDLER":
238
238
  return ot.get(t.name).deserialize(t.value);
@@ -240,26 +240,26 @@ function k(t) {
240
240
  return t.value;
241
241
  }
242
242
  }
243
- function T(t, e, n, r) {
243
+ function M(t, e, n, r) {
244
244
  return new Promise((o) => {
245
- const s = xt();
245
+ const s = Ft();
246
246
  e.set(s, o), t.start && t.start(), t.postMessage(Object.assign({ id: s }, n), r);
247
247
  });
248
248
  }
249
- function xt() {
249
+ function Ft() {
250
250
  return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
251
251
  }
252
- function kt(t, e) {
252
+ function xt(t, e) {
253
253
  return t.length === 0 ? e : `[${t}] ${e}`;
254
254
  }
255
- function Jt(t, e) {
255
+ function kt(t, e) {
256
256
  let n = !1, r, o, s;
257
- function g(u) {
258
- return kt(t, u);
257
+ function f(u) {
258
+ return xt(t, u);
259
259
  }
260
- let l, f = !1;
260
+ let c, g = !1;
261
261
  if (window.parent === window)
262
- console.warn(g("Contract link is not supported in standalone mode")), l = {
262
+ console.warn(f("Contract link is not supported in standalone mode")), c = {
263
263
  ready() {
264
264
  return Promise.resolve();
265
265
  },
@@ -274,37 +274,37 @@ function Jt(t, e) {
274
274
  }
275
275
  };
276
276
  else {
277
- const u = Ft(window.parent, void 0, e);
277
+ const u = Et(window.parent, void 0, e);
278
278
  _({
279
279
  declare(p) {
280
- if (r == null) throw new Error(g("No handler for declare"));
280
+ if (r == null) throw new Error(f("No handler for declare"));
281
281
  r(p);
282
282
  },
283
283
  done() {
284
- if (o == null) throw new Error(g("No handler for done"));
284
+ if (o == null) throw new Error(f("No handler for done"));
285
285
  o();
286
286
  },
287
287
  provide(p, y, C) {
288
- if (s == null) throw new Error(g("No handler for provide"));
288
+ if (s == null) throw new Error(f("No handler for provide"));
289
289
  s(p, y, C);
290
290
  }
291
- }, u), l = st(u), f = !0;
291
+ }, u), c = st(u), g = !0;
292
292
  }
293
293
  const d = () => {
294
294
  if (!n) {
295
295
  if (r == null || o == null || s == null) return;
296
- n = !0, l.ready();
296
+ n = !0, c.ready();
297
297
  }
298
298
  };
299
299
  return {
300
- declare: (u) => l.declare(u),
301
- done: () => l.done(),
302
- provide: (u, p, y) => l.provide(u, p, lt(y)),
300
+ declare: (u) => c.declare(u),
301
+ done: () => c.done(),
302
+ provide: (u, p, y) => c.provide(u, p, ct(y)),
303
303
  get name() {
304
304
  return t;
305
305
  },
306
306
  get isReady() {
307
- return f;
307
+ return g;
308
308
  },
309
309
  set onDeclare(u) {
310
310
  r = u, d();
@@ -317,23 +317,23 @@ function Jt(t, e) {
317
317
  }
318
318
  };
319
319
  }
320
- function Mt(t) {
320
+ function Jt(t) {
321
321
  return function(e) {
322
- let n, r = !1, o = !1, s, g, l = !1, f = !1, d, u, p, y;
322
+ let n, r = !1, o = !1, s, f, c = !1, g = !1, d, u, p, y;
323
323
  function C() {
324
- if (s != null && s !== 0 && g != null)
325
- return g;
324
+ if (s != null && s !== 0 && f != null)
325
+ return f;
326
326
  }
327
- function F(a) {
328
- if (s != null && g != null && !(a > s))
329
- return g;
327
+ function E(i) {
328
+ if (s != null && f != null && !(i > s))
329
+ return f;
330
330
  }
331
- function b() {
332
- return p ?? (f ? p = Promise.resolve() : p = new Promise((a, c) => {
333
- y = a;
331
+ function A() {
332
+ return p ?? (g ? p = Promise.resolve() : p = new Promise((i, l) => {
333
+ y = i;
334
334
  }));
335
335
  }
336
- function J() {
336
+ function k() {
337
337
  return d === void 0 && (d = {
338
338
  get name() {
339
339
  return e;
@@ -344,30 +344,30 @@ function Mt(t) {
344
344
  get i() {
345
345
  return C();
346
346
  },
347
- v: (a) => F(a)
347
+ v: (i) => E(i)
348
348
  }), d;
349
349
  }
350
- function R() {
350
+ function T() {
351
351
  return u === void 0 && (u = {
352
352
  get name() {
353
353
  return e;
354
354
  },
355
355
  get version() {
356
- return f ? s : void 0;
356
+ return g ? s : void 0;
357
357
  },
358
358
  get i() {
359
- return f ? C() : void 0;
359
+ return g ? C() : void 0;
360
360
  },
361
- v: (a) => f ? F(a) : void 0,
361
+ v: (i) => g ? E(i) : void 0,
362
362
  get promise() {
363
- return s === 0 ? Promise.reject(t("Remote interface not provided")) : b().then(() => {
363
+ return s === 0 ? Promise.reject(t("Remote interface not provided")) : A().then(() => {
364
364
  if (s === 0) throw new Error(t("Remote interface not provided"));
365
- return J();
365
+ return k();
366
366
  });
367
367
  }
368
368
  }), u;
369
369
  }
370
- function x() {
370
+ function F() {
371
371
  y != null && (y(), y = void 0);
372
372
  }
373
373
  return {
@@ -378,90 +378,90 @@ function Mt(t) {
378
378
  if (n != null)
379
379
  return n;
380
380
  },
381
- set localVersion(a) {
382
- if (n != null && n !== a) throw new Error(t("A different local version is already set"));
383
- n = a;
381
+ set localVersion(i) {
382
+ if (n != null && n !== i) throw new Error(t("A different local version is already set"));
383
+ n = i;
384
384
  },
385
385
  get localVersionSent() {
386
386
  return r;
387
387
  },
388
- set localVersionSent(a) {
389
- if (!a && r) throw new Error(t("Local version already notified"));
390
- r = a, a && n === 0 && (o = !0);
388
+ set localVersionSent(i) {
389
+ if (!i && r) throw new Error(t("Local version already notified"));
390
+ r = i, i && n === 0 && (o = !0);
391
391
  },
392
392
  get localInterfaceSent() {
393
393
  return o;
394
394
  },
395
- set localInterfaceSent(a) {
395
+ set localInterfaceSent(i) {
396
396
  if (n == null) throw new Error(t("Local version not set"));
397
- if (!a && o) throw new Error(t("Local interface already sent."));
398
- o = a;
397
+ if (!i && o) throw new Error(t("Local interface already sent."));
398
+ o = i;
399
399
  },
400
400
  get remoteVersion() {
401
401
  if (s != null)
402
402
  return s;
403
403
  },
404
- set remoteVersion(a) {
405
- if (s != null && s !== a) throw new Error(t("A different remote version is already set for " + e + `(${s} -> ${a})`));
406
- s = a, a === 0 && (l = !0);
404
+ set remoteVersion(i) {
405
+ if (s != null && s !== i) throw new Error(t("A different remote version is already set for " + e + `(${s} -> ${i})`));
406
+ s = i, i === 0 && (c = !0);
407
407
  },
408
408
  get remoteVersionReceived() {
409
409
  return s != null;
410
410
  },
411
- setRemoteInterface: (a) => {
411
+ setRemoteInterface: (i) => {
412
412
  if (s == null) throw new Error(t("Remote version not set"));
413
413
  if (s === 0) {
414
414
  console.warn(t("Remote version is 0, remote interface is ignored."));
415
415
  return;
416
416
  }
417
- if (l) throw new Error(t("Interface already provided."));
418
- g = a, l = !0;
417
+ if (c) throw new Error(t("Interface already provided."));
418
+ f = i, c = !0;
419
419
  },
420
420
  get remoteInterfaceReceived() {
421
- return l;
421
+ return c;
422
422
  },
423
423
  depGroup: void 0,
424
424
  get isActivable() {
425
- return l && o;
425
+ return c && o;
426
426
  },
427
427
  get isActivated() {
428
- return f;
428
+ return g;
429
429
  },
430
430
  activate() {
431
- if (!f) {
432
- if (!l) throw new Error(t("Remote interface not provided."));
431
+ if (!g) {
432
+ if (!c) throw new Error(t("Remote interface not provided."));
433
433
  if (!o) throw new Error(t("Local interface not sent"));
434
- f = !0, x();
434
+ g = !0, F();
435
435
  }
436
436
  },
437
- getRemote: () => J(),
438
- getLazyRemote: () => R(),
437
+ getRemote: () => k(),
438
+ getLazyRemote: () => T(),
439
439
  get activationPromise() {
440
- return b();
440
+ return A();
441
441
  }
442
442
  };
443
443
  };
444
444
  }
445
- function Tt(t) {
445
+ function Mt(t) {
446
446
  return function(e, n, r, o) {
447
- let s = r, g = !1, l = !1;
448
- function f() {
447
+ let s = r, f = !1, c = !1;
448
+ function g() {
449
449
  return e.every((d) => d.remoteVersionReceived && d.localVersionSent) && n.every((d) => d.remoteVersionReceived);
450
450
  }
451
451
  return {
452
452
  get isDeclared() {
453
- return l;
453
+ return c;
454
454
  },
455
455
  set isDeclared(d) {
456
- if (!d && l)
456
+ if (!d && c)
457
457
  throw new Error(t("Factory already declared"));
458
- l = d;
458
+ c = d;
459
459
  },
460
460
  get isReady() {
461
- return f();
461
+ return g();
462
462
  },
463
463
  get isDone() {
464
- return g;
464
+ return f;
465
465
  },
466
466
  get args() {
467
467
  return e;
@@ -470,9 +470,9 @@ function Tt(t) {
470
470
  return n;
471
471
  },
472
472
  invoke() {
473
- if (g)
473
+ if (f)
474
474
  throw new Error(t("Factory already invoked"));
475
- if (!f())
475
+ if (!g())
476
476
  throw new Error(t("Factory is not ready"));
477
477
  let d;
478
478
  o ? d = e.map((y) => y.getRemote()) : d = e[0].getRemote();
@@ -485,181 +485,181 @@ function Tt(t) {
485
485
  }
486
486
  if (o || (u = [u]), u.length != e.length)
487
487
  throw new Error(t("Invalid factory result"));
488
- return g = !0, s = null, u;
488
+ return f = !0, s = null, u;
489
489
  }
490
490
  };
491
491
  };
492
492
  }
493
- function Rt(t) {
493
+ function Tt(t) {
494
494
  return function(e, n, r, o) {
495
- let s = n, g = !1;
496
- function l() {
497
- return e.every((f) => f.isActivated);
495
+ let s = n, f = !1;
496
+ function c() {
497
+ return e.every((g) => g.isActivated);
498
498
  }
499
499
  return {
500
500
  get isReady() {
501
- return l();
501
+ return c();
502
502
  },
503
503
  get isDone() {
504
- return g;
504
+ return f;
505
505
  },
506
506
  get args() {
507
507
  return e;
508
508
  },
509
509
  invoke() {
510
- if (g || !l()) {
511
- const u = new Error(t(g ? "callback already invoked" : "callback parameters are not ready"));
510
+ if (f || !c()) {
511
+ const u = new Error(t(f ? "callback already invoked" : "callback parameters are not ready"));
512
512
  throw o?.[1](u), u;
513
513
  }
514
- const f = r ? e.map((u) => u.getRemote()) : e[0].getRemote();
514
+ const g = r ? e.map((u) => u.getRemote()) : e[0].getRemote();
515
515
  let d;
516
516
  try {
517
- d = s(f);
517
+ d = s(g);
518
518
  } catch (u) {
519
519
  o == null ? console.error(t("error in callback:"), u) : o[1](u);
520
520
  } finally {
521
- g = !0;
521
+ f = !0;
522
522
  }
523
523
  o?.[0](d);
524
524
  }
525
525
  };
526
526
  };
527
527
  }
528
- function ct(t, e) {
528
+ function lt(t, e) {
529
529
  return t == null || t.length === 0 ? e : `[${t}] ${e}`;
530
530
  }
531
531
  function Lt(t) {
532
- function e(a) {
533
- return ct(t.name, a);
532
+ function e(i) {
533
+ return lt(t.name, i);
534
534
  }
535
- const n = Rt(e), r = Mt(e), o = Tt(e), s = {}, g = [];
536
- let l = [], f;
537
- const d = () => (f == null ? f = 0 : f++, f);
538
- function u(a) {
539
- let c = s[a];
540
- return c == null && (c = r(a), c.localVersion == null && (b && (c.localVersion = 0), J && (c.localVersionSent = !0)), c.remoteVersion == null && R && (c.remoteVersion = 0), s[a] = c), c;
535
+ const n = Tt(e), r = Jt(e), o = Mt(e), s = {}, f = [];
536
+ let c = [], g;
537
+ const d = () => (g == null ? g = 0 : g++, g);
538
+ function u(i) {
539
+ let l = s[i];
540
+ return l == null && (l = r(i), l.localVersion == null && (A && (l.localVersion = 0), k && (l.localVersionSent = !0)), l.remoteVersion == null && T && (l.remoteVersion = 0), s[i] = l), l;
541
541
  }
542
- function p(a) {
543
- return a.map(u);
542
+ function p(i) {
543
+ return i.map(u);
544
544
  }
545
- function y(...a) {
546
- const c = d(), m = Array(c).fill(!1);
547
- a.forEach((v) => {
545
+ function y(...i) {
546
+ const l = d(), m = Array(l).fill(!1);
547
+ i.forEach((v) => {
548
548
  v.forEach((S) => {
549
- S.depGroup != null && (m[S.depGroup] = !0), S.depGroup = c;
549
+ S.depGroup != null && (m[S.depGroup] = !0), S.depGroup = l;
550
550
  });
551
551
  }), Object.values(s).forEach((v) => {
552
- v.depGroup != null && v.depGroup !== c && m[v.depGroup] && (v.depGroup = c);
552
+ v.depGroup != null && v.depGroup !== l && m[v.depGroup] && (v.depGroup = l);
553
553
  });
554
554
  }
555
- t.onDeclare = (a) => {
556
- const c = p(a.map((m) => m.name));
557
- for (let m = 0; m < a.length; m++)
558
- a[m].version != null && (c[m].remoteVersion = a[m].version);
559
- y(c), x();
555
+ t.onDeclare = (i) => {
556
+ const l = p(i.map((m) => m.name));
557
+ for (let m = 0; m < i.length; m++)
558
+ i[m].version != null && (l[m].remoteVersion = i[m].version);
559
+ y(l), F();
560
560
  }, t.onDone = () => {
561
- R || (R = !0, Object.values(s).forEach((a) => {
562
- a.remoteVersion == null && (a.remoteVersion = 0);
563
- }), x());
564
- }, t.onProvide = (a, c, m) => {
565
- let v = s[a];
561
+ T || (T = !0, Object.values(s).forEach((i) => {
562
+ i.remoteVersion == null && (i.remoteVersion = 0);
563
+ }), F());
564
+ }, t.onProvide = (i, l, m) => {
565
+ let v = s[i];
566
566
  if (v == null)
567
- throw new Error(e(`Contract not declared : ${a}`));
568
- if (v.remoteVersion != c)
569
- throw new Error(e(`Remote declared version ${v.remoteVersion} of contract "${a}" but provided version ${c}.`));
567
+ throw new Error(e(`Contract not declared : ${i}`));
568
+ if (v.remoteVersion != l)
569
+ throw new Error(e(`Remote declared version ${v.remoteVersion} of contract "${i}" but provided version ${l}.`));
570
570
  if (v.remoteInterfaceReceived)
571
- throw new Error(e(`Remote contract "${a}" is already provided.`));
572
- v.setRemoteInterface(m), x();
571
+ throw new Error(e(`Remote contract "${i}" is already provided.`));
572
+ v.setRemoteInterface(m), F();
573
573
  };
574
- let C = !1, F = !1, b = !1, J = !1, R = !1;
575
- async function x() {
576
- if (F = !0, !C) {
577
- for (C = !0; F; ) {
578
- if (F = !1, t.isReady) {
579
- const a = g.filter((c) => !c.isDeclared);
580
- if (a.length > 0)
581
- for (const c of a) {
582
- const m = Array(c.args.length + c.deps.length);
583
- c.args.forEach((v, S) => m[S] = v), c.deps.forEach((v, S) => m[S + c.args.length] = v), await t.declare(m.map((v) => ({ name: v.name, version: v.localVersion }))), m.forEach((v) => {
574
+ let C = !1, E = !1, A = !1, k = !1, T = !1;
575
+ async function F() {
576
+ if (E = !0, !C) {
577
+ for (C = !0; E; ) {
578
+ if (E = !1, t.isReady) {
579
+ const i = f.filter((l) => !l.isDeclared);
580
+ if (i.length > 0)
581
+ for (const l of i) {
582
+ const m = Array(l.args.length + l.deps.length);
583
+ l.args.forEach((v, S) => m[S] = v), l.deps.forEach((v, S) => m[S + l.args.length] = v), await t.declare(m.map((v) => ({ name: v.name, version: v.localVersion }))), m.forEach((v) => {
584
584
  v.localVersion != null && (v.localVersionSent = !0);
585
- }), c.isDeclared = !0;
585
+ }), l.isDeclared = !0;
586
586
  }
587
587
  }
588
- if (t.isReady && b && g.every((a) => a.isDeclared)) {
589
- const a = Object.values(s).filter((c) => !c.localVersionSent && c.localVersion != null);
590
- if (a.length > 0)
591
- for (const c of a)
592
- await t.declare([{ name: c.name, version: c.localVersion }]), c.localVersionSent = !0;
593
- J || (J = !0, await t.done());
588
+ if (t.isReady && A && f.every((i) => i.isDeclared)) {
589
+ const i = Object.values(s).filter((l) => !l.localVersionSent && l.localVersion != null);
590
+ if (i.length > 0)
591
+ for (const l of i)
592
+ await t.declare([{ name: l.name, version: l.localVersion }]), l.localVersionSent = !0;
593
+ k || (k = !0, await t.done());
594
594
  }
595
595
  if (t.isReady) {
596
- const a = g.filter((c) => !c.isDone && c.isReady);
597
- if (a.length > 0)
598
- for (const c of a) {
599
- const m = c.invoke();
600
- for (let v = 0; v < c.args.length; v++) {
601
- const S = c.args[v];
596
+ const i = f.filter((l) => !l.isDone && l.isReady);
597
+ if (i.length > 0)
598
+ for (const l of i) {
599
+ const m = l.invoke();
600
+ for (let v = 0; v < l.args.length; v++) {
601
+ const S = l.args[v];
602
602
  await t.provide(S.name, S.localVersion, m[v]), S.localInterfaceSent = !0;
603
603
  }
604
604
  }
605
605
  }
606
- if (f != null) {
607
- const a = Array(f + 1).fill(null);
608
- for (const c in s) {
609
- const m = s[c];
610
- m.depGroup != null && (m.isActivable ? a[m.depGroup] == null && !m.isActivated && (a[m.depGroup] = !0) : a[m.depGroup] = !1);
606
+ if (g != null) {
607
+ const i = Array(g + 1).fill(null);
608
+ for (const l in s) {
609
+ const m = s[l];
610
+ m.depGroup != null && (m.isActivable ? i[m.depGroup] == null && !m.isActivated && (i[m.depGroup] = !0) : i[m.depGroup] = !1);
611
611
  }
612
- if (a.some((c) => c === !0))
613
- for (const c in s) {
614
- const m = s[c];
615
- m.depGroup != null && a[m.depGroup] && m.activate();
612
+ if (i.some((l) => l === !0))
613
+ for (const l in s) {
614
+ const m = s[l];
615
+ m.depGroup != null && i[m.depGroup] && m.activate();
616
616
  }
617
617
  }
618
618
  if (t.isReady) {
619
- const a = l;
620
- l = [];
621
- const c = [];
622
- for (const m of a)
623
- !m.isDone && m.isReady ? m.invoke() : c.push(m);
624
- c.push(...l), l = c;
619
+ const i = c;
620
+ c = [];
621
+ const l = [];
622
+ for (const m of i)
623
+ !m.isDone && m.isReady ? m.invoke() : l.push(m);
624
+ l.push(...c), c = l;
625
625
  }
626
626
  }
627
627
  C = !1;
628
628
  }
629
629
  }
630
630
  return {
631
- get(a) {
632
- return u(a);
631
+ get(i) {
632
+ return u(i);
633
633
  },
634
- declareFactory: (a, c, m, v) => {
635
- if (b) throw new Error(e("Cannot declare a factory after done has been set to true."));
636
- const S = p(a.map((E) => E.name));
634
+ declareFactory: (i, l, m, v) => {
635
+ if (A) throw new Error(e("Cannot declare a factory after done has been set to true."));
636
+ const S = p(i.map((R) => R.name));
637
637
  {
638
- const E = S.filter((N) => N.localVersion != null);
639
- if (E.length > 0)
640
- throw new Error(e("Cannot declare a factory for already implemented contracts : " + E.map((N) => N.name).join(", ")));
638
+ const R = S.filter((N) => N.localVersion != null);
639
+ if (R.length > 0)
640
+ throw new Error(e("Cannot declare a factory for already implemented contracts : " + R.map((N) => N.name).join(", ")));
641
641
  }
642
- for (let E = 0; E < a.length; E++)
643
- S[E].localVersion = a[E].version;
644
- const M = p(c);
645
- y(S, M);
646
- const ft = o(S, M, m, v);
647
- g.push(ft), x();
642
+ for (let R = 0; R < i.length; R++)
643
+ S[R].localVersion = i[R].version;
644
+ const J = p(l);
645
+ y(S, J);
646
+ const gt = o(S, J, m, v);
647
+ f.push(gt), F();
648
648
  },
649
- declareCallback(a, c, m, v) {
650
- const S = p(a), M = n(S, c, m, v);
651
- !C && l.length === 0 && M.isReady ? M.invoke() : (l.push(M), x());
649
+ declareCallback(i, l, m, v) {
650
+ const S = p(i), J = n(S, l, m, v);
651
+ !C && c.length === 0 && J.isReady ? J.invoke() : (c.push(J), F());
652
652
  },
653
653
  get done() {
654
- return b;
654
+ return A;
655
655
  },
656
- set done(a) {
657
- if (b) {
658
- if (!a) throw new Error(e("Cannot set done to false after it has been set to true."));
656
+ set done(i) {
657
+ if (A) {
658
+ if (!i) throw new Error(e("Cannot set done to false after it has been set to true."));
659
659
  } else
660
- a && (b = !0, Object.values(s).forEach((c) => {
661
- c.localVersion == null && (c.localVersion = 0);
662
- }), x());
660
+ i && (A = !0, Object.values(s).forEach((l) => {
661
+ l.localVersion == null && (l.localVersion = 0);
662
+ }), F());
663
663
  }
664
664
  };
665
665
  }
@@ -673,21 +673,21 @@ function Pt(t) {
673
673
  function Vt(t) {
674
674
  const e = Lt(t);
675
675
  function n(r) {
676
- return ct(t.name, r);
676
+ return lt(t.name, r);
677
677
  }
678
678
  return {
679
679
  plug(r, o, s = void 0) {
680
680
  if (e.done) throw new Error(n("Cannot plug after plugsDone."));
681
681
  s == null && (s = o, o = []);
682
- let g = !0;
683
- Array.isArray(r) || (r = [r], g = !1);
684
- const l = r.map((f) => {
685
- const d = Pt(f);
682
+ let f = !0;
683
+ Array.isArray(r) || (r = [r], f = !1);
684
+ const c = r.map((g) => {
685
+ const d = Pt(g);
686
686
  if (d == null)
687
- throw new Error(n("Invalid contract id : " + f));
687
+ throw new Error(n("Invalid contract id : " + g));
688
688
  return d;
689
689
  });
690
- e.declareFactory(l, o, s, g);
690
+ e.declareFactory(c, o, s, f);
691
691
  },
692
692
  plugsDone() {
693
693
  e.done = !0;
@@ -698,8 +698,8 @@ function Vt(t) {
698
698
  },
699
699
  exec(r, o) {
700
700
  let s = !0;
701
- return Array.isArray(r) || (r = [r], s = !1), new Promise((...g) => {
702
- e.declareCallback(r, o, s, g);
701
+ return Array.isArray(r) || (r = [r], s = !1), new Promise((...f) => {
702
+ e.declareCallback(r, o, s, f);
703
703
  });
704
704
  },
705
705
  get(r) {
@@ -710,7 +710,7 @@ function Vt(t) {
710
710
  const ut = "app-agent";
711
711
  let B;
712
712
  function Dt(t) {
713
- return B != null || (B = Vt(Jt(ut, t))), B;
713
+ return B != null || (B = Vt(kt(ut, t))), B;
714
714
  }
715
715
  console.log(`[${ut}@1.0.12] loaded`);
716
716
  const K = (t) => {
@@ -721,8 +721,8 @@ const K = (t) => {
721
721
  const y = e;
722
722
  e = u ?? (typeof p != "object" || p === null) ? p : Object.assign({}, e, p), n.forEach((C) => C(e, y));
723
723
  }
724
- }, o = () => e, l = { setState: r, getState: o, getInitialState: () => f, subscribe: (d) => (n.add(d), () => n.delete(d)) }, f = e = t(r, o, l);
725
- return l;
724
+ }, o = () => e, c = { setState: r, getState: o, getInitialState: () => g, subscribe: (d) => (n.add(d), () => n.delete(d)) }, g = e = t(r, o, c);
725
+ return c;
726
726
  }, It = (t) => t ? K(t) : K, jt = (t) => t;
727
727
  function $t(t, e = jt) {
728
728
  const n = L.useSyncExternalStore(
@@ -737,22 +737,22 @@ const X = (t) => {
737
737
  return Object.assign(n, e), n;
738
738
  }, dt = (t) => t ? X(t) : X, Ot = (t) => (e, n, r) => {
739
739
  const o = r.subscribe;
740
- return r.subscribe = (g, l, f) => {
741
- let d = g;
742
- if (l) {
743
- const u = f?.equalityFn || Object.is;
744
- let p = g(r.getState());
740
+ return r.subscribe = (f, c, g) => {
741
+ let d = f;
742
+ if (c) {
743
+ const u = g?.equalityFn || Object.is;
744
+ let p = f(r.getState());
745
745
  d = (y) => {
746
- const C = g(y);
746
+ const C = f(y);
747
747
  if (!u(p, C)) {
748
- const F = p;
749
- l(p = C, F);
748
+ const E = p;
749
+ c(p = C, E);
750
750
  }
751
- }, f?.fireImmediately && l(p, p);
751
+ }, g?.fireImmediately && c(p, p);
752
752
  }
753
753
  return o(d);
754
754
  }, t(e, n, r);
755
- }, Nt = Ot, i = dt()(
755
+ }, Nt = Ot, a = dt()(
756
756
  Nt((t) => ({
757
757
  ready: !1,
758
758
  workflow: "current",
@@ -769,22 +769,22 @@ const X = (t) => {
769
769
  loadedJsonActivityBinaryData: null,
770
770
  loadedJsonAssignmentBinaryData: null,
771
771
  getTextContentFunction: () => {
772
- throw console.error("getTextContentFunction is not set"), new Error("getTextContentFunction is not set");
772
+ throw console.error("[React bindings] getTextContentFunction is not set"), new Error("[React bindings] getTextContentFunction is not set");
773
773
  },
774
774
  getJsonContentFunction: () => {
775
- throw console.error("getJsonContentFunction is not set"), new Error("getJsonContentFunction is not set");
775
+ throw console.error("[React bindings] getJsonContentFunction is not set"), new Error("[React bindings] getJsonContentFunction is not set");
776
776
  },
777
777
  getJsonActivityContentFunction: () => {
778
- throw console.error("getJsonActivityContentFunction is not set"), new Error("getJsonActivityContentFunction is not set");
778
+ throw console.error("[React bindings] getJsonActivityContentFunction is not set"), new Error("[React bindings] getJsonActivityContentFunction is not set");
779
779
  },
780
780
  getJsonAssignmentContentFunction: () => {
781
- throw console.error("getJsonAssignmentContentFunction is not set"), new Error("getJsonAssignmentContentFunction is not set");
781
+ throw console.error("[React bindings] getJsonAssignmentContentFunction is not set"), new Error("[React bindings] getJsonAssignmentContentFunction is not set");
782
782
  },
783
783
  getJsonActivitySplitContentFunction: () => {
784
- throw console.error("getJsonActivitySplitContentFunction is not set"), new Error("getJsonActivitySplitContentFunction is not set");
784
+ throw console.error("[React bindings] getJsonActivitySplitContentFunction is not set"), new Error("[React bindings] getJsonActivitySplitContentFunction is not set");
785
785
  },
786
786
  getJsonAssignmentSplitContentFunction: () => {
787
- throw console.error("getJsonAssignmentSplitContentFunction is not set"), new Error("getJsonAssignmentSplitContentFunction is not set");
787
+ throw console.error("[React bindings] getJsonAssignmentSplitContentFunction is not set"), new Error("[React bindings] getJsonAssignmentSplitContentFunction is not set");
788
788
  },
789
789
  sidebarActions: {},
790
790
  quickActions: {},
@@ -849,79 +849,79 @@ const qt = [
849
849
  ], tt = {
850
850
  "mode:1": {
851
851
  setMode: (t) => {
852
- i.setState({ mode: t });
852
+ a.setState({ mode: t });
853
853
  }
854
854
  },
855
855
  "reload:1": {
856
856
  reloaded: (t) => {
857
- console.log("Reloaded with state:", t), console.error("Not implemented yet");
857
+ console.log("[React bindings] Reloaded with state:", t), console.error("[React bindings] Not implemented yet");
858
858
  }
859
859
  },
860
860
  "theme:1": {
861
861
  setTheme: (t) => {
862
862
  if (t === null) {
863
- i.setState({ theme: null });
863
+ a.setState({ theme: null });
864
864
  return;
865
865
  }
866
866
  if (t !== "light" && t !== "dark") {
867
- console.warn(`Invalid theme: ${t}. Expected 'light' or 'dark'.`), i.setState({ theme: null });
867
+ console.warn(`[React bindings] Invalid theme: ${t}. Expected 'light' or 'dark'.`), a.setState({ theme: null });
868
868
  return;
869
869
  }
870
- i.setState({ theme: t });
870
+ a.setState({ theme: t });
871
871
  }
872
872
  },
873
873
  "workflow:1": {
874
874
  setWorkflow: (t) => {
875
- i.setState({ workflow: t });
875
+ a.setState({ workflow: t });
876
876
  }
877
877
  },
878
878
  "trigger-save:1": {
879
879
  setCanSave(t) {
880
- i.setState({ canSave: t });
880
+ a.setState({ canSave: t });
881
881
  }
882
882
  },
883
883
  "simple-content(text):1": {
884
884
  contentSaved: () => {
885
- i.setState((t) => ({
885
+ a.setState((t) => ({
886
886
  afterSaveCount: t.afterSaveCount + 1
887
887
  }));
888
888
  },
889
- getContent: () => i.getState().getTextContentFunction(),
889
+ getContent: () => a.getState().getTextContentFunction(),
890
890
  loadContent: (t) => {
891
- i.setState({ loadedTextContent: t });
891
+ a.setState({ loadedTextContent: t });
892
892
  }
893
893
  },
894
894
  "simple-content(json):1": {
895
895
  contentSaved: () => {
896
- i.setState((t) => ({
896
+ a.setState((t) => ({
897
897
  afterSaveCount: t.afterSaveCount + 1
898
898
  }));
899
899
  },
900
- getContent: () => i.getState().getJsonContentFunction(),
900
+ getContent: () => a.getState().getJsonContentFunction(),
901
901
  loadContent: (t) => {
902
- i.setState({ loadedJsonContent: t });
902
+ a.setState({ loadedJsonContent: t });
903
903
  }
904
904
  },
905
905
  "simple-binary-data(text):1": {
906
906
  contentSaved: () => {
907
- i.setState((t) => ({
907
+ a.setState((t) => ({
908
908
  afterSaveCount: t.afterSaveCount + 1
909
909
  }));
910
910
  },
911
- getContent: () => i.getState().getTextContentFunction(),
911
+ getContent: () => a.getState().getTextContentFunction(),
912
912
  loadContent: (t) => {
913
- i.setState({ loadedTextContent: t });
913
+ a.setState({ loadedTextContent: t });
914
914
  }
915
915
  },
916
916
  "simple-content-eval(text):1": {
917
917
  contentSaved: () => {
918
- i.setState((t) => ({
918
+ a.setState((t) => ({
919
919
  afterSaveCount: t.afterSaveCount + 1
920
920
  }));
921
921
  },
922
- getContent: () => i.getState().getTextContentFunction(),
922
+ getContent: () => a.getState().getTextContentFunction(),
923
923
  loadContent: (t) => {
924
- i.setState({ loadedTextContent: t });
924
+ a.setState({ loadedTextContent: t });
925
925
  },
926
926
  getAssignmentContent: () => {
927
927
  throw new Error(
@@ -931,13 +931,13 @@ const qt = [
931
931
  },
932
932
  "simple-content-eval(json):1": {
933
933
  contentSaved: () => {
934
- i.setState((t) => ({
934
+ a.setState((t) => ({
935
935
  afterSaveCount: t.afterSaveCount + 1
936
936
  }));
937
937
  },
938
- getContent: () => i.getState().getJsonContentFunction(),
938
+ getContent: () => a.getState().getJsonContentFunction(),
939
939
  loadContent: (t) => {
940
- i.setState({ loadedJsonContent: t });
940
+ a.setState({ loadedJsonContent: t });
941
941
  },
942
942
  getAssignmentContent: () => {
943
943
  throw new Error(
@@ -947,13 +947,13 @@ const qt = [
947
947
  },
948
948
  "simple-content-eval(json):2": {
949
949
  contentSaved: () => {
950
- i.setState((t) => ({
950
+ a.setState((t) => ({
951
951
  afterSaveCount: t.afterSaveCount + 1
952
952
  }));
953
953
  },
954
- getContent: () => i.getState().getJsonContentFunction(),
954
+ getContent: () => a.getState().getJsonContentFunction(),
955
955
  loadContent: (t) => {
956
- i.setState({ loadedJsonContent: t });
956
+ a.setState({ loadedJsonContent: t });
957
957
  },
958
958
  getAssignmentContent: () => {
959
959
  throw new Error(
@@ -963,13 +963,13 @@ const qt = [
963
963
  },
964
964
  "simple-content-eval(text):2": {
965
965
  contentSaved: () => {
966
- i.setState((t) => ({
966
+ a.setState((t) => ({
967
967
  afterSaveCount: t.afterSaveCount + 1
968
968
  }));
969
969
  },
970
- getContent: () => i.getState().getTextContentFunction(),
970
+ getContent: () => a.getState().getTextContentFunction(),
971
971
  loadContent: (t) => {
972
- i.setState({ loadedTextContent: t });
972
+ a.setState({ loadedTextContent: t });
973
973
  },
974
974
  getAssignmentContent: () => {
975
975
  throw new Error(
@@ -979,22 +979,22 @@ const qt = [
979
979
  },
980
980
  "separate-contents(json):1": {
981
981
  contentSaved: () => {
982
- i.setState((t) => ({
982
+ a.setState((t) => ({
983
983
  afterSaveCount: t.afterSaveCount + 1
984
984
  }));
985
985
  },
986
986
  loadContent: (t, e) => {
987
- i.setState({
987
+ a.setState({
988
988
  loadedJsonActivityContent: t,
989
989
  loadedJsonAssignmentContent: e
990
990
  });
991
991
  },
992
- getActivityContent: () => i.getState().getJsonActivityContentFunction(),
993
- getAssignmentContent: () => i.getState().getJsonAssignmentContentFunction()
992
+ getActivityContent: () => a.getState().getJsonActivityContentFunction(),
993
+ getAssignmentContent: () => a.getState().getJsonAssignmentContentFunction()
994
994
  },
995
995
  "separate-dual-contents(json):1": {
996
996
  contentSaved: () => {
997
- i.setState((t) => ({
997
+ a.setState((t) => ({
998
998
  afterSaveCount: t.afterSaveCount + 1
999
999
  }));
1000
1000
  },
@@ -1004,15 +1004,15 @@ const qt = [
1004
1004
  activityBinaryData: n,
1005
1005
  assignmentBinaryData: r
1006
1006
  }) => {
1007
- i.setState({
1007
+ a.setState({
1008
1008
  loadedJsonActivityContent: t,
1009
1009
  loadedJsonAssignmentContent: e,
1010
1010
  loadedJsonActivityBinaryData: n,
1011
1011
  loadedJsonAssignmentBinaryData: r
1012
1012
  });
1013
1013
  },
1014
- getActivityContentAndData: () => (console.log("Getting activity content and data"), i.getState().getJsonActivitySplitContentFunction()),
1015
- getAssignmentContentAndData: () => (console.log("Getting assignment content and data"), i.getState().getJsonAssignmentSplitContentFunction())
1014
+ getActivityContentAndData: () => (console.log("[React bindings] Getting activity content and data"), a.getState().getJsonActivitySplitContentFunction()),
1015
+ getAssignmentContentAndData: () => (console.log("[React bindings] Getting assignment content and data"), a.getState().getJsonAssignmentSplitContentFunction())
1016
1016
  },
1017
1017
  "meta-player-anti-cheat:1": {
1018
1018
  lock: () => {
@@ -1022,25 +1022,25 @@ const qt = [
1022
1022
  },
1023
1023
  "meta-player-ui:1": {
1024
1024
  executeAction(t) {
1025
- if (console.log("Executing action:", t), t.startsWith("qa")) {
1026
- const n = i.getState().quickActions[t];
1027
- n ? n() : console.error(`Quick action not found: ${t}`);
1025
+ if (console.log("[React bindings] Executing action:", t), t.startsWith("qa")) {
1026
+ const n = a.getState().quickActions[t];
1027
+ n ? n() : console.error(`[React bindings] Quick action not found: ${t}`);
1028
1028
  } else {
1029
- const n = i.getState().sidebarActions[t];
1030
- n ? n() : console.error(`Sidebar action not found: ${t}`);
1029
+ const n = a.getState().sidebarActions[t];
1030
+ n ? n() : console.error(`[React bindings] Sidebar action not found: ${t}`);
1031
1031
  }
1032
1032
  },
1033
1033
  executeFileUpload(t, e) {
1034
1034
  if (t.startsWith("qa")) {
1035
- const r = i.getState().quickActions[t];
1036
- r ? r(e) : console.error(`Quick action not found: ${t}`);
1035
+ const r = a.getState().quickActions[t];
1036
+ r ? r(e) : console.error(`[React bindings] Quick action not found: ${t}`);
1037
1037
  } else {
1038
- const r = i.getState().sidebarActions[t];
1039
- r ? r(e) : console.error(`Sidebar action not found: ${t}`);
1038
+ const r = a.getState().sidebarActions[t];
1039
+ r ? r(e) : console.error(`[React bindings] Sidebar action not found: ${t}`);
1040
1040
  }
1041
1041
  },
1042
1042
  updateSettings(t) {
1043
- const e = i.getState().activitySettingsCallback;
1043
+ const e = a.getState().activitySettingsCallback;
1044
1044
  e ? e(t) : console.warn(
1045
1045
  "activitySettingsCallback is not set. Changes:",
1046
1046
  t
@@ -1049,47 +1049,47 @@ const qt = [
1049
1049
  },
1050
1050
  "meta-player-events:1": {
1051
1051
  handleEvent(t) {
1052
- t === "all-loaded" && i.setState({ ready: !0 });
1052
+ t === "all-loaded" && a.setState({ ready: !0 });
1053
1053
  }
1054
1054
  },
1055
1055
  "llm:1": {
1056
1056
  getFirstMessageContext: (t) => {
1057
- const e = i.getState().llmGetFirstMessageContextFunction;
1057
+ const e = a.getState().llmGetFirstMessageContextFunction;
1058
1058
  if (!e)
1059
1059
  throw new Error("LLM first message context function is not set");
1060
1060
  return e(t);
1061
1061
  },
1062
1062
  getAllMessagesContext: (t) => {
1063
- const e = i.getState().llmGetAllMessagesContextFunction;
1063
+ const e = a.getState().llmGetAllMessagesContextFunction;
1064
1064
  if (!e)
1065
1065
  throw new Error("LLM all messages context function is not set");
1066
1066
  return e(t);
1067
1067
  }
1068
1068
  }
1069
- }, h = Dt();
1069
+ }, b = Dt();
1070
1070
  function Bt(t) {
1071
- if (console.log("Contracts to plug:", t), Z) {
1072
- console.warn("Contracts have already been plugged. Skipping.");
1071
+ if (console.log("[React bindings] Contracts to plug:", t), Z) {
1072
+ console.warn("[React bindings] Contracts have already been plugged. Skipping.");
1073
1073
  return;
1074
1074
  }
1075
1075
  Z = !0;
1076
1076
  for (const e of t) {
1077
1077
  if (!qt.includes(e)) {
1078
1078
  console.warn(
1079
- `Contract ${e} is not implemented in Capytale. Skipping plug.`
1079
+ `[React bindings] Contract ${e} is not implemented in Capytale. Skipping plug.`
1080
1080
  );
1081
1081
  continue;
1082
1082
  }
1083
1083
  if (!(e in tt)) {
1084
1084
  console.warn(
1085
- `Contract handler for ${e} is not defined. Skipping plug.`
1085
+ `[React bindings] Contract handler for ${e} is not defined. Skipping plug.`
1086
1086
  );
1087
1087
  continue;
1088
1088
  }
1089
1089
  const n = tt[e];
1090
- h.plug([e], ([]) => (console.log(`Contract ${e} plugged.`), [n]));
1090
+ console.log(`[React bindings] Plugging contract ${e}...`), b.plug([e], ([]) => (console.log(`[React bindings] Contract ${e} plugged.`), [n]));
1091
1091
  }
1092
- h.plugsDone();
1092
+ b.plugsDone();
1093
1093
  for (const e of [
1094
1094
  "simple-content(text):1",
1095
1095
  "simple-content(json):1",
@@ -1101,109 +1101,109 @@ function Bt(t) {
1101
1101
  "separate-contents(json):1",
1102
1102
  "separate-dual-contents(json):1"
1103
1103
  ])
1104
- if (console.log(`Contract ${e} is being subscribed to content changes.`), t.includes(e)) {
1105
- console.log(`Subscribing to content changes for contract ${e}`);
1104
+ if (console.log(`[React bindings] Contract ${e} is being subscribed to content changes.`), t.includes(e)) {
1105
+ console.log(`[React bindings] Subscribing to content changes for contract ${e}`);
1106
1106
  const n = e.split(":")[0];
1107
- h.use([n], ([r]) => {
1108
- i.subscribe(
1107
+ b.use([n], ([r]) => {
1108
+ a.subscribe(
1109
1109
  (o) => o.isDirtyCount,
1110
1110
  () => {
1111
1111
  r.i?.contentChanged(), console.log(
1112
- `Content changed for contract ${n}`
1112
+ `[React bindings] Content changed for contract ${n}`
1113
1113
  );
1114
1114
  }
1115
1115
  );
1116
1116
  });
1117
1117
  }
1118
1118
  }
1119
- const re = () => i((t) => {
1119
+ const re = () => a((t) => {
1120
1120
  if (t.mode === null)
1121
1121
  throw new Error("Mode is not set. Have you used contract 'mode'?");
1122
1122
  return t.mode;
1123
- }), se = () => i((t) => {
1123
+ }), se = () => a((t) => {
1124
1124
  if (t.workflow === null)
1125
1125
  throw new Error(
1126
1126
  "Workflow is not set. Have you used contract 'workflow'?"
1127
1127
  );
1128
1128
  return t.workflow;
1129
- }), ae = () => i((t) => {
1129
+ }), ie = () => a((t) => {
1130
1130
  if (t.theme === null)
1131
1131
  throw new Error("Theme is not set. Have you used contract 'theme'?");
1132
1132
  return t.theme;
1133
- }), ie = () => i((t) => t.incSaveCount), le = () => i((t) => t.incDirtyCount), ce = () => i((t) => t.loadedTextContent), ue = () => i((t) => t.loadedJsonContent), de = () => i((t) => t.loadedJsonActivityContent), fe = () => i((t) => t.loadedJsonAssignmentContent), ge = () => i((t) => t.loadedJsonActivityBinaryData), pe = () => i((t) => t.loadedJsonAssignmentBinaryData), me = () => A(() => i.getState().loadedTextContent, []), ye = () => A(() => i.getState().loadedJsonContent, []), ve = () => A(() => i.getState().loadedJsonActivityContent, []), Ce = () => A(() => i.getState().loadedJsonAssignmentContent, []), Se = () => A(
1133
+ }), ae = () => a((t) => t.incSaveCount), ce = () => a((t) => t.incDirtyCount), le = () => a((t) => t.loadedTextContent), ue = () => a((t) => t.loadedJsonContent), de = () => a((t) => t.loadedJsonActivityContent), ge = () => a((t) => t.loadedJsonAssignmentContent), fe = () => a((t) => t.loadedJsonActivityBinaryData), pe = () => a((t) => t.loadedJsonAssignmentBinaryData), me = () => h(() => a.getState().loadedTextContent, []), ye = () => h(() => a.getState().loadedJsonContent, []), ve = () => h(() => a.getState().loadedJsonActivityContent, []), Ce = () => h(() => a.getState().loadedJsonAssignmentContent, []), Se = () => h(
1134
1134
  () => ({
1135
- content: i.getState().loadedJsonActivityContent,
1136
- binaryData: i.getState().loadedJsonActivityBinaryData
1135
+ content: a.getState().loadedJsonActivityContent,
1136
+ binaryData: a.getState().loadedJsonActivityBinaryData
1137
1137
  }),
1138
1138
  []
1139
- ), we = () => A(
1139
+ ), we = () => h(
1140
1140
  () => ({
1141
- content: i.getState().loadedJsonAssignmentContent,
1142
- binaryData: i.getState().loadedJsonAssignmentBinaryData
1141
+ content: a.getState().loadedJsonAssignmentContent,
1142
+ binaryData: a.getState().loadedJsonAssignmentBinaryData
1143
1143
  }),
1144
1144
  []
1145
- ), he = (t) => {
1146
- const e = i(
1145
+ ), be = (t) => {
1146
+ const e = a(
1147
1147
  (n) => n.setGetTextContentFunction
1148
1148
  );
1149
1149
  w(() => {
1150
1150
  e(t);
1151
1151
  }, [t, e]);
1152
- }, Ae = (t) => {
1153
- const e = i(
1152
+ }, he = (t) => {
1153
+ const e = a(
1154
1154
  (n) => n.setGetJsonContentFunction
1155
1155
  );
1156
1156
  w(() => {
1157
1157
  e(t);
1158
1158
  }, [t, e]);
1159
- }, be = (t) => {
1160
- const e = i(
1159
+ }, Ae = (t) => {
1160
+ const e = a(
1161
1161
  (n) => n.setGetJsonActivityContentFunction
1162
1162
  );
1163
1163
  w(() => {
1164
1164
  e(t);
1165
1165
  }, [t, e]);
1166
- }, Ee = (t) => {
1167
- const e = i(
1166
+ }, Re = (t) => {
1167
+ const e = a(
1168
1168
  (n) => n.setGetJsonAssignmentContentFunction
1169
1169
  );
1170
1170
  w(() => {
1171
1171
  e(t);
1172
1172
  }, [t, e]);
1173
- }, Fe = (t) => {
1174
- const e = i(
1173
+ }, Ee = (t) => {
1174
+ const e = a(
1175
1175
  (n) => n.setGetJsonActivitySplitContentFunction
1176
1176
  );
1177
1177
  w(() => {
1178
1178
  e(t);
1179
1179
  }, [t, e]);
1180
- }, xe = (t) => {
1181
- const e = i(
1180
+ }, Fe = (t) => {
1181
+ const e = a(
1182
1182
  (n) => n.setGetJsonAssignmentSplitContentFunction
1183
1183
  );
1184
1184
  w(() => {
1185
1185
  e(t);
1186
1186
  }, [t, e]);
1187
- }, ke = (t) => {
1188
- const e = i((n) => n.afterSaveCount);
1187
+ }, xe = (t) => {
1188
+ const e = a((n) => n.afterSaveCount);
1189
1189
  w(() => {
1190
1190
  e > 0 && t();
1191
1191
  }, [e]);
1192
- }, Je = () => (t, e) => {
1193
- h.use(["meta-player-ui"], ([n]) => {
1192
+ }, ke = () => (t, e) => {
1193
+ b.use(["meta-player-ui"], ([n]) => {
1194
1194
  if (n.version === 0) {
1195
1195
  console.error(
1196
- "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1196
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1197
1197
  );
1198
1198
  return;
1199
1199
  }
1200
1200
  n.i?.previewTextFile(t, e);
1201
1201
  });
1202
- }, Me = () => (t, e) => {
1203
- h.use(["meta-player-ui"], ([n]) => {
1202
+ }, Je = () => (t, e) => {
1203
+ b.use(["meta-player-ui"], ([n]) => {
1204
1204
  if (n.version === 0) {
1205
1205
  console.error(
1206
- "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1206
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1207
1207
  );
1208
1208
  return;
1209
1209
  }
@@ -1211,36 +1211,36 @@ const re = () => i((t) => {
1211
1211
  });
1212
1212
  };
1213
1213
  let P = 0, W = 0;
1214
- const Te = (t, e) => {
1215
- const n = U(t, e), r = i((o) => o.setSidebarActions);
1214
+ const Me = (t, e) => {
1215
+ const n = U(t, e), r = a((o) => o.setSidebarActions);
1216
1216
  w(() => (P++, P > 1 && console.error(
1217
- "Capytale iframe React: Multiple sidebar actions registered: ",
1217
+ "[React bindings] Capytale iframe React: Multiple sidebar actions registered: ",
1218
1218
  P
1219
1219
  ), () => {
1220
1220
  P--;
1221
- }), []), w(() => (h.use(["meta-player-ui"], ([o]) => {
1221
+ }), []), w(() => (b.use(["meta-player-ui"], ([o]) => {
1222
1222
  if (o.version === 0) {
1223
1223
  console.error(
1224
- "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1224
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1225
1225
  );
1226
1226
  return;
1227
1227
  }
1228
1228
  W++;
1229
- const s = n.map((l, f) => ({
1230
- type: l.type,
1231
- title: l.title,
1232
- icon: l.icon,
1233
- id: `sa-${W}-${f}`,
1234
- ...l.type === "file-upload" ? { accept: l.accept } : {}
1235
- })), g = {};
1236
- n.forEach((l, f) => {
1237
- g[`sa-${W}-${f}`] = l.action;
1238
- }), o.i?.setSidebarActionButtons(s), r(g);
1229
+ const s = n.map((c, g) => ({
1230
+ type: c.type,
1231
+ title: c.title,
1232
+ icon: c.icon,
1233
+ id: `sa-${W}-${g}`,
1234
+ ...c.type === "file-upload" ? { accept: c.accept } : {}
1235
+ })), f = {};
1236
+ n.forEach((c, g) => {
1237
+ f[`sa-${W}-${g}`] = c.action;
1238
+ }), o.i?.setSidebarActionButtons(s), r(f);
1239
1239
  }), () => {
1240
- r({}), h.use(["meta-player-ui"], ([o]) => {
1240
+ r({}), b.use(["meta-player-ui"], ([o]) => {
1241
1241
  if (o.version === 0) {
1242
1242
  console.error(
1243
- "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1243
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1244
1244
  );
1245
1245
  return;
1246
1246
  }
@@ -1249,36 +1249,36 @@ const Te = (t, e) => {
1249
1249
  }), [n]);
1250
1250
  };
1251
1251
  let V = 0, H = 0;
1252
- const Re = (t, e) => {
1253
- const n = U(t, e), r = i((o) => o.setQuickActions);
1252
+ const Te = (t, e) => {
1253
+ const n = U(t, e), r = a((o) => o.setQuickActions);
1254
1254
  w(() => (V++, V > 1 && console.error(
1255
- "Capytale iframe React: Multiple quick actions registered: ",
1255
+ "[React bindings] Capytale iframe React: Multiple quick actions registered: ",
1256
1256
  V
1257
1257
  ), () => {
1258
1258
  V--;
1259
- }), []), w(() => (h.use(["meta-player-ui"], ([o]) => {
1259
+ }), []), w(() => (b.use(["meta-player-ui"], ([o]) => {
1260
1260
  if (o.version === 0) {
1261
1261
  console.error(
1262
- "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1262
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1263
1263
  );
1264
1264
  return;
1265
1265
  }
1266
1266
  H++;
1267
- const s = n.map((l, f) => ({
1268
- type: l.type,
1269
- title: l.title,
1270
- icon: l.icon,
1271
- id: `qa-${H}-${f}`,
1272
- ...l.type === "file-upload" ? { accept: l.accept } : {}
1273
- })), g = {};
1274
- n.forEach((l, f) => {
1275
- g[`qa-${H}-${f}`] = l.action;
1276
- }), o.i?.setQuickActionButtons(s), r(g);
1267
+ const s = n.map((c, g) => ({
1268
+ type: c.type,
1269
+ title: c.title,
1270
+ icon: c.icon,
1271
+ id: `qa-${H}-${g}`,
1272
+ ...c.type === "file-upload" ? { accept: c.accept } : {}
1273
+ })), f = {};
1274
+ n.forEach((c, g) => {
1275
+ f[`qa-${H}-${g}`] = c.action;
1276
+ }), o.i?.setQuickActionButtons(s), r(f);
1277
1277
  }), () => {
1278
- r({}), h.use(["meta-player-ui"], ([o]) => {
1278
+ r({}), b.use(["meta-player-ui"], ([o]) => {
1279
1279
  if (o.version === 0) {
1280
1280
  console.error(
1281
- "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1281
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1282
1282
  );
1283
1283
  return;
1284
1284
  }
@@ -1288,43 +1288,43 @@ const Re = (t, e) => {
1288
1288
  };
1289
1289
  let D = 0;
1290
1290
  const Wt = (t, e, n) => {
1291
- const r = U(t, n), o = i(
1291
+ const r = U(t, n), o = a(
1292
1292
  (s) => s.setActivitySettingsCallback
1293
1293
  );
1294
- w(() => (console.log("Mounting useSettings"), D++, D > 1 && console.error(
1295
- "Capytale iframe React: Multiple settings registered: ",
1294
+ w(() => (console.log("[React bindings] Mounting useSettings"), D++, D > 1 && console.error(
1295
+ "[React bindings] Capytale iframe React: Multiple settings registered: ",
1296
1296
  D
1297
1297
  ), () => {
1298
- console.log("Unmounting useSettings"), D--;
1299
- }), []), w(() => (h.use(["meta-player-ui"], ([s]) => {
1298
+ console.log("[React bindings] Unmounting useSettings"), D--;
1299
+ }), []), w(() => (b.use(["meta-player-ui"], ([s]) => {
1300
1300
  if (s.version === 0) {
1301
1301
  console.error(
1302
- "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1302
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1303
1303
  );
1304
1304
  return;
1305
1305
  }
1306
- console.log("Updating settings UI in MetaPlayer", r), s.i?.setSettingsUI(r);
1306
+ console.log("[React bindings] Updating settings UI in MetaPlayer", r), s.i?.setSettingsUI(r);
1307
1307
  }), o(
1308
1308
  e
1309
1309
  ), () => {
1310
1310
  o(null);
1311
1311
  }), [r]);
1312
- }, Ht = () => A((e) => h.exec(["meta-player-ui"], ([n]) => {
1312
+ }, Ht = () => h((e) => b.exec(["meta-player-ui"], ([n]) => {
1313
1313
  if (n.version === 0)
1314
1314
  throw console.error(
1315
- "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1315
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1316
1316
  ), new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
1317
1317
  return n.i?.showToast(e);
1318
- }), []), zt = () => A((e) => h.exec(["meta-player-ui"], ([n]) => {
1318
+ }), []), zt = () => h((e) => b.exec(["meta-player-ui"], ([n]) => {
1319
1319
  if (n.version === 0)
1320
1320
  throw console.error(
1321
- "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1321
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1322
1322
  ), new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
1323
1323
  return n.i?.clearToast(e);
1324
- }), []), Le = () => A(() => h.exec(["meta-player-ui"], ([e]) => {
1324
+ }), []), Le = () => h(() => b.exec(["meta-player-ui"], ([e]) => {
1325
1325
  if (e.version === 0)
1326
1326
  throw console.error(
1327
- "Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1327
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat meta-player-ui"
1328
1328
  ), new Error("Le MétaPlayer ne supporte pas le contrat meta-player-ui");
1329
1329
  return e.i?.clearToasts();
1330
1330
  }), []), Ut = (t, e) => {
@@ -1339,21 +1339,21 @@ const Wt = (t, e, n) => {
1339
1339
  });
1340
1340
  };
1341
1341
  }, [n, r, ...e]), null;
1342
- }, Ge = () => A(() => h.exec(["trigger-save"], ([e]) => {
1342
+ }, Ge = () => h(() => b.exec(["trigger-save"], ([e]) => {
1343
1343
  if (e.version === 0)
1344
1344
  throw console.error(
1345
- "Le MétaPlayer ne supporte pas le contrat trigger-save"
1345
+ "[React bindings] Le MétaPlayer ne supporte pas le contrat trigger-save"
1346
1346
  ), new Error("Le MétaPlayer ne supporte pas le contrat trigger-save");
1347
1347
  return e.i?.triggerSave();
1348
- }), []), Pe = () => i((t) => t.canSave), Ve = (t, e) => {
1349
- const n = i(
1348
+ }), []), Pe = () => a((t) => t.canSave), Ve = (t, e) => {
1349
+ const n = a(
1350
1350
  (r) => r.setLlmGetFirstMessageContextFunction
1351
1351
  );
1352
1352
  w(() => (n(t), () => {
1353
1353
  n(null);
1354
1354
  }), [e, n]);
1355
1355
  }, De = (t, e) => {
1356
- const n = i(
1356
+ const n = a(
1357
1357
  (r) => r.setLlmGetAllMessagesContextFunction
1358
1358
  );
1359
1359
  w(() => (n(t), () => {
@@ -1423,13 +1423,13 @@ function je({
1423
1423
  loadOnlyWhenReady: n = !0,
1424
1424
  activitySettingsStore: r
1425
1425
  }) {
1426
- const o = i((s) => s.ready);
1426
+ const o = a((s) => s.ready);
1427
1427
  return w(() => {
1428
1428
  const s = [...e];
1429
- for (const g of ee)
1430
- s.includes(g) || s.push(g);
1429
+ for (const f of ee)
1430
+ s.includes(f) || s.push(f);
1431
1431
  Bt(s);
1432
- }, []), n && !o ? /* @__PURE__ */ Q("div", { className: "capy-loading-container", children: "Chargement en cours..." }) : /* @__PURE__ */ gt(pt, { children: [
1432
+ }, []), n && !o ? /* @__PURE__ */ Q("div", { className: "capy-loading-container", children: "Chargement en cours..." }) : /* @__PURE__ */ ft(pt, { children: [
1433
1433
  r && /* @__PURE__ */ Q(te, { store: r }),
1434
1434
  t
1435
1435
  ] });
@@ -1441,7 +1441,7 @@ export {
1441
1441
  je as Capytale,
1442
1442
  $e as TemporaryToast,
1443
1443
  Ie as createActivitySettingsStore,
1444
- ke as useAfterSaveAction,
1444
+ xe as useAfterSaveAction,
1445
1445
  Pe as useCanSave,
1446
1446
  zt as useClearToast,
1447
1447
  Le as useClearToasts,
@@ -1451,30 +1451,30 @@ export {
1451
1451
  we as useGetLoadedJsonAssignmentSplitContent,
1452
1452
  ye as useGetLoadedJsonContent,
1453
1453
  me as useGetLoadedTextContent,
1454
- be as useJsonActivityContentSaveFunction,
1455
- Fe as useJsonActivitySplitContentSaveFunction,
1456
- Ee as useJsonAssignmentContentSaveFunction,
1457
- xe as useJsonAssignmentSplitContentSaveFunction,
1458
- Ae as useJsonContentSaveFunction,
1454
+ Ae as useJsonActivityContentSaveFunction,
1455
+ Ee as useJsonActivitySplitContentSaveFunction,
1456
+ Re as useJsonAssignmentContentSaveFunction,
1457
+ Fe as useJsonAssignmentSplitContentSaveFunction,
1458
+ he as useJsonContentSaveFunction,
1459
1459
  De as useLLMAllMessagesContext,
1460
1460
  Ve as useLLMFirstMessageContext,
1461
- ge as useLoadedJsonActivityBinaryData,
1461
+ fe as useLoadedJsonActivityBinaryData,
1462
1462
  de as useLoadedJsonActivityContent,
1463
1463
  pe as useLoadedJsonAssignmentBinaryData,
1464
- fe as useLoadedJsonAssignmentContent,
1464
+ ge as useLoadedJsonAssignmentContent,
1465
1465
  ue as useLoadedJsonContent,
1466
- ce as useLoadedTextContent,
1466
+ le as useLoadedTextContent,
1467
1467
  re as useMode,
1468
- le as useNotifyIsDirty,
1469
- Me as usePreviewImageFile,
1470
- Je as usePreviewTextFile,
1471
- Re as useQuickActions,
1472
- ie as useRequestSave,
1468
+ ce as useNotifyIsDirty,
1469
+ Je as usePreviewImageFile,
1470
+ ke as usePreviewTextFile,
1471
+ Te as useQuickActions,
1472
+ ae as useRequestSave,
1473
1473
  Wt as useSettings,
1474
1474
  Ht as useShowToast,
1475
- Te as useSidebarActions,
1476
- he as useTextContentSaveFunction,
1477
- ae as useTheme,
1475
+ Me as useSidebarActions,
1476
+ be as useTextContentSaveFunction,
1477
+ ie as useTheme,
1478
1478
  Ut as useToast,
1479
1479
  Ge as useTriggerSave,
1480
1480
  se as useWorkflow