sample-cross-fx 0.14.5-beta.3336 → 0.14.5-beta.3347

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
@@ -1200,6 +1200,7 @@ declare module "sample-cross-fx" {
1200
1200
  export interface ComponentContext {
1201
1201
  router: ReactRouter.RouteComponentProps;
1202
1202
  state: LibreAtom.Atom<GlobalState>;
1203
+ readState: PiralActions["readState"];
1203
1204
  }
1204
1205
 
1205
1206
  /**
@@ -1279,6 +1280,138 @@ declare module "sample-cross-fx" {
1279
1280
  provider?: React.ComponentType;
1280
1281
  }
1281
1282
 
1283
+ /**
1284
+ * The globally defined actions.
1285
+ */
1286
+ export interface PiralActions extends PiralCustomActions {
1287
+ /**
1288
+ * Initializes the application shell.
1289
+ * @param loading The current loading state.
1290
+ * @param error The application error, if any.
1291
+ * @param modules The loaded pilets.
1292
+ */
1293
+ initialize(loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
1294
+ /**
1295
+ * Injects a pilet at runtime - removes the pilet from registry first if available.
1296
+ * @param pilet The pilet to be injected.
1297
+ */
1298
+ injectPilet(pilet: Pilet): void;
1299
+ /**
1300
+ * Defines a single action for Piral.
1301
+ * @param actionName The name of the action to define.
1302
+ * @param action The action to include.
1303
+ */
1304
+ defineAction<T extends keyof PiralActions>(actionName: T, action: PiralAction<PiralActions[T]>): void;
1305
+ /**
1306
+ * Defines a set of actions for Piral.
1307
+ * @param actions The actions to define.
1308
+ */
1309
+ defineActions(actions: PiralDefineActions): void;
1310
+ /**
1311
+ * Reads the value of a shared data item.
1312
+ * @param name The name of the shared item.
1313
+ */
1314
+ readDataValue(name: string): any;
1315
+ /**
1316
+ * Tries to write a shared data item. The write access is only
1317
+ * possible if the name belongs to the provided owner or has not
1318
+ * been taken yet.
1319
+ * Setting the value to null will release it.
1320
+ * @param name The name of the shared data item.
1321
+ * @param value The value of the shared data item.
1322
+ * @param owner The owner of the shared data item.
1323
+ * @param target The target storage locatation.
1324
+ * @param expiration The time for when to dispose the shared item.
1325
+ */
1326
+ tryWriteDataItem(name: string, value: any, owner: string, target: DataStoreTarget, expiration: number): boolean;
1327
+ /**
1328
+ * Performs a layout change.
1329
+ * @param current The layout to take.
1330
+ */
1331
+ changeLayout(current: LayoutType): void;
1332
+ /**
1333
+ * Registers a new route to be resolved.
1334
+ * @param route The route to register.
1335
+ * @param value The page to be rendered on the route.
1336
+ */
1337
+ registerPage(route: string, value: PageRegistration): void;
1338
+ /**
1339
+ * Unregisters an existing route.
1340
+ * @param route The route to be removed.
1341
+ */
1342
+ unregisterPage(route: string): void;
1343
+ /**
1344
+ * Registers a new extension.
1345
+ * @param name The name of the extension category.
1346
+ * @param value The extension registration.
1347
+ */
1348
+ registerExtension(name: string, value: ExtensionRegistration): void;
1349
+ /**
1350
+ * Unregisters an existing extension.
1351
+ * @param name The name of the extension category.
1352
+ * @param value The extension that will be removed.
1353
+ */
1354
+ unregisterExtension(name: string, reference: any): void;
1355
+ /**
1356
+ * Sets the common component to render.
1357
+ * @param name The name of the component.
1358
+ * @param component The component to use for rendering.
1359
+ */
1360
+ setComponent<TKey extends keyof ComponentsState>(name: TKey, component: ComponentsState[TKey]): void;
1361
+ /**
1362
+ * Sets the error component to render.
1363
+ * @param type The type of the error.
1364
+ * @param component The component to use for rendering.
1365
+ */
1366
+ setErrorComponent<TKey extends keyof ErrorComponentsState>(type: TKey, component: ErrorComponentsState[TKey]): void;
1367
+ /**
1368
+ * Sets the common routes to render.
1369
+ * @param path The name of the component.
1370
+ * @param component The component to use for rendering.
1371
+ */
1372
+ setRoute<T = {}>(path: string, component: React.ComponentType<ReactRouter.RouteComponentProps<T>>): void;
1373
+ /**
1374
+ * Includes a new provider as a sub-provider to the current provider.
1375
+ * @param provider The provider to include.
1376
+ */
1377
+ includeProvider(provider: JSX.Element): void;
1378
+ /**
1379
+ * Destroys (i.e., resets) the given portal instance.
1380
+ * @param id The id of the portal to destroy.
1381
+ */
1382
+ destroyPortal(id: string): void;
1383
+ /**
1384
+ * Includes the provided portal in the rendering pipeline.
1385
+ * @param id The id of the portal to use.
1386
+ * @param entry The child to render.
1387
+ */
1388
+ showPortal(id: string, entry: React.ReactPortal): void;
1389
+ /**
1390
+ * Hides the provided portal in the rendering pipeline.
1391
+ * @param id The id of the portal to use.
1392
+ * @param entry The child to remove.
1393
+ */
1394
+ hidePortal(id: string, entry: React.ReactPortal): void;
1395
+ /**
1396
+ * Updates the provided portal in the rendering pipeline.
1397
+ * @param id The id of the portal to use.
1398
+ * @param current The currently displayed child.
1399
+ * @param next The updated child that should be displayed.
1400
+ */
1401
+ updatePortal(id: string, current: React.ReactPortal, next: React.ReactPortal): void;
1402
+ /**
1403
+ * Dispatches a state change.
1404
+ * @param update The update function creating a new state.
1405
+ */
1406
+ dispatch(update: (state: GlobalState) => GlobalState): void;
1407
+ /**
1408
+ * Reads the selected part of the global state.
1409
+ * @param select The selector for getting the desired part.
1410
+ * @returns The desired part.
1411
+ */
1412
+ readState<S>(select: (state: GlobalState) => S): S;
1413
+ }
1414
+
1282
1415
  /**
1283
1416
  * Custom state extensions defined outside of piral-core.
1284
1417
  */
@@ -1302,6 +1435,10 @@ declare module "sample-cross-fx" {
1302
1435
  * Gets an unrecoverable application error, if any.
1303
1436
  */
1304
1437
  error: Error | undefined;
1438
+ /**
1439
+ * Gets the public path of the application.
1440
+ */
1441
+ publicPath: string;
1305
1442
  }
1306
1443
 
1307
1444
  export type ErrorComponentsState = {
@@ -1376,11 +1513,64 @@ declare module "sample-cross-fx" {
1376
1513
  expires: number;
1377
1514
  }
1378
1515
 
1516
+ /**
1517
+ * Custom actions defined outside of piral-core.
1518
+ */
1519
+ export interface PiralCustomActions {
1520
+ /**
1521
+ * Registers a new tile.
1522
+ * @param name The name of the tile.
1523
+ * @param value The tile registration.
1524
+ */
1525
+ registerTile(name: string, value: TileRegistration): void;
1526
+ /**
1527
+ * Unregisters an existing tile.
1528
+ * @param name The name of the tile to be removed.
1529
+ */
1530
+ unregisterTile(name: string): void;
1531
+ }
1532
+
1533
+ /**
1534
+ * An evaluated pilet, i.e., a full pilet: functionality and metadata.
1535
+ */
1536
+ export type Pilet = SinglePilet | MultiPilet;
1537
+
1538
+ /**
1539
+ * The shape of an app action in Piral.
1540
+ */
1541
+ export interface PiralAction<T extends (...args: any) => any> {
1542
+ (ctx: GlobalStateContext, ...args: Parameters<T>): ReturnType<T>;
1543
+ }
1544
+
1545
+ /**
1546
+ * A subset of the available app actions in Piral.
1547
+ */
1548
+ export type PiralDefineActions = Partial<{
1549
+ [P in keyof PiralActions]: PiralAction<PiralActions[P]>;
1550
+ }>;
1551
+
1379
1552
  /**
1380
1553
  * The different known layout types.
1381
1554
  */
1382
1555
  export type LayoutType = "mobile" | "tablet" | "desktop";
1383
1556
 
1557
+ /**
1558
+ * The interface modeling the registration of a pilet page component.
1559
+ */
1560
+ export interface PageRegistration extends BaseRegistration {
1561
+ component: WrappedComponent<PageComponentProps>;
1562
+ meta: PiralPageMeta;
1563
+ }
1564
+
1565
+ /**
1566
+ * The interface modeling the registration of a pilet extension component.
1567
+ */
1568
+ export interface ExtensionRegistration extends BaseRegistration {
1569
+ component: WrappedComponent<ExtensionComponentProps<string>>;
1570
+ reference: any;
1571
+ defaults: any;
1572
+ }
1573
+
1384
1574
  /**
1385
1575
  * Map of all error types to their respective props.
1386
1576
  */
@@ -1456,23 +1646,53 @@ declare module "sample-cross-fx" {
1456
1646
  tiles: Dict<TileRegistration>;
1457
1647
  }
1458
1648
 
1649
+ export interface TileRegistration extends BaseRegistration {
1650
+ component: WrappedComponent<TileComponentProps>;
1651
+ preferences: TilePreferences;
1652
+ }
1653
+
1459
1654
  /**
1460
- * The interface modeling the registration of a pilet page component.
1655
+ * An evaluated single pilet.
1461
1656
  */
1462
- export interface PageRegistration extends BaseRegistration {
1463
- component: WrappedComponent<PageComponentProps>;
1464
- meta: PiralPageMeta;
1657
+ export type SinglePilet = SinglePiletApp & SinglePiletMetadata;
1658
+
1659
+ /**
1660
+ * An evaluated multi pilet.
1661
+ */
1662
+ export type MultiPilet = MultiPiletApp & MultiPiletMetadata;
1663
+
1664
+ /**
1665
+ * The Piral app instance context.
1666
+ */
1667
+ export interface GlobalStateContext extends PiralActions, EventEmitter {
1668
+ /**
1669
+ * The global state context atom.
1670
+ * Changes to the state should always be dispatched via the `dispatch` action.
1671
+ */
1672
+ state: LibreAtom.Atom<GlobalState>;
1673
+ /**
1674
+ * The API objects created for the loaded pilets.
1675
+ */
1676
+ apis: PiletsBag;
1677
+ /**
1678
+ * The available component converters.
1679
+ */
1680
+ converters: ComponentConverters<any>;
1681
+ /**
1682
+ * The initial options.
1683
+ */
1684
+ options: LoadPiletsOptions;
1465
1685
  }
1466
1686
 
1467
1687
  /**
1468
- * The interface modeling the registration of a pilet extension component.
1688
+ * The base type for pilet component registration in the global state context.
1469
1689
  */
1470
- export interface ExtensionRegistration extends BaseRegistration {
1471
- component: WrappedComponent<ExtensionComponentProps<string>>;
1472
- reference: any;
1473
- defaults: any;
1690
+ export interface BaseRegistration {
1691
+ pilet: string;
1474
1692
  }
1475
1693
 
1694
+ export type WrappedComponent<TProps> = React.ComponentType<Without<TProps, keyof BaseComponentProps>>;
1695
+
1476
1696
  /**
1477
1697
  * Custom errors defined outside of piral-core.
1478
1698
  */
@@ -1571,19 +1791,82 @@ declare module "sample-cross-fx" {
1571
1791
  [K in keyof T]: T[K];
1572
1792
  }[keyof T];
1573
1793
 
1574
- export interface TileRegistration extends BaseRegistration {
1575
- component: WrappedComponent<TileComponentProps>;
1576
- preferences: TilePreferences;
1794
+ /**
1795
+ * The pilet app, i.e., the functional exports.
1796
+ */
1797
+ export interface SinglePiletApp {
1798
+ /**
1799
+ * Integrates the evaluated pilet into the application.
1800
+ * @param api The API to access the application.
1801
+ */
1802
+ setup(api: PiletApi): void | Promise<void>;
1803
+ /**
1804
+ * Optional function for cleanup.
1805
+ * @param api The API to access the application.
1806
+ */
1807
+ teardown?(api: PiletApi): void;
1577
1808
  }
1578
1809
 
1579
1810
  /**
1580
- * The base type for pilet component registration in the global state context.
1811
+ * The pilet app, i.e., the functional exports.
1581
1812
  */
1582
- export interface BaseRegistration {
1583
- pilet: string;
1813
+ export interface MultiPiletApp {
1814
+ /**
1815
+ * Integrates the evaluated pilet into the application.
1816
+ * @param api The API to access the application.
1817
+ */
1818
+ setup(apiFactory: PiletApiCreator): void | Promise<void>;
1584
1819
  }
1585
1820
 
1586
- export type WrappedComponent<TProps> = React.ComponentType<Without<TProps, keyof BaseComponentProps>>;
1821
+ /**
1822
+ * Represents the dictionary of the loaded pilets and their APIs.
1823
+ */
1824
+ export interface PiletsBag {
1825
+ [name: string]: PiletApi;
1826
+ }
1827
+
1828
+ /**
1829
+ * The options for loading pilets.
1830
+ */
1831
+ export interface LoadPiletsOptions {
1832
+ /**
1833
+ * The callback function for creating an API object.
1834
+ * The API object is passed on to a specific pilet.
1835
+ */
1836
+ createApi: PiletApiCreator;
1837
+ /**
1838
+ * The callback for fetching the dynamic pilets.
1839
+ */
1840
+ fetchPilets: PiletRequester;
1841
+ /**
1842
+ * Optionally, some already existing evaluated pilets, e.g.,
1843
+ * helpful when debugging or in SSR scenarios.
1844
+ */
1845
+ pilets?: Array<Pilet>;
1846
+ /**
1847
+ * Optionally, configures the default loader.
1848
+ */
1849
+ config?: DefaultLoaderConfig;
1850
+ /**
1851
+ * Optionally, defines the default way how to load a pilet.
1852
+ */
1853
+ loadPilet?: PiletLoader;
1854
+ /**
1855
+ * Optionally, defines loaders for custom specifications.
1856
+ */
1857
+ loaders?: CustomSpecLoaders;
1858
+ /**
1859
+ * Gets the map of globally available dependencies with their names
1860
+ * as keys and their evaluated pilet content as value.
1861
+ */
1862
+ dependencies?: AvailableDependencies;
1863
+ /**
1864
+ * Optionally, defines the loading strategy to use.
1865
+ */
1866
+ strategy?: PiletLoadingStrategy;
1867
+ }
1868
+
1869
+ export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
1587
1870
 
1588
1871
  export interface TileErrorInfoProps {
1589
1872
  /**
@@ -1604,5 +1887,62 @@ declare module "sample-cross-fx" {
1604
1887
  rows: number;
1605
1888
  }
1606
1889
 
1607
- export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
1890
+ /**
1891
+ * The creator function for the pilet API.
1892
+ */
1893
+ export interface PiletApiCreator {
1894
+ (target: PiletMetadata): PiletApi;
1895
+ }
1896
+
1897
+ /**
1898
+ * The interface describing a function capable of fetching pilets.
1899
+ */
1900
+ export interface PiletRequester {
1901
+ (): Promise<Array<PiletMetadata>>;
1902
+ }
1903
+
1904
+ /**
1905
+ * Additional configuration options for the default loader.
1906
+ */
1907
+ export interface DefaultLoaderConfig {
1908
+ /**
1909
+ * Sets the cross-origin attribute of potential script tags.
1910
+ * For pilets v1 this may be useful. Otherwise, only pilets that
1911
+ * have an integrity defined will be set to "anonymous".
1912
+ */
1913
+ crossOrigin?: string;
1914
+ }
1915
+
1916
+ /**
1917
+ * The callback to be used to load a single pilet.
1918
+ */
1919
+ export interface PiletLoader {
1920
+ (meta: PiletMetadata): Promise<Pilet>;
1921
+ }
1922
+
1923
+ /**
1924
+ * Defines the spec identifiers for custom loading.
1925
+ */
1926
+ export type CustomSpecLoaders = Record<string, PiletLoader>;
1927
+
1928
+ /**
1929
+ * The record containing all available dependencies.
1930
+ */
1931
+ export interface AvailableDependencies {
1932
+ [name: string]: any;
1933
+ }
1934
+
1935
+ /**
1936
+ * The strategy for how pilets are loaded at runtime.
1937
+ */
1938
+ export interface PiletLoadingStrategy {
1939
+ (options: LoadPiletsOptions, pilets: PiletsLoaded): PromiseLike<void>;
1940
+ }
1941
+
1942
+ /**
1943
+ * The callback to be used when pilets have been loaded.
1944
+ */
1945
+ export interface PiletsLoaded {
1946
+ (error: Error | undefined, pilets: Array<Pilet>): void;
1947
+ }
1608
1948
  }
package/app/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <title>Sample - Cross Framework with Piral</title>
6
6
  <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
7
7
 
8
- <script defer src="/index.7f31c7.js"></script></head>
8
+ <script defer src="/index.201640.js"></script></head>
9
9
  <body>
10
10
  <div id="app"></div>
11
11
 
package/app/index.js CHANGED
@@ -2,7 +2,7 @@ if (process.env.NODE_ENV === 'test') {
2
2
  // behavior for the test environment, we'll try to make it work
3
3
 
4
4
  if (typeof window !== 'undefined') {
5
- require('.//index.7f31c7.js');
5
+ require('.//index.201640.js');
6
6
  const ctx = window['dbg:piral'];
7
7
  const dependencies = (ctx && ctx.pilets && ctx.pilets.getDependencies({})) || {};
8
8
  module.exports = dependencies['sample-cross-fx'] || {};
package/files.tar CHANGED
Binary file
package/files_once.tar CHANGED
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sample-cross-fx",
3
3
  "description": "Example project illustrating the mixing of different (opt-in) frameworks via plugins.",
4
- "version": "0.14.5-beta.3336",
4
+ "version": "0.14.5-beta.3347",
5
5
  "license": "MIT",
6
6
  "homepage": "https://piral.io",
7
7
  "keywords": [