@eodash/eodash 5.0.0-alpha.2.1 → 5.0.0-alpha.2.11

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.
Files changed (138) hide show
  1. package/README.md +36 -3
  2. package/core/client/App.vue +26 -0
  3. package/core/client/SuspensedDashboard.ce.vue +105 -0
  4. package/core/client/asWebComponent.d.ts +23 -0
  5. package/core/client/asWebComponent.js +12 -0
  6. package/core/client/components/DashboardLayout.vue +77 -0
  7. package/core/client/components/DynamicWebComponent.vue +68 -0
  8. package/core/client/components/ErrorAlert.vue +36 -0
  9. package/core/{components → client/components}/Footer.vue +34 -15
  10. package/core/client/components/Header.vue +19 -0
  11. package/core/client/components/IframeWrapper.vue +11 -0
  12. package/core/client/components/Loading.vue +37 -0
  13. package/core/client/components/MobileLayout.vue +109 -0
  14. package/core/client/composables/DefineEodash.js +67 -0
  15. package/core/client/composables/DefineWidgets.js +161 -0
  16. package/core/client/composables/index.js +155 -0
  17. package/core/client/eodash.js +129 -0
  18. package/core/client/main.js +2 -0
  19. package/core/client/plugins/index.js +20 -0
  20. package/core/client/plugins/vuetify.js +35 -0
  21. package/core/client/render.js +12 -0
  22. package/core/client/store/Actions.js +38 -0
  23. package/core/client/store/States.js +24 -0
  24. package/core/client/store/index.js +20 -0
  25. package/core/client/store/stac.js +81 -0
  26. package/core/client/types.d.ts +287 -0
  27. package/core/client/utils/createLayers.js +131 -0
  28. package/core/client/utils/eodashSTAC.js +259 -0
  29. package/core/client/utils/helpers.js +152 -0
  30. package/core/client/utils/index.js +51 -0
  31. package/core/{utils → client/utils}/keys.js +2 -2
  32. package/core/client/views/Dashboard.vue +116 -0
  33. package/core/client/vite-env.d.ts +39 -0
  34. package/dist/client/DashboardLayout-D5c2wAGC.js +156 -0
  35. package/dist/{DynamicWebComponent-BrHVTesn.js → client/DynamicWebComponent-CBuMCUIj.js} +11 -11
  36. package/dist/client/EodashDatePicker-D0qdMMTE.js +252 -0
  37. package/dist/client/EodashItemFilter-CTRnGRRS.js +10067 -0
  38. package/dist/client/EodashLayerControl-Bpm0BwcW.js +31499 -0
  39. package/dist/client/EodashMap-DaMtQefq.js +114367 -0
  40. package/dist/client/EodashMapBtns-B5z8h8mr.js +50 -0
  41. package/dist/client/ExportState-Bp3n6gba.js +558 -0
  42. package/dist/client/Footer-BROOTKhV.js +115 -0
  43. package/dist/client/Header-C_fKVTsg.js +350 -0
  44. package/dist/{IframeWrapper-Dd9zrX9s.js → client/IframeWrapper-32Q3DBYr.js} +4 -4
  45. package/dist/client/MobileLayout-TVGrYpNT.js +945 -0
  46. package/dist/client/PopUp-BJzmeeKG.js +300 -0
  47. package/dist/client/VImg-BT4Vb0UT.js +291 -0
  48. package/dist/client/VMain-BDVUXNEk.js +39 -0
  49. package/dist/client/VOverlay-Ck_4Lxcb.js +972 -0
  50. package/dist/{WidgetsContainer-DxfCu0I3.js → client/WidgetsContainer-DjjX_n1U.js} +25 -18
  51. package/dist/client/asWebComponent-wn9bbgx9.js +20404 -0
  52. package/dist/{basedecoder-Qm25PwVp-CHo5Pomv.js → client/basedecoder-DHcBySSe-BmCFNFnw.js} +5 -6
  53. package/dist/{decoder-kAoyGIq9-BBR5CgzS.js → client/decoder-Cth6J7EK-CLlwAswr.js} +1 -1
  54. package/dist/client/deflate-BXt-9JA_-CWfClgpK.js +10 -0
  55. package/dist/client/eo-dash.js +6 -0
  56. package/dist/client/eox-stacinfo-l7ALSV90.js +13969 -0
  57. package/dist/client/forwardRefs--PLRH8zp.js +185 -0
  58. package/dist/client/helpers-CoqJPYdE.js +1391 -0
  59. package/dist/{index-DTkOfh2g.js → client/index-Dt0NRXIq.js} +21 -20
  60. package/dist/{jpeg-DNfUpLwy-Fjan-04T.js → client/jpeg-BAgeD1d3-oeHbFPUL.js} +5 -6
  61. package/dist/{lerc-C9VL9kri-cIdbW0sg.js → client/lerc-BgbQqdFI-CCpDWUne.js} +37 -39
  62. package/dist/{lzw-BOMhmEDy-Dboc93VO.js → client/lzw-LAGDNbSC-DkP96qO9.js} +1 -1
  63. package/dist/{packbits-DaUD6MLm-Bu1PoTGa.js → client/packbits-BlDR4Kj5-C66n1-zr.js} +1 -1
  64. package/dist/{pako.esm-C3kYPGGQ-BMki8cQY.js → client/pako.esm-CB1uQYY0-DB0PYm1P.js} +6 -12
  65. package/dist/{raw-CcGKjn8q-DFOt-i8n.js → client/raw-CMGvRjfu-BRi6E4i1.js} +1 -1
  66. package/dist/{ssrBoot-D-b4-M19.js → client/ssrBoot-DjZDIkG_.js} +1 -1
  67. package/dist/client/style.css +5 -0
  68. package/dist/client/transition-C8OQt_kp.js +34 -0
  69. package/dist/{webfontloader-CyOFAuFB.js → client/webfontloader-qotgY98I.js} +56 -92
  70. package/dist/{webimage-D2c098k3-DLj1LQxB.js → client/webimage-BM_pbLN3-L2cGWK5l.js} +1 -1
  71. package/dist/node/cli.js +20 -0
  72. package/dist/node/main.js +2 -0
  73. package/dist/node/types.d.ts +47 -0
  74. package/package.json +57 -51
  75. package/widgets/EodashDatePicker.vue +146 -40
  76. package/widgets/EodashItemFilter.vue +81 -41
  77. package/widgets/EodashLayerControl.vue +16 -0
  78. package/widgets/EodashMap.vue +186 -42
  79. package/widgets/EodashMapBtns.vue +50 -0
  80. package/widgets/ExportState.vue +112 -0
  81. package/widgets/PopUp.vue +40 -0
  82. package/widgets/WidgetsContainer.vue +47 -27
  83. package/bin/app.js +0 -22
  84. package/bin/cli.js +0 -62
  85. package/bin/main.js +0 -9
  86. package/bin/serverConfig.js +0 -165
  87. package/bin/types.d.ts +0 -52
  88. package/bin/utils.js +0 -103
  89. package/core/App.vue +0 -19
  90. package/core/SuspensedDashboard.ce.vue +0 -65
  91. package/core/asWebComponent.d.ts +0 -18
  92. package/core/asWebComponent.js +0 -12
  93. package/core/components/DashboardLayout.vue +0 -44
  94. package/core/components/DynamicWebComponent.vue +0 -68
  95. package/core/components/Header.vue +0 -14
  96. package/core/components/IframeWrapper.vue +0 -11
  97. package/core/components/Loading.vue +0 -27
  98. package/core/components/MobileLayout.vue +0 -49
  99. package/core/composables/DefineEodash.js +0 -57
  100. package/core/composables/DefineWidgets.js +0 -129
  101. package/core/composables/index.js +0 -219
  102. package/core/eodash.js +0 -100
  103. package/core/main.js +0 -2
  104. package/core/plugins/index.js +0 -18
  105. package/core/plugins/vuetify.js +0 -30
  106. package/core/render.js +0 -13
  107. package/core/store/Actions.js +0 -0
  108. package/core/store/States.js +0 -21
  109. package/core/store/index.js +0 -17
  110. package/core/store/stac.js +0 -63
  111. package/core/types.d.ts +0 -356
  112. package/core/utils/eodashSTAC.js +0 -164
  113. package/core/utils/helpers.js +0 -40
  114. package/core/utils/index.js +0 -28
  115. package/core/views/Dashboard.vue +0 -59
  116. package/core/vite-env.d.ts +0 -31
  117. package/dist/DashboardLayout-Dp8AnYD9.js +0 -141
  118. package/dist/EodashDatePicker-D_udZ26j.js +0 -1645
  119. package/dist/EodashItemFilter-BLAGx2UD.js +0 -51
  120. package/dist/EodashMap-Bxl_aqY2.js +0 -53405
  121. package/dist/Footer-AohCH8U7.js +0 -118
  122. package/dist/Header-DC50S6GR.js +0 -609
  123. package/dist/MobileLayout-CgToA7Gp.js +0 -523
  124. package/dist/VBtn-Bz7ruRUg.js +0 -1106
  125. package/dist/VMain-BHfWJU2j.js +0 -35
  126. package/dist/asWebComponent-C8rb3b1D.js +0 -11323
  127. package/dist/color-DpYEub1f.js +0 -115
  128. package/dist/deflate-Be2Arps5-hDqMz3RA.js +0 -10
  129. package/dist/dimensions-CJaGeSrj.js +0 -53
  130. package/dist/eo-dash.js +0 -6
  131. package/dist/eox-itemfilter-DcQkRD2l.js +0 -7537
  132. package/dist/eox-map-BJ9SIixs.js +0 -36205
  133. package/dist/eox-stacinfo-B-YrT7Ug.js +0 -13698
  134. package/dist/forwardRefs-Bxeu9Obx.js +0 -142
  135. package/dist/index-Sa2Vg_gx.js +0 -65
  136. package/dist/style.css +0 -5
  137. /package/dist/{.gitkeep → client/.gitkeep} +0 -0
  138. /package/dist/{_commonjsHelpers-DaMA6jEr.js → client/_commonjsHelpers-DaMA6jEr.js} +0 -0
