@c9up/nebula 0.2.0 → 0.2.1

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.
@@ -29,6 +29,12 @@ interface Codemods {
29
29
  }): Promise<void>;
30
30
  /** Appends to `reamrc.commands` — the channel for package-shipped commands. */
31
31
  registerCommand(importPath: string): Promise<void>;
32
+ makeUsingStub(stubsRoot: string, stubPath: string, state?: Record<string, string | number | boolean>, options?: {
33
+ force?: boolean;
34
+ }): Promise<{
35
+ path: string;
36
+ contents: string;
37
+ }>;
32
38
  }
33
39
  /** Flags forwarded from `ream add` / `ream configure`, as the CLI encodes them. */
34
40
  type Flags = Record<string, string[] | undefined>;
package/dist/configure.js CHANGED
@@ -19,27 +19,7 @@ import { readFile } from "node:fs/promises";
19
19
  import { resolve } from "node:path";
20
20
  import { adapterFor, isAdapterName } from "./adapters/index.js";
21
21
  import { resolveConfig } from "./config.js";
22
- function configFile(adapter) {
23
- return `import { defineConfig } from '@c9up/nebula'
24
-
25
- /**
26
- * nebula — component registry and style adapter.
27
- *
28
- * Changing \`adapter\` and re-running \`ream configure @c9up/nebula\` swaps the
29
- * CSS engine. The components themselves are untouched: all three adapters
30
- * consume the same class names.
31
- */
32
- export default defineConfig({
33
- adapter: '${adapter}',
34
- paths: {
35
- // Where \`ream nebula:add\` copies components. The atomic layers live under it.
36
- components: 'resources/pages',
37
- css: 'resources/css/app.css',
38
- output: 'public/app.css',
39
- },
40
- })
41
- `;
42
- }
22
+ import { stubsRoot } from "./stubs.js";
43
23
  /**
44
24
  * Read the adapter from the forwarded flags.
45
25
  *
@@ -60,7 +40,9 @@ export async function configure(codemods, flags = {}) {
60
40
  const name = adapterFrom(flags);
61
41
  const adapter = adapterFor(name);
62
42
  const config = resolveConfig({ adapter: name });
63
- await codemods.writeFile("config/nebula.ts", configFile(name));
43
+ await codemods.makeUsingStub(stubsRoot, "config/nebula.stub", {
44
+ adapter: name,
45
+ });
64
46
  // `reamrc.commands` is the channel Ream provides for commands a package
65
47
  // ships, which directory discovery cannot see. `ream` forwards any
66
48
  // unrecognised name to the app's console kernel, so these exist without a
package/dist/lib/id.d.ts CHANGED
@@ -1,31 +1,15 @@
1
1
  /**
2
- * Stable element ids.
3
- *
4
- * Radix leans on React's `useId` to wire ARIA relationships — a trigger's
5
- * `aria-controls` has to name the id its content actually carries. Aurora has
6
- * no equivalent, and nebula needs one for two reasons: the ARIA wiring above,
7
- * and element lookup. Aurora templates have no `ref` directive, so a component
8
- * that must measure or focus a node finds it by id inside `onMount()`.
9
- *
10
- * The counter is monotonic per module instance, so the sequence depends only
11
- * on the order components are constructed in. That order is identical on the
12
- * server and in the browser for the same tree, which is what makes the ids
13
- * survive hydration — the same property React's `useId` relies on.
14
- *
15
- * `resetIds()` exists for the server: a long-lived process renders many
16
- * requests, and without a reset the counter climbs forever and every response
17
- * ships different markup, defeating any HTML cache. Call it once per render
18
- * pass, before the tree is built.
19
- */
20
- /** Mint an id unique within this render pass. */
21
- export declare function uid(prefix?: string): string;
22
- /** Restart the sequence. Call once per SSR render, before building the tree. */
23
- export declare function resetIds(): void;
24
- /**
25
- * Look an element up by the id a component minted for it.
26
- *
27
- * Returns `null` off the DOM (SSR) or before mount rather than throwing, so
28
- * callers can run the same code in both environments. Every consumer inside
29
- * nebula is in `onMount`, where the node is live.
2
+ * Stable element ids — aurora's counter, re-exported.
3
+ *
4
+ * It was nebula's own, and that was the bug: aurora resets its sequence at the
5
+ * start of each render pass (`renderPage` server-side, `hydrate` in the
6
+ * browser), and a second counter living here saw none of those resets. A
7
+ * long-lived server therefore shipped `tooltip-trigger-14` while the browser,
8
+ * hydrating from zero, minted `tooltip-trigger-1` and looked it up — so
9
+ * `byId` answered `null`, `floatingSurface` had no anchor, and the tooltip
10
+ * never opened although its mount hook had run and its trigger was wired.
11
+ *
12
+ * Every id nebula mints has to come from the same counter aurora resets; the
13
+ * names are kept so nothing importing them has to change.
30
14
  */
