@webstudio-is/react-sdk 0.59.0 → 0.61.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.
Files changed (163) hide show
  1. package/lib/app/custom-components/shared/remix-link.js +2 -2
  2. package/lib/app/index.js +0 -1
  3. package/lib/cjs/app/custom-components/shared/remix-link.js +2 -2
  4. package/lib/cjs/app/index.js +0 -1
  5. package/lib/cjs/components/__generated__/blockquote.props.js +5 -0
  6. package/lib/cjs/components/__generated__/body.props.js +5 -0
  7. package/lib/cjs/components/__generated__/bold.props.js +5 -0
  8. package/lib/cjs/components/__generated__/box.props.js +5 -0
  9. package/lib/cjs/components/__generated__/button.props.js +5 -1
  10. package/lib/cjs/components/__generated__/code.props.js +5 -0
  11. package/lib/cjs/components/__generated__/form.props.js +5 -0
  12. package/lib/cjs/components/__generated__/heading.props.js +5 -0
  13. package/lib/cjs/components/__generated__/image.props.js +5 -0
  14. package/lib/cjs/components/__generated__/input.props.js +11 -2
  15. package/lib/cjs/components/__generated__/italic.props.js +5 -0
  16. package/lib/cjs/components/__generated__/link-block.props.js +5 -1
  17. package/lib/cjs/components/__generated__/link.props.js +5 -1
  18. package/lib/cjs/components/__generated__/list-item.props.js +5 -0
  19. package/lib/cjs/components/__generated__/list.props.js +5 -0
  20. package/lib/cjs/components/__generated__/paragraph.props.js +5 -0
  21. package/lib/cjs/components/__generated__/rich-text-link.props.js +5 -1
  22. package/lib/cjs/components/__generated__/separator.props.js +5 -0
  23. package/lib/cjs/components/__generated__/span.props.js +5 -0
  24. package/lib/cjs/components/__generated__/subscript.props.js +5 -0
  25. package/lib/cjs/components/__generated__/superscript.props.js +5 -0
  26. package/lib/cjs/components/__generated__/text-block.props.js +5 -0
  27. package/lib/cjs/components/blockquote.ws.js +36 -48
  28. package/lib/cjs/components/body.ws.js +19 -24
  29. package/lib/cjs/components/button.ws.js +1 -1
  30. package/lib/cjs/components/code.ws.js +20 -28
  31. package/lib/cjs/components/component-meta.js +2 -1
  32. package/lib/cjs/components/form.ws.js +14 -7
  33. package/lib/cjs/components/heading.ws.js +1 -1
  34. package/lib/cjs/components/image.ws.js +8 -9
  35. package/lib/cjs/components/italic.ws.js +5 -5
  36. package/lib/cjs/components/link-block.ws.js +5 -5
  37. package/lib/cjs/components/link.js +1 -1
  38. package/lib/cjs/components/link.ws.js +9 -10
  39. package/lib/cjs/components/list-item.ws.js +1 -1
  40. package/lib/cjs/components/list.ws.js +22 -22
  41. package/lib/cjs/components/paragraph.ws.js +1 -1
  42. package/lib/cjs/components/separator.ws.js +20 -20
  43. package/lib/cjs/components/text-block.ws.js +6 -7
  44. package/lib/cjs/css/css.js +6 -9
  45. package/lib/cjs/css/normalize.js +166 -185
  46. package/lib/cjs/css/presets.js +14 -34
  47. package/lib/cjs/css/style-rules.js +17 -0
  48. package/lib/cjs/embed-template.js +160 -0
  49. package/lib/cjs/index.js +1 -0
  50. package/lib/components/__generated__/blockquote.props.js +5 -0
  51. package/lib/components/__generated__/body.props.js +5 -0
  52. package/lib/components/__generated__/bold.props.js +5 -0
  53. package/lib/components/__generated__/box.props.js +5 -0
  54. package/lib/components/__generated__/button.props.js +5 -1
  55. package/lib/components/__generated__/code.props.js +5 -0
  56. package/lib/components/__generated__/form.props.js +5 -0
  57. package/lib/components/__generated__/heading.props.js +5 -0
  58. package/lib/components/__generated__/image.props.js +5 -0
  59. package/lib/components/__generated__/input.props.js +11 -2
  60. package/lib/components/__generated__/italic.props.js +5 -0
  61. package/lib/components/__generated__/link-block.props.js +5 -1
  62. package/lib/components/__generated__/link.props.js +5 -1
  63. package/lib/components/__generated__/list-item.props.js +5 -0
  64. package/lib/components/__generated__/list.props.js +5 -0
  65. package/lib/components/__generated__/paragraph.props.js +5 -0
  66. package/lib/components/__generated__/rich-text-link.props.js +5 -1
  67. package/lib/components/__generated__/separator.props.js +5 -0
  68. package/lib/components/__generated__/span.props.js +5 -0
  69. package/lib/components/__generated__/subscript.props.js +5 -0
  70. package/lib/components/__generated__/superscript.props.js +5 -0
  71. package/lib/components/__generated__/text-block.props.js +5 -0
  72. package/lib/components/blockquote.ws.js +36 -48
  73. package/lib/components/body.ws.js +19 -24
  74. package/lib/components/button.ws.js +1 -1
  75. package/lib/components/code.ws.js +20 -28
  76. package/lib/components/component-meta.js +2 -1
  77. package/lib/components/form.ws.js +14 -7
  78. package/lib/components/heading.ws.js +1 -1
  79. package/lib/components/image.ws.js +8 -9
  80. package/lib/components/italic.ws.js +5 -5
  81. package/lib/components/link-block.ws.js +5 -5
  82. package/lib/components/link.js +1 -1
  83. package/lib/components/link.ws.js +9 -10
  84. package/lib/components/list-item.ws.js +1 -1
  85. package/lib/components/list.ws.js +22 -22
  86. package/lib/components/paragraph.ws.js +1 -1
  87. package/lib/components/separator.ws.js +20 -20
  88. package/lib/components/text-block.ws.js +6 -7
  89. package/lib/css/css.js +8 -11
  90. package/lib/css/normalize.js +166 -185
  91. package/lib/css/presets.js +14 -34
  92. package/lib/css/style-rules.js +17 -0
  93. package/lib/embed-template.js +140 -0
  94. package/lib/index.js +1 -0
  95. package/lib/types/app/index.d.ts +0 -1
  96. package/lib/types/components/box.stories.d.ts +2 -2
  97. package/lib/types/components/component-meta.d.ts +20 -5
  98. package/lib/types/components/components-utils.d.ts +1 -1
  99. package/lib/types/css/normalize.d.ts +8786 -2286
  100. package/lib/types/css/presets.d.ts +2 -38
  101. package/lib/types/css/style-rules.d.ts +11 -9
  102. package/lib/types/embed-template.d.ts +1725 -0
  103. package/lib/types/embed-template.test.d.ts +1 -0
  104. package/lib/types/index.d.ts +1 -0
  105. package/package.json +16 -19
  106. package/src/app/custom-components/shared/remix-link.tsx +2 -2
  107. package/src/app/index.ts +0 -1
  108. package/src/components/__generated__/blockquote.props.ts +5 -0
  109. package/src/components/__generated__/body.props.ts +5 -0
  110. package/src/components/__generated__/bold.props.ts +5 -0
  111. package/src/components/__generated__/box.props.ts +5 -0
  112. package/src/components/__generated__/button.props.ts +5 -1
  113. package/src/components/__generated__/code.props.ts +5 -0
  114. package/src/components/__generated__/form.props.ts +5 -0
  115. package/src/components/__generated__/heading.props.ts +5 -0
  116. package/src/components/__generated__/image.props.ts +5 -0
  117. package/src/components/__generated__/input.props.ts +11 -2
  118. package/src/components/__generated__/italic.props.ts +5 -0
  119. package/src/components/__generated__/link-block.props.ts +5 -1
  120. package/src/components/__generated__/link.props.ts +5 -1
  121. package/src/components/__generated__/list-item.props.ts +5 -0
  122. package/src/components/__generated__/list.props.ts +5 -0
  123. package/src/components/__generated__/paragraph.props.ts +5 -0
  124. package/src/components/__generated__/rich-text-link.props.ts +5 -1
  125. package/src/components/__generated__/separator.props.ts +5 -0
  126. package/src/components/__generated__/span.props.ts +5 -0
  127. package/src/components/__generated__/subscript.props.ts +5 -0
  128. package/src/components/__generated__/superscript.props.ts +5 -0
  129. package/src/components/__generated__/text-block.props.ts +5 -0
  130. package/src/components/blockquote.ws.tsx +42 -52
  131. package/src/components/body.ws.tsx +25 -32
  132. package/src/components/bold.ws.tsx +6 -3
  133. package/src/components/box.ws.ts +6 -3
  134. package/src/components/button.ws.tsx +7 -4
  135. package/src/components/code.ws.tsx +26 -32
  136. package/src/components/component-meta.ts +5 -3
  137. package/src/components/form.ws.tsx +19 -9
  138. package/src/components/heading.ws.tsx +7 -4
  139. package/src/components/image.ws.tsx +14 -12
  140. package/src/components/input.ws.tsx +6 -3
  141. package/src/components/italic.ws.tsx +11 -8
  142. package/src/components/link-block.ws.tsx +11 -8
  143. package/src/components/link.tsx +1 -1
  144. package/src/components/link.ws.tsx +15 -13
  145. package/src/components/list-item.ws.tsx +7 -4
  146. package/src/components/list.ws.tsx +28 -25
  147. package/src/components/paragraph.ws.tsx +7 -4
  148. package/src/components/separator.ws.tsx +26 -25
  149. package/src/components/span.ws.tsx +6 -3
  150. package/src/components/subscript.ws.tsx +6 -3
  151. package/src/components/superscript.ws.tsx +6 -3
  152. package/src/components/text-block.ws.tsx +12 -11
  153. package/src/css/css.ts +8 -11
  154. package/src/css/normalize.ts +165 -188
  155. package/src/css/presets.ts +15 -37
  156. package/src/css/style-rules.ts +24 -0
  157. package/src/embed-template.test.ts +210 -0
  158. package/src/embed-template.ts +187 -0
  159. package/src/index.ts +1 -0
  160. package/lib/app/handle-request.server.js +0 -16
  161. package/lib/cjs/app/handle-request.server.js +0 -36
  162. package/lib/types/app/handle-request.server.d.ts +0 -2
  163. package/src/app/handle-request.server.tsx +0 -21
