From 437e80f3e997771b96f4b0e416ac21680047a228 Mon Sep 17 00:00:00 2001
From: syuilo <4439005+syuilo@users.noreply.github.com>
Date: Fri, 23 Aug 2024 08:07:23 +0900
Subject: [PATCH] wip

---
 .github/workflows/check-spdx-license-id.yml |  1 +
 Dockerfile                                  |  1 +
 package.json                                |  1 +
 packages/embed/package.json                 | 58 +--------------------
 packages/embed/src/boot.ts                  |  2 +-
 pnpm-workspace.yaml                         |  1 +
 scripts/clean-all.js                        |  3 ++
 scripts/clean.js                            |  1 +
 scripts/dev.mjs                             |  6 +++
 9 files changed, 16 insertions(+), 58 deletions(-)

diff --git a/.github/workflows/check-spdx-license-id.yml b/.github/workflows/check-spdx-license-id.yml
index 6cd8bf60d5..341b35664c 100644
--- a/.github/workflows/check-spdx-license-id.yml
+++ b/.github/workflows/check-spdx-license-id.yml
@@ -54,6 +54,7 @@ jobs:
             "packages/frontend/public"
             "packages/frontend/src"
             "packages/frontend/test"
+            "packages/embed/src"
             "packages/misskey-bubble-game/src"
             "packages/misskey-reversi/src"
             "packages/sw/src"
diff --git a/Dockerfile b/Dockerfile
index e247bbcd77..8b02e45770 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -22,6 +22,7 @@ COPY --link ["pnpm-lock.yaml", "pnpm-workspace.yaml", "package.json", "./"]
 COPY --link ["scripts", "./scripts"]
 COPY --link ["packages/backend/package.json", "./packages/backend/"]
 COPY --link ["packages/frontend/package.json", "./packages/frontend/"]
+COPY --link ["packages/embed/package.json", "./packages/embed/"]
 COPY --link ["packages/sw/package.json", "./packages/sw/"]
 COPY --link ["packages/misskey-js/package.json", "./packages/misskey-js/"]
 COPY --link ["packages/misskey-reversi/package.json", "./packages/misskey-reversi/"]
