@c9up/aurora 0.1.13 → 0.1.15
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 +1 -1
- package/dist/AuroraManager.d.ts +19 -1
- package/dist/AuroraManager.js +31 -3
- package/dist/AuroraProvider.js +4 -2
- package/dist/cn.d.ts +27 -0
- package/dist/cn.js +908 -0
- package/dist/hydrate.js +130 -10
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/render.js +11 -0
- package/dist/server/renderPage.d.ts +8 -0
- package/dist/server/renderPage.js +8 -1
- package/dist/ssr.js +14 -56
- package/dist/url.d.ts +33 -0
- package/dist/url.js +68 -0
- package/package.json +6 -2
- package/src/AuroraManager.ts +41 -3
- package/src/AuroraProvider.ts +10 -2
- package/src/cn.ts +979 -0
- package/src/hydrate.ts +184 -10
- package/src/index.ts +2 -0
- package/src/render.ts +13 -0
- package/src/server/renderPage.ts +16 -1
- package/src/ssr.ts +14 -53
- package/src/url.ts +91 -0
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ providers: [
|
|
|
24
24
|
|
|
25
25
|
## Entry points
|
|
26
26
|
|
|
27
|
-
- `@c9up/aurora` — main API: reactive primitives (`signal`/`effect`/`html`/`component`/`hydrate`) plus the client toolkit — `WebStorage`/`persistedSignal`, reactive browser signals (`prefersDark`/`online`/`windowSize`/…), SPA navigation (`navigate`/`queryParam`), `cookie`/`clipboard`/`share`, the `HttpClient` fetch wrapper, `command()` (async action + reactive loading/data/error),
|
|
27
|
+
- `@c9up/aurora` — main API: reactive primitives (`signal`/`effect`/`html`/`component`/`hydrate`) plus the client toolkit — `WebStorage`/`persistedSignal`, reactive browser signals (`prefersDark`/`online`/`windowSize`/…), SPA navigation (`navigate`/`queryParam`), `cookie`/`clipboard`/`share`, the `HttpClient` fetch wrapper, `createRpcClient()` (JSON-RPC 2.0), `command()` (async action + reactive loading/data/error), `form()` (reactive form controller; optional rune validation + rosetta i18n), `urlFor()` (isomorphic named-route URLs, paired with Ream's `router.namedManifest()`), and `cn()` (zero-dependency Tailwind v4 class merge — `clsx` + `tailwind-merge` reimplemented)
|
|
28
28
|
- `@c9up/aurora/provider` — Ream IoC provider
|
|
29
29
|
- `@c9up/aurora/services/main` — container service accessor
|
|
30
30
|
- `@c9up/aurora/relay` — realtime adapter
|
package/dist/AuroraManager.d.ts
CHANGED
|
@@ -22,13 +22,31 @@ export interface AuroraManagerConfig {
|
|
|
22
22
|
* Override only if you want to serve a custom build.
|
|
23
23
|
*/
|
|
24
24
|
auroraDistRoot?: string;
|
|
25
|
+
/**
|
|
26
|
+
* URL prefix the asset routes mount under. The aurora runtime is served
|
|
27
|
+
* from `<assetsPrefix>/aurora/*` and the app's pages from
|
|
28
|
+
* `<assetsPrefix>/pages/*`, and the SSR importmap + page URLs derive from
|
|
29
|
+
* it. Default `/_assets` (the leading underscore namespaces framework
|
|
30
|
+
* assets away from app routes, Next.js `/_next` style). Set e.g. `/assets`
|
|
31
|
+
* for an underscore-free scheme. An explicit `pages.urlPrefix` still wins.
|
|
32
|
+
*/
|
|
33
|
+
assetsPrefix?: string;
|
|
25
34
|
}
|
|
26
35
|
export declare class AuroraManager {
|
|
27
36
|
readonly pages: Pages;
|
|
28
37
|
readonly auroraDistRoot: string;
|
|
38
|
+
/** Resolved asset prefix (default `/_assets`). */
|
|
39
|
+
readonly assetsPrefix: string;
|
|
40
|
+
/** Mount path for the aurora runtime — `<assetsPrefix>/aurora`. */
|
|
41
|
+
readonly auroraAssetPath: string;
|
|
42
|
+
/** Mount path for the app's pages — `<assetsPrefix>/pages`. */
|
|
43
|
+
readonly pageAssetPath: string;
|
|
29
44
|
constructor(config: AuroraManagerConfig);
|
|
30
45
|
/**
|
|
31
|
-
* SSR + hydrate + ship the document.
|
|
46
|
+
* SSR + hydrate + ship the document. The importmap default points
|
|
47
|
+
* `@c9up/aurora` at this manager's `assetsPrefix`; a caller's
|
|
48
|
+
* `options.importmap` still overrides (e.g. to remap to an app-curated
|
|
49
|
+
* browser entry).
|
|
32
50
|
*/
|
|
33
51
|
render(ctx: RenderHttpContext, name: string, props: unknown, options?: RenderPageOptions): Promise<void>;
|
|
34
52
|
/**
|
package/dist/AuroraManager.js
CHANGED
|
@@ -17,18 +17,46 @@ import { Pages } from "./Pages.js";
|
|
|
17
17
|
import { renderPage, } from "./server/renderPage.js";
|
|
18
18
|
import { serveAssets } from "./server/serveAssets.js";
|
|
19
19
|
const DEFAULT_AURORA_DIST = resolvePath(dirname(fileURLToPath(import.meta.url)), "../dist");
|
|
20
|
+
/** Normalize an asset prefix: ensure a leading slash, drop trailing slashes. */
|
|
21
|
+
function normalizePrefix(prefix) {
|
|
22
|
+
const withLead = prefix.startsWith("/") ? prefix : `/${prefix}`;
|
|
23
|
+
return withLead.replace(/\/+$/, "") || "/";
|
|
24
|
+
}
|
|
20
25
|
export class AuroraManager {
|
|
21
26
|
pages;
|
|
22
27
|
auroraDistRoot;
|
|
28
|
+
/** Resolved asset prefix (default `/_assets`). */
|
|
29
|
+
assetsPrefix;
|
|
30
|
+
/** Mount path for the aurora runtime — `<assetsPrefix>/aurora`. */
|
|
31
|
+
auroraAssetPath;
|
|
32
|
+
/** Mount path for the app's pages — `<assetsPrefix>/pages`. */
|
|
33
|
+
pageAssetPath;
|
|
23
34
|
constructor(config) {
|
|
24
|
-
this.
|
|
35
|
+
this.assetsPrefix = normalizePrefix(config.assetsPrefix ?? "/_assets");
|
|
36
|
+
this.auroraAssetPath = `${this.assetsPrefix}/aurora`;
|
|
37
|
+
this.pageAssetPath = `${this.assetsPrefix}/pages`;
|
|
38
|
+
// Pages serve their compiled JS from the same prefix unless the app
|
|
39
|
+
// pins an explicit urlPrefix.
|
|
40
|
+
this.pages = new Pages({
|
|
41
|
+
...config.pages,
|
|
42
|
+
urlPrefix: config.pages.urlPrefix ?? this.pageAssetPath,
|
|
43
|
+
});
|
|
25
44
|
this.auroraDistRoot = config.auroraDistRoot ?? DEFAULT_AURORA_DIST;
|
|
26
45
|
}
|
|
27
46
|
/**
|
|
28
|
-
* SSR + hydrate + ship the document.
|
|
47
|
+
* SSR + hydrate + ship the document. The importmap default points
|
|
48
|
+
* `@c9up/aurora` at this manager's `assetsPrefix`; a caller's
|
|
49
|
+
* `options.importmap` still overrides (e.g. to remap to an app-curated
|
|
50
|
+
* browser entry).
|
|
29
51
|
*/
|
|
30
52
|
render(ctx, name, props, options) {
|
|
31
|
-
return renderPage(ctx, this.pages, name, props,
|
|
53
|
+
return renderPage(ctx, this.pages, name, props, {
|
|
54
|
+
...options,
|
|
55
|
+
importmap: {
|
|
56
|
+
"@c9up/aurora": `${this.auroraAssetPath}/index.js`,
|
|
57
|
+
...options?.importmap,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
32
60
|
}
|
|
33
61
|
/**
|
|
34
62
|
* Handler for aurora's pre-built ESM runtime. Mount on
|
package/dist/AuroraProvider.js
CHANGED
|
@@ -63,8 +63,10 @@ export default class AuroraProvider {
|
|
|
63
63
|
return;
|
|
64
64
|
const router = this.app.container.resolve("router");
|
|
65
65
|
const manager = this.app.container.resolve(AuroraManager);
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
// Mount paths derive from the configured `assetsPrefix` (default
|
|
67
|
+
// `/_assets`) — set `config.aurora.assetsPrefix` to change the scheme.
|
|
68
|
+
router.get(`${manager.auroraAssetPath}/*`, adaptHandler(manager.auroraAssetsHandler()));
|
|
69
|
+
router.get(`${manager.pageAssetPath}/*`, adaptHandler(manager.pageAssetsHandler()));
|
|
68
70
|
}
|
|
69
71
|
async ready() { }
|
|
70
72
|
async shutdown() { }
|
package/dist/cn.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cn` — class-name composition with Tailwind conflict resolution, reimplemented
|
|
3
|
+
* from scratch with ZERO dependencies (no clsx, no tailwind-merge).
|
|
4
|
+
*
|
|
5
|
+
* cn('px-2 py-1', isActive && 'bg-indigo-600', props.class)
|
|
6
|
+
* cn('px-2', 'px-4') // → 'px-4' (later wins within a group)
|
|
7
|
+
* cn('mr-4', 'mr-8') // → 'mr-8' (dedup is the whole point)
|
|
8
|
+
* cn('text-red-500', 'text-sm') // → 'text-red-500 text-sm' (different groups)
|
|
9
|
+
* cn('hover:p-2', 'hover:p-4', 'p-1')// → 'p-1 hover:p-4' (variant-scoped)
|
|
10
|
+
*
|
|
11
|
+
* Two parts:
|
|
12
|
+
* 1. {@link clsx} — flatten strings / numbers / arrays / objects into a class
|
|
13
|
+
* string, dropping falsy values (full clsx semantics).
|
|
14
|
+
* 2. {@link twMerge} — within the SAME variant stack (`hover:`, `md:`, `!`, …),
|
|
15
|
+
* keep only the LAST class of each conflicting Tailwind group; unknown
|
|
16
|
+
* classes never conflict and are always kept, in source order.
|
|
17
|
+
*
|
|
18
|
+
* Targets the standard Tailwind v4 utility set. Node-free — part of aurora's
|
|
19
|
+
* client runtime.
|
|
20
|
+
*/
|
|
21
|
+
export type ClassValue = ClassValue[] | Record<string, unknown> | string | number | bigint | null | boolean | undefined;
|
|
22
|
+
/** clsx-equivalent: join truthy class values (strings, numbers, arrays, objects). */
|
|
23
|
+
export declare function clsx(...inputs: ClassValue[]): string;
|
|
24
|
+
/** Resolve Tailwind class conflicts: within a variant scope, the last class of each group wins. */
|
|
25
|
+
export declare function twMerge(classList: string): string;
|
|
26
|
+
/** Compose class values (clsx) then resolve Tailwind conflicts (twMerge). */
|
|
27
|
+
export declare function cn(...inputs: ClassValue[]): string;
|