index int64 0 0 | repo_id stringlengths 16 181 | file_path stringlengths 28 270 | content stringlengths 1 11.6M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/components/Header.tsx | import { Link } from "aleph/react";
export default function Header() {
return (
<header>
<div className="header-wrapper">
<h1>
<Link to="/">
<svg
viewBox="0 0 60 12.09"
fill="currentColor"
>
<title>Aleph.js</title>
... | 7,300 |
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/components/Heading.tsx | import type { FC, PropsWithChildren } from "react";
import { createElement } from "react";
// The props `id` is generated by `rehype-slug` plugin
export const Heading: FC<PropsWithChildren<{ id: string; level: number }>> = ({ id, level, children, ...rest }) => {
return createElement(
`h${level}`,
{ ...rest, ... | 7,301 |
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/routes/_404.tsx | import { Link } from "aleph/react";
export default function E404() {
return (
<div className="screen e404">
<h2>
Ooooooops, nothing here!
</h2>
<p>
<Link to="/">
Go back to the homepage
</Link>
</p>
</div>
);
}
| 7,302 |
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/routes/_app.tsx | import Header from "../components/Header.tsx";
export default function App({ children }: { children: React.ReactNode }) {
return (
<>
<Header />
{children}
</>
);
}
| 7,303 |
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/routes/_export.ts | /** @format */
// Exports router modules for serverless env that doesn't support the dynamic import.
// This module will be updated automatically in development mode, do NOT edit it manually.
// deno-fmt-ignore-file
// deno-lint-ignore-file
// @ts-nocheck
var u = Object.defineProperty;
var c = (s, e) => {
for (var o ... | 7,304 |
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/routes/docs.tsx | import { PropsWithChildren } from "react";
import { MDXProvider } from "@mdx-js/react";
import { Head, NavLink } from "aleph/react";
import { components } from "../components/Heading.tsx";
const nav = [
["About", "/docs"],
["Get Started", "/docs/get-started"],
];
export default function Docs(props: PropsWithChild... | 7,305 |
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/routes/index.tsx | import { Head, Link } from "aleph/react";
const externalLinks = [
["Get Started", "https://alephjs.org/docs/get-started"],
["Docs", "https://alephjs.org/docs"],
["Github", "https://github.com/alephjs/aleph.js"],
];
export default function Index() {
return (
<div className="screen index">
<Head>
... | 7,306 |
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/routes | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/routes/docs/get-started.mdx | ---
title: "Get Started - Docs"
author: ije
---
import { Head } from "aleph/react"
<Head>
<title>Get Started - Docs</title>
</Head>
# Get Started
Initialize a new project, you can pick a start template with `--template` flag, available templates:
`[react, react-mdx, api]`
```bash
deno run -A https://deno.land/x/... | 7,307 |
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/routes | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/routes/docs/index.mdx | ---
title: "About - Docs"
author: ije
---
import { Head } from "aleph/react"
<Head>
<title>About - Docs</title>
</Head>
# About
**Aleph.js** (or **Aleph** or **א** or **阿莱夫**, <samp>ˈɑːlɛf</samp>) is a
fullstack framework in [Deno]. Inspired by [Next.js], [Remix] and [Vite].
> The name is taken from the book [_T... | 7,308 |
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/style/app.css | @import url('./reset.css');
@import url('./markdown.css');
@import url('./hljs.css');
header {
width: 100%;
height: 80px;
position: sticky;
top: 0;
background: #fff;
}
header .header-wrapper {
margin: 0 auto;
width: 90%;
max-width: 1024px;
height: 100%;
display: flex;
align-items: center;
just... | 7,309 |
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/style/hljs.css | /* copied from https://esm.sh/highlightjs@9.16.2/styles/github.css */
.hljs {
display: block;
overflow-x: auto;
padding: .5em;
color: #333;
background: #f8f8f8
}
.hljs-comment,
.hljs-quote {
color: #998;
font-style: italic
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
color: #111;
font-weight:... | 7,310 |
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/style/markdown.css | :root {
--theme-color: #d63369;
}
.markdown-body {
overflow: hidden;
color: #333;
padding-left: 30px;
& a {
color: var(--theme-color);
&:hover {
text-decoration: underline;
}
}
& strong {
font-weight: 600;
color: #111;
}
& em {
font-style: italic;
}
& h1,
& h2... | 7,311 |
0 | petrpan-code/alephjs/aleph.js/examples/react-mdx-app | petrpan-code/alephjs/aleph.js/examples/react-mdx-app/style/reset.css | /*
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
*/
*,
::before,
::after {
box-sizing: border-box; /* 1 */
border-width: 0; /* 2 ... | 7,312 |
0 | petrpan-code/alephjs/aleph.js/examples | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr/README.md | # React Suspense SSR
A demo for [New Suspense SSR Architecture in React 18](https://github.com/reactwg/react-18/discussions/37) with Aleph.js
data fetching, deploy to [Deno Deploy](https://deno.com/deploy):
https://aleph-suspense-ssr.deno.dev/
> This demo is artificially slowed down. Open routes/index.tsx to adjust ... | 7,313 |
0 | petrpan-code/alephjs/aleph.js/examples | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr/index.html | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./style/main.css">
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.ts"></script>
</body>
</html>
| 7,314 |
0 | petrpan-code/alephjs/aleph.js/examples | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr/main.ts | import { bootstrap } from "aleph/react";
bootstrap();
| 7,315 |
0 | petrpan-code/alephjs/aleph.js/examples | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr/server.ts | import { serve } from "aleph/server";
import denoDeploy from "aleph/plugins/deploy";
import react from "aleph/plugins/react";
import modules from "./routes/_export.ts";
serve({
plugins: [
denoDeploy({ modules }),
react({ ssr: true }),
],
});
| 7,316 |
0 | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr/components/Comments.tsx | import { useData } from "aleph/react";
export default function Comments() {
const { data: { comments } } = useData<{ comments: string[] }>();
return (
<>
{comments.map((comment, i) => (
<p className="comment" key={i}>
{comment}
</p>
))}
</>
);
}
| 7,317 |
0 | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr/components/Post.tsx | export default function Post() {
return (
<>
<h1>Hello world</h1>
<p>
This demo is <b>artificially slowed down</b>. Open <code>routes/index.tsx</code>{" "}
to adjust how much different things are slowed down.
</p>
<p>
Notice how HTML for comments "streams in" before... | 7,318 |
0 | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr/components/Sidebar.tsx | export default function Sidebar() {
return (
<>
<h1>Archive</h1>
<ul>
<li>May 2021</li>
<li>April 2021</li>
<li>March 2021</li>
<li>February 2021</li>
<li>January 2021</li>
<li>December 2020</li>
<li>November 2020</li>
<li>October 2020</l... | 7,319 |
0 | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr/components/Spinner.tsx | export default function Spinner({ active = true }) {
return (
<div
className={["spinner", active && "spinner--active"].join(" ")}
role="progressbar"
aria-busy={active ? "true" : "false"}
/>
);
}
| 7,320 |
0 | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr/routes/_export.ts | // Exports router modules for serverless env that doesn't support the dynamic import.
// This module will be updated automatically in development mode, do NOT edit it manually.
import * as $0 from "./index.tsx";
export default {
"/": $0,
};
| 7,321 |
0 | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr/routes/index.tsx | import { Suspense } from "react";
import { Head } from "aleph/react";
import Spinner from "../components/Spinner.tsx";
import Sidebar from "../components/Sidebar.tsx";
import Post from "../components/Post.tsx";
import Comments from "../components/Comments.tsx";
// This demo is artificially slowed down.
// Please updat... | 7,322 |
0 | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr | petrpan-code/alephjs/aleph.js/examples/react-suspense-ssr/style/main.css | body {
font-family: system-ui, sans-serif;
}
* {
box-sizing: border-box;
}
nav {
padding: 20px;
}
.sidebar {
padding: 10px;
height: 500px;
float: left;
width: 30%;
}
.post {
padding: 20px;
float: left;
width: 60%;
}
h1, h2 {
padding: 0;
}
ul, li {
margin: 0;
}
.post p {
font-size: large... | 7,323 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/Cargo.lock | # This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "ahash"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
"getrandom... | 7,324 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/Cargo.toml | [package]
name = "leptos-app"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
broadcaster = "1"
console_log = "0.2"
console_error_panic_hook = "0.1"
serde = { version = "1", features = ["derive"] }
futures = "0.3"
cfg-if = "1"
lazy_static = "1"
leptos = { version = "0.1.3", def... | 7,325 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/LICENSE | MIT License
Copyright (c) 2022 Greg Johnston
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, dis... | 7,326 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/Makefile.toml | [tasks.build]
command = "cargo"
args = ["+nightly", "build-all-features"]
install_crate = "cargo-all-features"
| 7,327 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/README.md | # Leptos Counter Isomorphic Example
This example demonstrates how to use a function isomorphically, to run a server side function from the browser and
receive a result.
## Client Side Rendering
For this example the server must store the counter state since it can be modified by many users. This means it is not
possi... | 7,328 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/dev.ts | import { fromFileUrl, join } from "std/path/mod.ts";
import dev, { createWatchFsEmitter } from "aleph/dev";
const emitter = createWatchFsEmitter();
emitter.on("modify", ({ specifier }) => {
if (specifier.endsWith(".rs")) {
// rebuild the leptos app then restart the dev server
start();
}
});
let buildClien... | 7,329 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/index.html | <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Leptos - Aleph.js</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="./assets/logo.svg">
<script type="module" src="./main.ts"></script>
</head>
<body></body>
</html>
| 7,330 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/main.ts | import init, { hydrate } from "./pkg/client.js";
// reload page on rebuild
import.meta.hot?.decline();
// run app main
init().then(hydrate);
| 7,331 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/server.ts | import { serve } from "aleph/server";
import unocss from "aleph/plugins/unocss";
import config from "./unocss.config.ts";
import init, { ssr } from "./pkg/server.js";
const wasmUrl = new URL("./pkg/server_bg.wasm", import.meta.url);
await init(await Deno.readFile(wasmUrl));
serve({
plugins: [
unocss(/\.rs$/, co... | 7,332 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/unocss.config.ts | import type { UserConfig } from "@unocss/core";
import presetUno from "@unocss/preset-uno";
// @ref https://github.com/unocss/unocss#configurations
export default <UserConfig> {
presets: [presetUno()],
};
| 7,333 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/pkg/client.js | import { microtask } from "./snippets/leptos_reactive-81881a7e036355c6/inline0.js";
let wasm;
const heap = new Array(32).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) {
return heap[idx];
}
let heap_next = heap.length;
function dropObject(idx) {
if (idx < 36) return;
heap[... | 7,334 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/pkg/server.js | let wasm;
const heap = new Array(32).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) {
return heap[idx];
}
let heap_next = heap.length;
function dropObject(idx) {
if (idx < 36) return;
heap[idx] = heap_next;
heap_next = idx;
}
function takeObject(idx) {
const ret = getO... | 7,335 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/src/lib.rs | use cfg_if::cfg_if;
cfg_if! {
if #[cfg(feature = "hydrate")] {
use wasm_bindgen::prelude::wasm_bindgen;
use leptos::*;
pub mod routes;
use routes::{App, AppProps};
#[wasm_bindgen]
pub fn hydrate() {
console_error_panic_hook::set_once();
_ = co... | 7,336 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/src/routes.rs | use leptos::*;
use leptos_meta::*;
use leptos_router::*;
pub mod index;
use index::{Counter, CounterProps};
#[component]
pub fn App(cx: Scope) -> impl IntoView {
provide_meta_context(cx);
view! {
cx,
<Router>
<main>
<Routes>
<Route path="" view=|... | 7,337 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/src | petrpan-code/alephjs/aleph.js/examples/with-unocss/leptos-app/src/routes/index.rs | use leptos::*;
/// A simple counter component.
///
/// You can use doc comments like this to document your component.
#[component]
pub fn Counter(
cx: Scope,
) -> impl IntoView {
let (value, set_value) = create_signal(cx, 0);
let step = 1;
view! { cx,
<div class="flex flex-row gap-1 items-cen... | 7,338 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app/README.md | # React App
A React demo application powered by Aleph.js in Deno, deploy to [Deno Deploy](https://deno.com/deploy):
https://aleph-hello.deno.dev/
| 7,339 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app/index.html | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="./assets/logo.svg">
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.ts"></script>
</body>
</html>
| 7,340 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app/main.ts | import { bootstrap } from "aleph/react";
bootstrap();
| 7,341 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app/server.ts | import { serve } from "aleph/server";
import denoDeploy from "aleph/plugins/deploy";
import react from "aleph/plugins/react";
import unocss from "aleph/plugins/unocss";
import config from "./unocss.config.ts";
import modules from "./routes/_export.ts";
serve({
plugins: [
denoDeploy({ modules }),
react({ ssr:... | 7,342 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app/unocss.config.ts | import type { UserConfig } from "@unocss/core";
import presetUno from "@unocss/preset-uno";
// @ref https://github.com/unocss/unocss#configurations
export default <UserConfig> {
presets: [presetUno()],
};
| 7,343 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app/assets/logo.svg | <svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M52.9528 11.1C54.0959 11.1 55.1522 11.7097 55.7239 12.6995C68.5038 34.8259 81.2837 56.9524 94.0636 79.0788C94.642 80.0802 94.6355 81.316 94.0425 82.3088C93.0466 83.9762 92.028 85.6661 91.0325 87.3331C90.4529 8... | 7,344 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app/components/Header.tsx | import { Link } from "aleph/react";
export default function Header() {
return (
<header className="sticky top-0 w-full h-20">
<div className="flex items-center justify-between w-[90%] max-w-[900px] h-full m-x-auto">
<h1>
<Link to="/">
<svg
className="w-auto h-4"
... | 7,345 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app/routes/_404.tsx | import { Link } from "aleph/react";
export default function E404() {
return (
<div
className="w-screen flex flex-col items-center justify-center"
style={{
height: "calc(100vh - 2 * 80px)",
}}
>
<h2 className="text-2xl font-bold mt">
Ooooooops, nothing here!
</h2>... | 7,346 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app/routes/_app.tsx | import Header from "../components/Header.tsx";
export default function App({ children }: { children: React.ReactNode }) {
return (
<>
<Header />
{children}
</>
);
}
| 7,347 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app/routes/_export.ts | // Exports router modules for serverless env that doesn't support the dynamic import.
// This module will be updated automatically in development mode, do NOT edit it manually.
import * as $0 from "./_404.tsx";
import * as $1 from "./_app.tsx";
import * as $2 from "./index.tsx";
import * as $3 from "./todos.tsx";
exp... | 7,348 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app/routes/index.tsx | import { Head, Link } from "aleph/react";
const externalLinks = [
["Get Started", "https://alephjs.org/docs/get-started"],
["Docs", "https://alephjs.org/docs"],
["Github", "https://github.com/alephjs/aleph.js"],
];
export default function Index() {
return (
<div
className="w-screen flex flex-col ite... | 7,349 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/react-app/routes/todos.tsx | import type { FormEvent } from "react";
import { Head, useData } from "aleph/react";
type Todo = {
id: number;
message: string;
completed: boolean;
};
const store = {
todos: JSON.parse(window.localStorage?.getItem("todos") || "[]") as Todo[],
save() {
localStorage?.setItem("todos", JSON.stringify(this.t... | 7,350 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/Cargo.lock | # This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "anymap2"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c"
[[package]]
name = "auto... | 7,351 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/Cargo.toml | [package]
name = "yew-app"
version = "0.0.0"
edition = "2021"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
# this is the development version of Yew
yew = { git = "https://github.com/yewstack/yew.git", features = ["ssr", "hydration"] }
yew-router = { git = "https://github.com/yewstack/yew.git" }
wasm-bindgen =... | 7,352 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/README.md | # Yew App
A [Yew](https://yew.rs/) SSR demo application powered by Aleph.js in Deno, deploy to
[Deno Deploy](https://deno.com/deploy).
🚀 Both the CSR and SSR are using **[WebAssembly](https://webassembly.org/)** with great performance in modern browsers
and serverless platform at edge.
You will need [rust](https://... | 7,353 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/dev.ts | import { fromFileUrl, join } from "std/path/mod.ts";
import dev, { createWatchFsEmitter } from "aleph/dev";
const emitter = createWatchFsEmitter();
emitter.on("modify", ({ specifier }) => {
if (specifier.endsWith(".rs")) {
// rebuild the yew app then restart the dev server
start();
}
});
let buildProc: De... | 7,354 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/index.html | <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Yew - Aleph.js</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="./assets/logo.svg">
<script type="module" src="./main.ts"></script>
</head>
<body></body>
</html> | 7,355 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/main.ts | import init, { main } from "./pkg/yew_app.js";
// reload page on rebuild
import.meta.hot?.decline();
// run app main
init().then(main);
| 7,356 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/server.ts | import { serve } from "aleph/server";
import unocss from "aleph/plugins/unocss";
import config from "./unocss.config.ts";
import init, { ssr } from "./pkg/yew_app.js";
const wasmUrl = new URL("./pkg/yew_app_bg.wasm", import.meta.url);
await init(await Deno.readFile(wasmUrl));
serve({
plugins: [
unocss(/\.rs$/, ... | 7,357 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/unocss.config.ts | import type { UserConfig } from "@unocss/core";
import presetUno from "@unocss/preset-uno";
// @ref https://github.com/unocss/unocss#configurations
export default <UserConfig> {
presets: [presetUno()],
};
| 7,358 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/assets/external-link.svg | <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M14 5C13.4477 5 13 4.55228 13 4C13 3.44772 13.4477 3 14 3H20C20.2652 3 20.5196 3.10536 20.7071 3.29289C20.8946 3.48043 21 3.73478 21 4L21 10C21 10.5523 20.5523 11 20 11C19.4477 11 19 10.5523 19 10L19 6.41422L... | 7,359 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/assets/logo.svg | <svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M52.9528 11.1C54.0959 11.1 55.1522 11.7097 55.7239 12.6995C68.5038 34.8259 81.2837 56.9524 94.0636 79.0788C94.642 80.0802 94.6355 81.316 94.0425 82.3088C93.0466 83.9762 92.028 85.6661 91.0325 87.3331C90.4529 8... | 7,360 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/pkg/yew_app.js |
let wasm;
const heap = new Array(32).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) { return heap[idx]; }
let heap_next = heap.length;
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx... | 7,361 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/src/app.rs | use std::collections::HashMap;
use url::Url;
use yew::prelude::*;
use yew_router::history::{AnyHistory, History, MemoryHistory};
use yew_router::prelude::*;
use crate::components::header::Header;
use crate::routes::{switch, Route};
#[derive(Properties, PartialEq, Default)]
pub struct AppProps {
pub ssr_url: Option<... | 7,362 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/src/components.rs | pub mod header; | 7,363 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/src/lib.rs | mod app;
mod components;
mod routes;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn main() {
yew::Renderer::<app::App>::new().hydrate();
}
#[wasm_bindgen]
pub async fn ssr(url: String) -> Result<JsValue, JsValue> {
let html = yew::ServerRenderer::<app::App>::with_props(app::AppProps { ssr_url: Some(url) })... | 7,364 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/src/routes.rs | pub mod _404;
pub mod index;
pub mod todos;
use yew::prelude::*;
use yew_router::prelude::*;
use index::Index;
use todos::Todos;
use _404::NotFound;
#[derive(Clone, Routable, PartialEq)]
pub enum Route {
#[at("/")]
Home,
#[at("/todos")]
Todos,
#[at("/404")]
#[not_found]
NotFound,
}
pub fn switch(routes... | 7,365 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/src | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/src/components/header.rs | use yew::prelude::*;
use yew_router::prelude::*;
use crate::routes::Route;
#[function_component]
pub fn Header() -> Html {
html! {
<header class="sticky top-0 w-full h-20">
<div class="flex items-center justify-between w-[90%] max-w-[900px] h-full m-x-auto">
<h1>
<Link<Route> to={Route::... | 7,366 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/src | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/src/routes/_404.rs | use yew::prelude::*;
use yew_router::prelude::*;
use crate::routes::Route;
#[function_component]
pub fn NotFound() -> Html {
html! {
<div
class="w-screen flex flex-col items-center justify-center"
style="height: calc(100vh - 2 * 80px)"
>
<h2 class="text-2xl font-bold mt">
{"Ooooooo... | 7,367 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/src | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/src/routes/index.rs | use yew::prelude::*;
use yew_router::prelude::*;
use crate::routes::Route;
#[function_component]
pub fn Index() -> Html {
let icon = html! {
<svg
class="w-4 h-4"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M14 5C13.4477 5 13 4.55228 13 4C13 3.44772 13.44... | 7,368 |
0 | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/src | petrpan-code/alephjs/aleph.js/examples/with-unocss/yew-app/src/routes/todos.rs | use web_sys::HtmlInputElement;
use yew::prelude::*;
#[derive(Clone, Debug, PartialEq)]
struct Todo {
id: usize,
completed: bool,
title: String,
}
#[derive(PartialEq, Properties, Clone)]
struct EntryProps {
pub todo: Todo,
pub ontoggle: Callback<usize>,
pub onremove: Callback<usize>,
}
#[function_componen... | 7,369 |
0 | petrpan-code/alephjs/aleph.js/examples | petrpan-code/alephjs/aleph.js/examples/yew-app/Cargo.lock | # This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "anymap2"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c"
[[package]]
name = "auto... | 7,370 |
0 | petrpan-code/alephjs/aleph.js/examples | petrpan-code/alephjs/aleph.js/examples/yew-app/Cargo.toml | [package]
name = "yew-app"
version = "0.0.0"
edition = "2021"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
# this is the development version of Yew
yew = { git = "https://github.com/yewstack/yew.git", features = ["ssr", "hydration"] }
yew-router = { git = "https://github.com/yewstack/yew.git" }
wasm-bindgen =... | 7,371 |
0 | petrpan-code/alephjs/aleph.js/examples | petrpan-code/alephjs/aleph.js/examples/yew-app/README.md | # Yew App
This is a demo application powered by Aleph.js in Deno using [Yew](https://yew.rs/) SSR.
- 🚀 Both the client-side rendering (CSR) and server-side rendering (SSR) use
**[WebAssembly](https://webassembly.org/)**, delivering great performance on modern browsers and serverless platforms
at the edge.
- 🦀 T... | 7,372 |
0 | petrpan-code/alephjs/aleph.js/examples | petrpan-code/alephjs/aleph.js/examples/yew-app/dev.ts | import { fromFileUrl, join } from "std/path/mod.ts";
import dev, { createWatchFsEmitter } from "aleph/dev";
const emitter = createWatchFsEmitter();
emitter.on("modify", ({ specifier }) => {
if (specifier.endsWith(".rs")) {
// rebuild the yew app then restart the dev server
start();
}
});
let buildProc: De... | 7,373 |
0 | petrpan-code/alephjs/aleph.js/examples | petrpan-code/alephjs/aleph.js/examples/yew-app/index.html | <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Yew - Aleph.js</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="./assets/logo.svg">
<link rel="stylesheet" href="./style/app.css">
<script type="module" src="./main.ts"></script>
</head>
<bod... | 7,374 |
0 | petrpan-code/alephjs/aleph.js/examples | petrpan-code/alephjs/aleph.js/examples/yew-app/main.ts | import init, { main } from "./pkg/yew_app.js";
// reload page on rebuild
import.meta.hot?.decline();
// run app main
init().then(main);
| 7,375 |
0 | petrpan-code/alephjs/aleph.js/examples | petrpan-code/alephjs/aleph.js/examples/yew-app/server.ts | import { serve } from "aleph/server";
import init, { ssr } from "./pkg/yew_app.js";
const wasmUrl = new URL("./pkg/yew_app_bg.wasm", import.meta.url);
await init(await Deno.readFile(wasmUrl));
serve({
ssr: ({ url }) => ssr(url.href),
});
| 7,376 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app | petrpan-code/alephjs/aleph.js/examples/yew-app/assets/external-link.svg | <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M14 5C13.4477 5 13 4.55228 13 4C13 3.44772 13.4477 3 14 3H20C20.2652 3 20.5196 3.10536 20.7071 3.29289C20.8946 3.48043 21 3.73478 21 4L21 10C21 10.5523 20.5523 11 20 11C19.4477 11 19 10.5523 19 10L19 6.41422L... | 7,377 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app | petrpan-code/alephjs/aleph.js/examples/yew-app/assets/logo.svg | <svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M52.9528 11.1C54.0959 11.1 55.1522 11.7097 55.7239 12.6995C68.5038 34.8259 81.2837 56.9524 94.0636 79.0788C94.642 80.0802 94.6355 81.316 94.0425 82.3088C93.0466 83.9762 92.028 85.6661 91.0325 87.3331C90.4529 8... | 7,378 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app | petrpan-code/alephjs/aleph.js/examples/yew-app/pkg/yew_app.js |
let wasm;
const heap = new Array(32).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) { return heap[idx]; }
let heap_next = heap.length;
function addHeapObject(obj) {
if (heap_next === heap.length) heap.push(heap.length + 1);
const idx = heap_next;
heap_next = heap[idx... | 7,379 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app | petrpan-code/alephjs/aleph.js/examples/yew-app/src/app.rs | use std::collections::HashMap;
use url::Url;
use yew::prelude::*;
use yew_router::history::{AnyHistory, History, MemoryHistory};
use yew_router::prelude::*;
use crate::components::header::Header;
use crate::routes::{switch, Route};
#[derive(Properties, PartialEq, Default)]
pub struct AppProps {
pub ssr_url: Option<... | 7,380 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app | petrpan-code/alephjs/aleph.js/examples/yew-app/src/components.rs | pub mod header; | 7,381 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app | petrpan-code/alephjs/aleph.js/examples/yew-app/src/lib.rs | mod app;
mod components;
mod routes;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn main() {
yew::Renderer::<app::App>::new().hydrate();
}
#[wasm_bindgen]
pub async fn ssr(url: String) -> Result<JsValue, JsValue> {
let html = yew::ServerRenderer::<app::App>::with_props(app::AppProps { ssr_url: Some(url) })... | 7,382 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app | petrpan-code/alephjs/aleph.js/examples/yew-app/src/routes.rs | pub mod _404;
pub mod index;
pub mod todos;
use yew::prelude::*;
use yew_router::prelude::*;
use index::Index;
use todos::Todos;
use _404::NotFound;
#[derive(Clone, Routable, PartialEq)]
pub enum Route {
#[at("/")]
Home,
#[at("/todos")]
Todos,
#[at("/404")]
#[not_found]
NotFound,
}
pub fn switch(routes... | 7,383 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app/src | petrpan-code/alephjs/aleph.js/examples/yew-app/src/components/header.rs | use yew::prelude::*;
use yew_router::prelude::*;
use crate::routes::Route;
#[function_component]
pub fn Header() -> Html {
html! {
<header>
<div class={"header-wrapper"}>
<h1>
<Link<Route> to={Route::Home}>
<svg
viewbox="0 0 60 12.09"
fill="current... | 7,384 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app/src | petrpan-code/alephjs/aleph.js/examples/yew-app/src/routes/_404.rs | use yew::prelude::*;
use yew_router::prelude::*;
use crate::routes::Route;
#[function_component]
pub fn NotFound() -> Html {
html! {
<div class="screen e404">
<h2>
{"Ooooooops, nothing here!"}
</h2>
<p>
<Link<Route> to={Route::Home}>{"Go back to the homepage"}</Link<Route>>
... | 7,385 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app/src | petrpan-code/alephjs/aleph.js/examples/yew-app/src/routes/index.rs | use yew::prelude::*;
use yew_router::prelude::*;
use crate::routes::Route;
#[function_component]
pub fn Index() -> Html {
html! {
<div class="index screen">
<p class="logo">
<img src="/assets/logo.svg" width="70" height="70" title="Aleph.js" />
<img src="/assets/yew.png" width="70" height=... | 7,386 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app/src | petrpan-code/alephjs/aleph.js/examples/yew-app/src/routes/todos.rs | use web_sys::HtmlInputElement;
use yew::prelude::*;
#[derive(Clone, Debug, PartialEq)]
struct Todo {
id: usize,
completed: bool,
title: String,
}
#[derive(PartialEq, Properties, Clone)]
struct EntryProps {
pub todo: Todo,
pub ontoggle: Callback<usize>,
pub onremove: Callback<usize>,
}
#[function_componen... | 7,387 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app | petrpan-code/alephjs/aleph.js/examples/yew-app/style/app.css | @import url('./reset.css');
header {
width: 100%;
height: 80px;
position: sticky;
top: 0;
}
header .header-wrapper {
margin: 0 auto;
width: 90%;
max-width: 900px;
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
}
header h1 a {
color: #333;
}
header h1 svg {
... | 7,388 |
0 | petrpan-code/alephjs/aleph.js/examples/yew-app | petrpan-code/alephjs/aleph.js/examples/yew-app/style/reset.css | /*
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
*/
*,
::before,
::after {
box-sizing: border-box; /* 1 */
border-width: 0; /* 2 ... | 7,389 |
0 | petrpan-code/alephjs/aleph.js/framework | petrpan-code/alephjs/aleph.js/framework/core/error.ts | import { VERSION } from "../../version.ts";
export class FetchError extends Error {
public status: number;
public details: Record<string, unknown>;
constructor(
status: number,
message: string,
details?: Record<string, unknown>,
opts?: ErrorOptions,
) {
super(message, opts);
this.statu... | 7,390 |
0 | petrpan-code/alephjs/aleph.js/framework | petrpan-code/alephjs/aleph.js/framework/core/events.ts | /** @format */
import mitt from "https://esm.sh/v126/mitt@3.0.0";
// shared event emitter for client(browser)
export default mitt<Record<string, Record<string, unknown>>>();
| 7,391 |
0 | petrpan-code/alephjs/aleph.js/framework | petrpan-code/alephjs/aleph.js/framework/core/hmr.ts | // ESM Hot Module Replacement (ESM-HMR) Specification
// https://github.com/withastro/esm-hmr
import { cleanPath } from "../../shared/util.ts";
import events from "./events.ts";
const modules: Map<string, Module> = new Map();
const messageQueue: string[] = [];
class Module {
private _specifier: string;
private _... | 7,392 |
0 | petrpan-code/alephjs/aleph.js/framework | petrpan-code/alephjs/aleph.js/framework/core/nomodule.ts | // @ts-nocheck
// deno-lint-ignore-file
(function (document) {
var containerEl = document.createElement("div");
var hEl = document.createElement("h2");
var pEl = document.createElement("p");
var contarinStyle = {
position: "fixed",
top: "0",
left: "0",
zIndex: "999",
width: "100%",
padd... | 7,393 |
0 | petrpan-code/alephjs/aleph.js/framework | petrpan-code/alephjs/aleph.js/framework/core/redirect.ts | import { isFilledString } from "../../shared/util.ts";
import events from "./events.ts";
import { matchRoutes, type Router } from "./router.ts";
let router: Router | null = null;
let preRedirect: URL | null = null;
const onrouter = (e: Record<string, unknown>) => {
events.off("router", onrouter);
if (preRedirect)... | 7,394 |
0 | petrpan-code/alephjs/aleph.js/framework | petrpan-code/alephjs/aleph.js/framework/core/router.ts | import { isPlainObject, splitPath, trimSuffix } from "../../shared/util.ts";
import type { URLPatternInput, URLPatternResult } from "./url_pattern.ts";
import { createStaticURLPatternResult, URLPatternCompat } from "./url_pattern.ts";
import { FetchError } from "./error.ts";
import events from "./events.ts";
export ty... | 7,395 |
0 | petrpan-code/alephjs/aleph.js/framework | petrpan-code/alephjs/aleph.js/framework/core/style.ts | // deno-lint-ignore-file ban-ts-comment
export function applyCSS(url: string, css: string) {
const { document } = globalThis;
if (document) {
const ssrEl = Array.from<Element>(document.head.children).find((el: Element) =>
el.getAttribute("data-module-id") === url &&
el.hasAttribute("ssr")
);
... | 7,396 |
0 | petrpan-code/alephjs/aleph.js/framework | petrpan-code/alephjs/aleph.js/framework/core/url_pattern.ts | import { isFilledString, splitPath } from "../../shared/util.ts";
export type URLPatternInput = {
host?: string;
pathname: string;
};
export type URLPatternResult = {
host: { input: string; groups: Record<string, string> };
pathname: { input: string; groups: Record<string, string> };
};
/**
* A class uses t... | 7,397 |
0 | petrpan-code/alephjs/aleph.js/framework | petrpan-code/alephjs/aleph.js/framework/react/client.ts | import { createElement } from "react";
import { createRoot, hydrateRoot } from "react-dom/client";
import { App, RouterProps } from "./mod.ts";
import { createCSRContext } from "../core/router.ts";
export type RenderOptions = {
root?: string | HTMLElement | null;
createPortal?: RouterProps["createPortal"];
};
exp... | 7,398 |
0 | petrpan-code/alephjs/aleph.js/framework | petrpan-code/alephjs/aleph.js/framework/react/context.ts | import type { ReactNode, ReactPortal } from "react";
import { createContext } from "react";
export type HttpMethod = "get" | "post" | "put" | "patch" | "delete";
export type UpdateStrategy<T = unknown> = "none" | "replace" | {
optimisticUpdate?: (data: T) => T;
onFailure?: (error: Error) => void;
replace?: bool... | 7,399 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.