diff --git a/package.json b/package.json index b5ddc66..5b823fa 100644 --- a/package.json +++ b/package.json @@ -13,18 +13,17 @@ "author": "Uglyboy", "license": "MIT", "devDependencies": { - "@sveltejs/vite-plugin-svelte": "^7.0.0", "@tsconfig/bun": "^1.0.0", - "@tsconfig/svelte": "^5.0.0", "@types/mustache": "^4.2.0", "esbuild": "^0.28.0", - "svelte": "^5.0.0", - "vite": "^8.0.0" + "solid-js": "^1.9.12", + "vite": "^8.0.0", + "vite-plugin-solid": "^2.11.12" }, "dependencies": { - "@inkweave/core": "^2.0.4", - "@inkweave/plugins": "^2.0.4", - "@inkweave/svelte": "^2.0.4", + "@inkweave/core": "^2.3.1", + "@inkweave/plugins": "^2.3.1", + "@inkweave/solidjs": "^2.3.1", "zustand": "^5.0.0", "mustache": "^4.2.0" }, diff --git a/src/App.svelte b/src/App.svelte deleted file mode 100644 index a40dfa2..0000000 --- a/src/App.svelte +++ /dev/null @@ -1,24 +0,0 @@ - - -
- - - - -
diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 0000000..2038b20 --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,26 @@ +import type { InkStory } from "@inkweave/core"; +import { Image } from "@inkweave/plugins/solidjs"; +import { CommandBar, Story } from "@inkweave/solidjs"; +import { t } from "./locales/i18n"; + +const App = (props: { ink: InkStory }) => { + return ( +
+ + + + +
+ ); +}; + +export default App; diff --git a/src/utils/__tests__/plugins.test.ts b/src/utils/__tests__/plugins.test.ts index e5d2f43..6230d75 100644 --- a/src/utils/__tests__/plugins.test.ts +++ b/src/utils/__tests__/plugins.test.ts @@ -1,6 +1,38 @@ import { afterAll, describe, expect, it } from "bun:test"; +import type { Plugin } from "@inkweave/core"; import { PluginRegistry } from "@inkweave/core"; -import { plugins } from "../plugins"; + +// Stub plugins matching the obsidian plugin list (no SolidJS imports needed) +const plugins: Plugin[] = [ + { id: "audio", name: "Audio", enabledByDefault: true, onLoad: () => {} }, + { id: "auto-button", name: "Auto Button", enabledByDefault: true, onLoad: () => {} }, + { + id: "auto-restore", + name: "Auto Restore", + enabledByDefault: true, + onLoad: () => {}, + dependencies: ["memory"], + }, + { + id: "auto-save", + name: "Auto Save", + enabledByDefault: true, + onLoad: () => {}, + dependencies: ["memory"], + }, + { id: "cd-button", name: "CD Button", enabledByDefault: true, onLoad: () => {} }, + { id: "class-tag", name: "Class Tag", enabledByDefault: true, onLoad: () => {} }, + { id: "fade-effect", name: "Fade Effect", enabledByDefault: true, onLoad: () => {} }, + { id: "image", name: "Image", enabledByDefault: true, onLoad: () => {} }, + { id: "link-open", name: "Link Open", enabledByDefault: true, onLoad: () => {} }, + { id: "memory", name: "Memory", enabledByDefault: true, onLoad: () => {} }, + { + id: "scroll-after-choice", + name: "Scroll After Choice", + enabledByDefault: true, + onLoad: () => {}, + }, +]; for (const p of plugins) { PluginRegistry.register(p); diff --git a/src/utils/plugins.ts b/src/utils/plugins.ts index 7ea67d4..b9b74c9 100644 --- a/src/utils/plugins.ts +++ b/src/utils/plugins.ts @@ -11,7 +11,7 @@ import { linkOpenPlugin, memoryPlugin, scrollAfterChoicePlugin, -} from "@inkweave/plugins/svelte"; +} from "@inkweave/plugins/solidjs"; export const plugins: Plugin[] = [ audioPlugin, diff --git a/src/view.ts b/src/view.ts index 1adf781..036b337 100644 --- a/src/view.ts +++ b/src/view.ts @@ -1,18 +1,18 @@ -import "@inkweave/svelte/svelte.css"; -import "@inkweave/plugins/plugins.css"; +import "@inkweave/solidjs/solidjs.css"; +import "@inkweave/plugins/solidjs.css"; import "./styles/styles.custom.css"; import type { InkStory } from "@inkweave/core"; import { type EventRef, ItemView, type MarkdownView, TFile, type ViewStateResult } from "obsidian"; -import { mount, unmount } from "svelte"; -import App from "./App.svelte"; +import { render } from "solid-js/web"; +import App from "./App"; import { compile } from "./utils/compile"; import { default as useFile } from "./utils/file"; export const VIEW_TYPE = "InkWeave Story View"; export class StoryView extends ItemView { - appInstance: Record | null = null; + appInstance: (() => void) | null = null; ink: InkStory | null = null; private watcher: EventRef | null = null; @@ -54,14 +54,13 @@ export class StoryView extends ItemView { if (!container) return; if (this.appInstance) { - unmount(this.appInstance); + this.appInstance(); + this.appInstance = null; } if (this.ink) { - this.appInstance = mount(App, { - target: container as HTMLElement, - props: { ink: this.ink }, - }); + const ink = this.ink; + this.appInstance = render(() => App({ ink }), container as HTMLElement); } } @@ -117,7 +116,7 @@ export class StoryView extends ItemView { } this.ink?.dispose(); if (this.appInstance) { - unmount(this.appInstance); + this.appInstance(); this.appInstance = null; } } diff --git a/tsconfig.json b/tsconfig.json index ef63caa..a748323 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,11 @@ { "$schema": "https://www.schemastore.org/tsconfig", - "extends": ["@tsconfig/bun/tsconfig.json", "@tsconfig/svelte/tsconfig.json"], + "extends": ["@tsconfig/bun/tsconfig.json"], "compilerOptions": { - "types": ["bun-types"] + "jsx": "preserve", + "jsxImportSource": "solid-js", + "lib": ["ESNext", "DOM"], + "types": ["bun-types", "vite/client"] }, "include": ["src", "package.json"], "exclude": ["dist"] diff --git a/vite.config.ts b/vite.config.ts index fb43a09..25892d7 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,7 @@ import { builtinModules } from "node:module"; import { resolve } from "node:path"; import { defineConfig } from "vite"; -import { svelte } from "@sveltejs/vite-plugin-svelte"; +import solid from "vite-plugin-solid"; export default defineConfig(({ mode }) => ({ define: { @@ -32,5 +32,5 @@ export default defineConfig(({ mode }) => ({ cssMinify: "esbuild", emptyOutDir: true, }, - plugins: [svelte()], + plugins: [solid()], }));