buntic 0.3.0 → 0.4.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.
Files changed (34) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +39 -39
  3. package/dist/cli.js +1362 -189
  4. package/dist/config.d.ts +5 -5
  5. package/dist/index.d.ts +6 -5
  6. package/dist/index.js +1389 -201
  7. package/dist/router/routes.d.ts +1 -1
  8. package/dist/runtime.d.ts +8 -9
  9. package/dist/server/dev-helpers.d.ts +1 -1
  10. package/dist/storage/oras/adapter.d.ts +2 -2
  11. package/dist/template/block-scanner.d.ts +28 -0
  12. package/dist/template/directives.d.ts +17 -8
  13. package/dist/template/engine.d.ts +2 -1
  14. package/dist/template/errors.d.ts +58 -0
  15. package/dist/template/expressions.d.ts +16 -0
  16. package/dist/template/scoped-css.d.ts +1 -1
  17. package/dist/types.d.ts +1 -1
  18. package/dist/utils/html.d.ts +1 -1
  19. package/dist/utils/logger.d.ts +1 -1
  20. package/package.json +7 -7
  21. package/templates/blank/_gitignore +2 -2
  22. package/templates/blank/{bustatic.config.ts → buntic.config.ts} +2 -2
  23. package/templates/blank/src/pages/index.html +2 -2
  24. package/templates/blank/tsconfig.json +4 -9
  25. package/templates/simple/README.md +6 -6
  26. package/templates/simple/_gitignore +2 -2
  27. package/templates/simple/{bustatic.config.ts → buntic.config.ts} +2 -2
  28. package/templates/simple/src/components/footer.html +1 -1
  29. package/templates/simple/src/data/site.json +3 -3
  30. package/templates/simple/src/pages/about.html +1 -1
  31. package/templates/simple/src/pages/contact.html +1 -1
  32. package/templates/simple/tsconfig.json +4 -9
  33. package/templates/skills/{bustatic → buntic}/SKILL.md +83 -43
  34. package/templates/skills/{bustatic → buntic}/examples/README.md +4 -4
@@ -40,7 +40,7 @@ export declare function buildCleanUrl(patternRelPath: string, params: Record<str
40
40
  relOutputPath: string;
41
41
  };
42
42
  /**
43
- * Resolves all routes (static and dynamic) in a Bustatic project.
43
+ * Resolves all routes (static and dynamic) in a Buntic project.
44
44
  * Enforces co-located loaders, executes them, validates parameters, and prevents URL collisions.
45
45
  */
