@ui0/vite 0.1.4 → 0.1.6
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/css-modules.d.mts.map +1 -1
- package/dist/css-modules.mjs +20 -14
- package/dist/css-modules.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-modules.d.mts","names":[],"sources":["../src/css-modules.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"css-modules.d.mts","names":[],"sources":["../src/css-modules.ts"],"mappings":";wBAmEgB,cAAc;wBAKd,WAAW;iBAmEV;;EAEf;;EAEA;;;;;;;;;;;wBAYc,kBAAkB,eAAe;iBAqFhC;EAIf;EAKA;EAEA;EAIA;EACA;;iBAGe;EAEf;EAGA;IAAiB;IAAa;;;wBAoEhB,kBAAkB,SAAS,iBAAiB;iBA4F3C,iCAAiC;EAEhD;EAKA;EAKA;;wBAGc,kBAAkB,SAAS;;;;;;QAiDJ,qBAAA;QACN,QAAA,qBAAM,MAAQ;;;;EAWpB,eAAA;IAAE;IAAc;MAAU;;;EAM/B,UAAA,gBAAM;EAcf,KAAA;;;EAmDe,gBAAA;IACtB;MACE,MAAM;MACN,KAAK,YAAY,KAAK"}
|
package/dist/css-modules.mjs
CHANGED
|
@@ -12,9 +12,10 @@ import { sha256hex } from "@ui0/util";
|
|
|
12
12
|
* classes (`.sized,.sizeM,...{/*@*\/}`) plus an optional sibling
|
|
13
13
|
* `<name>.scss` with the matching mixins. The plugin does three jobs:
|
|
14
14
|
*
|
|
15
|
-
* 1. DISTILL (closeBundle + dev watcher): every listed entry folder
|
|
16
|
-
*
|
|
17
|
-
* <name>.module.css -> `@value className: classHash;` lines
|
|
15
|
+
* 1. DISTILL (closeBundle + dev watcher): every listed entry folder ships
|
|
16
|
+
* its `outDir` artifacts:
|
|
17
|
+
* <name>.module.css -> `@value className: classHash;` lines (only when
|
|
18
|
+
* the entry actually has a class module)
|
|
18
19
|
* <name>.scss -> source copy (relative @use/@import rewritten to
|
|
19
20
|
* `scssExportPrefix/<base>` package imports)
|
|
20
21
|
* so consumers can do:
|
|
@@ -41,10 +42,12 @@ import { sha256hex } from "@ui0/util";
|
|
|
41
42
|
* resolves to `export default "<hashed css>"` - a plain string the
|
|
42
43
|
* contract's generator hands back from css().
|
|
43
44
|
*
|
|
44
|
-
* Options.entries accepts a folder holding `<base(basename)>.module.css
|
|
45
|
-
* or a PARENT folder whose direct subfolders are such
|
|
46
|
-
* ('src/contracts' -> size, color, round, ...; 'src/components' ->
|
|
47
|
-
* per component that has a `<component>.module.css`).
|
|
45
|
+
* Options.entries accepts a folder holding `<base(basename)>.module.css`
|
|
46
|
+
* and/or `<base>.scss`, or a PARENT folder whose direct subfolders are such
|
|
47
|
+
* entries ('src/contracts' -> size, color, round, ...; 'src/components' ->
|
|
48
|
+
* one entry per component that has a `<component>.module.css`). A folder
|
|
49
|
+
* with only the scss is a valid entry - its distillation copies the scss
|
|
50
|
+
* without a class map (e.g. the duration contract).
|
|
48
51
|
*
|
|
49
52
|
* The plugin never imports 'vite' or 'vue' - plain node + inline types - so
|
|
50
53
|
* the same code loads in vite, vitest, tsdown (native ESM) and plain `node`
|
|
@@ -148,11 +151,12 @@ function findPackageRoot(from) {
|
|
|
148
151
|
}
|
|
149
152
|
function expandEntries(entries) {
|
|
150
153
|
const out = [];
|
|
154
|
+
const isEntry = (dir, name) => existsSync(path.join(dir, `${name}.module.css`)) || existsSync(path.join(dir, `${name}.scss`));
|
|
151
155
|
for (const raw of entries) {
|
|
152
156
|
const dir = path.resolve(raw);
|
|
153
157
|
if (!existsSync(dir) || !statSync(dir).isDirectory()) continue;
|
|
154
158
|
const name = path.basename(dir);
|
|
155
|
-
if (
|
|
159
|
+
if (isEntry(dir, name)) {
|
|
156
160
|
out.push({
|
|
157
161
|
dir,
|
|
158
162
|
name
|
|
@@ -162,7 +166,7 @@ function expandEntries(entries) {
|
|
|
162
166
|
for (const sub of readdirSync(dir).sort()) {
|
|
163
167
|
const subDir = path.join(dir, sub);
|
|
164
168
|
if (!statSync(subDir).isDirectory()) continue;
|
|
165
|
-
if (
|
|
169
|
+
if (isEntry(subDir, sub)) out.push({
|
|
166
170
|
dir: subDir,
|
|
167
171
|
name: sub
|
|
168
172
|
});
|
|
@@ -195,11 +199,13 @@ function distillCssModules(options) {
|
|
|
195
199
|
mkdirSync(outDir, { recursive: true });
|
|
196
200
|
for (const { dir, name } of entries) {
|
|
197
201
|
const moduleCss = path.join(dir, `${name}.module.css`);
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
if (existsSync(moduleCss)) {
|
|
203
|
+
const values = classNames(readFileSync(moduleCss, "utf8")).map((cls) => `@value ${cls}: ${hashClassName(cls)};`).join("\n") + "\n";
|
|
204
|
+
const moduleOut = path.join(outDir, `${name}.module.css`);
|
|
205
|
+
if (!existsSync(moduleOut) || readFileSync(moduleOut, "utf8") !== values) {
|
|
206
|
+
writeFileSync(moduleOut, values);
|
|
207
|
+
written.push(`${name}.module.css`);
|
|
208
|
+
}
|
|
203
209
|
}
|
|
204
210
|
const scss = path.join(dir, `${name}.scss`);
|
|
205
211
|
if (existsSync(scss)) {
|
package/dist/css-modules.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-modules.mjs","names":[],"sources":["../src/css-modules.ts"],"sourcesContent":["/**\n * @ui0/vite/css-modules - the ui0 class-registry pipeline as a vite/rolldown\n * plugin, shared by the theme package and by component packages.\n *\n * A \"class module\" is a `<name>.module.css` file that only ENUMERATES the\n * classes (`.sized,.sizeM,...{/*@*\\/}`) plus an optional sibling\n * `<name>.scss` with the matching mixins. The plugin does three jobs:\n *\n * 1. DISTILL (closeBundle + dev watcher): every listed entry folder becomes\n * a pair of build artifacts in `outDir`:\n * <name>.module.css -> `@value className: classHash;` lines\n * <name>.scss -> source copy (relative @use/@import rewritten to\n * `scssExportPrefix/<base>` package imports)\n * so consumers can do:\n * @value sized from '@ui0/theme/size.module.css'\n * @use '@ui0/theme/size'\n * 2. TS MAPS (resolveId/load): a DEFAULT import of a class module FROM the\n * listed folders resolves to the SAME hashed map\n * (`{ sized: 'si_xxxx', ... }`) - no css goes through the pipeline, which\n * keeps tsdown builds css-free and vitest away from its any-key proxy.\n * 3. The hash is name-only (sha256 of the class name), so every consumer,\n * test runner and build computes identical names. Format: `xx_hash`.\n *\n * A contract folder may also ship a `<name>.inject.module.scss` (or .css):\n * the contract's own STATIC css. The class names are IMPORTED from the\n * sibling `<name>.module.css` registry (the single source of logical names)\n * with `@value name from './<name>.module.css';` declarations, then used in\n * plain logical selectors. The same pipeline compiles it (sass-embedded for\n * scss), validates every imported name against the referenced registry and\n * every selector against the imports, then rewrites `.name` -> `.<hash(name)>`\n * and:\n * - DISTILL: additionally writes `dist/<name>.inject.module.css`\n * (`@value name: hash;` map lines + the hashed css)\n * - TS: a DEFAULT import of the inject file FROM the listed folders\n * resolves to `export default \"<hashed css>\"` - a plain string the\n * contract's generator hands back from css().\n *\n * Options.entries accepts a folder holding `<base(basename)>.module.css`,\n * or a PARENT folder whose direct subfolders are such entries\n * ('src/contracts' -> size, color, round, ...; 'src/components' -> one entry\n * per component that has a `<component>.module.css`).\n *\n * The plugin never imports 'vite' or 'vue' - plain node + inline types - so\n * the same code loads in vite, vitest, tsdown (native ESM) and plain `node`\n * (type stripping).\n */\nimport {\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n statSync,\n writeFileSync\n} from 'node:fs'\nimport { createRequire } from 'node:module'\nimport path from 'node:path'\nimport process from 'node:process'\n\nimport { sha256hex } from '@ui0/util'\n\n// ---------------------------------------------------------------------------\n// hashing - the single source of truth for class names\n\n/** deterministic scoped name for a class-registry entry: xx_<sha256(name):4> */\nexport function hashClassName(name: string): string {\n const hash = sha256hex(name).slice(0, 4)\n return `${name.slice(0, 2)}_${hash}`\n}\n\nexport function classNames(css: string): string[] {\n return [\n ...new Set(\n [...css.matchAll(/\\.(-?[_a-zA-Z]+[_a-zA-Z0-9-]*)/g)].map((m) => m[1])\n )\n ]\n}\n\n// ---------------------------------------------------------------------------\n// contract inject modules - a contract's own static css\n\n// `<name>.inject.module.css` / `.scss` - resolved by the plugin to a string\n// export of the hashed css (see the header); distilled next to the registry\n// artifacts as `dist/<name>.inject.module.css`.\nconst INJECT_RE = /\\.inject\\.module\\.(css|scss)$/\nconst INJECT_SUFFIX = '.ui0-inject'\n\n// minimal structural type - sass-embedded is an OPTIONAL dependency, only\n// required when an inject module is authored in scss\ninterface SassCompiler {\n compileString(\n source: string,\n options?: { syntax?: 'scss' }\n ): { css: string }\n}\n\nfunction compileInjectScss(source: string, file: string): string {\n let sass: SassCompiler\n try {\n sass = createRequire(import.meta.url)('sass-embedded') as SassCompiler\n } catch {\n throw new Error(\n `${file}: sass-embedded is required to compile an inject scss module - add it to the package running the ui0 plugin`\n )\n }\n return sass.compileString(source, { syntax: 'scss' }).css\n}\n\n// `@layer name { ... }` wrappers are flattened (all of them, nested or\n// sequential): the css is inlined into the theme's own layer, an explicit\n// wrapper would only create an accidental nested layer - and the dotted layer\n// name would otherwise parse as class selectors\nfunction unwrapLayers(css: string): string {\n let out = css\n for (;;) {\n const open = out.match(/@layer\\s+[^{\\s]+\\s*\\{/)\n if (!open || open.index === undefined) break\n let depth = 1\n let i = open.index + open[0].length\n for (; i < out.length && depth > 0; i++) {\n if (out[i] === '{') depth++\n else if (out[i] === '}') depth--\n }\n if (depth > 0) break\n out =\n out.slice(0, open.index) +\n out.slice(open.index + open[0].length, i - 1) +\n out.slice(i)\n }\n // drop the wrapper's common indent + trailing spaces line by line\n const lines = out.split('\\n').map((l) => l.replace(/\\s+$/, ''))\n const indent = Math.min(\n ...lines.filter((l) => l.trim()).map((l) => l.match(/^\\s*/)![0].length)\n )\n return lines.map((l) => l.slice(indent)).join('\\n')\n}\n\nexport interface InjectResult {\n /** compiled, hashed, @value-free css - ready to inline into the theme css */\n css: string\n /** the declared logical class names, in order of appearance */\n names: string[]\n}\n\n/**\n * Process a contract inject module: parse the `@value name from\n * './<base>.module.css';` imports (the class names pulled from the registry),\n * compile scss when needed, validate every imported name against the\n * referenced registry file and every selector against the imports, then hash\n * every imported class token. Throws with a precise message on any drift -\n * the registry stays the single source of logical names, so the emitted\n * hashes always agree with the class maps.\n */\nexport function processInjectFile(file: string): InjectResult {\n const source = readFileSync(file, 'utf8')\n\n // the only allowed @value shape is an import from a registry module:\n // @value name from './<base>.module.css';\n // @value name, other, alias: name from './<base>.module.css';\n const names: string[] = []\n for (const m of source.matchAll(\n /^[ \\t]*@value\\s+([^;\\n]+?)\\s+from\\s+['\"]([^'\"]+)['\"]\\s*;[ \\t]*$/gm\n )) {\n const targetFile = path.resolve(path.dirname(file), m[2])\n if (!existsSync(targetFile)) {\n throw new Error(\n `${file}: cannot resolve the @value import source '${m[2]}'`\n )\n }\n const registry = new Set(classNames(readFileSync(targetFile, 'utf8')))\n for (const part of m[1].split(',')) {\n const pair = part.trim().match(/^([-\\w]+)(?:\\s*:\\s*([-\\w]+))?$/)\n if (!pair) {\n throw new Error(`${file}: cannot parse the @value entry '${part.trim()}'`)\n }\n const name = pair[2] ?? pair[1]\n if (!registry.has(name)) {\n throw new Error(\n `${file}: @value ${name} is not listed in the ${m[2]} registry`\n )\n }\n if (!names.includes(name)) names.push(name)\n }\n }\n if (!names.length) {\n const legacy = source.match(/^[ \\t]*@value\\s+([-\\w]+)\\s*:\\s*([-\\w]+)\\s*;/m)\n if (legacy) {\n throw new Error(\n `${file}: self-referencing @value declarations were removed - import the name from the registry instead: \\`@value ${legacy[1]} from './${path.basename(file).replace(/\\.inject\\.module\\.(css|scss)$/, '')}.module.css';\\``\n )\n }\n throw new Error(`${file}: no @value imports found - nothing to hash`)\n }\n\n const stripped = source.replace(/^[ \\t]*@value\\s+[^\\n;]+;[ \\t]*\\n?/gm, '')\n let css = file.endsWith('.scss')\n ? compileInjectScss(stripped, file)\n : stripped\n css = unwrapLayers(css)\n\n const base = path.basename(file).replace(/\\.inject\\.module\\.(css|scss)$/, '')\n for (const cls of classNames(css)) {\n if (!names.includes(cls)) {\n throw new Error(\n `${file}: selector .${cls} is not imported from the registry - add \\`@value ${cls} from './${base}.module.css';\\` or fix the registry`\n )\n }\n }\n\n // `.name` -> `.<hash>`; longest first + token boundaries so `sizeS` never\n // rewrites inside `sizeXxxl`\n for (const name of [...names].sort((a, b) => b.length - a.length)) {\n const escaped = name.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n const token = new RegExp(`(?<![-\\\\w])\\\\.${escaped}(?![-\\\\w])`, 'g')\n css = css.replace(token, `.${hashClassName(name)}`)\n }\n\n return { css: css.trim(), names }\n}\n\n// the inject module next to an entry, if any - both spellings present is an\n// error (ambiguous which one ships)\nfunction injectSource(dir: string, name: string): string | null {\n const scss = path.join(dir, `${name}.inject.module.scss`)\n const css = path.join(dir, `${name}.inject.module.css`)\n const hasScss = existsSync(scss)\n const hasCss = existsSync(css)\n if (hasScss && hasCss) {\n throw new Error(\n `both ${name}.inject.module.scss and ${name}.inject.module.css exist in ${dir} - keep one`\n )\n }\n return hasScss ? scss : hasCss ? css : null\n}\n\n// ---------------------------------------------------------------------------\n// distillation (plain function - reusable without a bundler)\n\nexport interface DistillOptions {\n // entry folders (absolute or cwd-relative); a folder without its own\n // `<base>.module.css` is scanned one level deep for such subfolders\n entries: string[]\n // plain scss files (or folders of them) copied flat into outDir alongside\n // the distilled entries - shared utility scss with no class module of its\n // own (e.g. the theme package's src/styles). Relative @use/@import inside\n // them is rewritten exactly like the entries' scss.\n extraScss?: string[]\n // output dir for the artifacts (default: '<root>/dist')\n outDir?: string\n // when set, relative @use/@import inside copied scss files that resolve\n // INSIDE the same package are rewritten to `<prefix>/<basename>` imports\n // (the package must expose those paths via its package.json exports)\n scssExportPrefix?: string\n root?: string\n}\n\nexport interface DistillResult {\n // '<name>.module.css' / '<name>.scss' artifacts written or updated\n written: string[]\n // entry folders holding a class module (for the watcher + TS maps)\n moduleEntries: { dir: string; name: string }[]\n}\n\nfunction findPackageRoot(from: string): string | null {\n let dir = from\n while (true) {\n if (existsSync(path.join(dir, 'package.json'))) return dir\n const parent = path.dirname(dir)\n if (parent === dir) return null\n dir = parent\n }\n}\n\n// expand entries: a folder with its own registry is one entry, a parent\n// folder contributes each subfolder that has one\nfunction expandEntries(entries: string[]): { dir: string; name: string }[] {\n const out: { dir: string; name: string }[] = []\n for (const raw of entries) {\n const dir = path.resolve(raw)\n if (!existsSync(dir) || !statSync(dir).isDirectory()) continue\n const name = path.basename(dir)\n if (existsSync(path.join(dir, `${name}.module.css`))) {\n out.push({ dir, name })\n continue\n }\n for (const sub of readdirSync(dir).sort()) {\n const subDir = path.join(dir, sub)\n if (!statSync(subDir).isDirectory()) continue\n if (existsSync(path.join(subDir, `${sub}.module.css`)))\n out.push({ dir: subDir, name: sub })\n }\n }\n return out\n}\n\nfunction rewriteRelativeUses(\n scss: string,\n fromDir: string,\n prefix: string\n): string {\n const packageRoot = findPackageRoot(fromDir)\n const resolve = (spec: string) => {\n const base = path.resolve(fromDir, spec)\n for (const candidate of [\n base,\n `${base}.scss`,\n path.join(base, 'index.scss')\n ]) {\n if (existsSync(candidate)) return candidate\n }\n return undefined\n }\n return scss.replace(\n /(@(?:use|import|forward)\\s+[\"'])(\\.{1,2}\\/[^\"']+)([\"'])/g,\n (m, pre, spec, post) => {\n const file = resolve(spec)\n if (!file || !packageRoot) return m\n const rel = path.relative(packageRoot, file)\n if (rel.startsWith('..')) return m\n return `${pre}${prefix}/${path.basename(file, '.scss')}${post}`\n }\n )\n}\n\nexport function distillCssModules(options: DistillOptions): DistillResult {\n const root = options.root ?? process.cwd()\n const outDir = path.resolve(root, options.outDir ?? 'dist')\n const entries = expandEntries(\n options.entries.map((e) => path.resolve(root, e))\n )\n const written: string[] = []\n\n mkdirSync(outDir, { recursive: true })\n for (const { dir, name } of entries) {\n const moduleCss = path.join(dir, `${name}.module.css`)\n const values =\n classNames(readFileSync(moduleCss, 'utf8'))\n .map((cls) => `@value ${cls}: ${hashClassName(cls)};`)\n .join('\\n') + '\\n'\n const moduleOut = path.join(outDir, `${name}.module.css`)\n if (!existsSync(moduleOut) || readFileSync(moduleOut, 'utf8') !== values) {\n writeFileSync(moduleOut, values)\n written.push(`${name}.module.css`)\n }\n\n const scss = path.join(dir, `${name}.scss`)\n if (existsSync(scss)) {\n let content = readFileSync(scss, 'utf8')\n if (options.scssExportPrefix)\n content = rewriteRelativeUses(content, dir, options.scssExportPrefix)\n const scssOut = path.join(outDir, `${name}.scss`)\n if (!existsSync(scssOut) || readFileSync(scssOut, 'utf8') !== content) {\n writeFileSync(scssOut, content)\n written.push(`${name}.scss`)\n }\n }\n\n const inject = injectSource(dir, name)\n if (inject) {\n const { css, names } = processInjectFile(inject)\n const content =\n names.map((n) => `@value ${n}: ${hashClassName(n)};`).join('\\n') +\n `\\n\\n${css}\\n`\n const injectOut = path.join(outDir, `${name}.inject.module.css`)\n if (\n !existsSync(injectOut) ||\n readFileSync(injectOut, 'utf8') !== content\n ) {\n writeFileSync(injectOut, content)\n written.push(`${name}.inject.module.css`)\n }\n }\n }\n\n // plain utility scss (no class module) copied flat, same rewriting rules\n for (const file of expandExtraScss(options.extraScss ?? [], root)) {\n let content = readFileSync(file, 'utf8')\n if (options.scssExportPrefix)\n content = rewriteRelativeUses(\n content,\n path.dirname(file),\n options.scssExportPrefix\n )\n const scssOut = path.join(outDir, path.basename(file))\n if (!existsSync(scssOut) || readFileSync(scssOut, 'utf8') !== content) {\n writeFileSync(scssOut, content)\n written.push(path.basename(file))\n }\n }\n return { written, moduleEntries: entries }\n}\n\n// extraScss entries may be single files or folders (all direct *.scss)\nfunction expandExtraScss(extraScss: string[], root: string): string[] {\n const out: string[] = []\n for (const raw of extraScss) {\n const p = path.resolve(root, raw)\n if (!existsSync(p)) continue\n if (statSync(p).isDirectory()) {\n for (const f of readdirSync(p).sort()) {\n if (f.endsWith('.scss')) out.push(path.join(p, f))\n }\n } else if (p.endsWith('.scss')) {\n out.push(p)\n }\n }\n return out\n}\n\n// ---------------------------------------------------------------------------\n// the vite/rolldown plugin\n\nconst SUFFIX = '.ui0-map'\n\nexport interface Ui0CssModulesHashOptions extends DistillOptions {\n // re-distill on watched file changes (dev servers)\n watch?: boolean\n // run the distillation (closeBundle/writeBundle artifacts) at all - turn\n // OFF when the plugin is used by a CONSUMER dev server purely for the TS\n // maps (resolveId/load) over a package's sources - it has no dist of its\n // own to write into\n distill?: boolean\n // component <style module> support: hash the SFC module classes with\n // hashClassName (the same names the distilled contract modules use) and\n // emit `<outDir>/<comp>.module.css` (@value name: hash map) on build, so a\n // consumer can do `@value app from '@ui0/core/app'`\n components?: boolean\n}\n\nexport function ui0CssModulesHash(options: Ui0CssModulesHashOptions) {\n let root = process.cwd()\n let entries: { dir: string; name: string }[] = []\n let outDir = 'dist'\n // component name -> hashed class map, collected from the SFC modules\n const componentMaps: Record<string, Record<string, string>> = {}\n\n const refreshEntries = () => {\n entries = expandEntries(options.entries.map((e) => path.resolve(root, e)))\n }\n\n const entryDirs = () => {\n if (!entries.length) refreshEntries()\n return entries.map((e) => e.dir + path.sep)\n }\n\n // first existing candidate for a module-css file reference (importer ids\n // arrive in mixed shapes - absolute fs paths, root-relative '/src/...',\n // occasionally with a wrong/absent config root)\n function locate(file: string): string | null {\n if (existsSync(file)) return file\n const rel = file.replace(/^\\/+/, '')\n for (const base of [root, process.cwd()]) {\n const candidate = path.resolve(base, rel)\n if (existsSync(candidate)) return candidate\n }\n return null\n }\n\n function mapFor(id: string): string | null {\n const file = locate(id.endsWith(SUFFIX) ? id.slice(0, -SUFFIX.length) : id)\n if (!file || !entryDirs().some((dir) => file.startsWith(dir))) return null\n const css = readFileSync(file, 'utf8')\n const pairs = classNames(css)\n .map((n) => `${JSON.stringify(n)}: ${JSON.stringify(hashClassName(n))}`)\n .join(', ')\n return `export default { ${pairs} }`\n }\n\n return {\n name: 'ui0:css-modules-hash',\n enforce: 'pre' as const,\n config() {\n if (!options.components) return\n return {\n css: {\n modules: {\n // the SAME hash names as the distilled contract modules - a\n // component's own styles and its published module always agree\n generateScopedName: (name: string) => hashClassName(name),\n getJSON(cssFileName: string, json: Record<string, string>) {\n const comp = path\n .basename(cssFileName.split('?')[0])\n .replace(/\\.vue$/, '')\n .replace(/\\.module\\.css$/, '')\n componentMaps[comp] = { ...(componentMaps[comp] ?? {}), ...json }\n }\n }\n }\n }\n },\n configResolved(config: { root: string; build?: { outDir?: string } }) {\n root = config.root\n if (config.build?.outDir) outDir = config.build.outDir\n refreshEntries()\n },\n // the TS side: DEFAULT imports of the listed class modules -> hashed maps\n resolveId(source: string, importer: string | undefined) {\n // inject modules first - their names also end with .module.css\n if (INJECT_RE.test(source) && importer) {\n const file = locate(path.resolve(path.dirname(importer), source))\n if (!file || !entryDirs().some((dir) => file.startsWith(dir)))\n return null\n return file + INJECT_SUFFIX\n }\n if (!source.endsWith('.module.css') || !importer) return null\n const file = locate(path.resolve(path.dirname(importer), source))\n // only the listed entries - anything else stays with the default pipeline\n if (!file || !entryDirs().some((dir) => file.startsWith(dir))) return null\n return file + SUFFIX\n },\n load(id: string) {\n if (id.endsWith(INJECT_SUFFIX)) {\n // ids arrive in mixed shapes (absolute fs paths, root-relative\n // '/src/...') - locate before reading\n const file = locate(id.slice(0, -INJECT_SUFFIX.length))\n if (!file) return null\n const { css } = processInjectFile(file)\n return `export default ${JSON.stringify(css)}`\n }\n if (id.endsWith(`.module.css${SUFFIX}`)) return mapFor(id)\n if (INJECT_RE.test(id) && !existsSync(id)) {\n // a root-relative inject id that slipped past resolveId - map it to\n // the real file, same as the registry fallback below\n const file = locate(id)\n if (file) {\n const { css } = processInjectFile(file)\n return `export default ${JSON.stringify(css)}`\n }\n }\n if (id.endsWith('.module.css') && !existsSync(id)) {\n // a root-relative id ('/src/x.module.css') that slipped past resolveId\n // (cached/transformed import) - map it to the real file\n return mapFor(id)\n }\n return null\n },\n // after the bundler wrote (and cleaned) its outDir - distilling earlier\n // would be wiped by the bundler's own clean step. Skipped together with\n // the distillation when the plugin runs maps-only in a consumer\n writeBundle() {\n if (!options.components || options.distill === false) return\n const dir = path.resolve(root, outDir)\n mkdirSync(dir, { recursive: true })\n for (const [comp, map] of Object.entries(componentMaps)) {\n const names = Object.keys(map)\n if (!names.length) continue\n const content =\n names.map((n) => `@value ${n}: ${map[n]};`).join('\\n') + '\\n'\n const file = path.join(dir, `${comp}.module.css`)\n if (!existsSync(file) || readFileSync(file, 'utf8') !== content) {\n writeFileSync(file, content)\n }\n }\n },\n closeBundle() {\n if (options.distill === false) return\n const result = distillCssModules({ ...options, root })\n if (result.written.length) {\n console.log(`✓ ui0-css-modules-hash (${result.written.join(', ')})`)\n }\n },\n configureServer(server: {\n watcher: {\n add: (p: string) => void\n on: (ev: string, cb: (file: string) => void) => void\n }\n }) {\n if (options.watch === false || options.distill === false) return\n for (const { dir } of entries) server.watcher.add(dir)\n server.watcher.on('change', (file: string) => {\n if (!entryDirs().some((dir) => file.startsWith(dir))) return\n const result = distillCssModules({ ...options, root })\n if (result.written.length) {\n console.log(`✓ ui0-css-modules-hash (${result.written.join(', ')})`)\n }\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,SAAgB,cAAc,MAAsB;CAClD,MAAM,OAAO,UAAU,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;CACvC,OAAO,GAAG,KAAK,MAAM,GAAG,CAAC,EAAE,GAAG;AAChC;AAEA,SAAgB,WAAW,KAAuB;CAChD,OAAO,CACL,GAAG,IAAI,IACL,CAAC,GAAG,IAAI,SAAS,iCAAiC,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,EAAE,CACtE,CACF;AACF;AAQA,MAAM,YAAY;AAClB,MAAM,gBAAgB;AAWtB,SAAS,kBAAkB,QAAgB,MAAsB;CAC/D,IAAI;CACJ,IAAI;EACF,OAAO,cAAc,YAAY,GAAG,CA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CAAC,KAAK,IAAI,IAAI;IAC3D,MAAM,OAAO,KAAK,KAAK,KAAK,GAAG,KAAK,YAAY;IAChD,IAAI,CAAC,WAAW,IAAI,KAAK,aAAa,MAAM,MAAM,MAAM,SACtD,cAAc,MAAM,OAAO;GAE/B;EACF;EACA,cAAc;GACZ,IAAI,QAAQ,YAAY,OAAO;GAC/B,MAAM,SAAS,kBAAkB;IAAE,GAAG;IAAS;GAAK,CAAC;GACrD,IAAI,OAAO,QAAQ,QACjB,QAAQ,IAAI,2BAA2B,OAAO,QAAQ,KAAK,IAAI,EAAE,EAAE;EAEvE;EACA,gBAAgB,QAKb;GACD,IAAI,QAAQ,UAAU,SAAS,QAAQ,YAAY,OAAO;GAC1D,KAAK,MAAM,EAAE,SAAS,SAAS,OAAO,QAAQ,IAAI,GAAG;GACrD,OAAO,QAAQ,GAAG,WAAW,SAAiB;IAC5C,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,QAAQ,KAAK,WAAW,GAAG,CAAC,GAAG;IACtD,MAAM,SAAS,kBAAkB;KAAE,GAAG;KAAS;IAAK,CAAC;IACrD,IAAI,OAAO,QAAQ,QACjB,QAAQ,IAAI,2BAA2B,OAAO,QAAQ,KAAK,IAAI,EAAE,EAAE;GAEvE,CAAC;EACH;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"css-modules.mjs","names":[],"sources":["../src/css-modules.ts"],"sourcesContent":["/**\n * @ui0/vite/css-modules - the ui0 class-registry pipeline as a vite/rolldown\n * plugin, shared by the theme package and by component packages.\n *\n * A \"class module\" is a `<name>.module.css` file that only ENUMERATES the\n * classes (`.sized,.sizeM,...{/*@*\\/}`) plus an optional sibling\n * `<name>.scss` with the matching mixins. The plugin does three jobs:\n *\n * 1. DISTILL (closeBundle + dev watcher): every listed entry folder ships\n * its `outDir` artifacts:\n * <name>.module.css -> `@value className: classHash;` lines (only when\n * the entry actually has a class module)\n * <name>.scss -> source copy (relative @use/@import rewritten to\n * `scssExportPrefix/<base>` package imports)\n * so consumers can do:\n * @value sized from '@ui0/theme/size.module.css'\n * @use '@ui0/theme/size'\n * 2. TS MAPS (resolveId/load): a DEFAULT import of a class module FROM the\n * listed folders resolves to the SAME hashed map\n * (`{ sized: 'si_xxxx', ... }`) - no css goes through the pipeline, which\n * keeps tsdown builds css-free and vitest away from its any-key proxy.\n * 3. The hash is name-only (sha256 of the class name), so every consumer,\n * test runner and build computes identical names. Format: `xx_hash`.\n *\n * A contract folder may also ship a `<name>.inject.module.scss` (or .css):\n * the contract's own STATIC css. The class names are IMPORTED from the\n * sibling `<name>.module.css` registry (the single source of logical names)\n * with `@value name from './<name>.module.css';` declarations, then used in\n * plain logical selectors. The same pipeline compiles it (sass-embedded for\n * scss), validates every imported name against the referenced registry and\n * every selector against the imports, then rewrites `.name` -> `.<hash(name)>`\n * and:\n * - DISTILL: additionally writes `dist/<name>.inject.module.css`\n * (`@value name: hash;` map lines + the hashed css)\n * - TS: a DEFAULT import of the inject file FROM the listed folders\n * resolves to `export default \"<hashed css>\"` - a plain string the\n * contract's generator hands back from css().\n *\n * Options.entries accepts a folder holding `<base(basename)>.module.css`\n * and/or `<base>.scss`, or a PARENT folder whose direct subfolders are such\n * entries ('src/contracts' -> size, color, round, ...; 'src/components' ->\n * one entry per component that has a `<component>.module.css`). A folder\n * with only the scss is a valid entry - its distillation copies the scss\n * without a class map (e.g. the duration contract).\n *\n * The plugin never imports 'vite' or 'vue' - plain node + inline types - so\n * the same code loads in vite, vitest, tsdown (native ESM) and plain `node`\n * (type stripping).\n */\nimport {\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n statSync,\n writeFileSync\n} from 'node:fs'\nimport { createRequire } from 'node:module'\nimport path from 'node:path'\nimport process from 'node:process'\n\nimport { sha256hex } from '@ui0/util'\n\n// ---------------------------------------------------------------------------\n// hashing - the single source of truth for class names\n\n/** deterministic scoped name for a class-registry entry: xx_<sha256(name):4> */\nexport function hashClassName(name: string): string {\n const hash = sha256hex(name).slice(0, 4)\n return `${name.slice(0, 2)}_${hash}`\n}\n\nexport function classNames(css: string): string[] {\n return [\n ...new Set(\n [...css.matchAll(/\\.(-?[_a-zA-Z]+[_a-zA-Z0-9-]*)/g)].map((m) => m[1])\n )\n ]\n}\n\n// ---------------------------------------------------------------------------\n// contract inject modules - a contract's own static css\n\n// `<name>.inject.module.css` / `.scss` - resolved by the plugin to a string\n// export of the hashed css (see the header); distilled next to the registry\n// artifacts as `dist/<name>.inject.module.css`.\nconst INJECT_RE = /\\.inject\\.module\\.(css|scss)$/\nconst INJECT_SUFFIX = '.ui0-inject'\n\n// minimal structural type - sass-embedded is an OPTIONAL dependency, only\n// required when an inject module is authored in scss\ninterface SassCompiler {\n compileString(\n source: string,\n options?: { syntax?: 'scss' }\n ): { css: string }\n}\n\nfunction compileInjectScss(source: string, file: string): string {\n let sass: SassCompiler\n try {\n sass = createRequire(import.meta.url)('sass-embedded') as SassCompiler\n } catch {\n throw new Error(\n `${file}: sass-embedded is required to compile an inject scss module - add it to the package running the ui0 plugin`\n )\n }\n return sass.compileString(source, { syntax: 'scss' }).css\n}\n\n// `@layer name { ... }` wrappers are flattened (all of them, nested or\n// sequential): the css is inlined into the theme's own layer, an explicit\n// wrapper would only create an accidental nested layer - and the dotted layer\n// name would otherwise parse as class selectors\nfunction unwrapLayers(css: string): string {\n let out = css\n for (;;) {\n const open = out.match(/@layer\\s+[^{\\s]+\\s*\\{/)\n if (!open || open.index === undefined) break\n let depth = 1\n let i = open.index + open[0].length\n for (; i < out.length && depth > 0; i++) {\n if (out[i] === '{') depth++\n else if (out[i] === '}') depth--\n }\n if (depth > 0) break\n out =\n out.slice(0, open.index) +\n out.slice(open.index + open[0].length, i - 1) +\n out.slice(i)\n }\n // drop the wrapper's common indent + trailing spaces line by line\n const lines = out.split('\\n').map((l) => l.replace(/\\s+$/, ''))\n const indent = Math.min(\n ...lines.filter((l) => l.trim()).map((l) => l.match(/^\\s*/)![0].length)\n )\n return lines.map((l) => l.slice(indent)).join('\\n')\n}\n\nexport interface InjectResult {\n /** compiled, hashed, @value-free css - ready to inline into the theme css */\n css: string\n /** the declared logical class names, in order of appearance */\n names: string[]\n}\n\n/**\n * Process a contract inject module: parse the `@value name from\n * './<base>.module.css';` imports (the class names pulled from the registry),\n * compile scss when needed, validate every imported name against the\n * referenced registry file and every selector against the imports, then hash\n * every imported class token. Throws with a precise message on any drift -\n * the registry stays the single source of logical names, so the emitted\n * hashes always agree with the class maps.\n */\nexport function processInjectFile(file: string): InjectResult {\n const source = readFileSync(file, 'utf8')\n\n // the only allowed @value shape is an import from a registry module:\n // @value name from './<base>.module.css';\n // @value name, other, alias: name from './<base>.module.css';\n const names: string[] = []\n for (const m of source.matchAll(\n /^[ \\t]*@value\\s+([^;\\n]+?)\\s+from\\s+['\"]([^'\"]+)['\"]\\s*;[ \\t]*$/gm\n )) {\n const targetFile = path.resolve(path.dirname(file), m[2])\n if (!existsSync(targetFile)) {\n throw new Error(\n `${file}: cannot resolve the @value import source '${m[2]}'`\n )\n }\n const registry = new Set(classNames(readFileSync(targetFile, 'utf8')))\n for (const part of m[1].split(',')) {\n const pair = part.trim().match(/^([-\\w]+)(?:\\s*:\\s*([-\\w]+))?$/)\n if (!pair) {\n throw new Error(`${file}: cannot parse the @value entry '${part.trim()}'`)\n }\n const name = pair[2] ?? pair[1]\n if (!registry.has(name)) {\n throw new Error(\n `${file}: @value ${name} is not listed in the ${m[2]} registry`\n )\n }\n if (!names.includes(name)) names.push(name)\n }\n }\n if (!names.length) {\n const legacy = source.match(/^[ \\t]*@value\\s+([-\\w]+)\\s*:\\s*([-\\w]+)\\s*;/m)\n if (legacy) {\n throw new Error(\n `${file}: self-referencing @value declarations were removed - import the name from the registry instead: \\`@value ${legacy[1]} from './${path.basename(file).replace(/\\.inject\\.module\\.(css|scss)$/, '')}.module.css';\\``\n )\n }\n throw new Error(`${file}: no @value imports found - nothing to hash`)\n }\n\n const stripped = source.replace(/^[ \\t]*@value\\s+[^\\n;]+;[ \\t]*\\n?/gm, '')\n let css = file.endsWith('.scss')\n ? compileInjectScss(stripped, file)\n : stripped\n css = unwrapLayers(css)\n\n const base = path.basename(file).replace(/\\.inject\\.module\\.(css|scss)$/, '')\n for (const cls of classNames(css)) {\n if (!names.includes(cls)) {\n throw new Error(\n `${file}: selector .${cls} is not imported from the registry - add \\`@value ${cls} from './${base}.module.css';\\` or fix the registry`\n )\n }\n }\n\n // `.name` -> `.<hash>`; longest first + token boundaries so `sizeS` never\n // rewrites inside `sizeXxxl`\n for (const name of [...names].sort((a, b) => b.length - a.length)) {\n const escaped = name.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n const token = new RegExp(`(?<![-\\\\w])\\\\.${escaped}(?![-\\\\w])`, 'g')\n css = css.replace(token, `.${hashClassName(name)}`)\n }\n\n return { css: css.trim(), names }\n}\n\n// the inject module next to an entry, if any - both spellings present is an\n// error (ambiguous which one ships)\nfunction injectSource(dir: string, name: string): string | null {\n const scss = path.join(dir, `${name}.inject.module.scss`)\n const css = path.join(dir, `${name}.inject.module.css`)\n const hasScss = existsSync(scss)\n const hasCss = existsSync(css)\n if (hasScss && hasCss) {\n throw new Error(\n `both ${name}.inject.module.scss and ${name}.inject.module.css exist in ${dir} - keep one`\n )\n }\n return hasScss ? scss : hasCss ? css : null\n}\n\n// ---------------------------------------------------------------------------\n// distillation (plain function - reusable without a bundler)\n\nexport interface DistillOptions {\n // entry folders (absolute or cwd-relative); a folder without its own\n // `<base>.module.css` / `<base>.scss` pair is scanned one level deep for\n // such subfolders\n entries: string[]\n // plain scss files (or folders of them) copied flat into outDir alongside\n // the distilled entries - shared utility scss with no class module of its\n // own (e.g. the theme package's src/styles). Relative @use/@import inside\n // them is rewritten exactly like the entries' scss.\n extraScss?: string[]\n // output dir for the artifacts (default: '<root>/dist')\n outDir?: string\n // when set, relative @use/@import inside copied scss files that resolve\n // INSIDE the same package are rewritten to `<prefix>/<basename>` imports\n // (the package must expose those paths via its package.json exports)\n scssExportPrefix?: string\n root?: string\n}\n\nexport interface DistillResult {\n // '<name>.module.css' / '<name>.scss' artifacts written or updated\n written: string[]\n // entry folders (for the watcher + TS maps) - with or without a class\n // module of their own\n moduleEntries: { dir: string; name: string }[]\n}\n\nfunction findPackageRoot(from: string): string | null {\n let dir = from\n while (true) {\n if (existsSync(path.join(dir, 'package.json'))) return dir\n const parent = path.dirname(dir)\n if (parent === dir) return null\n dir = parent\n }\n}\n\n// expand entries: a folder with its own registry is one entry, a parent\n// folder contributes each subfolder that has one. An entry holds\n// `<name>.module.css` and/or `<name>.scss` - a contract may ship mixins or\n// variables only, with no class module of its own (e.g. duration).\nfunction expandEntries(entries: string[]): { dir: string; name: string }[] {\n const out: { dir: string; name: string }[] = []\n const isEntry = (dir: string, name: string): boolean =>\n existsSync(path.join(dir, `${name}.module.css`)) ||\n existsSync(path.join(dir, `${name}.scss`))\n for (const raw of entries) {\n const dir = path.resolve(raw)\n if (!existsSync(dir) || !statSync(dir).isDirectory()) continue\n const name = path.basename(dir)\n if (isEntry(dir, name)) {\n out.push({ dir, name })\n continue\n }\n for (const sub of readdirSync(dir).sort()) {\n const subDir = path.join(dir, sub)\n if (!statSync(subDir).isDirectory()) continue\n if (isEntry(subDir, sub)) out.push({ dir: subDir, name: sub })\n }\n }\n return out\n}\n\nfunction rewriteRelativeUses(\n scss: string,\n fromDir: string,\n prefix: string\n): string {\n const packageRoot = findPackageRoot(fromDir)\n const resolve = (spec: string) => {\n const base = path.resolve(fromDir, spec)\n for (const candidate of [\n base,\n `${base}.scss`,\n path.join(base, 'index.scss')\n ]) {\n if (existsSync(candidate)) return candidate\n }\n return undefined\n }\n return scss.replace(\n /(@(?:use|import|forward)\\s+[\"'])(\\.{1,2}\\/[^\"']+)([\"'])/g,\n (m, pre, spec, post) => {\n const file = resolve(spec)\n if (!file || !packageRoot) return m\n const rel = path.relative(packageRoot, file)\n if (rel.startsWith('..')) return m\n return `${pre}${prefix}/${path.basename(file, '.scss')}${post}`\n }\n )\n}\n\nexport function distillCssModules(options: DistillOptions): DistillResult {\n const root = options.root ?? process.cwd()\n const outDir = path.resolve(root, options.outDir ?? 'dist')\n const entries = expandEntries(\n options.entries.map((e) => path.resolve(root, e))\n )\n const written: string[] = []\n\n mkdirSync(outDir, { recursive: true })\n for (const { dir, name } of entries) {\n const moduleCss = path.join(dir, `${name}.module.css`)\n if (existsSync(moduleCss)) {\n const values =\n classNames(readFileSync(moduleCss, 'utf8'))\n .map((cls) => `@value ${cls}: ${hashClassName(cls)};`)\n .join('\\n') + '\\n'\n const moduleOut = path.join(outDir, `${name}.module.css`)\n if (!existsSync(moduleOut) || readFileSync(moduleOut, 'utf8') !== values) {\n writeFileSync(moduleOut, values)\n written.push(`${name}.module.css`)\n }\n }\n\n const scss = path.join(dir, `${name}.scss`)\n if (existsSync(scss)) {\n let content = readFileSync(scss, 'utf8')\n if (options.scssExportPrefix)\n content = rewriteRelativeUses(content, dir, options.scssExportPrefix)\n const scssOut = path.join(outDir, `${name}.scss`)\n if (!existsSync(scssOut) || readFileSync(scssOut, 'utf8') !== content) {\n writeFileSync(scssOut, content)\n written.push(`${name}.scss`)\n }\n }\n\n const inject = injectSource(dir, name)\n if (inject) {\n const { css, names } = processInjectFile(inject)\n const content =\n names.map((n) => `@value ${n}: ${hashClassName(n)};`).join('\\n') +\n `\\n\\n${css}\\n`\n const injectOut = path.join(outDir, `${name}.inject.module.css`)\n if (\n !existsSync(injectOut) ||\n readFileSync(injectOut, 'utf8') !== content\n ) {\n writeFileSync(injectOut, content)\n written.push(`${name}.inject.module.css`)\n }\n }\n }\n\n // plain utility scss (no class module) copied flat, same rewriting rules\n for (const file of expandExtraScss(options.extraScss ?? [], root)) {\n let content = readFileSync(file, 'utf8')\n if (options.scssExportPrefix)\n content = rewriteRelativeUses(\n content,\n path.dirname(file),\n options.scssExportPrefix\n )\n const scssOut = path.join(outDir, path.basename(file))\n if (!existsSync(scssOut) || readFileSync(scssOut, 'utf8') !== content) {\n writeFileSync(scssOut, content)\n written.push(path.basename(file))\n }\n }\n return { written, moduleEntries: entries }\n}\n\n// extraScss entries may be single files or folders (all direct *.scss)\nfunction expandExtraScss(extraScss: string[], root: string): string[] {\n const out: string[] = []\n for (const raw of extraScss) {\n const p = path.resolve(root, raw)\n if (!existsSync(p)) continue\n if (statSync(p).isDirectory()) {\n for (const f of readdirSync(p).sort()) {\n if (f.endsWith('.scss')) out.push(path.join(p, f))\n }\n } else if (p.endsWith('.scss')) {\n out.push(p)\n }\n }\n return out\n}\n\n// ---------------------------------------------------------------------------\n// the vite/rolldown plugin\n\nconst SUFFIX = '.ui0-map'\n\nexport interface Ui0CssModulesHashOptions extends DistillOptions {\n // re-distill on watched file changes (dev servers)\n watch?: boolean\n // run the distillation (closeBundle/writeBundle artifacts) at all - turn\n // OFF when the plugin is used by a CONSUMER dev server purely for the TS\n // maps (resolveId/load) over a package's sources - it has no dist of its\n // own to write into\n distill?: boolean\n // component <style module> support: hash the SFC module classes with\n // hashClassName (the same names the distilled contract modules use) and\n // emit `<outDir>/<comp>.module.css` (@value name: hash map) on build, so a\n // consumer can do `@value app from '@ui0/core/app'`\n components?: boolean\n}\n\nexport function ui0CssModulesHash(options: Ui0CssModulesHashOptions) {\n let root = process.cwd()\n let entries: { dir: string; name: string }[] = []\n let outDir = 'dist'\n // component name -> hashed class map, collected from the SFC modules\n const componentMaps: Record<string, Record<string, string>> = {}\n\n const refreshEntries = () => {\n entries = expandEntries(options.entries.map((e) => path.resolve(root, e)))\n }\n\n const entryDirs = () => {\n if (!entries.length) refreshEntries()\n return entries.map((e) => e.dir + path.sep)\n }\n\n // first existing candidate for a module-css file reference (importer ids\n // arrive in mixed shapes - absolute fs paths, root-relative '/src/...',\n // occasionally with a wrong/absent config root)\n function locate(file: string): string | null {\n if (existsSync(file)) return file\n const rel = file.replace(/^\\/+/, '')\n for (const base of [root, process.cwd()]) {\n const candidate = path.resolve(base, rel)\n if (existsSync(candidate)) return candidate\n }\n return null\n }\n\n function mapFor(id: string): string | null {\n const file = locate(id.endsWith(SUFFIX) ? id.slice(0, -SUFFIX.length) : id)\n if (!file || !entryDirs().some((dir) => file.startsWith(dir))) return null\n const css = readFileSync(file, 'utf8')\n const pairs = classNames(css)\n .map((n) => `${JSON.stringify(n)}: ${JSON.stringify(hashClassName(n))}`)\n .join(', ')\n return `export default { ${pairs} }`\n }\n\n return {\n name: 'ui0:css-modules-hash',\n enforce: 'pre' as const,\n config() {\n if (!options.components) return\n return {\n css: {\n modules: {\n // the SAME hash names as the distilled contract modules - a\n // component's own styles and its published module always agree\n generateScopedName: (name: string) => hashClassName(name),\n getJSON(cssFileName: string, json: Record<string, string>) {\n const comp = path\n .basename(cssFileName.split('?')[0])\n .replace(/\\.vue$/, '')\n .replace(/\\.module\\.css$/, '')\n componentMaps[comp] = { ...(componentMaps[comp] ?? {}), ...json }\n }\n }\n }\n }\n },\n configResolved(config: { root: string; build?: { outDir?: string } }) {\n root = config.root\n if (config.build?.outDir) outDir = config.build.outDir\n refreshEntries()\n },\n // the TS side: DEFAULT imports of the listed class modules -> hashed maps\n resolveId(source: string, importer: string | undefined) {\n // inject modules first - their names also end with .module.css\n if (INJECT_RE.test(source) && importer) {\n const file = locate(path.resolve(path.dirname(importer), source))\n if (!file || !entryDirs().some((dir) => file.startsWith(dir)))\n return null\n return file + INJECT_SUFFIX\n }\n if (!source.endsWith('.module.css') || !importer) return null\n const file = locate(path.resolve(path.dirname(importer), source))\n // only the listed entries - anything else stays with the default pipeline\n if (!file || !entryDirs().some((dir) => file.startsWith(dir))) return null\n return file + SUFFIX\n },\n load(id: string) {\n if (id.endsWith(INJECT_SUFFIX)) {\n // ids arrive in mixed shapes (absolute fs paths, root-relative\n // '/src/...') - locate before reading\n const file = locate(id.slice(0, -INJECT_SUFFIX.length))\n if (!file) return null\n const { css } = processInjectFile(file)\n return `export default ${JSON.stringify(css)}`\n }\n if (id.endsWith(`.module.css${SUFFIX}`)) return mapFor(id)\n if (INJECT_RE.test(id) && !existsSync(id)) {\n // a root-relative inject id that slipped past resolveId - map it to\n // the real file, same as the registry fallback below\n const file = locate(id)\n if (file) {\n const { css } = processInjectFile(file)\n return `export default ${JSON.stringify(css)}`\n }\n }\n if (id.endsWith('.module.css') && !existsSync(id)) {\n // a root-relative id ('/src/x.module.css') that slipped past resolveId\n // (cached/transformed import) - map it to the real file\n return mapFor(id)\n }\n return null\n },\n // after the bundler wrote (and cleaned) its outDir - distilling earlier\n // would be wiped by the bundler's own clean step. Skipped together with\n // the distillation when the plugin runs maps-only in a consumer\n writeBundle() {\n if (!options.components || options.distill === false) return\n const dir = path.resolve(root, outDir)\n mkdirSync(dir, { recursive: true })\n for (const [comp, map] of Object.entries(componentMaps)) {\n const names = Object.keys(map)\n if (!names.length) continue\n const content =\n names.map((n) => `@value ${n}: ${map[n]};`).join('\\n') + '\\n'\n const file = path.join(dir, `${comp}.module.css`)\n if (!existsSync(file) || readFileSync(file, 'utf8') !== content) {\n writeFileSync(file, content)\n }\n }\n },\n closeBundle() {\n if (options.distill === false) return\n const result = distillCssModules({ ...options, root })\n if (result.written.length) {\n console.log(`✓ ui0-css-modules-hash (${result.written.join(', ')})`)\n }\n },\n configureServer(server: {\n watcher: {\n add: (p: string) => void\n on: (ev: string, cb: (file: string) => void) => void\n }\n }) {\n if (options.watch === false || options.distill === false) return\n for (const { dir } of entries) server.watcher.add(dir)\n server.watcher.on('change', (file: string) => {\n if (!entryDirs().some((dir) => file.startsWith(dir))) return\n const result = distillCssModules({ ...options, root })\n if (result.written.length) {\n console.log(`✓ ui0-css-modules-hash (${result.written.join(', ')})`)\n }\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,SAAgB,cAAc,MAAsB;CAClD,MAAM,OAAO,UAAU,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC;CACvC,OAAO,GAAG,KAAK,MAAM,GAAG,CAAC,EAAE,GAAG;AAChC;AAEA,SAAgB,WAAW,KAAuB;CAChD,OAAO,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ui0/vite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "ui0 vite/rolldown plugins",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"vite:publish": "node ../../scripts/publish-packages.ts"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ui0/util": "^0.0.
|
|
29
|
+
"@ui0/util": "^0.0.8"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/node": "^22.0.0",
|