piral-core 0.15.0-beta.4465 → 0.15.0-beta.4512

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.
Files changed (48) hide show
  1. package/app.codegen +108 -12
  2. package/app.codegen.d.ts +4 -4
  3. package/esm/actions/app.d.ts +0 -1
  4. package/esm/actions/app.js +0 -3
  5. package/esm/actions/app.js.map +1 -1
  6. package/esm/components/wrapComponent.js +3 -4
  7. package/esm/components/wrapComponent.js.map +1 -1
  8. package/esm/debugger.js +1 -1
  9. package/esm/debugger.js.map +1 -1
  10. package/esm/state/createActions.js +2 -1
  11. package/esm/state/createActions.js.map +1 -1
  12. package/esm/types/components.d.ts +3 -1
  13. package/esm/types/index.d.ts +1 -0
  14. package/esm/types/index.js +1 -0
  15. package/esm/types/index.js.map +1 -1
  16. package/esm/types/navigation.d.ts +81 -0
  17. package/esm/types/navigation.js +2 -0
  18. package/esm/types/navigation.js.map +1 -0
  19. package/esm/types/state.d.ts +5 -11
  20. package/lib/actions/app.d.ts +0 -1
  21. package/lib/actions/app.js +1 -5
  22. package/lib/actions/app.js.map +1 -1
  23. package/lib/components/wrapComponent.js +3 -4
  24. package/lib/components/wrapComponent.js.map +1 -1
  25. package/lib/debugger.js +1 -1
  26. package/lib/debugger.js.map +1 -1
  27. package/lib/state/createActions.js +2 -1
  28. package/lib/state/createActions.js.map +1 -1
  29. package/lib/types/components.d.ts +3 -1
  30. package/lib/types/index.d.ts +1 -0
  31. package/lib/types/index.js +1 -0
  32. package/lib/types/index.js.map +1 -1
  33. package/lib/types/navigation.d.ts +81 -0
  34. package/lib/types/navigation.js +3 -0
  35. package/lib/types/navigation.js.map +1 -0
  36. package/lib/types/state.d.ts +5 -11
  37. package/package.json +5 -8
  38. package/src/actions/app.ts +0 -4
  39. package/src/components/ExtensionSlot.test.tsx +3 -0
  40. package/src/components/wrapComponent.tsx +3 -4
  41. package/src/debugger.ts +1 -1
  42. package/src/state/createActions.test.ts +1 -1
  43. package/src/state/createActions.ts +2 -0
  44. package/src/state/withApi.test.tsx +3 -0
  45. package/src/types/components.ts +3 -1
  46. package/src/types/index.ts +1 -0
  47. package/src/types/navigation.ts +88 -0
  48. package/src/types/state.ts +6 -13
package/app.codegen CHANGED
@@ -68,9 +68,59 @@ function createDefaultState(imports, exports) {
68
68
  `import { __RouterContext as RouterContext } from 'react-router'`,
69
69
  );
70
70
  exports.push(`
71
- function useNavigate() {
71
+ function useCurrentNavigation() {
72
72
  const ctx = useRouterContext();
73
- return (...args) => ctx.history.push(...args);
73
+
74
+ useEffect(() => {
75
+ _nav = ctx.history;
76
+ return () => {
77
+ _nav = undefined;
78
+ };
79
+ }, []);
80
+ }
81
+ `);
82
+
83
+ exports.push(`
84
+ export function createNavigation() {
85
+ const enhance = info => ({
86
+ ...info,
87
+ location: {
88
+ get href() {
89
+ return _nav.createHref(info.location);
90
+ },
91
+ ...info.location,
92
+ },
93
+ });
94
+
95
+ return {
96
+ push(target, state) {
97
+ if (_nav) {
98
+ _nav.push(target, state);
99
+ }
100
+ },
101
+ replace(target, state) {
102
+ if (_nav) {
103
+ _nav.replace(target, state);
104
+ }
105
+ },
106
+ go(n) {
107
+ if (_nav) {
108
+ _nav.go(n);
109
+ }
110
+ },
111
+ block(blocker) {
112
+ if (!_nav) {
113
+ return _noop;
114
+ }
115
+ return _nav.block((location, action) => blocker(enhance({ location, action })));
116
+ },
117
+ listen(listener) {
118
+ if (!_nav) {
119
+ return _noop;
120
+ }
121
+ return _nav.listen((location, action) => listener(enhance({ location, action })));
122
+ },
123
+ };
74
124
  }
75
125
  `);
76
126
  } else {
@@ -80,9 +130,59 @@ function createDefaultState(imports, exports) {
80
130
  `import { UNSAFE_NavigationContext as RouterContext } from 'react-router'`,
81
131
  );
82
132
  exports.push(`
83
- function useNavigate() {
133
+ function useCurrentNavigation() {
84
134
  const ctx = useRouterContext();
85
- return (...args) => ctx.navigator.push(...args);
135
+
136
+ useEffect(() => {
137
+ _nav = ctx.navigator;
138
+ return () => {
139
+ _nav = undefined;
140
+ };
141
+ }, []);
142
+ }
143
+ `);
144
+
145
+ exports.push(`
146
+ export function createNavigation() {
147
+ const enhance = info => ({
148
+ ...info,
149
+ location: {
150
+ get href() {
151
+ return _nav.createHref(info.location);
152
+ },
153
+ ...info.location,
154
+ },
155
+ });
156
+
157
+ return {
158
+ push(target, state) {
159
+ if (_nav) {
160
+ _nav.push(target, state);
161
+ }
162
+ },
163
+ replace(target, state) {
164
+ if (_nav) {
165
+ _nav.replace(target, state);
166
+ }
167
+ },
168
+ go(n) {
169
+ if (_nav) {
170
+ _nav.go(n);
171
+ }
172
+ },
173
+ block(blocker) {
174
+ if (!_nav) {
175
+ return _noop;
176
+ }
177
+ return _nav.block(transition => blocker(enhance(transition)));
178
+ },
179
+ listen(listener) {
180
+ if (!_nav) {
181
+ return _noop;
182
+ }
183
+ return _nav.listen(update => listener(enhance(update)));
184
+ },
185
+ };
86
186
  }
87
187
  `);
88
188
  }
@@ -144,14 +244,7 @@ function createRouteHandler(imports, exports) {
144
244
  );
145
245
 
