@akanjs/cli 3.1.0-rc.2 → 3.1.0-rc.20

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 (100) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-q50k4s45.js → CodeAgent-n3tzjm91.js} +2 -2
  3. package/{CodeAgentRpcHost-p7h6n2hp.js → CodeAgentRpcHost-9g27hmer.js} +1 -1
  4. package/{CodeTui-62g35ztk.js → CodeTui-fnm9ft4d.js} +47 -4
  5. package/TunnelShare-661cxz5e.js +14 -0
  6. package/{agent.command-adfd5299.js → agent.command-3qxf4xcj.js} +5 -5
  7. package/akanCode.js +7 -5
  8. package/{application.command-hj3gv1rx.js → application.command-zfja7x4r.js} +12 -11
  9. package/{applicationBuildRunner-by10r9gf.js → applicationBuildRunner-vh4j6vdv.js} +16 -9
  10. package/buildBatch.proc.js +7 -7
  11. package/{cloud.command-k2fhaape.js → cloud.command-fcc8e8tp.js} +17 -16
  12. package/cloud.script-1xt3tnts.js +24 -0
  13. package/{code.command-kt5zgcc2.js → code.command-130bdmhe.js} +25 -12
  14. package/{context.command-8fgn42jw.js → context.command-0qx447mb.js} +17 -16
  15. package/context.runner-1vsjztjg.js +25 -0
  16. package/{dependencyScanner-06z2dmrr.js → dependencyScanner-3afj2vt1.js} +1 -1
  17. package/{guideline.command-3yxxr2mm.js → guideline.command-cv5bmrx2.js} +2 -2
  18. package/guidelines/agentRule/agentRule.instruction.md +25 -10
  19. package/guidelines/conventions/conventions.instruction.md +463 -1084
  20. package/guidelines/cssRule/cssRule.instruction.md +16 -1
  21. package/guidelines/fieldRule/fieldRule.instruction.md +74 -0
  22. package/guidelines/framework/framework.instruction.md +4 -7
  23. package/guidelines/mcpRule/mcpRule.instruction.md +16 -9
  24. package/guidelines/modelConstant/modelConstant.instruction.md +2 -1
  25. package/guidelines/modelStore/modelStore.instruction.md +16 -0
  26. package/guidelines/pageRule/pageRule.instruction.md +80 -0
  27. package/guidelines/queryRule/queryRule.instruction.md +47 -12
  28. package/guidelines/runtimeRule/runtimeRule.instruction.md +89 -2
  29. package/guidelines/ssrRule/ssrRule.instruction.md +13 -0
  30. package/guidelines/transportRule/transportRule.instruction.md +107 -8
  31. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +4 -4
  32. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +70 -7
  33. package/incrementalBuilder.proc.js +4 -4
  34. package/{index-nq045px5.js → index-192ha4xh.js} +356 -307
  35. package/{index-t7nws9mx.js → index-1djcjcre.js} +661 -448
  36. package/{index-h85cxfkg.js → index-1p98exm2.js} +2 -2
  37. package/{index-hnby7p9n.js → index-1xj2t7cb.js} +7 -7
  38. package/{index-wa5jbxj1.js → index-2mrn1mrg.js} +1 -0
  39. package/{index-58vvz603.js → index-35hc95h5.js} +1 -1
  40. package/{index-tv8fjaba.js → index-4mhy6qme.js} +4 -4
  41. package/{index-rk9sdys3.js → index-5edzv8fn.js} +5 -5
  42. package/{index-k9rrten6.js → index-5nd1wtkv.js} +92 -94
  43. package/index-62md4dwy.js +260 -0
  44. package/{index-kc8z134d.js → index-665zp9rs.js} +38 -15
  45. package/{index-jwqtchha.js → index-86jt2a0e.js} +1 -1
  46. package/{index-d2242ksy.js → index-at7bz0xq.js} +3 -0
  47. package/{index-sqfdmb5b.js → index-awbdfcf2.js} +4 -4
  48. package/{index-azh29dc8.js → index-axs61rna.js} +19 -14
  49. package/{index-3hx1z96c.js → index-bqbf654f.js} +1 -1
  50. package/{index-6726qr1m.js → index-cpb3nvma.js} +57 -58
  51. package/{index-pyxn1b53.js → index-d72hfmdm.js} +13 -13
  52. package/{index-8zdwpxef.js → index-dye8pnxx.js} +119 -81
  53. package/{index-z507nzhg.js → index-fmzcs8v6.js} +4 -4
  54. package/{index-3reaaa1h.js → index-fyq1z6kt.js} +29 -27
  55. package/{index-0909wckt.js → index-g1mbppa9.js} +238 -236
  56. package/{index-fjsv10hd.js → index-hsadfb6c.js} +7 -7
  57. package/{index-tz5evhdr.js → index-j237xtew.js} +6 -6
  58. package/{index-nq2ja5e0.js → index-j4mkhz93.js} +3 -3
  59. package/{index-31ce9vhg.js → index-jw1zm273.js} +28 -30
  60. package/{index-q958tqqg.js → index-m9jj544v.js} +1 -1
  61. package/{index-8935h3n1.js → index-mdjc93e1.js} +1 -1
  62. package/{index-bea2gwc6.js → index-pydbnfez.js} +2 -2
  63. package/{index-20cebtth.js → index-qtfmtcrw.js} +17 -15
  64. package/{index-sby8fe1p.js → index-qwa5k1j8.js} +1 -1
  65. package/{index-e9prnmyt.js → index-tamvyvj3.js} +3 -3
  66. package/{index-rhbabmja.js → index-trpasv9q.js} +260 -259
  67. package/{index-2ahj896a.js → index-tvehn2sp.js} +1 -1
  68. package/{index-2etqq75t.js → index-va06nr10.js} +1090 -1078
  69. package/{index-g0vwzy9m.js → index-vk0pa0mn.js} +20 -21
  70. package/{index-xpdgxsj5.js → index-w44cy4vs.js} +2216 -2216
  71. package/index.js +22 -22
  72. package/{library.command-8tw59xzj.js → library.command-erp2f56n.js} +3 -3
  73. package/{localRegistry.command-tf3dmznd.js → localRegistry.command-hj3p16p5.js} +15 -14
  74. package/{module.command-9vm8hffy.js → module.command-gs2r615e.js} +5 -5
  75. package/{package.command-erbxe2tz.js → package.command-j10r76ax.js} +4 -4
  76. package/package.json +21 -21
  77. package/{page.command-jpavcj0p.js → page.command-4h4a8pnh.js} +3 -3
  78. package/{pipeline.command-b8rzvjvv.js → pipeline.command-a2nrk26m.js} +3 -3
  79. package/{primitive.command-sm32chzk.js → primitive.command-w6t0asqz.js} +6 -6
  80. package/{projectTypecheck-jamtx95x.js → projectTypecheck-f534enqj.js} +1 -1
  81. package/{quality.command-pkd17n6y.js → quality.command-77x7vbbx.js} +4 -4
  82. package/{repair.command-8y4mq6hs.js → repair.command-y6sstev7.js} +5 -5
  83. package/{scalar.command-q8khmyx5.js → scalar.command-20b8cy0k.js} +4 -4
  84. package/skills/akan-code/SKILL.md +4 -0
  85. package/skills/akan-store/SKILL.md +2 -1
  86. package/{subspace.command-51n0ykbx.js → subspace.command-baz73jpk.js} +11 -10
  87. package/templates/appSample/lib/task/Task.Util.tsx +7 -7
  88. package/templates/appSample/lib/task/Task.Zone.tsx +1 -1
  89. package/templates/appSample/ui/QuantityControl.tsx +2 -2
  90. package/templates/crudSinglePage/page.tsx +1 -1
  91. package/templates/lib/cnst.ts +0 -1
  92. package/templates/workspaceRoot/.gitignore.template +23 -52
  93. package/templates/workspaceRoot/biome.json.template +1 -1
  94. package/{tunnel.command-7820vtxq.js → tunnel.command-2kw8vt9g.js} +8 -7
  95. package/{workflow.command-n5sv4wqz.js → workflow.command-2djwmpqf.js} +10 -10
  96. package/{workspace.command-zdy60jh8.js → workspace.command-jqs7vjhe.js} +29 -28
  97. package/TunnelShare-f1egrktx.js +0 -13
  98. package/cloud.script-z8p5dz7e.js +0 -23
  99. package/context.runner-hnh0rg7m.js +0 -24
  100. package/index-n68jx79w.js +0 -120
