@holo-js/adapter-next 0.2.5 → 0.3.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/dist/chunk-VBBQ4VXY.mjs +27 -0
- package/dist/client.d.ts +10 -2
- package/dist/client.mjs +17 -2
- package/dist/realtime-definition-loader.d.ts +2 -1
- package/dist/realtime-definition-loader.mjs +13 -269
- package/dist/realtime.d.ts +14 -1
- package/dist/realtime.mjs +12 -3
- package/dist/runtime.d.ts +44 -115
- package/dist/runtime.mjs +60 -23
- package/package.json +7 -6
- package/dist/chunk-3RI2KDLY.mjs +0 -74
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/client-errors.ts
|
|
2
|
+
import {
|
|
3
|
+
normalizeHoloHttpError,
|
|
4
|
+
renderClientHttpErrorPage
|
|
5
|
+
} from "@holo-js/adapter-shared";
|
|
6
|
+
var nextHttpAccessFallbackStatuses = /* @__PURE__ */ new Set([401, 403, 404]);
|
|
7
|
+
function normalizeNextClientHttpError(error) {
|
|
8
|
+
return normalizeHoloHttpError(error);
|
|
9
|
+
}
|
|
10
|
+
function createNextRenderableError(error) {
|
|
11
|
+
if (!nextHttpAccessFallbackStatuses.has(error.status)) return new Error(error.message, { cause: error.cause });
|
|
12
|
+
const nextError = new Error(error.message, { cause: error.cause });
|
|
13
|
+
nextError.digest = `NEXT_HTTP_ERROR_FALLBACK;${error.status}`;
|
|
14
|
+
return nextError;
|
|
15
|
+
}
|
|
16
|
+
function renderNextClientHttpErrorPage(error) {
|
|
17
|
+
renderClientHttpErrorPage(error, {
|
|
18
|
+
rootId: "__holo_next_client_http_error__",
|
|
19
|
+
statusClassName: "next-error-h1"
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
normalizeNextClientHttpError,
|
|
25
|
+
createNextRenderableError,
|
|
26
|
+
renderNextClientHttpErrorPage
|
|
27
|
+
};
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { FormSchema, InferFormData } from '@holo-js/forms';
|
|
2
|
-
import { UseFormOptions, UseFormResult, InferFormFieldTree } from '@holo-js/forms/internal/client';
|
|
2
|
+
import { UseFormOptions, ClientSubmitContext, ClientSubmitResult, UseFormResult, InferFormFieldTree } from '@holo-js/forms/internal/client';
|
|
3
3
|
export { ClientSubmitContext, ClientSubmitResult, FormFieldState, FormFieldTree, UseFormOptions, UseFormResult, ValidateOnMode } from '@holo-js/forms/internal/client';
|
|
4
4
|
|
|
5
|
+
declare function isNextRedirectError(error: unknown): boolean;
|
|
6
|
+
declare function createSubmitterBridge<TData, TSuccess>(optionsRef: {
|
|
7
|
+
current: UseFormOptions<TData, TSuccess> | undefined;
|
|
8
|
+
}, onHttpError: (error: Error) => void): (context: ClientSubmitContext<TData>) => Promise<ClientSubmitResult<TData, TSuccess> | void> | ClientSubmitResult<TData, TSuccess> | void;
|
|
5
9
|
declare function useForm<TSchema extends FormSchema, TSuccess = unknown>(schemaDefinition: TSchema, options?: UseFormOptions<InferFormData<TSchema>, TSuccess>): UseFormResult<InferFormData<TSchema>, TSuccess, InferFormFieldTree<TSchema>>;
|
|
10
|
+
declare const adapterNextClientInternals: {
|
|
11
|
+
isNextRedirectError: typeof isNextRedirectError;
|
|
12
|
+
createSubmitterBridge: typeof createSubmitterBridge;
|
|
13
|
+
};
|
|
6
14
|
|
|
7
|
-
export { useForm };
|
|
15
|
+
export { adapterNextClientInternals, useForm };
|
package/dist/client.mjs
CHANGED
|
@@ -3,12 +3,13 @@ import {
|
|
|
3
3
|
createNextRenderableError,
|
|
4
4
|
normalizeNextClientHttpError,
|
|
5
5
|
renderNextClientHttpErrorPage
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VBBQ4VXY.mjs";
|
|
7
7
|
|
|
8
8
|
// src/client.ts
|
|
9
9
|
import { useEffect, useRef, useState } from "react";
|
|
10
10
|
import {
|
|
11
|
-
createFormClient
|
|
11
|
+
createFormClient,
|
|
12
|
+
markClientSubmitControlFlowError
|
|
12
13
|
} from "@holo-js/forms/internal/client";
|
|
13
14
|
function isPlainObject(value) {
|
|
14
15
|
return !!value && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof Blob);
|
|
@@ -36,6 +37,12 @@ function areEqual(left, right) {
|
|
|
36
37
|
function areOptionsEqual(left, right) {
|
|
37
38
|
return left.action === right.action && left.method === right.method && left.validateOn === right.validateOn && Boolean(left.submitter) === Boolean(right.submitter) && areEqual(left.initialValues, right.initialValues) && areEqual(left.initialState, right.initialState);
|
|
38
39
|
}
|
|
40
|
+
function isNextRedirectError(error) {
|
|
41
|
+
if (!error || typeof error !== "object" && typeof error !== "function" || !("digest" in error)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return typeof error.digest === "string" && error.digest.startsWith("NEXT_REDIRECT");
|
|
45
|
+
}
|
|
39
46
|
function createSubmitterBridge(optionsRef, onHttpError) {
|
|
40
47
|
return async (context) => {
|
|
41
48
|
const submitter = optionsRef.current?.submitter;
|
|
@@ -45,6 +52,9 @@ function createSubmitterBridge(optionsRef, onHttpError) {
|
|
|
45
52
|
try {
|
|
46
53
|
return await submitter(context);
|
|
47
54
|
} catch (error) {
|
|
55
|
+
if (isNextRedirectError(error)) {
|
|
56
|
+
throw markClientSubmitControlFlowError(error);
|
|
57
|
+
}
|
|
48
58
|
const httpError = normalizeNextClientHttpError(error);
|
|
49
59
|
if (httpError) {
|
|
50
60
|
renderNextClientHttpErrorPage(httpError);
|
|
@@ -88,6 +98,11 @@ function useForm(schemaDefinition, options = {}) {
|
|
|
88
98
|
useEffect(() => form.subscribe(() => setVersion((version) => version + 1)), [form]);
|
|
89
99
|
return form;
|
|
90
100
|
}
|
|
101
|
+
var adapterNextClientInternals = {
|
|
102
|
+
isNextRedirectError,
|
|
103
|
+
createSubmitterBridge
|
|
104
|
+
};
|
|
91
105
|
export {
|
|
106
|
+
adapterNextClientInternals,
|
|
92
107
|
useForm
|
|
93
108
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
type LoaderContext = {
|
|
2
2
|
cacheable?: () => void;
|
|
3
|
+
callback?(error: null, code: string, map: object): void;
|
|
3
4
|
};
|
|
4
|
-
declare function realtimeDefinitionLoader(this: LoaderContext, source: string): string;
|
|
5
|
+
declare function realtimeDefinitionLoader(this: LoaderContext, source: string): string | undefined;
|
|
5
6
|
|
|
6
7
|
export { realtimeDefinitionLoader as default };
|
|
@@ -1,278 +1,22 @@
|
|
|
1
1
|
// src/realtime-definition-transform.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const char = source[cursor];
|
|
10
|
-
if (char === "\\") {
|
|
11
|
-
cursor += 2;
|
|
12
|
-
continue;
|
|
13
|
-
}
|
|
14
|
-
if (char === quote) {
|
|
15
|
-
return cursor + 1;
|
|
16
|
-
}
|
|
17
|
-
cursor += 1;
|
|
18
|
-
}
|
|
19
|
-
return cursor;
|
|
20
|
-
}
|
|
21
|
-
function skipLineComment(source, index) {
|
|
22
|
-
const end = source.indexOf("\n", index + 2);
|
|
23
|
-
return end === -1 ? source.length : end + 1;
|
|
24
|
-
}
|
|
25
|
-
function skipBlockComment(source, index) {
|
|
26
|
-
const end = source.indexOf("*/", index + 2);
|
|
27
|
-
return end === -1 ? source.length : end + 2;
|
|
28
|
-
}
|
|
29
|
-
function findRealtimePropertyValueEnd(source, index) {
|
|
30
|
-
let cursor = index;
|
|
31
|
-
let braceDepth = 0;
|
|
32
|
-
let bracketDepth = 0;
|
|
33
|
-
let parenDepth = 0;
|
|
34
|
-
while (cursor < source.length) {
|
|
35
|
-
const char = source[cursor];
|
|
36
|
-
const next = source[cursor + 1];
|
|
37
|
-
if (char === '"' || char === "'" || char === "`") {
|
|
38
|
-
cursor = skipString(source, cursor, char);
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
if (char === "/" && next === "/") {
|
|
42
|
-
cursor = skipLineComment(source, cursor);
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
if (char === "/" && next === "*") {
|
|
46
|
-
cursor = skipBlockComment(source, cursor);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
if (char === "{") {
|
|
50
|
-
braceDepth += 1;
|
|
51
|
-
} else if (char === "}") {
|
|
52
|
-
if (braceDepth === 0 && bracketDepth === 0 && parenDepth === 0) {
|
|
53
|
-
return cursor;
|
|
54
|
-
}
|
|
55
|
-
braceDepth -= 1;
|
|
56
|
-
} else if (char === "[") {
|
|
57
|
-
bracketDepth += 1;
|
|
58
|
-
} else if (char === "]") {
|
|
59
|
-
bracketDepth -= 1;
|
|
60
|
-
} else if (char === "(") {
|
|
61
|
-
parenDepth += 1;
|
|
62
|
-
} else if (char === ")") {
|
|
63
|
-
parenDepth -= 1;
|
|
64
|
-
} else if (char === "," && braceDepth === 0 && bracketDepth === 0 && parenDepth === 0) {
|
|
65
|
-
return cursor;
|
|
66
|
-
}
|
|
67
|
-
cursor += 1;
|
|
68
|
-
}
|
|
69
|
-
return source.length;
|
|
70
|
-
}
|
|
71
|
-
function findClosingBrace(source, index) {
|
|
72
|
-
let cursor = index;
|
|
73
|
-
let depth = 0;
|
|
74
|
-
while (cursor < source.length) {
|
|
75
|
-
const char = source[cursor];
|
|
76
|
-
const next = source[cursor + 1];
|
|
77
|
-
if (char === '"' || char === "'" || char === "`") {
|
|
78
|
-
cursor = skipString(source, cursor, char);
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
if (char === "/" && next === "/") {
|
|
82
|
-
cursor = skipLineComment(source, cursor);
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (char === "/" && next === "*") {
|
|
86
|
-
cursor = skipBlockComment(source, cursor);
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
if (char === "{") {
|
|
90
|
-
depth += 1;
|
|
91
|
-
} else if (char === "}") {
|
|
92
|
-
depth -= 1;
|
|
93
|
-
if (depth === 0) {
|
|
94
|
-
return cursor;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
cursor += 1;
|
|
98
|
-
}
|
|
99
|
-
return -1;
|
|
100
|
-
}
|
|
101
|
-
function applyReplacements(source, replacements) {
|
|
102
|
-
if (replacements.length === 0) {
|
|
103
|
-
return source;
|
|
104
|
-
}
|
|
105
|
-
let output = "";
|
|
106
|
-
let cursor = 0;
|
|
107
|
-
const ordered = [...replacements].sort((left, right) => left.start - right.start);
|
|
108
|
-
for (const replacement of ordered) {
|
|
109
|
-
output += source.slice(cursor, replacement.start);
|
|
110
|
-
output += replacement.text;
|
|
111
|
-
cursor = replacement.end;
|
|
112
|
-
}
|
|
113
|
-
return output + source.slice(cursor);
|
|
114
|
-
}
|
|
115
|
-
function extractObjectPropertyValue(objectSource, propertyName) {
|
|
116
|
-
let cursor = 1;
|
|
117
|
-
while (cursor < objectSource.length - 1) {
|
|
118
|
-
const char = objectSource[cursor];
|
|
119
|
-
const next = objectSource[cursor + 1];
|
|
120
|
-
if (char === '"' || char === "'" || char === "`") {
|
|
121
|
-
cursor = skipString(objectSource, cursor, char);
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
if (char === "/" && next === "/") {
|
|
125
|
-
cursor = skipLineComment(objectSource, cursor);
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
if (char === "/" && next === "*") {
|
|
129
|
-
cursor = skipBlockComment(objectSource, cursor);
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
const match = objectSource.slice(cursor).match(/^[$A-Z_a-z][$\w]*/);
|
|
133
|
-
const name = match?.[0];
|
|
134
|
-
if (!name || name !== propertyName) {
|
|
135
|
-
cursor += 1;
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
const afterName = cursor + name.length;
|
|
139
|
-
if (!isIdentifierBoundary(objectSource[cursor - 1]) || !isIdentifierBoundary(objectSource[afterName])) {
|
|
140
|
-
cursor += name.length;
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
let colon = afterName;
|
|
144
|
-
while (/\s/.test(objectSource[colon] ?? "")) {
|
|
145
|
-
colon += 1;
|
|
146
|
-
}
|
|
147
|
-
if (objectSource[colon] !== ":") {
|
|
148
|
-
cursor += name.length;
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
const valueStart = colon + 1;
|
|
152
|
-
const valueEnd = findRealtimePropertyValueEnd(objectSource, valueStart);
|
|
153
|
-
return objectSource.slice(valueStart, valueEnd).trim();
|
|
154
|
-
}
|
|
155
|
-
return void 0;
|
|
156
|
-
}
|
|
157
|
-
function collectRealtimeDefinitionExports(source) {
|
|
158
|
-
const definitions = [];
|
|
159
|
-
let cursor = 0;
|
|
160
|
-
while (cursor < source.length) {
|
|
161
|
-
const char = source[cursor];
|
|
162
|
-
const next = source[cursor + 1];
|
|
163
|
-
if (char === '"' || char === "'" || char === "`") {
|
|
164
|
-
cursor = skipString(source, cursor, char);
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
if (char === "/" && next === "/") {
|
|
168
|
-
cursor = skipLineComment(source, cursor);
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
if (char === "/" && next === "*") {
|
|
172
|
-
cursor = skipBlockComment(source, cursor);
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
const match = source.slice(cursor).match(/^export\s+const\s+([$A-Z_a-z][$\w]*)\s*=\s*(query|mutation)\s*\(/);
|
|
176
|
-
const exportedName = match?.[1];
|
|
177
|
-
const factoryName = match?.[2];
|
|
178
|
-
if (!exportedName || !factoryName) {
|
|
179
|
-
cursor += 1;
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
let objectStart = cursor + match[0].length;
|
|
183
|
-
while (/\s/.test(source[objectStart] ?? "")) {
|
|
184
|
-
objectStart += 1;
|
|
185
|
-
}
|
|
186
|
-
if (source[objectStart] !== "{") {
|
|
187
|
-
cursor += match[0].length;
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
const objectEnd = findClosingBrace(source, objectStart);
|
|
191
|
-
if (objectEnd === -1) {
|
|
192
|
-
cursor += match[0].length;
|
|
193
|
-
continue;
|
|
194
|
-
}
|
|
195
|
-
const objectSource = source.slice(objectStart, objectEnd + 1);
|
|
196
|
-
definitions.push({
|
|
197
|
-
exportedName,
|
|
198
|
-
factoryName,
|
|
199
|
-
nameValue: extractObjectPropertyValue(objectSource, "name")
|
|
200
|
-
});
|
|
201
|
-
cursor = objectEnd + 1;
|
|
202
|
-
}
|
|
203
|
-
return definitions;
|
|
204
|
-
}
|
|
205
|
-
function createRealtimeClientDefinitionModule(source) {
|
|
206
|
-
const definitions = collectRealtimeDefinitionExports(source);
|
|
207
|
-
if (definitions.length === 0) {
|
|
208
|
-
return stripRealtimeServerHandlers(source);
|
|
209
|
-
}
|
|
210
|
-
const factories = [...new Set(definitions.map((definition) => definition.factoryName))];
|
|
211
|
-
return [
|
|
212
|
-
`import { ${factories.join(", ")} } from '@holo-js/adapter-next/realtime'`,
|
|
213
|
-
"",
|
|
214
|
-
...definitions.flatMap((definition) => [
|
|
215
|
-
`export const ${definition.exportedName} = ${definition.factoryName}({`,
|
|
216
|
-
...definition.nameValue ? [` name: ${definition.nameValue},`] : [],
|
|
217
|
-
" handler: undefined,",
|
|
218
|
-
"})",
|
|
219
|
-
""
|
|
220
|
-
])
|
|
221
|
-
].join("\n");
|
|
222
|
-
}
|
|
223
|
-
function stripRealtimeServerHandlers(source) {
|
|
224
|
-
const replacements = [];
|
|
225
|
-
let cursor = 0;
|
|
226
|
-
while (cursor < source.length) {
|
|
227
|
-
const char = source[cursor];
|
|
228
|
-
const next = source[cursor + 1];
|
|
229
|
-
if (char === '"' || char === "'" || char === "`") {
|
|
230
|
-
cursor = skipString(source, cursor, char);
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
if (char === "/" && next === "/") {
|
|
234
|
-
cursor = skipLineComment(source, cursor);
|
|
235
|
-
continue;
|
|
236
|
-
}
|
|
237
|
-
if (char === "/" && next === "*") {
|
|
238
|
-
cursor = skipBlockComment(source, cursor);
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
const match = source.slice(cursor).match(/^[$A-Z_a-z][$\w]*/);
|
|
242
|
-
const name = match?.[0];
|
|
243
|
-
if (!name || !serverOnlyRealtimeProperties.has(name)) {
|
|
244
|
-
cursor += 1;
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
const afterName = cursor + name.length;
|
|
248
|
-
if (!isIdentifierBoundary(source[cursor - 1]) || !isIdentifierBoundary(source[afterName])) {
|
|
249
|
-
cursor += name.length;
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
|
-
let colon = afterName;
|
|
253
|
-
while (/\s/.test(source[colon] ?? "")) {
|
|
254
|
-
colon += 1;
|
|
255
|
-
}
|
|
256
|
-
if (source[colon] !== ":") {
|
|
257
|
-
cursor += name.length;
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
const valueStart = colon + 1;
|
|
261
|
-
const valueEnd = findRealtimePropertyValueEnd(source, valueStart);
|
|
262
|
-
replacements.push({
|
|
263
|
-
start: valueStart,
|
|
264
|
-
end: valueEnd,
|
|
265
|
-
text: " undefined"
|
|
266
|
-
});
|
|
267
|
-
cursor = valueEnd;
|
|
268
|
-
}
|
|
269
|
-
return applyReplacements(source, replacements);
|
|
2
|
+
import {
|
|
3
|
+
createRealtimeClientDefinitionModule as createSharedRealtimeClientDefinitionModule,
|
|
4
|
+
createRealtimeClientDefinitionTransform as createSharedRealtimeClientDefinitionTransform,
|
|
5
|
+
stripRealtimeServerHandlers
|
|
6
|
+
} from "@holo-js/adapter-shared";
|
|
7
|
+
function createRealtimeClientDefinitionTransform(source) {
|
|
8
|
+
return createSharedRealtimeClientDefinitionTransform(source, "@holo-js/adapter-next/realtime");
|
|
270
9
|
}
|
|
271
10
|
|
|
272
11
|
// src/realtime-definition-loader.ts
|
|
273
12
|
function realtimeDefinitionLoader(source) {
|
|
274
13
|
this.cacheable?.();
|
|
275
|
-
|
|
14
|
+
const result = createRealtimeClientDefinitionTransform(source);
|
|
15
|
+
if (this.callback) {
|
|
16
|
+
this.callback(null, result.code, result.map);
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
return result.code;
|
|
276
20
|
}
|
|
277
21
|
export {
|
|
278
22
|
realtimeDefinitionLoader as default
|
package/dist/realtime.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import * as _holo_js_realtime from '@holo-js/realtime';
|
|
2
2
|
import { mutation as mutation$1 } from '@holo-js/realtime';
|
|
3
|
+
import { RealtimeClientTransport } from '@holo-js/realtime/client';
|
|
3
4
|
|
|
5
|
+
declare function subscribeRealtimeError(listener: () => void): () => void;
|
|
6
|
+
declare function emitRealtimeError(error: unknown): void;
|
|
7
|
+
declare function getRealtimeErrorSnapshot(): Error | undefined;
|
|
8
|
+
declare function consumeRealtimeError(): Error | undefined;
|
|
9
|
+
declare function createErrorHandlingRealtimeTransport(transport: RealtimeClientTransport): RealtimeClientTransport;
|
|
4
10
|
declare const query: typeof _holo_js_realtime.defineRealtimeQuery;
|
|
5
11
|
declare const mutation: typeof mutation$1;
|
|
12
|
+
declare const adapterNextRealtimeInternals: {
|
|
13
|
+
subscribeRealtimeError: typeof subscribeRealtimeError;
|
|
14
|
+
emitRealtimeError: typeof emitRealtimeError;
|
|
15
|
+
getRealtimeErrorSnapshot: typeof getRealtimeErrorSnapshot;
|
|
16
|
+
consumeRealtimeError: typeof consumeRealtimeError;
|
|
17
|
+
createErrorHandlingRealtimeTransport: typeof createErrorHandlingRealtimeTransport;
|
|
18
|
+
};
|
|
6
19
|
|
|
7
|
-
export { mutation, query };
|
|
20
|
+
export { adapterNextRealtimeInternals, mutation, query };
|
package/dist/realtime.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createNextRenderableError,
|
|
4
4
|
normalizeNextClientHttpError,
|
|
5
5
|
renderNextClientHttpErrorPage
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VBBQ4VXY.mjs";
|
|
7
7
|
|
|
8
8
|
// src/realtime.ts
|
|
9
9
|
import { useEffect, useSyncExternalStore } from "react";
|
|
@@ -95,10 +95,11 @@ function useReactiveRealtimeQuery(definition, args) {
|
|
|
95
95
|
useEffect(() => {
|
|
96
96
|
store.connect();
|
|
97
97
|
}, [store]);
|
|
98
|
+
const getSnapshot = () => store.snapshot;
|
|
98
99
|
const snapshot = useSyncExternalStore(
|
|
99
100
|
store.subscribe,
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
getSnapshot,
|
|
102
|
+
getSnapshot
|
|
102
103
|
);
|
|
103
104
|
return snapshot?.data;
|
|
104
105
|
}
|
|
@@ -107,7 +108,15 @@ configureRealtimeClientRuntime({
|
|
|
107
108
|
useQuery: useReactiveRealtimeQuery
|
|
108
109
|
});
|
|
109
110
|
configureRealtimeClientTransport(createErrorHandlingRealtimeTransport(createBroadcastRealtimeTransport()));
|
|
111
|
+
var adapterNextRealtimeInternals = {
|
|
112
|
+
subscribeRealtimeError,
|
|
113
|
+
emitRealtimeError,
|
|
114
|
+
getRealtimeErrorSnapshot,
|
|
115
|
+
consumeRealtimeError,
|
|
116
|
+
createErrorHandlingRealtimeTransport
|
|
117
|
+
};
|
|
110
118
|
export {
|
|
119
|
+
adapterNextRealtimeInternals,
|
|
111
120
|
mutation,
|
|
112
121
|
query
|
|
113
122
|
};
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,107 +1,7 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { CreateHoloOptions } from '@holo-js/core';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
interface GeneratedModelRegistryEntry {
|
|
6
|
-
readonly sourcePath: string;
|
|
7
|
-
readonly name: string;
|
|
8
|
-
readonly prunable: boolean;
|
|
9
|
-
}
|
|
10
|
-
interface GeneratedMigrationRegistryEntry {
|
|
11
|
-
readonly sourcePath: string;
|
|
12
|
-
readonly name: string;
|
|
13
|
-
}
|
|
14
|
-
interface GeneratedSeederRegistryEntry {
|
|
15
|
-
readonly sourcePath: string;
|
|
16
|
-
readonly name: string;
|
|
17
|
-
}
|
|
18
|
-
interface GeneratedCommandRegistryEntry {
|
|
19
|
-
readonly sourcePath: string;
|
|
20
|
-
readonly name: string;
|
|
21
|
-
readonly aliases: readonly string[];
|
|
22
|
-
readonly description: string;
|
|
23
|
-
readonly usage?: string;
|
|
24
|
-
}
|
|
25
|
-
interface GeneratedJobRegistryEntry {
|
|
26
|
-
readonly sourcePath: string;
|
|
27
|
-
readonly name: string;
|
|
28
|
-
readonly connection?: string;
|
|
29
|
-
readonly queue?: string;
|
|
30
|
-
readonly tries?: number;
|
|
31
|
-
readonly backoff?: number | readonly number[];
|
|
32
|
-
readonly timeout?: number;
|
|
33
|
-
}
|
|
34
|
-
interface GeneratedEventRegistryEntry {
|
|
35
|
-
readonly sourcePath: string;
|
|
36
|
-
readonly name: string;
|
|
37
|
-
readonly exportName?: string;
|
|
38
|
-
}
|
|
39
|
-
interface GeneratedListenerRegistryEntry {
|
|
40
|
-
readonly sourcePath: string;
|
|
41
|
-
readonly id: string;
|
|
42
|
-
readonly eventNames: readonly string[];
|
|
43
|
-
readonly exportName?: string;
|
|
44
|
-
}
|
|
45
|
-
interface GeneratedBroadcastRegistryEntry {
|
|
46
|
-
readonly sourcePath: string;
|
|
47
|
-
readonly name: string;
|
|
48
|
-
readonly exportName?: string;
|
|
49
|
-
readonly channels: readonly {
|
|
50
|
-
readonly type: 'public' | 'private' | 'presence';
|
|
51
|
-
readonly pattern: string;
|
|
52
|
-
}[];
|
|
53
|
-
}
|
|
54
|
-
interface GeneratedChannelRegistryEntry {
|
|
55
|
-
readonly sourcePath: string;
|
|
56
|
-
readonly pattern: string;
|
|
57
|
-
readonly exportName?: string;
|
|
58
|
-
readonly guard?: string;
|
|
59
|
-
readonly type: 'private' | 'presence';
|
|
60
|
-
readonly params: readonly string[];
|
|
61
|
-
readonly whispers: readonly string[];
|
|
62
|
-
}
|
|
63
|
-
interface GeneratedAuthorizationPolicyRegistryEntry {
|
|
64
|
-
readonly sourcePath: string;
|
|
65
|
-
readonly name: string;
|
|
66
|
-
readonly exportName?: string;
|
|
67
|
-
readonly target: string;
|
|
68
|
-
readonly classActions: readonly string[];
|
|
69
|
-
readonly recordActions: readonly string[];
|
|
70
|
-
}
|
|
71
|
-
interface GeneratedAuthorizationAbilityRegistryEntry {
|
|
72
|
-
readonly sourcePath: string;
|
|
73
|
-
readonly name: string;
|
|
74
|
-
readonly exportName?: string;
|
|
75
|
-
}
|
|
76
|
-
interface GeneratedProjectRegistry {
|
|
77
|
-
readonly version: 1;
|
|
78
|
-
readonly generatedAt: string;
|
|
79
|
-
readonly paths: {
|
|
80
|
-
readonly models: string;
|
|
81
|
-
readonly migrations: string;
|
|
82
|
-
readonly seeders: string;
|
|
83
|
-
readonly commands: string;
|
|
84
|
-
readonly jobs: string;
|
|
85
|
-
readonly events: string;
|
|
86
|
-
readonly listeners: string;
|
|
87
|
-
readonly broadcast: string;
|
|
88
|
-
readonly channels: string;
|
|
89
|
-
readonly authorizationPolicies: string;
|
|
90
|
-
readonly authorizationAbilities: string;
|
|
91
|
-
readonly generatedSchema: string;
|
|
92
|
-
};
|
|
93
|
-
readonly models: readonly GeneratedModelRegistryEntry[];
|
|
94
|
-
readonly migrations: readonly GeneratedMigrationRegistryEntry[];
|
|
95
|
-
readonly seeders: readonly GeneratedSeederRegistryEntry[];
|
|
96
|
-
readonly commands: readonly GeneratedCommandRegistryEntry[];
|
|
97
|
-
readonly jobs: readonly GeneratedJobRegistryEntry[];
|
|
98
|
-
readonly events: readonly GeneratedEventRegistryEntry[];
|
|
99
|
-
readonly listeners: readonly GeneratedListenerRegistryEntry[];
|
|
100
|
-
readonly broadcast: readonly GeneratedBroadcastRegistryEntry[];
|
|
101
|
-
readonly channels: readonly GeneratedChannelRegistryEntry[];
|
|
102
|
-
readonly authorizationPolicies: readonly GeneratedAuthorizationPolicyRegistryEntry[];
|
|
103
|
-
readonly authorizationAbilities: readonly GeneratedAuthorizationAbilityRegistryEntry[];
|
|
104
|
-
}
|
|
1
|
+
import * as _holo_js_core_runtime from '@holo-js/core/runtime';
|
|
2
|
+
import { CreateHoloOptions } from '@holo-js/core/runtime';
|
|
3
|
+
import * as _holo_js_config from '@holo-js/config';
|
|
4
|
+
import { HoloConfigMap, DotPath, HoloConfigValues, ValueAtPath } from '@holo-js/config';
|
|
105
5
|
|
|
106
6
|
type NextRequestLike = {
|
|
107
7
|
readonly cookies: {
|
|
@@ -116,24 +16,53 @@ declare function runWithNextRequest<TValue>(request: NextRequestLike, callback:
|
|
|
116
16
|
type NextHoloRuntimeOptions = CreateHoloOptions & {
|
|
117
17
|
readonly projectRoot: string;
|
|
118
18
|
};
|
|
19
|
+
type ResponseCookieOptions = {
|
|
20
|
+
path?: string;
|
|
21
|
+
domain?: string;
|
|
22
|
+
maxAge?: number;
|
|
23
|
+
expires?: Date;
|
|
24
|
+
secure?: boolean;
|
|
25
|
+
httpOnly?: boolean;
|
|
26
|
+
sameSite?: 'lax' | 'strict' | 'none';
|
|
27
|
+
partitioned?: boolean;
|
|
28
|
+
};
|
|
29
|
+
type ParsedResponseCookie = {
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly value: string;
|
|
32
|
+
readonly options: ResponseCookieOptions;
|
|
33
|
+
};
|
|
34
|
+
declare function createNextHttpAccessFallbackError(status: 403 | 404, message: string): never;
|
|
35
|
+
declare function safeDecodeCookieSegment(value: string): string;
|
|
36
|
+
declare function parseResponseCookie(cookie: string): ParsedResponseCookie | null;
|
|
37
|
+
declare function parseRequestCookies(header: string | null): Map<string, string>;
|
|
38
|
+
declare function isMissingNextRequestScope(error: unknown): boolean;
|
|
119
39
|
declare function createNextRequestContext(request: Request): NextRequestLike;
|
|
40
|
+
declare function resolveNextAuthRequestAccessors(): NonNullable<CreateHoloOptions['authRequest']>;
|
|
120
41
|
declare function createNextHoloHelpers<TCustom extends HoloConfigMap = HoloConfigMap>(options: NextHoloRuntimeOptions): {
|
|
121
42
|
getApp(): Promise<{
|
|
122
43
|
projectRoot: string;
|
|
123
|
-
config: LoadedHoloConfig<TCustom>;
|
|
124
|
-
registry: GeneratedProjectRegistry | undefined;
|
|
125
|
-
runtime:
|
|
44
|
+
config: _holo_js_config.LoadedHoloConfig<TCustom>;
|
|
45
|
+
registry: _holo_js_core_runtime.GeneratedProjectRegistry | undefined;
|
|
46
|
+
runtime: _holo_js_core_runtime.HoloRuntime<TCustom>;
|
|
126
47
|
}>;
|
|
127
48
|
getProject(): Promise<{
|
|
128
49
|
projectRoot: string;
|
|
129
|
-
config: LoadedHoloConfig<TCustom>;
|
|
130
|
-
registry: GeneratedProjectRegistry | undefined;
|
|
131
|
-
runtime:
|
|
50
|
+
config: _holo_js_config.LoadedHoloConfig<TCustom>;
|
|
51
|
+
registry: _holo_js_core_runtime.GeneratedProjectRegistry | undefined;
|
|
52
|
+
runtime: _holo_js_core_runtime.HoloRuntime<TCustom>;
|
|
132
53
|
}>;
|
|
133
|
-
getSession(): Promise<
|
|
134
|
-
getAuth(): Promise<
|
|
135
|
-
useConfig: <TPath extends DotPath<
|
|
136
|
-
config: <TPath extends DotPath<
|
|
54
|
+
getSession(): Promise<_holo_js_core_runtime.HoloSessionRuntimeBinding | undefined>;
|
|
55
|
+
getAuth(): Promise<_holo_js_core_runtime.HoloAuthRuntimeBinding | undefined>;
|
|
56
|
+
useConfig: <TPath extends DotPath<HoloConfigValues<TCustom>>>(path: TPath) => Promise<ValueAtPath<HoloConfigValues<TCustom>, TPath>>;
|
|
57
|
+
config: <TPath extends DotPath<HoloConfigValues<TCustom>>>(path: TPath) => Promise<ValueAtPath<HoloConfigValues<TCustom>, TPath>>;
|
|
58
|
+
};
|
|
59
|
+
declare const adapterNextRuntimeInternals: {
|
|
60
|
+
safeDecodeCookieSegment: typeof safeDecodeCookieSegment;
|
|
61
|
+
parseResponseCookie: typeof parseResponseCookie;
|
|
62
|
+
parseRequestCookies: typeof parseRequestCookies;
|
|
63
|
+
isMissingNextRequestScope: typeof isMissingNextRequestScope;
|
|
64
|
+
resolveNextAuthRequestAccessors: typeof resolveNextAuthRequestAccessors;
|
|
65
|
+
createNextHttpAccessFallbackError: typeof createNextHttpAccessFallbackError;
|
|
137
66
|
};
|
|
138
67
|
|
|
139
|
-
export { type NextHoloRuntimeOptions, type NextRequestLike, createNextHoloHelpers, createNextRequestContext, runWithNextRequest };
|
|
68
|
+
export { type NextHoloRuntimeOptions, type NextRequestLike, adapterNextRuntimeInternals, createNextHoloHelpers, createNextRequestContext, runWithNextRequest };
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/runtime.ts
|
|
2
|
-
import { initializeHolo } from "@holo-js/core";
|
|
2
|
+
import { initializeHolo } from "@holo-js/core/runtime";
|
|
3
3
|
|
|
4
4
|
// src/request-context.ts
|
|
5
5
|
import { AsyncLocalStorage } from "async_hooks";
|
|
@@ -12,7 +12,13 @@ function getCurrentNextRequest() {
|
|
|
12
12
|
return getNextRequestStore().getStore();
|
|
13
13
|
}
|
|
14
14
|
function runWithNextRequest(request, callback) {
|
|
15
|
-
return getNextRequestStore().run(request,
|
|
15
|
+
return getNextRequestStore().run(request, () => {
|
|
16
|
+
const runner = globalThis.__holoNextAuthRequestRunner;
|
|
17
|
+
return runner ? runner(callback) : callback();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function setNextAuthRequestRunner(runner) {
|
|
21
|
+
globalThis.__holoNextAuthRequestRunner = runner;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
// src/runtime.ts
|
|
@@ -29,8 +35,8 @@ function safeDecodeCookieSegment(value) {
|
|
|
29
35
|
}
|
|
30
36
|
}
|
|
31
37
|
function parseResponseCookie(cookie) {
|
|
32
|
-
const [nameValue, ...attributes] = cookie.split(";");
|
|
33
|
-
const separator = nameValue
|
|
38
|
+
const [nameValue = "", ...attributes] = cookie.split(";");
|
|
39
|
+
const separator = nameValue.indexOf("=");
|
|
34
40
|
if (!nameValue || separator <= 0) {
|
|
35
41
|
return null;
|
|
36
42
|
}
|
|
@@ -101,6 +107,9 @@ function parseRequestCookies(header) {
|
|
|
101
107
|
}
|
|
102
108
|
return cookies;
|
|
103
109
|
}
|
|
110
|
+
function isMissingNextRequestScope(error) {
|
|
111
|
+
return error instanceof Error && error.message.includes("outside a request scope");
|
|
112
|
+
}
|
|
104
113
|
function createNextRequestContext(request) {
|
|
105
114
|
const nextRequest = request;
|
|
106
115
|
const parsedCookies = nextRequest.cookies ? void 0 : parseRequestCookies(request.headers.get("cookie"));
|
|
@@ -125,27 +134,41 @@ function resolveNextAuthRequestAccessors() {
|
|
|
125
134
|
if (request) {
|
|
126
135
|
return request.cookies.get(name)?.value;
|
|
127
136
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
137
|
+
try {
|
|
138
|
+
const { cookies } = await import("next/headers.js");
|
|
139
|
+
const store = await cookies();
|
|
140
|
+
return store.get(name)?.value;
|
|
141
|
+
} catch (error) {
|
|
142
|
+
if (isMissingNextRequestScope(error)) return void 0;
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
131
145
|
},
|
|
132
146
|
async getHeader(name) {
|
|
133
147
|
const request = getCurrentNextRequest();
|
|
134
148
|
if (request) {
|
|
135
149
|
return request.headers.get(name) ?? void 0;
|
|
136
150
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
151
|
+
try {
|
|
152
|
+
const { headers } = await import("next/headers.js");
|
|
153
|
+
const requestHeaders = await headers();
|
|
154
|
+
return requestHeaders.get(name) ?? void 0;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
if (isMissingNextRequestScope(error)) return void 0;
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
140
159
|
},
|
|
141
160
|
async appendResponseCookie(cookie) {
|
|
142
161
|
const parsed = parseResponseCookie(cookie);
|
|
143
162
|
if (!parsed) {
|
|
144
163
|
return;
|
|
145
164
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
165
|
+
try {
|
|
166
|
+
const { cookies } = await import("next/headers.js");
|
|
167
|
+
const store = await cookies();
|
|
168
|
+
store.set(parsed.name, parsed.value, parsed.options);
|
|
169
|
+
} catch (error) {
|
|
170
|
+
if (!isMissingNextRequestScope(error)) throw error;
|
|
171
|
+
}
|
|
149
172
|
},
|
|
150
173
|
async redirectResponse(url) {
|
|
151
174
|
const { redirect } = await import("next/navigation.js");
|
|
@@ -154,18 +177,23 @@ function resolveNextAuthRequestAccessors() {
|
|
|
154
177
|
};
|
|
155
178
|
}
|
|
156
179
|
function createNextHoloHelpers(options) {
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
180
|
+
const authRequest = options.authRequest ?? resolveNextAuthRequestAccessors();
|
|
181
|
+
const resolveRuntime = async () => {
|
|
182
|
+
const runtime = await initializeHolo(options.projectRoot, {
|
|
183
|
+
...options,
|
|
184
|
+
authRequest,
|
|
185
|
+
authorizationError: options.authorizationError ?? {
|
|
186
|
+
createError(decision) {
|
|
187
|
+
if (decision.status === 404) {
|
|
188
|
+
return createNextHttpAccessFallbackError(404, decision.message ?? "Resource not found.");
|
|
189
|
+
}
|
|
190
|
+
return createNextHttpAccessFallbackError(403, decision.message ?? "Forbidden");
|
|
164
191
|
}
|
|
165
|
-
return createNextHttpAccessFallbackError(403, decision.message ?? "Forbidden");
|
|
166
192
|
}
|
|
167
|
-
}
|
|
168
|
-
|
|
193
|
+
});
|
|
194
|
+
setNextAuthRequestRunner((callback) => runtime.runWithAuthRequestAccessors(authRequest, callback));
|
|
195
|
+
return runtime;
|
|
196
|
+
};
|
|
169
197
|
const useConfig = async (path) => {
|
|
170
198
|
const runtime = await resolveRuntime();
|
|
171
199
|
return runtime.config(path);
|
|
@@ -198,7 +226,16 @@ function createNextHoloHelpers(options) {
|
|
|
198
226
|
config: useConfig
|
|
199
227
|
};
|
|
200
228
|
}
|
|
229
|
+
var adapterNextRuntimeInternals = {
|
|
230
|
+
safeDecodeCookieSegment,
|
|
231
|
+
parseResponseCookie,
|
|
232
|
+
parseRequestCookies,
|
|
233
|
+
isMissingNextRequestScope,
|
|
234
|
+
resolveNextAuthRequestAccessors,
|
|
235
|
+
createNextHttpAccessFallbackError
|
|
236
|
+
};
|
|
201
237
|
export {
|
|
238
|
+
adapterNextRuntimeInternals,
|
|
202
239
|
createNextHoloHelpers,
|
|
203
240
|
createNextRequestContext,
|
|
204
241
|
runWithNextRequest
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holo-js/adapter-next",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Holo-JS Framework - Next.js adapter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,12 +43,13 @@
|
|
|
43
43
|
"test": "vitest --run"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@holo-js/
|
|
47
|
-
"@holo-js/
|
|
46
|
+
"@holo-js/adapter-shared": "^0.3.0",
|
|
47
|
+
"@holo-js/config": "^0.3.0",
|
|
48
|
+
"@holo-js/core": "^0.3.0"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
|
-
"@holo-js/forms": "^0.
|
|
51
|
-
"@holo-js/realtime": "^0.
|
|
51
|
+
"@holo-js/forms": "^0.3.0",
|
|
52
|
+
"@holo-js/realtime": "^0.3.0",
|
|
52
53
|
"next": "^16.2.4",
|
|
53
54
|
"react": "^19.2.6"
|
|
54
55
|
},
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
}
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
|
-
"@holo-js/realtime": "^0.
|
|
65
|
+
"@holo-js/realtime": "^0.3.0",
|
|
65
66
|
"@types/node": "^22.10.2",
|
|
66
67
|
"next": "^16.2.4",
|
|
67
68
|
"tsup": "^8.3.5",
|
package/dist/chunk-3RI2KDLY.mjs
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
// src/client-errors.ts
|
|
2
|
-
import { normalizeHoloHttpError } from "@holo-js/core/errors";
|
|
3
|
-
var nextHttpAccessFallbackStatuses = /* @__PURE__ */ new Set([401, 403, 404]);
|
|
4
|
-
function normalizeNextClientHttpError(error) {
|
|
5
|
-
return normalizeHoloHttpError(error);
|
|
6
|
-
}
|
|
7
|
-
function createNextRenderableError(error) {
|
|
8
|
-
if (!nextHttpAccessFallbackStatuses.has(error.status)) {
|
|
9
|
-
return new Error(error.message, { cause: error.cause });
|
|
10
|
-
}
|
|
11
|
-
const nextError = new Error(error.message, { cause: error.cause });
|
|
12
|
-
nextError.digest = `NEXT_HTTP_ERROR_FALLBACK;${error.status}`;
|
|
13
|
-
return nextError;
|
|
14
|
-
}
|
|
15
|
-
function renderNextClientHttpErrorPage(error) {
|
|
16
|
-
const browserDocument = globalThis.document;
|
|
17
|
-
if (!browserDocument) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
browserDocument.title = `${error.status}: ${error.message}`;
|
|
21
|
-
const existingRoot = browserDocument.getElementById("__holo_next_client_http_error__");
|
|
22
|
-
const root = existingRoot ?? browserDocument.createElement("main");
|
|
23
|
-
root.id = "__holo_next_client_http_error__";
|
|
24
|
-
root.setAttribute("role", "alert");
|
|
25
|
-
root.style.cssText = [
|
|
26
|
-
"position:fixed",
|
|
27
|
-
"inset:0",
|
|
28
|
-
"z-index:2147483647",
|
|
29
|
-
"display:grid",
|
|
30
|
-
"place-items:center",
|
|
31
|
-
"margin:0",
|
|
32
|
-
"background:#fff",
|
|
33
|
-
"color:#000",
|
|
34
|
-
"font-family:Arial,Helvetica,sans-serif"
|
|
35
|
-
].join(";");
|
|
36
|
-
const wrapper = browserDocument.createElement("div");
|
|
37
|
-
wrapper.style.cssText = "display:flex;align-items:center;gap:1.5rem;padding:1.5rem";
|
|
38
|
-
const status = browserDocument.createElement("h1");
|
|
39
|
-
status.className = "next-error-h1";
|
|
40
|
-
status.textContent = String(error.status);
|
|
41
|
-
status.style.cssText = [
|
|
42
|
-
"display:inline-block",
|
|
43
|
-
"margin:0 1.25rem 0 0",
|
|
44
|
-
"padding:0 1.5rem 0 0",
|
|
45
|
-
"font-size:24px",
|
|
46
|
-
"font-weight:500",
|
|
47
|
-
"line-height:49px",
|
|
48
|
-
"vertical-align:top",
|
|
49
|
-
"border-right:1px solid rgba(0,0,0,.3)"
|
|
50
|
-
].join(";");
|
|
51
|
-
const description = browserDocument.createElement("div");
|
|
52
|
-
description.style.cssText = "display:inline-block;text-align:left;line-height:49px;height:49px;vertical-align:middle";
|
|
53
|
-
const message = browserDocument.createElement("h2");
|
|
54
|
-
message.textContent = error.message;
|
|
55
|
-
message.style.cssText = "font-size:14px;font-weight:400;line-height:49px;margin:0";
|
|
56
|
-
description.append(message);
|
|
57
|
-
wrapper.append(status, description);
|
|
58
|
-
root.replaceChildren(wrapper);
|
|
59
|
-
for (const child of Array.from(browserDocument.body.children)) {
|
|
60
|
-
if (child.id === root.id) {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
child.style.display = "none";
|
|
64
|
-
}
|
|
65
|
-
if (!existingRoot) {
|
|
66
|
-
browserDocument.body.append(root);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export {
|
|
71
|
-
normalizeNextClientHttpError,
|
|
72
|
-
createNextRenderableError,
|
|
73
|
-
renderNextClientHttpErrorPage
|
|
74
|
-
};
|