@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
package/src/runtime/image.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { kayLog } from './log'
|
|
|
3
3
|
import { textHash } from './text-hash'
|
|
4
4
|
|
|
5
5
|
declare const KAY_BROWSER: true | undefined
|
|
6
|
+
declare const KAY_STATIC_EXPORT: true | undefined
|
|
7
|
+
declare const KAY_STATIC_REMOTE: readonly string[] | undefined
|
|
6
8
|
|
|
7
9
|
// The widths an image is resized to unless `images.widths` says otherwise, the only ones the image route makes: a fixed ladder keeps how many files one image can turn into bounded.
|
|
8
10
|
export const IMAGE_WIDTHS = [320, 640, 960, 1280, 1920, 2560] as const
|
|
@@ -95,7 +97,7 @@ const requestedRemote = new Map<string, Map<string, ImageVariant>>()
|
|
|
95
97
|
let remoteListed: ((src: string) => boolean) | undefined
|
|
96
98
|
// Whether it leaves out the host of an image on another host, which then keeps its own URL, set with it.
|
|
97
99
|
let unlistedCheck: ((src: string, caller: string) => boolean) | undefined
|
|
98
|
-
// Set on the server, which records the variants pages ask for and links the files a static export wrote: the browser asks the route.
|
|
100
|
+
// Set on the server, which records the variants pages ask for and links the files a static export wrote: the browser asks the route, except in a static export's bundle, which links the files itself (`exportedVariantUrl`).
|
|
99
101
|
let serverVariantUrl: typeof recordedVariantUrl | undefined
|
|
100
102
|
// Whether `images.resolve` looks sources up, which the browser reads off the page.
|
|
101
103
|
let resolved: boolean | undefined
|
|
@@ -551,7 +553,7 @@ export function imageUrl(src: string, width: number, aspect?: Aspect, quality?:
|
|
|
551
553
|
function variantUrl(src: string, variant: ImageVariant): string {
|
|
552
554
|
const query = variant === 'card' ? 'card' : `w=${variant.width}${variant.aspect ? `&crop=${aspectKey(variant.aspect)}` : ''}${variant.quality === undefined ? '' : `&q=${variant.quality}`}`
|
|
553
555
|
|
|
554
|
-
return serverVariantUrl?.(src, variant) ?? `${IMAGE_ROUTE}?src=${encodeURIComponent(src)}&${query}`
|
|
556
|
+
return serverVariantUrl?.(src, variant) ?? (typeof KAY_STATIC_EXPORT === 'undefined' ? undefined : exportedVariantUrl(src, variant)) ?? `${IMAGE_ROUTE}?src=${encodeURIComponent(src)}&${query}`
|
|
555
557
|
}
|
|
556
558
|
|
|
557
559
|
// The file of a variant a static export wrote, recording the variants pages ask for beyond the ladder; nothing where the route serves it.
|
|
@@ -566,15 +568,31 @@ function recordedVariantUrl(src: string, variant: ImageVariant): string | undefi
|
|
|
566
568
|
}
|
|
567
569
|
|
|
568
570
|
if (src.startsWith(IMPORTED) && (asked || variantFiles)) {
|
|
569
|
-
const name =
|
|
571
|
+
const name = importedName(src)
|
|
570
572
|
|
|
571
573
|
// The ladder is written for every imported image, the rest only for those a page asks for.
|
|
572
574
|
if (asked)
|
|
573
575
|
requested.set(name, (requested.get(name) ?? new Map<string, ImageVariant>()).set(variantSuffix(variant), variant))
|
|
574
576
|
|
|
575
577
|
if (variantFiles)
|
|
576
|
-
return
|
|
578
|
+
return variantFile(name, variant)
|
|
577
579
|
}
|
|
578
580
|
|
|
579
581
|
return undefined
|
|
580
582
|
}
|
|
583
|
+
|
|
584
|
+
function importedName(src: string): string {
|
|
585
|
+
return decodeURIComponent(src.slice(IMPORTED.length).replace(QUERY, ''))
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function variantFile(name: string, variant: ImageVariant): string {
|
|
589
|
+
return `${VARIANTS}${encodeURIComponent(`${name.replace(EXTENSION, '')}${variantSuffix(variant)}`)}`
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// In the browser of a static export, which has no route: the file the build wrote of an imported image, the one the server HTML links, and of a remote image whose URL the build fetched. Any other image keeps its own URL. Only the export's bundle holds it, a server-rendered app's does not.
|
|
593
|
+
function exportedVariantUrl(src: string, variant: ImageVariant): string | undefined {
|
|
594
|
+
if (src.startsWith(IMPORTED))
|
|
595
|
+
return variantFile(importedName(src), variant)
|
|
596
|
+
|
|
597
|
+
return REMOTE.test(src) && typeof KAY_STATIC_REMOTE !== 'undefined' && KAY_STATIC_REMOTE.includes(src) ? `${VARIANTS}${remoteVariantName(src, variant)}` : src
|
|
598
|
+
}
|
package/src/runtime/index.ts
CHANGED
|
@@ -61,7 +61,7 @@ export type { QueuedJob } from './queue-jobs'
|
|
|
61
61
|
export { jobs } from './queue-jobs'
|
|
62
62
|
export { randomId } from './random-id'
|
|
63
63
|
export type { SignalOptions } from './reactive'
|
|
64
|
-
export { batch, flush, memo, onCleanup, root, untrack } from './reactive'
|
|
64
|
+
export { batch, flush, followed, memo, onCleanup, root, untrack } from './reactive'
|
|
65
65
|
export { reactiveMap, reactiveSet } from './reactive-collections'
|
|
66
66
|
export type { Recipe, RecipeConfig, RecipeProps, WidenedProps } from './recipe'
|
|
67
67
|
export { recipe } from './recipe'
|
|
@@ -9,7 +9,7 @@ import { BUTTON_FORM_KEY } from './button-form'
|
|
|
9
9
|
import { escapeAttribute, quotedAttribute } from './escape'
|
|
10
10
|
import { withFieldMarks } from './fields'
|
|
11
11
|
import { headMark, setsIslandTitle } from './head'
|
|
12
|
-
import { child, omit, prerendering } from './html'
|
|
12
|
+
import { child, loopIdentity, omit, prerendering } from './html'
|
|
13
13
|
import { noteLives } from './live-value'
|
|
14
14
|
import { localeState } from './locale-state'
|
|
15
15
|
import { TITLED_ATTRIBUTE } from './markers'
|
|
@@ -183,7 +183,7 @@ function persistKey(wanted: IslandOptions['persist'], id: string): string | unde
|
|
|
183
183
|
return wanted === false || wanted === '' ? undefined : wanted
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
// What tells an island from the others of its component when no `persist` does: the `key` or `id` its use gives, a string or a number, so a swap pairs it with its own copy when a sibling goes away.
|
|
186
|
+
// What tells an island from the others of its component when no `persist` does: the `key` or `id` its use gives, a string or a number, else the key of the keyed loop it is drawn in, so a swap pairs it with its own copy when a sibling goes away.
|
|
187
187
|
function identityOf(persist: string | undefined, props: object): string | undefined {
|
|
188
188
|
for (const name of persist === undefined ? ['key', 'id'] as const : []) {
|
|
189
189
|
const value = (props as Record<string, unknown>)[name]
|
|
@@ -192,7 +192,7 @@ function identityOf(persist: string | undefined, props: object): string | undefi
|
|
|
192
192
|
return String(value)
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
return undefined
|
|
195
|
+
return persist === undefined ? loopIdentity() : undefined
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
// Whether a `hydrate` makes the island wait, `media(...)` needing a query to wait for.
|
package/src/runtime/navigate.ts
CHANGED
|
@@ -73,6 +73,11 @@ export function startNavigation(given: NavigationHooks): void {
|
|
|
73
73
|
;(document as { _$kf?: typeof onClick })._$kf = onClick
|
|
74
74
|
document.addEventListener('focusin', onFocus)
|
|
75
75
|
document.addEventListener('toggle', onToggle, true)
|
|
76
|
+
|
|
77
|
+
// What each `details` of the first load shows is what the server served, as a swap records it for the ones it brings.
|
|
78
|
+
for (const details of document.querySelectorAll('details'))
|
|
79
|
+
navigation.opened.set(details, details.open)
|
|
80
|
+
|
|
76
81
|
window.addEventListener('popstate', onPopState)
|
|
77
82
|
// `pagehide` saves the scroll for a full load only: back or forward between entries of this document fires `popstate` once the entry already changed, too late to save the one left, so the entry is kept up to date as the page scrolls.
|
|
78
83
|
window.addEventListener('scroll', onScroll, { passive: true })
|
|
@@ -53,6 +53,10 @@ export interface Swap {
|
|
|
53
53
|
saved?: [number, number] | undefined
|
|
54
54
|
// The element focused before, found again by id or name once swapped: a traversal sets it between entries of one path, which keep the focus.
|
|
55
55
|
focused?: Element | null
|
|
56
|
+
// Where the focused element sat among the fields of its name before the swap, set as it begins, for the nearest one to take the focus when the swap removes it.
|
|
57
|
+
place?: number | undefined
|
|
58
|
+
// The id of the focused element's nearest ancestor having one, so a row the swap removes is told from a field rendered afresh: the removed one's typed text goes nowhere.
|
|
59
|
+
row?: string | undefined
|
|
56
60
|
// What the focused text field held when the swap began, so the keys typed in it while the page was fetched are told from the text the server rendered.
|
|
57
61
|
held?: string | undefined
|
|
58
62
|
// A form the server refused a post of, and the control focused in it, by their index among the page's forms and the form's controls.
|
package/src/runtime/page-swap.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { NAVIGATION_ENTRY } from './navigation-entry'
|
|
|
7
7
|
import { forgetPageData } from './page-data'
|
|
8
8
|
import { abandon, HTML, ownOrigin, pageFor, pageTimeout } from './swap-fetch'
|
|
9
9
|
import { bounded, CHUNK_TIMEOUT_MS, ENTRY_SCRIPT, inFlight, LATE, policyOf } from './swap-flight'
|
|
10
|
-
import { keepTyped, moveFocus, watchTyped } from './swap-focus'
|
|
10
|
+
import { keepTyped, moveFocus, placeOf, rowOf, watchTyped } from './swap-focus'
|
|
11
11
|
import { mergeHead, runnable, scriptMarkup, swapRoot } from './swap-head'
|
|
12
12
|
import { checkKept, heldLate, holding, swapBody } from './swap-kept'
|
|
13
13
|
import { MISSING } from './swap-morph'
|
|
@@ -441,6 +441,9 @@ async function showPage(page: FetchedPage, hash: string, swap: Swap, isCurrent:
|
|
|
441
441
|
head.commit()
|
|
442
442
|
inFlight.typing = swap.intent === 'refresh' || (process.env.NODE_ENV !== 'production' && navigation.typed === true)
|
|
443
443
|
|
|
444
|
+
swap.place = placeOf(swap.focused)
|
|
445
|
+
swap.row = rowOf(swap.focused)
|
|
446
|
+
|
|
444
447
|
try {
|
|
445
448
|
swapBody(next, policy, held, left)
|
|
446
449
|
}
|
package/src/runtime/reactive.ts
CHANGED
|
@@ -853,3 +853,75 @@ export function withSetter<T>(read: () => T, write: (value: T) => void): Signal<
|
|
|
853
853
|
|
|
854
854
|
return Object.assign(read, { set })
|
|
855
855
|
}
|
|
856
|
+
|
|
857
|
+
interface Argument {
|
|
858
|
+
value: unknown
|
|
859
|
+
read: () => unknown
|
|
860
|
+
taken: boolean
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
interface Following {
|
|
864
|
+
args: Argument[]
|
|
865
|
+
// The first place in the block's arguments not read yet: a block takes its arguments in order, so one drawn inside it finds them taken.
|
|
866
|
+
next: number
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
// The arguments being drawn by `followed`, which a block's parameters take while the block runs.
|
|
870
|
+
let following: Following | undefined
|
|
871
|
+
|
|
872
|
+
function follow<Drawn>(reads: (() => unknown)[], draw: (...values: never[]) => Drawn): Drawn {
|
|
873
|
+
const values = untrack(() => reads.map(read => read()))
|
|
874
|
+
const first = values[0]
|
|
875
|
+
|
|
876
|
+
if (typeof first !== 'object' || first === null)
|
|
877
|
+
return draw(...reads.map(read => read()) as never[])
|
|
878
|
+
|
|
879
|
+
const outer = following
|
|
880
|
+
|
|
881
|
+
// An item that leaves while the block still reads it is read as it was.
|
|
882
|
+
const args = values.map((value, place): Argument => ({ value, read: place === 0 ? () => reads[0]!() ?? first : reads[place]!, taken: false }))
|
|
883
|
+
|
|
884
|
+
following = { args, next: 0 }
|
|
885
|
+
|
|
886
|
+
try {
|
|
887
|
+
const drawn = untrack(() => draw(...values as never[]))
|
|
888
|
+
|
|
889
|
+
// What the block did not read through its parameters is its value as of the draw, so the block is drawn again when that changes. A draw that throws is the error, whatever these reads do.
|
|
890
|
+
for (const arg of args.filter(one => !one.taken))
|
|
891
|
+
arg.read()
|
|
892
|
+
|
|
893
|
+
return drawn
|
|
894
|
+
}
|
|
895
|
+
finally {
|
|
896
|
+
following = outer
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// kept: free, a call of the page's own draw.
|
|
901
|
+
// Draws what a block shows for one item of a keyed list once, though the item is replaced by a copy under the same key: the block gets the item as it is, and what it reads of its parameter, where it is used, is the current item each time, so its nodes keep, and a field in them its focus.
|
|
902
|
+
// A call made from a template would track the item it is handed and draw the block again on each replacement. Anything but an object is drawn as a call is, again when it changes, and so is a block that reads its parameter as it was handed.
|
|
903
|
+
export function followed<Item, Drawn, Rest extends unknown[] = []>(read: () => Item, draw: (item: Item, ...rest: Rest) => Drawn, ...others: { [Place in keyof Rest]: () => Rest[Place] }): Drawn {
|
|
904
|
+
return follow([read, ...others], draw as unknown as (...values: never[]) => Drawn)
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// A block's parameter as an accessor, which the compiled block reads through: the current value when `followed` gave it at this place in the arguments, else the value it was called with.
|
|
908
|
+
export function param<Value>(value: Value, place = 0): () => Value {
|
|
909
|
+
const at = following
|
|
910
|
+
// The item is found by what it is wherever the block takes it; the other arguments by their place, once each.
|
|
911
|
+
const arg = at?.args.find((one, at0) => at0 === 0 ? one.value === value : at0 === place && at0 >= at.next && Object.is(one.value, value))
|
|
912
|
+
|
|
913
|
+
if (arg === undefined)
|
|
914
|
+
return () => value
|
|
915
|
+
|
|
916
|
+
if (arg !== at!.args[0])
|
|
917
|
+
at!.next = place + 1
|
|
918
|
+
|
|
919
|
+
arg.taken = true
|
|
920
|
+
|
|
921
|
+
return arg.read as () => Value
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
// A `slot` called with names or paths: the block, when the component was given one, draws once for the item of the first argument, each of the others read in place by a block that takes it through `param`, and drawn again when one it does not takes changes.
|
|
925
|
+
export function slotCall(block: ((...args: never[]) => unknown) | undefined, first: () => unknown, ...rest: (() => unknown)[]): unknown {
|
|
926
|
+
return block === undefined ? undefined : follow([first, ...rest], block)
|
|
927
|
+
}
|
|
@@ -15,10 +15,50 @@ interface Typed { value: string, start: number | null, end: number | null, direc
|
|
|
15
15
|
|
|
16
16
|
const noteOf = (field: Field): Typed => ({ value: field.value, start: field.selectionStart, end: field.selectionEnd, direction: field.selectionDirection ?? 'none' })
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// The element's place in document order among the fields of its name, read before a swap removes it.
|
|
19
|
+
export function placeOf(element: Element | null | undefined): number | undefined {
|
|
19
20
|
const name = element?.getAttribute('name') ?? ''
|
|
20
21
|
|
|
21
|
-
return name === '' ?
|
|
22
|
+
return name === '' || !element?.isConnected ? undefined : Array.from<Element>(document.getElementsByName(name)).indexOf(element)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// The time stamp kay writes into a form of an action with `minTime`, new on every render, so it tells no row apart (`STAMP_FIELD` in action-form.ts, kept apart as form-protect.ts does).
|
|
26
|
+
const STAMP_FIELD = 'kay_since'
|
|
27
|
+
|
|
28
|
+
// What a form is by: its id, else its action with the hidden fields it posts, which a row's form carries its key in.
|
|
29
|
+
function formKey(form: HTMLFormElement): string | undefined {
|
|
30
|
+
const id = form.getAttribute('id')
|
|
31
|
+
|
|
32
|
+
if (id !== null && id !== '')
|
|
33
|
+
return `#${id}`
|
|
34
|
+
|
|
35
|
+
const hidden = Array.from(form.querySelectorAll<HTMLInputElement>(`input[type=hidden]:not([name="${STAMP_FIELD}"])`), input => `${input.name}=${input.value}`)
|
|
36
|
+
|
|
37
|
+
return hidden.length === 0 ? undefined : `${form.getAttribute('action')}?${hidden.join('&')}`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// The element's row in a list, read before a swap removes it: its form's key, else the id of its nearest ancestor having one. A row no longer on the page is a field removed, not one rendered afresh. A row with neither tells the two apart no better than before.
|
|
41
|
+
export function rowOf(element: Element | null | undefined): string | undefined {
|
|
42
|
+
const form = element?.closest('form')
|
|
43
|
+
const id = element?.parentElement?.closest('[id]:not([id=""])')?.getAttribute('id')
|
|
44
|
+
|
|
45
|
+
return (form ? formKey(form) : undefined) ?? (id !== null && id !== undefined && id !== '' ? `#${id}` : undefined)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function rowKept(row: string): boolean {
|
|
49
|
+
return row.startsWith('#') ? document.getElementById(row.slice(1)) !== null : Array.from(document.forms).some(form => formKey(form) === row)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// The field of the name nearest to where the removed one was: the one now at its place, else the last. None without a place.
|
|
53
|
+
function byName(element: Element | null, place: number | undefined): Element | null {
|
|
54
|
+
const name = element?.getAttribute('name') ?? ''
|
|
55
|
+
|
|
56
|
+
if (name === '' || place === undefined)
|
|
57
|
+
return null
|
|
58
|
+
|
|
59
|
+
const fields = document.getElementsByName(name)
|
|
60
|
+
|
|
61
|
+
return fields[Math.max(0, Math.min(place, fields.length - 1))] ?? null
|
|
22
62
|
}
|
|
23
63
|
|
|
24
64
|
// The element focused before, found again on a refreshed page or on Back and Forward between entries of one path; on a new page, the element its hash points at, else its autofocus field, its heading or its main, so a screen reader starts there, the title announced. Back and Forward skip the autofocus field, which the visitor left already, and a position an entry saved leaves the hash alone, as it does the scroll.
|
|
@@ -38,11 +78,14 @@ export async function moveFocus(swap: Swap, policy: Policy, hash: string): Promi
|
|
|
38
78
|
if (before?.isConnected)
|
|
39
79
|
return
|
|
40
80
|
|
|
41
|
-
const again = before?.id !== undefined && before.id !== '' ? document.getElementById(before.id) : byName(before)
|
|
81
|
+
const again = before?.id !== undefined && before.id !== '' ? document.getElementById(before.id) : byName(before, swap.place)
|
|
42
82
|
|
|
43
83
|
if (again instanceof HTMLElement) {
|
|
44
84
|
again.focus({ preventScroll: true })
|
|
45
|
-
|
|
85
|
+
|
|
86
|
+
// The text of a field removed with its row is no one else's.
|
|
87
|
+
if (swap.row === undefined || rowKept(swap.row))
|
|
88
|
+
carryCaret(before, again, swap.held)
|
|
46
89
|
}
|
|
47
90
|
|
|
48
91
|
return
|
|
@@ -94,6 +137,7 @@ function carryCaret(from: Element | null, to: HTMLElement, held: string | undefi
|
|
|
94
137
|
// The island hears the kept keys once it has hydrated, by this field's own listener so that no path of the swap can drop them: the text is put back if hydration wrote the server's over it, and `input` fires either way. The latest text typed meanwhile is the one kept, and the bound of 30 s ends the wait for an island that never hydrates.
|
|
95
138
|
function replayOnHydrate(field: Field, island: Island): void {
|
|
96
139
|
let typed = noteOf(field)
|
|
140
|
+
const place = placeOf(field)
|
|
97
141
|
const heard = new AbortController()
|
|
98
142
|
let timer: ReturnType<typeof setTimeout> | undefined
|
|
99
143
|
const end = () => {
|
|
@@ -112,7 +156,7 @@ function replayOnHydrate(field: Field, island: Island): void {
|
|
|
112
156
|
end()
|
|
113
157
|
|
|
114
158
|
if (island.isConnected)
|
|
115
|
-
putBack(found(field), { ...typed, replay: true })
|
|
159
|
+
putBack(found(field, place), { ...typed, replay: true })
|
|
116
160
|
}, { signal: heard.signal, once: true })
|
|
117
161
|
}
|
|
118
162
|
|
|
@@ -172,8 +216,8 @@ function putBack(now: Element | null, typed: Typed | undefined): void {
|
|
|
172
216
|
}
|
|
173
217
|
|
|
174
218
|
// The field itself, or the one hydration put in its place.
|
|
175
|
-
function found(field: Field, id = field.id): Element | null {
|
|
176
|
-
return field.isConnected ? field : (id === '' ? null : document.getElementById(id)) ?? byName(field)
|
|
219
|
+
function found(field: Field, place: number | undefined, id = field.id): Element | null {
|
|
220
|
+
return field.isConnected ? field : (id === '' ? null : document.getElementById(id)) ?? byName(field, place)
|
|
177
221
|
}
|
|
178
222
|
|
|
179
223
|
// Keys typed into an island's field after the swap and before the island hydrated land in the server's markup, which hydration then writes its own value over. Called as the swap hands the body to hydration, it notes them as they come into the focused field and puts them back once its island has hydrated, however late a `visible` or `idle` one is, with `input` fired so the island hears them, the caret after them. A newer swap, or a bound of 30 s (an island that never hydrates, or whose hydration failed, as the event fires only on success), ends the watch with nothing restored.
|
|
@@ -189,6 +233,7 @@ export function watchTyped(): void {
|
|
|
189
233
|
return
|
|
190
234
|
|
|
191
235
|
const id = field.id
|
|
236
|
+
const place = placeOf(field)
|
|
192
237
|
let typed: Typed | undefined
|
|
193
238
|
const note = (event: Event) => {
|
|
194
239
|
if (event.target === field)
|
|
@@ -208,7 +253,7 @@ export function watchTyped(): void {
|
|
|
208
253
|
timer = setTimeout(end, WATCH_BOUND_MS)
|
|
209
254
|
island.addEventListener(HYDRATED, () => {
|
|
210
255
|
end()
|
|
211
|
-
putBack(found(field, id), typed)
|
|
256
|
+
putBack(found(field, place, id), typed)
|
|
212
257
|
}, { once: true, signal: heard.signal })
|
|
213
258
|
}
|
|
214
259
|
|
|
@@ -216,6 +261,7 @@ export function watchTyped(): void {
|
|
|
216
261
|
export function keepTyped(part: ParentNode): void {
|
|
217
262
|
for (const island of part.querySelectorAll<Island>(ISLAND)) {
|
|
218
263
|
let field: Field | undefined
|
|
264
|
+
let place: number | undefined
|
|
219
265
|
let typed: Typed | undefined
|
|
220
266
|
const heard = new AbortController()
|
|
221
267
|
const timer = setTimeout(() => heard.abort(), WATCH_BOUND_MS)
|
|
@@ -224,13 +270,14 @@ export function keepTyped(part: ParentNode): void {
|
|
|
224
270
|
island.addEventListener('input', (event) => {
|
|
225
271
|
if (event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) {
|
|
226
272
|
field = event.target
|
|
273
|
+
place = placeOf(field)
|
|
227
274
|
typed = noteOf(field)
|
|
228
275
|
}
|
|
229
276
|
}, { ...options, capture: true })
|
|
230
277
|
island.addEventListener(HYDRATED, () => {
|
|
231
278
|
clearTimeout(timer)
|
|
232
279
|
heard.abort()
|
|
233
|
-
putBack(field ? found(field) : null, typed)
|
|
280
|
+
putBack(field ? found(field, place) : null, typed)
|
|
234
281
|
}, { ...options, once: true })
|
|
235
282
|
}
|
|
236
283
|
}
|
package/src/runtime/swap-kept.ts
CHANGED
|
@@ -86,6 +86,7 @@ export function swapBody(next: Document, policy: Policy, held: Held | undefined,
|
|
|
86
86
|
const body = document.adoptNode(next.body)
|
|
87
87
|
const old = document.body
|
|
88
88
|
const focused = heldFocus()
|
|
89
|
+
const release = holdScroll(policy)
|
|
89
90
|
|
|
90
91
|
const kept = new Set<Element>()
|
|
91
92
|
// What the server left to the page as it is, found by its id by the caller before anything moved.
|
|
@@ -177,6 +178,8 @@ export function swapBody(next: Document, policy: Policy, held: Held | undefined,
|
|
|
177
178
|
finally {
|
|
178
179
|
scoped.on = false
|
|
179
180
|
parking?.remove()
|
|
181
|
+
|
|
182
|
+
release()
|
|
180
183
|
}
|
|
181
184
|
|
|
182
185
|
for (const [element, [left, top]] of scrolls) {
|
|
@@ -206,6 +209,31 @@ export function swapBody(next: Document, policy: Policy, held: Held | undefined,
|
|
|
206
209
|
}
|
|
207
210
|
}
|
|
208
211
|
|
|
212
|
+
// Chrome's scroll anchoring follows an anchor node the morph moves or drops, and lands the window elsewhere, the end of a list of rows for one: it is off while the morph runs, and a position a refresh keeps is put back after, which the returned function does.
|
|
213
|
+
function holdScroll(policy: Policy): () => void {
|
|
214
|
+
const root = document.documentElement
|
|
215
|
+
const anchoring = root.style.overflowAnchor
|
|
216
|
+
const styled = root.hasAttribute('style')
|
|
217
|
+
const { scrollX: x, scrollY: y } = window
|
|
218
|
+
|
|
219
|
+
root.style.overflowAnchor = 'none'
|
|
220
|
+
|
|
221
|
+
return () => {
|
|
222
|
+
// Reading the scroll forces the layout while anchoring is still off, which is what keeps it from adjusting.
|
|
223
|
+
if (policy.scroll === 'keep' && (scrollX !== x || scrollY !== y))
|
|
224
|
+
scrollTo({ left: x, top: y, behavior: 'instant' })
|
|
225
|
+
|
|
226
|
+
if (anchoring !== '')
|
|
227
|
+
root.style.overflowAnchor = anchoring
|
|
228
|
+
else
|
|
229
|
+
root.style.removeProperty('overflow-anchor')
|
|
230
|
+
|
|
231
|
+
// An emptied style still leaves `style=""`, which the next swap reads as a script's change to <html>.
|
|
232
|
+
if (!styled && root.getAttribute('style') === '')
|
|
233
|
+
root.removeAttribute('style')
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
209
237
|
// An island of the next page that has its match among those of this one, the same component in the same place, stays and takes the new props: what the visitor did in it is its own.
|
|
210
238
|
function keepMatched(old: Element, body: Element, matching: string, standIns: ReadonlyMap<Element, Element>, keep: (placeholder: Element, live: Element) => void): void {
|
|
211
239
|
const live = new Map<string, KeptIsland[]>()
|
package/src/server/client.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ClientOptions } from '../build/client'
|
|
2
|
+
import type { IslandImages } from '../build/island-images'
|
|
2
3
|
import type { SizeReport } from '../build/report'
|
|
3
4
|
import type { StyleUses, UnresolvedClass } from '../build/style-uses'
|
|
4
5
|
import type { Node } from '../build/supports'
|
|
@@ -130,6 +131,8 @@ export interface ClientBuild extends Omit<ClientManifest, 'styles' | 'pages' | '
|
|
|
130
131
|
report?: SizeReport | undefined
|
|
131
132
|
// The directories of the packages its modules and stylesheets come from, for the notices file.
|
|
132
133
|
packages?: string[] | undefined
|
|
134
|
+
// A static export's: the images its islands draw that no page renders.
|
|
135
|
+
islandImages?: IslandImages | undefined
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
// Quoted, spaces included, or bare.
|
package/src/server/dev.ts
CHANGED
|
@@ -670,6 +670,8 @@ export interface DevRequest {
|
|
|
670
670
|
prerender?: 'page' | 'listed' | 'server islands' | undefined
|
|
671
671
|
// The page in each locale of a site with `i18n` that serves more than one, where a language switcher links to: the locale and the address, under the base.
|
|
672
672
|
locales?: { locale: string, href: string }[] | undefined
|
|
673
|
+
// Whether the app serves `/_kay/env.js`, which the Env tab asks for only then.
|
|
674
|
+
publicEnv?: boolean | undefined
|
|
673
675
|
}
|
|
674
676
|
|
|
675
677
|
// What the server recorded of one response, for the Request tab to ask for once the page is in view.
|
package/src/server/image.ts
CHANGED
|
@@ -769,7 +769,7 @@ export async function writeRemoteVariants(clientDir: string, remote: RemoteImage
|
|
|
769
769
|
const original = await remote(src)
|
|
770
770
|
|
|
771
771
|
if ('status' in original)
|
|
772
|
-
throw new KayError('image-invalid', `kay: a page links ${src}, which the build could not download: ${original.message}`)
|
|
772
|
+
throw new KayError('image-invalid', `kay: a page or an island links ${src}, which the build could not download: ${original.message}`)
|
|
773
773
|
|
|
774
774
|
await imageSize(Bun.file(original.path))
|
|
775
775
|
await writeVariant(original.path, variant, target, variantLevel(variant, 'webp', quality, DEFAULT_AVIF_QUALITY))
|
|
@@ -119,7 +119,7 @@ function pageClassesBlock(client: ClientBuild, files: string[]): string {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
// What the dev tool's Request tab shows: the route matched, the files that rendered, the params, the status, and how long each load took, the matched route's when another page shows its error.
|
|
122
|
-
function requestBlock(files: string[], rendering: Rendering, base: string): string {
|
|
122
|
+
function requestBlock(files: string[], rendering: Rendering, base: string, publicEnv: boolean): string {
|
|
123
123
|
const { loads } = rendering
|
|
124
124
|
const state = localeState()
|
|
125
125
|
// A host of its own is a protocol-relative address, which the base does not prefix.
|
|
@@ -141,6 +141,7 @@ function requestBlock(files: string[], rendering: Rendering, base: string): stri
|
|
|
141
141
|
...rendering.slow,
|
|
142
142
|
locale: rendering.ctx.locale,
|
|
143
143
|
locales,
|
|
144
|
+
publicEnv,
|
|
144
145
|
status: rendering.status,
|
|
145
146
|
error: (rendering.ctx as Partial<ErrorPageContext>).error?.message,
|
|
146
147
|
loads: loads ? loads.files.flatMap((file, index) => loads.modules[index]!.load ? [{ file: projectPath(file), ms: loads.timings?.[index] }] : []) : [],
|
|
@@ -523,7 +524,7 @@ function documentOf(files: string[], modules: PageModule[], data: Record<string,
|
|
|
523
524
|
const sheets = stylesheets(client, styled)
|
|
524
525
|
// The nearest-`data-prefetch` selector is needed once the page holds the attribute or may gain it later: a streamed part, an island, or a server island spliced into a prerendered page.
|
|
525
526
|
const mayPrefetchPerLink = shipsEntry || streamed || (scan?.modes.length ?? 0) > 0 || [markup, head.html, head.root].some(html => DATA_PREFETCH.test(html))
|
|
526
|
-
const closing = `${headHtml}${scripts}${islandData}${kayMetas(options, hasIslands)}${newTabRule(markup, hasIslands || streamed, options.sameTabLinks === true)}${buttonFormRule(markup, streamed, islands.messages)}${shipsEntry && client.build !== undefined ? `<meta name="${BUILD_META}" content="${client.build}">` : ''}${shipsEntry && client.navigation === true ? prefetchMeta(options.client?.prefetch) : pageSpeculation(options, mayPrefetchPerLink)}${rendering.guarded === true ? GUARDED_META : ''}${client.navigation === true && !shipsEntry ? historyScript : ''}${options.offline ? registerScript(options.base ?? '', options.installOffer === true) : ''}${keepsInstallOffer ? `<script>${INSTALL_OFFER}</script>` : ''}${options.dev && options.devTools ? devScripts(client, styled, options.client?.lateStyles === true) + (options.prerendering ? '' : requestBlock(files, rendering, options.base ?? '')) : ''}</head><body>${body}`
|
|
527
|
+
const closing = `${headHtml}${scripts}${islandData}${kayMetas(options, hasIslands)}${newTabRule(markup, hasIslands || streamed, options.sameTabLinks === true)}${buttonFormRule(markup, streamed, islands.messages)}${shipsEntry && client.build !== undefined ? `<meta name="${BUILD_META}" content="${client.build}">` : ''}${shipsEntry && client.navigation === true ? prefetchMeta(options.client?.prefetch) : pageSpeculation(options, mayPrefetchPerLink)}${rendering.guarded === true ? GUARDED_META : ''}${client.navigation === true && !shipsEntry ? historyScript : ''}${options.offline ? registerScript(options.base ?? '', options.installOffer === true) : ''}${keepsInstallOffer ? `<script>${INSTALL_OFFER}</script>` : ''}${options.dev && options.devTools ? devScripts(client, styled, options.client?.lateStyles === true) + (options.prerendering ? '' : requestBlock(files, rendering, options.base ?? '', options.publicEnv === true)) : ''}</head><body>${body}`
|
|
527
528
|
const written = opening + sheets + closing
|
|
528
529
|
const start = marks === undefined ? written : placeFieldMarks(written, marks)
|
|
529
530
|
|
package/src/server/render.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from 'elysia'
|
|
2
|
-
import type {
|
|
2
|
+
import type { LoadedConfig } from '../config'
|
|
3
3
|
import type { RenderConfigKey } from '../project'
|
|
4
4
|
import type { CardPageContext, ErrorPageContext, Locals, PageContext, PageError } from '../runtime'
|
|
5
5
|
import type { Action, Outcome } from '../runtime/action'
|
|
@@ -136,7 +136,7 @@ export interface ServedPage extends Omit<PrerenderedPage, 'pattern' | 'file' | '
|
|
|
136
136
|
cut?: CutIslands | undefined
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
export interface RenderOptions extends Pick<
|
|
139
|
+
export interface RenderOptions extends Pick<LoadedConfig, RenderConfigKey | 'publicEnv'> {
|
|
140
140
|
// Shows thrown errors with their stack instead of a generic message.
|
|
141
141
|
dev?: boolean | undefined
|
|
142
142
|
// Loads the dev tool's scripts, which the dev routes serve.
|
package/src/template-styles.ts
CHANGED
|
@@ -47,7 +47,7 @@ const ACCENT_COLOURS = {
|
|
|
47
47
|
coral: '#f27b72',
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
// The look of orbit's apps: kayjs-ui's space skin over a near-black palette, a hairline on every box,
|
|
50
|
+
// The look of orbit's apps: kayjs-ui's space skin over a near-black palette, a hairline on every box, and an accent the picker in the header changes.
|
|
51
51
|
// The colours carry kayjs-ui's names (`background`, `foreground`, `border`), none of them one of Tailwind's own utilities such as `text-base`.
|
|
52
52
|
export function tailwindCss({ has }: Setup): string {
|
|
53
53
|
const ui = has('ui')
|
|
@@ -83,7 +83,7 @@ ${has('accents') ? '\n /* The accent picker sets --accent on the page. */\n --
|
|
|
83
83
|
}`,
|
|
84
84
|
`@layer base {
|
|
85
85
|
body {
|
|
86
|
-
@apply
|
|
86
|
+
@apply flex min-h-screen flex-col bg-background font-sans text-foreground;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
a {
|
package/types/build/client.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { ClientBuild, ClientManifest } from '../server/client';
|
|
|
6
6
|
import type { ImportGraph, KayLibrary } from './libraries';
|
|
7
7
|
import type { ChunkInputs, IslandWhy } from './report';
|
|
8
8
|
import type { StyleUses, UnresolvedClass } from './style-uses';
|
|
9
|
+
import { exportedImages } from './island-images';
|
|
9
10
|
export interface ClientOptions extends Pick<KayConfig, ClientBuildKey> {
|
|
10
11
|
minify?: boolean | undefined;
|
|
11
12
|
sourcemap?: boolean | 'external' | undefined;
|
|
@@ -16,6 +17,10 @@ export interface ClientOptions extends Pick<KayConfig, ClientBuildKey> {
|
|
|
16
17
|
inspect?: boolean | undefined;
|
|
17
18
|
publicEnv?: boolean | undefined;
|
|
18
19
|
exported?: boolean | undefined;
|
|
20
|
+
staticImages?: {
|
|
21
|
+
allowed: (src: string) => boolean;
|
|
22
|
+
remote?: string[];
|
|
23
|
+
} | undefined;
|
|
19
24
|
report?: 'sizes' | 'modules' | undefined;
|
|
20
25
|
}
|
|
21
26
|
interface MetafileOutput {
|
|
@@ -55,6 +60,7 @@ export interface SessionBuild {
|
|
|
55
60
|
manifest: ClientManifest;
|
|
56
61
|
scripts?: Awaited<ReturnType<typeof bundleIslands>> | undefined;
|
|
57
62
|
styles?: Awaited<ReturnType<typeof bundleStyles>> | undefined;
|
|
63
|
+
images?: Awaited<ReturnType<typeof exportedImages>>['images'];
|
|
58
64
|
}
|
|
59
65
|
export interface ClientSession {
|
|
60
66
|
build: (changed: string[] | null) => Promise<SessionBuild>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/build/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGnE,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/build/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGnE,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;A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AAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC,CAwE3W;AAKD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,EAAE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAOzG;AAOD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC,cAAc,EAAE,QAAQ,CAAC,CA+CxJ"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CheckDiagnostic } from '../check';
|
|
2
|
+
import type { LintLevels } from '../compiler/lints';
|
|
3
|
+
import type { ImageOptions } from '../runtime/image';
|
|
4
|
+
import type { ClientOptions } from './client';
|
|
5
|
+
import type { ImportGraph, KayLibrary } from './libraries';
|
|
6
|
+
export interface IslandImage {
|
|
7
|
+
file: string;
|
|
8
|
+
options: ImageOptions;
|
|
9
|
+
}
|
|
10
|
+
export interface RemoteIslandImage extends Position {
|
|
11
|
+
src: string;
|
|
12
|
+
options: ImageOptions;
|
|
13
|
+
}
|
|
14
|
+
interface Position {
|
|
15
|
+
file: string;
|
|
16
|
+
line: number;
|
|
17
|
+
column: number;
|
|
18
|
+
}
|
|
19
|
+
export interface DynamicIslandImage extends Position {
|
|
20
|
+
reason: 'source' | 'size' | 'option';
|
|
21
|
+
}
|
|
22
|
+
export interface IslandImages {
|
|
23
|
+
imported: IslandImage[];
|
|
24
|
+
remote: RemoteIslandImage[];
|
|
25
|
+
dynamic: DynamicIslandImage[];
|
|
26
|
+
}
|
|
27
|
+
export declare function scanIslandImages(files: Iterable<string>): IslandImages;
|
|
28
|
+
export declare function assetNameOf(file: string): string | undefined;
|
|
29
|
+
export declare function assetUrlOf(file: string): string | undefined;
|
|
30
|
+
export declare function exportedImages(root: string, sources: {
|
|
31
|
+
islands: Map<string, string>;
|
|
32
|
+
libraries: KayLibrary[];
|
|
33
|
+
}, graph: ImportGraph, options: ClientOptions): Promise<{
|
|
34
|
+
images: IslandImages | undefined;
|
|
35
|
+
bundled: ClientOptions;
|
|
36
|
+
}>;
|
|
37
|
+
export declare function staticRemoteDefine({ staticImages }: ClientOptions): string;
|
|
38
|
+
export declare function linkedRemote(images: IslandImages, allowed: (src: string) => boolean): RemoteIslandImage[];
|
|
39
|
+
export declare function recordIslandImages(clientDir: string, images: IslandImages | undefined, allowed: (src: string) => boolean, { checking, lints }: {
|
|
40
|
+
checking: boolean;
|
|
41
|
+
lints: LintLevels | undefined;
|
|
42
|
+
}): Promise<CheckDiagnostic[]>;
|
|
43
|
+
export declare function dynamicImageLints(images: IslandImages, level: 'warn' | 'deny', allowed?: (src: string) => boolean): CheckDiagnostic[];
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=island-images.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"island-images.d.ts","sourceRoot":"","sources":["../../src/build/island-images.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,KAAK,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G,OAAO,CAAC;IAAE,MAAM,EAAE,YAAY,GAAG,SAAS,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,CAAC,CASxO;AAGD,wBAAgB,kBAAkB,CAAC,EAAE,YAAY,EAAE,EAAE,aAAa,GAAG,MAAM,CAE1E;AAGD,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GAAG,iBAAiB,EAAE,CAEzG;AAID,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;CAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CA+BtO;AAUD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAoB,GAAG,eAAe,EAAE,CAIjJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/build/pipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAM1C,OAAO,KAAK,EAAE,YAAY,EAAa,UAAU,EAAa,YAAY,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/build/pipeline.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,OAAO,KAAK,EAA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