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.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +135 -2
  3. package/dist/assets/cache.d.ts +10 -0
  4. package/dist/assets/image-processor.d.ts +39 -0
  5. package/dist/assets/photo-tag.d.ts +19 -0
  6. package/dist/builder/builder.d.ts +28 -0
  7. package/dist/builder/collisions.d.ts +10 -0
  8. package/dist/cli.d.ts +1 -0
  9. package/dist/cli.js +4205 -0
  10. package/dist/config.d.ts +11 -0
  11. package/dist/env.d.ts +18 -0
  12. package/dist/index.d.ts +30 -0
  13. package/dist/index.js +5060 -0
  14. package/dist/init.d.ts +15 -0
  15. package/dist/router/routes.d.ts +48 -0
  16. package/dist/runtime.d.ts +23 -0
  17. package/dist/seo/feeds.d.ts +11 -0
  18. package/dist/seo/metadata.d.ts +33 -0
  19. package/dist/seo/robots.d.ts +2 -0
  20. package/dist/seo/sitemap.d.ts +2 -0
  21. package/dist/server/dev-helpers.d.ts +29 -0
  22. package/dist/server/dev.d.ts +8 -0
  23. package/dist/storage/loader.d.ts +17 -0
  24. package/dist/storage/oras/adapter.d.ts +17 -0
  25. package/dist/storage/oras/auth.d.ts +46 -0
  26. package/dist/storage/oras/client.d.ts +83 -0
  27. package/dist/storage/oras/index.d.ts +6 -0
  28. package/dist/storage/oras/manifests.d.ts +42 -0
  29. package/dist/storage/oras/reference.d.ts +15 -0
  30. package/dist/storage/oras/types.d.ts +161 -0
  31. package/dist/template/css-graph.d.ts +49 -0
  32. package/dist/template/css-resolver.d.ts +19 -0
  33. package/dist/template/css-scoper.d.ts +12 -0
  34. package/dist/template/data-loader.d.ts +8 -0
  35. package/dist/template/directives.d.ts +13 -0
  36. package/dist/template/dsd-renderer.d.ts +23 -0
  37. package/dist/template/engine.d.ts +39 -0
  38. package/dist/template/html-scanner.d.ts +37 -0
  39. package/dist/template/scoped-css.d.ts +30 -0
  40. package/dist/template/svg-component.d.ts +32 -0
  41. package/dist/template/vfs.d.ts +57 -0
  42. package/dist/template/web-components.d.ts +91 -0
  43. package/dist/types.d.ts +152 -0
  44. package/dist/utils/html.d.ts +23 -0
  45. package/dist/utils/logger.d.ts +6 -0
  46. package/dist/utils/paths.d.ts +20 -0
  47. package/package.json +54 -4
  48. package/templates/blank/_gitignore +5 -0
  49. package/templates/blank/buntic.config.ts +15 -0
  50. package/templates/blank/src/layouts/main.html +14 -0
  51. package/templates/blank/src/pages/index.html +11 -0
  52. package/templates/blank/src/public/robots.txt +2 -0
  53. package/templates/blank/src/styles/main.css +40 -0
  54. package/templates/blank/tsconfig.json +21 -0
  55. package/templates/simple/README.md +35 -0
  56. package/templates/simple/_gitignore +5 -0
  57. package/templates/simple/buntic.config.ts +11 -0
  58. package/templates/simple/src/components/card.css +27 -0
  59. package/templates/simple/src/components/card.html +7 -0
  60. package/templates/simple/src/components/footer.css +14 -0
  61. package/templates/simple/src/components/footer.html +5 -0
  62. package/templates/simple/src/components/header.css +33 -0
  63. package/templates/simple/src/components/header.html +10 -0
  64. package/templates/simple/src/data/features.json +14 -0
  65. package/templates/simple/src/data/site.json +11 -0
  66. package/templates/simple/src/layouts/main.html +17 -0
  67. package/templates/simple/src/pages/about.html +16 -0
  68. package/templates/simple/src/pages/contact.html +13 -0
  69. package/templates/simple/src/pages/index.html +17 -0
  70. package/templates/simple/src/public/robots.txt +2 -0
  71. package/templates/simple/src/styles/main.css +67 -0
  72. package/templates/simple/tsconfig.json +21 -0
  73. package/templates/skills/buntic/SKILL.md +359 -0
  74. package/templates/skills/buntic/examples/README.md +177 -0
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Pure template directive evaluators: conditionals (<if> / if="...") and {{ var ?? "fallback" }} interpolation.
3
+ */
4
+ export declare function isTruthy(val: unknown): boolean;
5
+ export declare function getNestedValue(obj: unknown, path: string): unknown;
6
+ /**
7
+ * Resolves conditionals:
8
+ * 1. <if is="expr"> ... [ <else> ... </else> ] </if>
9
+ * 2. Self-closing elements: <tag ... if="expr" ... />
10
+ * 3. Paired elements: <tag ... if="expr" ...>...</tag>
11
+ */
12
+ export declare function resolveConditionals(html: string, context: Record<string, unknown>): string;
13
+ export declare function interpolateTemplate(html: string, context: Record<string, unknown>): string;
@@ -0,0 +1,23 @@
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
+ * Checks whether an HTML string already contains a `<script>` tag pointing to `srcPath`.
7
+ */
8
+ export declare function hasScriptWithSrc(html: string, srcPath: string): boolean;
9
+ /**
10
+ * Scans HTML for Custom Element tags (e.g. `<counter-button>`), expands Declarative Shadow DOM
11
+ * (`<template shadowrootmode="open">`) recursively when triad `.html`/`.css` files exist,
12
+ * and auto-injects the corresponding `<script type="module" src="...">` into `<head>`.
13
+ */
14
+ export declare function resolveWebComponentsInHtml(options: {
15
+ html: string;
16
+ context: Record<string, unknown>;
17
+ config: ResolvedConfig;
18
+ vfs: VirtualFileSystem;
19
+ cssGraph: CssDependencyGraph;
20
+ scopeRegistry: ScopeRegistry;
21
+ warnedUnknownTags: Set<string>;
22
+ resolveComponentsFn: (html: string, context: Record<string, unknown>, currentFile: string) => Promise<string>;
23
+ }): Promise<string>;
@@ -0,0 +1,39 @@
1
+ import type { ResolvedConfig } from "../types.js";
2
+ import { CssDependencyGraph } from "./css-graph.js";
3
+ import { type TemplateContext } from "./data-loader.js";
4
+ import { hasScriptWithSrc } from "./dsd-renderer.js";
5
+ import { ScopeRegistry } from "./scoped-css.js";
6
+ import { VirtualFileSystem } from "./vfs.js";
7
+ export { hasScriptWithSrc };
8
+ export declare class TemplateEngine {
9
+ private config;
10
+ vfs: VirtualFileSystem;
11
+ scopeRegistry: ScopeRegistry;
12
+ cssGraph: CssDependencyGraph;
13
+ generatedPageStyles: Map<string, string>;
14
+ private cachedData;
15
+ private warnedUnknownTags;
16
+ constructor(config: ResolvedConfig);
17
+ loadData(): Promise<TemplateContext>;
18
+ invalidateDataCache(): void;
19
+ invalidateCache(filePath?: string): void;
20
+ renderPage(pageHtml: string, currentFile?: string, pageContext?: {
21
+ params?: Record<string, string>;
22
+ props?: Record<string, unknown>;
23
+ } | TemplateContext): Promise<string>;
24
+ resolveCss(html: string, currentFile?: string, extraScopedRules?: string[]): Promise<string>;
25
+ resolveWebComponents(html: string, context?: TemplateContext): Promise<string>;
26
+ getUnusedWebComponents(): Array<{
27
+ tag: string;
28
+ file: string;
29
+ }>;
30
+ assertNoWebComponentConflicts(): void;
31
+ clearUsedWebComponents(): void;
32
+ resolveFilePath(rawSrc: string, currentFile: string, defaultDir: string): string;
33
+ private resolveLayout;
34
+ resolveEach(html: string, context: TemplateContext, currentFile: string, depth?: number): Promise<string>;
35
+ resolveComponents(html: string, context: TemplateContext, currentFile: string, depth?: number): Promise<string>;
36
+ private renderWebComponentAlias;
37
+ resolveConditionals(html: string, context: TemplateContext): string;
38
+ interpolate(html: string, context: TemplateContext): string;
39
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * HTML structural scanning helpers used by Scoped CSS and SVG attribute merging.
3
+ */
4
+ export declare const VOID_ELEMENTS: Set<string>;
5
+ export interface RootElementInfo {
6
+ tag: string;
7
+ openTagStart: number;
8
+ openTagEnd: number;
9
+ openTagRaw: string;
10
+ }
11
+ export interface TagOpenInfo {
12
+ tag: string;
13
+ start: number;
14
+ end: number;
15
+ raw: string;
16
+ depth: number;
17
+ }
18
+ /**
19
+ * Creates a fresh HTML tokenizer regex for tag-stack analysis:
20
+ * - Skips HTML comments, XML prologues, `<!doctype ...>`, `<script>...</script>`, and `<style>...</style>`
21
+ * - Captures closing tag name (group 1), opening tag name (group 2), attributes (group 3), and self-closing "/" (group 4)
22
+ */
23
+ export declare function createHtmlTagRegex(): RegExp;
24
+ /**
25
+ * Validates whether an HTML string has exactly one top-level container element.
26
+ * Returns information about the root element's opening tag, or null otherwise.
27
+ */
28
+ export declare function findSingleRootElement(html: string): RootElementInfo | null;
29
+ /**
30
+ * Finds the parent opening tag of `<style scoped>` by tracking the HTML tag stack
31
+ * up to `styleStartIdx`.
32
+ */
33
+ export declare function findParentTagOfScopedStyle(html: string, styleStartIdx: number): TagOpenInfo | null;
34
+ /**
35
+ * Injects a class name into an HTML element opening tag.
36
+ */
37
+ export declare function addClassToOpenTag(openTag: string, newClass: string): string;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Buntic Scoped CSS Processor
3
+ * Handles <style scoped> blocks, scoping registry, sibling CSS attachment,
4
+ * and depth-ordered extraction.
5
+ */
6
+ import { transformScopedCss } from "./css-scoper.js";
7
+ import { findSingleRootElement, type RootElementInfo } from "./html-scanner.js";
8
+ export { findSingleRootElement, transformScopedCss, type RootElementInfo };
9
+ export interface ScopedCssExtraction {
10
+ html: string;
11
+ scopedRules: string[];
12
+ }
13
+ /**
14
+ * Injects a scoped CSS block into the root element of an HTML template.
15
+ * Returns null if the template does not have a single root element.
16
+ */
17
+ export declare function attachSiblingScopedCss(html: string, cssContent: string): string | null;
18
+ export declare class ScopeRegistry {
19
+ private registry;
20
+ /**
21
+ * Generates a deterministic, collision-free scope class ID.
22
+ */
23
+ getScopeId(cssContent: string): string;
24
+ clear(): void;
25
+ }
26
+ /**
27
+ * Extracts all `<style scoped>` blocks from HTML, injects deterministic scope classes
28
+ * onto enclosing parent tags, and orders emitted rules by ascending DOM depth.
29
+ */
30
+ export declare function extractScopedStyles(html: string, registry?: ScopeRegistry): ScopedCssExtraction;
@@ -0,0 +1,32 @@
1
+ import type { ResolvedConfig } from "../types.js";
2
+ import type { CssDependencyGraph } from "./css-graph.js";
3
+ import type { VirtualFileSystem } from "./vfs.js";
4
+ /**
5
+ * Attaches a co-located sibling `.css` file as `<style scoped>` to an HTML/SVG template
6
+ * that has a single root element, emitting a warning when multiple roots exist.
7
+ */
8
+ export declare function attachSiblingCssIfPresent(options: {
9
+ templateHtml: string;
10
+ templatePath: string;
11
+ siblingCssPath: string;
12
+ kindLabel: "Page" | "Component" | "SVG";
13
+ config: ResolvedConfig;
14
+ vfs: VirtualFileSystem;
15
+ cssGraph: CssDependencyGraph;
16
+ }): Promise<string>;
17
+ /**
18
+ * Merges passthrough HTML attributes (class, width, height, aria-*, etc.)
19
+ * onto the root `<svg>` element of an inline SVG component.
20
+ */
21
+ export declare function mergeSvgAttributes(svgHtml: string, props: Record<string, string>): string;
22
+ /**
23
+ * Loads an inline SVG component, strips XML/DOCTYPE prologues, attaches sibling `.css`
24
+ * if present, and merges passthrough attributes.
25
+ */
26
+ export declare function renderSvgComponent(options: {
27
+ compPath: string;
28
+ props: Record<string, string>;
29
+ config: ResolvedConfig;
30
+ vfs: VirtualFileSystem;
31
+ cssGraph: CssDependencyGraph;
32
+ }): Promise<string>;
@@ -0,0 +1,57 @@
1
+ import { WebComponentRegistry } from "./web-components.js";
2
+ /**
3
+ * Checks whether a path or filename should be ignored by VFS and the dev file watcher.
4
+ * Filters out build/system folders and editor temporary/swap/backup files (Vim, Neovim, Emacs, JetBrains, macOS).
5
+ */
6
+ export declare function isIgnoredPath(filePathOrName: string): boolean;
7
+ export declare class VirtualFileSystem {
8
+ root: string;
9
+ registry: WebComponentRegistry;
10
+ private knownFiles;
11
+ private knownDirs;
12
+ private pathCache;
13
+ private contentCache;
14
+ private jsonCache;
15
+ constructor(root: string);
16
+ /**
17
+ * Fast in-memory scan of the project directory.
18
+ * Excludes common heavy or generated directories.
19
+ */
20
+ scan(dir?: string): void;
21
+ /**
22
+ * O(1) in-memory check to see if a file exists without touching disk.
23
+ */
24
+ hasFile(path: string): boolean;
25
+ /**
26
+ * Resolves a referenced template path using in-memory index and cached resolutions.
27
+ */
28
+ resolvePath(rawSrc: string, currentFile: string, defaultDir: string): string;
29
+ /**
30
+ * Reads a text file using in-memory content cache.
31
+ */
32
+ readText(path: string): Promise<string>;
33
+ /**
34
+ * Reads a JSON file using in-memory parsed JSON cache.
35
+ */
36
+ readJson(path: string): Promise<any>;
37
+ /**
38
+ * Returns all known indexed file paths in the workspace.
39
+ */
40
+ getAllFiles(): string[];
41
+ /**
42
+ * Returns all known files located inside a given subfolder (e.g. data/)
43
+ */
44
+ getFilesInDirectory(subDir: string): string[];
45
+ /**
46
+ * Invalidates cached entries when a file is modified, added, or deleted.
47
+ */
48
+ invalidateFile(path?: string): void;
49
+ /**
50
+ * Clears in-memory content, JSON, and path resolution caches without losing indexed files.
51
+ */
52
+ clearContentCache(): void;
53
+ /**
54
+ * Clears all caches and rescans the project directory.
55
+ */
56
+ clear(): void;
57
+ }
@@ -0,0 +1,91 @@
1
+ export declare const RESERVED_W3C_TAGS: Set<string>;
2
+ export interface ComponentConflict {
3
+ tag: string;
4
+ files: string[];
5
+ }
6
+ /**
7
+ * Converts a PascalCase string to kebab-case.
8
+ * e.g. "CounterButton" -> "counter-button"
9
+ */
10
+ export declare function pascalToKebab(pascal: string): string;
11
+ /**
12
+ * Converts a kebab-case string to PascalCase.
13
+ * e.g. "counter-button" -> "CounterButton"
14
+ */
15
+ export declare function kebabToPascal(kebab: string): string;
16
+ /**
17
+ * Derives the expected custom element tag name from a file path.
18
+ * The filename must be in hyphenated kebab-case (e.g. "counter-button.ts")
19
+ * or PascalCase with at least two words (e.g. "CounterButton.ts").
20
+ * Returns null if the filename does not adhere to Custom Element naming.
21
+ */
22
+ export declare function filenameToTagName(filePath: string): string | null;
23
+ export declare class WebComponentRegistry {
24
+ private tagToFile;
25
+ private fileToTags;
26
+ private conflicts;
27
+ private usedTags;
28
+ /**
29
+ * Validates if a custom element tag name is compliant with W3C specification.
30
+ */
31
+ validateTagName(tag: string): {
32
+ valid: boolean;
33
+ reason?: string;
34
+ };
35
+ /**
36
+ * Registers a JavaScript/TypeScript file for a Web Component under strict 1:1 convention:
37
+ * 1. The filename must match the custom element tag name (kebab-case or PascalCase).
38
+ * 2. Only 1 custom element may be defined per file.
39
+ */
40
+ registerFile(filePath: string, content?: string): string[];
41
+ /**
42
+ * Unregisters a file and cleans up its tags and conflicts.
43
+ */
44
+ unregisterFile(filePath: string): void;
45
+ /**
46
+ * Returns the file path for a registered tag, if any.
47
+ */
48
+ findScriptForTag(tag: string): string | undefined;
49
+ /**
50
+ * Marks a tag as having been referenced in an HTML document.
51
+ */
52
+ markTagUsed(tag: string): void;
53
+ /**
54
+ * Clears the set of used tags (e.g. before a new full build).
55
+ */
56
+ clearUsed(): void;
57
+ /**
58
+ * Returns any detected tag collisions.
59
+ */
60
+ getConflicts(): ComponentConflict[];
61
+ /**
62
+ * Throws an error if any unresolved tag collisions exist.
63
+ */
64
+ assertNoConflicts(): void;
65
+ /**
66
+ * Returns components that were registered in the project but never used in any page.
67
+ */
68
+ getUnusedComponents(): Array<{
69
+ tag: string;
70
+ file: string;
71
+ }>;
72
+ /**
73
+ * Returns all tags registered by a specific file.
74
+ */
75
+ getTagsForFile(filePath: string): string[];
76
+ /**
77
+ * Returns all registered tags.
78
+ */
79
+ getAllRegisteredTags(): string[];
80
+ }
81
+ export interface ComponentTriad {
82
+ tag: string;
83
+ scriptPath?: string;
84
+ htmlPath?: string;
85
+ cssPath?: string;
86
+ }
87
+ /**
88
+ * Given a Web Component script path (e.g. components/counter-button.ts or components/CounterButton.ts),
89
+ * locates any co-located sibling HTML template and CSS stylesheet.
90
+ */
91
+ export declare function findTriadForScript(scriptPath: string, existsFn: (p: string) => boolean): ComponentTriad | null;
@@ -0,0 +1,152 @@
1
+ export interface StorageAssetResult {
2
+ bytes: Uint8Array;
3
+ etag?: string;
4
+ contentType?: string;
5
+ }
6
+ export type StorageLoaderFn = (key: string) => Promise<StorageAssetResult | Uint8Array | Response | ArrayBuffer> | StorageAssetResult | Uint8Array | Response | ArrayBuffer;
7
+ export interface SeoImageConfig {
8
+ src?: string;
9
+ key?: string;
10
+ storage?: string;
11
+ alt?: string;
12
+ }
13
+ export interface PageSeo {
14
+ title?: string;
15
+ description?: string;
16
+ image?: string | SeoImageConfig;
17
+ url?: string;
18
+ type?: string;
19
+ twitterCard?: "summary" | "summary_large_image";
20
+ }
21
+ export interface FeedItem {
22
+ title: string;
23
+ description?: string;
24
+ date?: string | Date;
25
+ author?: string;
26
+ url?: string;
27
+ }
28
+ export interface SiteConfig {
29
+ url: string;
30
+ title?: string;
31
+ description?: string;
32
+ defaultOgImage?: string | SeoImageConfig;
33
+ defaultStorage?: string;
34
+ }
35
+ export interface SeoConfig {
36
+ sitemap?: boolean;
37
+ robots?: boolean | {
38
+ allow?: string[];
39
+ disallow?: string[];
40
+ };
41
+ }
42
+ export interface FeedsConfig {
43
+ rss?: boolean | string;
44
+ atom?: boolean | string;
45
+ title?: string;
46
+ description?: string;
47
+ limit?: number;
48
+ }
49
+ export interface PhotoAttributes {
50
+ src?: string;
51
+ key?: string;
52
+ storage?: string;
53
+ alt?: string;
54
+ width?: number | string;
55
+ height?: number | string;
56
+ widths?: number[] | string;
57
+ sizes?: string;
58
+ loading?: "lazy" | "eager";
59
+ decoding?: "async" | "sync" | "auto";
60
+ class?: string;
61
+ style?: string;
62
+ id?: string;
63
+ [key: string]: any;
64
+ }
65
+ export interface BunticConfig {
66
+ root?: string;
67
+ pagesDir?: string;
68
+ layoutsDir?: string;
69
+ componentsDir?: string;
70
+ dataDir?: string;
71
+ publicDir?: string;
72
+ storageDir?: string;
73
+ cacheDir?: string;
74
+ outDir?: string;
75
+ port?: number;
76
+ minify?: boolean;
77
+ cssStrategy?: "inline" | "external";
78
+ site?: SiteConfig;
79
+ seo?: SeoConfig;
80
+ feeds?: FeedsConfig;
81
+ defaultStorage?: string;
82
+ }
83
+ export interface ResolvedConfig {
84
+ root: string;
85
+ pagesDir: string;
86
+ layoutsDir: string;
87
+ componentsDir: string;
88
+ dataDir: string;
89
+ publicDir: string;
90
+ storageDir: string;
91
+ cacheDir: string;
92
+ outDir: string;
93
+ port: number;
94
+ minify: boolean;
95
+ cssStrategy: "inline" | "external";
96
+ site?: SiteConfig;
97
+ seo?: SeoConfig;
98
+ feeds?: FeedsConfig;
99
+ defaultStorage?: string;
100
+ }
101
+ export interface PageInfo {
102
+ relativeFilePath: string;
103
+ absoluteFilePath: string;
104
+ urlPath: string;
105
+ outputFilePath: string;
106
+ }
107
+ export interface StaticPathResult {
108
+ params: Record<string, string | number>;
109
+ props?: Record<string, any>;
110
+ seo?: PageSeo;
111
+ feed?: FeedItem;
112
+ }
113
+ export interface PaginateOptions {
114
+ pageSize?: number;
115
+ props?: Record<string, any>;
116
+ seo?: PageSeo;
117
+ feed?: FeedItem;
118
+ }
119
+ export interface PaginatePage<T = any> {
120
+ data: T[];
121
+ start: number;
122
+ end: number;
123
+ total: number;
124
+ currentPage: number;
125
+ size: number;
126
+ lastPage: number;
127
+ url: {
128
+ current: string;
129
+ prev: string | null;
130
+ next: string | null;
131
+ };
132
+ }
133
+ export interface PageRouteInfo {
134
+ /** Relative path pattern, e.g. "blog/[slug].html" or "about.html" */
135
+ patternRelativePath: string;
136
+ /** Absolute file path of the HTML template */
137
+ templateFilePath: string;
138
+ /** Clean URL path, e.g. "/blog/mi-post" or "/" */
139
+ urlPath: string;
140
+ /** Output file path in outDir (Clean URL: dist/.../index.html) */
141
+ outputFilePath: string;
142
+ /** Route parameters, e.g. { slug: "mi-post" } */
143
+ params: Record<string, string>;
144
+ /** Properties passed to the template */
145
+ props: Record<string, any>;
146
+ /** Whether this is a dynamic route */
147
+ isDynamic: boolean;
148
+ /** SEO metadata for this route */
149
+ seo?: PageSeo;
150
+ /** Feed item metadata for this route */
151
+ feed?: FeedItem;
152
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Shared HTML and XML string utilities for Buntic.
3
+ */
4
+ export declare function escapeHtml(str: string): string;
5
+ export declare function escapeXml(str: string): string;
6
+ /**
7
+ * Parses HTML/XML tag attributes from an attribute string.
8
+ * Handles double-quoted, single-quoted, unquoted, and boolean attributes.
9
+ */
10
+ export declare function parseHtmlAttributes(attrString: string, booleanDefault?: string): Record<string, string>;
11
+ /**
12
+ * Replaces the first occurrence of `search` in `source` literally,
13
+ * avoiding special replacement patterns like `$&`, `$1`, or `$$`.
14
+ */
15
+ export declare function replaceLiteral(source: string, search: string, replacement: string): string;
16
+ /**
17
+ * Injects an HTML snippet right before `</head>`, or falls back to `</body>` / document start/end.
18
+ */
19
+ export declare function injectIntoHead(html: string, snippet: string, fallbackPosition?: "prepend" | "append"): string;
20
+ /**
21
+ * Injects an HTML snippet right before `</body>`, or appends it if no `</body>` tag exists.
22
+ */
23
+ export declare function injectBeforeBodyEnd(html: string, snippet: string): string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Standardized console logging and error formatting utilities for Buntic.
3
+ */
4
+ export declare function getErrorMessage(err: unknown): string;
5
+ export declare function logWarn(message: string, label?: string): void;
6
+ export declare function logError(message: string, err?: unknown, label?: string): void;
@@ -0,0 +1,20 @@
1
+ import type { ResolvedConfig } from "../types.js";
2
+ /**
3
+ * Returns true if `targetPath` resolves strictly inside `baseDir` (or equals `baseDir`).
4
+ * Prevents path-traversal attacks via `..` segments or encoded slashes.
5
+ */
6
+ export declare function isPathInside(baseDir: string, targetPath: string): boolean;
7
+ /**
8
+ * Resolves a local asset reference (`src`) from either root/public (`/foo.png`) or relative to `fromFile`.
9
+ */
10
+ export declare function resolveLocalAssetPath(config: ResolvedConfig, src: string, fromFile: string): string;
11
+ /**
12
+ * Recursively collects file paths under `dir`, returning paths relative to `baseDir`
13
+ * when `relativeOutput` is true, or absolute paths otherwise.
14
+ */
15
+ export declare function walkFiles(dir: string, options?: {
16
+ baseDir?: string;
17
+ relativeToBase?: boolean;
18
+ ignoreDotfiles?: boolean;
19
+ filter?: (absPath: string, entryName: string) => boolean;
20
+ }): string[];
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "buntic",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.1",
4
+ "description": "Zero-dependency, blazing-fast static site generator native to Bun",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "bin": {
15
+ "buntic": "./dist/cli.js"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "templates",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "scripts": {
24
+ "build:pkg": "bun run scripts/build-package.ts",
25
+ "typecheck": "bunx tsc --noEmit",
26
+ "test": "bun test",
27
+ "prepublishOnly": "bun run build:pkg && bun test",
28
+ "dev": "bun ./bin/buntic.ts dev examples/simple --port 3333",
29
+ "build": "bun ./bin/buntic.ts build examples/simple"
30
+ },
31
+ "keywords": [
32
+ "bun",
33
+ "ssg",
34
+ "static-site-generator",
35
+ "zero-dependencies",
36
+ "htmlrewriter",
37
+ "web-components"
38
+ ],
39
+ "author": "j-loon <joselow.c.m@gmail.com>",
40
+ "license": "MIT",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/jloons/buntic.git"
44
+ },
45
+ "homepage": "https://github.com/jloons/buntic#readme",
46
+ "bugs": {
47
+ "url": "https://github.com/jloons/buntic/issues"
48
+ },
49
+ "engines": {
50
+ "bun": ">=1.4.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/bun": "^1.4.5",
54
+ "typescript": "^7.0.2"
55
+ }
56
+ }
@@ -0,0 +1,5 @@
1
+ dist
2
+ .buntic
3
+ .buntic-staging
4
+ .DS_Store
5
+ *.log
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from "buntic";
2
+
3
+ export default defineConfig({
4
+ port: 3000,
5
+ minify: true,
6
+ site: {
7
+ url: "https://example.com",
8
+ title: "Mi Sitio",
9
+ description: "Sitio web estático generado con Buntic",
10
+ },
11
+ seo: {
12
+ sitemap: true,
13
+ robots: true,
14
+ },
15
+ });
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="es">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <link rel="stylesheet" href="/styles/main.css">
7
+ <slot name="head"></slot>
8
+ </head>
9
+ <body>
10
+ <main>
11
+ <slot></slot>
12
+ </main>
13
+ </body>
14
+ </html>
@@ -0,0 +1,11 @@
1
+ <layout src="../layouts/main.html">
2
+ <seo
3
+ title="Inicio | Mi Sitio"
4
+ description="Sitio web estático generado con Buntic."
5
+ />
6
+
7
+ <section class="hero">
8
+ <h1>Hola desde Buntic</h1>
9
+ <p>Edita <code>src/pages/index.html</code> para empezar a construir tu sitio.</p>
10
+ </section>
11
+ </layout>
@@ -0,0 +1,2 @@
1
+ User-agent: *
2
+ Allow: /