@gjermundgaraba-designs/simple-rat 0.0.0-stage → 0.7.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.
Files changed (179) hide show
  1. package/DESIGN.md +397 -0
  2. package/LICENSE +21 -0
  3. package/README.md +64 -2
  4. package/dist/highlight/highlight.d.ts +5 -0
  5. package/dist/highlight/highlight.d.ts.map +1 -0
  6. package/dist/highlight/highlight.js +120 -0
  7. package/dist/highlight/vite.d.ts +19 -0
  8. package/dist/highlight/vite.d.ts.map +1 -0
  9. package/dist/highlight/vite.js +38 -0
  10. package/dist/src/code/code.d.ts +20 -0
  11. package/dist/src/code/code.d.ts.map +1 -0
  12. package/dist/src/code/code.js +9 -0
  13. package/dist/src/code/index.d.ts +3 -0
  14. package/dist/src/code/index.d.ts.map +1 -0
  15. package/dist/src/code/index.js +1 -0
  16. package/dist/src/codeBlock/codeBlock.d.ts +32 -0
  17. package/dist/src/codeBlock/codeBlock.d.ts.map +1 -0
  18. package/dist/src/codeBlock/codeBlock.js +35 -0
  19. package/dist/src/codeBlock/index.d.ts +3 -0
  20. package/dist/src/codeBlock/index.d.ts.map +1 -0
  21. package/dist/src/codeBlock/index.js +1 -0
  22. package/dist/src/copy/copy.d.ts +83 -0
  23. package/dist/src/copy/copy.d.ts.map +1 -0
  24. package/dist/src/copy/copy.js +76 -0
  25. package/dist/src/copyTab/copyTab.d.ts +47 -0
  26. package/dist/src/copyTab/copyTab.d.ts.map +1 -0
  27. package/dist/src/copyTab/copyTab.js +31 -0
  28. package/dist/src/copyTab/index.d.ts +3 -0
  29. package/dist/src/copyTab/index.d.ts.map +1 -0
  30. package/dist/src/copyTab/index.js +1 -0
  31. package/dist/src/diagram/diagram.d.ts +18 -0
  32. package/dist/src/diagram/diagram.d.ts.map +1 -0
  33. package/dist/src/diagram/diagram.js +18 -0
  34. package/dist/src/diagram/index.d.ts +3 -0
  35. package/dist/src/diagram/index.d.ts.map +1 -0
  36. package/dist/src/diagram/index.js +1 -0
  37. package/dist/src/footer/footer.d.ts +9 -0
  38. package/dist/src/footer/footer.d.ts.map +1 -0
  39. package/dist/src/footer/footer.js +3 -0
  40. package/dist/src/footer/index.d.ts +3 -0
  41. package/dist/src/footer/index.d.ts.map +1 -0
  42. package/dist/src/footer/index.js +1 -0
  43. package/dist/src/footnotes/footnotes.d.ts +12 -0
  44. package/dist/src/footnotes/footnotes.d.ts.map +1 -0
  45. package/dist/src/footnotes/footnotes.js +16 -0
  46. package/dist/src/footnotes/index.d.ts +3 -0
  47. package/dist/src/footnotes/index.d.ts.map +1 -0
  48. package/dist/src/footnotes/index.js +1 -0
  49. package/dist/src/header/header.d.ts +11 -0
  50. package/dist/src/header/header.d.ts.map +1 -0
  51. package/dist/src/header/header.js +8 -0
  52. package/dist/src/header/index.d.ts +3 -0
  53. package/dist/src/header/index.d.ts.map +1 -0
  54. package/dist/src/header/index.js +1 -0
  55. package/dist/src/heading/heading.d.ts +12 -0
  56. package/dist/src/heading/heading.d.ts.map +1 -0
  57. package/dist/src/heading/heading.js +12 -0
  58. package/dist/src/heading/index.d.ts +3 -0
  59. package/dist/src/heading/index.d.ts.map +1 -0
  60. package/dist/src/heading/index.js +1 -0
  61. package/dist/src/index.d.ts +19 -0
  62. package/dist/src/index.d.ts.map +1 -0
  63. package/dist/src/index.js +20 -0
  64. package/dist/src/navLink/index.d.ts +3 -0
  65. package/dist/src/navLink/index.d.ts.map +1 -0
  66. package/dist/src/navLink/index.js +1 -0
  67. package/dist/src/navLink/navLink.d.ts +13 -0
  68. package/dist/src/navLink/navLink.d.ts.map +1 -0
  69. package/dist/src/navLink/navLink.js +7 -0
  70. package/dist/src/note/index.d.ts +3 -0
  71. package/dist/src/note/index.d.ts.map +1 -0
  72. package/dist/src/note/index.js +1 -0
  73. package/dist/src/note/note.d.ts +12 -0
  74. package/dist/src/note/note.d.ts.map +1 -0
  75. package/dist/src/note/note.js +7 -0
  76. package/dist/src/pager/index.d.ts +3 -0
  77. package/dist/src/pager/index.d.ts.map +1 -0
  78. package/dist/src/pager/index.js +1 -0
  79. package/dist/src/pager/pager.d.ts +17 -0
  80. package/dist/src/pager/pager.d.ts.map +1 -0
  81. package/dist/src/pager/pager.js +15 -0
  82. package/dist/src/postList/index.d.ts +3 -0
  83. package/dist/src/postList/index.d.ts.map +1 -0
  84. package/dist/src/postList/index.js +1 -0
  85. package/dist/src/postList/postList.d.ts +13 -0
  86. package/dist/src/postList/postList.d.ts.map +1 -0
  87. package/dist/src/postList/postList.js +3 -0
  88. package/dist/src/postMeta/index.d.ts +3 -0
  89. package/dist/src/postMeta/index.d.ts.map +1 -0
  90. package/dist/src/postMeta/index.js +1 -0
  91. package/dist/src/postMeta/postMeta.d.ts +11 -0
  92. package/dist/src/postMeta/postMeta.d.ts.map +1 -0
  93. package/dist/src/postMeta/postMeta.js +10 -0
  94. package/dist/src/scheme/index.d.ts +4 -0
  95. package/dist/src/scheme/index.d.ts.map +1 -0
  96. package/dist/src/scheme/index.js +3 -0
  97. package/dist/src/scheme/scheme.d.ts +10 -0
  98. package/dist/src/scheme/scheme.d.ts.map +1 -0
  99. package/dist/src/scheme/scheme.js +9 -0
  100. package/dist/src/scheme/schemeSwitch.d.ts +18 -0
  101. package/dist/src/scheme/schemeSwitch.d.ts.map +1 -0
  102. package/dist/src/scheme/schemeSwitch.js +25 -0
  103. package/dist/src/scheme/script.d.ts +9 -0
  104. package/dist/src/scheme/script.d.ts.map +1 -0
  105. package/dist/src/scheme/script.js +8 -0
  106. package/dist/src/scheme/switch.d.ts +64 -0
  107. package/dist/src/scheme/switch.d.ts.map +1 -0
  108. package/dist/src/scheme/switch.js +72 -0
  109. package/dist/src/scrolls/index.d.ts +2 -0
  110. package/dist/src/scrolls/index.d.ts.map +1 -0
  111. package/dist/src/scrolls/index.js +1 -0
  112. package/dist/src/scrolls/scrolls.d.ts +19 -0
  113. package/dist/src/scrolls/scrolls.d.ts.map +1 -0
  114. package/dist/src/scrolls/scrolls.js +49 -0
  115. package/dist/src/skipLink/index.d.ts +2 -0
  116. package/dist/src/skipLink/index.d.ts.map +1 -0
  117. package/dist/src/skipLink/index.js +1 -0
  118. package/dist/src/skipLink/skipLink.d.ts +7 -0
  119. package/dist/src/skipLink/skipLink.d.ts.map +1 -0
  120. package/dist/src/skipLink/skipLink.js +6 -0
  121. package/dist/src/swatch/index.d.ts +2 -0
  122. package/dist/src/swatch/index.d.ts.map +1 -0
  123. package/dist/src/swatch/index.js +1 -0
  124. package/dist/src/swatch/swatch.d.ts +4 -0
  125. package/dist/src/swatch/swatch.d.ts.map +1 -0
  126. package/dist/src/swatch/swatch.js +3 -0
  127. package/dist/src/table/index.d.ts +3 -0
  128. package/dist/src/table/index.d.ts.map +1 -0
  129. package/dist/src/table/index.js +1 -0
  130. package/dist/src/table/table.d.ts +15 -0
  131. package/dist/src/table/table.d.ts.map +1 -0
  132. package/dist/src/table/table.js +23 -0
  133. package/highlight/highlight.ts +128 -0
  134. package/highlight/vite.ts +42 -0
  135. package/package.json +75 -3
  136. package/src/code/code.ts +23 -0
  137. package/src/code/index.ts +2 -0
  138. package/src/code/lines.d.ts +39 -0
  139. package/src/codeBlock/codeBlock.ts +83 -0
  140. package/src/codeBlock/index.ts +2 -0
  141. package/src/copy/copy.ts +106 -0
  142. package/src/copyTab/copyTab.ts +61 -0
  143. package/src/copyTab/index.ts +2 -0
  144. package/src/diagram/diagram.ts +43 -0
  145. package/src/diagram/index.ts +2 -0
  146. package/src/footer/footer.ts +11 -0
  147. package/src/footer/index.ts +2 -0
  148. package/src/footnotes/footnotes.ts +38 -0
  149. package/src/footnotes/index.ts +2 -0
  150. package/src/header/header.ts +24 -0
  151. package/src/header/index.ts +2 -0
  152. package/src/heading/heading.ts +21 -0
  153. package/src/heading/index.ts +2 -0
  154. package/src/index.ts +20 -0
  155. package/src/navLink/index.ts +2 -0
  156. package/src/navLink/navLink.ts +18 -0
  157. package/src/note/index.ts +2 -0
  158. package/src/note/note.ts +19 -0
  159. package/src/pager/index.ts +2 -0
  160. package/src/pager/pager.ts +30 -0
  161. package/src/postList/index.ts +2 -0
  162. package/src/postList/postList.ts +19 -0
  163. package/src/postMeta/index.ts +2 -0
  164. package/src/postMeta/postMeta.ts +23 -0
  165. package/src/scheme/index.ts +3 -0
  166. package/src/scheme/scheme.ts +25 -0
  167. package/src/scheme/schemeSwitch.ts +43 -0
  168. package/src/scheme/script.ts +10 -0
  169. package/src/scheme/switch.ts +99 -0
  170. package/src/scrolls/index.ts +1 -0
  171. package/src/scrolls/scrolls.ts +56 -0
  172. package/src/simple-rat.css +601 -0
  173. package/src/skipLink/index.ts +1 -0
  174. package/src/skipLink/skipLink.ts +8 -0
  175. package/src/swatch/index.ts +1 -0
  176. package/src/swatch/swatch.ts +5 -0
  177. package/src/table/index.ts +2 -0
  178. package/src/table/table.ts +50 -0
  179. package/src/tokens.css +67 -0
