@kayjs/kay 1.104.2 → 1.104.3

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 (112) hide show
  1. package/README.md +2 -7
  2. package/dist/eslint.js +208 -34
  3. package/editors/zed/extension.toml +2 -2
  4. package/llms/check-and-tools.md +5 -3
  5. package/llms/code-lints.md +1 -0
  6. package/llms/components.md +1 -1
  7. package/llms/islands.md +1 -1
  8. package/llms/project-new-and-add.md +5 -5
  9. package/llms/project.md +1 -2
  10. package/llms/styles-and-assets.md +1 -1
  11. package/llms/testing-browser.md +1 -0
  12. package/llms/upgrading.md +4 -0
  13. package/llms/whats-new-archive.md +17 -1
  14. package/llms/whats-new.md +20 -17
  15. package/llms.txt +1 -1
  16. package/package.json +9 -7
  17. package/src/add.ts +2 -0
  18. package/src/build/class-rules.ts +8 -0
  19. package/src/build/client.ts +6 -3
  20. package/src/build/recipe-classes.ts +11 -1
  21. package/src/build/recipe-utilities.ts +183 -0
  22. package/src/build/signals.ts +113 -14
  23. package/src/build/style-uses.ts +7 -6
  24. package/src/build/supports.ts +4 -4
  25. package/src/check/removed-ui-tokens.ts +2 -2
  26. package/src/check/shadow-types.ts +2 -0
  27. package/src/check/text-size-colour.ts +57 -0
  28. package/src/commands/new.ts +17 -7
  29. package/src/commands/upgrade-majors.ts +26 -0
  30. package/src/commands/upgrade-manifest.ts +23 -0
  31. package/src/commands/upgrade-messages.ts +16 -0
  32. package/src/commands/upgrade-peers.ts +89 -0
  33. package/src/commands/upgrade.ts +68 -36
  34. package/src/compiler/codegen.ts +1 -1
  35. package/src/compiler/dom.ts +12 -1
  36. package/src/compiler/index.ts +32 -17
  37. package/src/compiler/island-cause.ts +5 -2
  38. package/src/compiler/module-signals.ts +111 -8
  39. package/src/compiler/rewrite-reads.ts +1 -1
  40. package/src/compiler/route-lints.ts +8 -0
  41. package/src/compiler/script-props.ts +18 -1
  42. package/src/compiler/script-shared.ts +2 -0
  43. package/src/eslint/index.ts +19 -2
  44. package/src/features.ts +2 -2
  45. package/src/lsp/semantic-tokens.ts +2 -2
  46. package/src/migrate/project.ts +2 -2
  47. package/src/new.ts +6 -4
  48. package/src/runtime/dom.ts +11 -12
  49. package/src/template-config.ts +11 -4
  50. package/src/template-docker.ts +1 -1
  51. package/src/template-shared.ts +4 -1
  52. package/src/template-starter.ts +25 -4
  53. package/src/template-styles.ts +55 -43
  54. package/src/template-ws.ts +1 -1
  55. package/src/templates.ts +2 -4
  56. package/src/test/browser.ts +2 -5
  57. package/src/test/text-match.ts +44 -0
  58. package/types/add.d.ts.map +1 -1
  59. package/types/build/class-rules.d.ts +1 -0
  60. package/types/build/class-rules.d.ts.map +1 -1
  61. package/types/build/client.d.ts.map +1 -1
  62. package/types/build/recipe-classes.d.ts +2 -0
  63. package/types/build/recipe-classes.d.ts.map +1 -1
  64. package/types/build/recipe-utilities.d.ts +4 -0
  65. package/types/build/recipe-utilities.d.ts.map +1 -0
  66. package/types/build/signals.d.ts.map +1 -1
  67. package/types/build/style-uses.d.ts +1 -0
  68. package/types/build/style-uses.d.ts.map +1 -1
  69. package/types/build/supports.d.ts +1 -1
  70. package/types/build/supports.d.ts.map +1 -1
  71. package/types/check/removed-ui-tokens.d.ts +2 -0
  72. package/types/check/removed-ui-tokens.d.ts.map +1 -1
  73. package/types/check/shadow-types.d.ts.map +1 -1
  74. package/types/check/text-size-colour.d.ts +3 -0
  75. package/types/check/text-size-colour.d.ts.map +1 -0
  76. package/types/commands/new.d.ts.map +1 -1
  77. package/types/commands/upgrade-majors.d.ts +7 -0
  78. package/types/commands/upgrade-majors.d.ts.map +1 -0
  79. package/types/commands/upgrade-manifest.d.ts +6 -0
  80. package/types/commands/upgrade-manifest.d.ts.map +1 -0
  81. package/types/commands/upgrade-messages.d.ts +4 -0
  82. package/types/commands/upgrade-messages.d.ts.map +1 -0
  83. package/types/commands/upgrade-peers.d.ts +23 -0
  84. package/types/commands/upgrade-peers.d.ts.map +1 -0
  85. package/types/commands/upgrade.d.ts +7 -0
  86. package/types/commands/upgrade.d.ts.map +1 -1
  87. package/types/compiler/dom.d.ts +1 -0
  88. package/types/compiler/dom.d.ts.map +1 -1
  89. package/types/compiler/index.d.ts.map +1 -1
  90. package/types/compiler/island-cause.d.ts +2 -2
  91. package/types/compiler/island-cause.d.ts.map +1 -1
  92. package/types/compiler/lints.d.ts +8 -0
  93. package/types/compiler/lints.d.ts.map +1 -1
  94. package/types/compiler/module-signals.d.ts +14 -1
  95. package/types/compiler/module-signals.d.ts.map +1 -1
  96. package/types/compiler/route-lints.d.ts +8 -0
  97. package/types/compiler/route-lints.d.ts.map +1 -1
  98. package/types/compiler/script-props.d.ts.map +1 -1
  99. package/types/compiler/script-shared.d.ts +1 -0
  100. package/types/compiler/script-shared.d.ts.map +1 -1
  101. package/types/new.d.ts.map +1 -1
  102. package/types/runtime/dom.d.ts +1 -0
  103. package/types/runtime/dom.d.ts.map +1 -1
  104. package/types/template-config.d.ts.map +1 -1
  105. package/types/template-shared.d.ts +1 -1
  106. package/types/template-shared.d.ts.map +1 -1
  107. package/types/template-starter.d.ts.map +1 -1
  108. package/types/template-styles.d.ts.map +1 -1
  109. package/types/templates.d.ts.map +1 -1
  110. package/types/test/browser.d.ts.map +1 -1
  111. package/types/test/text-match.d.ts +13 -0
  112. package/types/test/text-match.d.ts.map +1 -0
