@supersoniks/concorde 1.1.44 → 1.1.46

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.
Files changed (54) hide show
  1. package/README.md +9 -7
  2. package/concorde-core.bundle.js +39 -24
  3. package/concorde-core.es.js +907 -320
  4. package/core/components/functional/fetch/fetch.d.ts +2 -1
  5. package/core/components/functional/list/list.d.ts +3 -1
  6. package/core/components/functional/list/list.js +12 -7
  7. package/core/components/functional/queue/queue.d.ts +9 -2
  8. package/core/components/functional/queue/queue.js +131 -67
  9. package/core/components/functional/router/router.js +13 -4
  10. package/core/components/functional/sdui/sdui.d.ts +3 -2
  11. package/core/components/functional/sdui/sdui.js +1 -1
  12. package/core/components/functional/states/states.js +1 -0
  13. package/core/components/functional/value/value.js +3 -2
  14. package/core/components/ui/alert/alert.d.ts +3 -0
  15. package/core/components/ui/alert/alert.js +33 -1
  16. package/core/components/ui/badge/badge.d.ts +1 -1
  17. package/core/components/ui/badge/badge.js +9 -3
  18. package/core/components/ui/button/button.d.ts +1 -0
  19. package/core/components/ui/button/button.js +32 -28
  20. package/core/components/ui/form/checkbox/checkbox.d.ts +3 -0
  21. package/core/components/ui/form/checkbox/checkbox.js +14 -3
  22. package/core/components/ui/form/css/form-control.d.ts +1 -0
  23. package/core/components/ui/form/css/form-control.js +17 -0
  24. package/core/components/ui/form/input/input.d.ts +5 -3
  25. package/core/components/ui/form/input/input.js +47 -3
  26. package/core/components/ui/form/input-autocomplete/input-autocomplete.d.ts +93 -13
  27. package/core/components/ui/form/input-autocomplete/input-autocomplete.js +181 -52
  28. package/core/components/ui/form/select/select.js +16 -4
  29. package/core/components/ui/form/textarea/textarea.d.ts +1 -0
  30. package/core/components/ui/group/group.js +7 -1
  31. package/core/components/ui/icon/icon.js +1 -1
  32. package/core/components/ui/modal/modal-close.js +2 -3
  33. package/core/components/ui/modal/modal-content.js +1 -0
  34. package/core/components/ui/modal/modal.d.ts +8 -0
  35. package/core/components/ui/modal/modal.js +34 -6
  36. package/core/components/ui/pop/pop.d.ts +5 -4
  37. package/core/components/ui/pop/pop.js +85 -44
  38. package/core/components/ui/theme/theme-collection/core-variables.js +18 -9
  39. package/core/components/ui/theme/theme.js +8 -3
  40. package/core/components/ui/tooltip/tooltip.js +3 -3
  41. package/core/mixins/Fetcher.d.ts +2 -1
  42. package/core/mixins/Fetcher.js +42 -10
  43. package/core/mixins/FormCheckable.d.ts +1 -0
  44. package/core/mixins/FormElement.d.ts +1 -0
  45. package/core/mixins/FormElement.js +6 -2
  46. package/core/mixins/FormInput.d.ts +1 -0
  47. package/core/mixins/Subscriber.d.ts +1 -0
  48. package/core/mixins/Subscriber.js +17 -12
  49. package/core/utils/PublisherProxy.d.ts +30 -3
  50. package/core/utils/PublisherProxy.js +218 -6
  51. package/core/utils/api.d.ts +29 -3
  52. package/core/utils/api.js +117 -24
  53. package/mixins.d.ts +4 -1
  54. package/package.json +7 -2
@@ -65,6 +65,7 @@ declare const Form: <T extends Constructor<FormElementInterface>>(superClass: T)
65
65
  getAttribute(name: string): string;
66
66
  hasAttribute(attributeName: string): boolean;
67
67
  disconnectedCallback(): void;
68
+ getBoundingClientRect(): DOMRect;
68
69
  };
