@uibot/registry 0.0.0-stage → 0.2.0
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/block-source.d.ts +97 -0
- package/dist/doctor.d.ts +35 -0
- package/dist/emit.d.ts +91 -0
- package/dist/http.d.ts +16 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +15 -0
- package/dist/resource-aliases.d.ts +2 -0
- package/dist/resource-index.d.ts +48 -0
- package/dist/resource-query.d.ts +28 -0
- package/dist/resource-receipt.d.ts +83 -0
- package/dist/shadcn.d.ts +195 -0
- package/dist/template-source.d.ts +39 -0
- package/package.json +35 -4
- package/README.md +0 -3
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ArtifactFile, CatalogEntry, UIBotRegistryChannel } from "@uibot/contracts";
|
|
2
|
+
/**
|
|
3
|
+
* Shared block extraction contract.
|
|
4
|
+
*
|
|
5
|
+
* `BlockSource` is the single neutral upstream consumed by both registry
|
|
6
|
+
* emitters:
|
|
7
|
+
* - the shadcn-style emitter transforms `sourceCode` (raw `.tsx`) into a
|
|
8
|
+
* shadcn registry item; and
|
|
9
|
+
* - the uibot-native emitter packages `files` into a `ComponentArtifact`.
|
|
10
|
+
*
|
|
11
|
+
* Because both emitters depend on this shape, the field set is **frozen**:
|
|
12
|
+
* extend it additively (new optional fields only) — never rename or remove
|
|
13
|
+
* existing fields without coordinating both emitters.
|
|
14
|
+
*/
|
|
15
|
+
export interface BlockSource {
|
|
16
|
+
/** Block name, e.g. `"Button"` or `"Form.Input"`. */
|
|
17
|
+
name: string;
|
|
18
|
+
/** Catalog category of the block (mirrors `catalogEntry.category`). */
|
|
19
|
+
category: string;
|
|
20
|
+
/** Short human description (mirrors `catalogEntry.description`). */
|
|
21
|
+
description?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Raw source code of the block's `.tsx` file, kept verbatim.
|
|
24
|
+
*
|
|
25
|
+
* Consumed by the shadcn emitter, which rewrites imports / strips the
|
|
26
|
+
* UIBot renderer shim during transform. Import rewriting is intentionally
|
|
27
|
+
* **not** performed here.
|
|
28
|
+
*/
|
|
29
|
+
sourceCode: string;
|
|
30
|
+
/**
|
|
31
|
+
* Normalised file array for the uibot-native `ComponentArtifact`.
|
|
32
|
+
*
|
|
33
|
+
* Consumed by the uibot-native emitter and `installArtifactToWorkspace`.
|
|
34
|
+
*/
|
|
35
|
+
files: ArtifactFile[];
|
|
36
|
+
/** Full catalog metadata for the block. */
|
|
37
|
+
catalogEntry: CatalogEntry;
|
|
38
|
+
/** External npm dependencies required by the block's source. */
|
|
39
|
+
dependencies?: string[];
|
|
40
|
+
/**
|
|
41
|
+
* Same-registry dependencies (e.g. `utils/cn`, the renderer shim, or another
|
|
42
|
+
* block in the same source set).
|
|
43
|
+
*/
|
|
44
|
+
registryDependencies?: string[];
|
|
45
|
+
/** Distribution channel for the shadcn registry (ADR 0012). Defaults to `public`. */
|
|
46
|
+
channel?: UIBotRegistryChannel;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Options for {@link collectBlockSources}.
|
|
50
|
+
*
|
|
51
|
+
* `blockFileMap` maps each block name to the source file (relative to
|
|
52
|
+
* `sourceDir`) that defines it. When several blocks share a single `.tsx`
|
|
53
|
+
* (the common case for the shadcn block set), their entries point at the same
|
|
54
|
+
* file and the source code is read once and shared.
|
|
55
|
+
*/
|
|
56
|
+
export interface CollectBlockSourcesOptions {
|
|
57
|
+
/** Absolute root directory the file map paths are resolved against. */
|
|
58
|
+
sourceDir: string;
|
|
59
|
+
/** Block name → source file path (relative to `sourceDir`). */
|
|
60
|
+
blockFileMap: Record<string, string>;
|
|
61
|
+
/** Block name → full catalog metadata. */
|
|
62
|
+
catalog: Record<string, CatalogEntry>;
|
|
63
|
+
/**
|
|
64
|
+
* Optional file reader override (defaults to a synchronous UTF-8 read).
|
|
65
|
+
* Useful for tests that inject in-memory fixtures without touching disk.
|
|
66
|
+
*/
|
|
67
|
+
readFile?: (absolutePath: string) => string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Read every block's `.tsx` source plus its catalog entry and assemble the
|
|
71
|
+
* neutral {@link BlockSource} array shared by both emitters.
|
|
72
|
+
*
|
|
73
|
+
* The function is pure aside from synchronous file reads (overridable via
|
|
74
|
+
* `readFile`). Blocks that share a source file have their content read once
|
|
75
|
+
* and reused. Source code is preserved verbatim — import rewriting is left to
|
|
76
|
+
* the shadcn transform downstream.
|
|
77
|
+
*/
|
|
78
|
+
export declare function collectBlockSources(opts: CollectBlockSourcesOptions): BlockSource[];
|
|
79
|
+
/**
|
|
80
|
+
* Collect and concatenate the {@link BlockSource} arrays of *several* block
|
|
81
|
+
* sets into one union, eliminating distribution drift.
|
|
82
|
+
*
|
|
83
|
+
* Each distribution path (the `scripts/build-registry.ts` build, the
|
|
84
|
+
* `uibot publish` CLI command, and the control-plane `/api/registry` endpoint)
|
|
85
|
+
* must expose the **same** block set — the shadcn base set *and* the studio set
|
|
86
|
+
* that backs the example templates. Hand-rolling the `[...shadcn, ...studio]`
|
|
87
|
+
* concat at each call site is exactly how those paths drifted apart (publish +
|
|
88
|
+
* control-plane shipped 0 studio blocks). Routing all three through this single
|
|
89
|
+
* helper makes the union the one source of truth.
|
|
90
|
+
*
|
|
91
|
+
* `@uibot/registry` must stay below `@uibot/blocks-*` in the dependency graph,
|
|
92
|
+
* so the helper never imports the block packages itself: the caller passes each
|
|
93
|
+
* set's own `{ sourceDir, blockFileMap, catalog }` descriptor (sourced from that
|
|
94
|
+
* package's `registry-source` module). Item names never collide across sets
|
|
95
|
+
* (distinct file leaves), so a plain concat is sufficient.
|
|
96
|
+
*/
|
|
97
|
+
export declare function collectAllBlockSources(blockSets: CollectBlockSourcesOptions[]): BlockSource[];
|
package/dist/doctor.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure lockfile-vs-manifest drift check for `uibot doctor` (v2.28 SC-1).
|
|
3
|
+
* CLI only presents results / sets exit codes.
|
|
4
|
+
*/
|
|
5
|
+
import type { ArtifactLock, ArtifactLockfile, ArtifactRegistryManifest } from "@uibot/contracts";
|
|
6
|
+
export type DoctorDriftKind = "version-mismatch" | "missing-in-manifest" | "missing-in-lock" | "extra-in-lock";
|
|
7
|
+
export interface DoctorDrift {
|
|
8
|
+
name: string;
|
|
9
|
+
kind: DoctorDriftKind;
|
|
10
|
+
lockVersion?: string;
|
|
11
|
+
manifestVersion?: string;
|
|
12
|
+
detail: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DoctorReport {
|
|
15
|
+
ok: boolean;
|
|
16
|
+
lockfilePath: string;
|
|
17
|
+
registryName?: string;
|
|
18
|
+
lockCount: number;
|
|
19
|
+
manifestCount: number;
|
|
20
|
+
drifts: DoctorDrift[];
|
|
21
|
+
}
|
|
22
|
+
export interface CompareLockToManifestInput {
|
|
23
|
+
lockfile: ArtifactLockfile | null;
|
|
24
|
+
manifest: ArtifactRegistryManifest;
|
|
25
|
+
lockfilePath?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Compare installed lock entries to a registry manifest.
|
|
29
|
+
* - null lockfile → caller should exit 2 (no lockfile)
|
|
30
|
+
* - version/name drift → exit 1
|
|
31
|
+
* - no drifts → ok
|
|
32
|
+
*/
|
|
33
|
+
export declare function compareLockToManifest(input: CompareLockToManifestInput): DoctorReport;
|
|
34
|
+
export declare function emptyLockfile(): ArtifactLockfile;
|
|
35
|
+
export declare function lockfileWith(artifacts: ArtifactLock[]): ArtifactLockfile;
|
package/dist/emit.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { ArtifactRegistryItem, ArtifactRegistryManifest, ComponentArtifact, TemplateArtifact } from "@uibot/contracts";
|
|
2
|
+
import type { BlockSource } from "./block-source.js";
|
|
3
|
+
import type { TemplateSource } from "./template-source.js";
|
|
4
|
+
/**
|
|
5
|
+
* Registry manifest emitters.
|
|
6
|
+
*
|
|
7
|
+
* Both emitters consume the same neutral {@link BlockSource}[] produced by
|
|
8
|
+
* {@link collectBlockSources}, so the two distribution formats never re-scan
|
|
9
|
+
* the block source set:
|
|
10
|
+
*
|
|
11
|
+
* - {@link buildUiBotRegistryManifest} → uibot-native `ArtifactRegistryManifest`
|
|
12
|
+
* (full `ComponentArtifact` + `CatalogEntry`, installable via
|
|
13
|
+
* `installArtifactToWorkspace`).
|
|
14
|
+
* - `buildShadcnRegistry` (in `./shadcn`) → shadcn-style `registry.json`.
|
|
15
|
+
*
|
|
16
|
+
* ## Two distribution channels — DO NOT confuse the endpoints
|
|
17
|
+
*
|
|
18
|
+
* The two emitters back two *different, non-interchangeable* `registry.json`
|
|
19
|
+
* files served at different endpoints/ports with different
|
|
20
|
+
* `registryDependencies` semantics:
|
|
21
|
+
*
|
|
22
|
+
* - **uibot-native** (this file): served by the control plane on **:3202** at
|
|
23
|
+
* `/api/registry/registry.json` + `/artifacts/:name` (via
|
|
24
|
+
* `createRegistryHttpHandler` in `./http`). Artifacts keep the
|
|
25
|
+
* `@uibot/renderer-react` *peer* dependency (consumer wires the UIBot
|
|
26
|
+
* renderer pipeline). Consumed by the `uibot` CLI (`@uibot/cli`) by default.
|
|
27
|
+
* - **shadcn-compatible** (`./shadcn`): built by `scripts/build-registry.ts`
|
|
28
|
+
* (root `registry:build`) into `public/registry/` (gitignored) and served by
|
|
29
|
+
* `scripts/serve-registry.ts` (root `registry:serve`) on **:4444** with CORS.
|
|
30
|
+
* `transformBlockSource` rewrites the `@uibot/renderer-react` import to a
|
|
31
|
+
* self-contained `@/lib/uibot-renderer` shim, so each block item declares
|
|
32
|
+
* `registryDependencies: ["uibot-base"]` (NOT a renderer peer). Consumed by
|
|
33
|
+
* `npx shadcn add`.
|
|
34
|
+
*
|
|
35
|
+
* Pointing `npx shadcn add` at :3202, or the `uibot` CLI at :4444, will fail —
|
|
36
|
+
* the manifests are not interchangeable.
|
|
37
|
+
*/
|
|
38
|
+
/** Options for {@link buildUiBotRegistryManifest}. */
|
|
39
|
+
export interface BuildUiBotRegistryManifestOptions {
|
|
40
|
+
/** Manifest name, e.g. `"uibot"` or `"local"`. */
|
|
41
|
+
name: string;
|
|
42
|
+
/**
|
|
43
|
+
* Default `runtime` stamped on every emitted `ComponentArtifact`.
|
|
44
|
+
* Currently only `"react"` is supported. Defaults to `"react"`.
|
|
45
|
+
*/
|
|
46
|
+
runtime?: ComponentArtifact["runtime"];
|
|
47
|
+
/**
|
|
48
|
+
* Default artifact version when a block source omits one. Defaults to
|
|
49
|
+
* `"0.1.0"`.
|
|
50
|
+
*/
|
|
51
|
+
defaultVersion?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Optional template sources (v2.28). Appended after component items.
|
|
54
|
+
* Native channel only — do not feed into shadcn emitter.
|
|
55
|
+
*/
|
|
56
|
+
templates?: TemplateSource[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Convert a single {@link BlockSource} into a uibot-native
|
|
60
|
+
* {@link ComponentArtifact}. Mirrors the shape `installArtifactToWorkspace`
|
|
61
|
+
* writes to disk.
|
|
62
|
+
*/
|
|
63
|
+
export declare function toComponentArtifact(source: BlockSource, opts?: {
|
|
64
|
+
runtime?: ComponentArtifact["runtime"];
|
|
65
|
+
defaultVersion?: string;
|
|
66
|
+
}): ComponentArtifact;
|
|
67
|
+
/**
|
|
68
|
+
* Convert a single {@link BlockSource} into a uibot-native
|
|
69
|
+
* {@link ArtifactRegistryItem} (the per-component payload served at
|
|
70
|
+
* `/artifacts/:name`).
|
|
71
|
+
*/
|
|
72
|
+
export declare function toArtifactRegistryItem(source: BlockSource, opts?: {
|
|
73
|
+
runtime?: ComponentArtifact["runtime"];
|
|
74
|
+
defaultVersion?: string;
|
|
75
|
+
}): ArtifactRegistryItem;
|
|
76
|
+
/**
|
|
77
|
+
* Build the uibot-native {@link ArtifactRegistryManifest} from a neutral
|
|
78
|
+
* {@link BlockSource}[]. Each source becomes one `ArtifactRegistryItem` whose
|
|
79
|
+
* `artifact` is a full `ComponentArtifact` (files + catalog entry).
|
|
80
|
+
*/
|
|
81
|
+
export declare function buildUiBotRegistryManifest(sources: BlockSource[], opts: BuildUiBotRegistryManifestOptions): ArtifactRegistryManifest;
|
|
82
|
+
/** Re-export for callers that build template items without going through BlockSource. */
|
|
83
|
+
export type { TemplateArtifact };
|
|
84
|
+
/**
|
|
85
|
+
* Emit the standalone per-component artifact JSON for a single block source —
|
|
86
|
+
* the value served at `GET {basePath}/artifacts/:name`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function emitArtifactJson(source: BlockSource, opts?: {
|
|
89
|
+
runtime?: ComponentArtifact["runtime"];
|
|
90
|
+
defaultVersion?: string;
|
|
91
|
+
}): ArtifactRegistryItem;
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ArtifactRegistryManifest } from "@uibot/contracts";
|
|
2
|
+
/**
|
|
3
|
+
* Normalise a registry base path: trim a trailing slash so `${base}/...`
|
|
4
|
+
* concatenation is unambiguous. Mirrors `normalizeHubBasePath`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeRegistryBasePath(basePath?: string): string;
|
|
7
|
+
export interface CreateUIBotRegistryHttpHandlerOptions {
|
|
8
|
+
manifest: ArtifactRegistryManifest;
|
|
9
|
+
/** Base path the registry routes hang off. Defaults to `/api/registry`. */
|
|
10
|
+
basePath?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Build a registry HTTP handler that serves the given manifest. The handler
|
|
14
|
+
* pre-indexes `manifest.items` by name for O(1) `/artifacts/:name` lookups.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createUIBotRegistryHttpHandler(options: CreateUIBotRegistryHttpHandlerOptions): (request: Request) => Promise<Response>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { ArtifactLock, ArtifactRegistryItem, ArtifactRegistryManifest, Catalog, ComponentArtifact, PluginDistributionItem, PluginDistributionManifest, TemplateArtifact } from "@uibot/contracts";
|
|
2
|
+
export type RegistryItem = ArtifactRegistryItem;
|
|
3
|
+
export type RegistryManifest = ArtifactRegistryManifest;
|
|
4
|
+
export declare function parseRegistryManifest(input: ArtifactRegistryManifest): ArtifactRegistryManifest;
|
|
5
|
+
export declare function parsePluginDistributionManifest(input: PluginDistributionManifest): PluginDistributionManifest;
|
|
6
|
+
export interface ArtifactRegistrySource {
|
|
7
|
+
id: string;
|
|
8
|
+
priority: number;
|
|
9
|
+
get(name: string): Promise<ArtifactRegistryItem | undefined> | ArtifactRegistryItem | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface PluginDistributionSource {
|
|
12
|
+
id: string;
|
|
13
|
+
priority: number;
|
|
14
|
+
get(pluginId: string): Promise<PluginDistributionItem | undefined> | PluginDistributionItem | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare class MemoryArtifactRegistrySource implements ArtifactRegistrySource {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly priority: number;
|
|
19
|
+
private readonly items;
|
|
20
|
+
constructor(id: string, priority: number, items: Record<string, ArtifactRegistryItem>);
|
|
21
|
+
get(name: string): ArtifactRegistryItem | undefined;
|
|
22
|
+
}
|
|
23
|
+
export declare class MemoryPluginRegistrySource implements PluginDistributionSource {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly priority: number;
|
|
26
|
+
private readonly items;
|
|
27
|
+
constructor(id: string, priority: number, items: Record<string, PluginDistributionItem>);
|
|
28
|
+
get(pluginId: string): PluginDistributionItem | undefined;
|
|
29
|
+
}
|
|
30
|
+
export type RegistryRequestHeaders = Record<string, string>;
|
|
31
|
+
export interface RemoteRegistrySourceOptions {
|
|
32
|
+
registryUrl: string;
|
|
33
|
+
id?: string;
|
|
34
|
+
priority: number;
|
|
35
|
+
headers?: RegistryRequestHeaders;
|
|
36
|
+
}
|
|
37
|
+
export declare function fetchArtifactRegistryManifest(registryUrl: string, headers?: RegistryRequestHeaders): Promise<ArtifactRegistryManifest>;
|
|
38
|
+
export declare function fetchPluginDistributionManifest(registryUrl: string, headers?: RegistryRequestHeaders): Promise<PluginDistributionManifest>;
|
|
39
|
+
export declare class RemoteArtifactRegistrySource implements ArtifactRegistrySource {
|
|
40
|
+
private readonly options;
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly priority: number;
|
|
43
|
+
private manifestPromise?;
|
|
44
|
+
constructor(options: RemoteRegistrySourceOptions);
|
|
45
|
+
private getManifest;
|
|
46
|
+
get(name: string): Promise<ArtifactRegistryItem | undefined>;
|
|
47
|
+
}
|
|
48
|
+
export declare class RemotePluginRegistrySource implements PluginDistributionSource {
|
|
49
|
+
private readonly options;
|
|
50
|
+
readonly id: string;
|
|
51
|
+
readonly priority: number;
|
|
52
|
+
private manifestPromise?;
|
|
53
|
+
constructor(options: RemoteRegistrySourceOptions);
|
|
54
|
+
private getManifest;
|
|
55
|
+
get(pluginId: string): Promise<PluginDistributionItem | undefined>;
|
|
56
|
+
}
|
|
57
|
+
export declare class ArtifactRegistryResolver {
|
|
58
|
+
private readonly sources;
|
|
59
|
+
constructor(sources: ArtifactRegistrySource[]);
|
|
60
|
+
resolve(name: string): Promise<ArtifactRegistryItem | undefined>;
|
|
61
|
+
}
|
|
62
|
+
export declare class PluginRegistryResolver {
|
|
63
|
+
private readonly sources;
|
|
64
|
+
constructor(sources: PluginDistributionSource[]);
|
|
65
|
+
resolve(pluginId: string): Promise<PluginDistributionItem | undefined>;
|
|
66
|
+
}
|
|
67
|
+
export interface ArtifactInstallerOptions {
|
|
68
|
+
workspaceRoot: string;
|
|
69
|
+
source?: string;
|
|
70
|
+
lockfilePath?: string;
|
|
71
|
+
componentsDir?: string;
|
|
72
|
+
templatesDir?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface ArtifactInstallResult {
|
|
75
|
+
artifactLock: ArtifactLock;
|
|
76
|
+
catalogPatch: Partial<Catalog>;
|
|
77
|
+
writtenFiles: string[];
|
|
78
|
+
}
|
|
79
|
+
export declare class ArtifactContainmentError extends Error {
|
|
80
|
+
readonly artifactName: string;
|
|
81
|
+
readonly offendingPath: string;
|
|
82
|
+
readonly baseDir: string;
|
|
83
|
+
constructor(artifactName: string, offendingPath: string, baseDir: string);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Validate that a relative file path stays within baseDir.
|
|
87
|
+
* Rejects absolute paths, `..` traversal, and null bytes.
|
|
88
|
+
*/
|
|
89
|
+
export declare function assertPathContained(relativePath: string, baseDir: string, artifactName: string): string;
|
|
90
|
+
export declare function installArtifactToWorkspace(artifact: ComponentArtifact | TemplateArtifact, options: ArtifactInstallerOptions): ArtifactInstallResult;
|
|
91
|
+
export { compareLockToManifest, emptyLockfile, lockfileWith, } from "./doctor.js";
|
|
92
|
+
export type { DoctorDrift, DoctorDriftKind, DoctorReport, CompareLockToManifestInput, } from "./doctor.js";
|
|
93
|
+
export * from "./block-source.js";
|
|
94
|
+
export { collectTemplateSources, collectTemplateSourcesFromDirs, toTemplateArtifact, templateSourceToRegistryItem, } from "./template-source.js";
|
|
95
|
+
export type { TemplateSource, CollectTemplateSourcesOptions } from "./template-source.js";
|
|
96
|
+
export * from "./emit.js";
|
|
97
|
+
export * from "./shadcn.js";
|
|
98
|
+
export * from "./http.js";
|
|
99
|
+
export * from "./resource-index.js";
|
|
100
|
+
export * from "./resource-aliases.js";
|
|
101
|
+
export * from "./resource-query.js";
|
|
102
|
+
export * from "./resource-receipt.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{lstatSync as cr,mkdirSync as Le,readFileSync as lr,realpathSync as dr,writeFileSync as Ne}from"fs";import{basename as ur,dirname as ue,isAbsolute as pr,resolve as E,sep as _e}from"path";function ze(e){let t=e.lockfilePath??"uibot.artifacts.lock.json",r=e.manifest.items??[],n=new Map;for(let i of r)n.set(i.name,i);if(e.lockfile===null)return{ok:!1,lockfilePath:t,registryName:e.manifest.name,lockCount:0,manifestCount:r.length,drifts:[{name:"*",kind:"missing-in-lock",detail:"lockfile missing or unreadable"}]};let o=[],a=new Set;for(let i of e.lockfile.artifacts??[]){a.add(i.name);let l=n.get(i.name);if(!l){o.push({name:i.name,kind:"missing-in-manifest",lockVersion:i.version,detail:`locked ${i.name}@${i.version} not present in registry manifest`});continue}let c=He(l);if(c&&c!==i.version)o.push({name:i.name,kind:"version-mismatch",lockVersion:i.version,manifestVersion:c,detail:`${i.name}: lock ${i.version} \u2260 registry ${c}`})}return{ok:o.length===0,lockfilePath:t,registryName:e.manifest.name,lockCount:(e.lockfile.artifacts??[]).length,manifestCount:r.length,drifts:o}}function He(e){return e.artifact?.version??e.version}function We(){return{version:1,artifacts:[]}}function Ke(e){return{version:1,artifacts:e}}import{readFileSync as Ye,realpathSync as ge}from"fs";import{resolve as B,relative as Ge,dirname as Je,extname as Qe,sep as Z}from"path";function Ze(e){if(e.endsWith(".css"))return"style";if(e.endsWith(".tsx")||e.endsWith(".jsx"))return"component";if(/(^|\/)use-[^/]+\.ts$/.test(e))return"hook";return"lib"}function Xe(e){let t=e.readFile??((c)=>Ye(c,"utf8")),r=new Map,n=(c,d=B(e.sourceDir))=>{let p=Ge(d,B(c));if(p===".."||p.startsWith(`..${Z}`)||p.startsWith(Z))throw Error(`Block dependency outside sourceDir: ${c}`);return p.replaceAll(Z,"/")},o=(c)=>{if(n(B(e.sourceDir,c)),!e.readFile)n(ge(B(e.sourceDir,c)),ge(e.sourceDir));let d=r.get(c);if(d!==void 0)return d;let p=t(B(e.sourceDir,c));return r.set(c,p),p},a=(c)=>{let d=new Map,p=(y)=>{if(d.has(y))return;let u=o(y);d.set(y,{path:y,type:Ze(y),content:u});let s=u.matchAll(/(?:\bfrom\s*|\bimport\s*)["'](\.[^"']+)["']/g);for(let g of s){let f=n(B(e.sourceDir,Je(y),g[1]??"")),C=Qe(f)?[f]:[`${f}.ts`,`${f}.tsx`,`${f}/index.ts`,`${f}/index.tsx`],S;for(let F of C)try{o(F),S=F;break}catch(D){if(D instanceof Error&&D.message.includes("outside sourceDir"))throw D}if(!S)throw Error(`Unresolved block dependency: ${y} -> ${g[1]}`);p(S)}};return p(c),[...d.values()]},i=(c)=>{let d=new Set;for(let p of c){if(typeof p.content!=="string")continue;for(let y of p.content.matchAll(/(?:\bfrom\s*|\bimport\s*)["']([^."'/][^"']*|@[^"']+)["']/g)){let u=y[1]??"";if(u.startsWith("node:"))continue;let s=u.startsWith("@")?u.split("/").slice(0,2).join("/"):u.split("/")[0]??"";if(s==="react"||s==="react-dom"||s.startsWith("@uibot/"))continue;d.add(s)}}return[...d].sort()},l=[];for(let c of Object.keys(e.catalog)){let d=e.blockFileMap[c];if(d===void 0)continue;let p=e.catalog[c];if(p===void 0)continue;let y=o(d),u=a(d),s=i(u);l.push({name:c,category:p.category,description:p.description,sourceCode:y,files:u,catalogEntry:p,...s.length>0?{dependencies:s}:{}})}return l}function Lr(e){return e.flatMap((t)=>Xe(t))}import{readdirSync as et,readFileSync as tt,statSync as rt}from"fs";import{basename as nt,join as ot}from"path";var it="0.1.0";function me(e){let{dir:t}=e,r;try{r=et(t)}catch{return[]}let n=e.defaultVersion??it,o=e.defaultLevel??"L4",a=e.defaultCategory??"template",i=[];for(let l of r){if(!/\.ya?ml$/i.test(l))continue;let c=ot(t,l);try{if(!rt(c).isFile())continue}catch{continue}let d=tt(c,"utf8");if(!d.trim())continue;let p=nt(l).replace(/\.ya?ml$/i,""),y=at(p),u=ct(p),s=lt(d)??`${u} template`;i.push({name:y,version:n,title:u,description:s,yaml:d,absolutePath:c,templateContract:{name:y,description:s,level:o,category:a,keywords:[y,p.toLowerCase(),"uibot-template",...e.extraKeywords??[]],composedFrom:dt(d)}})}return i.sort((l,c)=>l.name.localeCompare(c.name))}function st(e){let t=new Map;for(let r of e)for(let n of me(r)){let o=t.get(n.name);if(o)throw Error(`duplicate template source name "${n.name}": ${o.absolutePath} and ${n.absolutePath}`);t.set(n.name,n)}return[...t.values()].sort((r,n)=>r.name.localeCompare(n.name))}function fe(e){return{kind:"template",name:e.name,version:e.version,files:[{path:`${e.name}.yaml`,type:"template",content:e.yaml,target:`${e.name}.yaml`}],templateContract:e.templateContract}}function X(e){return{name:e.name,kind:"template",title:e.title,description:e.description,artifact:fe(e)}}function at(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"").toLowerCase()}function ct(e){return e.replace(/[-_]+/g," ").replace(/\b\w/g,(t)=>t.toUpperCase())}function lt(e){return(e.match(/^\s*title:\s*["']?(.+?)["']?\s*$/m)??e.match(/^\s*-\s*id:.*\n\s*path:.*\n\s*title:\s*["']?(.+?)["']?\s*$/m))?.[1]?.trim()}function dt(e){let t=new Set;for(let r of e.matchAll(/^\s*-\s*type:\s*["']?([^"'#\n]+?)["']?\s*$/gm)){let n=r[1]?.trim();if(n)t.add(n)}for(let r of e.matchAll(/^\s*template:\s*["']?([^"'#\n]+?)["']?\s*$/gm)){let n=r[1]?.trim();if(n)t.add(n)}return[...t].sort()}var ut="0.1.0";function pt(e,t={}){return{kind:"component",name:e.name,version:t.defaultVersion??ut,runtime:t.runtime??"react",files:e.files,...e.dependencies?{dependencies:e.dependencies}:{},...e.registryDependencies?{registryDependencies:e.registryDependencies}:{},...e.catalogEntry.tags?{tags:e.catalogEntry.tags}:{},catalogEntry:e.catalogEntry}}function ye(e,t={}){return{name:e.name,kind:"component",title:e.catalogEntry.name,description:e.description??e.catalogEntry.description,artifact:pt(e,t)}}function qr(e,t){let r={...t.runtime?{runtime:t.runtime}:{},...t.defaultVersion?{defaultVersion:t.defaultVersion}:{}},n=e.map((a)=>ye(a,r)),o=(t.templates??[]).map((a)=>X(a));return{name:t.name,items:[...n,...o]}}function zr(e,t={}){return ye(e,t)}var ft={spec:["html","markdown","zip"],prototype:["html","zip"],deck:["html","pptx","zip"],poster:["html","zip"]},Fn=Array.from(new Set(Object.values(ft).flat()));var Ce=["experimental","candidate","recommended"];var be=["missing","declared","verified","external-consumer"],ee=["source","license","contract","states","accessibility","light-theme","dark-theme","responsive","dependency-closure","packed-install","typecheck","browser"],yt=Object.freeze([Object.freeze({name:"manifest",summary:"Describe query operations and list the derived resource index.",positionals:Object.freeze([]),options:Object.freeze([])}),Object.freeze({name:"search",summary:"Search resources with deterministic bilingual ranking and reasons.",positionals:Object.freeze([Object.freeze({name:"text",property:"text",type:"string",required:!1})]),options:Object.freeze([Object.freeze({name:"kind",property:"kinds",type:"resource-kind",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"tag",property:"tags",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"category",property:"categories",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"capability",property:"capabilities",type:"string",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"maturity",property:"maturities",type:"resource-maturity",multiple:!0,cliEncoding:"comma-separated"}),Object.freeze({name:"limit",property:"limit",type:"positive-integer"})])}),Object.freeze({name:"get",summary:"Resolve one canonical resource id or unambiguous alias.",positionals:Object.freeze([Object.freeze({name:"id-or-alias",property:"id",type:"string",required:!0})]),options:Object.freeze([])}),Object.freeze({name:"build",summary:"Plan dependency closure and gaps without writing or installing.",positionals:Object.freeze([Object.freeze({name:"root",property:"roots",type:"string",required:!0,variadic:!0})]),options:Object.freeze([])})]);var te="uibot.registry.item.v1";var Ct="https://ui.shadcn.com/schema/registry.json",bt="https://ui.shadcn.com/schema/registry-item.json",ht=["clsx","tailwind-merge"],Rt="components/uibot",xt="lib",kt="@uibot",Pt="uibot/templates",re="uibot-base";function ne(e){return e.replace(/\./g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function he(e,t){let r=e.sourceCode;if(r=r.replace(/import\s+(type\s+)?(\{[^}]*\})\s+from\s+["']@uibot\/renderer-react["'];?/g,(a,i,l)=>`import ${i??"type "}${l} from "${t.rendererShimImport}";`),t.contractsShimImport){let a=t.contractsShimImport;r=r.replace(/import\s+(type\s+)?(\{[^}]*\})\s+from\s+["']@uibot\/contracts["'];?/g,(i,l,c)=>`import ${l??"type "}${c} from "${a}";`)}let n=new Set;r=r.replace(/\bReact\.([A-Z]\w*)/g,(a,i)=>(n.add(i),i));let o=!1;if(r=r.replace(/(?:^|\n)function cn\([\s\S]*?\)\s*(?::[^\n{]+)?\{[\s\S]*?\n\}\n?/,()=>(o=!0,`
|
|
3
|
+
`)),o){let a=`import { cn } from "${t.cnUtilImport}";
|
|
4
|
+
`,i=r.indexOf(`
|
|
5
|
+
`,r.indexOf("import "));if(i>=0)r=`${r.slice(0,i+1)}${a}${r.slice(i+1)}`;else r=a+r}if(n.size>0){let a=[...n].sort().join(", "),i=/import\s+type\s+\{([^}]*)\}\s+from\s+["']react["'];?/;if(i.test(r))r=r.replace(i,(l,c)=>`import type { ${[...new Set([...c.split(",").map((p)=>p.trim()).filter(Boolean),...n])].sort().join(", ")} } from "react";`);else{let l=`import type { ${a} } from "react";
|
|
6
|
+
`,c=r.indexOf(`
|
|
7
|
+
`,r.indexOf("import "));if(c>=0)r=`${r.slice(0,c+1)}${l}${r.slice(c+1)}`;else r=l+r}}return`${r.replace(/\n{3,}/g,`
|
|
8
|
+
|
|
9
|
+
`).trimStart().trimEnd()}
|
|
10
|
+
`}function St(e){let t={category:e.category,level:e.level};if(e.props)t.props=e.props;if(e.slots)t.slots=e.slots;if(e.events)t.events=e.events;if(e.usageScenarios)t.scenarios=e.usageScenarios;if(e.constraints)t.constraints=e.constraints;return t}function Vo(e){return{light:Re(e,":root"),dark:Re(e,".dark")}}function Re(e,t){let r={},n=new RegExp(`${xe(t)}\\s*\\{`,"g"),o;while((o=n.exec(e))!==null){let a=o.index+o[0].length,i=1,l=a;for(;l<e.length&&i>0;l++){let d=e[l];if(d==="{")i++;else if(d==="}")i--}let c=e.slice(a,l-1);for(let d of c.matchAll(/--([\w-]+)\s*:\s*([^;]+);/g)){let p=d[1],y=d[2];if(p!==void 0&&y!==void 0)r[p]=y.trim()}}return r}function xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Uo(e,t){let r=t.sharedDependencies??ht,n=t.channel??"public",o=It(t),a=(t.componentsDir??Rt).replace(/\/$/,""),i=(t.libDir??xt).replace(/\/$/,""),l=`${i}/uibot-renderer.ts`,c=`${i}/utils.ts`,d=`${i}/uibot-contracts.ts`,p="@/lib/uibot-renderer",y="@/lib/utils",u="@/lib/uibot-contracts",s={},g={name:re,type:"registry:lib",description:"UIBot runtime base: RendererComponent type shim + cn util + OKLCH theme tokens. Pulled automatically by every UIBot block.",dependencies:r,files:[{path:l,content:t.rendererShimContent,type:"registry:lib"},{path:c,content:t.cnUtilContent,type:"registry:lib"},...t.contractsShimContent?[{path:d,content:t.contractsShimContent,type:"registry:lib"}]:[]],...t.cssVars?{cssVars:t.cssVars}:{},meta:{base:!0}};s[re]=g;let f=new Map,C=new Map,S=new Map,F=new Map;for(let m of e){let I=m.files[0]?.path??`${ne(m.name)}.tsx`,x=m.channel??"public",b=F.get(I);if(b&&b!==x)throw Error(`${I} mixes ${b} and ${x} blocks; split the file`);F.set(I,x)}for(let m of e){if((m.channel??"public")!==n)continue;let x=m.files[0]?.path??`${ne(m.name)}.tsx`,b=f.get(x);if(!b){let R=ne(wt(x,m.name)),W=he(m,{rendererShimImport:"@/lib/uibot-renderer",cnUtilImport:"@/lib/utils",...t.contractsShimContent?{contractsShimImport:"@/lib/uibot-contracts"}:{}}),T=`${a}/${R}.tsx`,V={schema:te,item:R,channel:n,components:[]};S.set(R,V),b={name:R,type:"registry:ui",description:m.description??m.catalogEntry.description,dependencies:["react",...m.dependencies??[]],registryDependencies:[o(re)],files:m.files.length<=1?[{path:T,target:T,content:W,type:"registry:ui"}]:m.files.map((K)=>{if(typeof K.content!=="string")throw Error(`Missing block source content: ${K.path}`);let pe=`${a}/${K.path.replace(/^blocks\//,"")}`;return{path:pe,target:pe,content:he({...m,sourceCode:K.content},{rendererShimImport:"@/lib/uibot-renderer",cnUtilImport:"@/lib/utils",...t.contractsShimContent?{contractsShimImport:"@/lib/uibot-contracts"}:{}}),type:"registry:ui"}}),meta:{...St(m.catalogEntry),provides:[m.name],uibot:V}},f.set(x,b),s[R]=b}else{let R=b.meta;if(R.provides&&!R.provides.includes(m.name))R.provides.push(m.name)}let A=S.get(b.name);if(A?.components&&!C.has(m.name))A.components.push(At(m,b,a)),C.set(m.name,b.name)}for(let[m,I]of S){let x=s[m];if(!x)continue;I.components?.sort((A,R)=>A.name.localeCompare(R.name));let b=`${a}/${m}.uibot.json`;x.files.push({path:b,target:b,content:`${JSON.stringify(I,null,2)}
|
|
11
|
+
`,type:"registry:ui"})}let D={},Q=(t.templates??[]).filter((m)=>(m.channel??"public")===n),qe=new Set(Q.map((m)=>m.name));for(let m of Q){if(s[m.name])throw Error(`template item "${m.name}" collides with a component item`);let I=m.templateContract.composedFrom??[],x=new Set,b=[];for(let T of I){let V=C.get(T);if(V)x.add(o(V));else if(qe.has(T)&&T!==m.name)x.add(o(T));else b.push(T)}if(b.length>0)D[m.name]=b;let A=`${i}/${Pt}`,R=`${m.name}.uibot.yaml`,W={schema:te,item:m.name,channel:n,template:{file:R,contract:m.templateContract}};s[m.name]={name:m.name,type:"registry:block",description:m.description,registryDependencies:[...x].sort(),files:[{path:`${A}/${R}`,target:`${A}/${R}`,content:m.yaml,type:"registry:lib"},{path:`${A}/${m.name}.uibot.json`,target:`${A}/${m.name}.uibot.json`,content:`${JSON.stringify(W,null,2)}
|
|
12
|
+
`,type:"registry:lib"}],meta:{uibot:W}}}return{registry:{$schema:Ct,name:t.registryName,...t.homepage?{homepage:t.homepage}:{},items:Object.values(s).map((m)=>({name:m.name,type:m.type,...m.description?{description:m.description}:{},...m.registryDependencies?{registryDependencies:m.registryDependencies}:{},...m.dependencies?{dependencies:m.dependencies}:{}}))},items:s,unresolvedTemplateTypes:D}}function It(e){if(e.baseUrl){let r=e.baseUrl.replace(/\/$/,"");return(n)=>`${r}/r/${n}.json`}let t=e.namespace??kt;if(!/^@[a-z0-9][a-z0-9-]*$/.test(t))throw Error(`registry namespace must look like "@uibot", got "${t}"`);return(r)=>`${t}/${r}`}function At(e,t,r){let n=e.name.replace(/\./g,""),o=`${r}/`,a=t.files.find((i)=>i.path.startsWith(o)&&/\.(tsx|ts)$/.test(i.path)&&vt(i.content,n));if(!a)throw Error(`block "${e.name}" has no named export "${n}" in item "${t.name}"`);return{name:e.name,export:n,module:a.path.slice(o.length),catalog:e.catalogEntry}}function vt(e,t){let r=xe(t),n=e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/^\s*\/\/.*$/gm,"");if(new RegExp(`export\\s+(?:const|let|function|class)\\s+${r}\\b`).test(n))return!0;for(let o of n.matchAll(/export\s*\{([^}]*)\}/g)){let a=(o[1]??"").split(",").map((l)=>{let[,c]=l.trim().split(/\s+as\s+/);return(c??l.trim().replace(/^type\s+/,"")).trim()}),i=(o[1]??"").split(",").map((l)=>l.trim()).filter((l)=>l.startsWith("type ")).map((l)=>l.replace(/^type\s+/,"").split(/\s+as\s+/).pop()?.trim());if(a.includes(t)&&!i.includes(t))return!0}return!1}function wt(e,t){return(e.split("/").pop()??t).replace(/\.(tsx|ts|jsx|js)$/,"")||t}var jo=bt;function Et(e="/api/registry"){let t=(e||"/api/registry").trim(),r=t.startsWith("/")?t:`/${t}`;return r.length>1?r.replace(/\/$/,""):r}function U(e,t=200){return Response.json(e,{status:t})}function qo(e){let t=Et(e.basePath),r=`${t}/registry.json`,n=`${t}/artifacts/`,o=new Map(e.manifest.items.map((a)=>[a.name,a]));return async function(i){let l=new URL(i.url);if(i.method!=="GET")return U({error:"Method not allowed"},405);if(l.pathname===r)return U(e.manifest);if(l.pathname.startsWith(n)){let c=l.pathname.slice(n.length),d=decodeURIComponent(c.endsWith(".json")?c.slice(0,-5):c),p=o.get(d);if(!p)return U({error:`Artifact '${d}' not found`},404);return U(p)}return U({error:"Not found"},404)}}var oe="uibot.resource.admission.v1",Dt=["source","license","contract","states","accessibility","light-theme","dark-theme","responsive","dependency-closure"],Tt=["packed-install","typecheck","browser"],Wo=["invalid-admission-manifest","invalid-admission-record","invalid-admission-check","duplicate-admission-record","unknown-admission-resource","missing-source-metadata","missing-license-metadata","dependency-closure-failed"];class ke extends Error{expected;actual;code="resource-admission-index-mismatch";constructor(e,t){super(`resource admission index mismatch: expected ${e}, received ${t}`);this.expected=e;this.actual=t;this.name="ResourceAdmissionIndexMismatchError"}}class Pe extends Error{issueCount;code="resource-admission-report-rejected";constructor(e){super(`resource admission report contains ${e.toString()} issue(s)`);this.issueCount=e;this.name="ResourceAdmissionReportRejectedError"}}class Se extends Error{code="resource-admission-report-not-derived";constructor(){super("resource admission report must come directly from assessResourceAdmissions");this.name="ResourceAdmissionReportNotDerivedError"}}var Ot=new Set(ee),Ft=new Set(be),Ie=new WeakSet,Y={missing:0,declared:1,verified:2,"external-consumer":3};function Mt(e,t){return e<t?-1:e>t?1:0}function L(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}function G(e,t){let r=new Set(t);return Object.keys(e).every((n)=>r.has(n))}function Ae(e){return[...new Set(e.map((t)=>t.trim()).filter(Boolean))].sort(Mt)}function _t(e,t,r,n){if(!L(r)||!G(r,["status","evidence"])){n.push({code:"invalid-admission-check",resourceId:e,check:t,detail:`${t} must contain only status and evidence`});return}if(typeof r.status!=="string"||!Ft.has(r.status)||r.status==="missing"){n.push({code:"invalid-admission-check",resourceId:e,check:t,detail:`${t} status must be declared, verified or external-consumer`});return}if(!Array.isArray(r.evidence)||r.evidence.length===0||r.evidence.some((o)=>typeof o!=="string"||!o.trim())){n.push({code:"invalid-admission-check",resourceId:e,check:t,detail:`${t} evidence must be a non-empty string array`});return}return{status:r.status,evidence:Ae(r.evidence)}}function Bt(e){if(e===void 0)return;if(!L(e)||!G(e,["source","version","license"]))return;if(Object.values(e).some((r)=>r!==void 0&&typeof r!=="string"))return;return{...typeof e.source==="string"&&e.source.trim()?{source:e.source.trim()}:{},...typeof e.version==="string"&&e.version.trim()?{version:e.version.trim()}:{},...typeof e.license==="string"&&e.license.trim()?{license:e.license.trim()}:{}}}function Lt(e,t){let r=new Map,n=[];if(!L(t)||!G(t,["schemaVersion","records"])||t.schemaVersion!==oe||!Array.isArray(t.records))return n.push({code:"invalid-admission-manifest",detail:`expected ${oe} with a records array`}),{records:r,issues:n};let o=new Set(e.resources.map((a)=>a.id));for(let a of t.records){if(!L(a)||!G(a,["resourceId","provenance","checks"])||typeof a.resourceId!=="string"||!a.resourceId.trim()||!L(a.checks)){n.push({code:"invalid-admission-record",...L(a)&&typeof a.resourceId==="string"?{resourceId:a.resourceId}:{},detail:"record must contain only resourceId, optional provenance and checks"});continue}let i=a.resourceId.trim();if(r.has(i)){n.push({code:"duplicate-admission-record",resourceId:i,detail:i});continue}if(!o.has(i)){n.push({code:"unknown-admission-resource",resourceId:i,detail:i});continue}let l=Bt(a.provenance);if(a.provenance!==void 0&&!l){n.push({code:"invalid-admission-record",resourceId:i,detail:"provenance must contain only string source, version and license fields"});continue}let c={},d=!1;for(let[p,y]of Object.entries(a.checks)){if(!Ot.has(p)){n.push({code:"invalid-admission-check",resourceId:i,detail:`unknown receipt check: ${p}`}),d=!0;continue}let u=p,s=_t(i,u,y,n);if(s)c[u]=s;else d=!0}if(d)continue;r.set(i,{resourceId:i,...l?{provenance:l}:{},checks:c})}return{records:r,issues:n}}function Nt(e){let t=new Map(e.resources.map((o)=>[o.id,o])),r=new Map;function n(o,a,i,l){if(r.has(o)||l.has(a))return;if(i.has(a)){r.set(o,`dependency cycle reached ${a}`);return}let c=t.get(a);if(!c){r.set(o,`missing dependency ${a}`);return}i.add(a);for(let d of c.dependencies)if(n(o,d,i,l),r.has(o))break;i.delete(a),l.add(a)}for(let o of e.resources)n(o.id,o.id,new Set,new Set);return r}var Vt=/^(unknown|unlicensed|none|n\/?a)$/i,Ut=/^SPDX-License-Identifier:\s*(\S+)/im,jt=/^(?:the\s+)?(mit|apache(?:\s+license(?:\s*,?\s*version\s*2\.0)?)?|bsd-2-clause|bsd-3-clause|isc|unlicense)\b/i;function M(e){let t=e?.trim();if(!t||Vt.test(t))return;return t}function $t(e){if(!e?.trim())return;let t=e.match(Ut)?.[1];if(t)return M(t);let r=e.match(jt)?.[1];if(!r)return;let n=r.toLowerCase();if(n.startsWith("mit"))return"MIT";if(n.startsWith("apache"))return"Apache-2.0";if(n.startsWith("bsd-2"))return"BSD-2-Clause";if(n.startsWith("bsd-3"))return"BSD-3-Clause";if(n==="isc")return"ISC";if(n==="unlicense")return"Unlicense";return}function Ko(e){return M(e.frontmatterLicense)??M(e.packageJsonLicense)??$t(e.licenseFileText)}function ve(e){return Boolean(M(e))}var j={states:/\b(disabled|loading|error|empty|pending|busy|children|active|muted|boolean-state)\b/i,accessibility:/\b(label|aria|accessible|alt|role)\b/i,"light-theme":/:root\b|\b(light(?:-theme)?|theme token|css variables?)\b/i,"dark-theme":/\b(dark(?:-theme)?)\b/i,responsive:/\b(size|responsive|breakpoint|sm|md|lg|xl|full)\b/i};function ie(e,t){if(!e||typeof e!=="object")return;if(Array.isArray(e)){for(let n of e)ie(n,t);return}let r=e;for(let[n,o]of Object.entries(r)){if(t.push(n),n==="type"&&o==="boolean")t.push("boolean-state");ie(o,t)}}function qt(e){let t=[];return ie(e.props,t),[e.name,e.description,...e.tags??[],...e.usageScenarios??[],...e.constraints??[],...t,...Object.keys(e.slots??{}),...Object.keys(e.events??{}),e.slots&&Object.keys(e.slots).length>0?"empty":""].join(`
|
|
13
|
+
`)}function Yo(e,t={}){let r=[qt(e),t.sourceText??"",t.stylesText??""].join(`
|
|
14
|
+
`);return{contract:Boolean(e.props&&Object.keys(e.props).length>0||e.events&&Object.keys(e.events).length>0||e.slots&&Object.keys(e.slots).length>0)?"verified":"declared",states:j.states.test(r)?"verified":"missing",accessibility:j.accessibility.test(r)?"verified":"missing","light-theme":j["light-theme"].test(r)?"verified":"missing","dark-theme":j["dark-theme"].test(r)?"verified":"missing",responsive:j.responsive.test(r)?"verified":"missing"}}function zt(e){return{source:"declared",license:ve(e.source.license)?"declared":"missing",contract:"declared",states:"missing",accessibility:"missing","light-theme":"missing","dark-theme":"missing",responsive:"missing","dependency-closure":"missing","packed-install":"missing",typecheck:"missing",browser:"missing"}}function Ht(e){if(!Dt.every((n)=>Y[e[n]]>=Y.verified))return"experimental";return Tt.every((n)=>e[n]==="external-consumer")?"recommended":"candidate"}function we(e){let t=JSON.stringify({schemaVersion:e.schemaVersion,resources:e.resources.map((o)=>({id:o.id,kind:o.kind,title:o.title,description:o.description,...o.category?{category:o.category}:{},tags:o.tags,aliases:o.aliases,capabilities:o.capabilities,dependencies:o.dependencies,source:o.source})),aliases:e.aliases}),r=0xcbf29ce484222325n,n=0x100000001b3n;for(let o of new TextEncoder().encode(t))r^=BigInt(o),r=BigInt.asUintN(64,r*n);return`fnv1a64:${r.toString(16).padStart(16,"0")}`}function Wt(e,t,r){let n=zt(e),o=[`resource://${e.source.type}/${e.source.id}`,`resource://contract/${e.id}`],a=[];if(r)a.push({code:"dependency-closure-failed",resourceId:e.id,check:"dependency-closure",detail:r});else n["dependency-closure"]="verified",o.push(`resource://index/${e.id}`);if(t)for(let c of ee){if(c==="dependency-closure")continue;let d=t.checks[c];if(!d)continue;if(c==="source"&&Y[d.status]>=Y.verified&&(!t.provenance?.source||!t.provenance.version)){a.push({code:"missing-source-metadata",resourceId:e.id,check:c,detail:"verified source requires provenance.source and provenance.version"});continue}if(c==="license"&&!ve(t.provenance?.license)){a.push({code:"missing-license-metadata",resourceId:e.id,check:c,detail:"license evidence requires a concrete provenance.license"});continue}if(n[c]=d.status,o.push(...d.evidence),c==="source"&&t.provenance?.source)o.push(t.provenance.source)}let i=Ht(n),l={level:i==="recommended"?"external-consumer":i==="candidate"?"verified":"declared",maturity:i,checks:n,evidence:Ae(o)};return Object.freeze(l.checks),Object.freeze(l.evidence),Object.freeze(l),Object.freeze(a),Object.freeze({resourceId:e.id,receipt:l,issues:a})}function Go(e,t){let r=Lt(e,t),n=Nt(e),o=e.resources.map((c)=>Wt(c,r.records.get(c.id),n.get(c.id))),a=[...r.issues,...o.flatMap((c)=>c.issues)],i=Object.fromEntries(Ce.map((c)=>[c,0]));for(let c of o)i[c.receipt.maturity]+=1;Object.freeze(o),Object.freeze(i);for(let c of a)Object.freeze(c);Object.freeze(a);let l=Object.freeze({schemaVersion:oe,indexFingerprint:we(e),resources:o,counts:i,issues:a});return Ie.add(l),l}function Jo(e,t){if(!Ie.has(t))throw new Se;if(t.issues.length>0)throw new Pe(t.issues.length);let r=we(e);if(r!==t.indexFingerprint)throw new ke(t.indexFingerprint,r);let n=new Map(t.resources.map((a)=>[a.resourceId,a.receipt])),o=e.resources.map((a)=>{let i=n.get(a.id);if(!i)return a;return Object.freeze({...a,receipt:i})});return Object.freeze(o),Object.freeze({schemaVersion:e.schemaVersion,resources:o,aliases:e.aliases})}var Kt="uibot.resource.index.v1",Xo=["invalid-resource-source-id","duplicate-resource-id","dangling-resource-dependency","ambiguous-resource-dependency"];class N extends Error{code;detail;constructor(e,t){super(`${e}: ${t}`);this.code=e;this.detail=t;this.name="ResourceIndexError"}}function k(e,t){return e<t?-1:e>t?1:0}function h(e){return e.normalize("NFKC").replace(/([\p{Lu}]+)([\p{Lu}][\p{Ll}])/gu,"$1 $2").replace(/([\p{Ll}\p{N}])([\p{Lu}])/gu,"$1 $2").toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim().replace(/\s+/g," ")}function Yt(e){let t=h(e).replace(/ /g,"-");if(!t)throw new N("invalid-resource-source-id",e);return t}function v(e,t){return`${e}:${Yt(t)}`}function J(e){let t=new Map;for(let r of e){let n=r?.trim();if(!n)continue;let o=h(n);if(!o||t.has(o))continue;t.set(o,n)}return[...t.entries()].sort(([r],[n])=>k(r,n)).map(([,r])=>r)}function q(e){return{level:"declared",maturity:"experimental",checks:{source:"declared",license:e?"declared":"missing",contract:"declared",states:"missing",accessibility:"missing","light-theme":"missing","dark-theme":"missing",responsive:"missing","dependency-closure":"missing","packed-install":"missing",typecheck:"missing",browser:"missing"},evidence:[]}}function Gt(e){let t=M(e.license);return{type:e.type,id:e.id,...e.version?{version:e.version}:{},...e.url?{url:e.url}:{},...t?{license:t}:{}}}function z(e){return{id:e.id,kind:e.kind,title:e.title,description:e.description,...e.category?{category:e.category}:{},tags:J(e.tags),aliases:J(e.aliases),capabilities:J(e.capabilities),dependencies:[...new Set(e.dependencies)].sort(k),source:Gt(e.source),receipt:e.receipt}}function Jt(e){return(e.body.split(/\r?\n/).map((r)=>r.replace(/^#+\s*/,"").trim()).find(Boolean)??e.title).slice(0,240)}function Qt(e){return Object.freeze(e.tags),Object.freeze(e.aliases),Object.freeze(e.capabilities),Object.freeze(e.dependencies),Object.freeze(e.source),Object.freeze(e.receipt.checks),Object.freeze(e.receipt.evidence),Object.freeze(e.receipt),Object.freeze(e)}function Zt(e){let t=new Map;for(let r of Object.keys(e).sort(k)){let n=e[r];if(!n)continue;let o=v("component",r);for(let a of J([r,n.name])){let i=h(a),l=t.get(i)??[];if(!l.includes(o))l.push(o);t.set(i,l.sort(k))}}return t}function Xt(e,t,r){let n=r.get(h(e))??[];if(n.length===0)throw new N("dangling-resource-dependency",`${t} -> ${v("component",e)}`);if(n.length>1)throw new N("ambiguous-resource-dependency",`${t} -> ${e}: ${n.join(",")}`);return n[0]}function er(e,t,r,n){let o=e.startsWith("template:")?e.slice(9):e;if(Object.hasOwn(n,o))return v("template",o);return Xt(e,t,r)}function H(e,t,r){return M(r?.[e]??t)}function ei(e){return Object.entries(e).filter(([,t])=>t.level==="L4").sort(([t],[r])=>k(t,r)).map(([t,r])=>({id:`${t}-example`,title:`${r.name} Example`,description:r.description,category:r.category,tags:r.keywords,aliases:[`${t} example`,`${r.name} example`],capabilities:["example:template"],dependencies:[v("template",t)]}))}function ti(e){let t=e.components??{},r=e.templates??{},n=e.designGuides??[],o=e.examples??[],a=e.skills??[],i=e.licenses,l=Zt(t),c=[];for(let s of Object.keys(t).sort(k)){let g=t[s];if(!g)continue;let f=v("component",s),C=H(f,void 0,i);c.push(z({id:f,kind:"component",title:g.name,description:g.description,category:g.category,tags:g.tags??[],aliases:[s,g.name],capabilities:["catalog:component"],dependencies:[],source:{type:"catalog",id:s,...C?{license:C}:{}},receipt:q(Boolean(C))}))}for(let s of Object.keys(r).sort(k)){let g=r[s];if(!g)continue;let f=v("template",s),C=H(f,void 0,i);c.push(z({id:f,kind:"template",title:g.name,description:g.description,category:g.category,tags:g.keywords,aliases:[s,g.name],capabilities:[],dependencies:(g.composedFrom??[]).map((S)=>er(S,f,l,r)),source:{type:"template-contract",id:s,...C?{license:C}:{}},receipt:q(Boolean(C))}))}for(let s of[...n].sort((g,f)=>k(g.id,f.id))){let g=v("design-guide",s.id),f=H(g,void 0,i);c.push(z({id:g,kind:"design-guide",title:s.title,description:Jt(s),category:s.category,tags:s.tags,aliases:[s.id,s.title],capabilities:["designMd:source"],dependencies:[],source:{type:"design-md",id:s.id,...s.sourceUrl?{url:s.sourceUrl}:{},...f?{license:f}:{}},receipt:q(Boolean(f))}))}for(let s of[...o].sort((g,f)=>k(g.id,f.id))){let g=v("example",s.id),f=H(g,s.license,i);c.push(z({id:g,kind:"example",title:s.title,description:s.description,...s.category?{category:s.category}:{},tags:s.tags??[],aliases:[s.id,s.title,...s.aliases??[]],capabilities:s.capabilities??[],dependencies:s.dependencies??[],source:{type:"example",id:s.id,...s.version?{version:s.version}:{},...s.sourceUrl?{url:s.sourceUrl}:{},...f?{license:f}:{}},receipt:q(Boolean(f))}))}for(let s of[...a].sort((g,f)=>k(g.id,f.id))){let g=v("skill",s.id),f=H(g,void 0,i);c.push(z({id:g,kind:"skill",title:s.title,description:s.description?.trim()||s.title,tags:[...s.tags??[],...s.triggers??[]],aliases:[s.id,s.title,...s.triggers??[]],capabilities:["skill:definition"],dependencies:[],source:{type:"skill",id:s.id,...s.version?{version:s.version}:{},...f?{license:f}:{}},receipt:q(Boolean(f))}))}c.sort((s,g)=>k(s.id,g.id));let d=new Set;for(let s of c){if(d.has(s.id))throw new N("duplicate-resource-id",s.id);d.add(s.id)}for(let s of c)for(let g of s.dependencies)if(!d.has(g))throw new N("dangling-resource-dependency",`${s.id} -> ${g}`);let p=new Map;for(let s of c)for(let g of s.aliases){let f=h(g);if(!f)continue;let C=p.get(f)??new Set;C.add(s.id),p.set(f,C)}let y=Object.freeze(Object.fromEntries([...p.entries()].sort(([s],[g])=>k(s,g)).map(([s,g])=>[s,Object.freeze([...g].sort(k))]))),u=Object.freeze(c.map(Qt));return Object.freeze({schemaVersion:Kt,resources:u,aliases:y})}var tr=[["data table","data grid","datatable","table","\u8868\u683C","\u6570\u636E\u8868","\u6570\u636E\u8868\u683C"],["button","action button","\u6309\u94AE","\u64CD\u4F5C\u6309\u94AE"],["dashboard","admin dashboard","\u4EEA\u8868\u76D8","\u540E\u53F0","\u7BA1\u7406\u540E\u53F0"],["kanban","kanban board","\u770B\u677F","\u4EFB\u52A1\u770B\u677F"],["form","input form","\u8868\u5355","\u8F93\u5165\u8868\u5355"],["navigation","nav","sidebar","\u5BFC\u822A","\u4FA7\u8FB9\u680F"]],rr=Object.freeze(tr.map((e)=>Object.freeze([...e]))),Ee=new Map;for(let e of rr){let t=Object.freeze([...new Set(e.map(h).filter(Boolean))].sort());for(let r of t)Ee.set(r,t)}function se(e){let t=h(e);return Ee.get(t)??Object.freeze([t])}var ai=["resource-query-empty","resource-query-invalid-limit","resource-not-found","resource-alias-ambiguous"];class O extends Error{code;detail;constructor(e,t){super(`${e}: ${t}`);this.code=e;this.detail=t;this.name="ResourceQueryError"}}var de=Object.freeze({"exact-id":1000,"exact-title":900,alias:800,tag:600,capability:500,category:400,token:200,fuzzy:100}),nr=Object.freeze(Object.keys(de)),De=new Map(nr.map((e,t)=>[e,t])),Te=new Map([["component",0],["template",1],["design-guide",2],["example",3],["skill",4]]);function P(e,t){return e<t?-1:e>t?1:0}function Oe(e){return new Set((e??[]).map(h).filter(Boolean))}function ae(e,t){let r=Oe(t);if(r.size===0)return!0;let n=Oe(e);return[...r].some((o)=>n.has(o))}function or(e,t){if(t.kinds?.length&&!t.kinds.includes(e.kind))return!1;if(!ae(e.tags,t.tags))return!1;if(!ae(e.category?[e.category]:[],t.categories))return!1;if(!ae(e.capabilities,t.capabilities))return!1;if(t.maturities?.length&&!t.maturities.includes(e.receipt.maturity))return!1;return!0}function ir(e){return Boolean(e.kinds?.length||e.tags?.length||e.categories?.length||e.capabilities?.length||e.maturities?.length)}function w(e,t,r,n=de[t]){if(e.some((o)=>o.code===t&&o.value===r))return;e.push({code:t,value:r,score:n})}function ce(e,t){return e.find((r)=>h(r)===t)}function le(e){return[e.id,e.title,...e.aliases,...e.tags,...e.category?[e.category]:[],...e.capabilities]}function sr(e,t,r){if(Math.abs(e.length-t.length)>r)return r+1;let n=Array.from({length:t.length+1},(o,a)=>a);for(let o=1;o<=e.length;o+=1){let a=[o],i=o;for(let l=1;l<=t.length;l+=1){let c=(n[l-1]??r+1)+(e[o-1]===t[l-1]?0:1),d=Math.min((n[l]??r+1)+1,(a[l-1]??r+1)+1,c);a.push(d),i=Math.min(i,d)}if(i>r)return r+1;n=a}return n[t.length]??r+1}function ar(e,t){let r=h(t),n=[];if(h(e.id)===r)w(n,"exact-id",e.id);if(h(e.title)===r)w(n,"exact-title",e.title);let o=ce(e.aliases,r);if(o)w(n,"alias",o);let a=ce(e.tags,r);if(a)w(n,"tag",a);let i=ce(e.capabilities,r);if(i)w(n,"capability",i);if(e.category&&h(e.category)===r)w(n,"category",e.category);if(!o){let d=se(r).filter((y)=>y!==r),p=new Set(le(e).map(h));if(d.some((y)=>p.has(y)))w(n,"alias",t.trim())}let l=r.split(" ").filter(Boolean),c=h(le(e).join(" "));if(l.length>0&&l.every((d)=>c.includes(d)))w(n,"token",t.trim());if(n.length===0&&r.length>=4){let d;for(let p of le(e)){let y=h(p);if(y.length<4)continue;let u=sr(r,y,2);if(u<=2&&(!d||u<d.distance||u===d.distance&&P(p,d.value)<0))d={value:p,distance:u}}if(d)w(n,"fuzzy",d.value,de.fuzzy-d.distance)}return n.sort((d,p)=>{if(d.score!==p.score)return p.score-d.score;return(De.get(d.code)??99)-(De.get(p.code)??99)||P(d.value,p.value)})}function Fe(e,t,r){if(t.has(r))return[r];let n=h(r),o=e.aliases[n];if(o?.length)return[...o];let a=new Set;for(let i of se(n))for(let l of e.aliases[i]??[])a.add(l);return[...a].sort(P)}function Me(e,t){return new O("resource-alias-ambiguous",`${e.trim()}: ${t.join(",")}`)}function ci(e){let t=new Map(e.resources.map((n)=>[n.id,n]));function r(n){let o=n.trim(),a=Fe(e,t,o);if(a.length===0)throw new O("resource-not-found",o);if(a.length>1)throw Me(o,a);let i=a[0],l=i?t.get(i):void 0;if(!l)throw new O("resource-not-found",o);return l}return Object.freeze({manifest:()=>e,search(n){let o=n.text?.trim()??"";if(!o&&!ir(n))throw new O("resource-query-empty","text or filter is required");if(n.limit!==void 0&&(!Number.isInteger(n.limit)||n.limit<=0))throw new O("resource-query-invalid-limit",String(n.limit));let a=e.resources.filter((i)=>or(i,n)).map((i)=>{let l=o?ar(i,o):[];return{resource:i,score:l.reduce((c,d)=>c+d.score,0),reasons:l}}).filter((i)=>!o||i.reasons.length>0).sort((i,l)=>l.score-i.score||P(i.resource.id,l.resource.id));return n.limit===void 0?a:a.slice(0,n.limit)},get:r,build(n){if(n.length===0||n.every((u)=>!u.trim()))throw new O("resource-query-empty","at least one build root is required");let o=[],a=new Set;for(let u of n){let s=u.trim(),g=Fe(e,t,s);if(g.length===0)o.push({id:s,reason:"missing-resource"});else if(g.length>1)throw Me(s,g);else{let f=g[0];if(f)a.add(f)}}let i=new Set,l=new Set,c=new Set,d=[],p=[],y=(u,s)=>{if(i.has(u))return;if(l.has(u)){o.push({id:u,...s?{requiredBy:s}:{},reason:"dependency-cycle"});return}let g=t.get(u);if(!g){o.push({id:u,...s?{requiredBy:s}:{},reason:"missing-resource"});return}l.add(u),c.add(u);let f=[...g.dependencies].sort((C,S)=>{let F=t.get(C),D=t.get(S);return(Te.get(F?.kind??"")??99)-(Te.get(D?.kind??"")??99)||P(C,S)});for(let C of f)p.push({from:u,to:C,relation:"depends-on"}),y(C,u);l.delete(u),i.add(u),d.push(u)};for(let u of[...a].sort(P))y(u);return{roots:[...a].sort(P),nodes:[...c].sort(P).map((u)=>{let s=t.get(u);if(!s)throw new O("resource-not-found",u);return{id:u,kind:s.kind,maturity:s.receipt.maturity}}),edges:p.sort((u,s)=>P(u.from,s.from)||P(u.to,s.to)),order:d,gaps:o.sort((u,s)=>P(u.id,s.id)||P(u.requiredBy??"",s.requiredBy??"")||P(u.reason,s.reason))}}})}function gr(e){if(!e.name)throw Error("Artifact registry manifest requires a name");return e}function mr(e){if(!e.name)throw Error("Plugin distribution manifest requires a name");return e}class fr{id;priority;items;constructor(e,t,r){this.id=e;this.priority=t;this.items=r}get(e){return this.items[e]}}class yr{id;priority;items;constructor(e,t,r){this.id=e;this.priority=t;this.items=r}get(e){return this.items[e]}}async function Ve(e,t){let r=await fetch(e,t?{headers:t}:{});if(!r.ok)throw Error(`Failed to fetch ${e}: ${r.status} ${r.statusText}`);return await r.json()}async function Cr(e,t){let r=e.endsWith("/registry.json")?e:`${e.replace(/\/$/,"")}/registry.json`,n=await Ve(r,t);return gr(n)}async function br(e,t){let r=e.endsWith("/plugins.json")?e:`${e.replace(/\/$/,"")}/plugins.json`,n=await Ve(r,t);return mr(n)}class hr{options;id;priority;manifestPromise;constructor(e){this.options=e;this.id=e.id??e.registryUrl,this.priority=e.priority}getManifest(){return this.manifestPromise??=Cr(this.options.registryUrl,this.options.headers),this.manifestPromise}async get(e){return(await this.getManifest()).items.find((r)=>r.name===e)}}class Rr{options;id;priority;manifestPromise;constructor(e){this.options=e;this.id=e.id??e.registryUrl,this.priority=e.priority}getManifest(){return this.manifestPromise??=br(this.options.registryUrl,this.options.headers),this.manifestPromise}async get(e){return(await this.getManifest()).plugins.find((r)=>r.pluginId===e)}}class xr{sources;constructor(e){this.sources=e}async resolve(e){let t=[...this.sources].sort((r,n)=>r.priority-n.priority);for(let r of t){let n=await r.get(e);if(n)return n}return}}class kr{sources;constructor(e){this.sources=e}async resolve(e){let t=[...this.sources].sort((r,n)=>r.priority-n.priority);for(let r of t){let n=await r.get(e);if(n)return n}return}}var Pr="uibot.artifacts.lock.json";function Sr(e){return E(e,"components","registry")}function Ir(e){return E(e,"templates","registry")}function Ar(e,t){if(e.kind==="component")return E(t.componentsDir??Sr(t.workspaceRoot));return E(t.templatesDir??Ir(t.workspaceRoot))}function vr(e){return E(e.workspaceRoot,e.lockfilePath??Pr)}function wr(e){try{return JSON.parse(lr(e,"utf8"))}catch{return{version:1,artifacts:[]}}}function Er(e,t){Le(ue(e),{recursive:!0}),Ne(e,`${JSON.stringify(t,null,2)}
|
|
15
|
+
`,"utf8")}function Dr(e,t){return{version:1,artifacts:[...e.artifacts.filter((n)=>n.name!==t.name),t].sort((n,o)=>n.name.localeCompare(o.name))}}function Tr(e){if(e.kind==="component")return{components:{[e.name]:e.catalogEntry}};return{templates:{[e.name]:e.templateContract}}}class _ extends Error{artifactName;offendingPath;baseDir;constructor(e,t,r){super(`Artifact "${e}" file path escapes workspace: "${t}" resolves outside "${r}"`);this.artifactName=e;this.offendingPath=t;this.baseDir=r;this.name="ArtifactContainmentError"}}function Ue(e,t){let r=t.endsWith(_e)?t:t+_e;return e===t||e.startsWith(r)}function Be(e){let t=E(e),r=[];while(!0)try{return cr(t),E(dr(t),...r)}catch(n){if(n.code!=="ENOENT")throw n;let o=ue(t);if(o===t)throw n;r.unshift(ur(t)),t=o}}function je(e,t,r,n){try{let o=Be(t),a=Be(e);if(!Ue(a,o))throw new _(r,n,t)}catch(o){if(o instanceof _)throw o;throw new _(r,n,t)}}function $e(e,t,r){if(e.includes("\x00"))throw new _(r,e,t);if(pr(e))throw new _(r,e,t);let n=E(t,e);if(!Ue(n,t))throw new _(r,e,t);return je(n,t,r,e),n}function Or(e,t){let r=[];for(let n of e.files){let o=n.target??n.path;r.push($e(o,t,e.name))}return r}function gi(e,t){let r=E(t.workspaceRoot),n=Ar(e,t);je(n,r,e.name,n);let o=$e(e.name,n,e.name),a=Or(e,o),i=[];for(let y=0;y<e.files.length;y++){let u=e.files[y],s=a[y];Le(ue(s),{recursive:!0}),Ne(s,u.content??"","utf8"),i.push(s)}let l={name:e.name,version:e.version,source:t.source??"registry",installedAt:new Date().toISOString()},c=vr(t),d=wr(c),p=Dr(d,l);return Er(c,p),{artifactLock:l,catalogPatch:Tr(e),writtenFiles:i}}export{_ as ArtifactContainmentError,xr as ArtifactRegistryResolver,fr as MemoryArtifactRegistrySource,yr as MemoryPluginRegistrySource,kr as PluginRegistryResolver,Wo as RESOURCE_ADMISSION_ERROR_CODES,oe as RESOURCE_ADMISSION_SCHEMA_VERSION,Tt as RESOURCE_EXTERNAL_CHECKS,Xo as RESOURCE_INDEX_ERROR_CODES,Kt as RESOURCE_INDEX_SCHEMA_VERSION,Dt as RESOURCE_PREFLIGHT_CHECKS,rr as RESOURCE_QUERY_ALIAS_GROUPS,ai as RESOURCE_QUERY_ERROR_CODES,yt as RESOURCE_QUERY_OPERATION_MANIFEST,de as RESOURCE_QUERY_SCORE_WEIGHTS,hr as RemoteArtifactRegistrySource,Rr as RemotePluginRegistrySource,ke as ResourceAdmissionIndexMismatchError,Se as ResourceAdmissionReportNotDerivedError,Pe as ResourceAdmissionReportRejectedError,N as ResourceIndexError,O as ResourceQueryError,jo as SHADCN_REGISTRY_ITEM_SCHEMA,re as UIBOT_BASE_ITEM,Jo as applyResourceAdmissionReport,$e as assertPathContained,Go as assessResourceAdmissions,ei as buildExamplesFromL4Templates,ti as buildResourceIndex,Uo as buildShadcnRegistry,qr as buildUiBotRegistryManifest,St as catalogEntryToMeta,Lr as collectAllBlockSources,Xe as collectBlockSources,me as collectTemplateSources,st as collectTemplateSourcesFromDirs,ze as compareLockToManifest,ci as createResourceQueryService,qo as createUIBotRegistryHttpHandler,Ko as deriveResourceLicense,zr as emitArtifactJson,We as emptyLockfile,Yo as evaluateCatalogPreflight,se as expandResourceQueryAliases,Cr as fetchArtifactRegistryManifest,br as fetchPluginDistributionManifest,gi as installArtifactToWorkspace,Ke as lockfileWith,Et as normalizeRegistryBasePath,h as normalizeResourceAlias,M as normalizeResourceLicense,Vo as parseOklchCssVars,mr as parsePluginDistributionManifest,gr as parseRegistryManifest,we as resourceAdmissionIndexFingerprint,X as templateSourceToRegistryItem,ye as toArtifactRegistryItem,pt as toComponentArtifact,ne as toItemName,v as toResourceId,fe as toTemplateArtifact,he as transformBlockSource};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CatalogEntry, DesignMd, ResourceDescriptor, ResourceKind, TemplateContract } from "@uibot/contracts";
|
|
2
|
+
export declare const RESOURCE_INDEX_SCHEMA_VERSION: "uibot.resource.index.v1";
|
|
3
|
+
export declare const RESOURCE_INDEX_ERROR_CODES: readonly ["invalid-resource-source-id", "duplicate-resource-id", "dangling-resource-dependency", "ambiguous-resource-dependency"];
|
|
4
|
+
export type ResourceIndexErrorCode = (typeof RESOURCE_INDEX_ERROR_CODES)[number];
|
|
5
|
+
export declare class ResourceIndexError extends Error {
|
|
6
|
+
readonly code: ResourceIndexErrorCode;
|
|
7
|
+
readonly detail: string;
|
|
8
|
+
constructor(code: ResourceIndexErrorCode, detail: string);
|
|
9
|
+
}
|
|
10
|
+
export interface ResourceExampleDescriptor {
|
|
11
|
+
id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
description: string;
|
|
14
|
+
category?: string;
|
|
15
|
+
tags?: string[];
|
|
16
|
+
aliases?: string[];
|
|
17
|
+
capabilities?: string[];
|
|
18
|
+
dependencies?: string[];
|
|
19
|
+
version?: string;
|
|
20
|
+
sourceUrl?: string;
|
|
21
|
+
license?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ResourceSkillDescriptor {
|
|
24
|
+
id: string;
|
|
25
|
+
title: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
tags?: string[];
|
|
28
|
+
triggers?: string[];
|
|
29
|
+
version?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface BuildResourceIndexInput {
|
|
32
|
+
components?: Record<string, CatalogEntry>;
|
|
33
|
+
templates?: Record<string, TemplateContract>;
|
|
34
|
+
designGuides?: DesignMd[];
|
|
35
|
+
examples?: ResourceExampleDescriptor[];
|
|
36
|
+
skills?: ResourceSkillDescriptor[];
|
|
37
|
+
licenses?: Readonly<Record<string, string>>;
|
|
38
|
+
}
|
|
39
|
+
export interface ResourceIndex {
|
|
40
|
+
schemaVersion: typeof RESOURCE_INDEX_SCHEMA_VERSION;
|
|
41
|
+
resources: readonly ResourceDescriptor[];
|
|
42
|
+
aliases: Readonly<Record<string, readonly string[]>>;
|
|
43
|
+
}
|
|
44
|
+
export declare function normalizeResourceAlias(value: string): string;
|
|
45
|
+
export declare function toResourceId(kind: ResourceKind, sourceId: string): string;
|
|
46
|
+
/** Derive L4 page templates as searchable example resources. */
|
|
47
|
+
export declare function buildExamplesFromL4Templates(templates: Readonly<Record<string, TemplateContract>>): ResourceExampleDescriptor[];
|
|
48
|
+
export declare function buildResourceIndex(input: BuildResourceIndexInput): ResourceIndex;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ResourceBuildPlan, ResourceDescriptor, ResourceMatch, ResourceQuery } from "@uibot/contracts";
|
|
2
|
+
import { type ResourceIndex } from "./resource-index.js";
|
|
3
|
+
export { RESOURCE_QUERY_OPERATION_MANIFEST } from "@uibot/contracts";
|
|
4
|
+
export type { ResourceQueryArgumentValueType, ResourceQueryOperationName, ResourceQueryOptionManifest, ResourceQueryPositionManifest, } from "@uibot/contracts";
|
|
5
|
+
export declare const RESOURCE_QUERY_ERROR_CODES: readonly ["resource-query-empty", "resource-query-invalid-limit", "resource-not-found", "resource-alias-ambiguous"];
|
|
6
|
+
export type ResourceQueryErrorCode = (typeof RESOURCE_QUERY_ERROR_CODES)[number];
|
|
7
|
+
export declare class ResourceQueryError extends Error {
|
|
8
|
+
readonly code: ResourceQueryErrorCode;
|
|
9
|
+
readonly detail: string;
|
|
10
|
+
constructor(code: ResourceQueryErrorCode, detail: string);
|
|
11
|
+
}
|
|
12
|
+
export declare const RESOURCE_QUERY_SCORE_WEIGHTS: Readonly<{
|
|
13
|
+
"exact-id": number;
|
|
14
|
+
"exact-title": number;
|
|
15
|
+
alias: number;
|
|
16
|
+
tag: number;
|
|
17
|
+
capability: number;
|
|
18
|
+
category: number;
|
|
19
|
+
token: number;
|
|
20
|
+
fuzzy: number;
|
|
21
|
+
}>;
|
|
22
|
+
export interface ResourceQueryService {
|
|
23
|
+
manifest(): ResourceIndex;
|
|
24
|
+
search(query: ResourceQuery): ResourceMatch[];
|
|
25
|
+
get(idOrAlias: string): ResourceDescriptor;
|
|
26
|
+
build(roots: readonly string[]): ResourceBuildPlan;
|
|
27
|
+
}
|
|
28
|
+
export declare function createResourceQueryService(index: ResourceIndex): ResourceQueryService;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type CatalogEntry, type ResourceMaturity, type ResourceReceiptCheck, type ResourceReceiptStatus, type ResourceReceiptSummary } from "@uibot/contracts";
|
|
2
|
+
import type { ResourceIndex } from "./resource-index.js";
|
|
3
|
+
export declare const RESOURCE_ADMISSION_SCHEMA_VERSION: "uibot.resource.admission.v1";
|
|
4
|
+
export declare const RESOURCE_PREFLIGHT_CHECKS: readonly ["source", "license", "contract", "states", "accessibility", "light-theme", "dark-theme", "responsive", "dependency-closure"];
|
|
5
|
+
export declare const RESOURCE_EXTERNAL_CHECKS: readonly ["packed-install", "typecheck", "browser"];
|
|
6
|
+
export declare const RESOURCE_ADMISSION_ERROR_CODES: readonly ["invalid-admission-manifest", "invalid-admission-record", "invalid-admission-check", "duplicate-admission-record", "unknown-admission-resource", "missing-source-metadata", "missing-license-metadata", "dependency-closure-failed"];
|
|
7
|
+
export type ResourceAdmissionErrorCode = (typeof RESOURCE_ADMISSION_ERROR_CODES)[number];
|
|
8
|
+
export type ResourceAdmissionEvidenceStatus = Exclude<ResourceReceiptStatus, "missing">;
|
|
9
|
+
export interface ResourceAdmissionCheckEvidence {
|
|
10
|
+
status: ResourceAdmissionEvidenceStatus;
|
|
11
|
+
evidence: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface ResourceAdmissionProvenance {
|
|
14
|
+
source?: string;
|
|
15
|
+
version?: string;
|
|
16
|
+
license?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Evidence input deliberately has no maturity field. Maturity is derived from
|
|
20
|
+
* the normalized check matrix and cannot be promoted by an author assertion.
|
|
21
|
+
*/
|
|
22
|
+
export interface ResourceAdmissionRecord {
|
|
23
|
+
resourceId: string;
|
|
24
|
+
provenance?: ResourceAdmissionProvenance;
|
|
25
|
+
checks: Partial<Record<ResourceReceiptCheck, ResourceAdmissionCheckEvidence>>;
|
|
26
|
+
}
|
|
27
|
+
export interface ResourceAdmissionManifest {
|
|
28
|
+
schemaVersion: typeof RESOURCE_ADMISSION_SCHEMA_VERSION;
|
|
29
|
+
records: ResourceAdmissionRecord[];
|
|
30
|
+
}
|
|
31
|
+
export interface ResourceAdmissionIssue {
|
|
32
|
+
code: ResourceAdmissionErrorCode;
|
|
33
|
+
resourceId?: string;
|
|
34
|
+
check?: ResourceReceiptCheck;
|
|
35
|
+
detail: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ResourceAdmissionAssessment {
|
|
38
|
+
resourceId: string;
|
|
39
|
+
receipt: ResourceReceiptSummary;
|
|
40
|
+
issues: readonly ResourceAdmissionIssue[];
|
|
41
|
+
}
|
|
42
|
+
export interface ResourceAdmissionReport {
|
|
43
|
+
schemaVersion: typeof RESOURCE_ADMISSION_SCHEMA_VERSION;
|
|
44
|
+
indexFingerprint: string;
|
|
45
|
+
resources: readonly ResourceAdmissionAssessment[];
|
|
46
|
+
counts: Readonly<Record<ResourceMaturity, number>>;
|
|
47
|
+
issues: readonly ResourceAdmissionIssue[];
|
|
48
|
+
}
|
|
49
|
+
export declare class ResourceAdmissionIndexMismatchError extends Error {
|
|
50
|
+
readonly expected: string;
|
|
51
|
+
readonly actual: string;
|
|
52
|
+
readonly code: "resource-admission-index-mismatch";
|
|
53
|
+
constructor(expected: string, actual: string);
|
|
54
|
+
}
|
|
55
|
+
export declare class ResourceAdmissionReportRejectedError extends Error {
|
|
56
|
+
readonly issueCount: number;
|
|
57
|
+
readonly code: "resource-admission-report-rejected";
|
|
58
|
+
constructor(issueCount: number);
|
|
59
|
+
}
|
|
60
|
+
export declare class ResourceAdmissionReportNotDerivedError extends Error {
|
|
61
|
+
readonly code: "resource-admission-report-not-derived";
|
|
62
|
+
constructor();
|
|
63
|
+
}
|
|
64
|
+
export declare function normalizeResourceLicense(value: string | undefined): string | undefined;
|
|
65
|
+
export interface ResourceLicenseSources {
|
|
66
|
+
packageJsonLicense?: string;
|
|
67
|
+
licenseFileText?: string;
|
|
68
|
+
frontmatterLicense?: string;
|
|
69
|
+
noticesText?: string;
|
|
70
|
+
}
|
|
71
|
+
export declare function deriveResourceLicense(sources: ResourceLicenseSources): string | undefined;
|
|
72
|
+
export declare function evaluateCatalogPreflight(entry: CatalogEntry, extras?: {
|
|
73
|
+
sourceText?: string;
|
|
74
|
+
stylesText?: string;
|
|
75
|
+
}): Pick<Record<ResourceReceiptCheck, ResourceReceiptStatus>, "contract" | "states" | "accessibility" | "light-theme" | "dark-theme" | "responsive">;
|
|
76
|
+
export declare function resourceAdmissionIndexFingerprint(index: ResourceIndex): string;
|
|
77
|
+
export declare function assessResourceAdmissions(index: ResourceIndex, input: unknown): ResourceAdmissionReport;
|
|
78
|
+
/**
|
|
79
|
+
* Return a new immutable index carrying only receipts derived by
|
|
80
|
+
* assessResourceAdmissions. Resource ids, ordering and aliases remain byte-for-
|
|
81
|
+
* byte equivalent; callers still own manifest loading and evidence-path I/O.
|
|
82
|
+
*/
|
|
83
|
+
export declare function applyResourceAdmissionReport(index: ResourceIndex, report: ResourceAdmissionReport): ResourceIndex;
|
package/dist/shadcn.d.ts
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shadcn-style registry emitter (Phase 4 / Part2a).
|
|
3
|
+
*
|
|
4
|
+
* Produces a [shadcn registry](https://ui.shadcn.com/docs/registry/getting-started)
|
|
5
|
+
* from the neutral {@link BlockSource}[] that {@link collectBlockSources}
|
|
6
|
+
* yields — the **same** source set the uibot-native emitter (`./emit`)
|
|
7
|
+
* consumes, so the block set is never re-scanned.
|
|
8
|
+
*
|
|
9
|
+
* Two artefacts are produced:
|
|
10
|
+
* - a top-level `registry.json` ({@link ShadcnRegistry}) with an `items[]`
|
|
11
|
+
* summary (no file content); and
|
|
12
|
+
* - one registry-item JSON per block ({@link ShadcnRegistryItem}) carrying the
|
|
13
|
+
* transformed, self-contained source under `files[].content`.
|
|
14
|
+
*
|
|
15
|
+
* ## The dependency problem
|
|
16
|
+
*
|
|
17
|
+
* UIBot blocks are not standard prop components — they are
|
|
18
|
+
* `(props, ctx) => JSX` renderer adapters that `import type { RendererComponent }
|
|
19
|
+
* from "@uibot/renderer-react"` (type-only, zero runtime cost). We do **not**
|
|
20
|
+
* want consumers to install `@uibot/renderer-react` (it drags in the compiler
|
|
21
|
+
* and contracts). Instead every block item declares `registryDependencies:
|
|
22
|
+
* ["uibot-base"]`, and a single shared `uibot-base` item ships a self-contained
|
|
23
|
+
* `lib/uibot-renderer.ts` shim (+ `lib/utils.ts` `cn`). {@link transformBlockSource}
|
|
24
|
+
* rewrites the `@uibot/renderer-react` import to point at that shim, so each
|
|
25
|
+
* emitted source file compiles standalone. `shadcn add card.json` then pulls
|
|
26
|
+
* `uibot-base` automatically.
|
|
27
|
+
*
|
|
28
|
+
* ## Spec awareness (ADR 0012)
|
|
29
|
+
*
|
|
30
|
+
* Every component item also carries a {@link UIBotRegistryItemDescriptor}
|
|
31
|
+
* (`meta.uibot` plus an installed `<item>.uibot.json`) that binds each Spec
|
|
32
|
+
* component type to its export and full catalog entry, so a host can rebuild
|
|
33
|
+
* its Spec catalog from what it installed. Template items ship a Spec YAML whose
|
|
34
|
+
* `registryDependencies` are the component items its `composedFrom` resolves
|
|
35
|
+
* to — the same graph gap recovery uses at runtime.
|
|
36
|
+
*
|
|
37
|
+
* Same-registry dependencies are written as namespaced (`@uibot/uibot-base`) or
|
|
38
|
+
* absolute URLs: a bare name would resolve against the official shadcn registry.
|
|
39
|
+
*/
|
|
40
|
+
import { type CatalogEntry, type UIBotRegistryChannel } from "@uibot/contracts";
|
|
41
|
+
import type { BlockSource } from "./block-source.js";
|
|
42
|
+
import type { TemplateSource } from "./template-source.js";
|
|
43
|
+
/** shadcn registry-item file descriptor. */
|
|
44
|
+
export interface ShadcnRegistryFile {
|
|
45
|
+
/** Target path inside the consumer project, e.g. `components/uibot/card.tsx`. */
|
|
46
|
+
path: string;
|
|
47
|
+
/** Verbatim source written to `path`. */
|
|
48
|
+
content: string;
|
|
49
|
+
/** shadcn file type. */
|
|
50
|
+
type: "registry:ui" | "registry:lib";
|
|
51
|
+
/** Optional explicit install target (defaults to `path`). */
|
|
52
|
+
target?: string;
|
|
53
|
+
}
|
|
54
|
+
/** Light/dark OKLCH variable sets parsed from the studio stylesheet. */
|
|
55
|
+
export interface ShadcnCssVars {
|
|
56
|
+
light: Record<string, string>;
|
|
57
|
+
dark: Record<string, string>;
|
|
58
|
+
}
|
|
59
|
+
/** A single shadcn registry item — the value served at `/r/{name}.json`. */
|
|
60
|
+
export interface ShadcnRegistryItem {
|
|
61
|
+
/** kebab-case item name, e.g. `card`, `form-input`, `uibot-base`. */
|
|
62
|
+
name: string;
|
|
63
|
+
/**
|
|
64
|
+
* shadcn item type. UI blocks are `registry:ui`, the shared shim is
|
|
65
|
+
* `registry:lib`, Spec templates are `registry:block`.
|
|
66
|
+
*/
|
|
67
|
+
type: "registry:ui" | "registry:lib" | "registry:block";
|
|
68
|
+
description?: string;
|
|
69
|
+
/** External npm dependencies (e.g. `clsx`, `tailwind-merge`). */
|
|
70
|
+
dependencies?: string[];
|
|
71
|
+
/** Same-registry items pulled transitively (e.g. `["uibot-base"]`). */
|
|
72
|
+
registryDependencies?: string[];
|
|
73
|
+
files: ShadcnRegistryFile[];
|
|
74
|
+
/** OKLCH theme variables merged into the consumer's global stylesheet. */
|
|
75
|
+
cssVars?: ShadcnCssVars;
|
|
76
|
+
/** UIBot catalog metadata surfaced for docs / future AI reverse-consumption. */
|
|
77
|
+
meta?: Record<string, unknown>;
|
|
78
|
+
}
|
|
79
|
+
/** Top-level `registry.json` manifest (summary only — no file content). */
|
|
80
|
+
export interface ShadcnRegistryItemSummary {
|
|
81
|
+
name: string;
|
|
82
|
+
type: ShadcnRegistryItem["type"];
|
|
83
|
+
description?: string;
|
|
84
|
+
registryDependencies?: string[];
|
|
85
|
+
dependencies?: string[];
|
|
86
|
+
}
|
|
87
|
+
export interface ShadcnRegistry {
|
|
88
|
+
$schema: string;
|
|
89
|
+
name: string;
|
|
90
|
+
homepage?: string;
|
|
91
|
+
items: ShadcnRegistryItemSummary[];
|
|
92
|
+
}
|
|
93
|
+
/** Options for {@link buildShadcnRegistry}. */
|
|
94
|
+
export interface BuildShadcnRegistryOptions {
|
|
95
|
+
/** Registry name, e.g. `"uibot"`. */
|
|
96
|
+
registryName: string;
|
|
97
|
+
homepage?: string;
|
|
98
|
+
/** OKLCH theme vars (attached to the shared `uibot-base` item). */
|
|
99
|
+
cssVars?: ShadcnCssVars;
|
|
100
|
+
/**
|
|
101
|
+
* npm deps shared by every block (the `cn` util needs these). Defaults to
|
|
102
|
+
* `["clsx", "tailwind-merge"]`.
|
|
103
|
+
*/
|
|
104
|
+
sharedDependencies?: string[];
|
|
105
|
+
/** Body of the bundled `lib/uibot-renderer.ts` shim (RendererComponent types). */
|
|
106
|
+
rendererShimContent: string;
|
|
107
|
+
/** Body of the bundled `lib/utils.ts` `cn` helper. */
|
|
108
|
+
cnUtilContent: string;
|
|
109
|
+
/**
|
|
110
|
+
* Body of the bundled `lib/uibot-contracts.ts` type shim (`ActionChain` etc.).
|
|
111
|
+
* Optional — supply it when the source set includes blocks that import
|
|
112
|
+
* `@uibot/contracts` types (the studio block set does; the shadcn set does
|
|
113
|
+
* not). When provided, it is added to the shared `uibot-base` item and the
|
|
114
|
+
* `@uibot/contracts` import in each block is rewritten to point at it.
|
|
115
|
+
*/
|
|
116
|
+
contractsShimContent?: string;
|
|
117
|
+
/** Directory (relative to consumer root) blocks install into. Default `components/uibot`. */
|
|
118
|
+
componentsDir?: string;
|
|
119
|
+
/** Directory (relative to consumer root) shared libs install into. Default `lib`. */
|
|
120
|
+
libDir?: string;
|
|
121
|
+
/**
|
|
122
|
+
* How same-registry dependencies are referenced. Defaults to the namespace
|
|
123
|
+
* `@uibot` (`@uibot/uibot-base`); the consumer maps it in `components.json`
|
|
124
|
+
* `registries`. Pass `baseUrl` to emit absolute `<baseUrl>/r/<name>.json`
|
|
125
|
+
* references instead, which need no consumer configuration.
|
|
126
|
+
*/
|
|
127
|
+
namespace?: string;
|
|
128
|
+
baseUrl?: string;
|
|
129
|
+
/** Channel to emit. Items whose source declares another channel are left out. Default `public`. */
|
|
130
|
+
channel?: UIBotRegistryChannel;
|
|
131
|
+
/** Spec templates to emit as `registry:block` items (see {@link buildShadcnRegistry}). */
|
|
132
|
+
templates?: TemplateSource[];
|
|
133
|
+
}
|
|
134
|
+
export interface BuildShadcnRegistryResult {
|
|
135
|
+
/** The top-level `registry.json`. */
|
|
136
|
+
registry: ShadcnRegistry;
|
|
137
|
+
/** `name` → registry-item JSON (served at `/r/{name}.json`). */
|
|
138
|
+
items: Record<string, ShadcnRegistryItem>;
|
|
139
|
+
/** Template name → `composedFrom` types no emitted component item provides. */
|
|
140
|
+
unresolvedTemplateTypes: Record<string, string[]>;
|
|
141
|
+
}
|
|
142
|
+
/** The shared base item name every block depends on. */
|
|
143
|
+
export declare const UIBOT_BASE_ITEM = "uibot-base";
|
|
144
|
+
/**
|
|
145
|
+
* Convert a block name (`"Form.Input"`, `"Button"`) into a kebab-case
|
|
146
|
+
* registry-item / file slug (`"form-input"`, `"button"`).
|
|
147
|
+
*/
|
|
148
|
+
export declare function toItemName(blockName: string): string;
|
|
149
|
+
/**
|
|
150
|
+
* Rewrite a block's raw `.tsx` so it compiles standalone in a consumer app:
|
|
151
|
+
* 1. the type-only `import ... from "@uibot/renderer-react"` is repointed at
|
|
152
|
+
* the bundled `uibot-base` shim ({@link opts.rendererShimImport});
|
|
153
|
+
* 2. a local `cn` definition (if the block carries one) is stripped and an
|
|
154
|
+
* import of the shared `lib/utils` `cn` is injected, so all blocks share
|
|
155
|
+
* one battle-tested merger instead of N divergent inline copies;
|
|
156
|
+
* 3. references to the global `React.<Type>` namespace (e.g. `React.ReactNode`)
|
|
157
|
+
* are rewritten to bare named types (`ReactNode`) and a single merged
|
|
158
|
+
* `import type { … } from "react"` is injected, so the emitted file compiles
|
|
159
|
+
* in a consumer project that does not enable the legacy global `React`
|
|
160
|
+
* namespace (the registry-item declares a `react` dependency to match);
|
|
161
|
+
* 4. all other imports (React runtime, etc.) are preserved verbatim.
|
|
162
|
+
*/
|
|
163
|
+
export declare function transformBlockSource(source: BlockSource, opts: {
|
|
164
|
+
rendererShimImport: string;
|
|
165
|
+
cnUtilImport: string;
|
|
166
|
+
contractsShimImport?: string;
|
|
167
|
+
}): string;
|
|
168
|
+
/** Project a {@link CatalogEntry} into the item `meta` block surfaced for docs. */
|
|
169
|
+
export declare function catalogEntryToMeta(entry: CatalogEntry): Record<string, unknown>;
|
|
170
|
+
/**
|
|
171
|
+
* Parse the OKLCH design-token variables out of a stylesheet's `:root` and
|
|
172
|
+
* `.dark` rule blocks into shadcn `cssVars` { light, dark } maps.
|
|
173
|
+
*
|
|
174
|
+
* Tolerant of:
|
|
175
|
+
* - the rule block being nested (e.g. inside `@layer base { :root { … } }`),
|
|
176
|
+
* - arbitrary indentation, and
|
|
177
|
+
* - inline `/* … *\/` comments between declarations.
|
|
178
|
+
*
|
|
179
|
+
* Leading `--` is stripped from each key; values are preserved verbatim
|
|
180
|
+
* (e.g. `oklch(1 0 0)`, `0.5rem`). When neither block is found the maps are
|
|
181
|
+
* empty — callers may treat that as a warning.
|
|
182
|
+
*/
|
|
183
|
+
export declare function parseOklchCssVars(css: string): ShadcnCssVars;
|
|
184
|
+
/**
|
|
185
|
+
* Build the shadcn registry (top-level manifest + per-item JSON) from a neutral
|
|
186
|
+
* {@link BlockSource}[]. Emits one `registry:ui` item per block plus a single
|
|
187
|
+
* shared `uibot-base` (`registry:lib`) item carrying the renderer shim, the `cn`
|
|
188
|
+
* util, and the OKLCH theme vars.
|
|
189
|
+
*/
|
|
190
|
+
export declare function buildShadcnRegistry(sources: BlockSource[], opts: BuildShadcnRegistryOptions): BuildShadcnRegistryResult;
|
|
191
|
+
/**
|
|
192
|
+
* `$schema` constant for an individual registry-item file. Exposed so the build
|
|
193
|
+
* script can stamp it when writing `/r/{name}.json`.
|
|
194
|
+
*/
|
|
195
|
+
export declare const SHADCN_REGISTRY_ITEM_SCHEMA = "https://ui.shadcn.com/schema/registry-item.json";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collect TemplateArtifact sources from on-disk YAML templates (v2.28 SC-4).
|
|
3
|
+
* Native registry only — shadcn channel does not distribute templates.
|
|
4
|
+
*/
|
|
5
|
+
import type { UIBotRegistryChannel, TemplateArtifact, TemplateContract } from "@uibot/contracts";
|
|
6
|
+
export interface TemplateSource {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
title: string;
|
|
10
|
+
description: string;
|
|
11
|
+
yaml: string;
|
|
12
|
+
absolutePath: string;
|
|
13
|
+
templateContract: TemplateContract;
|
|
14
|
+
/** Distribution channel for the shadcn registry (ADR 0012). Defaults to `public`. */
|
|
15
|
+
channel?: UIBotRegistryChannel;
|
|
16
|
+
}
|
|
17
|
+
export interface CollectTemplateSourcesOptions {
|
|
18
|
+
/** Directory containing `*.yaml` / `*.yml` template specs. */
|
|
19
|
+
dir: string;
|
|
20
|
+
defaultVersion?: string;
|
|
21
|
+
defaultLevel?: TemplateContract["level"];
|
|
22
|
+
defaultCategory?: TemplateContract["category"];
|
|
23
|
+
extraKeywords?: readonly string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Scan a directory for template YAML files and return neutral sources.
|
|
27
|
+
* Non-yaml / README files are skipped. Empty files are skipped.
|
|
28
|
+
*/
|
|
29
|
+
export declare function collectTemplateSources(options: CollectTemplateSourcesOptions): TemplateSource[];
|
|
30
|
+
/** Merge several authoring directories. Duplicate `name` values fail closed. */
|
|
31
|
+
export declare function collectTemplateSourcesFromDirs(dirs: readonly CollectTemplateSourcesOptions[]): TemplateSource[];
|
|
32
|
+
export declare function toTemplateArtifact(source: TemplateSource): TemplateArtifact;
|
|
33
|
+
export declare function templateSourceToRegistryItem(source: TemplateSource): {
|
|
34
|
+
name: string;
|
|
35
|
+
kind: "template";
|
|
36
|
+
title: string;
|
|
37
|
+
description: string;
|
|
38
|
+
artifact: TemplateArtifact;
|
|
39
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uibot/registry",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Foundj/uibot.git",
|
|
8
|
+
"directory": "packages/registry"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"!dist/**/*.map",
|
|
23
|
+
"!dist/**/*.test.d.ts",
|
|
24
|
+
"!dist/**/*.spec.d.ts"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@uibot/contracts": "^0.2.0"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "rm -rf dist tsconfig.tsbuildinfo && bun build --minify ./src/index.ts --outdir ./dist --format esm --target bun && bun x tsc -b",
|
|
34
|
+
"typecheck": "bun x tsc -p tsconfig.json --noEmit",
|
|
35
|
+
"test": "bun test"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/README.md
DELETED