@eclipse-docks/create-app 0.7.76 → 0.7.79
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/index.js +9 -0
- package/package.json +1 -1
- package/template/README.md +4 -0
- package/template/packages/app/env.d.ts +2 -0
- package/template/packages/app/package.json +3 -1
- package/template/packages/app/src/extensions.ts +4 -1
- package/template/packages/app/src/main.ts +1 -0
- package/template/packages/app/src/sw.ts +50 -0
- package/template/packages/app/tsconfig.json +2 -1
- package/template/packages/app/vite.config.ts +52 -8
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ From the created project root, `npm run dev` runs the app (Vite). Use `npm run b
|
|
|
52
52
|
## What you get
|
|
53
53
|
|
|
54
54
|
- A **monorepo** with two workspace packages:
|
|
55
|
-
- **`packages/app`** – the Docks app (Vite, core + extensions from npm).
|
|
55
|
+
- **`packages/app`** – the Docks app (Vite, core + extensions from npm), including **PWA** (web app manifest, injectManifest service worker, `@eclipse-docks/extension-pwa` for install/update in the toolbar).
|
|
56
56
|
- **`packages/example-extension`** – a minimal example extension you can copy or extend.
|
|
57
57
|
- The app registers a **logo contribution** on the left main toolbar (slot `start`) with the text `my!app`; you can change it in `packages/app/src/main.ts`.
|
|
58
58
|
- The example extension is loaded by the app and adds an "Example" view in the left side panel.
|
package/index.js
CHANGED
|
@@ -54,6 +54,15 @@ function main() {
|
|
|
54
54
|
mainTs = mainTs.replace(/\{\{APP_NAME\}\}/g, appName);
|
|
55
55
|
writeFileSync(mainTsPath, mainTs);
|
|
56
56
|
|
|
57
|
+
function escapeForSingleQuotedTs(s) {
|
|
58
|
+
return s.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
|
|
59
|
+
}
|
|
60
|
+
const viteConfigPath = join(targetDir, 'packages', 'app', 'vite.config.ts');
|
|
61
|
+
let viteConfig = readFileSync(viteConfigPath, 'utf8');
|
|
62
|
+
viteConfig = viteConfig.replace(/\{\{APP_NAME\}\}/g, escapeForSingleQuotedTs(appName));
|
|
63
|
+
viteConfig = viteConfig.replace(/\{\{APP_DESCRIPTION\}\}/g, escapeForSingleQuotedTs(appDescription));
|
|
64
|
+
writeFileSync(viteConfigPath, viteConfig);
|
|
65
|
+
|
|
57
66
|
const logoSvgPath = join(targetDir, 'packages', 'app', 'public', 'logo.svg');
|
|
58
67
|
let logoSvg = readFileSync(logoSvgPath, 'utf8');
|
|
59
68
|
logoSvg = logoSvg.replace(/\{\{APP_NAME\}\}/g, appName);
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -20,3 +20,7 @@ Then open the URL shown in the terminal (e.g. https://localhost:5173/).
|
|
|
20
20
|
|
|
21
21
|
- **packages/app** – The Docks app (entry point, extensions, UI)
|
|
22
22
|
- **packages/example-extension** – Example extension; use it as a reference to add your own
|
|
23
|
+
|
|
24
|
+
## PWA
|
|
25
|
+
|
|
26
|
+
The app is set up with **vite-plugin-pwa** (injectManifest), a **service worker** at `packages/app/src/sw.ts`, and **`@eclipse-docks/extension-pwa`** for install / update controls in the bottom toolbar. Production `npm run build` emits the web app manifest and precached assets. To opt out, remove the PWA extension from `packages/app/src/main.ts` and `extensions.ts`, delete `src/sw.ts`, and strip the `VitePWA(...)` block from `packages/app/vite.config.ts`.
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@eclipse-docks/extension-media-viewer": "^0.x",
|
|
19
19
|
"@eclipse-docks/extension-memory-usage": "^0.x",
|
|
20
20
|
"@eclipse-docks/extension-monaco-editor": "^0.x",
|
|
21
|
+
"@eclipse-docks/extension-pwa": "^0.x",
|
|
21
22
|
"@eclipse-docks/extension-notebook": "^0.x",
|
|
22
23
|
"@eclipse-docks/extension-python-runtime": "^0.x",
|
|
23
24
|
"@eclipse-docks/extension-settings-tree": "^0.x",
|
|
@@ -28,7 +29,8 @@
|
|
|
28
29
|
"typescript": "^6.0.0",
|
|
29
30
|
"vite": "^8.0.0",
|
|
30
31
|
"vite-plugin-cross-origin-isolation": "^0.1.6",
|
|
31
|
-
"vite-plugin-mkcert": "^1.17.9"
|
|
32
|
+
"vite-plugin-mkcert": "^1.17.9",
|
|
33
|
+
"vite-plugin-pwa": "^1.2.0"
|
|
32
34
|
},
|
|
33
35
|
"marketplace": {
|
|
34
36
|
"catalogUrls": [
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Explicit imports of workspace extensions so they are included in the bundle.
|
|
3
|
-
* Replaces import.meta.glob('../../extension
|
|
3
|
+
* Replaces import.meta.glob('../../extension-xxx/src/index.ts') to avoid .ts paths
|
|
4
4
|
* in module URLs (servers often map .ts to video/mp2t MIME type).
|
|
5
5
|
* Add or remove imports when you add or remove extensions from the app config.
|
|
6
|
+
*
|
|
7
|
+
* PWA is imported first so `beforeinstallprompt` can be captured early (see extension-pwa).
|
|
6
8
|
*/
|
|
9
|
+
import '@eclipse-docks/extension-pwa';
|
|
7
10
|
import '@eclipse-docks/extension-ai-system';
|
|
8
11
|
import '@eclipse-docks/extension-command-palette';
|
|
9
12
|
import '@eclipse-docks/extension-catalog';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/// <reference lib="webworker" />
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
addPlugins,
|
|
5
|
+
cleanupOutdatedCaches,
|
|
6
|
+
createHandlerBoundToURL,
|
|
7
|
+
precacheAndRoute,
|
|
8
|
+
} from 'workbox-precaching';
|
|
9
|
+
import { NavigationRoute, registerRoute } from 'workbox-routing';
|
|
10
|
+
|
|
11
|
+
declare const self: ServiceWorkerGlobalScope;
|
|
12
|
+
|
|
13
|
+
function withCoopCoep(response: Response): Response {
|
|
14
|
+
if (response.status === 0 || response.type === 'opaque' || response.type === 'opaqueredirect') {
|
|
15
|
+
return response;
|
|
16
|
+
}
|
|
17
|
+
const headers = new Headers(response.headers);
|
|
18
|
+
headers.set('Cross-Origin-Opener-Policy', 'same-origin');
|
|
19
|
+
headers.set('Cross-Origin-Embedder-Policy', 'require-corp');
|
|
20
|
+
return new Response(response.body, {
|
|
21
|
+
status: response.status,
|
|
22
|
+
statusText: response.statusText,
|
|
23
|
+
headers,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
cleanupOutdatedCaches();
|
|
28
|
+
|
|
29
|
+
addPlugins([
|
|
30
|
+
{
|
|
31
|
+
cachedResponseWillBeUsed: async ({ cachedResponse }) =>
|
|
32
|
+
cachedResponse ? withCoopCoep(cachedResponse) : cachedResponse,
|
|
33
|
+
fetchDidSucceed: async ({ response }) => withCoopCoep(response),
|
|
34
|
+
},
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
precacheAndRoute(self.__WB_MANIFEST);
|
|
38
|
+
|
|
39
|
+
const indexUrl = new URL('index.html', self.registration.scope).href;
|
|
40
|
+
registerRoute(new NavigationRoute(createHandlerBoundToURL(indexUrl)));
|
|
41
|
+
|
|
42
|
+
self.addEventListener('message', (event) => {
|
|
43
|
+
if (event.data?.type === 'SKIP_WAITING') {
|
|
44
|
+
void self.skipWaiting();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
self.addEventListener('activate', (event) => {
|
|
49
|
+
event.waitUntil(self.clients.claim());
|
|
50
|
+
});
|
|
@@ -1,27 +1,71 @@
|
|
|
1
|
+
import path, { dirname } from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
1
3
|
import { defineConfig } from 'vite';
|
|
2
|
-
import mkcert from 'vite-plugin-mkcert';
|
|
3
4
|
import crossOriginIsolation from 'vite-plugin-cross-origin-isolation';
|
|
5
|
+
import mkcert from 'vite-plugin-mkcert';
|
|
6
|
+
import { VitePWA } from 'vite-plugin-pwa';
|
|
4
7
|
import { resolveDepVersionsPlugin } from '@eclipse-docks/core/vite-plugin-resolve-deps';
|
|
5
8
|
import { localAliasesPlugin } from '@eclipse-docks/core/vite-plugin-local-aliases';
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
8
9
|
|
|
9
|
-
const __dirname =
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const basePath = process.env.VITE_BASE_PATH || '/';
|
|
10
12
|
|
|
11
13
|
export default defineConfig({
|
|
12
14
|
root: __dirname,
|
|
13
|
-
base:
|
|
15
|
+
base: basePath,
|
|
14
16
|
resolve: {},
|
|
17
|
+
server: {
|
|
18
|
+
watch: {
|
|
19
|
+
ignored: ['**/node_modules/**', '**/dist/**'],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
15
22
|
plugins: [
|
|
16
23
|
resolveDepVersionsPlugin(),
|
|
17
24
|
localAliasesPlugin({
|
|
18
25
|
useSrcInDev: true,
|
|
19
|
-
patterns: [
|
|
20
|
-
{ folderPrefix: 'extension-' },
|
|
21
|
-
],
|
|
26
|
+
patterns: [{ folderPrefix: 'extension-' }],
|
|
22
27
|
}),
|
|
23
28
|
mkcert(),
|
|
24
29
|
crossOriginIsolation(),
|
|
30
|
+
VitePWA({
|
|
31
|
+
registerType: 'autoUpdate',
|
|
32
|
+
injectRegister: 'inline',
|
|
33
|
+
strategies: 'injectManifest',
|
|
34
|
+
srcDir: 'src',
|
|
35
|
+
filename: 'sw.ts',
|
|
36
|
+
manifest: {
|
|
37
|
+
name: '{{APP_NAME}}',
|
|
38
|
+
short_name: '{{APP_NAME}}',
|
|
39
|
+
description: '{{APP_DESCRIPTION}}',
|
|
40
|
+
theme_color: '#1a1a1a',
|
|
41
|
+
background_color: '#1a1a1a',
|
|
42
|
+
display: 'standalone',
|
|
43
|
+
start_url: basePath,
|
|
44
|
+
scope: basePath,
|
|
45
|
+
icons: [
|
|
46
|
+
{
|
|
47
|
+
src: 'logo.svg',
|
|
48
|
+
sizes: 'any',
|
|
49
|
+
type: 'image/svg+xml',
|
|
50
|
+
purpose: 'any',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
src: 'favicon.svg',
|
|
54
|
+
sizes: 'any',
|
|
55
|
+
type: 'image/svg+xml',
|
|
56
|
+
purpose: 'monochrome',
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
includeAssets: ['favicon.svg', 'logo.svg', 'logo-loading.svg'],
|
|
61
|
+
injectManifest: {
|
|
62
|
+
maximumFileSizeToCacheInBytes: 12 * 1024 * 1024,
|
|
63
|
+
globPatterns: ['**/*.{js,css,html,ico,png,svg,webp,woff2,woff,ttf,wasm}'],
|
|
64
|
+
},
|
|
65
|
+
devOptions: {
|
|
66
|
+
enabled: false,
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
25
69
|
],
|
|
26
70
|
worker: {
|
|
27
71
|
format: 'es',
|