@kirana-style/astro 0.1.0 → 0.2.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/CHANGELOG.md +63 -0
- package/LICENSE +21 -0
- package/package.json +9 -4
- package/src/index.d.ts +17 -16
- package/src/index.js +58 -60
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.2.1](https://github.com/kirana-style/kirana/compare/v0.2.0...v0.2.1) (2026-10-16)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* deno in kirana-style init and doctor, and doctor finds kirana-style ([#33](https://github.com/kirana-style/kirana/issues/33)) ([3730d82](https://github.com/kirana-style/kirana/commit/3730d827815164ab32e22f09ad739e0b92502ad3))
|
|
9
|
+
* **site:** mobile scenes, release changelog, blog and roadmap redesign ([#34](https://github.com/kirana-style/kirana/issues/34)) ([f9330a8](https://github.com/kirana-style/kirana/commit/f9330a8b8788847609bfcd6b5ea2b795ffbc86f9))
|
|
10
|
+
* **site:** read every benchmark number from kirana-lab's runs ([#39](https://github.com/kirana-style/kirana/issues/39)) ([718f253](https://github.com/kirana-style/kirana/commit/718f253dd8ef64d95f3299c2256463458283ec20))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug fixes
|
|
14
|
+
|
|
15
|
+
* compile the scales preset from node_modules without listing it ([#37](https://github.com/kirana-style/kirana/issues/37)) ([12d8b67](https://github.com/kirana-style/kirana/commit/12d8b67f4fc9359a9534af68ea10f51c0a2a637d))
|
|
16
|
+
* let the dev example check look again after the page reloads ([#31](https://github.com/kirana-style/kirana/issues/31)) ([8d21bfd](https://github.com/kirana-style/kirana/commit/8d21bfd39d8b95327f346e1bc38ed2e433be1879))
|
|
17
|
+
* pin vitest 4 in the qwik example, inside qwik's peer range ([#36](https://github.com/kirana-style/kirana/issues/36)) ([5317eed](https://github.com/kirana-style/kirana/commit/5317eed4f0293b2befe64bbfda00b18601b3d24b))
|
|
18
|
+
|
|
19
|
+
## [0.2.0](https://github.com/kirana-style/kirana/compare/v0.1.0...v0.2.0) (2026-10-15)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### ⚠ BREAKING CHANGES
|
|
23
|
+
|
|
24
|
+
* one command name, kirana-style ([#29](https://github.com/kirana-style/kirana/issues/29))
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* **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))
|
|
29
|
+
* one command name, kirana-style ([#29](https://github.com/kirana-style/kirana/issues/29)) ([b3f3154](https://github.com/kirana-style/kirana/commit/b3f3154662589dd1bd43fd0ff2341acf4f3df628))
|
|
30
|
+
* **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))
|
|
31
|
+
* **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))
|
|
32
|
+
* **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))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug fixes
|
|
36
|
+
|
|
37
|
+
* 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))
|
|
38
|
+
* 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))
|
|
39
|
+
* **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))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Documentation
|
|
43
|
+
|
|
44
|
+
* fix the extension's settings table ([#13](https://github.com/kirana-style/kirana/issues/13)) ([457e06d](https://github.com/kirana-style/kirana/commit/457e06d12f9e3b005e0820aab36faac5bf3f80b3))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Dependencies
|
|
48
|
+
|
|
49
|
+
* 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))
|
|
50
|
+
* 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))
|
|
51
|
+
|
|
52
|
+
## [0.1.0](https://github.com/kirana-style/kirana/compare/v0.1.0...v0.1.0) (2026-10-13)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Features
|
|
56
|
+
|
|
57
|
+
* kirana goes public — write objects, read classes, ship css ([79732ed](https://github.com/kirana-style/kirana/commit/79732edd5cab419169ab74ad59e1c70053dfa57d))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### Dependencies
|
|
61
|
+
|
|
62
|
+
* 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))
|
|
63
|
+
* 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/astro",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Kirana for Astro: the integration that compiles .astro components 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,9 +25,9 @@
|
|
|
22
25
|
"./package.json": "./package.json"
|
|
23
26
|
},
|
|
24
27
|
"dependencies": {
|
|
25
|
-
"@kirana-style/compiler": "0.1
|
|
26
|
-
"@kirana-style/core": "0.1
|
|
27
|
-
"@kirana-style/vite": "0.1
|
|
28
|
+
"@kirana-style/compiler": "0.2.1",
|
|
29
|
+
"@kirana-style/core": "0.2.1",
|
|
30
|
+
"@kirana-style/vite": "0.2.1"
|
|
28
31
|
},
|
|
29
32
|
"peerDependencies": {
|
|
30
33
|
"astro": ">=5.0.0"
|
|
@@ -35,6 +38,8 @@
|
|
|
35
38
|
"*.d.ts",
|
|
36
39
|
"*.css",
|
|
37
40
|
"README.md",
|
|
41
|
+
"CHANGELOG.md",
|
|
42
|
+
"LICENSE",
|
|
38
43
|
"builders.json",
|
|
39
44
|
"schemas",
|
|
40
45
|
"gatsby-node.mjs",
|
package/src/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { KiranaViteOptions } from "@kirana-style/vite";
|
|
2
|
+
//#region src/index.d.ts
|
|
2
3
|
export type KiranaAstroOptions = Omit<KiranaViteOptions, "renameStylesheet">;
|
|
3
4
|
/**
|
|
4
5
|
* Renames each filled stylesheet in `outDir` by its content hash and replaces its old name in every
|
|
@@ -6,22 +7,22 @@ export type KiranaAstroOptions = Omit<KiranaViteOptions, "renameStylesheet">;
|
|
|
6
7
|
*/
|
|
7
8
|
export declare function renameStylesheets(outDir: string, filled: Iterable<string>): Promise<Map<string, string>>;
|
|
8
9
|
type Hooks = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}) => void;
|
|
10
|
+
"astro:config:setup": (options: {
|
|
11
|
+
updateConfig: (config: {
|
|
12
|
+
vite: {
|
|
13
|
+
plugins: unknown[];
|
|
14
|
+
};
|
|
15
15
|
}) => void;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
16
|
+
}) => void;
|
|
17
|
+
"astro:config:done": (options: {
|
|
18
|
+
config: {
|
|
19
|
+
outDir: URL;
|
|
20
|
+
};
|
|
21
|
+
}) => void;
|
|
22
|
+
"astro:build:done": () => Promise<void>;
|
|
22
23
|
};
|
|
23
24
|
export default function kirana(options?: KiranaAstroOptions): {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
name: string;
|
|
26
|
+
hooks: Hooks;
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
+
//#endregion
|
package/src/index.js
CHANGED
|
@@ -1,73 +1,71 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Astro integration (KRN-INT-004): `@kirana-style/vite` for Astro's Vite, which compiles `.astro`
|
|
3
|
-
* components as they are read (`design-notes/sfc-masking.md`), plus the one step Astro needs after
|
|
4
|
-
* its build. Astro links each page's stylesheet — or inlines a small one — by the name and content it
|
|
5
|
-
* recorded before the bundle was finished, so the Vite plugin fills the stylesheet in place, and once
|
|
6
|
-
* Astro has written every page this integration renames the file by its real content and rewrites
|
|
7
|
-
* every reference to it.
|
|
8
|
-
*/
|
|
9
1
|
import { readFile, readdir, rename, writeFile } from "node:fs/promises";
|
|
10
2
|
import path from "node:path";
|
|
11
3
|
import { fileURLToPath } from "node:url";
|
|
12
4
|
import { renameAsset } from "@kirana-style/compiler/host";
|
|
13
5
|
import vite from "@kirana-style/vite";
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
/**
|
|
8
|
+
* The Astro integration (KRN-INT-004): `@kirana-style/vite` for Astro's Vite, which compiles `.astro`
|
|
9
|
+
* components as they are read (`design-notes/sfc-masking.md`), plus the one step Astro needs after
|
|
10
|
+
* its build. Astro links each page's stylesheet — or inlines a small one — by the name and content it
|
|
11
|
+
* recorded before the bundle was finished, so the Vite plugin fills the stylesheet in place, and once
|
|
12
|
+
* Astro has written every page this integration renames the file by its real content and rewrites
|
|
13
|
+
* every reference to it.
|
|
14
|
+
*/
|
|
14
15
|
/** Files whose text can name the stylesheet: pages, server chunks, manifests, other stylesheets. */
|
|
15
16
|
const TEXT = /\.(?:html|m?js|json|css)$/;
|
|
16
17
|
/** Every file under a directory. */
|
|
17
18
|
async function files(directory) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return entries
|
|
23
|
-
.filter((entry) => entry.isFile())
|
|
24
|
-
.map((entry) => path.join(entry.parentPath, entry.name));
|
|
19
|
+
return (await readdir(directory, {
|
|
20
|
+
recursive: true,
|
|
21
|
+
withFileTypes: true
|
|
22
|
+
})).filter((entry) => entry.isFile()).map((entry) => path.join(entry.parentPath, entry.name));
|
|
25
23
|
}
|
|
26
24
|
/**
|
|
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
|
-
next = next.replaceAll(from, to);
|
|
52
|
-
if (next !== text)
|
|
53
|
-
await writeFile(file, next);
|
|
54
|
-
}
|
|
55
|
-
return renames;
|
|
25
|
+
* Renames each filled stylesheet in `outDir` by its content hash and replaces its old name in every
|
|
26
|
+
* text file there. Returns the renames, old name to new.
|
|
27
|
+
*/
|
|
28
|
+
async function renameStylesheets(outDir, filled) {
|
|
29
|
+
const all = await files(outDir);
|
|
30
|
+
const renames = /* @__PURE__ */ new Map();
|
|
31
|
+
for (const fileName of filled) {
|
|
32
|
+
const base = path.posix.basename(fileName);
|
|
33
|
+
for (const file of all.filter((candidate) => path.basename(candidate) === base)) {
|
|
34
|
+
const next = path.basename(renameAsset(base, await readFile(file, "utf8")));
|
|
35
|
+
if (next === base) continue;
|
|
36
|
+
await rename(file, path.join(path.dirname(file), next));
|
|
37
|
+
renames.set(base, next);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (renames.size === 0) return renames;
|
|
41
|
+
for (const file of await files(outDir)) {
|
|
42
|
+
if (!TEXT.test(file)) continue;
|
|
43
|
+
const text = await readFile(file, "utf8");
|
|
44
|
+
let next = text;
|
|
45
|
+
for (const [from, to] of renames) next = next.replaceAll(from, to);
|
|
46
|
+
if (next !== text) await writeFile(file, next);
|
|
47
|
+
}
|
|
48
|
+
return renames;
|
|
56
49
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
50
|
+
function kirana(options = {}) {
|
|
51
|
+
const plugins = vite({
|
|
52
|
+
...options,
|
|
53
|
+
renameStylesheet: false
|
|
54
|
+
});
|
|
55
|
+
const { filled } = plugins[0].api;
|
|
56
|
+
let outDir = "";
|
|
57
|
+
return {
|
|
58
|
+
name: "@kirana-style/astro",
|
|
59
|
+
hooks: {
|
|
60
|
+
"astro:config:setup": ({ updateConfig }) => updateConfig({ vite: { plugins } }),
|
|
61
|
+
"astro:config:done": ({ config }) => {
|
|
62
|
+
outDir = fileURLToPath(config.outDir);
|
|
63
|
+
},
|
|
64
|
+
"astro:build:done": async () => {
|
|
65
|
+
await renameStylesheets(outDir, filled);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
73
69
|
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { kirana as default, renameStylesheets };
|