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
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "webstudio",
|
|
3
|
+
"version": "0.0.1-c87cdba.0",
|
|
4
|
+
"description": "Webstudio CLI",
|
|
5
|
+
"author": "Webstudio <github@webstudio.is>",
|
|
6
|
+
"homepage": "https://webstudio.is",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"webstudio-cli": "./bin.js",
|
|
10
|
+
"webstudio": "./bin.js"
|
|
11
|
+
},
|
|
12
|
+
"imports": {
|
|
13
|
+
"#cli": {
|
|
14
|
+
"webstudio": "./src/cli.ts",
|
|
15
|
+
"default": "./lib/cli.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"lib/*",
|
|
20
|
+
"templates/*",
|
|
21
|
+
"bin.js",
|
|
22
|
+
"!*.{test,stories}.*"
|
|
23
|
+
],
|
|
24
|
+
"license": "AGPL-3.0-or-later",
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20.12"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@clack/prompts": "^0.7.0",
|
|
30
|
+
"@emotion/hash": "^0.9.2",
|
|
31
|
+
"acorn": "^8.14.0",
|
|
32
|
+
"acorn-walk": "^8.3.4",
|
|
33
|
+
"change-case": "^5.4.4",
|
|
34
|
+
"deepmerge": "^4.3.1",
|
|
35
|
+
"env-paths": "^3.0.0",
|
|
36
|
+
"nanoid": "^5.0.8",
|
|
37
|
+
"p-limit": "^4.0.0",
|
|
38
|
+
"parse5": "7.1.2",
|
|
39
|
+
"picocolors": "^1.1.0",
|
|
40
|
+
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
41
|
+
"reserved-identifiers": "^1.0.0",
|
|
42
|
+
"tinyexec": "^0.3.1",
|
|
43
|
+
"warn-once": "^0.1.1",
|
|
44
|
+
"yargs": "^17.7.2",
|
|
45
|
+
"zod": "^3.22.4"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@netlify/remix-adapter": "^2.5.1",
|
|
49
|
+
"@netlify/remix-edge-adapter": "3.4.2",
|
|
50
|
+
"@remix-run/cloudflare": "^2.15.2",
|
|
51
|
+
"@remix-run/cloudflare-pages": "^2.15.2",
|
|
52
|
+
"@remix-run/dev": "^2.15.2",
|
|
53
|
+
"@remix-run/node": "^2.15.2",
|
|
54
|
+
"@remix-run/react": "^2.15.2",
|
|
55
|
+
"@remix-run/server-runtime": "^2.15.2",
|
|
56
|
+
"@types/react": "^18.2.70",
|
|
57
|
+
"@types/react-dom": "^18.2.25",
|
|
58
|
+
"@types/yargs": "^17.0.33",
|
|
59
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
60
|
+
"prettier": "3.4.2",
|
|
61
|
+
"react-dom": "18.3.0-canary-14898b6a9-20240318",
|
|
62
|
+
"ts-expect": "^1.3.0",
|
|
63
|
+
"vike": "^0.4.210",
|
|
64
|
+
"vite": "^5.4.11",
|
|
65
|
+
"vitest": "^2.1.8",
|
|
66
|
+
"wrangler": "^3.63.2",
|
|
67
|
+
"@webstudio-is/http-client": "0.0.1-c87cdba.0",
|
|
68
|
+
"@webstudio-is/image": "0.0.1-c87cdba.0",
|
|
69
|
+
"@webstudio-is/sdk": "0.0.1-c87cdba.0",
|
|
70
|
+
"@webstudio-is/sdk-components-react-radix": "0.0.1-c87cdba.0",
|
|
71
|
+
"@webstudio-is/sdk-components-react": "0.0.1-c87cdba.0",
|
|
72
|
+
"@webstudio-is/react-sdk": "0.0.1-c87cdba.0",
|
|
73
|
+
"@webstudio-is/sdk-components-react-remix": "0.0.1-c87cdba.0",
|
|
74
|
+
"@webstudio-is/tsconfig": "1.0.8-c87cdba.0"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"typecheck": "tsc",
|
|
78
|
+
"build": "rm -rf lib && vite build",
|
|
79
|
+
"test": "vitest run"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Welcome to Remix + Vite!
|
|
2
|
+
|
|
3
|
+
📖 See the [Remix docs](https://remix.run/docs) and the [Remix Vite docs](https://remix.run/docs/en/main/future/vite) for details on supported features.
|
|
4
|
+
|
|
5
|
+
## Typegen
|
|
6
|
+
|
|
7
|
+
Generate types for your Cloudflare bindings in `wrangler.toml`:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm run typegen
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
You will need to rerun typegen whenever you make changes to `wrangler.toml`.
|
|
14
|
+
|
|
15
|
+
## Development
|
|
16
|
+
|
|
17
|
+
Run the Vite dev server:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npm run dev
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
To run Wrangler:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
npm run build
|
|
27
|
+
npm run start
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Deployment
|
|
31
|
+
|
|
32
|
+
> [!WARNING]
|
|
33
|
+
> Cloudflare does _not_ use `wrangler.toml` to configure deployment bindings.
|
|
34
|
+
> You **MUST** [configure deployment bindings manually in the Cloudflare dashboard][bindings].
|
|
35
|
+
|
|
36
|
+
First, build your app for production:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm run build
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Then, deploy your app to Cloudflare Pages:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm run deploy
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
[bindings]: https://developers.cloudflare.com/pages/functions/bindings/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createPagesFunctionHandler } from "@remix-run/cloudflare-pages";
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
|
+
// @ts-ignore - the server build file is generated by `remix vite:build`
|
|
5
|
+
import * as build from "../build/server";
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
|
+
// @ts-ignore - the server build file is generated by `remix vite:build`
|
|
9
|
+
export const onRequest = createPagesFunctionHandler({ build });
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"private": true,
|
|
3
|
+
"sideEffects": false,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "remix vite:build",
|
|
7
|
+
"deploy": "npm run build && wrangler pages deploy ./build/client",
|
|
8
|
+
"dev": "remix vite:dev",
|
|
9
|
+
"start": "wrangler pages dev ./build/client",
|
|
10
|
+
"typegen": "wrangler types",
|
|
11
|
+
"preview": "npm run build && wrangler pages dev ./build/client",
|
|
12
|
+
"build-cf-types": "wrangler types"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@remix-run/cloudflare": "2.15.2",
|
|
16
|
+
"@remix-run/cloudflare-pages": "2.15.2"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@cloudflare/workers-types": "^4.20240620.0",
|
|
20
|
+
"wrangler": "^3.63.2"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": [
|
|
3
|
+
"**/*.ts",
|
|
4
|
+
"**/*.tsx",
|
|
5
|
+
"**/.server/**/*.ts",
|
|
6
|
+
"**/.server/**/*.tsx",
|
|
7
|
+
"**/.client/**/*.ts",
|
|
8
|
+
"**/.client/**/*.tsx"
|
|
9
|
+
],
|
|
10
|
+
"compilerOptions": {
|
|
11
|
+
"types": [
|
|
12
|
+
"@remix-run/cloudflare",
|
|
13
|
+
"vite/client",
|
|
14
|
+
"@cloudflare/workers-types/2023-07-01",
|
|
15
|
+
"@webstudio-is/react-sdk/placeholder"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
vitePlugin as remix,
|
|
3
|
+
cloudflareDevProxyVitePlugin as remixCloudflareDevProxy,
|
|
4
|
+
} from "@remix-run/dev";
|
|
5
|
+
import { defineConfig } from "vite";
|
|
6
|
+
|
|
7
|
+
export default defineConfig(({ mode }) => ({
|
|
8
|
+
plugins: [
|
|
9
|
+
// without this, remixCloudflareDevProxy trying to load workerd even for production (it's not needed for production)
|
|
10
|
+
mode === "production" ? undefined : remixCloudflareDevProxy(),
|
|
11
|
+
remix({
|
|
12
|
+
future: {
|
|
13
|
+
v3_lazyRouteDiscovery: false,
|
|
14
|
+
v3_relativeSplatPath: false,
|
|
15
|
+
v3_singleFetch: false,
|
|
16
|
+
v3_fetcherPersist: false,
|
|
17
|
+
v3_throwAbortReason: false,
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
].filter(Boolean),
|
|
21
|
+
}));
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#:schema node_modules/wrangler/config-schema.json
|
|
2
|
+
# https://developers.cloudflare.com/pages/functions/wrangler-configuration/
|
|
3
|
+
name = "webstudio-remix-app"
|
|
4
|
+
compatibility_date = "2024-04-05"
|
|
5
|
+
pages_build_output_dir="./build"
|
|
6
|
+
|
|
7
|
+
# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
|
|
8
|
+
# Note: Use secrets to store sensitive data.
|
|
9
|
+
# Docs: https://developers.cloudflare.com/pages/functions/bindings/#environment-variables
|
|
10
|
+
# [vars]
|
|
11
|
+
# MY_VARIABLE = "production_value"
|
|
12
|
+
|
|
13
|
+
# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
|
|
14
|
+
# Docs: https://developers.cloudflare.com/pages/functions/bindings/#workers-ai
|
|
15
|
+
# [ai]
|
|
16
|
+
# binding = "AI"
|
|
17
|
+
|
|
18
|
+
# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
|
|
19
|
+
# Docs: https://developers.cloudflare.com/pages/functions/bindings/#d1-databases
|
|
20
|
+
# [[d1_databases]]
|
|
21
|
+
# binding = "MY_DB"
|
|
22
|
+
# database_name = "my-database"
|
|
23
|
+
# database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
|
|
24
|
+
|
|
25
|
+
# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
|
|
26
|
+
# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
|
|
27
|
+
# Docs: https://developers.cloudflare.com/workers/runtime-apis/durable-objects
|
|
28
|
+
# [[durable_objects.bindings]]
|
|
29
|
+
# name = "MY_DURABLE_OBJECT"
|
|
30
|
+
# class_name = "MyDurableObject"
|
|
31
|
+
# script_name = 'my-durable-object'
|
|
32
|
+
|
|
33
|
+
# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
|
|
34
|
+
# Docs: https://developers.cloudflare.com/pages/functions/bindings/#kv-namespaces
|
|
35
|
+
# [[kv_namespaces]]
|
|
36
|
+
# binding = "MY_KV_NAMESPACE"
|
|
37
|
+
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
|
38
|
+
|
|
39
|
+
# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
|
|
40
|
+
# Docs: https://developers.cloudflare.com/pages/functions/bindings/#queue-producers
|
|
41
|
+
# [[queues.producers]]
|
|
42
|
+
# binding = "MY_QUEUE"
|
|
43
|
+
# queue = "my-queue"
|
|
44
|
+
|
|
45
|
+
# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
|
|
46
|
+
# Docs: https://developers.cloudflare.com/pages/functions/bindings/#r2-buckets
|
|
47
|
+
# [[r2_buckets]]
|
|
48
|
+
# binding = "MY_BUCKET"
|
|
49
|
+
# bucket_name = "my-bucket"
|
|
50
|
+
|
|
51
|
+
# Bind another Worker service. Use this binding to call another Worker without network overhead.
|
|
52
|
+
# Docs: https://developers.cloudflare.com/pages/functions/bindings/#service-bindings
|
|
53
|
+
# [[services]]
|
|
54
|
+
# binding = "MY_SERVICE"
|
|
55
|
+
# service = "my-service"
|
|
@@ -0,0 +1,13 @@
|
|
|
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 = ({ src }) => {
|
|
12
|
+
return src;
|
|
13
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2
|
+
// @ts-ignore
|
|
3
|
+
import { AppLoadContext } from "@remix-run/server-runtime";
|
|
4
|
+
import { ResourceRequest } from "@webstudio-is/sdk";
|
|
5
|
+
|
|
6
|
+
declare module "@remix-run/server-runtime" {
|
|
7
|
+
interface AppLoadContext {
|
|
8
|
+
EXCLUDE_FROM_SEARCH: boolean;
|
|
9
|
+
getDefaultActionResource?: (options: {
|
|
10
|
+
url: URL;
|
|
11
|
+
projectId: string;
|
|
12
|
+
contactEmail: string;
|
|
13
|
+
formData: FormData;
|
|
14
|
+
}) => ResourceRequest;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
|
+
|
|
3
|
+
import { Links, Meta, Outlet, useMatches } from "@remix-run/react";
|
|
4
|
+
// @todo think about how to make __generated__ typeable
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import { CustomCode } from "./__generated__/_index";
|
|
7
|
+
|
|
8
|
+
const Root = () => {
|
|
9
|
+
// Get language from matches
|
|
10
|
+
const matches = useMatches();
|
|
11
|
+
|
|
12
|
+
const lastMatchWithLanguage = matches.findLast((match) => {
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
const language = match?.data?.pageMeta?.language;
|
|
15
|
+
return language != null;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
const lang = lastMatchWithLanguage?.data?.pageMeta?.language ?? "en";
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<html lang={lang}>
|
|
23
|
+
<head>
|
|
24
|
+
<meta charSet="utf-8" />
|
|
25
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
26
|
+
<Meta />
|
|
27
|
+
<Links />
|
|
28
|
+
<CustomCode />
|
|
29
|
+
</head>
|
|
30
|
+
<Outlet />
|
|
31
|
+
</html>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default Root;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { LoaderFunctionArgs } from "@remix-run/server-runtime";
|
|
2
|
+
import { sitemap } from "__SITEMAP__";
|
|
3
|
+
|
|
4
|
+
export const loader = (arg: LoaderFunctionArgs) => {
|
|
5
|
+
const host =
|
|
6
|
+
arg.request.headers.get("x-forwarded-host") ||
|
|
7
|
+
arg.request.headers.get("host") ||
|
|
8
|
+
"";
|
|
9
|
+
|
|
10
|
+
const urls = sitemap.map((page) => {
|
|
11
|
+
const url = new URL(`https://${host}${page.path}`);
|
|
12
|
+
|
|
13
|
+
return `
|
|
14
|
+
<url>
|
|
15
|
+
<loc>${url.href}</loc>
|
|
16
|
+
<lastmod>${page.lastModified.split("T")[0]}</lastmod>
|
|
17
|
+
</url>
|
|
18
|
+
`;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return new Response(
|
|
22
|
+
`<?xml version="1.0" encoding="UTF-8"?>
|
|
23
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
24
|
+
${urls.join("")}
|
|
25
|
+
</urlset>
|
|
26
|
+
`,
|
|
27
|
+
{
|
|
28
|
+
headers: {
|
|
29
|
+
"Content-Type": "application/xml",
|
|
30
|
+
},
|
|
31
|
+
status: 200,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
};
|