piral-core 0.15.0-beta.4512 → 0.15.0-beta.4560
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.codegen +12 -2
- package/app.codegen.d.ts +5 -0
- package/esm/Piral.js +2 -8
- package/esm/Piral.js.map +1 -1
- package/esm/components/wrapComponent.js +2 -2
- package/esm/components/wrapComponent.js.map +1 -1
- package/esm/defaults/DefaultRouter_v5.js +1 -3
- package/esm/defaults/DefaultRouter_v5.js.map +1 -1
- package/esm/defaults/DefaultRouter_v6.js +1 -3
- package/esm/defaults/DefaultRouter_v6.js.map +1 -1
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -1
- package/esm/index.js.map +1 -1
- package/esm/setters/SetRedirect.js +2 -3
- package/esm/setters/SetRedirect.js.map +1 -1
- package/esm/types/components.d.ts +4 -0
- package/esm/types/state.d.ts +0 -4
- package/lib/Piral.js +2 -8
- package/lib/Piral.js.map +1 -1
- package/lib/components/wrapComponent.js +3 -3
- package/lib/components/wrapComponent.js.map +1 -1
- package/lib/defaults/DefaultRouter_v5.js +1 -3
- package/lib/defaults/DefaultRouter_v5.js.map +1 -1
- package/lib/defaults/DefaultRouter_v6.js +1 -3
- package/lib/defaults/DefaultRouter_v6.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/setters/SetRedirect.js +2 -3
- package/lib/setters/SetRedirect.js.map +1 -1
- package/lib/types/components.d.ts +4 -0
- package/lib/types/state.d.ts +0 -4
- package/package.json +4 -4
- package/src/Piral.tsx +3 -11
- package/src/components/wrapComponent.tsx +2 -2
- package/src/defaults/DefaultRouter_v5.tsx +1 -3
- package/src/defaults/DefaultRouter_v6.tsx +1 -3
- package/src/index.tsx +2 -1
- package/src/setters/SetRedirect.tsx +2 -2
- package/src/state/createGlobalState.test.ts +0 -8
- package/src/state/withApi.test.tsx +1 -3
- package/src/types/components.ts +4 -0
- package/src/types/state.ts +0 -4
package/app.codegen
CHANGED
|
@@ -187,13 +187,16 @@ function createDefaultState(imports, exports) {
|
|
|
187
187
|
`);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
exports.push(`
|
|
191
|
+
export const publicPath = ${JSON.stringify(publicPath)};
|
|
192
|
+
`);
|
|
193
|
+
|
|
190
194
|
exports.push(`
|
|
191
195
|
export function createDefaultState() {
|
|
192
196
|
return {
|
|
193
197
|
app: {
|
|
194
198
|
error: undefined,
|
|
195
199
|
loading: typeof window !== 'undefined',
|
|
196
|
-
publicPath: ${JSON.stringify(publicPath)},
|
|
197
200
|
},
|
|
198
201
|
components: {
|
|
199
202
|
ErrorInfo: DefaultErrorInfo,
|
|
@@ -239,7 +242,8 @@ function createRouteHandler(imports, exports) {
|
|
|
239
242
|
const assignments = [];
|
|
240
243
|
|
|
241
244
|
imports.push(
|
|
242
|
-
`import { useContext, useEffect } from 'react';`,
|
|
245
|
+
`import { useContext, useEffect, createElement } from 'react';`,
|
|
246
|
+
`import { Redirect } from 'react-router';`,
|
|
243
247
|
`import { useGlobalStateContext } from 'piral-core/${cat}/hooks/globalState';`,
|
|
244
248
|
);
|
|
245
249
|
|
|
@@ -254,6 +258,12 @@ function createRouteHandler(imports, exports) {
|
|
|
254
258
|
assignments.push('return paths;');
|
|
255
259
|
}
|
|
256
260
|
|
|
261
|
+
exports.push(`
|
|
262
|
+
export function createRedirect(to) {
|
|
263
|
+
return () => createElement(Redirect, { to });
|
|
264
|
+
}
|
|
265
|
+
`);
|
|
266
|
+
|
|
257
267
|
exports.push(`
|
|
258
268
|
export function useRouterContext() {
|
|
259
269
|
return useContext(RouterContext);
|
package/app.codegen.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { LoadPiletsOptions } from 'prial-base';
|
|
2
2
|
import type { DebuggerExtensionOptions } from 'piral-debug-utils';
|
|
3
|
+
import type { ComponentType } from 'react';
|
|
3
4
|
import type { RouteComponentProps } from 'react-router';
|
|
4
5
|
import type { AppPath, GlobalState, GlobalStateContext, NavigationApi } from './src/types';
|
|
5
6
|
|
|
7
|
+
export const publicPath: string;
|
|
8
|
+
|
|
6
9
|
export function createNavigation(): NavigationApi;
|
|
7
10
|
|
|
8
11
|
export function createDefaultState(): GlobalState;
|
|
9
12
|
|
|
13
|
+
export function createRedirect(to: string): ComponentType<RouteComponentProps>;
|
|
14
|
+
|
|
10
15
|
export function fillDependencies(deps: Record<string, any>): void;
|
|
11
16
|
|
|
12
17
|
export function useRouteFilter(paths: Array<AppPath>): Array<AppPath>;
|
package/esm/Piral.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { StaticRouter } from 'react-router';
|
|
3
2
|
import { createInstance } from './createInstance';
|
|
4
3
|
import { PiralView, RegisteredRouter } from './components';
|
|
5
|
-
import { useGlobalState } from './hooks';
|
|
6
4
|
import { PiralContext } from './PiralContext';
|
|
7
|
-
|
|
8
|
-
const publicPath = useGlobalState((s) => s.app.publicPath);
|
|
9
|
-
return React.createElement(StaticRouter, Object.assign({ location: "/" }, props, { basename: publicPath }));
|
|
10
|
-
};
|
|
11
|
-
const Router = typeof window === 'undefined' ? FallbackRouter : RegisteredRouter;
|
|
5
|
+
import { publicPath } from '../app.codegen';
|
|
12
6
|
/**
|
|
13
7
|
* Represents the Piral app shell frame. Use this component together
|
|
14
8
|
* with an existing instance to render the app shell.
|
|
@@ -25,7 +19,7 @@ const app = (
|
|
|
25
19
|
```
|
|
26
20
|
*/
|
|
27
21
|
export const Piral = ({ instance = createInstance(), breakpoints, children }) => (React.createElement(PiralContext, { instance: instance },
|
|
28
|
-
React.createElement(
|
|
22
|
+
React.createElement(RegisteredRouter, { publicPath: publicPath },
|
|
29
23
|
React.createElement(PiralView, { breakpoints: breakpoints }, children))));
|
|
30
24
|
Piral.displayName = 'Piral';
|
|
31
25
|
//# sourceMappingURL=Piral.js.map
|
package/esm/Piral.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Piral.js","sourceRoot":"","sources":["../src/Piral.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Piral.js","sourceRoot":"","sources":["../src/Piral.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,KAAK,GAAyB,CAAC,EAAE,QAAQ,GAAG,cAAc,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CACrG,oBAAC,YAAY,IAAC,QAAQ,EAAE,QAAQ;IAC9B,oBAAC,gBAAgB,IAAC,UAAU,EAAE,UAAU;QACtC,oBAAC,SAAS,IAAC,WAAW,EAAE,WAAW,IAAG,QAAQ,CAAa,CAC1C,CACN,CAChB,CAAC;AACF,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { PortalRenderer } from './PortalRenderer';
|
|
|
3
3
|
import { ForeignComponentContainer } from './ForeignComponentContainer';
|
|
4
4
|
import { useGlobalStateContext } from '../hooks';
|
|
5
5
|
import { convertComponent, none } from '../utils';
|
|
6
|
+
import { publicPath } from '../../app.codegen';
|
|
6
7
|
// this is an arbitrary start number to have 6 digits
|
|
7
8
|
let portalIdBase = 123456;
|
|
8
9
|
function wrapReactComponent(Component, captured, Wrapper) {
|
|
@@ -11,8 +12,7 @@ function wrapReactComponent(Component, captured, Wrapper) {
|
|
|
11
12
|
}
|
|
12
13
|
function wrapForeignComponent(component, captured, Wrapper) {
|
|
13
14
|
return React.memo((props) => {
|
|
14
|
-
const {
|
|
15
|
-
const publicPath = readState(s => s.app.publicPath);
|
|
15
|
+
const { destroyPortal, navigation } = useGlobalStateContext();
|
|
16
16
|
const id = React.useMemo(() => (portalIdBase++).toString(26), none);
|
|
17
17
|
const context = React.useMemo(() => ({ publicPath, navigation }), []);
|
|
18
18
|
const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), captured)), [props]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapComponent.js","sourceRoot":"","sources":["../../src/components/wrapComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"wrapComponent.js","sourceRoot":"","sources":["../../src/components/wrapComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,qDAAqD;AACrD,IAAI,YAAY,GAAG,MAAM,CAAC;AAM1B,SAAS,kBAAkB,CACzB,SAAsD,EACtD,QAAuB,EACvB,OAAoB;IAEpB,OAAO,CAAC,KAAQ,EAAE,EAAE,CAAC,CACnB,oBAAC,OAAO,oBAAK,KAAK;QAChB,oBAAC,SAAS,oBAAK,KAAK,EAAM,QAAQ,EAAI,CAC9B,CACX,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,SAAmD,EACnD,QAAuB,EACvB,OAAoB;IAEpB,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,KAAQ,EAAE,EAAE;QAC7B,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,qBAAqB,EAAE,CAAC;QAC9D,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QACpE,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACtE,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,iCAAM,KAAK,GAAK,QAAQ,EAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QAE7E,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAErD,OAAO,CACL,oBAAC,OAAO,oBAAK,KAAK;YAChB,oBAAC,cAAc,IAAC,EAAE,EAAE,EAAE,GAAI;YAC1B,oBAAC,yBAAyB,IAAC,UAAU,EAAE,UAAU,eAAa,EAAE,gBAAc,SAAS,cAAY,OAAO,GAAI,CACtG,CACX,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,SAAc;IACjC,OAAO,CAAE,SAAmC,CAAC,QAAQ,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,UAAuD,EACvD,SAA+C,EAC/C,QAAuB,EACvB,OAAoB;IAEpB,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QACvC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,6CAA6C,CAAC,CAAC;QACtE,2CAA2C;QAC3C,SAAS,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;KACxB;IAED,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE;QAC3D,MAAM,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;QACvE,OAAO,oBAAoB,CAAI,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC3D;IAED,OAAO,kBAAkB,CAAI,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BrowserRouter } from 'react-router-dom';
|
|
3
|
-
|
|
4
|
-
export const DefaultRouter = ({ children }) => {
|
|
5
|
-
const publicPath = useGlobalState((s) => s.app.publicPath);
|
|
3
|
+
export const DefaultRouter = ({ children, publicPath }) => {
|
|
6
4
|
return React.createElement(BrowserRouter, { basename: publicPath }, children);
|
|
7
5
|
};
|
|
8
6
|
DefaultRouter.displayName = 'DefaultRouter';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultRouter_v5.js","sourceRoot":"","sources":["../../src/defaults/DefaultRouter_v5.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"DefaultRouter_v5.js","sourceRoot":"","sources":["../../src/defaults/DefaultRouter_v5.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,CAAC,MAAM,aAAa,GAA0B,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;IAC/E,OAAO,oBAAC,aAAa,IAAC,QAAQ,EAAE,UAAU,IAAG,QAAQ,CAAiB,CAAC;AACzE,CAAC,CAAC;AACF,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BrowserRouter } from 'react-router-dom';
|
|
3
|
-
|
|
4
|
-
export const DefaultRouter = ({ children }) => {
|
|
5
|
-
const publicPath = useGlobalState((s) => s.app.publicPath);
|
|
3
|
+
export const DefaultRouter = ({ children, publicPath }) => {
|
|
6
4
|
return React.createElement(BrowserRouter, { basename: publicPath }, children);
|
|
7
5
|
};
|
|
8
6
|
DefaultRouter.displayName = 'DefaultRouter';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultRouter_v6.js","sourceRoot":"","sources":["../../src/defaults/DefaultRouter_v6.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"DefaultRouter_v6.js","sourceRoot":"","sources":["../../src/defaults/DefaultRouter_v6.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,CAAC,MAAM,aAAa,GAA0B,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;IAC/E,OAAO,oBAAC,aAAa,IAAC,QAAQ,EAAE,UAAU,IAAG,QAAQ,CAAiB,CAAC;AACzE,CAAC,CAAC;AACF,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC"}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export * from './createInstance';
|
|
2
|
-
export * from './Piral';
|
|
3
2
|
export * from './helpers';
|
|
4
3
|
export * from './components';
|
|
5
4
|
export * from './hooks';
|
|
6
5
|
export * from './setters';
|
|
7
6
|
export * from './state';
|
|
8
7
|
export * from './utils';
|
|
8
|
+
export * from './Piral';
|
|
9
|
+
export * from './PiralContext';
|
|
9
10
|
export * from './types';
|
package/esm/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export * from './createInstance';
|
|
2
|
-
export * from './Piral';
|
|
3
2
|
export * from './helpers';
|
|
4
3
|
export * from './components';
|
|
5
4
|
export * from './hooks';
|
|
6
5
|
export * from './setters';
|
|
7
6
|
export * from './state';
|
|
8
7
|
export * from './utils';
|
|
8
|
+
export * from './Piral';
|
|
9
|
+
export * from './PiralContext';
|
|
9
10
|
export * from './types';
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Redirect } from 'react-router';
|
|
3
1
|
import { useGlobalStateContext, useSetter } from '../hooks';
|
|
2
|
+
import { createRedirect } from '../../app.codegen';
|
|
4
3
|
/**
|
|
5
4
|
* The component capable of setting a global redirect route at mounting.
|
|
6
5
|
*/
|
|
7
6
|
export function SetRedirect({ from, to }) {
|
|
8
7
|
const { setRoute } = useGlobalStateContext();
|
|
9
|
-
useSetter(() => setRoute(from, (
|
|
8
|
+
useSetter(() => setRoute(from, createRedirect(to)));
|
|
10
9
|
// tslint:disable-next-line:no-null-keyword
|
|
11
10
|
return null;
|
|
12
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetRedirect.js","sourceRoot":"","sources":["../../src/setters/SetRedirect.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SetRedirect.js","sourceRoot":"","sources":["../../src/setters/SetRedirect.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAgBnD;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,IAAI,EAAE,EAAE,EAAoB;IACxD,MAAM,EAAE,QAAQ,EAAE,GAAG,qBAAqB,EAAE,CAAC;IAC7C,SAAS,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACpD,2CAA2C;IAC3C,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -193,6 +193,10 @@ export interface RouterProps {
|
|
|
193
193
|
* The content to be rendered inside the router.
|
|
194
194
|
*/
|
|
195
195
|
children?: ReactNode;
|
|
196
|
+
/**
|
|
197
|
+
* The public path to use.
|
|
198
|
+
*/
|
|
199
|
+
publicPath: string;
|
|
196
200
|
}
|
|
197
201
|
/**
|
|
198
202
|
* Represents a path in the app registration.
|
package/esm/types/state.d.ts
CHANGED
|
@@ -94,10 +94,6 @@ export interface AppState {
|
|
|
94
94
|
* Gets an unrecoverable application error, if any.
|
|
95
95
|
*/
|
|
96
96
|
error: Error | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Gets the public path of the application.
|
|
99
|
-
*/
|
|
100
|
-
publicPath: string;
|
|
101
97
|
}
|
|
102
98
|
/**
|
|
103
99
|
* The Piral global app sub-state container for component registrations.
|
package/lib/Piral.js
CHANGED
|
@@ -2,16 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Piral = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
|
-
const react_router_1 = require("react-router");
|
|
6
5
|
const createInstance_1 = require("./createInstance");
|
|
7
6
|
const components_1 = require("./components");
|
|
8
|
-
const hooks_1 = require("./hooks");
|
|
9
7
|
const PiralContext_1 = require("./PiralContext");
|
|
10
|
-
const
|
|
11
|
-
const publicPath = (0, hooks_1.useGlobalState)((s) => s.app.publicPath);
|
|
12
|
-
return React.createElement(react_router_1.StaticRouter, Object.assign({ location: "/" }, props, { basename: publicPath }));
|
|
13
|
-
};
|
|
14
|
-
const Router = typeof window === 'undefined' ? FallbackRouter : components_1.RegisteredRouter;
|
|
8
|
+
const app_codegen_1 = require("../app.codegen");
|
|
15
9
|
/**
|
|
16
10
|
* Represents the Piral app shell frame. Use this component together
|
|
17
11
|
* with an existing instance to render the app shell.
|
|
@@ -28,7 +22,7 @@ const app = (
|
|
|
28
22
|
```
|
|
29
23
|
*/
|
|
30
24
|
const Piral = ({ instance = (0, createInstance_1.createInstance)(), breakpoints, children }) => (React.createElement(PiralContext_1.PiralContext, { instance: instance },
|
|
31
|
-
React.createElement(
|
|
25
|
+
React.createElement(components_1.RegisteredRouter, { publicPath: app_codegen_1.publicPath },
|
|
32
26
|
React.createElement(components_1.PiralView, { breakpoints: breakpoints }, children))));
|
|
33
27
|
exports.Piral = Piral;
|
|
34
28
|
exports.Piral.displayName = 'Piral';
|
package/lib/Piral.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Piral.js","sourceRoot":"","sources":["../src/Piral.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B
|
|
1
|
+
{"version":3,"file":"Piral.js","sourceRoot":"","sources":["../src/Piral.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,qDAAkD;AAClD,6CAA2D;AAC3D,iDAA8C;AAC9C,gDAA4C;AAG5C;;;;;;;;;;;;;;GAcG;AACI,MAAM,KAAK,GAAyB,CAAC,EAAE,QAAQ,GAAG,IAAA,+BAAc,GAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CACrG,oBAAC,2BAAY,IAAC,QAAQ,EAAE,QAAQ;IAC9B,oBAAC,6BAAgB,IAAC,UAAU,EAAE,wBAAU;QACtC,oBAAC,sBAAS,IAAC,WAAW,EAAE,WAAW,IAAG,QAAQ,CAAa,CAC1C,CACN,CAChB,CAAC;AANW,QAAA,KAAK,SAMhB;AACF,aAAK,CAAC,WAAW,GAAG,OAAO,CAAC"}
|
|
@@ -6,6 +6,7 @@ const PortalRenderer_1 = require("./PortalRenderer");
|
|
|
6
6
|
const ForeignComponentContainer_1 = require("./ForeignComponentContainer");
|
|
7
7
|
const hooks_1 = require("../hooks");
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
|
+
const app_codegen_1 = require("../../app.codegen");
|
|
9
10
|
// this is an arbitrary start number to have 6 digits
|
|
10
11
|
let portalIdBase = 123456;
|
|
11
12
|
function wrapReactComponent(Component, captured, Wrapper) {
|
|
@@ -14,10 +15,9 @@ function wrapReactComponent(Component, captured, Wrapper) {
|
|
|
14
15
|
}
|
|
15
16
|
function wrapForeignComponent(component, captured, Wrapper) {
|
|
16
17
|
return React.memo((props) => {
|
|
17
|
-
const {
|
|
18
|
-
const publicPath = readState(s => s.app.publicPath);
|
|
18
|
+
const { destroyPortal, navigation } = (0, hooks_1.useGlobalStateContext)();
|
|
19
19
|
const id = React.useMemo(() => (portalIdBase++).toString(26), utils_1.none);
|
|
20
|
-
const context = React.useMemo(() => ({ publicPath, navigation }), []);
|
|
20
|
+
const context = React.useMemo(() => ({ publicPath: app_codegen_1.publicPath, navigation }), []);
|
|
21
21
|
const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), captured)), [props]);
|
|
22
22
|
React.useEffect(() => () => destroyPortal(id), utils_1.none);
|
|
23
23
|
return (React.createElement(Wrapper, Object.assign({}, props),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapComponent.js","sourceRoot":"","sources":["../../src/components/wrapComponent.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,qDAAkD;AAClD,2EAAwE;AACxE,oCAAiD;AACjD,oCAAkD;
|
|
1
|
+
{"version":3,"file":"wrapComponent.js","sourceRoot":"","sources":["../../src/components/wrapComponent.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,qDAAkD;AAClD,2EAAwE;AACxE,oCAAiD;AACjD,oCAAkD;AAClD,mDAA+C;AAG/C,qDAAqD;AACrD,IAAI,YAAY,GAAG,MAAM,CAAC;AAM1B,SAAS,kBAAkB,CACzB,SAAsD,EACtD,QAAuB,EACvB,OAAoB;IAEpB,OAAO,CAAC,KAAQ,EAAE,EAAE,CAAC,CACnB,oBAAC,OAAO,oBAAK,KAAK;QAChB,oBAAC,SAAS,oBAAK,KAAK,EAAM,QAAQ,EAAI,CAC9B,CACX,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,SAAmD,EACnD,QAAuB,EACvB,OAAoB;IAEpB,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,KAAQ,EAAE,EAAE;QAC7B,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,IAAA,6BAAqB,GAAE,CAAC;QAC9D,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,YAAI,CAAC,CAAC;QACpE,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,UAAU,EAAV,wBAAU,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACtE,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,iCAAM,KAAK,GAAK,QAAQ,EAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QAE7E,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,YAAI,CAAC,CAAC;QAErD,OAAO,CACL,oBAAC,OAAO,oBAAK,KAAK;YAChB,oBAAC,+BAAc,IAAC,EAAE,EAAE,EAAE,GAAI;YAC1B,oBAAC,qDAAyB,IAAC,UAAU,EAAE,UAAU,eAAa,EAAE,gBAAc,SAAS,cAAY,OAAO,GAAI,CACtG,CACX,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,SAAc;IACjC,OAAO,CAAE,SAAmC,CAAC,QAAQ,CAAC;AACxD,CAAC;AAED,SAAgB,aAAa,CAC3B,UAAuD,EACvD,SAA+C,EAC/C,QAAuB,EACvB,OAAoB;IAEpB,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QACvC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,6CAA6C,CAAC,CAAC;QACtE,2CAA2C;QAC3C,SAAS,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;KACxB;IAED,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE;QAC3D,MAAM,MAAM,GAAG,IAAA,wBAAgB,EAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;QACvE,OAAO,oBAAoB,CAAI,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC3D;IAED,OAAO,kBAAkB,CAAI,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC;AAnBD,sCAmBC"}
|
|
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DefaultRouter = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
-
const
|
|
7
|
-
const DefaultRouter = ({ children }) => {
|
|
8
|
-
const publicPath = (0, hooks_1.useGlobalState)((s) => s.app.publicPath);
|
|
6
|
+
const DefaultRouter = ({ children, publicPath }) => {
|
|
9
7
|
return React.createElement(react_router_dom_1.BrowserRouter, { basename: publicPath }, children);
|
|
10
8
|
};
|
|
11
9
|
exports.DefaultRouter = DefaultRouter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultRouter_v5.js","sourceRoot":"","sources":["../../src/defaults/DefaultRouter_v5.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,uDAAiD;
|
|
1
|
+
{"version":3,"file":"DefaultRouter_v5.js","sourceRoot":"","sources":["../../src/defaults/DefaultRouter_v5.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,uDAAiD;AAG1C,MAAM,aAAa,GAA0B,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;IAC/E,OAAO,oBAAC,gCAAa,IAAC,QAAQ,EAAE,UAAU,IAAG,QAAQ,CAAiB,CAAC;AACzE,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AACF,qBAAa,CAAC,WAAW,GAAG,eAAe,CAAC"}
|
|
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DefaultRouter = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
-
const
|
|
7
|
-
const DefaultRouter = ({ children }) => {
|
|
8
|
-
const publicPath = (0, hooks_1.useGlobalState)((s) => s.app.publicPath);
|
|
6
|
+
const DefaultRouter = ({ children, publicPath }) => {
|
|
9
7
|
return React.createElement(react_router_dom_1.BrowserRouter, { basename: publicPath }, children);
|
|
10
8
|
};
|
|
11
9
|
exports.DefaultRouter = DefaultRouter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultRouter_v6.js","sourceRoot":"","sources":["../../src/defaults/DefaultRouter_v6.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,uDAAiD;
|
|
1
|
+
{"version":3,"file":"DefaultRouter_v6.js","sourceRoot":"","sources":["../../src/defaults/DefaultRouter_v6.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,uDAAiD;AAG1C,MAAM,aAAa,GAA0B,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;IAC/E,OAAO,oBAAC,gCAAa,IAAC,QAAQ,EAAE,UAAU,IAAG,QAAQ,CAAiB,CAAC;AACzE,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AACF,qBAAa,CAAC,WAAW,GAAG,eAAe,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export * from './createInstance';
|
|
2
|
-
export * from './Piral';
|
|
3
2
|
export * from './helpers';
|
|
4
3
|
export * from './components';
|
|
5
4
|
export * from './hooks';
|
|
6
5
|
export * from './setters';
|
|
7
6
|
export * from './state';
|
|
8
7
|
export * from './utils';
|
|
8
|
+
export * from './Piral';
|
|
9
|
+
export * from './PiralContext';
|
|
9
10
|
export * from './types';
|
package/lib/index.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./createInstance"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./Piral"), exports);
|
|
6
5
|
tslib_1.__exportStar(require("./helpers"), exports);
|
|
7
6
|
tslib_1.__exportStar(require("./components"), exports);
|
|
8
7
|
tslib_1.__exportStar(require("./hooks"), exports);
|
|
9
8
|
tslib_1.__exportStar(require("./setters"), exports);
|
|
10
9
|
tslib_1.__exportStar(require("./state"), exports);
|
|
11
10
|
tslib_1.__exportStar(require("./utils"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./Piral"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./PiralContext"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./types"), exports);
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,oDAA0B;AAC1B,uDAA6B;AAC7B,kDAAwB;AACxB,oDAA0B;AAC1B,kDAAwB;AACxB,kDAAwB;AACxB,kDAAwB;AACxB,yDAA+B;AAC/B,kDAAwB"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SetRedirect = void 0;
|
|
4
|
-
const React = require("react");
|
|
5
|
-
const react_router_1 = require("react-router");
|
|
6
4
|
const hooks_1 = require("../hooks");
|
|
5
|
+
const app_codegen_1 = require("../../app.codegen");
|
|
7
6
|
/**
|
|
8
7
|
* The component capable of setting a global redirect route at mounting.
|
|
9
8
|
*/
|
|
10
9
|
function SetRedirect({ from, to }) {
|
|
11
10
|
const { setRoute } = (0, hooks_1.useGlobalStateContext)();
|
|
12
|
-
(0, hooks_1.useSetter)(() => setRoute(from, (
|
|
11
|
+
(0, hooks_1.useSetter)(() => setRoute(from, (0, app_codegen_1.createRedirect)(to)));
|
|
13
12
|
// tslint:disable-next-line:no-null-keyword
|
|
14
13
|
return null;
|
|
15
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SetRedirect.js","sourceRoot":"","sources":["../../src/setters/SetRedirect.tsx"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"SetRedirect.js","sourceRoot":"","sources":["../../src/setters/SetRedirect.tsx"],"names":[],"mappings":";;;AACA,oCAA4D;AAC5D,mDAAmD;AAgBnD;;GAEG;AACH,SAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,EAAE,EAAoB;IACxD,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,6BAAqB,GAAE,CAAC;IAC7C,IAAA,iBAAS,EAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAA,4BAAc,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACpD,2CAA2C;IAC3C,OAAO,IAAI,CAAC;AACd,CAAC;AALD,kCAKC"}
|
|
@@ -193,6 +193,10 @@ export interface RouterProps {
|
|
|
193
193
|
* The content to be rendered inside the router.
|
|
194
194
|
*/
|
|
195
195
|
children?: ReactNode;
|
|
196
|
+
/**
|
|
197
|
+
* The public path to use.
|
|
198
|
+
*/
|
|
199
|
+
publicPath: string;
|
|
196
200
|
}
|
|
197
201
|
/**
|
|
198
202
|
* Represents a path in the app registration.
|
package/lib/types/state.d.ts
CHANGED
|
@@ -94,10 +94,6 @@ export interface AppState {
|
|
|
94
94
|
* Gets an unrecoverable application error, if any.
|
|
95
95
|
*/
|
|
96
96
|
error: Error | undefined;
|
|
97
|
-
/**
|
|
98
|
-
* Gets the public path of the application.
|
|
99
|
-
*/
|
|
100
|
-
publicPath: string;
|
|
101
97
|
}
|
|
102
98
|
/**
|
|
103
99
|
* The Piral global app sub-state container for component registrations.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-core",
|
|
3
|
-
"version": "0.15.0-beta.
|
|
3
|
+
"version": "0.15.0-beta.4560",
|
|
4
4
|
"description": "The core library for creating a Piral instance.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"piral-base": "0.15.0-beta.
|
|
74
|
-
"piral-debug-utils": "0.15.0-beta.
|
|
73
|
+
"piral-base": "0.15.0-beta.4560",
|
|
74
|
+
"piral-debug-utils": "0.15.0-beta.4560",
|
|
75
75
|
"zustand": "^3.0.0"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"react-router-dom",
|
|
98
98
|
"tslib"
|
|
99
99
|
],
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "b4fa0e9b24f7b8e340dc3a32d0e37d21b3d26c3d"
|
|
101
101
|
}
|
package/src/Piral.tsx
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { StaticRouter } from 'react-router';
|
|
3
2
|
import { createInstance } from './createInstance';
|
|
4
3
|
import { PiralView, RegisteredRouter } from './components';
|
|
5
|
-
import { useGlobalState } from './hooks';
|
|
6
4
|
import { PiralContext } from './PiralContext';
|
|
5
|
+
import { publicPath } from '../app.codegen';
|
|
7
6
|
import type { PiralProps } from './types';
|
|
8
7
|
|
|
9
|
-
const FallbackRouter: React.FC = (props) => {
|
|
10
|
-
const publicPath = useGlobalState((s) => s.app.publicPath);
|
|
11
|
-
return <StaticRouter location="/" {...props} basename={publicPath} />;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const Router = typeof window === 'undefined' ? FallbackRouter : RegisteredRouter;
|
|
15
|
-
|
|
16
8
|
/**
|
|
17
9
|
* Represents the Piral app shell frame. Use this component together
|
|
18
10
|
* with an existing instance to render the app shell.
|
|
@@ -30,9 +22,9 @@ const app = (
|
|
|
30
22
|
*/
|
|
31
23
|
export const Piral: React.FC<PiralProps> = ({ instance = createInstance(), breakpoints, children }) => (
|
|
32
24
|
<PiralContext instance={instance}>
|
|
33
|
-
<
|
|
25
|
+
<RegisteredRouter publicPath={publicPath}>
|
|
34
26
|
<PiralView breakpoints={breakpoints}>{children}</PiralView>
|
|
35
|
-
</
|
|
27
|
+
</RegisteredRouter>
|
|
36
28
|
</PiralContext>
|
|
37
29
|
);
|
|
38
30
|
Piral.displayName = 'Piral';
|
|
@@ -3,6 +3,7 @@ import { PortalRenderer } from './PortalRenderer';
|
|
|
3
3
|
import { ForeignComponentContainer } from './ForeignComponentContainer';
|
|
4
4
|
import { useGlobalStateContext } from '../hooks';
|
|
5
5
|
import { convertComponent, none } from '../utils';
|
|
6
|
+
import { publicPath } from '../../app.codegen';
|
|
6
7
|
import type { AnyComponent, ComponentConverters, ForeignComponent, PiletApi, BaseComponentProps } from '../types';
|
|
7
8
|
|
|
8
9
|
// this is an arbitrary start number to have 6 digits
|
|
@@ -30,8 +31,7 @@ function wrapForeignComponent<T>(
|
|
|
30
31
|
Wrapper: React.FC<T>,
|
|
31
32
|
) {
|
|
32
33
|
return React.memo((props: T) => {
|
|
33
|
-
const {
|
|
34
|
-
const publicPath = readState(s => s.app.publicPath);
|
|
34
|
+
const { destroyPortal, navigation } = useGlobalStateContext();
|
|
35
35
|
const id = React.useMemo(() => (portalIdBase++).toString(26), none);
|
|
36
36
|
const context = React.useMemo(() => ({ publicPath, navigation }), []);
|
|
37
37
|
const innerProps = React.useMemo(() => ({ ...props, ...captured }), [props]);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BrowserRouter } from 'react-router-dom';
|
|
3
|
-
import { useGlobalState } from '../hooks';
|
|
4
3
|
import { RouterProps } from '../types';
|
|
5
4
|
|
|
6
|
-
export const DefaultRouter: React.FC<RouterProps> = ({ children }) => {
|
|
7
|
-
const publicPath = useGlobalState((s) => s.app.publicPath);
|
|
5
|
+
export const DefaultRouter: React.FC<RouterProps> = ({ children, publicPath }) => {
|
|
8
6
|
return <BrowserRouter basename={publicPath}>{children}</BrowserRouter>;
|
|
9
7
|
};
|
|
10
8
|
DefaultRouter.displayName = 'DefaultRouter';
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BrowserRouter } from 'react-router-dom';
|
|
3
|
-
import { useGlobalState } from '../hooks';
|
|
4
3
|
import { RouterProps } from '../types';
|
|
5
4
|
|
|
6
|
-
export const DefaultRouter: React.FC<RouterProps> = ({ children }) => {
|
|
7
|
-
const publicPath = useGlobalState((s) => s.app.publicPath);
|
|
5
|
+
export const DefaultRouter: React.FC<RouterProps> = ({ children, publicPath }) => {
|
|
8
6
|
return <BrowserRouter basename={publicPath}>{children}</BrowserRouter>;
|
|
9
7
|
};
|
|
10
8
|
DefaultRouter.displayName = 'DefaultRouter';
|
package/src/index.tsx
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export * from './createInstance';
|
|
2
|
-
export * from './Piral';
|
|
3
2
|
export * from './helpers';
|
|
4
3
|
export * from './components';
|
|
5
4
|
export * from './hooks';
|
|
6
5
|
export * from './setters';
|
|
7
6
|
export * from './state';
|
|
8
7
|
export * from './utils';
|
|
8
|
+
export * from './Piral';
|
|
9
|
+
export * from './PiralContext';
|
|
9
10
|
export * from './types';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Redirect } from 'react-router';
|
|
3
2
|
import { useGlobalStateContext, useSetter } from '../hooks';
|
|
3
|
+
import { createRedirect } from '../../app.codegen';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The props for the SetRedirect component.
|
|
@@ -21,7 +21,7 @@ export interface SetRedirectProps {
|
|
|
21
21
|
*/
|
|
22
22
|
export function SetRedirect({ from, to }: SetRedirectProps): React.ReactElement {
|
|
23
23
|
const { setRoute } = useGlobalStateContext();
|
|
24
|
-
useSetter(() => setRoute(from, (
|
|
24
|
+
useSetter(() => setRoute(from, createRedirect(to)));
|
|
25
25
|
// tslint:disable-next-line:no-null-keyword
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
@@ -15,7 +15,6 @@ describe('Create Global State Module', () => {
|
|
|
15
15
|
app: {
|
|
16
16
|
loading: true,
|
|
17
17
|
error: undefined,
|
|
18
|
-
publicPath: '/',
|
|
19
18
|
},
|
|
20
19
|
errorComponents: {},
|
|
21
20
|
components: {
|
|
@@ -43,7 +42,6 @@ describe('Create Global State Module', () => {
|
|
|
43
42
|
app: {
|
|
44
43
|
loading: true,
|
|
45
44
|
error: undefined,
|
|
46
|
-
publicPath: '/',
|
|
47
45
|
},
|
|
48
46
|
errorComponents: {},
|
|
49
47
|
components: {
|
|
@@ -75,7 +73,6 @@ describe('Create Global State Module', () => {
|
|
|
75
73
|
app: {
|
|
76
74
|
error: undefined,
|
|
77
75
|
loading: true,
|
|
78
|
-
publicPath: '/',
|
|
79
76
|
},
|
|
80
77
|
errorComponents: {},
|
|
81
78
|
components: {
|
|
@@ -103,7 +100,6 @@ describe('Create Global State Module', () => {
|
|
|
103
100
|
app: {
|
|
104
101
|
loading: true,
|
|
105
102
|
error: undefined,
|
|
106
|
-
publicPath: '/',
|
|
107
103
|
},
|
|
108
104
|
errorComponents: {},
|
|
109
105
|
components: {
|
|
@@ -133,7 +129,6 @@ describe('Create Global State Module', () => {
|
|
|
133
129
|
app: {
|
|
134
130
|
loading: true,
|
|
135
131
|
error: undefined,
|
|
136
|
-
publicPath: '/',
|
|
137
132
|
},
|
|
138
133
|
errorComponents: {},
|
|
139
134
|
components: {
|
|
@@ -163,7 +158,6 @@ describe('Create Global State Module', () => {
|
|
|
163
158
|
app: {
|
|
164
159
|
loading: true,
|
|
165
160
|
error: undefined,
|
|
166
|
-
publicPath: '/',
|
|
167
161
|
},
|
|
168
162
|
errorComponents: {},
|
|
169
163
|
components: {
|
|
@@ -197,7 +191,6 @@ describe('Create Global State Module', () => {
|
|
|
197
191
|
app: {
|
|
198
192
|
loading: true,
|
|
199
193
|
error: undefined,
|
|
200
|
-
publicPath: '/',
|
|
201
194
|
},
|
|
202
195
|
errorComponents: {},
|
|
203
196
|
components: {
|
|
@@ -232,7 +225,6 @@ describe('Create Global State Module', () => {
|
|
|
232
225
|
app: {
|
|
233
226
|
loading: false,
|
|
234
227
|
error: undefined,
|
|
235
|
-
publicPath: '/',
|
|
236
228
|
},
|
|
237
229
|
errorComponents: {},
|
|
238
230
|
components: {
|
package/src/types/components.ts
CHANGED
package/src/types/state.ts
CHANGED