minimal-piral 1.6.2-beta.7421 → 1.6.2-beta.7457

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/app/index.d.ts CHANGED
@@ -170,6 +170,8 @@ export interface PiralEventMap extends PiralCustomEventMap {
170
170
  [custom: string]: any;
171
171
  "store-data": PiralStoreDataEvent;
172
172
  "unhandled-error": PiralUnhandledErrorEvent;
173
+ "loading-pilets": PiralLoadingPiletsEvent;
174
+ "loaded-pilets": PiralLoadedPiletsEvent;
173
175
  }
174
176
 
175
177
  /**
@@ -308,6 +310,30 @@ export interface PiralUnhandledErrorEvent {
308
310
  pilet: string;
309
311
  }
310
312
 
313
+ /**
314
+ * Gets fired when the loading of pilets is triggered.
315
+ */
316
+ export interface PiralLoadingPiletsEvent {
317
+ /**
318
+ * The options that have been supplied for loading the pilets.
319
+ */
320
+ options: LoadPiletsOptions;
321
+ }
322
+
323
+ /**
324
+ * Gets fired when all pilets have been loaded.
325
+ */
326
+ export interface PiralLoadedPiletsEvent {
327
+ /**
328
+ * The pilets that have been loaded.
329
+ */
330
+ pilets: Array<Pilet>;
331
+ /**
332
+ * The loading error, if any.
333
+ */
334
+ error?: Error;
335
+ }
336
+
311
337
  /**
312
338
  * Defines the potential targets when storing data.
313
339
  */
@@ -419,6 +445,56 @@ export interface BaseExtensionSlotProps<TName, TParams> {
419
445
  name: TName;
420
446
  }
421
447
 
448
+ /**
449
+ * The options for loading pilets.
450
+ */
451
+ export interface LoadPiletsOptions {
452
+ /**
453
+ * The callback function for creating an API object.
454
+ * The API object is passed on to a specific pilet.
455
+ */
456
+ createApi: PiletApiCreator;
457
+ /**
458
+ * The callback for fetching the dynamic pilets.
459
+ */
460
+ fetchPilets: PiletRequester;
461
+ /**
462
+ * Optionally, some already existing evaluated pilets, e.g.,
463
+ * helpful when debugging or in SSR scenarios.
464
+ */
465
+ pilets?: Array<Pilet>;
466
+ /**
467
+ * Optionally, configures the default loader.
468
+ */
469
+ config?: DefaultLoaderConfig;
470
+ /**
471
+ * Optionally, defines the default way how to load a pilet.
472
+ */
473
+ loadPilet?: PiletLoader;
474
+ /**
475
+ * Optionally, defines loaders for custom specifications.
476
+ */
477
+ loaders?: CustomSpecLoaders;
478
+ /**
479
+ * Optionally, defines a set of loading hooks to be used.
480
+ */
481
+ hooks?: PiletLifecycleHooks;
482
+ /**
483
+ * Gets the map of globally available dependencies with their names
484
+ * as keys and their evaluated pilet content as value.
485
+ */
486
+ dependencies?: AvailableDependencies;
487
+ /**
488
+ * Optionally, defines the loading strategy to use.
489
+ */
490
+ strategy?: PiletLoadingStrategy;
491
+ }
492
+
493
+ /**
494
+ * An evaluated pilet, i.e., a full pilet: functionality and metadata.
495
+ */
496
+ export type Pilet = SinglePilet | MultiPilet;
497
+
422
498
  export type FirstParameter<T extends (arg: any) => any> = T extends (arg: infer P) => any ? P : never;
423
499
 
