From 14ec0f4c05abbb31a9d4957f4e13ae7ea3a53d8b Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Tue, 1 Oct 2024 11:42:25 +0100 Subject: [PATCH] SvelteKit migration: add `type: "module"` https://kit.svelte.dev/docs/migrating Signed-off-by: Jakub Zalas --- src/main/frontend/package-lock.json | 34 ++++---- src/main/frontend/package.json | 3 +- src/main/frontend/src/client.js | 5 -- .../src/components/VersionContainer.svelte | 2 +- src/main/frontend/src/server.js | 2 + src/main/frontend/src/service-worker.js | 82 ------------------- 6 files changed, 22 insertions(+), 106 deletions(-) delete mode 100644 src/main/frontend/src/client.js delete mode 100644 src/main/frontend/src/service-worker.js diff --git a/src/main/frontend/package-lock.json b/src/main/frontend/package-lock.json index 952fb1e4..a63605f5 100644 --- a/src/main/frontend/package-lock.json +++ b/src/main/frontend/package-lock.json @@ -14,7 +14,7 @@ "body-parser": "^1.20.3", "compression": "^1.7.4", "dompurify": "^2.5.7", - "marked": "^4.0.19", + "marked": "^14.1.2", "polka": "^1.0.0-next.28", "sirv": "^1.0.19" }, @@ -2048,9 +2048,9 @@ } }, "node_modules/@types/node": { - "version": "22.7.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.3.tgz", - "integrity": "sha512-qXKfhXXqGTyBskvWEzJZPUxSslAiLaB6JGP1ic/XTH9ctGgzdgYguuLP1C601aRTSDNlLb0jbKqXjZ48GNraSA==", + "version": "22.7.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.4.tgz", + "integrity": "sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==", "dev": true, "license": "MIT", "dependencies": { @@ -2779,9 +2779,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.29", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.29.tgz", - "integrity": "sha512-PF8n2AlIhCKXQ+gTpiJi0VhcHDb69kYX4MtCiivctc2QD3XuNZ/XIOlbGzt7WAjjEev0TtaH6Cu3arZExm5DOw==", + "version": "1.5.30", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.30.tgz", + "integrity": "sha512-sXI35EBN4lYxzc/pIGorlymYNzDBOqkSlVRe6MkgBsW/hW1tpC/HDJ2fjG7XnjakzfLEuvdmux0Mjs6jHq4UOA==", "dev": true, "license": "ISC" }, @@ -3883,15 +3883,15 @@ } }, "node_modules/marked": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/marked/-/marked-4.3.0.tgz", - "integrity": "sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==", + "version": "14.1.2", + "resolved": "https://registry.npmjs.org/marked/-/marked-14.1.2.tgz", + "integrity": "sha512-f3r0yqpz31VXiDB/wj9GaOB0a2PRLQl6vJmXiFrniNwjkKdvakqJRULhjFKJpxOchlCRiG5fcacoUZY5Xa6PEQ==", "license": "MIT", "bin": { "marked": "bin/marked.js" }, "engines": { - "node": ">= 12" + "node": ">= 18" } }, "node_modules/media-typer": { @@ -4748,9 +4748,9 @@ } }, "node_modules/sass": { - "version": "1.79.3", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.79.3.tgz", - "integrity": "sha512-m7dZxh0W9EZ3cw50Me5GOuYm/tVAJAn91SUnohLRo9cXBixGUOdvmryN+dXpwR831bhoY3Zv7rEFt85PUwTmzA==", + "version": "1.79.4", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.79.4.tgz", + "integrity": "sha512-K0QDSNPXgyqO4GZq2HO5Q70TLxTH6cIT59RdoCHMivrC8rqzaTw5ab9prjz9KUN1El4FLXrBXJhik61JR4HcGg==", "dev": true, "license": "MIT", "dependencies": { @@ -5211,9 +5211,9 @@ } }, "node_modules/terser": { - "version": "5.34.0", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.34.0.tgz", - "integrity": "sha512-y5NUX+U9HhVsK/zihZwoq4r9dICLyV2jXGOriDAVOeKhq3LKVjgJbGO90FisozXLlJfvjHqgckGmJFBb9KYoWQ==", + "version": "5.34.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.34.1.tgz", + "integrity": "sha512-FsJZ7iZLd/BXkz+4xrRTGJ26o/6VTjQytUk8b8OxkwcD2I+79VPJlz7qss1+zE7h8GNIScFqXcDyJ/KqBYZFVA==", "dev": true, "license": "BSD-2-Clause", "dependencies": { diff --git a/src/main/frontend/package.json b/src/main/frontend/package.json index 2387c8db..989b8252 100644 --- a/src/main/frontend/package.json +++ b/src/main/frontend/package.json @@ -2,6 +2,7 @@ "name": "vlingo-schemata-ui", "version": "0.1.1", "private": true, + "type": "module", "description": "The UI of the schema registry for the VLINGO XOOM Platform.", "scripts": { "dev": "sapper dev", @@ -16,7 +17,7 @@ "body-parser": "^1.20.3", "compression": "^1.7.4", "dompurify": "^2.5.7", - "marked": "^4.0.19", + "marked": "^14.1.2", "polka": "^1.0.0-next.28", "sirv": "^1.0.19" }, diff --git a/src/main/frontend/src/client.js b/src/main/frontend/src/client.js deleted file mode 100644 index cec91725..00000000 --- a/src/main/frontend/src/client.js +++ /dev/null @@ -1,5 +0,0 @@ -import * as sapper from '@sapper/app'; - -sapper.start({ - target: document.querySelector('#sapper') -}); \ No newline at end of file diff --git a/src/main/frontend/src/components/VersionContainer.svelte b/src/main/frontend/src/components/VersionContainer.svelte index 10db8069..3c8ede1a 100644 --- a/src/main/frontend/src/components/VersionContainer.svelte +++ b/src/main/frontend/src/components/VersionContainer.svelte @@ -5,7 +5,7 @@ import SchemataRepository from '../api/SchemataRepository'; import ButtonBar from '../components/form/ButtonBar.svelte'; import Button from '../components/form/Button.svelte'; - import marked from 'marked'; + import { marked } from 'marked'; import DOMPurify from 'dompurify'; diff --git a/src/main/frontend/src/server.js b/src/main/frontend/src/server.js index cb3fe8c8..c7108bf8 100644 --- a/src/main/frontend/src/server.js +++ b/src/main/frontend/src/server.js @@ -2,6 +2,8 @@ import sirv from 'sirv'; import polka from 'polka'; import compression from 'compression'; import * as sapper from '@sapper/server'; +import { createRequire } from "module"; +const require = createRequire(import.meta.url); const { json } = require('body-parser'); const { createProxyMiddleware } = require('http-proxy-middleware'); diff --git a/src/main/frontend/src/service-worker.js b/src/main/frontend/src/service-worker.js deleted file mode 100644 index 2289a556..00000000 --- a/src/main/frontend/src/service-worker.js +++ /dev/null @@ -1,82 +0,0 @@ -import { timestamp, files, shell, routes } from '@sapper/service-worker'; - -const ASSETS = `cache${timestamp}`; - -// `shell` is an array of all the files generated by the bundler, -// `files` is an array of everything in the `static` directory -const to_cache = shell.concat(files); -const cached = new Set(to_cache); - -self.addEventListener('install', event => { - event.waitUntil( - caches - .open(ASSETS) - .then(cache => cache.addAll(to_cache)) - .then(() => { - self.skipWaiting(); - }) - ); -}); - -self.addEventListener('activate', event => { - event.waitUntil( - caches.keys().then(async keys => { - // delete old caches - for (const key of keys) { - if (key !== ASSETS) await caches.delete(key); - } - - self.clients.claim(); - }) - ); -}); - -self.addEventListener('fetch', event => { - if (event.request.method !== 'GET' || event.request.headers.has('range')) return; - - const url = new URL(event.request.url); - - // don't try to handle e.g. data: URIs - if (!url.protocol.startsWith('http')) return; - - // ignore dev server requests - if (url.hostname === self.location.hostname && url.port !== self.location.port) return; - - // always serve static files and bundler-generated assets from cache - if (url.host === self.location.host && cached.has(url.pathname)) { - event.respondWith(caches.match(event.request)); - return; - } - - // for pages, you might want to serve a shell `service-worker-index.html` file, - // which Sapper has generated for you. It's not right for every - // app, but if it's right for yours then uncomment this section - /* - if (url.origin === self.origin && routes.find(route => route.pattern.test(url.pathname))) { - event.respondWith(caches.match('/service-worker-index.html')); - return; - } - */ - - if (event.request.cache === 'only-if-cached') return; - - // for everything else, try the network first, falling back to - // cache if the user is offline. (If the pages never change, you - // might prefer a cache-first approach to a network-first one.) - event.respondWith( - caches - .open(`offline${timestamp}`) - .then(async cache => { - try { - const response = await fetch(event.request); - cache.put(event.request, response.clone()); - return response; - } catch(err) { - const response = await cache.match(event.request); - if (response) return response; - - throw err; - } - }) - ); -});