@johnhenry/sitefile 0.0.0-stage → 0.0.1

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 (178) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/LICENSE +21 -0
  3. package/README.md +513 -2
  4. package/lib/src/archive-writers.d.ts +31 -0
  5. package/lib/src/archive-writers.js +197 -0
  6. package/lib/src/attest.d.ts +126 -0
  7. package/lib/src/attest.js +220 -0
  8. package/lib/src/bake.d.ts +74 -0
  9. package/lib/src/bake.js +372 -0
  10. package/lib/src/base-image.d.ts +76 -0
  11. package/lib/src/base-image.js +138 -0
  12. package/lib/src/build-args.d.ts +26 -0
  13. package/lib/src/build-args.js +164 -0
  14. package/lib/src/cache-limit.d.ts +54 -0
  15. package/lib/src/cache-limit.js +239 -0
  16. package/lib/src/casefold-data.d.ts +2 -0
  17. package/lib/src/casefold-data.js +217 -0
  18. package/lib/src/cbor.d.ts +39 -0
  19. package/lib/src/cbor.js +174 -0
  20. package/lib/src/checklinks.d.ts +42 -0
  21. package/lib/src/checklinks.js +120 -0
  22. package/lib/src/cli/bake.d.ts +2 -0
  23. package/lib/src/cli/bake.js +179 -0
  24. package/lib/src/cli/build-image.d.ts +21 -0
  25. package/lib/src/cli/build-image.js +42 -0
  26. package/lib/src/cli/cache.d.ts +8 -0
  27. package/lib/src/cli/cache.js +119 -0
  28. package/lib/src/cli/common.d.ts +29 -0
  29. package/lib/src/cli/common.js +100 -0
  30. package/lib/src/cli/git-context.d.ts +18 -0
  31. package/lib/src/cli/git-context.js +48 -0
  32. package/lib/src/cli/images.d.ts +6 -0
  33. package/lib/src/cli/images.js +285 -0
  34. package/lib/src/cli/index.d.ts +10 -0
  35. package/lib/src/cli/index.js +95 -0
  36. package/lib/src/cli/network.d.ts +34 -0
  37. package/lib/src/cli/network.js +56 -0
  38. package/lib/src/cli/outdated.d.ts +5 -0
  39. package/lib/src/cli/outdated.js +99 -0
  40. package/lib/src/cli/registry.d.ts +2 -0
  41. package/lib/src/cli/registry.js +127 -0
  42. package/lib/src/cli/serve-worker.d.ts +2 -0
  43. package/lib/src/cli/serve-worker.js +42 -0
  44. package/lib/src/cli/servers.d.ts +15 -0
  45. package/lib/src/cli/servers.js +467 -0
  46. package/lib/src/cli/vendor.d.ts +2 -0
  47. package/lib/src/cli/vendor.js +97 -0
  48. package/lib/src/cli/watch.d.ts +26 -0
  49. package/lib/src/cli/watch.js +81 -0
  50. package/lib/src/cli.d.ts +12 -0
  51. package/lib/src/cli.js +522 -0
  52. package/lib/src/csv.d.ts +27 -0
  53. package/lib/src/csv.js +117 -0
  54. package/lib/src/deflate.d.ts +76 -0
  55. package/lib/src/deflate.js +604 -0
  56. package/lib/src/digest.d.ts +3 -0
  57. package/lib/src/digest.js +7 -0
  58. package/lib/src/errors.d.ts +56 -0
  59. package/lib/src/errors.js +29 -0
  60. package/lib/src/executor.d.ts +393 -0
  61. package/lib/src/executor.js +2201 -0
  62. package/lib/src/explain.d.ts +64 -0
  63. package/lib/src/explain.js +445 -0
  64. package/lib/src/export-formats.d.ts +23 -0
  65. package/lib/src/export-formats.js +63 -0
  66. package/lib/src/exporter.d.ts +103 -0
  67. package/lib/src/exporter.js +676 -0
  68. package/lib/src/fingerprint.d.ts +40 -0
  69. package/lib/src/fingerprint.js +168 -0
  70. package/lib/src/frontmatter.d.ts +22 -0
  71. package/lib/src/frontmatter.js +45 -0
  72. package/lib/src/index.d.ts +13 -0
  73. package/lib/src/index.js +13 -0
  74. package/lib/src/language/ast.d.ts +360 -0
  75. package/lib/src/language/ast.js +57 -0
  76. package/lib/src/language/parser.d.ts +3 -0
  77. package/lib/src/language/parser.js +612 -0
  78. package/lib/src/language/scanner.d.ts +110 -0
  79. package/lib/src/language/scanner.js +449 -0
  80. package/lib/src/language/validate.d.ts +13 -0
  81. package/lib/src/language/validate.js +367 -0
  82. package/lib/src/links.d.ts +79 -0
  83. package/lib/src/links.js +583 -0
  84. package/lib/src/lint.d.ts +10 -0
  85. package/lib/src/lint.js +223 -0
  86. package/lib/src/markdown.d.ts +29 -0
  87. package/lib/src/markdown.js +612 -0
  88. package/lib/src/media.d.ts +82 -0
  89. package/lib/src/media.js +650 -0
  90. package/lib/src/memo.d.ts +57 -0
  91. package/lib/src/memo.js +93 -0
  92. package/lib/src/oci.d.ts +178 -0
  93. package/lib/src/oci.js +380 -0
  94. package/lib/src/outdated.d.ts +46 -0
  95. package/lib/src/outdated.js +195 -0
  96. package/lib/src/pages.d.ts +10 -0
  97. package/lib/src/pages.js +54 -0
  98. package/lib/src/paths.d.ts +39 -0
  99. package/lib/src/paths.js +101 -0
  100. package/lib/src/planner.d.ts +297 -0
  101. package/lib/src/planner.js +410 -0
  102. package/lib/src/plugins/cache.d.ts +96 -0
  103. package/lib/src/plugins/cache.js +325 -0
  104. package/lib/src/plugins/exec.d.ts +51 -0
  105. package/lib/src/plugins/exec.js +144 -0
  106. package/lib/src/plugins/host.d.ts +75 -0
  107. package/lib/src/plugins/host.js +277 -0
  108. package/lib/src/plugins/wasm.d.ts +23 -0
  109. package/lib/src/plugins/wasm.js +249 -0
  110. package/lib/src/profile.d.ts +42 -0
  111. package/lib/src/profile.js +68 -0
  112. package/lib/src/ref.d.ts +40 -0
  113. package/lib/src/ref.js +79 -0
  114. package/lib/src/registry-auth.d.ts +32 -0
  115. package/lib/src/registry-auth.js +151 -0
  116. package/lib/src/registry-cache.d.ts +71 -0
  117. package/lib/src/registry-cache.js +333 -0
  118. package/lib/src/registry-ops.d.ts +51 -0
  119. package/lib/src/registry-ops.js +248 -0
  120. package/lib/src/registry.d.ts +115 -0
  121. package/lib/src/registry.js +524 -0
  122. package/lib/src/render.d.ts +134 -0
  123. package/lib/src/render.js +576 -0
  124. package/lib/src/resources/archive.d.ts +11 -0
  125. package/lib/src/resources/archive.js +306 -0
  126. package/lib/src/resources/bundle-data.d.ts +16 -0
  127. package/lib/src/resources/bundle-data.js +50 -0
  128. package/lib/src/resources/convert.d.ts +12 -0
  129. package/lib/src/resources/convert.js +63 -0
  130. package/lib/src/resources/documents.d.ts +35 -0
  131. package/lib/src/resources/documents.js +122 -0
  132. package/lib/src/resources/git.d.ts +103 -0
  133. package/lib/src/resources/git.js +720 -0
  134. package/lib/src/resources/https.d.ts +74 -0
  135. package/lib/src/resources/https.js +413 -0
  136. package/lib/src/resources/ignore.d.ts +33 -0
  137. package/lib/src/resources/ignore.js +119 -0
  138. package/lib/src/resources/local.d.ts +64 -0
  139. package/lib/src/resources/local.js +248 -0
  140. package/lib/src/resources/lockfile.d.ts +52 -0
  141. package/lib/src/resources/lockfile.js +172 -0
  142. package/lib/src/resources/netpolicy.d.ts +6 -0
  143. package/lib/src/resources/netpolicy.js +82 -0
  144. package/lib/src/resources/network.d.ts +70 -0
  145. package/lib/src/resources/network.js +304 -0
  146. package/lib/src/resources/types.d.ts +69 -0
  147. package/lib/src/resources/types.js +13 -0
  148. package/lib/src/resources/vendor.d.ts +94 -0
  149. package/lib/src/resources/vendor.js +296 -0
  150. package/lib/src/resources/wbn-reader.d.ts +44 -0
  151. package/lib/src/resources/wbn-reader.js +302 -0
  152. package/lib/src/schema.d.ts +25 -0
  153. package/lib/src/schema.js +169 -0
  154. package/lib/src/secrets.d.ts +21 -0
  155. package/lib/src/secrets.js +103 -0
  156. package/lib/src/serve-rules.d.ts +29 -0
  157. package/lib/src/serve-rules.js +123 -0
  158. package/lib/src/server.d.ts +45 -0
  159. package/lib/src/server.js +246 -0
  160. package/lib/src/servers.d.ts +85 -0
  161. package/lib/src/servers.js +225 -0
  162. package/lib/src/site.d.ts +60 -0
  163. package/lib/src/site.js +169 -0
  164. package/lib/src/store.d.ts +151 -0
  165. package/lib/src/store.js +596 -0
  166. package/lib/src/tree.d.ts +50 -0
  167. package/lib/src/tree.js +134 -0
  168. package/lib/src/values.d.ts +7 -0
  169. package/lib/src/values.js +37 -0
  170. package/lib/src/vendor.d.ts +19 -0
  171. package/lib/src/vendor.js +145 -0
  172. package/lib/src/watch.d.ts +44 -0
  173. package/lib/src/watch.js +137 -0
  174. package/lib/src/wbn.d.ts +26 -0
  175. package/lib/src/wbn.js +241 -0
  176. package/lib/src/yaml.d.ts +34 -0
  177. package/lib/src/yaml.js +562 -0
  178. package/package.json +59 -4