146
246
  assignments.push(`
147
- const stateContext = useGlobalStateContext();
148
- const navigate = useNavigate();
149
-
150
- useEffect(() => {
151
- const handler = ({ path, state }) => navigate(path, state);
152
- stateContext.on('navigate', handler);
153
- return () => stateContext.off('navigate', handler);
154
- }, []);
247
+ useCurrentNavigation();
155
248
  `);
156
249
 
157
250
  if (process.env.DEBUG_PILET) {
@@ -186,6 +279,9 @@ module.exports = function () {
186
279
  return `
187
280
  ${imports.join('\n')}
188
281
 
282
+ let _nav;
283
+ const _noop = () => {};
284
+
189
285
  ${exports.join('\n')}
190
286
  `;
191
287
  };
package/app.codegen.d.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  import type { LoadPiletsOptions } from 'prial-base';
2
2
  import type { DebuggerExtensionOptions } from 'piral-debug-utils';
3
3
  import type { RouteComponentProps } from 'react-router';
4
- import type { AppPath, GlobalState, GlobalStateContext } from './src/types';
4
+ import type { AppPath, GlobalState, GlobalStateContext, NavigationApi } from './src/types';
5
5
 
6
- export function fillDependencies(deps: Record<string, any>): void;
6
+ export function createNavigation(): NavigationApi;
7
7
 
8
8
  export function createDefaultState(): GlobalState;
9
9
 
10
- export function useRouteFilter(paths: Array<AppPath>): Array<AppPath>;
10
+ export function fillDependencies(deps: Record<string, any>): void;
11
11
 
12
- export function useRouterContext(): RouteComponentProps;
12
+ export function useRouteFilter(paths: Array<AppPath>): Array<AppPath>;
13
13
 
14
14
  export function integrateDebugger(
15
15
  context: GlobalStateContext,
@@ -2,7 +2,6 @@ import { ComponentType } from 'react';
2
2
  import { RouteComponentProps } from 'react-router';
3
3
  import { ComponentsState, ErrorComponentsState, GlobalStateContext, Pilet, PiletEntry } from '../types';
4
4
  export declare function initialize(ctx: GlobalStateContext, loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
5
- export declare function navigate(ctx: GlobalStateContext, path: string, state?: any): void;
6
5
  export declare function addPilet(ctx: GlobalStateContext, meta: PiletEntry): Promise<void>;
7
6
  export declare function removePilet(ctx: GlobalStateContext, name: string): Promise<void>;
8
7
  export declare function injectPilet(ctx: GlobalStateContext, pilet: Pilet): Pilet;
@@ -4,9 +4,6 @@ export function initialize(ctx, loading, error, modules) {
4
4
  ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { app: Object.assign(Object.assign({}, state.app), { error,
5
5
  loading }), modules })));
6
6
  }