@@ -1,27 +1,18 @@
1
1
  **/dist
2
- /node_modules
3
- /.akan
2
+ **/node_modules
3
+ **/.akan
4
4
  .vscode/*
5
5
  .DS_Store
6
6
  Thumbs.db
7
7
  *.env
8
- **/node_modules
9
8
  /data
10
9
  apps/*/data
11
10
  /releases
12
11
  apps/*/scripts
13
- **/.env
14
- **/env.client.local.ts
15
- **/env.client.debug.ts
16
- **/env.client.develop.ts
17
- **/env.client.main.ts
18
- **/env.client.testing.ts
19
- **/env.server.local.ts
20
- **/env.server.debug.ts
21
- **/env.server.develop.ts
22
- **/env.server.main.ts
23
- **/env.server.testing.ts
24
- **/env.server.type.ts
12
+ **/env.client.*.ts
13
+ !**/env.client.type.ts
14
+ **/env.server.*.ts
15
+ !**/env.server.example.ts
25
16
  **/*secrets.yaml
26
17
  **/kubeconfig.yaml
27
18
  **/secrets.*
@@ -46,7 +37,6 @@ DerivedData
46
37
  *.ipa
47
38
  *.xcuserstate
48
39
 
49
- build/
50
40
  .gradle
51
41
  local.properties