@@ -0,0 +1,19 @@
1
+ type Plugin = ReturnType<typeof import("@foldkit/vite-plugin").foldkitViewIdentity>;
2
+ /**
3
+ * Colours code while the site is built, so no page loads the highlighter. An import with the
4
+ * query `?lines=<lang>` (one of `LANGUAGES`) is the file's text and its coloured lines,
5
+ * which `CodeBlock` takes as `code` and `lines`:
6
+ *
7
+ * ```ts
8
+ * import retry from "./code/retry.txt?lines=ts";
9
+ *
10
+ * CodeBlock.view({ lang: "ts", ...retry, toParentMessage }, h);
11
+ * ```
12
+ *
13
+ * Add it to the build's plugins, beside `foldkit()`. The file is watched, so a change to it
14
+ * colours it again. A `.txt` holds code the toolchain should leave alone; a source file can
15
+ * be imported twice, to run and to show.
16
+ */
17
+ export declare const codeLines: () => Plugin;
18
+ export {};
19
+ //# sourceMappingURL=vite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../highlight/vite.ts"],"names":[],"mappings":"AAKA,KAAK,MAAM,GAAG,UAAU,CAAC,cAAc,sBAAsB,EAAE,mBAAmB,CAAC,CAAC;AAOpF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,QAAO,MAc3B,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ import { readFile } from "node:fs/promises";
3
+ import { LANGUAGES } from "../src/code/code.js";
4
+ import { highlight } from "./highlight.js";
5
+ // A file's path, then `lines=<lang>` anywhere in its query.
6
+ const LINES_IMPORT = /^([^?]+)\?(?:.*&)?lines=([^&]*)/;
7
+ const isLanguage = (lang) => __foldkitBrandViewResult((LANGUAGES.some((known) => __foldkitBrandViewResult((known === lang), "@gjermundgaraba-designs/simple-rat/highlight/vite.js#anonymous"))), "@gjermundgaraba-designs/simple-rat/highlight/vite.js#isLanguage");
8
+ /**
9
+ * Colours code while the site is built, so no page loads the highlighter. An import with the
10
+ * query `?lines=<lang>` (one of `LANGUAGES`) is the file's text and its coloured lines,
11
+ * which `CodeBlock` takes as `code` and `lines`:
12
+ *
13
+ * ```ts
14
+ * import retry from "./code/retry.txt?lines=ts";
15
+ *
16
+ * CodeBlock.view({ lang: "ts", ...retry, toParentMessage }, h);
17
+ * ```
18
+ *
19
+ * Add it to the build's plugins, beside `foldkit()`. The file is watched, so a change to it
20
+ * colours it again. A `.txt` holds code the toolchain should leave alone; a source file can
21
+ * be imported twice, to run and to show.
22
+ */
23
+ export const codeLines = () => (__foldkitBrandViewResult(({
24
+ name: "simple-rat:code-lines",
25
+ // Before Vite's own loaders, which would take a .txt for an asset.
26
+ enforce: "pre",
27
+ async load(id) {
28
+ const [, file, lang] = LINES_IMPORT.exec(id) ?? [];
29
+ if (file === undefined || lang === undefined)
30
+ return __foldkitBrandViewResult((null), "@gjermundgaraba-designs/simple-rat/highlight/vite.js#load");
31
+ if (!isLanguage(lang)) {
32
+ return __foldkitBrandViewResult((this.error(`simple-rat: ?lines=${lang} is none of ${LANGUAGES.join(", ")}`)), "@gjermundgaraba-designs/simple-rat/highlight/vite.js#load");
33
+ }
34
+ this.addWatchFile(file);
35
+ const code = await readFile(file, "utf8");
36
+ return __foldkitBrandViewResult((`export default ${JSON.stringify({ code, lines: highlight(code, lang) })};`), "@gjermundgaraba-designs/simple-rat/highlight/vite.js#load");
37
+ },
38
+ }), "@gjermundgaraba-designs/simple-rat/highlight/vite.js#codeLines"));
@@ -0,0 +1,20 @@
1
+ /** The languages a block can be coloured in. */
2
+ export declare const LANGUAGES: readonly ["ts", "tsx", "sh", "json", "css", "html", "diff"];
3
+ export type Language = (typeof LANGUAGES)[number];
4
+ /** One coloured run of a line: its text, the `--t-*` colour Shiki gave it, and whether it
5
+ is italic. */
6
+ type Run = Readonly<{
7
+ content: string;
8
+ color: string | undefined;
9
+ isItalic: boolean;
10
+ }>;
11
+ /** A block's runs, line by line. A run in the plain code ink, upright, has no colour. */
12
+ export type Lines = ReadonlyArray<ReadonlyArray<Run>>;
13
+ /** A file's text and its coloured lines: what an import with `?lines=<lang>` gives (see
14
+ lines.d.ts). */
15
+ export type Highlighted = Readonly<{
16
+ code: string;
17
+ lines: Lines;
18
+ }>;
19
+ export {};
20
+ //# sourceMappingURL=code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../../src/code/code.ts"],"names":[],"mappings":"AASA,gDAAgD;AAChD,eAAO,MAAM,SAAS,YAAI,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AACrF,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAElD;iBACiB;AACjB,KAAK,GAAG,GAAG,QAAQ,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAEvF,yFAAyF;AACzF,MAAM,MAAM,KAAK,GAAG,aAAa,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;AAEtD;mBACmB;AACnB,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ // The `?lines=<lang>` imports are declared for every program that reaches this file, which
2
+ // is every one that imports the package: an ambient declaration has no import to travel by.
3
+ // oxlint-disable-next-line typescript/triple-slash-reference
4
+ /// <reference path="./lines.d.ts" />
5
+ // A code block's colours as data, with no highlighter: what `CodeBlock` renders and what a
6
+ // build makes with `highlight` (highlight/highlight.ts), so a page carries the colours and
7
+ // not Shiki.
8
+ /** The languages a block can be coloured in. */
9
+ export const LANGUAGES = ["ts", "tsx", "sh", "json", "css", "html", "diff"];
@@ -0,0 +1,3 @@
1
+ export { LANGUAGES } from "./code.ts";
2
+ export type { Highlighted, Language, Lines } from "./code.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/code/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ export { LANGUAGES } from "./code.js";
@@ -0,0 +1,32 @@
1
+ import type { Html, HtmlBuilder } from "foldkit/html";
2
+ import type { Language, Lines } from "../code/code.ts";
3
+ import type { ViewInputs as CopyInputs } from "../copyTab/copyTab.ts";
4
+ import * as Scrolls from "../scrolls/scrolls.ts";
5
+ /** Configuration for rendering a code block with `view`. */
6
+ export type ViewConfig<ParentMessage> = Readonly<{
7
+ code: string;
8
+ /** The code's language, named on the `code` element. A block without one, with a copy
9
+ tab, is a prose block that wraps at text size, like a prompt. */
10
+ lang?: Language;
11
+ /** The code's coloured lines, made at build: an import with `?lines=<lang>` gives them
12
+ with the `code` (the package's `./highlight/vite`), or `highlight` makes them (its
13
+ `./highlight`). Without them the block is plain. */
14
+ lines?: Lines;
15
+ /** A file name, shown in a tab on the block's top-left edge. */
16
+ file?: string;
17
+ /** A `copy` tab on the block's top-right edge: the page's `CopyTab`, rendered with
18
+ `copyInputs`. The tab wraps the block, so it is given the block's view to render as its
19
+ `toBlockView`. */
20
+ copy?: ((toBlockView: () => Html) => Html) | undefined;
21
+ /** The overflow Mount's report, lifted into the page's Messages, which may ignore it. */
22
+ toParentMessage: (message: Scrolls.Message) => ParentMessage;
23
+ }>;
24
+ /** The block's name for assistive technology: its file, or its first line. */
25
+ export declare const nameOf: (code: string, file?: string) => string;
26
+ /** What a block's `CopyTab` is given: the block's name and its code, without a trailing
27
+ newline. */
28
+ export declare const copyInputs: (code: string, file?: string) => Omit<CopyInputs, "toBlockView">;
29
+ /** A code block: coloured where it is given its lines, optionally with a file tab and a
30
+ copy tab. Only a block that overflows takes focus, through `Scrolls.WatchOverflow`. */
31
+ export declare const view: <ParentMessage>(config: ViewConfig<ParentMessage>, h: HtmlBuilder<ParentMessage>) => Html;
32
+ //# sourceMappingURL=codeBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeBlock.d.ts","sourceRoot":"","sources":["../../../src/codeBlock/codeBlock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGtD,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAEjD,4DAA4D;AAC5D,MAAM,MAAM,UAAU,CAAC,aAAa,IAAI,QAAQ,CAAC;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb;wEACoE;IACpE,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;2DAEuD;IACvD,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,gEAAgE;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;yBAEqB;IACrB,IAAI,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACvD,yFAAyF;IACzF,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,aAAa,CAAC;CAC9D,CAAC,CAAC;AAEH,8EAA8E;AAC9E,eAAO,MAAM,MAAM,SAAU,MAAM,SAAS,MAAM,KAAG,MAGpD,CAAC;AAEF;eACe;AACf,eAAO,MAAM,UAAU,SAAU,MAAM,SAAS,MAAM,KAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAGrF,CAAC;AAeH;0FAC0F;AAC1F,eAAO,MAAM,IAAI,GAAI,aAAa,UACxB,UAAU,CAAC,aAAa,CAAC,KAC9B,WAAW,CAAC,aAAa,CAAC,KAC5B,IAuBF,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ import { Option } from "effect";
3
+ import * as Mount from "foldkit/mount";
4
+ import * as Scrolls from "../scrolls/scrolls.js";
5
+ /** The block's name for assistive technology: its file, or its first line. */
6
+ export const nameOf = (code, file) => {
7
+ const firstLine = code.trim().split("\n")[0] ?? "";
8
+ return __foldkitBrandViewResult((file ?? (firstLine.length > 40 ? `${firstLine.slice(0, 40)}…` : firstLine)), "@gjermundgaraba-designs/simple-rat/src/codeBlock/codeBlock.js#nameOf");
9
+ };
10
+ /** What a block's `CopyTab` is given: the block's name and its code, without a trailing
11
+ newline. */
12
+ export const copyInputs = (code, file) => (__foldkitBrandViewResult(({
13
+ name: nameOf(code, file),
14
+ text: code.trimEnd(),
15
+ }), "@gjermundgaraba-designs/simple-rat/src/codeBlock/codeBlock.js#copyInputs"));
16
+ const linesView = (lines, h) => __foldkitBrandViewResult((lines.flatMap((line, index) => __foldkitBrandViewResult(([
17
+ ...(index > 0 ? ["\n"] : []),
18
+ ...line.map((run) => __foldkitBrandViewResult((run.color === undefined
19
+ ? run.content
20
+ : h.span([h.Style({ color: run.color, ...(run.isItalic ? { fontStyle: "italic" } : {}) })], [run.content])), "@gjermundgaraba-designs/simple-rat/src/codeBlock/codeBlock.js#anonymous~2")),
21
+ ]), "@gjermundgaraba-designs/simple-rat/src/codeBlock/codeBlock.js#anonymous"))), "@gjermundgaraba-designs/simple-rat/src/codeBlock/codeBlock.js#linesView");
22
+ /** A code block: coloured where it is given its lines, optionally with a file tab and a
23
+ copy tab. Only a block that overflows takes focus, through `Scrolls.WatchOverflow`. */
24
+ export const view = (config, h) => {
25
+ const { code, lang, lines, file, copy, toParentMessage } = config;
26
+ const name = nameOf(code, file);
27
+ const toBlockView = () => __foldkitBrandViewResult((h.pre([
28
+ ...(copy === undefined ? [] : [h.DataAttribute("copy", "")]),
29
+ h.OnMount(Mount.mapMessage(Scrolls.WatchOverflow({ maybeName: Option.some(name) }), toParentMessage)),
30
+ ], [
31
+ h.code(lang === undefined ? [] : [h.Class(`language-${lang}`)], lines === undefined ? [code] : linesView(lines, h)),
32
+ ])), "@gjermundgaraba-designs/simple-rat/src/codeBlock/codeBlock.js#toBlockView");
33
+ const body = copy === undefined ? toBlockView() : copy(toBlockView);
34
+ return __foldkitBrandViewResult((file === undefined ? body : h.figure([h.Class("file")], [h.figcaption([], [file]), body])), "@gjermundgaraba-designs/simple-rat/src/codeBlock/codeBlock.js#view");
35
+ };
@@ -0,0 +1,3 @@
1
+ export { copyInputs, view } from "./codeBlock.ts";
2
+ export type { ViewConfig } from "./codeBlock.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/codeBlock/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1 @@
1
+ export { copyInputs, view } from "./codeBlock.js";
@@ -0,0 +1,83 @@
1
+ import { Clipboard } from "@effect/platform-browser";
2
+ import { Effect, Schema } from "effect";
3
+ import * as Command from "foldkit/command";
4
+ import type * as Update from "foldkit/update";
5
+ /** Where a copy is: nothing yet, writing to the clipboard, just copied, or just refused. */
6
+ export declare const CopyState: import("foldkit/schema").TaggedUnion<{
7
+ readonly Idle: {};
8
+ readonly Copying: {};
9
+ readonly Copied: {};
10
+ readonly Failed: {};
11
+ }>;
12
+ export type CopyState = typeof CopyState.Type;
13
+ /** Schema for a copy control: what it says it just did. */
14
+ export declare const Model: Schema.Struct<{
15
+ readonly id: Schema.String;
16
+ readonly state: import("foldkit/schema").TaggedUnion<{
17
+ readonly Idle: {};
18
+ readonly Copying: {};
19
+ readonly Copied: {};
20
+ readonly Failed: {};
21
+ }>;
22
+ }>;
23
+ export type Model = typeof Model.Type;
24
+ /** Union of all Messages a copy control can produce. */
25
+ export declare const Message: import("foldkit/message").MessageUnion<{
26
+ readonly ClickedCopy: {
27
+ text: Schema.String;
28
+ };
29
+ readonly SucceededCopyText: {};
30
+ readonly FailedCopyText: {};
31
+ readonly CompletedWaitBeforeSettling: {};
32
+ }>;
33
+ export type Message = typeof Message.Type;
34
+ /** Configuration for creating a copy control with `init`: its id, unique in the document. */
35
+ export type InitConfig = Readonly<{
36
+ id: string;
37
+ }>;
38
+ /** Creates a copy control that has copied nothing. */
39
+ export declare const init: (config: InitConfig) => Model;
40
+ /** The control's id, unique in the document. */
41
+ export declare const id: (model: Model) => string;
42
+ /** Writes the text to the clipboard through Effect's `Clipboard` port. Provide
43
+ `Clipboard.layer` from `@effect/platform-browser` in the application's `resources`. */
44
+ export declare const CopyText: Command.CommandDefinitionWithArgs<"CopyText", {
45
+ text: Schema.String;
46
+ }, Effect.Effect<{
47
+ readonly _tag: "SucceededCopyText";
48
+ } | {
49
+ readonly _tag: "FailedCopyText";
50
+ }, never, Clipboard.Clipboard>>;
51
+ /** Waits out the beat the answer shows for. */
52
+ export declare const WaitBeforeSettling: Command.CommandDefinitionNoArgs<"WaitBeforeSettling", Effect.Effect<{
53
+ readonly _tag: "CompletedWaitBeforeSettling";
54
+ }, never, never>>;
55
+ /** Processes a copy control Message and returns the next Model and Commands. Its copy needs
56
+ the `Clipboard` service. A press counts only while the control is Idle, so one beat ends
57
+ before the next copy starts. */
58
+ export declare const update: (model: Model, message: Message) => Readonly<{
59
+ model: {
60
+ readonly id: string;
61
+ readonly state: {
62
+ readonly _tag: "Copied";
63
+ } | {
64
+ readonly _tag: "Copying";
65
+ } | {
66
+ readonly _tag: "Failed";
67
+ } | {
68
+ readonly _tag: "Idle";
69
+ };
70
+ };
71
+ commands?: Update.Commands<{
72
+ readonly _tag: "ClickedCopy";
73
+ readonly text: string;
74
+ } | {
75
+ readonly _tag: "CompletedWaitBeforeSettling";
76
+ } | {
77
+ readonly _tag: "FailedCopyText";
78
+ } | {
79
+ readonly _tag: "SucceededCopyText";
80
+ }, Clipboard.Clipboard>;
81
+ outMessage?: never;
82
+ }>;
83
+ //# sourceMappingURL=copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../../../src/copy/copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAY,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAI3C,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAM9C,4FAA4F;AAC5F,eAAO,MAAM,SAAS;;;;;EAKpB,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;AAE9C,2DAA2D;AAC3D,eAAO,MAAM,KAAK;;;;;;;;EAGhB,CAAC;AACH,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC;AAItC,wDAAwD;AACxD,eAAO,MAAM,OAAO;;QACH,IAAI;;;;;EAInB,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAI1C,6FAA6F;AAC7F,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAElD,sDAAsD;AACtD,eAAO,MAAM,IAAI,WAAY,UAAU,KAAG,KAGxC,CAAC;AAIH,gDAAgD;AAChD,eAAO,MAAM,EAAE,UAAW,KAAK,KAAG,MAAkB,CAAC;AAOrD;0FAC0F;AAC1F,eAAO,MAAM,QAAQ;;;;;;+BASnB,CAAC;AAEH,+CAA+C;AAC/C,eAAO,MAAM,kBAAkB;;iBAG7B,CAAC;AAWH;;mCAEmC;AACnC,eAAO,MAAM,MAAM,UAAW,KAAK,WAAW,OAAO;;;;;;;;;;;;;;;;;;;;;;;;EAcjD,CAAC"}
@@ -0,0 +1,76 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ import { Clipboard } from "@effect/platform-browser";
3
+ import { Duration, Effect, Schema } from "effect";
4
+ import * as Command from "foldkit/command";
5
+ import { defineMessageUnion } from "foldkit/message";
6
+ import { defineTaggedUnion } from "foldkit/schema";
7
+ import { modifyFields } from "foldkit/struct";
8
+ // A copy to the clipboard, without its view: the system's own control renders it.
9
+ // MODEL
10
+ /** Where a copy is: nothing yet, writing to the clipboard, just copied, or just refused. */
11
+ export const CopyState = defineTaggedUnion({
12
+ Idle: {},
13
+ Copying: {},
14
+ Copied: {},
15
+ Failed: {},
16
+ });
17
+ /** Schema for a copy control: what it says it just did. */
18
+ export const Model = Schema.Struct({
19
+ id: Schema.String,
20
+ state: CopyState,
21
+ });
22
+ // MESSAGE
23
+ /** Union of all Messages a copy control can produce. */
24
+ export const Message = defineMessageUnion({
25
+ ClickedCopy: { text: Schema.String },
26
+ SucceededCopyText: {},
27
+ FailedCopyText: {},
28
+ CompletedWaitBeforeSettling: {},
29
+ });
30
+ /** Creates a copy control that has copied nothing. */
31
+ export const init = (config) => (__foldkitBrandViewResult(({
32
+ id: config.id,
33
+ state: CopyState.Idle(),
34
+ }), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#init"));
35
+ // ACCESSORS
36
+ /** The control's id, unique in the document. */
37
+ export const id = (model) => __foldkitBrandViewResult((model.id), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#id");
38
+ // COMMAND
39
+ /** How long the control answers for: that it copied, or that the copy failed. */
40
+ const WORD_BEAT = Duration.millis(1600);
41
+ /** Writes the text to the clipboard through Effect's `Clipboard` port. Provide
42
+ `Clipboard.layer` from `@effect/platform-browser` in the application's `resources`. */
43
+ export const CopyText = Command.define("CopyText", {
44
+ args: { text: Schema.String },
45
+ messages: [Message.SucceededCopyText, Message.FailedCopyText],
46
+ execute: ({ text }) => __foldkitBrandViewResult((Effect.gen(function* () {
47
+ const clipboard = yield* Clipboard.Clipboard;
48
+ yield* clipboard.writeString(text);
49
+ return __foldkitBrandViewResult((Message.SucceededCopyText()), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#anonymous");
50
+ }).pipe(Effect.catch(() => __foldkitBrandViewResult((Effect.succeed(Message.FailedCopyText())), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#anonymous~2")))), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#execute"),
51
+ });
52
+ /** Waits out the beat the answer shows for. */
53
+ export const WaitBeforeSettling = Command.define("WaitBeforeSettling", {
54
+ messages: [Message.CompletedWaitBeforeSettling],
55
+ execute: Effect.sleep(WORD_BEAT).pipe(Effect.as(Message.CompletedWaitBeforeSettling())),
56
+ });
57
+ const holdAnswer = (model, state) => (__foldkitBrandViewResult(({
58
+ model: modifyFields(model, { state: () => __foldkitBrandViewResult((state), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#state") }),
59
+ commands: [WaitBeforeSettling()],
60
+ }), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#holdAnswer"));
61
+ /** Processes a copy control Message and returns the next Model and Commands. Its copy needs
62
+ the `Clipboard` service. A press counts only while the control is Idle, so one beat ends
63
+ before the next copy starts. */
64
+ export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
65
+ ClickedCopy: ({ text }) => __foldkitBrandViewResult((CopyState.guards.Idle(model.state)
66
+ ? {
67
+ model: modifyFields(model, { state: () => __foldkitBrandViewResult((CopyState.Copying()), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#state~2") }),
68
+ commands: [CopyText({ text })],
69
+ }
70
+ : { model }), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#ClickedCopy"),
71
+ SucceededCopyText: () => __foldkitBrandViewResult((holdAnswer(model, CopyState.Copied())), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#SucceededCopyText"),
72
+ FailedCopyText: () => __foldkitBrandViewResult((holdAnswer(model, CopyState.Failed())), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#FailedCopyText"),
73
+ CompletedWaitBeforeSettling: () => (__foldkitBrandViewResult(({
74
+ model: modifyFields(model, { state: () => __foldkitBrandViewResult((CopyState.Idle()), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#state~3") }),
75
+ }), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#CompletedWaitBeforeSettling")),
76
+ })), "@gjermundgaraba-designs/simple-rat/src/copy/copy.js#update");
@@ -0,0 +1,47 @@
1
+ import type { Html } from "foldkit/html";
2
+ export * from "../copy/copy.ts";
3
+ /** Per-render inputs passed to `view` through `h.submodel`'s `viewInputs`. */
4
+ export type ViewInputs = Readonly<{
5
+ /** What is copied, for the tab's accessible name: the block's file or first line. */
6
+ name: string;
7
+ /** What goes on the clipboard. */
8
+ text: string;
9
+ /** The block the tab sits on, built where it is called (in the page's own Message
10
+ boundary, so its Mount reports to the page). */
11
+ toBlockView: () => Html;
12
+ }>;
13
+ /** `div.copyable`: the block, a `copy` tab on its top-right edge, built on `@foldkit/ui`'s
14
+ Button, that answers `copied` (or `select and copy` when the browser refuses) for a beat
15
+ and says so to screen readers through a visually hidden status. The tab takes a press only
16
+ while it reads `copy`, and is held (`aria-disabled`) while it answers. Its `CopyText`
17
+ Command needs `Clipboard.layer` in the application's resources. */
18
+ export declare const view: import("foldkit/submodel").View<{
19
+ readonly id: string;
20
+ readonly state: {
21
+ readonly _tag: "Copied";
22
+ } | {
23
+ readonly _tag: "Copying";
24
+ } | {
25
+ readonly _tag: "Failed";
26
+ } | {
27
+ readonly _tag: "Idle";
28
+ };
29
+ }, {
30
+ readonly _tag: "ClickedCopy";
31
+ readonly text: string;
32
+ } | {
33
+ readonly _tag: "CompletedWaitBeforeSettling";
34
+ } | {
35
+ readonly _tag: "FailedCopyText";
36
+ } | {
37
+ readonly _tag: "SucceededCopyText";
38
+ }, Readonly<{
39
+ /** What is copied, for the tab's accessible name: the block's file or first line. */
40
+ name: string;
41
+ /** What goes on the clipboard. */
42
+ text: string;
43
+ /** The block the tab sits on, built where it is called (in the page's own Message
44
+ boundary, so its Mount reports to the page). */
45
+ toBlockView: () => Html;
46
+ }>>;
47
+ //# sourceMappingURL=copyTab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copyTab.d.ts","sourceRoot":"","sources":["../../../src/copyTab/copyTab.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAKzC,cAAc,iBAAiB,CAAC;AAIhC,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,qFAAqF;IACrF,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb;uDACmD;IACnD,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC,CAAC;AAkBH;;;;sEAIsE;AACtE,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;IA9Bf,qFAAqF;UAC/E,MAAM;IACZ,kCAAkC;UAC5B,MAAM;IACZ;uDACmD;iBACtC,MAAM,IAAI;GA0CxB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ import { Button as UiButton } from "@foldkit/ui";
3
+ import { defineView } from "foldkit/submodel";
4
+ import { CopyState, Message } from "../copy/copy.js";
5
+ export * from "../copy/copy.js";
6
+ const word = (state) => __foldkitBrandViewResult((CopyState.match(state, {
7
+ Idle: () => __foldkitBrandViewResult(("copy"), "@gjermundgaraba-designs/simple-rat/src/copyTab/copyTab.js#Idle"),
8
+ Copying: () => __foldkitBrandViewResult(("copy"), "@gjermundgaraba-designs/simple-rat/src/copyTab/copyTab.js#Copying"),
9
+ Copied: () => __foldkitBrandViewResult(("copied"), "@gjermundgaraba-designs/simple-rat/src/copyTab/copyTab.js#Copied"),
10
+ Failed: () => __foldkitBrandViewResult(("select and copy"), "@gjermundgaraba-designs/simple-rat/src/copyTab/copyTab.js#Failed"),
11
+ })), "@gjermundgaraba-designs/simple-rat/src/copyTab/copyTab.js#word");
12
+ const said = (state) => __foldkitBrandViewResult((CopyState.match(state, {
13
+ Idle: () => __foldkitBrandViewResult((""), "@gjermundgaraba-designs/simple-rat/src/copyTab/copyTab.js#Idle~2"),
14
+ Copying: () => __foldkitBrandViewResult((""), "@gjermundgaraba-designs/simple-rat/src/copyTab/copyTab.js#Copying~2"),
15
+ Copied: () => __foldkitBrandViewResult(("Copied"), "@gjermundgaraba-designs/simple-rat/src/copyTab/copyTab.js#Copied~2"),
16
+ Failed: () => __foldkitBrandViewResult(("Copy failed. Select the text and copy it by hand."), "@gjermundgaraba-designs/simple-rat/src/copyTab/copyTab.js#Failed~2"),
17
+ })), "@gjermundgaraba-designs/simple-rat/src/copyTab/copyTab.js#said");
18
+ /** `div.copyable`: the block, a `copy` tab on its top-right edge, built on `@foldkit/ui`'s
19
+ Button, that answers `copied` (or `select and copy` when the browser refuses) for a beat
20
+ and says so to screen readers through a visually hidden status. The tab takes a press only
21
+ while it reads `copy`, and is held (`aria-disabled`) while it answers. Its `CopyText`
22
+ Command needs `Clipboard.layer` in the application's resources. */
23
+ export const view = defineView((model, { name, text, toBlockView }, h) => __foldkitBrandViewResult((h.div([h.Class("copyable")], [
24
+ toBlockView(),
25
+ UiButton.view({
26
+ isDisabled: !CopyState.guards.Idle(model.state),
27
+ onClick: Message.ClickedCopy({ text }),
28
+ toView: ({ button }) => __foldkitBrandViewResult((h.button([...button, h.AriaLabel(`Copy ${name}`)], [word(model.state)])), "@gjermundgaraba-designs/simple-rat/src/copyTab/copyTab.js#toView"),
29
+ }, h),
30
+ h.span([h.Class("visually-hidden"), h.Role("status")], [said(model.state)]),
31
+ ])), "@gjermundgaraba-designs/simple-rat/src/copyTab/copyTab.js#anonymous"));
@@ -0,0 +1,3 @@
1
+ export { CopyText, Message, Model, WaitBeforeSettling, id, init, update, view } from "./copyTab.ts";
2
+ export type { InitConfig, ViewInputs } from "./copyTab.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/copyTab/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpG,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ export { CopyText, Message, Model, WaitBeforeSettling, id, init, update, view } from "./copyTab.js";
@@ -0,0 +1,18 @@
1
+ import type { Html, HtmlBuilder } from "foldkit/html";
2
+ import * as Scrolls from "../scrolls/scrolls.ts";
3
+ /** Configuration for rendering a diagram with `view`. */
4
+ export type ViewConfig<ParentMessage> = Readonly<{
5
+ /** The drawing, in box-drawing characters. */
6
+ drawing: string;
7
+ /** What the diagram shows, for screen readers. */
8
+ label: string;
9
+ /** What the diagram shows, for everyone. Defaults to the label. */
10
+ caption?: ReadonlyArray<Html | string>;
11
+ /** The overflow Mount's report, lifted into the page's Messages, which may ignore it. */
12
+ toParentMessage: (message: Scrolls.Message) => ParentMessage;
13
+ }>;
14
+ /** A box-drawing diagram: an image to assistive technology, with a visible caption. The
15
+ role sits on the `pre`, so a diagram too wide for the screen can still take focus
16
+ (through `Scrolls.WatchOverflow`) and scroll. */
17
+ export declare const view: <ParentMessage>(config: ViewConfig<ParentMessage>, h: HtmlBuilder<ParentMessage>) => Html;
18
+ //# sourceMappingURL=diagram.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagram.d.ts","sourceRoot":"","sources":["../../../src/diagram/diagram.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGtD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAEjD,yDAAyD;AACzD,MAAM,MAAM,UAAU,CAAC,aAAa,IAAI,QAAQ,CAAC;IAC/C,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,OAAO,CAAC,EAAE,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;IACvC,yFAAyF;IACzF,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,aAAa,CAAC;CAC9D,CAAC,CAAC;AAEH;;oDAEoD;AACpD,eAAO,MAAM,IAAI,GAAI,aAAa,UACxB,UAAU,CAAC,aAAa,CAAC,KAC9B,WAAW,CAAC,aAAa,CAAC,KAC5B,IAkBF,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ import { Option } from "effect";
3
+ import * as Mount from "foldkit/mount";
4
+ import * as Scrolls from "../scrolls/scrolls.js";
5
+ /** A box-drawing diagram: an image to assistive technology, with a visible caption. The
6
+ role sits on the `pre`, so a diagram too wide for the screen can still take focus
7
+ (through `Scrolls.WatchOverflow`) and scroll. */
8
+ export const view = (config, h) => {
9
+ const { drawing, label, caption = [label], toParentMessage } = config;
10
+ return __foldkitBrandViewResult((h.figure([], [
11
+ h.pre([
12
+ h.Role("img"),
13
+ h.AriaLabel(label),
14
+ h.OnMount(Mount.mapMessage(Scrolls.WatchOverflow({ maybeName: Option.none() }), toParentMessage)),
15
+ ], [h.code([], [drawing])]),
16
+ h.figcaption([], caption),
17
+ ])), "@gjermundgaraba-designs/simple-rat/src/diagram/diagram.js#view");
18
+ };
@@ -0,0 +1,3 @@
1
+ export { view } from "./diagram.ts";
2
+ export type { ViewConfig } from "./diagram.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/diagram/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ export { view } from "./diagram.js";
@@ -0,0 +1,9 @@
1
+ import type { Html, HtmlBuilder } from "foldkit/html";
2
+ /** Configuration for rendering the footer with `view`. */
3
+ export type ViewConfig = Readonly<{
4
+ /** The one line. */
5
+ body: ReadonlyArray<Html | string>;
6
+ }>;
7
+ /** A rule and one line. */
8
+ export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
9
+ //# sourceMappingURL=footer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"footer.d.ts","sourceRoot":"","sources":["../../../src/footer/footer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,oBAAoB;IACpB,IAAI,EAAE,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;CACpC,CAAC,CAAC;AAEH,2BAA2B;AAC3B,eAAO,MAAM,IAAI,GAAI,OAAO,UAAU,UAAU,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAC5B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ /** A rule and one line. */
3
+ export const view = (config, h) => __foldkitBrandViewResult((h.footer([], [h.hr([]), h.p([], config.body)])), "@gjermundgaraba-designs/simple-rat/src/footer/footer.js#view");
@@ -0,0 +1,3 @@
1
+ export { view } from "./footer.ts";
2
+ export type { ViewConfig } from "./footer.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/footer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1 @@
1
+ export { view } from "./footer.js";
@@ -0,0 +1,12 @@
1
+ import type { Html, HtmlBuilder } from "foldkit/html";
2
+ /** A superscript number that jumps to the note numbered `noteNumber`; the note links back. */
3
+ export declare const refView: <Message>(noteNumber: number, h: HtmlBuilder<Message>) => Html;
4
+ /** Configuration for rendering the notes with `view`. */
5
+ export type ViewConfig = Readonly<{
6
+ /** The notes, numbered from 1. */
7
+ notes: ReadonlyArray<ReadonlyArray<Html | string>>;
8
+ }>;
9
+ /** The notes, numbered from 1, at the end of the page under a rule. Each ends in a `Back`
10
+ link named for the reference it returns to. */
11
+ export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
12
+ //# sourceMappingURL=footnotes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"footnotes.d.ts","sourceRoot":"","sources":["../../../src/footnotes/footnotes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,8FAA8F;AAC9F,eAAO,MAAM,OAAO,GAAI,OAAO,cAAc,MAAM,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IACgB,CAAC;AAEhG,yDAAyD;AACzD,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,kCAAkC;IAClC,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC;CACpD,CAAC,CAAC;AAEH;kDACkD;AAClD,eAAO,MAAM,IAAI,GAAI,OAAO,UAAU,UAAU,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAuBzE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ /** A superscript number that jumps to the note numbered `noteNumber`; the note links back. */
3
+ export const refView = (noteNumber, h) => __foldkitBrandViewResult((h.sup([], [h.a([h.Href(`#fn-${noteNumber}`), h.Id(`ref-${noteNumber}`)], [`${noteNumber}`])])), "@gjermundgaraba-designs/simple-rat/src/footnotes/footnotes.js#refView");
4
+ /** The notes, numbered from 1, at the end of the page under a rule. Each ends in a `Back`
5
+ link named for the reference it returns to. */
6
+ export const view = (config, h) => __foldkitBrandViewResult((h.section([h.Class("footnotes"), h.AriaLabel("Footnotes")], [
7
+ h.hr([]),
8
+ h.ol([], config.notes.map((note, index) => {
9
+ const noteNumber = index + 1;
10
+ return __foldkitBrandViewResult((h.li([h.Id(`fn-${noteNumber}`)], [
11
+ ...note,
12
+ " ",
13
+ h.a([h.Href(`#ref-${noteNumber}`), h.AriaLabel(`Back to reference ${noteNumber}`)], ["Back"]),
14
+ ])), "@gjermundgaraba-designs/simple-rat/src/footnotes/footnotes.js#anonymous");
15
+ })),
16
+ ])), "@gjermundgaraba-designs/simple-rat/src/footnotes/footnotes.js#view");
@@ -0,0 +1,3 @@
1
+ export { refView, view } from "./footnotes.ts";
2
+ export type { ViewConfig } from "./footnotes.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/footnotes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1 @@
1
+ export { refView, view } from "./footnotes.js";
@@ -0,0 +1,11 @@
1
+ import type { Html, HtmlBuilder } from "foldkit/html";
2
+ /** Configuration for rendering the header with `view`. */
3
+ export type ViewConfig = Readonly<{
4
+ /** `NavLink`s, and optionally a `SchemeSwitch` last. */
5
+ items: ReadonlyArray<Html>;
6
+ }>;
7
+ /** The page's header: a nav named "Primary navigation", a line of lowercase links separated
8
+ by middots, then a rule. Each item after the first sits in a `span` with its middot, so a
9
+ wrapped line starts with the middot instead of ending on one. */
10
+ export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
11
+ //# sourceMappingURL=header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../../src/header/header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,wDAAwD;IACxD,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC,CAAC;AAEH;;oEAEoE;AACpE,eAAO,MAAM,IAAI,GAAI,OAAO,UAAU,UAAU,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAYzE,CAAC"}