diff --git a/package.json b/package.json
index 310ea98214..2f337d36e2 100644
--- a/package.json
+++ b/package.json
@@ -9,6 +9,7 @@
 	"packageManager": "pnpm@9.6.0",
 	"workspaces": [
 		"packages/frontend",
+		"packages/embed",
 		"packages/backend",
 		"packages/sw",
 		"packages/misskey-js",
diff --git a/packages/embed/package.json b/packages/embed/package.json
index dad545a9c2..df7a403961 100644
--- a/packages/embed/package.json
+++ b/packages/embed/package.json
@@ -6,12 +6,6 @@
 		"watch": "vite",
 		"dev": "vite --config vite.config.local-dev.ts --debug hmr",
 		"build": "vite build",
-		"storybook-dev": "nodemon --verbose --watch src --ext \"mdx,ts,vue\" --ignore \"*.stories.ts\" --exec \"pnpm build-storybook-pre && pnpm exec storybook dev -p 6006 --ci\"",
-		"build-storybook-pre": "(tsc -p .storybook || echo done.) && node .storybook/generate.js && node .storybook/preload-locale.js && node .storybook/preload-theme.js",
-		"build-storybook": "pnpm build-storybook-pre && storybook build --webpack-stats-json storybook-static",
-		"chromatic": "chromatic",
-		"test": "vitest --run --globals",
-		"test-and-coverage": "vitest --run --coverage --globals",
 		"typecheck": "vue-tsc --noEmit",
 		"eslint": "eslint --quiet \"src/**/*.{ts,vue}\"",
 		"lint": "pnpm typecheck && pnpm eslint"
@@ -19,91 +13,50 @@
 	"dependencies": {
 		"@discordapp/twemoji": "15.0.3",
 		"@github/webauthn-json": "2.1.1",
-		"@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
-		"@misskey-dev/browser-image-resizer": "2024.1.0",
 		"@rollup/plugin-json": "6.1.0",
 		"@rollup/plugin-replace": "5.0.7",
 		"@rollup/pluginutils": "5.1.0",
-		"@syuilo/aiscript": "0.19.0",
 		"@tabler/icons-webfont": "3.3.0",
 		"@twemoji/parser": "15.1.1",
 		"@vitejs/plugin-vue": "5.1.0",
 		"@vue/compiler-sfc": "3.4.37",
 		"aiscript-vscode": "github:aiscript-dev/aiscript-vscode#v0.1.11",
 		"astring": "1.8.6",
-		"broadcast-channel": "7.0.0",
 		"buraha": "0.0.1",
-		"canvas-confetti": "1.9.3",
-		"chart.js": "4.4.3",
-		"chartjs-adapter-date-fns": "3.0.0",
-		"chartjs-chart-matrix": "2.0.1",
-		"chartjs-plugin-gradient": "0.6.1",
-		"chartjs-plugin-zoom": "2.0.1",
-		"chromatic": "11.5.6",
 		"compare-versions": "6.1.1",
-		"cropperjs": "2.0.0-rc.1",
 		"date-fns": "2.30.0",
 		"escape-regexp": "0.0.1",
 		"estree-walker": "3.0.3",
 		"eventemitter3": "5.0.1",
 		"idb-keyval": "6.2.1",
-		"insert-text-at-cursor": "0.3.0",
 		"is-file-animated": "1.0.2",
 		"json5": "2.2.3",
-		"matter-js": "0.19.0",
 		"mfm-js": "0.24.0",
-		"misskey-bubble-game": "workspace:*",
 		"misskey-js": "workspace:*",
-		"misskey-reversi": "workspace:*",
-		"photoswipe": "5.4.4",
 		"punycode": "2.3.1",
 		"rollup": "4.19.1",
 		"sanitize-html": "2.13.0",
 		"sass": "1.77.8",
 		"shiki": "1.12.0",
 		"strict-event-emitter-types": "2.0.0",
-		"textarea-caret": "3.1.0",
-		"three": "0.167.0",
 		"throttle-debounce": "5.0.2",
 		"tinycolor2": "1.6.0",
 		"tsc-alias": "1.8.10",
 		"tsconfig-paths": "4.2.0",
 		"typescript": "5.5.4",
 		"uuid": "10.0.0",
-		"v-code-diff": "1.12.0",
 		"vite": "5.3.5",
-		"vue": "3.4.37",
-		"vuedraggable": "next"
+		"vue": "3.4.37"
 	},
 	"devDependencies": {
 		"@misskey-dev/summaly": "5.1.0",
-		"@storybook/addon-actions": "8.2.6",
-		"@storybook/addon-essentials": "8.2.6",
-		"@storybook/addon-interactions": "8.2.6",
-		"@storybook/addon-links": "8.2.6",
-		"@storybook/addon-mdx-gfm": "8.2.6",
-		"@storybook/addon-storysource": "8.2.6",
-		"@storybook/blocks": "8.2.6",
-		"@storybook/components": "8.2.6",
-		"@storybook/core-events": "8.2.6",
-		"@storybook/manager-api": "8.2.6",
-		"@storybook/preview-api": "8.2.6",
-		"@storybook/react": "8.2.6",
-		"@storybook/react-vite": "8.2.6",
-		"@storybook/test": "8.2.6",
-		"@storybook/theming": "8.2.6",
-		"@storybook/types": "8.2.6",
-		"@storybook/vue3": "8.2.6",
-		"@storybook/vue3-vite": "8.1.11",
 		"@testing-library/vue": "8.1.0",
 		"@types/escape-regexp": "0.0.3",
 		"@types/estree": "1.0.5",
-		"@types/matter-js": "0.19.7",
 		"@types/micromatch": "4.0.9",
 		"@types/node": "20.14.12",
 		"@types/punycode": "2.1.4",
 		"@types/sanitize-html": "2.11.0",
-		"@types/seedrandom": "3.0.8",
 		"@types/throttle-debounce": "5.0.2",
 		"@types/tinycolor2": "1.4.6",
 		"@types/uuid": "10.0.0",
@@ -114,7 +67,6 @@
 		"@vue/runtime-core": "3.4.37",
 		"acorn": "8.12.1",
 		"cross-env": "7.0.3",
-		"cypress": "13.13.1",
 		"eslint-plugin-import": "2.29.1",
 		"eslint-plugin-vue": "9.27.0",
 		"fast-glob": "3.3.2",
@@ -122,18 +74,10 @@
 		"intersection-observer": "0.12.2",
 		"micromatch": "4.0.7",
 		"msw": "2.3.4",
-		"msw-storybook-addon": "2.0.3",
 		"nodemon": "3.1.4",
 		"prettier": "3.3.3",
-		"react": "18.3.1",
-		"react-dom": "18.3.1",
-		"seedrandom": "3.0.5",
 		"start-server-and-test": "2.0.4",
-		"storybook": "8.2.6",
-		"storybook-addon-misskey-theme": "github:misskey-dev/storybook-addon-misskey-theme",
 		"vite-plugin-turbosnap": "1.0.3",
-		"vitest": "1.6.0",
-		"vitest-fetch-mock": "0.2.2",
 		"vue-component-type-helpers": "2.0.29",
 		"vue-eslint-parser": "9.4.3",
 		"vue-tsc": "2.0.29"
diff --git a/packages/embed/src/boot.ts b/packages/embed/src/boot.ts
index f8d6ea42a7..f1a12336cc 100644
--- a/packages/embed/src/boot.ts
+++ b/packages/embed/src/boot.ts
@@ -9,7 +9,7 @@ import 'vite/modulepreload-polyfill';
 import '@/style.scss';
 import { createApp, defineAsyncComponent } from 'vue';
 import { setIframeId, postMessageToParentWindow } from '@/scripts/post-message.js';
-import { parseEmbedParams } from '@/scripts/embed-page.js';
+import { parseEmbedParams } from '@/embed-page.js';
 import { createEmbedRouter } from '@/router.js';
 
 const params = new URLSearchParams(location.search);
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 193669e7a4..29517ed6cf 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -1,6 +1,7 @@
 packages:
  - 'packages/backend'
  - 'packages/frontend'
+ - 'packages/embed'
  - 'packages/sw'
  - 'packages/misskey-js'
  - 'packages/misskey-js/generator'
diff --git a/scripts/clean-all.js b/scripts/clean-all.js
index e9512e2d5a..ddb331837f 100644
--- a/scripts/clean-all.js
+++ b/scripts/clean-all.js
@@ -13,6 +13,9 @@ const fs = require('fs');
 	fs.rmSync(__dirname + '/../packages/frontend/built', { recursive: true, force: true });
 	fs.rmSync(__dirname + '/../packages/frontend/node_modules', { recursive: true, force: true });
 
+	fs.rmSync(__dirname + '/../packages/embed/built', { recursive: true, force: true });
+	fs.rmSync(__dirname + '/../packages/embed/node_modules', { recursive: true, force: true });
+
 	fs.rmSync(__dirname + '/../packages/sw/built', { recursive: true, force: true });
 	fs.rmSync(__dirname + '/../packages/sw/node_modules', { recursive: true, force: true });
 
diff --git a/scripts/clean.js b/scripts/clean.js
index af66c24a8f..6fd416fe2d 100644
--- a/scripts/clean.js
+++ b/scripts/clean.js
@@ -8,6 +8,7 @@ const fs = require('fs');
 (async () => {
 	fs.rmSync(__dirname + '/../packages/backend/built', { recursive: true, force: true });
 	fs.rmSync(__dirname + '/../packages/frontend/built', { recursive: true, force: true });
+	fs.rmSync(__dirname + '/../packages/embed/built', { recursive: true, force: true });
 	fs.rmSync(__dirname + '/../packages/sw/built', { recursive: true, force: true });
 	fs.rmSync(__dirname + '/../packages/misskey-js/built', { recursive: true, force: true });
 	fs.rmSync(__dirname + '/../packages/misskey-reversi/built', { recursive: true, force: true });
diff --git a/scripts/dev.mjs b/scripts/dev.mjs
index bbb2547758..be14903a29 100644
--- a/scripts/dev.mjs
+++ b/scripts/dev.mjs
@@ -71,6 +71,12 @@ execa('pnpm', ['--filter', 'frontend', process.env.MK_DEV_PREFER === 'backend' ?
 	stderr: process.stderr,
 });
 
+execa('pnpm', ['--filter', 'embed', process.env.MK_DEV_PREFER === 'backend' ? 'watch' : 'dev'], {
+	cwd: _dirname + '/../',
+	stdout: process.stdout,
+	stderr: process.stderr,
+});
+
 execa('pnpm', ['--filter', 'sw', 'watch'], {
 	cwd: _dirname + '/../',
 	stdout: process.stdout,