yamlover 0.3.3 → 0.3.5

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 (137) hide show
  1. package/bin/yamlover.js +199 -112
  2. package/dist/client/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  3. package/dist/client/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  4. package/dist/client/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  5. package/dist/client/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  6. package/dist/client/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  7. package/dist/client/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  8. package/dist/client/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  9. package/dist/client/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  10. package/dist/client/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  11. package/dist/client/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  12. package/dist/client/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  13. package/dist/client/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  14. package/dist/client/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  15. package/dist/client/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  16. package/dist/client/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  17. package/dist/client/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  18. package/dist/client/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  19. package/dist/client/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  20. package/dist/client/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  21. package/dist/client/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  22. package/dist/client/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  23. package/dist/client/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  24. package/dist/client/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  25. package/dist/client/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  26. package/dist/client/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  27. package/dist/client/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  28. package/dist/client/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  29. package/dist/client/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  30. package/dist/client/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  31. package/dist/client/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  32. package/dist/client/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  33. package/dist/client/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  34. package/dist/client/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  35. package/dist/client/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  36. package/dist/client/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  37. package/dist/client/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  38. package/dist/client/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  39. package/dist/client/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  40. package/dist/client/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  41. package/dist/client/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  42. package/dist/client/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  43. package/dist/client/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  44. package/dist/client/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  45. package/dist/client/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  46. package/dist/client/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  47. package/dist/client/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  48. package/dist/client/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  49. package/dist/client/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  50. package/dist/client/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  51. package/dist/client/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  52. package/dist/client/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  53. package/dist/client/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  54. package/dist/client/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  55. package/dist/client/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  56. package/dist/client/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  57. package/dist/client/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  58. package/dist/client/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  59. package/dist/client/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  60. package/dist/client/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  61. package/dist/client/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
  62. package/dist/client/assets/decoded-DRWSdzgb.js +1 -0
  63. package/dist/client/assets/djvu-CD0wXtTp.js +1 -0
  64. package/dist/client/assets/docx-BP_KsH_m.js +230 -0
  65. package/dist/client/assets/heic-B_4kLge_.js +66 -0
  66. package/dist/client/assets/imagemap-j0tV2wtS.js +1 -0
  67. package/dist/client/assets/index-BiwY33f2.js +617 -0
  68. package/dist/client/assets/index-wTjOzmSY.css +1 -0
  69. package/dist/client/assets/map-Cb9TTMM9.js +1 -0
  70. package/dist/client/assets/paged-DK_n72xc.js +1 -0
  71. package/dist/client/assets/panzoom-CIGW-MKW.css +1 -0
  72. package/dist/client/assets/panzoom-tORQ67Sx.js +4 -0
  73. package/dist/client/assets/pdf-DfMLV_Qu.js +12 -0
  74. package/dist/client/assets/pdf-m5e3jsV4.css +1 -0
  75. package/dist/client/assets/pdf.worker.min-qwK7q_zL.mjs +28 -0
  76. package/dist/client/assets/psd-CVyrW016.js +11 -0
  77. package/dist/client/assets/spreadsheet-QnPEhgjy.js +38 -0
  78. package/dist/client/assets/tiff-BswbwivW.js +1 -0
  79. package/{index.html → dist/client/index.html} +2 -1
  80. package/dist/server.js +370 -109
  81. package/package.json +18 -21
  82. package/src/client/App.tsx +0 -424
  83. package/src/client/NodeView.tsx +0 -422
  84. package/src/client/TaskStrip.tsx +0 -34
  85. package/src/client/Tree.tsx +0 -97
  86. package/src/client/api.ts +0 -186
  87. package/src/client/icons.ts +0 -91
  88. package/src/client/links.tsx +0 -108
  89. package/src/client/live.ts +0 -42
  90. package/src/client/main.tsx +0 -10
  91. package/src/client/paste-html.ts +0 -228
  92. package/src/client/paste-links.ts +0 -42
  93. package/src/client/paths.ts +0 -139
  94. package/src/client/render.tsx +0 -326
  95. package/src/client/renderers/annotate.tsx +0 -521
  96. package/src/client/renderers/asciidoc.tsx +0 -35
  97. package/src/client/renderers/chapter.tsx +0 -138
  98. package/src/client/renderers/csv.tsx +0 -233
  99. package/src/client/renderers/decoded.tsx +0 -72
  100. package/src/client/renderers/djvu.tsx +0 -271
  101. package/src/client/renderers/djvuWorker.ts +0 -99
  102. package/src/client/renderers/doc.tsx +0 -40
  103. package/src/client/renderers/docx.tsx +0 -49
  104. package/src/client/renderers/epub.tsx +0 -147
  105. package/src/client/renderers/explorer.tsx +0 -294
  106. package/src/client/renderers/fb2.tsx +0 -149
  107. package/src/client/renderers/headings.ts +0 -69
  108. package/src/client/renderers/heic.tsx +0 -23
  109. package/src/client/renderers/imagemap.tsx +0 -157
  110. package/src/client/renderers/kml.ts +0 -46
  111. package/src/client/renderers/latex.tsx +0 -36
  112. package/src/client/renderers/map.tsx +0 -205
  113. package/src/client/renderers/marklower.tsx +0 -119
  114. package/src/client/renderers/markup.tsx +0 -64
  115. package/src/client/renderers/media.tsx +0 -19
  116. package/src/client/renderers/paged.ts +0 -137
  117. package/src/client/renderers/panzoom.ts +0 -101
  118. package/src/client/renderers/pdf.tsx +0 -316
  119. package/src/client/renderers/plaintext.tsx +0 -120
  120. package/src/client/renderers/plantuml.tsx +0 -82
  121. package/src/client/renderers/psd.tsx +0 -25
  122. package/src/client/renderers/registry.tsx +0 -389
  123. package/src/client/renderers/rtf.tsx +0 -210
  124. package/src/client/renderers/spreadsheet.tsx +0 -105
  125. package/src/client/renderers/tag.tsx +0 -113
  126. package/src/client/renderers/text.tsx +0 -41
  127. package/src/client/renderers/tiff.tsx +0 -33
  128. package/src/client/styles.css +0 -1190
  129. package/src/client/vendor/README.md +0 -30
  130. package/src/client/vite-env.d.ts +0 -31
  131. package/src/server/api.ts +0 -147
  132. package/src/server/engine-api.ts +0 -1442
  133. package/src/server/gitignore.ts +0 -81
  134. package/src/server/node-kind.ts +0 -48
  135. package/src/server/tasks.ts +0 -83
  136. package/src/server/yamlover.ts +0 -1133
  137. /package/{src/client/vendor/djvu.js → dist/client/assets/djvu-Ci0lFKxE.js} +0 -0