424
500
  /**
@@ -501,6 +577,94 @@ export interface ExtensionRegistration extends BaseRegistration {
501
577
  defaults: any;
502
578
  }
503
579
 
580
+ /**
581
+ * The creator function for the pilet API.
582
+ */
583
+ export interface PiletApiCreator {
584
+ /**
585
+ * Creates an API for the given raw pilet.
586
+ * @param target The raw (meta) content of the pilet.
587
+ * @returns The API object to be used with the pilet.
588
+ */
589
+ (target: PiletMetadata): PiletApi;
590
+ }
591
+
592
+ /**
593
+ * The interface describing a function capable of fetching pilets.
594
+ */
595
+ export interface PiletRequester {
596
+ /**
597
+ * Gets the raw pilets (e.g., from a server) asynchronously.
598
+ */
599
+ (): Promise<PiletEntries>;
600
+ }
601
+
602
+ /**
603
+ * Additional configuration options for the default loader.
604
+ */
605
+ export interface DefaultLoaderConfig {
606
+ /**
607
+ * Sets the cross-origin attribute of potential script tags.
608
+ * For pilets v1 this may be useful. Otherwise, only pilets that
609
+ * have an integrity defined will be set to "anonymous".
610
+ */
611
+ crossOrigin?: string;
612
+ }
613
+
614
+ /**
615
+ * The callback to be used to load a single pilet.
616
+ */
617
+ export interface PiletLoader {
618
+ (entry: PiletEntry): Promise<Pilet>;
619
+ }
620
+
621
+ /**
622
+ * Defines the spec identifiers for custom loading.
623
+ */
624
+ export type CustomSpecLoaders = Record<string, PiletLoader>;
625
+
626
+ /**
627
+ * A set of pipeline hooks used by the Piral loading orchestrator.
628
+ */
629
+ export interface PiletLifecycleHooks {
630
+ /**
631
+ * Hook fired before a pilet is loaded.
632
+ */
633
+ loadPilet?(pilet: PiletMetadata): void;
634
+ /**
635
+ * Hook fired before a pilet is being set up.
636
+ */
637
+ setupPilet?(pilet: Pilet): void;
638
+ /**
639
+ * Hook fired before a pilet is being cleaned up.
640
+ */
641
+ cleanupPilet?(pilet: Pilet): void;
642
+ }
643
+
644
+ /**
645
+ * The record containing all available dependencies.
646
+ */
647
+ export interface AvailableDependencies {
648
+ [name: string]: any;
649
+ }
650
+
651
+ /**
652
+ * The strategy for how pilets are loaded at runtime.
653
+ */
654
+ export interface PiletLoadingStrategy {
655
+ (options: LoadPiletsOptions, pilets: PiletsLoaded): PromiseLike<void>;
656
+ }
657
+
658
+ /**
659
+ * An evaluated single pilet.
660
+ */
661
+ export type SinglePilet = SinglePiletApp & PiletMetadata;
662
+
663
+ /**
664
+ * An evaluated multi pilet.
665
+ */
666
+ export type MultiPilet = MultiPiletApp & PiletMetadata;
667
+
504
668
  /**
505
669
  * The context to be transported into the generic components.
506
670
  */
