@kayjs/kay 2.0.0-beta.0 → 2.0.0-beta.2
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/package.json +1 -1
- package/src/attrs.ts +35 -0
- package/src/build/bundle.ts +615 -0
- package/src/build/compile.ts +32 -19
- package/src/build/files.ts +174 -0
- package/src/build/graph.ts +223 -0
- package/src/build/index.ts +255 -1461
- package/src/build/islands.ts +177 -0
- package/src/build/manifest.ts +227 -0
- package/src/build/plugin-host.ts +186 -0
- package/src/build/prerender.ts +94 -0
- package/src/build/report.ts +157 -0
- package/src/build/resolve.ts +51 -0
- package/src/build/routes.ts +163 -0
- package/src/build/static.ts +73 -0
- package/src/cli/check.ts +300 -129
- package/src/cli/index.ts +297 -94
- package/src/cli/new.ts +58 -38
- package/src/compiler/analyze.ts +723 -93
- package/src/compiler/dom.ts +848 -762
- package/src/compiler/mistakes.ts +354 -0
- package/src/compiler/patch.ts +1 -1
- package/src/compiler/server-only.ts +172 -23
- package/src/compiler/shared.ts +485 -0
- package/src/compiler/ssr.ts +331 -342
- package/src/context.ts +120 -0
- package/src/dev/index.ts +358 -76
- package/src/dom/action.ts +114 -14
- package/src/dom/extras.ts +121 -83
- package/src/dom/index.ts +122 -80
- package/src/dom/island.ts +71 -36
- package/src/dom/loop.ts +28 -20
- package/src/index.ts +5 -1
- package/src/jsx-runtime.ts +432 -93
- package/src/plugins/context.ts +83 -0
- package/src/plugins/index.ts +285 -23
- package/src/reactivity/index.ts +237 -213
- package/src/reactivity/selector.ts +11 -9
- package/src/reactivity/store.ts +36 -11
- package/src/server/action.ts +157 -79
- package/src/server/compress.ts +197 -104
- package/src/server/cookies.ts +46 -16
- package/src/server/env.ts +18 -13
- package/src/server/http.ts +189 -77
- package/src/server/index.ts +1024 -878
- package/src/server/loader.ts +138 -0
- package/src/server/router.ts +69 -26
- package/src/server/security.ts +50 -58
- package/src/server/standard-schema.ts +42 -11
- package/src/server/static-dir.ts +144 -0
- package/src/ssr/context.ts +95 -10
- package/src/ssr/index.ts +167 -66
- package/src/style.ts +33 -0
- package/src/test/index.ts +5 -15
- package/src/unrenderable.ts +35 -0
package/src/jsx-runtime.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference path="./ambient.d.ts" />
|
|
2
2
|
// TypeScript JSX runtime types for Kay v2.
|
|
3
|
-
// Standard TSX compiles away at build time; these types
|
|
3
|
+
// Standard TSX compiles away at build time; these types derive HTML/SVG element attributes from lib.dom,
|
|
4
|
+
// type event `currentTarget` and `ref` per element, support async components, and allow custom elements via augmentation.
|
|
4
5
|
|
|
5
6
|
export type HydrateStrategy =
|
|
6
7
|
| 'load'
|
|
@@ -20,8 +21,12 @@ export type KayChild =
|
|
|
20
21
|
| Node
|
|
21
22
|
| KayChild[]
|
|
22
23
|
|
|
24
|
+
declare const htmlBrand: unique symbol
|
|
25
|
+
|
|
26
|
+
/** HTML kay injects unescaped; only `raw()` makes one, so a plain `{ __html }` object is not an Html. */
|
|
23
27
|
export interface Html {
|
|
24
28
|
readonly __html: string
|
|
29
|
+
readonly [htmlBrand]: true
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
export type Component<P = Record<string, unknown>> = (props: P) => KayChild | Promise<KayChild>
|
|
@@ -40,120 +45,463 @@ export function jsx(tag: unknown, props: Record<string, unknown>): KayChild | Pr
|
|
|
40
45
|
export const jsxs = jsx
|
|
41
46
|
export const jsxDEV = jsx
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
export type TargetedEvent<T extends EventTarget = Element, E extends Event = Event> = Omit<E, 'currentTarget'> & {
|
|
49
|
+
readonly currentTarget: T
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type EventHandler<T extends EventTarget, E extends Event = Event> = (e: TargetedEvent<T, E>) => void
|
|
53
|
+
|
|
54
|
+
export interface DOMEventHandlers<T extends EventTarget = Element> {
|
|
55
|
+
// Mouse & pointer
|
|
56
|
+
onClick?: EventHandler<T, MouseEvent> | undefined
|
|
57
|
+
onDblClick?: EventHandler<T, MouseEvent> | undefined
|
|
58
|
+
onAuxClick?: EventHandler<T, MouseEvent> | undefined
|
|
59
|
+
onContextMenu?: EventHandler<T, MouseEvent> | undefined
|
|
60
|
+
onMouseDown?: EventHandler<T, MouseEvent> | undefined
|
|
61
|
+
onMouseUp?: EventHandler<T, MouseEvent> | undefined
|
|
62
|
+
onMouseMove?: EventHandler<T, MouseEvent> | undefined
|
|
63
|
+
onMouseEnter?: EventHandler<T, MouseEvent> | undefined
|
|
64
|
+
onMouseLeave?: EventHandler<T, MouseEvent> | undefined
|
|
65
|
+
onMouseOver?: EventHandler<T, MouseEvent> | undefined
|
|
66
|
+
onMouseOut?: EventHandler<T, MouseEvent> | undefined
|
|
67
|
+
onPointerDown?: EventHandler<T, PointerEvent> | undefined
|
|
68
|
+
onPointerUp?: EventHandler<T, PointerEvent> | undefined
|
|
69
|
+
onPointerMove?: EventHandler<T, PointerEvent> | undefined
|
|
70
|
+
onPointerEnter?: EventHandler<T, PointerEvent> | undefined
|
|
71
|
+
onPointerLeave?: EventHandler<T, PointerEvent> | undefined
|
|
72
|
+
onPointerOver?: EventHandler<T, PointerEvent> | undefined
|
|
73
|
+
onPointerOut?: EventHandler<T, PointerEvent> | undefined
|
|
74
|
+
onPointerCancel?: EventHandler<T, PointerEvent> | undefined
|
|
75
|
+
onGotPointerCapture?: EventHandler<T, PointerEvent> | undefined
|
|
76
|
+
onLostPointerCapture?: EventHandler<T, PointerEvent> | undefined
|
|
77
|
+
// Touch
|
|
78
|
+
onTouchStart?: EventHandler<T, TouchEvent> | undefined
|
|
79
|
+
onTouchMove?: EventHandler<T, TouchEvent> | undefined
|
|
80
|
+
onTouchEnd?: EventHandler<T, TouchEvent> | undefined
|
|
81
|
+
onTouchCancel?: EventHandler<T, TouchEvent> | undefined
|
|
82
|
+
// Keyboard & composition
|
|
83
|
+
onKeyDown?: EventHandler<T, KeyboardEvent> | undefined
|
|
84
|
+
onKeyUp?: EventHandler<T, KeyboardEvent> | undefined
|
|
85
|
+
onKeyPress?: EventHandler<T, KeyboardEvent> | undefined
|
|
86
|
+
onCompositionStart?: EventHandler<T, CompositionEvent> | undefined
|
|
87
|
+
onCompositionUpdate?: EventHandler<T, CompositionEvent> | undefined
|
|
88
|
+
onCompositionEnd?: EventHandler<T, CompositionEvent> | undefined
|
|
89
|
+
// Focus
|
|
90
|
+
onFocus?: EventHandler<T, FocusEvent> | undefined
|
|
91
|
+
onBlur?: EventHandler<T, FocusEvent> | undefined
|
|
92
|
+
onFocusIn?: EventHandler<T, FocusEvent> | undefined
|
|
93
|
+
onFocusOut?: EventHandler<T, FocusEvent> | undefined
|
|
94
|
+
// Form & input
|
|
95
|
+
onInput?: EventHandler<T, Event> | undefined
|
|
96
|
+
onBeforeInput?: EventHandler<T, InputEvent> | undefined
|
|
97
|
+
onChange?: EventHandler<T, Event> | undefined
|
|
98
|
+
onSubmit?: EventHandler<T, SubmitEvent> | undefined
|
|
99
|
+
onReset?: EventHandler<T, Event> | undefined
|
|
100
|
+
onInvalid?: EventHandler<T, Event> | undefined
|
|
101
|
+
onFormData?: EventHandler<T, FormDataEvent> | undefined
|
|
102
|
+
onSelect?: EventHandler<T, Event> | undefined
|
|
103
|
+
onSearch?: EventHandler<T, Event> | undefined
|
|
104
|
+
// Scroll & wheel
|
|
105
|
+
onScroll?: EventHandler<T, Event> | undefined
|
|
106
|
+
onScrollEnd?: EventHandler<T, Event> | undefined
|
|
107
|
+
onWheel?: EventHandler<T, WheelEvent> | undefined
|
|
108
|
+
onResize?: EventHandler<T, UIEvent> | undefined
|
|
109
|
+
// Drag & drop
|
|
110
|
+
onDrag?: EventHandler<T, DragEvent> | undefined
|
|
111
|
+
onDragStart?: EventHandler<T, DragEvent> | undefined
|
|
112
|
+
onDragEnd?: EventHandler<T, DragEvent> | undefined
|
|
113
|
+
onDragEnter?: EventHandler<T, DragEvent> | undefined
|
|
114
|
+
onDragLeave?: EventHandler<T, DragEvent> | undefined
|
|
115
|
+
onDragOver?: EventHandler<T, DragEvent> | undefined
|
|
116
|
+
onDrop?: EventHandler<T, DragEvent> | undefined
|
|
117
|
+
// Clipboard
|
|
118
|
+
onCopy?: EventHandler<T, ClipboardEvent> | undefined
|
|
119
|
+
onCut?: EventHandler<T, ClipboardEvent> | undefined
|
|
120
|
+
onPaste?: EventHandler<T, ClipboardEvent> | undefined
|
|
121
|
+
// Dialog, details & popover
|
|
122
|
+
onToggle?: EventHandler<T, ToggleEvent> | undefined
|
|
123
|
+
onBeforeToggle?: EventHandler<T, ToggleEvent> | undefined
|
|
124
|
+
onClose?: EventHandler<T, Event> | undefined
|
|
125
|
+
onCancel?: EventHandler<T, Event> | undefined
|
|
126
|
+
// Media & resource lifecycle
|
|
127
|
+
onLoad?: EventHandler<T, Event> | undefined
|
|
128
|
+
onLoadStart?: EventHandler<T, Event> | undefined
|
|
129
|
+
onLoadEnd?: EventHandler<T, ProgressEvent> | undefined
|
|
130
|
+
onError?: EventHandler<T, Event> | undefined
|
|
131
|
+
onAbort?: EventHandler<T, Event> | undefined
|
|
132
|
+
onPlay?: EventHandler<T, Event> | undefined
|
|
133
|
+
onPause?: EventHandler<T, Event> | undefined
|
|
134
|
+
onPlaying?: EventHandler<T, Event> | undefined
|
|
135
|
+
onEnded?: EventHandler<T, Event> | undefined
|
|
136
|
+
onTimeUpdate?: EventHandler<T, Event> | undefined
|
|
137
|
+
onLoadedMetadata?: EventHandler<T, Event> | undefined
|
|
138
|
+
onLoadedData?: EventHandler<T, Event> | undefined
|
|
139
|
+
onCanPlay?: EventHandler<T, Event> | undefined
|
|
140
|
+
onCanPlayThrough?: EventHandler<T, Event> | undefined
|
|
141
|
+
onDurationChange?: EventHandler<T, Event> | undefined
|
|
142
|
+
onEmptied?: EventHandler<T, Event> | undefined
|
|
143
|
+
onProgress?: EventHandler<T, ProgressEvent> | undefined
|
|
144
|
+
onRateChange?: EventHandler<T, Event> | undefined
|
|
145
|
+
onSeeked?: EventHandler<T, Event> | undefined
|
|
146
|
+
onSeeking?: EventHandler<T, Event> | undefined
|
|
147
|
+
onStalled?: EventHandler<T, Event> | undefined
|
|
148
|
+
onSuspend?: EventHandler<T, Event> | undefined
|
|
149
|
+
onVolumeChange?: EventHandler<T, Event> | undefined
|
|
150
|
+
onWaiting?: EventHandler<T, Event> | undefined
|
|
151
|
+
// CSS animations & transitions
|
|
152
|
+
onAnimationStart?: EventHandler<T, AnimationEvent> | undefined
|
|
153
|
+
onAnimationEnd?: EventHandler<T, AnimationEvent> | undefined
|
|
154
|
+
onAnimationIteration?: EventHandler<T, AnimationEvent> | undefined
|
|
155
|
+
onAnimationCancel?: EventHandler<T, AnimationEvent> | undefined
|
|
156
|
+
onTransitionStart?: EventHandler<T, TransitionEvent> | undefined
|
|
157
|
+
onTransitionEnd?: EventHandler<T, TransitionEvent> | undefined
|
|
158
|
+
onTransitionRun?: EventHandler<T, TransitionEvent> | undefined
|
|
159
|
+
onTransitionCancel?: EventHandler<T, TransitionEvent> | undefined
|
|
160
|
+
// Misc
|
|
161
|
+
onSlotChange?: EventHandler<T, Event> | undefined
|
|
162
|
+
onSelectionChange?: EventHandler<T, Event> | undefined
|
|
163
|
+
onSelectStart?: EventHandler<T, Event> | undefined
|
|
164
|
+
onBeforeMatch?: EventHandler<T, Event> | undefined
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface CommonAttributes<T extends Element = Element> extends DOMEventHandlers<T> {
|
|
44
168
|
id?: string | undefined
|
|
45
169
|
class?: string | undefined
|
|
46
170
|
className?: string | undefined
|
|
47
171
|
style?: string | Record<string, string | number | undefined> | undefined
|
|
48
172
|
title?: string | undefined
|
|
49
|
-
tabIndex?: number | undefined
|
|
50
|
-
|
|
173
|
+
tabIndex?: number | string | undefined
|
|
174
|
+
tabindex?: number | string | undefined
|
|
175
|
+
hidden?: boolean | 'until-found' | undefined
|
|
176
|
+
inert?: boolean | undefined
|
|
51
177
|
role?: string | undefined
|
|
52
178
|
lang?: string | undefined
|
|
53
|
-
dir?: string | undefined
|
|
54
|
-
draggable?: boolean | undefined
|
|
179
|
+
dir?: 'ltr' | 'rtl' | 'auto' | string | undefined
|
|
180
|
+
draggable?: boolean | 'true' | 'false' | undefined
|
|
55
181
|
contentEditable?: boolean | 'true' | 'false' | 'plaintext-only' | undefined
|
|
182
|
+
contenteditable?: boolean | 'true' | 'false' | 'plaintext-only' | undefined
|
|
183
|
+
spellCheck?: boolean | 'true' | 'false' | undefined
|
|
184
|
+
spellcheck?: boolean | 'true' | 'false' | undefined
|
|
185
|
+
translate?: 'yes' | 'no' | undefined
|
|
186
|
+
accessKey?: string | undefined
|
|
187
|
+
accesskey?: string | undefined
|
|
188
|
+
autoCapitalize?: string | undefined
|
|
189
|
+
autocapitalize?: string | undefined
|
|
190
|
+
autoFocus?: boolean | undefined
|
|
191
|
+
autofocus?: boolean | undefined
|
|
192
|
+
enterKeyHint?: string | undefined
|
|
193
|
+
enterkeyhint?: string | undefined
|
|
194
|
+
inputMode?: string | undefined
|
|
195
|
+
inputmode?: string | undefined
|
|
196
|
+
is?: string | undefined
|
|
197
|
+
itemProp?: string | undefined
|
|
198
|
+
itemScope?: boolean | undefined
|
|
199
|
+
itemType?: string | undefined
|
|
200
|
+
nonce?: string | undefined
|
|
201
|
+
part?: string | undefined
|
|
202
|
+
popover?: '' | 'auto' | 'manual' | 'hint' | boolean | undefined
|
|
56
203
|
slot?: string | undefined
|
|
57
204
|
children?: KayChild | undefined
|
|
58
205
|
key?: string | number | undefined
|
|
59
|
-
ref?: ((el:
|
|
206
|
+
ref?: ((el: T) => void) | undefined
|
|
60
207
|
$hydrate?: HydrateStrategy | undefined
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
onKeyUp?: ((e: KeyboardEvent) => void) | undefined
|
|
69
|
-
onFocus?: ((e: FocusEvent) => void) | undefined
|
|
70
|
-
onBlur?: ((e: FocusEvent) => void) | undefined
|
|
71
|
-
onMouseEnter?: ((e: MouseEvent) => void) | undefined
|
|
72
|
-
onMouseLeave?: ((e: MouseEvent) => void) | undefined
|
|
73
|
-
onPointerDown?: ((e: PointerEvent) => void) | undefined
|
|
74
|
-
onPointerUp?: ((e: PointerEvent) => void) | undefined
|
|
208
|
+
innerHTML?: string | Html | null | undefined
|
|
209
|
+
// Spellings from React and Solid that kay refuses at compile time, refused here first.
|
|
210
|
+
dangerouslySetInnerHTML?: never
|
|
211
|
+
classList?: never
|
|
212
|
+
defaultValue?: never
|
|
213
|
+
defaultChecked?: never
|
|
214
|
+
onDoubleClick?: never
|
|
75
215
|
[attr: `data-${string}`]: string | number | boolean | undefined
|
|
76
216
|
[attr: `aria-${string}`]: string | number | boolean | undefined
|
|
77
|
-
[attr: string]: unknown
|
|
78
217
|
}
|
|
79
218
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
219
|
+
type WritableKeys<T> = {
|
|
220
|
+
[K in keyof T]-?: (<F>() => F extends { [Q in K]: T[K] } ? 1 : 2) extends (<F>() => F extends { -readonly [Q in K]: T[K] } ? 1 : 2)
|
|
221
|
+
? K
|
|
222
|
+
: never
|
|
223
|
+
}[keyof T]
|
|
86
224
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
225
|
+
type BlockedDomProps =
|
|
226
|
+
| keyof CommonAttributes
|
|
227
|
+
| 'outerHTML'
|
|
228
|
+
| 'innerText'
|
|
229
|
+
| 'outerText'
|
|
230
|
+
| 'textContent'
|
|
231
|
+
| 'nodeValue'
|
|
232
|
+
| 'scrollTop'
|
|
233
|
+
| 'scrollLeft'
|
|
234
|
+
| 'selectionStart'
|
|
235
|
+
| 'selectionEnd'
|
|
236
|
+
| 'selectionDirection'
|
|
237
|
+
| 'valueAsNumber'
|
|
238
|
+
| 'indeterminate'
|
|
239
|
+
| 'prefix'
|
|
240
|
+
| 'localName'
|
|
241
|
+
| 'namespaceURI'
|
|
93
242
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
checked?: boolean | undefined
|
|
99
|
-
disabled?: boolean | undefined
|
|
100
|
-
placeholder?: string | undefined
|
|
101
|
-
required?: boolean | undefined
|
|
102
|
-
min?: string | number | undefined
|
|
103
|
-
max?: string | number | undefined
|
|
104
|
-
step?: string | number | undefined
|
|
105
|
-
readOnly?: boolean | undefined
|
|
106
|
-
autoComplete?: string | undefined
|
|
107
|
-
autoFocus?: boolean | undefined
|
|
108
|
-
}
|
|
243
|
+
type PrimitiveDomPropKeys<E> = {
|
|
244
|
+
[K in Exclude<WritableKeys<E>, BlockedDomProps | `on${string}`>]:
|
|
245
|
+
NonNullable<E[K]> extends string | number | boolean ? K : never
|
|
246
|
+
}[Exclude<WritableKeys<E>, BlockedDomProps | `on${string}`>]
|
|
109
247
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
248
|
+
type DomAttrValue<V> =
|
|
249
|
+
NonNullable<V> extends boolean
|
|
250
|
+
? boolean | undefined
|
|
251
|
+
: NonNullable<V> extends number
|
|
252
|
+
? number | string | undefined
|
|
253
|
+
: V | undefined
|
|
254
|
+
|
|
255
|
+
type DerivedDomAttributes<E> = {
|
|
256
|
+
[K in PrimitiveDomPropKeys<E>]?: DomAttrValue<E[K]>
|
|
115
257
|
}
|
|
116
258
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
259
|
+
export type HTMLAttributes<E extends HTMLElement = HTMLElement> = CommonAttributes<E> & DerivedDomAttributes<E>
|
|
260
|
+
|
|
261
|
+
// Element-specific HTML attribute extras (lowercase spellings, form actions, popover triggers, etc.)
|
|
262
|
+
interface HtmlElementOverrides {
|
|
263
|
+
a: { download?: string | boolean | undefined, referrerpolicy?: string | undefined }
|
|
264
|
+
area: { download?: string | boolean | undefined, referrerpolicy?: string | undefined }
|
|
265
|
+
audio: { crossorigin?: string | undefined }
|
|
266
|
+
button: {
|
|
267
|
+
type?: 'button' | 'submit' | 'reset' | undefined
|
|
268
|
+
popovertarget?: string | undefined
|
|
269
|
+
popoverTarget?: string | undefined
|
|
270
|
+
popovertargetaction?: 'hide' | 'show' | 'toggle' | undefined
|
|
271
|
+
popoverTargetAction?: 'hide' | 'show' | 'toggle' | undefined
|
|
272
|
+
formaction?: string | ((...args: never[]) => unknown) | undefined
|
|
273
|
+
formenctype?: string | undefined
|
|
274
|
+
formmethod?: string | undefined
|
|
275
|
+
formnovalidate?: boolean | undefined
|
|
276
|
+
formtarget?: string | undefined
|
|
277
|
+
}
|
|
278
|
+
details: { name?: string | undefined, open?: boolean | undefined }
|
|
279
|
+
dialog: { closedby?: 'any' | 'closerequest' | 'none' | undefined }
|
|
280
|
+
form: {
|
|
281
|
+
action?: string | ((...args: never[]) => unknown) | undefined
|
|
282
|
+
method?: 'get' | 'post' | 'dialog' | 'GET' | 'POST' | undefined
|
|
283
|
+
enctype?: string | undefined
|
|
284
|
+
encType?: string | undefined
|
|
285
|
+
novalidate?: boolean | undefined
|
|
286
|
+
noValidate?: boolean | undefined
|
|
287
|
+
autocomplete?: string | undefined
|
|
288
|
+
'accept-charset'?: string | undefined
|
|
289
|
+
}
|
|
290
|
+
iframe: {
|
|
291
|
+
allowfullscreen?: boolean | undefined
|
|
292
|
+
loading?: 'lazy' | 'eager' | undefined
|
|
293
|
+
referrerpolicy?: string | undefined
|
|
294
|
+
sandbox?: string | undefined
|
|
295
|
+
srcdoc?: string | undefined
|
|
296
|
+
}
|
|
297
|
+
img: {
|
|
298
|
+
crossorigin?: string | undefined
|
|
299
|
+
decoding?: 'async' | 'sync' | 'auto' | undefined
|
|
300
|
+
fetchpriority?: 'high' | 'low' | 'auto' | undefined
|
|
301
|
+
fetchPriority?: 'high' | 'low' | 'auto' | undefined
|
|
302
|
+
loading?: 'lazy' | 'eager' | undefined
|
|
303
|
+
referrerpolicy?: string | undefined
|
|
304
|
+
sizes?: string | undefined
|
|
305
|
+
srcset?: string | undefined
|
|
306
|
+
srcSet?: string | undefined
|
|
307
|
+
usemap?: string | undefined
|
|
308
|
+
}
|
|
309
|
+
input: {
|
|
310
|
+
value?: string | number | undefined
|
|
311
|
+
autocomplete?: string | undefined
|
|
312
|
+
maxlength?: number | string | undefined
|
|
313
|
+
minlength?: number | string | undefined
|
|
314
|
+
readonly?: boolean | undefined
|
|
315
|
+
list?: string | undefined
|
|
316
|
+
popovertarget?: string | undefined
|
|
317
|
+
popoverTarget?: string | undefined
|
|
318
|
+
popovertargetaction?: 'hide' | 'show' | 'toggle' | undefined
|
|
319
|
+
popoverTargetAction?: 'hide' | 'show' | 'toggle' | undefined
|
|
320
|
+
formaction?: string | ((...args: never[]) => unknown) | undefined
|
|
321
|
+
formenctype?: string | undefined
|
|
322
|
+
formmethod?: string | undefined
|
|
323
|
+
formnovalidate?: boolean | undefined
|
|
324
|
+
formtarget?: string | undefined
|
|
325
|
+
}
|
|
326
|
+
label: { for?: string | undefined, htmlFor?: string | undefined }
|
|
327
|
+
link: {
|
|
328
|
+
as?: string | undefined
|
|
329
|
+
crossorigin?: string | undefined
|
|
330
|
+
fetchpriority?: 'high' | 'low' | 'auto' | undefined
|
|
331
|
+
imagesizes?: string | undefined
|
|
332
|
+
imagesrcset?: string | undefined
|
|
333
|
+
referrerpolicy?: string | undefined
|
|
334
|
+
}
|
|
335
|
+
meta: {
|
|
336
|
+
charset?: string | undefined
|
|
337
|
+
charSet?: string | undefined
|
|
338
|
+
'http-equiv'?: string | undefined
|
|
339
|
+
property?: string | undefined
|
|
340
|
+
}
|
|
341
|
+
ol: { reversed?: boolean | undefined, start?: number | string | undefined }
|
|
342
|
+
option: { value?: string | number | undefined, selected?: boolean | undefined, disabled?: boolean | undefined }
|
|
343
|
+
output: { for?: string | undefined, htmlFor?: string | undefined }
|
|
344
|
+
script: {
|
|
345
|
+
crossorigin?: string | undefined
|
|
346
|
+
fetchpriority?: 'high' | 'low' | 'auto' | undefined
|
|
347
|
+
nomodule?: boolean | undefined
|
|
348
|
+
referrerpolicy?: string | undefined
|
|
349
|
+
}
|
|
350
|
+
select: {
|
|
351
|
+
value?: string | number | undefined
|
|
352
|
+
autocomplete?: string | undefined
|
|
353
|
+
multiple?: boolean | undefined
|
|
354
|
+
}
|
|
355
|
+
source: {
|
|
356
|
+
media?: string | undefined
|
|
357
|
+
sizes?: string | undefined
|
|
358
|
+
srcset?: string | undefined
|
|
359
|
+
srcSet?: string | undefined
|
|
360
|
+
type?: string | undefined
|
|
361
|
+
width?: number | string | undefined
|
|
362
|
+
height?: number | string | undefined
|
|
363
|
+
}
|
|
364
|
+
td: { colspan?: number | string | undefined, rowspan?: number | string | undefined, headers?: string | undefined }
|
|
365
|
+
textarea: {
|
|
366
|
+
value?: string | number | undefined
|
|
367
|
+
autocomplete?: string | undefined
|
|
368
|
+
maxlength?: number | string | undefined
|
|
369
|
+
minlength?: number | string | undefined
|
|
370
|
+
readonly?: boolean | undefined
|
|
371
|
+
}
|
|
372
|
+
th: { colspan?: number | string | undefined, rowspan?: number | string | undefined, headers?: string | undefined, scope?: string | undefined }
|
|
373
|
+
time: { datetime?: string | undefined, dateTime?: string | undefined }
|
|
374
|
+
video: { crossorigin?: string | undefined, playsinline?: boolean | undefined, playsInline?: boolean | undefined }
|
|
124
375
|
}
|
|
125
376
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
377
|
+
type HtmlIntrinsicElements = {
|
|
378
|
+
[K in keyof HTMLElementTagNameMap]:
|
|
379
|
+
K extends keyof HtmlElementOverrides
|
|
380
|
+
? Omit<HTMLAttributes<HTMLElementTagNameMap[K]>, keyof HtmlElementOverrides[K]> & HtmlElementOverrides[K]
|
|
381
|
+
: HTMLAttributes<HTMLElementTagNameMap[K]>
|
|
129
382
|
}
|
|
130
383
|
|
|
131
|
-
interface
|
|
132
|
-
|
|
384
|
+
export interface SVGAttributes<T extends SVGElement = SVGElement> extends CommonAttributes<T> {
|
|
385
|
+
xmlns?: string | undefined
|
|
386
|
+
'xmlns:xlink'?: string | undefined
|
|
387
|
+
viewBox?: string | undefined
|
|
388
|
+
preserveAspectRatio?: string | undefined
|
|
389
|
+
width?: number | string | undefined
|
|
390
|
+
height?: number | string | undefined
|
|
391
|
+
x?: number | string | undefined
|
|
392
|
+
y?: number | string | undefined
|
|
393
|
+
x1?: number | string | undefined
|
|
394
|
+
y1?: number | string | undefined
|
|
395
|
+
x2?: number | string | undefined
|
|
396
|
+
y2?: number | string | undefined
|
|
397
|
+
cx?: number | string | undefined
|
|
398
|
+
cy?: number | string | undefined
|
|
399
|
+
r?: number | string | undefined
|
|
400
|
+
rx?: number | string | undefined
|
|
401
|
+
ry?: number | string | undefined
|
|
402
|
+
dx?: number | string | undefined
|
|
403
|
+
dy?: number | string | undefined
|
|
404
|
+
d?: string | undefined
|
|
405
|
+
points?: string | undefined
|
|
406
|
+
pathLength?: number | string | undefined
|
|
407
|
+
fill?: string | undefined
|
|
408
|
+
'fill-opacity'?: number | string | undefined
|
|
409
|
+
'fill-rule'?: 'nonzero' | 'evenodd' | 'inherit' | undefined
|
|
410
|
+
stroke?: string | undefined
|
|
411
|
+
'stroke-width'?: number | string | undefined
|
|
412
|
+
'stroke-linecap'?: 'butt' | 'round' | 'square' | 'inherit' | undefined
|
|
413
|
+
'stroke-linejoin'?: 'miter' | 'round' | 'bevel' | 'inherit' | undefined
|
|
414
|
+
'stroke-miterlimit'?: number | string | undefined
|
|
415
|
+
'stroke-dasharray'?: number | string | undefined
|
|
416
|
+
'stroke-dashoffset'?: number | string | undefined
|
|
417
|
+
'stroke-opacity'?: number | string | undefined
|
|
418
|
+
opacity?: number | string | undefined
|
|
419
|
+
color?: string | undefined
|
|
420
|
+
transform?: string | undefined
|
|
421
|
+
'transform-origin'?: string | undefined
|
|
422
|
+
'clip-path'?: string | undefined
|
|
423
|
+
'clip-rule'?: 'nonzero' | 'evenodd' | 'inherit' | undefined
|
|
424
|
+
mask?: string | undefined
|
|
425
|
+
filter?: string | undefined
|
|
426
|
+
'pointer-events'?: string | undefined
|
|
427
|
+
'vector-effect'?: string | undefined
|
|
428
|
+
'shape-rendering'?: string | undefined
|
|
429
|
+
'text-anchor'?: 'start' | 'middle' | 'end' | 'inherit' | undefined
|
|
430
|
+
'dominant-baseline'?: string | undefined
|
|
431
|
+
'font-family'?: string | undefined
|
|
432
|
+
'font-size'?: number | string | undefined
|
|
433
|
+
'font-weight'?: number | string | undefined
|
|
434
|
+
'letter-spacing'?: number | string | undefined
|
|
133
435
|
href?: string | undefined
|
|
134
|
-
|
|
436
|
+
'xlink:href'?: string | undefined
|
|
437
|
+
target?: string | undefined
|
|
438
|
+
offset?: number | string | undefined
|
|
439
|
+
'stop-color'?: string | undefined
|
|
440
|
+
'stop-opacity'?: number | string | undefined
|
|
441
|
+
gradientUnits?: string | undefined
|
|
442
|
+
gradientTransform?: string | undefined
|
|
443
|
+
spreadMethod?: string | undefined
|
|
444
|
+
patternUnits?: string | undefined
|
|
445
|
+
patternContentUnits?: string | undefined
|
|
446
|
+
patternTransform?: string | undefined
|
|
447
|
+
clipPathUnits?: string | undefined
|
|
448
|
+
maskUnits?: string | undefined
|
|
449
|
+
maskContentUnits?: string | undefined
|
|
450
|
+
markerWidth?: number | string | undefined
|
|
451
|
+
markerHeight?: number | string | undefined
|
|
452
|
+
refX?: number | string | undefined
|
|
453
|
+
refY?: number | string | undefined
|
|
454
|
+
orient?: number | string | undefined
|
|
455
|
+
'marker-start'?: string | undefined
|
|
456
|
+
'marker-mid'?: string | undefined
|
|
457
|
+
'marker-end'?: string | undefined
|
|
458
|
+
in?: string | undefined
|
|
459
|
+
in2?: string | undefined
|
|
460
|
+
result?: string | undefined
|
|
461
|
+
stdDeviation?: number | string | undefined
|
|
462
|
+
mode?: string | undefined
|
|
463
|
+
operator?: string | undefined
|
|
135
464
|
type?: string | undefined
|
|
136
|
-
|
|
465
|
+
values?: string | undefined
|
|
466
|
+
'flood-color'?: string | undefined
|
|
467
|
+
'flood-opacity'?: number | string | undefined
|
|
468
|
+
scale?: number | string | undefined
|
|
469
|
+
surfaceScale?: number | string | undefined
|
|
470
|
+
specularConstant?: number | string | undefined
|
|
471
|
+
specularExponent?: number | string | undefined
|
|
472
|
+
attributeName?: string | undefined
|
|
473
|
+
from?: number | string | undefined
|
|
474
|
+
to?: number | string | undefined
|
|
475
|
+
dur?: string | undefined
|
|
476
|
+
repeatCount?: number | string | undefined
|
|
477
|
+
begin?: string | undefined
|
|
478
|
+
end?: string | undefined
|
|
479
|
+
keyTimes?: string | undefined
|
|
480
|
+
keySplines?: string | undefined
|
|
481
|
+
calcMode?: string | undefined
|
|
482
|
+
focusable?: 'true' | 'false' | 'auto' | boolean | undefined
|
|
483
|
+
// Refuse React's camelCase SVG spellings in types too (SVG attributes are case-sensitive).
|
|
484
|
+
strokeWidth?: never
|
|
485
|
+
strokeLinecap?: never
|
|
486
|
+
strokeLinejoin?: never
|
|
487
|
+
fillOpacity?: never
|
|
488
|
+
fillRule?: never
|
|
489
|
+
clipPath?: never
|
|
490
|
+
clipRule?: never
|
|
491
|
+
xlinkHref?: never
|
|
137
492
|
}
|
|
138
493
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
property?: string | undefined
|
|
142
|
-
content?: string | undefined
|
|
143
|
-
charSet?: string | undefined
|
|
144
|
-
charset?: string | undefined
|
|
145
|
-
}
|
|
494
|
+
// Tags shared by HTML and SVG keep their HTML definitions (already typed above), while SVG-only tags get SVGAttributes.
|
|
495
|
+
type SvgOnlyTagName = Exclude<keyof SVGElementTagNameMap, keyof HTMLElementTagNameMap>
|
|
146
496
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
type?: string | undefined
|
|
150
|
-
async?: boolean | undefined
|
|
151
|
-
defer?: boolean | undefined
|
|
152
|
-
nonce?: string | undefined
|
|
497
|
+
type SvgIntrinsicElements = {
|
|
498
|
+
[K in SvgOnlyTagName]: SVGAttributes<SVGElementTagNameMap[K]>
|
|
153
499
|
}
|
|
154
500
|
|
|
155
501
|
export namespace JSX {
|
|
156
502
|
export type Element = KayChild
|
|
503
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
504
|
+
export type ElementType = keyof IntrinsicElements | ((props: any) => KayChild | Promise<KayChild>)
|
|
157
505
|
export interface IntrinsicAttributes {
|
|
158
506
|
key?: string | number | undefined
|
|
159
507
|
$hydrate?: HydrateStrategy | undefined
|
|
@@ -161,16 +509,7 @@ export namespace JSX {
|
|
|
161
509
|
export interface ElementChildrenAttribute {
|
|
162
510
|
children: object
|
|
163
511
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
input: InputAttributes
|
|
168
|
-
form: FormAttributes
|
|
169
|
-
img: ImageAttributes
|
|
170
|
-
label: LabelAttributes
|
|
171
|
-
link: LinkAttributes
|
|
172
|
-
meta: MetaAttributes
|
|
173
|
-
script: ScriptAttributes
|
|
174
|
-
[tag: string]: CommonAttributes
|
|
175
|
-
}
|
|
512
|
+
/** Augment this interface via `declare module 'kay/jsx-runtime'` to register custom elements (`<my-widget>`). */
|
|
513
|
+
export interface CustomElements {}
|
|
514
|
+
export interface IntrinsicElements extends HtmlIntrinsicElements, SvgIntrinsicElements, CustomElements {}
|
|
176
515
|
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Per-build / per-server scoped runtime context (AsyncLocalStorage-backed, zero mutable process globals).
|
|
2
|
+
|
|
3
|
+
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
4
|
+
|
|
5
|
+
export interface ActiveI18nConfig {
|
|
6
|
+
readonly locales: readonly string[]
|
|
7
|
+
readonly defaultLocale: string
|
|
8
|
+
readonly prefixDefault: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const I18N_CONFIG_SERVICE = 'kay.i18n.config'
|
|
12
|
+
|
|
13
|
+
export interface ContentImageResult {
|
|
14
|
+
src: string
|
|
15
|
+
srcset?: string | undefined
|
|
16
|
+
avifSrcset?: string | undefined
|
|
17
|
+
sizes?: string | undefined
|
|
18
|
+
width?: number | undefined
|
|
19
|
+
height?: number | undefined
|
|
20
|
+
loading?: 'lazy' | 'eager' | undefined
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type ContentImageResolver = (src: string, file: string | undefined) => ContentImageResult | string | undefined
|
|
24
|
+
|
|
25
|
+
export const CONTENT_IMAGE_RESOLVER_SERVICE = 'kay.content.imageResolver'
|
|
26
|
+
|
|
27
|
+
export interface AppRuntimeContext {
|
|
28
|
+
readonly root: string
|
|
29
|
+
readonly outDir: string
|
|
30
|
+
readonly publicDir: string
|
|
31
|
+
readonly assetPrefix: string
|
|
32
|
+
readonly site?: string | undefined
|
|
33
|
+
readonly dev: boolean
|
|
34
|
+
provide<T>(key: string, value: T): void
|
|
35
|
+
inject<T>(key: string): T | undefined
|
|
36
|
+
registerPublicFile(relPath: string): void
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface CreateAppContextOptions {
|
|
40
|
+
root: string
|
|
41
|
+
outDir: string
|
|
42
|
+
publicDir: string
|
|
43
|
+
assetPrefix: string
|
|
44
|
+
site?: string | undefined
|
|
45
|
+
dev: boolean
|
|
46
|
+
onRegisterPublicFile?: ((relPath: string) => void) | undefined
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const APP_STORAGE_KEY = Symbol.for('kay.app.storage')
|
|
50
|
+
const appStorage: AsyncLocalStorage<AppRuntimeContext> = (
|
|
51
|
+
(globalThis as Record<symbol, AsyncLocalStorage<AppRuntimeContext> | undefined>)[APP_STORAGE_KEY]
|
|
52
|
+
??= new AsyncLocalStorage<AppRuntimeContext>()
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
export function createAppContext(options: CreateAppContextOptions): AppRuntimeContext {
|
|
56
|
+
const services = new Map<string, unknown>()
|
|
57
|
+
const site = options.site?.replace(/\/$/, '')
|
|
58
|
+
return {
|
|
59
|
+
root: options.root,
|
|
60
|
+
outDir: options.outDir,
|
|
61
|
+
publicDir: options.publicDir,
|
|
62
|
+
assetPrefix: options.assetPrefix,
|
|
63
|
+
...(site !== undefined && site !== '' ? { site } : {}),
|
|
64
|
+
dev: options.dev,
|
|
65
|
+
provide<T>(key: string, value: T): void {
|
|
66
|
+
services.set(key, value)
|
|
67
|
+
},
|
|
68
|
+
inject<T>(key: string): T | undefined {
|
|
69
|
+
return services.get(key) as T | undefined
|
|
70
|
+
},
|
|
71
|
+
registerPublicFile(relPath: string): void {
|
|
72
|
+
options.onRegisterPublicFile?.(relPath)
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function runWithAppContext<T>(ctx: AppRuntimeContext, fn: () => T): T {
|
|
78
|
+
return appStorage.run(ctx, fn)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function getAppContext(): AppRuntimeContext | undefined {
|
|
82
|
+
return appStorage.getStore()
|
|
83
|
+
}
|