@eodash/eodash 5.0.0-alpha.1.8 → 5.0.0-alpha.2
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/README.md +1 -1
- package/bin/app.js +1 -4
- package/bin/cli.js +26 -29
- package/bin/main.js +9 -0
- package/bin/serverConfig.js +65 -35
- package/bin/types.d.ts +52 -0
- package/bin/utils.js +91 -21
- package/core/App.vue +10 -12
- package/core/SuspensedDashboard.ce.vue +59 -0
- package/core/asWebComponent.d.ts +18 -0
- package/core/asWebComponent.js +12 -0
- package/core/components/DashboardLayout.vue +23 -27
- package/core/components/DynamicWebComponent.vue +6 -6
- package/core/components/Footer.vue +11 -12
- package/core/components/Header.vue +5 -29
- package/core/components/Loading.vue +27 -0
- package/core/components/MobileLayout.vue +34 -63
- package/core/composables/DefineEodash.js +57 -0
- package/core/composables/DefineWidgets.js +26 -15
- package/core/composables/index.js +139 -67
- package/core/eodash.js +100 -0
- package/core/main.js +2 -4
- package/core/plugins/index.js +3 -12
- package/core/plugins/vuetify.js +5 -2
- package/core/store/Actions.js +0 -28
- package/core/store/States.js +12 -3
- package/core/store/stac.js +7 -5
- package/core/types.d.ts +148 -124
- package/core/utils/eodashSTAC.js +164 -0
- package/core/utils/helpers.js +40 -0
- package/core/utils/index.js +28 -0
- package/core/utils/keys.js +6 -0
- package/core/views/Dashboard.vue +33 -23
- package/core/vite-env.d.ts +16 -2
- package/dist/.gitkeep +0 -0
- package/dist/DashboardLayout-YLfAa8wH.js +168 -0
- package/dist/DynamicWebComponent-BDOQsEcj.js +57 -0
- package/dist/EodashDatePicker-DlehqSgz.js +1645 -0
- package/dist/EodashItemFilter-TSp7XRGy.js +51 -0
- package/dist/EodashMap-DInb9cfS.js +53405 -0
- package/dist/Footer-CIzHgJbK.js +118 -0
- package/dist/Header-C5PSB8Uc.js +609 -0
- package/dist/IframeWrapper-DYHQQRUh.js +19 -0
- package/dist/MobileLayout-DZmqrpub.js +523 -0
- package/dist/VBtn-CFPhsIX8.js +1106 -0
- package/dist/VMain-deI9jyIf.js +35 -0
- package/dist/WidgetsContainer-D_PLP1qf.js +122 -0
- package/dist/_commonjsHelpers-DaMA6jEr.js +8 -0
- package/dist/asWebComponent-BKe6Spni.js +11323 -0
- package/dist/basedecoder-Qm25PwVp-CHo5Pomv.js +89 -0
- package/dist/color-D72nEBIR.js +115 -0
- package/dist/decoder-kAoyGIq9-HAkjSTCt.js +10 -0
- package/dist/deflate-Be2Arps5-hDqMz3RA.js +10 -0
- package/dist/dimensions-BZkmIizV.js +53 -0
- package/dist/eo-dash.js +6 -0
- package/dist/eox-itemfilter-DcQkRD2l.js +7537 -0
- package/dist/eox-map-BJ9SIixs.js +36205 -0
- package/dist/eox-stacinfo-B-YrT7Ug.js +13698 -0
- package/dist/forwardRefs-Bxeu9Obx.js +142 -0
- package/dist/index-8ch8xKfa.js +152 -0
- package/dist/index-DIt8GjSR.js +65 -0
- package/dist/jpeg-DNfUpLwy-Fjan-04T.js +515 -0
- package/dist/lerc-C9VL9kri-DyVxBvsf.js +1029 -0
- package/dist/lzw-BOMhmEDy-Dboc93VO.js +84 -0
- package/dist/packbits-DaUD6MLm-Bu1PoTGa.js +24 -0
- package/dist/pako.esm-C3kYPGGQ-BMki8cQY.js +1087 -0
- package/dist/raw-CcGKjn8q-DFOt-i8n.js +9 -0
- package/dist/ssrBoot-Cm5pWM14.js +17 -0
- package/dist/style.css +5 -0
- package/dist/webfontloader-CyOFAuFB.js +471 -0
- package/dist/webimage-D2c098k3-DLj1LQxB.js +19 -0
- package/package.json +41 -12
- package/widgets/EodashDatePicker.vue +56 -0
- package/widgets/EodashItemFilter.vue +60 -0
- package/widgets/EodashMap.vue +82 -0
- package/widgets/WidgetsContainer.vue +1 -1
- package/core/composables/DefineConfig.js +0 -45
- package/core/eodashConfig.js +0 -136
- package/core/plugins/router.js +0 -20
- package/core/store/Keys.js +0 -6
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ npm run preview
|
|
|
20
20
|
.
|
|
21
21
|
├── core # Main source code that hosts the microfrontends and renders the dashboard
|
|
22
22
|
├── docs # Documentation files
|
|
23
|
-
├── widgets #
|
|
23
|
+
├── widgets # Vue componenets as internal widgets.
|
|
24
24
|
├── public # Statically served directory
|
|
25
25
|
└── README.md
|
|
26
26
|
|
package/bin/app.js
CHANGED
|
@@ -4,15 +4,12 @@ import { buildApp, createDevServer, previewApp } from './cli.js'
|
|
|
4
4
|
|
|
5
5
|
const command = process.argv?.[2];
|
|
6
6
|
(async () => {
|
|
7
|
-
const baseFlag = (
|
|
8
|
-
process.argv.indexOf('--base') > -1 ? process.argv[process.argv.indexOf('--base')+1] : null
|
|
9
|
-
);
|
|
10
7
|
switch (command) {
|
|
11
8
|
case "dev":
|
|
12
9
|
await createDevServer();
|
|
13
10
|
break;
|
|
14
11
|
case "build":
|
|
15
|
-
await buildApp(
|
|
12
|
+
await buildApp();
|
|
16
13
|
break;
|
|
17
14
|
case "preview":
|
|
18
15
|
await previewApp();
|
package/bin/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { build, createServer, preview } from "vite"
|
|
4
4
|
import {
|
|
5
5
|
rootPath, appPath, buildTargetPath,
|
|
6
|
-
|
|
6
|
+
userConfig, runtimeConfigPath,
|
|
7
7
|
} from "./utils.js";
|
|
8
8
|
import { writeFile, rm, cp } from "fs/promises";
|
|
9
9
|
import { indexHtml, serverConfig } from "./serverConfig.js";
|
|
@@ -18,47 +18,44 @@ export const createDevServer = async () => {
|
|
|
18
18
|
server.bindCLIShortcuts({ print: true })
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export const buildApp = async (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
export const buildApp = async () => {
|
|
22
|
+
/** @param {"production"|"lib"} mode */
|
|
23
|
+
const viteBuild = async (mode) => {
|
|
24
|
+
const config = await serverConfig({ mode, command: 'build' });
|
|
25
|
+
await build(config)
|
|
26
|
+
|
|
27
|
+
if (existsSync(runtimeConfigPath)) {
|
|
28
|
+
await cp(runtimeConfigPath, path.join(buildTargetPath, 'config.js'),
|
|
29
|
+
{ recursive: true }).catch((e) => {
|
|
30
30
|
console.error(e)
|
|
31
31
|
})
|
|
32
|
-
}
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
await
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
if (appPath.includes('node_modules') && existsSync(appPublicPath)) {
|
|
45
|
-
await rm(appPublicPath, { recursive: true }).catch((e) => {
|
|
46
|
-
console.error(e)
|
|
33
|
+
}
|
|
34
|
+
if (userConfig.lib) {
|
|
35
|
+
await viteBuild("lib")
|
|
36
|
+
} else {
|
|
37
|
+
const htmlPath = path.join(appPath, '/index.html')
|
|
38
|
+
await writeFile(htmlPath, indexHtml).then(async () => {
|
|
39
|
+
await viteBuild("production")
|
|
40
|
+
await rm(htmlPath).catch(() => {
|
|
41
|
+
console.error('failed to remove index.html')
|
|
47
42
|
})
|
|
48
|
-
}
|
|
49
|
-
}
|
|
43
|
+
})
|
|
44
|
+
}
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
|
|
53
48
|
export async function previewApp() {
|
|
54
49
|
const previewServer = await preview({
|
|
55
50
|
root: rootPath,
|
|
51
|
+
base: userConfig.base ?? '',
|
|
56
52
|
preview: {
|
|
57
|
-
port: 8080,
|
|
58
|
-
open:
|
|
53
|
+
port: isNaN(userConfig.port) ? 8080 : userConfig.port,
|
|
54
|
+
open: userConfig.open,
|
|
55
|
+
host: userConfig.host
|
|
59
56
|
},
|
|
60
57
|
build: {
|
|
61
|
-
outDir: buildTargetPath
|
|
58
|
+
outDir: buildTargetPath,
|
|
62
59
|
}
|
|
63
60
|
})
|
|
64
61
|
previewServer.printUrls()
|
package/bin/main.js
ADDED
package/bin/serverConfig.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
3
|
import vue from '@vitejs/plugin-vue';
|
|
6
4
|
import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify';
|
|
7
|
-
import virtual, { updateVirtualModule } from 'vite-plugin-virtual'
|
|
8
5
|
import { fileURLToPath, URL } from 'url';
|
|
9
6
|
import {
|
|
10
7
|
runtimeConfigPath,
|
|
11
|
-
appPath,
|
|
12
|
-
|
|
13
|
-
buildTargetPath
|
|
8
|
+
appPath, entryPath,
|
|
9
|
+
cachePath, publicPath, userConfig,
|
|
10
|
+
buildTargetPath,
|
|
11
|
+
logger,
|
|
12
|
+
rootPath,
|
|
13
|
+
internalWidgetsPath
|
|
14
14
|
} from "./utils.js";
|
|
15
15
|
import { readFile } from "fs/promises";
|
|
16
16
|
import { defineConfig, searchForWorkspaceRoot } from "vite"
|
|
17
|
-
import { getUserModules } from './utils.js';
|
|
18
17
|
import { existsSync } from 'fs';
|
|
19
18
|
import path from "path";
|
|
20
19
|
|
|
@@ -30,21 +29,22 @@ export const indexHtml = `
|
|
|
30
29
|
</head>
|
|
31
30
|
|
|
32
31
|
<body>
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
${userConfig.lib ? `<eo-dash/>
|
|
33
|
+
<script type="module" src="${path.resolve(`/@fs/${appPath}`, `core/asWebComponent.js`)}"></script>
|
|
34
|
+
`: ` <div id="app"/>
|
|
35
|
+
<script type="module" src="${path.resolve(`/@fs/${appPath}`, `core/render.js`)}"></script>
|
|
36
|
+
`}
|
|
35
37
|
</body>
|
|
36
38
|
</html>`
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
* @type {import('vite').Plugin | null}
|
|
40
|
-
*/
|
|
41
|
-
let virtualPlugin = null;
|
|
40
|
+
//@ts-expect-error
|
|
42
41
|
export const serverConfig = /** @type {import('vite').UserConfigFnPromise}*/(defineConfig(async ({ mode, command }) => {
|
|
43
42
|
return {
|
|
44
|
-
base: '',
|
|
43
|
+
base: userConfig.base ?? '',
|
|
45
44
|
cacheDir: cachePath,
|
|
46
45
|
plugins: [
|
|
47
46
|
vue({
|
|
47
|
+
customElement: userConfig.lib,
|
|
48
48
|
template: {
|
|
49
49
|
transformAssetUrls,
|
|
50
50
|
compilerOptions: {
|
|
@@ -59,35 +59,49 @@ export const serverConfig = /** @type {import('vite').UserConfigFnPromise}*/(def
|
|
|
59
59
|
(mode === "development" && {
|
|
60
60
|
name: "inject-html",
|
|
61
61
|
configureServer
|
|
62
|
-
})
|
|
63
|
-
virtualPlugin = virtual(await getUserModules())
|
|
62
|
+
})
|
|
64
63
|
],
|
|
64
|
+
customLogger: logger,
|
|
65
65
|
define: { 'process.env': {} },
|
|
66
66
|
resolve: {
|
|
67
67
|
alias: {
|
|
68
68
|
'@': fileURLToPath(new URL('../core', import.meta.url)),
|
|
69
69
|
'^': fileURLToPath(new URL('../widgets', import.meta.url)),
|
|
70
|
+
"user:config": entryPath,
|
|
71
|
+
"user:widgets": internalWidgetsPath
|
|
70
72
|
},
|
|
71
73
|
extensions: ['.js', '.json', '.jsx', '.mjs', '.ts', '.tsx', '.vue'],
|
|
72
74
|
},
|
|
73
75
|
server: {
|
|
74
|
-
|
|
76
|
+
warmup: {
|
|
77
|
+
clientFiles: [path.join(appPath, "core/**")]
|
|
78
|
+
},
|
|
79
|
+
port: userConfig.port ?? 3000,
|
|
80
|
+
open: userConfig.open,
|
|
75
81
|
fs: {
|
|
76
82
|
allow: [searchForWorkspaceRoot(process.cwd())]
|
|
77
83
|
},
|
|
84
|
+
host: userConfig.host
|
|
78
85
|
},
|
|
79
86
|
root: fileURLToPath(new URL('..', import.meta.url)),
|
|
80
87
|
optimizeDeps: mode === "development" ? {
|
|
81
|
-
include: ["webfontloader", "vuetify", "vue", "pinia"],
|
|
88
|
+
include: ["webfontloader", "vuetify", "vue", "pinia", "stac-js", "urijs"],
|
|
82
89
|
noDiscovery: true,
|
|
83
90
|
} : {},
|
|
84
|
-
|
|
91
|
+
/** @type {string|false} */
|
|
92
|
+
publicDir: userConfig.publicDir === false ? false : publicPath,
|
|
85
93
|
build: {
|
|
94
|
+
lib: (mode === 'lib' && command === 'build') && {
|
|
95
|
+
entry: path.join(appPath, "core/asWebComponent.js"),
|
|
96
|
+
fileName: "eo-dash",
|
|
97
|
+
formats: ["es"],
|
|
98
|
+
name: "@eodash/eodash"
|
|
99
|
+
},
|
|
86
100
|
outDir: buildTargetPath,
|
|
87
101
|
emptyOutDir: true,
|
|
88
|
-
rollupOptions: {
|
|
89
|
-
input: fileURLToPath(new URL(
|
|
90
|
-
},
|
|
102
|
+
rollupOptions: command == 'build' ? {
|
|
103
|
+
input: fileURLToPath(new URL(mode === 'lib' ? '../core/asWebComponent.js' : '../index.html', import.meta.url)),
|
|
104
|
+
} : undefined,
|
|
91
105
|
target: "esnext"
|
|
92
106
|
}
|
|
93
107
|
}
|
|
@@ -99,26 +113,42 @@ export const serverConfig = /** @type {import('vite').UserConfigFnPromise}*/(def
|
|
|
99
113
|
* @type {import("vite").ServerHook}
|
|
100
114
|
*/
|
|
101
115
|
async function configureServer(server) {
|
|
102
|
-
server.watcher.add([
|
|
116
|
+
server.watcher.add([entryPath, runtimeConfigPath, path.join(internalWidgetsPath, "**/*.vue")])
|
|
117
|
+
|
|
118
|
+
let updatedPath = ''
|
|
119
|
+
const loggerInfo = logger.info
|
|
120
|
+
logger.info = (msg, options) => {
|
|
121
|
+
if (msg.includes('core')) {
|
|
122
|
+
const removedPath = msg.split('/')[0].split(" ")
|
|
123
|
+
removedPath.pop()
|
|
124
|
+
const updatedMsg = removedPath.join(" ") + " " + updatedPath.replace(rootPath, "")
|
|
125
|
+
|
|
126
|
+
return loggerInfo(updatedMsg, options)
|
|
127
|
+
}
|
|
128
|
+
return loggerInfo(msg, options)
|
|
129
|
+
}
|
|
103
130
|
|
|
104
131
|
server.watcher.on('change', async (path) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
132
|
+
updatedPath = path
|
|
133
|
+
if (path === runtimeConfigPath) {
|
|
134
|
+
server.hot.send({
|
|
135
|
+
type: 'full-reload',
|
|
136
|
+
path: path
|
|
137
|
+
})
|
|
110
138
|
}
|
|
111
139
|
})
|
|
112
140
|
|
|
113
141
|
return () => {
|
|
114
142
|
server.middlewares.use(async (req, res, next) => {
|
|
115
|
-
if (req.originalUrl === '/@fs/config.js'
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
143
|
+
if (req.originalUrl === '/@fs/config.js') {
|
|
144
|
+
res.statusCode = 200
|
|
145
|
+
res.setHeader('Content-Type', 'text/javascript')
|
|
146
|
+
if (existsSync(runtimeConfigPath)) {
|
|
147
|
+
await readFile(runtimeConfigPath).then(runtimeConfig => {
|
|
148
|
+
res.write(runtimeConfig)
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
res.end()
|
|
122
152
|
return
|
|
123
153
|
}
|
|
124
154
|
|
package/bin/types.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extending [Vite's](https://vitejs.dev/) config to configure eodash's server, build and setup.
|
|
3
|
+
* @group CLI
|
|
4
|
+
*/
|
|
5
|
+
export interface EodashConfig {
|
|
6
|
+
dev?: {
|
|
7
|
+
/** serving port */
|
|
8
|
+
port?: string | number
|
|
9
|
+
host?: string | boolean
|
|
10
|
+
/** open default browser when the server starts */
|
|
11
|
+
open?: boolean
|
|
12
|
+
}
|
|
13
|
+
preview?: {
|
|
14
|
+
/** serving port */
|
|
15
|
+
port?: string | number
|
|
16
|
+
host?: string | boolean
|
|
17
|
+
/** open default browser when the server starts */
|
|
18
|
+
open?: boolean
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Base public path
|
|
22
|
+
*/
|
|
23
|
+
base?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Build target folder path
|
|
26
|
+
*/
|
|
27
|
+
outDir?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Path to statically served assets folder, can be set to `false`
|
|
30
|
+
* to disable serving assets statically
|
|
31
|
+
**/
|
|
32
|
+
publicDir?: string | false;
|
|
33
|
+
/**
|
|
34
|
+
* Cache folder
|
|
35
|
+
*/
|
|
36
|
+
cacheDir?: string
|
|
37
|
+
/** Specifies main entry file, exporting `createEodash`*/
|
|
38
|
+
entryPoint?: string
|
|
39
|
+
/**
|
|
40
|
+
* File exporting eodash client runtime config
|
|
41
|
+
*/
|
|
42
|
+
runtime?: string
|
|
43
|
+
widgets?: string
|
|
44
|
+
/** builds eodash as a web component library */
|
|
45
|
+
lib?: boolean
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* helper function that provides intellisense
|
|
49
|
+
* without the need for JSDOC for `eodash.config.js`:
|
|
50
|
+
* @group CLI
|
|
51
|
+
*/
|
|
52
|
+
export declare const definConfig: (config: EodashConfig) => EodashConfig
|
package/bin/utils.js
CHANGED
|
@@ -1,33 +1,103 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { existsSync } from 'fs';
|
|
3
|
+
import { existsSync, readFileSync } from 'fs';
|
|
5
4
|
import path from 'path';
|
|
6
5
|
import { fileURLToPath } from 'url';
|
|
7
|
-
import { searchForWorkspaceRoot } from 'vite';
|
|
6
|
+
import { searchForWorkspaceRoot, createLogger } from 'vite';
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
|
|
9
|
+
export const rootPath = searchForWorkspaceRoot(process.cwd());
|
|
10
|
+
const cli = new Command('eodash')
|
|
11
|
+
|
|
12
|
+
const pkg = JSON.parse(
|
|
13
|
+
readFileSync(
|
|
14
|
+
path.join(rootPath, 'package.json')
|
|
15
|
+
, 'utf-8')
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* CLI flags object
|
|
20
|
+
* @typedef {Object} Options
|
|
21
|
+
* @property {string | false} publicDir
|
|
22
|
+
* @property {string} outDir
|
|
23
|
+
* @property {string} entryPoint
|
|
24
|
+
* @property {string} widgets
|
|
25
|
+
* @property {string} cacheDir
|
|
26
|
+
* @property {string} runtime
|
|
27
|
+
* @property {string} base
|
|
28
|
+
* @property {string | number} port
|
|
29
|
+
* @property {boolean} open
|
|
30
|
+
* @property {boolean | string} host
|
|
31
|
+
* @property {string} config
|
|
32
|
+
* @property {boolean} lib
|
|
33
|
+
*/
|
|
34
|
+
cli.version(pkg.version, '-v, --version', 'output the current version')
|
|
35
|
+
.option('--publicDir <path>', 'path to statically served assets folder')
|
|
36
|
+
.option('--no-publicDir', 'stop serving static assets')
|
|
37
|
+
.option('--outDir <path>', 'minified output folder')
|
|
38
|
+
.option('-e, --entryPoint <path>', 'file exporting `createEodash`')
|
|
39
|
+
.option('-w, --widgets <path>', 'folder that contains vue components as internal widgets')
|
|
40
|
+
.option('--cacheDir <path>', 'cache folder')
|
|
41
|
+
.option('-r, --runtime <path>', 'file exporting eodash client runtime config')
|
|
42
|
+
.option('-b, --base <path>', 'base public path')
|
|
43
|
+
.option('-p, --port <port>', 'serving port')
|
|
44
|
+
.option('-o, --open', 'open default browser when the server starts')
|
|
45
|
+
.option('-c, --config <path>', 'path to eodash server and build configuration file')
|
|
46
|
+
.option('--host [IP address]', 'specify which IP addresses the server should listen on')
|
|
47
|
+
.option('-l, --lib', 'builds eodash as a web component library')
|
|
48
|
+
.option('--no-lib', 'builds eodash as an SPA')
|
|
49
|
+
.option('--no-host', 'do not expose server to the network')
|
|
50
|
+
.parse(process.argv)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
export const userConfig = await getUserConfig(cli.opts(), process.argv?.[2])
|
|
8
54
|
|
|
9
|
-
// global paths
|
|
10
55
|
export const appPath = fileURLToPath(new URL("..", import.meta.url)),
|
|
11
|
-
|
|
12
|
-
rootPath = searchForWorkspaceRoot(process.cwd()),
|
|
13
|
-
rootPublicPath = path.join(rootPath, './public'),
|
|
56
|
+
publicPath = userConfig.publicDir ? path.resolve(rootPath, userConfig.publicDir) : path.join(rootPath, './public'),
|
|
14
57
|
srcPath = path.join(rootPath, "/src"),
|
|
15
|
-
runtimeConfigPath = path.join(srcPath, "./
|
|
16
|
-
|
|
58
|
+
runtimeConfigPath = userConfig.runtime ? path.resolve(rootPath, userConfig.runtime) : path.join(srcPath, "./runtime.js"),
|
|
59
|
+
entryPath = userConfig.entryPoint ? path.resolve(rootPath, userConfig.entryPoint) : path.join(srcPath, "/main.js"),
|
|
60
|
+
internalWidgetsPath = userConfig.widgets ? path.resolve(rootPath, userConfig.widgets) : path.join(srcPath, "widgets"),
|
|
17
61
|
dotEodashPath = path.join(rootPath, "/.eodash"),
|
|
18
|
-
buildTargetPath = path.join(dotEodashPath, '/dist'),
|
|
19
|
-
cachePath = path.join(dotEodashPath, 'cache');
|
|
62
|
+
buildTargetPath = userConfig.outDir ? path.resolve(rootPath, userConfig.outDir) : path.join(dotEodashPath, '/dist'),
|
|
63
|
+
cachePath = userConfig.cacheDir ? path.resolve(rootPath, userConfig.cacheDir) : path.join(dotEodashPath, 'cache');
|
|
64
|
+
|
|
20
65
|
|
|
66
|
+
export const logger = createLogger()
|
|
21
67
|
|
|
68
|
+
/**
|
|
69
|
+
* @param {Options} options
|
|
70
|
+
* @param {string | undefined} command
|
|
71
|
+
*/
|
|
72
|
+
async function getUserConfig(options, command) {
|
|
73
|
+
let eodashCLiConfigFile = options.config ? path.resolve(rootPath, options.config) : path.join(rootPath, 'eodash.config.js');
|
|
74
|
+
/** @type {import("./types").EodashConfig} */
|
|
75
|
+
let config = {};
|
|
76
|
+
if (existsSync(eodashCLiConfigFile)) {
|
|
77
|
+
config = await import(eodashCLiConfigFile).then(config => {
|
|
78
|
+
if (config.default instanceof Function) {
|
|
79
|
+
return config.default()
|
|
80
|
+
} else {
|
|
81
|
+
return config.default
|
|
82
|
+
}
|
|
83
|
+
}).catch(err => {
|
|
84
|
+
console.error(err);
|
|
85
|
+
})
|
|
86
|
+
} else {
|
|
87
|
+
eodashCLiConfigFile = null
|
|
88
|
+
}
|
|
22
89
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
90
|
+
return {
|
|
91
|
+
base: options.base ?? config?.base,
|
|
92
|
+
port: Number(options.port ?? config?.[command]?.port),
|
|
93
|
+
host: options.host ?? config?.[/**@type {"dev"|"preview"} */(command)]?.host,
|
|
94
|
+
open: options.open ?? config?.[/**@type {"dev"|"preview"} */(command)]?.open,
|
|
95
|
+
cacheDir: options.cacheDir ?? config?.cacheDir,
|
|
96
|
+
entryPoint: options.entryPoint ?? config?.entryPoint,
|
|
97
|
+
outDir: options.outDir ?? config?.outDir,
|
|
98
|
+
publicDir: options.publicDir ?? config?.publicDir,
|
|
99
|
+
runtime: options.runtime ?? config?.runtime,
|
|
100
|
+
widgets: options.widgets ?? config?.widgets,
|
|
101
|
+
lib: options.lib ?? config?.lib
|
|
102
|
+
}
|
|
33
103
|
}
|
package/core/App.vue
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<v-app>
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<!-- main content -->
|
|
7
|
-
<component :is="Component"></component>
|
|
3
|
+
<Suspense>
|
|
4
|
+
<!-- main content -->
|
|
5
|
+
<Dashboard />
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
</template>
|
|
13
|
-
</Suspense>
|
|
7
|
+
<!-- loading state -->
|
|
8
|
+
<template #fallback>
|
|
9
|
+
<Loading />
|
|
14
10
|
</template>
|
|
15
|
-
</
|
|
11
|
+
</Suspense>
|
|
16
12
|
</v-app>
|
|
17
13
|
</template>
|
|
18
14
|
|
|
19
15
|
<script setup>
|
|
20
|
-
|
|
16
|
+
import Loading from '@/components/Loading.vue';
|
|
17
|
+
import Dashboard from '@/views/Dashboard.vue';
|
|
18
|
+
|
|
21
19
|
</script>
|
|
@@ -0,0 +1,59 @@
|
|
|
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') === '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
|
+
styleSheet.replaceSync(stylesStr.replaceAll(":root", ":host"))
|
|
57
|
+
eodashComponent?.shadowRoot?.adoptedStyleSheets.push(styleSheet)
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
|
@@ -0,0 +1,12 @@
|
|
|
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()
|