@@ -532,6 +696,60 @@ export interface BaseRegistration {
532
696
 
533
697
  export type WrappedComponent<TProps> = React.ComponentType<React.PropsWithChildren<Without<TProps, keyof BaseComponentProps>>>;
534
698
 
699
+ /**
700
+ * The entries representing pilets from a feed service response.
701
+ */
702
+ export type PiletEntries = Array<PiletEntry>;
703
+
704
+ /**
705
+ * Pilet entry representing part of a response from the feed service.
706
+ */
707
+ export type PiletEntry = MultiPiletEntry | SinglePiletEntry;
708
+
709
+ /**
710
+ * The callback to be used when pilets have been loaded.
711
+ */
712
+ export interface PiletsLoaded {
713
+ (error: Error | undefined, pilets: Array<Pilet>): void;
714
+ }
715
+
716
+ /**
717
+ * The pilet app, i.e., the functional exports.
718
+ */
719
+ export interface SinglePiletApp {
720
+ /**
721
+ * Integrates the evaluated pilet into the application.
722
+ * @param api The API to access the application.
723
+ */
724
+ setup(api: PiletApi): void | Promise<void>;
725
+ /**
726
+ * Optional function for cleanup.
727
+ * @param api The API to access the application.
728
+ */
729
+ teardown?(api: PiletApi): void;
730
+ /**
731
+ * The referenced stylesheets to load / integrate.
732
+ * This would only be used by v3 pilets.
733
+ */
734
+ styles?: Array<string>;
735
+ /**
736
+ * The referenced WebAssembly binaries to load / integrate.
737
+ * This would only be used by v3 pilets.
738
+ */
739
+ assemblies?: Array<string>;
740
+ }
741
+
742
+ /**
743
+ * The pilet app, i.e., the functional exports.
744
+ */
745
+ export interface MultiPiletApp {
746
+ /**
747
+ * Integrates the evaluated pilet into the application.
748
+ * @param api The API to access the application.
749
+ */
750
+ setup(apiFactory: PiletApiCreator): void | Promise<void>;
751
+ }
752
+
535
753
  export interface NavigationApi {
536
754
  /**
537
755
  * Pushes a new location onto the history stack.
@@ -582,6 +800,16 @@ export interface NavigationApi {
582
800
 
583
801
  export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
584
802
 
803
+ /**
804
+ * The metadata response for a multi pilet.
805
+ */
806
+ export type MultiPiletEntry = PiletBundleEntry;
807
+
808
+ /**
809
+ * The metadata response for a single pilet.
810
+ */
811
+ export type SinglePiletEntry = PiletV0Entry | PiletV1Entry | PiletV2Entry | PiletV3Entry | PiletMfEntry | PiletVxEntry;
812
+
585
813
  export interface NavigationBlocker {
586
814
  (tx: NavigationTransition): void;
587
815
  }
@@ -590,6 +818,238 @@ export interface NavigationListener {
590
818
  (update: NavigationUpdate): void;
591
819
  }
592
820
 
821
+ /**
822
+ * Metadata for pilets using the bundle schema.
823
+ */
824
+ export interface PiletBundleEntry {
825
+ /**
826
+ * The name of the bundle pilet, i.e., the package id.
827
+ */
828
+ name?: string;
829
+ /**
830
+ * Optionally provides the version of the specification for this pilet.
831
+ */
832
+ spec?: "v1";
833
+ /**
834
+ * The link for retrieving the bundle content of the pilet.
835
+ */
836
+ link: string;
837
+ /**
838
+ * The reference name for the global bundle-shared require.
839
+ */
840
+ bundle: string;
841
+ /**
842
+ * The computed integrity of the pilet. Will be used to set the
843
+ * integrity value of the script.
844
+ */
845
+ integrity?: string;
846
+ /**
847
+ * Optionally provides some custom metadata for the pilet.
848
+ */
849
+ custom?: any;
850
+ /**
851
+ * Additional shared dependency script files.
852
+ */
853
+ dependencies?: Record<string, string>;
854
+ }
855
+
856
+ /**
857
+ * Metadata for pilets using the v0 schema.
858
+ */
859
+ export type PiletV0Entry = PiletV0ContentEntry | PiletV0LinkEntry;
860
+
861
+ /**
862
+ * Metadata for pilets using the v1 schema.
863
+ */
864
+ export interface PiletV1Entry {
865
+ /**
866
+ * The name of the pilet, i.e., the package id.
867
+ */
868
+ name: string;
869
+ /**
870
+ * The version of the pilet. Should be semantically versioned.
871
+ */
872
+ version: string;
873
+ /**
874
+ * Optionally provides the version of the specification for this pilet.
875
+ */
876
+ spec?: "v1";
877
+ /**
878
+ * The link for retrieving the content of the pilet.
879
+ */
880
+ link: string;
881
+ /**
882
+ * The reference name for the global require.
883
+ */
884
+ requireRef: string;
885
+ /**
886
+ * The computed integrity of the pilet. Will be used to set the
887
+ * integrity value of the script.
888
+ */
889
+ integrity?: string;
890
+ /**
891
+ * Optionally provides some custom metadata for the pilet.
892
+ */
893
+ custom?: any;
894
+ /**
895
+ * Optionally provides some configuration to be used in the pilet.
896
+ */
897
+ config?: Record<string, any>;
898
+ /**
899
+ * Additional shared dependency script files.
900
+ */
901
+ dependencies?: Record<string, string>;
902
+ }
903
+
904
+ /**
905
+ * Metadata for pilets using the v2 schema.
906
+ */
907
+ export interface PiletV2Entry {
908
+ /**
909
+ * The name of the pilet, i.e., the package id.
910
+ */
911
+ name: string;
912
+ /**
913
+ * The version of the pilet. Should be semantically versioned.
914
+ */
915
+ version: string;
916
+ /**
917
+ * Provides the version of the specification for this pilet.
918
+ */
919
+ spec: "v2";
920
+ /**
921
+ * The reference name for the global require.
922
+ */
923
+ requireRef: string;
924
+ /**
925
+ * The computed integrity of the pilet.
926
+ */
927
+ integrity?: string;
928
+ /**
929
+ * The link for retrieving the content of the pilet.
930
+ */
931
+ link: string;
932
+ /**
933
+ * Optionally provides some custom metadata for the pilet.
934
+ */
935
+ custom?: any;
936
+ /**
937
+ * Optionally provides some configuration to be used in the pilet.
938
+ */
939
+ config?: Record<string, any>;
940
+ /**
941
+ * Additional shared dependency script files.
942
+ */
943
+ dependencies?: Record<string, string>;
944
+ }
945
+
946
+ /**
947
+ * Metadata for pilets using the v3 schema.
948
+ */
949
+ export interface PiletV3Entry {
950
+ /**
951
+ * The name of the pilet, i.e., the package id.
952
+ */
953
+ name: string;
954
+ /**
955
+ * The version of the pilet. Should be semantically versioned.
956
+ */
957
+ version: string;
958
+ /**
959
+ * Provides the version of the specification for this pilet.
960
+ */
961
+ spec: "v3";
962
+ /**
963
+ * The reference name for the global require.
964
+ */
965
+ requireRef: string;
966
+ /**
967
+ * The computed integrity of the pilet.
968
+ */
969
+ integrity?: string;
970
+ /**
971
+ * The fallback link for retrieving the content of the pilet.
972
+ */
973
+ link: string;
974
+ /**
975
+ * The links for specific variations of the pilet, e.g., "client", "server", ...
976
+ */
977
+ variations?: Record<string, string>;
978
+ /**
979
+ * Optionally provides some custom metadata for the pilet.
980
+ */
981
+ custom?: any;
982
+ /**
983
+ * Optionally provides some configuration to be used in the pilet.
984
+ */
985
+ config?: Record<string, any>;
986
+ /**
987
+ * Additional shared dependency script files.
988
+ */
989
+ dependencies?: Record<string, string>;
990
+ }
991
+
992
+ /**
993
+ * Metadata for pilets using the v2 schema.
994
+ */
995
+ export interface PiletMfEntry {
996
+ /**
997
+ * The name of the pilet, i.e., the package id.
998
+ */
999
+ name: string;
1000
+ /**
1001
+ * The version of the pilet. Should be semantically versioned.
1002
+ */
1003
+ version: string;
1004
+ /**
1005
+ * Provides the version of the specification for this pilet.
1006
+ */
1007
+ spec: "mf";
1008
+ /**
1009
+ * The computed integrity of the pilet.
1010
+ */
1011
+ integrity?: string;
1012
+ /**
1013
+ * The fallback link for retrieving the content of the pilet.
1014
+ */
1015
+ link: string;
1016
+ /**
1017
+ * Optionally provides some custom metadata for the pilet.
1018
+ */
1019
+ custom?: any;
1020
+ /**
1021
+ * Optionally provides some configuration to be used in the pilet.
1022
+ */
1023
+ config?: Record<string, any>;
1024
+ }
1025
+
1026
+ export interface PiletVxEntry {
1027
+ /**
1028
+ * The name of the pilet, i.e., the package id.
1029
+ */
1030
+ name: string;
1031
+ /**
1032
+ * The version of the pilet. Should be semantically versioned.
1033
+ */
1034
+ version: string;
1035
+ /**
1036
+ * Provides an identifier for the custom specification.
1037
+ */
1038
+ spec: string;
1039
+ /**
1040
+ * Optionally provides some custom metadata for the pilet.
1041
+ */
1042
+ custom?: any;
1043
+ /**
1044
+ * Optionally provides some configuration to be used in the pilet.
1045
+ */
1046
+ config?: Record<string, any>;
1047
+ /**
1048
+ * Additional shared dependency script files.
1049
+ */
1050
+ dependencies?: Record<string, string>;
1051
+ }
1052
+
593
1053
  export interface NavigationTransition extends NavigationUpdate {
594
1054
  retry?(): void;
595
1055
  }
@@ -599,6 +1059,34 @@ export interface NavigationUpdate {
599
1059
  location: NavigationLocation;
600
1060
  }
601
1061
 
1062
+ /**
1063
+ * Metadata for pilets using the v0 schema with a content.
1064
+ */
1065
+ export interface PiletV0ContentEntry extends PiletV0BaseEntry {
1066
+ /**
1067
+ * The content of the pilet. If the content is not available
1068
+ * the link will be used (unless caching has been activated).
1069
+ */
1070
+ content: string;
1071
+ /**
1072
+ * If available indicates that the pilet should not be cached.
1073
+ * In case of a string this is interpreted as the expiration time
1074
+ * of the cache. In case of an accurate hash this should not be
1075
+ * required or set.
1076
+ */
1077
+ noCache?: boolean | string;
1078
+ }
1079
+
1080
+ /**
1081
+ * Metadata for pilets using the v0 schema with a link.
1082
+ */
1083
+ export interface PiletV0LinkEntry extends PiletV0BaseEntry {
1084
+ /**
1085
+ * The link for retrieving the content of the pilet.
1086
+ */
1087
+ link: string;
1088
+ }
1089
+
602
1090
  export type NavigationAction = "POP" | "PUSH" | "REPLACE";
603
1091
 
604
1092
  export interface NavigationLocation {
@@ -636,4 +1124,39 @@ export interface NavigationLocation {
636
1124
  * locations, this string will be a unique identifier.
637
1125
  */
638
1126
  key?: string;
1127
+ }
1128
+
1129
+ /**
1130
+ * Basic metadata for pilets using the v0 schema.
1131
+ */
1132
+ export interface PiletV0BaseEntry {
1133
+ /**
1134
+ * The name of the pilet, i.e., the package id.
1135
+ */
1136
+ name: string;
1137
+ /**
1138
+ * The version of the pilet. Should be semantically versioned.
1139
+ */
1140
+ version: string;
1141
+ /**
1142
+ * Optionally provides the version of the specification for this pilet.
1143
+ */
1144
+ spec?: "v0";
1145
+ /**
1146
+ * The computed hash value of the pilet's content. Should be
1147
+ * accurate to allow caching.
1148
+ */
1149
+ hash: string;
1150
+ /**
1151
+ * Optionally provides some custom metadata for the pilet.
1152
+ */
1153
+ custom?: any;
1154
+ /**
1155
+ * Optionally provides some configuration to be used in the pilet.
1156
+ */
1157
+ config?: Record<string, any>;
1158
+ /**
1159
+ * Additional shared dependency script files.
1160
+ */
1161
+ dependencies?: Record<string, string>;
639
1162
  }
@@ -871,7 +871,8 @@ var Mediator = function Mediator(_ref) {
871
871
  var options = _ref.options;
872
872
  var _useGlobalStateContex = (0,_hooks__WEBPACK_IMPORTED_MODULE_1__.useGlobalStateContext)(),
873
873
  initialize = _useGlobalStateContex.initialize,
874
- readState = _useGlobalStateContex.readState;
874
+ readState = _useGlobalStateContex.readState,
875
+ emit = _useGlobalStateContex.emit;
875
876
  react__WEBPACK_IMPORTED_MODULE_0__.useEffect(function () {
876
877
  var shouldLoad = readState(function (s) {
877
878
  return s.app.loading;
@@ -880,8 +881,17 @@ var Mediator = function Mediator(_ref) {
880
881
  var _startLoadingPilets = (0,piral_base__WEBPACK_IMPORTED_MODULE_2__.startLoadingPilets)(options),
881
882
  connect = _startLoadingPilets.connect,
882
883
  disconnect = _startLoadingPilets.disconnect;
884
+ emit('loading-pilets', {
885
+ options: options
886
+ });
883
887
  var notifier = function notifier(error, pilets, loaded) {
884
888
  initialize(!loaded, error, pilets);
889
+ if (loaded) {
890
+ emit('loaded-pilets', {
891
+ pilets: pilets,
892
+ error: error
893
+ });
894
+ }
885
895
  };
886
896
  connect(notifier);
887
897
  return function () {
@@ -3804,12 +3814,12 @@ function installPiralDebug(options) {
3804
3814
  debug: debugApiVersion,
3805
3815
  instance: {
3806
3816
  name: "minimal-piral",
3807
- version: "1.6.2-beta.7421",
3817
+ version: "1.6.2-beta.7457",
3808
3818
  dependencies: "tslib,react,react-dom,react-router,react-router-dom"
3809
3819
  },
3810
3820
  build: {
3811
- date: "2024-09-18T08:18:35.420Z",
3812
- cli: "1.6.2-beta.7421",
3821
+ date: "2024-09-26T12:20:57.873Z",
3822
+ cli: "1.6.2-beta.7457",
3813
3823
  compat: "1"
3814
3824
  }
3815
3825
  };
@@ -45117,4 +45127,4 @@ var instance = (0,piral_core__WEBPACK_IMPORTED_MODULE_2__.createInstance)({
45117
45127
 
45118
45128
  /******/ })()
45119
45129
  ;
45120
- //# sourceMappingURL=index.2aef3d.js.map
45130
+ //# sourceMappingURL=index.ef08b6.js.map