@kirana-style/angular 0.3.4 → 0.3.6
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 +98 -0
- package/README.md +3 -0
- package/package.json +4 -4
- package/src/builders.js +3 -4
- package/src/fesm2022/directive.d.ts +11 -3
- package/src/fesm2022/directive.js +25 -11
- package/src/index.d.ts +3 -3
- package/src/index.js +3 -3
- package/src/mirror.d.ts +6 -2
- package/src/mirror.js +14 -11
- package/src/sx.d.ts +16 -1
- package/src/sx.js +13 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,103 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.6](https://github.com/kirana-style/kirana/compare/v0.3.5...v0.3.6) (2026-10-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* a contextual target may name a class ([#206](https://github.com/kirana-style/kirana/pull/206)) ([e71ff55](https://github.com/kirana-style/kirana/commit/e71ff551e41d0b645c7e00e238b736ab0a54a090))
|
|
9
|
+
* diagnostics print as oxc's graphical report, with the source ([#207](https://github.com/kirana-style/kirana/pull/207)) ([cbbdbe5](https://github.com/kirana-style/kirana/commit/cbbdbe5224e31739681576e1d29133122881d764))
|
|
10
|
+
* fallback() reads a token, then another, then a value ([#211](https://github.com/kirana-style/kirana/pull/211)) ([6e72f71](https://github.com/kirana-style/kirana/commit/6e72f71274ae0f98fb0fddcb3b2674a10a8d8e90))
|
|
11
|
+
* layers.tiers puts each ladder tier in a sub-layer of kirana.atoms ([#172](https://github.com/kirana-style/kirana/pull/172)) ([8bca0d5](https://github.com/kirana-style/kirana/commit/8bca0d55fe9edff698e4de10dcca2c2d4ee61093))
|
|
12
|
+
* migrate stylex writes styles as stylex read them ([#193](https://github.com/kirana-style/kirana/pull/193)) ([88a3a42](https://github.com/kirana-style/kirana/commit/88a3a42df4b38cf024e57caf620c05ad82da54ff))
|
|
13
|
+
* migrate tailwind reads a design system's conditions and handles ([#204](https://github.com/kirana-style/kirana/pull/204)) ([d753322](https://github.com/kirana-style/kirana/commit/d753322d29c272b1175278d30e480c29094ce40f))
|
|
14
|
+
* relation-read-on-anchor, a state read on its own anchor ([#186](https://github.com/kirana-style/kirana/pull/186)) ([3676f00](https://github.com/kirana-style/kirana/commit/3676f000aeaaf00e0aed681e5050390cadc23db1))
|
|
15
|
+
* the language server in a browser page, as project.language ([#184](https://github.com/kirana-style/kirana/pull/184)) ([c2d1bec](https://github.com/kirana-style/kirana/commit/c2d1bec0388bf3e430bdb92eb51b80d739b31c20))
|
|
16
|
+
* ui flattens each design axis, or keeps every design ([#209](https://github.com/kirana-style/kirana/pull/209)) ([2559372](https://github.com/kirana-style/kirana/commit/2559372d569c8000daf2eb2ebe6cb5df1bcb4e0c))
|
|
17
|
+
* ui init and ui preset take --pointer and --rtl ([#202](https://github.com/kirana-style/kirana/pull/202)) ([19859f8](https://github.com/kirana-style/kirana/commit/19859f8eb7fd41e5d7b5ada395af7c0522bc5e5f))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug fixes
|
|
21
|
+
|
|
22
|
+
* a dev page that loaded an older stylesheet gets the current one ([#187](https://github.com/kirana-style/kirana/pull/187)) ([8ba8538](https://github.com/kirana-style/kirana/commit/8ba853804b1a71f8a47f99babd0c6ad0babe19f7))
|
|
23
|
+
* a host reads the package root's config from a folder without one ([#183](https://github.com/kirana-style/kirana/pull/183)) ([47fa994](https://github.com/kirana-style/kirana/commit/47fa994a47339532272485cce2a4105b6704e49b))
|
|
24
|
+
* a key or spread decided at runtime is reported where it is written ([#208](https://github.com/kirana-style/kirana/pull/208)) ([2594a25](https://github.com/kirana-style/kirana/commit/2594a255a0f6242c8693fbc86b4e63638ab8fcb9))
|
|
25
|
+
* a listed library's components read sx, so it is not reported ([#196](https://github.com/kirana-style/kirana/pull/196)) ([16cc0d4](https://github.com/kirana-style/kirana/commit/16cc0d4fbd38a1e8c99309d38a2049740d45efea))
|
|
26
|
+
* a long editor or dev session no longer grows its memory with every edit ([#175](https://github.com/kirana-style/kirana/pull/175)) ([76e8a41](https://github.com/kirana-style/kirana/commit/76e8a412e0e0d3d1fa1d67ccb1004fd02988d073))
|
|
27
|
+
* a watch build forgets the tokens a rebuild no longer names ([#180](https://github.com/kirana-style/kirana/pull/180)) ([91bbc81](https://github.com/kirana-style/kirana/commit/91bbc8181f624b53186db9a64f78701e76640e41))
|
|
28
|
+
* an optional relation anchored without its readers is not reported ([#181](https://github.com/kirana-style/kirana/pull/181)) ([4acdcf7](https://github.com/kirana-style/kirana/commit/4acdcf76259e425797b912ae088669f85ad359d4))
|
|
29
|
+
* base-ui's accordion item, header and panel have closed ([#185](https://github.com/kirana-style/kirana/pull/185)) ([a33889f](https://github.com/kirana-style/kirana/commit/a33889ff0799cc7b6e57b8b7596dd518f738b923))
|
|
30
|
+
* removing both logical axes clears a component's physical box ([#200](https://github.com/kirana-style/kirana/pull/200)) ([9b61d15](https://github.com/kirana-style/kirana/commit/9b61d15b397e30f63476c14d11d5e6c2da9e9dee))
|
|
31
|
+
* tailwind migration keeps line heights, images and single layers ([#201](https://github.com/kirana-style/kirana/pull/201)) ([a34017c](https://github.com/kirana-style/kirana/commit/a34017cea2ffb6b2560df960d97adfed6e330e4e))
|
|
32
|
+
* the utility grammar hints import scales as its default export ([#182](https://github.com/kirana-style/kirana/pull/182)) ([22fca2b](https://github.com/kirana-style/kirana/commit/22fca2b7e39e78b2f9b921a11a25bd64828d1e69))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Performance
|
|
36
|
+
|
|
37
|
+
* a build that writes no source maps does not build them ([#176](https://github.com/kirana-style/kirana/pull/176)) ([4d8da10](https://github.com/kirana-style/kirana/commit/4d8da1039e915762767b7399604bf577c48ac44d))
|
|
38
|
+
* a dense build without source maps renames chunks in one pass ([#189](https://github.com/kirana-style/kirana/pull/189)) ([4ab17c5](https://github.com/kirana-style/kirana/commit/4ab17c5b31dd693c840868018eaec6e8c9d3a049))
|
|
39
|
+
* a style reused from another value is not copied ([#192](https://github.com/kirana-style/kirana/pull/192)) ([a79d1bd](https://github.com/kirana-style/kirana/commit/a79d1bdb95ab1c45fbeaae776f360fe25495f927))
|
|
40
|
+
* check places a file's diagnostics without walking it for each one ([#194](https://github.com/kirana-style/kirana/pull/194)) ([a21f5d7](https://github.com/kirana-style/kirana/commit/a21f5d70873485c99d622c0110ac3696dafe5a20))
|
|
41
|
+
* declarations compile without parsing longhands or copying plans ([#188](https://github.com/kirana-style/kirana/pull/188)) ([cd39382](https://github.com/kirana-style/kirana/commit/cd393829e0b92c7c41a75ad0bf68b77c89d9812d))
|
|
42
|
+
* esbuild, bun, webpack, next and parcel compile modules in parallel ([#195](https://github.com/kirana-style/kirana/pull/195)) ([7961d2e](https://github.com/kirana-style/kirana/commit/7961d2e9df3d7c023680f420485501a012653cc7))
|
|
43
|
+
* formatting diagnostics no longer walks the source for each one ([#190](https://github.com/kirana-style/kirana/pull/190)) ([700bea8](https://github.com/kirana-style/kirana/commit/700bea8d93387a268822b98da2e78045dc02bef1))
|
|
44
|
+
* merging styles and naming their classes copies and allocates less ([#178](https://github.com/kirana-style/kirana/pull/178)) ([f9fb902](https://github.com/kirana-style/kirana/commit/f9fb902591a08955495a0ff1138255a536b5cb75))
|
|
45
|
+
* styles compile and stylesheets are written with less repeated work ([#174](https://github.com/kirana-style/kirana/pull/174)) ([085984a](https://github.com/kirana-style/kirana/commit/085984a0c94f05a6122cfb50d31e79361c6cb693))
|
|
46
|
+
* the stylesheet is written from atoms kept in its order ([#179](https://github.com/kirana-style/kirana/pull/179)) ([428dda4](https://github.com/kirana-style/kirana/commit/428dda4e3b44e0417293ea4f1d89f6f8fbb1a09a))
|
|
47
|
+
* the stylesheet writes each key's values in order, which compresses better ([#191](https://github.com/kirana-style/kirana/pull/191)) ([4465ca5](https://github.com/kirana-style/kirana/commit/4465ca53f4b178e0674f820a975b76fb2d793441))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Documentation
|
|
51
|
+
|
|
52
|
+
* counts from their sources, two readmes, four more checks ([#203](https://github.com/kirana-style/kirana/pull/203)) ([3855e4c](https://github.com/kirana-style/kirana/commit/3855e4c4c6d7d6a10872994d5b3c0232060ffde6))
|
|
53
|
+
* every page says what the code does, and two more checks hold it ([#199](https://github.com/kirana-style/kirana/pull/199)) ([6615452](https://github.com/kirana-style/kirana/commit/661545274459072480780f25326018586bcf37d8))
|
|
54
|
+
* take the benchmarks of kirana 0.3.5 from kirana-lab ([#177](https://github.com/kirana-style/kirana/pull/177)) ([0920e23](https://github.com/kirana-style/kirana/commit/0920e23fc9614474bce7702a1f8bfe8c3b3b30bd))
|
|
55
|
+
* the agent skills say what shipped since 0.3.0 ([#197](https://github.com/kirana-style/kirana/pull/197)) ([8cfc693](https://github.com/kirana-style/kirana/commit/8cfc6938f0808fe2d6e977e5414826544219a4dc))
|
|
56
|
+
|
|
57
|
+
## [0.3.5](https://github.com/kirana-style/kirana/compare/v0.3.4...v0.3.5) (2026-10-28)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
### Features
|
|
61
|
+
|
|
62
|
+
* a part that anchors a relation can read its own kind beside it ([#163](https://github.com/kirana-style/kirana/pull/163)) ([71131ad](https://github.com/kirana-style/kirana/commit/71131adc72d053b547879b1ebaddbc4f22b012bc))
|
|
63
|
+
* add @kirana-style/compiler-browser, the engine in a browser page ([#155](https://github.com/kirana-style/kirana/pull/155)) ([566f300](https://github.com/kirana-style/kirana/commit/566f300bfe33f94f4c51399f1b199b0ae3915b64))
|
|
64
|
+
* angular parts merge sx through partSx beside SxDirective ([#167](https://github.com/kirana-style/kirana/pull/167)) ([0138926](https://github.com/kirana-style/kirana/commit/0138926c8249b337682b84f64d1587fb3e2d1740))
|
|
65
|
+
* font items, imported by ui add and installed by a preset ([#168](https://github.com/kirana-style/kirana/pull/168)) ([e6dc629](https://github.com/kirana-style/kirana/commit/e6dc62989b81038a6110eb731ccf4fc0b8325c12))
|
|
66
|
+
* own() claims an attribute for one component's style ([#169](https://github.com/kirana-style/kirana/pull/169)) ([52f6e52](https://github.com/kirana-style/kirana/commit/52f6e52bb3840521e3fc86ac6b1017aed6a6b8bb))
|
|
67
|
+
* style helpers evaluate object.entries, fromEntries and map ([#160](https://github.com/kirana-style/kirana/pull/160)) ([05421b8](https://github.com/kirana-style/kirana/commit/05421b8cccff73fdc0cf57aa288a2606b200eafd))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Bug fixes
|
|
71
|
+
|
|
72
|
+
* a relation read compiles in a module that does not import kirana ([#159](https://github.com/kirana-style/kirana/pull/159)) ([cb073a4](https://github.com/kirana-style/kirana/commit/cb073a4aa5f1c5039ed2182a18118d8123d11851))
|
|
73
|
+
* an import no style reads is not reported unresolved or cyclic ([#148](https://github.com/kirana-style/kirana/pull/148)) ([40eff25](https://github.com/kirana-style/kirana/commit/40eff2516620feade8130c8a2cf74b3d1b45fd06))
|
|
74
|
+
* an import of a file created during a watch session resolves ([#164](https://github.com/kirana-style/kirana/pull/164)) ([afdb700](https://github.com/kirana-style/kirana/commit/afdb7007c9908f7c3f3036e6eaec9cb0d2ac197f))
|
|
75
|
+
* angular and ember peer @kirana-style/vite at the release's version ([#157](https://github.com/kirana-style/kirana/pull/157)) ([09d71db](https://github.com/kirana-style/kirana/commit/09d71db1124dc722e54fbcfee70f3a511cfceea4))
|
|
76
|
+
* props() and keyframes() are typed as they compile ([#158](https://github.com/kirana-style/kirana/pull/158)) ([b797caa](https://github.com/kirana-style/kirana/commit/b797caa8f040ffc0e0dccfb513b76ef0517e407b))
|
|
77
|
+
* removing a whole box removes its logical sides too ([#171](https://github.com/kirana-style/kirana/pull/171)) ([f838ff1](https://github.com/kirana-style/kirana/commit/f838ff1de7c7b31c0c576fcda3394fc27abd5cd5))
|
|
78
|
+
* ui init gives a javascript next.js app its tsconfig and typescript ([#149](https://github.com/kirana-style/kirana/pull/149)) ([6eee0fd](https://github.com/kirana-style/kirana/commit/6eee0fdda35deca7ad66721ff12b3791bfba228c))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### Performance
|
|
82
|
+
|
|
83
|
+
* a dev server and a watch build reuse unchanged transforms ([#170](https://github.com/kirana-style/kirana/pull/170)) ([3eac1cf](https://github.com/kirana-style/kirana/commit/3eac1cfb6a730fae900d6c81ed86b9b5833baf22))
|
|
84
|
+
* a style written out in full compiles once a session ([#166](https://github.com/kirana-style/kirana/pull/166)) ([ec84bd3](https://github.com/kirana-style/kirana/commit/ec84bd35af1068fbfe0a6aa52972b70ed2eff05f))
|
|
85
|
+
* dense names build the renaming's source map only when the build writes maps ([#161](https://github.com/kirana-style/kirana/pull/161)) ([a655efd](https://github.com/kirana-style/kirana/commit/a655efd0632b97c86190cca95c5ce7b73dd38a88))
|
|
86
|
+
* reading a preset's tokens no longer walks the whole preset ([#165](https://github.com/kirana-style/kirana/pull/165)) ([b92775d](https://github.com/kirana-style/kirana/commit/b92775d74d96b8f4b357616937ddc7921ac1c73a))
|
|
87
|
+
* the engine loader looks up the c library once per process ([#156](https://github.com/kirana-style/kirana/pull/156)) ([344a932](https://github.com/kirana-style/kirana/commit/344a932ed212900c6cdeb980d135d5c248fd93c2))
|
|
88
|
+
* the stylesheet is written from one atom index, not every module's atoms ([#162](https://github.com/kirana-style/kirana/pull/162)) ([6718147](https://github.com/kirana-style/kirana/commit/6718147b0bb444f3d63403047c726d31e823a517))
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
### Documentation
|
|
92
|
+
|
|
93
|
+
* take the benchmarks of kirana 0.3.4 from kirana-lab ([#153](https://github.com/kirana-style/kirana/pull/153)) ([f093aa7](https://github.com/kirana-style/kirana/commit/f093aa7a693e38fcc8d252f9e797c775e2321ca1))
|
|
94
|
+
* the roadmap lists the products planned beside the compiler ([#154](https://github.com/kirana-style/kirana/pull/154)) ([7806842](https://github.com/kirana-style/kirana/commit/7806842cbd7ebf67efa98131f3343891351df01c))
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
### Dependencies
|
|
98
|
+
|
|
99
|
+
* bump the minor-and-patch group with 4 updates ([#151](https://github.com/kirana-style/kirana/pull/151)) ([4bb63be](https://github.com/kirana-style/kirana/commit/4bb63be11279c059c28f33e120b6fc36af06da02))
|
|
100
|
+
|
|
3
101
|
## [0.3.4](https://github.com/kirana-style/kirana/compare/v0.3.3...v0.3.4) (2026-10-27)
|
|
4
102
|
|
|
5
103
|
|
package/README.md
CHANGED
|
@@ -23,6 +23,9 @@ export class Card {
|
|
|
23
23
|
|
|
24
24
|
- **`SxDirective`** merges the handles with Kirana's runtime and adds and removes only the classes
|
|
25
25
|
and custom properties it set. `provideKirana({ prefix })` matches a `names.prefix` other than `k`.
|
|
26
|
+
- **Parts.** A directive that takes `sx` merges it with its own styles through `partSx(own, sx)`,
|
|
27
|
+
binds the `class` and `style` it returns to its host, types the input `SxInput`, and lists
|
|
28
|
+
`provideSxPart()` in its `providers`, which keeps `SxDirective` off its element.
|
|
26
29
|
- **Analog.** `kiranaAngular()` from `@kirana-style/angular/vite`, after `analog()`, compiles the JavaScript
|
|
27
30
|
Angular emits. Import `@kirana-style/core/stylesheet.css` from `src/main.ts`.
|
|
28
31
|
- **Angular CLI.** In `angular.json`, `@kirana-style/angular:application` and `@kirana-style/angular:dev-server`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kirana-style/angular",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "Kirana for Angular: the [sx] directive, the Analog (Vite) plugin and Angular CLI builders.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "The Kirana authors",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"./builders.json": "./builders.json"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@kirana-style/compiler": "0.3.
|
|
34
|
-
"@kirana-style/core": "0.3.
|
|
33
|
+
"@kirana-style/compiler": "0.3.6",
|
|
34
|
+
"@kirana-style/core": "0.3.6"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@angular/core": ">=20.0.0",
|
|
38
38
|
"@angular/build": ">=20.0.0",
|
|
39
39
|
"@angular-devkit/architect": ">=0.2000.0",
|
|
40
|
-
"@kirana-style/vite": "0.
|
|
40
|
+
"@kirana-style/vite": "0.3.6"
|
|
41
41
|
},
|
|
42
42
|
"builders": "./builders.json",
|
|
43
43
|
"peerDependenciesMeta": {
|
package/src/builders.js
CHANGED
|
@@ -10,8 +10,7 @@ import { buildApplication, executeDevServerBuilder } from "@angular/build";
|
|
|
10
10
|
* "build": { "builder": "@kirana-style/angular:application", "options": { … as before … } }
|
|
11
11
|
* "serve": { "builder": "@kirana-style/angular:dev-server", … }
|
|
12
12
|
*
|
|
13
|
-
* The dev server is Angular's,
|
|
14
|
-
* Angular reads those options itself and compiles them with its internal application build.
|
|
13
|
+
* The dev server is Angular's, given a context whose build target's options carry the mirror.
|
|
15
14
|
*/
|
|
16
15
|
/** The project's source folder, from its configuration (`src` unless it says otherwise). */
|
|
17
16
|
async function sourceRootOf(context) {
|
|
@@ -36,8 +35,8 @@ function withMirror(options, mirror) {
|
|
|
36
35
|
}
|
|
37
36
|
/** Prints the mirror's warnings and errors through the builder's logger (infos stay quiet). */
|
|
38
37
|
function report(context, mirror) {
|
|
39
|
-
for (const
|
|
40
|
-
else if (
|
|
38
|
+
for (const { severity, text } of mirror.messages()) if (severity === "error") context.logger.error(text);
|
|
39
|
+
else if (severity === "warning") context.logger.warn(text);
|
|
41
40
|
}
|
|
42
41
|
async function* application(options, context) {
|
|
43
42
|
const sourceRoot = await sourceRootOf(context);
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import { SxInput } from "../sx.js";
|
|
1
2
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { Handle } from "@kirana-style/core/internal";
|
|
3
|
-
import { Sx } from "@kirana-style/core";
|
|
4
3
|
/** The class-name prefix (`names.prefix`); `k` unless the app provides another (`provideKirana`). */
|
|
5
4
|
export declare const KIRANA_PREFIX: i0.InjectionToken<string>;
|
|
6
5
|
/** Providers for an app whose `kirana.config` sets another class-name prefix. */
|
|
7
6
|
export declare function provideKirana(options: {
|
|
8
7
|
prefix: string;
|
|
9
8
|
}): i0.Provider[];
|
|
9
|
+
/**
|
|
10
|
+
* Provided by a part, a directive that merges `sx` with its own styles itself (D-100, `partSx`):
|
|
11
|
+
* `SxDirective` on the same element then applies nothing, since a class it added would be dropped
|
|
12
|
+
* when the part's `[class]` binding next changed (KF-049). A part lists `provideSxPart()` in its
|
|
13
|
+
* `providers`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SX_PART: i0.InjectionToken<boolean>;
|
|
16
|
+
/** The provider that marks a part's element, so `SxDirective` leaves `[sx]` to the part. */
|
|
17
|
+
export declare function provideSxPart(): i0.Provider;
|
|
10
18
|
export declare class SxDirective implements i0.OnChanges {
|
|
11
19
|
#private;
|
|
12
20
|
/**
|
|
@@ -14,7 +22,7 @@ export declare class SxDirective implements i0.OnChanges {
|
|
|
14
22
|
* handles are class strings (the Angular CLI builders type-check the compiled copy), so both are
|
|
15
23
|
* accepted.
|
|
16
24
|
*/
|
|
17
|
-
sx:
|
|
25
|
+
sx: SxInput;
|
|
18
26
|
ngOnChanges(): void;
|
|
19
27
|
static ɵfac: i0.ɵɵFactoryDeclaration<SxDirective, never>;
|
|
20
28
|
static ɵdir: i0.ɵɵDirectiveDeclaration<SxDirective, "[sx]", never, {
|
|
@@ -3,16 +3,10 @@ import * as i0 from "@angular/core";
|
|
|
3
3
|
// src/fesm2022/directive.ts
|
|
4
4
|
/**
|
|
5
5
|
* `[sx]` for Angular templates (D-068). A template reaches only its component's members, so `sx`
|
|
6
|
-
* cannot be compiled away
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* The class carries Angular's partial declarations (`ɵɵngDeclareFactory`, `ɵɵngDeclareDirective`),
|
|
11
|
-
* the form `ngc` emits for a library and Angular's linker compiles in every app build. They are
|
|
12
|
-
* written here rather than generated because this workspace's TypeScript (7) has no JavaScript API
|
|
13
|
-
* for `ngc` to run on; the Analog and Angular CLI examples build them in CI. The static types are the
|
|
14
|
-
* ones `ngc` would declare, so templates type-check `[sx]` against `Sx`. The file sits under
|
|
15
|
-
* `fesm2022/`, the Angular Package Format's folder, because Analog links only files on such a path.
|
|
6
|
+
* cannot be compiled away: this directive merges the handles with Kirana's runtime and keeps the
|
|
7
|
+
* element's own classes and styles. Its partial declarations (`ɵɵngDeclare*`, with the types `ngc`
|
|
8
|
+
* would declare) are hand-written because TypeScript 7 has no JavaScript API for `ngc`; the examples
|
|
9
|
+
* build them in CI. It sits under `fesm2022/` because Analog links only files on such a path.
|
|
16
10
|
*/
|
|
17
11
|
/** The class-name prefix (`names.prefix`); `k` unless the app provides another (`provideKirana`). */
|
|
18
12
|
const KIRANA_PREFIX = new i0.InjectionToken("kirana prefix", {
|
|
@@ -26,6 +20,20 @@ function provideKirana(options) {
|
|
|
26
20
|
useValue: options.prefix
|
|
27
21
|
}];
|
|
28
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Provided by a part, a directive that merges `sx` with its own styles itself (D-100, `partSx`):
|
|
25
|
+
* `SxDirective` on the same element then applies nothing, since a class it added would be dropped
|
|
26
|
+
* when the part's `[class]` binding next changed (KF-049). A part lists `provideSxPart()` in its
|
|
27
|
+
* `providers`.
|
|
28
|
+
*/
|
|
29
|
+
const SX_PART = new i0.InjectionToken("kirana sx part");
|
|
30
|
+
/** The provider that marks a part's element, so `SxDirective` leaves `[sx]` to the part. */
|
|
31
|
+
function provideSxPart() {
|
|
32
|
+
return {
|
|
33
|
+
provide: SX_PART,
|
|
34
|
+
useValue: true
|
|
35
|
+
};
|
|
36
|
+
}
|
|
29
37
|
var SxDirective = class SxDirective {
|
|
30
38
|
/**
|
|
31
39
|
* The handles: one, or an array with falsy guards (`[styles.card, active && styles.on]`). Compiled
|
|
@@ -36,11 +44,17 @@ var SxDirective = class SxDirective {
|
|
|
36
44
|
#element = i0.inject(i0.ElementRef).nativeElement;
|
|
37
45
|
#renderer = i0.inject(i0.Renderer2);
|
|
38
46
|
#prefix = i0.inject(KIRANA_PREFIX);
|
|
47
|
+
/** Whether a part on this element merges `sx` itself (`SX_PART`). */
|
|
48
|
+
#part = i0.inject(SX_PART, {
|
|
49
|
+
self: true,
|
|
50
|
+
optional: true
|
|
51
|
+
}) ?? false;
|
|
39
52
|
#applied = {
|
|
40
53
|
classes: /* @__PURE__ */ new Set(),
|
|
41
54
|
styles: /* @__PURE__ */ new Set()
|
|
42
55
|
};
|
|
43
56
|
ngOnChanges() {
|
|
57
|
+
if (this.#part) return;
|
|
44
58
|
this.#applied = applySx(this.#renderer, this.#element, this.#applied, this.sx, this.#prefix);
|
|
45
59
|
}
|
|
46
60
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
@@ -62,4 +76,4 @@ var SxDirective = class SxDirective {
|
|
|
62
76
|
ngImport: i0
|
|
63
77
|
});
|
|
64
78
|
};
|
|
65
|
-
export { KIRANA_PREFIX, SxDirective, provideKirana };
|
|
79
|
+
export { KIRANA_PREFIX, SX_PART, SxDirective, provideKirana, provideSxPart };
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export { type Applied, KIRANA_PREFIX, type Renderer, SxDirective, applySx, provideKirana, runtimeFor };
|
|
1
|
+
import { Applied, Renderer, SxInput, applySx, partSx, runtimeFor } from "./sx.js";
|
|
2
|
+
import { KIRANA_PREFIX, SX_PART, SxDirective, provideKirana, provideSxPart } from "./fesm2022/directive.js";
|
|
3
|
+
export { type Applied, KIRANA_PREFIX, type Renderer, SX_PART, SxDirective, type SxInput, applySx, partSx, provideKirana, provideSxPart, runtimeFor };
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { applySx, runtimeFor } from "./sx.js";
|
|
2
|
-
import { KIRANA_PREFIX, SxDirective, provideKirana } from "./fesm2022/directive.js";
|
|
3
|
-
export { KIRANA_PREFIX, SxDirective, applySx, provideKirana, runtimeFor };
|
|
1
|
+
import { applySx, partSx, runtimeFor } from "./sx.js";
|
|
2
|
+
import { KIRANA_PREFIX, SX_PART, SxDirective, provideKirana, provideSxPart } from "./fesm2022/directive.js";
|
|
3
|
+
export { KIRANA_PREFIX, SX_PART, SxDirective, applySx, partSx, provideKirana, provideSxPart, runtimeFor };
|
package/src/mirror.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { watch } from "node:fs";
|
|
2
|
+
import { Diagnostic } from "@kirana-style/compiler";
|
|
2
3
|
/** Where the mirror lives, under the workspace root. */
|
|
3
4
|
export declare const MIRROR = ".kirana";
|
|
4
5
|
/** The stylesheet the builders add to `styles`. */
|
|
@@ -13,8 +14,11 @@ export type Mirror = {
|
|
|
13
14
|
}[];
|
|
14
15
|
/** Mirrors one changed or deleted file (and what read from it); returns whether anything changed. */
|
|
15
16
|
update: (file: string) => boolean;
|
|
16
|
-
/** Diagnostics from the last pass, formatted. */
|
|
17
|
-
messages: () =>
|
|
17
|
+
/** Diagnostics from the last pass, each formatted with its severity. */
|
|
18
|
+
messages: () => {
|
|
19
|
+
severity: Diagnostic["severity"];
|
|
20
|
+
text: string;
|
|
21
|
+
}[];
|
|
18
22
|
};
|
|
19
23
|
/** Builds the mirror of `sourceRoot` (relative to `root`) and writes the stylesheet. */
|
|
20
24
|
export declare function createMirror(root: string, sourceRoot: string, options?: {
|
package/src/mirror.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, watch, writeFileSync } from "node:fs";
|
|
3
|
-
import { Driver,
|
|
3
|
+
import { Driver, formatDiagnostics } from "@kirana-style/compiler";
|
|
4
4
|
import { SKIPPED, shouldCompile } from "@kirana-style/compiler/host";
|
|
5
5
|
// src/mirror.ts
|
|
6
6
|
/**
|
|
7
|
-
* Kirana for the Angular CLI (D-068, `design-notes/angular.md`). Angular's
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* the mirror, where every file exists. Every TypeScript file is replaced, the stylesheet is written
|
|
13
|
-
* beside the mirror, and in watch mode each change is mirrored again — Angular, which watches the
|
|
14
|
-
* replacements, rebuilds from there.
|
|
7
|
+
* Kirana for the Angular CLI (D-068, `design-notes/angular.md`). Angular's builder offers no hook to
|
|
8
|
+
* change a source, but honours `fileReplacements`, so the builders keep a mirror of the source folder
|
|
9
|
+
* in `.kirana/`: every file copied, the ones that hold styles compiled. Relative imports and
|
|
10
|
+
* `templateUrl`s resolve inside the mirror; in watch mode each change is mirrored again and Angular,
|
|
11
|
+
* which watches the replacements, rebuilds.
|
|
15
12
|
*/
|
|
16
13
|
/** Where the mirror lives, under the workspace root. */
|
|
17
14
|
const MIRROR = ".kirana";
|
|
@@ -50,7 +47,7 @@ async function createMirror(root, sourceRoot, options = {}) {
|
|
|
50
47
|
copyFileSync(from, to);
|
|
51
48
|
return;
|
|
52
49
|
}
|
|
53
|
-
const result = driver.transform(from, text);
|
|
50
|
+
const result = driver.transform(from, text, { map: false });
|
|
54
51
|
texts.set(path.relative(root, from).replaceAll("\\", "/"), text);
|
|
55
52
|
reported.push(...result.diagnostics);
|
|
56
53
|
writeFileSync(to, result.code ?? text);
|
|
@@ -82,7 +79,13 @@ async function createMirror(root, sourceRoot, options = {}) {
|
|
|
82
79
|
for (const changed of affected) mirror(path.relative(source, changed));
|
|
83
80
|
return stylesheet();
|
|
84
81
|
},
|
|
85
|
-
messages: () =>
|
|
82
|
+
messages: () => {
|
|
83
|
+
const formatted = formatDiagnostics(reported, (file) => texts.get(file));
|
|
84
|
+
return reported.map(({ severity }, index) => ({
|
|
85
|
+
severity,
|
|
86
|
+
text: formatted[index]
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
86
89
|
};
|
|
87
90
|
}
|
|
88
91
|
/** Mirrors every change under the source folder until closed (watch builds and the dev server). */
|
package/src/sx.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { runtime } from "@kirana-style/core/internal";
|
|
1
|
+
import { Handle, runtime } from "@kirana-style/core/internal";
|
|
2
|
+
import { Sx } from "@kirana-style/core";
|
|
3
|
+
/**
|
|
4
|
+
* What an `sx` input takes: `Sx`, or the class strings handles are once compiled. The Angular CLI
|
|
5
|
+
* builders type-check the compiled copy, where a template passes those strings.
|
|
6
|
+
*/
|
|
7
|
+
export type SxInput = Sx | Handle;
|
|
2
8
|
/** The part of Angular's `Renderer2` this needs. */
|
|
3
9
|
export type Renderer = {
|
|
4
10
|
addClass: (element: unknown, name: string) => void;
|
|
@@ -15,5 +21,14 @@ export type Applied = {
|
|
|
15
21
|
export declare const DASH_CASE = 2;
|
|
16
22
|
/** One runtime per class-name prefix, as each compiled module creates one. */
|
|
17
23
|
export declare function runtimeFor(prefix: string): ReturnType<typeof runtime>;
|
|
24
|
+
/**
|
|
25
|
+
* A part's host props: its own handles, then its caller's `sx`, merged with Kirana's runtime as
|
|
26
|
+
* `[sx]` merges them, the caller's last (KF-049). A part binds `class` and `style` to its host and
|
|
27
|
+
* lists `provideSxPart()`, so `SxDirective` leaves the element to it.
|
|
28
|
+
*/
|
|
29
|
+
export declare function partSx(own: SxInput, sx: SxInput, prefix?: string): {
|
|
30
|
+
class: string;
|
|
31
|
+
style: Record<string, string>;
|
|
32
|
+
};
|
|
18
33
|
/** Applies `value` (a handle, or an array of handles and falsy guards); returns what is applied now. */
|
|
19
34
|
export declare function applySx(renderer: Renderer, element: unknown, previous: Applied, value: unknown, prefix: string): Applied;
|
package/src/sx.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { runtime } from "@kirana-style/core/internal";
|
|
2
2
|
// src/sx.ts
|
|
3
|
-
/**
|
|
4
|
-
* What `[sx]` does to an element, without Angular: merge the handles with Kirana's runtime (the same
|
|
5
|
-
* one compiled modules call), then bring the element's classes and custom properties from what the
|
|
6
|
-
* last value applied to what this one applies. Only what `[sx]` added is ever removed, so the
|
|
7
|
-
* element's own `class` and `style` stay.
|
|
8
|
-
*/
|
|
9
3
|
/** `RendererStyleFlags2.DashCase`: the name is a custom property, set as written. */
|
|
10
4
|
const DASH_CASE = 2;
|
|
11
5
|
const runtimes = /* @__PURE__ */ new Map();
|
|
@@ -18,6 +12,18 @@ function runtimeFor(prefix) {
|
|
|
18
12
|
}
|
|
19
13
|
return created;
|
|
20
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* A part's host props: its own handles, then its caller's `sx`, merged with Kirana's runtime as
|
|
17
|
+
* `[sx]` merges them, the caller's last (KF-049). A part binds `class` and `style` to its host and
|
|
18
|
+
* lists `provideSxPart()`, so `SxDirective` leaves the element to it.
|
|
19
|
+
*/
|
|
20
|
+
function partSx(own, sx, prefix = "k") {
|
|
21
|
+
const props = runtimeFor(prefix).sx([own, sx], [], []);
|
|
22
|
+
return {
|
|
23
|
+
class: props.class ?? "",
|
|
24
|
+
style: props.style ?? {}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
21
27
|
/** Applies `value` (a handle, or an array of handles and falsy guards); returns what is applied now. */
|
|
22
28
|
function applySx(renderer, element, previous, value, prefix) {
|
|
23
29
|
const handles = Array.isArray(value) ? value : [value];
|
|
@@ -33,4 +39,4 @@ function applySx(renderer, element, previous, value, prefix) {
|
|
|
33
39
|
styles: new Set(Object.keys(styles))
|
|
34
40
|
};
|
|
35
41
|
}
|
|
36
|
-
export { DASH_CASE, applySx, runtimeFor };
|
|
42
|
+
export { DASH_CASE, applySx, partSx, runtimeFor };
|