first commit
Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled

This commit is contained in:
Arian Tron
2026-03-10 19:37:31 +03:30
commit 61f56f997c
27684 changed files with 2784175 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import React, { ReactNode } from "react";
import Link from "next/link";
import Head from "next/head";
type Props = {
children: ReactNode;
title?: string;
};
const Layout = ({ children, title = "This is the default title" }: Props) => (
<div>
<Head>
<title>{title}</title>
<meta charSet="utf-8" />
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
</Head>
<header>
<nav>
<Link href="/">Home</Link> | <Link href="/about">About</Link> |{" "}
<Link href="/initial-props">With Initial Props</Link>
</nav>
</header>
{children}
<footer>
<hr />
<span>I'm here to stay (Footer)</span>
</footer>
</div>
);
export default Layout;

View File

@@ -0,0 +1,19 @@
import React from "react";
import ListItem from "./ListItem";
import { User } from "../interfaces";
type Props = {
items: User[];
};
const List = ({ items }: Props) => (
<ul>
{items.map((item) => (
<li key={item.id}>
<ListItem data={item} />
</li>
))}
</ul>
);
export default List;

View File

@@ -0,0 +1,16 @@
import * as React from "react";
import { User } from "../interfaces";
type ListDetailProps = {
item: User;
};
const ListDetail = ({ item: user }: ListDetailProps) => (
<div>
<h1>Detail for {user.name}</h1>
<p>ID: {user.id}</p>
</div>
);
export default ListDetail;

View File

@@ -0,0 +1,16 @@
import React from "react";
import Link from "next/link";
import { User } from "../interfaces";
type Props = {
data: User;
};
const ListItem = ({ data }: Props) => (
<Link href="/detail/[id]" as={`/detail/${data.id}`}>
{data.id}:{data.name}
</Link>
);
export default ListItem;

View File

@@ -0,0 +1,22 @@
// You can include shared interfaces/types in a separate file
// and then use them in any component by importing them. For
// example, to import the interface below do:
//
// import User from 'path/to/interfaces';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
interface Window {
electron: {
sayHello: () => void;
receiveHello: (handler: (event, args) => void) => void;
stopReceivingHello: (handler: (event, args) => void) => void;
};
}
}
export type User = {
id: number;
name: string;
};

View File

@@ -0,0 +1,14 @@
import Link from "next/link";
import Layout from "../components/Layout";
const AboutPage = () => (
<Layout title="About | Next.js + TypeScript + Electron Example">
<h1>About</h1>
<p>This is the about page</p>
<p>
<Link href="/">Go home</Link>
</p>
</Layout>
);
export default AboutPage;

View File

@@ -0,0 +1,62 @@
// import { NextPageContext } from 'next'
import Layout from "../../components/Layout";
import { User } from "../../interfaces";
import { findAll, findData } from "../../utils/sample-api";
import ListDetail from "../../components/ListDetail";
import { GetStaticPaths, GetStaticProps } from "next";
type Params = {
id?: string;
};
type Props = {
item?: User;
errors?: string;
};
const InitialPropsDetail = ({ item, errors }: Props) => {
if (errors) {
return (
<Layout title={`Error | Next.js + TypeScript + Electron Example`}>
<p>
<span style={{ color: "red" }}>Error:</span> {errors}
</p>
</Layout>
);
}
return (
<Layout
title={`${item ? item.name : "Detail"} | Next.js + TypeScript Example`}
>
{item && <ListDetail item={item} />}
</Layout>
);
};
export const getStaticPaths: GetStaticPaths = async () => {
const items: User[] = await findAll();
const paths = items.map((item) => `/detail/${item.id}`);
return { paths, fallback: false };
};
export const getStaticProps: GetStaticProps = async ({ params }) => {
const { id } = params as Params;
try {
const item = await findData(Array.isArray(id) ? id[0] : id);
return {
props: {
item,
},
};
} catch (err) {
return {
props: {
errors: err.message,
},
};
}
};
export default InitialPropsDetail;

View File

@@ -0,0 +1,32 @@
import { useEffect } from "react";
import Link from "next/link";
import Layout from "../components/Layout";
const IndexPage = () => {
useEffect(() => {
const handleMessage = (_event, args) => alert(args);
// listen to the 'message' channel
window.electron.receiveHello(handleMessage);
return () => {
window.electron.stopReceivingHello(handleMessage);
};
}, []);
const onSayHiClick = () => {
window.electron.sayHello();
};
return (
<Layout title="Home | Next.js + TypeScript + Electron Example">
<h1>Hello Next.js 👋</h1>
<button onClick={onSayHiClick}>Say hi to electron</button>
<p>
<Link href="/about">About</Link>
</p>
</Layout>
);
};
export default IndexPage;

View File

@@ -0,0 +1,33 @@
import Link from "next/link";
import { useRouter } from "next/router";
import Layout from "../components/Layout";
import List from "../components/List";
import { User } from "../interfaces";
import { findAll } from "../utils/sample-api";
type Props = {
items: User[];
pathname: string;
};
const WithInitialProps = ({ items }: Props) => {
const router = useRouter();
return (
<Layout title="List Example (as Function Component) | Next.js + TypeScript + Electron Example">
<h1>List Example (as Function Component)</h1>
<p>You are currently on: {router.pathname}</p>
<List items={items} />
<p>
<Link href="/">Go home</Link>
</p>
</Layout>
);
};
export async function getStaticProps() {
const items: User[] = await findAll();
return { props: { items } };
}
export default WithInitialProps;

View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "../next.config.js"],
"exclude": ["node_modules"]
}

View File

@@ -0,0 +1,34 @@
import { User } from "../interfaces";
/** Dummy user data. */
export const dataArray: User[] = [
{ id: 101, name: "Alice" },
{ id: 102, name: "Bob" },
{ id: 103, name: "Caroline" },
{ id: 104, name: "Dave" },
];
/**
* Calls a mock API which finds a user by ID from the list above.
*
* Throws an error if not found.
*/
export async function findData(id: number | string) {
const selected = dataArray.find((data) => data.id === Number(id));
if (!selected) {
throw new Error("Cannot find user");
}
return selected;
}
/** Calls a mock API which returns the above array to simulate "get all". */
export async function findAll() {
// Throw an error, just for example.
if (!Array.isArray(dataArray)) {
throw new Error("Cannot find users");
}
return dataArray;
}