@@ -0,0 +1,103 @@
1
+ import type { Tree } from './tree.js';
2
+ export interface ExportOptions {
3
+ /** The build context. The destination may never be, or contain, it. */
4
+ readonly contextDir: string;
5
+ /** Replace a non-empty destination outside the context. */
6
+ readonly force?: boolean;
7
+ /**
8
+ * TEST-ONLY. Awaited after the temp tree is fully written and immediately
9
+ * before the final re-validation and swap, so tests can deterministically
10
+ * simulate a concurrent change to the destination. Not exposed by the CLI.
11
+ * @internal
12
+ */
13
+ readonly beforeSwap?: () => Promise<void>;
14
+ /**
15
+ * Watch mode (directory exports only): what the previous export of this session left on
16
+ * disk. When the destination still holds exactly that, only the files that changed are
17
+ * written ({@link ExportState}); either way the export is recorded for the next one.
18
+ */
19
+ readonly incremental?: ExportState;
20
+ /**
21
+ * TEST-ONLY. Incremental export: awaited after the changed files are staged, before any
22
+ * of them is moved into the destination. @internal
23
+ */
24
+ readonly beforeApply?: () => Promise<void>;
25
+ }
26
+ export interface ExportResult {
27
+ /** Real absolute path the tree was written to. */
28
+ readonly outDir: string;
29
+ readonly files: number;
30
+ /** Set when only the changes were applied in place (incremental export). */
31
+ readonly incremental?: {
32
+ readonly written: number;
33
+ readonly removed: number;
34
+ };
35
+ }
36
+ /**
37
+ * The temp directory starts empty and the tree has no two paths equal under
38
+ * case folding, so EEXIST/ENOTDIR/EISDIR here means the destination file
39
+ * system treats two different tree paths as one name (a folding or
40
+ * normalization rule wider than Sitefile's). Report the artifact path, not the
41
+ * temp path.
42
+ */
43
+ export declare function occupied(e: unknown, p: string): unknown;
44
+ /** Matches the exporter's temporary (`tmp`) and backup (`old`) sibling names. */
45
+ export declare const TEMP_PREFIX_PATTERN: RegExp;
46
+ /** True if `name` is a temp/backup sibling the exporter creates for `outBasename`. */
47
+ export declare function isExporterTempName(name: string, outBasename: string): boolean;
48
+ /**
49
+ * Materialize `tree` as a directory at `outDir`. Files are written into a
50
+ * fresh temporary sibling, which is then swapped in; on failure the previous
51
+ * destination (if any) is left in place.
52
+ */
53
+ export declare function exportDirectory(tree: Tree, outDir: string, options: ExportOptions): Promise<ExportResult>;
54
+ /** What a watch session's last directory export left on disk; see {@link ExportOptions.incremental}. */
55
+ export declare class ExportState {
56
+ /** @internal */
57
+ snapshot: Snapshot | undefined;
58
+ /** Forget the last export: the next one rewrites everything. */
59
+ clear(): void;
60
+ }
61
+ interface Stamp {
62
+ readonly dev: number;
63
+ readonly ino: number;
64
+ readonly size: number;
65
+ readonly mtimeMs: number;
66
+ readonly ctimeMs: number;
67
+ readonly mode: number;
68
+ }
69
+ interface Recorded {
70
+ readonly digest: string;
71
+ readonly mode: number;
72
+ readonly stamp: Stamp;
73
+ }
74
+ interface Snapshot {
75
+ readonly outReal: string;
76
+ readonly outId: FileId;
77
+ readonly parentId: FileId;
78
+ /** Artifact path (`/a/b.html`) → what was written there. */
79
+ readonly files: ReadonlyMap<string, Recorded>;
80
+ /** Every directory below the destination (`/a`, `/a/b`). */
81
+ readonly dirs: ReadonlySet<string>;
82
+ }
83
+ export interface ExportFileResult {
84
+ /** Real absolute path of the file that was written. */
85
+ readonly outFile: string;
86
+ readonly bytes: number;
87
+ }
88
+ /**
89
+ * Write `data` as a single file at `outFile` (zip, tar, tgz, wbn). Same
90
+ * destination rules as {@link exportDirectory}: never the filesystem root, the
91
+ * home directory, the build context or a parent of it; never through a symlink;
92
+ * a directory is refused; an existing file outside the context needs
93
+ * `force`. The bytes go to a temporary sibling that is renamed into place after
94
+ * the parent and destination are re-validated; only that exact temp file (by
95
+ * dev/ino) is ever deleted, and nothing already at `outFile` is removed except
96
+ * by the replacing rename.
97
+ */
98
+ export declare function exportFile(data: Uint8Array, outFile: string, options: ExportOptions): Promise<ExportFileResult>;
99
+ interface FileId {
100
+ readonly dev: number | bigint;
101
+ readonly ino: number | bigint;
102
+ }
103
+ export {};