sample-piral 0.14.29 → 0.15.0-beta.4411

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
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import * as ReactRouter from 'react-router';
3
- import * as LibreAtom from '@libre/atom';
4
3
 
5
4
  declare module "sample-piral" {
6
5
  /**
@@ -40,7 +39,7 @@ declare module "sample-piral" {
40
39
  /**
41
40
  * Custom Pilet API parts defined outside of piral-core.
42
41
  */
43
- export interface PiletCustomApi extends PiletLocaleApi, PiletDashboardApi, PiletMenuApi, PiletNotificationsApi, PiletModalsApi, PiletFeedsApi, PiletSearchApi, PiralAuthApi {}
42
+ export interface PiletCustomApi extends PiletLocaleApi, PiletDashboardApi, PiletMenuApi, PiletNotificationsApi, PiletModalsApi, PiletFeedsApi, PiletSearchApi, PiletAuthApi {}
44
43
 
45
44
  /**
46
45
  * Defines the Pilet API from piral-core.
@@ -106,9 +105,47 @@ declare module "sample-piral" {
106
105
  }
107
106
 
108
107
  /**
109
- * Describes the metadata transported by a pilet.
108
+ * Describes the metadata of a pilet available in its API.
110
109
  */
111
- export type PiletMetadata = (SinglePiletMetadata | MultiPiletMetadata) & PiletRuntimeMetadata;
110
+ export interface PiletMetadata {
111
+ /**
112
+ * The name of the pilet, i.e., the package id.
113
+ */
114
+ name: string;
115
+ /**
116
+ * The version of the pilet. Should be semantically versioned.
117
+ */
118
+ version: string;
119
+ /**
120
+ * Provides the version of the specification for this pilet.
121
+ */
122
+ spec: string;
123
+ /**
124
+ * Provides some custom metadata for the pilet.
125
+ */
126
+ custom?: any;
127
+ /**
128
+ * Optionally indicates the global require reference, if any.
129
+ */
130
+ requireRef?: string;
131
+ /**
132
+ * Additional shared dependencies from the pilet.
133
+ */
134
+ dependencies: Record<string, string>;
135
+ /**
136
+ * Provides some configuration to be used in the pilet.
137
+ */
138
+ config: Record<string, any>;
139
+ /**
140
+ * The URL of the main script of the pilet.
141
+ */
142
+ link: string;
143
+ /**
144
+ * The base path to the pilet. Can be used to make resource requests
145
+ * and override the public path.
146
+ */
147
+ basePath: string;
148
+ }
112
149
 
113
150
  /**
114
151
  * Listener for Piral app shell events.
@@ -272,7 +309,7 @@ declare module "sample-piral" {
272
309
  unregisterSearchProvider(name: string): void;
273
310
  }
274
311
 
275
- export interface PiralAuthApi {
312
+ export interface PiletAuthApi {
276
313
  /**
277
314
  * Gets the currently authenticated user, if any.
278
315
  */
@@ -309,7 +346,7 @@ declare module "sample-piral" {
309
346
  /**
310
347
  * The meta data registered for a page.
311
348
  */
312
- export interface PiralPageMeta extends PiralCustomPageMeta {}
349
+ export interface PiralPageMeta extends PiralCustomPageMeta, PiralCustomPageMeta {}
313
350
 
314
351
  /**
315
352
  * The shape of an implicit unregister function.
@@ -340,23 +377,6 @@ declare module "sample-piral" {
340
377
  (): void;
341
378
  }
342
379
 
343
- /**
344
- * The metadata response for a single pilet.
345
- */
346
- export type SinglePiletMetadata = PiletMetadataV0 | PiletMetadataV1 | PiletMetadataV2 | PiletMetadataVx;
347
-
348
- /**
349
- * The metadata response for a multi pilet.
350
- */
351
- export type MultiPiletMetadata = PiletMetadataBundle;
352
-
353
- /**
354
- * Additional metadata that may be added to the runtime information.
355
- */
356
- export interface PiletRuntimeMetadata {
357
- basePath?: string;
358
- }
359
-
360
380
  /**
361
381
  * Custom events defined outside of piral-core.
362
382
  */
@@ -651,158 +671,6 @@ declare module "sample-piral" {
651
671
  name: TName;
652
672
  }
653
673
 
654
- /**
655
- * Metadata for pilets using the v0 schema.
656
- */
657
- export type PiletMetadataV0 = PiletMetadataV0Content | PiletMetadataV0Link;
658
-
659
- /**
660
- * Metadata for pilets using the v1 schema.
661
- */
662
- export interface PiletMetadataV1 {
663
- /**
664
- * The name of the pilet, i.e., the package id.
665
- */
666
- name: string;
667
- /**
668
- * The version of the pilet. Should be semantically versioned.
669
- */
670
- version: string;
671
- /**
672
- * Optionally provides the version of the specification for this pilet.
673
- */
674
- spec?: "v1";
675
- /**
676
- * The link for retrieving the content of the pilet.
677
- */
678
- link: string;
679
- /**
680
- * The reference name for the global require.
681
- */
682
- requireRef: string;
683
- /**
684
- * The computed integrity of the pilet. Will be used to set the
685
- * integrity value of the script.
686
- */
687
- integrity?: string;
688
- /**
689
- * Optionally provides some custom metadata for the pilet.
690
- */
691
- custom?: any;
692
- /**
693
- * Optionally provides some configuration to be used in the pilet.
694
- */
695
- config?: Record<string, any>;
696
- /**
697
- * Additional shared dependency script files.
698
- */
699
- dependencies?: Record<string, string>;
700
- }
701
-
702
- /**
703
- * Metadata for pilets using the v2 schema.
704
- */
705
- export interface PiletMetadataV2 {
706
- /**
707
- * The name of the pilet, i.e., the package id.
708
- */
709
- name: string;
710
- /**
711
- * The version of the pilet. Should be semantically versioned.
712
- */
713
- version: string;
714
- /**
715
- * Provides the version of the specification for this pilet.
716
- */
717
- spec: "v2";
718
- /**
719
- * The reference name for the global require.
720
- */
721
- requireRef: string;
722
- /**
723
- * The computed integrity of the pilet.
724
- */
725
- integrity?: string;
726
- /**
727
- * The link for retrieving the content of the pilet.
728
- */
729
- link: string;
730
- /**
731
- * Optionally provides some custom metadata for the pilet.
732
- */
733
- custom?: any;
734
- /**
735
- * Optionally provides some configuration to be used in the pilet.
736
- */
737
- config?: Record<string, any>;
738
- /**
739
- * Additional shared dependency script files.
740
- */
741
- dependencies?: Record<string, string>;
742
- }
743
-
744
- export interface PiletMetadataVx {
745
- /**
746
- * The name of the pilet, i.e., the package id.
747
- */
748
- name: string;
749
- /**
750
- * The version of the pilet. Should be semantically versioned.
751
- */
752
- version: string;
753
- /**
754
- * Provides an identifier for the custom specification.
755
- */
756
- spec: string;
757
- /**
758
- * Optionally provides some custom metadata for the pilet.
759
- */
760
- custom?: any;
761
- /**
762
- * Optionally provides some configuration to be used in the pilet.
763
- */
764
- config?: Record<string, any>;
765
- /**
766
- * Additional shared dependency script files.
767
- */
768
- dependencies?: Record<string, string>;
769
- }
770
-
771
- /**
772
- * Metadata for pilets using the bundle schema.
773
- */
774
- export interface PiletMetadataBundle {
775
- /**
776
- * The name of the bundle pilet, i.e., the package id.
777
- */
778
- name?: string;
779
- /**
780
- * Optionally provides the version of the specification for this pilet.
781
- */
782
- spec?: "v1";
783
- /**
784
- * The link for retrieving the bundle content of the pilet.
785
- */
786
- link: string;
787
- /**
788
- * The reference name for the global bundle-shared require.
789
- */
790
- bundle: string;
791
- /**
792
- * The computed integrity of the pilet. Will be used to set the
793
- * integrity value of the script.
794
- */
795
- integrity?: string;
796
- /**
797
- * Optionally provides some custom metadata for the pilet.
798
- */
799
- custom?: any;
800
- /**
801
- * Additional shared dependency script files.
802
- */
803
- dependencies?: Record<string, string>;
804
- }
805
-
806
674
  export interface PiralSelectLanguageEvent {
807
675
  /**
808
676
  * Gets the previously selected language.
@@ -988,34 +856,6 @@ declare module "sample-piral" {
988
856
  defaults: any;
989
857
  }
990
858
 
991
- /**
992
- * Metadata for pilets using the v0 schema with a content.
993
- */
994
- export interface PiletMetadataV0Content extends PiletMetadataV0Base {
995
- /**
996
- * The content of the pilet. If the content is not available
997
- * the link will be used (unless caching has been activated).
998
- */
999
- content: string;
1000
- /**
1001
- * If available indicates that the pilet should not be cached.
1002
- * In case of a string this is interpreted as the expiration time
1003
- * of the cache. In case of an accurate hash this should not be
1004
- * required or set.
1005
- */
1006
- noCache?: boolean | string;
1007
- }
1008
-
1009
- /**
1010
- * Metadata for pilets using the v0 schema with a link.
1011
- */
1012
- export interface PiletMetadataV0Link extends PiletMetadataV0Base {
1013
- /**
1014
- * The link for retrieving the content of the pilet.
1015
- */
1016
- link: string;
1017
- }
1018
-
1019
859
  export type StandardMenuType = "general" | "admin" | "user" | "header" | "footer";
1020
860
 
1021
861
  export interface PiralCustomMenuTypes {}
@@ -1031,7 +871,6 @@ declare module "sample-piral" {
1031
871
  */
1032
872
  export interface ComponentContext {
1033
873
  router: ReactRouter.RouteComponentProps;
1034
- state: LibreAtom.Atom<GlobalState>;
1035
874
  readState: PiralActions["readState"];
1036
875
  }
1037
876
 
@@ -1045,117 +884,52 @@ declare module "sample-piral" {
1045
884
  pilet: string;
1046
885
  }
1047
886
 
1048
- export type WrappedComponent<TProps> = React.ComponentType<Without<TProps, keyof BaseComponentProps>>;
887
+ export type WrappedComponent<TProps> = React.ComponentType<React.PropsWithChildren<Without<TProps, keyof BaseComponentProps>>>;
1049
888
 
1050
889
  /**
1051
- * Basic metadata for pilets using the v0 schema.
890
+ * The globally defined actions.
1052
891
  */
1053
- export interface PiletMetadataV0Base {
1054
- /**
1055
- * The name of the pilet, i.e., the package id.
1056
- */
1057
- name: string;
892
+ export interface PiralActions extends PiralCustomActions {
1058
893
  /**
1059
- * The version of the pilet. Should be semantically versioned.
894
+ * Initializes the application shell.
895
+ * @param loading The current loading state.
896
+ * @param error The application error, if any.
897
+ * @param modules The loaded pilets.
1060
898
  */
1061
- version: string;
899
+ initialize(loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
1062
900
  /**
1063
- * Optionally provides the version of the specification for this pilet.
901
+ * Injects an evaluated pilet at runtime - removes the pilet from registry first if available.
902
+ * @param pilet The pilet to be injected.
903
+ * @returns The injected pilet.
1064
904
  */
1065
- spec?: "v0";
905
+ injectPilet(pilet: Pilet): Pilet;
1066
906
  /**
1067
- * The computed hash value of the pilet's content. Should be
1068
- * accurate to allow caching.
907
+ * Adds a pilet at runtime by loading it, evaluating it, and then injecting it.
908
+ * @param pilet The pilet to be added.
909
+ * @returns The promise indicating when the pilet was fully added.
1069
910
  */
1070
- hash: string;
911
+ addPilet(pilet: PiletEntry): Promise<void>;
1071
912
  /**
1072
- * Optionally provides some custom metadata for the pilet.
913
+ * Removes a pilet by unloading it and deleting all component registrations.
914
+ * @param name The name of the pilet to remove.
1073
915
  */
1074
- custom?: any;
916
+ removePilet(name: string): Promise<void>;
1075
917
  /**
1076
- * Optionally provides some configuration to be used in the pilet.
918
+ * Defines a single action for Piral.
919
+ * @param actionName The name of the action to define.
920
+ * @param action The action to include.
1077
921
  */
1078
- config?: Record<string, any>;
922
+ defineAction<T extends keyof PiralActions>(actionName: T, action: PiralAction<PiralActions[T]>): void;
1079
923
  /**
1080
- * Additional shared dependency script files.
924
+ * Defines a set of actions for Piral.
925
+ * @param actions The actions to define.
1081
926
  */
1082
- dependencies?: Record<string, string>;
1083
- }
1084
-
1085
- /**
1086
- * The Piral global app state container.
1087
- */
1088
- export interface GlobalState extends PiralCustomState {
927
+ defineActions(actions: PiralDefineActions): void;
1089
928
  /**
1090
- * The relevant state for the app itself.
929
+ * Reads the value of a shared data item.
930
+ * @param name The name of the shared item.
1091
931
  */
1092
- app: AppState;
1093
- /**
1094
- * The relevant state for rendering errors of the app.
1095
- */
1096
- errorComponents: ErrorComponentsState;
1097
- /**
1098
- * The relevant state for rendering parts of the app.
1099
- */
1100
- components: ComponentsState;
1101
- /**
1102
- * The relevant state for the registered components.
1103
- */
1104
- registry: RegistryState;
1105
- /**
1106
- * Gets the loaded modules.
1107
- */
1108
- modules: Array<PiletMetadata>;
1109
- /**
1110
- * The foreign component portals to render.
1111
- */
1112
- portals: Record<string, Array<React.ReactPortal>>;
1113
- /**
1114
- * The application's shared data.
1115
- */
1116
- data: Dict<SharedDataItem>;
1117
- /**
1118
- * The used (exact) application routes.
1119
- */
1120
- routes: Dict<React.ComponentType<ReactRouter.RouteComponentProps<any>>>;
1121
- /**
1122
- * The current provider.
1123
- */
1124
- provider?: React.ComponentType;
1125
- }
1126
-
1127
- /**
1128
- * The globally defined actions.
1129
- */
1130
- export interface PiralActions extends PiralCustomActions {
1131
- /**
1132
- * Initializes the application shell.
1133
- * @param loading The current loading state.
1134
- * @param error The application error, if any.
1135
- * @param modules The loaded pilets.
1136
- */
1137
- initialize(loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
1138
- /**
1139
- * Injects a pilet at runtime - removes the pilet from registry first if available.
1140
- * @param pilet The pilet to be injected.
1141
- */
1142
- injectPilet(pilet: Pilet): void;
1143
- /**
1144
- * Defines a single action for Piral.
1145
- * @param actionName The name of the action to define.
1146
- * @param action The action to include.
1147
- */
1148
- defineAction<T extends keyof PiralActions>(actionName: T, action: PiralAction<PiralActions[T]>): void;
1149
- /**
1150
- * Defines a set of actions for Piral.
1151
- * @param actions The actions to define.
1152
- */
1153
- defineActions(actions: PiralDefineActions): void;
1154
- /**
1155
- * Reads the value of a shared data item.
1156
- * @param name The name of the shared item.
1157
- */
1158
- readDataValue(name: string): any;
932
+ readDataValue(name: string): any;
1159
933
  /**
1160
934
  * Tries to write a shared data item. The write access is only
1161
935
  * possible if the name belongs to the provided owner or has not
@@ -1168,11 +942,6 @@ declare module "sample-piral" {
1168
942
  * @param expiration The time for when to dispose the shared item.
1169
943
  */
1170
944
  tryWriteDataItem(name: string, value: any, owner: string, target: DataStoreTarget, expiration: number): boolean;
1171
- /**
1172
- * Performs a layout change.
1173
- * @param current The layout to take.
1174
- */
1175
- changeLayout(current: LayoutType): void;
1176
945
  /**
1177
946
  * Registers a new route to be resolved.
1178
947
  * @param route The route to register.
@@ -1254,152 +1023,15 @@ declare module "sample-piral" {
1254
1023
  * @returns The desired part.
1255
1024
  */
1256
1025
  readState<S>(select: (state: GlobalState) => S): S;
1257
- }
1258
-
1259
- export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
1260
-
1261
- /**
1262
- * Custom state extensions defined outside of piral-core.
1263
- */
1264
- export interface PiralCustomState {
1265
- /**
1266
- * Information for the language display.
1267
- */
1268
- language: {
1269
- /**
1270
- * Gets if languages are currently loading.
1271
- */
1272
- loading: boolean;
1273
- /**
1274
- * The selected, i.e., active, language.
1275
- */
1276
- selected: string;
1277
- /**
1278
- * The available languages.
1279
- */
1280
- available: Array<string>;
1281
- };
1282
- /**
1283
- * The currently open notifications.
1284
- */
1285
- notifications: Array<OpenNotification>;
1286
- /**
1287
- * The currently open modal dialogs.
1288
- */
1289
- modals: Array<OpenModalDialog>;
1290
- /**
1291
- * The relevant state for the registered feeds.
1292
- */
1293
- feeds: FeedsState;
1294
- /**
1295
- * The relevant state for the in-site search.
1296
- */
1297
- search: SearchState;
1298
- /**
1299
- * The currently authenticated user, if any.
1300
- */
1301
- user: UserInfo | undefined;
1302
- }
1303
-
1304
- /**
1305
- * The Piral global app sub-state container for app information.
1306
- */
1307
- export interface AppState {
1308
- /**
1309
- * Information for the layout computation.
1310
- */
1311
- layout: LayoutType;
1312
- /**
1313
- * Gets if the application is currently performing a background loading
1314
- * activity, e.g., for loading modules asynchronously or fetching
1315
- * translations.
1316
- */
1317
- loading: boolean;
1318
- /**
1319
- * Gets an unrecoverable application error, if any.
1320
- */
1321
- error: Error | undefined;
1322
1026
  /**
1323
- * Gets the public path of the application.
1324
- */
1325
- publicPath: string;
1326
- }
1327
-
1328
- export type ErrorComponentsState = {
1329
- [P in keyof Errors]?: React.ComponentType<Errors[P]>;
1330
- };
1331
-
1332
- /**
1333
- * The Piral global app sub-state container for shared components.
1334
- */
1335
- export interface ComponentsState extends PiralCustomComponentsState {
1336
- /**
1337
- * The loading indicator renderer.
1338
- */
1339
- LoadingIndicator: React.ComponentType<LoadingIndicatorProps>;
1340
- /**
1341
- * The error renderer.
1342
- */
1343
- ErrorInfo: React.ComponentType<ErrorInfoProps>;
1344
- /**
1345
- * The router context.
1346
- */
1347
- Router: React.ComponentType<RouterProps>;
1348
- /**
1349
- * The layout used for pages.
1350
- */
1351
- Layout: React.ComponentType<LayoutProps>;
1352
- /**
1353
- * The route switch used for determining the route registration.
1354
- */
1355
- RouteSwitch: React.ComponentType<RouteSwitchProps>;
1356
- /**
1357
- * A component that can be used for debugging purposes.
1358
- */
1359
- Debug?: React.ComponentType;
1360
- }
1361
-
1362
- /**
1363
- * The Piral global app sub-state container for component registrations.
1364
- */
1365
- export interface RegistryState extends PiralCustomRegistryState {
1366
- /**
1367
- * The registered page components for the router.
1368
- */
1369
- pages: Dict<PageRegistration>;
1370
- /**
1371
- * The registered extension components for extension slots.
1372
- */
1373
- extensions: Dict<Array<ExtensionRegistration>>;
1374
- /**
1375
- * The registered wrappers for any component.
1027
+ * Performs a navigation.
1028
+ * @param path The path to navigate to.
1029
+ * @param state The optional state for the navigation.
1376
1030
  */
1377
- wrappers: Dict<React.ComponentType<any>>;
1031
+ navigate(path: string, state?: any): void;
1378
1032
  }
1379
1033
 
1380
- export type Dict<T> = Record<string, T>;
1381
-
1382
- /**
1383
- * Defines the shape of a shared data item.
1384
- */
1385
- export interface SharedDataItem<TValue = any> {
1386
- /**
1387
- * Gets the associated value.
1388
- */
1389
- value: TValue;
1390
- /**
1391
- * Gets the owner of the item.
1392
- */
1393
- owner: string;
1394
- /**
1395
- * Gets the storage location.
1396
- */
1397
- target: DataStoreTarget;
1398
- /**
1399
- * Gets the expiration of the item.
1400
- */
1401
- expires: number;
1402
- }
1034
+ export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
1403
1035
 
1404
1036
  /**
1405
1037
  * Custom actions defined outside of piral-core.
@@ -1558,6 +1190,11 @@ declare module "sample-piral" {
1558
1190
  */
1559
1191
  export type Pilet = SinglePilet | MultiPilet;
1560
1192
 
1193
+ /**
1194
+ * Pilet entry representing part of a response from the feed service.
1195
+ */
1196
+ export type PiletEntry = MultiPiletEntry | SinglePiletEntry;
1197
+
1561
1198
  /**
1562
1199
  * The shape of an app action in Piral.
1563
1200
  */
@@ -1572,11 +1209,6 @@ declare module "sample-piral" {
1572
1209
  [P in keyof PiralActions]: PiralAction<PiralActions[P]>;
1573
1210
  }>;
1574
1211
 
1575
- /**
1576
- * The different known layout types.
1577
- */
1578
- export type LayoutType = "mobile" | "tablet" | "desktop";
1579
-
1580
1212
  /**
1581
1213
  * The interface modeling the registration of a pilet page component.
1582
1214
  */
@@ -1591,303 +1223,826 @@ declare module "sample-piral" {
1591
1223
  meta: PiralPageMeta;
1592
1224
  }
1593
1225
 
1594
- export interface OpenNotification {
1595
- id: string;
1596
- component: React.ComponentType<BareNotificationProps>;
1597
- options: NotificationOptions;
1598
- close(): void;
1599
- }
1600
-
1601
- export interface OpenModalDialog {
1226
+ /**
1227
+ * The Piral global app sub-state container for shared components.
1228
+ */
1229
+ export interface ComponentsState extends PiralCustomComponentsState {
1602
1230
  /**
1603
- * Gets the ID of the modal to open. For tracking its state.
1231
+ * The loading indicator renderer.
1604
1232
  */
1605
- id: string;
1233
+ LoadingIndicator: React.ComponentType<LoadingIndicatorProps>;
1606
1234
  /**
1607
- * Specifies the fully qualified name of the dialog to show.
1235
+ * The error renderer.
1608
1236
  */
1609
- name: string;
1237
+ ErrorInfo: React.ComponentType<ErrorInfoProps>;
1610
1238
  /**
1611
- * Specifies the alternative (original) name of the dialog to show.
1239
+ * The router context.
1612
1240
  */
1613
- alternative?: string;
1241
+ Router: React.ComponentType<RouterProps>;
1614
1242
  /**
1615
- * Defines the transported options.
1243
+ * The layout used for pages.
1616
1244
  */
1617
- options: BaseModalOptions;
1245
+ Layout: React.ComponentType<LayoutProps>;
1618
1246
  /**
1619
- * Closes the modal dialog.
1247
+ * The route switch used for determining the route registration.
1620
1248
  */
1621
- close(): void;
1249
+ RouteSwitch: React.ComponentType<RouteSwitchProps>;
1250
+ /**
1251
+ * A component that can be used for debugging purposes.
1252
+ */
1253
+ Debug?: React.ComponentType;
1622
1254
  }
1623
1255
 
1624
- export interface FeedsState {
1625
- [id: string]: FeedDataState;
1626
- }
1256
+ export type ErrorComponentsState = {
1257
+ [P in keyof Errors]?: React.ComponentType<Errors[P]>;
1258
+ };
1627
1259
 
1628
- export interface SearchState {
1260
+ /**
1261
+ * The Piral global app state container.
1262
+ */
1263
+ export interface GlobalState extends PiralCustomState {
1264
+ /**
1265
+ * The relevant state for the app itself.
1266
+ */
1267
+ app: AppState;
1268
+ /**
1269
+ * The relevant state for rendering errors of the app.
1270
+ */
1271
+ errorComponents: ErrorComponentsState;
1272
+ /**
1273
+ * The relevant state for rendering parts of the app.
1274
+ */
1275
+ components: ComponentsState;
1276
+ /**
1277
+ * The relevant state for the registered components.
1278
+ */
1279
+ registry: RegistryState;
1280
+ /**
1281
+ * Gets the loaded modules.
1282
+ */
1283
+ modules: Array<Pilet>;
1284
+ /**
1285
+ * The foreign component portals to render.
1286
+ */
1287
+ portals: Record<string, Array<React.ReactPortal>>;
1288
+ /**
1289
+ * The application's shared data.
1290
+ */
1291
+ data: Dict<SharedDataItem>;
1292
+ /**
1293
+ * The used (exact) application routes.
1294
+ */
1295
+ routes: Dict<React.ComponentType<ReactRouter.RouteComponentProps<any>>>;
1296
+ /**
1297
+ * The current provider.
1298
+ */
1299
+ provider?: React.ComponentType;
1300
+ }
1301
+
1302
+ export interface LanguageData {
1303
+ global: Translations;
1304
+ locals: Array<{
1305
+ name: string;
1306
+ value: Translations;
1307
+ }>;
1308
+ }
1309
+
1310
+ export interface TileRegistration extends BaseRegistration {
1311
+ component: WrappedComponent<TileComponentProps>;
1312
+ preferences: TilePreferences;
1313
+ }
1314
+
1315
+ export interface MenuItemRegistration extends BaseRegistration {
1316
+ component: WrappedComponent<MenuComponentProps>;
1317
+ settings: MenuSettings;
1318
+ }
1319
+
1320
+ export interface OpenNotification {
1321
+ id: string;
1322
+ component: React.ComponentType<BareNotificationProps>;
1323
+ options: NotificationOptions;
1324
+ close(): void;
1325
+ }
1326
+
1327
+ export interface OpenModalDialog {
1328
+ /**
1329
+ * Gets the ID of the modal to open. For tracking its state.
1330
+ */
1331
+ id: string;
1332
+ /**
1333
+ * Specifies the fully qualified name of the dialog to show.
1334
+ */
1335
+ name: string;
1336
+ /**
1337
+ * Specifies the alternative (original) name of the dialog to show.
1338
+ */
1339
+ alternative?: string;
1340
+ /**
1341
+ * Defines the transported options.
1342
+ */
1343
+ options: BaseModalOptions;
1344
+ /**
1345
+ * Closes the modal dialog.
1346
+ */
1347
+ close(): void;
1348
+ }
1349
+
1350
+ export interface ModalRegistration extends BaseRegistration {
1351
+ name: string;
1352
+ component: WrappedComponent<ModalComponentProps<any>>;
1353
+ defaults: any;
1354
+ layout: ModalLayoutOptions;
1355
+ }
1356
+
1357
+ export interface ConnectorDetails<TData, TItem, TReducers extends FeedConnectorReducers<TData> = {}> extends FeedConnectorOptions<TData, TItem, TReducers> {
1358
+ /**
1359
+ * The ID of the connector.
1360
+ */
1361
+ id: string;
1362
+ /**
1363
+ * The dispose function if active.
1364
+ */
1365
+ dispose?(): void;
1366
+ }
1367
+
1368
+ export interface SearchProviderRegistration extends BaseRegistration {
1369
+ search: SearchHandler;
1370
+ cancel(): void;
1371
+ clear(): void;
1372
+ onlyImmediate: boolean;
1373
+ }
1374
+
1375
+ /**
1376
+ * An evaluated single pilet.
1377
+ */
1378
+ export type SinglePilet = SinglePiletApp & PiletMetadata;
1379
+
1380
+ /**
1381
+ * An evaluated multi pilet.
1382
+ */
1383
+ export type MultiPilet = MultiPiletApp & PiletMetadata;
1384
+
1385
+ /**
1386
+ * The metadata response for a multi pilet.
1387
+ */
1388
+ export type MultiPiletEntry = PiletBundleEntry;
1389
+
1390
+ /**
1391
+ * The metadata response for a single pilet.
1392
+ */
1393
+ export type SinglePiletEntry = PiletV0Entry | PiletV1Entry | PiletV2Entry | PiletVxEntry;
1394
+
1395
+ /**
1396
+ * The Piral app instance context.
1397
+ */
1398
+ export interface GlobalStateContext extends PiralActions, EventEmitter {
1399
+ /**
1400
+ * The global state context atom.
1401
+ * Changes to the state should always be dispatched via the `dispatch` action.
1402
+ */
1403
+ state: UseBoundStore<GlobalState>;
1404
+ /**
1405
+ * The API objects created for the loaded pilets.
1406
+ */
1407
+ apis: PiletsBag;
1408
+ /**
1409
+ * The available component converters.
1410
+ */
1411
+ converters: ComponentConverters<any>;
1412
+ /**
1413
+ * The initial options.
1414
+ */
1415
+ options: LoadPiletsOptions;
1416
+ }
1417
+
1418
+ /**
1419
+ * Custom parts of the global custom component state defined outside of piral-core.
1420
+ */
1421
+ export interface PiralCustomComponentsState {
1422
+ /**
1423
+ * Represents the component for rendering a language selection.
1424
+ */
1425
+ LanguagesPicker: React.ComponentType<LanguagesPickerProps>;
1426
+ /**
1427
+ * The dashboard container component.
1428
+ */
1429
+ DashboardContainer: React.ComponentType<DashboardContainerProps>;
1430
+ /**
1431
+ * The dashboard tile component.
1432
+ */
1433
+ DashboardTile: React.ComponentType<DashboardTileProps>;
1434
+ /**
1435
+ * The menu container component.
1436
+ */
1437
+ MenuContainer: React.ComponentType<MenuContainerProps>;
1438
+ /**
1439
+ * The menu item component.
1440
+ */
1441
+ MenuItem: React.ComponentType<MenuItemProps>;
1442
+ /**
1443
+ * The host component for notifications.
1444
+ */
1445
+ NotificationsHost: React.ComponentType<NotificationsHostProps>;
1446
+ /**
1447
+ * The notification toast component.
1448
+ */
1449
+ NotificationsToast: React.ComponentType<NotificationsToastProps>;
1450
+ /**
1451
+ * The host component for modal dialogs.
1452
+ */
1453
+ ModalsHost: React.ComponentType<ModalsHostProps>;
1454
+ /**
1455
+ * The modal dialog component.
1456
+ */
1457
+ ModalsDialog: React.ComponentType<ModalsDialogProps>;
1458
+ /**
1459
+ * The component for showing the results of the search.
1460
+ */
1461
+ SearchResult: React.ComponentType<SearchResultProps>;
1462
+ /**
1463
+ * The container for showing search.
1464
+ */
1465
+ SearchContainer: React.ComponentType<SearchContainerProps>;
1466
+ /**
1467
+ * The input component for search capability.
1468
+ */
1469
+ SearchInput: React.ComponentType<SearchInputProps>;
1470
+ }
1471
+
1472
+ /**
1473
+ * The props of a Loading indicator component.
1474
+ */
1475
+ export interface LoadingIndicatorProps {}
1476
+
1477
+ /**
1478
+ * The props for the ErrorInfo component.
1479
+ */
1480
+ export type ErrorInfoProps = UnionOf<Errors>;
1481
+
1482
+ /**
1483
+ * The props of a Router component.
1484
+ */
1485
+ export interface RouterProps {
1486
+ /**
1487
+ * The content to be rendered inside the router.
1488
+ */
1489
+ children?: React.ReactNode;
1490
+ }
1491
+
1492
+ /**
1493
+ * The props of a Layout component.
1494
+ */
1495
+ export interface LayoutProps {
1496
+ /**
1497
+ * The currently selected layout type.
1498
+ */
1499
+ currentLayout: LayoutType;
1500
+ /**
1501
+ * The page's content.
1502
+ */
1503
+ children: React.ReactNode;
1504
+ }
1505
+
1506
+ /**
1507
+ * The props of the RouteSwitch component.
1508
+ */
1509
+ export interface RouteSwitchProps extends ReactRouter.SwitchProps {
1510
+ /**
1511
+ * The component that should be used in case nothing was found.
1512
+ */
1513
+ NotFound: React.ComponentType<ReactRouter.RouteComponentProps>;
1514
+ /**
1515
+ * The component to register for the different paths.
1516
+ */
1517
+ paths: Array<AppPath>;
1518
+ }
1519
+
1520
+ /**
1521
+ * Map of all error types to their respective props.
1522
+ */
1523
+ export interface Errors extends PiralCustomErrors {
1524
+ /**
1525
+ * The props type for an extension error.
1526
+ */
1527
+ extension: ExtensionErrorInfoProps;
1528
+ /**
1529
+ * The props type for a loading error.
1530
+ */
1531
+ loading: LoadingErrorInfoProps;
1532
+ /**
1533
+ * The props type for a page error.
1534
+ */
1535
+ page: PageErrorInfoProps;
1536
+ /**
1537
+ * The props type for a not found error.
1538
+ */
1539
+ not_found: NotFoundErrorInfoProps;
1540
+ /**
1541
+ * The props type for an unknown error.
1542
+ */
1543
+ unknown: UnknownErrorInfoProps;
1544
+ }
1545
+
1546
+ /**
1547
+ * Custom state extensions defined outside of piral-core.
1548
+ */
1549
+ export interface PiralCustomState {
1550
+ /**
1551
+ * Information for the language display.
1552
+ */
1553
+ language: {
1554
+ /**
1555
+ * Gets if languages are currently loading.
1556
+ */
1557
+ loading: boolean;
1558
+ /**
1559
+ * The selected, i.e., active, language.
1560
+ */
1561
+ selected: string;
1562
+ /**
1563
+ * The available languages.
1564
+ */
1565
+ available: Array<string>;
1566
+ };
1567
+ /**
1568
+ * The currently open notifications.
1569
+ */
1570
+ notifications: Array<OpenNotification>;
1571
+ /**
1572
+ * The currently open modal dialogs.
1573
+ */
1574
+ modals: Array<OpenModalDialog>;
1575
+ /**
1576
+ * The relevant state for the registered feeds.
1577
+ */
1578
+ feeds: FeedsState;
1579
+ /**
1580
+ * The relevant state for the in-site search.
1581
+ */
1582
+ search: SearchState;
1583
+ /**
1584
+ * The currently authenticated user, if any.
1585
+ */
1586
+ user: UserInfo | undefined;
1587
+ }
1588
+
1589
+ /**
1590
+ * The Piral global app sub-state container for app information.
1591
+ */
1592
+ export interface AppState {
1593
+ /**
1594
+ * Gets if the application is currently performing a background loading
1595
+ * activity, e.g., for loading modules asynchronously or fetching
1596
+ * translations.
1597
+ */
1598
+ loading: boolean;
1629
1599
  /**
1630
- * Gets the current input value.
1600
+ * Gets an unrecoverable application error, if any.
1631
1601
  */
1632
- input: string;
1602
+ error: Error | undefined;
1633
1603
  /**
1634
- * Gets the current result state.
1604
+ * Gets the public path of the application.
1635
1605
  */
1636
- results: {
1637
- /**
1638
- * Gets weather the search is still loading.
1639
- */
1640
- loading: boolean;
1641
- /**
1642
- * The results to display for the current search.
1643
- */
1644
- items: Array<React.ReactChild>;
1645
- };
1606
+ publicPath: string;
1646
1607
  }
1647
1608
 
1648
1609
  /**
1649
- * Map of all error types to their respective props.
1610
+ * The Piral global app sub-state container for component registrations.
1650
1611
  */
1651
- export interface Errors extends PiralCustomErrors {
1612
+ export interface RegistryState extends PiralCustomRegistryState {
1652
1613
  /**
1653
- * The props type for an extension error.
1614
+ * The registered page components for the router.
1654
1615
  */
1655
- extension: ExtensionErrorInfoProps;
1616
+ pages: Dict<PageRegistration>;
1656
1617
  /**
1657
- * The props type for a loading error.
1618
+ * The registered extension components for extension slots.
1619
+ */
1620
+ extensions: Dict<Array<ExtensionRegistration>>;
1621
+ /**
1622
+ * The registered wrappers for any component.
1623
+ */
1624
+ wrappers: Dict<React.ComponentType<any>>;
1625
+ }
1626
+
1627
+ export type Dict<T> = Record<string, T>;
1628
+
1629
+ /**
1630
+ * Defines the shape of a shared data item.
1631
+ */
1632
+ export interface SharedDataItem<TValue = any> {
1633
+ /**
1634
+ * Gets the associated value.
1635
+ */
1636
+ value: TValue;
1637
+ /**
1638
+ * Gets the owner of the item.
1639
+ */
1640
+ owner: string;
1641
+ /**
1642
+ * Gets the storage location.
1643
+ */
1644
+ target: DataStoreTarget;
1645
+ /**
1646
+ * Gets the expiration of the item.
1647
+ */
1648
+ expires: number;
1649
+ }
1650
+
1651
+ export interface SearchHandler {
1652
+ (options: SearchOptions): Promise<Array<React.ReactChild>>;
1653
+ }
1654
+
1655
+ /**
1656
+ * The pilet app, i.e., the functional exports.
1657
+ */
1658
+ export interface SinglePiletApp {
1659
+ /**
1660
+ * Integrates the evaluated pilet into the application.
1661
+ * @param api The API to access the application.
1662
+ */
1663
+ setup(api: PiletApi): void | Promise<void>;
1664
+ /**
1665
+ * Optional function for cleanup.
1666
+ * @param api The API to access the application.
1667
+ */
1668
+ teardown?(api: PiletApi): void;
1669
+ }
1670
+
1671
+ /**
1672
+ * The pilet app, i.e., the functional exports.
1673
+ */
1674
+ export interface MultiPiletApp {
1675
+ /**
1676
+ * Integrates the evaluated pilet into the application.
1677
+ * @param api The API to access the application.
1678
+ */
1679
+ setup(apiFactory: PiletApiCreator): void | Promise<void>;
1680
+ }
1681
+
1682
+ /**
1683
+ * Metadata for pilets using the bundle schema.
1684
+ */
1685
+ export interface PiletBundleEntry {
1686
+ /**
1687
+ * The name of the bundle pilet, i.e., the package id.
1688
+ */
1689
+ name?: string;
1690
+ /**
1691
+ * Optionally provides the version of the specification for this pilet.
1692
+ */
1693
+ spec?: "v1";
1694
+ /**
1695
+ * The link for retrieving the bundle content of the pilet.
1696
+ */
1697
+ link: string;
1698
+ /**
1699
+ * The reference name for the global bundle-shared require.
1700
+ */
1701
+ bundle: string;
1702
+ /**
1703
+ * The computed integrity of the pilet. Will be used to set the
1704
+ * integrity value of the script.
1705
+ */
1706
+ integrity?: string;
1707
+ /**
1708
+ * Optionally provides some custom metadata for the pilet.
1709
+ */
1710
+ custom?: any;
1711
+ /**
1712
+ * Additional shared dependency script files.
1713
+ */
1714
+ dependencies?: Record<string, string>;
1715
+ }
1716
+
1717
+ /**
1718
+ * Metadata for pilets using the v0 schema.
1719
+ */
1720
+ export type PiletV0Entry = PiletV0ContentEntry | PiletV0LinkEntry;
1721
+
1722
+ /**
1723
+ * Metadata for pilets using the v1 schema.
1724
+ */
1725
+ export interface PiletV1Entry {
1726
+ /**
1727
+ * The name of the pilet, i.e., the package id.
1728
+ */
1729
+ name: string;
1730
+ /**
1731
+ * The version of the pilet. Should be semantically versioned.
1732
+ */
1733
+ version: string;
1734
+ /**
1735
+ * Optionally provides the version of the specification for this pilet.
1736
+ */
1737
+ spec?: "v1";
1738
+ /**
1739
+ * The link for retrieving the content of the pilet.
1740
+ */
1741
+ link: string;
1742
+ /**
1743
+ * The reference name for the global require.
1744
+ */
1745
+ requireRef: string;
1746
+ /**
1747
+ * The computed integrity of the pilet. Will be used to set the
1748
+ * integrity value of the script.
1749
+ */
1750
+ integrity?: string;
1751
+ /**
1752
+ * Optionally provides some custom metadata for the pilet.
1753
+ */
1754
+ custom?: any;
1755
+ /**
1756
+ * Optionally provides some configuration to be used in the pilet.
1757
+ */
1758
+ config?: Record<string, any>;
1759
+ /**
1760
+ * Additional shared dependency script files.
1761
+ */
1762
+ dependencies?: Record<string, string>;
1763
+ }
1764
+
1765
+ /**
1766
+ * Metadata for pilets using the v2 schema.
1767
+ */
1768
+ export interface PiletV2Entry {
1769
+ /**
1770
+ * The name of the pilet, i.e., the package id.
1771
+ */
1772
+ name: string;
1773
+ /**
1774
+ * The version of the pilet. Should be semantically versioned.
1775
+ */
1776
+ version: string;
1777
+ /**
1778
+ * Provides the version of the specification for this pilet.
1779
+ */
1780
+ spec: "v2";
1781
+ /**
1782
+ * The reference name for the global require.
1783
+ */
1784
+ requireRef: string;
1785
+ /**
1786
+ * The computed integrity of the pilet.
1787
+ */
1788
+ integrity?: string;
1789
+ /**
1790
+ * The link for retrieving the content of the pilet.
1791
+ */
1792
+ link: string;
1793
+ /**
1794
+ * Optionally provides some custom metadata for the pilet.
1795
+ */
1796
+ custom?: any;
1797
+ /**
1798
+ * Optionally provides some configuration to be used in the pilet.
1799
+ */
1800
+ config?: Record<string, any>;
1801
+ /**
1802
+ * Additional shared dependency script files.
1803
+ */
1804
+ dependencies?: Record<string, string>;
1805
+ }
1806
+
1807
+ export interface PiletVxEntry {
1808
+ /**
1809
+ * The name of the pilet, i.e., the package id.
1810
+ */
1811
+ name: string;
1812
+ /**
1813
+ * The version of the pilet. Should be semantically versioned.
1814
+ */
1815
+ version: string;
1816
+ /**
1817
+ * Provides an identifier for the custom specification.
1818
+ */
1819
+ spec: string;
1820
+ /**
1821
+ * Optionally provides some custom metadata for the pilet.
1822
+ */
1823
+ custom?: any;
1824
+ /**
1825
+ * Optionally provides some configuration to be used in the pilet.
1826
+ */
1827
+ config?: Record<string, any>;
1828
+ /**
1829
+ * Additional shared dependency script files.
1830
+ */
1831
+ dependencies?: Record<string, string>;
1832
+ }
1833
+
1834
+ export type UseBoundStore<T extends State, CustomStoreApi extends StoreApi<T> = StoreApi<T>> = {
1835
+ (): T;
1836
+ <U>(selector: StateSelector<T, U>, equalityFn?: EqualityChecker<U>): U;
1837
+ } & CustomStoreApi;
1838
+
1839
+ /**
1840
+ * Represents the dictionary of the loaded pilets and their APIs.
1841
+ */
1842
+ export interface PiletsBag {
1843
+ [name: string]: PiletApi;
1844
+ }
1845
+
1846
+ /**
1847
+ * The options for loading pilets.
1848
+ */
1849
+ export interface LoadPiletsOptions {
1850
+ /**
1851
+ * The callback function for creating an API object.
1852
+ * The API object is passed on to a specific pilet.
1658
1853
  */
1659
- loading: LoadingErrorInfoProps;
1854
+ createApi: PiletApiCreator;
1660
1855
  /**
1661
- * The props type for a page error.
1856
+ * The callback for fetching the dynamic pilets.
1662
1857
  */
1663
- page: PageErrorInfoProps;
1858
+ fetchPilets: PiletRequester;
1664
1859
  /**
1665
- * The props type for a not found error.
1860
+ * Optionally, some already existing evaluated pilets, e.g.,
1861
+ * helpful when debugging or in SSR scenarios.
1666
1862
  */
1667
- not_found: NotFoundErrorInfoProps;
1863
+ pilets?: Array<Pilet>;
1668
1864
  /**
1669
- * The props type for an unknown error.
1865
+ * Optionally, configures the default loader.
1670
1866
  */
1671
- unknown: UnknownErrorInfoProps;
1672
- }
1673
-
1674
- /**
1675
- * Custom parts of the global custom component state defined outside of piral-core.
1676
- */
1677
- export interface PiralCustomComponentsState {
1867
+ config?: DefaultLoaderConfig;
1678
1868
  /**
1679
- * Represents the component for rendering a language selection.
1869
+ * Optionally, defines the default way how to load a pilet.
1680
1870
  */
1681
- LanguagesPicker: React.ComponentType<LanguagesPickerProps>;
1871
+ loadPilet?: PiletLoader;
1682
1872
  /**
1683
- * The dashboard container component.
1873
+ * Optionally, defines loaders for custom specifications.
1684
1874
  */
1685
- DashboardContainer: React.ComponentType<DashboardContainerProps>;
1875
+ loaders?: CustomSpecLoaders;
1686
1876
  /**
1687
- * The dashboard tile component.
1877
+ * Optionally, defines a set of loading hooks to be used.
1688
1878
  */
1689
- DashboardTile: React.ComponentType<DashboardTileProps>;
1879
+ hooks?: PiletLifecycleHooks;
1690
1880
  /**
1691
- * The menu container component.
1881
+ * Gets the map of globally available dependencies with their names
1882
+ * as keys and their evaluated pilet content as value.
1692
1883
  */
1693
- MenuContainer: React.ComponentType<MenuContainerProps>;
1884
+ dependencies?: AvailableDependencies;
1694
1885
  /**
1695
- * The menu item component.
1886
+ * Optionally, defines the loading strategy to use.
1696
1887
  */
1697
- MenuItem: React.ComponentType<MenuItemProps>;
1888
+ strategy?: PiletLoadingStrategy;
1889
+ }
1890
+
1891
+ export interface LanguagesPickerProps {
1698
1892
  /**
1699
- * The host component for notifications.
1893
+ * The currently selected language.
1700
1894
  */
1701
- NotificationsHost: React.ComponentType<NotificationsHostProps>;
1895
+ selected: string;
1702
1896
  /**
1703
- * The notification toast component.
1897
+ * The languages available for selection.
1704
1898
  */
1705
- NotificationsToast: React.ComponentType<NotificationsToastProps>;
1899
+ available: Array<string>;
1900
+ }
1901
+
1902
+ export interface DashboardContainerProps extends ReactRouter.RouteComponentProps {
1706
1903
  /**
1707
- * The host component for modal dialogs.
1904
+ * The tiles to display.
1708
1905
  */
1709
- ModalsHost: React.ComponentType<ModalsHostProps>;
1906
+ children?: React.ReactNode;
1907
+ }
1908
+
1909
+ export interface DashboardTileProps {
1710
1910
  /**
1711
- * The modal dialog component.
1911
+ * The currently used number of columns.
1712
1912
  */
1713
- ModalsDialog: React.ComponentType<ModalsDialogProps>;
1913
+ columns: number;
1714
1914
  /**
1715
- * The component for showing the results of the search.
1915
+ * The currently used number of rows.
1716
1916
  */
1717
- SearchResult: React.ComponentType<SearchResultProps>;
1917
+ rows: number;
1718
1918
  /**
1719
- * The container for showing search.
1919
+ * The resizable status.
1720
1920
  */
1721
- SearchContainer: React.ComponentType<SearchContainerProps>;
1921
+ resizable: boolean;
1722
1922
  /**
1723
- * The input component for search capability.
1923
+ * The provided tile preferences.
1724
1924
  */
1725
- SearchInput: React.ComponentType<SearchInputProps>;
1726
- }
1727
-
1728
- /**
1729
- * The props of a Loading indicator component.
1730
- */
1731
- export interface LoadingIndicatorProps {}
1732
-
1733
- /**
1734
- * The props for the ErrorInfo component.
1735
- */
1736
- export type ErrorInfoProps = UnionOf<Errors>;
1737
-
1738
- /**
1739
- * The props of a Router component.
1740
- */
1741
- export interface RouterProps {}
1742
-
1743
- /**
1744
- * The props of a Layout component.
1745
- */
1746
- export interface LayoutProps {
1925
+ meta: TilePreferences;
1747
1926
  /**
1748
- * The currently selected layout type.
1927
+ * The content of the tile to display.
1749
1928
  */
1750
- currentLayout: LayoutType;
1929
+ children?: React.ReactNode;
1751
1930
  }
1752
1931
 
1753
- /**
1754
- * The props of the RouteSwitch component.
1755
- */
1756
- export interface RouteSwitchProps extends ReactRouter.SwitchProps {
1932
+ export interface MenuContainerProps {
1757
1933
  /**
1758
- * The component that should be used in case nothing was found.
1934
+ * The type of the menu.
1759
1935
  */
1760
- NotFound: React.ComponentType<ReactRouter.RouteComponentProps>;
1936
+ type: MenuType;
1761
1937
  /**
1762
- * The component to register for the different paths.
1938
+ * The menu items to display.
1763
1939
  */
1764
- paths: Array<{
1765
- /**
1766
- * The exact path to use.
1767
- */
1768
- path: string;
1769
- /**
1770
- * The component to register for this path.
1771
- */
1772
- Component: React.ComponentType<ReactRouter.RouteComponentProps>;
1773
- }>;
1940
+ children?: React.ReactNode;
1774
1941
  }
1775
1942
 
1776
- /**
1777
- * Custom parts of the global registry state defined outside of piral-core.
1778
- */
1779
- export interface PiralCustomRegistryState {
1780
- /**
1781
- * The registered tile components for a dashboard.
1782
- */
1783
- tiles: Dict<TileRegistration>;
1943
+ export interface MenuItemProps {
1784
1944
  /**
1785
- * The registered menu items for global display.
1945
+ * The type of the menu.
1786
1946
  */
1787
- menuItems: Dict<MenuItemRegistration>;
1947
+ type: MenuType;
1788
1948
  /**
1789
- * The registered modal dialog components.
1949
+ * The provided menu settings.
1790
1950
  */
1791
- modals: Dict<ModalRegistration>;
1951
+ meta: MenuSettings;
1792
1952
  /**
1793
- * The registered search providers for context aware search.
1953
+ * The content of the menu item.
1794
1954
  */
1795
- searchProviders: Dict<SearchProviderRegistration>;
1796
- }
1797
-
1798
- export interface LanguageData {
1799
- global: Translations;
1800
- locals: Array<{
1801
- name: string;
1802
- value: Translations;
1803
- }>;
1804
- }
1805
-
1806
- export interface TileRegistration extends BaseRegistration {
1807
- component: WrappedComponent<TileComponentProps>;
1808
- preferences: TilePreferences;
1955
+ children?: React.ReactNode;
1809
1956
  }
1810
1957
 
1811
- export interface MenuItemRegistration extends BaseRegistration {
1812
- component: WrappedComponent<MenuComponentProps>;
1813
- settings: MenuSettings;
1958
+ export interface NotificationsHostProps {
1959
+ /**
1960
+ * The notifications to display.
1961
+ */
1962
+ children?: React.ReactNode;
1814
1963
  }
1815
1964
 
1816
- export interface ModalRegistration extends BaseRegistration {
1817
- name: string;
1818
- component: WrappedComponent<ModalComponentProps<any>>;
1819
- defaults: any;
1820
- layout: ModalLayoutOptions;
1965
+ export interface NotificationsToastProps extends BareNotificationProps {
1966
+ /**
1967
+ * The content of the toast to display.
1968
+ */
1969
+ children?: React.ReactNode;
1821
1970
  }
1822
1971
 
1823
- export interface ConnectorDetails<TData, TItem, TReducers extends FeedConnectorReducers<TData> = {}> extends FeedConnectorOptions<TData, TItem, TReducers> {
1972
+ export interface ModalsHostProps {
1824
1973
  /**
1825
- * The ID of the connector.
1974
+ * Gets if the modal is currently open or closed.
1826
1975
  */
1827
- id: string;
1976
+ open: boolean;
1828
1977
  /**
1829
- * The dispose function if active.
1978
+ * Callback to invoke closing the modal dialog.
1830
1979
  */
1831
- dispose?(): void;
1832
- }
1833
-
1834
- export interface SearchProviderRegistration extends BaseRegistration {
1835
- search: SearchHandler;
1836
- cancel(): void;
1837
- clear(): void;
1838
- onlyImmediate: boolean;
1980
+ close(): void;
1981
+ /**
1982
+ * The dialogs to display.
1983
+ */
1984
+ children?: React.ReactNode;
1839
1985
  }
1840
1986
 
1841
- /**
1842
- * An evaluated single pilet.
1843
- */
1844
- export type SinglePilet = SinglePiletApp & SinglePiletMetadata;
1845
-
1846
- /**
1847
- * An evaluated multi pilet.
1848
- */
1849
- export type MultiPilet = MultiPiletApp & MultiPiletMetadata;
1850
-
1851
- /**
1852
- * The Piral app instance context.
1853
- */
1854
- export interface GlobalStateContext extends PiralActions, EventEmitter {
1987
+ export interface ModalsDialogProps extends OpenModalDialog {
1855
1988
  /**
1856
- * The global state context atom.
1857
- * Changes to the state should always be dispatched via the `dispatch` action.
1989
+ * The layout options given for the current dialog.
1858
1990
  */
1859
- state: LibreAtom.Atom<GlobalState>;
1991
+ layout: ModalLayoutOptions;
1860
1992
  /**
1861
- * The API objects created for the loaded pilets.
1993
+ * The provided default options.
1862
1994
  */
1863
- apis: PiletsBag;
1995
+ defaults: any;
1864
1996
  /**
1865
- * The available component converters.
1997
+ * The content of the dialog to display.
1866
1998
  */
1867
- converters: ComponentConverters<any>;
1999
+ children?: React.ReactNode;
2000
+ }
2001
+
2002
+ export interface SearchResultProps {
1868
2003
  /**
1869
- * The initial options.
2004
+ * The search results to display.
1870
2005
  */
1871
- options: LoadPiletsOptions;
2006
+ children?: React.ReactNode;
1872
2007
  }
1873
2008
 
1874
- export interface FeedDataState {
2009
+ export interface SearchContainerProps {
1875
2010
  /**
1876
- * Determines if the feed data is currently loading.
2011
+ * Gets if the results are still gathered.
1877
2012
  */
1878
2013
  loading: boolean;
1879
2014
  /**
1880
- * Indicates if the feed data was already loaded and is active.
2015
+ * The search to display.
1881
2016
  */
1882
- loaded: boolean;
2017
+ children?: React.ReactNode;
2018
+ }
2019
+
2020
+ export interface SearchInputProps {
2021
+ setValue(value: string): void;
2022
+ value: string;
2023
+ }
2024
+
2025
+ export type UnionOf<T> = {
2026
+ [K in keyof T]: T[K];
2027
+ }[keyof T];
2028
+
2029
+ /**
2030
+ * The different known layout types.
2031
+ */
2032
+ export type LayoutType = "mobile" | "tablet" | "desktop";
2033
+
2034
+ /**
2035
+ * Represents a path in the app registration.
2036
+ */
2037
+ export interface AppPath {
1883
2038
  /**
1884
- * Stores the potential error when initializing or loading the feed.
2039
+ * The exact path to use.
1885
2040
  */
1886
- error: any;
2041
+ path: string;
1887
2042
  /**
1888
- * The currently stored feed data.
2043
+ * The component to register for this path.
1889
2044
  */
1890
- data: any;
2045
+ Component: React.ComponentType<ReactRouter.RouteComponentProps>;
1891
2046
  }
1892
2047
 
1893
2048
  /**
@@ -1978,171 +2133,161 @@ declare module "sample-piral" {
1978
2133
  pilet?: string;
1979
2134
  }
1980
2135
 
1981
- export interface LanguagesPickerProps {
2136
+ export interface FeedsState {
2137
+ [id: string]: FeedDataState;
2138
+ }
2139
+
2140
+ export interface SearchState {
1982
2141
  /**
1983
- * The currently selected language.
2142
+ * Gets the current input value.
1984
2143
  */
1985
- selected: string;
2144
+ input: string;
1986
2145
  /**
1987
- * The languages available for selection.
2146
+ * Gets the current result state.
1988
2147
  */
1989
- available: Array<string>;
2148
+ results: {
2149
+ /**
2150
+ * Gets weather the search is still loading.
2151
+ */
2152
+ loading: boolean;
2153
+ /**
2154
+ * The results to display for the current search.
2155
+ */
2156
+ items: Array<React.ReactChild>;
2157
+ };
1990
2158
  }
1991
2159
 
1992
- export interface DashboardContainerProps extends ReactRouter.RouteComponentProps {}
1993
-
1994
- export interface DashboardTileProps {
2160
+ /**
2161
+ * Custom parts of the global registry state defined outside of piral-core.
2162
+ */
2163
+ export interface PiralCustomRegistryState {
1995
2164
  /**
1996
- * The currently used number of columns.
2165
+ * The registered tile components for a dashboard.
1997
2166
  */
1998
- columns: number;
2167
+ tiles: Dict<TileRegistration>;
1999
2168
  /**
2000
- * The currently used number of rows.
2169
+ * The registered menu items for global display.
2001
2170
  */
2002
- rows: number;
2171
+ menuItems: Dict<MenuItemRegistration>;
2003
2172
  /**
2004
- * The resizable status.
2173
+ * The registered modal dialog components.
2005
2174
  */
2006
- resizable: boolean;
2175
+ modals: Dict<ModalRegistration>;
2007
2176
  /**
2008
- * The provided tile preferences.
2177
+ * The registered search providers for context aware search.
2009
2178
  */
2010
- meta: TilePreferences;
2179
+ searchProviders: Dict<SearchProviderRegistration>;
2011
2180
  }
2012
2181
 
2013
- export interface MenuContainerProps {
2014
- /**
2015
- * The type of the menu.
2016
- */
2017
- type: MenuType;
2182
+ /**
2183
+ * The creator function for the pilet API.
2184
+ */
2185
+ export interface PiletApiCreator {
2186
+ (target: PiletMetadata): PiletApi;
2018
2187
  }
2019
2188
 
2020
- export interface MenuItemProps {
2189
+ /**
2190
+ * Metadata for pilets using the v0 schema with a content.
2191
+ */
2192
+ export interface PiletV0ContentEntry extends PiletV0BaseEntry {
2021
2193
  /**
2022
- * The type of the menu.
2194
+ * The content of the pilet. If the content is not available
2195
+ * the link will be used (unless caching has been activated).
2023
2196
  */
2024
- type: MenuType;
2197
+ content: string;
2025
2198
  /**
2026
- * The provided menu settings.
2199
+ * If available indicates that the pilet should not be cached.
2200
+ * In case of a string this is interpreted as the expiration time
2201
+ * of the cache. In case of an accurate hash this should not be
2202
+ * required or set.
2027
2203
  */
2028
- meta: MenuSettings;
2204
+ noCache?: boolean | string;
2029
2205
  }
2030
2206
 
2031
- export interface NotificationsHostProps {}
2032
-
2033
- export interface NotificationsToastProps extends BareNotificationProps {}
2034
-
2035
- export interface ModalsHostProps {
2036
- /**
2037
- * Gets if the modal is currently open or closed.
2038
- */
2039
- open: boolean;
2207
+ /**
2208
+ * Metadata for pilets using the v0 schema with a link.
2209
+ */
2210
+ export interface PiletV0LinkEntry extends PiletV0BaseEntry {
2040
2211
  /**
2041
- * Callback to invoke closing the modal dialog.
2212
+ * The link for retrieving the content of the pilet.
2042
2213
  */
2043
- close(): void;
2044
- }
2045
-
2046
- export interface ModalsDialogProps extends OpenModalDialog {
2047
- layout: ModalLayoutOptions;
2048
- defaults: any;
2214
+ link: string;
2049
2215
  }
2050
2216
 
2051
- export interface SearchResultProps {}
2217
+ export type StateSelector<T extends State, U> = (state: T) => U;
2052
2218
 
2053
- export interface SearchContainerProps {
2054
- /**
2055
- * Gets if the results are still gathered.
2056
- */
2057
- loading: boolean;
2058
- }
2219
+ export type EqualityChecker<T> = (state: T, newState: T) => boolean;
2059
2220
 
2060
- export interface SearchInputProps {
2061
- setValue(value: string): void;
2062
- value: string;
2063
- }
2221
+ export type State = object;
2064
2222
 
2065
- export type UnionOf<T> = {
2066
- [K in keyof T]: T[K];
2067
- }[keyof T];
2223
+ export type StoreApi<T extends State> = {
2224
+ setState: SetState<T>;
2225
+ getState: GetState<T>;
2226
+ subscribe: Subscribe<T>;
2227
+ destroy: Destroy;
2228
+ };
2068
2229
 
2069
- export interface SearchHandler {
2070
- (options: SearchOptions): Promise<Array<React.ReactChild>>;
2230
+ /**
2231
+ * The interface describing a function capable of fetching pilets.
2232
+ */
2233
+ export interface PiletRequester {
2234
+ (): Promise<PiletEntries>;
2071
2235
  }
2072
2236
 
2073
2237
  /**
2074
- * The pilet app, i.e., the functional exports.
2238
+ * Additional configuration options for the default loader.
2075
2239
  */
2076
- export interface SinglePiletApp {
2077
- /**
2078
- * Integrates the evaluated pilet into the application.
2079
- * @param api The API to access the application.
2080
- */
2081
- setup(api: PiletApi): void | Promise<void>;
2240
+ export interface DefaultLoaderConfig {
2082
2241
  /**
2083
- * Optional function for cleanup.
2084
- * @param api The API to access the application.
2242
+ * Sets the cross-origin attribute of potential script tags.
2243
+ * For pilets v1 this may be useful. Otherwise, only pilets that
2244
+ * have an integrity defined will be set to "anonymous".
2085
2245
  */
2086
- teardown?(api: PiletApi): void;
2246
+ crossOrigin?: string;
2087
2247
  }
2088
2248
 
2089
2249
  /**
2090
- * The pilet app, i.e., the functional exports.
2250
+ * The callback to be used to load a single pilet.
2091
2251
  */
2092
- export interface MultiPiletApp {
2093
- /**
2094
- * Integrates the evaluated pilet into the application.
2095
- * @param api The API to access the application.
2096
- */
2097
- setup(apiFactory: PiletApiCreator): void | Promise<void>;
2252
+ export interface PiletLoader {
2253
+ (entry: PiletEntry): Promise<Pilet>;
2098
2254
  }
2099
2255
 
2100
2256
  /**
2101
- * Represents the dictionary of the loaded pilets and their APIs.
2257
+ * Defines the spec identifiers for custom loading.
2102
2258
  */
2103
- export interface PiletsBag {
2104
- [name: string]: PiletApi;
2105
- }
2259
+ export type CustomSpecLoaders = Record<string, PiletLoader>;
2106
2260
 
2107
2261
  /**
2108
- * The options for loading pilets.
2262
+ * A set of pipeline hooks used by the Piral loading orchestrator.
2109
2263
  */
2110
- export interface LoadPiletsOptions {
2111
- /**
2112
- * The callback function for creating an API object.
2113
- * The API object is passed on to a specific pilet.
2114
- */
2115
- createApi: PiletApiCreator;
2116
- /**
2117
- * The callback for fetching the dynamic pilets.
2118
- */
2119
- fetchPilets: PiletRequester;
2120
- /**
2121
- * Optionally, some already existing evaluated pilets, e.g.,
2122
- * helpful when debugging or in SSR scenarios.
2123
- */
2124
- pilets?: Array<Pilet>;
2125
- /**
2126
- * Optionally, configures the default loader.
2127
- */
2128
- config?: DefaultLoaderConfig;
2129
- /**
2130
- * Optionally, defines the default way how to load a pilet.
2131
- */
2132
- loadPilet?: PiletLoader;
2264
+ export interface PiletLifecycleHooks {
2133
2265
  /**
2134
- * Optionally, defines loaders for custom specifications.
2266
+ * Hook fired before a pilet is loaded.
2135
2267
  */
2136
- loaders?: CustomSpecLoaders;
2268
+ loadPilet?(pilet: PiletMetadata): void;
2137
2269
  /**
2138
- * Gets the map of globally available dependencies with their names
2139
- * as keys and their evaluated pilet content as value.
2270
+ * Hook fired before a pilet is being set up.
2140
2271
  */
2141
- dependencies?: AvailableDependencies;
2272
+ setupPilet?(pilet: Pilet): void;
2142
2273
  /**
2143
- * Optionally, defines the loading strategy to use.
2274
+ * Hook fired before a pilet is being cleaned up.
2144
2275
  */
2145
- strategy?: PiletLoadingStrategy;
2276
+ cleanupPilet?(pilet: Pilet): void;
2277
+ }
2278
+
2279
+ /**
2280
+ * The record containing all available dependencies.
2281
+ */
2282
+ export interface AvailableDependencies {
2283
+ [name: string]: any;
2284
+ }
2285
+
2286
+ /**
2287
+ * The strategy for how pilets are loaded at runtime.
2288
+ */
2289
+ export interface PiletLoadingStrategy {
2290
+ (options: LoadPiletsOptions, pilets: PiletsLoaded): PromiseLike<void>;
2146
2291
  }
2147
2292
 
2148
2293
  export interface TileErrorInfoProps {
@@ -2230,62 +2375,96 @@ declare module "sample-piral" {
2230
2375
  pilet?: string;
2231
2376
  }
2232
2377
 
2233
- /**
2234
- * The creator function for the pilet API.
2235
- */
2236
- export interface PiletApiCreator {
2237
- (target: PiletMetadata): PiletApi;
2238
- }
2239
-
2240
- /**
2241
- * The interface describing a function capable of fetching pilets.
2242
- */
2243
- export interface PiletRequester {
2244
- (): Promise<Array<PiletMetadata>>;
2378
+ export interface FeedDataState {
2379
+ /**
2380
+ * Determines if the feed data is currently loading.
2381
+ */
2382
+ loading: boolean;
2383
+ /**
2384
+ * Indicates if the feed data was already loaded and is active.
2385
+ */
2386
+ loaded: boolean;
2387
+ /**
2388
+ * Stores the potential error when initializing or loading the feed.
2389
+ */
2390
+ error: any;
2391
+ /**
2392
+ * The currently stored feed data.
2393
+ */
2394
+ data: any;
2245
2395
  }
2246
2396
 
2247
2397
  /**
2248
- * Additional configuration options for the default loader.
2398
+ * Basic metadata for pilets using the v0 schema.
2249
2399
  */
2250
- export interface DefaultLoaderConfig {
2400
+ export interface PiletV0BaseEntry {
2251
2401
  /**
2252
- * Sets the cross-origin attribute of potential script tags.
2253
- * For pilets v1 this may be useful. Otherwise, only pilets that
2254
- * have an integrity defined will be set to "anonymous".
2402
+ * The name of the pilet, i.e., the package id.
2255
2403
  */
2256
- crossOrigin?: string;
2404
+ name: string;
2405
+ /**
2406
+ * The version of the pilet. Should be semantically versioned.
2407
+ */
2408
+ version: string;
2409
+ /**
2410
+ * Optionally provides the version of the specification for this pilet.
2411
+ */
2412
+ spec?: "v0";
2413
+ /**
2414
+ * The computed hash value of the pilet's content. Should be
2415
+ * accurate to allow caching.
2416
+ */
2417
+ hash: string;
2418
+ /**
2419
+ * Optionally provides some custom metadata for the pilet.
2420
+ */
2421
+ custom?: any;
2422
+ /**
2423
+ * Optionally provides some configuration to be used in the pilet.
2424
+ */
2425
+ config?: Record<string, any>;
2426
+ /**
2427
+ * Additional shared dependency script files.
2428
+ */
2429
+ dependencies?: Record<string, string>;
2257
2430
  }
2258
2431
 
2259
- /**
2260
- * The callback to be used to load a single pilet.
2261
- */
2262
- export interface PiletLoader {
2263
- (meta: PiletMetadata): Promise<Pilet>;
2264
- }
2432
+ export type SetState<T extends State> = {
2433
+ <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;
2434
+ };
2435
+
2436
+ export type GetState<T extends State> = () => T;
2437
+
2438
+ export type Subscribe<T extends State> = {
2439
+ (listener: StateListener<T>): () => void;
2440
+ <StateSlice>(listener: StateSliceListener<StateSlice>, selector?: StateSelector<T, StateSlice>, equalityFn?: EqualityChecker<StateSlice>): () => void;
2441
+ };
2442
+
2443
+ export type Destroy = () => void;
2265
2444
 
2266
2445
  /**
2267
- * Defines the spec identifiers for custom loading.
2446
+ * The entries representing pilets from a feed service response.
2268
2447
  */
2269
- export type CustomSpecLoaders = Record<string, PiletLoader>;
2448
+ export type PiletEntries = Array<PiletEntry>;
2270
2449
 
2271
2450
  /**
2272
- * The record containing all available dependencies.
2451
+ * The callback to be used when pilets have been loaded.
2273
2452
  */
2274
- export interface AvailableDependencies {
2275
- [name: string]: any;
2453
+ export interface PiletsLoaded {
2454
+ (error: Error | undefined, pilets: Array<Pilet>): void;
2276
2455
  }
2277
2456
 
2278
2457
  /**
2279
- * The strategy for how pilets are loaded at runtime.
2458
+ * @deprecated Use the builtin `Partial<T>` instead of `PartialState<T>`.
2459
+ * Additionally turn on `--exactOptionalPropertyTypes` tsc flag.
2460
+ * `PartialState` will be removed in next major
2280
2461
  */
2281
- export interface PiletLoadingStrategy {
2282
- (options: LoadPiletsOptions, pilets: PiletsLoaded): PromiseLike<void>;
2283
- }
2462
+ 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);
2463
+
2464
+ export type StateListener<T> = (state: T, previousState: T) => void;
2284
2465
 
2285
2466
  /**
2286
- * The callback to be used when pilets have been loaded.
2467
+ * @deprecated Use `StateListener<T>` instead of `StateSliceListener<T>`.
2287
2468
  */
2288
- export interface PiletsLoaded {
2289
- (error: Error | undefined, pilets: Array<Pilet>): void;
2290
- }
2469
+ export type StateSliceListener<T> = (slice: T, previousSlice: T) => void;
2291
2470
  }