@kirana-style/bun 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/LICENSE +21 -0
- package/package.json +8 -3
- package/src/index.d.ts +38 -37
- package/src/index.js +76 -86
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.2.0](https://github.com/kirana-style/kirana/compare/v0.1.0...v0.2.0) (2026-10-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* one command name, kirana-style ([#29](https://github.com/kirana-style/kirana/issues/29))
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **editor:** real editor output on the site, open vsx trusted publishing ([#21](https://github.com/kirana-style/kirana/issues/21)) ([350fa4e](https://github.com/kirana-style/kirana/commit/350fa4ec0d8054a082d6c7dcdae2b5be53f8d98a))
|
|
13
|
+
* one command name, kirana-style ([#29](https://github.com/kirana-style/kirana/issues/29)) ([b3f3154](https://github.com/kirana-style/kirana/commit/b3f3154662589dd1bd43fd0ff2341acf4f3df628))
|
|
14
|
+
* **site:** paper, ink, scenery and type for one identity ([#27](https://github.com/kirana-style/kirana/issues/27)) ([5da3c6f](https://github.com/kirana-style/kirana/commit/5da3c6f0f1c8cbfdb450b36a6609a3ab4b20e358))
|
|
15
|
+
* **site:** reorganise the homepage, product pages and docs ([#28](https://github.com/kirana-style/kirana/issues/28)) ([88b5209](https://github.com/kirana-style/kirana/commit/88b52093488b2aa0112b458ca04b836c83d03954))
|
|
16
|
+
* **site:** scenery gradients, logo downloads, pixel k, glass icons ([#25](https://github.com/kirana-style/kirana/issues/25)) ([2953dc1](https://github.com/kirana-style/kirana/commit/2953dc126f47b68257ebfdb33c61992984708c49))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug fixes
|
|
20
|
+
|
|
21
|
+
* hold emnapi at 2.0.0-alpha.6, the wasi engine fails on the beta ([#26](https://github.com/kirana-style/kirana/issues/26)) ([8aa33e1](https://github.com/kirana-style/kirana/commit/8aa33e1dbccaefa15b87f6487ac0a346bbf6581a))
|
|
22
|
+
* settle the ember dev check, resolve code scanning findings ([#23](https://github.com/kirana-style/kirana/issues/23)) ([0c266c8](https://github.com/kirana-style/kirana/commit/0c266c8428c1453892beeeb5f98918cbc0eae6ff))
|
|
23
|
+
* **site:** keep syntax colours in the production build ([#22](https://github.com/kirana-style/kirana/issues/22)) ([621f2fc](https://github.com/kirana-style/kirana/commit/621f2fcf67dada773ca66110e295ab7ac5605f56))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Documentation
|
|
27
|
+
|
|
28
|
+
* fix the extension's settings table ([#13](https://github.com/kirana-style/kirana/issues/13)) ([457e06d](https://github.com/kirana-style/kirana/commit/457e06d12f9e3b005e0820aab36faac5bf3f80b3))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Dependencies
|
|
32
|
+
|
|
33
|
+
* bump the minor-and-patch group across 1 directory with 3 updates ([#19](https://github.com/kirana-style/kirana/issues/19)) ([7ea00ed](https://github.com/kirana-style/kirana/commit/7ea00edcc5cc02b9ab5e41b13f152ae344ea448f))
|
|
34
|
+
* emnapi 2.0.0-beta.1, minor and patch updates ([#24](https://github.com/kirana-style/kirana/issues/24)) ([a399fa7](https://github.com/kirana-style/kirana/commit/a399fa78e53dcfd7f41f249ccee1133809e66544))
|
|
35
|
+
|
|
36
|
+
## [0.1.0](https://github.com/kirana-style/kirana/compare/v0.1.0...v0.1.0) (2026-10-13)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Features
|
|
40
|
+
|
|
41
|
+
* kirana goes public — write objects, read classes, ship css ([79732ed](https://github.com/kirana-style/kirana/commit/79732edd5cab419169ab74ad59e1c70053dfa57d))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Dependencies
|
|
45
|
+
|
|
46
|
+
* bump the minor-and-patch group in /packages/kirana with 6 updates ([#10](https://github.com/kirana-style/kirana/issues/10)) ([0deaf9f](https://github.com/kirana-style/kirana/commit/0deaf9f3e75ebc377d764c294250bd2577d53844))
|
|
47
|
+
* bump the oxc group in /packages/kirana with 7 updates ([#9](https://github.com/kirana-style/kirana/issues/9)) ([a3ca94c](https://github.com/kirana-style/kirana/commit/a3ca94c170b2ca49c9691abf5ad48c3ef4ac8620))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kirana authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kirana-style/bun",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Kirana for Bun's bundler: compiles modules and finishes the stylesheet.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "The Kirana authors",
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"url": "https://github.com/kirana-style/kirana/issues"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
17
20
|
"exports": {
|
|
18
21
|
".": {
|
|
19
22
|
"types": "./src/index.d.ts",
|
|
@@ -22,8 +25,8 @@
|
|
|
22
25
|
"./package.json": "./package.json"
|
|
23
26
|
},
|
|
24
27
|
"dependencies": {
|
|
25
|
-
"@kirana-style/compiler": "0.
|
|
26
|
-
"@kirana-style/core": "0.
|
|
28
|
+
"@kirana-style/compiler": "0.2.0",
|
|
29
|
+
"@kirana-style/core": "0.2.0"
|
|
27
30
|
},
|
|
28
31
|
"files": [
|
|
29
32
|
"src",
|
|
@@ -31,6 +34,8 @@
|
|
|
31
34
|
"*.d.ts",
|
|
32
35
|
"*.css",
|
|
33
36
|
"README.md",
|
|
37
|
+
"CHANGELOG.md",
|
|
38
|
+
"LICENSE",
|
|
34
39
|
"builders.json",
|
|
35
40
|
"schemas",
|
|
36
41
|
"gatsby-node.mjs",
|
package/src/index.d.ts
CHANGED
|
@@ -1,46 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { DriverOptions } from "@kirana-style/compiler";
|
|
2
|
+
import { KiranaConfig } from "@kirana-style/core/config";
|
|
3
|
+
//#region src/index.d.ts
|
|
3
4
|
export type KiranaBunOptions = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
/** The project root: where `kirana.config.*` and `@kirana-style/core` are found. Default: the working directory. */
|
|
6
|
+
root?: string;
|
|
7
|
+
/** Options that override `kirana.config.*`. */
|
|
8
|
+
config?: KiranaConfig;
|
|
9
|
+
/** Report `info` diagnostics (such as `dynamic-bridged`) as warnings. */
|
|
10
|
+
reportInfo?: boolean;
|
|
11
|
+
/** Injected Driver options (tests). */
|
|
12
|
+
driver?: Pick<DriverOptions, "native" | "importModule">;
|
|
12
13
|
};
|
|
13
14
|
type Loaded = {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
contents: string;
|
|
16
|
+
loader: string;
|
|
16
17
|
} | undefined;
|
|
17
18
|
/** The part of Bun's plugin builder the plugin uses. */
|
|
18
19
|
export type PluginBuilder = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
/** `Bun.build` passes its options, `entrypoints` included; the dev server (`bun ./index.html`) does not. */
|
|
21
|
+
config: {
|
|
22
|
+
minify?: boolean | object;
|
|
23
|
+
entrypoints?: unknown;
|
|
24
|
+
};
|
|
25
|
+
onResolve: (options: {
|
|
26
|
+
filter: RegExp;
|
|
27
|
+
}, resolve: (args: {
|
|
28
|
+
path: string;
|
|
29
|
+
}) => {
|
|
30
|
+
path: string;
|
|
31
|
+
} | undefined) => void;
|
|
32
|
+
onLoad: (options: {
|
|
33
|
+
filter: RegExp;
|
|
34
|
+
}, load: (args: {
|
|
35
|
+
path: string;
|
|
36
|
+
}) => Loaded | Promise<Loaded>) => void;
|
|
37
|
+
onEnd: (end: (result: {
|
|
38
|
+
outputs: {
|
|
39
|
+
path: string;
|
|
40
|
+
}[];
|
|
41
|
+
}) => void | Promise<void>) => void;
|
|
41
42
|
};
|
|
42
43
|
export default function kirana(options?: KiranaBunOptions): {
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
name: string;
|
|
45
|
+
setup(build: PluginBuilder): void;
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
+
//#endregion
|
package/src/index.js
CHANGED
|
@@ -1,95 +1,85 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Bun bundler host adapter (KRN-INT-001, KRN-INT-003): `onLoad` compiles modules, and `onEnd`
|
|
3
|
-
* writes the finished stylesheet into the CSS Bun emitted. It never interprets styles (D-028).
|
|
4
|
-
*
|
|
5
|
-
* The stylesheet entry loads as the placeholder rule, which Bun bundles like any CSS import; once
|
|
6
|
-
* every module has loaded, the plugin replaces it in the written file. Bun names CSS imported from a
|
|
7
|
-
* JavaScript entry after the entry (`main.css`), so the name stays right; a `naming` pattern that
|
|
8
|
-
* hashes assets would carry the placeholder's hash, and a build with `write: false` keeps the
|
|
9
|
-
* placeholder, since there is no file to finish.
|
|
10
|
-
*/
|
|
11
1
|
import { createHash } from "node:crypto";
|
|
12
2
|
import { existsSync, writeFileSync } from "node:fs";
|
|
13
3
|
import { readFile, writeFile } from "node:fs/promises";
|
|
14
4
|
import { tmpdir } from "node:os";
|
|
15
5
|
import { join } from "node:path";
|
|
16
6
|
import { Driver } from "@kirana-style/compiler";
|
|
17
|
-
import { PLACEHOLDER, createReporter, fillStylesheet, shouldCompile, stylesheetPath
|
|
7
|
+
import { PLACEHOLDER, createReporter, fillStylesheet, shouldCompile, stylesheetPath } from "@kirana-style/compiler/host";
|
|
8
|
+
//#region src/index.ts
|
|
9
|
+
/**
|
|
10
|
+
* The Bun bundler host adapter (KRN-INT-001, KRN-INT-003): `onLoad` compiles modules, and `onEnd`
|
|
11
|
+
* writes the finished stylesheet into the CSS Bun emitted. It never interprets styles (D-028).
|
|
12
|
+
*
|
|
13
|
+
* The stylesheet entry loads as the placeholder rule, which Bun bundles like any CSS import; once
|
|
14
|
+
* every module has loaded, the plugin replaces it in the written file. Bun names CSS imported from a
|
|
15
|
+
* JavaScript entry after the entry (`main.css`), so the name stays right; a `naming` pattern that
|
|
16
|
+
* hashes assets would carry the placeholder's hash, and a build with `write: false` keeps the
|
|
17
|
+
* placeholder, since there is no file to finish.
|
|
18
|
+
*/
|
|
18
19
|
const LOADERS = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
tsx: "tsx",
|
|
21
|
+
ts: "ts",
|
|
22
|
+
mts: "ts",
|
|
23
|
+
cts: "ts",
|
|
24
|
+
jsx: "jsx"
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const compiled = await session();
|
|
83
|
-
reporter.project(context, root, compiled.diagnostics());
|
|
84
|
-
const css = compiled.stylesheet(Boolean(build.config.minify));
|
|
85
|
-
for (const { path } of outputs) {
|
|
86
|
-
if (!path.endsWith(".css") || !existsSync(path))
|
|
87
|
-
continue;
|
|
88
|
-
const source = fillStylesheet(await readFile(path, "utf8"), css);
|
|
89
|
-
if (source !== undefined)
|
|
90
|
-
await writeFile(path, source);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
},
|
|
94
|
-
};
|
|
26
|
+
function kirana(options = {}) {
|
|
27
|
+
return {
|
|
28
|
+
name: "kirana",
|
|
29
|
+
setup(build) {
|
|
30
|
+
const root = options.root ?? process.cwd();
|
|
31
|
+
const stylesheetFile = stylesheetPath(root);
|
|
32
|
+
let driver;
|
|
33
|
+
const session = () => driver ??= Driver.create({
|
|
34
|
+
root,
|
|
35
|
+
config: options.config,
|
|
36
|
+
...options.driver
|
|
37
|
+
});
|
|
38
|
+
const reporter = createReporter(options);
|
|
39
|
+
const context = {
|
|
40
|
+
warn: (message) => console.warn(message),
|
|
41
|
+
error: (message) => {
|
|
42
|
+
throw new Error(message);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const live = !("entrypoints" in build.config) ? join(tmpdir(), `kirana-bun-${createHash("sha256").update(root).digest("hex").slice(0, 12)}.css`) : void 0;
|
|
46
|
+
const refresh = async () => {
|
|
47
|
+
if (live) await writeFile(live, (await session()).stylesheet(false));
|
|
48
|
+
};
|
|
49
|
+
if (live) {
|
|
50
|
+
writeFileSync(live, "");
|
|
51
|
+
build.onResolve({ filter: /^@kirana-style\/core\/stylesheet\.css$/ }, () => ({ path: live }));
|
|
52
|
+
}
|
|
53
|
+
build.onLoad({ filter: /stylesheet\.css$/ }, ({ path }) => path === stylesheetFile ? {
|
|
54
|
+
contents: PLACEHOLDER,
|
|
55
|
+
loader: "css"
|
|
56
|
+
} : void 0);
|
|
57
|
+
build.onLoad({ filter: /\.[cm]?[jt]sx?$/ }, async ({ path }) => {
|
|
58
|
+
const compiler = await session();
|
|
59
|
+
if (!compiler.compiles(path)) return void 0;
|
|
60
|
+
const code = await readFile(path, "utf8");
|
|
61
|
+
if (!shouldCompile(path, code, compiler.libraries)) return void 0;
|
|
62
|
+
const result = compiler.transform(path, code);
|
|
63
|
+
reporter.module(context, path, code, result.diagnostics);
|
|
64
|
+
if (result.cssChanged) await refresh();
|
|
65
|
+
if (result.code === void 0) return void 0;
|
|
66
|
+
return {
|
|
67
|
+
contents: result.code,
|
|
68
|
+
loader: LOADERS[path.slice(path.lastIndexOf(".") + 1)] ?? "js"
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
build.onEnd(async ({ outputs }) => {
|
|
72
|
+
const compiled = await session();
|
|
73
|
+
reporter.project(context, root, compiled.diagnostics());
|
|
74
|
+
const css = compiled.stylesheet(Boolean(build.config.minify));
|
|
75
|
+
for (const { path } of outputs) {
|
|
76
|
+
if (!path.endsWith(".css") || !existsSync(path)) continue;
|
|
77
|
+
const source = fillStylesheet(await readFile(path, "utf8"), css);
|
|
78
|
+
if (source !== void 0) await writeFile(path, source);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
95
83
|
}
|
|
84
|
+
//#endregion
|
|
85
|
+
export { kirana as default };
|