@johnhenry/sitefile 0.0.2 → 0.0.4

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.
Files changed (136) hide show
  1. package/CHANGELOG.md +516 -0
  2. package/README.md +59 -9
  3. package/lib/src/archive-writers.d.ts +12 -2
  4. package/lib/src/archive-writers.js +53 -10
  5. package/lib/src/bake.d.ts +2 -0
  6. package/lib/src/bake.js +30 -1
  7. package/lib/src/bcrypt.d.ts +25 -0
  8. package/lib/src/bcrypt.js +201 -0
  9. package/lib/src/canonical.d.ts +19 -0
  10. package/lib/src/canonical.js +60 -0
  11. package/lib/src/car.d.ts +34 -0
  12. package/lib/src/car.js +203 -0
  13. package/lib/src/checklinks.js +8 -2
  14. package/lib/src/cli/bake.js +4 -3
  15. package/lib/src/cli/build-image.d.ts +1 -0
  16. package/lib/src/cli/build-image.js +1 -0
  17. package/lib/src/cli/common.js +4 -1
  18. package/lib/src/cli/hosts.d.ts +5 -0
  19. package/lib/src/cli/hosts.js +78 -0
  20. package/lib/src/cli/images.js +23 -5
  21. package/lib/src/cli/import-config.d.ts +2 -0
  22. package/lib/src/cli/import-config.js +56 -0
  23. package/lib/src/cli/index.d.ts +6 -1
  24. package/lib/src/cli/index.js +34 -2
  25. package/lib/src/cli/integrity.d.ts +2 -0
  26. package/lib/src/cli/integrity.js +77 -0
  27. package/lib/src/cli/network.d.ts +7 -0
  28. package/lib/src/cli/network.js +14 -3
  29. package/lib/src/cli/serve-keys.d.ts +39 -0
  30. package/lib/src/cli/serve-keys.js +106 -0
  31. package/lib/src/cli/serve-worker.js +119 -8
  32. package/lib/src/cli/servers.d.ts +130 -1
  33. package/lib/src/cli/servers.js +754 -72
  34. package/lib/src/cli/up.d.ts +2 -0
  35. package/lib/src/cli/up.js +193 -0
  36. package/lib/src/cli/watch.d.ts +14 -1
  37. package/lib/src/cli/watch.js +20 -3
  38. package/lib/src/cli.js +138 -18
  39. package/lib/src/csp.d.ts +17 -0
  40. package/lib/src/csp.js +52 -0
  41. package/lib/src/dictionary.d.ts +16 -0
  42. package/lib/src/dictionary.js +89 -0
  43. package/lib/src/epub.d.ts +5 -0
  44. package/lib/src/epub.js +113 -0
  45. package/lib/src/errors.d.ts +22 -9
  46. package/lib/src/errors.js +20 -1
  47. package/lib/src/executor.d.ts +31 -1
  48. package/lib/src/executor.js +231 -24
  49. package/lib/src/explain.js +33 -3
  50. package/lib/src/export-for.d.ts +42 -0
  51. package/lib/src/export-for.js +466 -0
  52. package/lib/src/export-formats.d.ts +2 -2
  53. package/lib/src/export-formats.js +52 -2
  54. package/lib/src/fingerprint.d.ts +3 -1
  55. package/lib/src/fingerprint.js +32 -5
  56. package/lib/src/host-config.d.ts +34 -0
  57. package/lib/src/host-config.js +645 -0
  58. package/lib/src/hosts.d.ts +47 -0
  59. package/lib/src/hosts.js +106 -0
  60. package/lib/src/hreflang.d.ts +25 -0
  61. package/lib/src/hreflang.js +72 -0
  62. package/lib/src/index.d.ts +1 -1
  63. package/lib/src/index.js +1 -1
  64. package/lib/src/integrity.d.ts +115 -0
  65. package/lib/src/integrity.js +273 -0
  66. package/lib/src/language/ast.d.ts +126 -3
  67. package/lib/src/language/ast.js +7 -1
  68. package/lib/src/language/parser.js +189 -7
  69. package/lib/src/language/validate.js +24 -0
  70. package/lib/src/links.d.ts +47 -0
  71. package/lib/src/links.js +289 -3
  72. package/lib/src/lint.d.ts +1 -1
  73. package/lib/src/lint.js +26 -1
  74. package/lib/src/mime-data.d.ts +2 -0
  75. package/lib/src/mime-data.js +92 -0
  76. package/lib/src/oci.d.ts +20 -2
  77. package/lib/src/oci.js +70 -28
  78. package/lib/src/outdated.d.ts +3 -0
  79. package/lib/src/outdated.js +4 -4
  80. package/lib/src/planner.d.ts +87 -2
  81. package/lib/src/planner.js +189 -8
  82. package/lib/src/plugins/cache.d.ts +11 -0
  83. package/lib/src/plugins/cache.js +29 -0
  84. package/lib/src/plugins/host.d.ts +51 -2
  85. package/lib/src/plugins/host.js +141 -16
  86. package/lib/src/plugins/wasm.js +1 -3
  87. package/lib/src/portable.d.ts +8 -0
  88. package/lib/src/portable.js +47 -0
  89. package/lib/src/precache.d.ts +33 -0
  90. package/lib/src/precache.js +75 -0
  91. package/lib/src/precompress.d.ts +19 -0
  92. package/lib/src/precompress.js +35 -0
  93. package/lib/src/qr.d.ts +18 -0
  94. package/lib/src/qr.js +372 -0
  95. package/lib/src/registry-ops.js +4 -2
  96. package/lib/src/reload-client.d.ts +2 -0
  97. package/lib/src/reload-client.js +419 -0
  98. package/lib/src/resources/archive.d.ts +37 -1
  99. package/lib/src/resources/archive.js +353 -71
  100. package/lib/src/resources/convert.js +3 -1
  101. package/lib/src/resources/https.d.ts +9 -1
  102. package/lib/src/resources/https.js +36 -0
  103. package/lib/src/resources/network.d.ts +25 -3
  104. package/lib/src/resources/network.js +77 -6
  105. package/lib/src/secrets.d.ts +12 -3
  106. package/lib/src/secrets.js +18 -5
  107. package/lib/src/serve-auth.d.ts +33 -0
  108. package/lib/src/serve-auth.js +120 -0
  109. package/lib/src/serve-rules.d.ts +83 -7
  110. package/lib/src/serve-rules.js +264 -53
  111. package/lib/src/server.d.ts +529 -11
  112. package/lib/src/server.js +1439 -57
  113. package/lib/src/servers-file.d.ts +36 -0
  114. package/lib/src/servers-file.js +101 -0
  115. package/lib/src/servers.d.ts +115 -7
  116. package/lib/src/servers.js +151 -29
  117. package/lib/src/single-file.d.ts +12 -0
  118. package/lib/src/single-file.js +147 -0
  119. package/lib/src/site.d.ts +58 -0
  120. package/lib/src/site.js +216 -5
  121. package/lib/src/store.js +9 -5
  122. package/lib/src/swbn.d.ts +10 -0
  123. package/lib/src/swbn.js +86 -0
  124. package/lib/src/toml.d.ts +17 -0
  125. package/lib/src/toml.js +323 -0
  126. package/lib/src/wacz.d.ts +6 -0
  127. package/lib/src/wacz.js +96 -0
  128. package/lib/src/warc.d.ts +28 -0
  129. package/lib/src/warc.js +252 -0
  130. package/lib/src/watch.d.ts +12 -1
  131. package/lib/src/watch.js +67 -1
  132. package/lib/src/wbn.d.ts +9 -1
  133. package/lib/src/wbn.js +23 -33
  134. package/lib/src/zstd.d.ts +4 -0
  135. package/lib/src/zstd.js +328 -0
  136. package/package.json +1 -1
