@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,8 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ /** The page's header: a nav named "Primary navigation", a line of lowercase links separated
3
+ by middots, then a rule. Each item after the first sits in a `span` with its middot, so a
4
+ wrapped line starts with the middot instead of ending on one. */
5
+ export const view = (config, h) => __foldkitBrandViewResult((h.header([], [
6
+ h.nav([h.AriaLabel("Primary navigation")], config.items.flatMap((item, index) => __foldkitBrandViewResult((index === 0 ? [item] : [" ", h.span([], ["· ", item])]), "@gjermundgaraba-designs/simple-rat/src/header/header.js#anonymous"))),
7
+ h.hr([]),
8
+ ])), "@gjermundgaraba-designs/simple-rat/src/header/header.js#view");
@@ -0,0 +1,3 @@
1
+ export { view } from "./header.ts";
2
+ export type { ViewConfig } from "./header.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/header/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 "./header.js";
@@ -0,0 +1,12 @@
1
+ import type { Html, HtmlBuilder } from "foldkit/html";
2
+ /** Configuration for rendering a section heading with `view`. */
3
+ export type ViewConfig = Readonly<{
4
+ level: 2 | 3;
5
+ id: string;
6
+ /** The heading's words, which also name its link. */
7
+ text: string;
8
+ }>;
9
+ /** A section heading with a `#` link to itself, shown on hover and focus. The page title is
10
+ a plain `h1`. */
11
+ export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
12
+ //# sourceMappingURL=heading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heading.d.ts","sourceRoot":"","sources":["../../../src/heading/heading.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAEH;oBACoB;AACpB,eAAO,MAAM,IAAI,GAAI,OAAO,UAAU,UAAU,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAQ3E,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ /** A section heading with a `#` link to itself, shown on hover and focus. The page title is
3
+ a plain `h1`. */
4
+ export const view = (config, h) => {
5
+ const { level, id, text } = config;
6
+ const children = [
7
+ text,
8
+ " ",
9
+ h.a([h.Class("self"), h.Href(`#${id}`), h.AriaLabel(`Link to ${text}`)], ["#"]),
10
+ ];
11
+ return __foldkitBrandViewResult((level === 2 ? h.h2([h.Id(id)], children) : h.h3([h.Id(id)], children)), "@gjermundgaraba-designs/simple-rat/src/heading/heading.js#view");
12
+ };
@@ -0,0 +1,3 @@
1
+ export { view } from "./heading.ts";
2
+ export type { ViewConfig } from "./heading.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/heading/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 "./heading.js";
@@ -0,0 +1,19 @@
1
+ export * as Code from "./code/index.ts";
2
+ export * as CodeBlock from "./codeBlock/index.ts";
3
+ export * as CopyTab from "./copyTab/index.ts";
4
+ export * as Diagram from "./diagram/index.ts";
5
+ export * as Footer from "./footer/index.ts";
6
+ export * as Footnotes from "./footnotes/index.ts";
7
+ export * as Header from "./header/index.ts";
8
+ export * as Heading from "./heading/index.ts";
9
+ export * as NavLink from "./navLink/index.ts";
10
+ export * as Note from "./note/index.ts";
11
+ export * as Pager from "./pager/index.ts";
12
+ export * as PostList from "./postList/index.ts";
13
+ export * as PostMeta from "./postMeta/index.ts";
14
+ export * as Scheme from "./scheme/index.ts";
15
+ export * as Scrolls from "./scrolls/index.ts";
16
+ export * as SkipLink from "./skipLink/index.ts";
17
+ export * as Swatch from "./swatch/index.ts";
18
+ export * as Table from "./table/index.ts";
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,20 @@
1
+ // simple rat's Foldkit components. Each renders the markup simple-rat.css styles; plain
2
+ // elements (paragraphs, lists, quotes, kbd, mark, details) need no component.
3
+ export * as Code from "./code/index.js";
4
+ export * as CodeBlock from "./codeBlock/index.js";
5
+ export * as CopyTab from "./copyTab/index.js";
6
+ export * as Diagram from "./diagram/index.js";
7
+ export * as Footer from "./footer/index.js";
8
+ export * as Footnotes from "./footnotes/index.js";
9
+ export * as Header from "./header/index.js";
10
+ export * as Heading from "./heading/index.js";
11
+ export * as NavLink from "./navLink/index.js";
12
+ export * as Note from "./note/index.js";
13
+ export * as Pager from "./pager/index.js";
14
+ export * as PostList from "./postList/index.js";
15
+ export * as PostMeta from "./postMeta/index.js";
16
+ export * as Scheme from "./scheme/index.js";
17
+ export * as Scrolls from "./scrolls/index.js";
18
+ export * as SkipLink from "./skipLink/index.js";
19
+ export * as Swatch from "./swatch/index.js";
20
+ export * as Table from "./table/index.js";
@@ -0,0 +1,3 @@
1
+ export { view } from "./navLink.ts";
2
+ export type { ViewConfig } from "./navLink.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/navLink/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 "./navLink.js";
@@ -0,0 +1,13 @@
1
+ import type { Html, HtmlBuilder } from "foldkit/html";
2
+ /** Configuration for rendering a nav link with `view`. */
3
+ export type ViewConfig = Readonly<{
4
+ href: string;
5
+ /** The link's words, lowercase. */
6
+ label: string;
7
+ /** `"Page"` for the page you are on (plain text), `"Section"` for the section it belongs
8
+ to (plain, still underlined). */
9
+ current?: "Page" | "Section" | undefined;
10
+ }>;
11
+ /** A link in the header nav. Nav links never turn visited purple. */
12
+ export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
13
+ //# sourceMappingURL=navLink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navLink.d.ts","sourceRoot":"","sources":["../../../src/navLink/navLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd;wCACoC;IACpC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;CAC1C,CAAC,CAAC;AAEH,qEAAqE;AACrE,eAAO,MAAM,IAAI,GAAI,OAAO,UAAU,UAAU,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAI3E,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ /** A link in the header nav. Nav links never turn visited purple. */
3
+ export const view = (config, h) => {
4
+ const pageAttributes = config.current === "Page" ? [h.AriaCurrent("page")] : [];
5
+ const sectionAttributes = config.current === "Section" ? [h.AriaCurrent("true")] : [];
6
+ return __foldkitBrandViewResult((h.a([h.Href(config.href), ...pageAttributes, ...sectionAttributes], [config.label])), "@gjermundgaraba-designs/simple-rat/src/navLink/navLink.js#view");
7
+ };
@@ -0,0 +1,3 @@
1
+ export { view } from "./note.ts";
2
+ export type { ViewConfig } from "./note.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/note/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ export { view } from "./note.js";
@@ -0,0 +1,12 @@
1
+ import type { Html, HtmlBuilder } from "foldkit/html";
2
+ /** Configuration for rendering a note with `view`. */
3
+ export type ViewConfig = Readonly<{
4
+ /** A warning doubles the rule and turns the first word red. Keep it for real
5
+ consequences, like a step that deletes something. */
6
+ isWarn?: boolean;
7
+ body: ReadonlyArray<Html | string>;
8
+ }>;
9
+ /** A ruled box for the thing a reader must not miss, its first word "Note." (or "Warning.")
10
+ in bold; at most one per screen. */
11
+ export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
12
+ //# sourceMappingURL=note.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"note.d.ts","sourceRoot":"","sources":["../../../src/note/note.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,sDAAsD;AACtD,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC;4DACwD;IACxD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;CACpC,CAAC,CAAC;AAEH;uCACuC;AACvC,eAAO,MAAM,IAAI,GAAI,OAAO,UAAU,UAAU,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAM3E,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ /** A ruled box for the thing a reader must not miss, its first word "Note." (or "Warning.")
3
+ in bold; at most one per screen. */
4
+ export const view = (config, h) => {
5
+ const { isWarn = false, body } = config;
6
+ return __foldkitBrandViewResult((h.aside([h.Class(isWarn ? "note warn" : "note")], [h.p([], [h.strong([], [isWarn ? "Warning." : "Note."]), " ", ...body])])), "@gjermundgaraba-designs/simple-rat/src/note/note.js#view");
7
+ };
@@ -0,0 +1,3 @@
1
+ export { view } from "./pager.ts";
2
+ export type { Link, ViewConfig } from "./pager.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pager/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ export { view } from "./pager.js";
@@ -0,0 +1,17 @@
1
+ import type { Html, HtmlBuilder } from "foldkit/html";
2
+ /** A link in the pager: where it goes and its words. */
3
+ export type Link = Readonly<{
4
+ href: string;
5
+ label: string;
6
+ }>;
7
+ /** Configuration for rendering the pager with `view`. */
8
+ export type ViewConfig = Readonly<{
9
+ newer?: Link | undefined;
10
+ older?: Link | undefined;
11
+ /** The way back to all posts. */
12
+ all: Link;
13
+ }>;
14
+ /** Older and newer links at the end of a post, then the way back to all posts. A missing
15
+ neighbour becomes a muted line saying so. */
16
+ export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
17
+ //# sourceMappingURL=pager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pager.d.ts","sourceRoot":"","sources":["../../../src/pager/pager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,wDAAwD;AACxD,MAAM,MAAM,IAAI,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE7D,yDAAyD;AACzD,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,KAAK,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IACzB,KAAK,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IACzB,iCAAiC;IACjC,GAAG,EAAE,IAAI,CAAC;CACX,CAAC,CAAC;AAEH;gDACgD;AAChD,eAAO,MAAM,IAAI,GAAI,OAAO,UAAU,UAAU,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAc3E,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ /** Older and newer links at the end of a post, then the way back to all posts. A missing
3
+ neighbour becomes a muted line saying so. */
4
+ export const view = (config, h) => {
5
+ const { newer, older, all } = config;
6
+ return __foldkitBrandViewResult((h.nav([h.Class("pager"), h.AriaLabel("Older and newer posts")], [
7
+ newer === undefined
8
+ ? h.p([h.Class("muted")], ["This is the newest post."])
9
+ : h.p([], ["Newer: ", h.a([h.Href(newer.href)], [newer.label])]),
10
+ older === undefined
11
+ ? h.p([h.Class("muted")], ["This is the oldest post."])
12
+ : h.p([], ["Older: ", h.a([h.Href(older.href)], [older.label])]),
13
+ h.p([], [h.a([h.Href(all.href)], [all.label])]),
14
+ ])), "@gjermundgaraba-designs/simple-rat/src/pager/pager.js#view");
15
+ };
@@ -0,0 +1,3 @@
1
+ export { view } from "./postList.ts";
2
+ export type { Entry, ViewConfig } from "./postList.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/postList/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1 @@
1
+ export { view } from "./postList.js";
@@ -0,0 +1,13 @@
1
+ import type { Html, HtmlBuilder } from "foldkit/html";
2
+ export type Entry = Readonly<{
3
+ date: string;
4
+ title: string;
5
+ href: string;
6
+ }>;
7
+ /** Configuration for rendering a post list with `view`. */
8
+ export type ViewConfig = Readonly<{
9
+ posts: ReadonlyArray<Entry>;
10
+ }>;
11
+ /** A list of posts: date, then title, in two columns. */
12
+ export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
13
+ //# sourceMappingURL=postList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postList.d.ts","sourceRoot":"","sources":["../../../src/postList/postList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,MAAM,KAAK,GAAG,QAAQ,CAAC;IAAmB,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE7F,2DAA2D;AAC3D,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAAE,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAA;CAAE,CAAC,CAAC;AAEnE,yDAAyD;AACzD,eAAO,MAAM,IAAI,GAAI,OAAO,UAAU,UAAU,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAUzE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ /** A list of posts: date, then title, in two columns. */
3
+ export const view = (config, h) => __foldkitBrandViewResult((h.ul([h.Class("posts")], config.posts.map((post) => __foldkitBrandViewResult((h.keyed("li")(post.href, [], [h.time([h.Datetime(post.date)], [post.date]), h.a([h.Href(post.href)], [post.title])])), "@gjermundgaraba-designs/simple-rat/src/postList/postList.js#anonymous")))), "@gjermundgaraba-designs/simple-rat/src/postList/postList.js#view");
@@ -0,0 +1,3 @@
1
+ export { view } from "./postMeta.ts";
2
+ export type { ViewConfig } from "./postMeta.ts";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/postMeta/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1 @@
1
+ export { view } from "./postMeta.js";
@@ -0,0 +1,11 @@
1
+ import type { Html, HtmlBuilder } from "foldkit/html";
2
+ /** Configuration for rendering a post's meta line with `view`. */
3
+ export type ViewConfig = Readonly<{
4
+ /** ISO date. */
5
+ date: string;
6
+ /** The rest of the line, after the date. */
7
+ body?: ReadonlyArray<Html | string>;
8
+ }>;
9
+ /** Everything about a post, on one muted line under its title: the date, then the rest. */
10
+ export declare const view: <Message>(config: ViewConfig, h: HtmlBuilder<Message>) => Html;
11
+ //# sourceMappingURL=postMeta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postMeta.d.ts","sourceRoot":"","sources":["../../../src/postMeta/postMeta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,kEAAkE;AAClE,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,IAAI,CAAC,EAAE,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;CACrC,CAAC,CAAC;AAEH,2FAA2F;AAC3F,eAAO,MAAM,IAAI,GAAI,OAAO,UAAU,UAAU,KAAK,WAAW,CAAC,OAAO,CAAC,KAAG,IAUzE,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ import { Array } from "effect";
3
+ /** Everything about a post, on one muted line under its title: the date, then the rest. */
4
+ export const view = (config, h) => __foldkitBrandViewResult((h.p([h.Class("meta")], [
5
+ h.time([h.Datetime(config.date)], [config.date]),
6
+ ...Array.match(config.body ?? [], {
7
+ onEmpty: () => __foldkitBrandViewResult(([]), "@gjermundgaraba-designs/simple-rat/src/postMeta/postMeta.js#onEmpty"),
8
+ onNonEmpty: (body) => __foldkitBrandViewResult(([" · ", ...body]), "@gjermundgaraba-designs/simple-rat/src/postMeta/postMeta.js#onNonEmpty"),
9
+ }),
10
+ ])), "@gjermundgaraba-designs/simple-rat/src/postMeta/postMeta.js#view");
@@ -0,0 +1,4 @@
1
+ export { Scheme } from "./scheme.ts";
2
+ export { schemeScript } from "./script.ts";
3
+ export * as SchemeSwitch from "./schemeSwitch.ts";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scheme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Scheme } from "./scheme.js";
2
+ export { schemeScript } from "./script.js";
3
+ export * as SchemeSwitch from "./schemeSwitch.js";
@@ -0,0 +1,10 @@
1
+ import { Option, Schema } from "effect";
2
+ /** The colour scheme: `Light` or `Dark` pinned on `<html data-scheme>`, or `System`, which
3
+ follows the reader's system in CSS alone. */
4
+ export declare const Scheme: Schema.Literals<readonly ["System", "Light", "Dark"]>;
5
+ export type Scheme = typeof Scheme.Type;
6
+ /** The `data-scheme` value a scheme pins, or none for `System`. */
7
+ export declare const toPinnedValue: (scheme: Scheme) => Option.Option<string>;
8
+ /** The scheme a `data-scheme` value pins. Anything else, or nothing, is `System`. */
9
+ export declare const fromPinnedValue: (value: string | null | undefined) => Scheme;
10
+ //# sourceMappingURL=scheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheme.d.ts","sourceRoot":"","sources":["../../../src/scheme/scheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C;gDACgD;AAChD,eAAO,MAAM,MAAM,uDAA+C,CAAC;AACnE,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAC;AAExC,mEAAmE;AACnE,eAAO,MAAM,aAAa,WAAY,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAOhE,CAAC;AAEJ,qFAAqF;AACrF,eAAO,MAAM,eAAe,UAAW,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,MAMhE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ import { Match, Option, Schema } from "effect";
3
+ /** The colour scheme: `Light` or `Dark` pinned on `<html data-scheme>`, or `System`, which
4
+ follows the reader's system in CSS alone. */
5
+ export const Scheme = Schema.Literals(["System", "Light", "Dark"]);
6
+ /** The `data-scheme` value a scheme pins, or none for `System`. */
7
+ export const toPinnedValue = (scheme) => __foldkitBrandViewResult((Match.value(scheme).pipe(Match.withReturnType(), Match.when("System", () => __foldkitBrandViewResult((Option.none()), "@gjermundgaraba-designs/simple-rat/src/scheme/scheme.js#anonymous")), Match.when("Light", () => __foldkitBrandViewResult((Option.some("light")), "@gjermundgaraba-designs/simple-rat/src/scheme/scheme.js#anonymous~2")), Match.when("Dark", () => __foldkitBrandViewResult((Option.some("dark")), "@gjermundgaraba-designs/simple-rat/src/scheme/scheme.js#anonymous~3")), Match.exhaustive)), "@gjermundgaraba-designs/simple-rat/src/scheme/scheme.js#toPinnedValue");
8
+ /** The scheme a `data-scheme` value pins. Anything else, or nothing, is `System`. */
9
+ export const fromPinnedValue = (value) => __foldkitBrandViewResult((Match.value(value).pipe(Match.withReturnType(), Match.when("light", () => __foldkitBrandViewResult(("Light"), "@gjermundgaraba-designs/simple-rat/src/scheme/scheme.js#anonymous~4")), Match.when("dark", () => __foldkitBrandViewResult(("Dark"), "@gjermundgaraba-designs/simple-rat/src/scheme/scheme.js#anonymous~5")), Match.orElse(() => __foldkitBrandViewResult(("System"), "@gjermundgaraba-designs/simple-rat/src/scheme/scheme.js#anonymous~6")))), "@gjermundgaraba-designs/simple-rat/src/scheme/scheme.js#fromPinnedValue");
@@ -0,0 +1,18 @@
1
+ export * from "./switch.ts";
2
+ /** `theme: system/light/dark`, last in the header nav: three buttons, each built on
3
+ `@foldkit/ui`'s Button, the current choice pressed (and styled as plain text), each
4
+ pressed state announced. Put `schemeScript` in the page's `<head>` so a remembered choice
5
+ applies before first paint. */
6
+ export declare const view: import("foldkit/submodel").View<{
7
+ readonly id: string;
8
+ readonly scheme: "Dark" | "Light" | "System";
9
+ }, {
10
+ readonly _tag: "CompletedPinScheme";
11
+ } | {
12
+ readonly _tag: "CompletedReadScheme";
13
+ readonly scheme: "Dark" | "Light" | "System";
14
+ } | {
15
+ readonly _tag: "SelectedScheme";
16
+ readonly scheme: "Dark" | "Light" | "System";
17
+ }, void>;
18
+ //# sourceMappingURL=schemeSwitch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemeSwitch.d.ts","sourceRoot":"","sources":["../../../src/scheme/schemeSwitch.ts"],"names":[],"mappings":"AAOA,cAAc,aAAa,CAAC;AAU5B;;;kCAGkC;AAClC,eAAO,MAAM,IAAI;;;;;;;;;;;QAqBhB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ import { Button as UiButton } from "@foldkit/ui";
3
+ import { defineView } from "foldkit/submodel";
4
+ import { Message } from "./switch.js";
5
+ export * from "./switch.js";
6
+ // VIEW
7
+ const CHOICES = [
8
+ { scheme: "System", label: "system" },
9
+ { scheme: "Light", label: "light" },
10
+ { scheme: "Dark", label: "dark" },
11
+ ];
12
+ /** `theme: system/light/dark`, last in the header nav: three buttons, each built on
13
+ `@foldkit/ui`'s Button, the current choice pressed (and styled as plain text), each
14
+ pressed state announced. Put `schemeScript` in the page's `<head>` so a remembered choice
15
+ applies before first paint. */
16
+ export const view = defineView((model, h) => __foldkitBrandViewResult((h.span([h.Class("theme"), h.Role("group"), h.AriaLabel("Theme")], [
17
+ "theme: ",
18
+ ...CHOICES.flatMap(({ scheme: choice, label }, index) => __foldkitBrandViewResult(([
19
+ ...(index > 0 ? ["/"] : []),
20
+ UiButton.view({
21
+ onClick: Message.SelectedScheme({ scheme: choice }),
22
+ toView: ({ button }) => __foldkitBrandViewResult((h.button([...button, h.AriaPressed(choice === model.scheme ? "true" : "false")], [label])), "@gjermundgaraba-designs/simple-rat/src/scheme/schemeSwitch.js#toView"),
23
+ }, h),
24
+ ]), "@gjermundgaraba-designs/simple-rat/src/scheme/schemeSwitch.js#anonymous~2")),
25
+ ])), "@gjermundgaraba-designs/simple-rat/src/scheme/schemeSwitch.js#anonymous"));
@@ -0,0 +1,9 @@
1
+ /** Where a pinned scheme is remembered on this device, in `localStorage`. */
2
+ export declare const SCHEME_STORAGE_KEY = "simple-rat-scheme";
3
+ /** The attribute on `<html>` a pinned scheme is written to: `data-scheme="light"` or
4
+ `"dark"`. Without it the stylesheet follows the reader's system. */
5
+ export declare const SCHEME_ATTRIBUTE = "data-scheme";
6
+ /** Inline this in `<head>`, before the stylesheet paints, so a remembered scheme never
7
+ flashes the other one first. Blocked storage leaves the page on the system's scheme. */
8
+ export declare const schemeScript = "try{var s=localStorage.getItem(\"simple-rat-scheme\");if(s===\"light\"||s===\"dark\")document.documentElement.setAttribute(\"data-scheme\",s);}catch(e){}";
9
+ //# sourceMappingURL=script.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../src/scheme/script.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AAEtD;uEACuE;AACvE,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C;2FAC2F;AAC3F,eAAO,MAAM,YAAY,8JAAkK,CAAC"}
@@ -0,0 +1,8 @@
1
+ /** Where a pinned scheme is remembered on this device, in `localStorage`. */
2
+ export const SCHEME_STORAGE_KEY = "simple-rat-scheme";
3
+ /** The attribute on `<html>` a pinned scheme is written to: `data-scheme="light"` or
4
+ `"dark"`. Without it the stylesheet follows the reader's system. */
5
+ export const SCHEME_ATTRIBUTE = "data-scheme";
6
+ /** Inline this in `<head>`, before the stylesheet paints, so a remembered scheme never
7
+ flashes the other one first. Blocked storage leaves the page on the system's scheme. */
8
+ export const schemeScript = `try{var s=localStorage.getItem("${SCHEME_STORAGE_KEY}");if(s==="light"||s==="dark")document.documentElement.setAttribute("${SCHEME_ATTRIBUTE}",s);}catch(e){}`;
@@ -0,0 +1,64 @@
1
+ import { Effect, Schema } from "effect";
2
+ import * as Command from "foldkit/command";
3
+ import type * as Update from "foldkit/update";
4
+ /** Schema for the scheme switch: its id, and the scheme in force as far as the page has
5
+ seen. */
6
+ export declare const Model: Schema.Struct<{
7
+ readonly id: Schema.String;
8
+ readonly scheme: Schema.Literals<readonly ["System", "Light", "Dark"]>;
9
+ }>;
10
+ export type Model = typeof Model.Type;
11
+ /** Union of all Messages the scheme switch can produce. */
12
+ export declare const Message: import("foldkit/message").MessageUnion<{
13
+ readonly SelectedScheme: {
14
+ scheme: Schema.Literals<readonly ["System", "Light", "Dark"]>;
15
+ };
16
+ readonly CompletedPinScheme: {};
17
+ readonly CompletedReadScheme: {
18
+ scheme: Schema.Literals<readonly ["System", "Light", "Dark"]>;
19
+ };
20
+ }>;
21
+ export type Message = typeof Message.Type;
22
+ /** Pins a scheme on `<html data-scheme>` and remembers it on this device in `localStorage`
23
+ under the key `schemeScript` reads; `System` removes both. The attribute is written first,
24
+ so storage that refuses (blocked or full) still switches the page; the choice is just not
25
+ remembered. */
26
+ export declare const PinScheme: Command.CommandDefinitionWithArgs<"PinScheme", {
27
+ scheme: Schema.Literals<readonly ["System", "Light", "Dark"]>;
28
+ }, Effect.Effect<{
29
+ readonly _tag: "CompletedPinScheme";
30
+ }, never, never>>;
31
+ /** Reads the scheme in force from `<html data-scheme>`: what `schemeScript` pinned before
32
+ the page ran, or `System` without it. */
33
+ export declare const ReadScheme: Command.CommandDefinitionNoArgs<"ReadScheme", Effect.Effect<{
34
+ readonly _tag: "CompletedReadScheme";
35
+ readonly scheme: "Dark" | "Light" | "System";
36
+ }, never, never>>;
37
+ /** Configuration for creating a switch with `init`: its id, unique in the document. */
38
+ export type InitConfig = Readonly<{
39
+ id: string;
40
+ }>;
41
+ /** Creates the switch on `System`, as the server renders it, with `ReadScheme`, which the
42
+ client runs after hydration to pick up the scheme `schemeScript` pinned before first
43
+ paint (the server ignores it). A choice made in another tab is seen on the next load. */
44
+ export declare const init: (config: InitConfig) => Update.Return<Model, Message>;
45
+ /** The switch's id. */
46
+ export declare const id: (model: Model) => string;
47
+ /** Processes a scheme switch Message and returns the next Model and Commands. */
48
+ export declare const update: (model: Model, message: Message) => Readonly<{
49
+ model: {
50
+ readonly id: string;
51
+ readonly scheme: "Dark" | "Light" | "System";
52
+ };
53
+ commands?: Update.Commands<{
54
+ readonly _tag: "CompletedPinScheme";
55
+ } | {
56
+ readonly _tag: "CompletedReadScheme";
57
+ readonly scheme: "Dark" | "Light" | "System";
58
+ } | {
59
+ readonly _tag: "SelectedScheme";
60
+ readonly scheme: "Dark" | "Light" | "System";
61
+ }, never>;
62
+ outMessage?: never;
63
+ }>;
64
+ //# sourceMappingURL=switch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/scheme/switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAG3C,OAAO,KAAK,KAAK,MAAM,MAAM,gBAAgB,CAAC;AAU9C;YACY;AACZ,eAAO,MAAM,KAAK;;;EAGhB,CAAC;AACH,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC;AAItC,2DAA2D;AAC3D,eAAO,MAAM,OAAO;;QACA,MAAM;;;;QAED,MAAM;;EAC7B,CAAC;AACH,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAI1C;;;kBAGkB;AAClB,eAAO,MAAM,SAAS;;;;iBAgBpB,CAAC;AAEH;4CAC4C;AAC5C,eAAO,MAAM,UAAU;;;iBAOrB,CAAC;AAIH,uFAAuF;AACvF,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAElD;;4FAE4F;AAC5F,eAAO,MAAM,IAAI,WAAY,UAAU,KAAG,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAGpE,CAAC;AAIH,uBAAuB;AACvB,eAAO,MAAM,EAAE,UAAW,KAAK,KAAG,MAAkB,CAAC;AAIrD,iFAAiF;AACjF,eAAO,MAAM,MAAM,UAAW,KAAK,WAAW,OAAO;;;;;;;;;;;;;;;EAUjD,CAAC"}
@@ -0,0 +1,72 @@
1
+ import { brandViewResult as __foldkitBrandViewResult } from 'foldkit/brand'
2
+ import { Effect, Option, Schema } from "effect";
3
+ import * as Command from "foldkit/command";
4
+ import { defineMessageUnion } from "foldkit/message";
5
+ import { modifyFields } from "foldkit/struct";
6
+ import { Scheme, fromPinnedValue, toPinnedValue } from "./scheme.js";
7
+ import { SCHEME_ATTRIBUTE, SCHEME_STORAGE_KEY } from "./script.js";
8
+ // The scheme switch without its view, the same file in every system that has it; the view
9
+ // is the system's own, in schemeSwitch.ts, which also passes all of this on.
10
+ // MODEL
11
+ /** Schema for the scheme switch: its id, and the scheme in force as far as the page has
12
+ seen. */
13
+ export const Model = Schema.Struct({
14
+ id: Schema.String,
15
+ scheme: Scheme,
16
+ });
17
+ // MESSAGE
18
+ /** Union of all Messages the scheme switch can produce. */
19
+ export const Message = defineMessageUnion({
20
+ SelectedScheme: { scheme: Scheme },
21
+ CompletedPinScheme: {},
22
+ CompletedReadScheme: { scheme: Scheme },
23
+ });
24
+ // COMMAND
25
+ /** Pins a scheme on `<html data-scheme>` and remembers it on this device in `localStorage`
26
+ under the key `schemeScript` reads; `System` removes both. The attribute is written first,
27
+ so storage that refuses (blocked or full) still switches the page; the choice is just not
28
+ remembered. */
29
+ export const PinScheme = Command.define("PinScheme", {
30
+ args: { scheme: Scheme },
31
+ messages: [Message.CompletedPinScheme],
32
+ execute: ({ scheme }) => __foldkitBrandViewResult((Effect.try(() => __foldkitBrandViewResult((Option.match(toPinnedValue(scheme), {
33
+ onNone: () => {
34
+ document.documentElement.removeAttribute(SCHEME_ATTRIBUTE);
35
+ localStorage.removeItem(SCHEME_STORAGE_KEY);
36
+ },
37
+ onSome: (value) => {
38
+ document.documentElement.setAttribute(SCHEME_ATTRIBUTE, value);
39
+ localStorage.setItem(SCHEME_STORAGE_KEY, value);
40
+ },
41
+ })), "@gjermundgaraba-designs/simple-rat/src/scheme/switch.js#anonymous")).pipe(Effect.ignore, Effect.as(Message.CompletedPinScheme()))), "@gjermundgaraba-designs/simple-rat/src/scheme/switch.js#execute"),
42
+ });
43
+ /** Reads the scheme in force from `<html data-scheme>`: what `schemeScript` pinned before
44
+ the page ran, or `System` without it. */
45
+ export const ReadScheme = Command.define("ReadScheme", {
46
+ messages: [Message.CompletedReadScheme],
47
+ execute: Effect.sync(() => __foldkitBrandViewResult((Message.CompletedReadScheme({
48
+ scheme: fromPinnedValue(document.documentElement.getAttribute(SCHEME_ATTRIBUTE)),
49
+ })), "@gjermundgaraba-designs/simple-rat/src/scheme/switch.js#anonymous~2")),
50
+ });
51
+ /** Creates the switch on `System`, as the server renders it, with `ReadScheme`, which the
52
+ client runs after hydration to pick up the scheme `schemeScript` pinned before first
53
+ paint (the server ignores it). A choice made in another tab is seen on the next load. */
54
+ export const init = (config) => (__foldkitBrandViewResult(({
55
+ model: { id: config.id, scheme: "System" },
56
+ commands: [ReadScheme()],
57
+ }), "@gjermundgaraba-designs/simple-rat/src/scheme/switch.js#init"));
58
+ // ACCESSORS
59
+ /** The switch's id. */
60
+ export const id = (model) => __foldkitBrandViewResult((model.id), "@gjermundgaraba-designs/simple-rat/src/scheme/switch.js#id");
61
+ // UPDATE
62
+ /** Processes a scheme switch Message and returns the next Model and Commands. */
63
+ export const update = (model, message) => __foldkitBrandViewResult((Message.match(message, {
64
+ SelectedScheme: ({ scheme }) => (__foldkitBrandViewResult(({
65
+ model: modifyFields(model, { scheme: () => __foldkitBrandViewResult((scheme), "@gjermundgaraba-designs/simple-rat/src/scheme/switch.js#scheme") }),
66
+ commands: [PinScheme({ scheme })],
67
+ }), "@gjermundgaraba-designs/simple-rat/src/scheme/switch.js#SelectedScheme")),
68
+ CompletedPinScheme: () => (__foldkitBrandViewResult(({ model }), "@gjermundgaraba-designs/simple-rat/src/scheme/switch.js#CompletedPinScheme")),
69
+ CompletedReadScheme: ({ scheme }) => (__foldkitBrandViewResult(({
70
+ model: modifyFields(model, { scheme: () => __foldkitBrandViewResult((scheme), "@gjermundgaraba-designs/simple-rat/src/scheme/switch.js#scheme~2") }),
71
+ }), "@gjermundgaraba-designs/simple-rat/src/scheme/switch.js#CompletedReadScheme")),
72
+ })), "@gjermundgaraba-designs/simple-rat/src/scheme/switch.js#update");
@@ -0,0 +1,2 @@
1
+ export { Message, WatchOverflow } from "./scrolls.ts";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/scrolls/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ export { Message, WatchOverflow } from "./scrolls.js";