Skip to content

Commit 0abe66e

Browse files
committed
att
1 parent d051030 commit 0abe66e

File tree

20 files changed

+2230
-209
lines changed

20 files changed

+2230
-209
lines changed

bun.lock

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@
6363
"typescript": "^5.9.2",
6464
},
6565
},
66+
"packages/client": {
67+
"name": "@kirejs/client",
68+
"version": "0.1.0",
69+
"dependencies": {
70+
"kire": "workspace:../../core",
71+
},
72+
"devDependencies": {
73+
"@biomejs/biome": "2.2.4",
74+
"@types/bun": "^1.2.22",
75+
"dts-bundle-generator": "^9.5.1",
76+
"tsup": "^8.5.0",
77+
"typescript": "^5.9.2",
78+
},
79+
},
6680
"packages/iconify": {
6781
"name": "@kirejs/iconify",
6882
"version": "0.1.0",
@@ -268,6 +282,8 @@
268282

269283
"@kirejs/assets": ["@kirejs/assets@workspace:packages/assets"],
270284

285+
"@kirejs/client": ["@kirejs/client@workspace:packages/client"],
286+
271287
"@kirejs/iconify": ["@kirejs/iconify@workspace:packages/iconify"],
272288

273289
"@kirejs/markdown": ["@kirejs/markdown@workspace:packages/markdown"],
@@ -666,6 +682,8 @@
666682

667683
"@kirejs/assets/@biomejs/biome": ["@biomejs/[email protected]", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.2.4", "@biomejs/cli-darwin-x64": "2.2.4", "@biomejs/cli-linux-arm64": "2.2.4", "@biomejs/cli-linux-arm64-musl": "2.2.4", "@biomejs/cli-linux-x64": "2.2.4", "@biomejs/cli-linux-x64-musl": "2.2.4", "@biomejs/cli-win32-arm64": "2.2.4", "@biomejs/cli-win32-x64": "2.2.4" }, "bin": { "biome": "bin/biome" } }, "sha512-TBHU5bUy/Ok6m8c0y3pZiuO/BZoY/OcGxoLlrfQof5s8ISVwbVBdFINPQZyFfKwil8XibYWb7JMwnT8wT4WVPg=="],
668684

685+
"@kirejs/client/@biomejs/biome": ["@biomejs/[email protected]", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.2.4", "@biomejs/cli-darwin-x64": "2.2.4", "@biomejs/cli-linux-arm64": "2.2.4", "@biomejs/cli-linux-arm64-musl": "2.2.4", "@biomejs/cli-linux-x64": "2.2.4", "@biomejs/cli-linux-x64-musl": "2.2.4", "@biomejs/cli-win32-arm64": "2.2.4", "@biomejs/cli-win32-x64": "2.2.4" }, "bin": { "biome": "bin/biome" } }, "sha512-TBHU5bUy/Ok6m8c0y3pZiuO/BZoY/OcGxoLlrfQof5s8ISVwbVBdFINPQZyFfKwil8XibYWb7JMwnT8wT4WVPg=="],
686+
669687
"@kirejs/iconify/@biomejs/biome": ["@biomejs/[email protected]", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.2.4", "@biomejs/cli-darwin-x64": "2.2.4", "@biomejs/cli-linux-arm64": "2.2.4", "@biomejs/cli-linux-arm64-musl": "2.2.4", "@biomejs/cli-linux-x64": "2.2.4", "@biomejs/cli-linux-x64-musl": "2.2.4", "@biomejs/cli-win32-arm64": "2.2.4", "@biomejs/cli-win32-x64": "2.2.4" }, "bin": { "biome": "bin/biome" } }, "sha512-TBHU5bUy/Ok6m8c0y3pZiuO/BZoY/OcGxoLlrfQof5s8ISVwbVBdFINPQZyFfKwil8XibYWb7JMwnT8wT4WVPg=="],
670688

671689
"@kirejs/markdown/@biomejs/biome": ["@biomejs/[email protected]", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.2.4", "@biomejs/cli-darwin-x64": "2.2.4", "@biomejs/cli-linux-arm64": "2.2.4", "@biomejs/cli-linux-arm64-musl": "2.2.4", "@biomejs/cli-linux-x64": "2.2.4", "@biomejs/cli-linux-x64-musl": "2.2.4", "@biomejs/cli-win32-arm64": "2.2.4", "@biomejs/cli-win32-x64": "2.2.4" }, "bin": { "biome": "bin/biome" } }, "sha512-TBHU5bUy/Ok6m8c0y3pZiuO/BZoY/OcGxoLlrfQof5s8ISVwbVBdFINPQZyFfKwil8XibYWb7JMwnT8wT4WVPg=="],
@@ -740,6 +758,22 @@
740758

741759
"@kirejs/assets/@biomejs/biome/@biomejs/cli-win32-x64": ["@biomejs/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-3Y4V4zVRarVh/B/eSHczR4LYoSVyv3Dfuvm3cWs5w/HScccS0+Wt/lHOcDTRYeHjQmMYVC3rIRWqyN2EI52+zg=="],
742760

761+
"@kirejs/client/@biomejs/biome/@biomejs/cli-darwin-arm64": ["@biomejs/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-RJe2uiyaloN4hne4d2+qVj3d3gFJFbmrr5PYtkkjei1O9c+BjGXgpUPVbi8Pl8syumhzJjFsSIYkcLt2VlVLMA=="],
762+
763+
"@kirejs/client/@biomejs/biome/@biomejs/cli-darwin-x64": ["@biomejs/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-cFsdB4ePanVWfTnPVaUX+yr8qV8ifxjBKMkZwN7gKb20qXPxd/PmwqUH8mY5wnM9+U0QwM76CxFyBRJhC9tQwg=="],
764+
765+
"@kirejs/client/@biomejs/biome/@biomejs/cli-linux-arm64": ["@biomejs/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-M/Iz48p4NAzMXOuH+tsn5BvG/Jb07KOMTdSVwJpicmhN309BeEyRyQX+n1XDF0JVSlu28+hiTQ2L4rZPvu7nMw=="],
766+
767+
"@kirejs/client/@biomejs/biome/@biomejs/cli-linux-arm64-musl": ["@biomejs/[email protected]", "", { "os": "linux", "cpu": "arm64" }, "sha512-7TNPkMQEWfjvJDaZRSkDCPT/2r5ESFPKx+TEev+I2BXDGIjfCZk2+b88FOhnJNHtksbOZv8ZWnxrA5gyTYhSsQ=="],
768+
769+
"@kirejs/client/@biomejs/biome/@biomejs/cli-linux-x64": ["@biomejs/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-orr3nnf2Dpb2ssl6aihQtvcKtLySLta4E2UcXdp7+RTa7mfJjBgIsbS0B9GC8gVu0hjOu021aU8b3/I1tn+pVQ=="],
770+
771+
"@kirejs/client/@biomejs/biome/@biomejs/cli-linux-x64-musl": ["@biomejs/[email protected]", "", { "os": "linux", "cpu": "x64" }, "sha512-m41nFDS0ksXK2gwXL6W6yZTYPMH0LughqbsxInSKetoH6morVj43szqKx79Iudkp8WRT5SxSh7qVb8KCUiewGg=="],
772+
773+
"@kirejs/client/@biomejs/biome/@biomejs/cli-win32-arm64": ["@biomejs/[email protected]", "", { "os": "win32", "cpu": "arm64" }, "sha512-NXnfTeKHDFUWfxAefa57DiGmu9VyKi0cDqFpdI+1hJWQjGJhJutHPX0b5m+eXvTKOaf+brU+P0JrQAZMb5yYaQ=="],
774+
775+
"@kirejs/client/@biomejs/biome/@biomejs/cli-win32-x64": ["@biomejs/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-3Y4V4zVRarVh/B/eSHczR4LYoSVyv3Dfuvm3cWs5w/HScccS0+Wt/lHOcDTRYeHjQmMYVC3rIRWqyN2EI52+zg=="],
776+
743777
"@kirejs/iconify/@biomejs/biome/@biomejs/cli-darwin-arm64": ["@biomejs/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-RJe2uiyaloN4hne4d2+qVj3d3gFJFbmrr5PYtkkjei1O9c+BjGXgpUPVbi8Pl8syumhzJjFsSIYkcLt2VlVLMA=="],
744778

745779
"@kirejs/iconify/@biomejs/biome/@biomejs/cli-darwin-x64": ["@biomejs/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-cFsdB4ePanVWfTnPVaUX+yr8qV8ifxjBKMkZwN7gKb20qXPxd/PmwqUH8mY5wnM9+U0QwM76CxFyBRJhC9tQwg=="],

core/llms.txt

Lines changed: 64 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export interface KireCache<T = any> {
99
has(key: string): boolean;
1010
delete(key: string): boolean;
1111
clear(): void;
12+
entries(): IterableIterator<[string, T]>;
1213
}
1314

1415
export interface KireConfig {
@@ -212,6 +213,7 @@ export class Kire {
212213
has: (key: string) => store.has(key),
213214
delete: (key: string) => store.delete(key),
214215
clear: () => store.clear(),
216+
entries: () => store.entries(),
215217
};
216218
}
217219

@@ -1460,6 +1462,63 @@ export class Parser {
14601462
}
14611463

14621464

1465+
// --- From: core/src/utils/path.ts ---
1466+
/**
1467+
* Joins path segments and normalizes the resulting path
1468+
*/
1469+
export function join(...segments: string[]): string {
1470+
if (!segments.length) return ".";
1471+
1472+
const windowsAbsoluteRegex = /^[a-zA-Z]:[\\/]/;
1473+
const isWindowsAbsolute = segments.some((s) => windowsAbsoluteRegex.test(s));
1474+
const driveLetter = isWindowsAbsolute
1475+
? segments
1476+
.find((s) => windowsAbsoluteRegex.test(s))
1477+
?.charAt(0)
1478+
.toUpperCase()
1479+
: null;
1480+
1481+
// Normalize all segments at once
1482+
const normalized = segments
1483+
.join("/")
1484+
.replace(/\\/g, "/")
1485+
.replace(/\/+/g, "/");
1486+
const isAbsolute = /^(?:\/|[a-zA-Z]:\/)/.test(normalized);
1487+
1488+
const parts = normalized.split("/");
1489+
const result: string[] = [];
1490+
let i = 0;
1491+
1492+
while (i < parts.length) {
1493+
const part = parts[i++];
1494+
if (!part || part === ".") continue;
1495+
1496+
if (part === "..") {
1497+
if (result.length && result[result.length - 1] !== "..") {
1498+
result.pop();
1499+
} else {
1500+
result.push(part);
1501+
}
1502+
} else {
1503+
result.push(part);
1504+
}
1505+
}
1506+
1507+
let path = result.join("/");
1508+
1509+
if (isWindowsAbsolute && driveLetter) {
1510+
path = path.replace(/^[a-zA-Z]:/, "").replace(/^\//, "");
1511+
path = `${driveLetter}:\\${path.replace(/\//g, "\\")}`.replace(
1512+
/\\+/g,
1513+
"\\",
1514+
);
1515+
return path || ".";
1516+
}
1517+
1518+
return isAbsolute ? `/${path.replace(/^\//, "")}` : path || ".";
1519+
}
1520+
1521+
14631522
// --- From: core/src/compiler/index.ts ---
14641523
import type { Kire } from "../kire";
14651524
import type { KireContext, Node } from "../types";
@@ -1580,7 +1639,11 @@ export class Compiler {
15801639
this.preBuffer.push(code);
15811640
},
15821641
res: (content: string) => {
1583-
this.resBuffer.push(`$ctx.res(\`${content}\`);`);
1642+
const escaped = content
1643+
.replace(/\\/g, "\\\\")
1644+
.replace(/`/g, "\\`")
1645+
.replace(/\$\{/g, "\\${");
1646+
this.resBuffer.push(`$ctx.res(\`${escaped}\`);`);
15841647
},
15851648
raw: (code: string) => {
15861649
this.resBuffer.push(code);
@@ -1606,60 +1669,3 @@ export class Compiler {
16061669
}
16071670

16081671

1609-
// --- From: core/src/utils/path.ts ---
1610-
/**
1611-
* Joins path segments and normalizes the resulting path
1612-
*/
1613-
export function join(...segments: string[]): string {
1614-
if (!segments.length) return ".";
1615-
1616-
const windowsAbsoluteRegex = /^[a-zA-Z]:[\\/]/;
1617-
const isWindowsAbsolute = segments.some((s) => windowsAbsoluteRegex.test(s));
1618-
const driveLetter = isWindowsAbsolute
1619-
? segments
1620-
.find((s) => windowsAbsoluteRegex.test(s))
1621-
?.charAt(0)
1622-
.toUpperCase()
1623-
: null;
1624-
1625-
// Normalize all segments at once
1626-
const normalized = segments
1627-
.join("/")
1628-
.replace(/\\/g, "/")
1629-
.replace(/\/+/g, "/");
1630-
const isAbsolute = /^(?:\/|[a-zA-Z]:\/)/.test(normalized);
1631-
1632-
const parts = normalized.split("/");
1633-
const result: string[] = [];
1634-
let i = 0;
1635-
1636-
while (i < parts.length) {
1637-
const part = parts[i++];
1638-
if (!part || part === ".") continue;
1639-
1640-
if (part === "..") {
1641-
if (result.length && result[result.length - 1] !== "..") {
1642-
result.pop();
1643-
} else {
1644-
result.push(part);
1645-
}
1646-
} else {
1647-
result.push(part);
1648-
}
1649-
}
1650-
1651-
let path = result.join("/");
1652-
1653-
if (isWindowsAbsolute && driveLetter) {
1654-
path = path.replace(/^[a-zA-Z]:/, "").replace(/^\//, "");
1655-
path = `${driveLetter}:\\${path.replace(/\//g, "\\")}`.replace(
1656-
/\\+/g,
1657-
"\\",
1658-
);
1659-
return path || ".";
1660-
}
1661-
1662-
return isAbsolute ? `/${path.replace(/^\//, "")}` : path || ".";
1663-
}
1664-
1665-

core/src/compiler/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@ export class Compiler {
117117
this.preBuffer.push(code);
118118
},
119119
res: (content: string) => {
120-
this.resBuffer.push(`$ctx.res(\`${content}\`);`);
120+
const escaped = content
121+
.replace(/\\/g, "\\\\")
122+
.replace(/`/g, "\\`")
123+
.replace(/\$\{/g, "\\${");
124+
this.resBuffer.push(`$ctx.res(\`${escaped}\`);`);
121125
},
122126
raw: (code: string) => {
123127
this.resBuffer.push(code);

docs/.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# dependencies (bun install)
2+
node_modules
3+
4+
# output
5+
out
6+
dist
7+
*.tgz
8+
9+
# code coverage
10+
coverage
11+
*.lcov
12+
13+
# logs
14+
logs
15+
_.log
16+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
17+
18+
# dotenv environment variable files
19+
.env
20+
.env.development.local
21+
.env.test.local
22+
.env.production.local
23+
.env.local
24+
25+
# caches
26+
.eslintcache
27+
.cache
28+
*.tsbuildinfo
29+
30+
# IntelliJ based IDEs
31+
.idea
32+
33+
# Finder (MacOS) folder config
34+
.DS_Store

docs/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# kire-docs
2+
3+
To install dependencies:
4+
5+
```bash
6+
bun install
7+
```
8+
9+
To run:
10+
11+
```bash
12+
bun run
13+
```
14+
15+
This project was created using `bun init` in bun v1.3.3. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.

docs/bun.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,23 @@
1010
"marked": "^17.0.1",
1111
"tailwindcss": "^4.0.0",
1212
},
13+
"devDependencies": {
14+
"@types/bun": "latest",
15+
},
16+
"peerDependencies": {
17+
"typescript": "^5",
18+
},
1319
},
1420
},
1521
"packages": {
1622
"@tailwindcss/typography": ["@tailwindcss/[email protected]", "", { "dependencies": { "postcss-selector-parser": "6.0.10" }, "peerDependencies": { "tailwindcss": ">=3.0.0 || insiders || >=4.0.0-alpha.20 || >=4.0.0-beta.1" } }, "sha512-w31dd8HOx3k9vPtcQh5QHP9GwKcgbMp87j58qi6xgiBnFFtKEAgCWnDw4qUT8aHwkCp8bKvb/KGKWWHedP0AAg=="],
1723

24+
"@types/bun": ["@types/[email protected]", "", { "dependencies": { "bun-types": "1.3.3" } }, "sha512-ogrKbJ2X5N0kWLLFKeytG0eHDleBYtngtlbu9cyBKFtNL3cnpDZkNdQj8flVf6WTZUX5ulI9AY1oa7ljhSrp+g=="],
25+
26+
"@types/node": ["@types/[email protected]", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ=="],
27+
28+
"bun-types": ["[email protected]", "", { "dependencies": { "@types/node": "*" } }, "sha512-z3Xwlg7j2l9JY27x5Qn3Wlyos8YAp0kKRlrePAOjgjMGS5IG6E7Jnlx736vH9UVI4wUICwwhC9anYL++XeOgTQ=="],
29+
1830
"cssesc": ["[email protected]", "", { "bin": { "cssesc": "bin/cssesc" } }, "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg=="],
1931

2032
"daisyui": ["[email protected]", "", {}, "sha512-ekvI93ZkWIJoCOtDl0D2QMxnWvTejk9V5nWBqRv+7t0xjiBXqAK5U6o6JE2RPvlIC3EqwNyUoIZSdHX9MZK3nw=="],
@@ -25,6 +37,10 @@
2537

2638
"tailwindcss": ["[email protected]", "", {}, "sha512-j9Ee2YjuQqYT9bbRTfTZht9W/ytp5H+jJpZKiYdP/bpnXARAuELt9ofP0lPnmHjbga7SNQIxdTAXCmtKVYjN+Q=="],
2739

40+
"typescript": ["[email protected]", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
41+
42+
"undici-types": ["[email protected]", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
43+
2844
"util-deprecate": ["[email protected]", "", {}, "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="],
2945
}
3046
}

docs/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,12 @@
1111
"daisyui": "^5.0.0",
1212
"marked": "^17.0.1",
1313
"tailwindcss": "^4.0.0"
14+
},
15+
"private": true,
16+
"devDependencies": {
17+
"@types/bun": "latest"
18+
},
19+
"peerDependencies": {
20+
"typescript": "^5"
1421
}
1522
}

0 commit comments

Comments
 (0)