@darajs/core 0.4.8
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 +201 -0
- package/README.md +101 -0
- package/dist/actions/download-variable.d.ts +8 -0
- package/dist/actions/download-variable.d.ts.map +1 -0
- package/dist/actions/download-variable.js +140 -0
- package/dist/actions/download-variable.js.map +1 -0
- package/dist/actions/index.d.ts +7 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +7 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/navigate-to.d.ts +8 -0
- package/dist/actions/navigate-to.d.ts.map +1 -0
- package/dist/actions/navigate-to.js +37 -0
- package/dist/actions/navigate-to.js.map +1 -0
- package/dist/actions/notify.d.ts +4 -0
- package/dist/actions/notify.d.ts.map +1 -0
- package/dist/actions/notify.js +11 -0
- package/dist/actions/notify.js.map +1 -0
- package/dist/actions/reset-variables.d.ts +8 -0
- package/dist/actions/reset-variables.d.ts.map +1 -0
- package/dist/actions/reset-variables.js +37 -0
- package/dist/actions/reset-variables.js.map +1 -0
- package/dist/actions/trigger-variable.d.ts +8 -0
- package/dist/actions/trigger-variable.d.ts.map +1 -0
- package/dist/actions/trigger-variable.js +14 -0
- package/dist/actions/trigger-variable.js.map +1 -0
- package/dist/actions/update-variable.d.ts +15 -0
- package/dist/actions/update-variable.d.ts.map +1 -0
- package/dist/actions/update-variable.js +56 -0
- package/dist/actions/update-variable.js.map +1 -0
- package/dist/api/core.d.ts +35 -0
- package/dist/api/core.d.ts.map +1 -0
- package/dist/api/core.js +112 -0
- package/dist/api/core.js.map +1 -0
- package/dist/api/http.d.ts +29 -0
- package/dist/api/http.d.ts.map +1 -0
- package/dist/api/http.js +126 -0
- package/dist/api/http.js.map +1 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +5 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/websocket.d.ts +222 -0
- package/dist/api/websocket.d.ts.map +1 -0
- package/dist/api/websocket.js +353 -0
- package/dist/api/websocket.js.map +1 -0
- package/dist/assets/causalens-dark.svg +29 -0
- package/dist/assets/causalens-light.svg +29 -0
- package/dist/assets/dara-dark.svg +20 -0
- package/dist/assets/dara-light.svg +15 -0
- package/dist/assets/fonts/Manrope-VariableFont_wght.ttf +0 -0
- package/dist/auth/auth-wrapper.d.ts +15 -0
- package/dist/auth/auth-wrapper.d.ts.map +1 -0
- package/dist/auth/auth-wrapper.js +72 -0
- package/dist/auth/auth-wrapper.js.map +1 -0
- package/dist/auth/auth.d.ts +61 -0
- package/dist/auth/auth.d.ts.map +1 -0
- package/dist/auth/auth.js +163 -0
- package/dist/auth/auth.js.map +1 -0
- package/dist/auth/basic/basic-auth-login.d.ts +6 -0
- package/dist/auth/basic/basic-auth-login.d.ts.map +1 -0
- package/dist/auth/basic/basic-auth-login.js +171 -0
- package/dist/auth/basic/basic-auth-login.js.map +1 -0
- package/dist/auth/basic/basic-auth-logout.d.ts +6 -0
- package/dist/auth/basic/basic-auth-logout.d.ts.map +1 -0
- package/dist/auth/basic/basic-auth-logout.js +18 -0
- package/dist/auth/basic/basic-auth-logout.js.map +1 -0
- package/dist/auth/default/default-auth-login.d.ts +6 -0
- package/dist/auth/default/default-auth-login.d.ts.map +1 -0
- package/dist/auth/default/default-auth-login.js +59 -0
- package/dist/auth/default/default-auth-login.js.map +1 -0
- package/dist/auth/index.d.ts +7 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +7 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/use-session-token.d.ts +19 -0
- package/dist/auth/use-session-token.d.ts.map +1 -0
- package/dist/auth/use-session-token.js +30 -0
- package/dist/auth/use-session-token.js.map +1 -0
- package/dist/components/fallback/default.d.ts +5 -0
- package/dist/components/fallback/default.d.ts.map +1 -0
- package/dist/components/fallback/default.js +10 -0
- package/dist/components/fallback/default.js.map +1 -0
- package/dist/components/fallback/dots.d.ts +7 -0
- package/dist/components/fallback/dots.d.ts.map +1 -0
- package/dist/components/fallback/dots.js +78 -0
- package/dist/components/fallback/dots.js.map +1 -0
- package/dist/components/fallback/row.d.ts +5 -0
- package/dist/components/fallback/row.d.ts.map +1 -0
- package/dist/components/fallback/row.js +14 -0
- package/dist/components/fallback/row.js.map +1 -0
- package/dist/components/for/for.d.ts +35 -0
- package/dist/components/for/for.d.ts.map +1 -0
- package/dist/components/for/for.js +44 -0
- package/dist/components/for/for.js.map +1 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +9 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/menu/menu.d.ts +14 -0
- package/dist/components/menu/menu.d.ts.map +1 -0
- package/dist/components/menu/menu.js +58 -0
- package/dist/components/menu/menu.js.map +1 -0
- package/dist/components/progress-tracker/progress-tracker.d.ts +18 -0
- package/dist/components/progress-tracker/progress-tracker.d.ts.map +1 -0
- package/dist/components/progress-tracker/progress-tracker.js +204 -0
- package/dist/components/progress-tracker/progress-tracker.js.map +1 -0
- package/dist/components/router-content/router-content.d.ts +14 -0
- package/dist/components/router-content/router-content.d.ts.map +1 -0
- package/dist/components/router-content/router-content.js +17 -0
- package/dist/components/router-content/router-content.js.map +1 -0
- package/dist/components/side-bar-frame/side-bar-frame.d.ts +21 -0
- package/dist/components/side-bar-frame/side-bar-frame.d.ts.map +1 -0
- package/dist/components/side-bar-frame/side-bar-frame.js +87 -0
- package/dist/components/side-bar-frame/side-bar-frame.js.map +1 -0
- package/dist/components/top-bar-frame/top-bar-frame.d.ts +16 -0
- package/dist/components/top-bar-frame/top-bar-frame.d.ts.map +1 -0
- package/dist/components/top-bar-frame/top-bar-frame.js +89 -0
- package/dist/components/top-bar-frame/top-bar-frame.js.map +1 -0
- package/dist/dara_core-0.4.8-py3-none-any.whl +0 -0
- package/dist/devtools/backend-errors/backend-errors-ctx.d.ts +17 -0
- package/dist/devtools/backend-errors/backend-errors-ctx.d.ts.map +1 -0
- package/dist/devtools/backend-errors/backend-errors-ctx.js +37 -0
- package/dist/devtools/backend-errors/backend-errors-ctx.js.map +1 -0
- package/dist/devtools/backend-errors/backend-errors.d.ts +6 -0
- package/dist/devtools/backend-errors/backend-errors.d.ts.map +1 -0
- package/dist/devtools/backend-errors/backend-errors.js +57 -0
- package/dist/devtools/backend-errors/backend-errors.js.map +1 -0
- package/dist/devtools/backend-errors/error-display.d.ts +22 -0
- package/dist/devtools/backend-errors/error-display.d.ts.map +1 -0
- package/dist/devtools/backend-errors/error-display.js +101 -0
- package/dist/devtools/backend-errors/error-display.js.map +1 -0
- package/dist/devtools/backend-errors/index.d.ts +3 -0
- package/dist/devtools/backend-errors/index.d.ts.map +1 -0
- package/dist/devtools/backend-errors/index.js +3 -0
- package/dist/devtools/backend-errors/index.js.map +1 -0
- package/dist/devtools/devtools-content.d.ts +12 -0
- package/dist/devtools/devtools-content.d.ts.map +1 -0
- package/dist/devtools/devtools-content.js +73 -0
- package/dist/devtools/devtools-content.js.map +1 -0
- package/dist/devtools/devtools-context.d.ts +7 -0
- package/dist/devtools/devtools-context.d.ts.map +1 -0
- package/dist/devtools/devtools-context.js +9 -0
- package/dist/devtools/devtools-context.js.map +1 -0
- package/dist/devtools/devtools-wrapper.d.ts +8 -0
- package/dist/devtools/devtools-wrapper.d.ts.map +1 -0
- package/dist/devtools/devtools-wrapper.js +64 -0
- package/dist/devtools/devtools-wrapper.js.map +1 -0
- package/dist/devtools/devtools.d.ts +5 -0
- package/dist/devtools/devtools.d.ts.map +1 -0
- package/dist/devtools/devtools.js +10 -0
- package/dist/devtools/devtools.js.map +1 -0
- package/dist/devtools/floating-button.d.ts +23 -0
- package/dist/devtools/floating-button.d.ts.map +1 -0
- package/dist/devtools/floating-button.js +94 -0
- package/dist/devtools/floating-button.js.map +1 -0
- package/dist/devtools/index.d.ts +2 -0
- package/dist/devtools/index.d.ts.map +1 -0
- package/dist/devtools/index.js +2 -0
- package/dist/devtools/index.js.map +1 -0
- package/dist/devtools/resizer.d.ts +18 -0
- package/dist/devtools/resizer.d.ts.map +1 -0
- package/dist/devtools/resizer.js +49 -0
- package/dist/devtools/resizer.js.map +1 -0
- package/dist/devtools/use-move.d.ts +21 -0
- package/dist/devtools/use-move.d.ts.map +1 -0
- package/dist/devtools/use-move.js +56 -0
- package/dist/devtools/use-move.js.map +1 -0
- package/dist/index.css +95 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/jest-setup.d.ts +2 -0
- package/dist/jest-setup.d.ts.map +1 -0
- package/dist/jest-setup.js +18 -0
- package/dist/jest-setup.js.map +1 -0
- package/dist/pages/error-page.d.ts +3 -0
- package/dist/pages/error-page.d.ts.map +1 -0
- package/dist/pages/error-page.js +32 -0
- package/dist/pages/error-page.js.map +1 -0
- package/dist/pages/sso-callback-page.d.ts +6 -0
- package/dist/pages/sso-callback-page.d.ts.map +1 -0
- package/dist/pages/sso-callback-page.js +8 -0
- package/dist/pages/sso-callback-page.js.map +1 -0
- package/dist/run.d.ts +22 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +40 -0
- package/dist/run.js.map +1 -0
- package/dist/shared/center/center.d.ts +5 -0
- package/dist/shared/center/center.d.ts.map +1 -0
- package/dist/shared/center/center.js +15 -0
- package/dist/shared/center/center.js.map +1 -0
- package/dist/shared/context/direction-context.d.ts +6 -0
- package/dist/shared/context/direction-context.d.ts.map +1 -0
- package/dist/shared/context/direction-context.js +4 -0
- package/dist/shared/context/direction-context.js.map +1 -0
- package/dist/shared/context/display-context.d.ts +13 -0
- package/dist/shared/context/display-context.d.ts.map +1 -0
- package/dist/shared/context/display-context.js +4 -0
- package/dist/shared/context/display-context.js.map +1 -0
- package/dist/shared/context/fallback-context.d.ts +11 -0
- package/dist/shared/context/fallback-context.d.ts.map +1 -0
- package/dist/shared/context/fallback-context.js +4 -0
- package/dist/shared/context/fallback-context.js.map +1 -0
- package/dist/shared/context/global-task-context.d.ts +40 -0
- package/dist/shared/context/global-task-context.d.ts.map +1 -0
- package/dist/shared/context/global-task-context.js +81 -0
- package/dist/shared/context/global-task-context.js.map +1 -0
- package/dist/shared/context/importers-context.d.ts +6 -0
- package/dist/shared/context/importers-context.d.ts.map +1 -0
- package/dist/shared/context/importers-context.js +4 -0
- package/dist/shared/context/importers-context.js.map +1 -0
- package/dist/shared/context/index.d.ts +10 -0
- package/dist/shared/context/index.d.ts.map +1 -0
- package/dist/shared/context/index.js +10 -0
- package/dist/shared/context/index.js.map +1 -0
- package/dist/shared/context/registries-context.d.ts +20 -0
- package/dist/shared/context/registries-context.d.ts.map +1 -0
- package/dist/shared/context/registries-context.js +8 -0
- package/dist/shared/context/registries-context.js.map +1 -0
- package/dist/shared/context/request-extras-context.d.ts +33 -0
- package/dist/shared/context/request-extras-context.d.ts.map +1 -0
- package/dist/shared/context/request-extras-context.js +55 -0
- package/dist/shared/context/request-extras-context.js.map +1 -0
- package/dist/shared/context/variable-context.d.ts +10 -0
- package/dist/shared/context/variable-context.d.ts.map +1 -0
- package/dist/shared/context/variable-context.js +4 -0
- package/dist/shared/context/variable-context.js.map +1 -0
- package/dist/shared/context/websocket-context.d.ts +7 -0
- package/dist/shared/context/websocket-context.d.ts.map +1 -0
- package/dist/shared/context/websocket-context.js +4 -0
- package/dist/shared/context/websocket-context.js.map +1 -0
- package/dist/shared/dynamic-component/clean-props.d.ts +6 -0
- package/dist/shared/dynamic-component/clean-props.d.ts.map +1 -0
- package/dist/shared/dynamic-component/clean-props.js +13 -0
- package/dist/shared/dynamic-component/clean-props.js.map +1 -0
- package/dist/shared/dynamic-component/dynamic-component.d.ts +16 -0
- package/dist/shared/dynamic-component/dynamic-component.d.ts.map +1 -0
- package/dist/shared/dynamic-component/dynamic-component.js +252 -0
- package/dist/shared/dynamic-component/dynamic-component.js.map +1 -0
- package/dist/shared/error-handling/error-display.d.ts +8 -0
- package/dist/shared/error-handling/error-display.d.ts.map +1 -0
- package/dist/shared/error-handling/error-display.js +94 -0
- package/dist/shared/error-handling/error-display.js.map +1 -0
- package/dist/shared/error-handling/index.d.ts +3 -0
- package/dist/shared/error-handling/index.d.ts.map +1 -0
- package/dist/shared/error-handling/index.js +3 -0
- package/dist/shared/error-handling/index.js.map +1 -0
- package/dist/shared/error-handling/types.d.ts +11 -0
- package/dist/shared/error-handling/types.d.ts.map +1 -0
- package/dist/shared/error-handling/types.js +9 -0
- package/dist/shared/error-handling/types.js.map +1 -0
- package/dist/shared/event-bus/event-bus.d.ts +27 -0
- package/dist/shared/event-bus/event-bus.d.ts.map +1 -0
- package/dist/shared/event-bus/event-bus.js +58 -0
- package/dist/shared/event-bus/event-bus.js.map +1 -0
- package/dist/shared/global-state-store.d.ts +54 -0
- package/dist/shared/global-state-store.d.ts.map +1 -0
- package/dist/shared/global-state-store.js +168 -0
- package/dist/shared/global-state-store.js.map +1 -0
- package/dist/shared/index.d.ts +12 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +10 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/interactivity/data-variable.d.ts +78 -0
- package/dist/shared/interactivity/data-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/data-variable.js +218 -0
- package/dist/shared/interactivity/data-variable.js.map +1 -0
- package/dist/shared/interactivity/derived-variable.d.ts +160 -0
- package/dist/shared/interactivity/derived-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/derived-variable.js +446 -0
- package/dist/shared/interactivity/derived-variable.js.map +1 -0
- package/dist/shared/interactivity/filtering.d.ts +9 -0
- package/dist/shared/interactivity/filtering.d.ts.map +1 -0
- package/dist/shared/interactivity/filtering.js +20 -0
- package/dist/shared/interactivity/filtering.js.map +1 -0
- package/dist/shared/interactivity/index.d.ts +10 -0
- package/dist/shared/interactivity/index.d.ts.map +1 -0
- package/dist/shared/interactivity/index.js +9 -0
- package/dist/shared/interactivity/index.js.map +1 -0
- package/dist/shared/interactivity/internal.d.ts +9 -0
- package/dist/shared/interactivity/internal.d.ts.map +1 -0
- package/dist/shared/interactivity/internal.js +11 -0
- package/dist/shared/interactivity/internal.js.map +1 -0
- package/dist/shared/interactivity/nested.d.ts +16 -0
- package/dist/shared/interactivity/nested.d.ts.map +1 -0
- package/dist/shared/interactivity/nested.js +54 -0
- package/dist/shared/interactivity/nested.js.map +1 -0
- package/dist/shared/interactivity/persistence.d.ts +43 -0
- package/dist/shared/interactivity/persistence.d.ts.map +1 -0
- package/dist/shared/interactivity/persistence.js +215 -0
- package/dist/shared/interactivity/persistence.js.map +1 -0
- package/dist/shared/interactivity/plain-variable.d.ts +17 -0
- package/dist/shared/interactivity/plain-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/plain-variable.js +222 -0
- package/dist/shared/interactivity/plain-variable.js.map +1 -0
- package/dist/shared/interactivity/resolve-value.d.ts +13 -0
- package/dist/shared/interactivity/resolve-value.d.ts.map +1 -0
- package/dist/shared/interactivity/resolve-value.js +36 -0
- package/dist/shared/interactivity/resolve-value.js.map +1 -0
- package/dist/shared/interactivity/resolve-variable.d.ts +18 -0
- package/dist/shared/interactivity/resolve-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/resolve-variable.js +46 -0
- package/dist/shared/interactivity/resolve-variable.js.map +1 -0
- package/dist/shared/interactivity/store.d.ts +76 -0
- package/dist/shared/interactivity/store.d.ts.map +1 -0
- package/dist/shared/interactivity/store.js +99 -0
- package/dist/shared/interactivity/store.js.map +1 -0
- package/dist/shared/interactivity/triggers.d.ts +31 -0
- package/dist/shared/interactivity/triggers.d.ts.map +1 -0
- package/dist/shared/interactivity/triggers.js +105 -0
- package/dist/shared/interactivity/triggers.js.map +1 -0
- package/dist/shared/interactivity/url-variable.d.ts +12 -0
- package/dist/shared/interactivity/url-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/url-variable.js +27 -0
- package/dist/shared/interactivity/url-variable.js.map +1 -0
- package/dist/shared/interactivity/use-any-variable.d.ts +8 -0
- package/dist/shared/interactivity/use-any-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/use-any-variable.js +39 -0
- package/dist/shared/interactivity/use-any-variable.js.map +1 -0
- package/dist/shared/interactivity/use-data-variable.d.ts +18 -0
- package/dist/shared/interactivity/use-data-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/use-data-variable.js +58 -0
- package/dist/shared/interactivity/use-data-variable.js.map +1 -0
- package/dist/shared/interactivity/use-refresh-selector.d.ts +5 -0
- package/dist/shared/interactivity/use-refresh-selector.d.ts.map +1 -0
- package/dist/shared/interactivity/use-refresh-selector.js +20 -0
- package/dist/shared/interactivity/use-refresh-selector.js.map +1 -0
- package/dist/shared/interactivity/use-server-component.d.ts +24 -0
- package/dist/shared/interactivity/use-server-component.d.ts.map +1 -0
- package/dist/shared/interactivity/use-server-component.js +256 -0
- package/dist/shared/interactivity/use-server-component.js.map +1 -0
- package/dist/shared/interactivity/use-variable-state.d.ts +9 -0
- package/dist/shared/interactivity/use-variable-state.d.ts.map +1 -0
- package/dist/shared/interactivity/use-variable-state.js +26 -0
- package/dist/shared/interactivity/use-variable-state.js.map +1 -0
- package/dist/shared/interactivity/use-variable-value.d.ts +33 -0
- package/dist/shared/interactivity/use-variable-value.d.ts.map +1 -0
- package/dist/shared/interactivity/use-variable-value.js +94 -0
- package/dist/shared/interactivity/use-variable-value.js.map +1 -0
- package/dist/shared/interactivity/use-variable.d.ts +12 -0
- package/dist/shared/interactivity/use-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/use-variable.js +84 -0
- package/dist/shared/interactivity/use-variable.js.map +1 -0
- package/dist/shared/private-route/private-route.d.ts +19 -0
- package/dist/shared/private-route/private-route.d.ts.map +1 -0
- package/dist/shared/private-route/private-route.js +35 -0
- package/dist/shared/private-route/private-route.js.map +1 -0
- package/dist/shared/template-root/dynamic-context.d.ts +9 -0
- package/dist/shared/template-root/dynamic-context.d.ts.map +1 -0
- package/dist/shared/template-root/dynamic-context.js +29 -0
- package/dist/shared/template-root/dynamic-context.js.map +1 -0
- package/dist/shared/template-root/template-root.d.ts +12 -0
- package/dist/shared/template-root/template-root.d.ts.map +1 -0
- package/dist/shared/template-root/template-root.js +94 -0
- package/dist/shared/template-root/template-root.js.map +1 -0
- package/dist/shared/utils/clean-session-cache.d.ts +9 -0
- package/dist/shared/utils/clean-session-cache.d.ts.map +1 -0
- package/dist/shared/utils/clean-session-cache.js +19 -0
- package/dist/shared/utils/clean-session-cache.js.map +1 -0
- package/dist/shared/utils/embed.d.ts +22 -0
- package/dist/shared/utils/embed.d.ts.map +1 -0
- package/dist/shared/utils/embed.js +43 -0
- package/dist/shared/utils/embed.js.map +1 -0
- package/dist/shared/utils/get-icon.d.ts +9 -0
- package/dist/shared/utils/get-icon.d.ts.map +1 -0
- package/dist/shared/utils/get-icon.js +30 -0
- package/dist/shared/utils/get-icon.js.map +1 -0
- package/dist/shared/utils/hashing.d.ts +14 -0
- package/dist/shared/utils/hashing.d.ts.map +1 -0
- package/dist/shared/utils/hashing.js +26 -0
- package/dist/shared/utils/hashing.js.map +1 -0
- package/dist/shared/utils/index.d.ts +19 -0
- package/dist/shared/utils/index.d.ts.map +1 -0
- package/dist/shared/utils/index.js +17 -0
- package/dist/shared/utils/index.js.map +1 -0
- package/dist/shared/utils/inject-css.d.ts +12 -0
- package/dist/shared/utils/inject-css.d.ts.map +1 -0
- package/dist/shared/utils/inject-css.js +25 -0
- package/dist/shared/utils/inject-css.js.map +1 -0
- package/dist/shared/utils/is-js-component.d.ts +9 -0
- package/dist/shared/utils/is-js-component.d.ts.map +1 -0
- package/dist/shared/utils/is-js-component.js +11 -0
- package/dist/shared/utils/is-js-component.js.map +1 -0
- package/dist/shared/utils/normalization.d.ts +19 -0
- package/dist/shared/utils/normalization.d.ts.map +1 -0
- package/dist/shared/utils/normalization.js +121 -0
- package/dist/shared/utils/normalization.js.map +1 -0
- package/dist/shared/utils/resolve-theme.d.ts +9 -0
- package/dist/shared/utils/resolve-theme.d.ts.map +1 -0
- package/dist/shared/utils/resolve-theme.js +28 -0
- package/dist/shared/utils/resolve-theme.js.map +1 -0
- package/dist/shared/utils/templating.d.ts +24 -0
- package/dist/shared/utils/templating.d.ts.map +1 -0
- package/dist/shared/utils/templating.js +67 -0
- package/dist/shared/utils/templating.js.map +1 -0
- package/dist/shared/utils/use-action-registry.d.ts +11 -0
- package/dist/shared/utils/use-action-registry.d.ts.map +1 -0
- package/dist/shared/utils/use-action-registry.js +18 -0
- package/dist/shared/utils/use-action-registry.js.map +1 -0
- package/dist/shared/utils/use-action.d.ts +34 -0
- package/dist/shared/utils/use-action.d.ts.map +1 -0
- package/dist/shared/utils/use-action.js +314 -0
- package/dist/shared/utils/use-action.js.map +1 -0
- package/dist/shared/utils/use-component-registry.d.ts +11 -0
- package/dist/shared/utils/use-component-registry.d.ts.map +1 -0
- package/dist/shared/utils/use-component-registry.js +57 -0
- package/dist/shared/utils/use-component-registry.js.map +1 -0
- package/dist/shared/utils/use-component-styles.d.ts +24 -0
- package/dist/shared/utils/use-component-styles.d.ts.map +1 -0
- package/dist/shared/utils/use-component-styles.js +69 -0
- package/dist/shared/utils/use-component-styles.js.map +1 -0
- package/dist/shared/utils/use-defer-loadable.d.ts +8 -0
- package/dist/shared/utils/use-defer-loadable.d.ts.map +1 -0
- package/dist/shared/utils/use-defer-loadable.js +44 -0
- package/dist/shared/utils/use-defer-loadable.js.map +1 -0
- package/dist/shared/utils/use-interval.d.ts +9 -0
- package/dist/shared/utils/use-interval.d.ts.map +1 -0
- package/dist/shared/utils/use-interval.js +19 -0
- package/dist/shared/utils/use-interval.js.map +1 -0
- package/dist/shared/utils/use-previous.d.ts +10 -0
- package/dist/shared/utils/use-previous.d.ts.map +1 -0
- package/dist/shared/utils/use-previous.js +17 -0
- package/dist/shared/utils/use-previous.js.map +1 -0
- package/dist/shared/utils/use-url-sync.d.ts +20 -0
- package/dist/shared/utils/use-url-sync.d.ts.map +1 -0
- package/dist/shared/utils/use-url-sync.js +68 -0
- package/dist/shared/utils/use-url-sync.js.map +1 -0
- package/dist/shared/utils/use-window-title.d.ts +3 -0
- package/dist/shared/utils/use-window-title.d.ts.map +1 -0
- package/dist/shared/utils/use-window-title.js +14 -0
- package/dist/shared/utils/use-window-title.js.map +1 -0
- package/dist/shared/variable-state-provider/variable-state-provider.d.ts +10 -0
- package/dist/shared/variable-state-provider/variable-state-provider.d.ts.map +1 -0
- package/dist/shared/variable-state-provider/variable-state-provider.js +29 -0
- package/dist/shared/variable-state-provider/variable-state-provider.js.map +1 -0
- package/dist/shared/wrapper/wrapper.d.ts +7 -0
- package/dist/shared/wrapper/wrapper.d.ts.map +1 -0
- package/dist/shared/wrapper/wrapper.js +14 -0
- package/dist/shared/wrapper/wrapper.js.map +1 -0
- package/dist/types/auth.d.ts +15 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +6 -0
- package/dist/types/auth.js.map +1 -0
- package/dist/types/core.d.ts +440 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +22 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/utils.d.ts +56 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/utils.js +93 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/umd/dara.core.umd.js +86508 -0
- package/dist/umd/style.css +848 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +20 -0
- package/dist/utils.js.map +1 -0
- package/package.json +121 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-server-component.d.ts","sourceRoot":"","sources":["../../../js/shared/interactivity/use-server-component.tsx"],"names":[],"mappings":"AAUA,OAAO,EACH,WAAW,EACX,iBAAiB,EAKpB,MAAM,SAAS,CAAC;AAoEjB;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,GAAG,CAa9D;AA4LD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,GAChD,iBAAiB,CA4BnB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,IAAI,CAajE"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
22
|
+
import { useContext, useEffect } from 'react';
|
|
23
|
+
import { atom, selectorFamily, useRecoilCallback, useRecoilValueLoadable } from 'recoil';
|
|
24
|
+
import { HTTP_METHOD, validateResponse } from '@darajs/ui-utils';
|
|
25
|
+
import { fetchTaskResult, handleAuthErrors, request } from '../../api';
|
|
26
|
+
import { RequestExtrasSerializable } from '../../api/http';
|
|
27
|
+
import { useDeferLoadable } from '../../shared/utils';
|
|
28
|
+
import { denormalize, normalizeRequest } from '../../shared/utils/normalization';
|
|
29
|
+
import { isResolvedDerivedDataVariable, isResolvedDerivedVariable, } from '../../types';
|
|
30
|
+
import { VariableCtx, WebSocketCtx, useRequestExtras } from '../context';
|
|
31
|
+
import { useTaskContext } from '../context/global-task-context';
|
|
32
|
+
import { useEventBus } from '../event-bus/event-bus';
|
|
33
|
+
import { resolveDerivedValue } from './derived-variable';
|
|
34
|
+
import { resolveVariable } from './resolve-variable';
|
|
35
|
+
import { atomRegistry, depsRegistry, selectorFamilyMembersRegistry, selectorFamilyRegistry, } from './store';
|
|
36
|
+
function isTaskResponse(response) {
|
|
37
|
+
return response && typeof response === 'object' && 'task_id' in response;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Generate a registry key for a component instance
|
|
41
|
+
*
|
|
42
|
+
* @param uid component instance uid
|
|
43
|
+
* @param trigger whether it's a trigger key
|
|
44
|
+
*/
|
|
45
|
+
function getComponentRegistryKey(uid, trigger) {
|
|
46
|
+
let key = `_COMPONENT_${uid}`;
|
|
47
|
+
if (trigger) {
|
|
48
|
+
key += '_TRIGGER';
|
|
49
|
+
}
|
|
50
|
+
return key;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Fetch a component from the backend, expects a component instance to be returned.
|
|
54
|
+
*
|
|
55
|
+
* @param component the component to fetch
|
|
56
|
+
* @param values the values to pass into the component
|
|
57
|
+
* @param uid the component instance uid
|
|
58
|
+
* @param extras request extras to be merged into the options
|
|
59
|
+
* @param wsClient websocket client
|
|
60
|
+
*/
|
|
61
|
+
function fetchFunctionComponent(component, values, uid, extras, wsClient) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const ws_channel = yield wsClient.getChannel();
|
|
64
|
+
const res = yield request(`/api/core/components/${component}`, {
|
|
65
|
+
body: JSON.stringify({ uid, values, ws_channel }),
|
|
66
|
+
method: HTTP_METHOD.POST,
|
|
67
|
+
}, extras);
|
|
68
|
+
yield handleAuthErrors(res, true);
|
|
69
|
+
yield validateResponse(res, `Failed to fetch the component: ${component}`);
|
|
70
|
+
const result = yield res.json();
|
|
71
|
+
return result;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Claan value to a format understood by the backend.
|
|
76
|
+
* Removes `deps`, appends `force` to resolved derived(data)variables.
|
|
77
|
+
*
|
|
78
|
+
* @param value a value to clean
|
|
79
|
+
* @param force whether to force a derived variable recalculation
|
|
80
|
+
*/
|
|
81
|
+
export function cleanValue(value, force) {
|
|
82
|
+
if (isResolvedDerivedVariable(value) || isResolvedDerivedDataVariable(value)) {
|
|
83
|
+
const { deps } = value, rest = __rest(value, ["deps"]);
|
|
84
|
+
const cleanedValues = value.values.map((v) => cleanValue(v, force));
|
|
85
|
+
return Object.assign(Object.assign({}, rest), { force, values: cleanedValues });
|
|
86
|
+
}
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
function cleanKwargs(kwargs, force) {
|
|
90
|
+
return Object.keys(kwargs).reduce((acc, k) => {
|
|
91
|
+
acc[k] = cleanValue(kwargs[k], force);
|
|
92
|
+
return acc;
|
|
93
|
+
}, {});
|
|
94
|
+
}
|
|
95
|
+
function getOrRegisterComponentTrigger(uid) {
|
|
96
|
+
const triggerKey = getComponentRegistryKey(uid, true);
|
|
97
|
+
if (!atomRegistry.has(triggerKey)) {
|
|
98
|
+
atomRegistry.set(triggerKey, atom({
|
|
99
|
+
default: {
|
|
100
|
+
force: false,
|
|
101
|
+
inc: 0,
|
|
102
|
+
},
|
|
103
|
+
key: triggerKey,
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
return atomRegistry.get(triggerKey);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get a server component from the selector registry, registering it if not already registered
|
|
110
|
+
*
|
|
111
|
+
* @param name component name
|
|
112
|
+
* @param uid component uid
|
|
113
|
+
* @param dynamicKwargs kwargs
|
|
114
|
+
* @param wsClient websocket client
|
|
115
|
+
* @param taskContext task context
|
|
116
|
+
* @param search current search string
|
|
117
|
+
* @param currentExtras request extras to be merged into the options
|
|
118
|
+
*/
|
|
119
|
+
function getOrRegisterServerComponent(name, uid, dynamicKwargs, wsClient, taskContext, currentExtras) {
|
|
120
|
+
const key = getComponentRegistryKey(uid);
|
|
121
|
+
if (!selectorFamilyRegistry.has(key)) {
|
|
122
|
+
selectorFamilyRegistry.set(key, selectorFamily({
|
|
123
|
+
cachePolicy_UNSTABLE: {
|
|
124
|
+
eviction: 'most-recent',
|
|
125
|
+
},
|
|
126
|
+
get: (extrasSerializable) => (_a) => __awaiter(this, [_a], void 0, function* ({ get }) {
|
|
127
|
+
// Kwargs resolved to their simple values
|
|
128
|
+
const resolvedKwargs = Object.keys(dynamicKwargs).reduce((acc, k) => {
|
|
129
|
+
const value = dynamicKwargs[k];
|
|
130
|
+
acc[k] = resolveVariable(value, wsClient, taskContext, currentExtras);
|
|
131
|
+
return acc;
|
|
132
|
+
}, {});
|
|
133
|
+
// Turn kwargs into lists so we can re-use the DerivedVariable logic
|
|
134
|
+
const resolvedKwargsList = Object.values(resolvedKwargs);
|
|
135
|
+
const kwargsList = Object.values(dynamicKwargs);
|
|
136
|
+
const triggerAtom = getOrRegisterComponentTrigger(uid);
|
|
137
|
+
const selfTrigger = get(triggerAtom);
|
|
138
|
+
const { extras } = extrasSerializable;
|
|
139
|
+
const derivedResult = yield resolveDerivedValue(key, kwargsList, kwargsList, // pass deps=kwargs
|
|
140
|
+
resolvedKwargsList, wsClient, get, selfTrigger);
|
|
141
|
+
// returning previous result as no change in dependant values
|
|
142
|
+
if (derivedResult.type === 'previous') {
|
|
143
|
+
return derivedResult.entry.result;
|
|
144
|
+
}
|
|
145
|
+
// Otherwise fetch new component
|
|
146
|
+
// turn the resolved values back into an object and clean them up
|
|
147
|
+
const kwargValues = cleanKwargs(Object.keys(dynamicKwargs).reduce((acc, k, idx) => {
|
|
148
|
+
acc[k] = derivedResult.values[idx];
|
|
149
|
+
return acc;
|
|
150
|
+
}, {}), derivedResult.force);
|
|
151
|
+
let result = null;
|
|
152
|
+
try {
|
|
153
|
+
result = yield fetchFunctionComponent(name, normalizeRequest(kwargValues, dynamicKwargs), uid, extras, wsClient);
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
e.selectorId = key;
|
|
157
|
+
e.selectorExtras = extrasSerializable.toJSON();
|
|
158
|
+
throw e;
|
|
159
|
+
}
|
|
160
|
+
taskContext.cleanupRunningTasks(key);
|
|
161
|
+
// Metatask returned
|
|
162
|
+
if (isTaskResponse(result)) {
|
|
163
|
+
const taskId = result.task_id;
|
|
164
|
+
// Register the task under the component's instance key
|
|
165
|
+
taskContext.startTask(taskId, key, getComponentRegistryKey(uid, true));
|
|
166
|
+
try {
|
|
167
|
+
yield wsClient.waitForTask(taskId);
|
|
168
|
+
}
|
|
169
|
+
catch (_b) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
taskContext.endTask(taskId);
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
result = yield fetchTaskResult(taskId, extras);
|
|
177
|
+
}
|
|
178
|
+
catch (e) {
|
|
179
|
+
e.selectorId = key;
|
|
180
|
+
e.selectorExtras = extrasSerializable.toJSON();
|
|
181
|
+
throw e;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (result !== null) {
|
|
185
|
+
// Denormalize
|
|
186
|
+
result = denormalize(result.data, result.lookup);
|
|
187
|
+
}
|
|
188
|
+
depsRegistry.set(key, {
|
|
189
|
+
args: derivedResult.relevantValues,
|
|
190
|
+
cacheKey: null,
|
|
191
|
+
result,
|
|
192
|
+
});
|
|
193
|
+
return result;
|
|
194
|
+
}),
|
|
195
|
+
key,
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
const family = selectorFamilyRegistry.get(key);
|
|
199
|
+
// Get a selector instance for this particular extras value
|
|
200
|
+
// This is required as otherwise the selector is not aware of different possible extras values
|
|
201
|
+
// at the call site of e.g. useVariable and would otherwise be a stale closure using the initial extras when
|
|
202
|
+
// first registered
|
|
203
|
+
const serializableExtras = new RequestExtrasSerializable(currentExtras);
|
|
204
|
+
const selectorInstance = family(serializableExtras);
|
|
205
|
+
// register selector instance in the selector family registry
|
|
206
|
+
if (!selectorFamilyMembersRegistry.has(family)) {
|
|
207
|
+
selectorFamilyMembersRegistry.set(family, new Map());
|
|
208
|
+
}
|
|
209
|
+
selectorFamilyMembersRegistry.get(family).set(serializableExtras.toJSON(), selectorInstance);
|
|
210
|
+
return selectorInstance;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* A hook to fetch a server component
|
|
214
|
+
*
|
|
215
|
+
* @param name component name - specific to a given py_component
|
|
216
|
+
* @param uid component uid - specific to a given *instance* of a py_component
|
|
217
|
+
* @param dynamicKwargs kwargs passed into the component
|
|
218
|
+
*/
|
|
219
|
+
export default function useServerComponent(name, uid, dynamicKwargs) {
|
|
220
|
+
const extras = useRequestExtras();
|
|
221
|
+
const { client: wsClient } = useContext(WebSocketCtx);
|
|
222
|
+
const taskContext = useTaskContext();
|
|
223
|
+
const variablesContext = useContext(VariableCtx);
|
|
224
|
+
const bus = useEventBus();
|
|
225
|
+
// Synchronously register the py_component uid, and clean it up on unmount
|
|
226
|
+
variablesContext.variables.current.add(getComponentRegistryKey(uid));
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
return () => {
|
|
229
|
+
variablesContext.variables.current.delete(getComponentRegistryKey(uid));
|
|
230
|
+
};
|
|
231
|
+
}, []);
|
|
232
|
+
const componentSelector = getOrRegisterServerComponent(name, uid, dynamicKwargs, wsClient, taskContext, extras);
|
|
233
|
+
const componentLoadable = useRecoilValueLoadable(componentSelector);
|
|
234
|
+
useEffect(() => {
|
|
235
|
+
if (componentLoadable.state === 'hasValue') {
|
|
236
|
+
bus.publish('SERVER_COMPONENT_LOADED', { name, uid, value: componentLoadable.contents });
|
|
237
|
+
}
|
|
238
|
+
}, [componentLoadable]);
|
|
239
|
+
const deferred = useDeferLoadable(componentLoadable);
|
|
240
|
+
return deferred;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* A helper hook that returns a function to force a refresh of a server component
|
|
244
|
+
*
|
|
245
|
+
* @param name component uid
|
|
246
|
+
*/
|
|
247
|
+
export function useRefreshServerComponent(uid) {
|
|
248
|
+
return useRecoilCallback(({ set }) => () => {
|
|
249
|
+
const triggerAtom = getOrRegisterComponentTrigger(uid);
|
|
250
|
+
set(triggerAtom, (triggerIndexValue) => ({
|
|
251
|
+
force: false,
|
|
252
|
+
inc: triggerIndexValue.inc + 1,
|
|
253
|
+
}));
|
|
254
|
+
}, [uid]);
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=use-server-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-server-component.js","sourceRoot":"","sources":["../../../js/shared/interactivity/use-server-component.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,gDAAgD;AAChD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAA4B,IAAI,EAAE,cAAc,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAEnH,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAA4B,eAAe,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7F,OAAO,EAAiB,yBAAyB,EAAE,MAAM,YAAY,CAAC;A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;IAChH,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;IAEpE,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,iBAAiB,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;YACzC,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC7F,CAAC;IACL,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IAErD,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,GAAW;IACjD,OAAO,iBAAiB,CACpB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CACR,GAAG,EAAE;QACD,MAAM,WAAW,GAAG,6BAA6B,CAAC,GAAG,CAAC,CAAC;QAEvD,GAAG,CAAC,WAAW,EAAE,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;YACrC,KAAK,EAAE,KAAK;YACZ,GAAG,EAAE,iBAAiB,CAAC,GAAG,GAAG,CAAC;SACjC,CAAC,CAAC,CAAC;IACR,CAAC,EACL,CAAC,GAAG,CAAC,CACR,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ResolvedDataVariable, ResolvedDerivedDataVariable, ResolvedDerivedVariable } from '../../types';
|
|
2
|
+
type AnyResolvedVariable = ResolvedDataVariable | ResolvedDerivedDataVariable | ResolvedDerivedVariable;
|
|
3
|
+
/**
|
|
4
|
+
* Helper hook to get the current state of the variable.
|
|
5
|
+
* For client-side variables, returns their value. For server-side variables, returns their resolved forms.
|
|
6
|
+
*/
|
|
7
|
+
export default function useVariableState(): any | AnyResolvedVariable;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=use-variable-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-variable-state.d.ts","sourceRoot":"","sources":["../../../js/shared/interactivity/use-variable-state.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAe,oBAAoB,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAKlH,KAAK,mBAAmB,GAAG,oBAAoB,GAAG,2BAA2B,GAAG,uBAAuB,CAAC;AAExG;;;GAGG;AAEH,MAAM,CAAC,OAAO,UAAU,gBAAgB,IAAI,GAAG,GAAG,mBAAmB,CAmBpE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { useRecoilCallback } from 'recoil';
|
|
3
|
+
import { WebSocketCtx, useRequestExtras, useTaskContext } from '../../shared/context';
|
|
4
|
+
import { resolveVariable } from './resolve-variable';
|
|
5
|
+
import { isRegistered } from './store';
|
|
6
|
+
/**
|
|
7
|
+
* Helper hook to get the current state of the variable.
|
|
8
|
+
* For client-side variables, returns their value. For server-side variables, returns their resolved forms.
|
|
9
|
+
*/
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
11
|
+
export default function useVariableState() {
|
|
12
|
+
const extras = useRequestExtras();
|
|
13
|
+
const { client } = useContext(WebSocketCtx);
|
|
14
|
+
const taskCtx = useTaskContext();
|
|
15
|
+
return useRecoilCallback(({ snapshot }) => {
|
|
16
|
+
return (variable) => {
|
|
17
|
+
if (!isRegistered(variable)) {
|
|
18
|
+
return '__NOT_REGISTERED__';
|
|
19
|
+
}
|
|
20
|
+
// get the resolved form of the variable
|
|
21
|
+
const resolvedVariable = resolveVariable(variable, client, taskCtx, extras, (v) => snapshot.getLoadable(v).getValue());
|
|
22
|
+
return resolvedVariable;
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=use-variable-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-variable-state.js","sourceRoot":"","sources":["../../../js/shared/interactivity/use-variable-state.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAIvC;;;GAGG;AACH,6EAA6E;AAC7E,MAAM,CAAC,OAAO,UAAU,gBAAgB;IACpC,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;IAClC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IAEjC,OAAO,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;QACtC,OAAO,CAAC,QAA0B,EAAE,EAAE;YAClC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC1B,OAAO,oBAAoB,CAAC;YAChC,CAAC;YAED,wCAAwC;YACxC,MAAM,gBAAgB,GAAG,eAAe,CAAsB,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE,CACnG,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CACrC,CAAC;YAEF,OAAO,gBAAgB,CAAC;QAC5B,CAAC,CAAC;IACN,CAAC,EAAE,EAAE,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Snapshot } from 'recoil';
|
|
2
|
+
import { WebSocketClientInterface } from '../../api';
|
|
3
|
+
import { RequestExtras } from '../../api/http';
|
|
4
|
+
import { AnyVariable, DataFrame, DataVariable, DerivedDataVariable, DerivedVariable, ResolvedDataVariable, ResolvedDerivedDataVariable, ResolvedDerivedVariable, Variable } from '../../types';
|
|
5
|
+
import { GlobalTaskContext } from '../context/global-task-context';
|
|
6
|
+
type GetVariableValueCtx = {
|
|
7
|
+
client: WebSocketClientInterface;
|
|
8
|
+
extras: RequestExtras;
|
|
9
|
+
search: string;
|
|
10
|
+
snapshot: Snapshot;
|
|
11
|
+
taskContext: GlobalTaskContext;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Helper function that returns the current value of a variable.
|
|
15
|
+
*
|
|
16
|
+
* Plain variables are always resolved to their value.
|
|
17
|
+
* Computed (server-side) variables are resolved to their uid and dependency values, unless shouldFetchVariable is true.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getVariableValue<VV, B extends boolean = false>(variable: AnyVariable<VV>, shouldFetchVariable: B, ctx: GetVariableValueCtx): VV | DataFrame | ResolvedDataVariable | ResolvedDerivedVariable | ResolvedDerivedDataVariable | Promise<VV> | Promise<DataFrame>;
|
|
20
|
+
/**
|
|
21
|
+
* A helper hook that turns a Variable class into the actual value.
|
|
22
|
+
* As opposed to the `useVariable` hook, this one returns a callback to retrieve the latest value
|
|
23
|
+
* without subscribing the component using it to updates.
|
|
24
|
+
* For derived (data) variables, instead of returning its value directly - its resolved to its
|
|
25
|
+
* uid and dependency values.
|
|
26
|
+
*
|
|
27
|
+
* @param variable the variable to use
|
|
28
|
+
* @param shouldFetchVariable if true, if the variable is a derived (data) variable, the request to fetch the variable value will be made
|
|
29
|
+
* @returns Returns the value if the Variable is not derived/data. A Resolved(Data/Derived/DerivedData)Variable if shouldFetchVariable = false, and a Promise for fetching the variable if true.
|
|
30
|
+
*/
|
|
31
|
+
export default function useVariableValue<VV, B extends boolean = false>(variable: VV | Variable<VV> | DataVariable | DerivedVariable | DerivedDataVariable, shouldFetchVariable?: B): () => ReturnType<typeof getVariableValue<VV, B>>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=use-variable-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-variable-value.d.ts","sourceRoot":"","sources":["../../../js/shared/interactivity/use-variable-value.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAqB,MAAM,QAAQ,CAAC;AAKrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,OAAO,EACH,WAAW,EACX,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,uBAAuB,EACvB,QAAQ,EAQX,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAUnE,KAAK,mBAAmB,GAAG;IACvB,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,iBAAiB,CAAC;CAClC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,CAAC,SAAS,OAAO,GAAG,KAAK,EAC1D,QAAQ,EAAE,WAAW,CAAC,EAAE,CAAC,EACzB,mBAAmB,EAAE,CAAc,EACnC,GAAG,EAAE,mBAAmB,GAEtB,EAAE,GACF,SAAS,GACT,oBAAoB,GACpB,uBAAuB,GACvB,2BAA2B,GAC3B,OAAO,CAAC,EAAE,CAAC,GACX,OAAO,CAAC,SAAS,CAAC,CAgEvB;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EAAE,EAAE,CAAC,SAAS,OAAO,GAAG,KAAK,EAClE,QAAQ,EAAE,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC,GAAG,YAAY,GAAG,eAAe,GAAG,mBAAmB,EAClF,mBAAmB,GAAE,CAAc,GACpC,MAAM,UAAU,CAAC,OAAO,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAwBlD"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
import { useRecoilCallback } from 'recoil';
|
|
5
|
+
import { useDeepCompare } from '@darajs/ui-utils';
|
|
6
|
+
import { WebSocketCtx, useRequestExtras, useTaskContext } from '../../shared/context';
|
|
7
|
+
import { normalizeRequest } from '../../shared/utils/normalization';
|
|
8
|
+
import { isDataVariable, isDerivedDataVariable, isDerivedVariable, isResolvedDataVariable, isResolvedDerivedDataVariable, isResolvedDerivedVariable, isVariable, } from '../../types';
|
|
9
|
+
import { fetchDataVariable, fetchDerivedDataVariable, fetchDerivedVariable, formatDerivedVariableRequest, isTaskResponse, resolveVariable, } from './internal';
|
|
10
|
+
/**
|
|
11
|
+
* Helper function that returns the current value of a variable.
|
|
12
|
+
*
|
|
13
|
+
* Plain variables are always resolved to their value.
|
|
14
|
+
* Computed (server-side) variables are resolved to their uid and dependency values, unless shouldFetchVariable is true.
|
|
15
|
+
*/
|
|
16
|
+
export function getVariableValue(variable, shouldFetchVariable = false, ctx) {
|
|
17
|
+
// Using loadable since the resolver is only used for simple atoms and shouldn't cause problems
|
|
18
|
+
const resolved = resolveVariable(variable, ctx.client, ctx.taskContext, ctx.extras, (v) => ctx.snapshot.getLoadable(v).getValue());
|
|
19
|
+
// if we're NOT forced to fetch, or if it's not a DV/DDV/data variable, return the resolved value
|
|
20
|
+
// variable is plain/url
|
|
21
|
+
if (!shouldFetchVariable ||
|
|
22
|
+
(!isDerivedVariable(variable) && !isDataVariable(variable) && !isDerivedDataVariable(variable))) {
|
|
23
|
+
return resolved;
|
|
24
|
+
}
|
|
25
|
+
// we're forced to fetch but the resolved variable is not a resolved DV/data var, return the resolved value
|
|
26
|
+
// variable is plain/url
|
|
27
|
+
if (!isResolvedDerivedVariable(resolved) &&
|
|
28
|
+
!isResolvedDataVariable(resolved) &&
|
|
29
|
+
!isResolvedDerivedDataVariable(resolved)) {
|
|
30
|
+
return resolved;
|
|
31
|
+
}
|
|
32
|
+
// data variable
|
|
33
|
+
if (isResolvedDataVariable(resolved)) {
|
|
34
|
+
return fetchDataVariable(resolved.uid, ctx.extras, resolved.filters);
|
|
35
|
+
}
|
|
36
|
+
// derived variable
|
|
37
|
+
return fetchDerivedVariable({
|
|
38
|
+
cache: variable.cache,
|
|
39
|
+
extras: ctx.extras,
|
|
40
|
+
force: false,
|
|
41
|
+
/**
|
|
42
|
+
* In this case we're not concerned about different selectors fetching the value so just use the uid
|
|
43
|
+
*/
|
|
44
|
+
selectorKey: resolved.uid,
|
|
45
|
+
values: normalizeRequest(formatDerivedVariableRequest(resolved.values), variable.variables),
|
|
46
|
+
variableUid: resolved.uid,
|
|
47
|
+
wsClient: ctx.client,
|
|
48
|
+
}).then((resp) => {
|
|
49
|
+
// This is really only used in DownloadVariable currently; we can add support for tasks
|
|
50
|
+
// if it is requested in the future
|
|
51
|
+
if (isTaskResponse(resp)) {
|
|
52
|
+
throw new Error('Task DerivedVariables are not supported in this context');
|
|
53
|
+
}
|
|
54
|
+
// for derived data variables we need to make another request to retrieve the filtered value
|
|
55
|
+
if (isDerivedDataVariable(variable)) {
|
|
56
|
+
return ctx.client
|
|
57
|
+
.getChannel()
|
|
58
|
+
.then((chan) => fetchDerivedDataVariable(variable.uid, ctx.extras, resp.cache_key, chan, variable.filters));
|
|
59
|
+
}
|
|
60
|
+
return resp.value;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A helper hook that turns a Variable class into the actual value.
|
|
65
|
+
* As opposed to the `useVariable` hook, this one returns a callback to retrieve the latest value
|
|
66
|
+
* without subscribing the component using it to updates.
|
|
67
|
+
* For derived (data) variables, instead of returning its value directly - its resolved to its
|
|
68
|
+
* uid and dependency values.
|
|
69
|
+
*
|
|
70
|
+
* @param variable the variable to use
|
|
71
|
+
* @param shouldFetchVariable if true, if the variable is a derived (data) variable, the request to fetch the variable value will be made
|
|
72
|
+
* @returns Returns the value if the Variable is not derived/data. A Resolved(Data/Derived/DerivedData)Variable if shouldFetchVariable = false, and a Promise for fetching the variable if true.
|
|
73
|
+
*/
|
|
74
|
+
export default function useVariableValue(variable, shouldFetchVariable = false) {
|
|
75
|
+
const taskContext = useTaskContext();
|
|
76
|
+
const { client } = useContext(WebSocketCtx);
|
|
77
|
+
const { search } = useLocation();
|
|
78
|
+
const extras = useRequestExtras();
|
|
79
|
+
if (!isVariable(variable)) {
|
|
80
|
+
return () => variable;
|
|
81
|
+
}
|
|
82
|
+
return useRecoilCallback(({ snapshot }) => {
|
|
83
|
+
return () => {
|
|
84
|
+
return getVariableValue(variable, shouldFetchVariable, {
|
|
85
|
+
client,
|
|
86
|
+
extras,
|
|
87
|
+
search,
|
|
88
|
+
snapshot,
|
|
89
|
+
taskContext,
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
}, [variable.uid, useDeepCompare(taskContext), client, search, extras]);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=use-variable-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-variable-value.js","sourceRoot":"","sources":["../../../js/shared/interactivity/use-variable-value.tsx"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAY,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKlD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,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C,IAAI,CAAC,UAAU,CAAK,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC;IAC1B,CAAC;IAED,OAAO,iBAAiB,CACpB,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;QACb,OAAO,GAAG,EAAE;YACR,OAAO,gBAAgB,CAAQ,QAAQ,EAAE,mBAAmB,EAAE;gBAC1D,MAAM;gBACN,MAAM;gBACN,MAAM;gBACN,QAAQ;gBACR,WAAW;aACd,CAAC,CAAC;QACP,CAAC,CAAC;IACN,CAAC,EACD,CAAC,QAAQ,CAAC,GAAG,EAAE,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CACtE,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { Variable } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* A helper hook that turns a Variable class into the actual value by accessing the appropriate recoil state from the
|
|
5
|
+
* atomRegistry defined above. For convenience, it will also handle a non variable being passed and will return it
|
|
6
|
+
* directly and a noop function for setting it. In most cases components accept a variable or something else, so this
|
|
7
|
+
* helps to clean up all those areas in a consistent manner.
|
|
8
|
+
*
|
|
9
|
+
* @param variable the possible variable to use
|
|
10
|
+
*/
|
|
11
|
+
export declare function useVariable<T>(variable: Variable<T> | T): [value: T, update: Dispatch<SetStateAction<T>>];
|
|
12
|
+
//# sourceMappingURL=use-variable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-variable.d.ts","sourceRoot":"","sources":["../../../js/shared/interactivity/use-variable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAmC,MAAM,OAAO,CAAC;AAKlF,OAAO,EAAE,QAAQ,EAAuF,MAAM,SAAS,CAAC;AAmBxH;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAqEzG"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { useContext, useEffect, useState } from 'react';
|
|
2
|
+
import { useRecoilState, useRecoilStateLoadable, useRecoilValueLoadable_TRANSITION_SUPPORT_UNSTABLE } from 'recoil';
|
|
3
|
+
import { VariableCtx, WebSocketCtx, useRequestExtras, useTaskContext } from '../../shared/context';
|
|
4
|
+
import { useDeferLoadable } from '../../shared/utils';
|
|
5
|
+
import { isDataVariable, isDerivedDataVariable, isDerivedVariable, isUrlVariable, isVariable } from '../../types';
|
|
6
|
+
import { useEventBus } from '../event-bus/event-bus';
|
|
7
|
+
import { getOrRegisterPlainVariable, useDerivedVariable, useUrlVariable } from './internal';
|
|
8
|
+
/** Disabling rules of hook because of assumptions that variables never change their types which makes the hook order consistent */
|
|
9
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
10
|
+
/** Disabling no-use-before-define because of functions depending on each other */
|
|
11
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
12
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
13
|
+
/**
|
|
14
|
+
* Helper function to warn when trying to update DerivedVariable directly
|
|
15
|
+
*/
|
|
16
|
+
function warnUpdateOnDerivedState() {
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
console.warn('You tried to call update on variable with derived state, this is a noop and will be ignored.');
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A helper hook that turns a Variable class into the actual value by accessing the appropriate recoil state from the
|
|
22
|
+
* atomRegistry defined above. For convenience, it will also handle a non variable being passed and will return it
|
|
23
|
+
* directly and a noop function for setting it. In most cases components accept a variable or something else, so this
|
|
24
|
+
* helps to clean up all those areas in a consistent manner.
|
|
25
|
+
*
|
|
26
|
+
* @param variable the possible variable to use
|
|
27
|
+
*/
|
|
28
|
+
export function useVariable(variable) {
|
|
29
|
+
const extras = useRequestExtras();
|
|
30
|
+
const { client: WsClient } = useContext(WebSocketCtx);
|
|
31
|
+
const taskContext = useTaskContext();
|
|
32
|
+
const variablesContext = useContext(VariableCtx);
|
|
33
|
+
const bus = useEventBus();
|
|
34
|
+
if (!isVariable(variable)) {
|
|
35
|
+
return useState(variable);
|
|
36
|
+
}
|
|
37
|
+
// Synchronously register variable subscription, and clean it up on unmount
|
|
38
|
+
variablesContext.variables.current.add(variable.uid);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
return () => {
|
|
41
|
+
variablesContext.variables.current.delete(variable.uid);
|
|
42
|
+
};
|
|
43
|
+
}, []);
|
|
44
|
+
// This hook should only be used for components not expecting DataFrames
|
|
45
|
+
if (isDataVariable(variable) || isDerivedDataVariable(variable)) {
|
|
46
|
+
throw new Error(`Non-data variable expected, got ${variable.__typename}`);
|
|
47
|
+
}
|
|
48
|
+
if (isDerivedVariable(variable)) {
|
|
49
|
+
const selector = useDerivedVariable(variable, WsClient, taskContext, extras);
|
|
50
|
+
const selectorLoadable = useRecoilValueLoadable_TRANSITION_SUPPORT_UNSTABLE(selector);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (selectorLoadable.state !== 'loading') {
|
|
53
|
+
bus.publish('DERIVED_VARIABLE_LOADED', { variable, value: selectorLoadable.contents });
|
|
54
|
+
}
|
|
55
|
+
}, [selectorLoadable]);
|
|
56
|
+
const deferred = useDeferLoadable(selectorLoadable);
|
|
57
|
+
return [deferred.value, warnUpdateOnDerivedState];
|
|
58
|
+
}
|
|
59
|
+
if (isUrlVariable(variable)) {
|
|
60
|
+
const [urlValue, setUrlValue] = useUrlVariable(variable);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
bus.publish('URL_VARIABLE_LOADED', { variable, value: urlValue });
|
|
63
|
+
}, [urlValue]);
|
|
64
|
+
return [urlValue, setUrlValue];
|
|
65
|
+
}
|
|
66
|
+
const recoilState = getOrRegisterPlainVariable(variable, WsClient, taskContext, extras);
|
|
67
|
+
if (!isDerivedVariable(variable.default)) {
|
|
68
|
+
const [value, setValue] = useRecoilState(recoilState);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
bus.publish('PLAIN_VARIABLE_LOADED', { variable, value });
|
|
71
|
+
}, [value]);
|
|
72
|
+
return [value, setValue];
|
|
73
|
+
}
|
|
74
|
+
const [loadable, setLoadable] = useRecoilStateLoadable(recoilState);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
// when loadable resolves to a value/error
|
|
77
|
+
if (loadable.state !== 'loading') {
|
|
78
|
+
bus.publish('PLAIN_VARIABLE_LOADED', { variable, value: loadable.contents });
|
|
79
|
+
}
|
|
80
|
+
}, [loadable]);
|
|
81
|
+
const deferred = useDeferLoadable(loadable);
|
|
82
|
+
return [deferred, setLoadable];
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=use-variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-variable.js","sourceRoot":"","sources":["../../../js/shared/interactivity/use-variable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,kDAAkD,EAAE,MAAM,QAAQ,CAAC;AAEpH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAY,cAAc,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAExH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,cAAc,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AC,CAAC;QAC9D,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QACZ,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC;IACpE,SAAS,CAAC,GAAG,EAAE;QACX,0CAA0C;QAC1C,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjF,CAAC;IACL,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,MAAM,QAAQ,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAE5C,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Action } from '../../types';
|
|
3
|
+
interface PrivateRouteProps {
|
|
4
|
+
/** The children to wrap */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** Name of the page this route links to */
|
|
7
|
+
name?: string;
|
|
8
|
+
/** Variables which should be reset upon visiting the page */
|
|
9
|
+
on_load?: Action;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The PrivateRoute component takes a private route object and checks for authentication.
|
|
13
|
+
* It redirects to the login page if the user is not authenticated.
|
|
14
|
+
*
|
|
15
|
+
* @param props - the component props
|
|
16
|
+
*/
|
|
17
|
+
declare function PrivateRoute({ children, on_load, name }: PrivateRouteProps): ReactNode;
|
|
18
|
+
export default PrivateRoute;
|
|
19
|
+
//# sourceMappingURL=private-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-route.d.ts","sourceRoot":"","sources":["../../../js/shared/private-route/private-route.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAO7C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,UAAU,iBAAiB;IACvB,2BAA2B;IAC3B,QAAQ,EAAE,SAAS,CAAC;IACpB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,iBAAS,YAAY,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,iBAAiB,GAAG,SAAS,CA0B/E;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { Redirect } from 'react-router-dom';
|
|
5
|
+
import { useSessionToken } from '../../auth/use-session-token';
|
|
6
|
+
import DefaultFallback from '../../components/fallback/default';
|
|
7
|
+
import useAction, { useActionIsLoading } from '../../shared/utils/use-action';
|
|
8
|
+
import useWindowTitle from '../../shared/utils/use-window-title';
|
|
9
|
+
/**
|
|
10
|
+
* The PrivateRoute component takes a private route object and checks for authentication.
|
|
11
|
+
* It redirects to the login page if the user is not authenticated.
|
|
12
|
+
*
|
|
13
|
+
* @param props - the component props
|
|
14
|
+
*/
|
|
15
|
+
function PrivateRoute({ children, on_load, name }) {
|
|
16
|
+
const token = useSessionToken();
|
|
17
|
+
const onLoad = useAction(on_load);
|
|
18
|
+
const isLoading = useActionIsLoading(on_load);
|
|
19
|
+
useWindowTitle(name);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
// On mount, call the on_load action
|
|
22
|
+
onLoad();
|
|
23
|
+
}, []);
|
|
24
|
+
if (!token) {
|
|
25
|
+
const referrer = encodeURIComponent(window.location.pathname + window.location.search);
|
|
26
|
+
return (_jsx(Redirect, { to: {
|
|
27
|
+
pathname: '/login',
|
|
28
|
+
search: `?referrer=${referrer}`,
|
|
29
|
+
} }));
|
|
30
|
+
}
|
|
31
|
+
// Show fallback while the onLoad action is in progress
|
|
32
|
+
return isLoading ? _jsx(DefaultFallback, {}) : children;
|
|
33
|
+
}
|
|
34
|
+
export default PrivateRoute;
|
|
35
|
+
//# sourceMappingURL=private-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"private-route.js","sourceRoot":"","sources":["../../../js/shared/private-route/private-route.tsx"],"names":[],"mappings":";AAAA,gDAAgD;AAChD,OAAO,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAC5D,OAAO,SAAS,EAAE,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,cAAc,MAAM,iCAAiC,CAAC;AAY7D;;;;;GAKG;AACH,SAAS,YAAY,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAqB;IAChE,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,SAAS,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAE9C,cAAc,CAAC,IAAI,CAAC,CAAC;IAErB,SAAS,CAAC,GAAG,EAAE;QACX,oCAAoC;QACpC,MAAM,EAAE,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAI,CAAC,KAAK,EAAE,CAAC;QACT,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC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