-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,174 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "@shuvi/shared", | ||
"version": "0.0.1-alpha.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/liximomo/shuvi.git", | ||
"directory": "packages/shared" | ||
}, | ||
"author": "liximomo", | ||
"license": "MIT", | ||
"files": [ | ||
"lib" | ||
], | ||
"scripts": { | ||
"dev": "tsc -p tsconfig.build.json -w" | ||
}, | ||
"engines": { | ||
"node": ">= 8.0.0" | ||
}, | ||
"dependencies": { | ||
"async-sema": "3.0.0", | ||
"watchpack": "2.0.0-beta.12" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const NAME = "shuvi"; | ||
|
||
export const DEV_STYLE_ANCHOR_ID = "__style"; | ||
|
||
export const ROUTE_REGEXP = /^page-[0-9A-Fa-f]{4,4}$/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../tsconfig.build.json", | ||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "lib" | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
/// <reference lib="dom" /> | ||
import { bootstrap } from "@shuvi-app/bootstrap"; | ||
import { DEV_STYLE_ANCHOR_ID } from "@shuvi/shared/lib/constants"; | ||
import { CLIENT_CONTAINER_ID } from "../shared/constants"; | ||
import initWebpackHMR from "./dev/webpackHotDevClient"; | ||
import { getAppData } from "./helpers/getAppData"; | ||
|
||
// type Comp = any; | ||
// const shuvi: ShuviGlobal = (window as any)[CLIENT_GLOBAL_NAME]; | ||
const styleReady = new Promise(resolve => { | ||
(window.requestAnimationFrame || setTimeout)(() => { | ||
const el = document.querySelector(`#${DEV_STYLE_ANCHOR_ID}`) | ||
?.previousElementSibling; | ||
if (el) { | ||
el.parentNode!.removeChild(el); | ||
} | ||
resolve(); | ||
}); | ||
}); | ||
|
||
initWebpackHMR(); | ||
bootstrap({ | ||
appData: getAppData(), | ||
appContainer: document.getElementById(CLIENT_CONTAINER_ID)! | ||
styleReady!.then(() => { | ||
initWebpackHMR(); | ||
bootstrap({ | ||
appData: getAppData(), | ||
appContainer: document.getElementById(CLIENT_CONTAINER_ID)! | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { IncomingMessage, ServerResponse } from 'http' | ||
import send from 'send' | ||
|
||
export function serveStatic( | ||
req: IncomingMessage, | ||
res: ServerResponse, | ||
path: string | ||
): Promise<void> { | ||
return new Promise((resolve, reject) => { | ||
send(req, path) | ||
.on('directory', () => { | ||
// We don't allow directories to be read. | ||
const err: any = new Error('No directory access') | ||
err.code = 'ENOENT' | ||
reject(err) | ||
}) | ||
.on('error', reject) | ||
.pipe(res) | ||
.on('finish', resolve) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.