@supersoniks/concorde 3.3.2 → 4.0.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/build-infos.json +1 -1
- package/concorde-core.bundle.js +154 -154
- package/concorde-core.es.js +2366 -2356
- package/dist/concorde-core.bundle.js +154 -154
- package/dist/concorde-core.es.js +2366 -2356
- package/package.json +1 -4
- package/src/core/_types/types.ts +1 -1
- package/src/core/components/functional/queue/queue.ts +3 -4
- package/src/core/components/functional/states/states.demo.ts +5 -2
- package/src/core/components/functional/states/states.spec.ts +14 -13
- package/src/core/components/functional/submit/submit.ts +2 -2
- package/src/core/components/ui/captcha/captcha.ts +16 -12
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.ts +41 -7
- package/src/core/components/ui/pop/pop.ts +6 -6
- package/src/core/components/ui/theme/theme.ts +3 -3
- package/src/core/decorators/subscriber/bind.ts +2 -2
- package/src/core/decorators/subscriber/onAssign.ts +6 -4
- package/src/core/directives/DataProvider.ts +47 -60
- package/src/core/directives/Wording.ts +4 -4
- package/src/core/mixins/FormCheckable.ts +12 -12
- package/src/core/mixins/FormElement.ts +1 -1
- package/src/core/utils/PublisherProxy.ts +260 -178
- package/src/core/utils/Utils.ts +3 -0
- package/src/core/utils/api.ts +4 -6
- package/src/dataprovider.ts +1 -0
- package/src/directives.ts +27 -13
- package/src/docs/_misc/on-assign.md +5 -5
- package/src/docs/search/docs-search.json +70 -0
- package/src/tsconfig.json +0 -9
- package/src/tsconfig.tsbuildinfo +1 -1
- package/src/utils.ts +2 -4
- package/mcp-server/COMPARISON-MCP.md +0 -176
- package/mcp-server/README-MCP-NODEJS.md +0 -284
- package/mcp-server/README-MCP.md +0 -114
- package/mcp-server/README.md +0 -127
- package/mcp-server/TECHNICAL-DOCS.md +0 -269
- package/mcp-server/concorde-mcp-server.js +0 -859
- package/mcp-server/concorde-mcp-server.py +0 -801
- package/mcp-server/cursor-mcp-config-advanced.json +0 -68
- package/mcp-server/cursor-mcp-config-nodejs.json +0 -74
- package/mcp-server/cursor-mcp-config.json +0 -11
- package/mcp-server/install-mcp-nodejs.sh +0 -104
- package/mcp-server/install-mcp.sh +0 -62
- package/mcp-server/package-lock.json +0 -147
- package/mcp-server/package-mcp.json +0 -40
- package/mcp-server/package.json +0 -40
- package/mcp-server/test-mcp.js +0 -107
- package/mcp-server/test-mcp.py +0 -73
- package/src/core/components/ui/toast/message-subscriber.stories.ts +0 -43
|
@@ -4,13 +4,17 @@
|
|
|
4
4
|
* Merci de laisser ce fichier sans la moindre dépendance en dehors de types du ceur.
|
|
5
5
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
6
6
|
* **/
|
|
7
|
-
import {
|
|
7
|
+
import type {
|
|
8
8
|
PublisherInterface,
|
|
9
9
|
CoreJSType,
|
|
10
10
|
PublisherContentType,
|
|
11
11
|
} from "../_types/types";
|
|
12
12
|
import HTML from "./HTML";
|
|
13
|
+
import Objects from "./Objects";
|
|
13
14
|
import { sonicClassPrefix } from "./Utils";
|
|
15
|
+
|
|
16
|
+
export type Observable = string;
|
|
17
|
+
|
|
14
18
|
type DynamicFillingListener = any;
|
|
15
19
|
type TemplateFillingListener = {
|
|
16
20
|
propertyMap: Record<string, string>;
|
|
@@ -74,7 +78,7 @@ export class PublisherProxy<T = any> {
|
|
|
74
78
|
constructor(
|
|
75
79
|
target: T,
|
|
76
80
|
parentProxPub: PublisherProxy | null,
|
|
77
|
-
parentKey?: string
|
|
81
|
+
parentKey?: string,
|
|
78
82
|
) {
|
|
79
83
|
this._value_ = target;
|
|
80
84
|
this.parent = parentProxPub || null;
|
|
@@ -119,7 +123,7 @@ export class PublisherProxy<T = any> {
|
|
|
119
123
|
_assignmentId_ = 0;
|
|
120
124
|
_publishInternalMutation_(lockInternalMutationsTransmission = false) {
|
|
121
125
|
this._mutationListeners_.forEach((handler: VoidFunction): void =>
|
|
122
|
-
handler()
|
|
126
|
+
handler(),
|
|
123
127
|
);
|
|
124
128
|
if (this._is_savable_ && !PublisherManager.changed) {
|
|
125
129
|
PublisherManager.changed = true;
|
|
@@ -127,7 +131,7 @@ export class PublisherProxy<T = any> {
|
|
|
127
131
|
const saveId = PublisherManager.saveId;
|
|
128
132
|
setTimeout(
|
|
129
133
|
() => PublisherManager.getInstance().saveToLocalStorage(saveId),
|
|
130
|
-
1000
|
|
134
|
+
1000,
|
|
131
135
|
);
|
|
132
136
|
}
|
|
133
137
|
if (lockInternalMutationsTransmission) return;
|
|
@@ -153,7 +157,7 @@ export class PublisherProxy<T = any> {
|
|
|
153
157
|
|
|
154
158
|
_publishFormInvalidation_() {
|
|
155
159
|
this._formInvalidateListeners_.forEach((handler: VoidFunction) =>
|
|
156
|
-
handler()
|
|
160
|
+
handler(),
|
|
157
161
|
);
|
|
158
162
|
}
|
|
159
163
|
_publishDynamicFilling_(key: string, value: CoreJSType) {
|
|
@@ -376,7 +380,7 @@ export class PublisherProxy<T = any> {
|
|
|
376
380
|
if (this.parent && this._parentKey_) {
|
|
377
381
|
this.parent._publishDynamicFilling_(
|
|
378
382
|
this._parentKey_,
|
|
379
|
-
(this._value_ as any).__value
|
|
383
|
+
(this._value_ as any).__value,
|
|
380
384
|
);
|
|
381
385
|
}
|
|
382
386
|
|
|
@@ -421,7 +425,7 @@ export class PublisherProxy<T = any> {
|
|
|
421
425
|
if (this.parent && this._parentKey_)
|
|
422
426
|
this.parent._publishDynamicFilling_(
|
|
423
427
|
this._parentKey_,
|
|
424
|
-
this._value_ as any
|
|
428
|
+
this._value_ as any,
|
|
425
429
|
);
|
|
426
430
|
/**
|
|
427
431
|
* Si la donnée est complexe (objet, tableau)
|
|
@@ -436,7 +440,7 @@ export class PublisherProxy<T = any> {
|
|
|
436
440
|
const valueV = isVComplex ? v : { __value: v };
|
|
437
441
|
if (!this._proxies_.has(key)) {
|
|
438
442
|
// A surveiller ancienne version
|
|
439
|
-
// const newPublisher = new
|
|
443
|
+
// const newPublisher = new DataProvider({}, this);
|
|
440
444
|
// this._proxies_.set(key, newPublisher);
|
|
441
445
|
// newPublisher._proxies_.set("_parent_", this);
|
|
442
446
|
|
|
@@ -488,8 +492,8 @@ export class PublisherProxy<T = any> {
|
|
|
488
492
|
}
|
|
489
493
|
|
|
490
494
|
/**
|
|
491
|
-
* Utilitaires de gestion des
|
|
492
|
-
* Obtenir, replacer ou supprimer un
|
|
495
|
+
* Utilitaires de gestion des DataProvider
|
|
496
|
+
* Obtenir, replacer ou supprimer un DataProvider
|
|
493
497
|
*
|
|
494
498
|
*/
|
|
495
499
|
|
|
@@ -501,7 +505,7 @@ export class PublisherManager {
|
|
|
501
505
|
static instance: PublisherManager | null = null;
|
|
502
506
|
static instances: Map<string, PublisherManager> = new Map();
|
|
503
507
|
enabledLocaStorageProxies: string[] = [];
|
|
504
|
-
publishers = new Map<string,
|
|
508
|
+
publishers = new Map<string, PublisherInterface>();
|
|
505
509
|
localStorageData: Record<
|
|
506
510
|
string,
|
|
507
511
|
{
|
|
@@ -582,7 +586,7 @@ export class PublisherManager {
|
|
|
582
586
|
console.warn(
|
|
583
587
|
"No PublisherManager instance registered with id:",
|
|
584
588
|
id,
|
|
585
|
-
"creating new one"
|
|
589
|
+
"creating new one",
|
|
586
590
|
);
|
|
587
591
|
return new PublisherManager();
|
|
588
592
|
}
|
|
@@ -595,7 +599,7 @@ export class PublisherManager {
|
|
|
595
599
|
if (PublisherManager.instances.has(id)) {
|
|
596
600
|
console.warn(
|
|
597
601
|
"PublisherManager instance already registered with id: ",
|
|
598
|
-
id
|
|
602
|
+
id,
|
|
599
603
|
);
|
|
600
604
|
}
|
|
601
605
|
PublisherManager.instances.set(id, instance);
|
|
@@ -607,17 +611,17 @@ export class PublisherManager {
|
|
|
607
611
|
*/
|
|
608
612
|
public static get(
|
|
609
613
|
id: string,
|
|
610
|
-
options?: { localStorageMode?: string; expirationDelayMs?: number }
|
|
614
|
+
options?: { localStorageMode?: string; expirationDelayMs?: number },
|
|
611
615
|
) {
|
|
612
616
|
return PublisherManager.getInstance().get(id, options);
|
|
613
617
|
}
|
|
614
618
|
|
|
615
|
-
public static modifiedCollectore: Set<
|
|
619
|
+
public static modifiedCollectore: Set<any>[] = [];
|
|
616
620
|
public static collectModifiedPublisher() {
|
|
617
|
-
PublisherManager.modifiedCollectore.unshift(new Set());
|
|
621
|
+
PublisherManager.modifiedCollectore.unshift(new Set<any>());
|
|
618
622
|
}
|
|
619
623
|
public static getModifiedPublishers() {
|
|
620
|
-
return PublisherManager.modifiedCollectore.shift()
|
|
624
|
+
return PublisherManager.modifiedCollectore.shift() as Set<any>;
|
|
621
625
|
}
|
|
622
626
|
|
|
623
627
|
/**
|
|
@@ -636,38 +640,40 @@ export class PublisherManager {
|
|
|
636
640
|
await this.isLocalStrorageReady;
|
|
637
641
|
publisher.set(
|
|
638
642
|
this.localStorageData[id + "¤lang_" + HTML.getLanguage()]?.data ||
|
|
639
|
-
publisher.get()
|
|
643
|
+
publisher.get(),
|
|
640
644
|
);
|
|
641
645
|
}
|
|
642
646
|
|
|
643
647
|
initialisedData: string[] = [];
|
|
644
|
-
get(id: string, options?: PublisherProxyOptions) {
|
|
648
|
+
get<T = any>(id: string, options?: PublisherProxyOptions): DataProvider<T> {
|
|
645
649
|
const hasLocalStorage = options?.localStorageMode === "enabled";
|
|
646
650
|
const invalidateOnPageShow = options?.invalidateOnPageShow === true;
|
|
647
651
|
if (!this.publishers.has(id)) {
|
|
648
652
|
const data = {};
|
|
649
|
-
const publisher =
|
|
653
|
+
const publisher = createPublisher(data as T) as DataProvider<T>;
|
|
650
654
|
this.set(id, publisher);
|
|
651
655
|
}
|
|
652
|
-
const publisher = this.publishers.get(id) as
|
|
656
|
+
const publisher = this.publishers.get(id) as DataProvider<T>;
|
|
653
657
|
if (hasLocalStorage && this.initialisedData.indexOf(id) === -1) {
|
|
654
658
|
if (options?.expirationDelayMs) {
|
|
655
|
-
publisher._expiration_delay_ =
|
|
659
|
+
(publisher as PublisherProxy<T>)._expiration_delay_ =
|
|
660
|
+
options.expirationDelayMs;
|
|
656
661
|
}
|
|
657
|
-
publisher._is_savable_ = true;
|
|
662
|
+
(publisher as PublisherProxy<T>)._is_savable_ = true;
|
|
658
663
|
this.initialisedData.push(id);
|
|
659
664
|
this.setLocalData(publisher, id);
|
|
660
665
|
}
|
|
661
666
|
if (invalidateOnPageShow) {
|
|
662
|
-
publisher._invalidate_on_page_show_ =
|
|
667
|
+
(publisher as PublisherProxy<T>)._invalidate_on_page_show_ =
|
|
668
|
+
invalidateOnPageShow;
|
|
663
669
|
}
|
|
664
|
-
return this.publishers.get(id) as
|
|
670
|
+
return this.publishers.get(id) as DataProvider<T>;
|
|
665
671
|
}
|
|
666
672
|
/**
|
|
667
673
|
* Remplace un publisher pour l'id fourni par un autre.
|
|
668
674
|
* L'autre publisher n'est pas supprimé.
|
|
669
675
|
*/
|
|
670
|
-
set(id: string, publisher:
|
|
676
|
+
set<T = any>(id: string, publisher: DataProvider<T>) {
|
|
671
677
|
this.publishers.set(id, publisher);
|
|
672
678
|
}
|
|
673
679
|
/**
|
|
@@ -715,7 +721,7 @@ export class PublisherManager {
|
|
|
715
721
|
if (hasChanged) {
|
|
716
722
|
const compressedData = await this.compress(
|
|
717
723
|
JSON.stringify(this.localStorageData),
|
|
718
|
-
"gzip"
|
|
724
|
+
"gzip",
|
|
719
725
|
);
|
|
720
726
|
localStorage.setItem(localStorageDataKey, compressedData);
|
|
721
727
|
}
|
|
@@ -749,7 +755,7 @@ export class PublisherManager {
|
|
|
749
755
|
const decodedString = atob(str);
|
|
750
756
|
const arrayBufferViewFromLocalStorage = Uint8Array.from(
|
|
751
757
|
decodedString,
|
|
752
|
-
(c) => c.charCodeAt(0)
|
|
758
|
+
(c) => c.charCodeAt(0),
|
|
753
759
|
);
|
|
754
760
|
const byteArray = arrayBufferViewFromLocalStorage.buffer;
|
|
755
761
|
const win = window as any;
|
|
@@ -811,169 +817,194 @@ const internalProps: Set<string> = new Set([
|
|
|
811
817
|
"_assignmentId_",
|
|
812
818
|
"_invalidate_on_page_show_",
|
|
813
819
|
]);
|
|
814
|
-
|
|
820
|
+
// type UnderscoreWrappedKeys<T> = {
|
|
821
|
+
// [K in keyof T]-?: K extends `_${string}_` ? K : never
|
|
822
|
+
// }[keyof T];
|
|
815
823
|
/**
|
|
816
824
|
* Le Proxy Javascript
|
|
817
825
|
*/
|
|
818
|
-
|
|
819
|
-
T
|
|
820
|
-
|
|
821
|
-
constructor(
|
|
822
|
-
target: T,
|
|
823
|
-
parentProxPub: PublisherProxy | null = null,
|
|
824
|
-
parentKey?: string
|
|
825
|
-
) {
|
|
826
|
-
super(target, parentProxPub, parentKey);
|
|
826
|
+
type WithoutUnderscoreKeys<T> = {
|
|
827
|
+
[K in keyof T as K extends `_${string}_` ? never : K]: T[K];
|
|
828
|
+
};
|
|
827
829
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
* Les methodes de PublisherProxy (onAssign... : voir liste dans kle tableaus si dessous), si la clef est une méthode de PublisherProxy,,
|
|
832
|
-
* Sinon un autre proxy qui a comme valeur interne la valeur corespondante à la clef dans l'objet.
|
|
833
|
-
*/
|
|
834
|
-
get: function (publisherInstance: PublisherProxy<T>, sKey: any) {
|
|
835
|
-
if (internalProps.has(sKey)) return (publisherInstance as any)[sKey];
|
|
836
|
-
if (sKey == Symbol.toPrimitive) {
|
|
837
|
-
return () => thisProxy.get();
|
|
838
|
-
}
|
|
830
|
+
export type DataProvider<T = any> = WithoutUnderscoreKeys<PublisherProxy<T>> & {
|
|
831
|
+
[K in keyof T]: DataProvider<T[K]>;
|
|
832
|
+
};
|
|
839
833
|
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
}
|
|
857
|
-
return publisherInstance._proxies_.get(sKey);
|
|
858
|
-
},
|
|
859
|
-
/**
|
|
860
|
-
* Lorsque l'on écrit publisher.maClef = value ou publisher["maClef"] = value, on assigne la valeur à la clef dans l'objet interne.
|
|
861
|
-
* Les gestionnairs associés sopnt déclenchés en conséquence de manière profonde et remontante si nécessaire.
|
|
862
|
-
*/
|
|
863
|
-
set: function (publisherInstance, sKey: string, vValue) {
|
|
864
|
-
//Fonctionnement pour la donnée interne pas de dispatch;
|
|
865
|
-
if (sKey == "_value_") {
|
|
866
|
-
publisherInstance._value_ = vValue;
|
|
867
|
-
return true;
|
|
868
|
-
}
|
|
869
|
-
if (sKey == "_cachedGet_") {
|
|
870
|
-
publisherInstance._cachedGet_ = vValue;
|
|
871
|
-
return true;
|
|
872
|
-
}
|
|
873
|
-
if (sKey == "_assignmentId_") {
|
|
874
|
-
publisherInstance._assignmentId_ = vValue;
|
|
875
|
-
return true;
|
|
876
|
-
}
|
|
834
|
+
function createPublisherHandler<T = any>(
|
|
835
|
+
publisherInstance: PublisherProxy<T>,
|
|
836
|
+
getProxy: () => DataProvider<T>,
|
|
837
|
+
): ProxyHandler<PublisherProxy<T>> {
|
|
838
|
+
return {
|
|
839
|
+
/**
|
|
840
|
+
* Lorsque l'on écrit monConteneur = publisher.maClef ou monConteneur = publisher["maClef"] monConteneur contient :
|
|
841
|
+
* Les methodes de PublisherProxy (onAssign... : voir liste dans kle tableaus si dessous), si la clef est une méthode de PublisherProxy,,
|
|
842
|
+
* Sinon un autre proxy qui a comme valeur interne la valeur corespondante à la clef dans l'objet.
|
|
843
|
+
*/
|
|
844
|
+
get: function (_publisherInstance, sKey: any) {
|
|
845
|
+
if (typeof sKey === "string" && internalProps.has(sKey))
|
|
846
|
+
return (publisherInstance as any)[sKey];
|
|
847
|
+
if (sKey == Symbol.toPrimitive) {
|
|
848
|
+
return () => getProxy().get() as T;
|
|
849
|
+
}
|
|
877
850
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
publisherInstance._expiration_delay_ = vValue;
|
|
884
|
-
return true;
|
|
885
|
-
}
|
|
886
|
-
if (sKey == "_invalidate_on_page_show_") {
|
|
887
|
-
publisherInstance._invalidate_on_page_show_ = vValue;
|
|
888
|
-
return true;
|
|
889
|
-
}
|
|
890
|
-
if (sKey == "_instanceCounter_") {
|
|
891
|
-
publisherInstance._instanceCounter_ = vValue;
|
|
892
|
-
return true;
|
|
893
|
-
}
|
|
851
|
+
// Support de la notation à points (rigolo mais pas intuitif)
|
|
852
|
+
// if (sKey.includes(".")) {
|
|
853
|
+
// const keys = sKey.split(".");
|
|
854
|
+
// return thisProxy[keys.shift()][keys.join(".")];
|
|
855
|
+
// }
|
|
894
856
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
// const keys = sKey.split(".");
|
|
898
|
-
// thisProxy[keys.shift() || ""][keys.join(".")].set(vValue);
|
|
899
|
-
// return true;
|
|
900
|
-
// }
|
|
901
|
-
|
|
902
|
-
//Création du publisher si il n'existe pas
|
|
903
|
-
if (!publisherInstance._proxies_.has(sKey)) {
|
|
904
|
-
const newPublisher = new Publisher({}, publisherInstance, sKey);
|
|
905
|
-
newPublisher._proxies_.set("_parent_", thisProxy);
|
|
906
|
-
publisherInstance._proxies_.set(sKey, newPublisher);
|
|
907
|
-
}
|
|
908
|
-
//mis à jour et publication de la donnée si elle a changé
|
|
857
|
+
if (!publisherInstance._proxies_.has(sKey)) {
|
|
858
|
+
const vValue = (publisherInstance._value_ as any)[sKey];
|
|
909
859
|
|
|
910
|
-
const
|
|
860
|
+
const newPublisher = createPublisher(
|
|
861
|
+
isComplex(vValue) ? vValue : ({ __value: vValue } as any),
|
|
862
|
+
publisherInstance,
|
|
863
|
+
sKey,
|
|
864
|
+
);
|
|
865
|
+
newPublisher._proxies_.set("_parent_", getProxy());
|
|
866
|
+
publisherInstance._proxies_.set(sKey, newPublisher);
|
|
867
|
+
}
|
|
868
|
+
return publisherInstance._proxies_.get(sKey);
|
|
869
|
+
},
|
|
870
|
+
/**
|
|
871
|
+
* Lorsque l'on écrit publisher.maClef = value ou publisher["maClef"] = value, on assigne la valeur à la clef dans l'objet interne.
|
|
872
|
+
* Les gestionnairs associés sopnt déclenchés en conséquence de manière profonde et remontante si nécessaire.
|
|
873
|
+
*/
|
|
874
|
+
set: function (
|
|
875
|
+
_publisherInstance,
|
|
876
|
+
sKey: string,
|
|
877
|
+
vValue: T | PublisherProxy[keyof PublisherProxy],
|
|
878
|
+
) {
|
|
879
|
+
//Fonctionnement pour la donnée interne pas de dispatch;
|
|
880
|
+
if (sKey == "_value_") {
|
|
881
|
+
publisherInstance._value_ = vValue;
|
|
882
|
+
return true;
|
|
883
|
+
}
|
|
884
|
+
if (sKey == "_cachedGet_") {
|
|
885
|
+
publisherInstance._cachedGet_ = vValue;
|
|
886
|
+
return true;
|
|
887
|
+
}
|
|
888
|
+
if (sKey == "_assignmentId_") {
|
|
889
|
+
publisherInstance._assignmentId_ = vValue;
|
|
890
|
+
return true;
|
|
891
|
+
}
|
|
911
892
|
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
publisherInstance._publishDynamicFilling_(sKey, vValue);
|
|
915
|
-
publisherInstance._proxies_
|
|
916
|
-
.get(sKey)
|
|
917
|
-
?.set(isComplex(vValue) ? vValue : { __value: vValue });
|
|
918
|
-
}
|
|
919
|
-
//on retourne le proxy pour pouvoir chainer les assignements
|
|
920
|
-
// return publisherInstance._proxies_.get(sKey);
|
|
893
|
+
if (sKey == "_is_savable_") {
|
|
894
|
+
publisherInstance._is_savable_ = vValue;
|
|
921
895
|
return true;
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
*/
|
|
926
|
-
deleteProperty: function (publisherInstance, sKey: string) {
|
|
927
|
-
publisherInstance;
|
|
928
|
-
publisherInstance._publishDynamicFilling_(sKey, null);
|
|
929
|
-
// if (!publisherInstance._proxies_.get(sKey)?.hasListener()) {
|
|
930
|
-
// publisherInstance._proxies_.delete(sKey);
|
|
931
|
-
// } else {
|
|
932
|
-
publisherInstance._proxies_.get(sKey)?.set(null);
|
|
933
|
-
// }
|
|
934
|
-
return delete (publisherInstance._value_ as any)[sKey];
|
|
935
|
-
},
|
|
936
|
-
// enumerate: function (publisherInstance, sKey): CoreJSType {
|
|
937
|
-
// return publisherInstance._value_.keys();
|
|
938
|
-
// },
|
|
939
|
-
has: function (publisherInstance, sKey) {
|
|
940
|
-
publisherInstance;
|
|
941
|
-
return (
|
|
942
|
-
sKey in (publisherInstance._value_ as any) &&
|
|
943
|
-
sKey != "_lockInternalMutationPublishing_"
|
|
944
|
-
);
|
|
945
|
-
},
|
|
946
|
-
defineProperty: function (publisherInstance, sKey, oDesc) {
|
|
947
|
-
publisherInstance;
|
|
948
|
-
if (oDesc && "value" in oDesc) {
|
|
949
|
-
(publisherInstance._value_ as any)[sKey] = oDesc.value;
|
|
950
|
-
}
|
|
896
|
+
}
|
|
897
|
+
if (sKey == "_expiration_delay_") {
|
|
898
|
+
publisherInstance._expiration_delay_ = vValue;
|
|
951
899
|
return true;
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
},
|
|
962
|
-
ownKeys: function (publisherInstance) {
|
|
963
|
-
if ((publisherInstance._value_ as any).__value)
|
|
964
|
-
return Object.keys((publisherInstance._value_ as any).__value);
|
|
965
|
-
return Object.keys((publisherInstance as any)._value_);
|
|
966
|
-
},
|
|
967
|
-
});
|
|
968
|
-
return thisProxy as any;
|
|
969
|
-
}
|
|
900
|
+
}
|
|
901
|
+
if (sKey == "_invalidate_on_page_show_") {
|
|
902
|
+
publisherInstance._invalidate_on_page_show_ = vValue;
|
|
903
|
+
return true;
|
|
904
|
+
}
|
|
905
|
+
if (sKey == "_instanceCounter_") {
|
|
906
|
+
publisherInstance._instanceCounter_ = vValue;
|
|
907
|
+
return true;
|
|
908
|
+
}
|
|
970
909
|
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
910
|
+
// Support de la notation à points (rigolo mais pas intuitif)
|
|
911
|
+
// if (sKey.includes(".")) {
|
|
912
|
+
// const keys = sKey.split(".");
|
|
913
|
+
// thisProxy[keys.shift() || ""][keys.join(".")].set(vValue);
|
|
914
|
+
// return true;
|
|
915
|
+
// }
|
|
916
|
+
|
|
917
|
+
//Création du publisher si il n'existe pas
|
|
918
|
+
if (!publisherInstance._proxies_.has(sKey)) {
|
|
919
|
+
const newPublisher = createPublisher(
|
|
920
|
+
{} as any,
|
|
921
|
+
publisherInstance,
|
|
922
|
+
sKey,
|
|
923
|
+
);
|
|
924
|
+
newPublisher._proxies_.set("_parent_", getProxy());
|
|
925
|
+
publisherInstance._proxies_.set(sKey, newPublisher);
|
|
926
|
+
}
|
|
927
|
+
//mis à jour et publication de la donnée si elle a changé
|
|
928
|
+
|
|
929
|
+
const prevValue = (publisherInstance._value_ as any)[sKey];
|
|
930
|
+
|
|
931
|
+
if (prevValue !== vValue) {
|
|
932
|
+
(publisherInstance._value_ as any)[sKey] = vValue;
|
|
933
|
+
publisherInstance._publishDynamicFilling_(sKey, vValue);
|
|
934
|
+
publisherInstance._proxies_
|
|
935
|
+
.get(sKey)
|
|
936
|
+
?.set(isComplex(vValue) ? vValue : { __value: vValue });
|
|
937
|
+
}
|
|
938
|
+
//on retourne le proxy pour pouvoir chainer les assignements
|
|
939
|
+
// return publisherInstance._proxies_.get(sKey);
|
|
940
|
+
return true;
|
|
941
|
+
},
|
|
942
|
+
/**
|
|
943
|
+
* Autres propriétés classiques d'un objet implémentées par le proxy
|
|
944
|
+
*/
|
|
945
|
+
deleteProperty: function (_publisherInstance, sKey: string) {
|
|
946
|
+
publisherInstance._publishDynamicFilling_(sKey, null);
|
|
947
|
+
// if (!publisherInstance._proxies_.get(sKey)?.hasListener()) {
|
|
948
|
+
// publisherInstance._proxies_.delete(sKey);
|
|
949
|
+
// } else {
|
|
950
|
+
publisherInstance._proxies_.get(sKey)?.set(null);
|
|
951
|
+
// }
|
|
952
|
+
return delete (publisherInstance._value_ as any)[sKey];
|
|
953
|
+
},
|
|
954
|
+
// enumerate: function (publisherInstance, sKey): CoreJSType {
|
|
955
|
+
// return publisherInstance._value_.keys();
|
|
956
|
+
// },
|
|
957
|
+
has: function (_publisherInstance, sKey) {
|
|
958
|
+
return (
|
|
959
|
+
sKey in (publisherInstance._value_ as any) &&
|
|
960
|
+
sKey != "_lockInternalMutationPublishing_"
|
|
961
|
+
);
|
|
962
|
+
},
|
|
963
|
+
defineProperty: function (_publisherInstance, sKey, oDesc) {
|
|
964
|
+
if (oDesc && "value" in oDesc) {
|
|
965
|
+
(publisherInstance._value_ as any)[sKey] = oDesc.value;
|
|
966
|
+
}
|
|
967
|
+
return true;
|
|
968
|
+
// return publisherInstance._value_;
|
|
969
|
+
},
|
|
970
|
+
getOwnPropertyDescriptor: function (_publisherInstance, sKey) {
|
|
971
|
+
sKey;
|
|
972
|
+
return {
|
|
973
|
+
enumerable: true,
|
|
974
|
+
configurable: true,
|
|
975
|
+
};
|
|
976
|
+
},
|
|
977
|
+
ownKeys: function (_publisherInstance) {
|
|
978
|
+
if ((publisherInstance._value_ as any).__value)
|
|
979
|
+
return Object.keys((publisherInstance._value_ as any).__value);
|
|
980
|
+
return Object.keys((publisherInstance as any)._value_);
|
|
981
|
+
},
|
|
982
|
+
};
|
|
974
983
|
}
|
|
975
984
|
|
|
976
|
-
|
|
985
|
+
export function createPublisher<T = any>(
|
|
986
|
+
target: T,
|
|
987
|
+
parentProxPub: PublisherProxy<T> | null = null,
|
|
988
|
+
parentKey?: string,
|
|
989
|
+
) {
|
|
990
|
+
const instance = new PublisherProxy<T>(target, parentProxPub, parentKey);
|
|
991
|
+
let proxy = null as unknown as DataProvider<T> & T;
|
|
992
|
+
const handler = createPublisherHandler<T>(instance, () => proxy);
|
|
993
|
+
proxy = new Proxy<PublisherProxy<T>>(
|
|
994
|
+
instance,
|
|
995
|
+
handler,
|
|
996
|
+
) as unknown as DataProvider<T> & T;
|
|
997
|
+
return proxy;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* @deprecated @see {@link DataProvider} instead
|
|
1002
|
+
*/
|
|
1003
|
+
export default DataProvider;
|
|
1004
|
+
|
|
1005
|
+
export type Publisher<T = any> = DataProvider<T>;
|
|
1006
|
+
|
|
1007
|
+
// if (typeof module != "undefined") module.exports = {DataProvider: DataProvider, PublisherManager: PublisherManager};
|
|
977
1008
|
|
|
978
1009
|
// /**
|
|
979
1010
|
// * A custom webcomponent wich will be linked to a publisher via its attribute "publisher"
|
|
@@ -1000,10 +1031,61 @@ class PublisherWebComponent extends HTMLElement {
|
|
|
1000
1031
|
try {
|
|
1001
1032
|
customElements.define(
|
|
1002
1033
|
SONIC_PREFIX + "-publisher-proxy",
|
|
1003
|
-
PublisherWebComponent
|
|
1034
|
+
PublisherWebComponent,
|
|
1004
1035
|
);
|
|
1005
1036
|
} catch (e) {}
|
|
1006
1037
|
|
|
1038
|
+
export const getObservables = <T = any>(
|
|
1039
|
+
observable: string,
|
|
1040
|
+
): Set<DataProvider<T>> => {
|
|
1041
|
+
if (typeof observable === "function") {
|
|
1042
|
+
const func = observable as () => any;
|
|
1043
|
+
PublisherManager.collectModifiedPublisher();
|
|
1044
|
+
func();
|
|
1045
|
+
return PublisherManager.getModifiedPublishers() as Set<DataProvider<T>>;
|
|
1046
|
+
}
|
|
1047
|
+
if (typeof observable === "string") {
|
|
1048
|
+
const split = observable.split(".");
|
|
1049
|
+
const dataProvider: string = split.shift() || "";
|
|
1050
|
+
let publisher = PublisherManager.get(dataProvider);
|
|
1051
|
+
publisher = Objects.traverse(publisher, split);
|
|
1052
|
+
const set = new Set<DataProvider<T>>();
|
|
1053
|
+
set.add(publisher as DataProvider<T>);
|
|
1054
|
+
return set;
|
|
1055
|
+
}
|
|
1056
|
+
return new Set<DataProvider<T>>([observable as DataProvider<T>]);
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
// get value
|
|
1060
|
+
export const get = <T = any>(id: string) => {
|
|
1061
|
+
return getObservables<T>(id).values().next().value?.get() as T;
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
const deepee = <T = any>(id: string) => {
|
|
1065
|
+
const value = getObservables<T>(id).values().next().value as DataProvider<T>;
|
|
1066
|
+
// if (defaultValue !== undefined && value) {
|
|
1067
|
+
// const innerValue = value.get();
|
|
1068
|
+
// if (Objects.isEmpty(innerValue as Record<string, any>)) {
|
|
1069
|
+
// value.set(defaultValue);
|
|
1070
|
+
// }
|
|
1071
|
+
// }
|
|
1072
|
+
|
|
1073
|
+
return value;
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
export const dataProvider: <T = any>(
|
|
1077
|
+
id: string,
|
|
1078
|
+
defaultValue?: T,
|
|
1079
|
+
) => DataProvider<T> = deepee;
|
|
1080
|
+
export const dp = deepee;
|
|
1081
|
+
|
|
1082
|
+
export const set: <T = any>(id: string, value: T) => void = <T>(
|
|
1083
|
+
id: string,
|
|
1084
|
+
value: T,
|
|
1085
|
+
) => {
|
|
1086
|
+
getObservables(id).values().next().value?.set(value);
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1007
1089
|
/**
|
|
1008
1090
|
* next back handling data invalidation
|
|
1009
1091
|
*/
|
package/src/core/utils/Utils.ts
CHANGED
package/src/core/utils/api.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import HTML from "@supersoniks/concorde/core/utils/HTML";
|
|
4
4
|
import Objects from "@supersoniks/concorde/core/utils/Objects";
|
|
5
5
|
import { CoreJSType } from "@supersoniks/concorde/core/_types/types";
|
|
6
|
-
import { PublisherManager } from "./PublisherProxy";
|
|
6
|
+
import { dp, PublisherManager } from "./PublisherProxy";
|
|
7
7
|
|
|
8
8
|
export type APIConfiguration = {
|
|
9
9
|
serviceURL: string | null;
|
|
@@ -192,13 +192,11 @@ class API {
|
|
|
192
192
|
/**
|
|
193
193
|
* Publication en global de la réponse de l'api
|
|
194
194
|
*/
|
|
195
|
-
const apiPublisher =
|
|
196
|
-
|
|
197
|
-
};
|
|
198
|
-
apiPublisher.lastResponse = {
|
|
195
|
+
const apiPublisher = dp<{lastResponse: APIResponse}>("sonic-api");
|
|
196
|
+
apiPublisher.lastResponse.set({
|
|
199
197
|
http: fetchResult,
|
|
200
198
|
processed: result,
|
|
201
|
-
};
|
|
199
|
+
});
|
|
202
200
|
|
|
203
201
|
return result;
|
|
204
202
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@supersoniks/concorde/core/utils/PublisherProxy";
|