piral-core 1.0.0-pre.2296 → 1.0.1-beta.5640
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/LICENSE +1 -1
- package/README.md +12 -4
- package/app.codegen +36 -0
- package/app.codegen.d.ts +29 -0
- package/dist/codegen.js +5308 -0
- package/esm/Piral.d.ts +4 -4
- package/esm/Piral.js +8 -11
- package/esm/Piral.js.map +1 -1
- package/esm/PiralContext.d.ts +21 -0
- package/esm/PiralContext.js +34 -0
- package/esm/PiralContext.js.map +1 -0
- package/esm/RootListener.d.ts +2 -0
- package/esm/RootListener.js +23 -0
- package/esm/RootListener.js.map +1 -0
- package/esm/actions/app.d.ts +7 -4
- package/esm/actions/app.js +24 -14
- package/esm/actions/app.js.map +1 -1
- package/esm/actions/components.js +5 -6
- package/esm/actions/components.js.map +1 -1
- package/esm/actions/data.js +16 -17
- package/esm/actions/data.js.map +1 -1
- package/esm/actions/define.js +2 -3
- package/esm/actions/define.js.map +1 -1
- package/esm/actions/portal.d.ts +2 -0
- package/esm/actions/portal.js +9 -4
- package/esm/actions/portal.js.map +1 -1
- package/esm/actions/state.js +7 -4
- package/esm/actions/state.js.map +1 -1
- package/esm/components/ErrorBoundary.d.ts +14 -31
- package/esm/components/ErrorBoundary.js +22 -28
- package/esm/components/ErrorBoundary.js.map +1 -1
- package/esm/components/ExtensionSlot.d.ts +1 -0
- package/esm/components/ExtensionSlot.js +34 -11
- package/esm/components/ExtensionSlot.js.map +1 -1
- package/esm/components/ForeignComponentContainer.d.ts +19 -0
- package/esm/components/ForeignComponentContainer.js +46 -0
- package/esm/components/ForeignComponentContainer.js.map +1 -0
- package/esm/components/Mediator.js +15 -12
- package/esm/components/Mediator.js.map +1 -1
- package/esm/components/PiralGlobals.d.ts +6 -0
- package/esm/components/PiralGlobals.js +13 -0
- package/esm/components/PiralGlobals.js.map +1 -0
- package/esm/components/PiralRoutes.d.ts +5 -0
- package/esm/components/PiralRoutes.js +6 -11
- package/esm/components/PiralRoutes.js.map +1 -1
- package/esm/components/PiralSuspense.d.ts +5 -0
- package/esm/components/PiralSuspense.js +8 -0
- package/esm/components/PiralSuspense.js.map +1 -0
- package/esm/components/PiralView.d.ts +10 -1
- package/esm/components/PiralView.js +12 -25
- package/esm/components/PiralView.js.map +1 -1
- package/esm/components/PortalRenderer.d.ts +5 -0
- package/esm/components/PortalRenderer.js +7 -0
- package/esm/components/PortalRenderer.js.map +1 -0
- package/esm/components/ResponsiveLayout.d.ts +9 -1
- package/esm/components/ResponsiveLayout.js +5 -13
- package/esm/components/ResponsiveLayout.js.map +1 -1
- package/esm/components/SwitchErrorInfo.js +12 -10
- package/esm/components/SwitchErrorInfo.js.map +1 -1
- package/esm/components/components.d.ts +18 -6
- package/esm/components/components.js +21 -9
- package/esm/components/components.js.map +1 -1
- package/esm/components/index.d.ts +4 -10
- package/esm/components/index.js +4 -10
- package/esm/components/index.js.map +1 -1
- package/esm/components/wrapComponent.d.ts +7 -0
- package/esm/components/wrapComponent.js +42 -0
- package/esm/components/wrapComponent.js.map +1 -0
- package/esm/createInstance.d.ts +2 -2
- package/esm/createInstance.js +34 -30
- package/esm/createInstance.js.map +1 -1
- package/esm/defaults/DefaultErrorInfo.js +10 -0
- package/esm/defaults/DefaultErrorInfo.js.map +1 -0
- package/esm/{components → defaults}/DefaultLayout.js +1 -4
- package/esm/defaults/DefaultLayout.js.map +1 -0
- package/esm/{components/DefaultLoader.js → defaults/DefaultLoadingIndicator.js} +2 -2
- package/esm/defaults/DefaultLoadingIndicator.js.map +1 -0
- package/esm/defaults/DefaultRouteSwitch_v5.d.ts +3 -0
- package/esm/defaults/DefaultRouteSwitch_v5.js +11 -0
- package/esm/defaults/DefaultRouteSwitch_v5.js.map +1 -0
- package/esm/defaults/DefaultRouteSwitch_v6.d.ts +3 -0
- package/esm/defaults/DefaultRouteSwitch_v6.js +15 -0
- package/esm/defaults/DefaultRouteSwitch_v6.js.map +1 -0
- package/esm/defaults/DefaultRouter_v5.d.ts +3 -0
- package/esm/defaults/DefaultRouter_v5.js +7 -0
- package/esm/defaults/DefaultRouter_v5.js.map +1 -0
- package/esm/defaults/DefaultRouter_v6.d.ts +3 -0
- package/esm/defaults/DefaultRouter_v6.js +7 -0
- package/esm/defaults/DefaultRouter_v6.js.map +1 -0
- package/esm/defaults/navigator_none.d.ts +5 -0
- package/esm/defaults/navigator_none.js +30 -0
- package/esm/defaults/navigator_none.js.map +1 -0
- package/esm/defaults/navigator_v5.d.ts +6 -0
- package/esm/defaults/navigator_v5.js +81 -0
- package/esm/defaults/navigator_v5.js.map +1 -0
- package/esm/defaults/navigator_v6.d.ts +6 -0
- package/esm/defaults/navigator_v6.js +77 -0
- package/esm/defaults/navigator_v6.js.map +1 -0
- package/esm/helpers.d.ts +12 -26
- package/esm/helpers.js +14 -72
- package/esm/helpers.js.map +1 -1
- package/esm/hooks/action.js +2 -3
- package/esm/hooks/action.js.map +1 -1
- package/esm/hooks/actions.js +1 -1
- package/esm/hooks/actions.js.map +1 -1
- package/esm/hooks/globalState.d.ts +7 -0
- package/esm/hooks/globalState.js +10 -8
- package/esm/hooks/globalState.js.map +1 -1
- package/esm/hooks/index.d.ts +2 -5
- package/esm/hooks/index.js +2 -5
- package/esm/hooks/index.js.map +1 -1
- package/esm/hooks/media.js +8 -7
- package/esm/hooks/media.js.map +1 -1
- package/esm/hooks/piletApi.d.ts +7 -0
- package/esm/hooks/piletApi.js +14 -0
- package/esm/hooks/piletApi.js.map +1 -0
- package/esm/hooks/routes.d.ts +2 -0
- package/esm/hooks/routes.js +11 -0
- package/esm/hooks/routes.js.map +1 -0
- package/esm/hooks/setter.js +3 -2
- package/esm/hooks/setter.js.map +1 -1
- package/esm/hooks/sharedData.js +2 -2
- package/esm/hooks/sharedData.js.map +1 -1
- package/esm/index.d.ts +3 -1
- package/esm/index.js +3 -1
- package/esm/index.js.map +1 -1
- package/esm/modules/api.d.ts +2 -5
- package/esm/modules/api.js +9 -69
- package/esm/modules/api.js.map +1 -1
- package/esm/modules/core.d.ts +3 -0
- package/esm/modules/core.js +50 -0
- package/esm/modules/core.js.map +1 -0
- package/esm/modules/dependencies.d.ts +5 -6
- package/esm/modules/dependencies.js +9 -24
- package/esm/modules/dependencies.js.map +1 -1
- package/esm/modules/element.d.ts +5 -0
- package/esm/modules/element.js +169 -0
- package/esm/modules/element.js.map +1 -0
- package/esm/modules/index.d.ts +1 -0
- package/esm/modules/index.js +1 -0
- package/esm/modules/index.js.map +1 -1
- package/esm/setters/SetComponent.js +11 -0
- package/esm/setters/SetComponent.js.map +1 -0
- package/esm/setters/SetError.js +11 -0
- package/esm/setters/SetError.js.map +1 -0
- package/esm/setters/SetErrors.js +9 -0
- package/esm/setters/SetErrors.js.map +1 -0
- package/esm/setters/SetLayout.js +9 -0
- package/esm/setters/SetLayout.js.map +1 -0
- package/esm/setters/SetProvider.js +11 -0
- package/esm/setters/SetProvider.js.map +1 -0
- package/esm/setters/SetRedirect.js +12 -0
- package/esm/setters/SetRedirect.js.map +1 -0
- package/{lib/components → esm/setters}/SetRoute.d.ts +6 -2
- package/esm/setters/SetRoute.js +11 -0
- package/esm/setters/SetRoute.js.map +1 -0
- package/esm/setters/index.d.ts +7 -0
- package/esm/setters/index.js +8 -0
- package/esm/setters/index.js.map +1 -0
- package/esm/state/createActions.d.ts +2 -2
- package/esm/state/createActions.js +8 -12
- package/esm/state/createActions.js.map +1 -1
- package/esm/state/createGlobalState.d.ts +1 -2
- package/esm/state/createGlobalState.js +9 -34
- package/esm/state/createGlobalState.js.map +1 -1
- package/esm/state/stateContext.js +1 -1
- package/esm/state/stateContext.js.map +1 -1
- package/esm/state/withApi.d.ts +1 -1
- package/esm/state/withApi.js +19 -104
- package/esm/state/withApi.js.map +1 -1
- package/esm/tools/codegen.d.ts +21 -0
- package/esm/tools/codegen.js +145 -0
- package/esm/tools/codegen.js.map +1 -0
- package/esm/tools/debugger.d.ts +4 -0
- package/esm/tools/debugger.js +54 -0
- package/esm/tools/debugger.js.map +1 -0
- package/esm/tools/emulator.d.ts +3 -0
- package/esm/tools/emulator.js +11 -0
- package/esm/tools/emulator.js.map +1 -0
- package/esm/types/api.d.ts +34 -9
- package/esm/types/common.d.ts +11 -11
- package/esm/types/components.d.ts +74 -8
- package/esm/types/config.d.ts +24 -17
- package/esm/types/data.d.ts +2 -2
- package/esm/types/extension.d.ts +31 -4
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/esm/types/index.js.map +1 -1
- package/esm/types/instance.d.ts +26 -4
- package/esm/types/layout.d.ts +3 -3
- package/esm/types/navigation.d.ts +94 -0
- package/esm/types/navigation.js +2 -0
- package/esm/types/navigation.js.map +1 -0
- package/esm/types/plugin.d.ts +1 -14
- package/esm/types/state.d.ts +66 -27
- package/esm/types/utils.d.ts +1 -1
- package/esm/utils/compare.d.ts +1 -1
- package/esm/utils/compare.js +24 -7
- package/esm/utils/compare.js.map +1 -1
- package/esm/utils/data.js +6 -7
- package/esm/utils/data.js.map +1 -1
- package/esm/utils/extension.d.ts +16 -0
- package/esm/utils/extension.js +37 -0
- package/esm/utils/extension.js.map +1 -0
- package/esm/utils/foreign.d.ts +7 -2
- package/esm/utils/foreign.js +20 -9
- package/esm/utils/foreign.js.map +1 -1
- package/esm/utils/guid.js +3 -3
- package/esm/utils/guid.js.map +1 -1
- package/esm/utils/helpers.d.ts +11 -8
- package/esm/utils/helpers.js +29 -18
- package/esm/utils/helpers.js.map +1 -1
- package/esm/utils/index.d.ts +3 -1
- package/esm/utils/index.js +3 -1
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/media.js +8 -8
- package/esm/utils/media.js.map +1 -1
- package/esm/utils/state.d.ts +57 -0
- package/esm/utils/state.js +83 -0
- package/esm/utils/state.js.map +1 -0
- package/esm/utils/storage.js +13 -14
- package/esm/utils/storage.js.map +1 -1
- package/lib/Piral.d.ts +4 -4
- package/lib/Piral.js +11 -13
- package/lib/Piral.js.map +1 -1
- package/lib/PiralContext.d.ts +21 -0
- package/lib/PiralContext.js +38 -0
- package/lib/PiralContext.js.map +1 -0
- package/lib/RootListener.d.ts +2 -0
- package/lib/RootListener.js +27 -0
- package/lib/RootListener.js.map +1 -0
- package/lib/actions/app.d.ts +7 -4
- package/lib/actions/app.js +27 -16
- package/lib/actions/app.js.map +1 -1
- package/lib/actions/components.js +5 -6
- package/lib/actions/components.js.map +1 -1
- package/lib/actions/data.js +17 -18
- package/lib/actions/data.js.map +1 -1
- package/lib/actions/define.js +2 -3
- package/lib/actions/define.js.map +1 -1
- package/lib/actions/index.js +1 -1
- package/lib/actions/portal.d.ts +2 -0
- package/lib/actions/portal.js +12 -5
- package/lib/actions/portal.js.map +1 -1
- package/lib/actions/state.js +7 -4
- package/lib/actions/state.js.map +1 -1
- package/lib/components/ErrorBoundary.d.ts +14 -31
- package/lib/components/ErrorBoundary.js +23 -28
- package/lib/components/ErrorBoundary.js.map +1 -1
- package/lib/components/ExtensionSlot.d.ts +1 -0
- package/lib/components/ExtensionSlot.js +37 -14
- package/lib/components/ExtensionSlot.js.map +1 -1
- package/lib/components/ForeignComponentContainer.d.ts +19 -0
- package/lib/components/ForeignComponentContainer.js +50 -0
- package/lib/components/ForeignComponentContainer.js.map +1 -0
- package/lib/components/Mediator.js +18 -14
- package/lib/components/Mediator.js.map +1 -1
- package/lib/components/PiralGlobals.d.ts +6 -0
- package/lib/components/PiralGlobals.js +17 -0
- package/lib/components/PiralGlobals.js.map +1 -0
- package/lib/components/PiralRoutes.d.ts +5 -0
- package/lib/components/PiralRoutes.js +8 -12
- package/lib/components/PiralRoutes.js.map +1 -1
- package/lib/components/PiralSuspense.d.ts +5 -0
- package/lib/components/PiralSuspense.js +12 -0
- package/lib/components/PiralSuspense.js.map +1 -0
- package/lib/components/PiralView.d.ts +10 -1
- package/lib/components/PiralView.js +15 -27
- package/lib/components/PiralView.js.map +1 -1
- package/lib/components/PortalRenderer.d.ts +5 -0
- package/lib/components/PortalRenderer.js +11 -0
- package/lib/components/PortalRenderer.js.map +1 -0
- package/lib/components/ResponsiveLayout.d.ts +9 -1
- package/lib/components/ResponsiveLayout.js +7 -14
- package/lib/components/ResponsiveLayout.js.map +1 -1
- package/lib/components/SwitchErrorInfo.js +15 -12
- package/lib/components/SwitchErrorInfo.js.map +1 -1
- package/lib/components/components.d.ts +18 -6
- package/lib/components/components.js +24 -12
- package/lib/components/components.js.map +1 -1
- package/lib/components/index.d.ts +4 -10
- package/lib/components/index.js +5 -11
- package/lib/components/index.js.map +1 -1
- package/lib/components/wrapComponent.d.ts +7 -0
- package/lib/components/wrapComponent.js +46 -0
- package/lib/components/wrapComponent.js.map +1 -0
- package/lib/createInstance.d.ts +2 -2
- package/lib/createInstance.js +40 -36
- package/lib/createInstance.js.map +1 -1
- package/lib/defaults/DefaultErrorInfo.js +14 -0
- package/lib/defaults/DefaultErrorInfo.js.map +1 -0
- package/lib/{components → defaults}/DefaultLayout.js +3 -5
- package/lib/defaults/DefaultLayout.js.map +1 -0
- package/lib/{components/DefaultLoader.js → defaults/DefaultLoadingIndicator.js} +4 -3
- package/lib/defaults/DefaultLoadingIndicator.js.map +1 -0
- package/lib/defaults/DefaultRouteSwitch_v5.d.ts +3 -0
- package/lib/defaults/DefaultRouteSwitch_v5.js +15 -0
- package/lib/defaults/DefaultRouteSwitch_v5.js.map +1 -0
- package/lib/defaults/DefaultRouteSwitch_v6.d.ts +3 -0
- package/lib/defaults/DefaultRouteSwitch_v6.js +19 -0
- package/lib/defaults/DefaultRouteSwitch_v6.js.map +1 -0
- package/lib/defaults/DefaultRouter_v5.d.ts +3 -0
- package/lib/defaults/DefaultRouter_v5.js +11 -0
- package/lib/defaults/DefaultRouter_v5.js.map +1 -0
- package/lib/defaults/DefaultRouter_v6.d.ts +3 -0
- package/lib/defaults/DefaultRouter_v6.js +11 -0
- package/lib/defaults/DefaultRouter_v6.js.map +1 -0
- package/lib/defaults/navigator_none.d.ts +5 -0
- package/lib/defaults/navigator_none.js +37 -0
- package/lib/defaults/navigator_none.js.map +1 -0
- package/lib/defaults/navigator_v5.d.ts +6 -0
- package/lib/defaults/navigator_v5.js +88 -0
- package/lib/defaults/navigator_v5.js.map +1 -0
- package/lib/defaults/navigator_v6.d.ts +6 -0
- package/lib/defaults/navigator_v6.js +84 -0
- package/lib/defaults/navigator_v6.js.map +1 -0
- package/lib/helpers.d.ts +12 -26
- package/lib/helpers.js +15 -75
- package/lib/helpers.js.map +1 -1
- package/lib/hooks/action.js +2 -3
- package/lib/hooks/action.js.map +1 -1
- package/lib/hooks/actions.js +4 -4
- package/lib/hooks/actions.js.map +1 -1
- package/lib/hooks/globalState.d.ts +7 -0
- package/lib/hooks/globalState.js +14 -11
- package/lib/hooks/globalState.js.map +1 -1
- package/lib/hooks/index.d.ts +2 -5
- package/lib/hooks/index.js +3 -6
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/media.js +10 -9
- package/lib/hooks/media.js.map +1 -1
- package/lib/hooks/piletApi.d.ts +7 -0
- package/lib/hooks/piletApi.js +18 -0
- package/lib/hooks/piletApi.js.map +1 -0
- package/lib/hooks/routes.d.ts +2 -0
- package/lib/hooks/routes.js +15 -0
- package/lib/hooks/routes.js.map +1 -0
- package/lib/hooks/setter.js +4 -3
- package/lib/hooks/setter.js.map +1 -1
- package/lib/hooks/sharedData.js +3 -3
- package/lib/hooks/sharedData.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/modules/api.d.ts +2 -5
- package/lib/modules/api.js +12 -75
- package/lib/modules/api.js.map +1 -1
- package/lib/modules/core.d.ts +3 -0
- package/lib/modules/core.js +54 -0
- package/lib/modules/core.js.map +1 -0
- package/lib/modules/dependencies.d.ts +5 -6
- package/lib/modules/dependencies.js +12 -27
- package/lib/modules/dependencies.js.map +1 -1
- package/lib/modules/element.d.ts +5 -0
- package/lib/modules/element.js +173 -0
- package/lib/modules/element.js.map +1 -0
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +2 -1
- package/lib/modules/index.js.map +1 -1
- package/lib/setters/SetComponent.js +15 -0
- package/lib/setters/SetComponent.js.map +1 -0
- package/lib/setters/SetError.js +15 -0
- package/lib/setters/SetError.js.map +1 -0
- package/lib/setters/SetErrors.js +13 -0
- package/lib/setters/SetErrors.js.map +1 -0
- package/lib/setters/SetLayout.js +13 -0
- package/lib/setters/SetLayout.js.map +1 -0
- package/lib/{components → setters}/SetProvider.js +4 -5
- package/lib/setters/SetProvider.js.map +1 -0
- package/lib/setters/SetRedirect.js +16 -0
- package/lib/setters/SetRedirect.js.map +1 -0
- package/{esm/components → lib/setters}/SetRoute.d.ts +6 -2
- package/lib/setters/SetRoute.js +15 -0
- package/lib/setters/SetRoute.js.map +1 -0
- package/lib/setters/index.d.ts +7 -0
- package/lib/setters/index.js +11 -0
- package/lib/setters/index.js.map +1 -0
- package/lib/state/createActions.d.ts +2 -2
- package/lib/state/createActions.js +9 -13
- package/lib/state/createActions.js.map +1 -1
- package/lib/state/createGlobalState.d.ts +1 -2
- package/lib/state/createGlobalState.js +9 -34
- package/lib/state/createGlobalState.js.map +1 -1
- package/lib/state/index.js +1 -1
- package/lib/state/stateContext.js +1 -1
- package/lib/state/stateContext.js.map +1 -1
- package/lib/state/withApi.d.ts +1 -1
- package/lib/state/withApi.js +20 -105
- package/lib/state/withApi.js.map +1 -1
- package/lib/tools/codegen.d.ts +21 -0
- package/lib/tools/codegen.js +152 -0
- package/lib/tools/codegen.js.map +1 -0
- package/lib/tools/debugger.d.ts +4 -0
- package/lib/tools/debugger.js +58 -0
- package/lib/tools/debugger.js.map +1 -0
- package/lib/tools/emulator.d.ts +3 -0
- package/lib/tools/emulator.js +15 -0
- package/lib/tools/emulator.js.map +1 -0
- package/lib/types/api.d.ts +34 -9
- package/lib/types/common.d.ts +11 -11
- package/lib/types/components.d.ts +74 -8
- package/lib/types/config.d.ts +24 -17
- package/lib/types/data.d.ts +2 -2
- package/lib/types/extension.d.ts +31 -4
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +2 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/instance.d.ts +26 -4
- package/lib/types/layout.d.ts +3 -3
- package/lib/types/navigation.d.ts +94 -0
- package/lib/types/navigation.js +3 -0
- package/lib/types/navigation.js.map +1 -0
- package/lib/types/plugin.d.ts +1 -14
- package/lib/types/state.d.ts +66 -27
- package/lib/types/utils.d.ts +1 -1
- package/lib/utils/compare.d.ts +1 -1
- package/lib/utils/compare.js +26 -9
- package/lib/utils/compare.js.map +1 -1
- package/lib/utils/data.js +6 -7
- package/lib/utils/data.js.map +1 -1
- package/lib/utils/extension.d.ts +16 -0
- package/lib/utils/extension.js +42 -0
- package/lib/utils/extension.js.map +1 -0
- package/lib/utils/foreign.d.ts +7 -2
- package/lib/utils/foreign.js +25 -12
- package/lib/utils/foreign.js.map +1 -1
- package/lib/utils/guid.js +3 -3
- package/lib/utils/guid.js.map +1 -1
- package/lib/utils/helpers.d.ts +11 -8
- package/lib/utils/helpers.js +31 -18
- package/lib/utils/helpers.js.map +1 -1
- package/lib/utils/index.d.ts +3 -1
- package/lib/utils/index.js +7 -2
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/media.js +7 -7
- package/lib/utils/media.js.map +1 -1
- package/lib/utils/react.js +1 -1
- package/lib/utils/react.js.map +1 -1
- package/lib/utils/state.d.ts +57 -0
- package/lib/utils/state.js +94 -0
- package/lib/utils/state.js.map +1 -0
- package/lib/utils/storage.js +11 -12
- package/lib/utils/storage.js.map +1 -1
- package/package.json +51 -20
- package/src/Piral.test.tsx +7 -16
- package/src/Piral.tsx +12 -11
- package/src/PiralContext.tsx +43 -0
- package/src/RootListener.test.tsx +46 -0
- package/src/RootListener.tsx +26 -0
- package/src/actions/app.test.ts +114 -44
- package/src/actions/app.ts +33 -23
- package/src/actions/components.test.ts +11 -11
- package/src/actions/components.ts +5 -33
- package/src/actions/data.test.ts +50 -50
- package/src/actions/define.test.ts +2 -2
- package/src/actions/portal.test.ts +62 -17
- package/src/actions/portal.ts +19 -1
- package/src/actions/state.test.ts +3 -3
- package/src/actions/state.ts +8 -4
- package/src/components/ErrorBoundary.tsx +22 -49
- package/src/components/ExtensionSlot.test.tsx +115 -30
- package/src/components/ExtensionSlot.tsx +57 -18
- package/src/components/ForeignComponentContainer.test.tsx +100 -0
- package/src/components/ForeignComponentContainer.tsx +63 -0
- package/src/components/Mediator.test.tsx +16 -14
- package/src/components/Mediator.tsx +17 -9
- package/src/components/PiralGlobals.tsx +16 -0
- package/src/components/PiralRoutes.test.tsx +65 -57
- package/src/components/PiralRoutes.tsx +10 -17
- package/src/components/PiralSuspense.tsx +19 -0
- package/src/components/PiralView-server.test.tsx +61 -0
- package/src/components/PiralView.test.tsx +27 -26
- package/src/components/PiralView.tsx +28 -35
- package/src/components/PortalRenderer.tsx +12 -0
- package/src/components/ResponsiveLayout.test.tsx +18 -37
- package/src/components/ResponsiveLayout.tsx +18 -15
- package/src/components/SwitchErrorInfo.test.tsx +36 -0
- package/src/components/SwitchErrorInfo.tsx +5 -1
- package/src/components/components.tsx +20 -6
- package/src/components/index.ts +4 -10
- package/src/components/wrapComponent.tsx +74 -0
- package/src/createInstance.test.tsx +10 -0
- package/src/createInstance.tsx +19 -14
- package/src/{components → defaults}/DefaultErrorInfo.test.tsx +15 -18
- package/src/{components → defaults}/DefaultErrorInfo.tsx +2 -3
- package/src/defaults/DefaultLayout.test.tsx +23 -0
- package/src/defaults/DefaultLoadingIndicator.test.tsx +10 -0
- package/src/defaults/DefaultRouteSwitch_v5.tsx +15 -0
- package/src/defaults/DefaultRouteSwitch_v6.tsx +20 -0
- package/src/defaults/DefaultRouter_v5.tsx +8 -0
- package/src/defaults/DefaultRouter_v6.tsx +8 -0
- package/src/defaults/navigator_none.tsx +35 -0
- package/src/defaults/navigator_v5.tsx +99 -0
- package/src/defaults/navigator_v6.tsx +96 -0
- package/src/helpers.test.tsx +30 -49
- package/src/helpers.tsx +31 -108
- package/src/hooks/action.ts +2 -3
- package/src/hooks/globalState.ts +10 -9
- package/src/hooks/index.ts +2 -5
- package/src/hooks/media.ts +2 -1
- package/src/hooks/piletApi.ts +14 -0
- package/src/hooks/routes.ts +14 -0
- package/src/hooks/setter-server.test.ts +22 -0
- package/src/hooks/setter.test.ts +18 -0
- package/src/hooks/setter.ts +2 -1
- package/src/index.tsx +3 -1
- package/src/modules/api.test.ts +15 -26
- package/src/modules/api.ts +3 -66
- package/src/modules/core.test.ts +148 -0
- package/src/modules/core.ts +52 -0
- package/src/modules/dependencies.test.ts +16 -5
- package/src/modules/dependencies.ts +13 -31
- package/src/modules/element-server.test.ts +29 -0
- package/src/modules/element.test.ts +67 -0
- package/src/modules/element.ts +212 -0
- package/src/modules/index.ts +1 -0
- package/src/{components → setters}/SetComponent.test.tsx +9 -8
- package/src/{components → setters}/SetComponent.tsx +2 -2
- package/src/{components → setters}/SetError.test.tsx +9 -8
- package/src/{components → setters}/SetError.tsx +2 -2
- package/src/{components → setters}/SetErrors.test.tsx +9 -8
- package/src/{components → setters}/SetLayout.test.tsx +9 -8
- package/src/{components → setters}/SetProvider.test.tsx +9 -8
- package/src/{components → setters}/SetProvider.tsx +2 -2
- package/src/{components → setters}/SetRedirect.test.tsx +9 -8
- package/src/{components → setters}/SetRedirect.tsx +4 -4
- package/src/{components → setters}/SetRoute.test.tsx +9 -8
- package/src/{components → setters}/SetRoute.tsx +7 -4
- package/src/setters/index.ts +7 -0
- package/src/state/createActions.test.ts +2 -2
- package/src/state/createActions.ts +5 -3
- package/src/state/createGlobalState.test.ts +55 -54
- package/src/state/createGlobalState.ts +4 -28
- package/src/state/withApi.test.tsx +87 -40
- package/src/state/withApi.tsx +31 -165
- package/src/tools/codegen.ts +193 -0
- package/src/tools/debugger.ts +84 -0
- package/src/tools/emulator.ts +13 -0
- package/src/types/api.ts +47 -10
- package/src/types/components.ts +76 -7
- package/src/types/config.ts +23 -17
- package/src/types/extension.ts +38 -5
- package/src/types/index.ts +1 -0
- package/src/types/instance.ts +28 -4
- package/src/types/navigation.ts +101 -0
- package/src/types/plugin.ts +1 -15
- package/src/types/state.ts +65 -25
- package/src/types/utils.ts +1 -1
- package/src/utils/compare.test.ts +15 -15
- package/src/utils/compare.ts +23 -3
- package/src/utils/extension.test.tsx +21 -0
- package/src/utils/extension.tsx +48 -0
- package/src/utils/foreign.test.ts +29 -11
- package/src/utils/foreign.ts +34 -7
- package/src/utils/guid.test.ts +6 -1
- package/src/utils/helpers.test.ts +52 -0
- package/src/utils/helpers.ts +22 -8
- package/src/utils/index.ts +4 -1
- package/src/utils/media-server.test.ts +13 -0
- package/src/utils/media.ts +2 -2
- package/src/utils/state.test.ts +37 -0
- package/src/utils/state.ts +131 -0
- package/dependencies.codegen +0 -9
- package/dependencies.codegen.native.js +0 -2
- package/esm/components/DefaultErrorInfo.js +0 -12
- package/esm/components/DefaultErrorInfo.js.map +0 -1
- package/esm/components/DefaultLayout.js.map +0 -1
- package/esm/components/DefaultLoader.js.map +0 -1
- package/esm/components/SetComponent.js +0 -12
- package/esm/components/SetComponent.js.map +0 -1
- package/esm/components/SetError.js +0 -12
- package/esm/components/SetError.js.map +0 -1
- package/esm/components/SetErrors.js +0 -10
- package/esm/components/SetErrors.js.map +0 -1
- package/esm/components/SetLayout.js +0 -10
- package/esm/components/SetLayout.js.map +0 -1
- package/esm/components/SetProvider.js +0 -12
- package/esm/components/SetProvider.js.map +0 -1
- package/esm/components/SetRedirect.js +0 -14
- package/esm/components/SetRedirect.js.map +0 -1
- package/esm/components/SetRoute.js +0 -12
- package/esm/components/SetRoute.js.map +0 -1
- package/esm/hooks/debounce.d.ts +0 -8
- package/esm/hooks/debounce.js +0 -18
- package/esm/hooks/debounce.js.map +0 -1
- package/esm/hooks/lockBodyScroll.d.ts +0 -6
- package/esm/hooks/lockBodyScroll.js +0 -13
- package/esm/hooks/lockBodyScroll.js.map +0 -1
- package/esm/hooks/onClickOutside.d.ts +0 -8
- package/esm/hooks/onClickOutside.js +0 -23
- package/esm/hooks/onClickOutside.js.map +0 -1
- package/esm/hooks/onScreenVisible.d.ts +0 -11
- package/esm/hooks/onScreenVisible.js +0 -28
- package/esm/hooks/onScreenVisible.js.map +0 -1
- package/esm/hooks/promise.d.ts +0 -13
- package/esm/hooks/promise.js +0 -21
- package/esm/hooks/promise.js.map +0 -1
- package/esm/utils/events.d.ts +0 -3
- package/esm/utils/events.js +0 -35
- package/esm/utils/events.js.map +0 -1
- package/lib/components/DefaultErrorInfo.js +0 -15
- package/lib/components/DefaultErrorInfo.js.map +0 -1
- package/lib/components/DefaultLayout.js.map +0 -1
- package/lib/components/DefaultLoader.js.map +0 -1
- package/lib/components/SetComponent.js +0 -16
- package/lib/components/SetComponent.js.map +0 -1
- package/lib/components/SetError.js +0 -16
- package/lib/components/SetError.js.map +0 -1
- package/lib/components/SetErrors.js +0 -14
- package/lib/components/SetErrors.js.map +0 -1
- package/lib/components/SetLayout.js +0 -14
- package/lib/components/SetLayout.js.map +0 -1
- package/lib/components/SetProvider.js.map +0 -1
- package/lib/components/SetRedirect.js +0 -18
- package/lib/components/SetRedirect.js.map +0 -1
- package/lib/components/SetRoute.js +0 -16
- package/lib/components/SetRoute.js.map +0 -1
- package/lib/hooks/debounce.d.ts +0 -8
- package/lib/hooks/debounce.js +0 -22
- package/lib/hooks/debounce.js.map +0 -1
- package/lib/hooks/lockBodyScroll.d.ts +0 -6
- package/lib/hooks/lockBodyScroll.js +0 -17
- package/lib/hooks/lockBodyScroll.js.map +0 -1
- package/lib/hooks/onClickOutside.d.ts +0 -8
- package/lib/hooks/onClickOutside.js +0 -27
- package/lib/hooks/onClickOutside.js.map +0 -1
- package/lib/hooks/onScreenVisible.d.ts +0 -11
- package/lib/hooks/onScreenVisible.js +0 -32
- package/lib/hooks/onScreenVisible.js.map +0 -1
- package/lib/hooks/promise.d.ts +0 -13
- package/lib/hooks/promise.js +0 -25
- package/lib/hooks/promise.js.map +0 -1
- package/lib/utils/events.d.ts +0 -3
- package/lib/utils/events.js +0 -39
- package/lib/utils/events.js.map +0 -1
- package/src/components/DefaultLayout.test.tsx +0 -23
- package/src/components/DefaultLoader.test.tsx +0 -10
- package/src/hooks/debounce.test.ts +0 -67
- package/src/hooks/debounce.ts +0 -19
- package/src/hooks/globalState.test.ts +0 -47
- package/src/hooks/lockBodyScroll.test.ts +0 -24
- package/src/hooks/lockBodyScroll.ts +0 -13
- package/src/hooks/onClickOutside.test.ts +0 -113
- package/src/hooks/onClickOutside.ts +0 -25
- package/src/hooks/onScreenVisible.test.ts +0 -68
- package/src/hooks/onScreenVisible.ts +0 -28
- package/src/hooks/promise.test.ts +0 -76
- package/src/hooks/promise.ts +0 -35
- package/src/utils/events.test.ts +0 -65
- package/src/utils/events.ts +0 -39
- package/esm/{components → defaults}/DefaultErrorInfo.d.ts +0 -0
- package/esm/{components → defaults}/DefaultLayout.d.ts +0 -0
- package/esm/{components/DefaultLoader.d.ts → defaults/DefaultLoadingIndicator.d.ts} +0 -0
- package/esm/{components → setters}/SetComponent.d.ts +0 -0
- package/esm/{components → setters}/SetError.d.ts +0 -0
- package/esm/{components → setters}/SetErrors.d.ts +0 -0
- package/esm/{components → setters}/SetLayout.d.ts +0 -0
- package/esm/{components → setters}/SetProvider.d.ts +0 -0
- package/esm/{components → setters}/SetRedirect.d.ts +0 -0
- package/lib/{components → defaults}/DefaultErrorInfo.d.ts +0 -0
- package/lib/{components → defaults}/DefaultLayout.d.ts +0 -0
- package/lib/{components/DefaultLoader.d.ts → defaults/DefaultLoadingIndicator.d.ts} +0 -0
- package/lib/{components → setters}/SetComponent.d.ts +0 -0
- package/lib/{components → setters}/SetError.d.ts +0 -0
- package/lib/{components → setters}/SetErrors.d.ts +0 -0
- package/lib/{components → setters}/SetLayout.d.ts +0 -0
- package/lib/{components → setters}/SetProvider.d.ts +0 -0
- package/lib/{components → setters}/SetRedirect.d.ts +0 -0
- package/src/{components → defaults}/DefaultLayout.tsx +1 -1
- /package/src/{components/DefaultLoader.tsx → defaults/DefaultLoadingIndicator.tsx} +0 -0
- /package/src/{components → setters}/SetErrors.tsx +0 -0
- /package/src/{components → setters}/SetLayout.tsx +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import create from 'zustand';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
4
|
import { SetError } from './SetError';
|
|
5
5
|
import { StateContext } from '../state';
|
|
6
6
|
|
|
@@ -8,9 +8,9 @@ const FakeError = () => null;
|
|
|
8
8
|
FakeError.displayName = 'FakeError';
|
|
9
9
|
|
|
10
10
|
function createMockContainer() {
|
|
11
|
-
const state =
|
|
11
|
+
const state = create(() => ({
|
|
12
12
|
errorComponents: {},
|
|
13
|
-
});
|
|
13
|
+
}));
|
|
14
14
|
return {
|
|
15
15
|
context: {
|
|
16
16
|
on: jest.fn(),
|
|
@@ -18,13 +18,14 @@ function createMockContainer() {
|
|
|
18
18
|
emit: jest.fn(),
|
|
19
19
|
state,
|
|
20
20
|
setErrorComponent(name, comp) {
|
|
21
|
-
|
|
21
|
+
const s = state.getState();
|
|
22
|
+
state.setState({
|
|
22
23
|
...s,
|
|
23
24
|
errorComponents: {
|
|
24
25
|
...s.errorComponents,
|
|
25
26
|
[name]: comp,
|
|
26
27
|
},
|
|
27
|
-
})
|
|
28
|
+
});
|
|
28
29
|
},
|
|
29
30
|
} as any,
|
|
30
31
|
};
|
|
@@ -33,12 +34,12 @@ function createMockContainer() {
|
|
|
33
34
|
describe('Piral-Core SetError component', () => {
|
|
34
35
|
it('SetError sets the error component in the store', () => {
|
|
35
36
|
const { context } = createMockContainer();
|
|
36
|
-
|
|
37
|
+
render(
|
|
37
38
|
<StateContext.Provider value={context}>
|
|
38
39
|
<SetError type="loading" component={FakeError} />
|
|
39
40
|
</StateContext.Provider>,
|
|
40
41
|
);
|
|
41
|
-
expect(
|
|
42
|
+
expect((context.state.getState()).errorComponents).toEqual({
|
|
42
43
|
loading: FakeError,
|
|
43
44
|
});
|
|
44
45
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useGlobalStateContext, useSetter } from '../hooks';
|
|
3
3
|
import { ErrorComponentsState } from '../types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -23,7 +23,7 @@ export function SetError<TKey extends keyof ErrorComponentsState>({
|
|
|
23
23
|
type,
|
|
24
24
|
component,
|
|
25
25
|
}: SetErrorProps<TKey>): React.ReactElement {
|
|
26
|
-
const setErrorComponent =
|
|
26
|
+
const { setErrorComponent } = useGlobalStateContext();
|
|
27
27
|
useSetter(() => component && setErrorComponent(type, component));
|
|
28
28
|
// tslint:disable-next-line:no-null-keyword
|
|
29
29
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import create from 'zustand';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
4
|
import { SetErrors } from './SetErrors';
|
|
5
5
|
import { StateContext } from '../state/stateContext';
|
|
6
6
|
|
|
@@ -8,9 +8,9 @@ const FakeError = () => null;
|
|
|
8
8
|
FakeError.displayName = 'FakeError';
|
|
9
9
|
|
|
10
10
|
function createMockContainer() {
|
|
11
|
-
const state =
|
|
11
|
+
const state = create(() => ({
|
|
12
12
|
errorComponents: {},
|
|
13
|
-
});
|
|
13
|
+
}));
|
|
14
14
|
return {
|
|
15
15
|
context: {
|
|
16
16
|
on: jest.fn(),
|
|
@@ -18,13 +18,14 @@ function createMockContainer() {
|
|
|
18
18
|
emit: jest.fn(),
|
|
19
19
|
state,
|
|
20
20
|
setErrorComponent(name, comp) {
|
|
21
|
-
|
|
21
|
+
const s = state.getState();
|
|
22
|
+
state.setState({
|
|
22
23
|
...s,
|
|
23
24
|
errorComponents: {
|
|
24
25
|
...s.errorComponents,
|
|
25
26
|
[name]: comp,
|
|
26
27
|
},
|
|
27
|
-
})
|
|
28
|
+
});
|
|
28
29
|
},
|
|
29
30
|
} as any,
|
|
30
31
|
};
|
|
@@ -33,7 +34,7 @@ function createMockContainer() {
|
|
|
33
34
|
describe('Piral SetErrors component', () => {
|
|
34
35
|
it('SetErrors sets the error components', () => {
|
|
35
36
|
const { context } = createMockContainer();
|
|
36
|
-
|
|
37
|
+
render(
|
|
37
38
|
<StateContext.Provider value={context}>
|
|
38
39
|
<SetErrors
|
|
39
40
|
errors={
|
|
@@ -44,7 +45,7 @@ describe('Piral SetErrors component', () => {
|
|
|
44
45
|
/>
|
|
45
46
|
</StateContext.Provider>,
|
|
46
47
|
);
|
|
47
|
-
expect(
|
|
48
|
+
expect(context.state.getState().errorComponents).toEqual({
|
|
48
49
|
menu: FakeError,
|
|
49
50
|
});
|
|
50
51
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import create from 'zustand';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
4
|
import { SetLayout } from './SetLayout';
|
|
5
5
|
import { StateContext } from '../state/stateContext';
|
|
6
6
|
|
|
@@ -8,9 +8,9 @@ const FakeContainer = () => null;
|
|
|
8
8
|
FakeContainer.displayName = 'FakeContainer';
|
|
9
9
|
|
|
10
10
|
function createMockContainer() {
|
|
11
|
-
const state =
|
|
11
|
+
const state = create(() => ({
|
|
12
12
|
components: {},
|
|
13
|
-
});
|
|
13
|
+
}));
|
|
14
14
|
return {
|
|
15
15
|
context: {
|
|
16
16
|
on: jest.fn(),
|
|
@@ -18,13 +18,14 @@ function createMockContainer() {
|
|
|
18
18
|
emit: jest.fn(),
|
|
19
19
|
state,
|
|
20
20
|
setComponent(name, comp) {
|
|
21
|
-
|
|
21
|
+
const s = state.getState();
|
|
22
|
+
state.setState({
|
|
22
23
|
...s,
|
|
23
24
|
components: {
|
|
24
25
|
...s.components,
|
|
25
26
|
[name]: comp,
|
|
26
27
|
},
|
|
27
|
-
})
|
|
28
|
+
});
|
|
28
29
|
},
|
|
29
30
|
} as any,
|
|
30
31
|
};
|
|
@@ -33,7 +34,7 @@ function createMockContainer() {
|
|
|
33
34
|
describe('Piral SetLayout component', () => {
|
|
34
35
|
it('SetLayout sets the layout components', () => {
|
|
35
36
|
const { context } = createMockContainer();
|
|
36
|
-
|
|
37
|
+
render(
|
|
37
38
|
<StateContext.Provider value={context}>
|
|
38
39
|
<SetLayout
|
|
39
40
|
layout={
|
|
@@ -44,7 +45,7 @@ describe('Piral SetLayout component', () => {
|
|
|
44
45
|
/>
|
|
45
46
|
</StateContext.Provider>,
|
|
46
47
|
);
|
|
47
|
-
expect(
|
|
48
|
+
expect(context.state.getState().components).toEqual({
|
|
48
49
|
DashboardContainer: FakeContainer,
|
|
49
50
|
});
|
|
50
51
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import create from 'zustand';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
4
|
import { SetProvider } from './SetProvider';
|
|
5
5
|
import { StateContext } from '../state';
|
|
6
6
|
|
|
@@ -8,9 +8,9 @@ const FakeProvider = () => null;
|
|
|
8
8
|
FakeProvider.displayName = 'FakeProvider';
|
|
9
9
|
|
|
10
10
|
function createMockContainer() {
|
|
11
|
-
const state =
|
|
11
|
+
const state = create(() => ({
|
|
12
12
|
providers: [],
|
|
13
|
-
});
|
|
13
|
+
}));
|
|
14
14
|
return {
|
|
15
15
|
context: {
|
|
16
16
|
on: jest.fn(),
|
|
@@ -18,10 +18,11 @@ function createMockContainer() {
|
|
|
18
18
|
emit: jest.fn(),
|
|
19
19
|
state,
|
|
20
20
|
includeProvider(provider) {
|
|
21
|
-
|
|
21
|
+
const update = (s) => ({
|
|
22
22
|
...s,
|
|
23
23
|
providers: [...s.providers, provider],
|
|
24
|
-
})
|
|
24
|
+
});
|
|
25
|
+
state.setState(update(state.getState()));
|
|
25
26
|
},
|
|
26
27
|
} as any,
|
|
27
28
|
};
|
|
@@ -31,11 +32,11 @@ describe('Piral-Core SetProvider component', () => {
|
|
|
31
32
|
it('SetProvider uses the includeProvider action', () => {
|
|
32
33
|
const { context } = createMockContainer();
|
|
33
34
|
const provider = <FakeProvider />;
|
|
34
|
-
|
|
35
|
+
render(
|
|
35
36
|
<StateContext.Provider value={context}>
|
|
36
37
|
<SetProvider provider={provider} />
|
|
37
38
|
</StateContext.Provider>,
|
|
38
39
|
);
|
|
39
|
-
expect(
|
|
40
|
+
expect(context.state.getState().providers).toEqual([provider]);
|
|
40
41
|
});
|
|
41
42
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useGlobalStateContext, useSetter } from '../hooks';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The props for the SetProvider component.
|
|
@@ -15,7 +15,7 @@ export interface SetProviderProps {
|
|
|
15
15
|
* The component capable of setting a global provider at mounting.
|
|
16
16
|
*/
|
|
17
17
|
export function SetProvider({ provider }: SetProviderProps): React.ReactElement {
|
|
18
|
-
const includeProvider =
|
|
18
|
+
const {includeProvider} = useGlobalStateContext();
|
|
19
19
|
useSetter(() => provider && includeProvider(provider));
|
|
20
20
|
// tslint:disable-next-line:no-null-keyword
|
|
21
21
|
return null;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import create from 'zustand';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
4
|
import { SetRedirect } from './SetRedirect';
|
|
5
5
|
import { StateContext } from '../state';
|
|
6
6
|
|
|
7
7
|
function createMockContainer() {
|
|
8
|
-
const state =
|
|
8
|
+
const state = create(() => ({
|
|
9
9
|
routes: {},
|
|
10
|
-
});
|
|
10
|
+
}));
|
|
11
11
|
return {
|
|
12
12
|
context: {
|
|
13
13
|
on: jest.fn(),
|
|
@@ -15,13 +15,14 @@ function createMockContainer() {
|
|
|
15
15
|
emit: jest.fn(),
|
|
16
16
|
state,
|
|
17
17
|
setRoute(name, comp) {
|
|
18
|
-
|
|
18
|
+
const update = (s) => ({
|
|
19
19
|
...s,
|
|
20
20
|
routes: {
|
|
21
21
|
...s.routes,
|
|
22
22
|
[name]: comp,
|
|
23
23
|
},
|
|
24
|
-
})
|
|
24
|
+
});
|
|
25
|
+
state.setState(update(state.getState()));
|
|
25
26
|
},
|
|
26
27
|
} as any,
|
|
27
28
|
};
|
|
@@ -30,12 +31,12 @@ function createMockContainer() {
|
|
|
30
31
|
describe('Piral-Core SetRedirect component', () => {
|
|
31
32
|
it('SetRedirect sets the redirect route in the store', () => {
|
|
32
33
|
const { context } = createMockContainer();
|
|
33
|
-
|
|
34
|
+
render(
|
|
34
35
|
<StateContext.Provider value={context}>
|
|
35
36
|
<SetRedirect from="/foo" to="/bar" />
|
|
36
37
|
</StateContext.Provider>,
|
|
37
38
|
);
|
|
38
|
-
expect(
|
|
39
|
+
expect(context.state.getState().routes).toEqual({
|
|
39
40
|
'/foo': expect.anything(),
|
|
40
41
|
});
|
|
41
42
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useGlobalStateContext, useSetter } from '../hooks';
|
|
3
|
+
import { createRedirect } from '../../app.codegen';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The props for the SetRedirect component.
|
|
@@ -20,8 +20,8 @@ export interface SetRedirectProps {
|
|
|
20
20
|
* The component capable of setting a global redirect route at mounting.
|
|
21
21
|
*/
|
|
22
22
|
export function SetRedirect({ from, to }: SetRedirectProps): React.ReactElement {
|
|
23
|
-
const setRoute =
|
|
24
|
-
useSetter(() => setRoute(from, (
|
|
23
|
+
const { setRoute } = useGlobalStateContext();
|
|
24
|
+
useSetter(() => setRoute(from, createRedirect(to)));
|
|
25
25
|
// tslint:disable-next-line:no-null-keyword
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import create from 'zustand';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
4
|
import { SetRoute } from './SetRoute';
|
|
5
5
|
import { StateContext } from '../state';
|
|
6
6
|
|
|
@@ -8,9 +8,9 @@ const FakeRoute = () => null;
|
|
|
8
8
|
FakeRoute.displayName = 'FakeRoute';
|
|
9
9
|
|
|
10
10
|
function createMockContainer() {
|
|
11
|
-
const state =
|
|
11
|
+
const state = create(() => ({
|
|
12
12
|
routes: {},
|
|
13
|
-
});
|
|
13
|
+
}));
|
|
14
14
|
return {
|
|
15
15
|
context: {
|
|
16
16
|
on: jest.fn(),
|
|
@@ -18,13 +18,14 @@ function createMockContainer() {
|
|
|
18
18
|
emit: jest.fn(),
|
|
19
19
|
state,
|
|
20
20
|
setRoute(name, comp) {
|
|
21
|
-
|
|
21
|
+
const update = (s) => ({
|
|
22
22
|
...s,
|
|
23
23
|
routes: {
|
|
24
24
|
...s.routes,
|
|
25
25
|
[name]: comp,
|
|
26
26
|
},
|
|
27
|
-
})
|
|
27
|
+
});
|
|
28
|
+
state.setState(update(state.getState()));
|
|
28
29
|
},
|
|
29
30
|
} as any,
|
|
30
31
|
};
|
|
@@ -33,12 +34,12 @@ function createMockContainer() {
|
|
|
33
34
|
describe('Piral-Core SetRoute component', () => {
|
|
34
35
|
it('SetRoute sets the link route in the store', () => {
|
|
35
36
|
const { context } = createMockContainer();
|
|
36
|
-
|
|
37
|
+
render(
|
|
37
38
|
<StateContext.Provider value={context}>
|
|
38
39
|
<SetRoute path="/foo" component={FakeRoute} />
|
|
39
40
|
</StateContext.Provider>,
|
|
40
41
|
);
|
|
41
|
-
expect(
|
|
42
|
+
expect(context.state.getState().routes).toEqual({
|
|
42
43
|
'/foo': FakeRoute,
|
|
43
44
|
});
|
|
44
45
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { RouteComponentProps } from 'react-router';
|
|
3
|
-
import {
|
|
3
|
+
import { useGlobalStateContext, useSetter } from '../hooks';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The props for the SetRoute component.
|
|
7
7
|
*/
|
|
8
|
-
export interface SetRouteProps<T = {}> {
|
|
8
|
+
export interface SetRouteProps<T extends { [K in keyof T]?: string } = {}> {
|
|
9
9
|
/**
|
|
10
10
|
* The path to the route.
|
|
11
11
|
*/
|
|
@@ -19,8 +19,11 @@ export interface SetRouteProps<T = {}> {
|
|
|
19
19
|
/**
|
|
20
20
|
* The component capable of setting a global route at mounting.
|
|
21
21
|
*/
|
|
22
|
-
export function SetRoute<T
|
|
23
|
-
|
|
22
|
+
export function SetRoute<T extends { [K in keyof T]?: string } = {}>({
|
|
23
|
+
path,
|
|
24
|
+
component,
|
|
25
|
+
}: SetRouteProps<T>): React.ReactElement {
|
|
26
|
+
const { setRoute } = useGlobalStateContext();
|
|
24
27
|
useSetter(() => component && setRoute(path, component));
|
|
25
28
|
// tslint:disable-next-line:no-null-keyword
|
|
26
29
|
return null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { createListener } from 'piral-base';
|
|
1
2
|
import { createActions, includeActions } from './createActions';
|
|
2
|
-
import { createListener } from '../utils';
|
|
3
3
|
|
|
4
4
|
jest.mock('../actions', () => ({
|
|
5
5
|
a(arg) {
|
|
@@ -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,14 +1,16 @@
|
|
|
1
1
|
import * as actions from '../actions';
|
|
2
|
-
import {
|
|
2
|
+
import { UseBoundStore } from 'zustand';
|
|
3
|
+
import { createNavigation } from '../../app.codegen';
|
|
3
4
|
import { EventEmitter, GlobalState, GlobalStateContext, PiralDefineActions } from '../types';
|
|
4
5
|
|
|
5
|
-
function createContext(state:
|
|
6
|
+
function createContext(state: UseBoundStore<GlobalState>, events: EventEmitter) {
|
|
6
7
|
const ctx = {
|
|
7
8
|
...events,
|
|
8
9
|
apis: {},
|
|
9
10
|
converters: {
|
|
10
11
|
html: ({ component }) => component,
|
|
11
12
|
},
|
|
13
|
+
navigation: createNavigation(),
|
|
12
14
|
state,
|
|
13
15
|
} as GlobalStateContext;
|
|
14
16
|
return ctx;
|
|
@@ -23,7 +25,7 @@ export function includeActions(ctx: GlobalStateContext, actions: PiralDefineActi
|
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
export function createActions(state:
|
|
28
|
+
export function createActions(state: UseBoundStore<GlobalState>, events: EventEmitter): GlobalStateContext {
|
|
27
29
|
const context = createContext(state, events);
|
|
28
30
|
includeActions(context, actions);
|
|
29
31
|
return context;
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import { deref } from '@dbeining/react-atom';
|
|
2
|
-
import { BrowserRouter as DefaultRouter } from 'react-router-dom';
|
|
3
1
|
import { createGlobalState } from './createGlobalState';
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
process.env.PIRAL_PUBLIC_PATH = '/';
|
|
5
4
|
|
|
6
5
|
describe('Create Global State Module', () => {
|
|
7
6
|
window.matchMedia = jest.fn((q) => ({ matches: false })) as any;
|
|
8
7
|
|
|
9
8
|
it('global state works with language as empty string', () => {
|
|
10
9
|
const globalState = createGlobalState({});
|
|
11
|
-
|
|
10
|
+
const tmp = globalState.getState();
|
|
11
|
+
|
|
12
|
+
console.log(tmp);
|
|
13
|
+
|
|
14
|
+
expect(tmp).toEqual({
|
|
12
15
|
app: {
|
|
13
|
-
layout: 'desktop',
|
|
14
16
|
loading: true,
|
|
15
17
|
error: undefined,
|
|
16
18
|
},
|
|
17
19
|
errorComponents: {},
|
|
18
20
|
components: {
|
|
19
|
-
ErrorInfo:
|
|
20
|
-
LoadingIndicator:
|
|
21
|
-
Router:
|
|
22
|
-
Layout:
|
|
21
|
+
ErrorInfo: expect.anything(),
|
|
22
|
+
LoadingIndicator: expect.anything(),
|
|
23
|
+
Router: expect.anything(),
|
|
24
|
+
Layout: expect.anything(),
|
|
25
|
+
RouteSwitch: expect.anything(),
|
|
23
26
|
},
|
|
24
27
|
routes: {},
|
|
25
28
|
registry: {
|
|
@@ -35,18 +38,18 @@ describe('Create Global State Module', () => {
|
|
|
35
38
|
|
|
36
39
|
it('global state with custom language and translations', () => {
|
|
37
40
|
const globalState = createGlobalState({});
|
|
38
|
-
expect(
|
|
41
|
+
expect(globalState.getState()).toEqual({
|
|
39
42
|
app: {
|
|
40
|
-
layout: 'desktop',
|
|
41
43
|
loading: true,
|
|
42
44
|
error: undefined,
|
|
43
45
|
},
|
|
44
46
|
errorComponents: {},
|
|
45
47
|
components: {
|
|
46
|
-
ErrorInfo:
|
|
47
|
-
LoadingIndicator:
|
|
48
|
-
Router:
|
|
49
|
-
Layout:
|
|
48
|
+
ErrorInfo: expect.anything(),
|
|
49
|
+
LoadingIndicator: expect.anything(),
|
|
50
|
+
Router: expect.anything(),
|
|
51
|
+
Layout: expect.anything(),
|
|
52
|
+
RouteSwitch: expect.anything(),
|
|
50
53
|
},
|
|
51
54
|
routes: {},
|
|
52
55
|
registry: {
|
|
@@ -66,18 +69,18 @@ describe('Create Global State Module', () => {
|
|
|
66
69
|
'/foo': '...' as any,
|
|
67
70
|
};
|
|
68
71
|
const globalState = createGlobalState({ routes });
|
|
69
|
-
expect(
|
|
72
|
+
expect(globalState.getState()).toEqual({
|
|
70
73
|
app: {
|
|
71
74
|
error: undefined,
|
|
72
|
-
layout: 'desktop',
|
|
73
75
|
loading: true,
|
|
74
76
|
},
|
|
75
77
|
errorComponents: {},
|
|
76
78
|
components: {
|
|
77
|
-
ErrorInfo:
|
|
78
|
-
LoadingIndicator:
|
|
79
|
-
Router:
|
|
80
|
-
Layout:
|
|
79
|
+
ErrorInfo: expect.anything(),
|
|
80
|
+
LoadingIndicator: expect.anything(),
|
|
81
|
+
Router: expect.anything(),
|
|
82
|
+
Layout: expect.anything(),
|
|
83
|
+
RouteSwitch: expect.anything(),
|
|
81
84
|
},
|
|
82
85
|
routes,
|
|
83
86
|
registry: {
|
|
@@ -93,18 +96,18 @@ describe('Create Global State Module', () => {
|
|
|
93
96
|
|
|
94
97
|
it('global state can be created without arguments', () => {
|
|
95
98
|
const globalState = createGlobalState();
|
|
96
|
-
expect(
|
|
99
|
+
expect(globalState.getState()).toEqual({
|
|
97
100
|
app: {
|
|
98
|
-
layout: 'desktop',
|
|
99
101
|
loading: true,
|
|
100
102
|
error: undefined,
|
|
101
103
|
},
|
|
102
104
|
errorComponents: {},
|
|
103
105
|
components: {
|
|
104
|
-
ErrorInfo:
|
|
105
|
-
LoadingIndicator:
|
|
106
|
-
Router:
|
|
107
|
-
Layout:
|
|
106
|
+
ErrorInfo: expect.anything(),
|
|
107
|
+
LoadingIndicator: expect.anything(),
|
|
108
|
+
Router: expect.anything(),
|
|
109
|
+
Layout: expect.anything(),
|
|
110
|
+
RouteSwitch: expect.anything(),
|
|
108
111
|
},
|
|
109
112
|
registry: {
|
|
110
113
|
extensions: {},
|
|
@@ -122,18 +125,18 @@ describe('Create Global State Module', () => {
|
|
|
122
125
|
const globalState = createGlobalState({
|
|
123
126
|
app: {},
|
|
124
127
|
});
|
|
125
|
-
expect(
|
|
128
|
+
expect(globalState.getState()).toEqual({
|
|
126
129
|
app: {
|
|
127
|
-
layout: 'desktop',
|
|
128
130
|
loading: true,
|
|
129
131
|
error: undefined,
|
|
130
132
|
},
|
|
131
133
|
errorComponents: {},
|
|
132
134
|
components: {
|
|
133
|
-
ErrorInfo:
|
|
134
|
-
LoadingIndicator:
|
|
135
|
-
Router:
|
|
136
|
-
Layout:
|
|
135
|
+
ErrorInfo: expect.anything(),
|
|
136
|
+
LoadingIndicator: expect.anything(),
|
|
137
|
+
Router: expect.anything(),
|
|
138
|
+
Layout: expect.anything(),
|
|
139
|
+
RouteSwitch: expect.anything(),
|
|
137
140
|
},
|
|
138
141
|
registry: {
|
|
139
142
|
extensions: {},
|
|
@@ -151,18 +154,18 @@ describe('Create Global State Module', () => {
|
|
|
151
154
|
const globalState = createGlobalState({
|
|
152
155
|
app: {},
|
|
153
156
|
});
|
|
154
|
-
expect(
|
|
157
|
+
expect(globalState.getState()).toEqual({
|
|
155
158
|
app: {
|
|
156
|
-
layout: 'desktop',
|
|
157
159
|
loading: true,
|
|
158
160
|
error: undefined,
|
|
159
161
|
},
|
|
160
162
|
errorComponents: {},
|
|
161
163
|
components: {
|
|
162
|
-
ErrorInfo:
|
|
163
|
-
LoadingIndicator:
|
|
164
|
-
Router:
|
|
165
|
-
Layout:
|
|
164
|
+
ErrorInfo: expect.anything(),
|
|
165
|
+
LoadingIndicator: expect.anything(),
|
|
166
|
+
Router: expect.anything(),
|
|
167
|
+
Layout: expect.anything(),
|
|
168
|
+
RouteSwitch: expect.anything(),
|
|
166
169
|
},
|
|
167
170
|
registry: {
|
|
168
171
|
extensions: {},
|
|
@@ -178,26 +181,24 @@ describe('Create Global State Module', () => {
|
|
|
178
181
|
|
|
179
182
|
it('global state with non-default breakpoints and more routes', () => {
|
|
180
183
|
const globalState = createGlobalState({
|
|
181
|
-
app: {
|
|
182
|
-
layout: 'desktop',
|
|
183
|
-
},
|
|
184
|
+
app: {},
|
|
184
185
|
routes: {
|
|
185
186
|
'/': '...' as any,
|
|
186
187
|
'/foo': '...' as any,
|
|
187
188
|
},
|
|
188
189
|
});
|
|
189
|
-
expect(
|
|
190
|
+
expect(globalState.getState()).toEqual({
|
|
190
191
|
app: {
|
|
191
|
-
layout: 'desktop',
|
|
192
192
|
loading: true,
|
|
193
193
|
error: undefined,
|
|
194
194
|
},
|
|
195
195
|
errorComponents: {},
|
|
196
196
|
components: {
|
|
197
|
-
ErrorInfo:
|
|
198
|
-
LoadingIndicator:
|
|
199
|
-
Router:
|
|
200
|
-
Layout:
|
|
197
|
+
ErrorInfo: expect.anything(),
|
|
198
|
+
LoadingIndicator: expect.anything(),
|
|
199
|
+
Router: expect.anything(),
|
|
200
|
+
Layout: expect.anything(),
|
|
201
|
+
RouteSwitch: expect.anything(),
|
|
201
202
|
},
|
|
202
203
|
registry: {
|
|
203
204
|
extensions: {},
|
|
@@ -220,18 +221,18 @@ describe('Create Global State Module', () => {
|
|
|
220
221
|
loading: false,
|
|
221
222
|
},
|
|
222
223
|
});
|
|
223
|
-
expect(
|
|
224
|
+
expect(globalState.getState()).toEqual({
|
|
224
225
|
app: {
|
|
225
|
-
layout: 'desktop',
|
|
226
226
|
loading: false,
|
|
227
227
|
error: undefined,
|
|
228
228
|
},
|
|
229
229
|
errorComponents: {},
|
|
230
230
|
components: {
|
|
231
|
-
ErrorInfo:
|
|
232
|
-
LoadingIndicator:
|
|
233
|
-
Router:
|
|
234
|
-
Layout:
|
|
231
|
+
ErrorInfo: expect.anything(),
|
|
232
|
+
LoadingIndicator: expect.anything(),
|
|
233
|
+
Router: expect.anything(),
|
|
234
|
+
Layout: expect.anything(),
|
|
235
|
+
RouteSwitch: expect.anything(),
|
|
235
236
|
},
|
|
236
237
|
registry: {
|
|
237
238
|
extensions: {},
|