unhead 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.mts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/client.mjs +6 -63
- package/dist/index.d.mts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.mjs +2 -1
- package/dist/legacy.d.mts +26 -0
- package/dist/legacy.d.ts +26 -0
- package/dist/legacy.mjs +63 -0
- package/dist/parser.d.mts +1 -1
- package/dist/parser.d.ts +1 -1
- package/dist/plugins.d.mts +2 -2
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.mjs +5 -129
- package/dist/scripts.d.mts +4 -4
- package/dist/scripts.d.ts +4 -4
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/shared/{unhead.D4KaR-FM.d.ts → unhead.9aHQrEvB.d.ts} +2 -2
- package/dist/shared/{unhead.D_bywjUE.mjs → unhead.A4ndrqqe.mjs} +2 -5
- package/dist/shared/{unhead.DJ6joC2O.d.mts → unhead.Bbk6Q9rK.d.mts} +2 -2
- package/dist/shared/{unhead.BJTN1X0i.d.mts → unhead.BcynQ3qJ.d.mts} +81 -20
- package/dist/shared/{unhead.BJTN1X0i.d.ts → unhead.BcynQ3qJ.d.ts} +81 -20
- package/dist/shared/{unhead.C6alnWbQ.d.mts → unhead.BfINO8Du.d.mts} +2 -2
- package/dist/shared/{unhead.BRWMyYIW.d.ts → unhead.BmdY3z1V.d.ts} +1 -1
- package/dist/shared/unhead.CGloe9Qc.d.mts +6 -0
- package/dist/shared/unhead.CH30252c.mjs +129 -0
- package/dist/shared/{unhead.CpT6Kxc0.d.ts → unhead.CHsGwxB0.d.ts} +2 -2
- package/dist/shared/unhead.CUXLLRtV.mjs +5 -0
- package/dist/shared/{unhead.BhElfVXO.d.ts → unhead.CvqH1vcy.d.ts} +1 -1
- package/dist/shared/{unhead.BXRLaj2l.d.mts → unhead.D91IvQ_J.d.mts} +1 -1
- package/dist/shared/unhead.DCXRrsx_.d.ts +6 -0
- package/dist/shared/{unhead.DH3TZMHc.d.ts → unhead.DoIxTwSF.d.ts} +1 -1
- package/dist/shared/{unhead.Dp1MlAYz.d.mts → unhead.DvqMLXpO.d.mts} +1 -1
- package/dist/shared/{unhead.CZPkBynw.d.mts → unhead.LatFr5s0.d.mts} +1 -1
- package/dist/shared/{unhead.YGcEMcjf.d.ts → unhead.Ogog_XUX.d.ts} +1 -1
- package/dist/shared/unhead.YnmwhfIN.mjs +64 -0
- package/dist/shared/{unhead.DsHmk_XC.d.mts → unhead.m4TuRTvV.d.mts} +1 -1
- package/dist/stream/client.d.mts +3 -3
- package/dist/stream/client.d.ts +3 -3
- package/dist/stream/server.d.mts +3 -3
- package/dist/stream/server.d.ts +3 -3
- package/dist/types.d.mts +6 -6
- package/dist/types.d.ts +6 -6
- package/dist/utils.d.mts +2 -2
- package/dist/utils.d.ts +2 -2
- package/package.json +8 -1
|
@@ -942,6 +942,46 @@ interface CompressionDictionaryLink extends LinkBase {
|
|
|
942
942
|
rel: 'compression-dictionary';
|
|
943
943
|
href: string;
|
|
944
944
|
}
|
|
945
|
+
/**
|
|
946
|
+
* Sitemap link. Points to a sitemap for the site.
|
|
947
|
+
*
|
|
948
|
+
* @see https://www.iana.org/assignments/link-relations/link-relations.xhtml
|
|
949
|
+
*/
|
|
950
|
+
interface SitemapLink extends LinkBase {
|
|
951
|
+
rel: 'sitemap';
|
|
952
|
+
href: string;
|
|
953
|
+
type?: 'application/xml' | (string & Record<never, never>);
|
|
954
|
+
title?: string;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Apple touch startup image link. Specifies a splash screen image for iOS
|
|
958
|
+
* when a web app is launched from the home screen.
|
|
959
|
+
*
|
|
960
|
+
* @see https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
|
|
961
|
+
*/
|
|
962
|
+
interface AppleTouchStartupImageLink extends LinkBase {
|
|
963
|
+
rel: 'apple-touch-startup-image';
|
|
964
|
+
href: string;
|
|
965
|
+
media?: string;
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* AMP HTML link. Points to the AMP version of the current document.
|
|
969
|
+
*
|
|
970
|
+
* @see https://amp.dev/documentation/guides-and-tutorials/start/create/prepare_for_discovery/
|
|
971
|
+
*/
|
|
972
|
+
interface AmpHtmlLink extends LinkBase {
|
|
973
|
+
rel: 'amphtml';
|
|
974
|
+
href: string;
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* WebSub hub link. Points to a WebSub hub for real-time content distribution.
|
|
978
|
+
*
|
|
979
|
+
* @see https://www.w3.org/TR/websub/
|
|
980
|
+
*/
|
|
981
|
+
interface HubLink extends LinkBase {
|
|
982
|
+
rel: 'hub';
|
|
983
|
+
href: string;
|
|
984
|
+
}
|
|
945
985
|
/**
|
|
946
986
|
* Alternate stylesheet link. User-selectable alternate stylesheet.
|
|
947
987
|
* Requires a `title` to appear in the browser's stylesheet picker.
|
|
@@ -962,7 +1002,7 @@ interface AlternateStylesheetLink extends LinkBase, LinkHttpEvents {
|
|
|
962
1002
|
* Union of all `rel` values that have narrowed link type definitions.
|
|
963
1003
|
* Useful for building type guards or conditional logic based on `rel` values.
|
|
964
1004
|
*/
|
|
965
|
-
type KnownLinkRel = 'stylesheet' | 'alternate stylesheet' | 'preload' | 'modulepreload' | 'prefetch' | 'icon' | 'shortcut icon' | 'apple-touch-icon' | 'mask-icon' | 'manifest' | 'canonical' | 'dns-prefetch' | 'preconnect' | 'prerender' | 'alternate' | 'author' | 'license' | 'help' | 'search' | 'prev' | 'next' | 'pingback' | 'me' | 'webmention' | 'privacy-policy' | 'terms-of-service' | 'expect' | 'compression-dictionary';
|
|
1005
|
+
type KnownLinkRel = 'stylesheet' | 'alternate stylesheet' | 'preload' | 'modulepreload' | 'prefetch' | 'icon' | 'shortcut icon' | 'apple-touch-icon' | 'mask-icon' | 'manifest' | 'canonical' | 'dns-prefetch' | 'preconnect' | 'prerender' | 'alternate' | 'author' | 'license' | 'help' | 'search' | 'prev' | 'next' | 'pingback' | 'me' | 'webmention' | 'privacy-policy' | 'terms-of-service' | 'expect' | 'compression-dictionary' | 'sitemap' | 'apple-touch-startup-image' | 'amphtml' | 'hub';
|
|
966
1006
|
/**
|
|
967
1007
|
* Fallback for custom or unknown `rel` types.
|
|
968
1008
|
*
|
|
@@ -1011,7 +1051,7 @@ interface GenericLink extends LinkBase {
|
|
|
1011
1051
|
*
|
|
1012
1052
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel
|
|
1013
1053
|
*/
|
|
1014
|
-
type Link = StylesheetLink | AlternateStylesheetLink | PreloadLink | ModulepreloadLink | PrefetchLink | FaviconLink | AppleTouchIconLink | MaskIconLink | ManifestLink | CanonicalLink | DnsPrefetchLink | PreconnectLink | PrerenderLink | AlternateLanguageLink | AlternateFeedLink | AlternateMediaLink | BareAlternateLink | AuthorLink | LicenseLink | HelpLink | SearchLink | PrevLink | NextLink | PingbackLink | MeLink | WebmentionLink | PrivacyPolicyLink | TermsOfServiceLink | ExpectLink | CompressionDictionaryLink;
|
|
1054
|
+
type Link = StylesheetLink | AlternateStylesheetLink | PreloadLink | ModulepreloadLink | PrefetchLink | FaviconLink | AppleTouchIconLink | MaskIconLink | ManifestLink | CanonicalLink | DnsPrefetchLink | PreconnectLink | PrerenderLink | AlternateLanguageLink | AlternateFeedLink | AlternateMediaLink | BareAlternateLink | AuthorLink | LicenseLink | HelpLink | SearchLink | PrevLink | NextLink | PingbackLink | MeLink | WebmentionLink | PrivacyPolicyLink | TermsOfServiceLink | ExpectLink | CompressionDictionaryLink | SitemapLink | AppleTouchStartupImageLink | AmpHtmlLink | HubLink;
|
|
1015
1055
|
/**
|
|
1016
1056
|
* Pick {@link Link} union members whose `rel` accepts `R`.
|
|
1017
1057
|
*
|
|
@@ -2133,12 +2173,41 @@ type NoscriptContent = {
|
|
|
2133
2173
|
type Noscript = Pick<GlobalAttributes, 'id' | 'class' | 'style'> & NoscriptContent;
|
|
2134
2174
|
|
|
2135
2175
|
interface SpeculationRules {
|
|
2136
|
-
prefetch?: readonly
|
|
2137
|
-
prerender?: readonly
|
|
2176
|
+
prefetch?: readonly SpeculationRule[];
|
|
2177
|
+
prerender?: readonly SpeculationRule[];
|
|
2138
2178
|
}
|
|
2139
|
-
|
|
2179
|
+
/**
|
|
2180
|
+
* A single speculation rule entry.
|
|
2181
|
+
*
|
|
2182
|
+
* List rules provide explicit `urls`; document rules provide a `where` selector.
|
|
2183
|
+
* Both shapes share the same interface so TypeScript doesn't require exact
|
|
2184
|
+
* literal `source` values, which avoids widening issues inside `useHead`.
|
|
2185
|
+
*
|
|
2186
|
+
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md
|
|
2187
|
+
*/
|
|
2188
|
+
interface SpeculationRule {
|
|
2140
2189
|
/**
|
|
2141
|
-
*
|
|
2190
|
+
* The rule source type.
|
|
2191
|
+
*
|
|
2192
|
+
* `'list'` for explicit URL lists, `'document'` for selector-based rules.
|
|
2193
|
+
*
|
|
2194
|
+
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md
|
|
2195
|
+
*/
|
|
2196
|
+
source?: 'list' | 'document' | (string & Record<never, never>);
|
|
2197
|
+
/**
|
|
2198
|
+
* Explicit URLs to speculate on (list rules).
|
|
2199
|
+
*
|
|
2200
|
+
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#list-rules
|
|
2201
|
+
*/
|
|
2202
|
+
urls?: readonly string[];
|
|
2203
|
+
/**
|
|
2204
|
+
* Selector conditions for document rules.
|
|
2205
|
+
*
|
|
2206
|
+
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#document-rules
|
|
2207
|
+
*/
|
|
2208
|
+
where?: SpeculationRuleWhere;
|
|
2209
|
+
/**
|
|
2210
|
+
* A hint about how likely the user is to navigate to the URL.
|
|
2142
2211
|
*
|
|
2143
2212
|
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#scores
|
|
2144
2213
|
*/
|
|
@@ -2148,36 +2217,28 @@ interface SpeculationRuleBase {
|
|
|
2148
2217
|
*
|
|
2149
2218
|
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#using-the-documents-base-url-for-external-speculation-rule-sets
|
|
2150
2219
|
*/
|
|
2151
|
-
relative_to?: 'document';
|
|
2220
|
+
relative_to?: 'document' | (string & Record<never, never>);
|
|
2152
2221
|
/**
|
|
2153
|
-
* Assertions
|
|
2222
|
+
* Assertions about user agent capabilities required to execute the rule.
|
|
2154
2223
|
*
|
|
2155
2224
|
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#requirements
|
|
2156
2225
|
*/
|
|
2157
|
-
requires?: readonly 'anonymous-client-ip-when-cross-origin'[];
|
|
2226
|
+
requires?: readonly ('anonymous-client-ip-when-cross-origin' | (string & Record<never, never>))[];
|
|
2158
2227
|
/**
|
|
2159
|
-
*
|
|
2228
|
+
* Where the page expects the prerendered content to be activated.
|
|
2160
2229
|
*
|
|
2161
2230
|
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#window-name-targeting-hints
|
|
2162
2231
|
*/
|
|
2163
|
-
target_hint?: '_blank' | '_self' | '_parent' | '_top';
|
|
2232
|
+
target_hint?: '_blank' | '_self' | '_parent' | '_top' | (string & Record<never, never>);
|
|
2164
2233
|
/**
|
|
2165
|
-
* The policy
|
|
2234
|
+
* The referrer policy for the speculative request.
|
|
2166
2235
|
*
|
|
2167
2236
|
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#explicit-referrer-policy
|
|
2168
2237
|
*/
|
|
2169
2238
|
referrer_policy?: ReferrerPolicy;
|
|
2170
2239
|
}
|
|
2171
|
-
interface SpeculationRuleList extends SpeculationRuleBase {
|
|
2172
|
-
source: 'list';
|
|
2173
|
-
urls: readonly string[];
|
|
2174
|
-
}
|
|
2175
2240
|
type SpeculationRuleFn = 'and' | 'or' | 'href_matches' | 'selector_matches' | 'not';
|
|
2176
2241
|
type SpeculationRuleWhere = Partial<Record<SpeculationRuleFn, readonly Partial<(Record<SpeculationRuleFn, (Partial<Record<SpeculationRuleFn, string>>) | string>)>[]>>;
|
|
2177
|
-
interface SpeculationRuleDocument extends SpeculationRuleBase {
|
|
2178
|
-
source: 'document';
|
|
2179
|
-
where: SpeculationRuleWhere;
|
|
2180
|
-
}
|
|
2181
2242
|
|
|
2182
2243
|
/**
|
|
2183
2244
|
* Events that fire on script elements (load/error)
|
|
@@ -942,6 +942,46 @@ interface CompressionDictionaryLink extends LinkBase {
|
|
|
942
942
|
rel: 'compression-dictionary';
|
|
943
943
|
href: string;
|
|
944
944
|
}
|
|
945
|
+
/**
|
|
946
|
+
* Sitemap link. Points to a sitemap for the site.
|
|
947
|
+
*
|
|
948
|
+
* @see https://www.iana.org/assignments/link-relations/link-relations.xhtml
|
|
949
|
+
*/
|
|
950
|
+
interface SitemapLink extends LinkBase {
|
|
951
|
+
rel: 'sitemap';
|
|
952
|
+
href: string;
|
|
953
|
+
type?: 'application/xml' | (string & Record<never, never>);
|
|
954
|
+
title?: string;
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Apple touch startup image link. Specifies a splash screen image for iOS
|
|
958
|
+
* when a web app is launched from the home screen.
|
|
959
|
+
*
|
|
960
|
+
* @see https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
|
|
961
|
+
*/
|
|
962
|
+
interface AppleTouchStartupImageLink extends LinkBase {
|
|
963
|
+
rel: 'apple-touch-startup-image';
|
|
964
|
+
href: string;
|
|
965
|
+
media?: string;
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* AMP HTML link. Points to the AMP version of the current document.
|
|
969
|
+
*
|
|
970
|
+
* @see https://amp.dev/documentation/guides-and-tutorials/start/create/prepare_for_discovery/
|
|
971
|
+
*/
|
|
972
|
+
interface AmpHtmlLink extends LinkBase {
|
|
973
|
+
rel: 'amphtml';
|
|
974
|
+
href: string;
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* WebSub hub link. Points to a WebSub hub for real-time content distribution.
|
|
978
|
+
*
|
|
979
|
+
* @see https://www.w3.org/TR/websub/
|
|
980
|
+
*/
|
|
981
|
+
interface HubLink extends LinkBase {
|
|
982
|
+
rel: 'hub';
|
|
983
|
+
href: string;
|
|
984
|
+
}
|
|
945
985
|
/**
|
|
946
986
|
* Alternate stylesheet link. User-selectable alternate stylesheet.
|
|
947
987
|
* Requires a `title` to appear in the browser's stylesheet picker.
|
|
@@ -962,7 +1002,7 @@ interface AlternateStylesheetLink extends LinkBase, LinkHttpEvents {
|
|
|
962
1002
|
* Union of all `rel` values that have narrowed link type definitions.
|
|
963
1003
|
* Useful for building type guards or conditional logic based on `rel` values.
|
|
964
1004
|
*/
|
|
965
|
-
type KnownLinkRel = 'stylesheet' | 'alternate stylesheet' | 'preload' | 'modulepreload' | 'prefetch' | 'icon' | 'shortcut icon' | 'apple-touch-icon' | 'mask-icon' | 'manifest' | 'canonical' | 'dns-prefetch' | 'preconnect' | 'prerender' | 'alternate' | 'author' | 'license' | 'help' | 'search' | 'prev' | 'next' | 'pingback' | 'me' | 'webmention' | 'privacy-policy' | 'terms-of-service' | 'expect' | 'compression-dictionary';
|
|
1005
|
+
type KnownLinkRel = 'stylesheet' | 'alternate stylesheet' | 'preload' | 'modulepreload' | 'prefetch' | 'icon' | 'shortcut icon' | 'apple-touch-icon' | 'mask-icon' | 'manifest' | 'canonical' | 'dns-prefetch' | 'preconnect' | 'prerender' | 'alternate' | 'author' | 'license' | 'help' | 'search' | 'prev' | 'next' | 'pingback' | 'me' | 'webmention' | 'privacy-policy' | 'terms-of-service' | 'expect' | 'compression-dictionary' | 'sitemap' | 'apple-touch-startup-image' | 'amphtml' | 'hub';
|
|
966
1006
|
/**
|
|
967
1007
|
* Fallback for custom or unknown `rel` types.
|
|
968
1008
|
*
|
|
@@ -1011,7 +1051,7 @@ interface GenericLink extends LinkBase {
|
|
|
1011
1051
|
*
|
|
1012
1052
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel
|
|
1013
1053
|
*/
|
|
1014
|
-
type Link = StylesheetLink | AlternateStylesheetLink | PreloadLink | ModulepreloadLink | PrefetchLink | FaviconLink | AppleTouchIconLink | MaskIconLink | ManifestLink | CanonicalLink | DnsPrefetchLink | PreconnectLink | PrerenderLink | AlternateLanguageLink | AlternateFeedLink | AlternateMediaLink | BareAlternateLink | AuthorLink | LicenseLink | HelpLink | SearchLink | PrevLink | NextLink | PingbackLink | MeLink | WebmentionLink | PrivacyPolicyLink | TermsOfServiceLink | ExpectLink | CompressionDictionaryLink;
|
|
1054
|
+
type Link = StylesheetLink | AlternateStylesheetLink | PreloadLink | ModulepreloadLink | PrefetchLink | FaviconLink | AppleTouchIconLink | MaskIconLink | ManifestLink | CanonicalLink | DnsPrefetchLink | PreconnectLink | PrerenderLink | AlternateLanguageLink | AlternateFeedLink | AlternateMediaLink | BareAlternateLink | AuthorLink | LicenseLink | HelpLink | SearchLink | PrevLink | NextLink | PingbackLink | MeLink | WebmentionLink | PrivacyPolicyLink | TermsOfServiceLink | ExpectLink | CompressionDictionaryLink | SitemapLink | AppleTouchStartupImageLink | AmpHtmlLink | HubLink;
|
|
1015
1055
|
/**
|
|
1016
1056
|
* Pick {@link Link} union members whose `rel` accepts `R`.
|
|
1017
1057
|
*
|
|
@@ -2133,12 +2173,41 @@ type NoscriptContent = {
|
|
|
2133
2173
|
type Noscript = Pick<GlobalAttributes, 'id' | 'class' | 'style'> & NoscriptContent;
|
|
2134
2174
|
|
|
2135
2175
|
interface SpeculationRules {
|
|
2136
|
-
prefetch?: readonly
|
|
2137
|
-
prerender?: readonly
|
|
2176
|
+
prefetch?: readonly SpeculationRule[];
|
|
2177
|
+
prerender?: readonly SpeculationRule[];
|
|
2138
2178
|
}
|
|
2139
|
-
|
|
2179
|
+
/**
|
|
2180
|
+
* A single speculation rule entry.
|
|
2181
|
+
*
|
|
2182
|
+
* List rules provide explicit `urls`; document rules provide a `where` selector.
|
|
2183
|
+
* Both shapes share the same interface so TypeScript doesn't require exact
|
|
2184
|
+
* literal `source` values, which avoids widening issues inside `useHead`.
|
|
2185
|
+
*
|
|
2186
|
+
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md
|
|
2187
|
+
*/
|
|
2188
|
+
interface SpeculationRule {
|
|
2140
2189
|
/**
|
|
2141
|
-
*
|
|
2190
|
+
* The rule source type.
|
|
2191
|
+
*
|
|
2192
|
+
* `'list'` for explicit URL lists, `'document'` for selector-based rules.
|
|
2193
|
+
*
|
|
2194
|
+
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md
|
|
2195
|
+
*/
|
|
2196
|
+
source?: 'list' | 'document' | (string & Record<never, never>);
|
|
2197
|
+
/**
|
|
2198
|
+
* Explicit URLs to speculate on (list rules).
|
|
2199
|
+
*
|
|
2200
|
+
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#list-rules
|
|
2201
|
+
*/
|
|
2202
|
+
urls?: readonly string[];
|
|
2203
|
+
/**
|
|
2204
|
+
* Selector conditions for document rules.
|
|
2205
|
+
*
|
|
2206
|
+
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#document-rules
|
|
2207
|
+
*/
|
|
2208
|
+
where?: SpeculationRuleWhere;
|
|
2209
|
+
/**
|
|
2210
|
+
* A hint about how likely the user is to navigate to the URL.
|
|
2142
2211
|
*
|
|
2143
2212
|
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#scores
|
|
2144
2213
|
*/
|
|
@@ -2148,36 +2217,28 @@ interface SpeculationRuleBase {
|
|
|
2148
2217
|
*
|
|
2149
2218
|
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#using-the-documents-base-url-for-external-speculation-rule-sets
|
|
2150
2219
|
*/
|
|
2151
|
-
relative_to?: 'document';
|
|
2220
|
+
relative_to?: 'document' | (string & Record<never, never>);
|
|
2152
2221
|
/**
|
|
2153
|
-
* Assertions
|
|
2222
|
+
* Assertions about user agent capabilities required to execute the rule.
|
|
2154
2223
|
*
|
|
2155
2224
|
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#requirements
|
|
2156
2225
|
*/
|
|
2157
|
-
requires?: readonly 'anonymous-client-ip-when-cross-origin'[];
|
|
2226
|
+
requires?: readonly ('anonymous-client-ip-when-cross-origin' | (string & Record<never, never>))[];
|
|
2158
2227
|
/**
|
|
2159
|
-
*
|
|
2228
|
+
* Where the page expects the prerendered content to be activated.
|
|
2160
2229
|
*
|
|
2161
2230
|
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#window-name-targeting-hints
|
|
2162
2231
|
*/
|
|
2163
|
-
target_hint?: '_blank' | '_self' | '_parent' | '_top';
|
|
2232
|
+
target_hint?: '_blank' | '_self' | '_parent' | '_top' | (string & Record<never, never>);
|
|
2164
2233
|
/**
|
|
2165
|
-
* The policy
|
|
2234
|
+
* The referrer policy for the speculative request.
|
|
2166
2235
|
*
|
|
2167
2236
|
* @see https://github.com/WICG/nav-speculation/blob/main/triggers.md#explicit-referrer-policy
|
|
2168
2237
|
*/
|
|
2169
2238
|
referrer_policy?: ReferrerPolicy;
|
|
2170
2239
|
}
|
|
2171
|
-
interface SpeculationRuleList extends SpeculationRuleBase {
|
|
2172
|
-
source: 'list';
|
|
2173
|
-
urls: readonly string[];
|
|
2174
|
-
}
|
|
2175
2240
|
type SpeculationRuleFn = 'and' | 'or' | 'href_matches' | 'selector_matches' | 'not';
|
|
2176
2241
|
type SpeculationRuleWhere = Partial<Record<SpeculationRuleFn, readonly Partial<(Record<SpeculationRuleFn, (Partial<Record<SpeculationRuleFn, string>>) | string>)>[]>>;
|
|
2177
|
-
interface SpeculationRuleDocument extends SpeculationRuleBase {
|
|
2178
|
-
source: 'document';
|
|
2179
|
-
where: SpeculationRuleWhere;
|
|
2180
|
-
}
|
|
2181
2242
|
|
|
2182
2243
|
/**
|
|
2183
2244
|
* Events that fire on script elements (load/error)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HookableCore } from 'hookable';
|
|
2
|
-
import { U as Unhead, s as SSRHeadPayload, v as ServerHeadHooks, e as CreateServerHeadOptions } from './unhead.
|
|
3
|
-
import { at as ResolvableHead } from './unhead.
|
|
2
|
+
import { U as Unhead, s as SSRHeadPayload, v as ServerHeadHooks, e as CreateServerHeadOptions } from './unhead.m4TuRTvV.mjs';
|
|
3
|
+
import { at as ResolvableHead } from './unhead.BcynQ3qJ.mjs';
|
|
4
4
|
|
|
5
5
|
interface ServerUnhead<T = ResolvableHead> extends Unhead<T, SSRHeadPayload> {
|
|
6
6
|
hooks: HookableCore<ServerHeadHooks>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HookableCore } from 'hookable';
|
|
2
|
-
import { r as GenericScript, aK as ScriptHttpEvents, D as DataKeys, _ as MaybeEventFnHandlers, x as HttpEventAttributes, aH as SchemaAugmentations, t as HeadTag, at as ResolvableHead, aT as TagPosition, aU as TagPriority, ao as ProcessesTemplateParams, aG as ResolvesDuplicates, aW as TemplateParams } from './unhead.
|
|
2
|
+
import { r as GenericScript, aK as ScriptHttpEvents, D as DataKeys, _ as MaybeEventFnHandlers, x as HttpEventAttributes, aH as SchemaAugmentations, t as HeadTag, at as ResolvableHead, aT as TagPosition, aU as TagPriority, ao as ProcessesTemplateParams, aG as ResolvesDuplicates, aW as TemplateParams } from './unhead.BcynQ3qJ.js';
|
|
3
3
|
|
|
4
4
|
type UseScriptStatus = 'awaitingLoad' | 'loading' | 'loaded' | 'error' | 'removed';
|
|
5
5
|
type UseScriptContext<T extends Record<symbol | string, any>> = ScriptInstance<T>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { p as HeadRenderer, d as CreateHeadOptions, U as Unhead } from './unhead.m4TuRTvV.mjs';
|
|
2
|
+
import { at as ResolvableHead } from './unhead.BcynQ3qJ.mjs';
|
|
3
|
+
|
|
4
|
+
declare function createUnhead<T = ResolvableHead, R = unknown>(renderer: HeadRenderer<R>, resolvedOptions?: CreateHeadOptions): Unhead<T, R>;
|
|
5
|
+
|
|
6
|
+
export { createUnhead as c };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { d as defineHeadPlugin } from './unhead.CUXLLRtV.mjs';
|
|
2
|
+
import { p as processTemplateParams } from './unhead.BGFxPGPQ.mjs';
|
|
3
|
+
|
|
4
|
+
const sortTags = (a, b) => a._w === b._w ? a._p - b._p : a._w - b._w;
|
|
5
|
+
const formatKey = (k) => !k.includes(":key") ? k.split(":").join(":key:") : k;
|
|
6
|
+
const AliasSortingPlugin = defineHeadPlugin({
|
|
7
|
+
key: "aliasSorting",
|
|
8
|
+
hooks: {
|
|
9
|
+
"tags:resolve": (ctx) => {
|
|
10
|
+
let m = false;
|
|
11
|
+
for (const t of ctx.tags) {
|
|
12
|
+
const p = t.tagPriority;
|
|
13
|
+
if (!p)
|
|
14
|
+
continue;
|
|
15
|
+
const s = String(p);
|
|
16
|
+
if (s.startsWith("before:")) {
|
|
17
|
+
const k = formatKey(s.slice(7));
|
|
18
|
+
const l = ctx.tagMap.get(k);
|
|
19
|
+
if (l) {
|
|
20
|
+
if (typeof l.tagPriority === "number")
|
|
21
|
+
t.tagPriority = l.tagPriority;
|
|
22
|
+
t._p = l._p - 1;
|
|
23
|
+
m = true;
|
|
24
|
+
}
|
|
25
|
+
} else if (s.startsWith("after:")) {
|
|
26
|
+
const k = formatKey(s.slice(6));
|
|
27
|
+
const l = ctx.tagMap.get(k);
|
|
28
|
+
if (l) {
|
|
29
|
+
if (typeof l.tagPriority === "number")
|
|
30
|
+
t.tagPriority = l.tagPriority;
|
|
31
|
+
t._p = l._p + 1;
|
|
32
|
+
m = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (m)
|
|
37
|
+
ctx.tags = ctx.tags.sort(sortTags);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
async function walkPromises(v) {
|
|
43
|
+
const type = typeof v;
|
|
44
|
+
if (type === "function") {
|
|
45
|
+
return v;
|
|
46
|
+
}
|
|
47
|
+
if (v instanceof Promise) {
|
|
48
|
+
return await v;
|
|
49
|
+
}
|
|
50
|
+
if (Array.isArray(v)) {
|
|
51
|
+
return await Promise.all(v.map((r) => walkPromises(r)));
|
|
52
|
+
}
|
|
53
|
+
if (v?.constructor === Object) {
|
|
54
|
+
const next = {};
|
|
55
|
+
for (const key of Object.keys(v)) {
|
|
56
|
+
next[key] = await walkPromises(v[key]);
|
|
57
|
+
}
|
|
58
|
+
return next;
|
|
59
|
+
}
|
|
60
|
+
return v;
|
|
61
|
+
}
|
|
62
|
+
const PromisesPlugin = /* @__PURE__ */ defineHeadPlugin({
|
|
63
|
+
key: "promises",
|
|
64
|
+
hooks: {
|
|
65
|
+
"entries:resolve": async (ctx) => {
|
|
66
|
+
const promises = [];
|
|
67
|
+
for (const k in ctx.entries) {
|
|
68
|
+
if (!ctx.entries[k]._promisesProcessed) {
|
|
69
|
+
promises.push(
|
|
70
|
+
walkPromises(ctx.entries[k].input).then((val) => {
|
|
71
|
+
ctx.entries[k].input = val;
|
|
72
|
+
ctx.entries[k]._promisesProcessed = true;
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
await Promise.all(promises);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const SupportedAttrs = {
|
|
83
|
+
meta: "content",
|
|
84
|
+
link: "href",
|
|
85
|
+
htmlAttrs: "lang"
|
|
86
|
+
};
|
|
87
|
+
const contentAttrs = ["innerHTML", "textContent"];
|
|
88
|
+
const TemplateParamsPlugin = /* @__PURE__ */ defineHeadPlugin((head) => {
|
|
89
|
+
return {
|
|
90
|
+
key: "template-params",
|
|
91
|
+
hooks: {
|
|
92
|
+
"tags:resolve": ({ tagMap, tags }) => {
|
|
93
|
+
const params = tagMap.get("templateParams")?.props || {};
|
|
94
|
+
const sep = params.separator || "|";
|
|
95
|
+
delete params.separator;
|
|
96
|
+
params.pageTitle = processTemplateParams(
|
|
97
|
+
// find templateParams
|
|
98
|
+
params.pageTitle || head._title || "",
|
|
99
|
+
params,
|
|
100
|
+
sep
|
|
101
|
+
);
|
|
102
|
+
for (const tag of tags) {
|
|
103
|
+
if (tag.processTemplateParams === false) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const v = SupportedAttrs[tag.tag];
|
|
107
|
+
if (v && typeof tag.props[v] === "string") {
|
|
108
|
+
tag.props[v] = processTemplateParams(tag.props[v], params, sep);
|
|
109
|
+
} else if (tag.processTemplateParams || tag.tag === "titleTemplate" || tag.tag === "title") {
|
|
110
|
+
for (const p of contentAttrs) {
|
|
111
|
+
if (typeof tag[p] === "string")
|
|
112
|
+
tag[p] = processTemplateParams(tag[p], params, sep, tag.tag === "script" && tag.props.type.endsWith("json"));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
head._templateParams = params;
|
|
117
|
+
head._separator = sep;
|
|
118
|
+
},
|
|
119
|
+
"tags:afterResolve": ({ tagMap }) => {
|
|
120
|
+
const title = tagMap.get("title");
|
|
121
|
+
if (title?.textContent && title.processTemplateParams !== false) {
|
|
122
|
+
title.textContent = processTemplateParams(title.textContent, head._templateParams, head._separator);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
export { AliasSortingPlugin as A, PromisesPlugin as P, TemplateParamsPlugin as T };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HookableCore } from 'hookable';
|
|
2
|
-
import { U as Unhead, C as ClientHeadHooks, c as CreateClientHeadOptions } from './unhead.
|
|
3
|
-
import { at as ResolvableHead } from './unhead.
|
|
2
|
+
import { U as Unhead, C as ClientHeadHooks, c as CreateClientHeadOptions } from './unhead.BmdY3z1V.js';
|
|
3
|
+
import { at as ResolvableHead } from './unhead.BcynQ3qJ.js';
|
|
4
4
|
|
|
5
5
|
interface ClientUnhead<T = ResolvableHead> extends Unhead<T, boolean> {
|
|
6
6
|
hooks: HookableCore<ClientHeadHooks>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aq as RawInput, at as ResolvableHead, aF as ResolvableValue, ay as ResolvableProperties, G as GenericLink, D as DataKeys, aH as SchemaAugmentations, a3 as MetaGeneric, r as GenericScript, a_ as UnheadHtmlAttributes, aZ as UnheadBodyAttributesWithoutEvents } from './unhead.
|
|
1
|
+
import { aq as RawInput, at as ResolvableHead, aF as ResolvableValue, ay as ResolvableProperties, G as GenericLink, D as DataKeys, aH as SchemaAugmentations, a3 as MetaGeneric, r as GenericScript, a_ as UnheadHtmlAttributes, aZ as UnheadBodyAttributesWithoutEvents } from './unhead.BcynQ3qJ.js';
|
|
2
2
|
|
|
3
3
|
type Base = RawInput<'base'>;
|
|
4
4
|
type HtmlAttributes = RawInput<'htmlAttrs'>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { p as HeadRenderer, d as CreateHeadOptions, U as Unhead } from './unhead.BmdY3z1V.js';
|
|
2
|
+
import { at as ResolvableHead } from './unhead.BcynQ3qJ.js';
|
|
3
|
+
|
|
4
|
+
declare function createUnhead<T = ResolvableHead, R = unknown>(renderer: HeadRenderer<R>, resolvedOptions?: CreateHeadOptions): Unhead<T, R>;
|
|
5
|
+
|
|
6
|
+
export { createUnhead as c };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as Unhead, F as UseScriptInput, G as UseScriptOptions, J as UseScriptReturn } from './unhead.
|
|
1
|
+
import { U as Unhead, F as UseScriptInput, G as UseScriptOptions, J as UseScriptReturn } from './unhead.BmdY3z1V.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Load third-party scripts with SSR support and a proxied API.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as Unhead, F as UseScriptInput, G as UseScriptOptions, J as UseScriptReturn } from './unhead.
|
|
1
|
+
import { U as Unhead, F as UseScriptInput, G as UseScriptOptions, J as UseScriptReturn } from './unhead.m4TuRTvV.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Load third-party scripts with SSR support and a proxied API.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aq as RawInput, at as ResolvableHead, aF as ResolvableValue, ay as ResolvableProperties, G as GenericLink, D as DataKeys, aH as SchemaAugmentations, a3 as MetaGeneric, r as GenericScript, a_ as UnheadHtmlAttributes, aZ as UnheadBodyAttributesWithoutEvents } from './unhead.
|
|
1
|
+
import { aq as RawInput, at as ResolvableHead, aF as ResolvableValue, ay as ResolvableProperties, G as GenericLink, D as DataKeys, aH as SchemaAugmentations, a3 as MetaGeneric, r as GenericScript, a_ as UnheadHtmlAttributes, aZ as UnheadBodyAttributesWithoutEvents } from './unhead.BcynQ3qJ.mjs';
|
|
2
2
|
|
|
3
3
|
type Base = RawInput<'base'>;
|
|
4
4
|
type HtmlAttributes = RawInput<'htmlAttrs'>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { c as createUnhead, r as registerPlugin } from './unhead.CfgPMHXt.mjs';
|
|
2
|
+
import { c as createHooks } from './unhead.DvIxXxuO.mjs';
|
|
3
|
+
import { c as createDomRenderer } from './unhead.pv34ME7O.mjs';
|
|
4
|
+
|
|
5
|
+
const P = { critical: -8, high: -1, low: 2 };
|
|
6
|
+
const tagWeight = (tag) => typeof tag.tagPriority === "number" ? tag.tagPriority : 100 + (P[tag.tagPriority] || 0);
|
|
7
|
+
function createHead(options = {}) {
|
|
8
|
+
options.document = options.document || (typeof window !== "undefined" ? document : void 0);
|
|
9
|
+
const renderer = options.render || createDomRenderer({ document: options.document });
|
|
10
|
+
const initialPayload = options.document?.head.querySelector('script[id="unhead:payload"]')?.innerHTML || false;
|
|
11
|
+
const core = createUnhead(renderer, { document: options.document, propResolvers: options.propResolvers, _tagWeight: tagWeight, init: [] });
|
|
12
|
+
const hooks = createHooks(options.hooks);
|
|
13
|
+
let dirty = false;
|
|
14
|
+
const head = {
|
|
15
|
+
...core,
|
|
16
|
+
ssr: false,
|
|
17
|
+
hooks,
|
|
18
|
+
use: (p) => registerPlugin(head, p),
|
|
19
|
+
get dirty() {
|
|
20
|
+
return dirty;
|
|
21
|
+
},
|
|
22
|
+
set dirty(v) {
|
|
23
|
+
dirty = v;
|
|
24
|
+
},
|
|
25
|
+
render: () => renderer(head),
|
|
26
|
+
invalidate() {
|
|
27
|
+
for (const e of core.entries.values()) delete e._tags;
|
|
28
|
+
dirty = true;
|
|
29
|
+
hooks.callHook("entries:updated", head);
|
|
30
|
+
},
|
|
31
|
+
push(input, _options) {
|
|
32
|
+
const onRendered = _options?.onRendered;
|
|
33
|
+
const unhook = onRendered ? hooks.hook("dom:rendered", onRendered) : void 0;
|
|
34
|
+
const active = core.push(input, _options);
|
|
35
|
+
core.entries.get(active._i)._o = input;
|
|
36
|
+
dirty = true;
|
|
37
|
+
hooks.callHook("entries:updated", head);
|
|
38
|
+
return {
|
|
39
|
+
_i: active._i,
|
|
40
|
+
patch(input2) {
|
|
41
|
+
active.patch(input2);
|
|
42
|
+
dirty = true;
|
|
43
|
+
hooks.callHook("entries:updated", head);
|
|
44
|
+
},
|
|
45
|
+
dispose() {
|
|
46
|
+
unhook?.();
|
|
47
|
+
if (core.entries.has(active._i)) {
|
|
48
|
+
active.dispose();
|
|
49
|
+
head.invalidate();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
hooks.hook("entries:updated", () => {
|
|
56
|
+
renderer(head);
|
|
57
|
+
});
|
|
58
|
+
options.plugins?.forEach((p) => registerPlugin(head, p));
|
|
59
|
+
initialPayload && head.push(JSON.parse(initialPayload));
|
|
60
|
+
options.init?.forEach((e) => e && head.push(e));
|
|
61
|
+
return head;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { createHead as c };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HookableCore } from 'hookable';
|
|
2
|
-
import { r as GenericScript, aK as ScriptHttpEvents, D as DataKeys, _ as MaybeEventFnHandlers, x as HttpEventAttributes, aH as SchemaAugmentations, t as HeadTag, at as ResolvableHead, aT as TagPosition, aU as TagPriority, ao as ProcessesTemplateParams, aG as ResolvesDuplicates, aW as TemplateParams } from './unhead.
|
|
2
|
+
import { r as GenericScript, aK as ScriptHttpEvents, D as DataKeys, _ as MaybeEventFnHandlers, x as HttpEventAttributes, aH as SchemaAugmentations, t as HeadTag, at as ResolvableHead, aT as TagPosition, aU as TagPriority, ao as ProcessesTemplateParams, aG as ResolvesDuplicates, aW as TemplateParams } from './unhead.BcynQ3qJ.mjs';
|
|
3
3
|
|
|
4
4
|
type UseScriptStatus = 'awaitingLoad' | 'loading' | 'loaded' | 'error' | 'removed';
|
|
5
5
|
type UseScriptContext<T extends Record<symbol | string, any>> = ScriptInstance<T>;
|
package/dist/stream/client.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as ClientUnhead } from '../shared/unhead.
|
|
2
|
-
import { c as CreateClientHeadOptions, U as Unhead } from '../shared/unhead.
|
|
3
|
-
import { aM as SerializableHead, at as ResolvableHead } from '../shared/unhead.
|
|
1
|
+
import { C as ClientUnhead } from '../shared/unhead.Bbk6Q9rK.mjs';
|
|
2
|
+
import { c as CreateClientHeadOptions, U as Unhead } from '../shared/unhead.m4TuRTvV.mjs';
|
|
3
|
+
import { aM as SerializableHead, at as ResolvableHead } from '../shared/unhead.BcynQ3qJ.mjs';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
|
|
6
6
|
interface UnheadStreamQueue {
|
package/dist/stream/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as ClientUnhead } from '../shared/unhead.
|
|
2
|
-
import { c as CreateClientHeadOptions, U as Unhead } from '../shared/unhead.
|
|
3
|
-
import { aM as SerializableHead, at as ResolvableHead } from '../shared/unhead.
|
|
1
|
+
import { C as ClientUnhead } from '../shared/unhead.CHsGwxB0.js';
|
|
2
|
+
import { c as CreateClientHeadOptions, U as Unhead } from '../shared/unhead.BmdY3z1V.js';
|
|
3
|
+
import { aM as SerializableHead, at as ResolvableHead } from '../shared/unhead.BcynQ3qJ.js';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
|
|
6
6
|
interface UnheadStreamQueue {
|
package/dist/stream/server.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as ServerUnhead } from '../shared/unhead.
|
|
2
|
-
import { f as CreateStreamableServerHeadOptions, U as Unhead, s as SSRHeadPayload } from '../shared/unhead.
|
|
3
|
-
import { at as ResolvableHead } from '../shared/unhead.
|
|
1
|
+
import { S as ServerUnhead } from '../shared/unhead.BfINO8Du.mjs';
|
|
2
|
+
import { f as CreateStreamableServerHeadOptions, U as Unhead, s as SSRHeadPayload } from '../shared/unhead.m4TuRTvV.mjs';
|
|
3
|
+
import { at as ResolvableHead } from '../shared/unhead.BcynQ3qJ.mjs';
|
|
4
4
|
import 'hookable';
|
|
5
5
|
|
|
6
6
|
/**
|