@@ -1,30 +0,0 @@
1
- # Vendored: DjVu.js
2
-
3
- `djvu.js` is a prebuilt bundle of the **DjVu.js library** by Roman Chistokhodov
4
- (RussCoder), used by the `djvu` renderer to decode `.djvu` documents in the
5
- browser (the browser has no native DjVu support).
6
-
7
- - Upstream: https://github.com/RussCoder/djvujs — https://djvu.js.org
8
- - Version: 0.5.4
9
- - **License: GNU GPL v2** (the library only; the upstream viewer/extension are
10
- Unlicense). By bundling it here, the distributed client includes GPL-v2 code.
11
- See https://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
12
-
13
- ## Why it's vendored
14
-
15
- The npm package `djvujs-dist` ships *source*, not an importable module (no
16
- `main`/`module`/`types`), and pulls a large dev toolchain. We build its IIFE
17
- bundle once and commit the single output here instead of depending on the
18
- package at runtime.
19
-
20
- ## Regenerating
21
-
22
- ```sh
23
- npm install djvujs-dist # temporary
24
- cd node_modules/djvujs-dist/library && npm run build
25
- cp dist/djvu.js <repo>/tools/server/src/client/vendor/djvu.js
26
- npm uninstall djvujs-dist
27
- ```
28
-
29
- The bundle defines a global `DjVu` (`var DjVu = (function(){…})()`); the renderer
30
- loads it as a classic `<script>` and uses `new DjVu.Document(arrayBuffer)`.
@@ -1,31 +0,0 @@
1
- /// <reference types="vite/client" />
2
-
3
- // UTIF.js ships no types. Declare the minimal surface our TIFF renderer uses:
4
- // decode the container into IFDs, decode each IFD's pixels in place, then read it
5
- // back as RGBA. See https://github.com/photopea/UTIF.js.
6
- declare module "utif" {
7
- interface IFD {
8
- width?: number;
9
- height?: number;
10
- [key: string]: unknown;
11
- }
12
- const UTIF: {
13
- decode(buf: ArrayBuffer | Uint8Array): IFD[];
14
- decodeImage(buf: ArrayBuffer | Uint8Array, ifd: IFD): void;
15
- toRGBA8(ifd: IFD): Uint8Array;
16
- };
17
- export default UTIF;
18
- }
19
-
20
- // mammoth's browser build ships no types. Declare the one call our docx renderer
21
- // makes: convert a .docx ArrayBuffer to an HTML string. See https://github.com/mwilliamson/mammoth.js.
22
- declare module "mammoth/mammoth.browser" {
23
- interface ConvertResult {
24
- value: string;
25
- messages: { type: string; message: string }[];
26
- }
27
- const mammoth: {
28
- convertToHtml(input: { arrayBuffer: ArrayBuffer }): Promise<ConvertResult>;
29
- };
30
- export default mammoth;
31
- }
package/src/server/api.ts DELETED
@@ -1,147 +0,0 @@
1
- /**
2
- * api.ts — the JSON API the SPA calls.
3
- *
4
- * Endpoints, all keyed by a JSON-space `path` (`/key[0]/sub`, no "properties"):
5
- *
6
- * GET /api/tree the table of contents (containers only)
7
- * GET /api/json?path&depth the node's value as JSON
8
- * GET /api/schema?path&depth&format the node's instance schema (json | yaml)
9
- * GET /api/blob?path a file-backed node's raw bytes (for the
10
- * image / pdf / html / djvu / markup renderers)
11
- *
12
- * The materialized tree is cached per server for a short window (leaf bytes load
13
- * lazily within it), so a burst of clicks does not re-read the filesystem; edits
14
- * show up after the cache window on reload.
15
- */
16
-
17
- import path from "node:path";
18
- import fs from "node:fs";
19
- import type { IncomingMessage, ServerResponse } from "node:http";
20
- import {
21
- loadEntity,
22
- getNode,
23
- strToSegs,
24
- buildTree,
25
- labelForSeg,
26
- toPlain,
27
- toSchema,
28
- buildRelations,
29
- binaryContent,
30
- displayTypeLabel,
31
- documentPath,
32
- formatFromExt,
33
- setIgnoreFilter,
34
- YNode,
35
- } from "./yamlover.js";
36
- import { buildGitIgnore } from "./gitignore.js";
37
-
38
- type Handler = (req: IncomingMessage, res: ServerResponse, url: URL) => void;
39
-
40
- interface Options {
41
- gitignore?: boolean; // honor .gitignore for stray files (default: true)
42
- }
43
-
44
- // The materialized tree is cached this long. With lazy directory loading the
45
- // cached tree *accumulates* the levels you browse (each read once and memoized),
46
- // so a longer window keeps navigation warm; edits show after it on reload.
47
- const CACHE_TTL_MS = 15000;
48
-
49
- export function createHandlers(dataRoot: string, opts: Options = {}): Handler {
50
- // The root label (breadcrumb head and TOC root): the yamlover title if set,
51
- // else the served directory's name — always non-empty.
52
- const rootName = path.basename(path.resolve(dataRoot)) || "/";
53
- setIgnoreFilter(opts.gitignore === false ? () => false : buildGitIgnore(dataRoot));
54
-
55
- let cache: { root: YNode; time: number } | null = null;
56
- const root = (): YNode => {
57
- const now = Date.now();
58
- if (!cache || now - cache.time > CACHE_TTL_MS) cache = { root: loadEntity(dataRoot), time: now };
59
- return cache.root;
60
- };
61
-
62
- return (_req, res, url) => {
63
- try {
64
- const segs = strToSegs(url.searchParams.get("path") || "/");
65
- const depth = parseDepth(url.searchParams.get("depth"));
66
-
67
- if (url.pathname === "/api/info") {
68
- sendJson(res, 200, { root: root().title || rootName }); // breadcrumb head
69
- return;
70
- }
71
-
72
- if (url.pathname === "/api/tree") {
73
- // The TOC loads lazily: a subtree rooted at `path`, `depth` levels deep
74
- // (default 3). Past the boundary, nodes carry hasChildren for the client
75
- // to fetch on expand.
76
- const start = getNode(root(), segs);
77
- const label = segs.length === 0 ? start.title || rootName : labelForSeg(start, segs[segs.length - 1]);
78
- sendJson(res, 200, buildTree(start, segs, label, depth ?? 3));
79
- return;
80
- }
81
-
82
- if (url.pathname === "/api/blob") {
83
- // Raw file bytes, served with the node's (inferred) format as the
84
- // Content-Type, so a renderer can point an <img>/<iframe>/pdf loader at
85
- // the URL — or fetch the text of a markdown/asciidoc file — directly.
86
- const n = getNode(root(), segs);
87
- if (!n.path || !fs.existsSync(n.path) || fs.statSync(n.path).isDirectory()) {
88
- sendJson(res, 404, { error: `not a file-backed node: ${url.searchParams.get("path")}` });
89
- return;
90
- }
91
- const data = fs.readFileSync(n.path);
92
- res.statusCode = 200;
93
- res.setHeader("Content-Type", n.format ?? formatFromExt(n.path) ?? "application/octet-stream");
94
- res.setHeader("Content-Length", String(data.length));
95
- res.end(data);
96
- return;
97
- }
98
-
99
- const node = getNode(root(), segs);
100
- // display type: a virtual-children overlay reads as `object` (matches the TOC)
101
- const type = displayTypeLabel(node);
102
- // Every representation is one level deep with nested containers as links;
103
- // the client picks the YAML/JSON syntax. `depth` defaults to 1.
104
- const viewDepth = depth ?? 1;
105
-
106
- if (url.pathname === "/api/json") {
107
- // A binary leaf's bytes load only on explicit request (?binary=1) — the
108
- // selection's header fetch shows its cheap `repr` (size) via toPlain.
109
- const wantBytes = type === "binary" && url.searchParams.get("binary") === "1";
110
- sendJson(res, 200, {
111
- path: url.searchParams.get("path") || "/",
112
- type,
113
- format: node.format ?? null, // with `type`, the (type, format) renderer key
114
- concrete: node.concrete,
115
- // the document (nearest yamlover entity) this node belongs to — the anchor
116
- // a document-relative (`/…`) marklower link resolves against
117
- documentPath: documentPath(root(), segs),
118
- title: node.title ?? null,
119
- description: node.description ?? null,
120
- // virtual children are merged into the value; named up-edges (+ `..`)
121
- // ride alongside as `relations` for the panel above the divider
122
- value: wantBytes ? binaryContent(node) : toPlain(node, viewDepth, segs, true, root()),
123
- relations: buildRelations(node, segs, root()),
124
- });
125
- } else if (url.pathname === "/api/schema") {
126
- // pass the real root so a node's rel pointers (esp. absolute /…) resolve
127
- sendJson(res, 200, toSchema(node, viewDepth, segs, true, root()));
128
- } else {
129
- sendJson(res, 404, { error: `no such endpoint: ${url.pathname}` });
130
- }
131
- } catch (exc) {
132
- sendJson(res, 400, { error: (exc as Error).message || String(exc) });
133
- }
134
- };
135
- }
136
-
137
- function parseDepth(raw: string | null): number | null {
138
- if (raw == null || raw === "") return null;
139
- const n = Number(raw);
140
- return Number.isInteger(n) && n >= 0 ? n : null;
141
- }
142
-
143
- function sendJson(res: ServerResponse, status: number, body: unknown): void {
144
- res.statusCode = status;
145
- res.setHeader("Content-Type", "application/json; charset=utf-8");
146
- res.end(JSON.stringify(body, null, 2));
147
- }