31
- export declare function byId(id: string): HTMLElement | null;
15
+ export { byId, resetIds, uid } from "@c9up/aurora";
package/dist/lib/id.js CHANGED
@@ -1,41 +1,15 @@
1
1
  /**
2
- * Stable element ids.
3
- *
4
- * Radix leans on React's `useId` to wire ARIA relationships — a trigger's
5
- * `aria-controls` has to name the id its content actually carries. Aurora has
6
- * no equivalent, and nebula needs one for two reasons: the ARIA wiring above,
7
- * and element lookup. Aurora templates have no `ref` directive, so a component
8
- * that must measure or focus a node finds it by id inside `onMount()`.
9
- *
10
- * The counter is monotonic per module instance, so the sequence depends only
11
- * on the order components are constructed in. That order is identical on the
12
- * server and in the browser for the same tree, which is what makes the ids
13
- * survive hydration — the same property React's `useId` relies on.
14
- *
15
- * `resetIds()` exists for the server: a long-lived process renders many
16
- * requests, and without a reset the counter climbs forever and every response
17
- * ships different markup, defeating any HTML cache. Call it once per render
18
- * pass, before the tree is built.
19
- */
20
- let counter = 0;
21
- /** Mint an id unique within this render pass. */
22
- export function uid(prefix = "nebula") {
23
- counter += 1;
24
- return `${prefix}-${counter}`;
25
- }
26
- /** Restart the sequence. Call once per SSR render, before building the tree. */
27
- export function resetIds() {
28
- counter = 0;
29
- }
30
- /**
31
- * Look an element up by the id a component minted for it.
32
- *
33
- * Returns `null` off the DOM (SSR) or before mount rather than throwing, so
34
- * callers can run the same code in both environments. Every consumer inside
35
- * nebula is in `onMount`, where the node is live.
2
+ * Stable element ids — aurora's counter, re-exported.
3
+ *
4
+ * It was nebula's own, and that was the bug: aurora resets its sequence at the
5
+ * start of each render pass (`renderPage` server-side, `hydrate` in the
6
+ * browser), and a second counter living here saw none of those resets. A
7
+ * long-lived server therefore shipped `tooltip-trigger-14` while the browser,
8
+ * hydrating from zero, minted `tooltip-trigger-1` and looked it up — so
9
+ * `byId` answered `null`, `floatingSurface` had no anchor, and the tooltip
10
+ * never opened although its mount hook had run and its trigger was wired.
11
+ *
12
+ * Every id nebula mints has to come from the same counter aurora resets; the
13
+ * names are kept so nothing importing them has to change.
36
14
  */
37
- export function byId(id) {
38
- if (typeof document === "undefined")
39
- return null;
40
- return document.getElementById(id);
41
- }
15
+ export { byId, resetIds, uid } from "@c9up/aurora";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Where this package's stubs live.
3
+ *
4
+ * Its own module, as upstream keeps it: a stub root is a path a package
5
+ * publishes, and a caller importing it should not have to import the
6
+ * configure hook to get it.
7
+ *
8
+ * `import.meta.dirname` rather than a URL — upstream reads it straight off
9
+ * `import.meta`, and deriving it from `import.meta.url` breaks wherever that
10
+ * is not a `file://` URL, which is what a test runner serving modules over
11
+ * HTTP hands you.
12
+ */
13
+ export declare const stubsRoot: string;
package/dist/stubs.js ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Where this package's stubs live.
3
+ *
4
+ * Its own module, as upstream keeps it: a stub root is a path a package
5
+ * publishes, and a caller importing it should not have to import the
6
+ * configure hook to get it.
7
+ *
8
+ * `import.meta.dirname` rather than a URL — upstream reads it straight off
9
+ * `import.meta`, and deriving it from `import.meta.url` breaks wherever that
10
+ * is not a `file://` URL, which is what a test runner serving modules over
11
+ * HTTP hands you.
12
+ */
13
+ import { join } from "node:path";
14
+ export const stubsRoot = join(import.meta.dirname, "..", "stubs");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c9up/nebula",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Nebula — shadcn/ui ported to Aurora, organised as atomic design. Zero-dependency headless primitives, cva reimplemented, copy-the-source registry.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -61,7 +61,7 @@
61
61
  }
