@kayjs/kay 1.110.0 → 1.112.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/eslint.js +160 -27
- package/editors/zed/extension.toml +2 -2
- package/llms/build-and-start.md +1 -1
- package/llms/checks.md +1 -0
- package/llms/component-libraries.md +1 -1
- package/llms/deprecated-lints.md +1 -1
- package/llms/dev-tool.md +1 -1
- package/llms/effects.md +1 -0
- package/llms/head.md +1 -1
- package/llms/images.md +2 -0
- package/llms/islands-lazy-components.md +23 -0
- package/llms/islands.md +2 -14
- package/llms/lints.md +1 -1
- package/llms/navigation.md +2 -2
- package/llms/performance-lints.md +1 -0
- package/llms/prerendering.md +1 -1
- package/llms/project-new-and-add.md +2 -2
- package/llms/project.md +1 -1
- package/llms/templates-elements-slots-snippets.md +2 -2
- package/llms/upgrading-archive.md +107 -58
- package/llms/upgrading.md +20 -124
- package/llms/whats-new-archive.md +31 -31
- package/llms/whats-new.md +36 -32
- package/llms.txt +3 -2
- package/package.json +11 -11
- package/src/build/client.ts +10 -8
- package/src/build/island-images.ts +277 -0
- package/src/build/pipeline.ts +10 -4
- package/src/build/static.ts +99 -24
- package/src/check/schema-builders.ts +113 -8
- package/src/check/shadow-types.ts +3 -3
- package/src/compiler/codegen.ts +1 -1
- package/src/compiler/dom.ts +4 -3
- package/src/compiler/handed-data.ts +15 -0
- package/src/compiler/helper-imports.ts +2 -2
- package/src/compiler/html.ts +3 -7
- package/src/compiler/index.ts +3 -1
- package/src/compiler/items.ts +162 -0
- package/src/compiler/jsx.ts +6 -8
- package/src/compiler/kay-exports.ts +1 -0
- package/src/compiler/lints.ts +1 -1
- package/src/compiler/markup.ts +10 -3
- package/src/compiler/rewrite-types.ts +2 -0
- package/src/compiler/rewrite.ts +4 -2
- package/src/compiler/route-lints.ts +8 -0
- package/src/compiler/template-walk.ts +2 -1
- package/src/config-shape.ts +4 -1
- package/src/config.ts +2 -2
- package/src/features.ts +1 -1
- package/src/new.ts +16 -4
- package/src/project.ts +3 -3
- package/src/runtime/await.server.ts +4 -2
- package/src/runtime/dev-tab-env.ts +28 -3
- package/src/runtime/dom-loop.ts +2 -4
- package/src/runtime/dom.ts +1 -1
- package/src/runtime/html.ts +52 -6
- package/src/runtime/image.ts +22 -4
- package/src/runtime/index.ts +1 -1
- package/src/runtime/island.server.ts +3 -3
- package/src/runtime/navigate.ts +5 -0
- package/src/runtime/navigation.ts +4 -0
- package/src/runtime/page-swap.ts +4 -1
- package/src/runtime/reactive.ts +72 -0
- package/src/runtime/row-key.ts +4 -0
- package/src/runtime/swap-focus.ts +56 -9
- package/src/runtime/swap-kept.ts +28 -0
- package/src/server/client.ts +3 -0
- package/src/server/dev.ts +2 -0
- package/src/server/image.ts +1 -1
- package/src/server/kept-exports.ts +1 -0
- package/src/server/render-document.ts +3 -2
- package/src/server/render.ts +2 -2
- package/src/template-styles.ts +2 -2
- package/types/build/client.d.ts +6 -0
- package/types/build/client.d.ts.map +1 -1
- package/types/build/island-images.d.ts +45 -0
- package/types/build/island-images.d.ts.map +1 -0
- package/types/build/pipeline.d.ts.map +1 -1
- package/types/build/static.d.ts.map +1 -1
- package/types/check/schema-builders.d.ts.map +1 -1
- package/types/compiler/dom.d.ts.map +1 -1
- package/types/compiler/handed-data.d.ts +5 -0
- package/types/compiler/handed-data.d.ts.map +1 -0
- package/types/compiler/html.d.ts.map +1 -1
- package/types/compiler/index.d.ts.map +1 -1
- package/types/compiler/items.d.ts +13 -0
- package/types/compiler/items.d.ts.map +1 -1
- package/types/compiler/jsx.d.ts.map +1 -1
- package/types/compiler/kay-exports.d.ts.map +1 -1
- package/types/compiler/lints.d.ts +9 -1
- package/types/compiler/lints.d.ts.map +1 -1
- package/types/compiler/markup.d.ts +2 -0
- package/types/compiler/markup.d.ts.map +1 -1
- package/types/compiler/rewrite-types.d.ts +1 -0
- package/types/compiler/rewrite-types.d.ts.map +1 -1
- package/types/compiler/route-lints.d.ts +8 -0
- package/types/compiler/route-lints.d.ts.map +1 -1
- package/types/compiler/template-walk.d.ts.map +1 -1
- package/types/config-shape.d.ts.map +1 -1
- package/types/config.d.ts +3 -1
- package/types/config.d.ts.map +1 -1
- package/types/new.d.ts.map +1 -1
- package/types/project.d.ts +2 -2
- package/types/project.d.ts.map +1 -1
- package/types/runtime/await.server.d.ts.map +1 -1
- package/types/runtime/dev-tab-env.d.ts.map +1 -1
- package/types/runtime/dom-loop.d.ts +2 -1
- package/types/runtime/dom-loop.d.ts.map +1 -1
- package/types/runtime/dom.d.ts +1 -1
- package/types/runtime/dom.d.ts.map +1 -1
- package/types/runtime/html.d.ts +5 -2
- package/types/runtime/html.d.ts.map +1 -1
- package/types/runtime/image.d.ts.map +1 -1
- package/types/runtime/index.d.ts +1 -1
- package/types/runtime/index.d.ts.map +1 -1
- package/types/runtime/navigate.d.ts.map +1 -1
- package/types/runtime/navigation.d.ts +2 -0
- package/types/runtime/navigation.d.ts.map +1 -1
- package/types/runtime/reactive.d.ts +5 -0
- package/types/runtime/reactive.d.ts.map +1 -1
- package/types/runtime/row-key.d.ts +2 -0
- package/types/runtime/row-key.d.ts.map +1 -0
- package/types/runtime/swap-focus.d.ts +2 -0
- package/types/runtime/swap-focus.d.ts.map +1 -1
- package/types/runtime/swap-kept.d.ts.map +1 -1
- package/types/server/app-stages.d.ts +3 -1
- package/types/server/app-stages.d.ts.map +1 -1
- package/types/server/app.d.ts +3 -1
- package/types/server/app.d.ts.map +1 -1
- package/types/server/client.d.ts +2 -0
- package/types/server/client.d.ts.map +1 -1
- package/types/server/dev.d.ts +1 -0
- package/types/server/dev.d.ts.map +1 -1
- package/types/server/kept-exports.d.ts.map +1 -1
- package/types/server/render-document.d.ts.map +1 -1
- package/types/server/render.d.ts +2 -2
- package/types/server/render.d.ts.map +1 -1
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
# What's new, older releases
|
|
2
2
|
|
|
3
|
-
What each release before 1.
|
|
3
|
+
What each release before 1.110 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.109.0
|
|
6
|
+
|
|
7
|
+
- An endpoint file (`src/routes/a.txt.ts`) no longer stops an app with a root `_guard.ts` and an extension layout that reaches files, as kayjs-auth's, from starting or passing `kay check` (`the layouts of the extensions are placed before what the pages reach was opened`): the endpoints are scanned after what the pages reach is open, as the pages are.
|
|
8
|
+
- `kay env` and `kay check` list the variables of a `defineEnv` module that kay.config.ts imports, as for any other module, so a variable required in production and missing from `.env.example` is reported ([environment](environment.md)).
|
|
9
|
+
- kayjs-ui's centred modal `Dialog` is as tall as its content again, capped at the viewport less 2rem (`size="full"` still fills it), and the opened dialog box no longer draws a browser focus ring round itself (a regression of the 1.105 placement change).
|
|
10
|
+
- An island reading a `queryParam` follows a swap that changes only the query, a link `?x=1` or a component's `param=` navigation, and Back and Forward, whatever its render mode: a signal made outside a component and shared by islands reads the address again after each swap and traversal, as one in a component does ([islands](islands.md#keep-a-filter-in-the-url)).
|
|
11
|
+
- On a static build or a `prerender` page, an island reading a `queryParam` is drawn again from the address when the page is opened with a query, instead of reporting `did not match its server markup`; the build warns naming each page holding one ([prerendering](prerendering.md#static-export)).
|
|
12
|
+
- `site.call(action.with(fields), input)` and `site.submit(action.with(fields), fields, { from: '/path' })` send the fields `with` fixes, as an island's call and a form's post do, instead of answering 422 for a missing field ([testing](testing.md)).
|
|
13
|
+
|
|
14
|
+
## 1.108.0
|
|
15
|
+
|
|
16
|
+
- kayjs-ui's `BarChart` leaves `goals` out of an island that never writes them, a `ConfirmDelete` leaves out the inline pair (`ask`), the trigger looks and `details` it is never given, and the confirm words no longer carry the questions' queue: a plain `ConfirmDelete` island holds 3.1 KB less of kayjs-ui, a `BarChart` 1.6 KB, and a `Dialog`'s discard question loads when first asked, 1.2 KB less ([kayjs-ui](../../ui/llms/table.md))
|
|
17
|
+
- An island ships only the kayjs-ui icons it can draw: with kayjs-ui in the app's dependencies the default registry is cut to the slots the project writes as strings, about 8 KB minified off an island drawing a Dialog, and a slot named from a variable in the app keeps it whole; the app's own icon settings stay whole ([kayjs-ui setup](../../ui/llms/setup.md))
|
|
18
|
+
- The code that runs an action call (queue, timeout, retries, the post and what follows its answer) loads with the first call instead of with the first island holding an action: a page of hubble's with a table of rows and dialogs loads 1.8 KB gzip less ([islands](islands.md#the-action-caller))
|
|
19
|
+
- A component of an island that leaves a feature out (kayjs-ui's `Table` with no filter, selection, paging or detail rows) no longer ships the markers and the effects of the blocks it never draws, and an `aria-` or `data-` attribute of such a feature is not bound: a plain `Table` island carries 1.7 KB less of kayjs-ui's code, 9.9 KB in all, as any component declaring `uses()` features carries less.
|
|
20
|
+
- An extension's own islands, as kayjs-ui's toaster, tooltip host and confirm host, hydrate when the library resolves outside the project root (a workspace link, or a folder above it) and the app lists no dependency on it ([component libraries](component-libraries.md)).
|
|
21
|
+
|
|
22
|
+
## 1.107.0
|
|
23
|
+
|
|
24
|
+
- `--- script` as a file's first fence is a compile error naming `---`, and the `deprecated-script-fence` lint is gone ([components](components.md)).
|
|
25
|
+
- `kay new` pins kay with `~` through 1.x and with `^` from 2.0.0, when a breaking change becomes a major ([Upgrading](upgrading.md))
|
|
26
|
+
- A component an island draws only where it may not render at first paint (inside an `if`, a `match` case, `@failed`, or the body of a closed `Dialog` or `FormDialog`) loads when that branch first draws, with nothing to declare: the page preloads what the server drew, a visitor reaching for the island loads the rest ahead, and a failed chunk is retried and reported; the code that posts an action call loads with its first call, retried after 1 s and 3 s when the load fails ([islands](islands-lazy-components.md#components-that-load-when-they-first-draw)).
|
|
27
|
+
- An island whose closed forms and dialogs hold words that are also component names loads less: a name in a string or a comment no longer keeps a component eager, and `Form`, `FormDialog` and `SaveForm` load their sending code on the first send. An island with a table, a closed form dialog and a select in it sheds 4.6 KB gzip of eager JS ([islands](islands.md))
|
|
28
|
+
- `action({ input, ...options }, handler)`: an action takes its options first with its input in them, as an API route does; the old argument order works until 2.0 and `kay upgrade` rewrites it ([actions](actions.md))
|
|
29
|
+
- One `validate(schema, value, { source })` reads every input of an app, an action's, an API route's, a socket's and `defineEnv`'s, and refuses with `{ errors: [{ path, key, params, message }], status: 422 }` worded in the request's locale; a JSON body is never coerced, and a Standard Schema validator (Zod, ArkType) is accepted where a schema is ([schemas](schemas.md))
|
|
30
|
+
- An island validates with the same schema: `validate(schema, value, { source })` from `kay` is the server's `validate` in the browser (JSON Schema built by the browser's `s`, a Standard Schema validator called as it is), its code a chunk the first call loads ([Schemas](schemas.md#schemas)).
|
|
31
|
+
- `kay check` names a Standard Schema validator with no `~standard.jsonSchema` (`schema-without-json-schema`) where an action's `input` or an API route's `body`, `query`, `params`, `headers` or `cookie` takes it, in `.ts` modules and `.kay` fences ([Schemas](schemas.md#schemas)).
|
|
32
|
+
- kayjs-ui's `Table` draws its failure row's retry as a plain button with a `retry` part, so an island holding a plain Table ships 6 KB less (the `Button`, its busy state and the icon set stay out unless the page uses them) ([restyle](https://git.kaynooo.fr/kaynooo/kayjs/src/branch/main/packages/ui/llms/restyle.md)).
|
|
4
33
|
|
|
5
34
|
## 1.106.0
|
|
6
35
|
|
|
@@ -42,33 +71,4 @@ What each release before 1.107 added, and the end of a newest release that was c
|
|
|
42
71
|
- A kay extension takes `ui`, a module whose default export is `defineUi({ ... })`, so a package restyles components for every app listing it, under the app's own `src/ui.ts` ([component libraries](component-libraries.md)); `src/ui.ts` itself follows no import or spread.
|
|
43
72
|
- `input(field=...)` takes its `type` (`email`, `url`, `number`, `date`, `checkbox`, `file` with `accept`) and `autocomplete` from the schema, and `select(field=...)` with no `option` lists the values of an `s.enum`, each unless the template writes it ([Forms](actions.md#forms)).
|
|
44
73
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- kayjs-ui's `Badge` takes `color`, any CSS colour, in place of a tone ([Badge](/ui/badge#any-colour)); the new `IconTile` draws an icon, or a letter, on a rounded tile tinted in a tone or any `color`, and `Stat` and `Widget` draw their `icon` as one with `iconTile` ([IconTile](/ui/icon-tile)); an `AppSwitcher` app takes a `color` that tints its tile and icon, and an `@appIcon(app)` block replaces the icon ([AppSwitcher](/ui/app-switcher#a-colour-per-app)).
|
|
48
|
-
- The favicon, touch icon and manifest links, and the icons the manifest lists, end in `?v=` and a hash of the favicon source, so a CDN or browser holding the old icon fetches the new one after the source changes; the files keep their paths ([favicon](sitemap-search-fonts.md)).
|
|
49
|
-
- A redirect whose target has a query of its own (`'/calendar': '/?tab=calendar'`) keeps it and adds the request's params it does not name, the target's winning on a clash, in `redirects` and in the runtime set alike ([routing](routing-endpoints-and-base.md)).
|
|
50
|
-
- kayjs-ui's `Slider` and `AudioPlayer` fill their track in the accent up to the thumb (the danger colour when invalid, the muted when disabled): the range input carries `--range-fill`, its share from `0%` to `100%`, in its `style`, and Firefox draws `::-moz-range-progress`.
|
|
51
|
-
- kayjs-ui's `Slider` draws its value on the label's row, at its end, in place of a row under the track: the `value` part now comes before the `input` part in its markup.
|
|
52
|
-
- `deprecated-package-names` reports an old package name only where it is a specifier, a config key, a stylesheet path or a package.json entry, not a comment or a sentence in a string that mentions it ([deprecated lints](deprecated-lints.md)).
|
|
53
|
-
- kayjs-auth's `SignedIn` takes `require`, what `auth.guard({ require })` takes (a role, a list, a predicate), and an `@else` block for everyone who does not meet it, so `SignedOut` and `role=` are deprecated (`deprecated-auth-signed` renames `role`); `fresh: '10m'` on `auth.guard()` and `requireUser()` asks for the password or passkey again before a sensitive action, `auth.provedLately('10m')` and `reprove()` being its two halves ([The signed-in user in templates](../../auth/llms/signed-in-components.md), [Ask for the password or passkey again](../../auth/llms/sessions-and-guards.md#ask-for-the-password-or-passkey-again), [upgrading](upgrading.md)).
|
|
54
|
-
- kayjs-auth's groups share one set of verbs (`list`, `get`, `create`, `update`, `delete`, `revoke`) and every method sits in its group: `auth.organizations.listMembers()`, `auth.admin.require()`, `auth.captcha.required()`, `auth.proof.recent()`, `auth.tokens.hasScope()`, `auth.oauthServer.resource()`, `auth.email.signInWithCode()`; the old names work until 1.108 and `deprecated-auth-methods` rewrites them ([grouped methods](../../auth/llms/grouped-methods.md)).
|
|
55
|
-
- Every kayjs-auth method answers one `Result<Ok, Code, Fields>` in place of sixty `*Result` aliases, and a failure is a kay `Failure` too: an action returns `auth.password.signIn(input)` as it is, and its island call reads `{ ok: false, status, data: { code, message } }` (kayjs-auth's `passwords-and-mails` guide).
|
|
56
|
-
- An action's form readers are grouped under `form`, apart from its call state: `add.form.failed()`, `add.form.error('title')` and `await add.form.validate(form)`, where `add.pending()`, `add.status()` and `add.data()` stay on the action ([Reading the outcome](actions.md#reading-the-outcome)); the old names work until 1.108 and `deprecated-action-readers` rewrites them.
|
|
57
|
-
- A component's `slot` and `slot name` type the children and blocks a call may pass, so a component declares no `children` and no block it only renders with `slot name`, and a call passing a block with no `slot` for it is a `kay check` error; `children?: Snippet` beside a bare `slot` is rewritten by `deprecated-children-prop` ([Slots](templates-elements-slots-snippets.md#slots), [upgrading](upgrading.md)).
|
|
58
|
-
- kayjs-auth's `SignOutButton` and `SignInLink` replace the hand-written sign-out form and sign-in link, with no `features().prefix` in a template: `redirect`, `label`, children and a Button's `variant`, `tone`, `size` and `icon`, `SignInLink` taking `href` and `button`; `UserMenu` shows a visitor a link to sign in (`signIn={false}` leaves it out) and takes children and `redirect` ([signed-in components](../../auth/llms/signed-in-components.md)).
|
|
59
|
-
- A call from an island answers `{ ok: true, data }` or `{ ok: false, status, message, errors, data, error }` and never throws for a refusal, a failed handler, a network failure or a timeout, for an action and for `call()` of an API route alike, and `.orThrow()` is the throwing style: `await add(input).orThrow()` ([Calling actions from islands](actions-from-islands.md), [API from islands](api-from-islands.md), [upgrading](upgrading.md)).
|
|
60
|
-
- kayjs-ui's `Dialog` takes a `placement` (`center`, the default, or `right`): the side placement is the panel `SidePanel` draws, with the same parts, close guards and callbacks, and `SidePanel` and `FormDialog` are built on it, so `FormDialog` takes `placement` and `discard` too; a `src/ui.ts` restyle of a SidePanel's head, title, body or footer moves to the Dialog's ([upgrading](upgrading.md), [kayjs-ui](../../ui/llms/basics.md)).
|
|
61
|
-
- A top-level `const` computed from a prop or a signal follows it in the browser, with no `memo` or function written: `const last = items.length - 1` shows the new length once the parent changes `items`. `once-read-prop` now names only a `let`, a destructured `const`, one that awaits and a nested declaration; a `// kay-allow once-read-prop` keeps the first value as before ([Components](components.md), [upgrading](upgrading.md)).
|
|
62
|
-
- `endpoints` in kay.config.ts holds where the API and each feature are served, `{ api, openapi, mcp, health, metrics, jobs }`, every default under `/_kay` but the API's, and `openapi: { reference: { path } }` moves the reference page; the MCP endpoint is `/_kay/mcp` and the metrics `/_kay/metrics`, their old URLs answering until 1.108 ([Project](project.md), [upgrading](upgrading.md)).
|
|
63
|
-
- `kay lsp` serves a plain `.ts` endpoint and an `api()` module on the same shadow `kay check` types, so `params`, `query` and `guard` of a handler are typed in the editor with no generic written ([Guards](guards.md)).
|
|
64
|
-
- kayjs-ui controls that draw an input in a wrapper (Toggle, Checkbox, Slider, ColorInput, Combobox, DateInput) put `id`, `title` and `data-*` on the wrapper like every component, and the input takes `inputProps` (`deprecated-ui-input` rewrites the old form; [upgrading](upgrading.md)).
|
|
65
|
-
- kayjs-ui components with a floating panel (Menu, AppSwitcher, BellInbox, AvatarGroup, DateInput, DateRangeInput, MultiSelect, Table, Combobox) take `panelProps`, and the ones drawing their own opening button (BellInbox, AvatarGroup, DateInput, DateRangeInput, MultiSelect, Table) `triggerProps`, typed as the element's attributes; `...rest` stays on the root ([slots and links](../../ui/llms/slots-and-links.md)).
|
|
66
|
-
- kayjs-ui names the same things the same way: every list a component draws is `items` (`tabs`, `avatars`, `entries`, `links`, `steps`, `icons` and `slides` before, rewritten by `deprecated-ui-items`), an `infiniteList` is `items` too on Carousel, Masonry, MediaGallery, VirtualList, LoadMore and Table (`list` before), TextInput, Textarea, Select, DateInput, DateTimeInput, TimeInput, MarkdownEditor and FileDrop take `label` as their name, Tabs takes `disabled` for the whole group, TooltipHost takes `onOpenChange`, and a tooltip has one documented entry, `data-tooltip` ([blocks, links and parts](../../ui/llms/slots-and-links.md)).
|
|
67
|
-
- Helpers of kay, kayjs-auth, kayjs-mail, kayjs-cms and kayjs-ai throw a `KayError` with a `code` where they threw a plain `Error` (`config-invalid`, `argument-invalid`, `outside-request`, `hook-timeout` and the new `helper-failed`, its `kind` naming a mail provider timing out or refusing), the helpers that run in an island too (`route()`, `every()`, `shortcut()`, `presence()`, `local()`, `navigate()`, `persisted`, `sanitizeHtml`, kayjs-ui's refused props) do the same, and each timeout says which one it is: `StoreTimeoutError` for a database call, `RequestTimeoutError` for a request, an action call's `timeout`, kayjs-ai's call, connect and idle timeouts. See [errors raised while running](errors-runtime.md#errors-raised-while-running).
|
|
68
|
-
- An `await` with no `catch` and no `try` around it shows an alert in place of its block once its value rejects, instead of nothing, so `uncaught-await` is gone ([Rendering](rendering.md), [upgrading](upgrading.md)).
|
|
69
|
-
- `src/await-failed.kay` replaces the alert of an `await` with no `catch` for the whole app, on the server and in islands, given the `error` and, in the browser, a `retry` ([Rendering](rendering.md)).
|
|
70
|
-
- A component's parts are given as their own attribute, `Card(parts={{ head: 'p-6' }})`, `class` keeping strings, arrays and objects of conditions, on a component with parts too; `Card.mt-4(parts={{ ... }})` is allowed, and `deprecated-parts-class` rewrites the old `class={{ head: ... }}` ([Styles and assets](styles-and-assets.md), [upgrading](upgrading.md)).
|
|
71
|
-
- `unkeyed-rows` covers every component, not only islands: a `for` over rows with no `id` needs a `key` ([Templates](templates.md), [upgrading](upgrading.md)).
|
|
72
|
-
- A link's navigation flags are named as the options of `navigate()`: `data-scroll="keep"`, `data-transition="false"` and `data-prefetch="false"`, typed on every element, and a misspelt one such as `data-prefech` is a `kay check` error (`unknown-link-flag`); `data-keep-scroll`, `data-no-transition` and `data-no-prefetch` are rewritten by `deprecated-link-flags` ([Navigation](navigation-from-code.md#navigating-from-code), [upgrading](upgrading.md)).
|
|
73
|
-
|
|
74
|
-
Releases before 1.105 are in the notes of their releases, at https://git.kaynooo.fr/kaynooo/kayjs/releases.
|
|
74
|
+
Releases before 1.106 are in the notes of their releases, at https://git.kaynooo.fr/kaynooo/kayjs/releases.
|
package/llms/whats-new.md
CHANGED
|
@@ -2,6 +2,39 @@
|
|
|
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.112.0
|
|
6
|
+
|
|
7
|
+
- kayjs-ui's `starfield` utility is removed with `@kayjs/ui/starfield.css` and its `--color-star*` tokens, and `kay new` no longer puts stars behind the page: the fixed layer kept the GPU compositing and made pages lag on a machine short of video memory ([upgrading](upgrading.md)).
|
|
8
|
+
|
|
9
|
+
## 1.111.0
|
|
10
|
+
|
|
11
|
+
- kay and its libraries need Bun 1.4.5, a security release for HTTP/3, HTTP/1.1, TLS, DNS and Zstandard, and refuse 1.4.4 with the command that updates it ([project](project.md), [upgrading](upgrading.md)).
|
|
12
|
+
- A refresh in place no longer jumps the window to the end of the page in Chrome when it drops or moves rows around the one in view (an action posted from a long list of row forms): the swap turns scroll anchoring off while it morphs and keeps the scroll, and a focused field the refresh removed gives the focus to the field of that name now at its place rather than the first of the page, without the text typed into it meanwhile, which goes nowhere (a row is told by its form's `id`, or its action and hidden fields, else its nearest ancestor's `id`), and an island's field a refresh renders afresh gets its typed text back at its own place, not the first field of its name. See [navigation](navigation.md).
|
|
13
|
+
- A page that is an island (a closure passed to an interactive component) sends only the `--- server` values its script or template read as props, so a list the fence only reduces no longer weighs the page down ([Props to an island](islands.md#props-to-an-island)).
|
|
14
|
+
- The dev tool no longer requests `/_kay/env.js` on an app with no `s.Public` field, which logged a 404 in the browser console on every page: the page's request block says whether the route exists, so the Env tab asks for nothing and still says the app sends no public env ([dev tool](dev-tool.md)).
|
|
15
|
+
- A form in a file with a loop over a pattern (`for [key, value] of entries`, `for { id } of rows`) reads its own action again: its `error` and `pending` lines, field values, constraints and messages no longer fall back to the form of the function, where a bare `error` threw `KayFormHere is not defined` and the page answered 500.
|
|
16
|
+
- kay's `@kaynooo/pg-orm` peer range takes 9.x beside 7 and 8, and kayjs-ui, kayjs-cms, kayjs-mail, kayjs-ai and kayjs-auth ask for `@kaynooo/utils` `^3.2.0`, which the `kay check` of a lockfile on an older 3.x could not resolve ([component libraries](component-libraries.md)).
|
|
17
|
+
- kayjs-mail's confirmation and unsubscribe pages are set in the font and colours of the app's mails with a flat button, in place of a bare `system-ui` column, and the "confirmed" and "unsubscribed" answers state their title alone, so `mail.list.page.confirmed` and `mail.list.page.unsubscribed` are no longer read; a mail's field labels are sentence case and the dev outbox names a real font ([mailing lists](../../mail/llms/mailing-list.md)).
|
|
18
|
+
- kayjs-ai's Chat is flat (no shadow on the panel or the launcher unless `--kai-chat-shadow` sets one), waits behind a still `Thinking…` line, wraps its suggestions in a squared button, builds its controls from kayjs-ui's `Button` and `ConfirmDelete`, and shows a held tool call by its label and one line of its input, with calls counted `×2` ([chat](../../ai/llms/chat.md)).
|
|
19
|
+
- kayjs-mail's confirmation and unsubscribe pages follow the `settings` of the app's mails (font stack, colours, radius, so a site that sets them gets its own look) with a flat button, in place of a centred `system-ui` column, and the "confirmed" and "unsubscribed" answers state their title alone, so `mail.list.page.confirmed` and `mail.list.page.unsubscribed` are no longer read; a mail's field labels are sentence case and the dev outbox names a real font ([mailing lists](../../mail/llms/mailing-list.md)).
|
|
20
|
+
- kayjs-ui's fields draw their text at 16px on a coarse pointer or in a window under 40rem, so iOS no longer zooms the page in on one; a wide window with a mouse keeps the compact sizes ([TextInput](/ui/text-input)).
|
|
21
|
+
- kayjs-ui's `TabNav`, `Tabs` and `Segmented` fade out at the edge of a strip that scrolls, so a clipped tab reads as one to scroll to, and `Tabs` opens with its shown tab centred as `TabNav` does ([TabNav](/ui/tab-nav)).
|
|
22
|
+
- A kayjs-ui `Table` stacked as cards on a phone names its row of sort buttons with the words `Sort by` (`ui.table.sortBy`) instead of showing bare column names, and draws no per-card label when it has one column ([Table](/ui/table)).
|
|
23
|
+
- `kay new .` scaffolds in a fresh clone holding only `.git` and what a new forge repo carries (`README.md`, a licence, `.gitignore`, `.gitattributes`), keeping them and the `origin`, and a folder with anything else is refused naming the entries in the way ([kay new](project-new-and-add.md)).
|
|
24
|
+
- `kay build --static` writes the site to a folder beside the output and renames it over `dist` once complete, so a server pointed at `dist` never answers 404 during a rebuild and a failed export leaves the last one untouched (a folder git does not ignore is still removed first, as Tailwind would scan it) ([static export](prerendering.md#static-export)).
|
|
25
|
+
- A block drawn per item keeps its nodes and focus across a same-key replacement in kayjs-ui's `TreeView` (`@row`, `@actions`), `Steps` (`@step`), `VirtualList` (`@item`) and `Toaster` (`@toast`), `RelationGraph` (`@middle`) and `MapView` (`@popup`), in a `slot x(item)` inside a form, and in a block whose other arguments, a carousel's index for one, change; an island in an `await` block of a keyed row keeps the row's key as its identity ([slots](templates-elements-slots-snippets.md), [effects](effects.md)).
|
|
26
|
+
- On a static export the build reads the `img` and `image()` calls of the islands, so a crop, a quality or a small width only a browser-rendered island draws has its files, and a remote image an island names as a literal URL is downloaded and linked as files; any other remote image keeps its own address in the browser, and `kay build --static` warns of it with `static-remote-image` ([images](images.md)).
|
|
27
|
+
- On a static export an island that draws an imported image in the browser links the variant files the build wrote, as the server HTML does, instead of the image route, which a static host answers with a 404 ([images](images.md)).
|
|
28
|
+
- `kay check` resolves the imports of a library's own components from where Bun's isolated linker put the library's dependencies, so an app listing `@kayjs/ui` alone no longer lists `@kaynooo/utils` for the check to pass ([component libraries](component-libraries.md)).
|
|
29
|
+
- `kay check` reports an `auth()` whose users go through `@kaynooo/pg-orm`, a SQLite file by default, when the app has not installed it, with `bun add @kaynooo/pg-orm`, where the server stopped only at start ([checks](checks.md#peer-packages)).
|
|
30
|
+
- `kay check --fix` of `deprecated-schema-builders` keeps an unbounded `s.String()` unbounded, writing `max: Number.MAX_SAFE_INTEGER`, except in an action's input and an API route's `body`, which capped it at 10,000 characters already ([deprecated lints](deprecated-lints.md)).
|
|
31
|
+
- A `head` entry in `kay.config.ts` with `children` beside `props` is refused at load and by `kay check`, naming `props.children`, where it used to render an empty tag; the config type refuses it too ([Head](head.md)).
|
|
32
|
+
- kayjs-ui's `SiteNav`, `SideNav` and `TabNav` no longer mark every `/#section` link as the current page on that page: a link with a hash is current only when `current` carries the same hash ([TabNav](/ui/tab-nav)).
|
|
33
|
+
- The count badge of kayjs-ui's `TabNav`, `Tabs`, `SideNav` and `SiteNav` has the vertical padding of a `Badge`, so its number no longer touches the pill's top and bottom ([TabNav](/ui/tab-nav)).
|
|
34
|
+
- A block's item stays the real item when it follows a replacement under the same key: the `row` of a Table's `@cell` and `@detail` is the object in `rows`, so `rows.indexOf(row)` and `row === selected` hold in it and a class instance with private fields works, while its nodes and a field's focus still stay (the 1.110 view of the row, compared by key, is gone). A block or a snippet reads its plain parameters where they are used, `followed(read, draw)` from `kay` draws a call once for the item under its key, and `slot name(item, index)` called with names or paths does it for its first argument, so Tabs, TabNav, Breadcrumb, SiteNav, SideNav and Carousel keep the nodes of the entry blocks across a refresh as the other item blocks do ([templates](templates-elements-slots-snippets.md), [effects](effects.md), [Table](../../ui/llms/table.md)).
|
|
35
|
+
|
|
36
|
+
- An island drawn in a keyed `for` is paired by the loop's key across a refresh, with no `id` or `persist` on it, so deleting the first row leaves each other island its own state; the server writes the key as the island's `data-key`. A `details` of the first load takes the server's value as its baseline, as one a swap brings does ([Navigation](navigation.md#islands-kept-across-pages)).
|
|
37
|
+
|
|
5
38
|
## 1.110.0
|
|
6
39
|
|
|
7
40
|
- kayjs-ui's `Checkbox`, `RadioGroup` choices and `Toggle` rows are at least 24px tall, the tap target of WCAG 2.5.8, whatever the label's line height.
|
|
@@ -15,35 +48,6 @@ What each release of kay and its libraries adds, newest first, each feature with
|
|
|
15
48
|
- kayjs-ui's `Dialog` closes with a plain button with a `close` part, so an island holding a Dialog no longer ships `IconButton` and the icon set for it (a plain Dialog island is 7 KB smaller in an app that has no other icon button), and it leaves out `level`, `header`, `handle`, `trigger` and `closeHref` when no call site of the project writes them; the close draws kayjs-ui's `x` icon, and a `close` block replaces it ([restyle](https://git.kaynooo.fr/kaynooo/kayjs/src/branch/main/packages/ui/llms/restyle.md)).
|
|
16
49
|
- A kayjs-ui component handing its `...rest` props, or a prop it takes by name, on to a component with optional features (`FormDialog`, `SidePanel` and `ConfirmHost` into `Dialog`) counts by what its own callers write, no longer as every prop, so an island leaves out the features no call site uses.
|
|
17
50
|
- A part handed on to a component (`Icon(part="spinner")`) writes its `class` and `parts` as one source, about 45 bytes less in each island per hand-off.
|
|
18
|
-
- A `lints` entry in kay.config.ts naming a lint kay has removed (`'deprecated-package-names': 'allow'`) is accepted by the config type and warned about by `kay check`, instead of refused; `kay check --fix` writes `s.Union(Object.keys(R).map(key => s.Literal(key)))` as `s.enum(R)` and leaves any other mapped `s.Union` to the app, see [Upgrading](upgrading.md). The same fix writes `max: Number.MAX_SAFE_INTEGER` on an `s.Array` and `extra: 'strip'` on an `s.Object`, so a rewritten list or object keeps the old behaviour; an app rewritten before has lists capped at 1,000 and objects that refuse extra keys, [how to check](upgrading.md
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- An endpoint file (`src/routes/a.txt.ts`) no longer stops an app with a root `_guard.ts` and an extension layout that reaches files, as kayjs-auth's, from starting or passing `kay check` (`the layouts of the extensions are placed before what the pages reach was opened`): the endpoints are scanned after what the pages reach is open, as the pages are.
|
|
23
|
-
- `kay env` and `kay check` list the variables of a `defineEnv` module that kay.config.ts imports, as for any other module, so a variable required in production and missing from `.env.example` is reported ([environment](environment.md)).
|
|
24
|
-
- kayjs-ui's centred modal `Dialog` is as tall as its content again, capped at the viewport less 2rem (`size="full"` still fills it), and the opened dialog box no longer draws a browser focus ring round itself (a regression of the 1.105 placement change).
|
|
25
|
-
- An island reading a `queryParam` follows a swap that changes only the query, a link `?x=1` or a component's `param=` navigation, and Back and Forward, whatever its render mode: a signal made outside a component and shared by islands reads the address again after each swap and traversal, as one in a component does ([islands](islands.md#keep-a-filter-in-the-url)).
|
|
26
|
-
- On a static build or a `prerender` page, an island reading a `queryParam` is drawn again from the address when the page is opened with a query, instead of reporting `did not match its server markup`; the build warns naming each page holding one ([prerendering](prerendering.md#static-export)).
|
|
27
|
-
- `site.call(action.with(fields), input)` and `site.submit(action.with(fields), fields, { from: '/path' })` send the fields `with` fixes, as an island's call and a form's post do, instead of answering 422 for a missing field ([testing](testing.md)).
|
|
28
|
-
|
|
29
|
-
## 1.108.0
|
|
30
|
-
|
|
31
|
-
- kayjs-ui's `BarChart` leaves `goals` out of an island that never writes them, a `ConfirmDelete` leaves out the inline pair (`ask`), the trigger looks and `details` it is never given, and the confirm words no longer carry the questions' queue: a plain `ConfirmDelete` island holds 3.1 KB less of kayjs-ui, a `BarChart` 1.6 KB, and a `Dialog`'s discard question loads when first asked, 1.2 KB less ([kayjs-ui](../../ui/llms/table.md))
|
|
32
|
-
- An island ships only the kayjs-ui icons it can draw: with kayjs-ui in the app's dependencies the default registry is cut to the slots the project writes as strings, about 8 KB minified off an island drawing a Dialog, and a slot named from a variable in the app keeps it whole; the app's own icon settings stay whole ([kayjs-ui setup](../../ui/llms/setup.md))
|
|
33
|
-
- The code that runs an action call (queue, timeout, retries, the post and what follows its answer) loads with the first call instead of with the first island holding an action: a page of hubble's with a table of rows and dialogs loads 1.8 KB gzip less ([islands](islands.md#the-action-caller))
|
|
34
|
-
- A component of an island that leaves a feature out (kayjs-ui's `Table` with no filter, selection, paging or detail rows) no longer ships the markers and the effects of the blocks it never draws, and an `aria-` or `data-` attribute of such a feature is not bound: a plain `Table` island carries 1.7 KB less of kayjs-ui's code, 9.9 KB in all, as any component declaring `uses()` features carries less.
|
|
35
|
-
- An extension's own islands, as kayjs-ui's toaster, tooltip host and confirm host, hydrate when the library resolves outside the project root (a workspace link, or a folder above it) and the app lists no dependency on it ([component libraries](component-libraries.md)).
|
|
36
|
-
|
|
37
|
-
## 1.107.0
|
|
38
|
-
|
|
39
|
-
- `--- script` as a file's first fence is a compile error naming `---`, and the `deprecated-script-fence` lint is gone ([components](components.md)).
|
|
40
|
-
- `kay new` pins kay with `~` through 1.x and with `^` from 2.0.0, when a breaking change becomes a major ([Upgrading](upgrading.md))
|
|
41
|
-
- A component an island draws only where it may not render at first paint (inside an `if`, a `match` case, `@failed`, or the body of a closed `Dialog` or `FormDialog`) loads when that branch first draws, with nothing to declare: the page preloads what the server drew, a visitor reaching for the island loads the rest ahead, and a failed chunk is retried and reported; the code that posts an action call loads with its first call, retried after 1 s and 3 s when the load fails ([islands](islands.md#components-that-load-when-they-first-draw)).
|
|
42
|
-
- An island whose closed forms and dialogs hold words that are also component names loads less: a name in a string or a comment no longer keeps a component eager, and `Form`, `FormDialog` and `SaveForm` load their sending code on the first send. An island with a table, a closed form dialog and a select in it sheds 4.6 KB gzip of eager JS ([islands](islands.md))
|
|
43
|
-
- `action({ input, ...options }, handler)`: an action takes its options first with its input in them, as an API route does; the old argument order works until 2.0 and `kay upgrade` rewrites it ([actions](actions.md))
|
|
44
|
-
- One `validate(schema, value, { source })` reads every input of an app, an action's, an API route's, a socket's and `defineEnv`'s, and refuses with `{ errors: [{ path, key, params, message }], status: 422 }` worded in the request's locale; a JSON body is never coerced, and a Standard Schema validator (Zod, ArkType) is accepted where a schema is ([schemas](schemas.md))
|
|
45
|
-
- An island validates with the same schema: `validate(schema, value, { source })` from `kay` is the server's `validate` in the browser (JSON Schema built by the browser's `s`, a Standard Schema validator called as it is), its code a chunk the first call loads ([Schemas](schemas.md#schemas)).
|
|
46
|
-
- `kay check` names a Standard Schema validator with no `~standard.jsonSchema` (`schema-without-json-schema`) where an action's `input` or an API route's `body`, `query`, `params`, `headers` or `cookie` takes it, in `.ts` modules and `.kay` fences ([Schemas](schemas.md#schemas)).
|
|
47
|
-
- kayjs-ui's `Table` draws its failure row's retry as a plain button with a `retry` part, so an island holding a plain Table ships 6 KB less (the `Button`, its busy state and the icon set stay out unless the page uses them) ([restyle](https://git.kaynooo.fr/kaynooo/kayjs/src/branch/main/packages/ui/llms/restyle.md)).
|
|
48
|
-
|
|
49
|
-
Releases before 1.107 are in [What's new, older releases](whats-new-archive.md).
|
|
51
|
+
- A `lints` entry in kay.config.ts naming a lint kay has removed (`'deprecated-package-names': 'allow'`) is accepted by the config type and warned about by `kay check`, instead of refused; `kay check --fix` writes `s.Union(Object.keys(R).map(key => s.Literal(key)))` as `s.enum(R)` and leaves any other mapped `s.Union` to the app, see [Upgrading](upgrading.md). The same fix writes `max: Number.MAX_SAFE_INTEGER` on an `s.Array` and `extra: 'strip'` on an `s.Object`, so a rewritten list or object keeps the old behaviour; an app rewritten before has lists capped at 1,000 and objects that refuse extra keys, [how to check](upgrading-archive.md).
|
|
52
|
+
|
|
53
|
+
Releases before 1.110 are in [What's new, older releases](whats-new-archive.md).
|
package/llms.txt
CHANGED
|
@@ -46,6 +46,7 @@ To build a site, read [Build a site](llms/site.md) first, then the topics below;
|
|
|
46
46
|
- [Images and icons](llms/images.md): imported and responsive images, share cards, icons
|
|
47
47
|
- [Runtime and remote images](llms/images-runtime-and-remote.md): uploaded and remote images
|
|
48
48
|
- [Islands](llms/islands.md): props, hydration
|
|
49
|
+
- [Islands: lazy components](llms/islands-lazy-components.md): components an island loads when first drawn
|
|
49
50
|
- [Islands: state to ids](llms/islands-state-to-ids.md): shared state, transitions, context
|
|
50
51
|
- [Browser-only code](llms/browser-only.md): browser globals on the server, server globals in the browser
|
|
51
52
|
- [Navigation](llms/navigation.md): in-place navigation, islands kept across pages
|
|
@@ -117,9 +118,9 @@ To build a site, read [Build a site](llms/site.md) first, then the topics below;
|
|
|
117
118
|
- [Proxies and security headers](llms/proxy-and-security.md): headers, CSP, compression
|
|
118
119
|
- [Upgrading](llms/upgrading.md): what each recent minor breaks, what an app changes
|
|
119
120
|
- [Upgrading to 1.105, config](llms/upgrading-1-105-config.md): config and hooks
|
|
120
|
-
- [Upgrading, older](llms/upgrading-archive.md): the minors before 1.
|
|
121
|
+
- [Upgrading, older](llms/upgrading-archive.md): the minors before 1.110
|
|
121
122
|
- [What's new](llms/whats-new.md): what each recent release adds
|
|
122
|
-
- [What's new, older](llms/whats-new-archive.md): the releases before 1.
|
|
123
|
+
- [What's new, older](llms/whats-new-archive.md): the releases before 1.110
|
|
123
124
|
- [Privacy and personal data](llms/privacy.md): what kay keeps, erasing a person
|
|
124
125
|
- [Events and names](llms/events.md): DOM events, cookie and key rules
|
|
125
126
|
- [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.
|
|
4
|
+
"version": "1.112.0",
|
|
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",
|
|
@@ -233,7 +233,7 @@
|
|
|
233
233
|
"types"
|
|
234
234
|
],
|
|
235
235
|
"engines": {
|
|
236
|
-
"bun": ">=1.4.
|
|
236
|
+
"bun": ">=1.4.5"
|
|
237
237
|
},
|
|
238
238
|
"scripts": {
|
|
239
239
|
"check": "$npm_execpath check && $npm_execpath src/tsgo.ts --noEmit -p tsconfig.consumer.json",
|
|
@@ -262,7 +262,7 @@
|
|
|
262
262
|
},
|
|
263
263
|
"peerDependencies": {
|
|
264
264
|
"@happy-dom/global-registrator": "^20.14.6 || ^21.0.3",
|
|
265
|
-
"@kaynooo/pg-orm": "^7.0.0 || ^8.0.0",
|
|
265
|
+
"@kaynooo/pg-orm": "^7.0.0 || ^8.0.0 || ^9.0.0",
|
|
266
266
|
"@types/bun": "^1.4.4",
|
|
267
267
|
"axe-core": "^4.14.0",
|
|
268
268
|
"happy-dom": "^20.14.6 || ^21.0.3",
|
|
@@ -287,8 +287,8 @@
|
|
|
287
287
|
},
|
|
288
288
|
"dependencies": {
|
|
289
289
|
"@jsquash/avif": "2.1.1",
|
|
290
|
-
"@kaynooo/cli-kit": "0.
|
|
291
|
-
"@kaynooo/utils": "^3.
|
|
290
|
+
"@kaynooo/cli-kit": "0.47.0",
|
|
291
|
+
"@kaynooo/utils": "^3.2.0",
|
|
292
292
|
"@resvg/resvg-js": "^2.6.2",
|
|
293
293
|
"devalue": "^6.0.3",
|
|
294
294
|
"elysia": "^1.4.31",
|
|
@@ -304,13 +304,13 @@
|
|
|
304
304
|
"@fontsource/inter": "^5.3.0",
|
|
305
305
|
"@happy-dom/global-registrator": "^21.0.4",
|
|
306
306
|
"@iconify-json/tabler": "^1.2.42",
|
|
307
|
-
"@kayjs/ai": "1.
|
|
308
|
-
"@kayjs/auth": "1.
|
|
309
|
-
"@kayjs/cms": "1.
|
|
310
|
-
"@kayjs/mail": "1.
|
|
311
|
-
"@kayjs/ui": "1.
|
|
307
|
+
"@kayjs/ai": "1.112.0",
|
|
308
|
+
"@kayjs/auth": "1.112.0",
|
|
309
|
+
"@kayjs/cms": "1.112.0",
|
|
310
|
+
"@kayjs/mail": "1.112.0",
|
|
311
|
+
"@kayjs/ui": "1.112.0",
|
|
312
312
|
"@kaynooo/eslint": "^8.0.3",
|
|
313
|
-
"@kaynooo/pg-orm": "^
|
|
313
|
+
"@kaynooo/pg-orm": "^9.0.0",
|
|
314
314
|
"@oxc-parser/binding-wasm32-wasip1": "0.155.0",
|
|
315
315
|
"@types/babel__traverse": "^7.28.0",
|
|
316
316
|
"@types/bun": "^1.4.4",
|
package/src/build/client.ts
CHANGED
|
@@ -34,6 +34,7 @@ import { entryFile, KAY_OUTPUT, lazyEntryKey } from './entry-files'
|
|
|
34
34
|
import { CSS_FILE, findKayFiles, findProjectFiles, forgetSources, inWalkScope, keepSources, liftSources, readSource, readSourcePaths, readText, writeIfChanged } from './files'
|
|
35
35
|
import { iconSlotsOf, slotsKey } from './icon-slots'
|
|
36
36
|
import { Increments, realPaths, sameEntries } from './increments'
|
|
37
|
+
import { exportedImages, staticRemoteDefine } from './island-images'
|
|
37
38
|
import { keepBundleMapCached, pruneKeptMaps } from './kept-maps'
|
|
38
39
|
import { hoistLayerOrder } from './layer-order'
|
|
39
40
|
import { eagerKeys, lazyKey } from './lazy-components'
|
|
@@ -80,6 +81,7 @@ export interface ClientOptions extends Pick<KayConfig, ClientBuildKey> {
|
|
|
80
81
|
publicEnv?: boolean | undefined
|
|
81
82
|
// `kay build --static`: no server takes the errors the browser meets, so none are sent.
|
|
82
83
|
exported?: boolean | undefined
|
|
84
|
+
staticImages?: { allowed: (src: string) => boolean, remote?: string[] } | undefined
|
|
83
85
|
// Measures what the browser loads for islands, `modules` breaking each chunk down by the modules it holds.
|
|
84
86
|
report?: 'sizes' | 'modules' | undefined
|
|
85
87
|
}
|
|
@@ -132,10 +134,8 @@ const builtGraph: ImportGraph = new Map()
|
|
|
132
134
|
// Bundles what the browser needs: one entry hydrating the islands, each island in its own chunk, and a stylesheet per page and layout.
|
|
133
135
|
// Every component is compiled first, so all of the project's syntax errors come out together instead of one per bundler run. `stamps` takes what the build read, for the caller to tell later whether it is still current.
|
|
134
136
|
export async function buildClient(root: string, options: ClientOptions = {}, stamps?: BuildStamps): Promise<ClientBuild> {
|
|
135
|
-
const { sources, manifest, scripts, styles } = await clientSession(root, options, { graph: builtGraph, stamps }).build(null)
|
|
136
|
-
const built = fromManifest(root, manifest)
|
|
137
|
-
|
|
138
|
-
built.unresolved = styles!.server
|
|
137
|
+
const { sources, manifest, scripts, styles, images } = await clientSession(root, options, { graph: builtGraph, stamps }).build(null)
|
|
138
|
+
const built = Object.assign(fromManifest(root, manifest), { islandImages: images, unresolved: styles!.server })
|
|
139
139
|
const bundled = Object.values(scripts!.inputs).flatMap(inputs => Object.entries(inputs).filter(([, input]) => (input.bytesInOutput ?? 0) > 0).map(([input]) => variantFile(input)))
|
|
140
140
|
|
|
141
141
|
built.packages = packagesOf([...bundled, ...styles!.inputs])
|
|
@@ -162,6 +162,7 @@ export interface SessionBuild {
|
|
|
162
162
|
manifest: ClientManifest
|
|
163
163
|
scripts?: Awaited<ReturnType<typeof bundleIslands>> | undefined
|
|
164
164
|
styles?: Awaited<ReturnType<typeof bundleStyles>> | undefined
|
|
165
|
+
images?: Awaited<ReturnType<typeof exportedImages>>['images']
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
export interface ClientSession {
|
|
@@ -227,7 +228,8 @@ export function clientSession(root: string, options: ClientOptions, settings: Se
|
|
|
227
228
|
if (previous && islandsAgain)
|
|
228
229
|
await increments!.stopMaps(false)
|
|
229
230
|
|
|
230
|
-
const
|
|
231
|
+
const { images, bundled } = await exportedImages(root, sources, graph, options)
|
|
232
|
+
const [scripts, styles] = await bothBundles(islandsAgain ? bundleIslands(root, sources.islands, sources.files, sources.actionForms, sources.actionProps, bundled, classTable, islandTable, await iconSlotsOf(root, [...sources.files, ...sources.islands.values()], sources.libraries, graph)) : undefined, stylesAgain ? bundleStyles(root, sources, options) : undefined)
|
|
231
233
|
const styleUses = styles ? styles.uses : previous!.styleUses
|
|
232
234
|
const manifest: ClientManifest = { ...scripts?.manifest ?? previous!.islands, styles: styles?.styles ?? previous!.styles, ...classTable && { classTable }, ...styleUses && { styleUses }, ...options.hot && { problems: sources.problems }, ...key !== undefined && { options: key } }
|
|
233
235
|
|
|
@@ -253,7 +255,7 @@ export function clientSession(root: string, options: ClientOptions, settings: Se
|
|
|
253
255
|
}
|
|
254
256
|
}
|
|
255
257
|
|
|
256
|
-
return { sources, manifest, scripts, styles }
|
|
258
|
+
return { sources, manifest, scripts, styles, images }
|
|
257
259
|
}
|
|
258
260
|
|
|
259
261
|
return {
|
|
@@ -566,7 +568,7 @@ async function bundleRound(root: string, islands: Map<string, string>, files: st
|
|
|
566
568
|
].join('\n'))
|
|
567
569
|
|
|
568
570
|
// Bun resolves packages' `development` export condition unless NODE_ENV is defined as production, which would ship a package's dev build; a build for development, not NODE_ENV, asks for theirs.
|
|
569
|
-
const define: Record<string, string> = { 'KAY_BROWSER': 'true', 'process.env.NODE_ENV': JSON.stringify(options.hot === true ? 'development' : 'production'), 'KAY_STATIC_EXPORT': options.exported === true ? 'true' : 'undefined', 'KAY_NAV_ENTRY': 'undefined', 'KAY_FRENCH': options.french === true ? 'true' : 'undefined', 'KAY_I18N': options.i18n === true ? 'true' : 'undefined', 'KAY_NO_ACTION_PROPS': options.hot !== true && !actionProps ? 'true' : 'undefined', 'KAY_VISIBLE_MARGIN': JSON.stringify(rootMargin(options.client?.hydration?.visible, '200px', 'visible')), 'KAY_NEAR_MARGIN': JSON.stringify(rootMargin(options.client?.hydration?.serverIslands, '100% 0px', 'serverIslands')) }
|
|
571
|
+
const define: Record<string, string> = { 'KAY_BROWSER': 'true', 'process.env.NODE_ENV': JSON.stringify(options.hot === true ? 'development' : 'production'), 'KAY_STATIC_EXPORT': options.exported === true ? 'true' : 'undefined', 'KAY_STATIC_REMOTE': staticRemoteDefine(options), 'KAY_NAV_ENTRY': 'undefined', 'KAY_FRENCH': options.french === true ? 'true' : 'undefined', 'KAY_I18N': options.i18n === true ? 'true' : 'undefined', 'KAY_NO_ACTION_PROPS': options.hot !== true && !actionProps ? 'true' : 'undefined', 'KAY_VISIBLE_MARGIN': JSON.stringify(rootMargin(options.client?.hydration?.visible, '200px', 'visible')), 'KAY_NEAR_MARGIN': JSON.stringify(rootMargin(options.client?.hydration?.serverIslands, '100% 0px', 'serverIslands')) }
|
|
570
572
|
const external = publicEnv !== undefined ? [publicEnv] : []
|
|
571
573
|
const plugins = (anchor?: string, anchored?: ReadonlySet<string>, direct?: boolean) => [withoutStyles(), api, kay({ target: 'dom', root, variants, localeLinks: options.i18n === true, cacheDir: projectPaths(root).cache, settings: options.librarySettings, iconSlots, anchor, anchored, direct, inspect: options.inspect, api: trees, external, classTable }), ...options.plugins ?? []]
|
|
572
574
|
|
|
@@ -574,7 +576,7 @@ async function bundleRound(root: string, islands: Map<string, string>, files: st
|
|
|
574
576
|
|
|
575
577
|
// Without the registry in the boot, each island is an entry point of its own.
|
|
576
578
|
const islandFiles = options.hot ? [] : [...entries.values()]
|
|
577
|
-
const chunk = await runtimeChunk(entryFile, { plugins: plugins(), define, external, islands: islandFiles, cache: { file: join(projectPaths(root).cache, `runtime-search-${options.hot ? 'dev' : 'build'}.json`), key: `${JSON.stringify([options.librarySettings, slotsKey(iconSlots), options.inspect, options.client?.navigation, trees, islandFiles, eagerKeys()])}\0${await Bun.file(bootFile).text()}` } })
|
|
579
|
+
const chunk = await runtimeChunk(entryFile, { plugins: plugins(), define, external, islands: islandFiles, cache: { file: join(projectPaths(root).cache, `runtime-search-${options.hot ? 'dev' : 'build'}.json`), key: `${JSON.stringify([options.librarySettings, slotsKey(iconSlots), options.inspect, options.client?.navigation, trees, islandFiles, eagerKeys(), staticRemoteDefine(options)])}\0${await Bun.file(bootFile).text()}` } })
|
|
578
580
|
|
|
579
581
|
// In development the entry keeps its own code, the islands it imports by their hashed names included: the runtime's chunk then stays as it was through an edit of an island, which swaps in alone.
|
|
580
582
|
// A second entry point importing the runtime alone has Bun give it that chunk of its own, which it would otherwise merge into the entry's.
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import type { CheckDiagnostic } from '../check'
|
|
2
|
+
import type { NamedAttribute } from '../compiler/ast'
|
|
3
|
+
import type { LintLevels } from '../compiler/lints'
|
|
4
|
+
import type { ImageOptions } from '../runtime/image'
|
|
5
|
+
import type { ClientOptions } from './client'
|
|
6
|
+
import type { ImportGraph, KayLibrary } from './libraries'
|
|
7
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
8
|
+
import { basename, dirname, extname, join, resolve } from 'node:path'
|
|
9
|
+
import { walkNodes } from '../compiler/ast'
|
|
10
|
+
import { lintLevel } from '../compiler/lints'
|
|
11
|
+
import { positionAt } from '../compiler/mapping'
|
|
12
|
+
import { parseKay } from '../compiler/parser'
|
|
13
|
+
import { image, registerImage } from '../runtime/image'
|
|
14
|
+
import { imageHeader } from '../server/image-format'
|
|
15
|
+
import { ASSET_PREFIX, ASSETS_DIR } from './assets'
|
|
16
|
+
import { importEdges, reachedFrom } from './libraries'
|
|
17
|
+
|
|
18
|
+
// What the browser of a static export draws that no page rendered: an island's `img` or `image()` of an image the build cannot see otherwise, so no file would be written for its crop, its quality or its small width.
|
|
19
|
+
// Read from the sources of the components an island reaches, as `iconSlotsOf` reads icon slots; a value that is no literal is not known here.
|
|
20
|
+
export interface IslandImage {
|
|
21
|
+
// The imported file, which the build names its asset after.
|
|
22
|
+
file: string
|
|
23
|
+
options: ImageOptions
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// An `image(url, { width, height, ... })` of an image on another host, its URL a literal.
|
|
27
|
+
export interface RemoteIslandImage extends Position {
|
|
28
|
+
src: string
|
|
29
|
+
options: ImageOptions
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface Position {
|
|
33
|
+
file: string
|
|
34
|
+
line: number
|
|
35
|
+
column: number
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// An image of an island that a static export cannot write files for, and why: its source is neither an import nor a literal (a remote image the build cannot fetch), its size is no number literal, or its crop, quality or sizes is no literal.
|
|
39
|
+
export interface DynamicIslandImage extends Position {
|
|
40
|
+
reason: 'source' | 'size' | 'option'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface IslandImages {
|
|
44
|
+
imported: IslandImage[]
|
|
45
|
+
remote: RemoteIslandImage[]
|
|
46
|
+
dynamic: DynamicIslandImage[]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const IMAGE_IMPORT = /^import\s+(\w+)\s+from\s+(["'])(\.[^"'\n]*\.(?:png|jpe?g|webp|gif|avif))\2/gm
|
|
50
|
+
const KAY_IMAGE_IMPORT = /import\s*\{[^}]*\bimage\b[^}]*\}\s*from\s*["']kay\/image["']/
|
|
51
|
+
const IMAGE_CALL = /(?<![\w$])(?<!(?<!\.\.)\.)image\(\s*(?:(["'])(https?:\/\/[^"'\n]+)\1|([\w$.]+)\s*(?=[,)]))\s*(?:,\s*\{((?:[^{}]|\$\{[^}]*\})*)\})?/g
|
|
52
|
+
const NUMBER = /^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i
|
|
53
|
+
const STRING = /^(["'`])(.*)\1$/s
|
|
54
|
+
const SCANNED = /\.(?:kay|[cm]?[jt]sx?)$/
|
|
55
|
+
const REMOTE = /^https?:\/\//i
|
|
56
|
+
|
|
57
|
+
// A literal as written, a number or a string; undefined for anything computed.
|
|
58
|
+
function literal(text: string): string | number | undefined {
|
|
59
|
+
const written = text.trim()
|
|
60
|
+
|
|
61
|
+
if (NUMBER.test(written))
|
|
62
|
+
return Number(written)
|
|
63
|
+
|
|
64
|
+
const inner = STRING.exec(written)?.[2]
|
|
65
|
+
|
|
66
|
+
// A template literal is read when nothing is interpolated.
|
|
67
|
+
return written.startsWith('`') && inner?.includes('${') === true ? undefined : inner
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function optionsOf(read: (name: string) => string | undefined): ImageOptions {
|
|
71
|
+
const sizes = literal(read('sizes') ?? '')
|
|
72
|
+
const aspect = literal(read('aspect') ?? '')
|
|
73
|
+
const quality = literal(read('quality') ?? '')
|
|
74
|
+
const width = literal(read('width') ?? '')
|
|
75
|
+
const height = literal(read('height') ?? '')
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
...typeof sizes === 'string' && { sizes },
|
|
79
|
+
...typeof aspect === 'string' && { aspect },
|
|
80
|
+
...typeof quality === 'number' && { quality },
|
|
81
|
+
...typeof width === 'number' && { width },
|
|
82
|
+
...typeof height === 'number' && { height },
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// The options `read` finds written but `optionsOf` could not take, as a value computed.
|
|
87
|
+
function unreadOptions(read: (name: string) => string | undefined): boolean {
|
|
88
|
+
const options = optionsOf(read)
|
|
89
|
+
|
|
90
|
+
return (['sizes', 'aspect', 'quality'] as const).some(name => read(name) !== undefined && options[name] === undefined)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function fieldOf(text: string, name: string): string | undefined {
|
|
94
|
+
const found = new RegExp(`(?:^|[,{\\s])${name}(?:\\s*:\\s*("[^"]*"|'[^']*'|\x60[^\x60]*\x60|[^,}\\s]+)|(?=\\s*(?:[,}]|$)))`).exec(text)
|
|
95
|
+
|
|
96
|
+
// A shorthand property holds a variable, written by its name.
|
|
97
|
+
return found === null ? undefined : found[1] ?? name
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// The files the sources import by identifier, as absolute paths.
|
|
101
|
+
function importedImages(source: string, file: string): Map<string, string> {
|
|
102
|
+
const found = new Map<string, string>()
|
|
103
|
+
|
|
104
|
+
for (const [, name, , path] of source.matchAll(IMAGE_IMPORT))
|
|
105
|
+
found.set(name!, resolve(dirname(file), path!))
|
|
106
|
+
|
|
107
|
+
return found
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// What the `.kay` and script files hand the browser to draw, an image option written: a bare `img` of an imported image gives nothing new unless it asks for a crop, a quality or a width.
|
|
111
|
+
export function scanIslandImages(files: Iterable<string>): IslandImages {
|
|
112
|
+
const found: IslandImages = { imported: [], remote: [], dynamic: [] }
|
|
113
|
+
|
|
114
|
+
for (const file of files) {
|
|
115
|
+
if (!SCANNED.test(file))
|
|
116
|
+
continue
|
|
117
|
+
|
|
118
|
+
let source: string
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
source = readFileSync(file, 'utf8')
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
continue
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (!source.includes('img') && !source.includes('image('))
|
|
128
|
+
continue
|
|
129
|
+
|
|
130
|
+
const imports = importedImages(source, file)
|
|
131
|
+
|
|
132
|
+
if (file.endsWith('.kay')) {
|
|
133
|
+
walkNodes(parseKay(source).template, undefined, (node) => {
|
|
134
|
+
if (node.kind !== 'element' || node.component || node.name !== 'img')
|
|
135
|
+
return undefined
|
|
136
|
+
|
|
137
|
+
const named = (name: string) => node.attributes.find((attribute): attribute is NamedAttribute => attribute.kind !== 'spread' && attribute.kind !== 'boolean' && source.slice(attribute.name.start, attribute.name.end) === name)
|
|
138
|
+
const value = (name: string) => {
|
|
139
|
+
const attribute = named(name)
|
|
140
|
+
|
|
141
|
+
if (attribute?.kind === 'static')
|
|
142
|
+
return JSON.stringify(attribute.text)
|
|
143
|
+
|
|
144
|
+
return attribute?.kind === 'expression' ? source.slice(attribute.expression.start, attribute.expression.end) : undefined
|
|
145
|
+
}
|
|
146
|
+
const src = value('src')?.trim()
|
|
147
|
+
const options = optionsOf(value)
|
|
148
|
+
const imported = src === undefined ? undefined : imports.get(src)
|
|
149
|
+
|
|
150
|
+
if (imported !== undefined && (options.aspect !== undefined || options.quality !== undefined || options.sizes !== undefined))
|
|
151
|
+
found.imported.push({ file: imported, options })
|
|
152
|
+
|
|
153
|
+
if (imported !== undefined && unreadOptions(value))
|
|
154
|
+
found.dynamic.push({ file, ...positionAt(source, node.start), reason: 'option' })
|
|
155
|
+
|
|
156
|
+
return undefined
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (!KAY_IMAGE_IMPORT.test(source))
|
|
161
|
+
continue
|
|
162
|
+
|
|
163
|
+
for (const match of source.matchAll(IMAGE_CALL)) {
|
|
164
|
+
const [, , url, name, written] = match
|
|
165
|
+
const options = optionsOf(field => written === undefined ? undefined : fieldOf(written, field))
|
|
166
|
+
|
|
167
|
+
const at = { file, ...positionAt(source, match.index) }
|
|
168
|
+
const read = (field: string) => written === undefined ? undefined : fieldOf(written, field)
|
|
169
|
+
const sized = options.width !== undefined && options.height !== undefined
|
|
170
|
+
|
|
171
|
+
if (url !== undefined && sized)
|
|
172
|
+
found.remote.push({ src: url, options, ...at })
|
|
173
|
+
else if (url !== undefined)
|
|
174
|
+
found.dynamic.push({ ...at, reason: 'size' })
|
|
175
|
+
else if (imports.has(name!))
|
|
176
|
+
found.imported.push({ file: imports.get(name!)!, options })
|
|
177
|
+
else if (url === undefined && read('width') !== undefined && read('height') !== undefined)
|
|
178
|
+
found.dynamic.push({ ...at, reason: 'source' })
|
|
179
|
+
|
|
180
|
+
if ((url !== undefined || imports.has(name!)) && unreadOptions(read))
|
|
181
|
+
found.dynamic.push({ ...at, reason: 'option' })
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return found
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// The name the build gives an imported file in `assets`: its content's hash after its own name.
|
|
189
|
+
export function assetNameOf(file: string): string | undefined {
|
|
190
|
+
try {
|
|
191
|
+
const extension = extname(file)
|
|
192
|
+
|
|
193
|
+
return `${basename(file, extension)}-${Bun.hash(readFileSync(file)).toString(36)}${extension}`
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
return undefined
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// The URL `registerImage` knows an imported file by.
|
|
201
|
+
export function assetUrlOf(file: string): string | undefined {
|
|
202
|
+
const name = assetNameOf(file)
|
|
203
|
+
|
|
204
|
+
return name === undefined ? undefined : `${ASSET_PREFIX}${ASSETS_DIR}/${encodeURIComponent(name)}`
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// What the islands of a static export draw that no page renders, and the options its browser bundle is built with: it links a remote image as a file only when the build fetches it, a literal URL given its size on a host `images.remote` lists.
|
|
208
|
+
// `ClientOptions.staticImages` is the hosts `images.remote` lists, and what this adds: the remote URLs the build fetches.
|
|
209
|
+
export async function exportedImages(root: string, sources: { islands: Map<string, string>, libraries: KayLibrary[] }, graph: ImportGraph, options: ClientOptions): Promise<{ images: IslandImages | undefined, bundled: ClientOptions }> {
|
|
210
|
+
if (options.exported !== true)
|
|
211
|
+
return { images: undefined, bundled: options }
|
|
212
|
+
|
|
213
|
+
const images = scanIslandImages(await reachedFrom([...sources.islands.values()], importEdges(root, sources.libraries, graph)))
|
|
214
|
+
|
|
215
|
+
const { staticImages } = options
|
|
216
|
+
|
|
217
|
+
return { images, bundled: staticImages ? { ...options, staticImages: { ...staticImages, remote: linkedRemote(images, staticImages.allowed).map(({ src }) => src) } } : options }
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// The value of `KAY_STATIC_REMOTE` in the browser bundle.
|
|
221
|
+
export function staticRemoteDefine({ staticImages }: ClientOptions): string {
|
|
222
|
+
return staticImages?.remote === undefined ? 'undefined' : JSON.stringify(staticImages.remote)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// The remote images a static export writes files for: a literal URL given its size, on a host `images.remote` lists.
|
|
226
|
+
export function linkedRemote(images: IslandImages, allowed: (src: string) => boolean): RemoteIslandImage[] {
|
|
227
|
+
return images.remote.filter(({ src }) => REMOTE.test(src) && allowed(src))
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Asks the image runtime for the variants the islands draw, which records the ones beyond the ladder for the build to write: the images are registered first, as a server that never loaded the island's module has not.
|
|
231
|
+
// Returns what `kay check` says of the ones it cannot read, when `checking`.
|
|
232
|
+
export async function recordIslandImages(clientDir: string, images: IslandImages | undefined, allowed: (src: string) => boolean, { checking, lints }: { checking: boolean, lints: LintLevels | undefined }): Promise<CheckDiagnostic[]> {
|
|
233
|
+
if (images === undefined)
|
|
234
|
+
return []
|
|
235
|
+
|
|
236
|
+
for (const { file, options } of images.imported) {
|
|
237
|
+
const name = assetNameOf(file)
|
|
238
|
+
const path = name === undefined ? undefined : join(clientDir, ASSETS_DIR, name)
|
|
239
|
+
|
|
240
|
+
if (path === undefined || !existsSync(path))
|
|
241
|
+
continue
|
|
242
|
+
|
|
243
|
+
// An image kay cannot decode is served as it is, with no variants.
|
|
244
|
+
let header: Awaited<ReturnType<typeof imageHeader>>
|
|
245
|
+
|
|
246
|
+
try {
|
|
247
|
+
header = await imageHeader(Bun.file(path))
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
continue
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (!header.animated)
|
|
254
|
+
image(registerImage(assetUrlOf(file)!, header.width, header.height), options)
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
for (const { src, options } of linkedRemote(images, allowed))
|
|
258
|
+
image(src, options)
|
|
259
|
+
|
|
260
|
+
const level = lintLevel('static-remote-image', lints)
|
|
261
|
+
|
|
262
|
+
return checking && level !== 'allow' ? dynamicImageLints(images, level, allowed) : []
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const UNREAD = {
|
|
266
|
+
source: { message: 'This `image()` of an island takes a source the build cannot read, so a static export, which has no image route, links the original image instead of resized files', help: 'give `image()` the image\'s URL as a literal in the island, on a host `images.remote` lists, so the build fetches and resizes it, or draw the image where the server renders it' },
|
|
267
|
+
size: { message: 'This `image()` of an island takes a width or a height that is no number literal, so the build cannot fetch and resize the image and a static export links the original', help: 'write the width and the height as numbers' },
|
|
268
|
+
option: { message: 'This island image takes a crop, a quality or sizes that is no literal, so a static export, which writes the files it reads from the source, has none for it and the browser asks for a file that does not exist', help: 'write `aspect`, `quality` and `sizes` as literals in the island' },
|
|
269
|
+
host: { message: 'This `image()` URL is on a host `images.remote` does not list, so a static export links the original image instead of resized files', help: 'list the host in `images.remote`, so the build fetches and resizes it' },
|
|
270
|
+
} as const
|
|
271
|
+
|
|
272
|
+
// What `kay check` says of the island images a static export cannot write files for: they keep their own URL, or ask the browser for a file that is not there.
|
|
273
|
+
export function dynamicImageLints(images: IslandImages, level: 'warn' | 'deny', allowed: (src: string) => boolean = () => true): CheckDiagnostic[] {
|
|
274
|
+
const unlisted = images.remote.filter(({ src }) => !allowed(src)).map(({ file, line, column }) => ({ file, line, column, reason: 'host' as const }))
|
|
275
|
+
|
|
276
|
+
return [...images.dynamic, ...unlisted].map(({ file, line, column, reason }) => ({ file, line, column, code: 'static-remote-image', severity: level === 'warn' ? 'warning' : 'error', ...UNREAD[reason] }))
|
|
277
|
+
}
|