webstudio 0.0.1-c87cdba.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/LICENSE +661 -0
- package/README.md +145 -0
- package/bin.js +5 -0
- package/lib/cli.js +5469 -0
- package/package.json +81 -0
- package/templates/cloudflare/WS_CF_README.md +48 -0
- package/templates/cloudflare/functions/[[path]].ts +9 -0
- package/templates/cloudflare/load-context.ts +9 -0
- package/templates/cloudflare/package.json +22 -0
- package/templates/cloudflare/tsconfig.json +18 -0
- package/templates/cloudflare/vite.config.ts +21 -0
- package/templates/cloudflare/worker-configuration.d.ts +3 -0
- package/templates/cloudflare/wrangler.toml +55 -0
- package/templates/defaults/app/constants.mjs +13 -0
- package/templates/defaults/app/extension.ts +16 -0
- package/templates/defaults/app/root.tsx +35 -0
- package/templates/defaults/app/route-templates/default-sitemap.tsx +34 -0
- package/templates/defaults/app/route-templates/html.tsx +341 -0
- package/templates/defaults/app/route-templates/redirect.tsx +6 -0
- package/templates/defaults/app/route-templates/xml.tsx +78 -0
- package/templates/defaults/app/routes/[robots.txt].tsx +24 -0
- package/templates/defaults/package.json +34 -0
- package/templates/defaults/public/favicon.ico +0 -0
- package/templates/defaults/tsconfig.json +22 -0
- package/templates/defaults/vite.config.ts +16 -0
- package/templates/internal/package.json +10 -0
- package/templates/internal/tsconfig.json +5 -0
- package/templates/netlify-edge-functions/app/constants.mjs +29 -0
- package/templates/netlify-edge-functions/app/entry.server.tsx +21 -0
- package/templates/netlify-edge-functions/netlify.toml +16 -0
- package/templates/netlify-edge-functions/package.json +9 -0
- package/templates/netlify-edge-functions/vite.config.ts +18 -0
- package/templates/netlify-functions/app/constants.mjs +29 -0
- package/templates/netlify-functions/app/entry.server.tsx +1 -0
- package/templates/netlify-functions/netlify.toml +16 -0
- package/templates/netlify-functions/package.json +9 -0
- package/templates/netlify-functions/vite.config.ts +18 -0
- package/templates/saas-helpers/package.json +6 -0
- package/templates/saas-helpers/tsconfig.json +18 -0
- package/templates/ssg/app/constants.mjs +14 -0
- package/templates/ssg/app/route-templates/html/+Head.tsx +92 -0
- package/templates/ssg/app/route-templates/html/+Page.tsx +21 -0
- package/templates/ssg/app/route-templates/html/+data.ts +37 -0
- package/templates/ssg/package.json +30 -0
- package/templates/ssg/pages/+config.ts +12 -0
- package/templates/ssg/public/favicon.ico +0 -0
- package/templates/ssg/renderer/+onRenderClient.tsx +30 -0
- package/templates/ssg/renderer/+onRenderHtml.tsx +29 -0
- package/templates/ssg/tsconfig.json +22 -0
- package/templates/ssg/vike.d.ts +26 -0
- package/templates/ssg/vite.config.ts +7 -0
- package/templates/ssg-netlify/app/constants.mjs +35 -0
- package/templates/ssg-vercel/app/constants.mjs +35 -0
- package/templates/ssg-vercel/public/vercel.json +11 -0
- package/templates/vercel/.vercelignore +8 -0
- package/templates/vercel/app/constants.mjs +29 -0
- package/templates/vercel/package.json +1 -0
- package/templates/vercel/vercel.json +11 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ServerRuntimeMetaFunction as MetaFunction,
|
|
3
|
+
type LinksFunction,
|
|
4
|
+
type LinkDescriptor,
|
|
5
|
+
type ActionFunctionArgs,
|
|
6
|
+
type LoaderFunctionArgs,
|
|
7
|
+
type HeadersFunction,
|
|
8
|
+
json,
|
|
9
|
+
redirect,
|
|
10
|
+
} from "@remix-run/server-runtime";
|
|
11
|
+
import { useLoaderData } from "@remix-run/react";
|
|
12
|
+
import {
|
|
13
|
+
isLocalResource,
|
|
14
|
+
loadResource,
|
|
15
|
+
loadResources,
|
|
16
|
+
formIdFieldName,
|
|
17
|
+
formBotFieldName,
|
|
18
|
+
} from "@webstudio-is/sdk/runtime";
|
|
19
|
+
import { ReactSdkContext } from "@webstudio-is/react-sdk/runtime";
|
|
20
|
+
import {
|
|
21
|
+
Page,
|
|
22
|
+
siteName,
|
|
23
|
+
favIconAsset,
|
|
24
|
+
pageFontAssets,
|
|
25
|
+
pageBackgroundImageAssets,
|
|
26
|
+
} from "__CLIENT__";
|
|
27
|
+
import {
|
|
28
|
+
getResources,
|
|
29
|
+
getPageMeta,
|
|
30
|
+
getRemixParams,
|
|
31
|
+
projectId,
|
|
32
|
+
contactEmail,
|
|
33
|
+
} from "__SERVER__";
|
|
34
|
+
import { assetBaseUrl, imageLoader } from "__CONSTANTS__";
|
|
35
|
+
import css from "__CSS__?url";
|
|
36
|
+
import { sitemap } from "__SITEMAP__";
|
|
37
|
+
|
|
38
|
+
const customFetch: typeof fetch = (input, init) => {
|
|
39
|
+
if (typeof input !== "string") {
|
|
40
|
+
return fetch(input, init);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (isLocalResource(input, "sitemap.xml")) {
|
|
44
|
+
// @todo: dynamic import sitemap ???
|
|
45
|
+
const response = new Response(JSON.stringify(sitemap));
|
|
46
|
+
response.headers.set("content-type", "application/json; charset=utf-8");
|
|
47
|
+
return Promise.resolve(response);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return fetch(input, init);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const loader = async (arg: LoaderFunctionArgs) => {
|
|
54
|
+
const url = new URL(arg.request.url);
|
|
55
|
+
const host =
|
|
56
|
+
arg.request.headers.get("x-forwarded-host") ||
|
|
57
|
+
arg.request.headers.get("host") ||
|
|
58
|
+
"";
|
|
59
|
+
url.host = host;
|
|
60
|
+
url.protocol = "https";
|
|
61
|
+
|
|
62
|
+
const params = getRemixParams(arg.params);
|
|
63
|
+
const system = {
|
|
64
|
+
params,
|
|
65
|
+
search: Object.fromEntries(url.searchParams),
|
|
66
|
+
origin: url.origin,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const resources = await loadResources(
|
|
70
|
+
customFetch,
|
|
71
|
+
getResources({ system }).data
|
|
72
|
+
);
|
|
73
|
+
const pageMeta = getPageMeta({ system, resources });
|
|
74
|
+
|
|
75
|
+
if (pageMeta.redirect) {
|
|
76
|
+
const status =
|
|
77
|
+
pageMeta.status === 301 || pageMeta.status === 302
|
|
78
|
+
? pageMeta.status
|
|
79
|
+
: 302;
|
|
80
|
+
return redirect(pageMeta.redirect, status);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// typecheck
|
|
84
|
+
arg.context.EXCLUDE_FROM_SEARCH satisfies boolean;
|
|
85
|
+
|
|
86
|
+
if (arg.context.EXCLUDE_FROM_SEARCH) {
|
|
87
|
+
pageMeta.excludePageFromSearch = arg.context.EXCLUDE_FROM_SEARCH;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return json(
|
|
91
|
+
{
|
|
92
|
+
host,
|
|
93
|
+
url: url.href,
|
|
94
|
+
system,
|
|
95
|
+
resources,
|
|
96
|
+
pageMeta,
|
|
97
|
+
},
|
|
98
|
+
// No way for current information to change, so add cache for 10 minutes
|
|
99
|
+
// In case of CRM Data, this should be set to 0
|
|
100
|
+
{
|
|
101
|
+
status: pageMeta.status,
|
|
102
|
+
headers: {
|
|
103
|
+
"Cache-Control": "public, max-age=600",
|
|
104
|
+
},
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const headers: HeadersFunction = () => {
|
|
110
|
+
return {
|
|
111
|
+
"Cache-Control": "public, max-age=0, must-revalidate",
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const meta: MetaFunction<typeof loader> = ({ data }) => {
|
|
116
|
+
const metas: ReturnType<MetaFunction> = [];
|
|
117
|
+
if (data === undefined) {
|
|
118
|
+
return metas;
|
|
119
|
+
}
|
|
120
|
+
const { pageMeta } = data;
|
|
121
|
+
|
|
122
|
+
if (data.url) {
|
|
123
|
+
metas.push({
|
|
124
|
+
property: "og:url",
|
|
125
|
+
content: data.url,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (pageMeta.title) {
|
|
130
|
+
metas.push({ title: pageMeta.title });
|
|
131
|
+
|
|
132
|
+
metas.push({
|
|
133
|
+
property: "og:title",
|
|
134
|
+
content: pageMeta.title,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
metas.push({ property: "og:type", content: "website" });
|
|
139
|
+
|
|
140
|
+
const origin = `https://${data.host}`;
|
|
141
|
+
|
|
142
|
+
if (siteName) {
|
|
143
|
+
metas.push({
|
|
144
|
+
property: "og:site_name",
|
|
145
|
+
content: siteName,
|
|
146
|
+
});
|
|
147
|
+
metas.push({
|
|
148
|
+
"script:ld+json": {
|
|
149
|
+
"@context": "https://schema.org",
|
|
150
|
+
"@type": "WebSite",
|
|
151
|
+
name: siteName,
|
|
152
|
+
url: origin,
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (pageMeta.excludePageFromSearch) {
|
|
158
|
+
metas.push({
|
|
159
|
+
name: "robots",
|
|
160
|
+
content: "noindex, nofollow",
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (pageMeta.description) {
|
|
165
|
+
metas.push({
|
|
166
|
+
name: "description",
|
|
167
|
+
content: pageMeta.description,
|
|
168
|
+
});
|
|
169
|
+
metas.push({
|
|
170
|
+
property: "og:description",
|
|
171
|
+
content: pageMeta.description,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (pageMeta.socialImageAssetName) {
|
|
176
|
+
metas.push({
|
|
177
|
+
property: "og:image",
|
|
178
|
+
content: `https://${data.host}${imageLoader({
|
|
179
|
+
src: pageMeta.socialImageAssetName,
|
|
180
|
+
// Do not transform social image (not enough information do we need to do this)
|
|
181
|
+
format: "raw",
|
|
182
|
+
})}`,
|
|
183
|
+
});
|
|
184
|
+
} else if (pageMeta.socialImageUrl) {
|
|
185
|
+
metas.push({
|
|
186
|
+
property: "og:image",
|
|
187
|
+
content: pageMeta.socialImageUrl,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
metas.push(...pageMeta.custom);
|
|
192
|
+
|
|
193
|
+
return metas;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export const links: LinksFunction = () => {
|
|
197
|
+
const result: LinkDescriptor[] = [];
|
|
198
|
+
|
|
199
|
+
result.push({
|
|
200
|
+
rel: "stylesheet",
|
|
201
|
+
href: css,
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
if (favIconAsset) {
|
|
205
|
+
result.push({
|
|
206
|
+
rel: "icon",
|
|
207
|
+
href: imageLoader({
|
|
208
|
+
src: favIconAsset.name,
|
|
209
|
+
// width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
|
|
210
|
+
width: 144,
|
|
211
|
+
height: 144,
|
|
212
|
+
fit: "pad",
|
|
213
|
+
quality: 100,
|
|
214
|
+
format: "auto",
|
|
215
|
+
}),
|
|
216
|
+
type: undefined,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
for (const asset of pageFontAssets) {
|
|
221
|
+
result.push({
|
|
222
|
+
rel: "preload",
|
|
223
|
+
href: `${assetBaseUrl}${asset.name}`,
|
|
224
|
+
as: "font",
|
|
225
|
+
crossOrigin: "anonymous",
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
for (const backgroundImageAsset of pageBackgroundImageAssets) {
|
|
230
|
+
result.push({
|
|
231
|
+
rel: "preload",
|
|
232
|
+
href: `${assetBaseUrl}${backgroundImageAsset.name}`,
|
|
233
|
+
as: "image",
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return result;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
const getRequestHost = (request: Request): string =>
|
|
241
|
+
request.headers.get("x-forwarded-host") || request.headers.get("host") || "";
|
|
242
|
+
|
|
243
|
+
export const action = async ({
|
|
244
|
+
request,
|
|
245
|
+
context,
|
|
246
|
+
}: ActionFunctionArgs): Promise<
|
|
247
|
+
{ success: true } | { success: false; errors: string[] }
|
|
248
|
+
> => {
|
|
249
|
+
try {
|
|
250
|
+
const url = new URL(request.url);
|
|
251
|
+
url.host = getRequestHost(request);
|
|
252
|
+
|
|
253
|
+
const formData = await request.formData();
|
|
254
|
+
|
|
255
|
+
const system = {
|
|
256
|
+
params: {},
|
|
257
|
+
search: {},
|
|
258
|
+
origin: url.origin,
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
const resourceName = formData.get(formIdFieldName);
|
|
262
|
+
let resource =
|
|
263
|
+
typeof resourceName === "string"
|
|
264
|
+
? getResources({ system }).action.get(resourceName)
|
|
265
|
+
: undefined;
|
|
266
|
+
|
|
267
|
+
const formBotValue = formData.get(formBotFieldName);
|
|
268
|
+
|
|
269
|
+
if (formBotValue == null || typeof formBotValue !== "string") {
|
|
270
|
+
throw new Error("Form bot field not found");
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const submitTime = parseInt(formBotValue, 16);
|
|
274
|
+
// Assumes that the difference between the server time and the form submission time,
|
|
275
|
+
// including any client-server time drift, is within a 5-minute range.
|
|
276
|
+
// Note: submitTime might be NaN because formBotValue can be any string used for logging purposes.
|
|
277
|
+
// Example: `formBotValue: jsdom`, or `formBotValue: headless-env`
|
|
278
|
+
if (
|
|
279
|
+
Number.isNaN(submitTime) ||
|
|
280
|
+
Math.abs(Date.now() - submitTime) > 1000 * 60 * 5
|
|
281
|
+
) {
|
|
282
|
+
throw new Error(`Form bot value invalid ${formBotValue}`);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
formData.delete(formIdFieldName);
|
|
286
|
+
formData.delete(formBotFieldName);
|
|
287
|
+
|
|
288
|
+
if (resource) {
|
|
289
|
+
resource.headers.push({
|
|
290
|
+
name: "Content-Type",
|
|
291
|
+
value: "application/json",
|
|
292
|
+
});
|
|
293
|
+
resource.body = Object.fromEntries(formData);
|
|
294
|
+
} else {
|
|
295
|
+
if (contactEmail === undefined) {
|
|
296
|
+
throw new Error("Contact email not found");
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
resource = context.getDefaultActionResource?.({
|
|
300
|
+
url,
|
|
301
|
+
projectId,
|
|
302
|
+
contactEmail,
|
|
303
|
+
formData,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (resource === undefined) {
|
|
308
|
+
throw Error("Resource not found");
|
|
309
|
+
}
|
|
310
|
+
const { ok, statusText } = await loadResource(fetch, resource);
|
|
311
|
+
if (ok) {
|
|
312
|
+
return { success: true };
|
|
313
|
+
}
|
|
314
|
+
return { success: false, errors: [statusText] };
|
|
315
|
+
} catch (error) {
|
|
316
|
+
console.error(error);
|
|
317
|
+
|
|
318
|
+
return {
|
|
319
|
+
success: false,
|
|
320
|
+
errors: [error instanceof Error ? error.message : "Unknown error"],
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const Outlet = () => {
|
|
326
|
+
const { system, resources, url } = useLoaderData<typeof loader>();
|
|
327
|
+
return (
|
|
328
|
+
<ReactSdkContext.Provider
|
|
329
|
+
value={{
|
|
330
|
+
imageLoader,
|
|
331
|
+
assetBaseUrl,
|
|
332
|
+
resources,
|
|
333
|
+
}}
|
|
334
|
+
>
|
|
335
|
+
{/* Use the URL as the key to force scripts in HTML Embed to reload on dynamic pages */}
|
|
336
|
+
<Page key={url} system={system} />
|
|
337
|
+
</ReactSdkContext.Provider>
|
|
338
|
+
);
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
export default Outlet;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { renderToString } from "react-dom/server";
|
|
2
|
+
import { type LoaderFunctionArgs, redirect } from "@remix-run/server-runtime";
|
|
3
|
+
import { isLocalResource, loadResources } from "@webstudio-is/sdk/runtime";
|
|
4
|
+
import { ReactSdkContext } from "@webstudio-is/react-sdk/runtime";
|
|
5
|
+
import { Page } from "__CLIENT__";
|
|
6
|
+
import { getPageMeta, getRemixParams, getResources } from "__SERVER__";
|
|
7
|
+
import { assetBaseUrl, imageLoader } from "__CONSTANTS__";
|
|
8
|
+
import { sitemap } from "__SITEMAP__";
|
|
9
|
+
|
|
10
|
+
const customFetch: typeof fetch = (input, init) => {
|
|
11
|
+
if (typeof input !== "string") {
|
|
12
|
+
return fetch(input, init);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (isLocalResource(input, "sitemap.xml")) {
|
|
16
|
+
// @todo: dynamic import sitemap ???
|
|
17
|
+
const response = new Response(JSON.stringify(sitemap));
|
|
18
|
+
response.headers.set("content-type", "application/json; charset=utf-8");
|
|
19
|
+
return Promise.resolve(response);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return fetch(input, init);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const loader = async (arg: LoaderFunctionArgs) => {
|
|
26
|
+
const url = new URL(arg.request.url);
|
|
27
|
+
const host =
|
|
28
|
+
arg.request.headers.get("x-forwarded-host") ||
|
|
29
|
+
arg.request.headers.get("host") ||
|
|
30
|
+
"";
|
|
31
|
+
url.host = host;
|
|
32
|
+
url.protocol = "https";
|
|
33
|
+
|
|
34
|
+
const params = getRemixParams(arg.params);
|
|
35
|
+
|
|
36
|
+
const system = {
|
|
37
|
+
params,
|
|
38
|
+
search: Object.fromEntries(url.searchParams),
|
|
39
|
+
origin: url.origin,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const resources = await loadResources(
|
|
43
|
+
customFetch,
|
|
44
|
+
getResources({ system }).data
|
|
45
|
+
);
|
|
46
|
+
const pageMeta = getPageMeta({ system, resources });
|
|
47
|
+
|
|
48
|
+
if (pageMeta.redirect) {
|
|
49
|
+
const status =
|
|
50
|
+
pageMeta.status === 301 || pageMeta.status === 302
|
|
51
|
+
? pageMeta.status
|
|
52
|
+
: 302;
|
|
53
|
+
return redirect(pageMeta.redirect, status);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// typecheck
|
|
57
|
+
arg.context.EXCLUDE_FROM_SEARCH satisfies boolean;
|
|
58
|
+
|
|
59
|
+
let text = renderToString(
|
|
60
|
+
<ReactSdkContext.Provider
|
|
61
|
+
value={{
|
|
62
|
+
imageLoader,
|
|
63
|
+
assetBaseUrl,
|
|
64
|
+
resources,
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
<Page system={system} />
|
|
68
|
+
</ReactSdkContext.Provider>
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// Xml is wrapped with <svg> to prevent React from hoisting elements like <title>, <meta>, and <link> out of their intended scope during rendering.
|
|
72
|
+
// More details: https://github.com/facebook/react/blob/7c8e5e7ab8bb63de911637892392c5efd8ce1d0f/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js#L3083
|
|
73
|
+
text = text.replace(/^<svg>/g, "").replace(/<\/svg>$/g, "");
|
|
74
|
+
|
|
75
|
+
return new Response(`<?xml version="1.0" encoding="UTF-8"?>\n${text}`, {
|
|
76
|
+
headers: { "Content-Type": "application/xml" },
|
|
77
|
+
});
|
|
78
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LoaderFunctionArgs } from "@remix-run/server-runtime";
|
|
2
|
+
|
|
3
|
+
export const loader = (arg: LoaderFunctionArgs) => {
|
|
4
|
+
const host =
|
|
5
|
+
arg.request.headers.get("x-forwarded-host") ||
|
|
6
|
+
arg.request.headers.get("host") ||
|
|
7
|
+
"";
|
|
8
|
+
|
|
9
|
+
return new Response(
|
|
10
|
+
`
|
|
11
|
+
User-agent: *
|
|
12
|
+
Disallow: /api/
|
|
13
|
+
|
|
14
|
+
Sitemap: https://${host}/sitemap.xml
|
|
15
|
+
|
|
16
|
+
`,
|
|
17
|
+
{
|
|
18
|
+
headers: {
|
|
19
|
+
"Content-Type": "text/plain",
|
|
20
|
+
},
|
|
21
|
+
status: 200,
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"private": true,
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "remix vite:build",
|
|
7
|
+
"dev": "remix vite:dev",
|
|
8
|
+
"typecheck": "tsc"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@remix-run/node": "2.15.2",
|
|
12
|
+
"@remix-run/react": "2.15.2",
|
|
13
|
+
"@remix-run/server-runtime": "2.15.2",
|
|
14
|
+
"@webstudio-is/react-sdk": "0.0.0-webstudio-version",
|
|
15
|
+
"@webstudio-is/sdk-components-react-radix": "0.0.0-webstudio-version",
|
|
16
|
+
"@webstudio-is/sdk-components-react-remix": "0.0.0-webstudio-version",
|
|
17
|
+
"@webstudio-is/sdk-components-react": "0.0.0-webstudio-version",
|
|
18
|
+
"@webstudio-is/image": "0.0.0-webstudio-version",
|
|
19
|
+
"@webstudio-is/sdk": "0.0.0-webstudio-version",
|
|
20
|
+
"isbot": "^5.1.19",
|
|
21
|
+
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
22
|
+
"react-dom": "18.3.0-canary-14898b6a9-20240318"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@remix-run/dev": "2.15.2",
|
|
26
|
+
"@types/react": "^18.2.70",
|
|
27
|
+
"@types/react-dom": "^18.2.25",
|
|
28
|
+
"typescript": "5.7.2",
|
|
29
|
+
"vite": "^5.4.11"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=20.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": ["**/*.ts", "**/*.tsx", "**/*.mjs"],
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
5
|
+
"types": [
|
|
6
|
+
"@remix-run/node",
|
|
7
|
+
"vite/client",
|
|
8
|
+
"@webstudio-is/react-sdk/placeholder"
|
|
9
|
+
],
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"jsx": "react-jsx",
|
|
13
|
+
"module": "ESNext",
|
|
14
|
+
"moduleResolution": "bundler",
|
|
15
|
+
"target": "ES2022",
|
|
16
|
+
"strict": true,
|
|
17
|
+
"allowJs": true,
|
|
18
|
+
"forceConsistentCasingInFileNames": true,
|
|
19
|
+
"noEmit": true,
|
|
20
|
+
"skipLibCheck": true
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import { vitePlugin as remix } from "@remix-run/dev";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [
|
|
6
|
+
remix({
|
|
7
|
+
future: {
|
|
8
|
+
v3_lazyRouteDiscovery: false,
|
|
9
|
+
v3_relativeSplatPath: false,
|
|
10
|
+
v3_singleFetch: false,
|
|
11
|
+
v3_fetcherPersist: false,
|
|
12
|
+
v3_throwAbortReason: false,
|
|
13
|
+
},
|
|
14
|
+
}),
|
|
15
|
+
],
|
|
16
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"dependencies": {
|
|
3
|
+
"@webstudio-is/react-sdk": "workspace:*",
|
|
4
|
+
"@webstudio-is/sdk-components-react-radix": "workspace:*",
|
|
5
|
+
"@webstudio-is/sdk-components-react-remix": "workspace:*",
|
|
6
|
+
"@webstudio-is/sdk-components-react": "workspace:*",
|
|
7
|
+
"@webstudio-is/image": "workspace:*",
|
|
8
|
+
"@webstudio-is/sdk": "workspace:*"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We use mjs extension as constants in this file is shared with the build script
|
|
3
|
+
* and we use `node --eval` to extract the constants.
|
|
4
|
+
*/
|
|
5
|
+
export const assetBaseUrl = "/assets/";
|
|
6
|
+
export const imageBaseUrl = "/assets/";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @type {import("@webstudio-is/image").ImageLoader}
|
|
10
|
+
*/
|
|
11
|
+
export const imageLoader = (props) => {
|
|
12
|
+
if (process.env.NODE_ENV !== "production") {
|
|
13
|
+
return props.src;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (props.format === "raw") {
|
|
17
|
+
return props.src;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// https://docs.netlify.com/image-cdn/overview/
|
|
21
|
+
return (
|
|
22
|
+
"/.netlify/images?url=" +
|
|
23
|
+
encodeURIComponent(props.src) +
|
|
24
|
+
"&w=" +
|
|
25
|
+
props.width +
|
|
26
|
+
"&q=" +
|
|
27
|
+
props.quality
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EntryContext } from "@remix-run/node";
|
|
2
|
+
import { RemixServer } from "@remix-run/react";
|
|
3
|
+
import { renderToString } from "react-dom/server";
|
|
4
|
+
|
|
5
|
+
export default function handleRequest(
|
|
6
|
+
request: Request,
|
|
7
|
+
responseStatusCode: number,
|
|
8
|
+
responseHeaders: Headers,
|
|
9
|
+
remixContext: EntryContext
|
|
10
|
+
) {
|
|
11
|
+
const markup = renderToString(
|
|
12
|
+
<RemixServer context={remixContext} url={request.url} />
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
responseHeaders.set("Content-Type", "text/html");
|
|
16
|
+
|
|
17
|
+
return new Response("<!DOCTYPE html>" + markup, {
|
|
18
|
+
headers: responseHeaders,
|
|
19
|
+
status: responseStatusCode,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[build]
|
|
2
|
+
command = "npm run build"
|
|
3
|
+
publish = "build/client"
|
|
4
|
+
|
|
5
|
+
[dev]
|
|
6
|
+
command = "npm run dev"
|
|
7
|
+
framework = "vite"
|
|
8
|
+
|
|
9
|
+
# Set immutable caching for static files, because they have fingerprinted filenames
|
|
10
|
+
|
|
11
|
+
[[headers]]
|
|
12
|
+
for = "/build/*"
|
|
13
|
+
|
|
14
|
+
[headers.values]
|
|
15
|
+
|
|
16
|
+
"Cache-Control" = "public, max-age=31560000, immutable"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { vitePlugin as remix } from "@remix-run/dev";
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
|
+
import { netlifyPlugin } from "@netlify/remix-edge-adapter/plugin";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [
|
|
7
|
+
remix({
|
|
8
|
+
future: {
|
|
9
|
+
v3_lazyRouteDiscovery: false,
|
|
10
|
+
v3_relativeSplatPath: false,
|
|
11
|
+
v3_singleFetch: false,
|
|
12
|
+
v3_fetcherPersist: false,
|
|
13
|
+
v3_throwAbortReason: false,
|
|
14
|
+
},
|
|
15
|
+
}),
|
|
16
|
+
netlifyPlugin(),
|
|
17
|
+
],
|
|
18
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We use mjs extension as constants in this file is shared with the build script
|
|
3
|
+
* and we use `node --eval` to extract the constants.
|
|
4
|
+
*/
|
|
5
|
+
export const assetBaseUrl = "/assets/";
|
|
6
|
+
export const imageBaseUrl = "/assets/";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @type {import("@webstudio-is/image").ImageLoader}
|
|
10
|
+
*/
|
|
11
|
+
export const imageLoader = (props) => {
|
|
12
|
+
if (process.env.NODE_ENV !== "production") {
|
|
13
|
+
return props.src;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (props.format === "raw") {
|
|
17
|
+
return props.src;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// https://docs.netlify.com/image-cdn/overview/
|
|
21
|
+
return (
|
|
22
|
+
"/.netlify/images?url=" +
|
|
23
|
+
encodeURIComponent(props.src) +
|
|
24
|
+
"&w=" +
|
|
25
|
+
props.width +
|
|
26
|
+
"&q=" +
|
|
27
|
+
props.quality
|
|
28
|
+
);
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { handleRequest as default } from "@netlify/remix-adapter";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[build]
|
|
2
|
+
command = "npm run build"
|
|
3
|
+
publish = "build/client"
|
|
4
|
+
|
|
5
|
+
[dev]
|
|
6
|
+
command = "npm run dev"
|
|
7
|
+
framework = "vite"
|
|
8
|
+
|
|
9
|
+
# Set immutable caching for static files, because they have fingerprinted filenames
|
|
10
|
+
|
|
11
|
+
[[headers]]
|
|
12
|
+
for = "/build/*"
|
|
13
|
+
|
|
14
|
+
[headers.values]
|
|
15
|
+
|
|
16
|
+
"Cache-Control" = "public, max-age=31560000, immutable"
|