Skip to content

Commit

Permalink
Merge pull request #19 from nakasyou/react-to-solid
Browse files Browse the repository at this point in the history
React to solid
  • Loading branch information
nakasyou authored Feb 5, 2024
2 parents f91353b + 5706890 commit 6f778ba
Show file tree
Hide file tree
Showing 70 changed files with 4,382 additions and 1,238 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/deno.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Setup deno
uses: denoland/setup-deno@v1
- name: Setup Bun
uses: oven-sh/setup-bun@v1
- uses: actions/cache@v3
id: deno_cache
env:
Expand All @@ -23,11 +23,14 @@ jobs:
path: |
node_modules
/home/runner/.cache/deno
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/deno.lock', '**/pnpm-lock.yaml') }}
- name: Test deno cache dir
run: deno info
- name: Build Astro from Deno
run: deno task build
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/deno.lock', '**/bun.lock') }}
- name: Bun Install
run: bun i
- name: Build Astro from Bun
run: bun run build
- run: |
mkdir ./dist/dist
cp -r ./dist/client ./dist/dist/client
- name: Deploy Astro Website
uses: denoland/deployctl@v1
with:
Expand Down
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"semi": false
"semi": false,
"singleQuote": true,
"trailingComma": "none"
}
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"deno.enable": false,
"[astro]": {

"editor.tabSize": 2
},
"[svelte]": {
"editor.tabSize": 2
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
一言で言えば、デジタル赤シートです。
二言で言えば、「じぶん」でつくる、暗記用デジタルノートブックです。
あなたの暗記をサポートします!
3.2.0
## 開発
### Develop using Deno
開発モード:
Expand Down
15 changes: 10 additions & 5 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { defineConfig } from 'astro/config';
import deno from "@astrojs/deno";

import react from "@astrojs/react";
import { defineConfig, squooshImageService, passthroughImageService } from 'astro/config';
import tailwind from "@astrojs/tailwind";
import solidJs from "@astrojs/solid-js";
import svelte from "@astrojs/svelte";
import deno from './integrations/deno';

// https://astro.build/config
export default defineConfig({
output: "server",
adapter: deno(),
integrations: [react(), tailwind()]
integrations: [tailwind({

}), solidJs(), svelte()],
image: {
service: passthroughImageService()
}
});
Binary file modified bun.lockb
Binary file not shown.
2,099 changes: 2,095 additions & 4 deletions deno.lock

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions integrations/deno/const/compatibleNodeModules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// REF: https://github.com/denoland/deno/tree/main/ext/node/polyfills
export const compatibleNodeModules = [
"assert",
"assert/strict",
"async_hooks",
"buffer",
"child_process",
"cluster",
"console",
"constants",
"crypto",
"dgram",
"diagnostics_channel",
"dns",
"events",
"fs",
"fs/promises",
"http",
// 'http2',
"https",
"inspector",
"module",
"net",
"os",
"path",
"path/posix",
"path/win32",
"perf_hooks",
"process",
"punycode",
"querystring",
"readline",
"repl",
"stream",
"stream/promises",
"stream/web",
"string_decoder",
"sys",
"timers",
"timers/promises",
// 'tls',
"trace_events",
"tty",
"url",
"util",
"util/types",
// 'v8',
// 'vm',
// 'wasi',
// 'webcrypto',
"worker_threads",
"zlib",
]
51 changes: 51 additions & 0 deletions integrations/deno/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { type AstroConfig, type AstroIntegration } from "astro"
import { fileURLToPath } from "url"
import { compatibleNodeModules } from "./const/compatibleNodeModules"
import { build } from 'esbuild'

export default (): AstroIntegration => {
let buildConfig: AstroConfig['build']

return {
name: "deno-adapter",
hooks: {
"astro:config:done": ({ setAdapter, config }) => {
buildConfig = config.build
setAdapter({
name: "deno-adapter",
serverEntrypoint: "./integrations/deno/server/server.ts",
supportedAstroFeatures: {
staticOutput: "stable",
serverOutput: "stable",
assets: {

}
},
})
},
"astro:build:done": async () => {
const entryUrl = new URL(buildConfig.serverEntry, buildConfig.server)
const entryPath = fileURLToPath(entryUrl)
await build({
target: "esnext",
platform: 'node',
bundle: true,
allowOverwrite: true,
entryPoints: [entryPath],
outfile: entryPath,
format: "esm",
external: [
...compatibleNodeModules.map((mod) => `node:${mod}`),
"@astrojs/markdown-remark",
],
plugins: [],
minify: false,
alias: {
'hono': 'https://deno.land/x/[email protected]/mod.ts',
...Object.fromEntries(compatibleNodeModules.map(mod => [mod, `node:${mod}`]))
}
})
}
},
}
}
64 changes: 64 additions & 0 deletions integrations/deno/server/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// @ts-check
// @ts-ignore
import { Hono } from 'hono'
import { App } from 'astro/app';
import path from 'node:path'

declare global {
const Deno: {
readFile (path: string): Promise<Uint8Array>
serve (handler: (req: Request) => Promise<Response> | Response): void
}
}

const mimetypeMap: Record<string, string | undefined> = {
'.js': 'text/javascript',
'.html': 'text/html',
'.svg': 'image/svg+xml'
}
export async function start (manifest: import('astro').SSRManifest) {
const app = new App(manifest)

const honoApp = new Hono()
const setAsset = (assetData: {
path: string
filePath: string
}) => {
const ext = path.extname(assetData.path)
const asset = {
path: assetData.path,
extname: ext,
filePath: assetData.filePath,
mimetype: mimetypeMap[ext] || ''
}
honoApp.all(asset.path, async (c) => {
const file = await Deno.readFile(asset.filePath)
const buff = file.buffer as ArrayBuffer

if (asset.mimetype) {
c.header('Content-Type', asset.mimetype)
}
return c.body(buff)
})
}
const indexHtmlRegExp = /^.*\/index\.html$/
const removeIndexHtmlRegExp = /\/index\.html$/
for (const asset of [...manifest.assets]) {
setAsset({
path: asset,
filePath: path.join('dist/client', asset)
})
if (indexHtmlRegExp.test(asset)) {
setAsset({
path: asset.replace(removeIndexHtmlRegExp, ''),
filePath: path.join('dist/client', asset)
})
}
}
honoApp.all('/*', async (c) => {
const res = await app.render(c.req.raw)
return res
})
Deno.serve(honoApp.fetch);
}

40 changes: 24 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,33 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/deno": "^4.3.0",
"@astrojs/react": "^2.2.1",
"@astrojs/tailwind": "^4.0.0",
"@material/material-color-utilities": "^0.2.7",
"@tabler/icons-react": "^2.30.0",
"@astrojs/svelte": "latest",
"@astrojs/tailwind": "5.1.0",
"@astrojs/vercel": "7.0.2",
"@solid-primitives/keyed": "^1.2.0",
"@tabler/icons": "^2.44.0",
"@tabler/icons-solidjs": "^2.36.0",
"@tabler/icons-svelte": "^2.37.0",
"@tailwindcss/typography": "^0.5.9",
"@tiptap/core": "^2.0.4",
"@tiptap/pm": "^2.0.4",
"@tiptap/react": "^2.0.4",
"@tiptap/starter-kit": "^2.0.4",
"@types/react": "^18.0.21",
"@types/react-dom": "^18.0.6",
"@tiptap/core": "^2.2.1",
"@tiptap/pm": "^2.1.11",
"@tiptap/starter-kit": "^2.2.1",
"array-move": "^4.0.0",
"astro": "^2.10.4",
"astro": "4.2.6",
"classnames": "^2.3.2",
"dexie": "^3.2.4",
"fflate": "^0.8.0",
"mikanui": "^0.1.11",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"tailwindcss": "^3.0.24"
"mikanui": "^0.1.12",
"sharp": "0.33.0-alpha.6",
"solid-js": "^1.7.12",
"svelte": "^4.2.1",
"tailwindcss": "^3.0.24",
"valibot": "^0.24.1"
},
"devDependencies": {
"@astrojs/solid-js": "^3.0.1",
"bun-types": "^1.0.7",
"esbuild": "^0.19.5",
"hono": "^3.8.3"
}
}
8 changes: 8 additions & 0 deletions postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
plugins: {
'postcss-import': {},
'tailwindcss/nesting': {},
tailwindcss: {},
autoprefixer: {},
}
}
Binary file added src/assets/home/nanohanote-playing.webp
Binary file not shown.
4 changes: 1 addition & 3 deletions src/components/Footer.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---
import {
IconBrandGithub
} from '@tabler/icons-react'
import IconBrandGithub from '@tabler/icons-svelte/dist/svelte/icons/IconBrandGithub.svelte'
---
<div class="bg-on-surface text-surface">
<div class="mx-5">
Expand Down
5 changes: 3 additions & 2 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
import Icon from "../assets/icon.svg"
import icon from "../assets/icon.svg"
import Image from './Image.astro'
---
<header class="w-full flex top-0 fixed dark:text-white">
<div class="px-7 py-2 flex justify-between items-center w-full">
<div class="flex items-center">
<a href="/" class="flex items-center gap-2">
<img src={ Icon } alt="NanohaNote icon" class="w-10 h-10" />
<Image src={ icon } alt="NanohaNote icon" class="w-10 h-10" />
<div class="text-xl">NanohaNote</div>
</a>
</div>
Expand Down
8 changes: 8 additions & 0 deletions src/components/Image.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
export interface Props {
alt: string
src: ImageMetadata
class?: string
}
---
<img src={Astro.props.src.src} class={Astro.props.class} alt={Astro.props.alt} />
1 change: 1 addition & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />
22 changes: 0 additions & 22 deletions src/islands/camera/index.tsx

This file was deleted.

Loading

0 comments on commit 6f778ba

Please sign in to comment.