@orieljs/live 0.1.0-alpha.10

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.
@@ -0,0 +1,519 @@
1
+ import * as _orieljs_contracts from '@orieljs/contracts';
2
+ import { Class, RouteName, RouteArguments, Rules, InferValidatedType, MessageBag, LiveEffects, Htmlable, LiveSnapshot, LiveManager, Application, HttpRequest, LiveUpdateRequest, LiveUpdateResponse, OrielError, ErrorKind, UploadedFile, MiddlewareClass, Router } from '@orieljs/contracts';
3
+ import { ServiceProvider } from '@orieljs/support';
4
+
5
+ /** Marks Live component classes (Symbol.for, so two copies of the package agree). */
6
+ declare const COMPONENT: unique symbol;
7
+ /** A browser event queued by dispatch(). `to` is resolved to a component name when the effects are built. */
8
+ interface QueuedDispatch {
9
+ name: string;
10
+ params: Record<string, unknown>;
11
+ self?: true;
12
+ to?: string | Class<Component>;
13
+ }
14
+ /** The validation errors of a component (Laravel's MessageBag), for render(): `this.errors.first('title')`. */
15
+ declare class ErrorBag implements MessageBag {
16
+ #private;
17
+ private readonly messages;
18
+ constructor(messages: Record<string, string[]>);
19
+ /** Adds to the component's errors, as addError() does. */
20
+ add(key: string, message: string): void;
21
+ has(key: string): boolean;
22
+ first(key?: string): string | undefined;
23
+ get(key: string): string[];
24
+ all(): string[];
25
+ any(): boolean;
26
+ isEmpty(): boolean;
27
+ count(): number;
28
+ toObject(): Record<string, string[]>;
29
+ }
30
+ /** What dispatch() returns: `this.dispatch('saved').self()` or `.to(Sidebar)`. */
31
+ declare class PendingEvent {
32
+ private readonly event;
33
+ constructor(event: QueuedDispatch);
34
+ /** Only this component's own listeners receive the event. */
35
+ self(): this;
36
+ /** Only components of this class (or registered name) receive the event. */
37
+ to(component: string | Class<Component>): this;
38
+ }
39
+ /**
40
+ * A Live component (Livewire 3): public fields are its state, public methods are actions the browser can call, and
41
+ * render() returns its TSX. Lifecycle hooks, all optional: `boot()`, `mount(params)`, `hydrate()`, `dehydrate()`,
42
+ * `updating(name, value)`/`updated(name, value)` and per property `updatingTitle(value)`/`updatedTitle(value)`,
43
+ * `rendering()`/`rendered(html)`. Fields that must not be state use `#private` syntax.
44
+ */
45
+ declare abstract class Component {
46
+ static readonly [COMPONENT] = true;
47
+ /** The view that wraps a full-page component (default: config `live.layout`). */
48
+ static layout?: string;
49
+ /** The page title passed to the layout as `title`. */
50
+ static title?: string;
51
+ /**
52
+ * Livewire's #[Lazy]: every embed (and the full page) renders the placeholder first and mounts once the browser shows
53
+ * it. `<Live component={…} lazy={false} />` mounts one at once. The placeholder is the component's
54
+ * `placeholder(params)` method (TSX), else the `live.lazy_placeholder` view, else an empty `<div>`: give it the root
55
+ * element the component renders.
56
+ */
57
+ static lazy?: boolean;
58
+ /** Static fallbacks for runtimes without decorators: { event: 'method' }, locked names, computed getter names. */
59
+ static listeners?: Record<string, string>;
60
+ static locked?: string[];
61
+ static computed?: string[];
62
+ abstract render(): unknown;
63
+ getId(): string;
64
+ getName(): string;
65
+ /** Dispatches a browser event; every component listening for it (@On) runs its handler. */
66
+ dispatch(name: string, params?: Record<string, unknown>): PendingEvent;
67
+ /** Sends the browser to `url` after this request; `navigate` uses o:navigate instead of a full page load. */
68
+ redirect(url: string, options?: {
69
+ navigate?: boolean;
70
+ }): void;
71
+ /**
72
+ * redirect() to a named route: `this.redirectRoute('posts.show', post, { navigate: true })`. Once `oriel
73
+ * route:types` has run, the name and the route's parameters are checked, as route()'s are.
74
+ */
75
+ redirectRoute<N extends RouteName>(name: N, ...args: RouteArguments<N, [options?: {
76
+ navigate?: boolean;
77
+ }]>): void;
78
+ /**
79
+ * Validates the public state. On success clears the error bag and returns the validated data, typed from the rules
80
+ * (`await this.validate({ title: 'required|string' })` is `{ title: string }`); on failure fills the error bag and
81
+ * throws (the rest of the action is skipped and the component re-renders with `errors`).
82
+ */
83
+ validate<const R extends Rules>(rules: R, messages?: Record<string, string>, attributes?: Record<string, string>): Promise<InferValidatedType<R>>;
84
+ addError(key: string, message: string): void;
85
+ /** Clears every error, or only those of `keys`. */
86
+ resetErrorBag(...keys: string[]): void;
87
+ get errors(): ErrorBag;
88
+ /** Puts public properties (all of them when none are named) back to their initial values. */
89
+ reset(...properties: string[]): void;
90
+ /** Keeps the current HTML: the response carries the new state but no `html` effect. */
91
+ skipRender(): void;
92
+ /**
93
+ * An action for an `o:` directive, typed against its method: `o:click={this.$action(this.delete, tag.id)}` writes
94
+ * `delete(5)`, and a string where `delete` takes a number is a type error. The arguments are written as JSON, the
95
+ * trailing `undefined` ones left out so the method's defaults apply. The method must be one of this component's
96
+ * actions (a public method of its class, not a hook and not @Locked); anything else throws while rendering.
97
+ */
98
+ $action<P extends unknown[]>(method: (...params: P) => unknown, ...params: NoInfer<P>): string;
99
+ /** A full-page component as a route action: Route.get('/counter', Counter). Route parameters go to mount(). */
100
+ __invoke(): Promise<unknown>;
101
+ }
102
+
103
+ /** @On('post-created'): calls the method when the event is dispatched (by this or any component, or the browser). */
104
+ declare function On(event: string): (_method: unknown, context: ClassMethodDecoratorContext) => void;
105
+ /** @Locked: a property the browser can't change, or a method the browser can't call. */
106
+ declare function Locked(_target: unknown, context: ClassFieldDecoratorContext | ClassMethodDecoratorContext): void;
107
+ /** @Computed: a getter cached for the rest of the request, never part of the component's state. */
108
+ declare function Computed<T>(getter: (this: object) => T, context: ClassGetterDecoratorContext): (this: object) => T;
109
+
110
+ /**
111
+ * Runs Live.test()'s mount and each update. The testing package binds one for every test, so they run in a request
112
+ * scope like the test's HTTP requests (a request, the carried session, actingAs users) and what they change carries
113
+ * on to the next request. Without one they run in the current scope.
114
+ */
115
+ type TestRequestScope = <T>(run: () => Promise<T>) => Promise<T>;
116
+ declare const TestRequestScope: _orieljs_contracts.Token<TestRequestScope>;
117
+ /**
118
+ * Livewire's Livewire::test(): drives one component through the real mount → snapshot → checksum → update pipeline
119
+ * (no HTTP), inside the test's request scope. Actions are async (`await counter.call('increment')`); assertions are
120
+ * sync and return `this`.
121
+ */
122
+ declare class Testable<C extends Component = Component> {
123
+ #private;
124
+ private readonly manager;
125
+ private readonly scope;
126
+ private constructor();
127
+ /**
128
+ * Mounts `component` with `params`, as `<Live component={…} {...params} />` would. A lazy component mounts at once
129
+ * (Livewire's withoutLazyLoading()); `{ lazy: true }` renders its placeholder, and `call('__lazyLoad', …)` loads it.
130
+ */
131
+ static create<C extends Component>(component: Class<C> | string, params?: Record<string, unknown>): Promise<Testable<C>>;
132
+ /** The component instance after the last request. */
133
+ instance(): C;
134
+ /** A public property (dotted paths reach into arrays and objects). */
135
+ get<T = unknown>(path: string): T;
136
+ /** The last rendered HTML, without the o:id, o:snapshot and o:effects attributes (Livewire strips them too). */
137
+ html(): string;
138
+ /** The effects of the last request. */
139
+ effects(): LiveEffects;
140
+ /**
141
+ * Sets public properties through an update. A file (a FakeFile) or an array of files is uploaded as `o:model` on a
142
+ * file input does it: the upload rules, the temporary disk, then a TemporaryUploadedFile (or an array) in the
143
+ * property, or the upload's errors on it (Livewire's).
144
+ */
145
+ set(path: string | Record<string, unknown>, value?: unknown): Promise<this>;
146
+ /** Uploads `files` into the property `name` (an array when `multiple`), as the browser's upload calls do. */
147
+ upload(name: string, files: readonly Blob[], multiple?: boolean): Promise<this>;
148
+ call(method: string, ...params: unknown[]): Promise<this>;
149
+ toggle(path: string): Promise<this>;
150
+ /** Dispatches an event to this component, as the browser does for its listeners. */
151
+ dispatch(event: string, params?: Record<string, unknown>): Promise<this>;
152
+ refresh(): Promise<this>;
153
+ assertSet(path: string, value: unknown): this;
154
+ assertNotSet(path: string, value: unknown): this;
155
+ /** Each value, HTML-escaped, appears in the rendered HTML. */
156
+ assertSee(...values: string[]): this;
157
+ assertDontSee(...values: string[]): this;
158
+ /** Each value appears in the rendered HTML as written (not escaped). */
159
+ assertSeeHtml(...values: string[]): this;
160
+ /** Each value, HTML-escaped, appears in the rendered text: the HTML with its tags stripped (Livewire's assertSeeText). */
161
+ assertSeeText(...values: string[]): this;
162
+ assertDontSeeText(...values: string[]): this;
163
+ assertDispatched(name: string, params?: Record<string, unknown>): this;
164
+ assertNotDispatched(name: string): this;
165
+ /** The error bag has errors for every key given (or any error at all with no keys). */
166
+ assertHasErrors(keys?: string | string[]): this;
167
+ /** No errors for the keys given (or none at all with no keys). */
168
+ assertHasNoErrors(keys?: string | string[]): this;
169
+ assertRedirect(url?: string): this;
170
+ assertNoRedirect(): this;
171
+ /** The last call returned `value`. */
172
+ assertReturned(value: unknown): this;
173
+ }
174
+
175
+ /** Props of `<Live component={Counter} count={3} o:key="c1" />`: the rest become mount params. */
176
+ interface LiveProps {
177
+ component: Class<Component> | string;
178
+ /** Identifies a child inside its parent across re-renders (Livewire's :key / wire:key). */
179
+ 'o:key'?: string | number;
180
+ /**
181
+ * Renders the placeholder and mounts the component once it scrolls into view (`'on-load'`: once the page starts);
182
+ * `false` mounts a `static lazy` component at once.
183
+ */
184
+ lazy?: boolean | 'on-load';
185
+ [param: string]: unknown;
186
+ }
187
+ /** Blade's @livewire('counter', ['count' => 3], key('c1')): the component's first render, as trusted HTML. */
188
+ declare function live(component: Class<Component> | string, params?: Record<string, unknown>, key?: string | number): Promise<Htmlable>;
189
+ /** `<Live component={Counter} />` in any view or component. */
190
+ declare function LiveComponent({ component, 'o:key': key, children: _children, ...params }: LiveProps): Promise<Htmlable>;
191
+ /** The `<Live />` element, and the Live facade: Live.component(name, Class), Live.test(Component). */
192
+ declare const Live: typeof LiveComponent & {
193
+ /** Registers a component under a name (components in app/Live are registered at boot). */
194
+ component(name: string, component: Class<Component>): void;
195
+ /** Livewire::test(): mounts `component` for assertions. */
196
+ test<C extends Component>(component: Class<C> | string, params?: Record<string, unknown>): Promise<Testable<C>>;
197
+ };
198
+
199
+ type Call = {
200
+ method: string;
201
+ params: unknown[];
202
+ };
203
+ /** One component after a mount or an update: the live instance (for Live.test), its snapshot, effects and HTML. */
204
+ interface ComponentResult {
205
+ instance: Component;
206
+ snapshot: LiveSnapshot;
207
+ effects: LiveEffects;
208
+ /** The rendered HTML with o:id (and, after a mount, o:snapshot/o:effects); undefined after skipRender(). */
209
+ html?: string;
210
+ tag?: string;
211
+ }
212
+ /** Livewire's update request handling and first render, on Oriel's contracts. */
213
+ declare class LiveComponentManager implements LiveManager {
214
+ private readonly app;
215
+ constructor(app: Application);
216
+ /** The request scope when there is one (sessions, the current route), else the application. */
217
+ private container;
218
+ private registry;
219
+ /** Live.component('counter', Counter): registers a component under a name the snapshots use. */
220
+ register(component: Class<unknown>, name?: string): void;
221
+ /** The registered name of a component class, registering it under its kebab-case class name the first time. */
222
+ nameOf(component: Class<Component>): string;
223
+ resolve(name: string): Class<Component>;
224
+ isLiveRequest(request: HttpRequest): boolean;
225
+ /** The first render: HTML with o:id, o:snapshot and o:effects on the root element. */
226
+ mount(component: string | Class<unknown>, params?: Record<string, unknown>, key?: string): Promise<string>;
227
+ /**
228
+ * Mounts a component: boot(), the params into its properties, mount(params), then its first render. A lazy one
229
+ * (`lazy` in the params, or `static lazy`) renders its placeholder instead and mounts when the browser loads it.
230
+ */
231
+ mountComponent(component: string | Class<unknown>, embedParams?: Record<string, unknown>, existing?: Component): Promise<ComponentResult>;
232
+ /**
233
+ * A lazy component's first render (Livewire's): its placeholder, with the state it has before mount() and the mount
234
+ * params signed for the `__lazyLoad` call the browser makes when it shows it (`o:lazy`, or `o:lazy-on-load`).
235
+ */
236
+ private mountPlaceholder;
237
+ /** Applies each component's updates and calls, re-renders it and returns its new snapshot and effects. */
238
+ update(request: LiveUpdateRequest): Promise<LiveUpdateResponse>;
239
+ updateComponent(snapshotJson: string, updates: Record<string, unknown>, calls: Call[]): Promise<ComponentResult>;
240
+ /**
241
+ * The mount params and placeholder tag of a `__lazyLoad` request, or undefined for any other update. The load comes
242
+ * alone (no updates, no other call: the browser sends it in a request of its own) and its payload must be the one
243
+ * signed for this component: anything else is refused as corrupt (a 403) before the component boots.
244
+ */
245
+ private lazyLoad;
246
+ /**
247
+ * The route action of POST /oriel/live/update. Each component's update runs behind the persistent middleware of the
248
+ * route that rendered its page (Livewire's): `auth`, `verified`, `guest` and `can`, with the page route's parameters
249
+ * bound again. A signed-out tab gets a 401, a revoked ability a 403 and a deleted model a 404, before the component
250
+ * hydrates. When a middleware answers instead (a redirect), that is the response. A key first flashed during the
251
+ * update shows in this response only, unless the update redirects.
252
+ */
253
+ handle(request: HttpRequest): Promise<LiveUpdateResponse | Response>;
254
+ /** A full-page component (Route.get('/counter', Counter)): mounted with the route parameters, inside the layout. */
255
+ page(component: Component): Promise<unknown>;
256
+ /** Parses and checks a snapshot: a bad checksum throws before anything is hydrated. */
257
+ private verify;
258
+ private key;
259
+ /** The request body, read from the raw JSON when the request has it, so TrimStrings can't alter typed values. */
260
+ private payload;
261
+ /** Makes every computed getter (static `computed` too) cache its value for the rest of the request. */
262
+ private prepareComputed;
263
+ private applyUpdate;
264
+ /** Runs one call from the browser: a magic action, an event, an upload call, or a public method. Returns its return value. */
265
+ private call;
266
+ /**
267
+ * Renders the component (rendering/rendered hooks, nested children tracked) and checks for a single root. A
268
+ * WithPagination component's page and page URL are what paginate() reads while it renders, as in its mount() and in
269
+ * its update's hooks and actions.
270
+ */
271
+ private render;
272
+ /** The absolute URL of the page a memo path belongs to, on the current request's origin ('/' + path without one). */
273
+ private pageUrl;
274
+ /** Dispatches, redirects: the effects every response carries. */
275
+ private effects;
276
+ /** dehydrate() hook, then the state as snapshot data, the error bag, and the checksum over both. */
277
+ private snapshot;
278
+ }
279
+
280
+ /** The URI the client runtime posts updates to. */
281
+ declare const UPDATE_URI = "/oriel/live/update";
282
+ /**
283
+ * Binds the LiveManager and the PaginationState that WithPagination components answer, merges the `live` config,
284
+ * registers POST /oriel/live/update (named `live.update`, in the `web` group: sessions and CSRF apply), the upload and
285
+ * preview routes of WithFileUploads (`live.upload-file`, `live.preview-file`), the make:live command, and the
286
+ * components under app/Live.
287
+ */
288
+ declare class LiveServiceProvider extends ServiceProvider {
289
+ register(): void;
290
+ boot(): Promise<void>;
291
+ }
292
+
293
+ /** A component's Livewire name from its path under app/Live: Posts/CreatePost.tsx → posts.create-post. */
294
+ declare function componentName(file: string): string;
295
+ /** Component files under `directory` (recursive), relative paths with `/`. Test and declaration files are skipped. */
296
+ declare function componentFiles(directory: string): string[];
297
+
298
+ /**
299
+ * What the browser may do with a component class, for editors (`oriel ide:info`): the actions it may call and the
300
+ * properties it may set, each sorted. The instance is built as mounting builds one, and none of its hooks run.
301
+ */
302
+ declare function describeComponent(cls: new () => Component): {
303
+ actions: string[];
304
+ properties: string[];
305
+ };
306
+
307
+ /** A Live programming error (unsupported state, a missing root element, an unknown component): a 500. */
308
+ declare class LiveError extends Error implements OrielError {
309
+ readonly name: string;
310
+ readonly kind: ErrorKind;
311
+ readonly status: number;
312
+ }
313
+ /** A snapshot whose checksum doesn't match (tampered with, or signed with another APP_KEY). Nothing is hydrated. */
314
+ declare class CorruptComponentPayloadError extends LiveError {
315
+ readonly name: string;
316
+ readonly kind: ErrorKind;
317
+ readonly status: number;
318
+ constructor(component?: string);
319
+ }
320
+ /** The browser asked for a method that isn't a public action of the component. */
321
+ declare class MethodNotCallableError extends LiveError {
322
+ readonly name: string;
323
+ readonly kind: ErrorKind;
324
+ readonly status: number;
325
+ constructor(method: string, component: string);
326
+ }
327
+ /** The browser tried to set a property that is locked, computed, private (`_x`) or not declared. */
328
+ declare class PropertyNotUpdatableError extends LiveError {
329
+ readonly name: string;
330
+ readonly kind: ErrorKind;
331
+ readonly status: number;
332
+ constructor(path: string, component: string);
333
+ }
334
+ /** A snapshot names a component that isn't registered. */
335
+ declare class LiveComponentNotFoundError extends LiveError {
336
+ readonly name: string;
337
+ readonly kind: ErrorKind;
338
+ readonly status: number;
339
+ constructor(component: string);
340
+ }
341
+ /** An update request without the X-Oriel-Live header or with a malformed body. */
342
+ declare class InvalidLiveRequestError extends LiveError {
343
+ readonly name: string;
344
+ readonly kind: ErrorKind;
345
+ readonly status: number;
346
+ }
347
+ /** An upload or preview URL whose signature is missing, wrong or expired (Livewire's 401). Nothing is read or stored. */
348
+ declare class InvalidUploadSignatureError extends LiveError {
349
+ readonly name: string;
350
+ readonly kind: ErrorKind;
351
+ readonly status: number;
352
+ constructor();
353
+ }
354
+ /** A preview of a temporary upload that is no longer on the disk (cleaned up, or stored and deleted). */
355
+ declare class TemporaryFileNotFoundError extends LiveError {
356
+ readonly name: string;
357
+ readonly kind: ErrorKind;
358
+ readonly status: number;
359
+ constructor(filename: string);
360
+ }
361
+ /** temporaryUrl() on an upload whose type has no preview (live.temporary_file_upload.preview_mimes). */
362
+ declare class FileNotPreviewableError extends LiveError {
363
+ readonly name: string;
364
+ constructor(extension: string);
365
+ }
366
+ /** The errors an upload came back with (`_uploadErrored`): the component re-renders with them on the property. */
367
+ declare class UploadValidationError extends LiveError {
368
+ readonly errors: Record<string, string[]>;
369
+ readonly name: string;
370
+ readonly kind: ErrorKind;
371
+ readonly status: number;
372
+ readonly errorBag: string;
373
+ constructor(errors: Record<string, string[]>);
374
+ }
375
+
376
+ /**
377
+ * Livewire's `temporary_file_upload` settings, read from config `live.temporary_file_upload.*` (each one falls back on
378
+ * its own): the disk (the default filesystem disk), the directory on it, the rules every upload must pass, the upload
379
+ * route's middleware, the types a preview is served for, how long an upload URL lasts (minutes), and whether a finished
380
+ * upload removes the temporary files older than a day.
381
+ */
382
+ declare const TEMPORARY_UPLOAD_DEFAULTS: {
383
+ disk: string | null;
384
+ directory: string;
385
+ rules: string | string[];
386
+ middleware: string | string[];
387
+ preview_mimes: string[];
388
+ max_upload_time: number;
389
+ cleanup: boolean;
390
+ };
391
+ /** What a temporary upload is: its stored name on the temporary disk and what the browser sent (signed with it). */
392
+ interface TemporaryFileData {
393
+ /** A random 40-character name with the extension its bytes showed: `live-tmp/<filename>` on the temporary disk. */
394
+ filename: string;
395
+ /** The name the browser gave the file. */
396
+ name: string;
397
+ size: number;
398
+ /** The MIME type the browser claimed. */
399
+ type: string;
400
+ /** The extension of the upload's own type (its bytes, else a plain claimed extension), or ''. */
401
+ extension: string;
402
+ }
403
+ /**
404
+ * Livewire's TemporaryUploadedFile: a file the browser uploaded to the temporary directory before an action stores
405
+ * it. A WithFileUploads component's property holds one (or an array of them) once `o:model` on a file input has
406
+ * uploaded it: validate it like any upload (`'photo' => 'image|max:1024'`), preview it with `temporaryUrl()`, then
407
+ * `store()` it. It travels in the component's snapshot as its data, signed with the rest.
408
+ */
409
+ declare class TemporaryUploadedFile implements UploadedFile {
410
+ #private;
411
+ readonly filename: string;
412
+ readonly clientName: string;
413
+ readonly mimeType: string;
414
+ readonly size: number;
415
+ constructor(data: TemporaryFileData);
416
+ /** What the snapshot carries. */
417
+ toData(): TemporaryFileData;
418
+ /** The file's path on the temporary disk. */
419
+ get path(): string;
420
+ /** The extension of the upload's own type, as FormUploadedFile's extension(): what putFile() names a stored copy by. */
421
+ extension(): string;
422
+ /** The extension of the name the browser gave the file, lower-cased ('' without one). */
423
+ clientExtension(): string;
424
+ /** A random 40-character name with extension(), as FormUploadedFile's. */
425
+ hashName(): string;
426
+ arrayBuffer(): Promise<ArrayBuffer>;
427
+ text(): Promise<string>;
428
+ /** The file's bytes from the temporary disk, opened on the first read. */
429
+ stream(): ReadableStream<Uint8Array>;
430
+ /** Stores a copy under a random name in `directory`, on `disk` (by default the temporary disk, as Livewire's). */
431
+ store(directory: string, disk?: string): Promise<string>;
432
+ storeAs(directory: string, name: string, disk?: string): Promise<string>;
433
+ exists(): Promise<boolean>;
434
+ /** Removes the temporary file (a stored copy stays). */
435
+ delete(): Promise<boolean>;
436
+ /** Whether temporaryUrl() serves this file: its type is in `live.temporary_file_upload.preview_mimes`. */
437
+ isPreviewable(): boolean;
438
+ /**
439
+ * A signed link to the file for `<img src>` or `<video src>` before it is stored. It lasts until the end of the hour
440
+ * at least 30 minutes away (Livewire's), so a re-render keeps the same link and the browser doesn't reload it.
441
+ */
442
+ temporaryUrl(): string;
443
+ }
444
+
445
+ /** Where the browser POSTs a WithFileUploads component's files (Livewire's /livewire/upload-file), named live.upload-file. */
446
+ declare const UPLOAD_URI = "/oriel/live/upload-file";
447
+ /** Where temporaryUrl() links lead (Livewire's /livewire/preview-file/{filename}), named live.preview-file. */
448
+ declare const PREVIEW_URI = "/oriel/live/preview-file";
449
+
450
+ /** The route middleware an update re-applies by default (config live.persistent_middleware), by alias. */
451
+ declare const PERSISTENT_MIDDLEWARE: string[];
452
+ /** A route middleware after alias and group expansion: 'auth:web' → { cls: Authenticate, parameters: ['web'] }. */
453
+ interface PersistentMiddleware {
454
+ readonly cls: MiddlewareClass;
455
+ readonly parameters: readonly string[];
456
+ }
457
+ /**
458
+ * Livewire's persistent middleware: the middleware among `persistent` (aliases) that the page route (the component's
459
+ * memo path and method) ran, in the order an update runs them. A path no route matches has none.
460
+ */
461
+ declare function persistentMiddleware(router: Router, persistent: readonly string[], method: string, path: string): PersistentMiddleware[];
462
+
463
+ type ComponentConstructor = abstract new (...args: any[]) => Component;
464
+ /** What WithPagination() adds to a component: its page and the actions that move it. */
465
+ interface Paginated {
466
+ /** The current page. The browser may set it; Live reads it as a page number. */
467
+ page: number;
468
+ nextPage(): Promise<void>;
469
+ previousPage(): Promise<void>;
470
+ gotoPage(page: number | string): Promise<void>;
471
+ resetPage(): Promise<void>;
472
+ setPage(page: number | string): Promise<void>;
473
+ }
474
+ /**
475
+ * Livewire's WithPagination: `class Posts extends WithPagination(Component)`. The public `page` (1 to start; there
476
+ * is no address-bar sync) is what `paginate()` shows in the component (in `render()`, `mount()`, `hydrate()`, the
477
+ * update hooks and actions, or in a `@Computed` getter any of them reads), and its page links are built on the
478
+ * page's URL. The actions move it: `o:click="nextPage"`, `previousPage`, `gotoPage(3)`, `setPage(3)`,
479
+ * `resetPage` (call it from `updatedSearch()` so a new search starts on page 1). `updatingPage(page)` and
480
+ * `updatedPage(page)` run around every change. One paginator per component: other page names read the request.
481
+ */
482
+ declare function WithPagination<TBase extends ComponentConstructor>(Base: TBase): TBase & (abstract new (...args: any[]) => Paginated);
483
+
484
+ /**
485
+ * Livewire's WithFileUploads: `class Profile extends WithFileUploads(Component)`. A file input with `o:model="photo"`
486
+ * uploads the file to the temporary directory as soon as it is picked, then sets `photo` to a TemporaryUploadedFile
487
+ * (`<input type="file" multiple>` sets an array), through `updatingPhoto()`/`updatedPhoto()` like any update. Validate
488
+ * it with the file rules, preview it with `temporaryUrl()`, store it with `store()`.
489
+ */
490
+ declare function WithFileUploads<TBase extends ComponentConstructor>(Base: TBase): TBase;
491
+
492
+ /**
493
+ * What <Pagination> reads from a paginator. Structural, since Live can't import Database: paginate()'s
494
+ * LengthAwarePaginator (with lastPage(), so page buttons) and simplePaginate()'s Paginator (Previous and Next only).
495
+ */
496
+ interface PaginationSource {
497
+ currentPage(): number;
498
+ lastPage?(): number;
499
+ hasMorePages(): boolean;
500
+ onFirstPage(): boolean;
501
+ /** Page buttons on each side of the current one (the paginator's onEachSide(), 3 by default). */
502
+ readonly onEachSideCount?: number;
503
+ /** Not cursorPaginate(): its pages are cursors, which a component's page number can't follow. */
504
+ readonly nextCursor?: never;
505
+ }
506
+ interface PaginationProps {
507
+ paginator: PaginationSource;
508
+ /** Classes for the <nav>, such as its layout ("flex gap-2"); in your file, so Tailwind generates them. */
509
+ class?: string;
510
+ }
511
+ /**
512
+ * Livewire's pagination links for a WithPagination component: `<Pagination paginator={posts} />` in render(). A
513
+ * <nav aria-label="Pagination"> with « Previous, the page buttons and Next » as Live actions (previousPage,
514
+ * gotoPage(n), nextPage), the current page marked aria-current="page", the ends disabled, the kits' theme classes
515
+ * (btn, btn-secondary). Nothing when everything fits on one page. The address bar is left alone.
516
+ */
517
+ declare function Pagination({ paginator, class: className }: PaginationProps): Htmlable;
518
+
519
+ export { Component, type ComponentResult, Computed, CorruptComponentPayloadError, ErrorBag, FileNotPreviewableError, InvalidLiveRequestError, InvalidUploadSignatureError, Live, LiveComponentManager, LiveComponentNotFoundError, LiveError, type LiveProps, LiveServiceProvider, Locked, MethodNotCallableError, On, PERSISTENT_MIDDLEWARE, PREVIEW_URI, type Paginated, Pagination, type PaginationProps, type PaginationSource, PendingEvent, type PersistentMiddleware, PropertyNotUpdatableError, TEMPORARY_UPLOAD_DEFAULTS, type TemporaryFileData, TemporaryFileNotFoundError, TemporaryUploadedFile, TestRequestScope, Testable, UPDATE_URI, UPLOAD_URI, UploadValidationError, WithFileUploads, WithPagination, componentFiles, componentName, describeComponent, live, persistentMiddleware };