@escape-game-over/atlas 0.1.93 → 0.1.95

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/docs/rich-text.md CHANGED
@@ -252,6 +252,10 @@ per `[v:name]` and one for links — usually in a small wrapper
252
252
  </p>
253
253
  ```
254
254
 
255
+ A `[tel]` link renders with `dir="ltr"`: a number has no letters to set its
256
+ direction, and on a right-to-left page it would otherwise read "2227 0244 965+".
257
+ A number on its own, outside copy, is `@escape-game-over/atlas/astro/phone`.
258
+
255
259
  `attrs` puts attributes on a variant's run, so a script can find it and rewrite
256
260
  its words — see [client-scripts.md](client-scripts.md). A variant with neither a
257
261
  class nor attrs still renders its words, and warns at build.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@escape-game-over/atlas",
3
- "version": "0.1.93",
3
+ "version": "0.1.95",
4
4
  "type": "module",
5
5
  "description": "Typed, data-driven machinery for static multi-locale, multi-deployment Astro sites.",
6
6
  "private": false,
@@ -23,6 +23,7 @@
23
23
  "./astro/element": "./src/astro/AtlasElement.astro",
24
24
  "./astro/google-map": "./src/astro/GoogleMap.astro",
25
25
  "./astro/image": "./src/astro/Image.astro",
26
+ "./astro/phone": "./src/astro/Phone.astro",
26
27
  "./astro/rich-text": "./src/astro/RichText.astro"
27
28
  },
28
29
  "bin": {
@@ -50,7 +51,7 @@
50
51
  "check-fmt": "biome check . --error-on-warnings"
51
52
  },
52
53
  "dependencies": {
53
- "@types/google.maps": "3.66.9"
54
+ "@types/google.maps": "3.66.10"
54
55
  },
55
56
  "peerDependencies": {
56
57
  "@types/node": ">=22",
@@ -59,7 +60,7 @@
59
60
  "vite": ">= 8"
60
61
  },
61
62
  "devDependencies": {
62
- "@biomejs/biome": "2.6.5",
63
+ "@biomejs/biome": "2.6.6",
63
64
  "@types/node": "26.6.6",
64
65
  "@vitest/coverage-istanbul": "5.1.0",
65
66
  "astro": "7.4.7",
@@ -275,13 +275,19 @@ const CATEGORY_SIGNALS: Readonly<
275
275
  marketing: ["adStorage", "adUserData", "adPersonalization"],
276
276
  };
277
277
 
278
- /** The signals no answer grants — see `CATEGORY_SIGNALS`. */
279
- const UNASKED = SIGNAL_KEYS.filter(
280
- (key) =>
281
- !CONSENT_CATEGORIES.some((category) =>
282
- CATEGORY_SIGNALS[category].includes(key)
283
- )
284
- );
278
+ /**
279
+ * The signals no answer grants — see `CATEGORY_SIGNALS`. A function, not a
280
+ * value worked out at import: browser bundles import this file for its
281
+ * consent constants and would otherwise compute it on every page.
282
+ */
283
+ function unasked(): readonly (keyof ConsentDefaults)[] {
284
+ return SIGNAL_KEYS.filter(
285
+ (key) =>
286
+ !CONSENT_CATEGORIES.some((category) =>
287
+ CATEGORY_SIGNALS[category].includes(key)
288
+ )
289
+ );
290
+ }
285
291
 
286
292
  /**
287
293
  * What `google-tag.ts` is handed: the settings, already in Google's own names.
@@ -435,7 +441,7 @@ export function googleScripts(
435
441
  }
436
442
 
437
443
  const consent = google.consent ?? DENIED_BY_DEFAULT;
438
- for (const key of UNASKED) {
444
+ for (const key of unasked()) {
439
445
  if (consent.some((given) => given[key] === "denied")) {
440
446
  warn(
441
447
  at,
@@ -0,0 +1,34 @@
1
+ ---
2
+ /**
3
+ * A phone number on the page, kept left to right on a right-to-left one.
4
+ *
5
+ * ```astro
6
+ * <a href={telHref(phone)}><Phone phone={phone} /></a>
7
+ * ```
8
+ *
9
+ * "+965 2227 0244" has no letters to set its direction, so on an Arabic page
10
+ * the browser would lay it out right to left and show "2227 0244 965+". Its own
11
+ * element with `dir="ltr"` keeps it whole, the way the page expects a number
12
+ * to read, and copies as just the number. An email needs none of this: its
13
+ * letters already make it read left to right.
14
+ *
15
+ * Where a number sits inside copy, the `[tel]` mark does the same; this is for
16
+ * a number on its own. `formatPhone` stays plain text, for an aria label or a
17
+ * sentence built as a string.
18
+ */
19
+ import type { HTMLAttributes } from "astro/types";
20
+ import { formatPhone, type PhoneNumber } from "../contact.ts";
21
+
22
+ // Anything a span takes, but not `dir`: that is the point of the component.
23
+ type Props = Omit<HTMLAttributes<"span">, "dir"> & {
24
+ readonly phone: PhoneNumber;
25
+ };
26
+
27
+ const { phone, ...rest } = Astro.props;
28
+ ---
29
+
30
+ <span
31
+ {...rest}
32
+ dir="ltr"
33
+ >{formatPhone(phone)}</span
34
+ >
@@ -74,10 +74,20 @@ const variantAttrs = (variant: string) =>
74
74
  </a>
75
75
  );
76
76
  case "mail":
77
+ return (
78
+ <a
79
+ href={span.href}
80
+ class={link}>
81
+ {span.text}
82
+ </a>
83
+ );
84
+ // A number has no letters to set its direction; on a right-to-left
85
+ // page it would read "2227 0244 965+". See `Phone.astro`.
77
86
  case "tel":
78
87
  return (
79
88
  <a
80
89
  href={span.href}
90
+ dir='ltr'
81
91
  class={link}>
82
92
  {span.text}
83
93
  </a>
package/src/warn.ts CHANGED
@@ -43,19 +43,22 @@ const RESET = `${ESC}[0m`;
43
43
  * `process` and simply gets colour, which is what a browser console renders
44
44
  * anyway.
45
45
  */
46
- const env = (
47
- globalThis as {
48
- process?: { env?: Readonly<Record<string, string | undefined>> };
49
- }
50
- ).process?.env;
46
+ const env = () =>
47
+ (
48
+ globalThis as {
49
+ process?: { env?: Readonly<Record<string, string | undefined>> };
50
+ }
51
+ ).process?.env;
51
52
 
52
- const colour = env?.NO_COLOR === undefined;
53
+ // Functions, not values worked out at import: a browser bundle that imports
54
+ // anything near this file would otherwise run the reads on every page.
55
+ const colour = (): boolean => env()?.NO_COLOR === undefined;
53
56
 
54
57
  /** Read per call rather than once, so a test can switch it. */
55
- const strict = (): boolean => env?.ATLAS_STRICT === "1";
58
+ const strict = (): boolean => env()?.ATLAS_STRICT === "1";
56
59
 
57
60
  const paint = (code: string, text: string): string =>
58
- colour ? `${code}${text}${RESET}` : text;
61
+ colour() ? `${code}${text}${RESET}` : text;
59
62
 
60
63
  /**
61
64
  * Warns about one page, or one file.