htmx-router 1.0.0-alpha.6 → 1.0.0-pre1
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/package.json +6 -8
- package/readme.md +20 -3
- package/cookies.d.ts +0 -25
- package/cookies.js +0 -60
- package/css.d.ts +0 -13
- package/css.js +0 -55
- package/dynamic.d.ts +0 -5
- package/dynamic.js +0 -42
- package/endpoint.d.ts +0 -13
- package/endpoint.js +0 -34
- package/event-source.d.ts +0 -26
- package/event-source.js +0 -123
- package/index.d.ts +0 -19
- package/index.js +0 -2
- package/internal/cli/config.d.ts +0 -13
- package/internal/cli/config.js +0 -11
- package/internal/cli/index.d.ts +0 -2
- package/internal/cli/index.js +0 -15
- package/internal/client.d.ts +0 -1
- package/internal/client.js +0 -14
- package/internal/compile/manifest.d.ts +0 -1
- package/internal/compile/manifest.js +0 -178
- package/internal/compile/router.d.ts +0 -1
- package/internal/compile/router.js +0 -51
- package/internal/component/dynamic.d.ts +0 -4
- package/internal/component/dynamic.js +0 -18
- package/internal/component/head.d.ts +0 -5
- package/internal/component/head.js +0 -22
- package/internal/component/scripts.d.ts +0 -4
- package/internal/component/scripts.js +0 -23
- package/internal/hash.d.ts +0 -4
- package/internal/hash.js +0 -10
- package/internal/mount.d.ts +0 -2
- package/internal/mount.js +0 -81
- package/internal/request/http.d.ts +0 -10
- package/internal/request/http.js +0 -61
- package/internal/request/index.d.ts +0 -16
- package/internal/request/index.js +0 -8
- package/internal/request/native.d.ts +0 -9
- package/internal/request/native.js +0 -48
- package/internal/util.d.ts +0 -4
- package/internal/util.js +0 -49
- package/request/http.d.ts +0 -10
- package/request/http.js +0 -59
- package/request/index.d.ts +0 -13
- package/request/index.js +0 -3
- package/request/native.d.ts +0 -9
- package/request/native.js +0 -46
- package/response.d.ts +0 -13
- package/response.js +0 -46
- package/router.d.ts +0 -51
- package/router.js +0 -231
- package/shell.d.ts +0 -120
- package/shell.js +0 -253
- package/util/parameters.d.ts +0 -7
- package/util/parameters.js +0 -14
- package/util/path-builder.d.ts +0 -1
- package/util/path-builder.js +0 -45
- package/util/route.d.ts +0 -2
- package/util/route.js +0 -58
- package/vite/bundle-splitter.d.ts +0 -4
- package/vite/bundle-splitter.js +0 -26
- package/vite/client-island.d.ts +0 -4
- package/vite/client-island.js +0 -14
- package/vite/code-splitting.d.ts +0 -4
- package/vite/code-splitting.js +0 -14
- package/vite/index.d.ts +0 -3
- package/vite/index.js +0 -3
- package/vite/router.d.ts +0 -2
- package/vite/router.js +0 -29
package/shell.js
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import { ServerOnlyWarning } from "./internal/util.js";
|
|
2
|
-
ServerOnlyWarning("shell");
|
|
3
|
-
export function ApplyMetaDescriptorDefaults(options, defaults) {
|
|
4
|
-
if (defaults.title && !options.title)
|
|
5
|
-
options.title = defaults.title;
|
|
6
|
-
if (defaults.description && !options.description)
|
|
7
|
-
options.description = defaults.description;
|
|
8
|
-
if (defaults.meta && !options.meta)
|
|
9
|
-
options.meta = defaults.meta;
|
|
10
|
-
if (defaults.og && !options.og)
|
|
11
|
-
options.og = defaults.og;
|
|
12
|
-
if (defaults.jsonLD && !options.jsonLD)
|
|
13
|
-
options.jsonLD = defaults.jsonLD;
|
|
14
|
-
}
|
|
15
|
-
export function RenderMetaDescriptor(options) {
|
|
16
|
-
let out = "";
|
|
17
|
-
if (options.title)
|
|
18
|
-
out += `<title>${EscapeHTML(options.title)}</title>`;
|
|
19
|
-
if (options.description)
|
|
20
|
-
out += `<meta name="description" content="${EscapeHTML(options.description)}">\n`;
|
|
21
|
-
if (options.meta)
|
|
22
|
-
for (const key in options.meta) {
|
|
23
|
-
out += `<meta name="${EscapeHTML(key)}" content="${EscapeHTML(options.meta[key])}">\n`;
|
|
24
|
-
}
|
|
25
|
-
if (options.jsonLD)
|
|
26
|
-
for (const json of options.jsonLD) {
|
|
27
|
-
out += `<script type="application/ld+json">${JSON.stringify(json)}</script>\n`;
|
|
28
|
-
}
|
|
29
|
-
// Auto apply og:title + og:description if not present
|
|
30
|
-
if (options.title && !options.og?.title)
|
|
31
|
-
out += `<meta property="og:title" content="${EscapeHTML(options.title)}">\n`;
|
|
32
|
-
if (options.description && !options.og?.description)
|
|
33
|
-
out += `<meta property="og:description" content="${EscapeHTML(options.description)}">\n`;
|
|
34
|
-
// Apply open graphs
|
|
35
|
-
if (options.og)
|
|
36
|
-
out += RenderOpenGraph(options.og);
|
|
37
|
-
return out;
|
|
38
|
-
}
|
|
39
|
-
function RenderOpenGraph(og) {
|
|
40
|
-
// Manually encoding everything rather than using a loop to ensure they are in the correct order
|
|
41
|
-
// And to ensure extra values can't leak in creating unsafe og tags
|
|
42
|
-
const type = og.type || "website";
|
|
43
|
-
let out = RenderProperty("og:type", type);
|
|
44
|
-
if (og.title)
|
|
45
|
-
out += RenderProperty("og:title", og.title);
|
|
46
|
-
if (og.description)
|
|
47
|
-
out += RenderProperty("og:description", og.description);
|
|
48
|
-
if (og.determiner)
|
|
49
|
-
out += RenderProperty("og:determiner", og.determiner);
|
|
50
|
-
if (og.url)
|
|
51
|
-
out += RenderProperty("og:url", og.url);
|
|
52
|
-
if (og.secure_url)
|
|
53
|
-
out += RenderProperty("og:secure_url", og.secure_url);
|
|
54
|
-
if (og.locale) {
|
|
55
|
-
if (typeof og.locale === "string")
|
|
56
|
-
out += RenderProperty("og:locale", og.locale);
|
|
57
|
-
else {
|
|
58
|
-
out += RenderProperty("og:locale", og.locale.base);
|
|
59
|
-
for (const l of og.locale.alternative)
|
|
60
|
-
out += RenderProperty("og:locale:alternative", l);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (og.image)
|
|
64
|
-
for (const img of og.image) {
|
|
65
|
-
out += RenderProperty("og:image", img.url);
|
|
66
|
-
if (img.secure_url)
|
|
67
|
-
out += RenderProperty("og:image:secure_url", img.secure_url);
|
|
68
|
-
if (img.type)
|
|
69
|
-
out += RenderProperty("og:image:type", img.type);
|
|
70
|
-
if (img.width)
|
|
71
|
-
out += RenderProperty("og:image:width", img.width.toString());
|
|
72
|
-
if (img.height)
|
|
73
|
-
out += RenderProperty("og:image:height", img.height.toString());
|
|
74
|
-
if (img.alt)
|
|
75
|
-
out += RenderProperty("og:image:alt", img.alt);
|
|
76
|
-
}
|
|
77
|
-
if (og.video)
|
|
78
|
-
for (const vid of og.video) {
|
|
79
|
-
out += RenderProperty("og:video", vid.url);
|
|
80
|
-
if (vid.secure_url)
|
|
81
|
-
out += RenderProperty("og:video:secure_url", vid.secure_url);
|
|
82
|
-
if (vid.type)
|
|
83
|
-
out += RenderProperty("og:video:type", vid.type);
|
|
84
|
-
if (vid.width)
|
|
85
|
-
out += RenderProperty("og:video:width", vid.width.toString());
|
|
86
|
-
if (vid.height)
|
|
87
|
-
out += RenderProperty("og:video:height", vid.height.toString());
|
|
88
|
-
if (vid.alt)
|
|
89
|
-
out += RenderProperty("og:video:alt", vid.alt);
|
|
90
|
-
}
|
|
91
|
-
if (og.audio)
|
|
92
|
-
for (const audio of og.audio) {
|
|
93
|
-
out += RenderProperty("og:audio", audio.url);
|
|
94
|
-
if (audio.secure_url)
|
|
95
|
-
out += RenderProperty("og:audio:secure_url", audio.secure_url);
|
|
96
|
-
if (audio.type)
|
|
97
|
-
out += RenderProperty("og:audio:type", audio.type);
|
|
98
|
-
}
|
|
99
|
-
return out + RenderOpenGraphExtras(og);
|
|
100
|
-
}
|
|
101
|
-
function RenderProperty(name, value) {
|
|
102
|
-
return `<meta property="${name}" content="${EscapeHTML(value)}">\n`;
|
|
103
|
-
}
|
|
104
|
-
function RenderOpenGraphExtras(og) {
|
|
105
|
-
let out = "";
|
|
106
|
-
if (og.type === "music.song") {
|
|
107
|
-
const g = og;
|
|
108
|
-
if (g.duration)
|
|
109
|
-
out += RenderProperty("og:music:duration", g.duration.toString());
|
|
110
|
-
if (g.album)
|
|
111
|
-
for (const album of g.album) {
|
|
112
|
-
if (typeof album === "string")
|
|
113
|
-
out += RenderProperty("og:music:album", album);
|
|
114
|
-
else {
|
|
115
|
-
out += RenderProperty("og:music:album", album.url);
|
|
116
|
-
if (album.disc)
|
|
117
|
-
out += RenderProperty("og:music:album:disc", album.disc.toString());
|
|
118
|
-
if (album.track)
|
|
119
|
-
out += RenderProperty("og:music:album:track", album.track.toString());
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (g.musician)
|
|
123
|
-
for (const profile of g.musician)
|
|
124
|
-
out += RenderProperty("og:music:musician", profile);
|
|
125
|
-
return out;
|
|
126
|
-
}
|
|
127
|
-
if (og.type === "music.album") {
|
|
128
|
-
const g = og;
|
|
129
|
-
if (g.songs)
|
|
130
|
-
for (const song of g.songs) {
|
|
131
|
-
if (typeof song === "string")
|
|
132
|
-
out += RenderProperty("og:music:song", song);
|
|
133
|
-
else {
|
|
134
|
-
out += RenderProperty("og:music:song", song.url);
|
|
135
|
-
if (song.disc)
|
|
136
|
-
out += RenderProperty("og:music:song:disc", song.disc.toString());
|
|
137
|
-
if (song.track)
|
|
138
|
-
out += RenderProperty("og:music:song:track", song.track.toString());
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (g.musician)
|
|
142
|
-
for (const profile of g.musician)
|
|
143
|
-
out += RenderProperty("og:music:musician", profile);
|
|
144
|
-
if (g.release_date)
|
|
145
|
-
out += RenderProperty("og:music:release_date", g.release_date.toISOString());
|
|
146
|
-
return out;
|
|
147
|
-
}
|
|
148
|
-
if (og.type === "music.playlist") {
|
|
149
|
-
const g = og;
|
|
150
|
-
if (g.songs)
|
|
151
|
-
for (const song of g.songs) {
|
|
152
|
-
if (typeof song === "string")
|
|
153
|
-
out += RenderProperty("og:music:song", song);
|
|
154
|
-
else {
|
|
155
|
-
out += RenderProperty("og:music:song", song.url);
|
|
156
|
-
if (song.disc)
|
|
157
|
-
out += RenderProperty("og:music:song:disc", song.disc.toString());
|
|
158
|
-
if (song.track)
|
|
159
|
-
out += RenderProperty("og:music:song:track", song.track.toString());
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
if (g.creator)
|
|
163
|
-
for (const profile of g.creator)
|
|
164
|
-
out += RenderProperty("og:music:creator", profile);
|
|
165
|
-
return out;
|
|
166
|
-
}
|
|
167
|
-
if (og.type === "music.radio_station") {
|
|
168
|
-
const g = og;
|
|
169
|
-
if (g.creator)
|
|
170
|
-
for (const profile of g.creator)
|
|
171
|
-
out += RenderProperty("og:music:creator", profile);
|
|
172
|
-
return out;
|
|
173
|
-
}
|
|
174
|
-
if (og.type === "video.movie" || og.type === "video.episode" || og.type === "video.tv_show" || og.type === "video.other") {
|
|
175
|
-
const g = og;
|
|
176
|
-
if (g.actors)
|
|
177
|
-
for (const actor of g.actors) {
|
|
178
|
-
if (typeof actor === "string")
|
|
179
|
-
out += RenderProperty("og:video:actor", actor);
|
|
180
|
-
else {
|
|
181
|
-
out += RenderProperty("og:video:actor", actor.url);
|
|
182
|
-
out += RenderProperty("og:video:actor:role", actor.role);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (g.directors)
|
|
186
|
-
for (const profile of g.directors)
|
|
187
|
-
out += RenderProperty("og:video:director", profile);
|
|
188
|
-
if (g.writers)
|
|
189
|
-
for (const profile of g.writers)
|
|
190
|
-
out += RenderProperty("og:video:writer", profile);
|
|
191
|
-
if (g.duration)
|
|
192
|
-
out += RenderProperty("og:video:duration", g.duration.toString());
|
|
193
|
-
if (g.release_date)
|
|
194
|
-
out += RenderProperty("og:video:release_date", g.release_date.toISOString());
|
|
195
|
-
if (g.tag)
|
|
196
|
-
for (const tag of g.tag)
|
|
197
|
-
out += RenderProperty("og:video:tag", tag);
|
|
198
|
-
if (g.series)
|
|
199
|
-
out += RenderProperty("og:video:series", g.series);
|
|
200
|
-
}
|
|
201
|
-
if (og.type === "article") {
|
|
202
|
-
const g = og;
|
|
203
|
-
if (g.published_time)
|
|
204
|
-
out += RenderProperty("og:article:published_time", g.published_time.toISOString());
|
|
205
|
-
if (g.modified_time)
|
|
206
|
-
out += RenderProperty("og:article:modified_time", g.modified_time.toISOString());
|
|
207
|
-
if (g.expiration_time)
|
|
208
|
-
out += RenderProperty("og:article:expiration_time", g.expiration_time.toISOString());
|
|
209
|
-
if (g.authors)
|
|
210
|
-
for (const profile of g.authors)
|
|
211
|
-
out += RenderProperty("og:article:author", profile);
|
|
212
|
-
if (g.section)
|
|
213
|
-
out += RenderProperty("og:article:section", g.section);
|
|
214
|
-
if (g.tag)
|
|
215
|
-
for (const tag of g.tag)
|
|
216
|
-
out += RenderProperty("og:video:tag", tag);
|
|
217
|
-
}
|
|
218
|
-
if (og.type === "book") {
|
|
219
|
-
const g = og;
|
|
220
|
-
if (g.authors)
|
|
221
|
-
for (const profile of g.authors)
|
|
222
|
-
out += RenderProperty("og:article:author", profile);
|
|
223
|
-
if (g.isbn)
|
|
224
|
-
out += RenderProperty("og:book:isbn", g.isbn);
|
|
225
|
-
if (g.release_date)
|
|
226
|
-
out += RenderProperty("og:book:release_date", g.release_date.toISOString());
|
|
227
|
-
if (g.tag)
|
|
228
|
-
for (const tag of g.tag)
|
|
229
|
-
out += RenderProperty("og:video:tag", tag);
|
|
230
|
-
}
|
|
231
|
-
if (og.type === "profile") {
|
|
232
|
-
const g = og;
|
|
233
|
-
if (g.first_name)
|
|
234
|
-
out += RenderProperty("og:profile:first_name", g.first_name);
|
|
235
|
-
if (g.last_name)
|
|
236
|
-
out += RenderProperty("og:profile:last_name", g.last_name);
|
|
237
|
-
if (g.username)
|
|
238
|
-
out += RenderProperty("og:profile:username", g.username);
|
|
239
|
-
if (g.gender)
|
|
240
|
-
out += RenderProperty("og:profile:gender", g.gender);
|
|
241
|
-
}
|
|
242
|
-
return "";
|
|
243
|
-
}
|
|
244
|
-
const escapeTo = {
|
|
245
|
-
"&": "&",
|
|
246
|
-
"<": "<",
|
|
247
|
-
">": ">",
|
|
248
|
-
"\"": """,
|
|
249
|
-
"'": "'",
|
|
250
|
-
};
|
|
251
|
-
function EscapeHTML(str) {
|
|
252
|
-
return str.replace(/[&<>"']/g, (match) => escapeTo[match] || match);
|
|
253
|
-
}
|
package/util/parameters.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type Parameterized<T extends ParameterShaper> = {
|
|
2
|
-
[K in keyof T]: ReturnType<T[K]>;
|
|
3
|
-
};
|
|
4
|
-
export type ParameterShaper = Record<string, (val: string) => any>;
|
|
5
|
-
export declare function Parameterize<T extends ParameterShaper>(params: {
|
|
6
|
-
[key: string]: string;
|
|
7
|
-
}, shape: T): Parameterized<T>;
|
package/util/parameters.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export function Parameterize(params, shape) {
|
|
2
|
-
const out = {};
|
|
3
|
-
for (const key in shape) {
|
|
4
|
-
if (!(key in params))
|
|
5
|
-
console.warn(`Parameter ${key} not present in route, but defined in parameters`);
|
|
6
|
-
const func = shape[key];
|
|
7
|
-
const val = func(params[key] || "");
|
|
8
|
-
// NaN moment
|
|
9
|
-
if (func === Number && typeof val === "number" && isNaN(val))
|
|
10
|
-
throw new Error("Invalid Number");
|
|
11
|
-
out[key] = val;
|
|
12
|
-
}
|
|
13
|
-
return out;
|
|
14
|
-
}
|
package/util/path-builder.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/util/path-builder.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ServerOnlyWarning } from "../internal/util.js";
|
|
2
|
-
ServerOnlyWarning("path-builder");
|
|
3
|
-
import { relative } from "path";
|
|
4
|
-
/*
|
|
5
|
-
// This feature is disabled because vite doesn't compile import.meta.url to the original url when making the SSR build
|
|
6
|
-
// Even though it's used statically in the routes
|
|
7
|
-
|
|
8
|
-
const parameters = {
|
|
9
|
-
userID: Number
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const urlPath = RoutePathBuilder<typeof parameters>(import.meta.url);
|
|
13
|
-
|
|
14
|
-
export function loader({ params }: RouteContext<typeof parameters>) {
|
|
15
|
-
return <div>You are currently at {urlPath({ userID: params.userID.toString() })}</div>
|
|
16
|
-
}
|
|
17
|
-
*/
|
|
18
|
-
// This feature isn't particularly helpful for a router to refer to it's own URL
|
|
19
|
-
// But instead is useful because you could export this function
|
|
20
|
-
// Allowing other routes to use it, and thus if you move the file your imports will auto update by your LSP
|
|
21
|
-
// And thus so would your SSR rendered urls
|
|
22
|
-
function RoutePathBuilder(importUrl) {
|
|
23
|
-
// file runs all imports before actually executing the route.tsx
|
|
24
|
-
// so I have to do this BS instead of pre-compiling
|
|
25
|
-
let compiled = null;
|
|
26
|
-
return (params) => {
|
|
27
|
-
if (!compiled) {
|
|
28
|
-
const root = globalThis.HTMX_ROUTER_ROOT;
|
|
29
|
-
let path = importUrl.slice("file:///".length);
|
|
30
|
-
const raw = relative(root, path).replaceAll("\\", "/");
|
|
31
|
-
const i = raw.lastIndexOf(".");
|
|
32
|
-
compiled = raw.slice(0, i).split("/");
|
|
33
|
-
}
|
|
34
|
-
let path = "";
|
|
35
|
-
for (const frag of compiled) {
|
|
36
|
-
path += "/";
|
|
37
|
-
if (frag[0] != "$") {
|
|
38
|
-
path += frag;
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
path += params[frag.slice(1)] || "_";
|
|
42
|
-
}
|
|
43
|
-
return path;
|
|
44
|
-
};
|
|
45
|
-
}
|
package/util/route.d.ts
DELETED
package/util/route.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { ServerOnlyWarning } from "../internal/util.js";
|
|
2
|
-
ServerOnlyWarning("route-path");
|
|
3
|
-
export function RoutePath() {
|
|
4
|
-
const frags = new Array();
|
|
5
|
-
return (params) => {
|
|
6
|
-
const t = params;
|
|
7
|
-
if (typeof t === "string") {
|
|
8
|
-
Compile("/" + t, frags);
|
|
9
|
-
return "";
|
|
10
|
-
}
|
|
11
|
-
return Parse(frags, params);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
const indexRoute = "/_index";
|
|
15
|
-
function Compile(url, into) {
|
|
16
|
-
let cursor = 0;
|
|
17
|
-
let i = 1;
|
|
18
|
-
for (; i < url.length; i++) {
|
|
19
|
-
if (url[i] !== "$")
|
|
20
|
-
continue;
|
|
21
|
-
if (url[i - 1] !== "/")
|
|
22
|
-
continue;
|
|
23
|
-
let e = url.indexOf("/", i + 1);
|
|
24
|
-
if (e === -1)
|
|
25
|
-
e = url.length;
|
|
26
|
-
into.push(url.slice(cursor, i));
|
|
27
|
-
into.push(url.slice(i, e));
|
|
28
|
-
cursor = e;
|
|
29
|
-
i = e - 1;
|
|
30
|
-
}
|
|
31
|
-
// remainder
|
|
32
|
-
if (cursor != i)
|
|
33
|
-
into.push(url.slice(cursor));
|
|
34
|
-
// remove _index from end if present
|
|
35
|
-
const lastI = into.length - 1;
|
|
36
|
-
const last = into[lastI];
|
|
37
|
-
if (last && last.endsWith(indexRoute)) {
|
|
38
|
-
if (last.length === indexRoute.length)
|
|
39
|
-
into.length--;
|
|
40
|
-
else
|
|
41
|
-
into[lastI] = last.slice(0, -indexRoute.length);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function Parse(fragments, params) {
|
|
45
|
-
let out = "";
|
|
46
|
-
for (const frag of fragments) {
|
|
47
|
-
if (!frag.startsWith("$")) {
|
|
48
|
-
out += frag;
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
const key = frag.slice(1);
|
|
52
|
-
const param = params[key];
|
|
53
|
-
if (!param)
|
|
54
|
-
throw new Error(`Missing ${key} parameter required for route`);
|
|
55
|
-
out += param;
|
|
56
|
-
}
|
|
57
|
-
return out;
|
|
58
|
-
}
|
package/vite/bundle-splitter.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ServerOnlyWarning } from "../internal/util.js";
|
|
2
|
-
ServerOnlyWarning("bundle-splitter");
|
|
3
|
-
const serverPattern = /\.server\.[tj]s(x)?/;
|
|
4
|
-
const clientPattern = /\.client\.[tj]s(x)?/;
|
|
5
|
-
const BLANK_MODULE = "export {};";
|
|
6
|
-
export function BundleSplitter() {
|
|
7
|
-
return {
|
|
8
|
-
name: "htmx-bundle-splitter",
|
|
9
|
-
enforce: "pre",
|
|
10
|
-
transform: (code, id, options) => {
|
|
11
|
-
const ssr = options?.ssr || false;
|
|
12
|
-
const pattern = ssr ? clientPattern : serverPattern;
|
|
13
|
-
if (pattern.test(id))
|
|
14
|
-
return BLANK_MODULE;
|
|
15
|
-
if (ssr) {
|
|
16
|
-
if (code.startsWith('"use client"'))
|
|
17
|
-
return BLANK_MODULE;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
if (code.startsWith('"use server"'))
|
|
21
|
-
return BLANK_MODULE;
|
|
22
|
-
}
|
|
23
|
-
return code;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
package/vite/client-island.d.ts
DELETED
package/vite/client-island.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { resolve } from "path";
|
|
2
|
-
import { CompileManifest } from "../internal/compile/manifest.js";
|
|
3
|
-
export function ClientIsland(framework) {
|
|
4
|
-
const file = resolve("./app/manifest.tsx").replaceAll("\\", "/");
|
|
5
|
-
return {
|
|
6
|
-
name: "vite-plugin-htmx-client-island",
|
|
7
|
-
enforce: "pre",
|
|
8
|
-
transform: (code, id, options) => {
|
|
9
|
-
if (id !== file)
|
|
10
|
-
return code;
|
|
11
|
-
return CompileManifest(framework, code, options?.ssr || false);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
package/vite/code-splitting.d.ts
DELETED
package/vite/code-splitting.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const serverPattern = /\.server\.[tj]s(x)?/;
|
|
2
|
-
const clientPattern = /\.client\.[tj]s(x)?/;
|
|
3
|
-
export function BundleSplitting() {
|
|
4
|
-
return {
|
|
5
|
-
name: "htmx-bundle-splitter",
|
|
6
|
-
enforce: "pre",
|
|
7
|
-
transform: (code, id, options) => {
|
|
8
|
-
const pattern = options?.ssr ? clientPattern : serverPattern;
|
|
9
|
-
if (pattern.test(id))
|
|
10
|
-
return "export {};";
|
|
11
|
-
return code;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
package/vite/index.d.ts
DELETED
package/vite/index.js
DELETED
package/vite/router.d.ts
DELETED
package/vite/router.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export function Router() {
|
|
2
|
-
const virtualModuleId = "virtual:htmx-router/dynamic.tsx";
|
|
3
|
-
const resolvedVirtualModuleId = '\0' + virtualModuleId;
|
|
4
|
-
return {
|
|
5
|
-
name: "vite-plugin-htmx-router",
|
|
6
|
-
resolveId(id) {
|
|
7
|
-
if (id === virtualModuleId)
|
|
8
|
-
return resolvedVirtualModuleId;
|
|
9
|
-
},
|
|
10
|
-
load(id) {
|
|
11
|
-
if (id !== resolvedVirtualModuleId)
|
|
12
|
-
return;
|
|
13
|
-
return source;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
const source = `export function Scripts() {
|
|
18
|
-
if (headCache) return headCache;
|
|
19
|
-
|
|
20
|
-
const res = <>
|
|
21
|
-
<link href={GetSheetUrl()} rel="stylesheet"></link>
|
|
22
|
-
{ isProduction ? "" : <script type="module" src="/@vite/client"></script> }
|
|
23
|
-
<script type="module" src={clientEntry}></script>
|
|
24
|
-
<script src={GetMountUrl()}></script>
|
|
25
|
-
</>;
|
|
26
|
-
|
|
27
|
-
if (isProduction) headCache = res;
|
|
28
|
-
return res;
|
|
29
|
-
}`;
|