@choosemycompany/lib 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,22 +1,22 @@
1
- import { mande as K } from "mande";
2
- import { ref as A, computed as y, onMounted as N, onBeforeUnmount as F, onUnmounted as O } from "vue";
3
- import { defineStore as x } from "pinia";
4
- import { useI18n as E } from "vue-i18n";
5
- import { createError as q } from "h3";
6
- import { showError as Z, useRuntimeConfig as V, useState as J } from "nuxt/app";
7
- let I;
8
- function pe(e) {
1
+ import { mande as q } from "mande";
2
+ import { ref as A, computed as T, onMounted as F, onBeforeUnmount as x, onUnmounted as Z } from "vue";
3
+ import { defineStore as V } from "pinia";
4
+ import { useI18n as y } from "vue-i18n";
5
+ import { createError as J } from "h3";
6
+ import { showError as j, useRuntimeConfig as _, useState as $ } from "nuxt/app";
7
+ let k;
8
+ function he(e) {
9
9
  if (!e.baseUrl)
10
10
  throw new Error("@choosemycompany/lib: configureHttp() needs a non-empty baseUrl");
11
- I = e;
11
+ k = e;
12
12
  }
13
- function H(e) {
14
- if (!I)
13
+ function O(e) {
14
+ if (!k)
15
15
  throw new Error(
16
16
  "@choosemycompany/lib: useHttp() was called before configureHttp(). Declare the base URLs from an app plugin."
17
17
  );
18
- if (e === void 0) return I.baseUrl;
19
- const a = I.targets ?? {}, i = Object.hasOwn(a, e) ? a[e] : void 0;
18
+ if (e === void 0) return k.baseUrl;
19
+ const a = k.targets ?? {}, i = Object.hasOwn(a, e) ? a[e] : void 0;
20
20
  if (typeof i != "string" || !i) {
21
21
  const t = Object.keys(a), n = t.length > 0 ? t.join(", ") : "none";
22
22
  throw new Error(
@@ -25,50 +25,50 @@ function H(e) {
25
25
  }
26
26
  return i;
27
27
  }
28
- const j = "/auth/api/v2/session/tokens", _ = "/auth/api/v2/", $ = "cmc-auth-session-refresh", W = x("cmc-auth-session", () => {
28
+ const W = "/auth/api/v2/session/tokens", Q = "/auth/api/v2/", Y = "cmc-auth-session-refresh", X = V("cmc-auth-session", () => {
29
29
  const e = A(!1), a = A(!1), i = A(void 0);
30
30
  let t, n = 0;
31
- const o = y(() => e.value && !a.value);
32
- function d() {
31
+ const o = T(() => e.value && !a.value);
32
+ function u() {
33
33
  e.value = !0, a.value = !1, i.value = void 0;
34
34
  }
35
- function c() {
35
+ function f() {
36
36
  n += 1, e.value = !1, a.value = !1, i.value = void 0;
37
37
  }
38
- function f() {
38
+ function g() {
39
39
  n += 1, e.value = !1, a.value = !0, i.value = "logout";
40
40
  }
41
- function p(h) {
42
- n += 1, e.value = !1, a.value = !0, i.value = h;
41
+ function l(v) {
42
+ n += 1, e.value = !1, a.value = !0, i.value = v;
43
43
  }
44
- async function g() {
44
+ async function b() {
45
45
  if (a.value)
46
46
  throw new Error("Session is expired: no refresh will be attempted");
47
- return t ??= v(m).finally(() => {
47
+ return t ??= m(h).finally(() => {
48
48
  t = void 0;
49
49
  }), t;
50
50
  }
51
- async function v(h) {
52
- const b = globalThis.navigator?.locks;
53
- if (!b) return h();
54
- await b.request($, h);
51
+ async function m(v) {
52
+ const p = globalThis.navigator?.locks;
53
+ if (!p) return v();
54
+ await p.request(Y, v);
55
55
  }
56
- async function m() {
57
- const h = n, b = () => h !== n, R = new URL(j, H()).href;
58
- let r;
56
+ async function h() {
57
+ const v = n, p = () => v !== n, P = new URL(W, O()).href;
58
+ let M;
59
59
  try {
60
- r = await fetch(R, {
60
+ M = await fetch(P, {
61
61
  method: "POST",
62
62
  credentials: "include"
63
63
  });
64
- } catch (u) {
65
- throw b() || C(), u;
64
+ } catch (U) {
65
+ throw p() || C(), U;
66
66
  }
67
- if (!r.ok)
68
- throw b() || (r.status === 401 ? p(e.value ? "refresh-rejected" : "no-session") : C()), new Error(`Token refresh failed with status ${r.status}`);
69
- if (b())
67
+ if (!M.ok)
68
+ throw p() || (M.status === 401 ? l(e.value ? "refresh-rejected" : "no-session") : C()), new Error(`Token refresh failed with status ${M.status}`);
69
+ if (p())
70
70
  throw new Error("Session was dropped while the refresh was in flight");
71
- d();
71
+ u();
72
72
  }
73
73
  function C() {
74
74
  i.value = "refresh-unreachable";
@@ -78,27 +78,27 @@ const j = "/auth/api/v2/session/tokens", _ = "/auth/api/v2/", $ = "cmc-auth-sess
78
78
  isExpired: a,
79
79
  expiryReason: i,
80
80
  isAuthenticated: o,
81
- open: d,
82
- expire: p,
83
- clear: c,
84
- logout: f,
85
- refresh: g
81
+ open: u,
82
+ expire: l,
83
+ clear: f,
84
+ logout: g,
85
+ refresh: b
86
86
  };
87
87
  });
88
- function Q() {
88
+ function ee() {
89
89
  return import.meta.server || typeof document > "u";
90
90
  }
91
- function Y(e) {
92
- return (typeof e == "string" ? e : e instanceof URL ? e.href : e.url).includes(_);
91
+ function ae(e) {
92
+ return (typeof e == "string" ? e : e instanceof URL ? e.href : e.url).includes(Q);
93
93
  }
94
- function X() {
94
+ function ne() {
95
95
  return async (e, a) => {
96
- if (Q()) return fetch(e, a);
96
+ if (ee()) return fetch(e, a);
97
97
  const i = await fetch(e, a);
98
- if (i.status !== 401 || Y(e) || new Headers(a?.headers).has("Authorization")) return i;
98
+ if (i.status !== 401 || ae(e) || new Headers(a?.headers).has("Authorization")) return i;
99
99
  let t;
100
100
  try {
101
- t = W();
101
+ t = X();
102
102
  } catch {
103
103
  return i;
104
104
  }
@@ -111,10 +111,10 @@ function X() {
111
111
  return fetch(e, a);
112
112
  };
113
113
  }
114
- function ge(e) {
115
- const a = K(H(e), {
114
+ function be(e) {
115
+ const a = q(O(e), {
116
116
  headers: {}
117
- }, X());
117
+ }, ne());
118
118
  function i(n) {
119
119
  a.options.headers = {
120
120
  ...a.options.headers ?? {},
@@ -126,153 +126,165 @@ function ge(e) {
126
126
  }
127
127
  return { http: a, setToken: i, clearToken: t };
128
128
  }
129
- function me(e, a) {
130
- return e.replace(ee, (i, t) => {
129
+ function ve(e, a) {
130
+ return e.replace(ie, (i, t) => {
131
131
  const n = Object.hasOwn(a, t) ? a[t] : void 0;
132
132
  if (typeof n != "string" && typeof n != "number")
133
133
  throw new Error(`Missing URL parameter "${t}" for template "${e}"`);
134
134
  return encodeURIComponent(String(n));
135
135
  });
136
136
  }
137
- const ee = /\{(\w+)\}/g;
138
- function G(e) {
137
+ const ie = /\{(\w+)\}/g;
138
+ function N(e) {
139
139
  return Object.entries(e).sort(([a], [i]) => a.localeCompare(i)).map(([a, i]) => `${a}=${i}`).join("|");
140
140
  }
141
- const ae = "create";
142
- function he(e) {
143
- const a = A({}), i = A({}), t = A({}), n = A({}), o = A(0), d = e.getItemId ?? ((r) => {
144
- const u = r.id;
145
- if (u === void 0)
141
+ const te = "create";
142
+ function Be(e) {
143
+ const a = A({}), i = A({}), t = A({}), n = A({}), o = A(0);
144
+ let u = 0;
145
+ const f = e.getItemId ?? ((r) => {
146
+ const d = r.id;
147
+ if (d === void 0)
146
148
  throw new Error(
147
149
  "useStore: no `getItemId` option provided and item has no `id` property. Either pass `getItemId` in the store options, or expose an `id` field on your items."
148
150
  );
149
- return u;
151
+ return d;
150
152
  });
151
- function c(r) {
153
+ function g(r) {
152
154
  return !!n.value[r];
153
155
  }
154
- async function f(r, u) {
155
- n.value[r] = u;
156
+ async function l(r, d) {
157
+ n.value[r] = d;
156
158
  try {
157
- const s = await u;
159
+ const s = await d;
158
160
  return delete t.value[r], s;
159
161
  } catch (s) {
160
162
  throw t.value[r] = s, s;
161
163
  } finally {
162
- n.value[r] === u && delete n.value[r];
164
+ n.value[r] === d && delete n.value[r];
163
165
  }
164
166
  }
165
- async function p(r, u = {}) {
167
+ async function b(r, d = {}) {
166
168
  if (!e.fetchOne)
167
169
  throw new Error("useStore.retrieve called but fetchOne is not defined in store options");
168
- const { force: s = !1 } = u;
170
+ const { force: s = !1 } = d;
169
171
  if (a.value[r] && !s)
170
172
  return a.value[r];
171
- const l = n.value[r];
172
- if (l)
173
- return l;
173
+ const c = n.value[r];
174
+ if (c)
175
+ return c;
174
176
  const B = e.fetchOne, S = (async () => {
177
+ const I = u;
175
178
  try {
176
- const w = await B(r), k = e.enrichItem ? e.enrichItem(w) : w;
177
- return a.value[r] = k, delete t.value[r], a.value[r];
178
- } catch (w) {
179
- t.value[r] = w;
179
+ const E = await B(r);
180
+ if (I !== u)
181
+ return;
182
+ const R = e.enrichItem ? e.enrichItem(E) : E;
183
+ return a.value[r] = R, delete t.value[r], a.value[r];
184
+ } catch (E) {
185
+ I === u && (t.value[r] = E);
180
186
  return;
181
187
  } finally {
182
- delete n.value[r];
188
+ I === u && delete n.value[r];
183
189
  }
184
190
  })();
185
191
  return n.value[r] = S, S;
186
192
  }
187
- function g(r) {
188
- const u = G(r), s = i.value[u];
193
+ function m(r) {
194
+ const d = N(r), s = i.value[d];
189
195
  if (s)
190
196
  return {
191
- items: s.itemIds.map((l) => a.value[l]).filter((l) => l !== void 0),
197
+ items: s.itemIds.map((c) => a.value[c]).filter((c) => c !== void 0),
192
198
  total: s.total,
193
199
  hasMore: s.hasMore,
194
200
  page: s.page,
195
201
  limit: s.limit
196
202
  };
197
203
  }
198
- async function v(r, u = {}) {
204
+ async function h(r, d = {}) {
199
205
  if (!e.fetchPage)
200
206
  throw new Error("useStore.list called but fetchPage is not defined in store options");
201
- const s = G(r), { force: l = !1 } = u;
202
- if (i.value[s]?.revision === o.value && !l)
203
- return g(r);
207
+ const s = N(r), { force: c = !1 } = d;
208
+ if (i.value[s]?.revision === o.value && !c)
209
+ return m(r);
204
210
  const B = n.value[s];
205
211
  if (B)
206
- return await B, g(r);
207
- const S = e.fetchPage, w = (async () => {
208
- const k = o.value;
212
+ return await B, m(r);
213
+ const S = e.fetchPage, I = (async () => {
214
+ const E = o.value, R = u;
209
215
  try {
210
- const M = await S(r), P = [];
211
- for (const U of M.items) {
212
- const T = e.enrichItem ? e.enrichItem(U) : U, L = d(T);
213
- a.value[L] = T, P.push(L);
216
+ const w = await S(r);
217
+ if (R !== u)
218
+ return;
219
+ const L = [];
220
+ for (const G of w.items) {
221
+ const z = e.enrichItem ? e.enrichItem(G) : G, D = f(z);
222
+ a.value[D] = z, L.push(D);
214
223
  }
215
224
  i.value[s] = {
216
- itemIds: P,
217
- total: M.total,
218
- hasMore: M.hasMore,
219
- page: M.page,
220
- limit: M.limit,
221
- revision: k
225
+ itemIds: L,
226
+ total: w.total,
227
+ hasMore: w.hasMore,
228
+ page: w.page,
229
+ limit: w.limit,
230
+ revision: E
222
231
  }, delete t.value[s];
223
- } catch (M) {
224
- t.value[s] = M;
232
+ } catch (w) {
233
+ R === u && (t.value[s] = w);
225
234
  } finally {
226
- delete n.value[s];
235
+ R === u && delete n.value[s];
227
236
  }
228
237
  })();
229
- return n.value[s] = w, await w, g(r);
238
+ return n.value[s] = I, await I, m(r);
230
239
  }
231
- async function m(r, u = ae) {
240
+ async function C(r, d = te) {
232
241
  if (!e.createMutation)
233
242
  throw new Error("useStore.create called but createMutation is not defined in store options");
234
- const s = e.createMutation, l = await f(u, (async () => s(r))()), B = e.enrichItem ? e.enrichItem(l) : l, S = d(B);
235
- return a.value[S] = B, i.value = {}, B;
243
+ const s = e.createMutation, c = await l(d, (async () => s(r))()), B = e.enrichItem ? e.enrichItem(c) : c, S = f(B);
244
+ return a.value[S] = B, i.value = {}, p(), B;
236
245
  }
237
- async function C(r, u) {
246
+ async function v(r, d) {
238
247
  if (!e.updateMutation)
239
248
  throw new Error("useStore.update called but updateMutation is not defined in store options");
240
- const s = e.updateMutation, l = await f(r, (async () => s(r, u))()), B = e.enrichItem ? e.enrichItem(l) : l;
241
- return a.value[r] = B, o.value += 1, B;
249
+ const s = e.updateMutation, c = await l(r, (async () => s(r, d))()), B = e.enrichItem ? e.enrichItem(c) : c;
250
+ return a.value[r] = B, p(), B;
251
+ }
252
+ function p() {
253
+ o.value += 1;
242
254
  }
243
- async function h(r) {
255
+ async function P(r) {
244
256
  if (!e.removeMutation)
245
257
  throw new Error("useStore.remove called but removeMutation is not defined in store options");
246
- const u = e.removeMutation;
247
- await f(r, (async () => u(r))()), delete a.value[r];
258
+ const d = e.removeMutation;
259
+ await l(r, (async () => d(r))()), delete a.value[r];
248
260
  for (const s of Object.values(i.value)) {
249
- const l = s.itemIds.indexOf(r);
250
- l !== -1 && (s.itemIds.splice(l, 1), s.total = Math.max(0, s.total - 1));
261
+ const c = s.itemIds.indexOf(r);
262
+ c !== -1 && (s.itemIds.splice(c, 1), s.total = Math.max(0, s.total - 1));
251
263
  }
252
264
  }
253
- function b() {
265
+ function M() {
254
266
  t.value = {};
255
267
  }
256
- function R() {
257
- a.value = {}, i.value = {}, t.value = {}, n.value = {};
268
+ function U() {
269
+ u += 1, a.value = {}, i.value = {}, t.value = {}, n.value = {};
258
270
  }
259
- return { items: a, views: i, errors: t, isPending: c, list: v, reset: R, retrieve: p, getView: g, withPending: f, create: m, update: C, remove: h, clearErrors: b };
271
+ return { items: a, views: i, errors: t, isPending: g, list: h, reset: U, retrieve: b, getView: m, withPending: l, create: C, update: v, markViewsStale: p, remove: P, clearErrors: M };
260
272
  }
261
- function be(e, a) {
273
+ function Ae(e, a) {
262
274
  const i = (t) => {
263
275
  const n = e.value, o = t.target;
264
276
  !n || !o || n.contains(o) || a();
265
277
  };
266
- N(() => {
278
+ F(() => {
267
279
  document.addEventListener("click", i);
268
- }), F(() => {
280
+ }), x(() => {
269
281
  document.removeEventListener("click", i);
270
282
  });
271
283
  }
272
- function Be() {
273
- const { locale: e } = E();
284
+ function Ce() {
285
+ const { locale: e } = y();
274
286
  function a(i, t = null) {
275
- const n = ne[i.trim().toUpperCase()];
287
+ const n = re[i.trim().toUpperCase()];
276
288
  if (!n)
277
289
  throw new Error(`Unknown country code: ${i}`);
278
290
  if (t && n[t])
@@ -285,7 +297,7 @@ function Be() {
285
297
  }
286
298
  return a;
287
299
  }
288
- const ne = {
300
+ const re = {
289
301
  AD: { en: "Andorra", fr: "Andorre", es: "Andorra", de: "Andorra", it: "Andorra", pt: "Andorra", da: "Andorra" },
290
302
  AE: { en: "United Arab Emirates", fr: "Émirats arabes unis", es: "Emiratos Árabes Unidos", de: "Vereinigte Arabische Emirate", it: "Emirati Arabi Uniti", pt: "Emirados Árabes Unidos", da: "De Forenede Arabiske Emirater" },
291
303
  AF: { en: "Afghanistan", fr: "Afghanistan", es: "Afganistán", de: "Afghanistan", it: "Afghanistan", pt: "Afeganistão", da: "Afghanistan" },
@@ -423,130 +435,130 @@ const ne = {
423
435
  ZA: { en: "South Africa", fr: "Afrique Du Sud", es: "Sudáfrica", de: "Südafrika", it: "Sudafrica", pt: "África Do Sul", da: "Sydafrika" },
424
436
  ZM: { en: "Zambia", fr: "Zambie", es: "Zambia", de: "Sambia", it: "Zambia", pt: "Zâmbia", da: "Zambia" },
425
437
  ZW: { en: "Zimbabwe", fr: "Zimbabwe", es: "Zimbabue", de: "Simbabwe", it: "Zimbabwe", pt: "Zimbábue", da: "Zimbabwe" }
426
- }, ve = ({ code: e, message: a, data: i }) => {
427
- const t = a || "An unexpected error occurred", n = q({
438
+ }, we = ({ code: e, message: a, data: i }) => {
439
+ const t = a || "An unexpected error occurred", n = J({
428
440
  statusCode: e,
429
441
  statusMessage: t,
430
442
  message: t,
431
443
  data: i
432
444
  });
433
- throw Z(n), n;
434
- }, ie = "ilcJCL_lmpwcEJfSkKND";
435
- function Ae() {
436
- const { gtagId: e } = V().public;
445
+ throw j(n), n;
446
+ }, oe = "ilcJCL_lmpwcEJfSkKND";
447
+ function Me() {
448
+ const { gtagId: e } = _().public;
437
449
  return { reportConversion: () => {
438
450
  if (typeof window > "u" || typeof window.gtag > "u" || !e)
439
451
  return;
440
- const i = `${e}/${ie}`;
452
+ const i = `${e}/${oe}`;
441
453
  window.gtag("event", "conversion", {
442
454
  send_to: i
443
455
  });
444
456
  } };
445
457
  }
446
- const z = "https://5509641.hs-sites-eu1.com";
447
- function Ce() {
448
- const { locale: e } = E();
449
- return { contactUrl: y(() => e.value === "fr" ? `${z}/contact` : `${z}/${e.value}/contact`) };
458
+ const H = "https://5509641.hs-sites-eu1.com";
459
+ function Se() {
460
+ const { locale: e } = y();
461
+ return { contactUrl: T(() => e.value === "fr" ? `${H}/contact` : `${H}/${e.value}/contact`) };
450
462
  }
451
- function we() {
463
+ function Ie() {
452
464
  async function e(t) {
453
465
  await Promise.all(
454
466
  t.map(
455
467
  (n) => new Promise((o) => {
456
468
  if (!n) return o(null);
457
- const d = new Image();
458
- d.onload = () => o(null), d.onerror = () => o(null), d.src = n;
469
+ const u = new Image();
470
+ u.onload = () => o(null), u.onerror = () => o(null), u.src = n;
459
471
  })
460
472
  )
461
473
  );
462
474
  }
463
475
  function a(t, n) {
464
- return n.split(".").reduce((o, d) => o && typeof o == "object" && d in o ? o[d] : "", t) ?? "";
476
+ return n.split(".").reduce((o, u) => o && typeof o == "object" && u in o ? o[u] : "", t) ?? "";
465
477
  }
466
478
  function i(t, n, o) {
467
479
  if (import.meta.server)
468
- return async (c) => {
480
+ return async (f) => {
469
481
  t.value = !0;
470
482
  };
471
- const d = J(
483
+ const u = $(
472
484
  `${n}LoadedImageCache`,
473
485
  () => ({})
474
486
  );
475
- return async (c) => {
476
- if (!c) {
487
+ return async (f) => {
488
+ if (!f) {
477
489
  t.value = !1;
478
490
  return;
479
491
  }
480
- const f = o.map((v) => a(c, v)), p = `${n}|${f.join("|")}`;
481
- if (d.value[p]) {
492
+ const g = o.map((m) => a(f, m)), l = `${n}|${g.join("|")}`;
493
+ if (u.value[l]) {
482
494
  t.value = !0;
483
495
  return;
484
496
  }
485
497
  t.value = !1;
486
- const g = f.filter(Boolean).map(String);
487
- await e(g), d.value[p] = !0, t.value = !0;
498
+ const b = g.filter(Boolean).map(String);
499
+ await e(b), u.value[l] = !0, t.value = !0;
488
500
  };
489
501
  }
490
502
  return i;
491
503
  }
492
- const te = {
504
+ const se = {
493
505
  en: ["US", "UK"]
494
- }, re = "FR";
495
- function oe(e) {
506
+ }, ue = "FR";
507
+ function de(e) {
496
508
  const a = e.trim().replace("_", "-"), [i, t] = a.split("-");
497
509
  return {
498
510
  language: i?.toLowerCase() ?? "",
499
511
  region: t?.toUpperCase() ?? ""
500
512
  };
501
513
  }
502
- function D(e) {
514
+ function K(e) {
503
515
  return e.toString().trim().toUpperCase();
504
516
  }
505
- function Me() {
517
+ function Ee() {
506
518
  function e(a, i) {
507
519
  if (!i.length) return;
508
- const t = i.map(D), n = new Set(t), { language: o, region: d } = oe(a), c = [];
509
- d && c.push(d);
510
- const f = te[o];
511
- f?.length && c.push(...f.map(D)), o && c.push(o.toUpperCase()), c.push(re);
512
- for (const p of c)
513
- if (n.has(p))
514
- return p;
520
+ const t = i.map(K), n = new Set(t), { language: o, region: u } = de(a), f = [];
521
+ u && f.push(u);
522
+ const g = se[o];
523
+ g?.length && f.push(...g.map(K)), o && f.push(o.toUpperCase()), f.push(ue);
524
+ for (const l of f)
525
+ if (n.has(l))
526
+ return l;
515
527
  return t[0];
516
528
  }
517
529
  return { getRegionFromLocale: e };
518
530
  }
519
- function Se() {
520
- const { t: e } = E();
531
+ function Re() {
532
+ const { t: e } = y();
521
533
  function a(i, t) {
522
- const n = e(i), o = [], c = t.map((m) => m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), f = new RegExp(`\\[(${c})\\]([\\s\\S]*?)\\[\\/\\1\\]`, "g"), p = t.reduce((m, C) => (m[C] = !1, m), {});
523
- let g = 0, v = f.exec(n);
524
- for (; v; ) {
525
- const { index: m, 0: C, 1: h, 2: b } = v;
526
- m > g && o.push({ text: n.slice(g, m), ...p }), b && h && o.push({ text: b, ...p, [h]: !0 }), g = m + C.length, v = f.exec(n);
534
+ const n = e(i), o = [], f = t.map((h) => h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), g = new RegExp(`\\[(${f})\\]([\\s\\S]*?)\\[\\/\\1\\]`, "g"), l = t.reduce((h, C) => (h[C] = !1, h), {});
535
+ let b = 0, m = g.exec(n);
536
+ for (; m; ) {
537
+ const { index: h, 0: C, 1: v, 2: p } = m;
538
+ h > b && o.push({ text: n.slice(b, h), ...l }), p && v && o.push({ text: p, ...l, [v]: !0 }), b = h + C.length, m = g.exec(n);
527
539
  }
528
- return g < n.length && o.push({ text: n.slice(g), ...p }), o;
540
+ return b < n.length && o.push({ text: n.slice(b), ...l }), o;
529
541
  }
530
542
  return { parse: a };
531
543
  }
532
- function Ie(e, a, i = 768) {
533
- const t = A(i - 1), n = y(
544
+ function ke(e, a, i = 768) {
545
+ const t = A(i - 1), n = T(
534
546
  () => t.value >= i ? a : e
535
547
  );
536
548
  if (import.meta.client) {
537
549
  const o = () => {
538
550
  t.value = window.innerWidth;
539
551
  };
540
- N(() => {
552
+ F(() => {
541
553
  o(), window.addEventListener("resize", o);
542
- }), O(() => {
554
+ }), Z(() => {
543
555
  window.removeEventListener("resize", o);
544
556
  });
545
557
  }
546
558
  return { size: n, windowWidth: t };
547
559
  }
548
- function Ee() {
549
- const { locale: e } = E();
560
+ function ye() {
561
+ const { locale: e } = y();
550
562
  function a(i, t = "fr") {
551
563
  if (!i) return "";
552
564
  const n = e.value;
@@ -555,21 +567,21 @@ function Ee() {
555
567
  return a;
556
568
  }
557
569
  export {
558
- ae as CREATE_PENDING_KEY,
559
- me as buildUrl,
560
- pe as configureHttp,
561
- G as getViewKey,
562
- ve as showAndThrowError,
563
- W as useAuthSession,
564
- be as useClickOutside,
565
- Be as useCountriesTranslation,
566
- Ae as useGtagConversion,
567
- ge as useHttp,
568
- Ce as useHubspotContactUrl,
569
- we as useImageCacheWatcherCallback,
570
- Me as useLocaleHelpers,
571
- Se as useParseTranslation,
572
- Ie as useResponsiveSize,
573
- he as useStore,
574
- Ee as useTranslate
570
+ te as CREATE_PENDING_KEY,
571
+ ve as buildUrl,
572
+ he as configureHttp,
573
+ N as getViewKey,
574
+ we as showAndThrowError,
575
+ X as useAuthSession,
576
+ Ae as useClickOutside,
577
+ Ce as useCountriesTranslation,
578
+ Me as useGtagConversion,
579
+ be as useHttp,
580
+ Se as useHubspotContactUrl,
581
+ Ie as useImageCacheWatcherCallback,
582
+ Ee as useLocaleHelpers,
583
+ Re as useParseTranslation,
584
+ ke as useResponsiveSize,
585
+ Be as useStore,
586
+ ye as useTranslate
575
587
  };
@@ -8,8 +8,8 @@ type ViewKey = string;
8
8
  * where a view's `items[]` could drift from `items.value[id]` after a re-fetch.
9
9
  *
10
10
  * `revision` is the store's revision when the page was requested: an `update()`
11
- * landing after that request makes the view stale, and the next `list()` on it
12
- * refetches the page.
11
+ * or a `markViewsStale()` landing after that request makes the view stale, and
12
+ * the next `list()` on it refetches the page.
13
13
  */
14
14
  type StoredView<Id extends IdKey> = ViewKeyParams & {
15
15
  itemIds: Id[];
@@ -64,6 +64,8 @@ export type Store<Id extends IdKey, Item, Params extends ViewKeyParams, CreatePa
64
64
  create: (payload: CreatePayload, key?: ViewKey | Id) => Promise<Item>;
65
65
  /** Calls `updateMutation` (wrapped in `withPending(id)`), replaces `items[id]`, and marks every view stale. */
66
66
  update: (id: Id, patch: UpdatePatch) => Promise<Item>;
67
+ /** Marks every cached view stale: `getView()` keeps serving it, the next `list()` on it refetches the page. */
68
+ markViewsStale: () => void;
67
69
  /** Calls `removeMutation` (wrapped in `withPending(id)`), deletes `items[id]`, removes id from every view. */
68
70
  remove: (id: Id) => Promise<void>;
69
71
  /** Clears every entry from `errors`. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@choosemycompany/lib",
3
3
  "description": "Shared composables, stores and types for ChooseMyCompany front apps",
4
- "version": "0.9.1",
4
+ "version": "0.10.0",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "packageManager": "pnpm@10.17.0",