46
46
  export declare function resolveAllRoutes(config: ResolvedConfig, globalData: Record<string, unknown>, options?: {
package/dist/runtime.d.ts CHANGED
@@ -1,24 +1,23 @@
1
1
  /**
2
- * Resolves the root directory of the installed/running bustatic package.
2
+ * Resolves the root directory of the installed/running buntic package.
3
3
  */
4
4
  export declare function getPackageRoot(): string;
5
5
  /**
6
- * Returns the runtime entry point for the currently running bustatic package.
6
+ * Returns the runtime entry point for the currently running buntic package.
7
7
  */
8
8
  export declare function getSelfEntryPath(): string;
9
9
  /**
10
- * Checks whether a project directory (or any ancestor) has a local
11
- * node_modules/bun-bustatic or node_modules/bustatic installation.
10
+ * Checks whether a project directory (or any ancestor) has a local node_modules/buntic installation.
12
11
  */
13
- export declare function hasLocalBustaticPackage(startDir: string): boolean;
12
+ export declare function hasLocalBunticPackage(startDir: string): boolean;
14
13
  /**
15
14
  * Registers a runtime Bun.plugin so projects without package.json / node_modules
16
- * can import from "bun-bustatic" or "bustatic" (e.g. bustatic.config.ts, storage/*.ts)
17
- * when executed via a globally installed bustatic CLI.
15
+ * can import from "buntic" (e.g. buntic.config.ts, storage/*.ts) when executed
16
+ * via a globally installed buntic CLI.
18
17
  */
19
- export declare function registerBustaticModuleResolver(projectDir?: string): void;
18
+ export declare function registerBunticModuleResolver(projectDir?: string): void;
20
19
  /**
21
- * Copies Bustatic's .d.ts declarations into .bustatic/types/ so TypeScript / VS Code
20
+ * Copies Buntic's .d.ts declarations into .buntic/types/ so TypeScript / VS Code
22
21
  * provides full autocomplete and type checking in zero-package.json projects via tsconfig paths.
23
22
  */
24
23
  export declare function syncProjectTypes(projectRoot: string): boolean;
@@ -2,7 +2,7 @@ import type { PageRouteInfo, PageSeo, ResolvedConfig } from "../types.js";
2
2
  import type { PhotoProcessor } from "../assets/photo-tag.js";
3
3
  import type { SeoMetadataEngine } from "../seo/metadata.js";
4
4
  import type { TemplateEngine } from "../template/engine.js";
5
- export declare const LIVE_RELOAD_SCRIPT = "\n<script id=\"__bustatic_live_reload\">\n (() => {\n const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';\n const ws = new WebSocket(`${protocol}//${location.host}/_bustatic/ws`);\n ws.onmessage = (event) => {\n if (event.data === 'reload') {\n console.log('[bustatic] Change detected. Reloading...');\n location.reload();\n }\n };\n ws.onclose = () => {\n setTimeout(() => location.reload(), 1500);\n };\n })();\n</script>\n";
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
6
  /**
7
7
  * Renders an HTML page through TemplateEngine, PhotoProcessor, SeoMetadataEngine,
8
8
  * and appends the dev live-reload WebSocket snippet.
@@ -1,12 +1,12 @@
1
1
  import type { StorageLoaderFn } from "../../types.js";
2
2
  import type { OrasStorageOptions } from "./types.js";
3
3
  /**
4
- * Creates a Bustatic storage loader function backed by an OCI Registry / ORAS.
4
+ * Creates a Buntic storage loader function backed by an OCI Registry / ORAS.
5
5
  *
6
6
  * @example
7
7
  * ```ts
8
8
  * // storage/oci.ts
9
- * import { createOrasStorage } from "bustatic";
9
+ * import { createOrasStorage } from "buntic";
10
10
  *
11
11
  * export default createOrasStorage({
12
12
  * hostname: "localhost:5000",
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Balanced, quote-aware HTML directive block scanner.
3
+ * Handles nested blocks (<if>, <unless>, <match>, <each>), operators like ">" inside
4
+ * quoted attributes (e.g. <if is="age > 18">), HTML comments, and raw <script>/<style> blocks.
5
+ */
6
+ export interface TemplateBlock {
7
+ tag: string;
8
+ fullMatch: string;
9
+ openTag: string;
10
+ attrString: string;
11
+ inner: string;
12
+ start: number;
13
+ end: number;
14
+ }
15
+ export interface SplitSubBlocksResult {
16
+ body: string;
17
+ subBlocks: TemplateBlock[];
18
+ }
19
+ /**
20
+ * Finds all top-level balanced blocks for the given directive tag names.
21
+ */
22
+ export declare function findTopLevelBlocks(html: string, tagNames: string[]): TemplateBlock[];
23
+ /**
24
+ * Extracts direct (depth-0) child sub-blocks (`allowedTags`) from `inner` while ignoring
25
+ * identically named tags nested inside `nestedScopeTags` (e.g. an `<else>` inside a nested `<if>`).
26
+ * Returns the remaining body text (with extracted sub-blocks removed) and the ordered sub-blocks.
27
+ */
28
+ export declare function splitDirectSubBlocks(inner: string, allowedTags: string[], nestedScopeTags: string[]): SplitSubBlocksResult;
@@ -1,13 +1,22 @@
1
1
  /**
2
- * Pure template directive evaluators: conditionals (<if> / if="...") and {{ var ?? "fallback" }} interpolation.
2
+ * Template directive evaluators:
3
+ * - Decision blocks: <if>, <unless>, <match>/<case>/<else>/<none>/<default>
4
+ * - Safe expressions in is="..." and conditional attribute if="..."
5
+ * - Strict typed value & range matchers (string, number, boolean, min, max)
6
+ * - Variable interpolation {{ var ?? "fallback" }}
3
7
  */
4
- export declare function isTruthy(val: unknown): boolean;
5
- export declare function getNestedValue(obj: unknown, path: string): unknown;
8
+ import { evaluateExpression, ExpressionSyntaxError, getNestedValue, isTruthy } from "./expressions.js";
9
+ export { evaluateExpression, ExpressionSyntaxError, getNestedValue, isTruthy };
10
+ export interface DirectiveDiagnosticContext {
11
+ filePath?: string;
12
+ source?: string;
13
+ projectRoot?: string;
14
+ }
6
15
  /**
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>
16
+ * Resolves all decision directives in `html`:
17
+ * 1. Block directives: `<if>`, `<unless>`, `<match>` (with balanced nesting)
18
+ * 2. Self-closing elements with conditional attribute: `<tag ... if="expr" ... />`
19
+ * 3. Paired elements with conditional attribute: `<tag ... if="expr" ...>...</tag>`
11
20
  */
12
- export declare function resolveConditionals(html: string, context: Record<string, unknown>): string;
21
+ export declare function resolveConditionals(html: string, context: Record<string, unknown>, diag?: DirectiveDiagnosticContext): string;
13
22
  export declare function interpolateTemplate(html: string, context: Record<string, unknown>): string;
@@ -30,10 +30,11 @@ export declare class TemplateEngine {
30
30
  assertNoWebComponentConflicts(): void;
31
31
  clearUsedWebComponents(): void;
32
32
  resolveFilePath(rawSrc: string, currentFile: string, defaultDir: string): string;
33
+ private getOriginalSource;
33
34
  private resolveLayout;
34
35
  resolveEach(html: string, context: TemplateContext, currentFile: string, depth?: number): Promise<string>;
35
36
  resolveComponents(html: string, context: TemplateContext, currentFile: string, depth?: number): Promise<string>;
36
37
  private renderWebComponentAlias;
37
- resolveConditionals(html: string, context: TemplateContext): string;
38
+ resolveConditionals(html: string, context: TemplateContext, currentFile?: string, originalSource?: string): string;
38
39
  interpolate(html: string, context: TemplateContext): string;
39
40
  }
@@ -0,0 +1,58 @@
1
+ export interface TemplateErrorLocation {
2
+ filePath?: string;
3
+ line?: number;
4
+ column?: number;
5
+ endColumn?: number;
6
+ source?: string;
7
+ }
8
+ export interface TemplateErrorOptions {
9
+ message: string;
10
+ location?: TemplateErrorLocation;
11
+ projectRoot?: string;
12
+ resolvedTarget?: string;
13
+ hint?: string;
14
+ cause?: unknown;
15
+ }
16
+ /**
17
+ * Formats an absolute file path cleanly relative to `projectRoot` when inside it.
18
+ */
19
+ export declare function formatTemplatePath(filePath: string, projectRoot?: string): string;
20
+ /**
21
+ * Converts a 0-based character offset in `source` into 1-based `{ line, column }`.
22
+ */
23
+ export declare function offsetToLineColumn(source: string, offset: number): {
24
+ line: number;
25
+ column: number;
26
+ };
27
+ /**
28
+ * Renders a compiler-style code frame highlighting `line` and underlining `column..endColumn`.
29
+ */
30
+ export declare function formatCodeFrame(source: string, line: number, column?: number, endColumn?: number, contextLines?: number): string;
31
+ /**
32
+ * Locates a template snippet inside the original template source (falling back to
33
+ * `fallbackHtml` + `fallbackOffset` when rendering inline/virtual templates).
34
+ */
35
+ export declare function findSnippetLocation(options: {
36
+ source?: string;
37
+ snippet: string;
38
+ openTag?: string;
39
+ fallbackHtml?: string;
40
+ fallbackOffset?: number;
41
+ filePath?: string;
42
+ }): TemplateErrorLocation;
43
+ /**
44
+ * Structured template error with source file, line/column, highlighted code frame,
45
+ * resolved target path, underlying cause, and actionable hint.
46
+ */
47
+ export declare class BunticTemplateError extends Error {
48
+ readonly summary: string;
49
+ readonly filePath?: string;
50
+ readonly line?: number;
51
+ readonly column?: number;
52
+ readonly endColumn?: number;
53
+ readonly codeFrame?: string;
54
+ readonly resolvedTarget?: string;
55
+ readonly causeMessage?: string;
56
+ readonly hint?: string;
57
+ constructor(options: TemplateErrorOptions);
58
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Zero-dependency, eval-free expression parser and evaluator for Buntic template directives.
3
+ * Supports nested paths (e.g. `position.x`, `items.length`), literals (numbers, strings,
4
+ * booleans, null, undefined), unary (`!`, `-`), relational (`<`, `<=`, `>`, `>=`),
5
+ * equality (`===`, `!==`, `==`, `!=`), logical (`&&`, `||`), and parentheses.
6
+ */
7
+ export declare class ExpressionSyntaxError extends Error {
8
+ readonly hint?: string;
9
+ constructor(message: string, hint?: string);
10
+ }
11
+ export declare function isTruthy(val: unknown): boolean;
12
+ export declare function getNestedValue(obj: unknown, path: string): unknown;
13
+ /**
14
+ * Safely parses and evaluates a template expression against `context`.
15
+ */
16
+ export declare function evaluateExpression(expr: string, context: Record<string, unknown>): unknown;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Bustatic Scoped CSS Processor
2
+ * Buntic Scoped CSS Processor
3
3
  * Handles <style scoped> blocks, scoping registry, sibling CSS attachment,
4
4
  * and depth-ordered extraction.
5
5
  */
package/dist/types.d.ts CHANGED
@@ -62,7 +62,7 @@ export interface PhotoAttributes {
62
62
  id?: string;
63
63
  [key: string]: any;
64
64
  }
65
- export interface BustaticConfig {
65
+ export interface BunticConfig {
66
66
  root?: string;
67
67
  pagesDir?: string;
68
68
  layoutsDir?: string;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Shared HTML and XML string utilities for Bustatic.
2
+ * Shared HTML and XML string utilities for Buntic.
3
3
  */
4
4
  export declare function escapeHtml(str: string): string;
5
5
  export declare function escapeXml(str: string): string;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Standardized console logging and error formatting utilities for Bustatic.
2
+ * Standardized console logging and error formatting utilities for Buntic.
3
3
  */
4
4
  export declare function getErrorMessage(err: unknown): string;
5
5
  export declare function logWarn(message: string, label?: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buntic",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Zero-dependency, blazing-fast static site generator native to Bun",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -12,7 +12,7 @@
12
12
  }
13
13
  },
14
14
  "bin": {
15
- "bustatic": "./dist/cli.js"
15
+ "buntic": "./dist/cli.js"
16
16
  },
17
17
  "files": [
18
18
  "dist",
@@ -25,8 +25,8 @@
25
25
  "typecheck": "bunx tsc --noEmit",
26
26
  "test": "bun test",
27
27
  "prepublishOnly": "bun run build:pkg && bun test",
28
- "dev": "bun ./bin/bustatic.ts dev examples/simple --port 3333",
29
- "build": "bun ./bin/bustatic.ts build examples/simple"
28
+ "dev": "bun ./bin/buntic.ts dev examples/simple --port 3333",
29
+ "build": "bun ./bin/buntic.ts build examples/simple"
30
30
  },
31
31
  "keywords": [
32
32
  "bun",
@@ -40,11 +40,11 @@
40
40
  "license": "MIT",
41
41
  "repository": {
42
42
  "type": "git",
43
- "url": "git+https://github.com/jloons/bustatic.git"
43
+ "url": "git+https://github.com/jloons/buntic.git"
44
44
  },
45
- "homepage": "https://github.com/jloons/bustatic#readme",
45
+ "homepage": "https://github.com/jloons/buntic#readme",
46
46
  "bugs": {
47
- "url": "https://github.com/jloons/bustatic/issues"
47
+ "url": "https://github.com/jloons/buntic/issues"
48
48
  },
49
49
  "engines": {
50
50
  "bun": ">=1.4.0"
@@ -1,5 +1,5 @@
1
1
  dist
2
- .bustatic
3
- .bustatic-staging
2
+ .buntic
3
+ .buntic-staging
4
4
  .DS_Store
5
5
  *.log
@@ -1,4 +1,4 @@
1
- import { defineConfig } from "bun-bustatic";
1
+ import { defineConfig } from "buntic";
2
2
 
3
3
  export default defineConfig({
4
4
  port: 3000,
@@ -6,7 +6,7 @@ export default defineConfig({
6
6
  site: {
7
7
  url: "https://example.com",
8
8
  title: "Mi Sitio",
9
- description: "Sitio web estático generado con Bustatic",
9
+ description: "Sitio web estático generado con Buntic",
10
10
  },
11
11
  seo: {
12
12
  sitemap: true,
@@ -1,11 +1,11 @@
1
1
  <layout src="../layouts/main.html">
2
2
  <seo
3
3
  title="Inicio | Mi Sitio"
4
- description="Sitio web estático generado con Bustatic."
4
+ description="Sitio web estático generado con Buntic."
5
5
  />
6
6
 
7
7
  <section class="hero">
8
- <h1>Hola desde Bustatic</h1>
8
+ <h1>Hola desde Buntic</h1>
9
9
  <p>Edita <code>src/pages/index.html</code> para empezar a construir tu sitio.</p>
10
10
  </section>
11
11
  </layout>
@@ -11,16 +11,11 @@
11
11
  "skipLibCheck": true,
12
12
  "forceConsistentCasingInFileNames": true,
13
13
  "paths": {
14
- "bun-bustatic": [
15
- "./node_modules/bun-bustatic/dist/index.d.ts",
16
- "./.bustatic/types/index.d.ts"
17
- ],
18
- "bustatic": [
19
- "./node_modules/bun-bustatic/dist/index.d.ts",
20
- "./node_modules/bustatic/dist/index.d.ts",
21
- "./.bustatic/types/index.d.ts"
14
+ "buntic": [
15
+ "./node_modules/buntic/dist/index.d.ts",
16
+ "./.buntic/types/index.d.ts"
22
17
  ]
23
18
  }
24
19
  },
25
- "include": ["src/**/*", "bustatic.config.ts"]
20
+ "include": ["src/**/*", "buntic.config.ts"]
26
21
  }
@@ -1,6 +1,6 @@
1
- # ⚡ Bustatic Simple
1
+ # ⚡ Buntic Simple
2
2
 
3
- Sitio multipágina estático creado con **Bustatic** (sin `package.json` ni `node_modules`).
3
+ Sitio multipágina estático creado con **Buntic** (sin `package.json` ni `node_modules`).
4
4
 
5
5
  ---
6
6
 
@@ -15,7 +15,7 @@ mi-sitio/
15
15
  │ ├── data/ # site.json, features.json
16
16
  │ ├── styles/ # main.css
17
17
  │ └── public/ # robots.txt
18
- ├── bustatic.config.ts
18
+ ├── buntic.config.ts
19
19
  └── tsconfig.json
20
20
  ```
21
21
 
@@ -25,11 +25,11 @@ mi-sitio/
25
25
 
26
26
  ```bash
27
27
  # Servidor de desarrollo con live-reload
28
- bustatic dev
28
+ buntic dev
29
29
 
30
30
  # Compilar para producción en dist/
31
- bustatic build
31
+ buntic build
32
32
 
33
33
  # Limpiar dist/ y caché
34
- bustatic clean
34
+ buntic clean
35
35
  ```
@@ -1,5 +1,5 @@
1
1
  dist
2
- .bustatic
3
- .bustatic-staging
2
+ .buntic
3
+ .buntic-staging
4
4
  .DS_Store
5
5
  *.log
@@ -1,4 +1,4 @@
1
- import { defineConfig } from "bun-bustatic";
1
+ import { defineConfig } from "buntic";
2
2
 
3
3
  export default defineConfig({
4
4
  port: 3000,
@@ -6,6 +6,6 @@ export default defineConfig({
6
6
  site: {
7
7
  url: "https://misitio.com",
8
8
  title: "Mi Proyecto",
9
- description: "Sitio web generado con Bustatic"
9
+ description: "Sitio web generado con Buntic"
10
10
  }
11
11
  });
@@ -1,5 +1,5 @@
1
1
  <footer class="site-footer">
2
2
  <div class="footer-inner">
3
- <p>&copy; {{ site.year }} {{ site.title }} - Hecho con Bustatic</p>
3
+ <p>&copy; {{ site.year }} {{ site.title }} - Hecho con Buntic</p>
4
4
  </div>
5
5
  </footer>
@@ -1,8 +1,8 @@
1
1
  {
2
- "title": "Bustatic Simple",
3
- "description": "Ejemplo estático sencillo y moderno creado con Bustatic",
2
+ "title": "Buntic Simple",
3
+ "description": "Ejemplo estático sencillo y moderno creado con Buntic",
4
4
  "year": 2026,
5
- "author": "Equipo Bustatic",
5
+ "author": "Equipo Buntic",
6
6
  "navLinks": [
7
7
  { "label": "Inicio", "url": "/" },
8
8
  { "label": "Acerca de", "url": "/about" },
@@ -4,7 +4,7 @@
4
4
  <article>
5
5
  <h1>Acerca de este proyecto</h1>
6
6
  <p>
7
- Este es un ejemplo simple y completamente estático generado con <strong>Bustatic</strong>,
7
+ Este es un ejemplo simple y completamente estático generado con <strong>Buntic</strong>,
8
8
  demostrando la estructura de carpetas <code>src/</code> y componentes modulares.
9
9
  </p>
10
10
  <br>
@@ -6,7 +6,7 @@
6
6
  <p>¿Tienes dudas o comentarios? Puedes encontrarnos en:</p>
7
7
  <br>
8
8
  <ul>
9
- <li>GitHub: <a href="https://github.com" target="_blank">Repositorio de Bustatic</a></li>
9
+ <li>GitHub: <a href="https://github.com" target="_blank">Repositorio de Buntic</a></li>
10
10
  <li>Correo: contacto@example.com</li>
11
11
  </ul>
12
12
  </article>
@@ -11,16 +11,11 @@
11
11
  "skipLibCheck": true,
12
12
  "forceConsistentCasingInFileNames": true,
13
13
  "paths": {
14
- "bun-bustatic": [
15
- "./node_modules/bun-bustatic/dist/index.d.ts",
16
- "./.bustatic/types/index.d.ts"
17
- ],
18
- "bustatic": [
19
- "./node_modules/bun-bustatic/dist/index.d.ts",
20
- "./node_modules/bustatic/dist/index.d.ts",
21
- "./.bustatic/types/index.d.ts"
14
+ "buntic": [
15
+ "./node_modules/buntic/dist/index.d.ts",
16
+ "./.buntic/types/index.d.ts"
22
17
  ]
23
18
  }
24
19
  },
25
- "include": ["src/**/*", "bustatic.config.ts"]
20
+ "include": ["src/**/*", "buntic.config.ts"]
26
21
  }