69
70
  } & T;
70
71
  export default Form;
@@ -30,6 +30,7 @@ export interface SubscriberInterface<PropsType = CoreJSType> {
30
30
  getAttribute(name: string): string;
31
31
  hasAttribute(attributeName: string): boolean;
32
32
  disconnectedCallback(): void;
33
+ getBoundingClientRect(): DOMRect;
33
34
  }
34
35
  declare const Subscriber: <PropsType = CoreJSType, T extends Constructor<LitElement> = Constructor<LitElement>>(superClass: T, type?: PropsType | undefined) => Constructor<SubscriberInterface<PropsType>> & T;
35
36
  export default Subscriber;
@@ -54,7 +54,7 @@ const Subscriber = (superClass, type) => {
54
54
  this.noAutoFill = false;
55
55
  this.forceAutoFill = false;
56
56
  /**
57
- *
57
+ * Passer ce paramètre à true permet de ne pas mettre à jour le composant lors d'un changement de interne de la propriété nommé props.
58
58
  */
59
59
  this.renderOnPropsInternalChange = false;
60
60
  /**
@@ -132,27 +132,31 @@ const Subscriber = (superClass, type) => {
132
132
  }
133
133
  updated(_changedProperties) {
134
134
  super.updated(_changedProperties);
135
- let ref = this.shadowRoot || this;
135
+ const ref = this.shadowRoot || this;
136
136
  const children = [...ref.children].filter((child) => child.tagName != "STYLE");
137
- let display = this.displayContents ? "contents" : children.length == 0 ? "none" : null;
137
+ const display = this.displayContents ? "contents" : children.length == 0 ? "none" : null;
138
138
  if (display)
139
139
  this.style.display = display;
140
140
  else
141
141
  this.style.removeProperty("display");
142
142
  }
143
143
  connectedCallback() {
144
+ SubscriberElement.instanceCounter++;
144
145
  if (this.hasAttribute("lazyRendering")) {
145
146
  const options = {
146
147
  root: null,
147
- rootMargin: Math.max(window.innerWidth * 0.1, window.innerHeight * 0.1) + "px",
148
+ rootMargin: Math.max(window.innerWidth, window.innerHeight) + "px",
148
149
  };
149
150
  let firstView = true;
150
151
  const iObserver = new IntersectionObserver((entries) => {
151
152
  for (const e of entries) {
152
153
  if (firstView && e.isIntersecting) {
154
+ this.addDebugger();
153
155
  firstView = false;
154
156
  this.initWording();
155
157
  this.initPublisher();
158
+ iObserver.disconnect();
159
+ break;
156
160
  }
157
161
  }
158
162
  }, options);
@@ -161,10 +165,9 @@ const Subscriber = (superClass, type) => {
161
165
  else {
162
166
  this.initWording();
163
167
  this.initPublisher();
168
+ this.addDebugger();
164
169
  }
165
- this.addDebugger();
166
170
  super.connectedCallback();
167
- SubscriberElement.instanceCounter++;
168
171
  }
169
172
  disconnectedCallback() {
170
173
  var _a;
@@ -253,14 +256,15 @@ const Subscriber = (superClass, type) => {
253
256
  const serviceURL = this.getAncestorAttributeValue("serviceURL");
254
257
  let userName = null;
255
258
  let password = null;
256
- let tokenProvider = null;
259
+ const tokenProvider = this.getAncestorAttributeValue("tokenProvider");
260
+ const authToken = this.getAncestorAttributeValue("eventsApiToken");
257
261
  if (!token) {
258
262
  userName = this.getAncestorAttributeValue("userName");
259
263
  password = this.getAncestorAttributeValue("password");
260
- tokenProvider = this.getAncestorAttributeValue("tokenProvider");
261
264
  }
262
265
  const credentials = this.getAncestorAttributeValue("credentials") || undefined;
263
- return { serviceURL, token, userName, password, tokenProvider, addHTTPResponse, credentials };
266
+ const cache = (this.getAttribute("cache") || undefined) || undefined;
267
+ return { serviceURL, token, userName, password, authToken, tokenProvider, addHTTPResponse, credentials, cache };
264
268
  }
265
269
  initWording() {
266
270
  return __awaiter(this, void 0, void 0, function* () {
@@ -274,16 +278,17 @@ const Subscriber = (superClass, type) => {
274
278
  }
275
279
  if (!hasWording)
276
280
  return;
277
- const publisher = PublisherManager.getInstance().get("sonic-wording");
281
+ const publisher = PublisherManager.get("sonic-wording");
278
282
  const wordingProvider = this.getAncestorAttributeValue("wordingProvider");
279
283
  const api = new API(this.getApiConfiguration());
280
284
  if (wordingProvider) {
281
285
  const wordings = [];
282
286
  const wordingsAll = [];
287
+ const publisherValue = publisher.get();
283
288
  for (const p of propNames) {
284
289
  if (p.indexOf("wording_") == 0) {
285
290
  const p8 = p.substring(8);
286
- if (!publisher.get()[p]) {
291
+ if (!publisherValue[p]) {
287
292
  publisher[p] = "...";
288
293
  wordings.push(p8);
289
294
  }
@@ -334,7 +339,7 @@ const Subscriber = (superClass, type) => {
334
339
  if (this.bindPublisher) {
335
340
  mng.set(publisherId, this.bindPublisher());
336
341
  }
337
- let pub = mng.get(publisherId);
342
+ let pub = mng.get(publisherId, { localStorageMode: this.getAttribute("localStorage") || "disabled" });
338
343
  this.dataProvider = publisherId;
339
344
  if (this.hasAttribute("subDataProvider")) {
340
345
  const dataPath = this.getAttribute("subDataProvider");
@@ -3,7 +3,7 @@
3
3
  * Merci de laisser ce fichier sans la moindre dépendance en dehors de types du ceur.
4
4
  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5
5
  * **/
6
- import { CoreJSType, PublisherContentType } from "../_types/types";
6
+ import { PublisherInterface, CoreJSType, PublisherContentType } from "../_types/types";
7
7
  type DynamicFillingListener = any;
8
8
  type TemplateFillingListener = {
9
9
  propertyMap: Record<string, string>;
@@ -12,15 +12,19 @@ type TemplateFillingListener = {
12
12
  * Custom Proxy contient les méthodes des publishers retournés par PublisherManager.get(publisherId) qui seront utilisées couramment
13
13
  */
14
14
  export declare class PublisherProxy<T = any> {
15
+ static instances: Map<number, PublisherProxy<any>>;
16
+ static instancesCounter: number;
15
17
  _proxies_: Map<string, PublisherProxy>;
16
18
  _value_: T;
17
19
  _key_: string;
20
+ _is_savable_: boolean;
18
21
  _invalidateListeners_: Set<VoidFunction>;
19
22
  _assignListeners_: Set<(value: T) => void>;
20
23
  _mutationListeners_: Set<VoidFunction>;
21
24
  _fillListeners_: Set<Record<string, CoreJSType>>;
22
25
  _templateFillListeners_: Set<any>;
23
26
  _lockInternalMutationPublishing_: boolean;
27
+ _instanceCounter_: number;
24
28
  parent: PublisherProxy | null;
25
29
  root: PublisherProxy;
26
30
  constructor(target: T, parentProxPub: PublisherProxy | null);
@@ -91,6 +95,10 @@ export declare class PublisherProxy<T = any> {
91
95
  * Extraire la valeur actuelle du proxy
92
96
  */
93
97
  get(): T;
98
+ /**
99
+ * retourner le webcomponent auquel le proxy est associé
100
+ */
101
+ get $tag(): string;
94
102
  }
95
103
  /**
96
104
  * Utilitaires de gestion des Publisher
@@ -98,9 +106,19 @@ export declare class PublisherProxy<T = any> {
98
106
  *
99
107
  */
100
108
  export declare class PublisherManager {
109
+ static changed: boolean;
110
+ static saving: boolean;
111
+ static saveId: number;
101
112
  static instance: PublisherManager | null;
113
+ enabledLocaStorageProxies: string[];
102
114
  publishers: Map<string, Publisher<PublisherContentType>>;
115
+ localStorageData: Record<string, {
116
+ lastModifiationMS: number;
117
+ data: PublisherContentType;
118
+ }>;
119
+ isLocalStrorageReady: Promise<boolean> | null;
103
120
  constructor();
121
+ cleanStorageData(): Promise<unknown>;
104
122
  /**
105
123
  * PublisherManager est un singleton
106
124
  */
@@ -109,7 +127,9 @@ export declare class PublisherManager {
109
127
  * shortcut static pour obtenir un publisher vias sont id/adresse sans taper getInstance.
110
128
  * Si le publisher n'existe pas, il est créé.
111
129
  */
112
- static get(id: string): any;
130
+ static get(id: string, options?: {
131
+ localStorageMode?: string;
132
+ }): any;
113
133
  /**
114
134
  * shortcut static pour supprimer un publisher de la liste et appel également delete sur le publisher ce qui le supprime, de même que ses sous publishers
115
135
  */
@@ -118,7 +138,11 @@ export declare class PublisherManager {
118
138
  * Obtenir un publisher vias sont id/adresse
119
139
  * Si le publisher n'existe pas, il est créé.
120
140
  */
121
- get(id: string): any;
141
+ setLocalData(publisher: PublisherInterface, id: string): Promise<void>;
142
+ initialisedData: string[];
143
+ get(id: string, options?: {
144
+ localStorageMode?: string;
145
+ }): any;
122
146
  /**
123
147
  * Remplace un publisher pour l'id fourni par un autre.
124
148
  * L'autre publisher n'est pas supprimé.
@@ -128,6 +152,9 @@ export declare class PublisherManager {
128
152
  * supprimer un publisher de la liste et appel également delete sur le publisher ce qui le supprime, de même que ses sous publishers
129
153
  */
130
154
  delete(id: string): boolean;
155
+ saveToLocalStorage(saveId?: number): Promise<void>;
156
+ compress(string: string, encoding: string): Promise<string>;
157
+ decompress(str: string, encoding: string): Promise<string>;
131
158
  }
132
159
  /**
133
160
  * Le Proxy Javascript
@@ -1,4 +1,13 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any*/
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  function isComplex(value) {
3
12
  return typeof value === "object" && value != null;
4
13
  }
@@ -9,15 +18,18 @@ export class PublisherProxy {
9
18
  constructor(target, parentProxPub) {
10
19
  this._proxies_ = new Map();
11
20
  this._key_ = "";
21
+ this._is_savable_ = false;
12
22
  this._invalidateListeners_ = new Set();
13
23
  this._assignListeners_ = new Set();
14
24
  this._mutationListeners_ = new Set();
15
25
  this._fillListeners_ = new Set();
16
26
  this._templateFillListeners_ = new Set();
17
27
  this._lockInternalMutationPublishing_ = false;
28
+ this._instanceCounter_ = 0;
18
29
  this._value_ = target;
19
30
  this.parent = parentProxPub || null;
20
31
  this.root = this;
32
+ this._instanceCounter_ = 0;
21
33
  while (this.root.parent) {
22
34
  this.root = this.root.parent;
23
35
  }
@@ -36,6 +48,7 @@ export class PublisherProxy {
36
48
  this._fillListeners_.clear();
37
49
  this._templateFillListeners_.clear();
38
50
  this._proxies_.clear();
51
+ PublisherProxy.instances.delete(this._instanceCounter_);
39
52
  }
40
53
  /**
41
54
  * Utile pour savoir si quelque chose est en écoute d'une modification sur le proxy via une des methodes associées
@@ -51,6 +64,12 @@ export class PublisherProxy {
51
64
  this._mutationListeners_.forEach((handler) => handler());
52
65
  if (lockInternalMutationsTransmission)
53
66
  return;
67
+ if (!PublisherManager.changed && this._is_savable_) {
68
+ PublisherManager.changed = true;
69
+ PublisherManager.saveId++;
70
+ const saveId = PublisherManager.saveId;
71
+ setTimeout(() => PublisherManager.getInstance().saveToLocalStorage(saveId), 1000);
72
+ }
54
73
  if (this.parent) {
55
74
  this.parent._publishInternalMutation_();
56
75
  }
@@ -273,7 +292,21 @@ export class PublisherProxy {
273
292
  }
274
293
  return this._value_;
275
294
  }
295
+ /**
296
+ * retourner le webcomponent auquel le proxy est associé
297
+ */
298
+ get $tag() {
299
+ if (!this._instanceCounter_) {
300
+ PublisherProxy.instancesCounter++;
301
+ this._instanceCounter_ = PublisherProxy.instancesCounter;
302
+ }
303
+ PublisherProxy.instances.set(this._instanceCounter_, this);
304
+ const str = '<reactive-publisher-proxy publisher="' + this._instanceCounter_ + '"></reactive-publisher-proxy>';
305
+ return str;
306
+ }
276
307
  }
308
+ PublisherProxy.instances = new Map();
309
+ PublisherProxy.instancesCounter = 0;
277
310
  /**
278
311
  * Utilitaires de gestion des Publisher
279
312
  * Obtenir, replacer ou supprimer un Publisher
@@ -281,10 +314,59 @@ export class PublisherProxy {
281
314
  */
282
315
  export class PublisherManager {
283
316
  constructor() {
317
+ this.enabledLocaStorageProxies = [];
284
318
  this.publishers = new Map();
319
+ this.localStorageData = {};
320
+ this.isLocalStrorageReady = null;
321
+ this.initialisedData = [];
285
322
  if (PublisherManager.instance != null)
286
323
  throw "Singleton / use getInstance";
287
324
  PublisherManager.instance = this;
325
+ this.isLocalStrorageReady = this.cleanStorageData();
326
+ }
327
+ cleanStorageData() {
328
+ return __awaiter(this, void 0, void 0, function* () {
329
+ return new Promise((resolve) => {
330
+ const doiIt = () => __awaiter(this, void 0, void 0, function* () {
331
+ try {
332
+ let compressedData = localStorage.getItem("publisher-proxies-data");
333
+ let localStorageJSON = null;
334
+ if (compressedData)
335
+ localStorageJSON = yield this.decompress(compressedData, "gzip");
336
+ if (localStorageJSON) {
337
+ try {
338
+ this.localStorageData = JSON.parse(localStorageJSON);
339
+ }
340
+ catch (e) {
341
+ this.localStorageData = {};
342
+ }
343
+ }
344
+ else {
345
+ compressedData = yield this.compress("{}", "gzip");
346
+ localStorage.setItem("publisher-proxies-data", compressedData);
347
+ this.localStorageData = {};
348
+ }
349
+ const expires = new Date().getTime() - 1000 * 60 * 60 * 12;
350
+ for (const key in this.localStorageData) {
351
+ const item = this.localStorageData[key];
352
+ if (item.lastModifiationMS < expires) {
353
+ delete this.localStorageData[key];
354
+ }
355
+ }
356
+ resolve(true);
357
+ // compressedData = await this.compress(JSON.stringify(this.localStorageData), "gzip");
358
+ // localStorage.setItem("publisher-proxies-data", compressedData);
359
+ }
360
+ catch (e) {
361
+ window.requestAnimationFrame(() => {
362
+ resolve(false);
363
+ });
364
+ console.log("no publisher cache in this browser");
365
+ }
366
+ });
367
+ doiIt();
368
+ });
369
+ });
288
370
  }
289
371
  /**
290
372
  * PublisherManager est un singleton
@@ -298,8 +380,8 @@ export class PublisherManager {
298
380
  * shortcut static pour obtenir un publisher vias sont id/adresse sans taper getInstance.
299
381
  * Si le publisher n'existe pas, il est créé.
300
382
  */
301
- static get(id) {
302
- return PublisherManager.getInstance().get(id);
383
+ static get(id, options) {
384
+ return PublisherManager.getInstance().get(id, options);
303
385
  }
304
386
  /**
305
387
  * shortcut static pour supprimer un publisher de la liste et appel également delete sur le publisher ce qui le supprime, de même que ses sous publishers
@@ -311,9 +393,26 @@ export class PublisherManager {
311
393
  * Obtenir un publisher vias sont id/adresse
312
394
  * Si le publisher n'existe pas, il est créé.
313
395
  */
314
- get(id) {
315
- if (!this.publishers.has(id))
316
- this.publishers.set(id, new Publisher({}));
396
+ setLocalData(publisher, id) {
397
+ var _a;
398
+ return __awaiter(this, void 0, void 0, function* () {
399
+ yield this.isLocalStrorageReady;
400
+ publisher.set(((_a = this.localStorageData[id + "¤page:>" + document.location.pathname]) === null || _a === void 0 ? void 0 : _a.data) || publisher.get());
401
+ });
402
+ }
403
+ get(id, options) {
404
+ const hasLocalStorage = (options === null || options === void 0 ? void 0 : options.localStorageMode) === "enabled";
405
+ if (!this.publishers.has(id)) {
406
+ const data = {};
407
+ const publisher = new Publisher(data);
408
+ this.set(id, publisher);
409
+ }
410
+ const publisher = this.publishers.get(id);
411
+ if (hasLocalStorage && this.initialisedData.indexOf(id) === -1) {
412
+ publisher._is_savable_ = true;
413
+ this.initialisedData.push(id);
414
+ this.setLocalData(publisher, id);
415
+ }
317
416
  return this.publishers.get(id);
318
417
  }
319
418
  /**
@@ -332,7 +431,86 @@ export class PublisherManager {
332
431
  this.publishers.delete(id);
333
432
  return true;
334
433
  }
434
+ saveToLocalStorage(saveId = 0) {
435
+ return __awaiter(this, void 0, void 0, function* () {
436
+ /**
437
+ * si l'id a changé et que ce n'est pas un multiple de 10, on ne sauve pas
438
+ * on sauvegarde quand même tous les 10 au cas ou on aurrait des changements en continue, par exemple à chaque frame
439
+ */
440
+ if (saveId !== PublisherManager.saveId && saveId % 10 != 0)
441
+ return;
442
+ try {
443
+ if (!PublisherManager.changed || PublisherManager.saving)
444
+ return;
445
+ PublisherManager.saving = true;
446
+ PublisherManager.changed = false;
447
+ const keys = Array.from(this.publishers.keys());
448
+ let hasChanged = false;
449
+ for (const key of keys) {
450
+ const publisher = this.publishers.get(key);
451
+ if (!(publisher === null || publisher === void 0 ? void 0 : publisher._is_savable_))
452
+ continue;
453
+ const data = publisher === null || publisher === void 0 ? void 0 : publisher.get();
454
+ if (!data)
455
+ continue;
456
+ this.localStorageData[key + "¤page:>" + document.location.pathname] = {
457
+ lastModifiationMS: new Date().getTime(),
458
+ data: data,
459
+ };
460
+ hasChanged = true;
461
+ }
462
+ // on enregistre les données
463
+ if (hasChanged) {
464
+ const compressedData = yield this.compress(JSON.stringify(this.localStorageData), "gzip");
465
+ localStorage.setItem("publisher-proxies-data", compressedData);
466
+ }
467
+ PublisherManager.saving = false;
468
+ if (PublisherManager.changed) {
469
+ PublisherManager.saveId++;
470
+ const saveId = PublisherManager.saveId;
471
+ setTimeout(() => this.saveToLocalStorage(saveId), 1000);
472
+ }
473
+ }
474
+ catch (e) {
475
+ PublisherManager.saving = false;
476
+ }
477
+ });
478
+ }
479
+ compress(string, encoding) {
480
+ return __awaiter(this, void 0, void 0, function* () {
481
+ const byteArray = new TextEncoder().encode(string);
482
+ const win = window;
483
+ const cs = new win.CompressionStream(encoding);
484
+ const writer = cs.writable.getWriter();
485
+ writer.write(byteArray);
486
+ writer.close();
487
+ const result = yield new Response(cs.readable).arrayBuffer();
488
+ const arrayBufferView = new Uint8Array(result);
489
+ let str = "";
490
+ for (let i = 0; i < arrayBufferView.length; i++) {
491
+ str += String.fromCharCode(arrayBufferView[i]);
492
+ }
493
+ return btoa(str);
494
+ });
495
+ }
496
+ decompress(str, encoding) {
497
+ return __awaiter(this, void 0, void 0, function* () {
498
+ const decodedString = atob(str);
499
+ const arrayBufferViewFromLocalStorage = Uint8Array.from(decodedString, (c) => c.charCodeAt(0));
500
+ const byteArray = arrayBufferViewFromLocalStorage.buffer;
501
+ const win = window;
502
+ const cs = new win.DecompressionStream(encoding);
503
+ const writer = cs.writable.getWriter();
504
+ writer.write(byteArray);
505
+ writer.close();
506
+ const result = yield new Response(cs.readable).arrayBuffer();
507
+ return new TextDecoder().decode(result);
508
+ });
509
+ }
335
510
  }
511
+ PublisherManager.changed = false;
512
+ PublisherManager.saving = false;
513
+ PublisherManager.saveId = 0;
336
514
  PublisherManager.instance = null;
337
515
  /**
338
516
  * Le Proxy Javascript
@@ -361,6 +539,7 @@ export default class Publisher extends PublisherProxy {
361
539
  "offInternalMutation",
362
540
  "set",
363
541
  "get",
542
+ "$tag",
364
543
  "_templateFillListeners_",
365
544
  "_fillListeners_",
366
545
  "_assignListeners_",
@@ -376,7 +555,9 @@ export default class Publisher extends PublisherProxy {
376
555
  "_proxies_",
377
556
  "parent",
378
557
  "_value_",
558
+ "_is_savable_",
379
559
  "_lockInternalMutationPublishing_",
560
+ "_instanceCounter_",
380
561
  ].includes(sKey))
381
562
  return publisherInstance[sKey];
382
563
  if (!publisherInstance._proxies_.has(sKey)) {
@@ -396,7 +577,14 @@ export default class Publisher extends PublisherProxy {
396
577
  //Fonctionnement pour la donnée interne pas de dispatch;
397
578
  if (sKey == "_value_") {
398
579
  publisherInstance._value_ = vValue;
399
- // return publisherInstance._value_;
580
+ return true;
581
+ }
582
+ if (sKey == "_is_savable_") {
583
+ publisherInstance._is_savable_ = vValue;
584
+ return true;
585
+ }
586
+ if (sKey == "_instanceCounter_") {
587
+ publisherInstance._instanceCounter_ = vValue;
400
588
  return true;
401
589
  }
402
590
  //Création du publisher si il n'existe pas
@@ -463,3 +651,27 @@ export default class Publisher extends PublisherProxy {
463
651
  }
464
652
  if (typeof module != "undefined")
465
653
  module.exports = { Publisher: Publisher, PublisherManager: PublisherManager };
654
+ // /**
655
+ // * A custom webcomponent wich will be linked to a publisher via its attribute "publisher"
656
+ // * the publisher will be found via PublisherManager.get(publisherId) and will be used to fill the component using the onAssign method
657
+ // */
658
+ class PublisherWebComponent extends HTMLElement {
659
+ constructor() {
660
+ super();
661
+ this.publisherId = "";
662
+ this.onAssign = (value) => {
663
+ this.innerHTML = value.toString();
664
+ };
665
+ }
666
+ connectedCallback() {
667
+ var _a;
668
+ this.publisherId = this.getAttribute("publisher") || "";
669
+ this.publisher = PublisherProxy.instances.get(parseInt(this.publisherId));
670
+ (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.onAssign(this.onAssign);
671
+ }
672
+ disconnectedCallback() {
673
+ var _a;
674
+ (_a = this.publisher) === null || _a === void 0 ? void 0 : _a.offAssign(this.onAssign);
675
+ }
676
+ }
677
+ customElements.define("reactive-publisher-proxy", PublisherWebComponent);
@@ -4,14 +4,24 @@ export type APIConfiguration = {
4
4
  token: string | null;
5
5
  userName: string | null;
6
6
  password: string | null;
7
+ authToken: string | null;
7
8
  tokenProvider: string | null;
8
9
  addHTTPResponse?: boolean;
9
10
  credentials?: RequestCredentials;
11
+ cache?: RequestCache;
10
12
  };
11
13
  export type ResultTypeInterface = CoreJSType & {
12
14
  _sonic_http_response_?: Response;
13
15
  text?: string;
14
16
  };
17
+ export type APICall = {
18
+ apiMethod: "get" | "send" | "submitFormData";
19
+ path: string;
20
+ additionalHeaders: HeadersInit | undefined;
21
+ method?: string | undefined;
22
+ data?: unknown;
23
+ cache?: RequestCache;
24
+ };
15
25
  declare class API {
16
26
  /**
17
27
  * Ce tableau static permet de ne pas appeler plusieurs fois le même service lors d'appel concurrents en GET.
@@ -32,11 +42,17 @@ declare class API {
32
42
  /**
33
43
  * le bearer token a passer pour les appels REST
34
44
  */
35
- token: string | null | undefined;
45
+ private _token;
46
+ set token(token: string | null | undefined);
47
+ get token(): string | null | undefined;
36
48
  /**
37
49
  * Le endPoint pour obtenir le bearer token qui sera concaténé à l'url du service
38
50
  */
39
51
  tokenProvider: string | null;
52
+ /**
53
+ * le bearer token à passer pour un éventuel renouvellement de token automatique
54
+ */
55
+ authToken: string | null;
40
56
  /**
41
57
  * credentials
42
58
  */
@@ -45,13 +61,23 @@ declare class API {
45
61
  * Tableau static des tokens stokés en memoire vive (comportement à revoir à l'occasion)
46
62
  */
47
63
  static tokens: Map<string | null, string | null | undefined>;
64
+ /**
65
+ * Tableau stockant l'ensemble des tokens invalides
66
+ */
67
+ static invalidTokens: (string | null | undefined)[];
68
+ handleInvalidToken(token: string | null | undefined): void;
69
+ /**
70
+ * Tableau static des tentatives échouées de récupération auto du token
71
+ */
72
+ static failledTokenUpdates: Map<string | null, true>;
48
73
  /**
49
74
  * Le endPoint pour obtenir le bearer token qui sera concaténé à l'url du service
50
75
  */
51
76
  addHTTPResponse: boolean;
77
+ cache: RequestCache;
52
78
  lastResult?: Response;
53
79
  constructor(config: APIConfiguration);
54
- handleResult(fetchResult?: Response): Promise<ResultTypeInterface>;
80
+ handleResult(fetchResult: Response, lastCall: APICall): Promise<ResultTypeInterface>;
55
81
  /**
56
82
  * Basic auth
57
83
  */
@@ -65,7 +91,7 @@ declare class API {
65
91
  /**
66
92
  * Concatène le serviceURL et le endpoint donné en paramètre
67
93
  */
68
- computeURL(path: string): string;
94
+ computeURL(path: string, query?: Record<string, string>): string;
69
95
  send<T, SendType = CoreJSType>(path: string, data: SendType, method?: string, additionalHeaders?: HeadersInit): Promise<T & ResultTypeInterface>;
70
96
  /**
71
97
  * Agit comme une soumission de formulaire, mais attends un json en réponse