@alepha/react 0.14.4 → 0.15.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/README.md +10 -0
- package/dist/auth/index.d.ts +4 -4
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +22 -31
- package/dist/auth/index.js.map +1 -1
- package/dist/core/index.d.ts +118 -118
- package/dist/core/index.d.ts.map +1 -1
- package/dist/form/index.d.ts +27 -28
- package/dist/form/index.d.ts.map +1 -1
- package/dist/head/index.d.ts +30 -40
- package/dist/head/index.d.ts.map +1 -1
- package/dist/i18n/index.d.ts +33 -33
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/router/index.d.ts +458 -458
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +22 -31
- package/dist/router/index.js.map +1 -1
- package/dist/websocket/index.d.ts +38 -39
- package/dist/websocket/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/auth/__tests__/$auth.spec.ts +10 -11
- package/src/router/providers/ReactServerProvider.ts +3 -13
- package/src/router/providers/ReactServerTemplateProvider.ts +47 -29
package/dist/core/index.d.ts
CHANGED
|
@@ -43,14 +43,14 @@ declare const ClientOnly: (props: PropsWithChildren<ClientOnlyProps>) => ReactNo
|
|
|
43
43
|
*/
|
|
44
44
|
interface ErrorBoundaryProps {
|
|
45
45
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
* Fallback React node to render when an error is caught.
|
|
47
|
+
* If not provided, a default error message will be shown.
|
|
48
|
+
*/
|
|
49
49
|
fallback: (error: Error) => ReactNode;
|
|
50
50
|
/**
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
* Optional callback that receives the error and error info.
|
|
52
|
+
* Use this to log errors to a monitoring service.
|
|
53
|
+
*/
|
|
54
54
|
onError?: (error: Error, info: ErrorInfo) => void;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
@@ -67,13 +67,13 @@ interface ErrorBoundaryState {
|
|
|
67
67
|
declare class ErrorBoundary extends React.Component<PropsWithChildren<ErrorBoundaryProps>, ErrorBoundaryState> {
|
|
68
68
|
constructor(props: ErrorBoundaryProps);
|
|
69
69
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
* Update state so the next render shows the fallback UI.
|
|
71
|
+
*/
|
|
72
72
|
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
73
73
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
* Lifecycle method called when an error is caught.
|
|
75
|
+
* You can log the error or perform side effects here.
|
|
76
|
+
*/
|
|
77
77
|
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
78
78
|
render(): ReactNode;
|
|
79
79
|
}
|
|
@@ -209,126 +209,126 @@ declare function useAction<Args extends any[], Result = void>(options: UseAction
|
|
|
209
209
|
*/
|
|
210
210
|
interface ActionContext {
|
|
211
211
|
/**
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
212
|
+
* AbortSignal that can be passed to fetch or other async operations.
|
|
213
|
+
* The signal will be aborted when:
|
|
214
|
+
* - The component unmounts
|
|
215
|
+
* - A new action is triggered (cancels previous)
|
|
216
|
+
* - The cancel() method is called
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```tsx
|
|
220
|
+
* const action = useAction({
|
|
221
|
+
* handler: async (url, { signal }) => {
|
|
222
|
+
* const response = await fetch(url, { signal });
|
|
223
|
+
* return response.json();
|
|
224
|
+
* }
|
|
225
|
+
* }, []);
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
228
|
signal: AbortSignal;
|
|
229
229
|
}
|
|
230
230
|
interface UseActionOptions<Args extends any[] = any[], Result = any> {
|
|
231
231
|
/**
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
* The async action handler function.
|
|
233
|
+
* Receives the action arguments plus an ActionContext as the last parameter.
|
|
234
|
+
*/
|
|
235
235
|
handler: (...args: [...Args, ActionContext]) => Async<Result>;
|
|
236
236
|
/**
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
* Custom error handler. If provided, prevents default error re-throw.
|
|
238
|
+
*/
|
|
239
239
|
onError?: (error: Error) => void | Promise<void>;
|
|
240
240
|
/**
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
* Custom success handler.
|
|
242
|
+
*/
|
|
243
243
|
onSuccess?: (result: Result) => void | Promise<void>;
|
|
244
244
|
/**
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
* Optional identifier for this action (useful for debugging/analytics)
|
|
246
|
+
*/
|
|
247
247
|
id?: string;
|
|
248
248
|
name?: string;
|
|
249
249
|
/**
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
250
|
+
* Debounce delay in milliseconds. If specified, the action will only execute
|
|
251
|
+
* after the specified delay has passed since the last call. Useful for search inputs
|
|
252
|
+
* or other high-frequency events.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```tsx
|
|
256
|
+
* // Execute search 300ms after user stops typing
|
|
257
|
+
* const search = useAction({ handler: search, debounce: 300 }, [])
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
260
|
debounce?: number;
|
|
261
261
|
/**
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
262
|
+
* If true, the action will be executed once when the component mounts.
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```tsx
|
|
266
|
+
* const fetchData = useAction({
|
|
267
|
+
* handler: async () => await api.getData(),
|
|
268
|
+
* runOnInit: true
|
|
269
|
+
* }, []);
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
272
|
runOnInit?: boolean;
|
|
273
273
|
/**
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
274
|
+
* If specified, the action will be executed periodically at the given interval.
|
|
275
|
+
* The interval is specified as a DurationLike value (number in ms, Duration object, or [number, unit] tuple).
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* ```tsx
|
|
279
|
+
* // Run every 5 seconds
|
|
280
|
+
* const poll = useAction({
|
|
281
|
+
* handler: async () => await api.poll(),
|
|
282
|
+
* runEvery: 5000
|
|
283
|
+
* }, []);
|
|
284
|
+
* ```
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```tsx
|
|
288
|
+
* // Run every 1 minute
|
|
289
|
+
* const poll = useAction({
|
|
290
|
+
* handler: async () => await api.poll(),
|
|
291
|
+
* runEvery: [1, 'minute']
|
|
292
|
+
* }, []);
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
295
|
runEvery?: DurationLike;
|
|
296
296
|
}
|
|
297
297
|
interface UseActionReturn<Args extends any[], Result> {
|
|
298
298
|
/**
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
299
|
+
* Execute the action with the provided arguments.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```tsx
|
|
303
|
+
* const action = useAction({ handler: async (data) => { ... } }, []);
|
|
304
|
+
* action.run(data);
|
|
305
|
+
* ```
|
|
306
|
+
*/
|
|
307
307
|
run: (...args: Args) => Promise<Result | undefined>;
|
|
308
308
|
/**
|
|
309
|
-
|
|
310
|
-
|
|
309
|
+
* Loading state - true when action is executing.
|
|
310
|
+
*/
|
|
311
311
|
loading: boolean;
|
|
312
312
|
/**
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
* Error state - contains error if action failed, undefined otherwise.
|
|
314
|
+
*/
|
|
315
315
|
error?: Error;
|
|
316
316
|
/**
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
317
|
+
* Cancel any pending debounced action or abort the current in-flight request.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```tsx
|
|
321
|
+
* const action = useAction({ ... }, []);
|
|
322
|
+
*
|
|
323
|
+
* <button onClick={action.cancel} disabled={!action.loading}>
|
|
324
|
+
* Cancel
|
|
325
|
+
* </button>
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
328
|
cancel: () => void;
|
|
329
329
|
/**
|
|
330
|
-
|
|
331
|
-
|
|
330
|
+
* The result data from the last successful action execution.
|
|
331
|
+
*/
|
|
332
332
|
result?: Result;
|
|
333
333
|
}
|
|
334
334
|
//#endregion
|
|
@@ -379,7 +379,7 @@ type UseEvents = { [T in keyof Hooks]?: Hook<T> | ((payload: Hooks[T]) => Async<
|
|
|
379
379
|
* Hook to inject a service instance.
|
|
380
380
|
* It's a wrapper of `useAlepha().inject(service)` with a memoization.
|
|
381
381
|
*/
|
|
382
|
-
declare const useInject: <T
|
|
382
|
+
declare const useInject: <T extends object>(service: Service<T>) => T;
|
|
383
383
|
//#endregion
|
|
384
384
|
//#region ../../src/core/hooks/useClient.d.ts
|
|
385
385
|
/**
|
|
@@ -387,48 +387,48 @@ declare const useInject: <T$1 extends object>(service: Service<T$1>) => T$1;
|
|
|
387
387
|
*
|
|
388
388
|
* It's the React-hook version of `$client()`, from `AlephaServerLinks` module.
|
|
389
389
|
*/
|
|
390
|
-
declare const useClient: <T
|
|
390
|
+
declare const useClient: <T extends object>(scope?: ClientScope) => HttpVirtualClient<T>;
|
|
391
391
|
//#endregion
|
|
392
392
|
//#region ../../src/core/hooks/useStore.d.ts
|
|
393
393
|
/**
|
|
394
394
|
* Hook to access and mutate the Alepha state.
|
|
395
395
|
*/
|
|
396
|
-
declare function useStore<T
|
|
396
|
+
declare function useStore<T extends TAtomObject>(target: Atom<T>, defaultValue?: Static<T>): UseStoreReturn<Static<T>>;
|
|
397
397
|
declare function useStore<Key extends keyof State>(target: Key, defaultValue?: State[Key]): UseStoreReturn<State[Key]>;
|
|
398
|
-
type UseStoreReturn<T
|
|
398
|
+
type UseStoreReturn<T> = [T, (value: T) => void];
|
|
399
399
|
//#endregion
|
|
400
400
|
//#region ../../src/core/index.d.ts
|
|
401
401
|
declare module "alepha" {
|
|
402
402
|
interface Hooks {
|
|
403
403
|
/**
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
404
|
+
* Fires when a user action is starting.
|
|
405
|
+
* Action can be a form submission, a route transition, or a custom action.
|
|
406
|
+
*/
|
|
407
407
|
"react:action:begin": {
|
|
408
408
|
type: string;
|
|
409
409
|
id?: string;
|
|
410
410
|
};
|
|
411
411
|
/**
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
412
|
+
* Fires when a user action has succeeded.
|
|
413
|
+
* Action can be a form submission, a route transition, or a custom action.
|
|
414
|
+
*/
|
|
415
415
|
"react:action:success": {
|
|
416
416
|
type: string;
|
|
417
417
|
id?: string;
|
|
418
418
|
};
|
|
419
419
|
/**
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
420
|
+
* Fires when a user action has failed.
|
|
421
|
+
* Action can be a form submission, a route transition, or a custom action.
|
|
422
|
+
*/
|
|
423
423
|
"react:action:error": {
|
|
424
424
|
type: string;
|
|
425
425
|
id?: string;
|
|
426
426
|
error: Error;
|
|
427
427
|
};
|
|
428
428
|
/**
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
429
|
+
* Fires when a user action has completed, regardless of success or failure.
|
|
430
|
+
* Action can be a form submission, a route transition, or a custom action.
|
|
431
|
+
*/
|
|
432
432
|
"react:action:end": {
|
|
433
433
|
type: string;
|
|
434
434
|
id?: string;
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/core/components/ClientOnly.tsx","../../src/core/components/ErrorBoundary.tsx","../../src/core/contexts/AlephaProvider.tsx","../../src/core/contexts/AlephaContext.ts","../../src/core/hooks/useAction.ts","../../src/core/hooks/useAlepha.ts","../../src/core/hooks/useEvents.ts","../../src/core/hooks/useInject.ts","../../src/core/hooks/useClient.ts","../../src/core/hooks/useStore.ts","../../src/core/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/core/components/ClientOnly.tsx","../../src/core/components/ErrorBoundary.tsx","../../src/core/contexts/AlephaProvider.tsx","../../src/core/contexts/AlephaContext.ts","../../src/core/hooks/useAction.ts","../../src/core/hooks/useAlepha.ts","../../src/core/hooks/useEvents.ts","../../src/core/hooks/useInject.ts","../../src/core/hooks/useClient.ts","../../src/core/hooks/useStore.ts","../../src/core/index.ts"],"mappings":";;;;;;;;;UAOiB,eAAA;EAAA,QAAA,GACJ,SAAA;EAAA,QAAA;AAAA;AAAA;AAEZ;;;;;;;;ACDD;;;;;;AAYC;AAcD;;;;;;;;AD3Ba,cA4BP,UAAA,GAAA,KAAA,EAAqB,iBAAA,CAAkB,eAAA,MAAgB,SAAA;;;;AC3B7D;;UAAiB,kBAAA;EAAA;;;;EAAA,QAAA,GAAA,KAAA,EAKG,KAAA,KAAU,SAAA;EAAA;;;;EAAA,OAAA,IAAA,KAAA,EAMV,KAAA,EAAA,IAAA,EAA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Ae,MAAA,CAAO,CAAA;AAAA,iBAChB,QAAA,mBAA2B,KAAA,CAAA,CAAA,MAAA,EAC1B,GAAA,EAAA,YAAA,GACO,KAAA,CAAM,GAAA,IACpB,cAAA,CAAe,KAAA,CAAM,GAAA;AAAA,KAkCZ,cAAA,OAAqB,CAAA,GAAA,KAAA,EAAW,CAAA;;;;;;AClCR;;;;;;;;AAAA;;;;;;;;AAAA;;;;;;aA6BvB,KAAA;IAAA;IAAA;;;AAyBb;IAzBa;MAAA,IAAA;MAAA,EAAA;IAAA;EAAA;AAAA;AAAA;;;AAyBb;;;;;;;AAzBa,cAyBA,WAAA,EAAW,OAAA,CAAA,OAAA,CAEtB,OAAA,CAFsB,MAAA"}
|
package/dist/form/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { InputHTMLAttributes, ReactNode } from "react";
|
|
|
4
4
|
import * as alepha_logger0 from "alepha/logger";
|
|
5
5
|
|
|
6
6
|
//#region ../../src/form/services/FormModel.d.ts
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* FormModel is a dynamic form handler that generates form inputs based on a provided TypeBox schema.
|
|
10
9
|
* It manages form state, handles input changes, and processes form submissions with validation.
|
|
@@ -34,14 +33,14 @@ declare class FormModel<T extends TObject> {
|
|
|
34
33
|
readonly reset: (event: FormEventLike) => Promise<void>;
|
|
35
34
|
readonly submit: () => Promise<void>;
|
|
36
35
|
/**
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
* Restructures flat keys like "address.city" into nested objects like { address: { city: ... } }
|
|
37
|
+
* Values are already typed from onChange, so no conversion is needed.
|
|
38
|
+
*/
|
|
40
39
|
protected restructureValues(store: Record<string, any>): Record<string, any>;
|
|
41
40
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
* Helper to restructure a flat key like "address.city" into nested object structure.
|
|
42
|
+
* The value is already typed, so we just assign it to the nested path.
|
|
43
|
+
*/
|
|
45
44
|
protected restructureNestedValue(values: Record<string, any>, key: string, value: any): void;
|
|
46
45
|
protected createProxyFromSchema<T extends TObject>(options: FormCtrlOptions<T>, schema: TSchema, context: {
|
|
47
46
|
parent: string;
|
|
@@ -52,9 +51,9 @@ declare class FormModel<T extends TObject> {
|
|
|
52
51
|
store: Record<string, any>;
|
|
53
52
|
}): BaseInputField;
|
|
54
53
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
* Convert an input value to the correct type based on the schema.
|
|
55
|
+
* Handles raw DOM values (strings, booleans from checkboxes, Files, etc.)
|
|
56
|
+
*/
|
|
58
57
|
protected getValueFromInput(input: any, schema: TSchema): any;
|
|
59
58
|
protected valueToInputEntry(value: any): string | number | boolean;
|
|
60
59
|
}
|
|
@@ -86,34 +85,34 @@ type InputHTMLAttributesLike = Pick<InputHTMLAttributes<unknown>, "id" | "name"
|
|
|
86
85
|
};
|
|
87
86
|
type FormCtrlOptions<T extends TObject> = {
|
|
88
87
|
/**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
* The schema defining the structure and validation rules for the form.
|
|
89
|
+
* This should be a TypeBox schema object.
|
|
90
|
+
*/
|
|
92
91
|
schema: T;
|
|
93
92
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
* Callback function to handle form submission.
|
|
94
|
+
* This function will receive the parsed and validated form values.
|
|
95
|
+
*/
|
|
97
96
|
handler: (values: Static<T>, args: {
|
|
98
97
|
form: HTMLFormElement;
|
|
99
98
|
}) => unknown;
|
|
100
99
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
* Optional initial values for the form fields.
|
|
101
|
+
* This can be used to pre-populate the form with existing data.
|
|
102
|
+
*/
|
|
104
103
|
initialValues?: Partial<Static<T>>;
|
|
105
104
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
* Optional function to create custom field attributes.
|
|
106
|
+
* This can be used to add custom validation, styles, or other attributes.
|
|
107
|
+
*/
|
|
109
108
|
onCreateField?: (name: keyof Static<T> & string, schema: TSchema) => InputHTMLAttributes<unknown>;
|
|
110
109
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
110
|
+
* If defined, this will generate a unique ID for each field, prefixed with this string.
|
|
111
|
+
*
|
|
112
|
+
* > "username" with id="form-123" will become "form-123-username".
|
|
113
|
+
*
|
|
114
|
+
* If omitted, IDs will not be generated.
|
|
115
|
+
*/
|
|
117
116
|
id?: string;
|
|
118
117
|
onError?: (error: Error, args: {
|
|
119
118
|
form: HTMLFormElement;
|
package/dist/form/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/form/services/FormModel.ts","../../src/form/components/FormState.tsx","../../src/form/hooks/useForm.ts","../../src/form/hooks/useFormState.ts","../../src/form/errors/FormValidationError.ts","../../src/form/index.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/form/services/FormModel.ts","../../src/form/components/FormState.tsx","../../src/form/hooks/useForm.ts","../../src/form/hooks/useFormState.ts","../../src/form/errors/FormValidationError.ts","../../src/form/index.ts"],"mappings":";;;;;;;AAaA;;;;;;;cAAa,SAAA,WAAoB,OAAA;EAAA,SAAA,EAAA;EAAA,SAAA,OAAA,EAcJ,eAAA,CAAgB,CAAA;EAAA,mBAAA,GAAA,EAAD,cAAA,CAbpB,MAAA;EAAA,mBAAA,MAAA,EACG,MAAA;EAAA,mBAAA,MAAA,EACE,MAAA;EAAA,UAAA,gBAAA;EAAA,KAAA,EAGb,aAAA,CAAc,CAAA;EAAA,IAAA,WAAA;EAAA,YAAA,EAAA,UAAA,OAAA,EAQD,eAAA,CAAgB,CAAA;EAAA,IAAA,QAAA,GAiBrB,eAAA;EAAA,IAAA,cAAA,GAIM,MAAA;EAAA,IAAA,MAAA;IAAA,EAAA;IAAA,UAAA;IA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,aACD,OAAA,qBACS,kBAAA,EAAA,MAAA,EAEX,SAAA,CAAU,CAAA;EAAA,IAAA,EAAa,SAAA,CAAU,CAAA;EAAA,IAAA;AAAA,GAAA,OAAA,GAChC,IAAA,OACR,IAAA,CAAK,kBAAA,EAAoB,IAAA;;;cChBf,mBAAA,SAA4B,YAAA;EAAA,SAAA,IAAA;EAAA,YAAA,OAAA;IAAA,OAAA;IAAA,IAAA;EAAA;AAAA;;;;;;;;;;;;cCaD,MAAA;IAAA;IAAA;MAAA,EAAA;IAAA;IAAA;MAAA,EAAA;MAAA,MAAA,EAES,MAAA;IAAA;IAAA;MAAA,EAAA;MAAA,KAAA,EACH,KAAA;IAAA;IAAA;MAAA,EAAA;IAAA;EAAA;AAAA;AAAA;;;;AAkB9C;;;;;;;AAlB8C,cAkBjC,eAAA,EAAe,OAAA,CAAA,OAAA,CAE1B,OAAA,CAF0B,MAAA"}
|
package/dist/head/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { Alepha, KIND, Primitive } from "alepha";
|
|
|
3
3
|
import * as alepha_logger0 from "alepha/logger";
|
|
4
4
|
|
|
5
5
|
//#region ../../src/head/interfaces/Head.d.ts
|
|
6
|
-
|
|
7
6
|
/**
|
|
8
7
|
* Complete head configuration combining basic head elements with SEO fields.
|
|
9
8
|
*
|
|
@@ -45,26 +44,17 @@ interface Seo {
|
|
|
45
44
|
imageAlt?: string;
|
|
46
45
|
/** Twitter-specific overrides */
|
|
47
46
|
twitter?: {
|
|
48
|
-
/** Twitter card type */
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
creator?: string;
|
|
54
|
-
/** Override title for Twitter */
|
|
55
|
-
title?: string;
|
|
56
|
-
/** Override description for Twitter */
|
|
57
|
-
description?: string;
|
|
58
|
-
/** Override image for Twitter */
|
|
47
|
+
/** Twitter card type */card?: "summary" | "summary_large_image" | "app" | "player"; /** @username of website */
|
|
48
|
+
site?: string; /** @username of content creator */
|
|
49
|
+
creator?: string; /** Override title for Twitter */
|
|
50
|
+
title?: string; /** Override description for Twitter */
|
|
51
|
+
description?: string; /** Override image for Twitter */
|
|
59
52
|
image?: string;
|
|
60
53
|
};
|
|
61
54
|
/** OpenGraph-specific overrides */
|
|
62
55
|
og?: {
|
|
63
|
-
/** Override title for OpenGraph */
|
|
64
|
-
|
|
65
|
-
/** Override description for OpenGraph */
|
|
66
|
-
description?: string;
|
|
67
|
-
/** Override image for OpenGraph */
|
|
56
|
+
/** Override title for OpenGraph */title?: string; /** Override description for OpenGraph */
|
|
57
|
+
description?: string; /** Override image for OpenGraph */
|
|
68
58
|
image?: string;
|
|
69
59
|
};
|
|
70
60
|
}
|
|
@@ -139,18 +129,18 @@ declare class HeadProvider {
|
|
|
139
129
|
protected readonly seoExpander: SeoExpander;
|
|
140
130
|
global?: Array<Head | (() => Head)>;
|
|
141
131
|
/**
|
|
142
|
-
|
|
143
|
-
|
|
132
|
+
* Track if we've warned about page-level htmlAttributes to avoid spam.
|
|
133
|
+
*/
|
|
144
134
|
protected warnedAboutHtmlAttributes: boolean;
|
|
145
135
|
/**
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
136
|
+
* Resolve global head configuration (from $head primitives only).
|
|
137
|
+
*
|
|
138
|
+
* This is used to get htmlAttributes early, before page loaders run.
|
|
139
|
+
* Only htmlAttributes from global $head are allowed; page-level htmlAttributes
|
|
140
|
+
* are ignored for early streaming optimization.
|
|
141
|
+
*
|
|
142
|
+
* @returns Merged global head with htmlAttributes
|
|
143
|
+
*/
|
|
154
144
|
resolveGlobalHead(): Head;
|
|
155
145
|
fillHead(state: HeadState): void;
|
|
156
146
|
protected mergeHead(state: HeadState, head: Head): void;
|
|
@@ -222,16 +212,16 @@ type UseHeadReturn = [Head, (head?: Head | ((previous?: Head) => Head)) => void]
|
|
|
222
212
|
declare class ServerHeadProvider {
|
|
223
213
|
protected readonly headProvider: HeadProvider;
|
|
224
214
|
/**
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
215
|
+
* Resolve global head configuration (htmlAttributes only).
|
|
216
|
+
*
|
|
217
|
+
* Used for early streaming optimization - htmlAttributes can be sent
|
|
218
|
+
* before page loaders run since they come from global $head only.
|
|
219
|
+
*/
|
|
230
220
|
resolveGlobalHead(): Head;
|
|
231
221
|
/**
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
222
|
+
* Fill head state from route configurations.
|
|
223
|
+
* Delegates to HeadProvider to merge head data from all route layers.
|
|
224
|
+
*/
|
|
235
225
|
fillHead(state: {
|
|
236
226
|
head: SimpleHead;
|
|
237
227
|
layers: Array<any>;
|
|
@@ -251,11 +241,11 @@ declare class BrowserHeadProvider {
|
|
|
251
241
|
protected readonly headProvider: HeadProvider;
|
|
252
242
|
protected get document(): Document;
|
|
253
243
|
/**
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
244
|
+
* Fill head state from route configurations and render to document.
|
|
245
|
+
* Combines fillHead from HeadProvider with renderHead to the DOM.
|
|
246
|
+
*
|
|
247
|
+
* Only runs in browser environment - no-op on server.
|
|
248
|
+
*/
|
|
259
249
|
fillAndRenderHead(state: {
|
|
260
250
|
head: Head;
|
|
261
251
|
layers: Array<any>;
|