piral-core 1.0.0-pre.2217 → 1.0.0
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 +4 -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 -68
- 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 +37 -10
- 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 -74
- 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 +37 -10
- 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 +55 -18
- 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 -65
- 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 +50 -11
- 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
package/esm/helpers.d.ts
CHANGED
|
@@ -1,31 +1,17 @@
|
|
|
1
|
-
import { PiletApiCreator, LoadPiletsOptions, CustomSpecLoaders, DefaultLoaderConfig,
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
* Creates a dependency getter that sets the shared dependencies explicitly.
|
|
5
|
-
* Overrides the potentially set shared dependencies from the Piral CLI, but
|
|
6
|
-
* keeps all global dependencies such as react, react-dom, ...
|
|
7
|
-
* @param sharedDependencies The shared dependencies to declare.
|
|
8
|
-
*/
|
|
9
|
-
export declare function setSharedDependencies(sharedDependencies: AvailableDependencies): () => {
|
|
10
|
-
[x: string]: any;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Creates a dependency getter that extends the shared dependencies with additional dependencies.
|
|
14
|
-
* @param additionalDependencies The additional dependencies to declare.
|
|
15
|
-
*/
|
|
16
|
-
export declare function extendSharedDependencies(additionalDependencies: AvailableDependencies): () => {
|
|
17
|
-
[x: string]: any;
|
|
18
|
-
};
|
|
1
|
+
import { PiletApiCreator, LoadPiletsOptions, CustomSpecLoaders, DefaultLoaderConfig, PiletLoader, PiletLifecycleHooks } from 'piral-base';
|
|
2
|
+
import type { DebuggerExtensionOptions } from 'piral-debug-utils';
|
|
3
|
+
import type { Pilet, PiletRequester, GlobalStateContext, PiletLoadingStrategy, DependencySelector } from './types';
|
|
19
4
|
export interface PiletOptionsConfig {
|
|
5
|
+
context: GlobalStateContext;
|
|
6
|
+
hooks?: PiletLifecycleHooks;
|
|
7
|
+
loaders?: CustomSpecLoaders;
|
|
8
|
+
loaderConfig?: DefaultLoaderConfig;
|
|
20
9
|
availablePilets: Array<Pilet>;
|
|
21
|
-
createApi: PiletApiCreator;
|
|
22
|
-
fetchDependency: PiletDependencyFetcher;
|
|
23
|
-
getDependencies: PiletDependencyGetter;
|
|
24
10
|
strategy: PiletLoadingStrategy;
|
|
25
|
-
|
|
26
|
-
loaderConfig?: DefaultLoaderConfig;
|
|
27
|
-
loaders?: CustomSpecLoaders;
|
|
11
|
+
createApi: PiletApiCreator;
|
|
28
12
|
loadPilet: PiletLoader;
|
|
29
|
-
|
|
13
|
+
requestPilets: PiletRequester;
|
|
14
|
+
shareDependencies: DependencySelector;
|
|
15
|
+
debug?: DebuggerExtensionOptions;
|
|
30
16
|
}
|
|
31
|
-
export declare function createPiletOptions({ context,
|
|
17
|
+
export declare function createPiletOptions({ hooks, context, loaders, loaderConfig, availablePilets, strategy, createApi, loadPilet, requestPilets, shareDependencies, debug, }: PiletOptionsConfig): LoadPiletsOptions;
|
package/esm/helpers.js
CHANGED
|
@@ -1,77 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
export function setSharedDependencies(sharedDependencies) {
|
|
12
|
-
var dependencies = __assign(__assign({}, globalDependencies), sharedDependencies);
|
|
13
|
-
return function () { return dependencies; };
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Creates a dependency getter that extends the shared dependencies with additional dependencies.
|
|
17
|
-
* @param additionalDependencies The additional dependencies to declare.
|
|
18
|
-
*/
|
|
19
|
-
export function extendSharedDependencies(additionalDependencies) {
|
|
20
|
-
var dependencies = __assign(__assign({}, getLocalDependencies()), additionalDependencies);
|
|
21
|
-
return function () { return dependencies; };
|
|
22
|
-
}
|
|
23
|
-
export function createPiletOptions(_a) {
|
|
24
|
-
var context = _a.context, createApi = _a.createApi, availablePilets = _a.availablePilets, fetchDependency = _a.fetchDependency, getDependencies = _a.getDependencies, loaderConfig = _a.loaderConfig, loadPilet = _a.loadPilet, strategy = _a.strategy, loaders = _a.loaders, requestPilets = _a.requestPilets;
|
|
25
|
-
getDependencies = getDependencyResolver(globalDependencies, getDependencies);
|
|
26
|
-
loadPilet = extendLoader(loadPilet !== null && loadPilet !== void 0 ? loadPilet : getDefaultLoader(getDependencies, fetchDependency, loaderConfig), loaders);
|
|
27
|
-
// if we build the debug version of piral (debug and emulator build)
|
|
28
|
-
if (process.env.DEBUG_PIRAL) {
|
|
29
|
-
var installPiralDebug = require('piral-debug-utils').installPiralDebug;
|
|
30
|
-
installPiralDebug({
|
|
31
|
-
context: context,
|
|
32
|
-
createApi: createApi,
|
|
33
|
-
getDependencies: getDependencies,
|
|
34
|
-
loadPilet: loadPilet,
|
|
35
|
-
requestPilets: requestPilets,
|
|
36
|
-
});
|
|
37
|
-
// we watch the state container for changes
|
|
38
|
-
addChangeHandler(context.state, 'debugging', function (_a) {
|
|
39
|
-
var current = _a.current, previous = _a.previous;
|
|
40
|
-
var viewState = sessionStorage.getItem('dbg:view-state') !== 'off';
|
|
41
|
-
if (viewState) {
|
|
42
|
-
var infos = new Error().stack;
|
|
43
|
-
if (infos) {
|
|
44
|
-
// Chrome, Firefox, ... (full capability)
|
|
45
|
-
var action = infos.split('\n')[7].replace(/^\s+at\s+(Atom\.|Object\.)?/, '');
|
|
46
|
-
console.group("%c Piral State Change %c " + new Date().toLocaleTimeString(), 'color: gray; font-weight: lighter;', 'color: black; font-weight: bold;');
|
|
47
|
-
console.log('%c Previous', "color: #9E9E9E; font-weight: bold", previous);
|
|
48
|
-
console.log('%c Action', "color: #03A9F4; font-weight: bold", action);
|
|
49
|
-
console.log('%c Next', "color: #4CAF50; font-weight: bold", current);
|
|
50
|
-
console.groupEnd();
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
// IE 11, ... (does not know colors etc.)
|
|
54
|
-
console.log('Changed state', previous, current);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
if (process.env.DEBUG_PILET) {
|
|
60
|
-
var withEmulatorPilets = require('piral-debug-utils').withEmulatorPilets;
|
|
61
|
-
requestPilets = withEmulatorPilets(requestPilets, {
|
|
62
|
-
inject: context.injectPilet,
|
|
63
|
-
createApi: createApi,
|
|
64
|
-
loadPilet: loadPilet,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
strategy: strategy,
|
|
69
|
-
loadPilet: loadPilet,
|
|
70
|
-
createApi: createApi,
|
|
71
|
-
getDependencies: getDependencies,
|
|
1
|
+
import { getDefaultLoader, extendLoader, } from 'piral-base';
|
|
2
|
+
import { globalDependencies } from './modules';
|
|
3
|
+
import { integrateDebugger, integrateEmulator } from '../app.codegen';
|
|
4
|
+
export function createPiletOptions({ hooks, context, loaders, loaderConfig, availablePilets, strategy, createApi, loadPilet, requestPilets, shareDependencies, debug, }) {
|
|
5
|
+
const options = {
|
|
6
|
+
config: loaderConfig,
|
|
7
|
+
strategy,
|
|
8
|
+
loadPilet: extendLoader(loadPilet !== null && loadPilet !== void 0 ? loadPilet : getDefaultLoader(loaderConfig), loaders),
|
|
9
|
+
createApi,
|
|
72
10
|
pilets: availablePilets,
|
|
73
11
|
fetchPilets: requestPilets,
|
|
74
|
-
|
|
12
|
+
hooks,
|
|
13
|
+
dependencies: shareDependencies(globalDependencies),
|
|
75
14
|
};
|
|
15
|
+
integrateDebugger(context, options, debug);
|
|
16
|
+
integrateEmulator(context, options, debug);
|
|
17
|
+
return options;
|
|
76
18
|
}
|
|
77
19
|
//# sourceMappingURL=helpers.js.map
|
package/esm/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,gBAAgB,EAChB,YAAY,GAGb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAgBtE,MAAM,UAAU,kBAAkB,CAAC,EACjC,KAAK,EACL,OAAO,EACP,OAAO,EACP,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,KAAK,GACc;IACnB,MAAM,OAAO,GAAsB;QACjC,MAAM,EAAE,YAAY;QACpB,QAAQ;QACR,SAAS,EAAE,YAAY,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,gBAAgB,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;QAC7E,SAAS;QACT,MAAM,EAAE,eAAe;QACvB,WAAW,EAAE,aAAa;QAC1B,KAAK;QACL,YAAY,EAAE,iBAAiB,CAAC,kBAAkB,CAAC;KACpD,CAAC;IAEF,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC3C,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAE3C,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/esm/hooks/action.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StateContext } from '../state/stateContext';
|
|
1
|
+
import { useGlobalStateContext } from './globalState';
|
|
3
2
|
/**
|
|
4
3
|
* Hook that gets an action for manipulating the global state.
|
|
5
4
|
* @param action The name of the action to retrieve.
|
|
6
5
|
*/
|
|
7
6
|
export function useAction(action) {
|
|
8
|
-
|
|
7
|
+
const ctx = useGlobalStateContext();
|
|
9
8
|
return ctx[action];
|
|
10
9
|
}
|
|
11
10
|
//# sourceMappingURL=action.js.map
|
package/esm/hooks/action.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/hooks/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/hooks/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAGtD;;;GAGG;AACH,MAAM,UAAU,SAAS,CAA+B,MAAS;IAC/D,MAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;IACpC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC;AACrB,CAAC"}
|
package/esm/hooks/actions.js
CHANGED
|
@@ -5,7 +5,7 @@ import { StateContext } from '../state/stateContext';
|
|
|
5
5
|
* Hook that gets the actions for manipulating the global state.
|
|
6
6
|
*/
|
|
7
7
|
export function useActions() {
|
|
8
|
-
|
|
8
|
+
const _a = useContext(StateContext), { state } = _a, actions = __rest(_a, ["state"]);
|
|
9
9
|
return actions;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=actions.js.map
|
package/esm/hooks/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/hooks/actions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/hooks/actions.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD;;GAEG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,KAAwB,UAAU,CAAqB,YAAY,CAAC,EAApE,EAAE,KAAK,OAA6D,EAAxD,OAAO,cAAnB,SAAqB,CAA+C,CAAC;IAC3E,OAAO,OAAuB,CAAC;AACjC,CAAC"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { GlobalState } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to obtain the global state context, which gives you directly
|
|
4
|
+
* all actions, state, and more of the Piral instance.
|
|
5
|
+
* If you are only interested in reading out the state, use the
|
|
6
|
+
* `useGlobalState` hook instead.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useGlobalStateContext(): import("../types").GlobalStateContext;
|
|
2
9
|
/**
|
|
3
10
|
* Hook that yields the full global state.
|
|
4
11
|
* Any change to the global state yields the new state.
|
package/esm/hooks/globalState.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
|
-
import { useAtom, deref } from '@dbeining/react-atom';
|
|
3
2
|
import { StateContext } from '../state/stateContext';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Hook to obtain the global state context, which gives you directly
|
|
5
|
+
* all actions, state, and more of the Piral instance.
|
|
6
|
+
* If you are only interested in reading out the state, use the
|
|
7
|
+
* `useGlobalState` hook instead.
|
|
8
|
+
*/
|
|
9
|
+
export function useGlobalStateContext() {
|
|
10
|
+
return useContext(StateContext);
|
|
9
11
|
}
|
|
10
12
|
export function useGlobalState(select) {
|
|
11
|
-
|
|
12
|
-
return
|
|
13
|
+
const { state: useState } = useGlobalStateContext();
|
|
14
|
+
return useState(select);
|
|
13
15
|
}
|
|
14
16
|
//# sourceMappingURL=globalState.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalState.js","sourceRoot":"","sources":["../../src/hooks/globalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"globalState.js","sourceRoot":"","sources":["../../src/hooks/globalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,UAAU,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC;AAeD,MAAM,UAAU,cAAc,CAAI,MAAkC;IAClE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,qBAAqB,EAAE,CAAC;IACpD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC"}
|
package/esm/hooks/index.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
export * from './action';
|
|
2
2
|
export * from './actions';
|
|
3
|
-
export * from './debounce';
|
|
4
3
|
export * from './globalState';
|
|
5
|
-
export * from './
|
|
4
|
+
export * from './piletApi';
|
|
6
5
|
export * from './media';
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './onScreenVisible';
|
|
9
|
-
export * from './promise';
|
|
6
|
+
export * from './routes';
|
|
10
7
|
export * from './setter';
|
|
11
8
|
export * from './sharedData';
|
package/esm/hooks/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
export * from './action';
|
|
2
2
|
export * from './actions';
|
|
3
|
-
export * from './debounce';
|
|
4
3
|
export * from './globalState';
|
|
5
|
-
export * from './
|
|
4
|
+
export * from './piletApi';
|
|
6
5
|
export * from './media';
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './onScreenVisible';
|
|
9
|
-
export * from './promise';
|
|
6
|
+
export * from './routes';
|
|
10
7
|
export * from './setter';
|
|
11
8
|
export * from './sharedData';
|
|
12
9
|
//# sourceMappingURL=index.js.map
|
package/esm/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC"}
|
package/esm/hooks/media.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
|
+
import { none } from '../utils/helpers';
|
|
2
3
|
import { getCurrentLayout } from '../utils/media';
|
|
3
4
|
/**
|
|
4
5
|
* Hook to detect layout changes (e.g., which UI breakpoint was hit).
|
|
@@ -7,15 +8,15 @@ import { getCurrentLayout } from '../utils/media';
|
|
|
7
8
|
* @param defaultValue The default value.
|
|
8
9
|
*/
|
|
9
10
|
export function useMedia(queries, values, defaultValue) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
useEffect(
|
|
11
|
+
const match = () => getCurrentLayout(queries, values, defaultValue);
|
|
12
|
+
const [value, update] = useState(match);
|
|
13
|
+
useEffect(() => {
|
|
13
14
|
if (typeof document !== 'undefined') {
|
|
14
|
-
|
|
15
|
-
window.addEventListener('resize',
|
|
16
|
-
return
|
|
15
|
+
const handler = () => update(match);
|
|
16
|
+
window.addEventListener('resize', handler);
|
|
17
|
+
return () => window.removeEventListener('resize', handler);
|
|
17
18
|
}
|
|
18
|
-
},
|
|
19
|
+
}, none);
|
|
19
20
|
return value;
|
|
20
21
|
}
|
|
21
22
|
//# sourceMappingURL=media.js.map
|
package/esm/hooks/media.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/hooks/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAI,OAAsB,EAAE,MAAgB,EAAE,YAAe;IACnF,
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/hooks/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAI,OAAsB,EAAE,MAAgB,EAAE,YAAe;IACnF,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;IACpE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;YACnC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACpC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC3C,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;SAC5D;IACH,CAAC,EAAE,IAAI,CAAC,CAAC;IAET,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uses the global state context to retrieve the pilet API stored
|
|
3
|
+
* for the root pilet. This allows interaction with the pilet API
|
|
4
|
+
* from the app shell.
|
|
5
|
+
* @returns The pilet API object of the root pilet.
|
|
6
|
+
*/
|
|
7
|
+
export declare function usePiletApi(): import("piral-base").PiletApi;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { useGlobalStateContext } from "./globalState";
|
|
3
|
+
/**
|
|
4
|
+
* Uses the global state context to retrieve the pilet API stored
|
|
5
|
+
* for the root pilet. This allows interaction with the pilet API
|
|
6
|
+
* from the app shell.
|
|
7
|
+
* @returns The pilet API object of the root pilet.
|
|
8
|
+
*/
|
|
9
|
+
export function usePiletApi() {
|
|
10
|
+
const context = useGlobalStateContext();
|
|
11
|
+
const [api] = useState(() => Object.values(context.apis).shift());
|
|
12
|
+
return api;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=piletApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"piletApi.js","sourceRoot":"","sources":["../../src/hooks/piletApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,OAAO,GAAG,qBAAqB,EAAE,CAAC;IACxC,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IAClE,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useGlobalState } from './globalState';
|
|
2
|
+
import { useRouteFilter } from '../../app.codegen';
|
|
3
|
+
export function useRoutes() {
|
|
4
|
+
const routes = useGlobalState((s) => s.routes);
|
|
5
|
+
const pages = useGlobalState((s) => s.registry.pages);
|
|
6
|
+
const paths = [];
|
|
7
|
+
Object.keys(routes).map((path) => paths.push({ path, Component: routes[path] }));
|
|
8
|
+
Object.keys(pages).map((path) => paths.push({ path, Component: pages[path].component }));
|
|
9
|
+
return useRouteFilter(paths);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/hooks/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,MAAM,UAAU,SAAS;IACvB,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,KAAK,GAAmB,EAAE,CAAC;IAEjC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACjF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAEzF,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
|
package/esm/hooks/setter.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { useEffect as useSideEffect } from 'react';
|
|
2
|
+
import { none } from '../utils/helpers';
|
|
2
3
|
function useMainEffect(cb) {
|
|
3
4
|
cb();
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
+
const useEffect = typeof window !== 'undefined' ? useSideEffect : useMainEffect;
|
|
6
7
|
/**
|
|
7
8
|
* Hook for running the callback once on mount.
|
|
8
9
|
* @param cb The callback to be invoked on mounting.
|
|
9
10
|
*/
|
|
10
11
|
export function useSetter(cb) {
|
|
11
|
-
useEffect(cb,
|
|
12
|
+
useEffect(cb, none);
|
|
12
13
|
}
|
|
13
14
|
//# sourceMappingURL=setter.js.map
|
package/esm/hooks/setter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setter.js","sourceRoot":"","sources":["../../src/hooks/setter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"setter.js","sourceRoot":"","sources":["../../src/hooks/setter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,SAAS,aAAa,CAAC,EAAc;IACnC,EAAE,EAAE,CAAC;AACP,CAAC;AAED,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC;AAEhF;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,EAAc;IACtC,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;AACtB,CAAC"}
|
package/esm/hooks/sharedData.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useGlobalState } from './globalState';
|
|
2
2
|
export function useSharedData(s) {
|
|
3
|
-
|
|
4
|
-
return useGlobalState(
|
|
3
|
+
const select = s || ((m) => m);
|
|
4
|
+
return useGlobalState((s) => select(s.data));
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=sharedData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedData.js","sourceRoot":"","sources":["../../src/hooks/sharedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAgB/C,MAAM,UAAU,aAAa,CAAI,CAAiD;IAChF,
|
|
1
|
+
{"version":3,"file":"sharedData.js","sourceRoot":"","sources":["../../src/hooks/sharedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAgB/C,MAAM,UAAU,aAAa,CAAI,CAAiD;IAChF,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/B,OAAO,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from './createInstance';
|
|
2
|
-
export * from './Piral';
|
|
3
2
|
export * from './helpers';
|
|
4
3
|
export * from './components';
|
|
5
4
|
export * from './hooks';
|
|
5
|
+
export * from './setters';
|
|
6
6
|
export * from './state';
|
|
7
7
|
export * from './utils';
|
|
8
|
+
export * from './Piral';
|
|
9
|
+
export * from './PiralContext';
|
|
8
10
|
export * from './types';
|
package/esm/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export * from './createInstance';
|
|
2
|
-
export * from './Piral';
|
|
3
2
|
export * from './helpers';
|
|
4
3
|
export * from './components';
|
|
5
4
|
export * from './hooks';
|
|
5
|
+
export * from './setters';
|
|
6
6
|
export * from './state';
|
|
7
7
|
export * from './utils';
|
|
8
|
+
export * from './Piral';
|
|
9
|
+
export * from './PiralContext';
|
|
8
10
|
export * from './types';
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC"}
|
package/esm/modules/api.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import { PiletApiCreator } from 'piral-base';
|
|
2
|
-
import {
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function initializeApi(target: PiletMetadata, context: GlobalStateContext): PiletApi;
|
|
5
|
-
export declare function mergeApis(api: PiletApi, extenders: Array<PiletApiExtender<Partial<PiletApi>>>, target: PiletMetadata): PiletApi;
|
|
6
|
-
export declare function createExtenders(context: GlobalStateContext, apis: Array<PiralPlugin>): PiletApiExtender<Partial<PiletApi>>[];
|
|
2
|
+
import { GlobalStateContext, PiralPlugin } from '../types';
|
|
3
|
+
export declare function createExtenders(context: GlobalStateContext, apis: Array<PiralPlugin>): import("piral-base").PiletApiExtender<Partial<import("piral-base").PiletApi>>[];
|
|
7
4
|
export declare function defaultApiFactory(context: GlobalStateContext, apis: Array<PiralPlugin>): PiletApiCreator;
|
package/esm/modules/api.js
CHANGED
|
@@ -1,80 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { __assign } from 'tslib';
|
|
4
|
-
import { withApi } from '../state';
|
|
5
|
-
import { ExtensionSlot } from '../components';
|
|
6
|
-
import { createDataOptions, getDataExpiration, renderInDom } from '../utils';
|
|
7
|
-
export function createCoreApi(context) {
|
|
8
|
-
return function (api, target) {
|
|
9
|
-
var pilet = target.name;
|
|
10
|
-
return {
|
|
11
|
-
getData: function (name) {
|
|
12
|
-
return context.readDataValue(name);
|
|
13
|
-
},
|
|
14
|
-
setData: function (name, value, options) {
|
|
15
|
-
var _a = createDataOptions(options), _b = _a.target, target = _b === void 0 ? 'memory' : _b, expires = _a.expires;
|
|
16
|
-
var expiration = getDataExpiration(expires);
|
|
17
|
-
return context.tryWriteDataItem(name, value, pilet, target, expiration);
|
|
18
|
-
},
|
|
19
|
-
registerPage: function (route, arg, meta) {
|
|
20
|
-
context.registerPage(route, {
|
|
21
|
-
pilet: pilet,
|
|
22
|
-
meta: meta,
|
|
23
|
-
component: withApi(context, arg, api, 'page'),
|
|
24
|
-
});
|
|
25
|
-
return function () { return api.unregisterPage(route); };
|
|
26
|
-
},
|
|
27
|
-
unregisterPage: function (route) {
|
|
28
|
-
context.unregisterPage(route);
|
|
29
|
-
},
|
|
30
|
-
registerExtension: function (name, arg, defaults) {
|
|
31
|
-
context.registerExtension(name, {
|
|
32
|
-
pilet: pilet,
|
|
33
|
-
component: withApi(context, arg, api, 'extension'),
|
|
34
|
-
reference: arg,
|
|
35
|
-
defaults: defaults,
|
|
36
|
-
});
|
|
37
|
-
return function () { return api.unregisterExtension(name, arg); };
|
|
38
|
-
},
|
|
39
|
-
unregisterExtension: function (name, arg) {
|
|
40
|
-
context.unregisterExtension(name, arg);
|
|
41
|
-
},
|
|
42
|
-
renderHtmlExtension: function (element, props) {
|
|
43
|
-
renderInDom(context, element, ExtensionSlot, props);
|
|
44
|
-
},
|
|
45
|
-
Extension: ExtensionSlot,
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
export function initializeApi(target, context) {
|
|
50
|
-
return {
|
|
51
|
-
on: context.on,
|
|
52
|
-
off: context.off,
|
|
53
|
-
emit: context.emit,
|
|
54
|
-
meta: __assign_1({}, target),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
export function mergeApis(api, extenders, target) {
|
|
58
|
-
var frags = extenders.map(function (extender) { return extender(api, target); });
|
|
59
|
-
__assign.apply(void 0, __spreadArrays([api], frags));
|
|
60
|
-
return api;
|
|
61
|
-
}
|
|
1
|
+
import { isfunc, initializeApi, mergeApis } from 'piral-base';
|
|
2
|
+
import { createCoreApi } from './core';
|
|
62
3
|
export function createExtenders(context, apis) {
|
|
63
|
-
|
|
64
|
-
return creators.map(
|
|
65
|
-
|
|
4
|
+
const creators = [createCoreApi, ...apis.filter(isfunc)];
|
|
5
|
+
return creators.map((c) => {
|
|
6
|
+
const ctx = c(context);
|
|
66
7
|
if (isfunc(ctx)) {
|
|
67
8
|
return ctx;
|
|
68
9
|
}
|
|
69
10
|
else {
|
|
70
|
-
return
|
|
11
|
+
return () => (Object.assign({}, ctx));
|
|
71
12
|
}
|
|
72
13
|
});
|
|
73
14
|
}
|
|
74
15
|
export function defaultApiFactory(context, apis) {
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
|
|
16
|
+
const extenders = createExtenders(context, apis);
|
|
17
|
+
return (target) => {
|
|
18
|
+
const api = initializeApi(target, context);
|
|
78
19
|
context.apis[target.name] = api;
|
|
79
20
|
return mergeApis(api, extenders, target);
|
|
80
21
|
};
|
package/esm/modules/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/modules/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/modules/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmB,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE/E,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC,MAAM,UAAU,eAAe,CAAC,OAA2B,EAAE,IAAwB;IACnF,MAAM,QAAQ,GAAuB,CAAC,aAAa,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7E,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACxB,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;QAEvB,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE;YACf,OAAO,GAAG,CAAC;SACZ;aAAM;YACL,OAAO,GAAG,EAAE,CAAC,mBACR,GAAG,EACN,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAA2B,EAAE,IAAwB;IACrF,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACjD,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;QAChC,OAAO,SAAS,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { renderElement } from './element';
|
|
2
|
+
import { withApi } from '../state';
|
|
3
|
+
import { ExtensionSlot } from '../components';
|
|
4
|
+
import { createDataOptions, getDataExpiration } from '../utils';
|
|
5
|
+
export function createCoreApi(context) {
|
|
6
|
+
return (api, meta) => {
|
|
7
|
+
const pilet = meta.name;
|
|
8
|
+
return {
|
|
9
|
+
getData(name) {
|
|
10
|
+
return context.readDataValue(name);
|
|
11
|
+
},
|
|
12
|
+
setData(name, value, options) {
|
|
13
|
+
const { target = 'memory', expires } = createDataOptions(options);
|
|
14
|
+
const expiration = getDataExpiration(expires);
|
|
15
|
+
return context.tryWriteDataItem(name, value, pilet, target, expiration);
|
|
16
|
+
},
|
|
17
|
+
registerPage(route, arg, meta = {}) {
|
|
18
|
+
const component = withApi(context, arg, api, 'page', undefined, { meta });
|
|
19
|
+
context.registerPage(route, {
|
|
20
|
+
pilet,
|
|
21
|
+
meta,
|
|
22
|
+
component,
|
|
23
|
+
});
|
|
24
|
+
return () => api.unregisterPage(route);
|
|
25
|
+
},
|
|
26
|
+
unregisterPage(route) {
|
|
27
|
+
context.unregisterPage(route);
|
|
28
|
+
},
|
|
29
|
+
registerExtension(name, reference, defaults) {
|
|
30
|
+
const component = withApi(context, reference, api, 'extension');
|
|
31
|
+
context.registerExtension(name, {
|
|
32
|
+
pilet,
|
|
33
|
+
component,
|
|
34
|
+
reference,
|
|
35
|
+
defaults,
|
|
36
|
+
});
|
|
37
|
+
return () => api.unregisterExtension(name, reference);
|
|
38
|
+
},
|
|
39
|
+
unregisterExtension(name, arg) {
|
|
40
|
+
context.unregisterExtension(name, arg);
|
|
41
|
+
},
|
|
42
|
+
renderHtmlExtension(element, props) {
|
|
43
|
+
const [dispose] = renderElement(context, element, props);
|
|
44
|
+
return dispose;
|
|
45
|
+
},
|
|
46
|
+
Extension: ExtensionSlot,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/modules/core.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGhE,MAAM,UAAU,aAAa,CAAC,OAA2B;IACvD,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC;QACxB,OAAO;YACL,OAAO,CAAC,IAAI;gBACV,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO;gBAC1B,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;gBAClE,MAAM,UAAU,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;gBAC9C,OAAO,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;YAC1E,CAAC;YACD,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,GAAG,EAAE;gBAChC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC1E,OAAO,CAAC,YAAY,CAAC,KAAK,EAAE;oBAC1B,KAAK;oBACL,IAAI;oBACJ,SAAS;iBACV,CAAC,CAAC;gBACH,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YACzC,CAAC;YACD,cAAc,CAAC,KAAK;gBAClB,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;YACD,iBAAiB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ;gBACzC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;gBAChE,OAAO,CAAC,iBAAiB,CAAC,IAAI,EAAE;oBAC9B,KAAK;oBACL,SAAS;oBACT,SAAS;oBACT,QAAQ;iBACT,CAAC,CAAC;gBACH,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YACxD,CAAC;YACD,mBAAmB,CAAC,IAAI,EAAE,GAAG;gBAC3B,OAAO,CAAC,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACzC,CAAC;YACD,mBAAmB,CAAC,OAAO,EAAE,KAAK;gBAChC,MAAM,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;gBACzD,OAAO,OAAO,CAAC;YACjB,CAAC;YACD,SAAS,EAAE,aAAa;SACzB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|