@@ -1,14 +1,143 @@
1
+ import { type CachePreview, type HostProfileName, type HtmlHandling, type SyncMode } from '../server.js';
1
2
  import { ServerRegistry, type ServerState } from '../servers.js';
2
- import { type Command } from './common.js';
3
+ import { type AuthEntry } from '../serve-auth.js';
4
+ import type { Plan } from '../planner.js';
5
+ import { Store } from '../store.js';
6
+ import { type Command, type ParsedValues } from './common.js';
3
7
  /** `-p` value: `port`, `host:port` or `[v6]:port`. Default bind is 127.0.0.1 with a free port. */
4
8
  export declare function parsePublish(spec: string | undefined): {
5
9
  host: string;
6
10
  port: number;
7
11
  };
12
+ /** `--spa`, `--spa-exclude` and `--spa-fallback` (which implies `--spa`), as server options. */
13
+ export declare function spaOptions(v: ParsedValues): {
14
+ spa: boolean;
15
+ spaExclude?: string[];
16
+ spaFallback?: string;
17
+ };
18
+ /** `--base`: the path prefix to serve under (`/repo/`), or undefined for `/`. */
19
+ export declare function parseBase(v: string | undefined): string | undefined;
20
+ /** The path of an EXPORT BASE that is an http(s) URL (`https://user.github.io/repo/` → `/repo/`), else undefined. */
21
+ export declare function exportBasePath(exportBase: string | undefined): string | undefined;
22
+ /** `--rewrite-base <url>`: the production URL, normalized; usage error when it is not an http(s) URL. */
23
+ export declare function parseRewriteBase(v: string | undefined): string | undefined;
24
+ /** A build's production URL (`serve --watch`): its EXPORT BASE when that is an http(s) URL, else the first SITEMAP or FEED BASE. */
25
+ export declare function productionUrl(plan: Plan): string | undefined;
26
+ /** `--host-profile` and `--html-handling`, checked: the names, or usage errors. */
27
+ export declare function profileOptions(v: ParsedValues): {
28
+ hostProfile?: HostProfileName;
29
+ htmlHandling?: HtmlHandling;
30
+ };
31
+ /** `--country`: an ISO 3166-1 alpha-2 code (any case). */
32
+ export declare function parseCountry(v: string | undefined): string | undefined;
33
+ declare function isFile(p: string): Promise<boolean>;
34
+ /** An archive file source: labelled by its absolute path, stored by its real path. */
35
+ export declare function archiveSource(arg: string): Promise<{
36
+ label: string;
37
+ source: ServerState['source'];
38
+ }>;
39
+ /**
40
+ * A directory or archive file when `arg` looks like a path, else an image reference or ID, else an
41
+ * archive file by that name (`site.zip`). Whether a file is an archive is checked when it is loaded.
42
+ */
43
+ export declare function resolveSource(store: Store, arg: string): Promise<{
44
+ label: string;
45
+ source: ServerState['source'];
46
+ }>;
47
+ /** What a detached server serves and how (`serve -d`, `sitefile up`). */
48
+ export interface DetachedServe {
49
+ readonly label: string;
50
+ readonly source: ServerState['source'];
51
+ readonly name?: string | undefined;
52
+ readonly bind: {
53
+ readonly host: string;
54
+ readonly port: number;
55
+ };
56
+ readonly spa: boolean;
57
+ /** `--spa-exclude`. */
58
+ readonly spaExclude?: readonly string[] | undefined;
59
+ /** `--spa-fallback`. */
60
+ readonly spaFallback?: string | undefined;
61
+ /** `--base` (normalized; undefined for `/`). */
62
+ readonly base?: string | undefined;
63
+ /** `--rewrite-base` (normalized). */
64
+ readonly rewriteBase?: string | undefined;
65
+ /** `--host-profile`. */
66
+ readonly hostProfile?: HostProfileName | undefined;
67
+ /** `--html-handling`. */
68
+ readonly htmlHandling?: HtmlHandling | undefined;
69
+ /** `--keep-os-metadata`. */
70
+ readonly keepOsMetadata?: boolean | undefined;
71
+ /** `--allowed-host` names. */
72
+ readonly allowedHosts?: readonly string[] | undefined;
73
+ /** `--cors`. */
74
+ readonly cors?: boolean | undefined;
75
+ /** `--isolate`: the COEP value. */
76
+ readonly isolate?: 'require-corp' | 'credentialless' | undefined;
77
+ /** `--max-age`, `--immutable`, `--max-age-html`. */
78
+ readonly cache?: CachePreview | undefined;
79
+ /** `--log-format json`. */
80
+ readonly logFormat?: 'json' | undefined;
81
+ /** `--log-ip`. */
82
+ readonly logIp?: boolean | undefined;
83
+ /** `--quiet`. */
84
+ readonly quiet?: boolean | undefined;
85
+ /** `--auth` verifiers. */
86
+ readonly auth?: AuthEntry[] | undefined;
87
+ /** `--auth-file`, an absolute path read at every start. */
88
+ readonly authFile?: string | undefined;
89
+ /** `--max-connections-per-ip` (absent: no limit). */
90
+ readonly maxConnectionsPerIp?: number | undefined;
91
+ /** `--random-route` prefix. */
92
+ readonly hideBase?: boolean | undefined;
93
+ /** `--allow-ip`, `--deny-ip` blocks as given. */
94
+ readonly allowIp?: string[] | undefined;
95
+ readonly denyIp?: string[] | undefined;
96
+ /** `--stop-after`: when the server stops (ISO time). */
97
+ readonly expires?: string | undefined;
98
+ /** `--compress`. */
99
+ readonly compress?: boolean | undefined;
100
+ /** `--throttle` as given. */
101
+ readonly throttle?: string | undefined;
102
+ /** `--mime`, `--mime-file`: extension → content type. */
103
+ readonly mime?: Record<string, string> | undefined;
104
+ /** `--tls-cert`, `--tls-key`, absolute paths. */
105
+ readonly tlsCert?: string | undefined;
106
+ readonly tlsKey?: string | undefined;
107
+ /** `--country`. */
108
+ readonly country?: string | undefined;
109
+ /** `--strict-site-files`. */
110
+ readonly strictSiteFiles?: boolean | undefined;
111
+ /** `-d --watch`: a directory source re-read on change, with live reload. */
112
+ readonly watch?: boolean | undefined;
113
+ /** `--poll`, `--poll-interval` with `-d --watch`. */
114
+ readonly pollMs?: number | undefined;
115
+ /** `--sync` with `-d --watch`. */
116
+ readonly sync?: SyncMode | undefined;
117
+ /** The servers file it belongs to (`sitefile up`). */
118
+ readonly project?: string | undefined;
119
+ }
120
+ /**
121
+ * `serve -d`: check that the source loads, allocate an ID and name, record the server, start its worker and
122
+ * wait until it listens. On failure the record is removed.
123
+ */
124
+ export declare function serveDetached(reg: ServerRegistry, d: DetachedServe, warn?: (m: string) => void): Promise<ServerState>;
125
+ /**
126
+ * `server restart`: stop `s` if it is running, then start it again with the same ID, name, source and
127
+ * requested bind address. On failure the record stays, marked not ready.
128
+ */
129
+ export declare function restartDetached(reg: ServerRegistry, s: ServerState, graceMs: number): Promise<ServerState>;
130
+ /** `--proxy /prefix=url`: a path prefix (no trailing slash, except `/`) and an http(s) URL. */
131
+ export declare function parseProxyRoute(raw: string): {
132
+ prefix: string;
133
+ target: string;
134
+ };
8
135
  /** SIGTERM, wait, then SIGKILL. Returns false if the server was not running. */
9
136
  export declare function stopServer(reg: ServerRegistry, s: ServerState, graceMs: number): Promise<boolean>;
137
+ export declare function graceOf(v: ParsedValues): number;
10
138
  /** The last n lines of text, each newline-terminated; a trailing newline is not an extra empty line. */
11
139
  export declare function tailLines(text: string, n: number): string;
140
+ export { isFile };
12
141
  /** Top-level: `sitefile serve`, `sitefile servers`. */
13
142
  export declare const serverCommands: ReadonlyMap<string, Command>;
14
143
  /** `sitefile server <ls|stop|rm|logs|restart>`. */