@hanzo/design 0.3.4 → 0.3.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/design",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "packageManager": "pnpm@11.17.0",
5
5
  "description": "Hanzo Design System \u2014 monochrome, dark-default tokens + components + brand assets, the single source of truth for every Hanzo surface. CSS + typed programmatic tokens.",
6
6
  "license": "BSD-3-Clause",
@@ -3,7 +3,7 @@
3
3
  // unimported token file resolves nothing, and a 1.66:1 focus ring looks fine to
4
4
  // whoever shipped it. None of them can fail loudly on their own, so they fail
5
5
  // here. Run via `npm test` (part of `build`).
6
- import { readFileSync, readdirSync } from 'node:fs'
6
+ import { existsSync, readFileSync, readdirSync } from 'node:fs'
7
7
  import { fileURLToPath } from 'node:url'
8
8
  import { dirname, join } from 'node:path'
9
9
 
@@ -44,6 +44,19 @@ const pass = (msg) => console.log(` ok ${msg}`)
44
44
  entry.includes('@import')
45
45
  ? fail('styles.css contains an @import — a consumer cannot resolve it (see gen-tokens.mjs)')
46
46
  : pass('styles.css has no @import to resolve')
47
+
48
+ // Every asset it names must EXIST at the path it names, from the root the
49
+ // bundle now sits at. tokens/fonts.css points one directory up because it is
50
+ // authored one directory down; flattening rebases that, and a rebase that
51
+ // silently stopped happening would put the faces outside the package and fail
52
+ // every consumer's build on a missing module.
53
+ const urls = [...entry.matchAll(/url\(\s*['"]?([^'")]+)['"]?\s*\)/g)]
54
+ .map((m) => m[1])
55
+ .filter((u) => !/^(data:|https?:|\/\/)/.test(u))
56
+ const broken = urls.filter((u) => !existsSync(join(root, u)))
57
+ broken.length
58
+ ? broken.forEach((u) => fail(`styles.css references ${u}, which does not exist at the package root`))
59
+ : pass(`all ${urls.length} asset url()s resolve from the package root`)
47
60
  }
48
61
 
49
62
  // ── 2. every var() used inside the token layer must resolve ──────────────
@@ -109,8 +109,17 @@ const banner = `/* Hanzo Design System — the entry point. Import THIS one file
109
109
  * always imported in.
110
110
  */
111
111
  `
112
+ // Hoisting a file from tokens/ to the package root moves what its relative
113
+ // url()s point at. tokens/fonts.css says `../assets/fonts/Geist-Variable.woff2`
114
+ // — correct from tokens/, one directory too high from the root, where it lands
115
+ // outside the package entirely and every consumer's build fails on a missing
116
+ // module. Rebasing is therefore part of flattening, not an afterthought: the
117
+ // bundle is one level shallower, so `../` becomes `./`.
118
+ const rebase = (css) =>
119
+ css.replace(/url\((\s*['"]?)\.\.\/(?!\.)/g, 'url($1./')
120
+
112
121
  const bundle = banner + FILES.map((f) => {
113
- const css = readFileSync(join(tokensDir, `${f}.css`), 'utf8').trim()
122
+ const css = rebase(readFileSync(join(tokensDir, `${f}.css`), 'utf8').trim())
114
123
  return `\n/* ── tokens/${f}.css ─────────────────────────────────────── */\n${css}\n`
115
124
  }).join('')
116
125
  writeFileSync(join(root, 'styles.css'), bundle)
package/styles.css CHANGED
@@ -449,14 +449,14 @@
449
449
 
450
450
  @font-face{
451
451
  font-family:"Geist";
452
- src:url("../assets/fonts/Geist-Variable.woff2") format("woff2");
452
+ src:url("./assets/fonts/Geist-Variable.woff2") format("woff2");
453
453
  font-weight:100 900;
454
454
  font-style:normal;
455
455
  font-display:swap;
456
456
  }
457
457
  @font-face{
458
458
  font-family:"Geist Mono";
459
- src:url("../assets/fonts/GeistMono-Variable.woff2") format("woff2");
459
+ src:url("./assets/fonts/GeistMono-Variable.woff2") format("woff2");
460
460
  font-weight:100 900;
461
461
  font-style:normal;
462
462
  font-display:swap;