52
42
  *.iml
@@ -56,19 +46,18 @@ local.properties
56
46
  !debug.keystore
57
47
 
58
48
  **/public/precache.*.*.js
59
- **/public/sw.js
60
- **/public/workbox-*.js
61
- **/public/worker-*.js
62
- **/public/fallback-*.js
63
49
  **/public/precache.*.*.js.map
64
- **/public/sw.js.map
50
+ **/public/*sw.js
51
+ **/public/*sw.js.map
52
+ **/public/workbox-*.js
65
53
  **/public/workbox-*.js.map
54
+ **/public/worker-*.js
66
55
  **/public/worker-*.js.map
67
56
  **/public/fallback-*.js
57
+ **/public/fallback-*.js.map
68
58
  **/public/libs
69
59
  **/private/libs
70
60
  **/page/**/(libs)
71
- **/public/firebase-messaging-sw.js
72
61
 
73
62
  **/android/keystore.properties
74
63
  **/vendor/bundle/
@@ -78,24 +67,18 @@ local.properties
78
67
  **/*-secret.yaml
79
68
 
80
69
  # Akanjs files
81
- **/akan.app.json
82
- **/akan.lib.json
83
- **/akan.pkg.json
84
- **/next.config.ts
85
- **/next-env.d.ts
86
- apps/**/lib/__lib/**
87
- libs/**/lib/__lib/**
88
- apps/*/lib/cnst.ts
89
- apps/*/lib/dict.ts
90
- apps/*/lib/db.ts
91
- apps/*/lib/srv.ts
92
- apps/*/lib/st.ts
93
- apps/*/lib/sig.ts
94
- apps/*/lib/useClient.ts
95
- apps/*/lib/useServer.ts
96
- apps/*/lib/*/index.tsx
97
- apps/*/lib/*/index.ts
98
- apps/*/lib/__scalar/*/index.ts
70
+ **/akan.*.json
71
+ */*/lib/__lib/**
72
+ */*/lib/cnst.ts
73
+ */*/lib/dict.ts
74
+ */*/lib/db.ts
75
+ */*/lib/srv.ts
76
+ */*/lib/st.ts
77
+ */*/lib/sig.ts
78
+ */*/lib/useClient.ts
79
+ */*/lib/useServer.ts
80
+ */*/lib/*/index.ts*
81
+ */*/lib/__scalar/*/index.ts
99
82
  apps/*/ui/index.ts
100
83
  apps/*/webkit/index.ts
101
84
  apps/*/srvkit/index.ts
@@ -103,17 +86,6 @@ apps/*/common/index.ts
103
86
  apps/*/plugin/index.ts
