@unhead/schema 0.2.5 → 0.2.6

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.
Files changed (2) hide show
  1. package/dist/index.d.ts +24 -24
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -220,13 +220,20 @@ interface EntryResolveCtx<T> {
220
220
  entries: HeadEntry<T>[];
221
221
  }
222
222
  interface DomRenderTagContext {
223
- head: HeadClient;
223
+ shouldRender: boolean;
224
224
  tag: HeadTag;
225
- document: Document;
225
+ }
226
+ interface BeforeRenderContext {
227
+ shouldRender: boolean;
228
+ tags: HeadTag[];
229
+ }
230
+ interface SSRRenderContext {
231
+ tags: HeadTag[];
232
+ html: SSRHeadPayload;
226
233
  }
227
234
  interface HeadHooks {
228
- 'init': (ctx: HeadClient<any>) => HookResult;
229
- 'entries:updated': (ctx: HeadClient<any>) => HookResult;
235
+ 'init': (ctx: Unhead<any>) => HookResult;
236
+ 'entries:updated': (ctx: Unhead<any>) => HookResult;
230
237
  'entries:resolve': (ctx: EntryResolveCtx<any>) => HookResult;
231
238
  'tag:normalise': (ctx: {
232
239
  tag: HeadTag;
@@ -235,19 +242,10 @@ interface HeadHooks {
235
242
  'tags:resolve': (ctx: {
236
243
  tags: HeadTag[];
237
244
  }) => HookResult;
238
- 'dom:beforeRender': (ctx: {
239
- head: HeadClient;
240
- tags: HeadTag[];
241
- document: Document;
242
- }) => HookResult;
245
+ 'dom:beforeRender': (ctx: BeforeRenderContext) => HookResult;
243
246
  'dom:renderTag': (ctx: DomRenderTagContext) => HookResult;
244
- 'ssr:beforeRender': (ctx: {
245
- tags: HeadTag[];
246
- }) => HookResult;
247
- 'ssr:render': (ctx: {
248
- tags: HeadTag[];
249
- html: SSRHeadPayload;
250
- }) => HookResult;
247
+ 'ssr:beforeRender': (ctx: BeforeRenderContext) => HookResult;
248
+ 'ssr:render': (ctx: SSRRenderContext) => HookResult;
251
249
  }
252
250
 
253
251
  /**
@@ -257,11 +255,11 @@ interface HeadHooks {
257
255
  */
258
256
  declare type SideEffectsRecord = Record<string, () => void>;
259
257
  declare type RuntimeMode = 'server' | 'client' | 'all';
260
- interface HeadEntry<T> {
258
+ interface HeadEntry<Input> {
261
259
  /**
262
260
  * User provided input for the entry.
263
261
  */
264
- input: T;
262
+ input: Input;
265
263
  /**
266
264
  * The mode that the entry should be used in.
267
265
  *
@@ -285,13 +283,13 @@ declare type HeadPlugin = Omit<CreateHeadOptions, 'plugins'>;
285
283
  /**
286
284
  * An active head entry provides an API to manipulate it.
287
285
  */
288
- interface ActiveHeadEntry<T> {
286
+ interface ActiveHeadEntry<Input> {
289
287
  /**
290
288
  * Updates the entry with new input.
291
289
  *
292
290
  * Will first clear any side effects for previous input.
293
291
  */
294
- patch: (resolvedInput: T) => void;
292
+ patch: (input: Input) => void;
295
293
  /**
296
294
  * Dispose the entry, removing it from the active head.
297
295
  *
@@ -300,21 +298,23 @@ interface ActiveHeadEntry<T> {
300
298
  dispose: () => void;
301
299
  }
302
300
  interface CreateHeadOptions {
301
+ domDelayFn?: (fn: () => void) => void;
302
+ document?: Document;
303
303
  plugins?: HeadPlugin[];
304
304
  hooks?: NestedHooks<HeadHooks>;
305
305
  }
306
306
  interface HeadEntryOptions {
307
307
  mode?: RuntimeMode;
308
308
  }
309
- interface HeadClient<T extends {} = Head> {
309
+ interface Unhead<Input extends {} = Head> {
310
310
  /**
311
311
  * The active head entries.
312
312
  */
313
- headEntries: () => HeadEntry<T>[];
313
+ headEntries: () => HeadEntry<Input>[];
314
314
  /**
315
315
  * Create a new head entry.
316
316
  */
317
- push: (entry: T, options?: HeadEntryOptions) => ActiveHeadEntry<T>;
317
+ push: (entry: Input, options?: HeadEntryOptions) => ActiveHeadEntry<Input>;
318
318
  /**
319
319
  * Resolve tags from head entries.
320
320
  */
@@ -333,4 +333,4 @@ interface HeadClient<T extends {} = Head> {
333
333
  _flushQueuedSideEffects: () => void;
334
334
  }
335
335
 
336
- export { ActiveHeadEntry, Base, BaseBodyAttr, BaseHtmlAttr, BodyAttributes, CreateHeadOptions, DomRenderTagContext, EntryAugmentation, EntryResolveCtx, Head, HeadClient, HeadEntry, HeadEntryOptions, HeadHooks, HeadPlugin, HeadTag, HeadTagKeys, HookResult, HtmlAttributes, InnerContent, Link, MaybeArray, Meta, Never, Noscript, ResolvesDuplicates, RuntimeMode, SSRHeadPayload, SchemaAugmentations, Script, SideEffectsRecord, Style, TagInternalProperties, TagPosition, TagPriority, TagUserProperties, Title, TitleTemplate, UserAttributesConfig, UserTagConfigWithoutInnerContent };
336
+ export { ActiveHeadEntry, Base, BaseBodyAttr, BaseHtmlAttr, BeforeRenderContext, BodyAttributes, CreateHeadOptions, DomRenderTagContext, EntryAugmentation, EntryResolveCtx, Head, HeadEntry, HeadEntryOptions, HeadHooks, HeadPlugin, HeadTag, HeadTagKeys, HookResult, HtmlAttributes, InnerContent, Link, MaybeArray, Meta, Never, Noscript, ResolvesDuplicates, RuntimeMode, SSRHeadPayload, SSRRenderContext, SchemaAugmentations, Script, SideEffectsRecord, Style, TagInternalProperties, TagPosition, TagPriority, TagUserProperties, Title, TitleTemplate, Unhead, UserAttributesConfig, UserTagConfigWithoutInnerContent };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/schema",
3
3
  "type": "module",
4
- "version": "0.2.5",
4
+ "version": "0.2.6",
5
5
  "packageManager": "pnpm@7.14.0",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",