62
62
  },
63
63
  "peerDependencies": {
64
- "@c9up/aurora": "^0.1.45",
64
+ "@c9up/aurora": "^0.1.47",
65
65
  "tw-animate-css": "^1.4.0"
66
66
  },
67
67
  "peerDependenciesMeta": {
@@ -71,7 +71,7 @@
71
71
  },
72
72
  "devDependencies": {
73
73
  "@biomejs/biome": "^2.5.12",
74
- "@c9up/aurora": "^0.1.45",
74
+ "@c9up/aurora": "^0.1.47",
75
75
  "@tailwindcss/cli": "^4.3.3",
76
76
  "@types/node": "^22.20.1",
77
77
  "@vitest/coverage-v8": "4.1.11",
@@ -85,6 +85,7 @@
85
85
  "LICENSE",
86
86
  "README.md",
87
87
  "dist",
88
+ "stubs",
88
89
  "nebula.css",
89
90
  "registry.json",
90
91
  "src",
package/src/configure.ts CHANGED
@@ -21,6 +21,7 @@ import { resolve } from "node:path";
21
21
  import { adapterFor, isAdapterName } from "./adapters/index.js";
22
22
  import type { GeneratedFile } from "./adapters/types.js";
23
23
  import { type AdapterName, resolveConfig } from "./config.js";
24
+ import { stubsRoot } from "./stubs.js";
24
25
 
25
26
  /**
26
27
  * The subset of the CLI's codemods this hook uses.
@@ -38,33 +39,17 @@ interface Codemods {
38
39
  ): Promise<void>;
39
40
  /** Appends to `reamrc.commands` — the channel for package-shipped commands. */
40
41
  registerCommand(importPath: string): Promise<void>;
42
+ makeUsingStub(
43
+ stubsRoot: string,
44
+ stubPath: string,
45
+ state?: Record<string, string | number | boolean>,
46
+ options?: { force?: boolean },
47
+ ): Promise<{ path: string; contents: string }>;
41
48
  }
42
49
 
43
50
  /** Flags forwarded from `ream add` / `ream configure`, as the CLI encodes them. */
44
51
  type Flags = Record<string, string[] | undefined>;
45
52
 