104
87
  apps/*/client.ts
105
88
  apps/*/server.ts
106
- libs/*/lib/cnst.ts
107
- libs/*/lib/dict.ts
108
- libs/*/lib/db.ts
109
- libs/*/lib/srv.ts
110
- libs/*/lib/st.ts
111
- libs/*/lib/sig.ts
112
- libs/*/lib/useClient.ts
113
- libs/*/lib/useServer.ts
114
- libs/*/lib/*/index.tsx
115
- libs/*/lib/*/index.ts
116
- libs/*/lib/__scalar/*/index.ts
117
89
  libs/*/ui/index.ts
118
90
  libs/*/webkit/index.ts
119
91
  libs/*/srvkit/index.ts
@@ -122,5 +94,4 @@ libs/*/plugin/index.ts
122
94
  libs/*/client.ts
123
95
  libs/*/server.ts
124
96
  libs/*/index.ts
125
- **/.akan
126
97
  **/tsconfig.tsbuildinfo
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.5.12/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.5.14/schema.json",
3
3
  "extends": ["@akanjs/devkit/biome.base.json"],
4
4
  "files": {
5
5
  "includes": [
@@ -4,24 +4,25 @@ import {
4
4
  runner,
5
5
  script,
6
6
  command
7
- } from "./index-31ce9vhg.js";
7
+ } from "./index-jw1zm273.js";
8
8
  import"./index-52w0fvh8.js";
9
9
  import {
10
10
  AppExecutor
11
- } from "./index-2etqq75t.js";
11
+ } from "./index-va06nr10.js";
12
12
  import {
13
13
  GlobalConfig,
14
14
  CloudApi
15
- } from "./index-6726qr1m.js";
16
- import"./index-0909wckt.js";
17
- import"./index-nq045px5.js";
15
+ } from "./index-cpb3nvma.js";
16
+ import"./index-m9jj544v.js";
17
+ import"./index-g1mbppa9.js";
18
+ import"./index-192ha4xh.js";
18
19
  import {
19
20
  TunnelShare2
20
- } from "./index-sby8fe1p.js";
21
+ } from "./index-qwa5k1j8.js";
21
22
  import {
22
23
  writeClipboard
23
24
  } from "./index-p6pbz9n5.js";
24
- import"./index-kc8z134d.js";
25
+ import"./index-665zp9rs.js";
25
26
 
26
27
  // pkgs/@akanjs/cli/tunnel/tunnel.script.ts
27
28
  import { select } from "@inquirer/prompts";
@@ -3,20 +3,20 @@ import {
3
3
  Workspace,
4
4
  script,
5
5
  command
6
- } from "./index-31ce9vhg.js";
6
+ } from "./index-jw1zm273.js";
7
7
  import"./index-52w0fvh8.js";
8
- import"./index-2etqq75t.js";
8
+ import"./index-va06nr10.js";
9
9
  import"./index-hj6w4ka1.js";
10
- import"./index-rhbabmja.js";
11
- import"./index-rk9sdys3.js";
12
- import"./index-jwqtchha.js";
13
- import"./index-z507nzhg.js";
14
- import"./index-sqfdmb5b.js";
15
- import"./index-nq2ja5e0.js";
16
- import"./index-h85cxfkg.js";
10
+ import"./index-trpasv9q.js";
11
+ import"./index-5edzv8fn.js";
12
+ import"./index-86jt2a0e.js";
13
+ import"./index-fmzcs8v6.js";
14
+ import"./index-awbdfcf2.js";
15
+ import"./index-j4mkhz93.js";
16
+ import"./index-1p98exm2.js";
17
17
  import {
18
18
  WorkflowRunner
19
- } from "./index-hnby7p9n.js";
19
+ } from "./index-1xj2t7cb.js";
20
20
 
21
21
  // pkgs/@akanjs/cli/workflow/workflow.script.ts
22
22
  import { Logger } from "akanjs/common";
@@ -5,7 +5,7 @@ import {
5
5
  runner,
6
6
  script,
7
7
  command
8
- } from "./index-31ce9vhg.js";
8
+ } from "./index-jw1zm273.js";
9
9
  import {
10
10
  FileSys2
11
11
  } from "./index-52w0fvh8.js";