@@ -1,65 +0,0 @@
1
- <template>
2
- <v-app>
3
- <Suspense>
4
- <Dashboard :on-template-mount="setStylesFromHead" :config="config" />
5
- <template #fallback>
6
- <div style="height: 100dvh; display: flex; align-items: center; justify-content: center;">
7
- <Loading />
8
- </div>
9
- </template>
10
- </Suspense>
11
- </v-app>
12
- </template>
13
- <script setup>
14
- import Dashboard from '@/views/Dashboard.vue';
15
- import { createApp, getCurrentInstance } from "vue"
16
- import { registerPlugins } from '@/plugins';
17
- import { eodashKey } from '@/utils/keys';
18
- import Loading from '@/components/Loading.vue';
19
-
20
- defineProps({
21
- config: {
22
- type: String,
23
- }
24
- })
25
- const app = createApp({})
26
- registerPlugins(app)
27
-
28
- const inst = getCurrentInstance()
29
- //@ts-expect-error
30
- Object.assign(inst.appContext, app._context)
31
- //@ts-expect-error
32
- Object.assign(inst.provides, app._context.provides)
33
-
34
- function setStylesFromHead() {
35
- const eodashComponent = document.querySelector('eo-dash')
36
- const styleSheet = new CSSStyleSheet()
37
- const head = document.querySelector('head')
38
- let stylesStr = ''
39
-
40
- Array.from(head?.children ?? []).forEach((child) => {
41
- if (child.getAttribute('type') === 'text/css') {
42
- stylesStr += `\n ${child.innerHTML}`
43
- return
44
- }
45
-
46
- if (child.tagName == 'LINK' && child.getAttribute('rel')?.includes('stylesheet')) {
47
- eodashComponent?.shadowRoot?.appendChild(child.cloneNode(true))
48
- }
49
- });
50
-
51
- stylesStr += `\n * {
52
- font-family:${
53
- //@ts-expect-error
54
- /** @type {import("@/types").Eodash} */ (inst.provides[eodashKey])?.brand.font?.family ?? 'Roboto'}
55
- }
56
- ${//@ts-expect-error
57
- /** @type {import("@/types").Eodash} */ (inst.provides[eodashKey]).brand.noLayout ?
58
- `div.v-application__wrap {
59
- min-height: fit-content;
60
- }`: ""}
61
- `
62
- styleSheet.replaceSync(stylesStr.replaceAll(":root", ":host"))
63
- eodashComponent?.shadowRoot?.adoptedStyleSheets.push(styleSheet)
64
- }
65
- </script>
@@ -1,18 +0,0 @@
1
- /** @group WebComponent */
2
- type EodashConstructor = import("vue").VueElementConstructor<import("vue").ExtractPropTypes<{ config: string }>>
3
- /**
4
- * Eodash Web Component constructor
5
- * @group WebComponent
6
- */
7
- export declare const Eodash: EodashConstructor
8
- /**
9
- * Registers `eo-dash` as Custom Element in the window
10
- * @group WebComponent
11
- */
12
- export declare function register(): void
13
-
14
- /**
15
- * Eodash store @see EodashStore
16
- * @group WebComponent
17
- */
18
- export declare const store: import("./types").EodashStore
@@ -1,12 +0,0 @@
1
- import SuspensedDashboard from './SuspensedDashboard.ce.vue';
2
- import { defineCustomElement } from 'vue'
3
- /** @type {import("./asWebComponent").EodashConstructor} */
4
- export const Eodash = defineCustomElement(SuspensedDashboard)
5
-
6
- export function register() {
7
- customElements.define('eo-dash', Eodash)
8
- }
9
-
10
- export { default as store } from '@/store'
11
-
12
- register()
@@ -1,44 +0,0 @@
1
- <template>
2
- <v-main>
3
- <eox-layout :gap="eodash.template.gap ?? 2">
4
- <eox-layout-item style="z-index: 0;" x="0" y="0" h="12" w="12">
5
- <component id="bg-widget" :is="bgWidget.component" v-bind="bgWidget.props" />
6
- </eox-layout-item>
7
- <eox-layout-item v-for="(config, idx) in widgetsConfig" ref="itemEls" :key="idx"
8
- style="position: relative; overflow: visible; z-index: 1; border-radius: 0px; background: rgb(var(--v-theme-surface))"
9
- :x="config.layout.x" :y="config.layout.y" :h="config.layout.h" :w="config.layout.w">
10
-
11
- <v-btn v-if="slideBtns[idx].enabled" position="absolute" variant="tonal" :style="slideBtns[idx].style"
12
- class="slide-btn" @click="slideInOut(idx)">
13
- <v-icon :icon="slideBtns[idx].active ? slideBtns[idx].icon.in : slideBtns[idx].icon.out" />
14
- </v-btn>
15
- <component :key="importedWidgets[idx].value.id" :is="importedWidgets[idx].value.component"
16
- v-bind="importedWidgets[idx].value.props" />
17
-
18
- </eox-layout-item>
19
- </eox-layout>
20
- </v-main>
21
- </template>
22
- <script setup>
23
- import { eodashKey } from '@/utils/keys';
24
- import { inject } from 'vue';
25
- import { useDefineWidgets } from '@/composables/DefineWidgets'
26
- import { useSlidePanels } from '@/composables'
27
- import { ref } from 'vue';
28
- import '@eox/layout'
29
-
30
- const eodash = /** @type {import("@/types").Eodash} */ (inject(eodashKey))
31
-
32
- const [bgWidget] = useDefineWidgets([eodash.template?.background])
33
-
34
- const widgetsConfig = eodash.template?.widgets
35
-
36
- const importedWidgets = useDefineWidgets(widgetsConfig)
37
- /**
38
- * Layout items template ref
39
- * @type {import('vue').Ref<HTMLElement[]>}
40
- */
41
- const itemEls = ref([])
42
-
43
- const { slideBtns, slideInOut } = useSlidePanels(itemEls, widgetsConfig)
44
- </script>
@@ -1,68 +0,0 @@
1
- <template>
2
- <span class="d-flex flex-column fill-height overflow-auto">
3
- <component :is="tagName" v-bind="properties" ref="elementRef" />
4
- </span>
5
- </template>
6
-
7
- <script async setup>
8
- import { useSTAcStore } from '@/store/stac';
9
- import {
10
- onUnmounted as whenUnMounted,
11
- onMounted as whenMounted
12
- } from 'vue';
13
- import { ref } from 'vue';
14
-
15
- const props = /** @type {import("@/types").WebComponentProps} */(defineProps({
16
- link: {
17
- type: [String, Function],
18
- required: true
19
- },
20
- constructorProp: String,
21
- tagName: {
22
- type: String,
23
- required: true
24
- },
25
- properties: {
26
- type: Object,
27
- default: () => {
28
- return {}
29
- }
30
- },
31
- onMounted: Function,
32
- onUnmounted: Function
33
- }))
34
-
35
-
36
- const getWebComponent = async () => typeof props.link === 'string' ?
37
- await import( /* @vite-ignore */props.link) : await props.link()
38
-
39
- const imported = !customElements.get(props.tagName) ? await getWebComponent().catch(e => {
40
- console.error(e)
41
- }) : null
42
-
43
- const defined = customElements.get(props.tagName)
44
-
45
- // if the imported link doesn't define the custom tag provided
46
- if (!defined && props.constructorProp) {
47
- const Constructor = imported[props.constructorProp]
48
- customElements.define(props.tagName, Constructor)
49
- }
50
-
51
- const store = useSTAcStore()
52
-
53
- /**
54
- * @typedef {HTMLElement &
55
- * Record<string|number|symbol,unknown>} CustomElement
56
- * @type {import('vue').Ref<CustomElement|null>}
57
- */
58
- const elementRef = ref(null)
59
-
60
-
61
- whenMounted(() => {
62
- props.onMounted?.(elementRef.value, store)
63
- })
64
-
65
- whenUnMounted(() => {
66
- props.onUnmounted?.(elementRef.value, store)
67
- })
68
- </script>
@@ -1,14 +0,0 @@
1
- <template>
2
- <v-app-bar color="primary">
3
- <v-app-bar-title>{{ title }}</v-app-bar-title>
4
- <v-img class="mx-12" style="max-width: 140px;" :src="eodash.brand?.logo" />
5
- </v-app-bar>
6
- </template>
7
- <script setup>
8
- import { eodashKey } from '@/utils/keys';
9
- import { inject } from 'vue';
10
-
11
- const eodash = /** @type {import("@/types").Eodash} */(inject(eodashKey))
12
-
13
- const title = eodash.brand?.name
14
- </script>
@@ -1,11 +0,0 @@
1
- <template>
2
- <iframe :src="src" style="width: 100%; height: 100%"></iframe>
3
- </template>
4
- <script setup>
5
- defineProps({
6
- src: {
7
- type: String,
8
- required: true
9
- }
10
- })
11
- </script>
@@ -1,27 +0,0 @@
1
- <template>
2
- <v-row class="d-flex justify-center align-center ">
3
- <v-col class="flex-column justify-center align-center">
4
- <Suspense>
5
- <component v-if="loading.component" :is="loading.component" v-bind="loading.props"></component>
6
- <div v-else class="text-center">
7
- Loading...
8
- </div>
9
- <template #fallback>
10
- <div class="text-center">
11
- Loading...
12
- </div>
13
- </template>
14
- </Suspense>
15
- </v-col>
16
- </v-row>
17
- </template>
18
- <script setup>
19
- import { inject } from 'vue';
20
- import { eodashKey } from '@/utils/keys';
21
- import { useDefineWidgets } from '@/composables/DefineWidgets';
22
-
23
- const eodash = /** @type {import("@/types").Eodash} */ (inject(eodashKey))
24
-
25
- const [loading] = useDefineWidgets([eodash.template.loading])
26
-
27
- </script>
@@ -1,49 +0,0 @@
1
- <template>
2
- <v-main class="overflow-hidden" style="height: 91dvh;">
3
-
4
- <component id="bg-widget" :is="bgWidget.component" v-bind="bgWidget.props"></component>
5
-
6
- <div v-show="activeIdx === idx" id="overlay" class="pa-2" v-for="(importedWidget, idx) in importedWidgets"
7
- :key="idx" :style="{
8
- bottom: tabsHeightFromBtm, position: 'absolute', overflow: 'hidden',
9
- width: '100%', left: 0, top: mainRect.top + 'px', zIndex: 1, background: 'rgb(var(--v-theme-surface))'
10
- }">
11
- <v-btn icon variant="text" style="height: 5%;position: relative;" @click="activeIdx = -1">&#x2715;</v-btn>
12
- <component style="height: 94% !important;" :key="importedWidget.value.id" :is="importedWidget.value.component"
13
- v-show="activeIdx === idx" v-bind="importedWidget.value.props" />
14
- </div>
15
-
16
- <v-tabs ref="tabs" align-tabs="center" bg-color="surface"
17
- :style="{ position: 'relative', bottom: (mainRect.bottom || 48) + 'px', zIndex: 10 }" show-arrows
18
- v-model="activeIdx">
19
- <v-tab v-for="(importedWidget, idx) in importedWidgets" :key="idx" :value="idx">
20
- {{ importedWidget.value.title }}
21
- </v-tab>
22
- </v-tabs>
23
-
24
- </v-main>
25
- </template>
26
- <script setup>
27
- import { eodashKey } from '@/utils/keys';
28
- import { inject, ref, onMounted } from 'vue';
29
- import { useDefineWidgets } from '@/composables/DefineWidgets'
30
- import { useLayout } from "vuetify"
31
-
32
- const eodash = /** @type {import("@/types").Eodash} */(inject(eodashKey));
33
-
34
- //import widgets
35
- const widgetsConfig = eodash.template.widgets
36
- const importedWidgets = useDefineWidgets(widgetsConfig)
37
- const [bgWidget] = useDefineWidgets([eodash.template?.background])
38
-
39
- const { mainRect } = useLayout()
40
-
41
- const activeIdx = ref(-1)
42
-
43
- /** @type {import("vue").Ref<import("vuetify/components").VTabs|null>} */
44
- const tabs = ref(null)
45
- const tabsHeightFromBtm = ref('')
46
- onMounted(() => {
47
- tabsHeightFromBtm.value = mainRect.value.bottom + (/** @type {HTMLElement} */(tabs.value?.$el)?.clientHeight ?? 0) + "px"
48
- })
49
- </script>
@@ -1,57 +0,0 @@
1
- import store from "@/store";
2
- import { eodashKey } from "@/utils/keys";
3
- import { inject } from "vue";
4
-
5
-
6
-
7
- /**
8
- * Sets user defined instance on runtime.
9
- * Consumes `/@fs/config.js` and assign it to `eodash`
10
- * @async
11
- * @returns {Promise<import("@/types").Eodash>}
12
- * @param {string | undefined} runtimeConfig
13
- * @see {@linkplain '@/eodash.js'}
14
- */
15
- export const useEodashRuntime = async (runtimeConfig) => {
16
- const eodash = /** @type {import("@/types").Eodash} */(inject(eodashKey))
17
- /**
18
- * @param {import("@/types").Eodash} config
19
- */
20
- const assignInstance = (config) => {
21
- /** @type {(keyof import("@/types").Eodash)[]} */(Object.keys(eodash))
22
- .forEach((key) => {
23
- //@ts-expect-error
24
- eodash[key] = config[key]
25
- })
26
- }
27
-
28
- if (runtimeConfig) {
29
- assignInstance((await import( /* @vite-ignore */new URL(runtimeConfig, import.meta.url).href)).default);
30
- return eodash
31
- }
32
-
33
- try {
34
- assignInstance(
35
- (await import( /* @vite-ignore */new URL('/config.js', import.meta.url).href)).default
36
- )
37
- } catch {
38
- try {
39
- assignInstance(await import("user:config").then(async m => await m['default']))
40
- } catch {
41
- console.error('no dashboard configuration defined')
42
- }
43
- }
44
- return eodash
45
- }
46
-
47
- /**
48
- * @param {((store:import("@/types").EodashStore)=> Promise<import("@/types").Eodash>)
49
- * | import("@/types").Eodash} config
50
- */
51
- export const createEodash = async (config) => {
52
- if (config instanceof Function) {
53
- return await config(store)
54
- } else {
55
- return config
56
- }
57
- }
@@ -1,129 +0,0 @@
1
- import { defineAsyncComponent, reactive, shallowRef, watch } from 'vue'
2
- import { useSTAcStore } from '@/store/stac'
3
- import { storeToRefs } from 'pinia'
4
- import Loading from '@/components/Loading.vue';
5
-
6
- /**
7
- * @typedef {{
8
- * component:import('vue').Component | null;
9
- * props: Record<string, unknown>;
10
- * title :string;
11
- * id:string|number|symbol;
12
- * }} DefinedWidget
13
- */
14
-
15
- /**
16
- * @typedef {import('vue').ShallowRef<DefinedWidget>} ReactiveDefinedWidget
17
- */
18
-
19
- const internalWidgets = (() => {
20
- /**
21
- * @type {Record<string,() => Promise<import('vue').Component>>}
22
- */
23
- const importMap = {
24
- ...import.meta.glob('^/**/*.vue'),
25
- ...import.meta.glob("user:widgets/**/*.vue")
26
- }
27
- for (const key in importMap) {
28
- const newKey = /** @type {string} */(key.split('/').at(-1)).slice(0, -4)
29
- Object.defineProperty(importMap, newKey,
30
- /** @type {PropertyDescriptor} */(Object.getOwnPropertyDescriptor(importMap, key)));
31
- delete importMap[key];
32
- }
33
- return importMap
34
- })();
35
-
36
-
37
- /**
38
- * Composable that converts widgets Configurations to defined imported widgets
39
- * @param { (import("@/types").Widget | import("@/types").BackgroundWidget | undefined)[] |
40
- * import("@/types").WidgetsContainerProps['widgets'] | undefined} widgetConfigs
41
- * @returns {Array<ReactiveDefinedWidget>}
42
- **/
43
- export const useDefineWidgets = (widgetConfigs) => {
44
- /**
45
- * @type {Array<ReactiveDefinedWidget>}
46
- */
47
- const definedWidgets = []
48
-
49
- for (const config of (widgetConfigs ?? [])) {
50
- /**
51
- * @type {ReactiveDefinedWidget}
52
- */
53
- const definedWidget = shallowRef({
54
- component: null,
55
- props: {},
56
- title: '',
57
- id: Symbol(),
58
- })
59
-
60
- if ('defineWidget' in (config ?? {})) {
61
- const { selectedStac } = storeToRefs(useSTAcStore())
62
- watch(selectedStac, (updatedStac) => {
63
- const definedConfig = reactive(/** @type {import("@/types").FunctionalWidget} */
64
- (config)?.defineWidget(updatedStac))
65
- definedWidget.value = definedWidget.value.id === definedConfig.id ?
66
- definedWidget.value : getWidgetDefinition(definedConfig);
67
- }, { immediate: true })
68
- } else {
69
- definedWidget.value = getWidgetDefinition(/** @type {import("@/types").StaticWidget} */(config))
70
- }
71
- definedWidgets.push(definedWidget)
72
- }
73
- return definedWidgets
74
- }
75
-
76
-
77
- /**
78
- * Converts a static widget configuration to a defined imported widget
79
- * @param {import("@/types").StaticWidget| Omit<import("@/types").StaticWidget, "layout">| undefined} config
80
- * @returns {DefinedWidget}
81
- **/
82
- const getWidgetDefinition = (config) => {
83
- /**
84
- * @type {DefinedWidget}
85
- */
86
- const importedWidget = {
87
- component: null,
88
- props: {},
89
- title: '',
90
- id: Symbol(),
91
- }
92
- switch (config?.type) {
93
- case 'internal':
94
- importedWidget.component = defineAsyncComponent({
95
- loader: internalWidgets[/** @type {import("@/types").InternalComponentWidget} **/(config)?.widget.name],
96
- suspensible: true,
97
- loadingComponent: Loading
98
- })
99
- importedWidget.props = reactive(/** @type {import("@/types").InternalComponentWidget} **/(config)?.widget.properties ?? {})
100
-
101
- break;
102
-
103
- case 'web-component':
104
- importedWidget.component = defineAsyncComponent({
105
- loader: () => import('@/components/DynamicWebComponent.vue'),
106
- suspensible: true,
107
- loadingComponent: Loading
108
- })
109
- importedWidget.props = reactive(config.widget)
110
-
111
- break;
112
- case 'iframe':
113
- importedWidget.component = defineAsyncComponent({
114
- loader: () => import('@/components/IframeWrapper.vue'),
115
- suspensible: true,
116
- loadingComponent: Loading
117
- })
118
- importedWidget.props = reactive(config.widget)
119
- break;
120
-
121
- default:
122
- console.error('Widget type not found')
123
- break;
124
- }
125
- importedWidget.title = config?.title ?? ''
126
- importedWidget.id = config?.id ?? importedWidget.id
127
- return importedWidget
128
- }
129
-