@darajs/core 1.0.0-a.1
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 +7 -0
- package/dist/actions/download-content.d.ts +8 -0
- package/dist/actions/download-content.d.ts.map +1 -0
- package/dist/actions/download-content.js +46 -0
- package/dist/actions/download-content.js.map +1 -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 +153 -0
- package/dist/actions/download-variable.js.map +1 -0
- package/dist/actions/index.d.ts +11 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +11 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/logout.d.ts +8 -0
- package/dist/actions/logout.d.ts.map +1 -0
- package/dist/actions/logout.js +24 -0
- package/dist/actions/logout.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 +77 -0
- package/dist/actions/navigate-to.js.map +1 -0
- package/dist/actions/notify.d.ts +8 -0
- package/dist/actions/notify.d.ts.map +1 -0
- package/dist/actions/notify.js +16 -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 +24 -0
- package/dist/actions/reset-variables.js.map +1 -0
- package/dist/actions/side-effect.d.ts +8 -0
- package/dist/actions/side-effect.d.ts.map +1 -0
- package/dist/actions/side-effect.js +44 -0
- package/dist/actions/side-effect.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 +25 -0
- package/dist/actions/trigger-variable.js.map +1 -0
- package/dist/actions/update-variable.d.ts +9 -0
- package/dist/actions/update-variable.d.ts.map +1 -0
- package/dist/actions/update-variable.js +89 -0
- package/dist/actions/update-variable.js.map +1 -0
- package/dist/actions/utils.d.ts +9 -0
- package/dist/actions/utils.d.ts.map +1 -0
- package/dist/actions/utils.js +37 -0
- package/dist/actions/utils.js.map +1 -0
- package/dist/api/core.d.ts +34 -0
- package/dist/api/core.d.ts.map +1 -0
- package/dist/api/core.js +110 -0
- package/dist/api/core.js.map +1 -0
- package/dist/api/http.d.ts +9 -0
- package/dist/api/http.d.ts.map +1 -0
- package/dist/api/http.js +38 -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 +140 -0
- package/dist/api/websocket.d.ts.map +1 -0
- package/dist/api/websocket.js +241 -0
- package/dist/api/websocket.js.map +1 -0
- package/dist/assets/fonts/Manrope-VariableFont_wght.ttf +0 -0
- package/dist/assets/login-background.svg +11 -0
- package/dist/assets/logo.svg +12 -0
- package/dist/auth/auth-context.d.ts +22 -0
- package/dist/auth/auth-context.d.ts.map +1 -0
- package/dist/auth/auth-context.js +18 -0
- package/dist/auth/auth-context.js.map +1 -0
- package/dist/auth/auth-wrapper.d.ts +14 -0
- package/dist/auth/auth-wrapper.d.ts.map +1 -0
- package/dist/auth/auth-wrapper.js +90 -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 +161 -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 +174 -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 +66 -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/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 +8 -0
- package/dist/components/fallback/dots.d.ts.map +1 -0
- package/dist/components/fallback/dots.js +77 -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 +43 -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 +202 -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 +63 -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 +70 -0
- package/dist/components/top-bar-frame/top-bar-frame.js.map +1 -0
- package/dist/dara_core-1.0.0a1-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 +99 -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 +24 -0
- package/dist/devtools/floating-button.d.ts.map +1 -0
- package/dist/devtools/floating-button.js +96 -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 +48 -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 +55 -0
- package/dist/devtools/use-move.js.map +1 -0
- package/dist/index.css +95 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -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 +7 -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 +7 -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 +14 -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 +78 -0
- package/dist/shared/context/global-task-context.js.map +1 -0
- package/dist/shared/context/importers-context.d.ts +7 -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 +21 -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/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 +8 -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/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 +243 -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 +92 -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 +10 -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/index.d.ts +11 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +9 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/interactivity/data-variable.d.ts +66 -0
- package/dist/shared/interactivity/data-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/data-variable.js +186 -0
- package/dist/shared/interactivity/data-variable.js.map +1 -0
- package/dist/shared/interactivity/derived-variable.d.ts +153 -0
- package/dist/shared/interactivity/derived-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/derived-variable.js +403 -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 +12 -0
- package/dist/shared/interactivity/index.d.ts.map +1 -0
- package/dist/shared/interactivity/index.js +11 -0
- package/dist/shared/interactivity/index.js.map +1 -0
- package/dist/shared/interactivity/internal.d.ts +8 -0
- package/dist/shared/interactivity/internal.d.ts.map +1 -0
- package/dist/shared/interactivity/internal.js +10 -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 +50 -0
- package/dist/shared/interactivity/nested.js.map +1 -0
- package/dist/shared/interactivity/plain-variable.d.ts +23 -0
- package/dist/shared/interactivity/plain-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/plain-variable.js +89 -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 +47 -0
- package/dist/shared/interactivity/resolve-variable.js.map +1 -0
- package/dist/shared/interactivity/store.d.ts +35 -0
- package/dist/shared/interactivity/store.d.ts.map +1 -0
- package/dist/shared/interactivity/store.js +47 -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 +28 -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 +38 -0
- package/dist/shared/interactivity/use-any-variable.js.map +1 -0
- package/dist/shared/interactivity/use-data-variable.d.ts +12 -0
- package/dist/shared/interactivity/use-data-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/use-data-variable.js +56 -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 +16 -0
- package/dist/shared/interactivity/use-refresh-selector.js.map +1 -0
- package/dist/shared/interactivity/use-reset-variables.d.ts +8 -0
- package/dist/shared/interactivity/use-reset-variables.d.ts.map +1 -0
- package/dist/shared/interactivity/use-reset-variables.js +46 -0
- package/dist/shared/interactivity/use-reset-variables.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 +227 -0
- package/dist/shared/interactivity/use-server-component.js.map +1 -0
- package/dist/shared/interactivity/use-trigger-variable.d.ts +9 -0
- package/dist/shared/interactivity/use-trigger-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/use-trigger-variable.js +18 -0
- package/dist/shared/interactivity/use-trigger-variable.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 +35 -0
- package/dist/shared/interactivity/use-variable-state.js.map +1 -0
- package/dist/shared/interactivity/use-variable-value.d.ts +20 -0
- package/dist/shared/interactivity/use-variable-value.d.ts.map +1 -0
- package/dist/shared/interactivity/use-variable-value.js +77 -0
- package/dist/shared/interactivity/use-variable-value.js.map +1 -0
- package/dist/shared/interactivity/use-variable.d.ts +11 -0
- package/dist/shared/interactivity/use-variable.d.ts.map +1 -0
- package/dist/shared/interactivity/use-variable.js +62 -0
- package/dist/shared/interactivity/use-variable.js.map +1 -0
- package/dist/shared/private-route/private-route.d.ts +23 -0
- package/dist/shared/private-route/private-route.d.ts.map +1 -0
- package/dist/shared/private-route/private-route.js +39 -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 +28 -0
- package/dist/shared/template-root/dynamic-context.js.map +1 -0
- package/dist/shared/template-root/template-root.d.ts +8 -0
- package/dist/shared/template-root/template-root.d.ts.map +1 -0
- package/dist/shared/template-root/template-root.js +76 -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 +17 -0
- package/dist/shared/utils/clean-session-cache.js.map +1 -0
- package/dist/shared/utils/embed.d.ts +13 -0
- package/dist/shared/utils/embed.d.ts.map +1 -0
- package/dist/shared/utils/embed.js +23 -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 +18 -0
- package/dist/shared/utils/index.d.ts.map +1 -0
- package/dist/shared/utils/index.js +16 -0
- package/dist/shared/utils/index.js.map +1 -0
- package/dist/shared/utils/inject-css.d.ts +13 -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 +118 -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 +9 -0
- package/dist/shared/utils/use-action.d.ts.map +1 -0
- package/dist/shared/utils/use-action.js +84 -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 +46 -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 +68 -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 +18 -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 +21 -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 +325 -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 +50 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/utils.js +84 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/umd/dara.core.umd.js +93592 -0
- package/dist/umd/style.css +848 -0
- package/package.json +117 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
|
+
import { useContext, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
import { useRecoilValueLoadable } from 'recoil';
|
|
5
|
+
// eslint-disable-next-line import/no-cycle
|
|
6
|
+
import { useSessionToken } from '../../auth/auth-context';
|
|
7
|
+
import { VariableCtx, WebSocketCtx, useTaskContext } from '../../shared/context';
|
|
8
|
+
import { isDataVariable } from '../../types';
|
|
9
|
+
import { registerDataVariable, useDerivedVariable, useFetchDataVariable, useFetchDerivedDataVariable, } from './internal';
|
|
10
|
+
/**
|
|
11
|
+
* Helper hook which turns a (Derived)DataVariable into a callback to return DataFrame.
|
|
12
|
+
* Can be used in components that only work with data variables.
|
|
13
|
+
*
|
|
14
|
+
* The callback identity changes whenever a refetch should be triggered.
|
|
15
|
+
*
|
|
16
|
+
* @param variable data variable
|
|
17
|
+
*/
|
|
18
|
+
export function useDataVariable(variable) {
|
|
19
|
+
const token = useSessionToken();
|
|
20
|
+
const { client: WsClient } = useContext(WebSocketCtx);
|
|
21
|
+
if (isDataVariable(variable)) {
|
|
22
|
+
registerDataVariable(variable);
|
|
23
|
+
const serverTriggers$ = useMemo(() => WsClient.serverTriggers$(variable.uid), []);
|
|
24
|
+
const [serverTriggerCounter, setServerTriggerCounter] = useState(0);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const sub = serverTriggers$.subscribe(() => setServerTriggerCounter((c) => c + 1));
|
|
27
|
+
return () => sub.unsubscribe();
|
|
28
|
+
}, [serverTriggers$]);
|
|
29
|
+
const fetchDataVariable = useFetchDataVariable(variable, serverTriggerCounter);
|
|
30
|
+
return fetchDataVariable;
|
|
31
|
+
}
|
|
32
|
+
// Synchronously register subscription to the underlying DV, clean up on unmount
|
|
33
|
+
const variablesContext = useContext(VariableCtx);
|
|
34
|
+
variablesContext.variables.current.add(variable.uid);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
return () => {
|
|
37
|
+
variablesContext.variables.current.delete(variable.uid);
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
const taskContext = useTaskContext();
|
|
41
|
+
const { search } = useLocation();
|
|
42
|
+
const dvSelector = useDerivedVariable(variable, WsClient, taskContext, search, token);
|
|
43
|
+
const dvLoadable = useRecoilValueLoadable(dvSelector);
|
|
44
|
+
// We can't directly use the loadable as the callback's dependency because the loadable identity
|
|
45
|
+
// changes whenever it also changes state; we only want to update it when there is a new value
|
|
46
|
+
const [dvValue, setDvValue] = useState(dvLoadable.toPromise());
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
// Whenever loadable becomes loading update the promise stored
|
|
49
|
+
if (dvLoadable.state === 'loading') {
|
|
50
|
+
setDvValue(dvLoadable.toPromise());
|
|
51
|
+
}
|
|
52
|
+
}, [dvLoadable]);
|
|
53
|
+
const fetchDerivedDataVariable = useFetchDerivedDataVariable(variable, taskContext, WsClient, dvValue);
|
|
54
|
+
return fetchDerivedDataVariable;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=use-data-variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-data-variable.js","sourceRoot":"","sources":["../../../js/shared/interactivity/use-data-variable.tsx"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAEhD,2CAA2C;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAA4C,cAAc,EAAE,MAAM,SAAS,CAAC;AAEnF,OAAO,EAGH,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,2BAA2B,GAC9B,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC3B,QAAyB;IAEzB,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAEtD,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE;QAC1B,oBAAoB,CAAC,QAA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CAAC;IAEtD,gGAAgG;IAChG,8FAA8F;IAC9F,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAA6C,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;IAC3G,SAAS,CAAC,GAAG,EAAE;QACX,8DAA8D;QAC9D,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE;YAChC,UAAU,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;SACtC;IACL,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,MAAM,wBAAwB,GAAG,2BAA2B,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAEvG,OAAO,wBAAwB,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-refresh-selector.d.ts","sourceRoot":"","sources":["../../../js/shared/interactivity/use-refresh-selector.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,IAAI,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAUlE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useRecoilCallback } from 'recoil';
|
|
2
|
+
import { selectorRegistry } from './store';
|
|
3
|
+
/**
|
|
4
|
+
* Helper hook to refresh a selector by its key
|
|
5
|
+
*/
|
|
6
|
+
export default function useRefreshSelector() {
|
|
7
|
+
return useRecoilCallback(({ refresh }) => {
|
|
8
|
+
return (key) => {
|
|
9
|
+
const selector = selectorRegistry.get(key);
|
|
10
|
+
if (selector) {
|
|
11
|
+
refresh(selector);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=use-refresh-selector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-refresh-selector.js","sourceRoot":"","sources":["../../../js/shared/interactivity/use-refresh-selector.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB;IACtC,OAAO,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;QACrC,OAAO,CAAC,GAAW,EAAE,EAAE;YACnB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAE3C,IAAI,QAAQ,EAAE;gBACV,OAAO,CAAC,QAAQ,CAAC,CAAC;aACrB;QACL,CAAC,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Variable } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* A helper hook that returns a function to reset a list of variables to their default values
|
|
4
|
+
*
|
|
5
|
+
* @param variables list of variables to reset
|
|
6
|
+
*/
|
|
7
|
+
export default function useResetVariables(variables: Variable<any>[]): () => void;
|
|
8
|
+
//# sourceMappingURL=use-reset-variables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-reset-variables.d.ts","sourceRoot":"","sources":["../../../js/shared/interactivity/use-reset-variables.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAuF,MAAM,SAAS,CAAC;AAIxH;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,IAAI,CAkChF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { useHistory, useLocation } from 'react-router-dom';
|
|
3
|
+
import { useRecoilCallback } from 'recoil';
|
|
4
|
+
// eslint-disable-next-line import/no-cycle
|
|
5
|
+
import { useSessionToken } from '../../auth/auth-context';
|
|
6
|
+
import { WebSocketCtx, useTaskContext } from '../../shared/context';
|
|
7
|
+
import { isDataVariable, isDerivedDataVariable, isDerivedVariable, isUrlVariable, isVariable } from '../../types';
|
|
8
|
+
import { getOrRegisterPlainVariable, getOrRegisterTrigger, getOrRegisterUrlVariable } from './internal';
|
|
9
|
+
/**
|
|
10
|
+
* A helper hook that returns a function to reset a list of variables to their default values
|
|
11
|
+
*
|
|
12
|
+
* @param variables list of variables to reset
|
|
13
|
+
*/
|
|
14
|
+
export default function useResetVariables(variables) {
|
|
15
|
+
const taskContext = useTaskContext();
|
|
16
|
+
const { client } = useContext(WebSocketCtx);
|
|
17
|
+
const { search } = useLocation();
|
|
18
|
+
const token = useSessionToken();
|
|
19
|
+
const history = useHistory();
|
|
20
|
+
return useRecoilCallback(({ reset, set }) => () => {
|
|
21
|
+
variables.filter(isVariable).forEach((variable) => {
|
|
22
|
+
// For DVs, trigger their recalculation
|
|
23
|
+
if (isDerivedVariable(variable) || isDerivedDataVariable(variable)) {
|
|
24
|
+
const triggerAtom = getOrRegisterTrigger(variable);
|
|
25
|
+
set(triggerAtom, (triggerIndexValue) => ({
|
|
26
|
+
force: true,
|
|
27
|
+
inc: triggerIndexValue.inc + 1,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
else if (isUrlVariable(variable)) {
|
|
31
|
+
// For UrlVariables, we use set instead of reset to update the URL as well; otherwise just the atom is reset
|
|
32
|
+
const urlAtom = getOrRegisterUrlVariable(variable);
|
|
33
|
+
set(urlAtom, variable.default);
|
|
34
|
+
}
|
|
35
|
+
else if (isDataVariable(variable)) {
|
|
36
|
+
// for data variables this is a noop
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// For plain variables reset them to default values
|
|
40
|
+
const plainAtom = getOrRegisterPlainVariable(variable, client, taskContext, search, token);
|
|
41
|
+
reset(plainAtom);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}, [variables, history]);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=use-reset-variables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-reset-variables.js","sourceRoot":"","sources":["../../../js/shared/interactivity/use-reset-variables.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE3C,2CAA2C;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAY,cAAc,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAExH,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAExG;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,SAA0B;IAChE,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAC5C,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;IAE7B,OAAO,iBAAiB,CACpB,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CACf,GAAG,EAAE;QACD,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC9C,uCAAuC;YACvC,IAAI,iBAAiB,CAAC,QAAQ,CAAC,IAAI,qBAAqB,CAAC,QAAQ,CAAC,EAAE;gBAChE,MAAM,WAAW,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;gBAEnD,GAAG,CAAC,WAAW,EAAE,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;oBACrC,KAAK,EAAE,IAAI;oBACX,GAAG,EAAE,iBAAiB,CAAC,GAAG,GAAG,CAAC;iBACjC,CAAC,CAAC,CAAC;aACP;iBAAM,IAAI,aAAa,CAAC,QAAQ,CAAC,EAAE;gBAChC,4GAA4G;gBAC5G,MAAM,OAAO,GAAG,wBAAwB,CAAC,QAAQ,CAAC,CAAC;gBACnD,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;aAClC;iBAAM,IAAI,cAAc,CAAC,QAAQ,CAAC,EAAE;gBACjC,oCAAoC;aACvC;iBAAM;gBACH,mDAAmD;gBACnD,MAAM,SAAS,GAAG,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;gBAC3F,KAAK,CAAC,SAAS,CAAC,CAAC;aACpB;QACL,CAAC,CAAC,CAAC;IACP,CAAC,EACL,CAAC,SAAS,EAAE,OAAO,CAAC,CACvB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AnyVariable, ComponentInstance } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Claan value to a format understood by the backend.
|
|
4
|
+
* Removes `deps`, appends `force` to resolved derived(data)variables.
|
|
5
|
+
*
|
|
6
|
+
* @param value a value to clean
|
|
7
|
+
* @param force whether to force a derived variable recalculation
|
|
8
|
+
*/
|
|
9
|
+
export declare function cleanValue(value: unknown, force: boolean): any;
|
|
10
|
+
/**
|
|
11
|
+
* A hook to fetch a server component
|
|
12
|
+
*
|
|
13
|
+
* @param name component name - specific to a given py_component
|
|
14
|
+
* @param uid component uid - specific to a given *instance* of a py_component
|
|
15
|
+
* @param dynamicKwargs kwargs passed into the component
|
|
16
|
+
*/
|
|
17
|
+
export default function useServerComponent(name: string, uid: string, dynamicKwargs: Record<string, AnyVariable<any>>): ComponentInstance;
|
|
18
|
+
/**
|
|
19
|
+
* A helper hook that returns a function to force a refresh of a server component
|
|
20
|
+
*
|
|
21
|
+
* @param name component uid
|
|
22
|
+
*/
|
|
23
|
+
export declare function useRefreshServerComponent(uid: string): () => void;
|
|
24
|
+
//# sourceMappingURL=use-server-component.d.ts.map
|
|
@@ -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,EAIpB,MAAM,SAAS,CAAC;AAyDjB;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,GAAG,CAa9D;AA0JD;;;;;;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,227 @@
|
|
|
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
|
+
import { useContext, useEffect } from 'react';
|
|
22
|
+
import { useLocation } from 'react-router';
|
|
23
|
+
import { atom, selector, useRecoilCallback, useRecoilValueLoadable } from 'recoil';
|
|
24
|
+
import { HTTP_METHOD, validateResponse } from '@darajs/ui-utils';
|
|
25
|
+
import { fetchTaskResult, request } from '../../api';
|
|
26
|
+
import { useSessionToken } from '../../auth';
|
|
27
|
+
import { useDeferLoadable } from '../../shared/utils';
|
|
28
|
+
import { normalizeRequest } from '../../shared/utils/normalization';
|
|
29
|
+
import { isResolvedDerivedDataVariable, isResolvedDerivedVariable, } from '../../types';
|
|
30
|
+
import { VariableCtx, WebSocketCtx } from '../context';
|
|
31
|
+
import { useTaskContext } from '../context/global-task-context';
|
|
32
|
+
import { resolveDerivedValue } from './derived-variable';
|
|
33
|
+
import { resolveVariable } from './resolve-variable';
|
|
34
|
+
import { atomRegistry, depsRegistry, selectorRegistry } from './store';
|
|
35
|
+
function isTaskResponse(response) {
|
|
36
|
+
return response && typeof response === 'object' && 'task_id' in response;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generate a registry key for a component instance
|
|
40
|
+
*
|
|
41
|
+
* @param uid component instance uid
|
|
42
|
+
* @param trigger whether it's a trigger key
|
|
43
|
+
*/
|
|
44
|
+
function getComponentRegistryKey(uid, trigger) {
|
|
45
|
+
let key = `_COMPONENT_${uid}`;
|
|
46
|
+
if (trigger) {
|
|
47
|
+
key += '_TRIGGER';
|
|
48
|
+
}
|
|
49
|
+
return key;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Fetch a component from the backend, expects a component instance to be returned.
|
|
53
|
+
*
|
|
54
|
+
* @param component the component to fetch
|
|
55
|
+
* @param taskRef ref holding the current running task id
|
|
56
|
+
*/
|
|
57
|
+
function fetchFunctionComponent(component, values, uid, token, wsClient) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const ws_channel = yield wsClient.getChannel();
|
|
60
|
+
const res = yield request(`/api/core/components/${component}`, {
|
|
61
|
+
body: JSON.stringify({ uid, values, ws_channel }),
|
|
62
|
+
method: HTTP_METHOD.POST,
|
|
63
|
+
}, token);
|
|
64
|
+
yield validateResponse(res, `Failed to fetch the component: ${component}`);
|
|
65
|
+
const result = yield res.json();
|
|
66
|
+
return result;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Claan value to a format understood by the backend.
|
|
71
|
+
* Removes `deps`, appends `force` to resolved derived(data)variables.
|
|
72
|
+
*
|
|
73
|
+
* @param value a value to clean
|
|
74
|
+
* @param force whether to force a derived variable recalculation
|
|
75
|
+
*/
|
|
76
|
+
export function cleanValue(value, force) {
|
|
77
|
+
if (isResolvedDerivedVariable(value) || isResolvedDerivedDataVariable(value)) {
|
|
78
|
+
const { deps } = value, rest = __rest(value, ["deps"]);
|
|
79
|
+
const cleanedValues = value.values.map((v) => cleanValue(v, force));
|
|
80
|
+
return Object.assign(Object.assign({}, rest), { force, values: cleanedValues });
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
function cleanKwargs(kwargs, force) {
|
|
85
|
+
return Object.keys(kwargs).reduce((acc, k) => {
|
|
86
|
+
acc[k] = cleanValue(kwargs[k], force);
|
|
87
|
+
return acc;
|
|
88
|
+
}, {});
|
|
89
|
+
}
|
|
90
|
+
function getOrRegisterComponentTrigger(uid) {
|
|
91
|
+
const triggerKey = getComponentRegistryKey(uid, true);
|
|
92
|
+
if (!atomRegistry.has(triggerKey)) {
|
|
93
|
+
atomRegistry.set(triggerKey, atom({
|
|
94
|
+
default: {
|
|
95
|
+
force: false,
|
|
96
|
+
inc: 0,
|
|
97
|
+
},
|
|
98
|
+
key: triggerKey,
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
return atomRegistry.get(triggerKey);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get a server component from the selector registry, registering it if not already registered
|
|
105
|
+
*
|
|
106
|
+
* @param name component name
|
|
107
|
+
* @param uid component uid
|
|
108
|
+
* @param dynamicKwargs kwargs
|
|
109
|
+
* @param wsClient websocket client
|
|
110
|
+
* @param taskContext task context
|
|
111
|
+
* @param search current search string
|
|
112
|
+
* @param token auth token
|
|
113
|
+
*/
|
|
114
|
+
function getOrRegisterServerComponent(name, uid, dynamicKwargs, wsClient, taskContext, search, token) {
|
|
115
|
+
const key = getComponentRegistryKey(uid);
|
|
116
|
+
if (!selectorRegistry.has(key)) {
|
|
117
|
+
// Kwargs resolved to their simple values
|
|
118
|
+
const resolvedKwargs = Object.keys(dynamicKwargs).reduce((acc, k) => {
|
|
119
|
+
const value = dynamicKwargs[k];
|
|
120
|
+
acc[k] = resolveVariable(value, wsClient, taskContext, search, token);
|
|
121
|
+
return acc;
|
|
122
|
+
}, {});
|
|
123
|
+
// Turn kwargs into lists so we can re-use the DerivedVariable logic
|
|
124
|
+
const resolvedKwargsList = Object.values(resolvedKwargs);
|
|
125
|
+
const kwargsList = Object.values(dynamicKwargs);
|
|
126
|
+
const triggerAtom = getOrRegisterComponentTrigger(uid);
|
|
127
|
+
selectorRegistry.set(key, selector({
|
|
128
|
+
cachePolicy_UNSTABLE: {
|
|
129
|
+
eviction: 'most-recent',
|
|
130
|
+
},
|
|
131
|
+
get: ({ get }) => __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
const selfTrigger = get(triggerAtom);
|
|
133
|
+
const derivedResult = yield resolveDerivedValue(key, kwargsList, kwargsList, // pass deps=kwargs
|
|
134
|
+
resolvedKwargsList, wsClient, get, selfTrigger);
|
|
135
|
+
// returning previous result as no change in dependant values
|
|
136
|
+
if (derivedResult.type === 'previous') {
|
|
137
|
+
return derivedResult.entry.result;
|
|
138
|
+
}
|
|
139
|
+
// Otherwise fetch new component
|
|
140
|
+
// turn the resolved values back into an object and clean them up
|
|
141
|
+
const kwargValues = cleanKwargs(Object.keys(dynamicKwargs).reduce((acc, k, idx) => {
|
|
142
|
+
acc[k] = derivedResult.values[idx];
|
|
143
|
+
return acc;
|
|
144
|
+
}, {}), derivedResult.force);
|
|
145
|
+
let result = null;
|
|
146
|
+
try {
|
|
147
|
+
result = yield fetchFunctionComponent(name, normalizeRequest(kwargValues, dynamicKwargs), uid, token, wsClient);
|
|
148
|
+
}
|
|
149
|
+
catch (e) {
|
|
150
|
+
e.selectorId = key;
|
|
151
|
+
throw e;
|
|
152
|
+
}
|
|
153
|
+
taskContext.cleanupRunningTasks(key);
|
|
154
|
+
// Metatask returned
|
|
155
|
+
if (isTaskResponse(result)) {
|
|
156
|
+
const taskId = result.task_id;
|
|
157
|
+
// Register the task under the component's instance key
|
|
158
|
+
taskContext.startTask(taskId, key, getComponentRegistryKey(uid, true));
|
|
159
|
+
try {
|
|
160
|
+
yield wsClient.waitForTask(taskId);
|
|
161
|
+
}
|
|
162
|
+
catch (_a) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
taskContext.endTask(taskId);
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
result = yield fetchTaskResult(taskId, token);
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
e.selectorId = key;
|
|
173
|
+
throw e;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
depsRegistry.set(key, {
|
|
177
|
+
args: derivedResult.relevantValues,
|
|
178
|
+
cacheKey: null,
|
|
179
|
+
result,
|
|
180
|
+
});
|
|
181
|
+
return result;
|
|
182
|
+
}),
|
|
183
|
+
key,
|
|
184
|
+
}));
|
|
185
|
+
}
|
|
186
|
+
return selectorRegistry.get(key);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* A hook to fetch a server component
|
|
190
|
+
*
|
|
191
|
+
* @param name component name - specific to a given py_component
|
|
192
|
+
* @param uid component uid - specific to a given *instance* of a py_component
|
|
193
|
+
* @param dynamicKwargs kwargs passed into the component
|
|
194
|
+
*/
|
|
195
|
+
export default function useServerComponent(name, uid, dynamicKwargs) {
|
|
196
|
+
const token = useSessionToken();
|
|
197
|
+
const { client: wsClient } = useContext(WebSocketCtx);
|
|
198
|
+
const taskContext = useTaskContext();
|
|
199
|
+
const variablesContext = useContext(VariableCtx);
|
|
200
|
+
const { search } = useLocation();
|
|
201
|
+
// Synchronously register the py_component uid, and clean it up on unmount
|
|
202
|
+
variablesContext.variables.current.add(getComponentRegistryKey(uid));
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
return () => {
|
|
205
|
+
variablesContext.variables.current.delete(getComponentRegistryKey(uid));
|
|
206
|
+
};
|
|
207
|
+
}, []);
|
|
208
|
+
const componentSelector = getOrRegisterServerComponent(name, uid, dynamicKwargs, wsClient, taskContext, search, token);
|
|
209
|
+
const componentLoadable = useRecoilValueLoadable(componentSelector);
|
|
210
|
+
const deferred = useDeferLoadable(componentLoadable);
|
|
211
|
+
return deferred;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* A helper hook that returns a function to force a refresh of a server component
|
|
215
|
+
*
|
|
216
|
+
* @param name component uid
|
|
217
|
+
*/
|
|
218
|
+
export function useRefreshServerComponent(uid) {
|
|
219
|
+
return useRecoilCallback(({ set }) => () => {
|
|
220
|
+
const triggerAtom = getOrRegisterComponentTrigger(uid);
|
|
221
|
+
set(triggerAtom, (triggerIndexValue) => ({
|
|
222
|
+
force: false,
|
|
223
|
+
inc: triggerIndexValue.inc + 1,
|
|
224
|
+
}));
|
|
225
|
+
}, [uid]);
|
|
226
|
+
}
|
|
227
|
+
//# 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,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAA4B,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAE7G,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAA4B,eAAe,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAIH,6BAA6B,EAC7B,yBAAyB,GAC5B,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAqB,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAqB,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE1F,SAAS,cAAc,CAAC,QAAa;IACjC,OAAO,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,SAAS,IAAI,QAAQ,CA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CAAC;IACR,CAAC,EACL,CAAC,GAAG,CAAC,CACR,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DerivedDataVariable, DerivedVariable } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* A helper hook that returns a function to trigger a calculation for a given variable.
|
|
4
|
+
*
|
|
5
|
+
* @param variable variable to use
|
|
6
|
+
* @param force whether to force the recalculation irrespective of the caching setting
|
|
7
|
+
*/
|
|
8
|
+
export default function useTriggerVariable(variable: DerivedVariable | DerivedDataVariable, force: boolean): () => void;
|
|
9
|
+
//# sourceMappingURL=use-trigger-variable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-trigger-variable.d.ts","sourceRoot":"","sources":["../../../js/shared/interactivity/use-trigger-variable.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI/D;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACtC,QAAQ,EAAE,eAAe,GAAG,mBAAmB,EAC/C,KAAK,EAAE,OAAO,GACf,MAAM,IAAI,CAaZ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useRecoilCallback } from 'recoil';
|
|
2
|
+
import { getOrRegisterTrigger } from './internal';
|
|
3
|
+
/**
|
|
4
|
+
* A helper hook that returns a function to trigger a calculation for a given variable.
|
|
5
|
+
*
|
|
6
|
+
* @param variable variable to use
|
|
7
|
+
* @param force whether to force the recalculation irrespective of the caching setting
|
|
8
|
+
*/
|
|
9
|
+
export default function useTriggerVariable(variable, force) {
|
|
10
|
+
return useRecoilCallback(({ set }) => () => {
|
|
11
|
+
const triggerAtom = getOrRegisterTrigger(variable);
|
|
12
|
+
set(triggerAtom, (triggerIndexValue) => ({
|
|
13
|
+
force,
|
|
14
|
+
inc: triggerIndexValue.inc + 1,
|
|
15
|
+
}));
|
|
16
|
+
}, [variable.uid, force]);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=use-trigger-variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-trigger-variable.js","sourceRoot":"","sources":["../../../js/shared/interactivity/use-trigger-variable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAK3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACtC,QAA+C,EAC/C,KAAc;IAEd,OAAO,iBAAiB,CACpB,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CACR,GAAG,EAAE;QACD,MAAM,WAAW,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAEnD,GAAG,CAAC,WAAW,EAAE,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;YACrC,KAAK;YACL,GAAG,EAAE,iBAAiB,CAAC,GAAG,GAAG,CAAC;SACjC,CAAC,CAAC,CAAC;IACR,CAAC,EACL,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CACxB,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":"AAMA,OAAO,EAEH,oBAAoB,EACpB,2BAA2B,EAC3B,uBAAuB,EAE1B,MAAM,SAAS,CAAC;AAKjB,KAAK,mBAAmB,GAAG,oBAAoB,GAAG,2BAA2B,GAAG,uBAAuB,CAAC;AAExG;;;GAGG;AAEH,MAAM,CAAC,OAAO,UAAU,gBAAgB,IAAI,GAAG,GAAG,mBAAmB,CA+BpE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { useLocation } from 'react-router';
|
|
3
|
+
import { useRecoilCallback } from 'recoil';
|
|
4
|
+
import { useSessionToken } from '../../auth/auth-context';
|
|
5
|
+
import { WebSocketCtx, useTaskContext } from '../../shared/context';
|
|
6
|
+
import { isVariable, } from '../../types';
|
|
7
|
+
import { resolveVariable } from './resolve-variable';
|
|
8
|
+
import { atomRegistry, isRegistered } from './store';
|
|
9
|
+
/**
|
|
10
|
+
* Helper hook to get the current state of the variable.
|
|
11
|
+
* For client-side variables, returns their value. For server-side variables, returns their resolved forms.
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
14
|
+
export default function useVariableState() {
|
|
15
|
+
const token = useSessionToken();
|
|
16
|
+
const { client } = useContext(WebSocketCtx);
|
|
17
|
+
const taskCtx = useTaskContext();
|
|
18
|
+
const { search } = useLocation();
|
|
19
|
+
return useRecoilCallback(({ snapshot }) => {
|
|
20
|
+
return (variable) => {
|
|
21
|
+
if (!isRegistered(variable)) {
|
|
22
|
+
return '__NOT_REGISTERED__';
|
|
23
|
+
}
|
|
24
|
+
// For variables and url-variables, get the value directly out of recoil store
|
|
25
|
+
if (isVariable(variable) && (variable.__typename === 'Variable' || variable.__typename === 'UrlVariable')) {
|
|
26
|
+
const atom = atomRegistry.get(variable.uid);
|
|
27
|
+
return snapshot.getLoadable(atom).getValue();
|
|
28
|
+
}
|
|
29
|
+
// otherwise we'll just get the resolved form of the variable
|
|
30
|
+
const resolvedVariable = resolveVariable(variable, client, taskCtx, search, token, (v) => snapshot.getLoadable(v).getValue());
|
|
31
|
+
return resolvedVariable;
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
}
|
|
35
|
+
//# 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,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAKH,UAAU,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAIrD;;;GAGG;AACH,6EAA6E;AAC7E,MAAM,CAAC,OAAO,UAAU,gBAAgB;IACpC,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,MAAM,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,cAAc,EAAE,CAAC;IACjC,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,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;gBACzB,OAAO,oBAAoB,CAAC;aAC/B;YAED,8EAA8E;YAC9E,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,KAAK,UAAU,IAAI,QAAQ,CAAC,UAAU,KAAK,aAAa,CAAC,EAAE;gBACvG,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBAC5C,OAAO,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;aAChD;YAED,6DAA6D;YAC7D,MAAM,gBAAgB,GAAG,eAAe,CACpC,QAAQ,EACR,MAAM,EACN,OAAO,EACP,MAAM,EACN,KAAK,EACL,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAC5C,CAAC;YAEF,OAAO,gBAAgB,CAAC;QAC5B,CAAC,CAAC;IACN,CAAC,EAAE,EAAE,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DataVariable, DerivedDataVariable, DerivedVariable, ResolvedDataVariable, ResolvedDerivedDataVariable, ResolvedDerivedVariable, Variable } from '../../types';
|
|
2
|
+
type UseVariableValueSigOne<V, B extends boolean | undefined> = (variable: DerivedVariable, shouldFetchVariable?: B) => () => B extends true ? Promise<V> : ResolvedDerivedVariable;
|
|
3
|
+
type UseVariableValueSigTwo<V, B extends boolean | undefined> = (variable: DataVariable, shouldFetchVariable?: B) => () => B extends true ? Promise<V> : ResolvedDataVariable;
|
|
4
|
+
type UseVariableValueSigThree<V, B extends boolean | undefined> = (variable: V | Variable<V>, shouldFetchVariable?: B) => () => V;
|
|
5
|
+
type UseVariableValueSigFour<V, B extends boolean | undefined> = (variable: DerivedDataVariable, shouldFetchVariable?: B) => () => B extends true ? Promise<V> : ResolvedDerivedDataVariable;
|
|
6
|
+
type UseVariableValueSig<V, B extends boolean | undefined> = UseVariableValueSigOne<V, B> | UseVariableValueSigTwo<V, B> | UseVariableValueSigThree<V, B> | UseVariableValueSigFour<V, B>;
|
|
7
|
+
/**
|
|
8
|
+
* A helper hook that turns a Variable class into the actual value.
|
|
9
|
+
* As opposed to the `useVariable` hook, this one returns a callback to retrieve the latest value
|
|
10
|
+
* without subscribing the component using it to updates.
|
|
11
|
+
* For derived (data) variables, instead of returning its value directly - its resolved to its
|
|
12
|
+
* uid and dependency values.
|
|
13
|
+
*
|
|
14
|
+
* @param variable the variable to use
|
|
15
|
+
* @param shouldFetchVariable if true, if the variable is a derived (data) variable, the request to fetch the variable value will be made
|
|
16
|
+
* @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.
|
|
17
|
+
*/
|
|
18
|
+
export default function useVariableValue<VV, B extends boolean = false>(variable: VV | Variable<VV> | DataVariable | DerivedVariable | DerivedDataVariable, shouldFetchVariable?: B): ReturnType<UseVariableValueSig<VV, B>>;
|
|
19
|
+
export {};
|
|
20
|
+
//# 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":"AAWA,OAAO,EACH,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,uBAAuB,EACvB,QAAQ,EAQX,MAAM,SAAS,CAAC;AAWjB,KAAK,sBAAsB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,GAAG,SAAS,IAAI,CAC5D,QAAQ,EAAE,eAAe,EACzB,mBAAmB,CAAC,EAAE,CAAC,KACtB,MAAM,CAAC,SAAS,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,uBAAuB,CAAC;AAEjE,KAAK,sBAAsB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,GAAG,SAAS,IAAI,CAC5D,QAAQ,EAAE,YAAY,EACtB,mBAAmB,CAAC,EAAE,CAAC,KACtB,MAAM,CAAC,SAAS,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAAC;AAE9D,KAAK,wBAAwB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,GAAG,SAAS,IAAI,CAC9D,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,EACzB,mBAAmB,CAAC,EAAE,CAAC,KACtB,MAAM,CAAC,CAAC;AACb,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,GAAG,SAAS,IAAI,CAC7D,QAAQ,EAAE,mBAAmB,EAC7B,mBAAmB,CAAC,EAAE,CAAC,KACtB,MAAM,CAAC,SAAS,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,2BAA2B,CAAC;AACrE,KAAK,mBAAmB,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,GAAG,SAAS,IACnD,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC9B,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEpC;;;;;;;;;;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,UAAU,CAAC,mBAAmB,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CA2ExC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
// eslint-disable-next-line import/no-cycle
|
|
7
|
+
import { useSessionToken } from '../../auth/auth-context';
|
|
8
|
+
import { WebSocketCtx, useTaskContext } from '../../shared/context';
|
|
9
|
+
import { normalizeRequest } from '../../shared/utils/normalization';
|
|
10
|
+
import { isDataVariable, isDerivedDataVariable, isDerivedVariable, isResolvedDataVariable, isResolvedDerivedDataVariable, isResolvedDerivedVariable, isVariable, } from '../../types';
|
|
11
|
+
import { fetchDataVariable, fetchDerivedDataVariable, fetchDerivedVariable, formatDerivedVariableRequest, isTaskResponse, resolveVariable, } from './internal';
|
|
12
|
+
/**
|
|
13
|
+
* A helper hook that turns a Variable class into the actual value.
|
|
14
|
+
* As opposed to the `useVariable` hook, this one returns a callback to retrieve the latest value
|
|
15
|
+
* without subscribing the component using it to updates.
|
|
16
|
+
* For derived (data) variables, instead of returning its value directly - its resolved to its
|
|
17
|
+
* uid and dependency values.
|
|
18
|
+
*
|
|
19
|
+
* @param variable the variable to use
|
|
20
|
+
* @param shouldFetchVariable if true, if the variable is a derived (data) variable, the request to fetch the variable value will be made
|
|
21
|
+
* @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.
|
|
22
|
+
*/
|
|
23
|
+
export default function useVariableValue(variable, shouldFetchVariable = false) {
|
|
24
|
+
const taskContext = useTaskContext();
|
|
25
|
+
const { client } = useContext(WebSocketCtx);
|
|
26
|
+
const { search } = useLocation();
|
|
27
|
+
const token = useSessionToken();
|
|
28
|
+
if (!isVariable(variable)) {
|
|
29
|
+
return () => variable;
|
|
30
|
+
}
|
|
31
|
+
return useRecoilCallback(({ snapshot }) => {
|
|
32
|
+
return () => {
|
|
33
|
+
// Using loadable since the resolver is only used for simple atoms and shouldn't cause problems
|
|
34
|
+
const resolved = resolveVariable(variable, client, taskContext, search, token, (v) => snapshot.getLoadable(v).getValue());
|
|
35
|
+
// if we're NOT forced to fetch, or if it's not a DV/DDV/data variable, return the resolved value
|
|
36
|
+
// variable is plain/url
|
|
37
|
+
if (!shouldFetchVariable ||
|
|
38
|
+
(!isDerivedVariable(variable) && !isDataVariable(variable) && !isDerivedDataVariable(variable))) {
|
|
39
|
+
return resolved;
|
|
40
|
+
}
|
|
41
|
+
// we're forced to fetch but the resolved variable is not a resolved DV/data var, return the resolved value
|
|
42
|
+
// variable is plain/url
|
|
43
|
+
if (!isResolvedDerivedVariable(resolved) &&
|
|
44
|
+
!isResolvedDataVariable(resolved) &&
|
|
45
|
+
!isResolvedDerivedDataVariable(resolved)) {
|
|
46
|
+
return resolved;
|
|
47
|
+
}
|
|
48
|
+
// data variable
|
|
49
|
+
if (isResolvedDataVariable(resolved)) {
|
|
50
|
+
return fetchDataVariable(resolved.uid, token, resolved.filters);
|
|
51
|
+
}
|
|
52
|
+
// derived variable
|
|
53
|
+
return fetchDerivedVariable({
|
|
54
|
+
cache: variable.cache,
|
|
55
|
+
force: false,
|
|
56
|
+
token,
|
|
57
|
+
uid: resolved.uid,
|
|
58
|
+
values: normalizeRequest(formatDerivedVariableRequest(resolved.values), variable.variables),
|
|
59
|
+
wsClient: client,
|
|
60
|
+
}).then((resp) => {
|
|
61
|
+
// This is really only used in DownloadVariable currently; we can add support for tasks
|
|
62
|
+
// if it is requested in the future
|
|
63
|
+
if (isTaskResponse(resp)) {
|
|
64
|
+
throw new Error('Task DerivedVariables are not supported in this context');
|
|
65
|
+
}
|
|
66
|
+
// for derived data variables we need to make another request to retrieve the filtered value
|
|
67
|
+
if (isDerivedDataVariable(variable)) {
|
|
68
|
+
return client
|
|
69
|
+
.getChannel()
|
|
70
|
+
.then((chan) => fetchDerivedDataVariable(variable.uid, token, resp.cache_key, chan, variable.filters));
|
|
71
|
+
}
|
|
72
|
+
return resp.value;
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
}, [variable.uid, useDeepCompare(taskContext), client, search, token]);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=use-variable-value.js.map
|