@@ -19,64 +19,65 @@ import {
19
19
  AppExecutor,
20
20
  LibExecutor,
21
21
  PkgExecutor
22
- } from "./index-2etqq75t.js";
22
+ } from "./index-va06nr10.js";
23
23
  import {
24
24
  countBlocking,
25
25
  formatStyleContract,
26
26
  ThemeValidator
27
- } from "./index-n68jx79w.js";
27
+ } from "./index-62md4dwy.js";
28
28
  import {
29
29
  collectRecipeSources2,
30
30
  scanRecipes2
31
31
  } from "./index-hj6w4ka1.js";
32
- import"./index-rhbabmja.js";
33
- import"./index-rk9sdys3.js";
32
+ import"./index-trpasv9q.js";
33
+ import"./index-5edzv8fn.js";
34
34
  import"./index-zzvvc845.js";
35
35
  import {
36
36
  AgentScript
37
- } from "./index-e9prnmyt.js";
38
- import"./index-k9rrten6.js";
39
- import"./index-g0vwzy9m.js";
40
- import"./index-0909wckt.js";
41
- import"./index-nq045px5.js";
37
+ } from "./index-tamvyvj3.js";
38
+ import"./index-5nd1wtkv.js";
39
+ import"./index-vk0pa0mn.js";
40
+ import"./index-m9jj544v.js";
41
+ import"./index-g1mbppa9.js";
42
+ import"./index-192ha4xh.js";
42
43
  import {
43
44
  LibraryScript
44
- } from "./index-bea2gwc6.js";
45
+ } from "./index-pydbnfez.js";
45
46
  import {
46
47
  ApplicationScript
47
- } from "./index-20cebtth.js";
48
+ } from "./index-qtfmtcrw.js";
48
49
  import"./index-7md2g9vw.js";
49
- import"./index-6726qr1m.js";
50
- import"./index-2ahj896a.js";
50
+ import"./index-cpb3nvma.js";
51
+ import"./index-tvehn2sp.js";
51
52
  import {
52
53
  PackageScript
53
- } from "./index-tz5evhdr.js";
54
+ } from "./index-j237xtew.js";
54
55
  import {
55
56
  getNpmRegistryUrl,
56
57
  getLatestPackageVersion
57
- } from "./index-3reaaa1h.js";
58
+ } from "./index-fyq1z6kt.js";
58
59
  import {
59
60
  CloudScript2
60
- } from "./index-fjsv10hd.js";
61
- import"./index-pyxn1b53.js";
62
- import"./index-nq2ja5e0.js";
63
- import"./index-jwqtchha.js";
64
- import"./index-z507nzhg.js";
65
- import"./index-sqfdmb5b.js";
66
- import"./index-h85cxfkg.js";
67
- import"./index-hnby7p9n.js";
61
+ } from "./index-hsadfb6c.js";
62
+ import"./index-d72hfmdm.js";
63
+ import"./index-j4mkhz93.js";
64
+ import"./index-86jt2a0e.js";
65
+ import"./index-fmzcs8v6.js";
66
+ import"./index-awbdfcf2.js";
67
+ import"./index-1p98exm2.js";
68
+ import"./index-1xj2t7cb.js";
68
69
  import {
69
70
  ContextScript
70
- } from "./index-tv8fjaba.js";
71
- import"./index-58vvz603.js";
72
- import"./index-kc8z134d.js";
71
+ } from "./index-4mhy6qme.js";
72
+ import"./index-35hc95h5.js";
73
+ import"./index-665zp9rs.js";
73
74
 
74
75
  // pkgs/@akanjs/cli/workspace/workspace.runner.ts
75
76
  import { mkdir, writeFile } from "fs/promises";
76
77
  import path from "path";
77
78
 
78
79
  // pkgs/@akanjs/devkit/biomeBase.ts
79
- var biomeVersion = "2.5.12";
80
+ var biomeVersion = "2.5.14";
80
81
 
81
82
  // pkgs/@akanjs/cli/workspace/workspace.runner.ts
