Jannick Knudsen há 1 ano atrás
pai
commit
6d55faaad8

+ 1 - 0
epic-stack

@@ -0,0 +1 @@
+Subproject commit c15d899d714a7006f3a327330514075d421f3d4f

+ 6 - 0
my-desktop-app/.gitignore

@@ -0,0 +1,6 @@
+node_modules
+.cache
+build
+public/build
+dist
+.env

+ 4 - 0
my-desktop-app/.npmrc

@@ -0,0 +1,4 @@
+# this is needed if using pnpm with electron builder,
+# as electron builder needs to copy _all_ node modules,
+# and pnpm doesn't normally make them all available
+shamefully-hoist = true

+ 35 - 0
my-desktop-app/README.md

@@ -0,0 +1,35 @@
+# remix-electron-template
+
+Welcome to your new remix-electron project!
+
+- [remix-electron docs](https://github.com/itsMapleLeaf/remix-electron)
+- [Remix docs](https://remix.run/docs)
+
+## Getting Started
+
+1. To install our app's dependencies, run the following command:
+
+   ```sh
+   npm install
+   ```
+
+1. To start the app in development mode, run the dev script:
+
+   ```sh
+   npm run dev
+   ```
+
+## Scripts
+
+The following scripts are defined in the `package.json` file:
+
+- `prepare`: This sets up remix dependencies after an install. Don't remove this!
+- `dev`: Starts the app with hot reloading. Uses nodemon to restart the app when main process files change.
+- `build`: Builds the app for production. Uses [Electron Builder](https://www.electron.build/) to create a distributable package.
+- `start`: Starts the app in production mode. Make sure you ran `build` first.
+
+## Debugging in VSCode
+
+See this guide: https://gist.github.com/kiliman/a9d7c874af03369a1d105a92560d89e9
+
+Choose the `dev` script to debug in dev, and `start` to debug in production.

+ 2 - 0
my-desktop-app/app/electron.server.ts

@@ -0,0 +1,2 @@
+import electron from "electron"
+export default electron

+ 33 - 0
my-desktop-app/app/root.tsx

@@ -0,0 +1,33 @@
+import type { LinksFunction, MetaFunction } from "@remix-run/node"
+import {
+	Links,
+	LiveReload,
+	Meta,
+	Outlet,
+	Scripts,
+	ScrollRestoration,
+} from "@remix-run/react"
+import styles from "./styles.css"
+
+export const meta: MetaFunction = () => [{ title: "New Remix App" }]
+
+export const links: LinksFunction = () => [{ rel: "stylesheet", href: styles }]
+
+export default function App() {
+	return (
+		<html lang="en">
+			<head>
+				<meta charSet="utf8" />
+				<meta name="viewport" content="width=device-width,initial-scale=1" />
+				<Meta />
+				<Links />
+			</head>
+			<body>
+				<Outlet />
+				<ScrollRestoration />
+				<Scripts />
+				<LiveReload />
+			</body>
+		</html>
+	)
+}

+ 20 - 0
my-desktop-app/app/routes/_index.tsx

@@ -0,0 +1,20 @@
+import { useLoaderData } from "@remix-run/react"
+import electron from "~/electron.server"
+
+export function loader() {
+	return {
+		userDataPath: electron.app.getPath("userData"),
+	}
+}
+
+export default function Index() {
+	const data = useLoaderData<typeof loader>()
+	return (
+		<main>eee
+			<h1>Welcome to Remix sdfsfsd</h1>
+			<p>User data path: {data.userDataPath}</p>
+			
+
+		</main>
+	)
+}

+ 7 - 0
my-desktop-app/app/styles.css

@@ -0,0 +1,7 @@
+* {
+	box-sizing: border-box;
+}
+
+:root {
+	font-family: sans-serif;
+}

+ 45 - 0
my-desktop-app/desktop/index.js

@@ -0,0 +1,45 @@
+const { initRemix } = require("remix-electron")
+const { app, BrowserWindow, dialog } = require("electron")
+const path = require("node:path")
+
+/** @type {BrowserWindow | undefined} */
+let win
+
+/** @param {string} url */
+async function createWindow(url) {
+	win = new BrowserWindow({ show: false })
+	await win.loadURL(url)
+	win.show()
+
+	if (process.env.NODE_ENV === "development") {
+		win.webContents.openDevTools()
+	}
+}
+
+app.on("ready", () => {
+	void (async () => {
+		try {
+			if (process.env.NODE_ENV === "development") {
+				const {
+					default: installExtension,
+					REACT_DEVELOPER_TOOLS,
+				} = require("electron-devtools-installer")
+
+				await installExtension(REACT_DEVELOPER_TOOLS)
+			}
+
+			const url = await initRemix({
+				serverBuild: path.join(__dirname, "../build/index.js"),
+			})
+			await createWindow(url)
+		} catch (error) {
+			dialog.showErrorBox("Error", getErrorStack(error))
+			console.error(error)
+		}
+	})()
+})
+
+/** @param {unknown} error */
+function getErrorStack(error) {
+	return error instanceof Error ? error.stack || error.message : String(error)
+}

+ 6 - 0
my-desktop-app/nodemon.json

@@ -0,0 +1,6 @@
+{
+	"$schema": "https://json.schemastore.org/nodemon.json",
+	"exec": "electron",
+	"watch": ["desktop"],
+	"ignore": ["build", "public/build"]
+}

+ 39 - 0
my-desktop-app/package.json

@@ -0,0 +1,39 @@
+{
+	"name": "remix-electron-template",
+	"description": "",
+	"version": "0.0.0",
+	"private": true,
+	"main": "desktop/index.js",
+	"scripts": {
+		"dev": "remix dev --command \"nodemon .\" --manual",
+		"build": "remix build && electron-builder",
+		"start": "electron ."
+	},
+	"build": {
+		"files": [
+			"build",
+			"desktop",
+			"public",
+			"remix.config.js"
+		]
+	},
+	"dependencies": {
+		"@remix-run/node": "^2.5.1",
+		"@remix-run/react": "^2.5.1",
+		"isbot": "^4.4.0",
+		"react": "^18.2.0",
+		"react-dom": "^18.2.0",
+		"remix-electron": "^2.0.2"
+	},
+	"devDependencies": {
+		"@remix-run/dev": "^2.5.1",
+		"@remix-run/serve": "^2.5.1",
+		"@types/react": "^18.2.48",
+		"@types/react-dom": "^18.2.18",
+		"electron": "^28.2.3",
+		"electron-builder": "^24.9.1",
+		"electron-devtools-installer": "^3.2.0",
+		"nodemon": "^3.0.3",
+		"typescript": "^5.3.3"
+	}
+}

BIN
my-desktop-app/public/favicon.ico


+ 4 - 0
my-desktop-app/remix.config.js

@@ -0,0 +1,4 @@
+/** @type {import("@remix-run/dev").AppConfig} */
+module.exports = {
+	serverModuleFormat: "cjs",
+}

+ 2 - 0
my-desktop-app/remix.env.d.ts

@@ -0,0 +1,2 @@
+/// <reference types="@remix-run/dev" />
+/// <reference types="@remix-run/node" />

+ 26 - 0
my-desktop-app/tsconfig.json

@@ -0,0 +1,26 @@
+{
+	"compilerOptions": {
+		"allowJs": true,
+		"checkJs": true,
+		"esModuleInterop": true,
+		"forceConsistentCasingInFileNames": true,
+		"isolatedModules": true,
+		"jsx": "react-jsx",
+		"lib": ["dom", "dom.iterable", "esnext"],
+		"module": "NodeNext",
+		"moduleResolution": "NodeNext",
+		"moduleDetection": "force",
+		"noEmit": true,
+		"noFallthroughCasesInSwitch": true,
+		"noUncheckedIndexedAccess": true,
+		"resolveJsonModule": true,
+		"skipLibCheck": true,
+		"strict": true,
+		"target": "esnext",
+		"verbatimModuleSyntax": false, // TODO: enable this when moving to ESM
+		"paths": {
+			"~/*": ["./app/*"],
+		},
+	},
+	"exclude": ["build", "public/build", ".cache"],
+}

+ 1 - 0
my-remix-app

@@ -0,0 +1 @@
+Subproject commit a303577f40ec5ec3684aad01a21ca5f2625020a5

+ 1 - 0
node-express-sequelize-nextjs-realworld-example-app

@@ -0,0 +1 @@
+Subproject commit b7f8b80dec84ec6472487fe11585bb3b99e0818e

+ 1 - 0
ohmy

@@ -0,0 +1 @@
+Subproject commit 71d76c0e887ed406be694857deea9e91893321f0

+ 1 - 0
portfolio

@@ -0,0 +1 @@
+Subproject commit e053c2fe9309119def72573ac4ba5ddd7c6787a9