@eighty4/dank 0.0.3 → 0.0.4-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/esbuild.js +8 -5
- package/lib/build.ts +128 -72
- package/lib/{tag.ts → build_tag.ts} +3 -3
- package/lib/dank.ts +147 -11
- package/lib/define.ts +4 -5
- package/lib/esbuild.ts +192 -41
- package/lib/flags.ts +148 -10
- package/lib/html.ts +325 -117
- package/lib/http.ts +195 -47
- package/lib/metadata.ts +284 -0
- package/lib/public.ts +21 -13
- package/lib/serve.ts +204 -144
- package/lib/services.ts +28 -4
- package/lib_js/build.js +82 -57
- package/lib_js/{tag.js → build_tag.js} +2 -3
- package/lib_js/dank.js +73 -5
- package/lib_js/define.js +3 -5
- package/lib_js/esbuild.js +139 -34
- package/lib_js/flags.js +118 -8
- package/lib_js/html.js +203 -88
- package/lib_js/http.js +111 -30
- package/lib_js/metadata.js +198 -0
- package/lib_js/public.js +19 -11
- package/lib_js/serve.js +135 -110
- package/lib_js/services.js +13 -2
- package/lib_types/dank.d.ts +18 -1
- package/package.json +7 -1
- package/lib/manifest.ts +0 -61
- package/lib_js/manifest.js +0 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eighty4/dank",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4-0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Adam McKee Bennett <adam.be.g84d@gmail.com>",
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
"esbuild",
|
|
12
12
|
"dank"
|
|
13
13
|
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/eighty4/dank"
|
|
17
|
+
},
|
|
14
18
|
"bin": "./lib_js/bin.js",
|
|
15
19
|
"exports": {
|
|
16
20
|
".": {
|
|
@@ -39,6 +43,8 @@
|
|
|
39
43
|
"build": "tsc && tsc -p tsconfig.client.json && tsc -p tsconfig.exports.json",
|
|
40
44
|
"fmt": "prettier --write .",
|
|
41
45
|
"fmtcheck": "prettier --check .",
|
|
46
|
+
"test": "node --test \"test/**/*.test.ts\"",
|
|
47
|
+
"test:rebuild": "pnpm build && pnpm test",
|
|
42
48
|
"typecheck": "tsc --noEmit"
|
|
43
49
|
}
|
|
44
50
|
}
|
package/lib/manifest.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { writeFile } from 'node:fs/promises'
|
|
2
|
-
import { extname, join } from 'node:path'
|
|
3
|
-
|
|
4
|
-
// catalog of build's filesystem output
|
|
5
|
-
export type BuildManifest = {
|
|
6
|
-
buildTag: string
|
|
7
|
-
files: Array<string>
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// functional data for service worker
|
|
11
|
-
export type CacheManifest = {
|
|
12
|
-
apiRoutes: Array<string>
|
|
13
|
-
buildTag: string
|
|
14
|
-
files: Array<string>
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function writeBuildManifest(buildTag: string, files: Set<string>) {
|
|
18
|
-
await writeJsonToBuildDir('manifest.json', {
|
|
19
|
-
buildTag,
|
|
20
|
-
files: Array.from(files).map(f =>
|
|
21
|
-
extname(f).length
|
|
22
|
-
? f
|
|
23
|
-
: f === '/'
|
|
24
|
-
? '/index.html'
|
|
25
|
-
: f + '/index.html',
|
|
26
|
-
),
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export async function writeJsonToBuildDir(
|
|
31
|
-
filename: `${string}.json`,
|
|
32
|
-
json: any,
|
|
33
|
-
) {
|
|
34
|
-
await writeFile(join('./build', filename), JSON.stringify(json, null, 4))
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export async function writeMetafile(filename: `${string}.json`, json: any) {
|
|
38
|
-
await writeJsonToBuildDir(
|
|
39
|
-
join('metafiles', filename) as `${string}.json`,
|
|
40
|
-
json,
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export async function writeCacheManifest(buildTag: string, files: Set<string>) {
|
|
45
|
-
await writeJsonToBuildDir('cache.json', {
|
|
46
|
-
apiRoutes: [],
|
|
47
|
-
buildTag,
|
|
48
|
-
files: Array.from(files).map(filenameToWebappPath),
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// drops index.html from path
|
|
53
|
-
function filenameToWebappPath(p: string): string {
|
|
54
|
-
if (p === '/index.html') {
|
|
55
|
-
return '/'
|
|
56
|
-
} else if (p.endsWith('/index.html')) {
|
|
57
|
-
return p.substring(0, p.length - '/index.html'.length) as `/${string}`
|
|
58
|
-
} else {
|
|
59
|
-
return p
|
|
60
|
-
}
|
|
61
|
-
}
|
package/lib_js/manifest.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { writeFile } from 'node:fs/promises';
|
|
2
|
-
import { extname, join } from 'node:path';
|
|
3
|
-
export async function writeBuildManifest(buildTag, files) {
|
|
4
|
-
await writeJsonToBuildDir('manifest.json', {
|
|
5
|
-
buildTag,
|
|
6
|
-
files: Array.from(files).map(f => extname(f).length
|
|
7
|
-
? f
|
|
8
|
-
: f === '/'
|
|
9
|
-
? '/index.html'
|
|
10
|
-
: f + '/index.html'),
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
export async function writeJsonToBuildDir(filename, json) {
|
|
14
|
-
await writeFile(join('./build', filename), JSON.stringify(json, null, 4));
|
|
15
|
-
}
|
|
16
|
-
export async function writeMetafile(filename, json) {
|
|
17
|
-
await writeJsonToBuildDir(join('metafiles', filename), json);
|
|
18
|
-
}
|
|
19
|
-
export async function writeCacheManifest(buildTag, files) {
|
|
20
|
-
await writeJsonToBuildDir('cache.json', {
|
|
21
|
-
apiRoutes: [],
|
|
22
|
-
buildTag,
|
|
23
|
-
files: Array.from(files).map(filenameToWebappPath),
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
// drops index.html from path
|
|
27
|
-
function filenameToWebappPath(p) {
|
|
28
|
-
if (p === '/index.html') {
|
|
29
|
-
return '/';
|
|
30
|
-
}
|
|
31
|
-
else if (p.endsWith('/index.html')) {
|
|
32
|
-
return p.substring(0, p.length - '/index.html'.length);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return p;
|
|
36
|
-
}
|
|
37
|
-
}
|