@g3nomaly/ui 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/README.md +7 -6
- package/dist/cli/adapter.d.ts +11 -2
- package/dist/cli/adapter.d.ts.map +1 -1
- package/dist/cli/adapter.js +14 -5
- package/dist/cli/adapter.js.map +1 -1
- package/dist/cli/commands/add.js +1 -1
- package/dist/cli/commands/add.js.map +1 -1
- package/dist/cli/commands/ls.js +1 -1
- package/dist/cli/commands/ls.js.map +1 -1
- package/dist/cli/commands/source.d.ts +2 -0
- package/dist/cli/commands/source.d.ts.map +1 -1
- package/dist/cli/commands/source.js +1 -1
- package/dist/cli/commands/source.js.map +1 -1
- package/dist/cli/commands/sourceInit.d.ts.map +1 -1
- package/dist/cli/commands/sourceInit.js +3 -2
- package/dist/cli/commands/sourceInit.js.map +1 -1
- package/dist/cli/commands/update.js +1 -1
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/index.js +2 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/localSources.d.ts +12 -0
- package/dist/cli/localSources.d.ts.map +1 -0
- package/dist/cli/localSources.js +49 -0
- package/dist/cli/localSources.js.map +1 -0
- package/dist/cli/npmDependencies.d.ts +1 -1
- package/dist/cli/npmDependencies.d.ts.map +1 -1
- package/dist/cli/npmDependencies.js +12 -6
- package/dist/cli/npmDependencies.js.map +1 -1
- package/dist/cli/themeTokens.d.ts +1 -1
- package/dist/cli/themeTokens.d.ts.map +1 -1
- package/dist/cli/themeTokens.js +23 -15
- package/dist/cli/themeTokens.js.map +1 -1
- package/dist/packages/dependencies.d.ts +6 -2
- package/dist/packages/dependencies.d.ts.map +1 -1
- package/dist/packages/dependencies.js +8 -2
- package/dist/packages/dependencies.js.map +1 -1
- package/dist/packages/install.d.ts +20 -0
- package/dist/packages/install.d.ts.map +1 -1
- package/dist/packages/install.js +40 -7
- package/dist/packages/install.js.map +1 -1
- package/dist/packages/localPack.d.ts +48 -0
- package/dist/packages/localPack.d.ts.map +1 -0
- package/dist/packages/localPack.js +72 -0
- package/dist/packages/localPack.js.map +1 -0
- package/dist/registry/componentsJson.d.ts +5 -2
- package/dist/registry/componentsJson.d.ts.map +1 -1
- package/dist/registry/componentsJson.js +21 -2
- package/dist/registry/componentsJson.js.map +1 -1
- package/dist/registry/packageImports.d.ts +23 -0
- package/dist/registry/packageImports.d.ts.map +1 -0
- package/dist/registry/packageImports.js +51 -0
- package/dist/registry/packageImports.js.map +1 -0
- package/dist/registry/readSource.js +1 -1
- package/dist/registry/readSource.js.map +1 -1
- package/dist/theme/cssVars.d.ts +18 -5
- package/dist/theme/cssVars.d.ts.map +1 -1
- package/dist/theme/cssVars.js +37 -22
- package/dist/theme/cssVars.js.map +1 -1
- package/package.json +2 -2
- package/template/build.ts +12 -5
- package/template/package.json +5 -1
- package/template/src/components/example/example.meta.ts +8 -0
package/dist/theme/cssVars.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const ROOT = { selector: ":root", find: /(^|\n)[ \t]*:root[ \t]*\{/ };
|
|
2
|
-
const DARK = { selector: ".dark", find: /(^|\n)[ \t]*\.dark[ \t]*\{/ };
|
|
3
|
-
const THEME = { selector: "@theme inline", find: /(^|\n)[ \t]*@theme(?:[ \t]+inline)?[ \t]*\{/ };
|
|
4
|
-
/**
|
|
5
|
-
const
|
|
1
|
+
const ROOT = { selector: ":root", find: /(^|\n)[ \t]*:root[ \t]*\{/g };
|
|
2
|
+
const DARK = { selector: ".dark", find: /(^|\n)[ \t]*\.dark[ \t]*\{/g };
|
|
3
|
+
const THEME = { selector: "@theme inline", find: /(^|\n)[ \t]*@theme(?:[ \t]+inline)?[ \t]*\{/g };
|
|
4
|
+
/** A value that is a colour: a colour function, a `var()` that may hold one, a hex colour or a colour keyword. */
|
|
5
|
+
const COLOUR_VALUE = /^(?:(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix|light-dark|var)\(|#[\da-f]{3,8}$|(?:transparent|currentcolor)$)/i;
|
|
6
6
|
/** A token name with its leading `--`, e.g. `--sidebar` for `sidebar`. */
|
|
7
7
|
function property(name) {
|
|
8
8
|
return name.startsWith("--") ? name : `--${name}`;
|
|
@@ -25,45 +25,60 @@ function closingBrace(css, open) {
|
|
|
25
25
|
return -1;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* @brief Adds the tokens
|
|
29
|
-
*
|
|
28
|
+
* @brief Adds the tokens no block of a kind defines, before the closing brace of the first block
|
|
29
|
+
* written as `selector` (so `@theme inline` before a plain `@theme`), else of the first block of the
|
|
30
|
+
* kind, else as a new block at the end. A token any block of the kind defines keeps its value.
|
|
30
31
|
*
|
|
31
32
|
* @param css - The stylesheet.
|
|
32
|
-
* @param block - The block to add to.
|
|
33
|
+
* @param block - The kind of block to add to.
|
|
33
34
|
* @param tokens - Tokens by name, with or without the leading `--`.
|
|
34
35
|
* @returns The stylesheet and the names of the tokens added.
|
|
35
36
|
*/
|
|
36
37
|
function addToBlock(css, block, tokens) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
const bodies = [...css.matchAll(block.find)].flatMap((match) => {
|
|
39
|
+
const open = match.index + match[0].length;
|
|
40
|
+
const end = closingBrace(css, open);
|
|
41
|
+
return end === -1 ? [] : [{ opening: match[0], open, end }];
|
|
42
|
+
});
|
|
43
|
+
const target = bodies.find((body) => body.opening.includes(block.selector)) ?? bodies[0];
|
|
44
|
+
const close = target?.end ?? -1;
|
|
45
|
+
const defined = new Set(bodies.flatMap(({ open, end }) => [...css.slice(open, end).matchAll(/(--[\w-]+)\s*:/g)].map((m) => m[1])));
|
|
42
46
|
const missing = Object.entries(tokens).map(([name, value]) => [property(name), value]).filter(([name]) => !defined.has(name));
|
|
43
47
|
if (missing.length === 0)
|
|
44
48
|
return { css, added: [] };
|
|
45
49
|
const lines = missing.map(([name, value]) => ` ${name}: ${value};\n`).join("");
|
|
46
|
-
const added = missing.map(([name]) => name);
|
|
50
|
+
const added = missing.map(([name, value]) => ({ block: block.selector, name, value }));
|
|
47
51
|
if (close === -1)
|
|
48
52
|
return { css: `${css.trimEnd()}\n\n${block.selector} {\n${lines}}\n`, added };
|
|
49
53
|
const before = css.slice(0, close);
|
|
50
54
|
return { css: `${before}${before.endsWith("\n") ? "" : "\n"}${lines}${css.slice(close)}`, added };
|
|
51
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* @brief The names of the `light` and `dark` tokens whose value is a colour, without the leading `--`.
|
|
58
|
+
* A token counts when its light or its dark value is one.
|
|
59
|
+
*
|
|
60
|
+
* @param vars - Tokens to look through.
|
|
61
|
+
* @returns Names such as `sidebar`, each once; `radius: 0.5rem` and `font-sans: Inter` are left out.
|
|
62
|
+
*/
|
|
63
|
+
function colourTokens(vars) {
|
|
64
|
+
const values = [...Object.entries(vars.light ?? {}), ...Object.entries(vars.dark ?? {})];
|
|
65
|
+
const names = values.filter(([, value]) => COLOUR_VALUE.test(value.trim())).map(([name]) => name.replace(/^--/, ""));
|
|
66
|
+
return [...new Set(names)];
|
|
67
|
+
}
|
|
52
68
|
/**
|
|
53
69
|
* @brief Adds the theme tokens a stylesheet lacks: `light` to `:root`, `dark` to `.dark`, `theme` to
|
|
54
|
-
* `@theme inline`. When the stylesheet has a `@theme` block (Tailwind v4), each
|
|
55
|
-
* its `--color-<name>: var(--<name>)` mapping there, the way shadcn adds them, so
|
|
56
|
-
* as `bg-sidebar` work. Tokens the stylesheet defines
|
|
70
|
+
* `@theme inline`. When the stylesheet has a `@theme` block (Tailwind v4), each token whose value is a
|
|
71
|
+
* colour also gets its `--color-<name>: var(--<name>)` mapping there, the way shadcn adds them, so
|
|
72
|
+
* Tailwind classes such as `bg-sidebar` work. Tokens the stylesheet defines, in any block of the same
|
|
73
|
+
* kind, keep their value: the app's theme wins.
|
|
57
74
|
*
|
|
58
75
|
* @param css - The stylesheet, e.g. the contents of `src/index.css`.
|
|
59
76
|
* @param vars - Tokens to add.
|
|
60
77
|
* @returns The stylesheet with the missing tokens added, and which were added.
|
|
61
78
|
*/
|
|
62
79
|
export function addCssVars(css, vars) {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
.filter((name) => !NOT_COLOURS.has(name));
|
|
66
|
-
const mappings = THEME.find.test(css) ? Object.fromEntries(colours.map((name) => [`color-${name}`, `var(--${name})`])) : {};
|
|
80
|
+
const hasTheme = [...css.matchAll(THEME.find)].length > 0;
|
|
81
|
+
const mappings = hasTheme ? Object.fromEntries(colourTokens(vars).map((name) => [`color-${name}`, `var(--${name})`])) : {};
|
|
67
82
|
let result = css;
|
|
68
83
|
const added = [];
|
|
69
84
|
for (const [block, tokens] of [[ROOT, vars.light], [DARK, vars.dark], [THEME, { ...mappings, ...vars.theme }]]) {
|
|
@@ -71,7 +86,7 @@ export function addCssVars(css, vars) {
|
|
|
71
86
|
continue;
|
|
72
87
|
const merged = addToBlock(result, block, tokens);
|
|
73
88
|
result = merged.css;
|
|
74
|
-
added.push(...merged.added
|
|
89
|
+
added.push(...merged.added);
|
|
75
90
|
}
|
|
76
91
|
return { css: result, added };
|
|
77
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cssVars.js","sourceRoot":"","sources":["../../src/theme/cssVars.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cssVars.js","sourceRoot":"","sources":["../../src/theme/cssVars.ts"],"names":[],"mappings":"AAeA,MAAM,IAAI,GAAc,EAAE,QAAQ,EAAE,OAAO,EAAU,IAAI,EAAE,4BAA4B,EAAE,CAAC;AAC1F,MAAM,IAAI,GAAc,EAAE,QAAQ,EAAE,OAAO,EAAU,IAAI,EAAE,6BAA6B,EAAE,CAAC;AAC3F,MAAM,KAAK,GAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,8CAA8C,EAAE,CAAC;AAE5G,kHAAkH;AAClH,MAAM,YAAY,GAAG,6HAA6H,CAAC;AA0BnJ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AAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAU;YAAE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IAChH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@g3nomaly/ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Installs React components from any registered source into a project, the way shadcn does.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@clack/prompts": "^1.7.0",
|
|
49
|
-
"@g3nomaly/core": "^0.3.
|
|
49
|
+
"@g3nomaly/core": "^0.3.5",
|
|
50
50
|
"chalk": "^6.0.0",
|
|
51
51
|
"commander": "^15.0.0",
|
|
52
52
|
"glob": "^13.0.6",
|
package/template/build.ts
CHANGED
|
@@ -6,11 +6,18 @@
|
|
|
6
6
|
// build, even under the same version. Raise the version in package.json for every release anyway:
|
|
7
7
|
// it is stamped on every component, and `update` shows it as `0.1.0 → 0.2.0`.
|
|
8
8
|
//
|
|
9
|
-
// How apps get the source
|
|
10
|
-
//
|
|
11
|
-
// -
|
|
12
|
-
//
|
|
13
|
-
//
|
|
9
|
+
// How apps get the source. Apps add it with `bun add`, not `-d`, when a component keeps files in the
|
|
10
|
+
// package, since the app then imports them at runtime:
|
|
11
|
+
// - npm: `bun publish`. Apps run `bun add <name>`, then `bunx @g3nomaly/ui source add npm:<name>`.
|
|
12
|
+
// - git: commit dist/, since the installer reads a git source as it is and never builds it. Apps
|
|
13
|
+
// install it as `bun add github:<owner>/<repo>#<tag>` and register it as an npm source.
|
|
14
|
+
// - a workspace: put this package and the app in one Bun workspace, add it as `"<name>": "workspace:*"`
|
|
15
|
+
// and register it as an npm source. The best way to work on a source next to an app.
|
|
16
|
+
// - a folder: apps run `bun add file:<path>` and register it as an npm source. When a component keeps
|
|
17
|
+
// files in the package, the installer swaps the link for a packed copy (`bun pm pack`, which runs
|
|
18
|
+
// `prepack` and so this build) on every `add` and `update`, because a link to this folder would load
|
|
19
|
+
// this folder's own node_modules, such as a second React. `source add <path>` reads the folder
|
|
20
|
+
// directly, but cannot serve files kept in the package.
|
|
14
21
|
import fs from "node:fs";
|
|
15
22
|
import path from "node:path";
|
|
16
23
|
import { COMPONENTS_DIR, COMPONENTS_JSON, writeComponentsJson } from "@g3nomaly/ui/registry";
|
package/template/package.json
CHANGED
|
@@ -32,6 +32,14 @@ export default {
|
|
|
32
32
|
// dist/components/example/exampleStore.ts. The build fails when no export reaches the file.
|
|
33
33
|
// Apps then need this package installed with `bun add`, and update the store with `bun install`.
|
|
34
34
|
// `add --include-unsafe` gives an app a copy anyway, which its components do not import.
|
|
35
|
+
//
|
|
36
|
+
// Such a file runs in the app, so every package it imports must be in `peerDependencies` of
|
|
37
|
+
// package.json, so it loads the app's copy and not a second one, such as a second React. List it in
|
|
38
|
+
// `devDependencies` too to build here. The build fails on an import that is not a peer.
|
|
39
|
+
//
|
|
40
|
+
// A component needs at least one file the app gets copied; the build fails otherwise. A helper that
|
|
41
|
+
// several stores share needs no meta file of its own: keep it in a component's folder, inside the
|
|
42
|
+
// `exports`, and import it by package path.
|
|
35
43
|
files: [
|
|
36
44
|
{ path: "example/Example.tsx", type: "component" },
|
|
37
45
|
{ path: "example/Example.css", type: "style" },
|