@escape-game-over/atlas 0.1.24 → 0.1.26

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 (50) hide show
  1. package/README.md +27 -44
  2. package/bin/use-project.mjs +18 -13
  3. package/docs/NOT-BUILT.md +1 -1
  4. package/docs/client-scripts.md +96 -193
  5. package/docs/rich-text.md +18 -20
  6. package/package.json +9 -15
  7. package/src/analytics/google.ts +6 -6
  8. package/src/analytics/index.ts +4 -3
  9. package/src/analytics/tags.ts +13 -58
  10. package/src/analytics/umami.ts +8 -8
  11. package/src/astro/AtlasElement.astro +26 -0
  12. package/src/astro/ConsentBanner.astro +25 -0
  13. package/src/astro/ConsentElement.astro +67 -0
  14. package/src/astro/Document.astro +44 -0
  15. package/src/astro/Image.astro +101 -0
  16. package/src/astro/MetaTags.astro +30 -40
  17. package/src/astro/RichText.astro +88 -0
  18. package/src/astro/Zoom.astro +61 -0
  19. package/src/astro/client.ts +18 -9
  20. package/src/astro/consent.ts +20 -0
  21. package/src/astro/dev-log.ts +8 -14
  22. package/src/astro/element.ts +76 -112
  23. package/src/astro/filters-view.ts +48 -64
  24. package/src/astro/filters.ts +42 -35
  25. package/src/astro/index.ts +2 -9
  26. package/src/astro/ref.ts +46 -0
  27. package/src/astro/site-routes.ts +9 -15
  28. package/src/config.ts +23 -36
  29. package/src/content/index.ts +1 -1
  30. package/src/content/marks.ts +13 -13
  31. package/src/content/rich.ts +26 -42
  32. package/src/hours.ts +48 -11
  33. package/src/i18n/define.ts +14 -74
  34. package/src/index.ts +40 -57
  35. package/src/meta/index.ts +7 -13
  36. package/src/meta/share-image.ts +2 -26
  37. package/src/meta/tag.ts +1 -45
  38. package/src/money.ts +161 -6
  39. package/src/project.ts +84 -73
  40. package/src/routes/define.ts +8 -44
  41. package/src/routes/resolve.ts +1 -1
  42. package/src/site/api.ts +7 -33
  43. package/src/site/create.ts +6 -10
  44. package/src/site/define.ts +120 -0
  45. package/src/site/index.ts +2 -5
  46. package/src/site/page.ts +4 -2
  47. package/src/sitemap.ts +2 -35
  48. package/src/warn.ts +16 -17
  49. package/src/astro/dom.ts +0 -35
  50. package/src/astro/markup.ts +0 -656
package/src/warn.ts CHANGED
@@ -2,22 +2,16 @@
2
2
  * The one place lib writes to a console.
3
3
  *
4
4
  * Everything here is a *warning* by definition: a fact about a file or a string
5
- * that no type can see, worth saying out loud but never worth failing a build
6
- * over. Errors throw instead, and say so at the point they are wrong.
5
+ * that no type can see. Errors throw instead, and say so at the point they are
6
+ * wrong. `ATLAS_STRICT=1` makes every warning throw too, for CI.
7
7
  *
8
- * Shared so the colouring and the `[lib]` prefix are decided once — a warning
8
+ * Shared so the colouring and the `[atlas]` prefix are decided once — a warning
9
9
  * that looks different depending on which module raised it reads like two
10
10
  * different tools.
11
11
  */
12
12
 
13
- /**
14
- * What every line lib writes is labelled with.
15
- *
16
- * A constant rather than a literal at each call site: grep for it to find every
17
- * warning the library can raise, and change it once if this folder is ever
18
- * published under its real name.
19
- */
20
- const PREFIX = "lib";
13
+ /** What every line lib writes is labelled with. */
14
+ const PREFIX = "atlas";
21
15
 
22
16
  /**
23
17
  * The escape character, named rather than embedded. 27 is its code point.
@@ -49,12 +43,16 @@ const RESET = `${ESC}[0m`;
49
43
  * `process` and simply gets colour, which is what a browser console renders
50
44
  * anyway.
51
45
  */
52
- const colour =
53
- (
54
- globalThis as {
55
- process?: { env?: Readonly<Record<string, string | undefined>> };
56
- }
57
- ).process?.env?.NO_COLOR === undefined;
46
+ const env = (
47
+ globalThis as {
48
+ process?: { env?: Readonly<Record<string, string | undefined>> };
49
+ }
50
+ ).process?.env;
51
+
52
+ const colour = env?.NO_COLOR === undefined;
53
+
54
+ /** Read per call rather than once, so a test can switch it. */
55
+ const strict = (): boolean => env?.ATLAS_STRICT === "1";
58
56
 
59
57
  const paint = (code: string, text: string): string =>
60
58
  colour ? `${code}${text}${RESET}` : text;
@@ -66,6 +64,7 @@ const paint = (code: string, text: string): string =>
66
64
  * always printed, because a warning nobody can locate is one nobody acts on.
67
65
  */
68
66
  export function warn(at: string, message: string): void {
67
+ if (strict()) throw new Error(`${shorten(at)}: ${message}`);
69
68
  console.warn(
70
69
  `${paint(YELLOW, `[${PREFIX}] [WARN]`)} ${paint(DIM, shorten(at))}\n ${message}`
71
70
  );
package/src/astro/dom.ts DELETED
@@ -1,35 +0,0 @@
1
- /**
2
- * Scoped element lookups, typed.
3
- *
4
- * ```ts
5
- * const { one, all } = within(root);
6
- * const dots = all<HTMLButtonElement>("[data-carousel-dot]");
7
- * ```
8
- *
9
- * The root is bound once, so a script cannot reach a second copy of itself
10
- * elsewhere on the page. `document` belongs in one place per script: finding
11
- * the roots.
12
- *
13
- * **A selector with a combinator still matches against the whole document.**
14
- * `within(form).one("form p")` can match a `<p>` under a different form; only
15
- * the final filter is scoped. Use `:scope` if a combinator is needed.
16
- */
17
-
18
- export interface Within {
19
- /** The first match inside the root, or `null`. */
20
- one<T extends Element = HTMLElement>(selector: string): T | null;
21
- /** Every match inside the root, as an array rather than a `NodeList`. */
22
- all<T extends Element = HTMLElement>(selector: string): T[];
23
- }
24
-
25
- // `HTMLElement` by default because `hidden`, `dataset` and `focus` live there;
26
- // the bound stays `Element` so inline `<svg>` lookups are not refused.
27
- export function within(root: ParentNode): Within {
28
- return {
29
- one: <T extends Element = HTMLElement>(selector: string) =>
30
- root.querySelector<T>(selector),
31
- all: <T extends Element = HTMLElement>(selector: string) => [
32
- ...root.querySelectorAll<T>(selector),
33
- ],
34
- };
35
- }