7
- export function navigate(ctx, path, state) {
8
- ctx.emit('navigate', { path, state });
9
- }
10
7
  export function addPilet(ctx, meta) {
11
8
  return ctx.options
12
9
  .loadPilet(meta)
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/actions/app.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAWlG,MAAM,UAA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K,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,eAAe,EAAE,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,EAAE,SAAS,CAAC,IAChE,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,GAAuB,EACvB,IAAY,EACZ,SAAgD;IAEhD,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAuB,EAAE,QAAqB;IAC5E,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;AACvC,CAAC"}
@@ -3,7 +3,6 @@ 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 { useRouterContext } from '../../app.codegen';
7
6
  // this is an arbitrary start number to have 6 digits
8
7
  let portalIdBase = 123456;
9
8
  function wrapReactComponent(Component, captured, Wrapper) {
@@ -12,10 +11,10 @@ function wrapReactComponent(Component, captured, Wrapper) {
12
11
  }
13
12
  function wrapForeignComponent(component, captured, Wrapper) {
14
13
  return React.memo((props) => {
15
- const { state, readState, destroyPortal } = useGlobalStateContext();
16
- const router = useRouterContext();
14
+ const { readState, destroyPortal, navigation } = useGlobalStateContext();
15
+ const publicPath = readState(s => s.app.publicPath);
17
16
  const id = React.useMemo(() => (portalIdBase++).toString(26), none);
18
- const context = React.useMemo(() => ({ router, state, readState }), [router, state]);
17
+ const context = React.useMemo(() => ({ publicPath, navigation }), []);
19
18
  const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), captured)), [props]);
20
19
  React.useEffect(() => () => destroyPortal(id), none);
21
20
  return (React.createElement(Wrapper, Object.assign({}, props),
@@ -1 +1 @@
1
- {"version":3,"file":"wrapComponent.js","sourceRoot":"","sources":["../../src/components/wrapComponent.ts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AC,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"}
package/esm/debugger.js CHANGED
@@ -30,7 +30,7 @@ export function integrateDebugger(context, options, debug = {}) {
30
30
  return context.readState((s) => s);
31
31
  },
32
32
  navigate(path, state) {
33
- return context.navigate(path, state);
33
+ return context.navigation.push(path, state);
34
34
  },
35
35
  getPilets() {
36
36
  return context.readState((s) => s.modules);
@@ -1 +1 @@
1
- {"version":3,"file":"debugger.js","sourceRoot":"","sources":["../src/debugger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAA4B,MAAM,mBAAmB,CAAC;AAGhF,MAAM,UAAU,iBAAiB,CAC/B,OAA2B,EAC3B,OAA0B,EAC1B,QAAkC,EAAE;IAEpC,iBAAiB,iCACZ,KAAK,KACR,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,WAAW,EAAE,OAAO,CAAC,WAAW,EAChC,WAAW,CAAC,KAAK;YACf,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;gBACnB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;gBAC9B,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;gBAEhC,IAAI;oBACF,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;oBAC3B,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;iBACrB;gBAAC,OAAO,KAAK,EAAE;oBACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACtB;aACF;iBAAM;gBACL,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;aAC5B;QACH,CAAC,EACD,SAAS,EAAE,OAAO,CAAC,IAAI,EACvB,eAAe;YACb,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3C,CAAC;QACD,aAAa;YACX,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QACtE,CAAC;QACD,SAAS;YACP,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KA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nB,CAAC,CAAC;YAEJ,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;gBAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,OAAO,CAAC;gBACpD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,CAAC,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;gBACvG,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAChF,MAAM,KAAK,GAAG,OAAO,KAAK,QAAQ,CAAC;gBACnC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE;oBAC9B,MAAM;oBACN,KAAK;oBACL,UAAU;oBACV,KAAK;iBACN,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,IACD,CAAC;AACL,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import * as actions from '../actions';
2
+ import { createNavigation } from '../../app.codegen';
2
3
  function createContext(state, events) {
3
4
  const ctx = Object.assign(Object.assign({}, events), { apis: {}, converters: {
4
5
  html: ({ component }) => component,
5
- }, state });
6
+ }, navigation: createNavigation(), state });
6
7
  return ctx;
7
8
  }
8
9
  export function includeActions(ctx, actions) {
@@ -1 +1 @@
1
- {"version":3,"file":"createActions.js","sourceRoot":"","sources":["../../src/state/createActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AAItC,SAAS,aAAa,CAAC,KAAiC,EAAE,MAAoB;IAC5E,MAAM,GAAG,GAAG,gCACP,MAAM,KACT,IAAI,EAAE,EAAE,EACR,UAAU,EAAE;YACV,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS;SACnC,EACD,KAAK,GACgB,CAAC;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G,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KACzC;AACH,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAiC,EAAE,MAAoB;IACnF,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7C,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -2,6 +2,7 @@ import type { ComponentType, ReactNode } from 'react';
2
2
  import type { RouteComponentProps, SwitchProps } from 'react-router';
3
3
  import type { FirstParametersOf, UnionOf } from './common';
4
4
  import type { PiralCustomErrors, PiralCustomComponentConverters } from './custom';
5
+ import type { NavigationApi } from './navigation';
5
6
  import type { LayoutType } from './layout';
6
7
  /**
7
8
  * Mapping of available component converters.
@@ -30,7 +31,8 @@ export interface HtmlComponent<TProps> {
30
31
  * The context to be transported into the generic components.
31
32
  */
32
33
  export interface ComponentContext {
33
- router: RouteComponentProps;
34
+ navigation: NavigationApi;
35
+ publicPath: string;
34
36
  }
35
37
  /**
36
38
  * Generic definition of a framework-independent component.
@@ -7,6 +7,7 @@ export * from './data';
7
7
  export * from './extension';
8
8
  export * from './instance';
9
9
  export * from './layout';
10
+ export * from './navigation';
10
11
  export * from './plugin';
11
12
  export * from './state';
12
13
  export * from './utils';
@@ -7,6 +7,7 @@ export * from './data';
7
7
  export * from './extension';
8
8
  export * from './instance';
9
9
  export * from './layout';
10
+ export * from './navigation';
10
11
  export * from './plugin';
11
12
  export * from './state';
12
13
  export * from './utils';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -0,0 +1,81 @@
1
+ import type { Disposable } from './utils';
2
+ export declare type NavigationAction = 'POP' | 'PUSH' | 'REPLACE';
3
+ export interface NavigationLocation {
4
+ /**
5
+ * The fully qualified URL incl. the origin and base path.
6
+ */
7
+ href: string;
8
+ /**
9
+ * The location.pathname property is a string that contains an initial "/"
10
+ * followed by the remainder of the URL up to the ?.
11
+ */
12
+ pathname: string;
13
+ /**
14
+ * The location.search property is a string that contains an initial "?"
15
+ * followed by the key=value pairs in the query string. If there are no
16
+ * parameters, this value may be the empty string (i.e. '').
17
+ */
18
+ search: string;
19
+ /**
20
+ * The location.hash property is a string that contains an initial "#"
21
+ * followed by fragment identifier of the URL. If there is no fragment
22
+ * identifier, this value may be the empty string (i.e. '').
23
+ */
24
+ hash: string;
25
+ /**
26
+ * The location.state property is a user-supplied State object that is
27
+ * associated with this location. This can be a useful place to store
28
+ * any information you do not want to put in the URL, e.g. session-specific
29
+ * data.
30
+ */
31
+ state: unknown;
32
+ /**
33
+ * The location.key property is a unique string associated with this location.
34
+ * On the initial location, this will be the string default. On all subsequent
35
+ * locations, this string will be a unique identifier.
36
+ */
37
+ key: string;
38
+ }
39
+ export interface NavigationListener {
40
+ (update: NavigationUpdate): void;
41
+ }
42
+ export interface NavigationBlocker {
43
+ (tx: NavigationTransition): void;
44
+ }
45
+ export interface NavigationUpdate {
46
+ action: NavigationAction;
47
+ location: NavigationLocation;
48
+ }
49
+ export interface NavigationTransition extends NavigationUpdate {
50
+ retry(): void;
51
+ }
52
+ export interface NavigationApi {
53
+ /**
54
+ * Pushes a new location onto the history stack.
55
+ */
56
+ push(target: string, state?: any): void;
57
+ /**
58
+ * Replaces the current location with another.
59
+ */
60
+ replace(target: string, state?: any): void;
61
+ /**
62
+ * Changes the current index in the history stack by a given delta.
63
+ */
64
+ go(n: number): void;
65
+ /**
66
+ * Prevents changes to the history stack from happening.
67
+ * This is useful when you want to prevent the user navigating
68
+ * away from the current page, for example when they have some
69
+ * unsaved data on the current page.
70
+ * @param blocker The function being called with a transition request.
71
+ * @returns The disposable for stopping the block.
72
+ */
73
+ block(blocker: NavigationBlocker): Disposable;
74
+ /**
75
+ * Starts listening for location changes and calls the given
76
+ * callback with an Update when it does.
77
+ * @param listener The function being called when the route changes.
78
+ * @returns The disposable for stopping the block.
79
+ */
80
+ listen(listener: NavigationListener): Disposable;
81
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/types/navigation.ts"],"names":[],"mappings":""}
@@ -3,6 +3,7 @@ import type { RouteComponentProps } from 'react-router';
3
3
  import type { LoadPiletsOptions } from 'piral-base';
4
4
  import type { UseBoundStore } from 'zustand';
5
5
  import type { Dict, Without } from './common';
6
+ import type { NavigationApi } from './navigation';
6
7
  import type { SharedDataItem, DataStoreTarget } from './data';
7
8
  import type { PiralCustomActions, PiralCustomState, PiralCustomRegistryState, PiralCustomComponentsState } from './custom';
8
9
  import type { EventEmitter, Pilet, BaseComponentProps, PageComponentProps, ExtensionComponentProps, PiletsBag, PiralPageMeta, PiletEntry } from './api';
@@ -10,11 +11,6 @@ import type { ComponentConverters, LoadingIndicatorProps, ErrorInfoProps, Router
10
11
  export interface StateDispatcher<TState> {
11
12
  (state: TState): Partial<TState>;
12
13
  }
13
- declare module './components' {
14
- interface ComponentContext {
15
- readState: PiralActions['readState'];
16
- }
17
- }
18
14
  export declare type WrappedComponent<TProps> = ComponentType<PropsWithChildren<Without<TProps, keyof BaseComponentProps>>>;
19
15
  /**
20
16
  * The base type for pilet component registration in the global state context.
@@ -313,12 +309,6 @@ export interface PiralActions extends PiralCustomActions {
313
309
  * @returns The desired part.
314
310
  */
315
311
  readState<S>(select: (state: GlobalState) => S): S;
316
- /**
317
- * Performs a navigation.
318
- * @param path The path to navigate to.
319
- * @param state The optional state for the navigation.
320
- */
321
- navigate(path: string, state?: any): void;
322
312
  }
323
313
  /**
324
314
  * The Piral app instance context.
@@ -337,6 +327,10 @@ export interface GlobalStateContext extends PiralActions, EventEmitter {
337
327
  * The available component converters.
338
328
  */
339
329
  converters: ComponentConverters<any>;
330
+ /**
331
+ * The navigation manager for the whole instance.
332
+ */
333
+ navigation: NavigationApi;
340
334
  /**
341
335
  * The initial options.
342
336
  */
@@ -2,7 +2,6 @@ import { ComponentType } from 'react';
2
2
  import { RouteComponentProps } from 'react-router';
3
3
  import { ComponentsState, ErrorComponentsState, GlobalStateContext, Pilet, PiletEntry } from '../types';
4
4
  export declare function initialize(ctx: GlobalStateContext, loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
5
- export declare function navigate(ctx: GlobalStateContext, path: string, state?: any): void;
6
5
  export declare function addPilet(ctx: GlobalStateContext, meta: PiletEntry): Promise<void>;
7
6
  export declare function removePilet(ctx: GlobalStateContext, name: string): Promise<void>;
8
7
  export declare function injectPilet(ctx: GlobalStateContext, pilet: Pilet): Pilet;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.includeProvider = exports.setRoute = exports.setErrorComponent = exports.setComponent = exports.injectPilet = exports.removePilet = exports.addPilet = exports.navigate = exports.initialize = void 0;
3
+ exports.includeProvider = exports.setRoute = exports.setErrorComponent = exports.setComponent = exports.injectPilet = exports.removePilet = exports.addPilet = exports.initialize = void 0;
4
4
  const piral_base_1 = require("piral-base");
5
5
  const utils_1 = require("../utils");
6
6
  function initialize(ctx, loading, error, modules) {
@@ -8,10 +8,6 @@ function initialize(ctx, loading, error, modules) {
8
8
  loading }), modules })));
9
9
  }
10
10
  exports.initialize = initialize;
11
- function navigate(ctx, path, state) {
12
- ctx.emit('navigate', { path, state });
13
- }
14
- exports.navigate = navigate;
15
11
  function addPilet(ctx, meta) {
16
12
  return ctx.options
17
13
  .loadPilet(meta)
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/actions/app.ts"],"names":[],"mappings":";;;AAEA,2CAAsC;AACtC,oCAAkG;AAWlG,SAAgB,UAAU,CAAC,GAAuB,EAAE,OAAgB,EAAE,KAAwB,EAAE,OAAqB;IACnH,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,GAAG,kCACE,KAAK,CAAC,GAAG,KACZ,KAAK;YACL,OAAO,KAET,OAAO,IACP,CAAC,CAAC;AACN,CAAC;AAVD,gCAUC;AAED,SAAgB,QAAQ,CAAC,GAAuB,EAAE,IAAY,EAAE,KAAW;IACzE,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACxC,CAAC;AAFD,4BAEC;AAED,SAAgB,QAAQ,CAAC,GAAuB,EAAE,IAAgB;IAChE,OAAO,GAAG,CAAC,OAAO;SACf,SAAS,CAAC,IAAI,CAAC;SACf,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;SACvC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,qBAAQ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AY,EAAkC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,IACtG,CAAC,CAAC;IAEJ,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE;QACvB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAZD,kCAYC;AAED,SAAgB,YAAY,CAC1B,GAAuB,EACvB,IAAU,EACV,SAAgC;IAEhC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,UAAU,EAAE,IAAA,eAAO,EAAC,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,IACtD,CAAC,CAAC;AACN,CAAC;AATD,oCASC;AAED,SAAgB,iBAAiB,CAC/B,GAAuB,EACvB,IAAU,EACV,SAAqC;IAErC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,eAAe,EAAE,IAAA,eAAO,EAAC,KAAK,CAAC,eAAe,EAAE,IAAI,EAAE,SAAS,CAAC,IAChE,CAAC,CAAC;AACN,CAAC;AATD,8CASC;AAED,SAAgB,QAAQ,CACtB,GAAuB,EACvB,IAAY,EACZ,SAAgD;IAEhD,GAAG,CAAC,QAAQ,CAAC,IAAA,iBAAS,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AAC3C,CAAC;AAND,4BAMC;AAED,SAAgB,eAAe,CAAC,GAAuB,EAAE,QAAqB;IAC5E,GAAG,CAAC,QAAQ,CAAC,IAAA,oBAAY,EAAC,QAAQ,CAAC,CAAC,CAAC;AACvC,CAAC;AAFD,0CAEC"}
@@ -6,7 +6,6 @@ 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");
10
9
  // this is an arbitrary start number to have 6 digits
11
10
  let portalIdBase = 123456;
12
11
  function wrapReactComponent(Component, captured, Wrapper) {
@@ -15,10 +14,10 @@ function wrapReactComponent(Component, captured, Wrapper) {
15
14
  }
16
15
  function wrapForeignComponent(component, captured, Wrapper) {
17
16
  return React.memo((props) => {
18
- const { state, readState, destroyPortal } = (0, hooks_1.useGlobalStateContext)();
19
- const router = (0, app_codegen_1.useRouterContext)();
17
+ const { readState, destroyPortal, navigation } = (0, hooks_1.useGlobalStateContext)();
18
+ const publicPath = readState(s => s.app.publicPath);
20
19
  const id = React.useMemo(() => (portalIdBase++).toString(26), utils_1.none);
21
- const context = React.useMemo(() => ({ router, state, readState }), [router, state]);
20
+ const context = React.useMemo(() => ({ publicPath, navigation }), []);
22
21
  const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), captured)), [props]);
23
22
  React.useEffect(() => () => destroyPortal(id), utils_1.none);
24
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;AAClD,mDAAqD;AAGrD,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;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,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"}
package/lib/debugger.js CHANGED
@@ -33,7 +33,7 @@ function integrateDebugger(context, options, debug = {}) {
33
33
  return context.readState((s) => s);
34
34
  },
35
35
  navigate(path, state) {
36
- return context.navigate(path, state);
36
+ return context.navigation.push(path, state);
37
37
  },
38
38
  getPilets() {
39
39
  return context.readState((s) => s.modules);
@@ -1 +1 @@
1
- {"version":3,"file":"debugger.js","sourceRoot":"","sources":["../src/debugger.ts"],"names":[],"mappings":";;;AACA,yDAAgF;AAGhF,SAAgB,iBAAiB,CAC/B,OAA2B,EAC3B,OAA0B,EAC1B,QAAkC,EAAE;IAEpC,IAAA,qCAAiB,kCACZ,KAAK,KACR,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,WAAW,EAAE,OAAO,CAAC,WAAW,EAChC,WAAW,CAAC,KAAK;YACf,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;gBACnB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;gBAC9B,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;gBAEhC,IAAI;oBACF,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;oBAC3B,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;iBACrB;gBAAC,OAAO,KAAK,EAAE;oBACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACtB;aACF;iBAAM;gBACL,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;aAC5B;QACH,CAAC,EACD,SAAS,EAAE,OAAO,CAAC,IAAI,EACvB,eAAe;YACb,OAAO,MAAM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C,GAAG;YACX,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iCACnB,CAAC,KACJ,UAAU,kCACL,CAAC,CAAC,UAAU,GACZ,GAAG,CAAC,UAAU,GAEnB,MAAM,kCACD,CAAC,CAAC,MAAM,GACR,GAAG,CAAC,MAAM,GAEf,QAAQ,kCACH,CAAC,CAAC,QAAQ,KACb,QAAQ,kCACH,CAAC,CAAC,QAAQ,CAAC,QAAQ,GACnB,GAAG,CAAC,QAAQ,QAGnB,CAAC,CAAC;YAEJ,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;gBAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,OAAO,CAAC;gBACpD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,CAAC,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;gBACvG,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAChF,MAAM,KAAK,GAAG,OAAO,KAAK,QAAQ,CAAC;gBACnC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE;oBAC9B,MAAM;oBACN,KAAK;oBACL,UAAU;oBACV,KAAK;iBACN,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,IACD,CAAC;AACL,CAAC;AA/ED,8CA+EC"}
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createActions = exports.includeActions = void 0;
4
4
  const actions = require("../actions");
5
+ const app_codegen_1 = require("../../app.codegen");
5
6
  function createContext(state, events) {
6
7
  const ctx = Object.assign(Object.assign({}, events), { apis: {}, converters: {
7
8
  html: ({ component }) => component,
8
- }, state });
9
+ }, navigation: (0, app_codegen_1.createNavigation)(), state });
9
10
  return ctx;
10
11
  }
11
12
  function includeActions(ctx, actions) {
@@ -1 +1 @@
1
- {"version":3,"file":"createActions.js","sourceRoot":"","sources":["../../src/state/createActions.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AAItC,SAAS,aAAa,CAAC,KAAiC,EAAE,MAAoB;IAC5E,MAAM,GAAG,GAAG,gCACP,MAAM,KACT,IAAI,EAAE,EAAE,EACR,UAAU,EAAE;YACV,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS;SACnC,EACD,KAAK,GACgB,CAAC;IACxB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,cAAc,CAAC,GAAuB,EAAE,OAA2B;IACjF,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEzC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QACpC,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACnC,GAAG,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KACzC;AACH,CAAC;AAPD,wCAOC;AAED,SAAgB,aAAa,CAAC,KAAiC,EAAE,MAAoB;IACnF,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7C,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC;AACjB,CAAC;AAJD,sCAIC"}
1
+ {"version":3,"file":"createActions.js","sourceRoot":"","sources":["../../src/state/createActions.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AAEtC,mDAAqD;AAGrD,SAAS,aAAa,CAAC,KAAiC,EAAE,MAAoB;IAC5E,MAAM,GAAG,GAAG,gCACP,MAAM,KACT,IAAI,EAAE,EAAE,EACR,UAAU,EAAE;YACV,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS;SACnC,EACD,UAAU,EAAE,IAAA,8BAAgB,GAAE,EAC9B,KAAK,GACgB,CAAC;IACxB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,cAAc,CAAC,GAAuB,EAAE,OAA2B;IACjF,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEzC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QACpC,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACnC,GAAG,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KACzC;AACH,CAAC;AAPD,wCAOC;AAED,SAAgB,aAAa,CAAC,KAAiC,EAAE,MAAoB;IACnF,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7C,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC;AACjB,CAAC;AAJD,sCAIC"}
@@ -2,6 +2,7 @@ import type { ComponentType, ReactNode } from 'react';
2
2
  import type { RouteComponentProps, SwitchProps } from 'react-router';
3
3
  import type { FirstParametersOf, UnionOf } from './common';
4
4
  import type { PiralCustomErrors, PiralCustomComponentConverters } from './custom';
5
+ import type { NavigationApi } from './navigation';
5
6
  import type { LayoutType } from './layout';
6
7
  /**
7
8
  * Mapping of available component converters.
@@ -30,7 +31,8 @@ export interface HtmlComponent<TProps> {
30
31
  * The context to be transported into the generic components.
31
32
  */
32
33
  export interface ComponentContext {
33
- router: RouteComponentProps;
34
+ navigation: NavigationApi;
35
+ publicPath: string;
34
36
  }
35
37
  /**
36
38
  * Generic definition of a framework-independent component.
@@ -7,6 +7,7 @@ export * from './data';
7
7
  export * from './extension';
8
8
  export * from './instance';
9
9
  export * from './layout';
10
+ export * from './navigation';
10
11
  export * from './plugin';
11
12
  export * from './state';
12
13
  export * from './utils';
@@ -10,6 +10,7 @@ tslib_1.__exportStar(require("./data"), exports);
10
10
  tslib_1.__exportStar(require("./extension"), exports);
11
11
  tslib_1.__exportStar(require("./instance"), exports);
12
12
  tslib_1.__exportStar(require("./layout"), exports);
13
+ tslib_1.__exportStar(require("./navigation"), exports);
13
14
  tslib_1.__exportStar(require("./plugin"), exports);
14
15
  tslib_1.__exportStar(require("./state"), exports);
15
16
  tslib_1.__exportStar(require("./utils"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,gDAAsB;AACtB,mDAAyB;AACzB,uDAA6B;AAC7B,mDAAyB;AACzB,mDAAyB;AACzB,iDAAuB;AACvB,sDAA4B;AAC5B,qDAA2B;AAC3B,mDAAyB;AACzB,mDAAyB;AACzB,kDAAwB;AACxB,kDAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;AAAA,gDAAsB;AACtB,mDAAyB;AACzB,uDAA6B;AAC7B,mDAAyB;AACzB,mDAAyB;AACzB,iDAAuB;AACvB,sDAA4B;AAC5B,qDAA2B;AAC3B,mDAAyB;AACzB,uDAA6B;AAC7B,mDAAyB;AACzB,kDAAwB;AACxB,kDAAwB"}
@@ -0,0 +1,81 @@
1
+ import type { Disposable } from './utils';
2
+ export declare type NavigationAction = 'POP' | 'PUSH' | 'REPLACE';
3
+ export interface NavigationLocation {
4
+ /**
5
+ * The fully qualified URL incl. the origin and base path.
6
+ */
7
+ href: string;
8
+ /**
9
+ * The location.pathname property is a string that contains an initial "/"
10
+ * followed by the remainder of the URL up to the ?.
11
+ */
12
+ pathname: string;
13
+ /**
14
+ * The location.search property is a string that contains an initial "?"
15
+ * followed by the key=value pairs in the query string. If there are no
16
+ * parameters, this value may be the empty string (i.e. '').
17
+ */
18
+ search: string;
19
+ /**
20
+ * The location.hash property is a string that contains an initial "#"
21
+ * followed by fragment identifier of the URL. If there is no fragment
22
+ * identifier, this value may be the empty string (i.e. '').
23
+ */
24
+ hash: string;
25
+ /**
26
+ * The location.state property is a user-supplied State object that is
27
+ * associated with this location. This can be a useful place to store
28
+ * any information you do not want to put in the URL, e.g. session-specific
29
+ * data.
30
+ */
31
+ state: unknown;
32
+ /**
33
+ * The location.key property is a unique string associated with this location.
34
+ * On the initial location, this will be the string default. On all subsequent
35
+ * locations, this string will be a unique identifier.
36
+ */
37
+ key: string;
38
+ }
39
+ export interface NavigationListener {
40
+ (update: NavigationUpdate): void;
41
+ }
42
+ export interface NavigationBlocker {
43
+ (tx: NavigationTransition): void;
44
+ }
45
+ export interface NavigationUpdate {
46
+ action: NavigationAction;
47
+ location: NavigationLocation;
48
+ }
49
+ export interface NavigationTransition extends NavigationUpdate {
50
+ retry(): void;
51
+ }
52
+ export interface NavigationApi {
53
+ /**
54
+ * Pushes a new location onto the history stack.
55
+ */
56
+ push(target: string, state?: any): void;
57
+ /**
58
+ * Replaces the current location with another.
59
+ */
60
+ replace(target: string, state?: any): void;
61
+ /**
62
+ * Changes the current index in the history stack by a given delta.
63
+ */
64
+ go(n: number): void;
65
+ /**
66
+ * Prevents changes to the history stack from happening.
67
+ * This is useful when you want to prevent the user navigating
68
+ * away from the current page, for example when they have some
69
+ * unsaved data on the current page.
70
+ * @param blocker The function being called with a transition request.
71
+ * @returns The disposable for stopping the block.
72
+ */
73
+ block(blocker: NavigationBlocker): Disposable;
74
+ /**
75
+ * Starts listening for location changes and calls the given
76
+ * callback with an Update when it does.
77
+ * @param listener The function being called when the route changes.
78
+ * @returns The disposable for stopping the block.
79
+ */
80
+ listen(listener: NavigationListener): Disposable;
81
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../src/types/navigation.ts"],"names":[],"mappings":""}
@@ -3,6 +3,7 @@ import type { RouteComponentProps } from 'react-router';
3
3
  import type { LoadPiletsOptions } from 'piral-base';
4
4
  import type { UseBoundStore } from 'zustand';
5
5
  import type { Dict, Without } from './common';
6
+ import type { NavigationApi } from './navigation';
6
7
  import type { SharedDataItem, DataStoreTarget } from './data';
7
8
  import type { PiralCustomActions, PiralCustomState, PiralCustomRegistryState, PiralCustomComponentsState } from './custom';
8
9
  import type { EventEmitter, Pilet, BaseComponentProps, PageComponentProps, ExtensionComponentProps, PiletsBag, PiralPageMeta, PiletEntry } from './api';
@@ -10,11 +11,6 @@ import type { ComponentConverters, LoadingIndicatorProps, ErrorInfoProps, Router
10
11
  export interface StateDispatcher<TState> {
11
12
  (state: TState): Partial<TState>;
12
13
  }
13
- declare module './components' {
14
- interface ComponentContext {
15
- readState: PiralActions['readState'];
16
- }
17
- }
18
14
  export declare type WrappedComponent<TProps> = ComponentType<PropsWithChildren<Without<TProps, keyof BaseComponentProps>>>;
19
15
  /**
20
16
  * The base type for pilet component registration in the global state context.
@@ -313,12 +309,6 @@ export interface PiralActions extends PiralCustomActions {
313
309
  * @returns The desired part.
314
310
  */
315
311
  readState<S>(select: (state: GlobalState) => S): S;
316
- /**
317
- * Performs a navigation.
318
- * @param path The path to navigate to.
319
- * @param state The optional state for the navigation.
320
- */
321
- navigate(path: string, state?: any): void;
322
312
  }
323
313
  /**
324
314
  * The Piral app instance context.
@@ -337,6 +327,10 @@ export interface GlobalStateContext extends PiralActions, EventEmitter {
337
327
  * The available component converters.
338
328
  */
339
329
  converters: ComponentConverters<any>;
330
+ /**
331
+ * The navigation manager for the whole instance.
332
+ */
333
+ navigation: NavigationApi;
340
334
  /**
341
335
  * The initial options.
342
336
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-core",
3
- "version": "0.15.0-beta.4465",
3
+ "version": "0.15.0-beta.4512",
4
4
  "description": "The core library for creating a Piral instance.",
5
5
  "keywords": [
6
6
  "portal",
@@ -16,8 +16,7 @@
16
16
  "react": "react",
17
17
  "react-dom": "react-dom",
18
18
  "react-router": "react-router",
19
- "react-router-dom": "react-router-dom",
20
- "history": "history"
19
+ "react-router-dom": "react-router-dom"
21
20
  }
22
21
  },
23
22
  "author": "smapiot",
@@ -71,8 +70,8 @@
71
70
  "test": "echo \"Error: run tests from root\" && exit 1"
72
71
  },
73
72
  "dependencies": {
74
- "piral-base": "0.15.0-beta.4465",
75
- "piral-debug-utils": "0.15.0-beta.4465",
73
+ "piral-base": "0.15.0-beta.4512",
74
+ "piral-debug-utils": "0.15.0-beta.4512",
76
75
  "zustand": "^3.0.0"
77
76
  },
78
77
  "peerDependencies": {
@@ -82,7 +81,6 @@
82
81
  "react-router-dom": "5.x"
83
82
  },
84
83
  "devDependencies": {
85
- "@types/history": "^4.7.8",
86
84
  "@types/react": "^18.0.0",
87
85
  "@types/react-dom": "^18.0.0",
88
86
  "@types/react-router": "^5.1.8",
@@ -97,8 +95,7 @@
97
95
  "react-dom",
98
96
  "react-router",
99
97
  "react-router-dom",
100
- "history",
101
98
  "tslib"
102
99
  ],
103
- "gitHead": "3c7c64ebefd180d4e1cfbf0a397ea1c68063ae08"
100
+ "gitHead": "8c26175fb38ac3323c30b154d7ff28c13c29cb39"
104
101
  }
@@ -24,10 +24,6 @@ export function initialize(ctx: GlobalStateContext, loading: boolean, error: Err
24
24
  }));
25
25
  }
26
26
 
27
- export function navigate(ctx: GlobalStateContext, path: string, state?: any) {
28
- ctx.emit('navigate', { path, state });
29
- }
30
-
31
27
  export function addPilet(ctx: GlobalStateContext, meta: PiletEntry): Promise<void> {
32
28
  return ctx.options
33
29
  .loadPilet(meta)
@@ -15,6 +15,9 @@ jest.mock('../hooks/globalState', () => ({
15
15
  },
16
16
  },
17
17
  },
18
+ readState() {
19
+ return '/';
20
+ },
18
21
  destroyPortal: jest.fn(),
19
22
  }),
20
23
  }));
@@ -3,7 +3,6 @@ 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 { useRouterContext } from '../../app.codegen';
7
6
  import type { AnyComponent, ComponentConverters, ForeignComponent, PiletApi, BaseComponentProps } from '../types';
8
7
 
9
8
  // this is an arbitrary start number to have 6 digits
@@ -31,10 +30,10 @@ function wrapForeignComponent<T>(
31
30
  Wrapper: React.FC<T>,
32
31
  ) {
33
32
  return React.memo((props: T) => {
34
- const { state, readState, destroyPortal } = useGlobalStateContext();
35
- const router = useRouterContext();
33
+ const { readState, destroyPortal, navigation } = useGlobalStateContext();
34
+ const publicPath = readState(s => s.app.publicPath);
36
35
  const id = React.useMemo(() => (portalIdBase++).toString(26), none);
37
- const context = React.useMemo(() => ({ router, state, readState }), [router, state]);
36
+ const context = React.useMemo(() => ({ publicPath, navigation }), []);
38
37
  const innerProps = React.useMemo(() => ({ ...props, ...captured }), [props]);
39
38
 
40
39
  React.useEffect(() => () => destroyPortal(id), none);
package/src/debugger.ts CHANGED
@@ -42,7 +42,7 @@ export function integrateDebugger(
42
42
  return context.readState((s) => s);
43
43
  },
44
44
  navigate(path, state) {
45
- return context.navigate(path, state);
45
+ return context.navigation.push(path, state);
46
46
  },
47
47
  getPilets() {
48
48
  return context.readState((s) => s.modules);
@@ -14,7 +14,7 @@ describe('Create Actions Module', () => {
14
14
  it('createActions works with all actions', () => {
15
15
  const events = createListener(undefined);
16
16
  const actions = createActions('abc' as any, events);
17
- expect(Object.keys(actions)).toEqual(['on', 'off', 'emit', 'apis', 'converters', 'state', 'a', 'b']);
17
+ expect(Object.keys(actions)).toEqual(['on', 'off', 'emit', 'apis', 'converters', 'navigation', 'state', 'a', 'b']);
18
18
  });
19
19
 
20
20
  it('createActions binds against given context', () => {
@@ -1,5 +1,6 @@
1
1
  import * as actions from '../actions';
2
2
  import { UseBoundStore } from 'zustand';
3
+ import { createNavigation } from '../../app.codegen';
3
4
  import { EventEmitter, GlobalState, GlobalStateContext, PiralDefineActions } from '../types';
4
5
 
5
6
  function createContext(state: UseBoundStore<GlobalState>, events: EventEmitter) {
@@ -9,6 +10,7 @@ function createContext(state: UseBoundStore<GlobalState>, events: EventEmitter)
9
10
  converters: {
10
11
  html: ({ component }) => component,
11
12
  },
13
+ navigation: createNavigation(),
12
14
  state,
13
15
  } as GlobalStateContext;
14
16
  return ctx;
@@ -6,6 +6,9 @@ import { StateContext } from '../state';
6
6
 
7
7
  function createMockContainer() {
8
8
  const state = create(() => ({
9
+ app: {
10
+ publicPath: '/',
11
+ },
9
12
  components: {
10
13
  ErrorInfo: StubErrorInfo,
11
14
  },
@@ -2,6 +2,7 @@ import type { ComponentType, ReactNode } from 'react';
2
2
  import type { RouteComponentProps, SwitchProps } from 'react-router';
3
3
  import type { FirstParametersOf, UnionOf } from './common';
4
4
  import type { PiralCustomErrors, PiralCustomComponentConverters } from './custom';
5
+ import type { NavigationApi } from './navigation';
5
6
  import type { LayoutType } from './layout';
6
7
 
7
8
  /**
@@ -33,7 +34,8 @@ export interface HtmlComponent<TProps> {
33
34
  * The context to be transported into the generic components.
34
35
  */
35
36
  export interface ComponentContext {
36
- router: RouteComponentProps;
37
+ navigation: NavigationApi;
38
+ publicPath: string;
37
39
  }
38
40
 
39
41
  /**
@@ -7,6 +7,7 @@ export * from './data';
7
7
  export * from './extension';
8
8
  export * from './instance';
9
9
  export * from './layout';
10
+ export * from './navigation';
10
11
  export * from './plugin';
11
12
  export * from './state';
12
13
  export * from './utils';
@@ -0,0 +1,88 @@
1
+ import type { Disposable } from './utils';
2
+
3
+ export type NavigationAction = 'POP' | 'PUSH' | 'REPLACE';
4
+
5
+ export interface NavigationLocation {
6
+ /**
7
+ * The fully qualified URL incl. the origin and base path.
8
+ */
9
+ href: string;
10
+ /**
11
+ * The location.pathname property is a string that contains an initial "/"
12
+ * followed by the remainder of the URL up to the ?.
13
+ */
14
+ pathname: string;
15
+ /**
16
+ * The location.search property is a string that contains an initial "?"
17
+ * followed by the key=value pairs in the query string. If there are no
18
+ * parameters, this value may be the empty string (i.e. '').
19
+ */
20
+ search: string;
21
+ /**
22
+ * The location.hash property is a string that contains an initial "#"
23
+ * followed by fragment identifier of the URL. If there is no fragment
24
+ * identifier, this value may be the empty string (i.e. '').
25
+ */
26
+ hash: string;
27
+ /**
28
+ * The location.state property is a user-supplied State object that is
29
+ * associated with this location. This can be a useful place to store
30
+ * any information you do not want to put in the URL, e.g. session-specific
31
+ * data.
32
+ */
33
+ state: unknown;
34
+ /**
35
+ * The location.key property is a unique string associated with this location.
36
+ * On the initial location, this will be the string default. On all subsequent
37
+ * locations, this string will be a unique identifier.
38
+ */
39
+ key: string;
40
+ }
41
+
42
+ export interface NavigationListener {
43
+ (update: NavigationUpdate): void;
44
+ }
45
+
46
+ export interface NavigationBlocker {
47
+ (tx: NavigationTransition): void;
48
+ }
49
+
50
+ export interface NavigationUpdate {
51
+ action: NavigationAction;
52
+ location: NavigationLocation;
53
+ }
54
+
55
+ export interface NavigationTransition extends NavigationUpdate {
56
+ retry(): void;
57
+ }
58
+
59
+ export interface NavigationApi {
60
+ /**
61
+ * Pushes a new location onto the history stack.
62
+ */
63
+ push(target: string, state?: any): void;
64
+ /**
65
+ * Replaces the current location with another.
66
+ */
67
+ replace(target: string, state?: any): void;
68
+ /**
69
+ * Changes the current index in the history stack by a given delta.
70
+ */
71
+ go(n: number): void;
72
+ /**
73
+ * Prevents changes to the history stack from happening.
74
+ * This is useful when you want to prevent the user navigating
75
+ * away from the current page, for example when they have some
76
+ * unsaved data on the current page.
77
+ * @param blocker The function being called with a transition request.
78
+ * @returns The disposable for stopping the block.
79
+ */
80
+ block(blocker: NavigationBlocker): Disposable;
81
+ /**
82
+ * Starts listening for location changes and calls the given
83
+ * callback with an Update when it does.
84
+ * @param listener The function being called when the route changes.
85
+ * @returns The disposable for stopping the block.
86
+ */
87
+ listen(listener: NavigationListener): Disposable;
88
+ }
@@ -1,8 +1,9 @@
1
1
  import type { ComponentType, ReactPortal, PropsWithChildren } from 'react';
2
2
  import type { RouteComponentProps } from 'react-router';
3
3
  import type { LoadPiletsOptions } from 'piral-base';
4
- import type { StoreApi, UseBoundStore } from 'zustand';
4
+ import type { UseBoundStore } from 'zustand';
5
5
  import type { Dict, Without } from './common';
6
+ import type { NavigationApi } from './navigation';
6
7
  import type { SharedDataItem, DataStoreTarget } from './data';
7
8
  import type {
8
9
  PiralCustomActions,
@@ -34,12 +35,6 @@ export interface StateDispatcher<TState> {
34
35
  (state: TState): Partial<TState>;
35
36
  }
36
37
 
37
- declare module './components' {
38
- interface ComponentContext {
39
- readState: PiralActions['readState'];
40
- }
41
- }
42
-
43
38
  export type WrappedComponent<TProps> = ComponentType<PropsWithChildren<Without<TProps, keyof BaseComponentProps>>>;
44
39
 
45
40
  /**
@@ -347,12 +342,6 @@ export interface PiralActions extends PiralCustomActions {
347
342
  * @returns The desired part.
348
343
  */
349
344
  readState<S>(select: (state: GlobalState) => S): S;
350
- /**
351
- * Performs a navigation.
352
- * @param path The path to navigate to.
353
- * @param state The optional state for the navigation.
354
- */
355
- navigate(path: string, state?: any): void;
356
345
  }
357
346
 
358
347
  /**
@@ -372,6 +361,10 @@ export interface GlobalStateContext extends PiralActions, EventEmitter {
372
361
  * The available component converters.
373
362
  */
374
363
  converters: ComponentConverters<any>;
364
+ /**
365
+ * The navigation manager for the whole instance.
366
+ */
367
+ navigation: NavigationApi;
375
368
  /**
376
369
  * The initial options.
377
370
  */