@@ -0,0 +1,210 @@
1
+ import { expect, test } from "@jest/globals";
2
+ import { generateDataFromEmbedTemplate } from "./embed-template";
3
+
4
+ const expectString = expect.any(String) as unknown as string;
5
+
6
+ const defaultBreakpointId = "base";
7
+
8
+ test("generate data for embedding from instances and text", () => {
9
+ expect(
10
+ generateDataFromEmbedTemplate(
11
+ [
12
+ { type: "text", value: "hello" },
13
+ {
14
+ type: "instance",
15
+ component: "Box1",
16
+ children: [
17
+ { type: "instance", component: "Box2", children: [] },
18
+ { type: "text", value: "world" },
19
+ ],
20
+ },
21
+ ],
22
+ defaultBreakpointId
23
+ )
24
+ ).toEqual({
25
+ children: [
26
+ { type: "text", value: "hello" },
27
+ { type: "id", value: expectString },
28
+ ],
29
+ instances: [
30
+ {
31
+ type: "instance",
32
+ id: expectString,
33
+ component: "Box1",
34
+ children: [
35
+ { type: "id", value: expectString },
36
+ { type: "text", value: "world" },
37
+ ],
38
+ },
39
+ {
40
+ type: "instance",
41
+ id: expectString,
42
+ component: "Box2",
43
+ children: [],
44
+ },
45
+ ],
46
+ props: [],
47
+ styleSourceSelections: [],
48
+ styleSources: [],
49
+ styles: [],
50
+ });
51
+ });
52
+
53
+ test("generate data for embedding from props", () => {
54
+ expect(
55
+ generateDataFromEmbedTemplate(
56
+ [
57
+ {
58
+ type: "instance",
59
+ component: "Box1",
60
+ props: [
61
+ { type: "string", name: "data-prop1", value: "value1" },
62
+ { type: "string", name: "data-prop2", value: "value2" },
63
+ ],
64
+ children: [
65
+ {
66
+ type: "instance",
67
+ component: "Box2",
68
+ props: [{ type: "string", name: "data-prop3", value: "value3" }],
69
+ children: [],
70
+ },
71
+ ],
72
+ },
73
+ ],
74
+ defaultBreakpointId
75
+ )
76
+ ).toEqual({
77
+ children: [{ type: "id", value: expectString }],
78
+ instances: [
79
+ {
80
+ type: "instance",
81
+ id: expectString,
82
+ component: "Box1",
83
+ children: [{ type: "id", value: expectString }],
84
+ },
85
+ {
86
+ type: "instance",
87
+ id: expectString,
88
+ component: "Box2",
89
+ children: [],
90
+ },
91
+ ],
92
+ props: [
93
+ {
94
+ type: "string",
95
+ id: expectString,
96
+ instanceId: expectString,
97
+ name: "data-prop1",
98
+ value: "value1",
99
+ },
100
+ {
101
+ type: "string",
102
+ id: expectString,
103
+ instanceId: expectString,
104
+ name: "data-prop2",
105
+ value: "value2",
106
+ },
107
+ {
108
+ type: "string",
109
+ id: expectString,
110
+ instanceId: expectString,
111
+ name: "data-prop3",
112
+ value: "value3",
113
+ },
114
+ ],
115
+ styleSourceSelections: [],
116
+ styleSources: [],
117
+ styles: [],
118
+ });
119
+ });
120
+
121
+ test("generate data for embedding from styles", () => {
122
+ expect(
123
+ generateDataFromEmbedTemplate(
124
+ [
125
+ {
126
+ type: "instance",
127
+ component: "Box1",
128
+ styles: [
129
+ { property: "width", value: { type: "keyword", value: "auto" } },
130
+ { property: "height", value: { type: "keyword", value: "auto" } },
131
+ ],
132
+ children: [
133
+ {
134
+ type: "instance",
135
+ component: "Box2",
136
+ styles: [
137
+ {
138
+ property: "color",
139
+ value: { type: "keyword", value: "black" },
140
+ },
141
+ ],
142
+ children: [],
143
+ },
144
+ ],
145
+ },
146
+ ],
147
+ defaultBreakpointId
148
+ )
149
+ ).toEqual({
150
+ children: [{ type: "id", value: expectString }],
151
+ instances: [
152
+ {
153
+ type: "instance",
154
+ id: expectString,
155
+ component: "Box1",
156
+ children: [{ type: "id", value: expectString }],
157
+ },
158
+ {
159
+ type: "instance",
160
+ id: expectString,
161
+ component: "Box2",
162
+ children: [],
163
+ },
164
+ ],
165
+ props: [],
166
+ styleSourceSelections: [
167
+ {
168
+ instanceId: expectString,
169
+ values: [expectString],
170
+ },
171
+ {
172
+ instanceId: expectString,
173
+ values: [expectString],
174
+ },
175
+ ],
176
+ styleSources: [
177
+ {
178
+ type: "local",
179
+ id: expectString,
180
+ },
181
+ {
182
+ type: "local",
183
+ id: expectString,
184
+ },
185
+ ],
186
+ styles: [
187
+ {
188
+ breakpointId: "base",
189
+ styleSourceId: expectString,
190
+ state: undefined,
191
+ property: "width",
192
+ value: { type: "keyword", value: "auto" },
193
+ },
194
+ {
195
+ breakpointId: "base",
196
+ styleSourceId: expectString,
197
+ state: undefined,
198
+ property: "height",
199
+ value: { type: "keyword", value: "auto" },
200
+ },
201
+ {
202
+ breakpointId: "base",
203
+ styleSourceId: expectString,
204
+ state: undefined,
205
+ property: "color",
206
+ value: { type: "keyword", value: "black" },
207
+ },
208
+ ],
209
+ });
210
+ });
@@ -0,0 +1,187 @@
1
+ import { z } from "zod";
2
+ import { nanoid } from "nanoid";
3
+ import {
4
+ type Instance,
5
+ type InstancesList,
6
+ PropsList,
7
+ StyleSourceSelectionsList,
8
+ StyleSourcesList,
9
+ StylesList,
10
+ Breakpoint,
11
+ } from "@webstudio-is/project-build";
12
+ import { StyleValue, type StyleProperty } from "@webstudio-is/css-data";
13
+
14
+ const EmbedTemplateText = z.object({
15
+ type: z.literal("text"),
16
+ value: z.string(),
17
+ });
18
+
19
+ type EmbedTemplateText = z.infer<typeof EmbedTemplateText>;
20
+
21
+ const EmbedTemplateProp = z.union([
22
+ z.object({
23
+ type: z.literal("number"),
24
+ name: z.string(),
25
+ value: z.number(),
26
+ }),
27
+ z.object({
28
+ type: z.literal("string"),
29
+ name: z.string(),
30
+ value: z.string(),
31
+ }),
32
+ z.object({
33
+ type: z.literal("boolean"),
34
+ name: z.string(),
35
+ value: z.boolean(),
36
+ }),
37
+ z.object({
38
+ type: z.literal("string[]"),
39
+ name: z.string(),
40
+ value: z.array(z.string()),
41
+ }),
42
+ ]);
43
+
44
+ type EmbedTemplateProp = z.infer<typeof EmbedTemplateProp>;
45
+
46
+ export const EmbedTemplateStyleDecl = z.object({
47
+ state: z.optional(z.string()),
48
+ property: z.string() as z.ZodType<StyleProperty>,
49
+ value: StyleValue,
50
+ });
51
+
52
+ export type EmbedTemplateStyleDecl = z.infer<typeof EmbedTemplateStyleDecl>;
53
+
54
+ export type EmbedTemplateInstance = {
55
+ type: "instance";
56
+ component: string;
57
+ props?: EmbedTemplateProp[];
58
+ styles?: EmbedTemplateStyleDecl[];
59
+ children: Array<EmbedTemplateInstance | EmbedTemplateText>;
60
+ };
61
+
62
+ export const EmbedTemplateInstance: z.ZodType<EmbedTemplateInstance> = z.lazy(
63
+ () =>
64
+ z.object({
65
+ type: z.literal("instance"),
66
+ component: z.string(),
67
+ props: z.optional(z.array(EmbedTemplateProp)),
68
+ styles: z.optional(z.array(EmbedTemplateStyleDecl)),
69
+ children: WsEmbedTemplate,
70
+ })
71
+ );
72
+
73
+ export const WsEmbedTemplate = z.lazy(() =>
74
+ z.array(z.union([EmbedTemplateInstance, EmbedTemplateText]))
75
+ );
76
+
77
+ export type WsEmbedTemplate = z.infer<typeof WsEmbedTemplate>;
78
+
79
+ const createInstancesFromTemplate = (
80
+ treeTemplate: WsEmbedTemplate,
81
+ instances: InstancesList,
82
+ props: PropsList,
83
+ styleSourceSelections: StyleSourceSelectionsList,
84
+ styleSources: StyleSourcesList,
85
+ styles: StylesList,
86
+ defaultBreakpointId: Breakpoint["id"]
87
+ ) => {
88
+ const parentChildren: Instance["children"] = [];
89
+ for (const item of treeTemplate) {
90
+ if (item.type === "instance") {
91
+ const instanceId = nanoid();
92
+
93
+ // populate props
94
+ if (item.props) {
95
+ for (const prop of item.props) {
96
+ props.push({
97
+ id: nanoid(),
98
+ instanceId,
99
+ ...prop,
100
+ });
101
+ }
102
+ }
103
+
104
+ // populate styles
105
+ if (item.styles) {
106
+ const styleSourceId = nanoid();
107
+ styleSources.push({
108
+ type: "local",
109
+ id: styleSourceId,
110
+ });
111
+ styleSourceSelections.push({
112
+ instanceId,
113
+ values: [styleSourceId],
114
+ });
115
+ for (const styleDecl of item.styles) {
116
+ styles.push({
117
+ breakpointId: defaultBreakpointId,
118
+ styleSourceId,
119
+ state: styleDecl.state,
120
+ property: styleDecl.property,
121
+ value: styleDecl.value,
122
+ });
123
+ }
124
+ }
125
+
126
+ // populate instances
127
+ const instance: Instance = {
128
+ type: "instance",
129
+ id: instanceId,
130
+ component: item.component,
131
+ children: [],
132
+ };
133
+ instances.push(instance);
134
+ // traverse children after to preserve top down order
135
+ instance.children = createInstancesFromTemplate(
136
+ item.children,
137
+ instances,
138
+ props,
139
+ styleSourceSelections,
140
+ styleSources,
141
+ styles,
142
+ defaultBreakpointId
143
+ );
144
+ parentChildren.push({
145
+ type: "id",
146
+ value: instanceId,
147
+ });
148
+ }
149
+
150
+ if (item.type === "text") {
151
+ parentChildren.push({
152
+ type: "text",
153
+ value: item.value,
154
+ });
155
+ }
156
+ }
157
+ return parentChildren;
158
+ };
159
+
160
+ export const generateDataFromEmbedTemplate = (
161
+ treeTemplate: WsEmbedTemplate,
162
+ defaultBreakpointId: Breakpoint["id"]
163
+ ) => {
164
+ const instances: InstancesList = [];
165
+ const props: PropsList = [];
166
+ const styleSourceSelections: StyleSourceSelectionsList = [];
167
+ const styleSources: StyleSourcesList = [];
168
+ const styles: StylesList = [];
169
+
170
+ const children = createInstancesFromTemplate(
171
+ treeTemplate,
172
+ instances,
173
+ props,
174
+ styleSourceSelections,
175
+ styleSources,
176
+ styles,
177
+ defaultBreakpointId
178
+ );
179
+ return {
180
+ children,
181
+ instances,
182
+ props,
183
+ styleSourceSelections,
184
+ styleSources,
185
+ styles,
186
+ };
187
+ };
package/src/index.ts CHANGED
@@ -16,3 +16,4 @@ export {
16
16
  type ComponentState,
17
17
  componentCategories,
18
18
  } from "./components/component-meta";
