buntic 0.0.0-stage → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +135 -2
- package/dist/assets/cache.d.ts +10 -0
- package/dist/assets/image-processor.d.ts +39 -0
- package/dist/assets/photo-tag.d.ts +19 -0
- package/dist/builder/builder.d.ts +28 -0
- package/dist/builder/collisions.d.ts +10 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +4205 -0
- package/dist/config.d.ts +11 -0
- package/dist/env.d.ts +18 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +5060 -0
- package/dist/init.d.ts +15 -0
- package/dist/router/routes.d.ts +48 -0
- package/dist/runtime.d.ts +23 -0
- package/dist/seo/feeds.d.ts +11 -0
- package/dist/seo/metadata.d.ts +33 -0
- package/dist/seo/robots.d.ts +2 -0
- package/dist/seo/sitemap.d.ts +2 -0
- package/dist/server/dev-helpers.d.ts +29 -0
- package/dist/server/dev.d.ts +8 -0
- package/dist/storage/loader.d.ts +17 -0
- package/dist/storage/oras/adapter.d.ts +17 -0
- package/dist/storage/oras/auth.d.ts +46 -0
- package/dist/storage/oras/client.d.ts +83 -0
- package/dist/storage/oras/index.d.ts +6 -0
- package/dist/storage/oras/manifests.d.ts +42 -0
- package/dist/storage/oras/reference.d.ts +15 -0
- package/dist/storage/oras/types.d.ts +161 -0
- package/dist/template/css-graph.d.ts +49 -0
- package/dist/template/css-resolver.d.ts +19 -0
- package/dist/template/css-scoper.d.ts +12 -0
- package/dist/template/data-loader.d.ts +8 -0
- package/dist/template/directives.d.ts +13 -0
- package/dist/template/dsd-renderer.d.ts +23 -0
- package/dist/template/engine.d.ts +39 -0
- package/dist/template/html-scanner.d.ts +37 -0
- package/dist/template/scoped-css.d.ts +30 -0
- package/dist/template/svg-component.d.ts +32 -0
- package/dist/template/vfs.d.ts +57 -0
- package/dist/template/web-components.d.ts +91 -0
- package/dist/types.d.ts +152 -0
- package/dist/utils/html.d.ts +23 -0
- package/dist/utils/logger.d.ts +6 -0
- package/dist/utils/paths.d.ts +20 -0
- package/package.json +54 -4
- package/templates/blank/_gitignore +5 -0
- package/templates/blank/buntic.config.ts +15 -0
- package/templates/blank/src/layouts/main.html +14 -0
- package/templates/blank/src/pages/index.html +11 -0
- package/templates/blank/src/public/robots.txt +2 -0
- package/templates/blank/src/styles/main.css +40 -0
- package/templates/blank/tsconfig.json +21 -0
- package/templates/simple/README.md +35 -0
- package/templates/simple/_gitignore +5 -0
- package/templates/simple/buntic.config.ts +11 -0
- package/templates/simple/src/components/card.css +27 -0
- package/templates/simple/src/components/card.html +7 -0
- package/templates/simple/src/components/footer.css +14 -0
- package/templates/simple/src/components/footer.html +5 -0
- package/templates/simple/src/components/header.css +33 -0
- package/templates/simple/src/components/header.html +10 -0
- package/templates/simple/src/data/features.json +14 -0
- package/templates/simple/src/data/site.json +11 -0
- package/templates/simple/src/layouts/main.html +17 -0
- package/templates/simple/src/pages/about.html +16 -0
- package/templates/simple/src/pages/contact.html +13 -0
- package/templates/simple/src/pages/index.html +17 -0
- package/templates/simple/src/public/robots.txt +2 -0
- package/templates/simple/src/styles/main.css +67 -0
- package/templates/simple/tsconfig.json +21 -0
- package/templates/skills/buntic/SKILL.md +359 -0
- package/templates/skills/buntic/examples/README.md +177 -0
package/dist/init.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const AVAILABLE_TEMPLATES: readonly ["blank", "simple"];
|
|
2
|
+
export type TemplateName = (typeof AVAILABLE_TEMPLATES)[number];
|
|
3
|
+
export interface InitProjectOptions {
|
|
4
|
+
targetDir?: string;
|
|
5
|
+
template?: string;
|
|
6
|
+
includeSkills?: boolean;
|
|
7
|
+
force?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface InitProjectResult {
|
|
10
|
+
targetDir: string;
|
|
11
|
+
template: TemplateName;
|
|
12
|
+
skillsDir: string | null;
|
|
13
|
+
filesCopied: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function initProject(options?: InitProjectOptions): InitProjectResult;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { FeedItem, PageRouteInfo, PageSeo, PaginateOptions, ResolvedConfig, StaticPathResult } from "../types.js";
|
|
2
|
+
export interface StaticLoaderResult {
|
|
3
|
+
props: Record<string, unknown>;
|
|
4
|
+
seo?: PageSeo;
|
|
5
|
+
feed?: FeedItem;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Extracts parameter tokens from a route path, e.g. "blog/[slug].html" -> ["slug"]
|
|
9
|
+
*/
|
|
10
|
+
export declare function extractRouteTokens(routePattern: string): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Checks whether a relative path contains dynamic parameter brackets.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isDynamicPattern(routePattern: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Finds a co-located data loader (.data.ts, .data.js, .data.mjs) for a given template file.
|
|
17
|
+
*/
|
|
18
|
+
export declare function findCoLocatedLoader(templateFilePath: string): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Executes a co-located static page data loader (`.data.ts` / `.data.js`) and normalizes
|
|
21
|
+
* `{ props, seo, feed }` or plain object returns.
|
|
22
|
+
*/
|
|
23
|
+
export declare function executeStaticLoader(loaderPath: string, globalData: Record<string, unknown>, options?: {
|
|
24
|
+
cacheBust?: boolean;
|
|
25
|
+
}): Promise<StaticLoaderResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a declarative pagination helper for a given base route URL.
|
|
28
|
+
* Automatically handles page 1 omission for canonical clean URLs.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createPaginator(baseRouteUrl: string): <T = unknown>(items: T[], options?: PaginateOptions) => StaticPathResult[];
|
|
31
|
+
/**
|
|
32
|
+
* Validates route parameters: ensures they exist, are non-empty, and URL-safe.
|
|
33
|
+
*/
|
|
34
|
+
export declare function validateRouteParams(requiredTokens: string[], params: Record<string, unknown>, loaderPath: string): Record<string, string>;
|
|
35
|
+
/**
|
|
36
|
+
* Builds a clean URL path and relative output file path from a template pattern and parameters.
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildCleanUrl(patternRelPath: string, params: Record<string, string>): {
|
|
39
|
+
urlPath: string;
|
|
40
|
+
relOutputPath: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Resolves all routes (static and dynamic) in a Buntic project.
|
|
44
|
+
* Enforces co-located loaders, executes them, validates parameters, and prevents URL collisions.
|
|
45
|
+
*/
|
|
46
|
+
export declare function resolveAllRoutes(config: ResolvedConfig, globalData: Record<string, unknown>, options?: {
|
|
47
|
+
cacheBust?: boolean;
|
|
48
|
+
}): Promise<PageRouteInfo[]>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves the root directory of the installed/running buntic package.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getPackageRoot(): string;
|
|
5
|
+
/**
|
|
6
|
+
* Returns the runtime entry point for the currently running buntic package.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSelfEntryPath(): string;
|
|
9
|
+
/**
|
|
10
|
+
* Checks whether a project directory (or any ancestor) has a local node_modules/buntic installation.
|
|
11
|
+
*/
|
|
12
|
+
export declare function hasLocalBunticPackage(startDir: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Registers a runtime Bun.plugin so projects without package.json / node_modules
|
|
15
|
+
* can import from "buntic" (e.g. buntic.config.ts, storage/*.ts) when executed
|
|
16
|
+
* via a globally installed buntic CLI.
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerBunticModuleResolver(projectDir?: string): void;
|
|
19
|
+
/**
|
|
20
|
+
* Copies Buntic's .d.ts declarations into .buntic/types/ so TypeScript / VS Code
|
|
21
|
+
* provides full autocomplete and type checking in zero-package.json projects via tsconfig paths.
|
|
22
|
+
*/
|
|
23
|
+
export declare function syncProjectTypes(projectRoot: string): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PageRouteInfo, ResolvedConfig } from "../types.js";
|
|
2
|
+
export interface ResolvedFeedEntry {
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
date: Date;
|
|
6
|
+
author?: string;
|
|
7
|
+
url: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function extractFeedEntries(routes: PageRouteInfo[], config: ResolvedConfig): ResolvedFeedEntry[];
|
|
10
|
+
export declare function generateRss2Xml(routes: PageRouteInfo[], config: ResolvedConfig): string | null;
|
|
11
|
+
export declare function generateAtomXml(routes: PageRouteInfo[], config: ResolvedConfig): string | null;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ResolvedConfig, PageSeo } from "../types.js";
|
|
2
|
+
import { ImageProcessor } from "../assets/image-processor.js";
|
|
3
|
+
import { StorageManager } from "../storage/loader.js";
|
|
4
|
+
import type { EmittedAsset } from "../assets/photo-tag.js";
|
|
5
|
+
export interface HeadSeoData {
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
image?: string;
|
|
9
|
+
imageWidth?: number;
|
|
10
|
+
imageHeight?: number;
|
|
11
|
+
url?: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
twitterCard?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class SeoMetadataEngine {
|
|
16
|
+
private config;
|
|
17
|
+
private imageProcessor;
|
|
18
|
+
private storageManager;
|
|
19
|
+
emittedAssets: Map<string, EmittedAsset>;
|
|
20
|
+
constructor(config: ResolvedConfig, imageProcessor?: ImageProcessor, storageManager?: StorageManager);
|
|
21
|
+
parseSeoTag(html: string): {
|
|
22
|
+
seo: PageSeo | null;
|
|
23
|
+
cleanHtml: string;
|
|
24
|
+
};
|
|
25
|
+
processSeo(html: string, options: {
|
|
26
|
+
templatePath: string;
|
|
27
|
+
urlPath: string;
|
|
28
|
+
routeSeo?: PageSeo;
|
|
29
|
+
}): Promise<string>;
|
|
30
|
+
private emitSocialVariant;
|
|
31
|
+
private resolveAndProcessSocialImage;
|
|
32
|
+
private generateMetaTagsHtml;
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PageRouteInfo, PageSeo, ResolvedConfig } from "../types.js";
|
|
2
|
+
import type { PhotoProcessor } from "../assets/photo-tag.js";
|
|
3
|
+
import type { SeoMetadataEngine } from "../seo/metadata.js";
|
|
4
|
+
import type { TemplateEngine } from "../template/engine.js";
|
|
5
|
+
export declare const LIVE_RELOAD_SCRIPT = "\n<script id=\"__buntic_live_reload\">\n (() => {\n const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';\n const ws = new WebSocket(`${protocol}//${location.host}/_buntic/ws`);\n ws.onmessage = (event) => {\n if (event.data === 'reload') {\n console.log('[buntic] Change detected. Reloading...');\n location.reload();\n }\n };\n ws.onclose = () => {\n setTimeout(() => location.reload(), 1500);\n };\n })();\n</script>\n";
|
|
6
|
+
/**
|
|
7
|
+
* Renders an HTML page through TemplateEngine, PhotoProcessor, SeoMetadataEngine,
|
|
8
|
+
* and appends the dev live-reload WebSocket snippet.
|
|
9
|
+
*/
|
|
10
|
+
export declare function renderDevPage(options: {
|
|
11
|
+
templatePath: string;
|
|
12
|
+
urlPath: string;
|
|
13
|
+
params?: Record<string, string>;
|
|
14
|
+
props?: Record<string, unknown>;
|
|
15
|
+
routeSeo?: PageSeo;
|
|
16
|
+
engine: TemplateEngine;
|
|
17
|
+
photoProcessor: PhotoProcessor;
|
|
18
|
+
seoEngine: SeoMetadataEngine;
|
|
19
|
+
}): Promise<Response>;
|
|
20
|
+
export declare function tryServeSeoRoute(pathname: string, config: ResolvedConfig, engine: TemplateEngine): Promise<Response | null>;
|
|
21
|
+
/**
|
|
22
|
+
* Safely resolves a request pathname inside a base directory, returning the file path
|
|
23
|
+
* only if it stays strictly inside `baseDir` and points to an existing regular file.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveSafeStaticFile(baseDir: string, pathname: string): string | null;
|
|
26
|
+
export declare function serveFileWithTranspiler(filePath: string): Promise<Response>;
|
|
27
|
+
export declare function getMimeType(path: string): string;
|
|
28
|
+
export declare function renderErrorResponse(title: string, err: unknown): Response;
|
|
29
|
+
export declare function renderNotFoundResponse(pathname: string, routes: PageRouteInfo[]): Response;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Server } from "bun";
|
|
2
|
+
import type { ResolvedConfig } from "../types.js";
|
|
3
|
+
export interface DevServerInstance {
|
|
4
|
+
server: Server<undefined>;
|
|
5
|
+
port: number;
|
|
6
|
+
stop: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function startDevServer(config: ResolvedConfig): DevServerInstance;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ResolvedConfig, StorageAssetResult, StorageLoaderFn } from "../types.js";
|
|
2
|
+
export interface LoadedStorage {
|
|
3
|
+
name: string;
|
|
4
|
+
filePath: string;
|
|
5
|
+
loaderFn: StorageLoaderFn;
|
|
6
|
+
}
|
|
7
|
+
export declare class StorageManager {
|
|
8
|
+
private config;
|
|
9
|
+
private storages;
|
|
10
|
+
private initialized;
|
|
11
|
+
constructor(config: ResolvedConfig);
|
|
12
|
+
init(): Promise<void>;
|
|
13
|
+
getAvailableStorages(): string[];
|
|
14
|
+
getDefaultStorageName(): string | undefined;
|
|
15
|
+
invalidate(): void;
|
|
16
|
+
fetchAsset(key: string, storageName?: string): Promise<StorageAssetResult>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StorageLoaderFn } from "../../types.js";
|
|
2
|
+
import type { OrasStorageOptions } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Buntic storage loader function backed by an OCI Registry / ORAS.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* // storage/oci.ts
|
|
9
|
+
* import { createOrasStorage } from "buntic";
|
|
10
|
+
*
|
|
11
|
+
* export default createOrasStorage({
|
|
12
|
+
* hostname: "localhost:5000",
|
|
13
|
+
* insecure: true,
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function createOrasStorage(options: OrasStorageOptions): StorageLoaderFn;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AuthCredentials } from "./types.js";
|
|
2
|
+
export interface ParsedChallenge {
|
|
3
|
+
scheme: "basic" | "bearer" | string;
|
|
4
|
+
realm?: string;
|
|
5
|
+
service?: string;
|
|
6
|
+
scope?: string;
|
|
7
|
+
params: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Parses a `Www-Authenticate` header string into its scheme and parameters.
|
|
11
|
+
* Example inputs:
|
|
12
|
+
* - Basic realm="Registry Realm"
|
|
13
|
+
* - Bearer realm="https://auth.example.com/token",service="registry",scope="repository:foo:pull"
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseWwwAuthenticate(header: string): ParsedChallenge;
|
|
16
|
+
/**
|
|
17
|
+
* Manages authentication challenges, token caching and Authorization headers.
|
|
18
|
+
*/
|
|
19
|
+
export declare class AuthManager {
|
|
20
|
+
private credentials?;
|
|
21
|
+
private tokenCache;
|
|
22
|
+
constructor(credentials?: AuthCredentials);
|
|
23
|
+
/**
|
|
24
|
+
* Set or update authentication credentials.
|
|
25
|
+
*/
|
|
26
|
+
setCredentials(credentials?: AuthCredentials): void;
|
|
27
|
+
/**
|
|
28
|
+
* Generates a direct Basic auth header if username/password are available.
|
|
29
|
+
*/
|
|
30
|
+
getBasicHeader(): string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Generates initial Authorization header if known ahead of time.
|
|
33
|
+
*/
|
|
34
|
+
getInitialAuthHeader(): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Handles a 401 challenge from a Www-Authenticate header, obtaining a token if needed.
|
|
37
|
+
* Returns the Authorization header value to retry with, or undefined if auth cannot be resolved.
|
|
38
|
+
*/
|
|
39
|
+
handleChallenge(wwwAuthHeader: string, requestedScope?: string): Promise<string | undefined>;
|
|
40
|
+
private requestBearerToken;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Searches and loads stored Docker / Podman credentials from ~/.docker/config.json
|
|
44
|
+
* or ~/.config/containers/auth.json for a given registry hostname.
|
|
45
|
+
*/
|
|
46
|
+
export declare function loadStoredCredentials(registryHostname?: string): Promise<AuthCredentials | undefined>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { BlobStreamResult, OCIDescriptor, OCIManifest, OCIReference, OrasClientOptions, PullOptions, PullResult, PushOptions, PushResult } from "./types.js";
|
|
2
|
+
export declare class OrasClient {
|
|
3
|
+
private hostname?;
|
|
4
|
+
private insecure;
|
|
5
|
+
private authManager;
|
|
6
|
+
private defaultHeaders;
|
|
7
|
+
constructor(options?: OrasClientOptions);
|
|
8
|
+
/**
|
|
9
|
+
* Builds the base URL for a given registry hostname.
|
|
10
|
+
*/
|
|
11
|
+
private getBaseUrl;
|
|
12
|
+
private buildRepoUrl;
|
|
13
|
+
private assertOk;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves an input target string or OCIReference into an OCIReference object.
|
|
16
|
+
*/
|
|
17
|
+
resolveRef(target: string | OCIReference): OCIReference;
|
|
18
|
+
/**
|
|
19
|
+
* Internal fetch wrapper that automatically handles authentication challenges (401).
|
|
20
|
+
*/
|
|
21
|
+
request(url: string, init?: RequestInit, scope?: string): Promise<Response>;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if the registry endpoint /v2/ is reachable.
|
|
24
|
+
*/
|
|
25
|
+
ping(registry?: string): Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a blob exists in the repository (HEAD /v2/<repo>/blobs/<digest>).
|
|
28
|
+
*/
|
|
29
|
+
hasBlob(target: string | OCIReference, digest: string): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves a blob as a raw streaming HTTP response (GET /v2/<repo>/blobs/<digest>).
|
|
32
|
+
*/
|
|
33
|
+
getBlobStream(target: string | OCIReference, digest: string): Promise<Response>;
|
|
34
|
+
/**
|
|
35
|
+
* Uploads a blob stream using OCI monolithic upload.
|
|
36
|
+
*/
|
|
37
|
+
uploadBlobStream(target: string | OCIReference, body: BodyInit, size: number, digest: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Uploads a local file as an OCI blob using native Bun.file().
|
|
40
|
+
*/
|
|
41
|
+
uploadBlobFile(target: string | OCIReference, filePath: string, options?: {
|
|
42
|
+
mediaType?: string;
|
|
43
|
+
filename?: string;
|
|
44
|
+
}): Promise<OCIDescriptor>;
|
|
45
|
+
/**
|
|
46
|
+
* Deletes a blob by its digest.
|
|
47
|
+
*/
|
|
48
|
+
deleteBlob(target: string | OCIReference, digest: string): Promise<boolean>;
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves an OCI Image Manifest.
|
|
51
|
+
*/
|
|
52
|
+
getManifest(target: string | OCIReference, tagOrDigest?: string): Promise<OCIManifest>;
|
|
53
|
+
/**
|
|
54
|
+
* Puts an OCI Image Manifest onto the registry.
|
|
55
|
+
*/
|
|
56
|
+
putManifest(target: string | OCIReference, tagOrDigest: string, manifest: OCIManifest): Promise<{
|
|
57
|
+
digest: string;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Lists tags for a given repository.
|
|
61
|
+
*/
|
|
62
|
+
getTags(target: string | OCIReference): Promise<string[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Deletes a manifest reference by tag or digest.
|
|
65
|
+
*/
|
|
66
|
+
deleteManifest(target: string | OCIReference, tagOrDigest: string): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* Pushes files as an OCI artifact.
|
|
69
|
+
*/
|
|
70
|
+
push(options: PushOptions): Promise<PushResult>;
|
|
71
|
+
/**
|
|
72
|
+
* Pulls an OCI artifact and writes its layers to disk.
|
|
73
|
+
*/
|
|
74
|
+
pull(options: PullOptions): Promise<PullResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Retrieves an artifact directly as a stream without writing to disk.
|
|
77
|
+
*/
|
|
78
|
+
getArtifactStream(target: string | OCIReference, filename?: string): Promise<BlobStreamResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Retrieves the catalog of repositories from the registry (GET /v2/_catalog).
|
|
81
|
+
*/
|
|
82
|
+
getCatalog(registry?: string, n?: number): Promise<string[]>;
|
|
83
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { OrasClient } from "./client.js";
|
|
2
|
+
export { createOrasStorage } from "./adapter.js";
|
|
3
|
+
export { parseOciReference, formatOciReference } from "./reference.js";
|
|
4
|
+
export { AuthManager, loadStoredCredentials, parseWwwAuthenticate, type ParsedChallenge, } from "./auth.js";
|
|
5
|
+
export { buildManifest, createEmptyConfigDescriptor, createLayerDescriptor, guessMediaType, hashData, hashFile, EMPTY_CONFIG_CONTENT, EMPTY_CONFIG_DIGEST, EMPTY_CONFIG_SIZE, } from "./manifests.js";
|
|
6
|
+
export * from "./types.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { OCIDescriptor, OCIManifest } from "./types.js";
|
|
2
|
+
export declare const EMPTY_CONFIG_CONTENT = "{}";
|
|
3
|
+
export declare const EMPTY_CONFIG_DIGEST = "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a";
|
|
4
|
+
export declare const EMPTY_CONFIG_SIZE = 2;
|
|
5
|
+
/**
|
|
6
|
+
* Creates the standard empty config descriptor for OCI artifacts.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createEmptyConfigDescriptor(mediaType?: string): OCIDescriptor;
|
|
9
|
+
/**
|
|
10
|
+
* Computes sha256 digest string for a string or Uint8Array.
|
|
11
|
+
*/
|
|
12
|
+
export declare function hashData(data: string | Uint8Array): string;
|
|
13
|
+
/**
|
|
14
|
+
* Computes sha256 digest and size of a file on disk using Bun.file().
|
|
15
|
+
*/
|
|
16
|
+
export declare function hashFile(filePath: string): Promise<{
|
|
17
|
+
digest: string;
|
|
18
|
+
size: number;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Guesses or resolves a media type based on file extension.
|
|
22
|
+
*/
|
|
23
|
+
export declare function guessMediaType(filename: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Builds an OCIDescriptor for a layer.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createLayerDescriptor(options: {
|
|
28
|
+
digest: string;
|
|
29
|
+
size: number;
|
|
30
|
+
mediaType?: string;
|
|
31
|
+
filename?: string;
|
|
32
|
+
annotations?: Record<string, string>;
|
|
33
|
+
}): OCIDescriptor;
|
|
34
|
+
/**
|
|
35
|
+
* Assembles a standard OCI Image Manifest v1.
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildManifest(options: {
|
|
38
|
+
config?: OCIDescriptor;
|
|
39
|
+
layers: OCIDescriptor[];
|
|
40
|
+
artifactType?: string;
|
|
41
|
+
annotations?: Record<string, string>;
|
|
42
|
+
}): OCIManifest;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OCIReference } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Parses a target string into an OCIReference object.
|
|
4
|
+
* Examples:
|
|
5
|
+
* - "localhost:5000/product/1/portrait:latest"
|
|
6
|
+
* - "product/1/portrait:2020" (uses fallbackRegistry)
|
|
7
|
+
* - "product/1/portrait" (defaults tag to "latest")
|
|
8
|
+
* - "localhost:5000/media@sha256:45b23dee08af..."
|
|
9
|
+
* - "product/1/gallery:v1#thumb.png" (extracts subpath)
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseOciReference(target: string, fallbackRegistry?: string): OCIReference;
|
|
12
|
+
/**
|
|
13
|
+
* Formats an OCIReference back into a canonical URI string.
|
|
14
|
+
*/
|
|
15
|
+
export declare function formatOciReference(ref: OCIReference): string;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard OCI and ORAS media types.
|
|
3
|
+
*/
|
|
4
|
+
export declare const MEDIA_TYPES: {
|
|
5
|
+
readonly OCI_IMAGE_MANIFEST_V1: "application/vnd.oci.image.manifest.v1+json";
|
|
6
|
+
readonly OCI_IMAGE_INDEX_V1: "application/vnd.oci.image.index.v1+json";
|
|
7
|
+
readonly DOCKER_MANIFEST_V2: "application/vnd.docker.distribution.manifest.v2+json";
|
|
8
|
+
readonly OCI_EMPTY_CONFIG_V1: "application/vnd.oci.empty.v1+json";
|
|
9
|
+
readonly OCI_IMAGE_CONFIG_V1: "application/vnd.oci.image.config.v1+json";
|
|
10
|
+
readonly OCI_LAYER_TAR: "application/vnd.oci.image.layer.v1.tar";
|
|
11
|
+
readonly OCI_LAYER_TAR_GZIP: "application/vnd.oci.image.layer.v1.tar+gzip";
|
|
12
|
+
readonly ORAS_DEFAULT_LAYER: "application/vnd.oci.image.layer.v1.tar";
|
|
13
|
+
readonly DEFAULT_BLOB_TYPE: "application/octet-stream";
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Standard OCI annotations keys.
|
|
17
|
+
*/
|
|
18
|
+
export declare const ANNOTATIONS: {
|
|
19
|
+
readonly TITLE: "org.opencontainers.image.title";
|
|
20
|
+
readonly CREATED: "org.opencontainers.image.created";
|
|
21
|
+
readonly DESCRIPTION: "org.opencontainers.image.description";
|
|
22
|
+
readonly VENDOR: "org.opencontainers.image.vendor";
|
|
23
|
+
readonly VERSION: "org.opencontainers.image.version";
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* OCI Content Descriptor
|
|
27
|
+
*/
|
|
28
|
+
export interface OCIDescriptor {
|
|
29
|
+
mediaType: string;
|
|
30
|
+
digest: string;
|
|
31
|
+
size: number;
|
|
32
|
+
urls?: string[];
|
|
33
|
+
annotations?: Record<string, string>;
|
|
34
|
+
data?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* OCI Image Manifest Spec (v1)
|
|
38
|
+
*/
|
|
39
|
+
export interface OCIManifest {
|
|
40
|
+
schemaVersion: number;
|
|
41
|
+
mediaType?: string;
|
|
42
|
+
artifactType?: string;
|
|
43
|
+
config: OCIDescriptor;
|
|
44
|
+
layers: OCIDescriptor[];
|
|
45
|
+
subject?: OCIDescriptor;
|
|
46
|
+
annotations?: Record<string, string>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Parsed container/artifact target reference.
|
|
50
|
+
* Example: "reg:5000/namespace/repo:tag" or "reg:5000/repo@sha256:..."
|
|
51
|
+
*/
|
|
52
|
+
export interface OCIReference {
|
|
53
|
+
raw: string;
|
|
54
|
+
registry: string;
|
|
55
|
+
repository: string;
|
|
56
|
+
tag?: string;
|
|
57
|
+
digest?: string;
|
|
58
|
+
subpath?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Client authentication credentials.
|
|
62
|
+
*/
|
|
63
|
+
export interface BasicAuth {
|
|
64
|
+
username: string;
|
|
65
|
+
password: string;
|
|
66
|
+
}
|
|
67
|
+
export interface TokenAuth {
|
|
68
|
+
token: string;
|
|
69
|
+
}
|
|
70
|
+
export type AuthCredentials = BasicAuth | TokenAuth;
|
|
71
|
+
/**
|
|
72
|
+
* Options for instantiating OrasClient.
|
|
73
|
+
*/
|
|
74
|
+
export interface OrasClientOptions {
|
|
75
|
+
/**
|
|
76
|
+
* Default registry hostname (e.g. "localhost:5000" or "ghcr.io").
|
|
77
|
+
* Can also be inferred from the target string in push/pull.
|
|
78
|
+
*/
|
|
79
|
+
hostname?: string;
|
|
80
|
+
/**
|
|
81
|
+
* When true, uses HTTP instead of HTTPS (ideal for local development).
|
|
82
|
+
* Default: false (HTTPS).
|
|
83
|
+
*/
|
|
84
|
+
insecure?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Authentication credentials (Basic username/password or Bearer token).
|
|
87
|
+
*/
|
|
88
|
+
auth?: AuthCredentials;
|
|
89
|
+
/**
|
|
90
|
+
* Custom headers to send with each request.
|
|
91
|
+
*/
|
|
92
|
+
headers?: Record<string, string>;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Options for createOrasStorage helper.
|
|
96
|
+
*/
|
|
97
|
+
export interface OrasStorageOptions extends OrasClientOptions {
|
|
98
|
+
/**
|
|
99
|
+
* Optional repository prefix (e.g. "catalog" -> "<host>/catalog/<key>").
|
|
100
|
+
*/
|
|
101
|
+
prefix?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Default tag if none specified in key (default: "latest").
|
|
104
|
+
*/
|
|
105
|
+
defaultTag?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* High-level Push parameters.
|
|
109
|
+
*/
|
|
110
|
+
export interface PushOptions {
|
|
111
|
+
/** Target reference: e.g. "reg:5000/my-app/media:v1" */
|
|
112
|
+
target: string;
|
|
113
|
+
/** Local file paths to upload as layers */
|
|
114
|
+
files?: string[];
|
|
115
|
+
/** Optional custom media type for the config descriptor */
|
|
116
|
+
configMediaType?: string;
|
|
117
|
+
/** Optional config content as JSON object */
|
|
118
|
+
config?: Record<string, any>;
|
|
119
|
+
/** Custom annotations for the manifest */
|
|
120
|
+
manifestAnnotations?: Record<string, string>;
|
|
121
|
+
/** Custom annotations mapped by file path or filename */
|
|
122
|
+
fileAnnotations?: Record<string, Record<string, string>>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Result of a push operation.
|
|
126
|
+
*/
|
|
127
|
+
export interface PushResult {
|
|
128
|
+
target: OCIReference;
|
|
129
|
+
digest: string;
|
|
130
|
+
size: number;
|
|
131
|
+
layers: OCIDescriptor[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* High-level Pull parameters.
|
|
135
|
+
*/
|
|
136
|
+
export interface PullOptions {
|
|
137
|
+
/** Target reference: e.g. "reg:5000/my-app/media:v1" or "@sha256:..." */
|
|
138
|
+
target: string;
|
|
139
|
+
/** Directory where downloaded files should be saved */
|
|
140
|
+
outdir: string;
|
|
141
|
+
/** If true, will overwrite existing files */
|
|
142
|
+
overwrite?: boolean;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Result of a pull operation.
|
|
146
|
+
*/
|
|
147
|
+
export interface PullResult {
|
|
148
|
+
manifest: OCIManifest;
|
|
149
|
+
files: string[];
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* In-memory or streaming blob response.
|
|
153
|
+
*/
|
|
154
|
+
export interface BlobStreamResult {
|
|
155
|
+
digest: string;
|
|
156
|
+
size: number;
|
|
157
|
+
mediaType: string;
|
|
158
|
+
filename?: string;
|
|
159
|
+
annotations?: Record<string, string>;
|
|
160
|
+
stream: ReadableStream<Uint8Array>;
|
|
161
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { VirtualFileSystem } from "./vfs.js";
|
|
2
|
+
export interface CssNode {
|
|
3
|
+
filePath: string;
|
|
4
|
+
relativeToRoot: string;
|
|
5
|
+
imports: string[];
|
|
6
|
+
importedBy: Set<string>;
|
|
7
|
+
isSiblingRoot: boolean;
|
|
8
|
+
claimedBySibling?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface GlobalRootResult {
|
|
11
|
+
root: string | null;
|
|
12
|
+
relativeRoot: string | null;
|
|
13
|
+
conflicts: string[];
|
|
14
|
+
hasCycle: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class CssDependencyGraph {
|
|
17
|
+
rootDir: string;
|
|
18
|
+
private nodes;
|
|
19
|
+
private siblingRoots;
|
|
20
|
+
private globalRootResult;
|
|
21
|
+
private isAnalyzed;
|
|
22
|
+
constructor(rootDir: string);
|
|
23
|
+
invalidate(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Scans and builds the complete CSS dependency graph across the project.
|
|
26
|
+
*/
|
|
27
|
+
analyze(vfs: VirtualFileSystem): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the computed global CSS root result.
|
|
30
|
+
*/
|
|
31
|
+
getGlobalRoot(): GlobalRootResult;
|
|
32
|
+
/**
|
|
33
|
+
* Flattens a CSS file by resolving all local @import statements recursively in topological order.
|
|
34
|
+
* Keeps external @imports at the top.
|
|
35
|
+
*/
|
|
36
|
+
flattenCss(entryFilePath: string, vfs: VirtualFileSystem, visited?: Set<string>): Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Checks whether a CSS file is a sibling of an .html or .ts/.js file in the same directory.
|
|
39
|
+
*/
|
|
40
|
+
checkIsSiblingRoot(cssPath: string, vfs: VirtualFileSystem): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Extracts local relative @import paths from CSS content.
|
|
43
|
+
*/
|
|
44
|
+
private extractLocalImports;
|
|
45
|
+
/**
|
|
46
|
+
* Calculates the global root among candidate files.
|
|
47
|
+
*/
|
|
48
|
+
private calculateGlobalRoot;
|
|
49
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ResolvedConfig } from "../types.js";
|
|
2
|
+
import type { CssDependencyGraph } from "./css-graph.js";
|
|
3
|
+
import { type ScopeRegistry } from "./scoped-css.js";
|
|
4
|
+
import type { VirtualFileSystem } from "./vfs.js";
|
|
5
|
+
/**
|
|
6
|
+
* Processes `<style scoped>` blocks and manages CSS injection based on `config.cssStrategy`:
|
|
7
|
+
* - `"inline"`: inlines global stylesheets and scoped styles directly into `<head>` (default).
|
|
8
|
+
* - `"external"`: leaves global stylesheets as `<link>` and registers page-specific `.scoped.css` files.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolvePageCss(options: {
|
|
11
|
+
html: string;
|
|
12
|
+
currentFile: string;
|
|
13
|
+
extraScopedRules?: string[];
|
|
14
|
+
config: ResolvedConfig;
|
|
15
|
+
vfs: VirtualFileSystem;
|
|
16
|
+
cssGraph: CssDependencyGraph;
|
|
17
|
+
scopeRegistry: ScopeRegistry;
|
|
18
|
+
generatedPageStyles: Map<string, string>;
|
|
19
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure CSS block parsing and selector scoping transformation helpers.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Transforms scoped CSS rules to apply under the given `scopeTarget`:
|
|
6
|
+
* - `&` and `:host` replaced by `.${scopeTarget}` (or raw element tag if `isElement`)
|
|
7
|
+
* - Combinators (`> p`) prefixed as `.${scopeTarget} > p`
|
|
8
|
+
* - Descendants (`p`, `.btn`) prefixed as `.${scopeTarget} p`
|
|
9
|
+
* - `@media` / `@supports` / `@container` recursively scoped
|
|
10
|
+
* - `@keyframes` and `@font-face` preserved without scoping
|
|
11
|
+
*/
|
|
12
|
+
export declare function transformScopedCss(css: string, scopeTarget: string, isElement?: boolean): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResolvedConfig } from "../types.js";
|
|
2
|
+
import type { VirtualFileSystem } from "./vfs.js";
|
|
3
|
+
export type TemplateContext = Record<string, any>;
|
|
4
|
+
/**
|
|
5
|
+
* Loads all JSON and TS/JS data files in `config.dataDir` into an in-memory map,
|
|
6
|
+
* along with public environment variables under the reserved `"env"` namespace.
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadGlobalData(config: ResolvedConfig, vfs: VirtualFileSystem): Promise<TemplateContext>;
|