82
83
  import { Ed25519Key } from "akanjs/server/ed25519Key";
@@ -1,13 +0,0 @@
1
- // @bun
2
- import {
3
- TunnelShare2
4
- } from "./index-sby8fe1p.js";
5
- import"./index-6726qr1m.js";
6
- import"./index-0909wckt.js";
7
- import"./index-kc8z134d.js";
8
- import"./index-nq045px5.js";
9
- import"./index-2etqq75t.js";
10
- import"./index-52w0fvh8.js";
11
- export {
12
- TunnelShare2 as TunnelShare
13
- };
@@ -1,23 +0,0 @@
1
- // @bun
2
- import {
3
- CloudScript2
4
- } from "./index-fjsv10hd.js";
5
- import"./index-3reaaa1h.js";
6
- import"./index-20cebtth.js";
7
- import"./index-58vvz603.js";
8
- import"./index-bea2gwc6.js";
9
- import"./index-tz5evhdr.js";
10
- import"./index-g0vwzy9m.js";
11
- import"./index-6726qr1m.js";
12
- import"./index-0909wckt.js";
13
- import"./index-31ce9vhg.js";
14
- import"./index-7md2g9vw.js";
15
- import"./index-kc8z134d.js";
16
- import"./index-k9rrten6.js";
17
- import"./index-nq045px5.js";
18
- import"./index-2etqq75t.js";
19
- import"./index-2ahj896a.js";
20
- import"./index-52w0fvh8.js";
21
- export {
22
- CloudScript2 as CloudScript
23
- };
@@ -1,24 +0,0 @@
1
- // @bun
2
- import {
3
- ContextRunner2
4
- } from "./index-pyxn1b53.js";
5
- import"./index-hnby7p9n.js";
6
- import"./index-h85cxfkg.js";
7
- import"./index-sqfdmb5b.js";
8
- import"./index-nq2ja5e0.js";
9
- import"./index-z507nzhg.js";
10
- import"./index-jwqtchha.js";
11
- import"./index-g0vwzy9m.js";
12
- import"./index-0909wckt.js";
13
- import"./index-rk9sdys3.js";
14
- import"./index-rhbabmja.js";
15
- import"./index-zzvvc845.js";
16
- import"./index-31ce9vhg.js";
17
- import"./index-kc8z134d.js";
18
- import"./index-nq045px5.js";
19
- import"./index-2etqq75t.js";
20
- import"./index-hj6w4ka1.js";
21
- import"./index-52w0fvh8.js";
22
- export {
23
- ContextRunner2 as ContextRunner
24
- };
package/index-n68jx79w.js DELETED
@@ -1,120 +0,0 @@
1
- // @bun
2
- // pkgs/@akanjs/devkit/frontendBuild/styleContract.ts
3
- var countBlocking = (violations) => violations.theme.length;
4
- var formatStyleContract = (violations) => violations.theme.flatMap((theme) => [
5
- ` [error] contrast ${theme.scope} ${theme.pair} = ${theme.ratio}:1 (min ${theme.threshold}:1)`,
6
- ` \u2192 ${theme.suggestion}`
7
- ]).join(`
8
- `);
9
-
10
- // pkgs/@akanjs/devkit/frontendBuild/themeValidator.ts
11
- var PAIRS = [
12
- { base: "background", fg: "foreground", threshold: 4.5 },
13
- { base: "primary", fg: "primary-foreground", threshold: 4.5 },
14
- { base: "secondary", fg: "secondary-foreground", threshold: 4.5 },
15
- { base: "accent", fg: "accent-foreground", threshold: 4.5 },
16
- { base: "neutral", fg: "neutral-foreground", threshold: 4.5 },
17
- { base: "card", fg: "card-foreground", threshold: 4.5 },
18
- { base: "popover", fg: "popover-foreground", threshold: 4.5 },
19
- { base: "muted", fg: "muted-foreground", threshold: 3 },
20
- { base: "info", fg: "info-foreground", threshold: 3 },
21
- { base: "success", fg: "success-foreground", threshold: 3 },
22
- { base: "warning", fg: "warning-foreground", threshold: 3 },
23
- { base: "destructive", fg: "destructive-foreground", threshold: 3 },
24
- { base: "open", fg: "open-foreground", threshold: 3 }
25
- ];
26
- var THEME_SCOPES = new Set([":root", '[data-theme="dark"]', '[data-theme="light"]']);
27
-
28
- class ThemeValidator {
29
- validate(css) {
30
- const tokensByScope = ThemeValidator.parseThemeTokens(css);
31
- const violations = [];
32
- for (const [scope, tokens] of Object.entries(tokensByScope)) {
33
- if (!THEME_SCOPES.has(scope))
34
- continue;
35
- violations.push(...this.validateScope(tokens, scope));
36
- }
37
- return violations;
38
- }
39
- validateScope(tokens, scope) {
40
- const violations = [];
41
- for (const { base, fg, threshold } of PAIRS) {
42
- const bg = tokens[base];
43
- const front = tokens[fg];
44
- if (!bg || !front)
45
- continue;
46
- const bgRgb = ThemeValidator.parseHex(bg);
47
- const fgRgb = ThemeValidator.parseHex(front);
48
- if (!bgRgb || !fgRgb)
49
- continue;
50
- const ratio = ThemeValidator.contrastRatio(bgRgb, fgRgb);
51
- if (ratio >= threshold)
52
- continue;
53
- violations.push({
54
- scope,
55
- pair: `${base} / ${fg}`,
56
- background: bg,
57
- foreground: front,
58
- ratio: Math.round(ratio * 100) / 100,
59
- threshold,
60
- suggestion: `In ${scope}, --${base} (${bg}) against --${fg} (${front}) is ${ratio.toFixed(2)}:1, under the ${threshold}:1 minimum. Lighten or darken one of them until it clears.`
61
- });
62
- }
63
- return violations;
64
- }
65
- static parseThemeTokens(css) {
66
- const result = {};
67
- const blockRe = /(?:^|})\s*([^{}@]+?)\s*\{([^{}]*)\}/g;
68
- for (const block of css.matchAll(blockRe)) {
69
- const selectors = block[1].split(",").map((s) => s.trim());
70
- const relevant = selectors.filter((s) => THEME_SCOPES.has(ThemeValidator.#normalizeScope(s)));
71
- if (relevant.length === 0)
72
- continue;
73
- const decls = {};
74
- for (const decl of block[2].matchAll(/--([\w-]+)\s*:\s*([^;]+?)\s*(?:;|$)/g)) {
75
- decls[decl[1]] = decl[2].trim();
76
- }
77
- for (const selector of relevant) {
78
- const scope = ThemeValidator.#normalizeScope(selector);
79
- result[scope] = { ...result[scope] ?? {}, ...decls };
80
- }
81
- }
82
- return result;
83
- }
84
- static #normalizeScope(selector) {
85
- return selector.replace(/\[data-theme=['"]?([\w-]+)['"]?\]/g, '[data-theme="$1"]').trim();
86
- }
87
- static parseHex(value) {
88
- const v = value.trim();
89
- if (!v.startsWith("#"))
90
- return null;
91
- const hex = v.slice(1);
92
- let full;
93
- if (hex.length === 3 || hex.length === 4)
94
- full = hex.slice(0, 3).split("").map((c) => c + c).join("");
95
- else if (hex.length === 6 || hex.length === 8)
96
- full = hex.slice(0, 6);
97
- else
98
- return null;
99
- if (!/^[0-9a-fA-F]{6}$/.test(full))
100
- return null;
101
- const n = Number.parseInt(full, 16);
102
- return [n >> 16 & 255, n >> 8 & 255, n & 255];
103
- }
104
- static #relativeLuminance([r, g, b]) {
105
- const channel = (c) => {
106
- const s = c / 255;
107
- return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
108
- };
109
- return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);
110
- }
111
- static contrastRatio(a, b) {
112
- const la = ThemeValidator.#relativeLuminance(a);
113
- const lb = ThemeValidator.#relativeLuminance(b);
114
- const hi = Math.max(la, lb);
115
- const lo = Math.min(la, lb);
116
- return (hi + 0.05) / (lo + 0.05);
117
- }
118
- }
119
-
120
- export { countBlocking, formatStyleContract, ThemeValidator };