19
+ export * from "./embed-template";
@@ -1,16 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { renderToString } from "react-dom/server";
3
- import { RemixServer } from "@remix-run/react";
4
- const handleRequest = (request, responseStatusCode, responseHeaders, remixContext) => {
5
- const markup = renderToString(
6
- /* @__PURE__ */ jsx(RemixServer, { context: remixContext, url: request.url })
7
- );
8
- responseHeaders.set("Content-Type", "text/html");
9
- return new Response(`<!DOCTYPE html>${markup}`, {
10
- status: responseStatusCode,
11
- headers: responseHeaders
12
- });
13
- };
14
- export {
15
- handleRequest
16
- };
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var handle_request_server_exports = {};
20
- __export(handle_request_server_exports, {
21
- handleRequest: () => handleRequest
22
- });
23
- module.exports = __toCommonJS(handle_request_server_exports);
24
- var import_jsx_runtime = require("react/jsx-runtime");
25
- var import_server = require("react-dom/server");
26
- var import_react = require("@remix-run/react");
27
- const handleRequest = (request, responseStatusCode, responseHeaders, remixContext) => {
28
- const markup = (0, import_server.renderToString)(
29
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.RemixServer, { context: remixContext, url: request.url })
30
- );
31
- responseHeaders.set("Content-Type", "text/html");
32
- return new Response(`<!DOCTYPE html>${markup}`, {
33
- status: responseStatusCode,
34
- headers: responseHeaders
35
- });
36
- };
@@ -1,2 +0,0 @@
1
- import type { EntryContext } from "@remix-run/node";
2
- export declare const handleRequest: (request: Request, responseStatusCode: number, responseHeaders: Headers, remixContext: EntryContext) => Response;
@@ -1,21 +0,0 @@
1
- import { renderToString } from "react-dom/server";
2
- import { RemixServer } from "@remix-run/react";
3
- import type { EntryContext } from "@remix-run/node";
4
-
5
- export const 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
- status: responseStatusCode,
19
- headers: responseHeaders,
20
- });
21
- };