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
package/lib/state/withApi.js
CHANGED
|
@@ -1,114 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withApi = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var id = _a.id;
|
|
15
|
-
var children = hooks_1.useGlobalState(function (m) { return m.portals[id] || []; });
|
|
16
|
-
return utils_1.defaultRender(children);
|
|
17
|
-
};
|
|
18
|
-
var DefaultWrapper = function (props) { return React.createElement(React.Fragment, null, props.children); };
|
|
19
|
-
var ForeignComponentContainer = /** @class */ (function (_super) {
|
|
20
|
-
tslib_1.__extends(ForeignComponentContainer, _super);
|
|
21
|
-
function ForeignComponentContainer() {
|
|
22
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const components_1 = require("../components");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const DefaultWrapper = (props) => (0, utils_1.defaultRender)(props.children);
|
|
8
|
+
function getWrapper(wrappers, wrapperType) {
|
|
9
|
+
const WrapAll = wrappers['*'];
|
|
10
|
+
const WrapType = wrappers[wrapperType];
|
|
11
|
+
if (WrapAll && WrapType) {
|
|
12
|
+
return (props) => (React.createElement(WrapAll, Object.assign({}, props),
|
|
13
|
+
React.createElement(WrapType, Object.assign({}, props))));
|
|
23
14
|
}
|
|
24
|
-
|
|
25
|
-
var node = this.current;
|
|
26
|
-
var _a = this.props, $component = _a.$component, $context = _a.$context, innerProps = _a.innerProps;
|
|
27
|
-
var mount = $component.mount;
|
|
28
|
-
if (node && piral_base_1.isfunc(mount)) {
|
|
29
|
-
mount(node, innerProps, $context);
|
|
30
|
-
}
|
|
31
|
-
this.previous = node;
|
|
32
|
-
};
|
|
33
|
-
ForeignComponentContainer.prototype.componentDidUpdate = function () {
|
|
34
|
-
var _a = this, current = _a.current, previous = _a.previous;
|
|
35
|
-
var _b = this.props, $component = _b.$component, $context = _b.$context, innerProps = _b.innerProps;
|
|
36
|
-
var update = $component.update;
|
|
37
|
-
if (current !== previous) {
|
|
38
|
-
previous && this.componentWillUnmount();
|
|
39
|
-
current && this.componentDidMount();
|
|
40
|
-
}
|
|
41
|
-
else if (piral_base_1.isfunc(update)) {
|
|
42
|
-
update(current, innerProps, $context);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
ForeignComponentContainer.prototype.componentWillUnmount = function () {
|
|
46
|
-
var node = this.previous;
|
|
47
|
-
var $component = this.props.$component;
|
|
48
|
-
var unmount = $component.unmount;
|
|
49
|
-
if (node && piral_base_1.isfunc(unmount)) {
|
|
50
|
-
unmount(node);
|
|
51
|
-
}
|
|
52
|
-
this.previous = undefined;
|
|
53
|
-
};
|
|
54
|
-
ForeignComponentContainer.prototype.render = function () {
|
|
55
|
-
var _this = this;
|
|
56
|
-
var $portalId = this.props.$portalId;
|
|
57
|
-
return (React.createElement("div", { "data-portal-id": $portalId, ref: function (node) {
|
|
58
|
-
_this.current = node;
|
|
59
|
-
} }));
|
|
60
|
-
};
|
|
61
|
-
return ForeignComponentContainer;
|
|
62
|
-
}(React.Component));
|
|
63
|
-
function wrapReactComponent(Component, stasisOptions, piral, Wrapper) {
|
|
64
|
-
return function (props) { return (React.createElement(Wrapper, tslib_1.__assign({}, props, { piral: piral }),
|
|
65
|
-
React.createElement(components_1.ErrorBoundary, tslib_1.__assign({}, stasisOptions, { renderProps: props }),
|
|
66
|
-
React.createElement(Component, tslib_1.__assign({}, props, { piral: piral }))))); };
|
|
15
|
+
return WrapType || WrapAll || DefaultWrapper;
|
|
67
16
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var router = React.useContext(react_router_1.__RouterContext);
|
|
73
|
-
var state = React.useContext(stateContext_1.StateContext).state;
|
|
74
|
-
var innerProps = tslib_1.__assign(tslib_1.__assign({}, props), { piral: piral });
|
|
75
|
-
React.useEffect(function () { return function () { return destroyPortal(id); }; }, []);
|
|
76
|
-
return (React.createElement(Wrapper, tslib_1.__assign({}, innerProps),
|
|
77
|
-
React.createElement(components_1.ErrorBoundary, tslib_1.__assign({}, stasisOptions, { renderProps: props }),
|
|
78
|
-
React.createElement(PortalRenderer, { id: id }),
|
|
79
|
-
React.createElement(ForeignComponentContainer, { innerProps: innerProps, "$portalId": id, "$component": component, "$context": { router: router, state: state } }))));
|
|
80
|
-
};
|
|
17
|
+
function makeWrapper(context, outerProps, wrapperType, errorType) {
|
|
18
|
+
const OuterWrapper = context.readState((m) => getWrapper(m.registry.wrappers, wrapperType));
|
|
19
|
+
return (props) => (React.createElement(OuterWrapper, Object.assign({}, outerProps, props),
|
|
20
|
+
React.createElement(components_1.ErrorBoundary, Object.assign({}, outerProps, props, { errorType: errorType }), props.children)));
|
|
81
21
|
}
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
console.error('The given value is not a valid component.');
|
|
88
|
-
// tslint:disable-next-line:no-null-keyword
|
|
89
|
-
component = function () { return null; };
|
|
90
|
-
}
|
|
91
|
-
if (typeof component === 'object' && isNotExotic(component)) {
|
|
92
|
-
var result = utils_1.convertComponent(converters[component.type], component);
|
|
93
|
-
return wrapForeignComponent(result, stasisOptions, piral, Wrapper);
|
|
94
|
-
}
|
|
95
|
-
return wrapReactComponent(component, stasisOptions, piral, Wrapper);
|
|
96
|
-
}
|
|
97
|
-
function withApi(context, component, piral, errorType, wrapperType) {
|
|
98
|
-
if (wrapperType === void 0) { wrapperType = errorType; }
|
|
99
|
-
var converters = context.converters;
|
|
100
|
-
var Wrapper = context.readState(function (m) { return m.registry.wrappers[wrapperType]; }) || DefaultWrapper;
|
|
101
|
-
return wrapComponent(converters, component, piral, Wrapper, {
|
|
102
|
-
onError: function (error) {
|
|
103
|
-
console.error(piral, error);
|
|
104
|
-
},
|
|
105
|
-
renderChild: function (child) {
|
|
106
|
-
return React.createElement(React.Suspense, { fallback: React.createElement(components_1.PiralLoadingIndicator, null) }, child);
|
|
107
|
-
},
|
|
108
|
-
renderError: function (error, props) {
|
|
109
|
-
return React.createElement(components_1.PiralError, tslib_1.__assign({ type: errorType, error: error }, props));
|
|
110
|
-
},
|
|
111
|
-
});
|
|
22
|
+
function withApi(context, component, piral, errorType, wrapperType = errorType, captured = {}) {
|
|
23
|
+
const outerProps = Object.assign(Object.assign({}, captured), { piral });
|
|
24
|
+
const converters = context.converters;
|
|
25
|
+
const Wrapper = makeWrapper(context, outerProps, wrapperType, errorType);
|
|
26
|
+
return (0, components_1.wrapComponent)(converters, component, outerProps, Wrapper);
|
|
112
27
|
}
|
|
113
28
|
exports.withApi = withApi;
|
|
114
29
|
//# sourceMappingURL=withApi.js.map
|
package/lib/state/withApi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withApi.js","sourceRoot":"","sources":["../../src/state/withApi.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"withApi.js","sourceRoot":"","sources":["../../src/state/withApi.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,8CAA6D;AAC7D,oCAAyC;AAGzC,MAAM,cAAc,GAA0C,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,qBAAa,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAEvG,SAAS,UAAU,CAAC,QAAkD,EAAE,WAAmB;IACzF,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9B,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;IAEvC,IAAI,OAAO,IAAI,QAAQ,EAAE;QACvB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAChB,oBAAC,OAAO,oBAAK,KAAK;YAChB,oBAAC,QAAQ,oBAAK,KAAK,EAAI,CACf,CACX,CAAC;KACH;IAED,OAAO,QAAQ,IAAI,OAAO,IAAI,cAAc,CAAC;AAC/C,CAAC;AAED,SAAS,WAAW,CAClB,OAA2B,EAC3B,UAAe,EACf,WAAmB,EACnB,SAAuB;IAEvB,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;IAE5F,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAChB,oBAAC,YAAY,oBAAK,UAAU,EAAM,KAAK;QACrC,oBAAC,0BAAa,oBAAK,UAAU,EAAM,KAAK,IAAE,SAAS,EAAE,SAAS,KAC3D,KAAK,CAAC,QAAQ,CACD,CACH,CAChB,CAAC;AACJ,CAAC;AAED,SAAgB,OAAO,CACrB,OAA2B,EAC3B,SAAoD,EACpD,KAAe,EACf,SAAuB,EACvB,cAAsB,SAAS,EAC/B,QAAQ,GAAG,EAAE;IAEb,MAAM,UAAU,mCAAQ,QAAQ,KAAE,KAAK,GAAE,CAAC;IAC1C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACtC,MAAM,OAAO,GAAG,WAAW,CAAS,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACjF,OAAO,IAAA,0BAAa,EAAC,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC;AAZD,0BAYC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface CodegenOptions {
|
|
2
|
+
root: string;
|
|
3
|
+
cat: string;
|
|
4
|
+
appName: string;
|
|
5
|
+
externals: Array<string>;
|
|
6
|
+
publicPath: string;
|
|
7
|
+
debug?: {
|
|
8
|
+
viewState?: boolean;
|
|
9
|
+
loadPilets?: boolean;
|
|
10
|
+
hardRefresh?: boolean;
|
|
11
|
+
viewOrigins?: boolean;
|
|
12
|
+
extensionCatalogue?: boolean;
|
|
13
|
+
clearConsole?: boolean;
|
|
14
|
+
};
|
|
15
|
+
emulator: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function createDependencies(imports: Array<string>, exports: Array<string>, opts: CodegenOptions): void;
|
|
18
|
+
export declare function createDefaultState(imports: Array<string>, exports: Array<string>, opts: CodegenOptions): void;
|
|
19
|
+
export declare function createDebugHandler(imports: Array<string>, exports: Array<string>, opts: CodegenOptions): void;
|
|
20
|
+
export declare function createRouteHandler(imports: Array<string>, exports: Array<string>, opts: CodegenOptions): void;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRouteHandler = exports.createDebugHandler = exports.createDefaultState = exports.createDependencies = void 0;
|
|
4
|
+
// this file is bundled, so the references here will not be at runtime (i.e., for a user)
|
|
5
|
+
const resolve_1 = require("piral-cli/src/external/resolve");
|
|
6
|
+
function getRouterVersion(root) {
|
|
7
|
+
const router = 'react-router';
|
|
8
|
+
try {
|
|
9
|
+
const modulePath = (0, resolve_1.getModulePath)(root, `${router}/package.json`);
|
|
10
|
+
const { version } = require(modulePath);
|
|
11
|
+
const [major] = version.split('.');
|
|
12
|
+
return parseInt(major, 10);
|
|
13
|
+
}
|
|
14
|
+
catch (_a) {
|
|
15
|
+
console.warn(`⚠ Could not determine version of ${router}. Falling back to v5.`);
|
|
16
|
+
return 5;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function getIdentifiers(root, packageName) {
|
|
20
|
+
const packageJson = `${packageName}/package.json`;
|
|
21
|
+
const identifiers = [packageName];
|
|
22
|
+
try {
|
|
23
|
+
const modulePath = (0, resolve_1.getModulePath)(root, packageJson);
|
|
24
|
+
const details = require(modulePath);
|
|
25
|
+
if (details.version) {
|
|
26
|
+
identifiers.push(`${packageName}@${details.version}`);
|
|
27
|
+
if (details.name !== packageName) {
|
|
28
|
+
identifiers.push(`${details.name}@${details.version}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (_a) { }
|
|
33
|
+
return identifiers;
|
|
34
|
+
}
|
|
35
|
+
function getModulePathOrDefault(root, name) {
|
|
36
|
+
try {
|
|
37
|
+
return (0, resolve_1.getModulePath)(root, name);
|
|
38
|
+
}
|
|
39
|
+
catch (_a) {
|
|
40
|
+
return name;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function createDependencies(imports, exports, opts) {
|
|
44
|
+
const { root, appName, externals } = opts;
|
|
45
|
+
const assignments = [];
|
|
46
|
+
if (appName) {
|
|
47
|
+
assignments.push(`deps['${appName}']={}`);
|
|
48
|
+
}
|
|
49
|
+
for (const name of externals) {
|
|
50
|
+
const identifiers = getIdentifiers(root, name);
|
|
51
|
+
const path = getModulePathOrDefault(root, name);
|
|
52
|
+
const ref = `_${imports.length}`;
|
|
53
|
+
imports.push(`import * as ${ref} from ${JSON.stringify(path)}`);
|
|
54
|
+
for (const id of identifiers) {
|
|
55
|
+
assignments.push(`deps[${JSON.stringify(id)}]=${ref}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.push(`
|
|
59
|
+
export function fillDependencies(deps) {
|
|
60
|
+
${assignments.join(';')}
|
|
61
|
+
}
|
|
62
|
+
`);
|
|
63
|
+
}
|
|
64
|
+
exports.createDependencies = createDependencies;
|
|
65
|
+
function createDefaultState(imports, exports, opts) {
|
|
66
|
+
const { root, cat, publicPath } = opts;
|
|
67
|
+
const routerVersion = getRouterVersion(root);
|
|
68
|
+
imports.push(`import { DefaultErrorInfo } from 'piral-core/${cat}/defaults/DefaultErrorInfo';`, `import { DefaultLoadingIndicator } from 'piral-core/${cat}/defaults/DefaultLoadingIndicator';`, `import { DefaultLayout } from 'piral-core/${cat}/defaults/DefaultLayout';`);
|
|
69
|
+
if (routerVersion < 6) {
|
|
70
|
+
imports.push(`import { DefaultRouter } from 'piral-core/${cat}/defaults/DefaultRouter_v5';`, `import { DefaultRouteSwitch } from 'piral-core/${cat}/defaults/DefaultRouteSwitch_v5';`, `import { createRedirect, createNavigation, useCurrentNavigation, useRouterContext } from 'piral-core/${cat}/defaults/navigator_v5'`);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
imports.push(`import { DefaultRouter } from 'piral-core/${cat}/defaults/DefaultRouter_v6';`, `import { DefaultRouteSwitch } from 'piral-core/${cat}/defaults/DefaultRouteSwitch_v6';`, `import { createRedirect, createNavigation, useCurrentNavigation, useRouterContext } from 'piral-core/${cat}/defaults/navigator_v6'`);
|
|
74
|
+
}
|
|
75
|
+
exports.push(`
|
|
76
|
+
export { createRedirect, createNavigation, useRouterContext };
|
|
77
|
+
`);
|
|
78
|
+
exports.push(`
|
|
79
|
+
export const publicPath = ${JSON.stringify(publicPath)};
|
|
80
|
+
`);
|
|
81
|
+
exports.push(`
|
|
82
|
+
export function createDefaultState() {
|
|
83
|
+
return {
|
|
84
|
+
app: {
|
|
85
|
+
error: undefined,
|
|
86
|
+
loading: typeof window !== 'undefined',
|
|
87
|
+
},
|
|
88
|
+
components: {
|
|
89
|
+
ErrorInfo: DefaultErrorInfo,
|
|
90
|
+
LoadingIndicator: DefaultLoadingIndicator,
|
|
91
|
+
Router: DefaultRouter,
|
|
92
|
+
RouteSwitch: DefaultRouteSwitch,
|
|
93
|
+
Layout: DefaultLayout,
|
|
94
|
+
},
|
|
95
|
+
errorComponents: {},
|
|
96
|
+
registry: {
|
|
97
|
+
extensions: {},
|
|
98
|
+
pages: {},
|
|
99
|
+
wrappers: {},
|
|
100
|
+
},
|
|
101
|
+
routes: {},
|
|
102
|
+
data: {},
|
|
103
|
+
portals: {},
|
|
104
|
+
modules: [],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
`);
|
|
108
|
+
}
|
|
109
|
+
exports.createDefaultState = createDefaultState;
|
|
110
|
+
function createDebugHandler(imports, exports, opts) {
|
|
111
|
+
const { cat, debug, emulator } = opts;
|
|
112
|
+
// if we build the debug version of piral (debug and emulator build)
|
|
113
|
+
if (debug) {
|
|
114
|
+
const originalCall = `originalDebugger(context, options, { defaultSettings: ${JSON.stringify(debug)}, ...debug })`;
|
|
115
|
+
imports.push(`import { integrateDebugger as originalDebugger } from "piral-core/${cat}/tools/debugger"`);
|
|
116
|
+
exports.push(`export function integrateDebugger(context, options, debug) { return ${originalCall}; }`);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
exports.push(`export function integrateDebugger() {}`);
|
|
120
|
+
}
|
|
121
|
+
// if we build the emulator version of piral (shipped to pilets)
|
|
122
|
+
if (emulator) {
|
|
123
|
+
imports.push(`import { integrateEmulator } from "piral-core/${cat}/tools/emulator"`);
|
|
124
|
+
exports.push(`export { integrateEmulator }`);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
exports.push(`export function integrateEmulator() {}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
exports.createDebugHandler = createDebugHandler;
|
|
131
|
+
function createRouteHandler(imports, exports, opts) {
|
|
132
|
+
const { cat, emulator } = opts;
|
|
133
|
+
const assignments = [];
|
|
134
|
+
imports.push(`import { useGlobalStateContext } from 'piral-core/${cat}/hooks/globalState';`);
|
|
135
|
+
assignments.push(`
|
|
136
|
+
useCurrentNavigation();
|
|
137
|
+
`);
|
|
138
|
+
if (emulator) {
|
|
139
|
+
imports.push(`import { useDebugRouteFilter } from 'piral-debug-utils';`);
|
|
140
|
+
assignments.push('return useDebugRouteFilter(paths);');
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
assignments.push('return paths;');
|
|
144
|
+
}
|
|
145
|
+
exports.push(`
|
|
146
|
+
export function useRouteFilter(paths) {
|
|
147
|
+
${assignments.join('\n')}
|
|
148
|
+
}
|
|
149
|
+
`);
|
|
150
|
+
}
|
|
151
|
+
exports.createRouteHandler = createRouteHandler;
|
|
152
|
+
//# sourceMapp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kBAAkB,CAAC,CAAC;QACrF,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;KAC9C;SAAM;QACL,OAAO,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;KACxD;AACH,CAAC;AAnBD,gDAmBC;AAED,SAAgB,kBAAkB,CAAC,OAAsB,EAAE,OAAsB,EAAE,IAAoB;IACrG,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAC/B,MAAM,WAAW,GAAG,EAAE,CAAC;IAEvB,OAAO,CAAC,IAAI,CAAC,qDAAqD,GAAG,sBAAsB,CAAC,CAAC;IAE7F,WAAW,CAAC,IAAI,CAAC;;GAEhB,CAAC,CAAC;IAEH,IAAI,QAAQ,EAAE;QACZ,OAAO,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;QACzE,WAAW,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;KACxD;SAAM;QACL,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;KACnC;IAED,OAAO,CAAC,IAAI,CAAC;;QAEP,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;;GAE3B,CAAC,CAAC;AACL,CAAC;AAtBD,gDAsBC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { LoadPiletsOptions } from 'piral-base';
|
|
2
|
+
import { DebuggerExtensionOptions } from 'piral-debug-utils';
|
|
3
|
+
import { GlobalStateContext } from '../types';
|
|
4
|
+
export declare function integrateDebugger(context: GlobalStateContext, options: LoadPiletsOptions, debug?: DebuggerExtensionOptions): void;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.integrateDebugger = void 0;
|
|
4
|
+
const piral_debug_utils_1 = require("piral-debug-utils");
|
|
5
|
+
function integrateDebugger(context, options, debug = {}) {
|
|
6
|
+
(0, piral_debug_utils_1.installPiralDebug)(Object.assign(Object.assign({}, debug), { addPilet: context.addPilet, removePilet: context.removePilet, updatePilet(pilet) {
|
|
7
|
+
if (!pilet.disabled) {
|
|
8
|
+
const { createApi } = options;
|
|
9
|
+
const newApi = createApi(pilet);
|
|
10
|
+
try {
|
|
11
|
+
context.injectPilet(pilet);
|
|
12
|
+
pilet.setup(newApi);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
console.error(error);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
context.injectPilet(pilet);
|
|
20
|
+
}
|
|
21
|
+
}, fireEvent: context.emit, getDependencies() {
|
|
22
|
+
return Object.keys(options.dependencies);
|
|
23
|
+
},
|
|
24
|
+
getExtensions() {
|
|
25
|
+
return context.readState((s) => Object.keys(s.registry.extensions));
|
|
26
|
+
},
|
|
27
|
+
getRoutes() {
|
|
28
|
+
const registeredRoutes = context.readState((state) => Object.keys(state.registry.pages));
|
|
29
|
+
const componentRoutes = context.readState((state) => Object.keys(state.routes));
|
|
30
|
+
return [...componentRoutes, ...registeredRoutes];
|
|
31
|
+
},
|
|
32
|
+
getGlobalState() {
|
|
33
|
+
return context.readState((s) => s);
|
|
34
|
+
},
|
|
35
|
+
navigate(path, state) {
|
|
36
|
+
return context.navigation.push(path, state);
|
|
37
|
+
},
|
|
38
|
+
getPilets() {
|
|
39
|
+
return context.readState((s) => s.modules);
|
|
40
|
+
},
|
|
41
|
+
integrate(dbg) {
|
|
42
|
+
context.dispatch((s) => (Object.assign(Object.assign({}, s), { components: Object.assign(Object.assign({}, s.components), dbg.components), routes: Object.assign(Object.assign({}, s.routes), dbg.routes), registry: Object.assign(Object.assign({}, s.registry), { wrappers: Object.assign(Object.assign({}, s.registry.wrappers), dbg.wrappers) }) })));
|
|
43
|
+
context.state.subscribe((current, previous) => {
|
|
44
|
+
const pilets = current.modules !== previous.modules;
|
|
45
|
+
const pages = current.registry.pages !== previous.registry.pages || current.routes !== previous.routes;
|
|
46
|
+
const extensions = current.registry.extensions !== previous.registry.extensions;
|
|
47
|
+
const state = current !== previous;
|
|
48
|
+
dbg.onChange(previous, current, {
|
|
49
|
+
pilets,
|
|
50
|
+
pages,
|
|
51
|
+
extensions,
|
|
52
|
+
state,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
} }));
|
|
56
|
+
}
|
|
57
|
+
exports.integrateDebugger = integrateDebugger;
|
|
58
|
+
//# sourceMappingURL=debugger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugger.js","sourceRoot":"","sources":["../../src/tools/debugger.ts"],"names":[],"mappings":";;;AACA,yDAAgF;AAGhF,SAAgB,iBAAiB,CAC/B,OAA2B,EAC3B,OAA0B,EAC1B,QAAkC,EAAE;IAEpC,IAAA,qCAAiB,kCACZ,KAAK,KACR,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,WAAW,EAAE,OAAO,CAAC,WAAW,EAChC,WAAW,CAAC,KAAK;YACf,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;gBACnB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;gBAC9B,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;gBAEhC,IAAI;oBACF,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;oBAC3B,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;iBACrB;gBAAC,OAAO,KAAK,EAAE;oBACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACtB;aACF;iBAAM;gBACL,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;aAC5B;QACH,CAAC,EACD,SAAS,EAAE,OAAO,CAAC,IAAI,EACvB,eAAe;YACb,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3C,CAAC;QACD,aAAa;YACX,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,I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;gBAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,OAAO,CAAC;gBACpD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,CAAC,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;gBACvG,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAChF,MAAM,KAAK,GAAG,OAAO,KAAK,QAAQ,CAAC;gBACnC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE;oBAC9B,MAAM;oBACN,KAAK;oBACL,UAAU;oBACV,KAAK;iBACN,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,IACD,CAAC;AACL,CAAC;AA/ED,8CA+EC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.integrateEmulator = void 0;
|
|
4
|
+
const piral_debug_utils_1 = require("piral-debug-utils");
|
|
5
|
+
function integrateEmulator(context, options) {
|
|
6
|
+
(0, piral_debug_utils_1.installPiletEmulator)(options.fetchPilets, {
|
|
7
|
+
addPilet: context.addPilet,
|
|
8
|
+
removePilet: context.removePilet,
|
|
9
|
+
integrate(requester) {
|
|
10
|
+
options.fetchPilets = requester;
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.integrateEmulator = integrateEmulator;
|
|
15
|
+
//# sourceMappingURL=emulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../../src/tools/emulator.ts"],"names":[],"mappings":";;;AACA,yDAAyD;AAGzD,SAAgB,iBAAiB,CAAC,OAA2B,EAAE,OAA0B;IACvF,IAAA,wCAAoB,EAAC,OAAO,CAAC,WAAW,EAAE;QACxC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,SAAS,CAAC,SAAS;YACjB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;QAClC,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AARD,8CAQC"}
|
package/lib/types/api.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { ReactElement } from 'react';
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import type { RouteComponentProps } from 'react-router';
|
|
3
|
-
import type { PiletApi, Pilet, PiletMetadata, EventEmitter,
|
|
3
|
+
import type { PiletApi, Pilet, PiletEntry, PiletEntries, PiletMetadata, EventEmitter, PiletLoader, PiletLoadingStrategy } from 'piral-base';
|
|
4
4
|
import type { PiletCustomApi, PiralCustomPageMeta } from './custom';
|
|
5
5
|
import type { AnyComponent } from './components';
|
|
6
|
-
import type { ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
|
|
6
|
+
import type { ExtensionParams, ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
|
|
7
7
|
import type { SharedData, DataStoreOptions } from './data';
|
|
8
8
|
import type { Disposable } from './utils';
|
|
9
|
-
export { PiletApi, Pilet, PiletMetadata, EventEmitter,
|
|
9
|
+
export { PiletApi, Pilet, PiletMetadata, EventEmitter, PiletEntry, PiletEntries, PiletLoader, PiletLoadingStrategy };
|
|
10
10
|
/**
|
|
11
11
|
* The props that every registered component obtains.
|
|
12
12
|
*/
|
|
@@ -33,22 +33,47 @@ export interface ExtensionComponentProps<T> extends BaseComponentProps {
|
|
|
33
33
|
* The provided parameters for showing the extension.
|
|
34
34
|
*/
|
|
35
35
|
params: T extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[T] : T extends string ? any : T;
|
|
36
|
+
/**
|
|
37
|
+
* The optional children to receive, if any.
|
|
38
|
+
*/
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The meta data registered for a page.
|
|
43
|
+
*/
|
|
44
|
+
export interface PiralPageMeta extends PiralCustomPageMeta {
|
|
36
45
|
}
|
|
37
46
|
/**
|
|
38
47
|
* The props that every registered page component obtains.
|
|
39
48
|
*/
|
|
40
|
-
export interface RouteBaseProps<UrlParams
|
|
49
|
+
export interface RouteBaseProps<UrlParams extends {
|
|
50
|
+
[K in keyof UrlParams]?: string;
|
|
51
|
+
} = {}, UrlState = any> extends RouteComponentProps<UrlParams, {}, UrlState>, BaseComponentProps {
|
|
41
52
|
}
|
|
42
53
|
/**
|
|
43
54
|
* The props used by a page component.
|
|
44
55
|
*/
|
|
45
|
-
export interface PageComponentProps<T
|
|
56
|
+
export interface PageComponentProps<T extends {
|
|
57
|
+
[K in keyof T]?: string;
|
|
58
|
+
} = {}, S = any> extends RouteBaseProps<T, S> {
|
|
59
|
+
/**
|
|
60
|
+
* The meta data registered with the page.
|
|
61
|
+
*/
|
|
62
|
+
meta: PiralPageMeta;
|
|
63
|
+
/**
|
|
64
|
+
* The children of the page.
|
|
65
|
+
*/
|
|
66
|
+
children: ReactNode;
|
|
46
67
|
}
|
|
47
68
|
/**
|
|
48
69
|
* The meta data registered for a page.
|
|
49
70
|
*/
|
|
50
71
|
export interface PiralPageMeta extends PiralCustomPageMeta {
|
|
51
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Shorthand for the definition of an extension component.
|
|
75
|
+
*/
|
|
76
|
+
export type AnyExtensionComponent<TName> = TName extends keyof PiralExtensionSlotMap ? AnyComponent<ExtensionComponentProps<TName>> : TName extends string ? AnyComponent<ExtensionComponentProps<any>> : AnyComponent<ExtensionComponentProps<TName>>;
|
|
52
77
|
/**
|
|
53
78
|
* Defines the Pilet API from piral-core.
|
|
54
79
|
* This interface will be consumed by pilet developers so that their pilet can interact with the piral instance.
|
|
@@ -89,14 +114,14 @@ export interface PiletCoreApi {
|
|
|
89
114
|
* @param Component The component to be rendered.
|
|
90
115
|
* @param defaults Optionally, sets the default values for the expected data.
|
|
91
116
|
*/
|
|
92
|
-
registerExtension<TName>(name: TName extends string ? TName : string, Component:
|
|
117
|
+
registerExtension<TName>(name: TName extends string ? TName : string, Component: AnyExtensionComponent<TName>, defaults?: Partial<ExtensionParams<TName>>): RegistrationDisposer;
|
|
93
118
|
/**
|
|
94
119
|
* Unregisters a global extension component.
|
|
95
120
|
* Only previously registered extension components can be unregistered.
|
|
96
121
|
* @param name The name of the extension slot to unregister from.
|
|
97
122
|
* @param Component The registered extension component to unregister.
|
|
98
123
|
*/
|
|
99
|
-
unregisterExtension<TName>(name: TName extends string ? TName : string, Component:
|
|
124
|
+
unregisterExtension<TName>(name: TName extends string ? TName : string, Component: AnyExtensionComponent<TName>): void;
|
|
100
125
|
/**
|
|
101
126
|
* React component for displaying extensions for a given name.
|
|
102
127
|
* @param props The extension's rendering props.
|
|
@@ -111,7 +136,7 @@ export interface PiletCoreApi {
|
|
|
111
136
|
*/
|
|
112
137
|
renderHtmlExtension<TName>(element: HTMLElement | ShadowRoot, props: ExtensionSlotProps<TName>): Disposable;
|
|
113
138
|
}
|
|
114
|
-
declare module 'piral-base/lib/types' {
|
|
139
|
+
declare module 'piral-base/lib/types/runtime' {
|
|
115
140
|
interface PiletApi extends PiletCustomApi, PiletCoreApi {
|
|
116
141
|
}
|
|
117
142
|
}
|
package/lib/types/common.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ValuesOf<T> = T extends {
|
|
2
2
|
[_ in keyof T]: infer U;
|
|
3
3
|
} ? U : never;
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
4
|
+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
5
|
+
export type RemainingArgs<T> = T extends (_: any, ...args: infer U) => any ? U : never;
|
|
6
|
+
export type DeepPartial<T> = {
|
|
7
7
|
[P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends {} ? DeepPartial<T[P]> : T[P];
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type NestedPartial<T> = {
|
|
10
10
|
[P in keyof T]?: T[P] extends Array<infer U> ? Array<Partial<U>> : T[P] extends {} ? Partial<T[P]> : T[P];
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
12
|
+
export type Dict<T> = Record<string, T>;
|
|
13
|
+
export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
14
|
+
export type FirstParameter<T extends (arg: any) => any> = T extends (arg: infer P) => any ? P : never;
|
|
15
|
+
export type FirstParametersOf<T> = {
|
|
16
16
|
[K in keyof T]: T[K] extends (arg: any) => any ? FirstParameter<T[K]> : never;
|
|
17
17
|
}[keyof T];
|
|
18
|
-
export
|
|
18
|
+
export type UnionOf<T> = {
|
|
19
19
|
[K in keyof T]: T[K];
|
|
20
20
|
}[keyof T];
|
|
21
|
-
export
|
|
21
|
+
export type MaybeAsync<T> = T | (() => Promise<T>);
|