minimal-piral 0.15.0-beta.4411 → 0.15.0-beta.4472

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
@@ -460,8 +460,8 @@ declare module "minimal-piral" {
460
460
  * The context to be transported into the generic components.
461
461
  */
462
462
  export interface ComponentContext {
463
- router: ReactRouter.RouteComponentProps;
464
- readState: PiralActions["readState"];
463
+ navigation: NavigationApi;
464
+ publicPath: string;
465
465
  }
466
466
 
467
467
  /**
@@ -476,990 +476,92 @@ declare module "minimal-piral" {
476
476
 
477
477
  export type WrappedComponent<TProps> = React.ComponentType<React.PropsWithChildren<Without<TProps, keyof BaseComponentProps>>>;
478
478
 
479
- /**
480
- * The globally defined actions.
481
- */
482
- export interface PiralActions extends PiralCustomActions {
483
- /**
484
- * Initializes the application shell.
485
- * @param loading The current loading state.
486
- * @param error The application error, if any.
487
- * @param modules The loaded pilets.
488
- */
489
- initialize(loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
490
- /**
491
- * Injects an evaluated pilet at runtime - removes the pilet from registry first if available.
492
- * @param pilet The pilet to be injected.
493
- * @returns The injected pilet.
494
- */
495
- injectPilet(pilet: Pilet): Pilet;
496
- /**
497
- * Adds a pilet at runtime by loading it, evaluating it, and then injecting it.
498
- * @param pilet The pilet to be added.
499
- * @returns The promise indicating when the pilet was fully added.
500
- */
501
- addPilet(pilet: PiletEntry): Promise<void>;
502
- /**
503
- * Removes a pilet by unloading it and deleting all component registrations.
504
- * @param name The name of the pilet to remove.
505
- */
506
- removePilet(name: string): Promise<void>;
507
- /**
508
- * Defines a single action for Piral.
509
- * @param actionName The name of the action to define.
510
- * @param action The action to include.
511
- */
512
- defineAction<T extends keyof PiralActions>(actionName: T, action: PiralAction<PiralActions[T]>): void;
513
- /**
514
- * Defines a set of actions for Piral.
515
- * @param actions The actions to define.
516
- */
517
- defineActions(actions: PiralDefineActions): void;
518
- /**
519
- * Reads the value of a shared data item.
520
- * @param name The name of the shared item.
521
- */
522
- readDataValue(name: string): any;
523
- /**
524
- * Tries to write a shared data item. The write access is only
525
- * possible if the name belongs to the provided owner or has not
526
- * been taken yet.
527
- * Setting the value to null will release it.
528
- * @param name The name of the shared data item.
529
- * @param value The value of the shared data item.
530
- * @param owner The owner of the shared data item.
531
- * @param target The target storage locatation.
532
- * @param expiration The time for when to dispose the shared item.
533
- */
534
- tryWriteDataItem(name: string, value: any, owner: string, target: DataStoreTarget, expiration: number): boolean;
535
- /**
536
- * Registers a new route to be resolved.
537
- * @param route The route to register.
538
- * @param value The page to be rendered on the route.
539
- */
540
- registerPage(route: string, value: PageRegistration): void;
541
- /**
542
- * Unregisters an existing route.
543
- * @param route The route to be removed.
544
- */
545
- unregisterPage(route: string): void;
546
- /**
547
- * Registers a new extension.
548
- * @param name The name of the extension category.
549
- * @param value The extension registration.
550
- */
551
- registerExtension(name: string, value: ExtensionRegistration): void;
552
- /**
553
- * Unregisters an existing extension.
554
- * @param name The name of the extension category.
555
- * @param value The extension that will be removed.
556
- */
557
- unregisterExtension(name: string, reference: any): void;
558
- /**
559
- * Sets the common component to render.
560
- * @param name The name of the component.
561
- * @param component The component to use for rendering.
562
- */
563
- setComponent<TKey extends keyof ComponentsState>(name: TKey, component: ComponentsState[TKey]): void;
479
+ export interface NavigationApi {
564
480
  /**
565
- * Sets the error component to render.
566
- * @param type The type of the error.
567
- * @param component The component to use for rendering.
481
+ * Pushes a new location onto the history stack.
568
482
  */
569
- setErrorComponent<TKey extends keyof ErrorComponentsState>(type: TKey, component: ErrorComponentsState[TKey]): void;
483
+ push(target: string, state?: any): void;
570
484
  /**
571
- * Sets the common routes to render.
572
- * @param path The name of the component.
573
- * @param component The component to use for rendering.
485
+ * Replaces the current location with another.
574
486
  */
575
- setRoute<T = {}>(path: string, component: React.ComponentType<ReactRouter.RouteComponentProps<T>>): void;
487
+ replace(target: string, state?: any): void;
576
488
  /**
577
- * Includes a new provider as a sub-provider to the current provider.
578
- * @param provider The provider to include.
489
+ * Changes the current index in the history stack by a given delta.
579
490
  */
580
- includeProvider(provider: JSX.Element): void;
491
+ go(n: number): void;
581
492
  /**
582
- * Destroys (i.e., resets) the given portal instance.
583
- * @param id The id of the portal to destroy.
493
+ * Prevents changes to the history stack from happening.
494
+ * This is useful when you want to prevent the user navigating
495
+ * away from the current page, for example when they have some
496
+ * unsaved data on the current page.
497
+ * @param blocker The function being called with a transition request.
498
+ * @returns The disposable for stopping the block.
584
499
  */
585
- destroyPortal(id: string): void;
500
+ block(blocker: NavigationBlocker): Disposable;
586
501
  /**
587
- * Includes the provided portal in the rendering pipeline.
588
- * @param id The id of the portal to use.
589
- * @param entry The child to render.
502
+ * Starts listening for location changes and calls the given
503
+ * callback with an Update when it does.
504
+ * @param listener The function being called when the route changes.
505
+ * @returns The disposable for stopping the block.
590
506
  */
591
- showPortal(id: string, entry: React.ReactPortal): void;
592
- /**
593
- * Hides the provided portal in the rendering pipeline.
594
- * @param id The id of the portal to use.
595
- * @param entry The child to remove.
596
- */
597
- hidePortal(id: string, entry: React.ReactPortal): void;
598
- /**
599
- * Updates the provided portal in the rendering pipeline.
600
- * @param id The id of the portal to use.
601
- * @param current The currently displayed child.
602
- * @param next The updated child that should be displayed.
603
- */
604
- updatePortal(id: string, current: React.ReactPortal, next: React.ReactPortal): void;
605
- /**
606
- * Dispatches a state change.
607
- * @param update The update function creating a new state.
608
- */
609
- dispatch(update: (state: GlobalState) => GlobalState): void;
610
- /**
611
- * Reads the selected part of the global state.
612
- * @param select The selector for getting the desired part.
613
- * @returns The desired part.
614
- */
615
- readState<S>(select: (state: GlobalState) => S): S;
616
- /**
617
- * Performs a navigation.
618
- * @param path The path to navigate to.
619
- * @param state The optional state for the navigation.
620
- */
621
- navigate(path: string, state?: any): void;
507
+ listen(listener: NavigationListener): Disposable;
622
508
  }
623
509
 
624
510
  export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
625
511
 
626
- /**
627
- * Custom actions defined outside of piral-core.
628
- */
629
- export interface PiralCustomActions {}
630
-
631
- /**
632
- * An evaluated pilet, i.e., a full pilet: functionality and metadata.
633
- */
634
- export type Pilet = SinglePilet | MultiPilet;
635
-
636
- /**
637
- * Pilet entry representing part of a response from the feed service.
638
- */
639
- export type PiletEntry = MultiPiletEntry | SinglePiletEntry;
640
-
641
- /**
642
- * The shape of an app action in Piral.
643
- */
644
- export interface PiralAction<T extends (...args: any) => any> {
645
- (ctx: GlobalStateContext, ...args: Parameters<T>): ReturnType<T>;
646
- }
647
-
648
- /**
649
- * A subset of the available app actions in Piral.
650
- */
651
- export type PiralDefineActions = Partial<{
652
- [P in keyof PiralActions]: PiralAction<PiralActions[P]>;
653
- }>;
654
-
655
- /**
656
- * The interface modeling the registration of a pilet page component.
657
- */
658
- export interface PageRegistration extends BaseRegistration {
659
- /**
660
- * The registered page component.
661
- */
662
- component: WrappedComponent<PageComponentProps>;
663
- /**
664
- * The page's associated metadata.
665
- */
666
- meta: PiralPageMeta;
667
- }
668
-
669
- /**
670
- * The Piral global app sub-state container for shared components.
671
- */
672
- export interface ComponentsState extends PiralCustomComponentsState {
673
- /**
674
- * The loading indicator renderer.
675
- */
676
- LoadingIndicator: React.ComponentType<LoadingIndicatorProps>;
677
- /**
678
- * The error renderer.
679
- */
680
- ErrorInfo: React.ComponentType<ErrorInfoProps>;
681
- /**
682
- * The router context.
683
- */
684
- Router: React.ComponentType<RouterProps>;
685
- /**
686
- * The layout used for pages.
687
- */
688
- Layout: React.ComponentType<LayoutProps>;
689
- /**
690
- * The route switch used for determining the route registration.
691
- */
692
- RouteSwitch: React.ComponentType<RouteSwitchProps>;
693
- /**
694
- * A component that can be used for debugging purposes.
695
- */
696
- Debug?: React.ComponentType;
697
- }
698
-
699
- export type ErrorComponentsState = {
700
- [P in keyof Errors]?: React.ComponentType<Errors[P]>;
701
- };
702
-
703
- /**
704
- * The Piral global app state container.
705
- */
706
- export interface GlobalState extends PiralCustomState {
707
- /**
708
- * The relevant state for the app itself.
709
- */
710
- app: AppState;
711
- /**
712
- * The relevant state for rendering errors of the app.
713
- */
714
- errorComponents: ErrorComponentsState;
715
- /**
716
- * The relevant state for rendering parts of the app.
717
- */
718
- components: ComponentsState;
719
- /**
720
- * The relevant state for the registered components.
721
- */
722
- registry: RegistryState;
723
- /**
724
- * Gets the loaded modules.
725
- */
726
- modules: Array<Pilet>;
727
- /**
728
- * The foreign component portals to render.
729
- */
730
- portals: Record<string, Array<React.ReactPortal>>;
731
- /**
732
- * The application's shared data.
733
- */
734
- data: Dict<SharedDataItem>;
735
- /**
736
- * The used (exact) application routes.
737
- */
738
- routes: Dict<React.ComponentType<ReactRouter.RouteComponentProps<any>>>;
739
- /**
740
- * The current provider.
741
- */
742
- provider?: React.ComponentType;
743
- }
744
-
745
- /**
746
- * An evaluated single pilet.
747
- */
748
- export type SinglePilet = SinglePiletApp & PiletMetadata;
749
-
750
- /**
751
- * An evaluated multi pilet.
752
- */
753
- export type MultiPilet = MultiPiletApp & PiletMetadata;
754
-
755
- /**
756
- * The metadata response for a multi pilet.
757
- */
758
- export type MultiPiletEntry = PiletBundleEntry;
759
-
760
- /**
761
- * The metadata response for a single pilet.
762
- */
763
- export type SinglePiletEntry = PiletV0Entry | PiletV1Entry | PiletV2Entry | PiletVxEntry;
764
-
765
- /**
766
- * The Piral app instance context.
767
- */
768
- export interface GlobalStateContext extends PiralActions, EventEmitter {
769
- /**
770
- * The global state context atom.
771
- * Changes to the state should always be dispatched via the `dispatch` action.
772
- */
773
- state: UseBoundStore<GlobalState>;
774
- /**
775
- * The API objects created for the loaded pilets.
776
- */
777
- apis: PiletsBag;
778
- /**
779
- * The available component converters.
780
- */
781
- converters: ComponentConverters<any>;
782
- /**
783
- * The initial options.
784
- */
785
- options: LoadPiletsOptions;
786
- }
787
-
788
- /**
789
- * Custom parts of the global custom component state defined outside of piral-core.
790
- */
791
- export interface PiralCustomComponentsState {}
792
-
793
- /**
794
- * The props of a Loading indicator component.
795
- */
796
- export interface LoadingIndicatorProps {}
797
-
798
- /**
799
- * The props for the ErrorInfo component.
800
- */
801
- export type ErrorInfoProps = UnionOf<Errors>;
802
-
803
- /**
804
- * The props of a Router component.
805
- */
806
- export interface RouterProps {
807
- /**
808
- * The content to be rendered inside the router.
809
- */
810
- children?: React.ReactNode;
811
- }
812
-
813
- /**
814
- * The props of a Layout component.
815
- */
816
- export interface LayoutProps {
817
- /**
818
- * The currently selected layout type.
819
- */
820
- currentLayout: LayoutType;
821
- /**
822
- * The page's content.
823
- */
824
- children: React.ReactNode;
825
- }
826
-
827
- /**
828
- * The props of the RouteSwitch component.
829
- */
830
- export interface RouteSwitchProps extends ReactRouter.SwitchProps {
831
- /**
832
- * The component that should be used in case nothing was found.
833
- */
834
- NotFound: React.ComponentType<ReactRouter.RouteComponentProps>;
835
- /**
836
- * The component to register for the different paths.
837
- */
838
- paths: Array<AppPath>;
839
- }
840
-
841
- /**
842
- * Map of all error types to their respective props.
843
- */
844
- export interface Errors extends PiralCustomErrors {
845
- /**
846
- * The props type for an extension error.
847
- */
848
- extension: ExtensionErrorInfoProps;
849
- /**
850
- * The props type for a loading error.
851
- */
852
- loading: LoadingErrorInfoProps;
853
- /**
854
- * The props type for a page error.
855
- */
856
- page: PageErrorInfoProps;
857
- /**
858
- * The props type for a not found error.
859
- */
860
- not_found: NotFoundErrorInfoProps;
861
- /**
862
- * The props type for an unknown error.
863
- */
864
- unknown: UnknownErrorInfoProps;
865
- }
866
-
867
- /**
868
- * Custom state extensions defined outside of piral-core.
869
- */
870
- export interface PiralCustomState {}
871
-
872
- /**
873
- * The Piral global app sub-state container for app information.
874
- */
875
- export interface AppState {
876
- /**
877
- * Gets if the application is currently performing a background loading
878
- * activity, e.g., for loading modules asynchronously or fetching
879
- * translations.
880
- */
881
- loading: boolean;
882
- /**
883
- * Gets an unrecoverable application error, if any.
884
- */
885
- error: Error | undefined;
886
- /**
887
- * Gets the public path of the application.
888
- */
889
- publicPath: string;
512
+ export interface NavigationBlocker {
513
+ (tx: NavigationTransition): void;
890
514
  }
891
515
 
892
- /**
893
- * The Piral global app sub-state container for component registrations.
894
- */
895
- export interface RegistryState extends PiralCustomRegistryState {
896
- /**
897
- * The registered page components for the router.
898
- */
899
- pages: Dict<PageRegistration>;
900
- /**
901
- * The registered extension components for extension slots.
902
- */
903
- extensions: Dict<Array<ExtensionRegistration>>;
904
- /**
905
- * The registered wrappers for any component.
906
- */
907
- wrappers: Dict<React.ComponentType<any>>;
516
+ export interface NavigationListener {
517
+ (update: NavigationUpdate): void;
908
518
  }
909
519
 
910
- export type Dict<T> = Record<string, T>;
911
-
912
- /**
913
- * Defines the shape of a shared data item.
914
- */
915
- export interface SharedDataItem<TValue = any> {
916
- /**
917
- * Gets the associated value.
918
- */
919
- value: TValue;
920
- /**
921
- * Gets the owner of the item.
922
- */
923
- owner: string;
924
- /**
925
- * Gets the storage location.
926
- */
927
- target: DataStoreTarget;
928
- /**
929
- * Gets the expiration of the item.
930
- */
931
- expires: number;
520
+ export interface NavigationTransition extends NavigationUpdate {
521
+ retry(): void;
932
522
  }
933
523
 
934
- /**
935
- * The pilet app, i.e., the functional exports.
936
- */
937
- export interface SinglePiletApp {
938
- /**
939
- * Integrates the evaluated pilet into the application.
940
- * @param api The API to access the application.
941
- */
942
- setup(api: PiletApi): void | Promise<void>;
943
- /**
944
- * Optional function for cleanup.
945
- * @param api The API to access the application.
946
- */
947
- teardown?(api: PiletApi): void;
524
+ export interface NavigationUpdate {
525
+ action: NavigationAction;
526
+ location: NavigationLocation;
948
527
  }
949
528
 
950
- /**
951
- * The pilet app, i.e., the functional exports.
952
- */
953
- export interface MultiPiletApp {
954
- /**
955
- * Integrates the evaluated pilet into the application.
956
- * @param api The API to access the application.
957
- */
958
- setup(apiFactory: PiletApiCreator): void | Promise<void>;
959
- }
529
+ export type NavigationAction = "POP" | "PUSH" | "REPLACE";
960
530
 
961
- /**
962
- * Metadata for pilets using the bundle schema.
963
- */
964
- export interface PiletBundleEntry {
965
- /**
966
- * The name of the bundle pilet, i.e., the package id.
967
- */
968
- name?: string;
969
- /**
970
- * Optionally provides the version of the specification for this pilet.
971
- */
972
- spec?: "v1";
973
- /**
974
- * The link for retrieving the bundle content of the pilet.
975
- */
976
- link: string;
531
+ export interface NavigationLocation {
977
532
  /**
978
- * The reference name for the global bundle-shared require.
533
+ * The fully qualified URL incl. the origin and base path.
979
534
  */
980
- bundle: string;
535
+ href: string;
981
536
  /**
982
- * The computed integrity of the pilet. Will be used to set the
983
- * integrity value of the script.
537
+ * The location.pathname property is a string that contains an initial "/"
538
+ * followed by the remainder of the URL up to the ?.
984
539
  */
985
- integrity?: string;
540
+ pathname: string;
986
541
  /**
987
- * Optionally provides some custom metadata for the pilet.
542
+ * The location.search property is a string that contains an initial "?"
543
+ * followed by the key=value pairs in the query string. If there are no
544
+ * parameters, this value may be the empty string (i.e. '').
988
545
  */
989
- custom?: any;
546
+ search: string;
990
547
  /**
991
- * Additional shared dependency script files.
992
- */
993
- dependencies?: Record<string, string>;
994
- }
995
-
996
- /**
997
- * Metadata for pilets using the v0 schema.
998
- */
999
- export type PiletV0Entry = PiletV0ContentEntry | PiletV0LinkEntry;
1000
-
1001
- /**
1002
- * Metadata for pilets using the v1 schema.
1003
- */
1004
- export interface PiletV1Entry {
1005
- /**
1006
- * The name of the pilet, i.e., the package id.
1007
- */
1008
- name: string;
1009
- /**
1010
- * The version of the pilet. Should be semantically versioned.
1011
- */
1012
- version: string;
1013
- /**
1014
- * Optionally provides the version of the specification for this pilet.
1015
- */
1016
- spec?: "v1";
1017
- /**
1018
- * The link for retrieving the content of the pilet.
1019
- */
1020
- link: string;
1021
- /**
1022
- * The reference name for the global require.
1023
- */
1024
- requireRef: string;
1025
- /**
1026
- * The computed integrity of the pilet. Will be used to set the
1027
- * integrity value of the script.
1028
- */
1029
- integrity?: string;
1030
- /**
1031
- * Optionally provides some custom metadata for the pilet.
1032
- */
1033
- custom?: any;
1034
- /**
1035
- * Optionally provides some configuration to be used in the pilet.
1036
- */
1037
- config?: Record<string, any>;
1038
- /**
1039
- * Additional shared dependency script files.
1040
- */
1041
- dependencies?: Record<string, string>;
1042
- }
1043
-
1044
- /**
1045
- * Metadata for pilets using the v2 schema.
1046
- */
1047
- export interface PiletV2Entry {
1048
- /**
1049
- * The name of the pilet, i.e., the package id.
1050
- */
1051
- name: string;
1052
- /**
1053
- * The version of the pilet. Should be semantically versioned.
1054
- */
1055
- version: string;
1056
- /**
1057
- * Provides the version of the specification for this pilet.
1058
- */
1059
- spec: "v2";
1060
- /**
1061
- * The reference name for the global require.
1062
- */
1063
- requireRef: string;
1064
- /**
1065
- * The computed integrity of the pilet.
1066
- */
1067
- integrity?: string;
1068
- /**
1069
- * The link for retrieving the content of the pilet.
1070
- */
1071
- link: string;
1072
- /**
1073
- * Optionally provides some custom metadata for the pilet.
1074
- */
1075
- custom?: any;
1076
- /**
1077
- * Optionally provides some configuration to be used in the pilet.
1078
- */
1079
- config?: Record<string, any>;
1080
- /**
1081
- * Additional shared dependency script files.
1082
- */
1083
- dependencies?: Record<string, string>;
1084
- }
1085
-
1086
- export interface PiletVxEntry {
1087
- /**
1088
- * The name of the pilet, i.e., the package id.
1089
- */
1090
- name: string;
1091
- /**
1092
- * The version of the pilet. Should be semantically versioned.
1093
- */
1094
- version: string;
1095
- /**
1096
- * Provides an identifier for the custom specification.
1097
- */
1098
- spec: string;
1099
- /**
1100
- * Optionally provides some custom metadata for the pilet.
1101
- */
1102
- custom?: any;
1103
- /**
1104
- * Optionally provides some configuration to be used in the pilet.
1105
- */
1106
- config?: Record<string, any>;
1107
- /**
1108
- * Additional shared dependency script files.
1109
- */
1110
- dependencies?: Record<string, string>;
1111
- }
1112
-
1113
- export type UseBoundStore<T extends State, CustomStoreApi extends StoreApi<T> = StoreApi<T>> = {
1114
- (): T;
1115
- <U>(selector: StateSelector<T, U>, equalityFn?: EqualityChecker<U>): U;
1116
- } & CustomStoreApi;
1117
-
1118
- /**
1119
- * Represents the dictionary of the loaded pilets and their APIs.
1120
- */
1121
- export interface PiletsBag {
1122
- [name: string]: PiletApi;
1123
- }
1124
-
1125
- /**
1126
- * The options for loading pilets.
1127
- */
1128
- export interface LoadPiletsOptions {
1129
- /**
1130
- * The callback function for creating an API object.
1131
- * The API object is passed on to a specific pilet.
1132
- */
1133
- createApi: PiletApiCreator;
1134
- /**
1135
- * The callback for fetching the dynamic pilets.
1136
- */
1137
- fetchPilets: PiletRequester;
1138
- /**
1139
- * Optionally, some already existing evaluated pilets, e.g.,
1140
- * helpful when debugging or in SSR scenarios.
1141
- */
1142
- pilets?: Array<Pilet>;
1143
- /**
1144
- * Optionally, configures the default loader.
1145
- */
1146
- config?: DefaultLoaderConfig;
1147
- /**
1148
- * Optionally, defines the default way how to load a pilet.
1149
- */
1150
- loadPilet?: PiletLoader;
1151
- /**
1152
- * Optionally, defines loaders for custom specifications.
1153
- */
1154
- loaders?: CustomSpecLoaders;
1155
- /**
1156
- * Optionally, defines a set of loading hooks to be used.
1157
- */
1158
- hooks?: PiletLifecycleHooks;
1159
- /**
1160
- * Gets the map of globally available dependencies with their names
1161
- * as keys and their evaluated pilet content as value.
1162
- */
1163
- dependencies?: AvailableDependencies;
1164
- /**
1165
- * Optionally, defines the loading strategy to use.
1166
- */
1167
- strategy?: PiletLoadingStrategy;
1168
- }
1169
-
1170
- export type UnionOf<T> = {
1171
- [K in keyof T]: T[K];
1172
- }[keyof T];
1173
-
1174
- /**
1175
- * The different known layout types.
1176
- */
1177
- export type LayoutType = "mobile" | "tablet" | "desktop";
1178
-
1179
- /**
1180
- * Represents a path in the app registration.
1181
- */
1182
- export interface AppPath {
1183
- /**
1184
- * The exact path to use.
1185
- */
1186
- path: string;
1187
- /**
1188
- * The component to register for this path.
1189
- */
1190
- Component: React.ComponentType<ReactRouter.RouteComponentProps>;
1191
- }
1192
-
1193
- /**
1194
- * Custom errors defined outside of piral-core.
1195
- */
1196
- export interface PiralCustomErrors {}
1197
-
1198
- /**
1199
- * The error used when a registered extension component crashed.
1200
- */
1201
- export interface ExtensionErrorInfoProps {
1202
- /**
1203
- * The type of the error.
1204
- */
1205
- type: "extension";
1206
- /**
1207
- * The provided error details.
1208
- */
1209
- error: any;
1210
- /**
1211
- * The name of the pilet emitting the error.
1212
- */
1213
- pilet?: string;
1214
- }
1215
-
1216
- /**
1217
- * The error used when the app could not be loaded.
1218
- */
1219
- export interface LoadingErrorInfoProps {
1220
- /**
1221
- * The type of the error.
1222
- */
1223
- type: "loading";
1224
- /**
1225
- * The provided error details.
1226
- */
1227
- error: any;
1228
- }
1229
-
1230
- /**
1231
- * The error used when a registered page component crashes.
1232
- */
1233
- export interface PageErrorInfoProps extends ReactRouter.RouteComponentProps {
1234
- /**
1235
- * The type of the error.
1236
- */
1237
- type: "page";
1238
- /**
1239
- * The provided error details.
1240
- */
1241
- error: any;
1242
- /**
1243
- * The name of the pilet emitting the error.
1244
- */
1245
- pilet?: string;
1246
- }
1247
-
1248
- /**
1249
- * The error used when a route cannot be resolved.
1250
- */
1251
- export interface NotFoundErrorInfoProps extends ReactRouter.RouteComponentProps {
1252
- /**
1253
- * The type of the error.
1254
- */
1255
- type: "not_found";
1256
- }
1257
-
1258
- /**
1259
- * The error used when the exact type is unknown.
1260
- */
1261
- export interface UnknownErrorInfoProps {
1262
- /**
1263
- * The type of the error.
1264
- */
1265
- type: "unknown";
1266
- /**
1267
- * The provided error details.
1268
- */
1269
- error: any;
1270
- /**
1271
- * The name of the pilet emitting the error.
1272
- */
1273
- pilet?: string;
1274
- }
1275
-
1276
- /**
1277
- * Custom parts of the global registry state defined outside of piral-core.
1278
- */
1279
- export interface PiralCustomRegistryState {}
1280
-
1281
- /**
1282
- * The creator function for the pilet API.
1283
- */
1284
- export interface PiletApiCreator {
1285
- (target: PiletMetadata): PiletApi;
1286
- }
1287
-
1288
- /**
1289
- * Metadata for pilets using the v0 schema with a content.
1290
- */
1291
- export interface PiletV0ContentEntry extends PiletV0BaseEntry {
1292
- /**
1293
- * The content of the pilet. If the content is not available
1294
- * the link will be used (unless caching has been activated).
1295
- */
1296
- content: string;
1297
- /**
1298
- * If available indicates that the pilet should not be cached.
1299
- * In case of a string this is interpreted as the expiration time
1300
- * of the cache. In case of an accurate hash this should not be
1301
- * required or set.
1302
- */
1303
- noCache?: boolean | string;
1304
- }
1305
-
1306
- /**
1307
- * Metadata for pilets using the v0 schema with a link.
1308
- */
1309
- export interface PiletV0LinkEntry extends PiletV0BaseEntry {
1310
- /**
1311
- * The link for retrieving the content of the pilet.
1312
- */
1313
- link: string;
1314
- }
1315
-
1316
- export type StateSelector<T extends State, U> = (state: T) => U;
1317
-
1318
- export type EqualityChecker<T> = (state: T, newState: T) => boolean;
1319
-
1320
- export type State = object;
1321
-
1322
- export type StoreApi<T extends State> = {
1323
- setState: SetState<T>;
1324
- getState: GetState<T>;
1325
- subscribe: Subscribe<T>;
1326
- destroy: Destroy;
1327
- };
1328
-
1329
- /**
1330
- * The interface describing a function capable of fetching pilets.
1331
- */
1332
- export interface PiletRequester {
1333
- (): Promise<PiletEntries>;
1334
- }
1335
-
1336
- /**
1337
- * Additional configuration options for the default loader.
1338
- */
1339
- export interface DefaultLoaderConfig {
1340
- /**
1341
- * Sets the cross-origin attribute of potential script tags.
1342
- * For pilets v1 this may be useful. Otherwise, only pilets that
1343
- * have an integrity defined will be set to "anonymous".
1344
- */
1345
- crossOrigin?: string;
1346
- }
1347
-
1348
- /**
1349
- * The callback to be used to load a single pilet.
1350
- */
1351
- export interface PiletLoader {
1352
- (entry: PiletEntry): Promise<Pilet>;
1353
- }
1354
-
1355
- /**
1356
- * Defines the spec identifiers for custom loading.
1357
- */
1358
- export type CustomSpecLoaders = Record<string, PiletLoader>;
1359
-
1360
- /**
1361
- * A set of pipeline hooks used by the Piral loading orchestrator.
1362
- */
1363
- export interface PiletLifecycleHooks {
1364
- /**
1365
- * Hook fired before a pilet is loaded.
1366
- */
1367
- loadPilet?(pilet: PiletMetadata): void;
1368
- /**
1369
- * Hook fired before a pilet is being set up.
1370
- */
1371
- setupPilet?(pilet: Pilet): void;
1372
- /**
1373
- * Hook fired before a pilet is being cleaned up.
1374
- */
1375
- cleanupPilet?(pilet: Pilet): void;
1376
- }
1377
-
1378
- /**
1379
- * The record containing all available dependencies.
1380
- */
1381
- export interface AvailableDependencies {
1382
- [name: string]: any;
1383
- }
1384
-
1385
- /**
1386
- * The strategy for how pilets are loaded at runtime.
1387
- */
1388
- export interface PiletLoadingStrategy {
1389
- (options: LoadPiletsOptions, pilets: PiletsLoaded): PromiseLike<void>;
1390
- }
1391
-
1392
- /**
1393
- * Basic metadata for pilets using the v0 schema.
1394
- */
1395
- export interface PiletV0BaseEntry {
1396
- /**
1397
- * The name of the pilet, i.e., the package id.
1398
- */
1399
- name: string;
1400
- /**
1401
- * The version of the pilet. Should be semantically versioned.
1402
- */
1403
- version: string;
1404
- /**
1405
- * Optionally provides the version of the specification for this pilet.
1406
- */
1407
- spec?: "v0";
1408
- /**
1409
- * The computed hash value of the pilet's content. Should be
1410
- * accurate to allow caching.
548
+ * The location.hash property is a string that contains an initial "#"
549
+ * followed by fragment identifier of the URL. If there is no fragment
550
+ * identifier, this value may be the empty string (i.e. '').
1411
551
  */
1412
552
  hash: string;
1413
553
  /**
1414
- * Optionally provides some custom metadata for the pilet.
1415
- */
1416
- custom?: any;
1417
- /**
1418
- * Optionally provides some configuration to be used in the pilet.
554
+ * The location.state property is a user-supplied State object that is
555
+ * associated with this location. This can be a useful place to store
556
+ * any information you do not want to put in the URL, e.g. session-specific
557
+ * data.
1419
558
  */
1420
- config?: Record<string, any>;
559
+ state: unknown;
1421
560
  /**
1422
- * Additional shared dependency script files.
561
+ * The location.key property is a unique string associated with this location.
562
+ * On the initial location, this will be the string default. On all subsequent
563
+ * locations, this string will be a unique identifier.
1423
564
  */
1424
- dependencies?: Record<string, string>;
1425
- }
1426
-
1427
- export type SetState<T extends State> = {
1428
- <K1 extends keyof T, K2 extends keyof T = K1, K3 extends keyof T = K2, K4 extends keyof T = K3>(partial: PartialState<T, K1, K2, K3, K4>, replace?: boolean): void;
1429
- };
1430
-
1431
- export type GetState<T extends State> = () => T;
1432
-
1433
- export type Subscribe<T extends State> = {
1434
- (listener: StateListener<T>): () => void;
1435
- <StateSlice>(listener: StateSliceListener<StateSlice>, selector?: StateSelector<T, StateSlice>, equalityFn?: EqualityChecker<StateSlice>): () => void;
1436
- };
1437
-
1438
- export type Destroy = () => void;
1439
-
1440
- /**
1441
- * The entries representing pilets from a feed service response.
1442
- */
1443
- export type PiletEntries = Array<PiletEntry>;
1444
-
1445
- /**
1446
- * The callback to be used when pilets have been loaded.
1447
- */
1448
- export interface PiletsLoaded {
1449
- (error: Error | undefined, pilets: Array<Pilet>): void;
565
+ key: string;
1450
566
  }
1451
-
1452
- /**
1453
- * @deprecated Use the builtin `Partial<T>` instead of `PartialState<T>`.
1454
- * Additionally turn on `--exactOptionalPropertyTypes` tsc flag.
1455
- * `PartialState` will be removed in next major
1456
- */
1457
- export type PartialState<T extends State, K1 extends keyof T = keyof T, K2 extends keyof T = K1, K3 extends keyof T = K2, K4 extends keyof T = K3> = (Pick<T, K1> | Pick<T, K2> | Pick<T, K3> | Pick<T, K4> | T) | ((state: T) => Pick<T, K1> | Pick<T, K2> | Pick<T, K3> | Pick<T, K4> | T);
1458
-
1459
- export type StateListener<T> = (state: T, previousState: T) => void;
1460
-
1461
- /**
1462
- * @deprecated Use `StateListener<T>` instead of `StateSliceListener<T>`.
1463
- */
1464
- export type StateSliceListener<T> = (slice: T, previousSlice: T) => void;
1465
567
  }