Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit a196ff5

Browse files
committed
merged from master
2 parents bb5774e + 52ed72c commit a196ff5

31 files changed

+402
-128
lines changed

.github/workflows/aleph_in_deno.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
# separate terms of service, privacy policy, and support
44
# documentation.
55

6-
# This workflow will install Deno and run tests across stable and nightly builds on Windows, Ubuntu and macOS.
7-
# For more information see: https://github.com/denolib/setup-deno
8-
96
name: Aleph.js in Deno
107

118
on:
@@ -16,24 +13,23 @@ on:
1613

1714
jobs:
1815
test:
19-
runs-on: ${{ matrix.os }} # runs a test on Ubuntu, Windows and macOS
16+
runs-on: ${{ matrix.os }} # runs a test on macOS, Windows and Ubuntu
2017

2118
strategy:
2219
matrix:
23-
deno: ["v1.x", "nightly"]
2420
os: [macOS-latest, windows-latest, ubuntu-latest]
2521

2622
steps:
2723
- name: Setup repo
2824
uses: actions/checkout@v2
2925

3026
- name: Setup Deno
31-
uses: denolib/setup-deno@c7d7968ad4a59c159a777f79adddad6872ee8d96
27+
uses: denolib/setup-deno@v2
3228
with:
33-
deno-version: ${{ matrix.deno }} # tests across multiple Deno versions
29+
deno-version: v1.x
3430

35-
- name: Cache Dependencies
31+
- name: Cache std modules
3632
run: deno cache std.ts
3733

38-
- name: Run Tests
34+
- name: Run tests
3935
run: deno test -A --unstable

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
Thumbs.db
33
.aleph/
44
dist/
5+
6+
.vscode/launch.json

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function Home() {
4343

4444
### Installation
4545
```bash
46-
deno install -A -f -n aleph https://deno.land/x/[email protected].24/cli.ts
46+
deno install -A -f -n aleph https://deno.land/x/[email protected].26/cli.ts
4747
```
4848

4949
### Usage

aleph.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { E400MissingDefaultExportAsComponent, E404Page, ErrorBoundary } from './
44
import events from './events.ts'
55
import { createPageProps, RouteModule, Routing } from './routing.ts'
66
import type { RouterURL } from './types.ts'
7-
import util, { hashShort, reModuleExt } from './util.ts'
7+
import util, { hashShort, reHttp } from './util.ts'
88

99
export function ALEPH({ initial }: {
1010
initial: {
@@ -50,7 +50,7 @@ export function ALEPH({ initial }: {
5050
if (mod.deps) {
5151
// import async dependencies
5252
for (const dep of mod.deps.filter(({ isStyle }) => !!isStyle)) {
53-
await import(getModuleImportUrl(baseUrl, { id: dep.url.replace(reModuleExt, '.js'), hash: dep.hash }, e.forceRefetch))
53+
await import(getModuleImportUrl(baseUrl, { id: util.ensureExt(dep.url.replace(reHttp, '/-/'), '.js'), hash: dep.hash }, e.forceRefetch))
5454
}
5555
if (mod.deps.filter(({ isData, url }) => !!isData && url.startsWith('#useDeno.')).length > 0) {
5656
const { default: data } = await import(`/_aleph/data${[url.pathname, url.query.toString()].filter(Boolean).join('@')}/data.js` + (e.forceRefetch ? `?t=${Date.now()}` : ''))
@@ -146,7 +146,7 @@ export function ALEPH({ initial }: {
146146
if (mod.deps) {
147147
// import async dependencies
148148
for (const dep of mod.deps.filter(({ isStyle }) => !!isStyle)) {
149-
await import(getModuleImportUrl(baseUrl, { id: dep.url.replace(reModuleExt, '.js'), hash: dep.hash }))
149+
await import(getModuleImportUrl(baseUrl, { id: util.ensureExt(dep.url.replace(reHttp, '/-/'), '.js'), hash: dep.hash }))
150150
}
151151
if (mod.deps.filter(({ isData, url }) => !!isData && url.startsWith('#useDeno.')).length > 0) {
152152
const { default: data } = await import(`/_aleph/data${[url.pathname, url.query.toString()].filter(Boolean).join('@')}/data.js`)
@@ -208,7 +208,7 @@ export function ALEPH({ initial }: {
208208
}
209209

210210
export function getModuleImportUrl(baseUrl: string, mod: RouteModule, forceRefetch = false) {
211-
return util.cleanPath(baseUrl + '/_aleph/' + util.trimSuffix(mod.id, '.js') + `.${mod.hash.slice(0, hashShort)}.js` + (forceRefetch ? `?t=${Date.now()}` : ''))
211+
return util.cleanPath(baseUrl + '/_aleph/' + (mod.id.startsWith('/-/') ? mod.id : util.trimSuffix(mod.id, '.js') + `.${mod.hash.slice(0, hashShort)}.js`) + (forceRefetch ? `?t=${Date.now()}` : ''))
212212
}
213213

214214
export async function redirect(url: string, replace?: boolean) {

bootstrap.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@ import React, { ComponentType } from 'https://esm.sh/react'
22
import { hydrate, render } from 'https://esm.sh/react-dom'
33
import { ALEPH, getModuleImportUrl } from './aleph.ts'
44
import { Route, RouteModule, Routing } from './routing.ts'
5-
import { reModuleExt } from './util.ts'
5+
import util, { reHttp } from './util.ts'
66

77
export default async function bootstrap({
88
routes,
99
baseUrl,
1010
defaultLocale,
1111
locales,
12-
preloadModules
12+
preloadModules,
13+
renderMode
1314
}: {
1415
routes: Route[]
1516
baseUrl: string
1617
defaultLocale: string
1718
locales: string[]
18-
preloadModules: RouteModule[]
19+
preloadModules: RouteModule[],
20+
renderMode: 'ssr' | 'spa'
1921
}) {
2022
const { document } = window as any
2123
const mainEl = document.querySelector('main')
@@ -29,7 +31,7 @@ export default async function bootstrap({
2931
if (mod.deps) {
3032
// import async dependencies
3133
for (const dep of mod.deps.filter(({ isStyle }) => !!isStyle)) {
32-
await import(getModuleImportUrl(baseUrl, { id: dep.url.replace(reModuleExt, '.js'), hash: dep.hash }))
34+
await import(getModuleImportUrl(baseUrl, { id: util.ensureExt(dep.url.replace(reHttp, '/-/'), '.js'), hash: dep.hash }))
3335
}
3436
}
3537
switch (mod.id) {
@@ -67,7 +69,7 @@ export default async function bootstrap({
6769
}
6870
}
6971
)
70-
if (mainEl.childElementCount > 0) {
72+
if (renderMode === 'ssr') {
7173
hydrate(el, mainEl)
7274
} else {
7375
render(el, mainEl)

design/github_avatar.psd

660 KB
Binary file not shown.
File renamed without changes.

design/logo.png

-44 KB
Binary file not shown.

design/poster.png

-42.2 KB
Binary file not shown.
File renamed without changes.

0 commit comments

Comments
 (0)