@escape-game-over/atlas 0.1.24 → 0.1.25
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.
- package/README.md +27 -44
- package/bin/use-project.mjs +18 -13
- package/docs/NOT-BUILT.md +1 -1
- package/docs/client-scripts.md +73 -141
- package/docs/rich-text.md +13 -20
- package/package.json +5 -12
- package/src/analytics/google.ts +6 -6
- package/src/analytics/index.ts +4 -3
- package/src/analytics/tags.ts +13 -58
- package/src/analytics/umami.ts +8 -8
- package/src/astro/ConsentBanner.astro +25 -0
- package/src/astro/ConsentElement.astro +61 -0
- package/src/astro/Document.astro +44 -0
- package/src/astro/Image.astro +102 -0
- package/src/astro/MetaTags.astro +3 -26
- package/src/astro/RichText.astro +71 -0
- package/src/astro/Zoom.astro +61 -0
- package/src/astro/client.ts +19 -9
- package/src/astro/consent.ts +20 -0
- package/src/astro/dev-log.ts +8 -14
- package/src/astro/element.ts +111 -112
- package/src/astro/filters-view.ts +48 -64
- package/src/astro/filters.ts +42 -35
- package/src/astro/index.ts +2 -9
- package/src/astro/markup.ts +6 -6
- package/src/astro/site-routes.ts +9 -15
- package/src/config.ts +23 -36
- package/src/content/index.ts +1 -1
- package/src/content/marks.ts +13 -13
- package/src/content/rich.ts +26 -42
- package/src/hours.ts +48 -11
- package/src/i18n/define.ts +14 -74
- package/src/index.ts +40 -57
- package/src/meta/index.ts +7 -13
- package/src/meta/share-image.ts +2 -26
- package/src/meta/tag.ts +1 -45
- package/src/money.ts +161 -6
- package/src/project.ts +84 -73
- package/src/routes/define.ts +8 -44
- package/src/routes/resolve.ts +1 -1
- package/src/site/api.ts +7 -33
- package/src/site/create.ts +6 -10
- package/src/site/define.ts +120 -0
- package/src/site/index.ts +2 -5
- package/src/site/page.ts +4 -2
- package/src/sitemap.ts +2 -35
- package/src/warn.ts +16 -17
- package/src/astro/dom.ts +0 -35
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
|
|
6
|
-
*
|
|
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 `[
|
|
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
|
-
|
|
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
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
}
|