@hanzo/design 0.4.11 → 0.4.12
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/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/scripts/check-dist.mjs +81 -0
- package/src/index.ts +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,6 @@ export declare function tokenValue(name: CssVarName): string | undefined;
|
|
|
33
33
|
* bare. Pass a URL you serve.
|
|
34
34
|
*/
|
|
35
35
|
export declare function injectDesignCss(href: string): void;
|
|
36
|
-
export { vars, css, isColor, TYPE_MIN, TYPE_MAX } from './preference';
|
|
37
|
-
export type { Preference, Density } from './preference';
|
|
36
|
+
export { vars, css, isColor, TYPE_MIN, TYPE_MAX } from './preference.js';
|
|
37
|
+
export type { Preference, Density } from './preference.js';
|
|
38
38
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE1D,uFAAuF;AACvF,MAAM,MAAM,SAAS,GAAG,UAAU,SAAS,KAAK,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAA;AAErE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAI9E;AAED,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAE/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAQlD;AAKD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,cAAc,iBAAiB,CAAA;AAC/B,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE1D,uFAAuF;AACvF,MAAM,MAAM,SAAS,GAAG,UAAU,SAAS,KAAK,MAAM,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAA;AAErE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAI9E;AAED,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAE/D;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAQlD;AAKD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACzE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -61,4 +61,4 @@ export function injectDesignCss(href) {
|
|
|
61
61
|
// A person's own reading of the system — type size, density, accent — as CSS
|
|
62
62
|
// custom properties. Pure: it maps a preference to variables and returns them,
|
|
63
63
|
// so an app, an embedded preview and a server render all apply it the same way.
|
|
64
|
-
export { vars, css, isColor, TYPE_MIN, TYPE_MAX } from './preference';
|
|
64
|
+
export { vars, css, isColor, TYPE_MIN, TYPE_MAX } from './preference.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/design",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.12",
|
|
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": "MIT OR Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"scripts": {
|
|
34
34
|
"gen": "node scripts/gen-tokens.mjs",
|
|
35
35
|
"test": "node scripts/check-tokens.mjs && node scripts/check-preference.mjs && node scripts/lint.mjs .",
|
|
36
|
-
"build": "pnpm gen && pnpm test && tsc -p tsconfig.json",
|
|
36
|
+
"build": "pnpm gen && pnpm test && tsc -p tsconfig.json && node scripts/check-dist.mjs",
|
|
37
37
|
"prepublishOnly": "pnpm build",
|
|
38
38
|
"lint": "node scripts/lint.mjs"
|
|
39
39
|
},
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import the BUILT package the way a consumer does.
|
|
3
|
+
*
|
|
4
|
+
* Everything else in this repo checks the sources: the token files, the
|
|
5
|
+
* generator's output, the preference contract. All of it passed while
|
|
6
|
+
* `dist/index.js` was unimportable — 0.4.10 and 0.4.11 both shipped a barrel
|
|
7
|
+
* that re-exported `'./preference'` with no extension, which TypeScript emits
|
|
8
|
+
* verbatim and Node ESM refuses to resolve. `pnpm build` was green, `pnpm test`
|
|
9
|
+
* was green, and `import '@hanzo/design'` threw ERR_MODULE_NOT_FOUND for every
|
|
10
|
+
* consumer.
|
|
11
|
+
*
|
|
12
|
+
* A test that reads source cannot see that. This one loads the artifact.
|
|
13
|
+
*/
|
|
14
|
+
import { readFileSync, existsSync } from 'node:fs'
|
|
15
|
+
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
16
|
+
import { dirname, join } from 'node:path'
|
|
17
|
+
|
|
18
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
19
|
+
const root = join(here, '..')
|
|
20
|
+
|
|
21
|
+
let failed = 0
|
|
22
|
+
const check = async (name, fn) => {
|
|
23
|
+
try {
|
|
24
|
+
await fn()
|
|
25
|
+
console.log(` ok ${name}`)
|
|
26
|
+
} catch (e) {
|
|
27
|
+
failed++
|
|
28
|
+
console.error(` FAIL ${name}\n ${e.message}`)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log('dist:')
|
|
33
|
+
|
|
34
|
+
const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'))
|
|
35
|
+
|
|
36
|
+
await check('every export the package advertises actually exists on disk', () => {
|
|
37
|
+
const missing = []
|
|
38
|
+
for (const [name, entry] of Object.entries(pkg.exports ?? {})) {
|
|
39
|
+
for (const target of typeof entry === 'string' ? [entry] : Object.values(entry)) {
|
|
40
|
+
if (typeof target !== 'string' || target.includes('*')) continue
|
|
41
|
+
if (!existsSync(join(root, target))) missing.push(`${name} -> ${target}`)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (missing.length) throw new Error(`exports pointing at nothing:\n ${missing.join('\n ')}`)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
await check('the barrel IMPORTS — the check that 0.4.10 and 0.4.11 needed', async () => {
|
|
48
|
+
const entry = join(root, 'dist/index.js')
|
|
49
|
+
if (!existsSync(entry)) throw new Error('dist/index.js is missing — run the build first')
|
|
50
|
+
const mod = await import(pathToFileURL(entry).href)
|
|
51
|
+
// The preference API is the part that was unreachable; naming it here means a
|
|
52
|
+
// future re-export losing its extension fails by name rather than by silence.
|
|
53
|
+
for (const name of ['vars', 'css', 'isColor', 'TYPE_MIN', 'TYPE_MAX', 'cssVar', 'tokenValue']) {
|
|
54
|
+
if (mod[name] === undefined) throw new Error(`dist/index.js does not export ${name}`)
|
|
55
|
+
}
|
|
56
|
+
if (typeof mod.vars !== 'function') throw new Error('vars is not callable from the built package')
|
|
57
|
+
const v = mod.vars({ type: 1.2, density: 'compact' })
|
|
58
|
+
if (v['--type-scale'] !== '1.2') throw new Error(`built vars() returned ${JSON.stringify(v)}`)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
await check('no emitted module uses an extensionless relative specifier', () => {
|
|
62
|
+
// The class of bug, not just the one instance: Node ESM resolves relative
|
|
63
|
+
// specifiers literally, so a missing `.js` is always a runtime failure.
|
|
64
|
+
const bad = []
|
|
65
|
+
for (const [, entry] of Object.entries(pkg.exports ?? {})) {
|
|
66
|
+
const target = typeof entry === 'string' ? entry : entry.import
|
|
67
|
+
if (typeof target !== 'string' || target.includes('*') || !target.endsWith('.js')) continue
|
|
68
|
+
const file = join(root, target)
|
|
69
|
+
if (!existsSync(file)) continue
|
|
70
|
+
for (const m of readFileSync(file, 'utf8').matchAll(/from\s+['"](\.[^'"]*)['"]/g)) {
|
|
71
|
+
if (!/\.(js|mjs|cjs|json|css)$/.test(m[1])) bad.push(`${target}: ${m[1]}`)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (bad.length) throw new Error(`extensionless relative imports:\n ${bad.join('\n ')}`)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
if (failed) {
|
|
78
|
+
console.error(`\n${failed} dist check(s) failed`)
|
|
79
|
+
process.exit(1)
|
|
80
|
+
}
|
|
81
|
+
console.log('dist: all checks passed')
|
package/src/index.ts
CHANGED
|
@@ -66,5 +66,5 @@ export function injectDesignCss(href: string): void {
|
|
|
66
66
|
// A person's own reading of the system — type size, density, accent — as CSS
|
|
67
67
|
// custom properties. Pure: it maps a preference to variables and returns them,
|
|
68
68
|
// so an app, an embedded preview and a server render all apply it the same way.
|
|
69
|
-
export { vars, css, isColor, TYPE_MIN, TYPE_MAX } from './preference';
|
|
70
|
-
export type { Preference, Density } from './preference';
|
|
69
|
+
export { vars, css, isColor, TYPE_MIN, TYPE_MAX } from './preference.js';
|
|
70
|
+
export type { Preference, Density } from './preference.js';
|