@@ -1,6 +1,22 @@
1
1
  # What's new, older releases
2
2
 
3
- What each release before 1.101 added, and the end of a newest release that was cut short (`(continued)`), newest first, each feature with where it is documented. The newer releases are in [What's new](whats-new.md); what a release breaks is in [Upgrading](upgrading.md).
3
+ What each release before 1.102 added, and the end of a newest release that was cut short (`(continued)`), newest first, each feature with where it is documented. The newer releases are in [What's new](whats-new.md); what a release breaks is in [Upgrading](upgrading.md).
4
+
5
+ ## 1.101.0
6
+
7
+ - Compile errors carry their own code per problem instead of `template-invalid` (`head-invalid`, `duplicate-attribute`, `part-invalid`, `bind-misuse`, `name-clash` and more), and the ones with one right answer carry a quick fix `kay check --fix` applies: `onclick` and `on:click`, a repeated static `class`, a valueless `class`, a `part`, `field` or `style:` value written the wrong way. `kay explain` covers lints and errors alike. See [Errors](errors.md).
8
+ - A browser global read while rendering is caught earlier and says more: `kay check --fix` wraps a call on the global (`localStorage.setItem(...)`, `document.title = ...`) in `effect`, `kay check` and the build report a module a page imports that reads `window` or `document` as it loads (the `browser-global-at-load` lint), and a server render failing on one names the global, the component and its line in production too ([browser-only](browser-only.md#browser-globals-on-the-server)).
9
+ - `apiUrl(module, path, { params, query })` is typed from the module: the path is one of its routes (the editor completes them), a path with params asks for them as `route()` does (a number fills one), and an unknown path is a type error; `apiUrl(request, path)` in a handler takes any path. See [API routes](api-routes.md).
10
+ - A `for` with no `key` matches rows by `id`, else by the item itself, never by position: a copy of an object with no `id` is a new row, and `unkeyed-rows` warns of such a `for` in an island and offers `key={i}` ([Templates](templates.md), [Lints](lints.md), upgrade line).
11
+ - The editor completes the attributes and events of a plain element from `JSX.IntrinsicElements` (`onDblClick`, `inputmode`, `form`, `aria-*`, `transition:*`), the words of an enumerated attribute inside its quotes (`type=`, `role=`, `autocomplete=`, `target=`, `loading=`) and the modifiers after `|` on an event; `role` and `autocomplete` type their common words while any other still goes ([editor](editor-and-agent-commands.md)).
12
+ - `online()`, `pageVisible()`, `inView(options)` and `throttled(source, delay)` from `kay` give the connection, the tab's visibility, an element's presence in the viewport and a rate-limited value as reactive values; `elementSize().ref` and `inView().ref` let go of an element an `if` removes and take several ([Islands](islands.md#follow-the-connection-the-tab-and-the-scroll), [Effects](effects.md)).
13
+ - kayjs-auth: `account: { deleteAfter: '14d' }` gives a deleted account a grace period: `account.delete` marks it pending and mails a link to cancel, the user cancels from the `DeletionBanner` on the prebuilt pages (or `account.cancelDeletion()`), and the prune does the real deletion, `beforeDelete`, the audit log, `onEvent` and the account-deleted mail following it; off by default, and the Postgres table gains a nullable `delete_at` column ([grace period](../../auth/llms/passwords-and-mails.md#deleting-an-account-after-a-grace-period)).
14
+ - kayjs-auth: `linkedin`, `facebook`, `twitch`, `slack` and `x` join the OAuth presets, so `oauth: { x: true }` reads `X_CLIENT_ID` and `X_CLIENT_SECRET` and `kay env` lists them; X gives no email, and an `OAuthProvider` can set `clientAuth: 'basic'` for a token endpoint that wants an HTTP Basic header ([OAuth provider presets](../../auth/llms/oauth-providers.md)).
15
+ - Eight accessibility lints, all warnings: `empty-heading`, `anchor-is-valid` (an `a` with no `href`, or `#` or `javascript:`, and no handler), `redundant-role` (`button(role="button")`), `unsupported-aria` (`aria-checked` on a `button`), `multiple-h1`, `no-access-key`, `click-without-key` (`onClick` on a focusable element with no key handler on it or around it) and `interactive-tabindex` (`tabindex="0"` on a `p`); each leaves a component, a spread or an expression alone ([Lints](lints.md), [Checks](checks.md)).
16
+ - A `_loading.kay` in a routes folder shows, after `client.loadingDelay` (`'200ms'`), when a link to a slow page in its folder or below is followed, inside the page's layouts, until the page swaps in ([Navigation](navigation.md), [Special pages](routing-special-pages.md#special-pages)).
17
+ - kayjs-mail: components take per-use styling: `style` (appended last), the element's own attributes and `align` where it makes sense, `Button` takes `tone` (`accent`, `neutral`, `danger`), `block` and `target`, `Heading` and `Paragraph` take `tone`, `Image` takes `href`; the settings gain optional `danger` and `onDanger` colours, with dark equivalents derived or set through `dark`, and the Outlook fixes and the dark-mode classes still apply ([kayjs-mail](../../mail/llms/writing-and-sending.md)).
18
+ - `persisted` has one entry per storage, each with the options its storage takes: `persisted.cookie()` (which `persisted()` is), `persisted.local()`, `persisted.session()` (new, sessionStorage) and `persisted.query()`; `sync` reaches `local` and `session` through the `storage` event. `storage` of `persisted()` works until 1.104 and `kay upgrade` rewrites it ([persisted](islands-state-to-ids.md), upgrade line, `deprecated-persisted-storage`).
19
+ - `persisted` has one entry per storage, each with the options its storage takes: `persisted.cookie()` (which `persisted()` is), `persisted.local()`, `persisted.session()` (new, sessionStorage) and `persisted.query()`; `session` takes `sync` too, through the `storage` event, which a sessionStorage's tab shares with its frames only. `storage` of `persisted()` works until 1.104 and `kay upgrade` rewrites it ([persisted](islands-state-to-ids.md), upgrade line, `deprecated-persisted-storage`).
4
20
 
5
21
  ## 1.100.0
6
22
 
package/llms/whats-new.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  What each release of kay and its libraries adds, newest first, each feature with where it is documented. kay and its libraries share one version, so one section covers them all; what a release breaks is in [Upgrading](upgrading.md).
4
4
 
5
+ ## 1.104.3
6
+
7
+ - `kay new` writes no `.npmrc`: kay and every package a preset installs (`@kaynooo/eslint`, `@kaynooo/pg-orm`, `@kaynooo/utils`) are on npm, and kay depends on `@kaynooo/cli-kit` 0.46.1, a version npm carries, so a project installs with Bun's defaults and the install pages have no registry step; the generated `Dockerfile` copies `package.json` and the lockfile alone, and an existing project's `.npmrc` stays harmless ([project setup](project-new-and-add.md)).
8
+ - A compiled component is smaller: a prop whose default is a literal (a string, number, boolean, `null`, a template with no expression) is written where the prop is read, with no holder, and a branch holding one component compiles to one call; an object, array or function default keeps its holder, so its identity holds across reads ([props](components.md)).
9
+ - kayjs-ui: `starfield` works without the space skin and in light mode: `@import '@kayjs/ui/starfield.css'` after the theme, `class="starfield"` on `body`; the dots (eleven, three tints, scattered where `random()` works) read `--color-star`, `--color-star-cool` and `--color-star-warm`, white by night and ink by day, and `kay new`'s starter uses it ([Setup](../../ui/llms/setup.md)).
10
+ - kayjs-ui: the space skin's sky is now orbit's, denser and in three tints, and `starfield` works without the skin and in light mode: `@import '@kayjs/ui/starfield.css'` after the theme, `class="starfield"` on `body`; the dots (eleven, three tints, scattered where `random()` works) read `--color-star`, `--color-star-cool` and `--color-star-warm`, white by night and ink by day, and `kay new`'s starter uses it ([Setup](../../ui/llms/setup.md)).
11
+ - `kay upgrade` adds to `devDependencies` the optional peers the app had installed without declaring them (`typescript7`, `axe-core`, `@happy-dom/global-registrator`, `@kaynooo/pg-orm`), at the new kay's range, in text, under `--dry-run` and as `changed` under `--format json` ([kay upgrade](check-and-tools.md)).
12
+ - `kay upgrade` warns when it raises a dependency the app shares with kay across a major (a 0.x minor counts), naming the versions and the package's migration file or repository, in text and as `warnings` under `--format json` ([kay upgrade](check-and-tools.md)).
13
+ - kayjs-ui: a Meter and a Progress draw their track `surface-strong`, so the unfilled part reads inside a Card or any `bg-surface` box; Toggle's frame, Slider's and AudioPlayer's range track already read at 3:1, and a test holds every track on the background, surface and popover in both schemes and each skin ([Setup](../../ui/llms/setup.md)).
14
+ - `kay new` starts from orbit's look: kayjs-ui's space skin (the `ui` feature, now in every preset, with `AppHeader`, Space Grotesk and JetBrains Mono through `fonts`), a near-black palette named as kayjs-ui names it (`background`, `foreground`, `border`, `muted`), a starfield behind the page, a hairline on every box, and an accent picker of twelve accents; the palette no longer defines `--color-base`, which made `text-base` paint text the page background ([kay new](project-new-and-add.md)).
15
+ - kayjs-ui's `AppHeader` and `SiteNav` are islands only in a use that sets `open`, `onOpenChange` or `link`, so a header with none of them is markup and its menu the browser's popover, with no script of its own ([kayjs-ui](../../ui/llms/tables-navigation-and-layout.md)).
16
+ - The `text-size-colour` lint reports `text-base` (or another size) in an app whose CSS defines a colour of the same name, such as `--color-base`, where the utility is the font size and the text colour at once ([code lints](code-lints.md)).
17
+ - `kay lint --fix` leaves no semicolon in a `.kay` fence: a fix that rewrites code up to the next token (`style/semi` after the `import type` split of `import/consistent-type-specifier-style`) is cut down to what it changes, so it applies instead of being dropped.
18
+ - A component reading a `persisted` value (`local`, `session`, `cookie` or `query`) imported from a `.ts` module is an island, as one reading a `live` value is, also when the module re-exports it (`export { x } from`, `export *`) or imports it and exposes it; `kay explain island` says so: [Islands](islands.md).
19
+ - A component reading a `persisted` value (`local`, `session`, `cookie` or `query`) imported from a `.ts` module is an island, as one reading a `live` value is, also when the module re-exports it (`export { x } from`, `export *`) or imports it and exposes it (a `live` value or a `signal` reached that way is now found too); `kay explain island` says so: [Islands](islands.md).
20
+ - `waitFor(selector, { text })` in a browser test matches a French page's text typed with plain spaces, where kay wrote non-breaking ones (U+00A0, U+202F), and a timeout says when an element holds the text up to its whitespace: [Browser tests](testing-browser.md).
21
+ - kayjs-ui: `Meter(segments={[{ value: 5, tone: 'success', label: 'known' }, ...]} max={22})` draws parts of one total end to end, each a `fill` part, and screen readers hear each one ([Meter](../../ui/llms/basics.md)).
22
+ - A utility a recipe lifts has one rule, in `utilities.recipe`: Tailwind no longer also writes it in `utilities` unless a file, a word of the build or an `@source inline` names it too ([styles](styles-and-assets.md)).
23
+
5
24
  ## 1.104.0
6
25
 
7
26
  - The 1.100 deprecations are gone: the `id` of a kayjs-ui TreeNode and the `id`, `title` and `url` of a Bell item (now `key`, `label` and `href`, with `nodeKey()` removed), `pageSize` of `infiniteList` (`limit`), `cmsSignInAs`, `cmsSignInWith` and `cmsSignOut` (`cmsTest(site)`), and `count` of `CollectionInfo` (`total`): [Upgrading](upgrading.md).
@@ -36,20 +55,4 @@ What each release of kay and its libraries adds, newest first, each feature with
36
55
  - `--- script` opening a file is written `---`: `kay upgrade` rewrites it (`deprecated-script-fence`), and the one place the word stays is a script after a `--- server`, `--- module` or `--- style` fence, in the [fence table](components.md#file-layout).
37
56
  - `if user then u` names the value an `if` or `else if` tests, as `await x then v` does, so `as` is only a cast and no longer an alias by the casing of what follows; `if user as u` works until 1.105 and `kay upgrade` rewrites it ([templates](templates.md)).
38
57
 
39
- ## 1.101.0
40
-
41
- - Compile errors carry their own code per problem instead of `template-invalid` (`head-invalid`, `duplicate-attribute`, `part-invalid`, `bind-misuse`, `name-clash` and more), and the ones with one right answer carry a quick fix `kay check --fix` applies: `onclick` and `on:click`, a repeated static `class`, a valueless `class`, a `part`, `field` or `style:` value written the wrong way. `kay explain` covers lints and errors alike. See [Errors](errors.md).
42
- - A browser global read while rendering is caught earlier and says more: `kay check --fix` wraps a call on the global (`localStorage.setItem(...)`, `document.title = ...`) in `effect`, `kay check` and the build report a module a page imports that reads `window` or `document` as it loads (the `browser-global-at-load` lint), and a server render failing on one names the global, the component and its line in production too ([browser-only](browser-only.md#browser-globals-on-the-server)).
43
- - `apiUrl(module, path, { params, query })` is typed from the module: the path is one of its routes (the editor completes them), a path with params asks for them as `route()` does (a number fills one), and an unknown path is a type error; `apiUrl(request, path)` in a handler takes any path. See [API routes](api-routes.md).
44
- - A `for` with no `key` matches rows by `id`, else by the item itself, never by position: a copy of an object with no `id` is a new row, and `unkeyed-rows` warns of such a `for` in an island and offers `key={i}` ([Templates](templates.md), [Lints](lints.md), upgrade line).
45
- - The editor completes the attributes and events of a plain element from `JSX.IntrinsicElements` (`onDblClick`, `inputmode`, `form`, `aria-*`, `transition:*`), the words of an enumerated attribute inside its quotes (`type=`, `role=`, `autocomplete=`, `target=`, `loading=`) and the modifiers after `|` on an event; `role` and `autocomplete` type their common words while any other still goes ([editor](editor-and-agent-commands.md)).
46
- - `online()`, `pageVisible()`, `inView(options)` and `throttled(source, delay)` from `kay` give the connection, the tab's visibility, an element's presence in the viewport and a rate-limited value as reactive values; `elementSize().ref` and `inView().ref` let go of an element an `if` removes and take several ([Islands](islands.md#follow-the-connection-the-tab-and-the-scroll), [Effects](effects.md)).
47
- - kayjs-auth: `account: { deleteAfter: '14d' }` gives a deleted account a grace period: `account.delete` marks it pending and mails a link to cancel, the user cancels from the `DeletionBanner` on the prebuilt pages (or `account.cancelDeletion()`), and the prune does the real deletion, `beforeDelete`, the audit log, `onEvent` and the account-deleted mail following it; off by default, and the Postgres table gains a nullable `delete_at` column ([grace period](../../auth/llms/passwords-and-mails.md#deleting-an-account-after-a-grace-period)).
48
- - kayjs-auth: `linkedin`, `facebook`, `twitch`, `slack` and `x` join the OAuth presets, so `oauth: { x: true }` reads `X_CLIENT_ID` and `X_CLIENT_SECRET` and `kay env` lists them; X gives no email, and an `OAuthProvider` can set `clientAuth: 'basic'` for a token endpoint that wants an HTTP Basic header ([OAuth provider presets](../../auth/llms/oauth-providers.md)).
49
- - Eight accessibility lints, all warnings: `empty-heading`, `anchor-is-valid` (an `a` with no `href`, or `#` or `javascript:`, and no handler), `redundant-role` (`button(role="button")`), `unsupported-aria` (`aria-checked` on a `button`), `multiple-h1`, `no-access-key`, `click-without-key` (`onClick` on a focusable element with no key handler on it or around it) and `interactive-tabindex` (`tabindex="0"` on a `p`); each leaves a component, a spread or an expression alone ([Lints](lints.md), [Checks](checks.md)).
50
- - A `_loading.kay` in a routes folder shows, after `client.loadingDelay` (`'200ms'`), when a link to a slow page in its folder or below is followed, inside the page's layouts, until the page swaps in ([Navigation](navigation.md), [Special pages](routing-special-pages.md#special-pages)).
51
- - kayjs-mail: components take per-use styling: `style` (appended last), the element's own attributes and `align` where it makes sense, `Button` takes `tone` (`accent`, `neutral`, `danger`), `block` and `target`, `Heading` and `Paragraph` take `tone`, `Image` takes `href`; the settings gain optional `danger` and `onDanger` colours, with dark equivalents derived or set through `dark`, and the Outlook fixes and the dark-mode classes still apply ([kayjs-mail](../../mail/llms/writing-and-sending.md)).
52
- - `persisted` has one entry per storage, each with the options its storage takes: `persisted.cookie()` (which `persisted()` is), `persisted.local()`, `persisted.session()` (new, sessionStorage) and `persisted.query()`; `sync` reaches `local` and `session` through the `storage` event. `storage` of `persisted()` works until 1.104 and `kay upgrade` rewrites it ([persisted](islands-state-to-ids.md), upgrade line, `deprecated-persisted-storage`).
53
- - `persisted` has one entry per storage, each with the options its storage takes: `persisted.cookie()` (which `persisted()` is), `persisted.local()`, `persisted.session()` (new, sessionStorage) and `persisted.query()`; `session` takes `sync` too, through the `storage` event, which a sessionStorage's tab shares with its frames only. `storage` of `persisted()` works until 1.104 and `kay upgrade` rewrites it ([persisted](islands-state-to-ids.md), upgrade line, `deprecated-persisted-storage`).
54
-
55
- Releases before 1.101 are in [What's new, older releases](whats-new-archive.md).
58
+ Releases before 1.102 are in [What's new, older releases](whats-new-archive.md).
package/llms.txt CHANGED
@@ -115,7 +115,7 @@ To build a site, read [Build a site](llms/site.md) first, then the topics below;
115
115
  - [Upgrading](llms/upgrading.md): what each recent minor breaks, and what an app changes
116
116
  - [Upgrading, older](llms/upgrading-archive.md): the minors before 1.98
117
117
  - [What's new](llms/whats-new.md): what each recent release adds
118
- - [What's new, older](llms/whats-new-archive.md): the releases before 1.101
118
+ - [What's new, older](llms/whats-new-archive.md): the releases before 1.102
119
119
  - [Privacy and personal data](llms/privacy.md): what kay keeps, erasing a person
120
120
  - [Events and names](llms/events.md): DOM events, cookie and key rules
121
121
  - [Notifications](llms/notifications.md): `notify()`, the Bell
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kayjs/kay",
3
3
  "type": "module",
4
- "version": "1.104.2",
4
+ "version": "1.104.3",
5
5
  "description": "A Bun web framework: one .kay file per component, pages rendered to plain HTML on the server, interactive islands in the browser",
6
6
  "author": "Kaynooo <https://github.com/Kayno0o>",
7
7
  "license": "MIT",
@@ -278,7 +278,7 @@
278
278
  },
279
279
  "dependencies": {
280
280
  "@jsquash/avif": "2.1.1",
281
- "@kaynooo/cli-kit": "0.41.2",
281
+ "@kaynooo/cli-kit": "0.46.1",
282
282
  "@kaynooo/utils": "^3.1.0",
283
283
  "@resvg/resvg-js": "^2.6.2",
284
284
  "devalue": "^6.0.3",
@@ -290,14 +290,16 @@
290
290
  "@babel/parser": "^7.29.7",
291
291
  "@babel/traverse": "^7.29.10",
292
292
  "@babel/types": "^7.29.11",
293
+ "@fontsource-variable/jetbrains-mono": "5.3.0",
294
+ "@fontsource-variable/space-grotesk": "5.3.0",
293
295
  "@fontsource/inter": "^5.3.0",
294
296
  "@happy-dom/global-registrator": "^21.0.4",
295
297
  "@iconify-json/tabler": "^1.2.42",
296
- "@kayjs/ai": "1.104.2",
297
- "@kayjs/auth": "1.104.2",
298
- "@kayjs/cms": "1.104.2",
299
- "@kayjs/mail": "1.104.2",
300
- "@kayjs/ui": "1.104.2",
298
+ "@kayjs/ai": "1.104.3",
299
+ "@kayjs/auth": "1.104.3",
300
+ "@kayjs/cms": "1.104.3",
301
+ "@kayjs/mail": "1.104.3",
302
+ "@kayjs/ui": "1.104.3",
301
303
  "@kaynooo/eslint": "^7.1.6",
302
304
  "@kaynooo/pg-orm": "^8.1.4",
303
305
  "@oxc-parser/binding-wasm32-wasip1": "0.155.0",
package/src/add.ts CHANGED
@@ -112,6 +112,8 @@ export async function detectFeatures(dir: string): Promise<Set<Feature>> {
112
112
  ['tailwind', css?.includes('@import \'tailwindcss\'') === true],
113
113
  ['accents', at('src/theme.ts')],
114
114
  ['eslint', at('eslint.config.ts')],
115
+ // kayjs-ui's skin, imported by the stylesheet whether `ui()` mounts it or not.
116
+ ['ui', css?.includes('@kayjs/ui/') === true],
115
117
  ['tests', at('bunfig.toml')],
116
118
  ['ci', ['.forgejo', '.github'].some(host => at(`${host}/workflows/test.yml`) || at(`${host}/workflows/pages.yml`))],
117
119
  ['docker', at('Dockerfile')],
@@ -194,6 +194,14 @@ export function pruneNodes(nodes: Node[], unused: ReadonlySet<string>): Node[] {
194
194
  return unused.size === 0 ? nodes : prune(nodes, name => unused.has(name))
195
195
  }
196
196
 
197
+ // The parsed stylesheet with the selectors needing a class of `unused`, as the class attribute writes it, left out of its `@layer utilities` blocks alone.
198
+ export function pruneUtilityLayer(nodes: Node[], unused: ReadonlySet<string>): Node[] {
199
+ if (unused.size === 0)
200
+ return nodes
201
+
202
+ return nodes.map(node => 'prelude' in node && node.prelude.replace(COMMENTS, '').trim() === '@layer utilities' ? { prelude: node.prelude, body: prune(node.body, name => unused.has(unescapeClass(name))) } : node)
203
+ }
204
+
197
205
  const ESCAPE = /\\(?:([\da-f]{1,6})\s?|([\s\S]))/gi
198
206
 
199
207
  // CSS reads a code point out of range, a surrogate or zero as the replacement character.
@@ -27,7 +27,7 @@ import { fontFallbacks, withFontFallbacks } from '../server/fonts'
27
27
  import { routeMounts } from '../server/routes'
28
28
  import { declaresAction } from './action-calls'
29
29
  import { ASSET_PREFIX, clientDir, DEV_MAPS_DIR, MAPS_DIR, outputDir } from './assets'
30
- import { pruneNodes } from './class-rules'
30
+ import { pruneNodes, pruneUtilityLayer } from './class-rules'
31
31
  import { buildClassTable, mergesAtRuntime } from './class-table'
32
32
  import { CSS_FILE, findKayFiles, findProjectFiles, forgetSources, inWalkScope, keepSources, liftSources, readSource, readSourcePaths, readText, writeIfChanged } from './files'
33
33
  import { Increments, realPaths, sameEntries } from './increments'
@@ -40,6 +40,7 @@ import { isPageFile, pageDirs } from './page-dirs'
40
40
  import { kay } from './plugin'
41
41
  import { unusedLibraryClasses } from './prune'
42
42
  import { recipeLifter } from './recipe-classes'
43
+ import { recipeOnlyUtilities } from './recipe-utilities'
43
44
  import { referencesOf } from './references'
44
45
  import { sizeReport } from './report'
45
46
  import { ANCHOR, runtimeAnchor, runtimeChunk } from './runtime-chunk'
@@ -690,6 +691,8 @@ async function bundleStyles(root: string, { pages, files, libraries, classes, sh
690
691
 
691
692
  await writeComponentStylesheets(root, files)
692
693
 
694
+ // Tailwind scans the raw sources, whose recipes still name the utilities they lifted: their rules are cut from its output.
695
+ const recipeOnlyNames = recipeOnlyUtilities(root, await recipeLifter(root), classes)
693
696
  const since = raisedMark()
694
697
  const [build, unused] = await Promise.all([Bun.build({
695
698
  entrypoints: pages,
@@ -698,8 +701,8 @@ async function bundleStyles(root: string, { pages, files, libraries, classes, sh
698
701
  minify: options.minify ?? false,
699
702
  metafile: true,
700
703
  naming: { entry: '[name]-[hash].[ext]', chunk: '[name]-[hash].[ext]', asset: '[name]-[hash].[ext]' },
701
- plugins: [styleImports(root, libraries, shrunk, reached), ...mergingSupports(options.plugins ?? [], async nodes => pruneNodes(nodes, await unusedClasses), { root, files: referencesOf(options.extensions) })],
702
- }), unusedClasses])
704
+ plugins: [styleImports(root, libraries, shrunk, reached), ...mergingSupports(options.plugins ?? [], async (nodes, tailwind) => pruneUtilityLayer(pruneNodes(nodes, await unusedClasses), tailwind ? await recipeOnlyNames : new Set()), { root, files: referencesOf(options.extensions) })],
705
+ }), unusedClasses, recipeOnlyNames])
703
706
 
704
707
  if (!build.success)
705
708
  throw buildFailure(build.logs, 'kay: stylesheet build failed', since)
@@ -26,6 +26,8 @@ export interface Lifted {
26
26
  source: string
27
27
  // The stylesheet rules of the lifted classes, in the order a variant beats the base.
28
28
  rules: string
29
+ // The utilities that left the source, each once.
30
+ utilities: string[]
29
31
  }
30
32
 
31
33
  // The string a literal of a recipe's config holds, or none for any other node.
@@ -97,6 +99,7 @@ export function liftRecipes(source: string, moduleId: string, utility: (token: s
97
99
  const calls = recipeNames(program.body)
98
100
  const edits: Edit[] = []
99
101
  const rules: string[] = []
102
+ const utilities = new Set<string>()
100
103
  // The hash's last digits are the evenly spread ones.
101
104
  const prefix = scopeHash(moduleId).slice(-6)
102
105
 
@@ -116,6 +119,10 @@ export function liftRecipes(source: string, moduleId: string, utility: (token: s
116
119
  const name = `k${prefix}${rules.length.toString(36)}`
117
120
 
118
121
  rules.push(` .${name} { @apply ${lifted.join(' ')}; }`)
122
+
123
+ for (const token of lifted)
124
+ utilities.add(token)
125
+
119
126
  const start = script.start + node.start
120
127
  const end = script.start + node.end
121
128
 
@@ -133,13 +140,15 @@ export function liftRecipes(source: string, moduleId: string, utility: (token: s
133
140
  for (const edit of edits.toReversed())
134
141
  changed = changed.slice(0, edit.start) + edit.text + changed.slice(edit.end)
135
142
 
136
- return { source: changed, rules: `@layer utilities.recipe {\n${rules.join('\n')}\n}\n` }
143
+ return { source: changed, rules: `@layer utilities.recipe {\n${rules.join('\n')}\n}\n`, utilities: [...utilities] }
137
144
  }
138
145
 
139
146
  export interface RecipeLifter {
140
147
  // Changes with the design system the tokens are read through, so what was read of a source under another does not stand.
141
148
  readonly id: number
142
149
  lift: (source: string, file: string) => Lifted | undefined
150
+ // The utilities the sources lifted so far moved out of their classes.
151
+ utilities: () => Set<string>
143
152
  }
144
153
 
145
154
  // A design system can serve several roots, and a module's name comes from its path in its own.
@@ -185,6 +194,7 @@ export async function recipeLifter(root: string): Promise<RecipeLifter | undefin
185
194
 
186
195
  return result
187
196
  },
197
+ utilities: () => new Set([...lifted.values()].flatMap(({ result }) => result?.utilities ?? [])),
188
198
  }
189
199
  byRoot.set(root, known)
190
200
  }
@@ -0,0 +1,183 @@
1
+ import type { RecipeLifter } from './recipe-classes'
2
+ import { readFileSync, statSync } from 'node:fs'
3
+ import { dirname, isAbsolute, resolve, sep } from 'node:path'
4
+ import { CSS_FILE, fileStamp, KAY_FILE, projectTree, readSource, realPath, resolveFrom, settledBefore } from './files'
5
+ import { inlineClasses } from './style-uses'
6
+
7
+ // What Tailwind reads classes out of is text: images, fonts, archives and binaries are left unread.
8
+ const BINARY_FILE = /\.(?:png|jpe?g|gif|webp|avif|ico|bmp|tiff?|woff2?|ttf|otf|eot|mp[34]|m4a|webm|ogg|wav|zip|gz|tgz|br|zst|7z|pdf|wasm|node|exe|bin|so|dylib|sqlite3?|db)$/i
9
+ const IMPORT = /@import\s+(?:url\(\s*)?(["'])([^"']+)\1([^;]*);/g
10
+ const SOURCE_FUNCTION = /\bsource\(\s*(?:none|(["'])((?:\\.|(?!\1)[^\\])*)\1)\s*\)/
11
+ // A path `@source` names; `@source not` and `@source inline(...)` do not match, as the first only takes files out.
12
+ const SOURCE_PATH = /@source\s+(["'])((?:\\.|(?!\1)[^\\])*)\1\s*;/g
13
+ const GLOB = /[*{[?]/
14
+ // A run of characters a class name can sit in, cut where markup, a string or a list ends it.
15
+ const CANDIDATE = /[^\s'"`<>{}=;,|\\]+/g
16
+ const PIECES = /[.()[\]]/
17
+ // What the runs above are cut at but an arbitrary value or variant holds (`data-[state=open]:p-2`): a name with one is looked for in the text itself.
18
+ const CUT_INSIDE = /[=>,;|{}'"`]/
19
+
20
+ // Where Tailwind looks for classes besides what it finds from the app's root: the folders and files `source()` and `@source` of the stylesheets name, and the classes `@source inline` lists. Undefined when one cannot be read or lies outside the root.
21
+ function stylesheetSources(root: string, stylesheets: string[]): { extra: string[], inline: string[] } | undefined {
22
+ const real = realPath(root)
23
+ const inside = (path: string) => path === real || path.startsWith(real + sep)
24
+ const extra = new Set<string>()
25
+ const inline = new Set<string>()
26
+ const seen = new Set<string>()
27
+ const pending = [...stylesheets]
28
+
29
+ // A glob stands for the folder before its first wildcard.
30
+ const located = (from: string, path: string): string => {
31
+ const parts = path.split('/')
32
+ const end = parts.findIndex(part => GLOB.test(part))
33
+
34
+ return realPath(resolve(dirname(from), (end === -1 ? parts : parts.slice(0, end)).join('/') || '.'))
35
+ }
36
+
37
+ for (let file = pending.pop(); file !== undefined; file = pending.pop()) {
38
+ if (seen.has(file))
39
+ continue
40
+
41
+ seen.add(file)
42
+
43
+ let text: string
44
+
45
+ try {
46
+ text = readFileSync(file, 'utf8')
47
+ }
48
+ catch {
49
+ return undefined
50
+ }
51
+
52
+ for (const found of inlineClasses(text))
53
+ inline.add(found)
54
+
55
+ const paths: string[] = []
56
+
57
+ for (const [, , specifier, rest] of text.matchAll(IMPORT)) {
58
+ const given = SOURCE_FUNCTION.exec(rest!)?.[2]
59
+
60
+ if (given !== undefined)
61
+ paths.push(given)
62
+
63
+ if (!specifier!.startsWith('http')) {
64
+ const imported = specifier!.startsWith('.') || isAbsolute(specifier!) ? resolve(dirname(file), specifier!) : resolveFrom(specifier!, file)
65
+
66
+ if (imported === undefined)
67
+ return undefined
68
+
69
+ if (CSS_FILE.test(imported))
70
+ pending.push(imported)
71
+ }
72
+ }
73
+
74
+ for (const match of text.matchAll(SOURCE_PATH))
75
+ paths.push(match[2]!)
76
+
77
+ for (const path of paths) {
78
+ const target = located(file, path)
79
+
80
+ if (!inside(target))
81
+ return undefined
82
+
83
+ extra.add(target)
84
+ }
85
+ }
86
+
87
+ return { extra: [...extra], inline: [...inline] }
88
+ }
89
+
90
+ // The candidate words of a text, each run whole, cut at the dots and brackets, and after each colon, the way a class stands as a variant's tail.
91
+ function* candidates(text: string): Generator<string, void, undefined> {
92
+ for (const [run] of text.matchAll(CANDIDATE)) {
93
+ yield run
94
+
95
+ for (const piece of run.split(PIECES)) {
96
+ if (piece !== '' && piece !== run)
97
+ yield piece
98
+ }
99
+
100
+ for (let colon = run.indexOf(':'); colon !== -1; colon = run.indexOf(':', colon + 1))
101
+ yield run.slice(colon + 1)
102
+ }
103
+ }
104
+
105
+ // The words of each file that are among the lifted utilities, kept with the file's stamp and the lifter that read its components.
106
+ const fileWords = new Map<string, { stamp: string, key: string, found: string[] }>()
107
+
108
+ // The files whose words are kept.
109
+ export function keptWordFiles(): string[] {
110
+ return [...fileWords.keys()]
111
+ }
112
+
113
+ function wordsIn(file: string, universe: ReadonlySet<string>, key: string): string[] {
114
+ const stamp = fileStamp(file)
115
+
116
+ if (stamp === undefined)
117
+ return []
118
+
119
+ const known = fileWords.get(file)
120
+
121
+ if (known?.stamp === stamp && known.key === key && settledBefore(file, Date.now()))
122
+ return known.found
123
+
124
+ const text = KAY_FILE.test(file) ? readSource(file).text : readFileSync(file, 'utf8')
125
+ const found = [...new Set([...candidates(text).filter(word => universe.has(word)), ...[...universe].filter(word => CUT_INSIDE.test(word) && text.includes(word))])]
126
+
127
+ fileWords.set(file, { stamp, key, found })
128
+
129
+ return found
130
+ }
131
+
132
+ // The utilities a recipe lifted into its own rules whose rule Tailwind still writes from the raw source it scans: none that any file Tailwind would read names, as a `.kay` file is read with its recipe strings gone, nor a word kay read, nor an `@source inline`.
133
+ // Tailwind reads everything under the app's root but dependencies, plus the folders and files its stylesheets add, and is taken as reading the ignored files too, so no name is missed. Empty when something cannot be read or resolved, so that no rule is dropped on a guess.
134
+ export async function recipeOnlyUtilities(root: string, lifter: RecipeLifter | undefined, named: Iterable<string>): Promise<Set<string>> {
135
+ const lifted = lifter?.utilities() ?? new Set<string>()
136
+
137
+ if (lifted.size === 0)
138
+ return lifted
139
+
140
+ const tree = await projectTree(root, { project: true })
141
+ const sources = stylesheetSources(root, tree.files.filter(file => CSS_FILE.test(file)))
142
+
143
+ if (sources === undefined)
144
+ return new Set()
145
+
146
+ const files = new Set(tree.files)
147
+
148
+ try {
149
+ for (const target of sources.extra) {
150
+ if (statSync(target, { throwIfNoEntry: false })?.isFile() === true) {
151
+ files.add(target)
152
+ }
153
+ else if (statSync(target, { throwIfNoEntry: false })?.isDirectory() === true) {
154
+ for (const file of (await projectTree(target)).files) {
155
+ files.add(file)
156
+ }
157
+ }
158
+ }
159
+
160
+ const universe = new Set(lifted)
161
+ const key = `${lifter!.id} ${Bun.hash([...universe].sort().join(' ')).toString(36)}`
162
+
163
+ for (const file of files) {
164
+ if (!BINARY_FILE.test(file)) {
165
+ for (const word of wordsIn(file, universe, key))
166
+ lifted.delete(word)
167
+ }
168
+ }
169
+ }
170
+ catch {
171
+ return new Set()
172
+ }
173
+
174
+ for (const kept of fileWords.keys()) {
175
+ if (!files.has(kept))
176
+ fileWords.delete(kept)
177
+ }
178
+
179
+ for (const name of [...sources.inline, ...named])
180
+ lifted.delete(name)
181
+
182
+ return lifted
183
+ }
@@ -1,14 +1,15 @@
1
1
  import type { ImportedSignals, SignalKind } from '../compiler/module-signals'
2
2
  import { AsyncLocalStorage } from 'node:async_hooks'
3
3
  import { readFileSync, statSync } from 'node:fs'
4
- import { importedModules, moduleSignals } from '../compiler/module-signals'
4
+ import { importedModules, moduleSignals, scanModule } from '../compiler/module-signals'
5
5
  import { parseKay } from '../compiler/parser'
6
6
  import { resolveFrom, SCRIPT_FILE, scriptLoader, transpilerFor } from './files'
7
7
  import { fences } from './libraries'
8
8
 
9
9
  const KAY_FILE = /\.kay$/
10
10
  const KAY_MODULE = /^kay(?:\/|$)/
11
- const scanned = new Map<string, { stamp: string, signals: Record<string, SignalKind> }>()
11
+ // A module's signals with the stamp of every file they were read from, the module and each one it re-exports from.
12
+ const scanned = new Map<string, { stamps: Map<string, string | undefined>, misses: Miss[], signals: Record<string, SignalKind> }>()
12
13
 
13
14
  // Inside a scope, what a component's imports exported, found once for all the passes over it: the analysis, the browser and the server compile.
14
15
  type Memo = Map<string, { source: string, found: ImportedSignals }>
@@ -70,9 +71,9 @@ function readImportedSignals(file: string, source: string): ImportedSignals {
70
71
  imports.set(file, { hash, specifiers })
71
72
 
72
73
  for (const specifier of specifiers) {
73
- const path = KAY_MODULE.test(specifier) ? undefined : resolveFrom(specifier, file)
74
+ const path = scannable(specifier, file)
74
75
 
75
- if (path === undefined || !(SCRIPT_FILE.test(path) || KAY_FILE.test(path)) || (!specifier.startsWith('.') && path.includes('/node_modules/')))
76
+ if (path === undefined)
76
77
  continue
77
78
 
78
79
  const signals = signalsOf(path)
@@ -92,23 +93,31 @@ export function keepImportedSignals(files: ReadonlySet<string>): void {
92
93
  }
93
94
  }
94
95
 
95
- // What a module exports, read again once its stamp changes.
96
- function signalsOf(path: string): Record<string, SignalKind> {
97
- try {
98
- const stats = statSync(path, { throwIfNoEntry: false })
96
+ // The file a specifier names when its signals are worth scanning: a script or a component, not a `kay` entry, and a package only through a relative import.
97
+ function scannable(specifier: string, from: string): string | undefined {
98
+ const path = KAY_MODULE.test(specifier) ? undefined : resolveFrom(specifier, from)
99
+
100
+ return path === undefined || !(SCRIPT_FILE.test(path) || KAY_FILE.test(path)) || (!specifier.startsWith('.') && path.includes('/node_modules/')) ? undefined : path
101
+ }
102
+
103
+ function stampOf(path: string): string | undefined {
104
+ const stats = statSync(path, { throwIfNoEntry: false })
99
105
 
100
- if (!stats)
101
- return {}
106
+ return stats && `${stats.mtimeMs}-${stats.size}`
107
+ }
102
108
 
103
- const stamp = `${stats.mtimeMs}-${stats.size}`
109
+ // What a module exports, read again once the stamp of it or of a module it re-exports from changes.
110
+ function signalsOf(path: string): Record<string, SignalKind> {
111
+ try {
104
112
  const known = scanned.get(path)
105
113
 
106
- if (known?.stamp === stamp)
114
+ if (known && [...known.stamps].every(([file, stamp]) => stampOf(file) === stamp) && known.misses.every(miss => resolveFrom(miss.specifier, miss.from) === undefined))
107
115
  return known.signals
108
116
 
109
- const signals = kindsOf(path, readFileSync(path, 'utf8'))
117
+ const scan: Scan = { stamps: new Map(), misses: [], done: new Map(), cuts: 0 }
118
+ const signals = Object.fromEntries(Object.entries(collect(path, scan, [])).map(([name, entry]) => [name, entry.kind]))
110
119
 
111
- scanned.set(path, { stamp, signals })
120
+ scanned.set(path, { stamps: scan.stamps, misses: scan.misses, signals })
112
121
 
113
122
  return signals
114
123
  }
@@ -117,6 +126,96 @@ function signalsOf(path: string): Record<string, SignalKind> {
117
126
  }
118
127
  }
119
128
 
129
+ // One scan of a module: the stamps of the files it read, what each finished module exported, and how many times a cycle cut a read short, a module read under a cut being incomplete and so not kept.
130
+ interface Scan {
131
+ stamps: Map<string, string | undefined>
132
+ // The specifiers that named no file, which a file created later would answer.
133
+ misses: Miss[]
134
+ done: Map<string, Exports>
135
+ cuts: number
136
+ }
137
+
138
+ interface Miss {
139
+ specifier: string
140
+ from: string
141
+ }
142
+
143
+ // Each signal a module exports, with the module and name it is made by, so two re-exports of one name tell the same signal from two.
144
+ type Exports = Record<string, { kind: SignalKind, origin: string }>
145
+
146
+ // The signals a module exports, those it hands on from another included; `trail` is the modules being read, so a cycle of re-exports ends.
147
+ function collect(path: string, scan: Scan, trail: string[]): Exports {
148
+ const kept = scan.done.get(path)
149
+
150
+ if (kept)
151
+ return kept
152
+
153
+ const stamp = stampOf(path)
154
+
155
+ scan.stamps.set(path, stamp)
156
+
157
+ if (stamp === undefined)
158
+ return {}
159
+
160
+ if (trail.includes(path)) {
161
+ scan.cuts++
162
+
163
+ return {}
164
+ }
165
+
166
+ const cuts = scan.cuts
167
+ const text = readFileSync(path, 'utf8')
168
+
169
+ const own = (kinds: Record<string, SignalKind>): Exports => Object.fromEntries(Object.entries(kinds).map(([name, kind]) => [name, { kind, origin: `${path}#${name}` }]))
170
+
171
+ if (KAY_FILE.test(path))
172
+ return own(kindsOf(path, text))
173
+
174
+ const parsed = scanModule(text, scriptLoader(path) === 'tsx' || scriptLoader(path) === 'jsx')
175
+ const { links } = parsed
176
+ const signals = own(parsed.signals)
177
+ const next = [...trail, path]
178
+ const from = (specifier: string): Exports => {
179
+ const target = scannable(specifier, path)
180
+
181
+ if (target === undefined && resolveFrom(specifier, path) === undefined && !KAY_MODULE.test(specifier))
182
+ scan.misses.push({ specifier, from: path })
183
+
184
+ return target === undefined ? {} : collect(target, scan, next)
185
+ }
186
+
187
+ // A name the module exports itself shadows a star's, and one two stars give from different places is ambiguous, so it is no export at all.
188
+ const starred = new Map<string, Exports[string] | undefined>()
189
+
190
+ for (const specifier of links.stars) {
191
+ for (const [name, entry] of Object.entries(from(specifier))) {
192
+ if (name === 'default' || links.own.has(name))
193
+ continue
194
+
195
+ const before = starred.get(name)
196
+
197
+ starred.set(name, starred.has(name) && before?.origin !== entry.origin ? undefined : entry)
198
+ }
199
+ }
200
+
201
+ for (const [name, entry] of starred) {
202
+ if (entry)
203
+ signals[name] = entry
204
+ }
205
+
206
+ for (const { exported, source, imported } of links.names) {
207
+ const found = from(source)
208
+
209
+ if (Object.hasOwn(found, imported))
210
+ signals[exported] = found[imported]!
211
+ }
212
+
213
+ if (scan.cuts === cuts)
214
+ scan.done.set(path, signals)
215
+
216
+ return signals
217
+ }
218
+
120
219
  function kindsOf(path: string, text: string): Record<string, SignalKind> {
121
220
  // A component's signals are the ones its `--- module` fence exports.
122
221
  if (KAY_FILE.test(path)) {
@@ -64,6 +64,11 @@ function tokensOf(file: string): { text: string, words: Set<string>, fragments:
64
64
  return found
65
65
  }
66
66
 
67
+ // The classes a stylesheet's `@source inline` lists.
68
+ export function inlineClasses(css: string): string[] {
69
+ return [...css.matchAll(SOURCE_INLINE)].flatMap(([, , pattern]) => pattern!.split(SPACES).flatMap(expandInline))
70
+ }
71
+
67
72
  // The class-like words of the string literals of a script, which are what it writes out as names, unlike an identifier or a comment.
68
73
  const STRING_LITERAL = /'(?:\\.|[^'\\\n])*'|"(?:\\.|[^"\\\n])*"|`(?:\\.|[^`\\])*`/g
69
74
 
@@ -239,12 +244,8 @@ function stylesheetClasses(file: string, kept: Set<string>, seen = new Set<strin
239
244
  for (const name of styledClassNames(parse(text)))
240
245
  found.add(name)
241
246
 
242
- for (const [, , pattern] of text.matchAll(SOURCE_INLINE)) {
243
- for (const word of pattern!.split(SPACES)) {
244
- for (const name of expandInline(word))
245
- kept.add(name)
246
- }
247
- }
247
+ for (const name of inlineClasses(text))
248
+ kept.add(name)
248
249
 
249
250
  for (const match of text.matchAll(CSS_IMPORT)) {
250
251
  const imported = resolve(dirname(file), match[1]!)