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/types/state.d.ts
CHANGED
|
@@ -1,41 +1,54 @@
|
|
|
1
|
-
import type { ComponentType, ReactPortal } from 'react';
|
|
1
|
+
import type { ComponentType, ReactPortal, PropsWithChildren } from 'react';
|
|
2
2
|
import type { RouteComponentProps } from 'react-router';
|
|
3
|
-
import type { Atom } from '@dbeining/react-atom';
|
|
4
3
|
import type { LoadPiletsOptions } from 'piral-base';
|
|
4
|
+
import type { UseBoundStore } from 'zustand';
|
|
5
5
|
import type { Dict, Without } from './common';
|
|
6
|
-
import type {
|
|
6
|
+
import type { NavigationApi } from './navigation';
|
|
7
7
|
import type { SharedDataItem, DataStoreTarget } from './data';
|
|
8
8
|
import type { PiralCustomActions, PiralCustomState, PiralCustomRegistryState, PiralCustomComponentsState } from './custom';
|
|
9
|
-
import type {
|
|
10
|
-
import type { ComponentConverters, LoadingIndicatorProps, ErrorInfoProps, RouterProps, LayoutProps, Errors } from './components';
|
|
9
|
+
import type { EventEmitter, Pilet, BaseComponentProps, PageComponentProps, ExtensionComponentProps, PiletsBag, PiralPageMeta, PiletEntry } from './api';
|
|
10
|
+
import type { ComponentConverters, LoadingIndicatorProps, ErrorInfoProps, RouterProps, LayoutProps, Errors, RouteSwitchProps } from './components';
|
|
11
11
|
export interface StateDispatcher<TState> {
|
|
12
12
|
(state: TState): Partial<TState>;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
interface ComponentContext {
|
|
16
|
-
state: Atom<GlobalState>;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export declare type WrappedComponent<TProps> = ComponentType<Without<TProps, keyof BaseComponentProps>>;
|
|
14
|
+
export type WrappedComponent<TProps> = ComponentType<PropsWithChildren<Without<TProps, keyof BaseComponentProps>>>;
|
|
20
15
|
/**
|
|
21
16
|
* The base type for pilet component registration in the global state context.
|
|
22
17
|
*/
|
|
23
18
|
export interface BaseRegistration {
|
|
19
|
+
/**
|
|
20
|
+
* The pilet registering the component.
|
|
21
|
+
*/
|
|
24
22
|
pilet: string;
|
|
25
23
|
}
|
|
26
24
|
/**
|
|
27
25
|
* The interface modeling the registration of a pilet page component.
|
|
28
26
|
*/
|
|
29
27
|
export interface PageRegistration extends BaseRegistration {
|
|
28
|
+
/**
|
|
29
|
+
* The registered page component.
|
|
30
|
+
*/
|
|
30
31
|
component: WrappedComponent<PageComponentProps>;
|
|
32
|
+
/**
|
|
33
|
+
* The page's associated metadata.
|
|
34
|
+
*/
|
|
31
35
|
meta: PiralPageMeta;
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* The interface modeling the registration of a pilet extension component.
|
|
35
39
|
*/
|
|
36
40
|
export interface ExtensionRegistration extends BaseRegistration {
|
|
41
|
+
/**
|
|
42
|
+
* The wrapped registered extension component.
|
|
43
|
+
*/
|
|
37
44
|
component: WrappedComponent<ExtensionComponentProps<string>>;
|
|
45
|
+
/**
|
|
46
|
+
* The original extension component that has been registered.
|
|
47
|
+
*/
|
|
38
48
|
reference: any;
|
|
49
|
+
/**
|
|
50
|
+
* The default params (i.e., meta) of the extension.
|
|
51
|
+
*/
|
|
39
52
|
defaults: any;
|
|
40
53
|
}
|
|
41
54
|
/**
|
|
@@ -58,6 +71,10 @@ export interface ComponentsState extends PiralCustomComponentsState {
|
|
|
58
71
|
* The layout used for pages.
|
|
59
72
|
*/
|
|
60
73
|
Layout: ComponentType<LayoutProps>;
|
|
74
|
+
/**
|
|
75
|
+
* The route switch used for determining the route registration.
|
|
76
|
+
*/
|
|
77
|
+
RouteSwitch: ComponentType<RouteSwitchProps>;
|
|
61
78
|
/**
|
|
62
79
|
* A component that can be used for debugging purposes.
|
|
63
80
|
*/
|
|
@@ -67,10 +84,6 @@ export interface ComponentsState extends PiralCustomComponentsState {
|
|
|
67
84
|
* The Piral global app sub-state container for app information.
|
|
68
85
|
*/
|
|
69
86
|
export interface AppState {
|
|
70
|
-
/**
|
|
71
|
-
* Information for the layout computation.
|
|
72
|
-
*/
|
|
73
|
-
layout: LayoutType;
|
|
74
87
|
/**
|
|
75
88
|
* Gets if the application is currently performing a background loading
|
|
76
89
|
* activity, e.g., for loading modules asynchronously or fetching
|
|
@@ -99,7 +112,7 @@ export interface RegistryState extends PiralCustomRegistryState {
|
|
|
99
112
|
*/
|
|
100
113
|
wrappers: Dict<ComponentType<any>>;
|
|
101
114
|
}
|
|
102
|
-
export
|
|
115
|
+
export type ErrorComponentsState = {
|
|
103
116
|
[P in keyof Errors]?: ComponentType<Errors[P]>;
|
|
104
117
|
};
|
|
105
118
|
/**
|
|
@@ -125,7 +138,7 @@ export interface GlobalState extends PiralCustomState {
|
|
|
125
138
|
/**
|
|
126
139
|
* Gets the loaded modules.
|
|
127
140
|
*/
|
|
128
|
-
modules: Array<
|
|
141
|
+
modules: Array<Pilet>;
|
|
129
142
|
/**
|
|
130
143
|
* The foreign component portals to render.
|
|
131
144
|
*/
|
|
@@ -152,7 +165,7 @@ export interface PiralAction<T extends (...args: any) => any> {
|
|
|
152
165
|
/**
|
|
153
166
|
* A subset of the available app actions in Piral.
|
|
154
167
|
*/
|
|
155
|
-
export
|
|
168
|
+
export type PiralDefineActions = Partial<{
|
|
156
169
|
[P in keyof PiralActions]: PiralAction<PiralActions[P]>;
|
|
157
170
|
}>;
|
|
158
171
|
/**
|
|
@@ -167,10 +180,22 @@ export interface PiralActions extends PiralCustomActions {
|
|
|
167
180
|
*/
|
|
168
181
|
initialize(loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
|
|
169
182
|
/**
|
|
170
|
-
* Injects
|
|
183
|
+
* Injects an evaluated pilet at runtime - removes the pilet from registry first if available.
|
|
171
184
|
* @param pilet The pilet to be injected.
|
|
185
|
+
* @returns The injected pilet.
|
|
186
|
+
*/
|
|
187
|
+
injectPilet(pilet: Pilet): Pilet;
|
|
188
|
+
/**
|
|
189
|
+
* Adds a pilet at runtime by loading it, evaluating it, and then injecting it.
|
|
190
|
+
* @param pilet The pilet to be added.
|
|
191
|
+
* @returns The promise indicating when the pilet was fully added.
|
|
192
|
+
*/
|
|
193
|
+
addPilet(pilet: PiletEntry): Promise<void>;
|
|
194
|
+
/**
|
|
195
|
+
* Removes a pilet by unloading it and deleting all component registrations.
|
|
196
|
+
* @param name The name of the pilet to remove.
|
|
172
197
|
*/
|
|
173
|
-
|
|
198
|
+
removePilet(name: string): Promise<void>;
|
|
174
199
|
/**
|
|
175
200
|
* Defines a single action for Piral.
|
|
176
201
|
* @param actionName The name of the action to define.
|
|
@@ -199,11 +224,6 @@ export interface PiralActions extends PiralCustomActions {
|
|
|
199
224
|
* @param expiration The time for when to dispose the shared item.
|
|
200
225
|
*/
|
|
201
226
|
tryWriteDataItem(name: string, value: any, owner: string, target: DataStoreTarget, expiration: number): boolean;
|
|
202
|
-
/**
|
|
203
|
-
* Performs a layout change.
|
|
204
|
-
* @param current The layout to take.
|
|
205
|
-
*/
|
|
206
|
-
changeLayout(current: LayoutType): void;
|
|
207
227
|
/**
|
|
208
228
|
* Registers a new route to be resolved.
|
|
209
229
|
* @param route The route to register.
|
|
@@ -244,7 +264,9 @@ export interface PiralActions extends PiralCustomActions {
|
|
|
244
264
|
* @param path The name of the component.
|
|
245
265
|
* @param component The component to use for rendering.
|
|
246
266
|
*/
|
|
247
|
-
setRoute<T
|
|
267
|
+
setRoute<T extends {
|
|
268
|
+
[K in keyof T]?: string;
|
|
269
|
+
} = {}>(path: string, component: ComponentType<RouteComponentProps<T>>): void;
|
|
248
270
|
/**
|
|
249
271
|
* Includes a new provider as a sub-provider to the current provider.
|
|
250
272
|
* @param provider The provider to include.
|
|
@@ -261,6 +283,19 @@ export interface PiralActions extends PiralCustomActions {
|
|
|
261
283
|
* @param entry The child to render.
|
|
262
284
|
*/
|
|
263
285
|
showPortal(id: string, entry: ReactPortal): void;
|
|
286
|
+
/**
|
|
287
|
+
* Hides the provided portal in the rendering pipeline.
|
|
288
|
+
* @param id The id of the portal to use.
|
|
289
|
+
* @param entry The child to remove.
|
|
290
|
+
*/
|
|
291
|
+
hidePortal(id: string, entry: ReactPortal): void;
|
|
292
|
+
/**
|
|
293
|
+
* Updates the provided portal in the rendering pipeline.
|
|
294
|
+
* @param id The id of the portal to use.
|
|
295
|
+
* @param current The currently displayed child.
|
|
296
|
+
* @param next The updated child that should be displayed.
|
|
297
|
+
*/
|
|
298
|
+
updatePortal(id: string, current: ReactPortal, next: ReactPortal): void;
|
|
264
299
|
/**
|
|
265
300
|
* Dispatches a state change.
|
|
266
301
|
* @param update The update function creating a new state.
|
|
@@ -281,7 +316,7 @@ export interface GlobalStateContext extends PiralActions, EventEmitter {
|
|
|
281
316
|
* The global state context atom.
|
|
282
317
|
* Changes to the state should always be dispatched via the `dispatch` action.
|
|
283
318
|
*/
|
|
284
|
-
state:
|
|
319
|
+
state: UseBoundStore<GlobalState>;
|
|
285
320
|
/**
|
|
286
321
|
* The API objects created for the loaded pilets.
|
|
287
322
|
*/
|
|
@@ -290,6 +325,10 @@ export interface GlobalStateContext extends PiralActions, EventEmitter {
|
|
|
290
325
|
* The available component converters.
|
|
291
326
|
*/
|
|
292
327
|
converters: ComponentConverters<any>;
|
|
328
|
+
/**
|
|
329
|
+
* The navigation manager for the whole instance.
|
|
330
|
+
*/
|
|
331
|
+
navigation: NavigationApi;
|
|
293
332
|
/**
|
|
294
333
|
* The initial options.
|
|
295
334
|
*/
|
package/esm/types/utils.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export interface PiralStoreDataEvent<TValue = any> {
|
|
|
55
55
|
*/
|
|
56
56
|
expires: number;
|
|
57
57
|
}
|
|
58
|
-
declare module 'piral-base/lib/types' {
|
|
58
|
+
declare module 'piral-base/lib/types/api' {
|
|
59
59
|
interface PiralEventMap extends PiralCustomEventMap {
|
|
60
60
|
'store-data': PiralStoreDataEvent;
|
|
61
61
|
}
|
package/esm/utils/compare.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function isSame<T>(a: T, b: T): boolean;
|
package/esm/utils/compare.js
CHANGED
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
function compareObjects(a, b) {
|
|
2
|
-
for (
|
|
2
|
+
for (const i in a) {
|
|
3
3
|
if (!(i in b)) {
|
|
4
4
|
return false;
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
for (
|
|
8
|
-
if (!
|
|
7
|
+
for (const i in b) {
|
|
8
|
+
if (!isSame(a[i], b[i])) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
return true;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
function compareArrays(a, b) {
|
|
15
|
+
const l = a.length;
|
|
16
|
+
if (l === b.length) {
|
|
17
|
+
for (let i = 0; i < l; i++) {
|
|
18
|
+
if (!isSame(a[i], b[i])) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
export function isSame(a, b) {
|
|
15
27
|
if (a !== b) {
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
const ta = typeof a;
|
|
29
|
+
const tb = typeof b;
|
|
18
30
|
if (ta === tb && ta === 'object' && a && b) {
|
|
19
|
-
|
|
31
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
32
|
+
return compareArrays(a, b);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
return compareObjects(a, b);
|
|
36
|
+
}
|
|
20
37
|
}
|
|
21
38
|
return false;
|
|
22
39
|
}
|
package/esm/utils/compare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/utils/compare.ts"],"names":[],"mappings":"AAAA,SAAS,cAAc,CAAC,CAAM,EAAE,CAAM;IACpC,KAAK,
|
|
1
|
+
{"version":3,"file":"compare.js","sourceRoot":"","sources":["../../src/utils/compare.ts"],"names":[],"mappings":"AAAA,SAAS,cAAc,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AC,CAAC,CAAC;aAC7B;SACF;QAED,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/esm/utils/data.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
const defaultTarget = 'memory';
|
|
2
2
|
export function createDataView(data) {
|
|
3
|
-
|
|
3
|
+
const proxyName = 'Proxy';
|
|
4
4
|
return (window[proxyName] &&
|
|
5
5
|
new Proxy(data, {
|
|
6
|
-
get
|
|
7
|
-
|
|
6
|
+
get(target, name) {
|
|
7
|
+
const item = target[name];
|
|
8
8
|
return item && item.value;
|
|
9
9
|
},
|
|
10
|
-
set
|
|
10
|
+
set(_target, _name, _value) {
|
|
11
11
|
return true;
|
|
12
12
|
},
|
|
13
13
|
}));
|
|
14
14
|
}
|
|
15
|
-
export function createDataOptions(options) {
|
|
16
|
-
if (options === void 0) { options = defaultTarget; }
|
|
15
|
+
export function createDataOptions(options = defaultTarget) {
|
|
17
16
|
if (typeof options === 'string') {
|
|
18
17
|
return {
|
|
19
18
|
target: options,
|
package/esm/utils/data.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/utils/data.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/utils/data.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAAoB,QAAQ,CAAC;AAEhD,MAAM,UAAU,cAAc,CAAC,IAA0B;IACvD,MAAM,SAAS,GAAG,OAAO,CAAC;IAC1B,OAAO,CACL,MAAM,CAAC,SAAS,CAAC;QACjB,IAAI,KAAK,CAAC,IAAI,EAAE;YACd,GAAG,CAAC,MAAM,EAAE,IAAI;gBACd,MAAM,IAAI,GAAG,MAAM,CAAC,IAAc,CAAC,CAAC;gBACpC,OAAO,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC;YAC5B,CAAC;YACD,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM;gBACxB,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,UAA4B,aAAa;IACzE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO;YACL,MAAM,EAAE,OAAO;SAChB,CAAC;KACH;SAAM,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC5E,OAAO,OAAO,CAAC;KAChB;SAAM;QACL,OAAO;YACL,MAAM,EAAE,aAAa;SACtB,CAAC;KACH;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAiC;IACjE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO,OAAO,CAAC;KAChB;SAAM,IAAI,OAAO,YAAY,IAAI,EAAE;QAClC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;KAC1B;IAED,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ExtensionComponentProps, WrappedComponent } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms the given component to an extension component.
|
|
5
|
+
* @param Component The component to transform.
|
|
6
|
+
* @returns The extension component (receiving its props via params).
|
|
7
|
+
*/
|
|
8
|
+
export declare function toExtension<T>(Component: React.ComponentType<T>): WrappedComponent<ExtensionComponentProps<T>>;
|
|
9
|
+
/**
|
|
10
|
+
* Reactifies the list of child nodes to a React Node by removing the
|
|
11
|
+
* nodes from the DOM and carrying it in a React Node, where it would be
|
|
12
|
+
* attached at a slot.
|
|
13
|
+
* @param childNodes The child nodes to reactify.
|
|
14
|
+
* @returns The React Node.
|
|
15
|
+
*/
|
|
16
|
+
export declare function reactifyContent(childNodes: NodeListOf<ChildNode>): React.ReactNode;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
function removeAll(nodes) {
|
|
3
|
+
nodes.forEach((node) => node.remove());
|
|
4
|
+
}
|
|
5
|
+
const SlotCarrier = ({ nodes }) => {
|
|
6
|
+
const host = React.useRef();
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
var _a;
|
|
9
|
+
(_a = host.current) === null || _a === void 0 ? void 0 : _a.append(...nodes);
|
|
10
|
+
return () => removeAll(nodes);
|
|
11
|
+
}, [nodes]);
|
|
12
|
+
if (nodes.length) {
|
|
13
|
+
return React.createElement("piral-slot", { ref: host });
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Transforms the given component to an extension component.
|
|
19
|
+
* @param Component The component to transform.
|
|
20
|
+
* @returns The extension component (receiving its props via params).
|
|
21
|
+
*/
|
|
22
|
+
export function toExtension(Component) {
|
|
23
|
+
return (props) => React.createElement(Component, Object.assign({}, props.params));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Reactifies the list of child nodes to a React Node by removing the
|
|
27
|
+
* nodes from the DOM and carrying it in a React Node, where it would be
|
|
28
|
+
* attached at a slot.
|
|
29
|
+
* @param childNodes The child nodes to reactify.
|
|
30
|
+
* @returns The React Node.
|
|
31
|
+
*/
|
|
32
|
+
export function reactifyContent(childNodes) {
|
|
33
|
+
const nodes = Array.prototype.filter.call(childNodes, Boolean);
|
|
34
|
+
removeAll(nodes);
|
|
35
|
+
return React.createElement(SlotCarrier, { nodes: nodes });
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/utils/extension.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,SAAS,SAAS,CAAC,KAAuB;IACxC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AACzC,CAAC;AAMD,MAAM,WAAW,GAA+B,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;IAC5D,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,EAAmB,CAAC;IAE7C,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;;QACnB,MAAA,IAAI,CAAC,OAAO,0CAAE,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;QAC/B,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,IAAI,KAAK,CAAC,MAAM,EAAE;QAChB,OAAO,oCAAY,GAAG,EAAE,IAAI,GAAI,CAAC;KAClC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAI,SAAiC;IAC9D,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAC,SAAS,oBAAK,KAAK,CAAC,MAAM,EAAI,CAAC;AACpD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,UAAiC;IAC/D,MAAM,KAAK,GAAqB,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACjF,SAAS,CAAC,KAAK,CAAC,CAAC;IACjB,OAAO,oBAAC,WAAW,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC;AACvC,CAAC"}
|
package/esm/utils/foreign.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
1
|
+
import { ComponentType, ReactPortal } from 'react';
|
|
2
2
|
import { GlobalStateContext, ForeignComponent } from '../types';
|
|
3
|
+
export declare const extensionName = "piral-extension";
|
|
4
|
+
export declare const portalName = "piral-portal";
|
|
5
|
+
export declare const slotName = "piral-slot";
|
|
6
|
+
export declare function attachDomPortal<TProps>(id: string, context: GlobalStateContext, element: HTMLElement | ShadowRoot, component: ComponentType<TProps>, props: TProps): [string, ReactPortal];
|
|
7
|
+
export declare function changeDomPortal<TProps>(id: string, current: ReactPortal, context: GlobalStateContext, element: HTMLElement | ShadowRoot, component: ComponentType<TProps>, props: TProps): [string, ReactPortal];
|
|
3
8
|
export declare function convertComponent<T extends {
|
|
4
9
|
type: string;
|
|
5
10
|
}, U>(converter: (component: T) => ForeignComponent<U>, component: T): ForeignComponent<U>;
|
|
6
|
-
export declare function renderInDom<TProps>(context: GlobalStateContext, element: HTMLElement | ShadowRoot, component: ComponentType<TProps>, props: TProps): string;
|
|
11
|
+
export declare function renderInDom<TProps>(context: GlobalStateContext, element: HTMLElement | ShadowRoot, component: ComponentType<TProps>, props: TProps): [string, ReactPortal];
|
package/esm/utils/foreign.js
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
|
+
export const extensionName = 'piral-extension';
|
|
4
|
+
export const portalName = 'piral-portal';
|
|
5
|
+
export const slotName = 'piral-slot';
|
|
6
|
+
export function attachDomPortal(id, context, element, component, props) {
|
|
7
|
+
const portal = createPortal(createElement(component, props), element);
|
|
8
|
+
context.showPortal(id, portal);
|
|
9
|
+
return [id, portal];
|
|
10
|
+
}
|
|
11
|
+
export function changeDomPortal(id, current, context, element, component, props) {
|
|
12
|
+
const next = createPortal(createElement(component, props), element);
|
|
13
|
+
context.updatePortal(id, current, next);
|
|
14
|
+
return [id, next];
|
|
15
|
+
}
|
|
3
16
|
export function convertComponent(converter, component) {
|
|
4
17
|
if (typeof converter !== 'function') {
|
|
5
|
-
throw new Error(
|
|
18
|
+
throw new Error(`No converter for component of type "${component.type}" registered.`);
|
|
6
19
|
}
|
|
7
20
|
return converter(component);
|
|
8
21
|
}
|
|
9
22
|
export function renderInDom(context, element, component, props) {
|
|
10
|
-
|
|
11
|
-
|
|
23
|
+
const portalId = 'pid';
|
|
24
|
+
let parent = element;
|
|
12
25
|
while (parent) {
|
|
13
|
-
if (parent instanceof Element && parent.hasAttribute(portalId)) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
context.showPortal(id, portal);
|
|
17
|
-
return id;
|
|
26
|
+
if (parent instanceof Element && parent.localName === portalName && parent.hasAttribute(portalId)) {
|
|
27
|
+
const id = parent.getAttribute(portalId);
|
|
28
|
+
return attachDomPortal(id, context, element, component, props);
|
|
18
29
|
}
|
|
19
30
|
parent = parent.parentNode || parent.host;
|
|
20
31
|
}
|
|
21
|
-
return
|
|
32
|
+
return attachDomPortal('root', context, element, component, props);
|
|
22
33
|
}
|
|
23
34
|
//# sourceMappingURL=foreign.js.map
|
package/esm/utils/foreign.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"foreign.js","sourceRoot":"","sources":["../../src/utils/foreign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"foreign.js","sourceRoot":"","sources":["../../src/utils/foreign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA8B,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAC/C,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC;AACzC,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC,MAAM,UAAU,eAAe,CAC7B,EAAU,EACV,OAA2B,EAC3B,OAAiC,EACjC,SAAgC,EAChC,KAAa;IAEb,MAAM,MAAM,GAAG,YAAY,CAAC,aAAa,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,OAAsB,CAAC,CAAC;IACrF,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,EAAE,M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id.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
function rand(c) {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const r = (Math.random() * 16) | 0;
|
|
3
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
4
4
|
return v.toString(16);
|
|
5
5
|
}
|
|
6
6
|
export function generateId() {
|
|
7
7
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, rand);
|
|
8
8
|
}
|
|
9
9
|
export function buildName(prefix, name) {
|
|
10
|
-
return prefix
|
|
10
|
+
return `${prefix}://${name}`;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=guid.js.map
|
package/esm/utils/guid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guid.js","sourceRoot":"","sources":["../../src/utils/guid.ts"],"names":[],"mappings":"AAAA,SAAS,IAAI,CAAC,CAAY;IACxB,
|
|
1
|
+
{"version":3,"file":"guid.js","sourceRoot":"","sources":["../../src/utils/guid.ts"],"names":[],"mappings":"AAAA,SAAS,IAAI,CAAC,CAAY;IACxB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;IAC1C,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,MAAc,EAAE,IAAqB;IAC7D,OAAO,GAAG,MAAM,MAAM,IAAI,EAAE,CAAC;AAC/B,CAAC"}
|
package/esm/utils/helpers.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
export declare const removeIndicator: any;
|
|
2
|
-
export declare
|
|
3
|
-
export declare
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
2
|
+
export declare const none: any[];
|
|
3
|
+
export declare const noop: () => void;
|
|
4
|
+
export declare function prependItem<T>(items: Array<T>, item: T): any[];
|
|
5
|
+
export declare function appendItem<T>(items: Array<T>, item: T): any[];
|
|
6
|
+
export declare function prependItems<T>(items: Array<T>, newItems: Array<T>): any[];
|
|
7
|
+
export declare function appendItems<T>(items: Array<T>, newItems: Array<T>): any[];
|
|
8
|
+
export declare function excludeItem<T>(items: Array<T>, item: T): any[];
|
|
9
|
+
export declare function includeItem<T>(items: Array<T>, item: T): any[];
|
|
10
|
+
export declare function replaceOrAddItem<T>(items: Array<T>, item: T, predicate: (item: T) => boolean): any[];
|
|
9
11
|
export declare function removeNested<T, U = any>(obj: T, predicate: (item: U) => boolean): T;
|
|
10
|
-
export declare function excludeOn<T>(items: Array<T>, predicate: (item: T) => boolean):
|
|
12
|
+
export declare function excludeOn<T>(items: Array<T>, predicate: (item: T) => boolean): any[];
|
|
11
13
|
export declare function updateKey<T, TKey extends keyof T>(obj: T, key: TKey, value: T[TKey]): T;
|
|
12
14
|
export declare function withKey<T, TKey extends keyof T>(obj: T, key: TKey, value: T[TKey]): T;
|
|
13
15
|
export declare function withoutKey<T, TKey extends keyof T>(obj: T, key: TKey): T;
|
|
16
|
+
export declare function tryParseJson(content: string): any;
|
package/esm/utils/helpers.js
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
2
|
// tslint:disable-next-line
|
|
3
|
-
export
|
|
3
|
+
export const removeIndicator = null;
|
|
4
|
+
// to avoid creating unnecessary empty arrays
|
|
5
|
+
export const none = [];
|
|
6
|
+
// to avoid creating unnecessary empty functions
|
|
7
|
+
export const noop = () => { };
|
|
4
8
|
export function prependItem(items, item) {
|
|
5
|
-
return
|
|
9
|
+
return [item, ...(items || none)];
|
|
6
10
|
}
|
|
7
11
|
export function appendItem(items, item) {
|
|
8
|
-
return
|
|
12
|
+
return [...(items || none), item];
|
|
9
13
|
}
|
|
10
14
|
export function prependItems(items, newItems) {
|
|
11
|
-
return
|
|
15
|
+
return [...newItems, ...(items || none)];
|
|
12
16
|
}
|
|
13
17
|
export function appendItems(items, newItems) {
|
|
14
|
-
return
|
|
18
|
+
return [...(items || none), ...newItems];
|
|
15
19
|
}
|
|
16
20
|
export function excludeItem(items, item) {
|
|
17
|
-
return (items ||
|
|
21
|
+
return (items || none).filter((m) => m !== item);
|
|
18
22
|
}
|
|
19
23
|
export function includeItem(items, item) {
|
|
20
|
-
return
|
|
24
|
+
return appendItem(excludeItem(items, item), item);
|
|
21
25
|
}
|
|
22
26
|
export function replaceOrAddItem(items, item, predicate) {
|
|
23
|
-
|
|
24
|
-
for (
|
|
27
|
+
const newItems = [...(items || none)];
|
|
28
|
+
for (let i = 0; i < newItems.length; i++) {
|
|
25
29
|
if (predicate(newItems[i])) {
|
|
26
30
|
newItems[i] = item;
|
|
27
31
|
return newItems;
|
|
@@ -31,10 +35,10 @@ export function replaceOrAddItem(items, item, predicate) {
|
|
|
31
35
|
return newItems;
|
|
32
36
|
}
|
|
33
37
|
export function removeNested(obj, predicate) {
|
|
34
|
-
return Object.keys(obj).reduce(
|
|
35
|
-
|
|
36
|
-
entries[key] = Object.keys(item).reduce(
|
|
37
|
-
|
|
38
|
+
return Object.keys(obj).reduce((entries, key) => {
|
|
39
|
+
const item = obj[key];
|
|
40
|
+
entries[key] = Object.keys(item).reduce((all, key) => {
|
|
41
|
+
const value = item[key];
|
|
38
42
|
if (Array.isArray(value)) {
|
|
39
43
|
all[key] = excludeOn(value, predicate);
|
|
40
44
|
}
|
|
@@ -47,17 +51,24 @@ export function removeNested(obj, predicate) {
|
|
|
47
51
|
}, {});
|
|
48
52
|
}
|
|
49
53
|
export function excludeOn(items, predicate) {
|
|
50
|
-
return (items ||
|
|
54
|
+
return (items || none).filter((m) => !predicate(m));
|
|
51
55
|
}
|
|
52
56
|
export function updateKey(obj, key, value) {
|
|
53
57
|
return value === removeIndicator ? withoutKey(obj, key) : withKey(obj, key, value);
|
|
54
58
|
}
|
|
55
59
|
export function withKey(obj, key, value) {
|
|
56
|
-
|
|
57
|
-
return __assign(__assign({}, obj), (_a = {}, _a[key] = value, _a));
|
|
60
|
+
return Object.assign(Object.assign({}, obj), { [key]: value });
|
|
58
61
|
}
|
|
59
62
|
export function withoutKey(obj, key) {
|
|
60
|
-
|
|
63
|
+
const _a = obj || {}, _b = key, _ = _a[_b], newObj = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
61
64
|
return newObj;
|
|
62
65
|
}
|
|
66
|
+
export function tryParseJson(content) {
|
|
67
|
+
try {
|
|
68
|
+
return JSON.parse(content);
|
|
69
|
+
}
|
|
70
|
+
catch (_a) {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
63
74
|
//# sourceMappingURL=helpers.js.map
|
package/esm/utils/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":";AAAA,2BAA2B;AAC3B,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/utils/helpers.ts"],"names":[],"mappings":";AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC;AAEpC,6CAA6C;AAC7C,MAAM,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;AAEvB,gDAAgD;AAChD,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAE7B,MAAM,UAAU,WAAW,CAAI,KAAe,EAAE,IAAO;IACrD,OAAO,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,GAAG,EAAE,KAAK,CAAC,CAAC;AACrF,CAAC;AAED,MAAM,UAAU,OAAO,CAA0B,GAAM,EAAE,GAAS,EAAE,KAAc;IAChF,uCACK,GAAG,KACN,CAAC,GAAG,CAAC,EAAE,KAAK,IACZ;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAA0B,GAAM,EAAE,GAAS;IACnE,MAAgC,KAAA,GAAG,IAAI,EAAE,EAAjC,KAAC,GAAI,EAAE,CAAC,SAAA,EAAK,MAAM,cAArB,uCAAuB,CAAY,CAAC;IAC1C,OAAO,MAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC5B;IAAC,WAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,CAAC"}
|
package/esm/utils/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
export { isfunc, requireModule } from 'piral-base';
|
|
1
2
|
export * from './compare';
|
|
2
3
|
export * from './data';
|
|
3
|
-
export * from './
|
|
4
|
+
export * from './extension';
|
|
4
5
|
export * from './foreign';
|
|
5
6
|
export * from './guid';
|
|
6
7
|
export * from './helpers';
|
|
7
8
|
export * from './media';
|
|
8
9
|
export * from './react';
|
|
10
|
+
export * from './state';
|
|
9
11
|
export * from './storage';
|
package/esm/utils/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
export { isfunc, requireModule } from 'piral-base';
|
|
1
2
|
export * from './compare';
|
|
2
3
|
export * from './data';
|
|
3
|
-
export * from './
|
|
4
|
+
export * from './extension';
|
|
4
5
|
export * from './foreign';
|
|
5
6
|
export * from './guid';
|
|
6
7
|
export * from './helpers';
|
|
7
8
|
export * from './media';
|
|
8
9
|
export * from './react';
|
|
10
|
+
export * from './state';
|
|
9
11
|
export * from './storage';
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
package/esm/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEnD,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|