@@ -6,201 +6,11 @@ import type { AssetsManifest } from "./entry";
6
6
import type { RouteModules , RouteModule } from "./routeModules" ;
7
7
import type { EntryRoute } from "./routes" ;
8
8
import { loadRouteModule } from "./routeModules" ;
9
-
10
- type Primitive = null | undefined | string | number | boolean | symbol | bigint ;
11
-
12
- type LiteralUnion < LiteralType , BaseType extends Primitive > =
13
- | LiteralType
14
- | ( BaseType & Record < never , never > ) ;
15
-
16
- interface HtmlLinkProps {
17
- /**
18
- * Address of the hyperlink
19
- */
20
- href ?: string ;
21
-
22
- /**
23
- * How the element handles crossorigin requests
24
- */
25
- crossOrigin ?: "anonymous" | "use-credentials" ;
26
-
27
- /**
28
- * Relationship between the document containing the hyperlink and the destination resource
29
- */
30
- rel : LiteralUnion <
31
- | "alternate"
32
- | "dns-prefetch"
33
- | "icon"
34
- | "manifest"
35
- | "modulepreload"
36
- | "next"
37
- | "pingback"
38
- | "preconnect"
39
- | "prefetch"
40
- | "preload"
41
- | "prerender"
42
- | "search"
43
- | "stylesheet" ,
44
- string
45
- > ;
46
-
47
- /**
48
- * Applicable media: "screen", "print", "(max-width: 764px)"
49
- */
50
- media ?: string ;
51
-
52
- /**
53
- * Integrity metadata used in Subresource Integrity checks
54
- */
55
- integrity ?: string ;
56
-
57
- /**
58
- * Language of the linked resource
59
- */
60
- hrefLang ?: string ;
61
-
62
- /**
63
- * Hint for the type of the referenced resource
64
- */
65
- type ?: string ;
66
-
67
- /**
68
- * Referrer policy for fetches initiated by the element
69
- */
70
- referrerPolicy ?:
71
- | ""
72
- | "no-referrer"
73
- | "no-referrer-when-downgrade"
74
- | "same-origin"
75
- | "origin"
76
- | "strict-origin"
77
- | "origin-when-cross-origin"
78
- | "strict-origin-when-cross-origin"
79
- | "unsafe-url" ;
80
-
81
- /**
82
- * Sizes of the icons (for rel="icon")
83
- */
84
- sizes ?: string ;
85
-
86
- /**
87
- * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
88
- */
89
- as ?: LiteralUnion <
90
- | "audio"
91
- | "audioworklet"
92
- | "document"
93
- | "embed"
94
- | "fetch"
95
- | "font"
96
- | "frame"
97
- | "iframe"
98
- | "image"
99
- | "manifest"
100
- | "object"
101
- | "paintworklet"
102
- | "report"
103
- | "script"
104
- | "serviceworker"
105
- | "sharedworker"
106
- | "style"
107
- | "track"
108
- | "video"
109
- | "worker"
110
- | "xslt" ,
111
- string
112
- > ;
113
-
114
- /**
115
- * Color to use when customizing a site's icon (for rel="mask-icon")
116
- */
117
- color ?: string ;
118
-
119
- /**
120
- * Whether the link is disabled
121
- */
122
- disabled ?: boolean ;
123
-
124
- /**
125
- * The title attribute has special semantics on this element: Title of the link; CSS style sheet set name.
126
- */
127
- title ?: string ;
128
-
129
- /**
130
- * Images to use in different situations, e.g., high-resolution displays,
131
- * small monitors, etc. (for rel="preload")
132
- */
133
- imageSrcSet ?: string ;
134
-
135
- /**
136
- * Image sizes for different page layouts (for rel="preload")
137
- */
138
- imageSizes ?: string ;
139
- }
140
-
141
- interface HtmlLinkPreloadImage extends HtmlLinkProps {
142
- /**
143
- * Relationship between the document containing the hyperlink and the destination resource
144
- */
145
- rel : "preload" ;
146
-
147
- /**
148
- * Potential destination for a preload request (for rel="preload" and rel="modulepreload")
149
- */
150
- as : "image" ;
151
-
152
- /**
153
- * Address of the hyperlink
154
- */
155
- href ?: string ;
156
-
157
- /**
158
- * Images to use in different situations, e.g., high-resolution displays,
159
- * small monitors, etc. (for rel="preload")
160
- */
161
- imageSrcSet : string ;
162
-
163
- /**
164
- * Image sizes for different page layouts (for rel="preload")
165
- */
166
- imageSizes ?: string ;
167
- }
168
-
169
- /**
170
- * Represents a `<link>` element.
171
- *
172
- * WHATWG Specification: https://html.spec.whatwg.org/multipage/semantics.html#the-link-element
173
- */
174
- export type HtmlLinkDescriptor =
175
- // Must have an href *unless* it's a `<link rel="preload" as="image">` with an
176
- // `imageSrcSet` and `imageSizes` props
177
- | ( HtmlLinkProps & Pick < Required < HtmlLinkProps > , "href" > )
178
- | ( HtmlLinkPreloadImage & Pick < Required < HtmlLinkPreloadImage > , "imageSizes" > )
179
- | ( HtmlLinkPreloadImage &
180
- Pick < Required < HtmlLinkPreloadImage > , "href" > & { imageSizes ?: never } ) ;
181
-
182
- export interface PrefetchPageDescriptor
183
- extends Omit <
184
- HtmlLinkDescriptor ,
185
- | "href"
186
- | "rel"
187
- | "type"
188
- | "sizes"
189
- | "imageSrcSet"
190
- | "imageSizes"
191
- | "as"
192
- | "color"
193
- | "title"
194
- > {
195
- /**
196
- * The absolute path of the page to prefetch.
197
- */
198
- page : string ;
199
- }
200
-
201
- export type LinkDescriptor = HtmlLinkDescriptor | PrefetchPageDescriptor ;
202
-
203
- ////////////////////////////////////////////////////////////////////////////////
9
+ import type {
10
+ HtmlLinkDescriptor ,
11
+ LinkDescriptor ,
12
+ PageLinkDescriptor ,
13
+ } from "../../router/links" ;
204
14
205
15
/**
206
16
* Gets all the links for a set of matches. The modules are assumed to have been
@@ -296,7 +106,7 @@ async function prefetchStyleLink(
296
106
////////////////////////////////////////////////////////////////////////////////
297
107
export function isPageLinkDescriptor (
298
108
object : any
299
- ) : object is PrefetchPageDescriptor {
109
+ ) : object is PageLinkDescriptor {
300
110
return object != null && typeof object . page === "string" ;
301
111
}
302
112
0 commit comments