46
- function configFile(adapter: AdapterName): string {
47
- return `import { defineConfig } from '@c9up/nebula'
48
-
49
- /**
50
- * nebula — component registry and style adapter.
51
- *
52
- * Changing \`adapter\` and re-running \`ream configure @c9up/nebula\` swaps the
53
- * CSS engine. The components themselves are untouched: all three adapters
54
- * consume the same class names.
55
- */
56
- export default defineConfig({
57
- adapter: '${adapter}',
58
- paths: {
59
- // Where \`ream nebula:add\` copies components. The atomic layers live under it.
60
- components: 'resources/pages',
61
- css: 'resources/css/app.css',
62
- output: 'public/app.css',
63
- },
64
- })
65
- `;
66
- }
67
-
68
53
  /**
69
54
  * Read the adapter from the forwarded flags.
70
55
  *
@@ -91,7 +76,9 @@ export async function configure(
91
76
  const adapter = adapterFor(name);
92
77
  const config = resolveConfig({ adapter: name });
93
78
 
94
- await codemods.writeFile("config/nebula.ts", configFile(name));
79
+ await codemods.makeUsingStub(stubsRoot, "config/nebula.stub", {
80
+ adapter: name,
81
+ });
95
82
 
96
83
  // `reamrc.commands` is the channel Ream provides for commands a package
97
84
  // ships, which directory discovery cannot see. `ream` forwards any
package/src/lib/id.ts CHANGED
@@ -1,44 +1,16 @@
1
1
  /**
2
- * Stable element ids.
2
+ * Stable element ids — aurora's counter, re-exported.
3
3
  *
4
- * Radix leans on React's `useId` to wire ARIA relationships — a trigger's
5
- * `aria-controls` has to name the id its content actually carries. Aurora has
6
- * no equivalent, and nebula needs one for two reasons: the ARIA wiring above,
7
- * and element lookup. Aurora templates have no `ref` directive, so a component
8
- * that must measure or focus a node finds it by id inside `onMount()`.
4
+ * It was nebula's own, and that was the bug: aurora resets its sequence at the
5
+ * start of each render pass (`renderPage` server-side, `hydrate` in the
6
+ * browser), and a second counter living here saw none of those resets. A
7
+ * long-lived server therefore shipped `tooltip-trigger-14` while the browser,
8
+ * hydrating from zero, minted `tooltip-trigger-1` and looked it up — so
9
+ * `byId` answered `null`, `floatingSurface` had no anchor, and the tooltip
10
+ * never opened although its mount hook had run and its trigger was wired.
9
11
  *
10
- * The counter is monotonic per module instance, so the sequence depends only
11
- * on the order components are constructed in. That order is identical on the
12
- * server and in the browser for the same tree, which is what makes the ids
13
- * survive hydration — the same property React's `useId` relies on.
14
- *
15
- * `resetIds()` exists for the server: a long-lived process renders many
16
- * requests, and without a reset the counter climbs forever and every response
17
- * ships different markup, defeating any HTML cache. Call it once per render
18
- * pass, before the tree is built.
12
+ * Every id nebula mints has to come from the same counter aurora resets; the
13
+ * names are kept so nothing importing them has to change.
19
14
  */
20
15
 
21
- let counter = 0;
22
-
23
- /** Mint an id unique within this render pass. */
24
- export function uid(prefix = "nebula"): string {
25
- counter += 1;
26
- return `${prefix}-${counter}`;
27
- }
28
-
29
- /** Restart the sequence. Call once per SSR render, before building the tree. */
30
- export function resetIds(): void {
31
- counter = 0;
32
- }
33
-
34
- /**
35
- * Look an element up by the id a component minted for it.
36
- *
37
- * Returns `null` off the DOM (SSR) or before mount rather than throwing, so
38
- * callers can run the same code in both environments. Every consumer inside
39
- * nebula is in `onMount`, where the node is live.
40
- */
41
- export function byId(id: string): HTMLElement | null {
42
- if (typeof document === "undefined") return null;
43
- return document.getElementById(id);
44
- }
16
+ export { byId, resetIds, uid } from "@c9up/aurora";
package/src/stubs.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Where this package's stubs live.
3
+ *
4
+ * Its own module, as upstream keeps it: a stub root is a path a package
5
+ * publishes, and a caller importing it should not have to import the
6
+ * configure hook to get it.
7
+ *
8
+ * `import.meta.dirname` rather than a URL — upstream reads it straight off
9
+ * `import.meta`, and deriving it from `import.meta.url` breaks wherever that
10
+ * is not a `file://` URL, which is what a test runner serving modules over
11
+ * HTTP hands you.
12
+ */
13
+
14
+ import { join } from "node:path";
15
+
16
+ export const stubsRoot = join(import.meta.dirname, "..", "stubs");
@@ -0,0 +1,21 @@
1
+ ---
2
+ to: config/nebula.ts
3
+ ---
4
+ import { defineConfig } from '@c9up/nebula'
5
+
6
+ /**
7
+ * nebula — component registry and style adapter.
8
+ *
9
+ * Changing `adapter` and re-running `ream configure @c9up/nebula` swaps the
10
+ * CSS engine. The components themselves are untouched: all three adapters
11
+ * consume the same class names.
12
+ */
13
+ export default defineConfig({
14
+ adapter: '{{ adapter }}',
15
+ paths: {
16
+ // Where `ream nebula:add` copies components. The atomic layers live under it.
17
+ components: 'resources/pages',
18
+ css: 'resources/css/app.css',
19
+ output: 'public/app.css',
20
+ },
21
+ })