@holo-js/adapter-next 0.5.0 → 0.5.2
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/.holo-build-fingerprint +1 -1
- package/dist/chunk-755YLPDP.mjs +51 -0
- package/dist/chunk-RFEFJPTI.mjs +13 -0
- package/dist/chunk-ZPWXXNMV.mjs +13 -0
- package/dist/client.d.ts +2 -15
- package/dist/client.mjs +4 -102
- package/dist/config.d.ts +1 -0
- package/dist/internal/request-validation-flash.browser.d.ts +5 -0
- package/dist/internal/request-validation-flash.browser.mjs +26 -0
- package/dist/internal/request-validation-flash.d.ts +9 -0
- package/dist/internal/request-validation-flash.mjs +33 -0
- package/dist/internal/use-form.d.ts +15 -0
- package/dist/internal/use-form.mjs +107 -0
- package/dist/internal/use-validation-errors.d.ts +10 -0
- package/dist/internal/use-validation-errors.mjs +122 -0
- package/dist/module-transform-loader-B5slbWAk.d.ts +9 -0
- package/dist/route-loader.d.ts +4 -4
- package/dist/route-loader.mjs +7 -4
- package/dist/runtime.d.ts +2 -1
- package/dist/runtime.mjs +77 -20
- package/dist/server-action-loader.d.ts +4 -4
- package/dist/server-action-loader.mjs +7 -4
- package/package.json +27 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3ea9037da21ddc3c03bcd3a9105f0feab1f647d3112428cbcc09c81578afcd45
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// src/validation-flash.ts
|
|
2
|
+
var VALIDATION_FLASH_COOKIE = "holo_form_failure";
|
|
3
|
+
var VALIDATION_FLASH_ELEMENT_ID = "__holo_validation_flash";
|
|
4
|
+
var MAX_FLASH_COOKIE_BYTES = 3800;
|
|
5
|
+
function isMessages(value) {
|
|
6
|
+
return Array.isArray(value) && value.every((message) => typeof message === "string");
|
|
7
|
+
}
|
|
8
|
+
function isErrors(value) {
|
|
9
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every(isMessages);
|
|
10
|
+
}
|
|
11
|
+
function parseValidationFlash(value) {
|
|
12
|
+
if (!value) return void 0;
|
|
13
|
+
try {
|
|
14
|
+
const flash = JSON.parse(value);
|
|
15
|
+
if (typeof flash !== "object" || flash === null) return void 0;
|
|
16
|
+
const { bag, page, errors } = flash;
|
|
17
|
+
return typeof bag === "string" && typeof page === "string" && isErrors(errors) ? { bag, page, errors } : void 0;
|
|
18
|
+
} catch {
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function validationFlashPage(pathname) {
|
|
23
|
+
let hash = 2166136261;
|
|
24
|
+
for (const character of pathname) {
|
|
25
|
+
hash = Math.imul(hash ^ (character.codePointAt(0) ?? 0), 16777619);
|
|
26
|
+
}
|
|
27
|
+
return (hash >>> 0).toString(36);
|
|
28
|
+
}
|
|
29
|
+
function fitsInCookie(flash) {
|
|
30
|
+
return encodeURIComponent(JSON.stringify(flash)).length <= MAX_FLASH_COOKIE_BYTES;
|
|
31
|
+
}
|
|
32
|
+
function firstMessages(errors) {
|
|
33
|
+
return Object.fromEntries(Object.entries(errors).map(([path, messages]) => [path, messages.slice(0, 1)]));
|
|
34
|
+
}
|
|
35
|
+
function serializeValidationFlash(flash) {
|
|
36
|
+
if (fitsInCookie(flash)) return JSON.stringify(flash);
|
|
37
|
+
if (!fitsInCookie({ ...flash, errors: {} })) return void 0;
|
|
38
|
+
const errors = {};
|
|
39
|
+
for (const [path, messages] of Object.entries(firstMessages(flash.errors))) {
|
|
40
|
+
if (fitsInCookie({ ...flash, errors: { ...errors, [path]: messages } })) errors[path] = messages;
|
|
41
|
+
}
|
|
42
|
+
return JSON.stringify({ ...flash, errors });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
VALIDATION_FLASH_COOKIE,
|
|
47
|
+
VALIDATION_FLASH_ELEMENT_ID,
|
|
48
|
+
parseValidationFlash,
|
|
49
|
+
validationFlashPage,
|
|
50
|
+
serializeValidationFlash
|
|
51
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/module-transform-loader.ts
|
|
2
|
+
function runModuleTransform(context, transform, source, incomingMap) {
|
|
3
|
+
context.cacheable?.();
|
|
4
|
+
const inputMap = incomingMap ?? void 0;
|
|
5
|
+
const result = transform(source, context.resourcePath, inputMap);
|
|
6
|
+
if (!context.callback) return result?.code ?? source;
|
|
7
|
+
context.callback(null, result?.code ?? source, result?.map ?? inputMap);
|
|
8
|
+
return void 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
runModuleTransform
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/rendered-validation-flash.ts
|
|
2
|
+
var renderedValidationFlashes = globalThis.__holoNextRenderedValidationFlashes ??= /* @__PURE__ */ new WeakMap();
|
|
3
|
+
function rememberRenderedValidationFlash(request, flash) {
|
|
4
|
+
renderedValidationFlashes.set(request, flash);
|
|
5
|
+
}
|
|
6
|
+
function renderedValidationFlash(request) {
|
|
7
|
+
return request ? renderedValidationFlashes.get(request) : void 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
rememberRenderedValidationFlash,
|
|
12
|
+
renderedValidationFlash
|
|
13
|
+
};
|
package/dist/client.d.ts
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { UseFormOptions, ClientSubmitContext, ClientSubmitResult, UseFormResult, InferFormFieldTree } from '@holo-js/forms/internal/client';
|
|
1
|
+
export { adapterNextClientInternals, useForm } from '@holo-js/adapter-next/internal/use-form';
|
|
2
|
+
export { useValidationErrors } from '@holo-js/adapter-next/internal/use-validation-errors';
|
|
4
3
|
export { ClientCsrfOptions, ClientSubmitContext, ClientSubmitResult, FormFieldState, FormFieldTree, FormRequestCredentials, UseFormOptions, UseFormResult, ValidateOnMode } from '@holo-js/forms/internal/client';
|
|
5
|
-
|
|
6
|
-
declare function isNextRedirectError(error: unknown): boolean;
|
|
7
|
-
declare function createSubmitterBridge<TData, TSuccess>(optionsRef: {
|
|
8
|
-
current: UseFormOptions<TData, TSuccess> | undefined;
|
|
9
|
-
}, onHttpError: (error: Error) => void): (context: ClientSubmitContext<TData>) => Promise<ClientSubmitResult<TData, TSuccess> | void> | ClientSubmitResult<TData, TSuccess> | void;
|
|
10
|
-
declare function useForm<TSchema extends ValidationSchema, TSuccess = unknown>(schemaDefinition: TSchema, options?: UseFormOptions<InferFormData<TSchema>, TSuccess>): UseFormResult<InferFormData<TSchema>, TSuccess, InferFormFieldTree<TSchema>>;
|
|
11
|
-
declare const adapterNextClientInternals: {
|
|
12
|
-
isNextRedirectError: typeof isNextRedirectError;
|
|
13
|
-
createSubmitterBridge: typeof createSubmitterBridge;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export { adapterNextClientInternals, useForm };
|
package/dist/client.mjs
CHANGED
|
@@ -1,108 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
createNextRenderableError,
|
|
4
|
-
normalizeNextClientHttpError,
|
|
5
|
-
renderNextClientHttpErrorPage
|
|
6
|
-
} from "./chunk-PLFHK46L.mjs";
|
|
7
2
|
|
|
8
3
|
// src/client.ts
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
createFormClient,
|
|
12
|
-
markClientSubmitControlFlowError
|
|
13
|
-
} from "@holo-js/forms/internal/client";
|
|
14
|
-
function isPlainObject(value) {
|
|
15
|
-
return !!value && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof Blob);
|
|
16
|
-
}
|
|
17
|
-
function areEqual(left, right) {
|
|
18
|
-
if (Object.is(left, right)) {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
if (left instanceof Date && right instanceof Date) {
|
|
22
|
-
return left.getTime() === right.getTime();
|
|
23
|
-
}
|
|
24
|
-
if (left instanceof Blob || right instanceof Blob) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
if (Array.isArray(left) && Array.isArray(right)) {
|
|
28
|
-
return left.length === right.length && left.every((value, index) => areEqual(value, right[index]));
|
|
29
|
-
}
|
|
30
|
-
if (isPlainObject(left) && isPlainObject(right)) {
|
|
31
|
-
const leftKeys = Object.keys(left);
|
|
32
|
-
const rightKeys = Object.keys(right);
|
|
33
|
-
return leftKeys.length === rightKeys.length && leftKeys.every((key) => key in right && areEqual(left[key], right[key]));
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
function areOptionsEqual(left, right) {
|
|
38
|
-
return left.action === right.action && left.method === right.method && left.credentials === right.credentials && left.csrf?.endpoint === right.csrf?.endpoint && left.validateOn === right.validateOn && Boolean(left.submitter) === Boolean(right.submitter) && areEqual(left.initialValues, right.initialValues) && areEqual(left.initialState, right.initialState);
|
|
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
|
-
}
|
|
46
|
-
function createSubmitterBridge(optionsRef, onHttpError) {
|
|
47
|
-
return async (context) => {
|
|
48
|
-
const submitter = optionsRef.current?.submitter;
|
|
49
|
-
if (!submitter) {
|
|
50
|
-
throw new TypeError("Expected submitter to be defined.");
|
|
51
|
-
}
|
|
52
|
-
try {
|
|
53
|
-
return await submitter(context);
|
|
54
|
-
} catch (error) {
|
|
55
|
-
if (isNextRedirectError(error)) {
|
|
56
|
-
throw markClientSubmitControlFlowError(error);
|
|
57
|
-
}
|
|
58
|
-
const httpError = normalizeNextClientHttpError(error);
|
|
59
|
-
if (httpError) {
|
|
60
|
-
renderNextClientHttpErrorPage(httpError);
|
|
61
|
-
onHttpError(createNextRenderableError(httpError));
|
|
62
|
-
}
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function useForm(schemaDefinition, options = {}) {
|
|
68
|
-
const formRef = useRef(void 0);
|
|
69
|
-
const previousSchemaRef = useRef(void 0);
|
|
70
|
-
const previousOptionsRef = useRef(void 0);
|
|
71
|
-
const latestOptionsRef = useRef(void 0);
|
|
72
|
-
const submitterBridgeRef = useRef(void 0);
|
|
73
|
-
const [httpError, setHttpError] = useState(void 0);
|
|
74
|
-
const [, setVersion] = useState(0);
|
|
75
|
-
if (httpError) {
|
|
76
|
-
throw httpError;
|
|
77
|
-
}
|
|
78
|
-
latestOptionsRef.current = options;
|
|
79
|
-
if (options.submitter && !submitterBridgeRef.current) {
|
|
80
|
-
submitterBridgeRef.current = createSubmitterBridge(latestOptionsRef, setHttpError);
|
|
81
|
-
}
|
|
82
|
-
const resolvedOptions = options.submitter ? {
|
|
83
|
-
...options,
|
|
84
|
-
submitter: submitterBridgeRef.current
|
|
85
|
-
} : options;
|
|
86
|
-
if (!formRef.current || previousSchemaRef.current !== schemaDefinition) {
|
|
87
|
-
formRef.current = createFormClient(schemaDefinition, resolvedOptions);
|
|
88
|
-
previousSchemaRef.current = schemaDefinition;
|
|
89
|
-
previousOptionsRef.current = options;
|
|
90
|
-
} else {
|
|
91
|
-
const previousOptions = previousOptionsRef.current;
|
|
92
|
-
if (!areOptionsEqual(previousOptions, options)) {
|
|
93
|
-
formRef.current = createFormClient(schemaDefinition, resolvedOptions);
|
|
94
|
-
previousOptionsRef.current = options;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const form = formRef.current;
|
|
98
|
-
useEffect(() => form.subscribe(() => setVersion((version) => version + 1)), [form]);
|
|
99
|
-
return form;
|
|
100
|
-
}
|
|
101
|
-
var adapterNextClientInternals = {
|
|
102
|
-
isNextRedirectError,
|
|
103
|
-
createSubmitterBridge
|
|
104
|
-
};
|
|
4
|
+
import { adapterNextClientInternals, useForm } from "@holo-js/adapter-next/internal/use-form";
|
|
5
|
+
import { useValidationErrors } from "@holo-js/adapter-next/internal/use-validation-errors";
|
|
105
6
|
export {
|
|
106
7
|
adapterNextClientInternals,
|
|
107
|
-
useForm
|
|
8
|
+
useForm,
|
|
9
|
+
useValidationErrors
|
|
108
10
|
};
|
package/dist/config.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ interface NextConfig {
|
|
|
14
14
|
readonly outputFileTracingExcludes?: Record<string, string[]>;
|
|
15
15
|
readonly outputFileTracingRoot?: string;
|
|
16
16
|
readonly experimental?: Record<string, unknown>;
|
|
17
|
+
readonly pageExtensions?: readonly string[];
|
|
17
18
|
readonly turbopack?: TurbopackConfig;
|
|
18
19
|
readonly rewrites?: () => Promise<unknown>;
|
|
19
20
|
readonly webpack?: (config: WebpackConfig, context: WebpackConfigContext) => WebpackConfig;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VALIDATION_FLASH_ELEMENT_ID
|
|
3
|
+
} from "../chunk-755YLPDP.mjs";
|
|
4
|
+
|
|
5
|
+
// src/request-validation-flash.browser.ts
|
|
6
|
+
var hydrationFlash;
|
|
7
|
+
function readHydrationFlash() {
|
|
8
|
+
const text = globalThis.document?.getElementById(VALIDATION_FLASH_ELEMENT_ID)?.textContent;
|
|
9
|
+
if (!text) return "";
|
|
10
|
+
try {
|
|
11
|
+
const flash = JSON.parse(text);
|
|
12
|
+
return typeof flash === "string" ? flash : "";
|
|
13
|
+
} catch {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function documentValidationFlash() {
|
|
18
|
+
return hydrationFlash ??= readHydrationFlash();
|
|
19
|
+
}
|
|
20
|
+
function useRequestValidationFlash() {
|
|
21
|
+
return documentValidationFlash();
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
documentValidationFlash,
|
|
25
|
+
useRequestValidationFlash
|
|
26
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The server render has no document; see useRequestValidationFlash(). */
|
|
2
|
+
declare function documentValidationFlash(): string;
|
|
3
|
+
/**
|
|
4
|
+
* The flash a form posted without JavaScript left for this server render. The render writes
|
|
5
|
+
* it into the page once, so the browser hydrates with the same errors.
|
|
6
|
+
*/
|
|
7
|
+
declare function useRequestValidationFlash(): string;
|
|
8
|
+
|
|
9
|
+
export { documentValidationFlash, useRequestValidationFlash };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderedValidationFlash
|
|
3
|
+
} from "../chunk-ZPWXXNMV.mjs";
|
|
4
|
+
import {
|
|
5
|
+
VALIDATION_FLASH_ELEMENT_ID
|
|
6
|
+
} from "../chunk-755YLPDP.mjs";
|
|
7
|
+
|
|
8
|
+
// src/request-validation-flash.ts
|
|
9
|
+
import { createElement } from "react";
|
|
10
|
+
import { useServerInsertedHTML } from "next/navigation.js";
|
|
11
|
+
import { workUnitAsyncStorage } from "next/dist/server/app-render/work-unit-async-storage.external.js";
|
|
12
|
+
var writtenRequests = /* @__PURE__ */ new WeakSet();
|
|
13
|
+
function documentValidationFlash() {
|
|
14
|
+
return "";
|
|
15
|
+
}
|
|
16
|
+
function useRequestValidationFlash() {
|
|
17
|
+
const request = workUnitAsyncStorage.getStore();
|
|
18
|
+
const flash = renderedValidationFlash(request) ?? "";
|
|
19
|
+
useServerInsertedHTML(() => {
|
|
20
|
+
if (!flash || !request || writtenRequests.has(request)) return null;
|
|
21
|
+
writtenRequests.add(request);
|
|
22
|
+
return createElement("script", {
|
|
23
|
+
id: VALIDATION_FLASH_ELEMENT_ID,
|
|
24
|
+
type: "application/json",
|
|
25
|
+
dangerouslySetInnerHTML: { __html: JSON.stringify(flash).replace(/</g, "\\u003c") }
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return flash;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
documentValidationFlash,
|
|
32
|
+
useRequestValidationFlash
|
|
33
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InferFormData } from '@holo-js/forms';
|
|
2
|
+
import { ValidationSchema } from '@holo-js/validation';
|
|
3
|
+
import { UseFormOptions, ClientSubmitContext, ClientSubmitResult, UseFormResult, InferFormFieldTree } from '@holo-js/forms/internal/client';
|
|
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;
|
|
9
|
+
declare function useForm<TSchema extends ValidationSchema, 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
|
+
};
|
|
14
|
+
|
|
15
|
+
export { adapterNextClientInternals, useForm };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createNextRenderableError,
|
|
3
|
+
normalizeNextClientHttpError,
|
|
4
|
+
renderNextClientHttpErrorPage
|
|
5
|
+
} from "../chunk-PLFHK46L.mjs";
|
|
6
|
+
|
|
7
|
+
// src/use-form.ts
|
|
8
|
+
import { useEffect, useRef, useState } from "react";
|
|
9
|
+
import {
|
|
10
|
+
createFormClient,
|
|
11
|
+
markClientSubmitControlFlowError
|
|
12
|
+
} from "@holo-js/forms/internal/client";
|
|
13
|
+
function isPlainObject(value) {
|
|
14
|
+
return !!value && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof Blob);
|
|
15
|
+
}
|
|
16
|
+
function areEqual(left, right) {
|
|
17
|
+
if (Object.is(left, right)) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
if (left instanceof Date && right instanceof Date) {
|
|
21
|
+
return left.getTime() === right.getTime();
|
|
22
|
+
}
|
|
23
|
+
if (left instanceof Blob || right instanceof Blob) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
27
|
+
return left.length === right.length && left.every((value, index) => areEqual(value, right[index]));
|
|
28
|
+
}
|
|
29
|
+
if (isPlainObject(left) && isPlainObject(right)) {
|
|
30
|
+
const leftKeys = Object.keys(left);
|
|
31
|
+
const rightKeys = Object.keys(right);
|
|
32
|
+
return leftKeys.length === rightKeys.length && leftKeys.every((key) => key in right && areEqual(left[key], right[key]));
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
function areOptionsEqual(left, right) {
|
|
37
|
+
return left.action === right.action && left.method === right.method && left.credentials === right.credentials && left.csrf?.endpoint === right.csrf?.endpoint && left.validateOn === right.validateOn && Boolean(left.submitter) === Boolean(right.submitter) && areEqual(left.initialValues, right.initialValues) && areEqual(left.initialState, right.initialState);
|
|
38
|
+
}
|
|
39
|
+
function isNextRedirectError(error) {
|
|
40
|
+
if (!error || typeof error !== "object" && typeof error !== "function" || !("digest" in error)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
return typeof error.digest === "string" && error.digest.startsWith("NEXT_REDIRECT");
|
|
44
|
+
}
|
|
45
|
+
function createSubmitterBridge(optionsRef, onHttpError) {
|
|
46
|
+
return async (context) => {
|
|
47
|
+
const submitter = optionsRef.current?.submitter;
|
|
48
|
+
if (!submitter) {
|
|
49
|
+
throw new TypeError("Expected submitter to be defined.");
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
return await submitter(context);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (isNextRedirectError(error)) {
|
|
55
|
+
throw markClientSubmitControlFlowError(error);
|
|
56
|
+
}
|
|
57
|
+
const httpError = normalizeNextClientHttpError(error);
|
|
58
|
+
if (httpError) {
|
|
59
|
+
renderNextClientHttpErrorPage(httpError);
|
|
60
|
+
onHttpError(createNextRenderableError(httpError));
|
|
61
|
+
}
|
|
62
|
+
throw error;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function useForm(schemaDefinition, options = {}) {
|
|
67
|
+
const formRef = useRef(void 0);
|
|
68
|
+
const previousSchemaRef = useRef(void 0);
|
|
69
|
+
const previousOptionsRef = useRef(void 0);
|
|
70
|
+
const latestOptionsRef = useRef(void 0);
|
|
71
|
+
const submitterBridgeRef = useRef(void 0);
|
|
72
|
+
const [httpError, setHttpError] = useState(void 0);
|
|
73
|
+
const [, setVersion] = useState(0);
|
|
74
|
+
if (httpError) {
|
|
75
|
+
throw httpError;
|
|
76
|
+
}
|
|
77
|
+
latestOptionsRef.current = options;
|
|
78
|
+
if (options.submitter && !submitterBridgeRef.current) {
|
|
79
|
+
submitterBridgeRef.current = createSubmitterBridge(latestOptionsRef, setHttpError);
|
|
80
|
+
}
|
|
81
|
+
const resolvedOptions = options.submitter ? {
|
|
82
|
+
...options,
|
|
83
|
+
submitter: submitterBridgeRef.current
|
|
84
|
+
} : options;
|
|
85
|
+
if (!formRef.current || previousSchemaRef.current !== schemaDefinition) {
|
|
86
|
+
formRef.current = createFormClient(schemaDefinition, resolvedOptions);
|
|
87
|
+
previousSchemaRef.current = schemaDefinition;
|
|
88
|
+
previousOptionsRef.current = options;
|
|
89
|
+
} else {
|
|
90
|
+
const previousOptions = previousOptionsRef.current;
|
|
91
|
+
if (!areOptionsEqual(previousOptions, options)) {
|
|
92
|
+
formRef.current = createFormClient(schemaDefinition, resolvedOptions);
|
|
93
|
+
previousOptionsRef.current = options;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const form = formRef.current;
|
|
97
|
+
useEffect(() => form.subscribe(() => setVersion((version) => version + 1)), [form]);
|
|
98
|
+
return form;
|
|
99
|
+
}
|
|
100
|
+
var adapterNextClientInternals = {
|
|
101
|
+
isNextRedirectError,
|
|
102
|
+
createSubmitterBridge
|
|
103
|
+
};
|
|
104
|
+
export {
|
|
105
|
+
adapterNextClientInternals,
|
|
106
|
+
useForm
|
|
107
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ValidationErrorBag } from '@holo-js/validation';
|
|
2
|
+
|
|
3
|
+
/** Runs when a page first loads the hook. */
|
|
4
|
+
declare function startDocument(): void;
|
|
5
|
+
declare function useValidationErrors<TData = Record<string, unknown>>(bag?: string): ValidationErrorBag<TData>;
|
|
6
|
+
declare const adapterNextValidationErrorsInternals: {
|
|
7
|
+
startDocument: typeof startDocument;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { adapterNextValidationErrorsInternals, useValidationErrors };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
VALIDATION_FLASH_COOKIE,
|
|
3
|
+
parseValidationFlash,
|
|
4
|
+
validationFlashPage
|
|
5
|
+
} from "../chunk-755YLPDP.mjs";
|
|
6
|
+
|
|
7
|
+
// src/use-validation-errors.ts
|
|
8
|
+
import { useContext, useEffect, useMemo, useSyncExternalStore } from "react";
|
|
9
|
+
import { usePathname } from "next/navigation.js";
|
|
10
|
+
import { LayoutRouterContext } from "next/dist/shared/lib/app-router-context.shared-runtime.js";
|
|
11
|
+
import { DEFAULT_VALIDATION_BAG, createErrorBag } from "@holo-js/validation/internal/error-bag";
|
|
12
|
+
import { documentValidationFlash, useRequestValidationFlash } from "@holo-js/adapter-next/internal/request-validation-flash";
|
|
13
|
+
var SEEN = "~";
|
|
14
|
+
var shown = "";
|
|
15
|
+
var shownPath;
|
|
16
|
+
var shownLocation;
|
|
17
|
+
var mountedCalls = 0;
|
|
18
|
+
var navigationEvents = false;
|
|
19
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
20
|
+
function browserDocument() {
|
|
21
|
+
return globalThis.document;
|
|
22
|
+
}
|
|
23
|
+
function locationPath() {
|
|
24
|
+
return globalThis.location?.pathname;
|
|
25
|
+
}
|
|
26
|
+
function rawFlashCookie() {
|
|
27
|
+
const prefix = `${VALIDATION_FLASH_COOKIE}=`;
|
|
28
|
+
return browserDocument()?.cookie.split(";").map((part) => part.trim()).find((part) => part.startsWith(prefix))?.slice(prefix.length) ?? "";
|
|
29
|
+
}
|
|
30
|
+
function readFlashCookie() {
|
|
31
|
+
const raw = rawFlashCookie();
|
|
32
|
+
const seen = raw.startsWith(SEEN);
|
|
33
|
+
try {
|
|
34
|
+
return { flash: decodeURIComponent(seen ? raw.slice(SEEN.length) : raw), seen };
|
|
35
|
+
} catch {
|
|
36
|
+
return { flash: "", seen };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function markFlashCookieSeen() {
|
|
40
|
+
const document = browserDocument();
|
|
41
|
+
const raw = rawFlashCookie();
|
|
42
|
+
if (!document || !raw || raw.startsWith(SEEN)) return;
|
|
43
|
+
const secure = globalThis.location?.protocol === "https:" ? "; Secure" : "";
|
|
44
|
+
document.cookie = `${VALIDATION_FLASH_COOKIE}=${SEEN}${raw}; Path=/; SameSite=Lax${secure}`;
|
|
45
|
+
}
|
|
46
|
+
function clearFlashCookie() {
|
|
47
|
+
const document = browserDocument();
|
|
48
|
+
if (document) document.cookie = `${VALIDATION_FLASH_COOKIE}=; Max-Age=0; Path=/; SameSite=Lax`;
|
|
49
|
+
}
|
|
50
|
+
function forget() {
|
|
51
|
+
shownPath = void 0;
|
|
52
|
+
shownLocation = void 0;
|
|
53
|
+
clearFlashCookie();
|
|
54
|
+
show("");
|
|
55
|
+
}
|
|
56
|
+
function subscribe(listener) {
|
|
57
|
+
listeners.add(listener);
|
|
58
|
+
return () => listeners.delete(listener);
|
|
59
|
+
}
|
|
60
|
+
function show(flash) {
|
|
61
|
+
if (shown === flash) return;
|
|
62
|
+
shown = flash;
|
|
63
|
+
for (const listener of listeners) listener();
|
|
64
|
+
}
|
|
65
|
+
function startDocument() {
|
|
66
|
+
if (!browserDocument()) return;
|
|
67
|
+
shown = documentValidationFlash();
|
|
68
|
+
shownPath = void 0;
|
|
69
|
+
shownLocation = void 0;
|
|
70
|
+
const cookie = readFlashCookie();
|
|
71
|
+
if (cookie.seen) clearFlashCookie();
|
|
72
|
+
else if (shown && cookie.flash === shown) markFlashCookieSeen();
|
|
73
|
+
const navigation = globalThis.navigation;
|
|
74
|
+
navigationEvents = Boolean(navigation);
|
|
75
|
+
navigation?.addEventListener("currententrychange", () => {
|
|
76
|
+
const url = navigation.currentEntry?.url;
|
|
77
|
+
if (shownLocation !== void 0 && url && new URL(url).pathname !== shownLocation) forget();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
startDocument();
|
|
81
|
+
function readableValidationFlash(value) {
|
|
82
|
+
const flash = parseValidationFlash(value);
|
|
83
|
+
if (!flash) return void 0;
|
|
84
|
+
try {
|
|
85
|
+
createErrorBag(flash.errors);
|
|
86
|
+
return flash;
|
|
87
|
+
} catch {
|
|
88
|
+
return void 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function useValidationErrors(bag = DEFAULT_VALIDATION_BAG) {
|
|
92
|
+
const pathname = usePathname();
|
|
93
|
+
useContext(LayoutRouterContext);
|
|
94
|
+
const requestFlash = useRequestValidationFlash();
|
|
95
|
+
const value = useSyncExternalStore(subscribe, () => shown, () => requestFlash);
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
mountedCalls++;
|
|
98
|
+
return () => {
|
|
99
|
+
mountedCalls--;
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
if (mountedCalls === 0 && shownPath !== void 0 && !navigationEvents) forget();
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
}, []);
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (shownPath !== void 0 && shownPath !== pathname) clearFlashCookie();
|
|
107
|
+
shownPath = pathname;
|
|
108
|
+
shownLocation = locationPath();
|
|
109
|
+
const cookie = readFlashCookie();
|
|
110
|
+
if (cookie.flash && !cookie.seen) markFlashCookieSeen();
|
|
111
|
+
show(cookie.flash);
|
|
112
|
+
});
|
|
113
|
+
const flash = useMemo(() => readableValidationFlash(value), [value]);
|
|
114
|
+
return createErrorBag(flash?.bag === bag && flash.page === validationFlashPage(pathname) ? flash.errors : {});
|
|
115
|
+
}
|
|
116
|
+
var adapterNextValidationErrorsInternals = {
|
|
117
|
+
startDocument
|
|
118
|
+
};
|
|
119
|
+
export {
|
|
120
|
+
adapterNextValidationErrorsInternals,
|
|
121
|
+
useValidationErrors
|
|
122
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NextModuleInputSourceMap } from '@holo-js/adapter-shared/build';
|
|
2
|
+
|
|
3
|
+
type ModuleTransformLoaderContext = {
|
|
4
|
+
cacheable?: () => void;
|
|
5
|
+
readonly resourcePath: string;
|
|
6
|
+
callback?(error: null, code: string, map?: NextModuleInputSourceMap): void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type { ModuleTransformLoaderContext as M };
|
package/dist/route-loader.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { NextModuleInputSourceMap } from '@holo-js/adapter-shared/build';
|
|
2
|
+
import { M as ModuleTransformLoaderContext } from './module-transform-loader-B5slbWAk.js';
|
|
3
|
+
|
|
4
|
+
declare function routeLoader(this: ModuleTransformLoaderContext, source: string, inputMap?: NextModuleInputSourceMap | null): string | undefined;
|
|
5
5
|
|
|
6
6
|
export { routeLoader as default };
|
package/dist/route-loader.mjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runModuleTransform
|
|
3
|
+
} from "./chunk-RFEFJPTI.mjs";
|
|
4
|
+
|
|
1
5
|
// src/route-loader.ts
|
|
2
|
-
import {
|
|
3
|
-
function routeLoader(source) {
|
|
4
|
-
this
|
|
5
|
-
return compileNextRoute(source, this.resourcePath);
|
|
6
|
+
import { transformNextRoute } from "@holo-js/adapter-shared/build";
|
|
7
|
+
function routeLoader(source, inputMap) {
|
|
8
|
+
return runModuleTransform(this, transformNextRoute, source, inputMap);
|
|
6
9
|
}
|
|
7
10
|
export {
|
|
8
11
|
routeLoader as default
|
package/dist/runtime.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _holo_js_core_runtime from '@holo-js/core/runtime';
|
|
|
3
3
|
import { CreateHoloOptions } from '@holo-js/core/runtime';
|
|
4
4
|
import * as _holo_js_config from '@holo-js/config';
|
|
5
5
|
import { HoloConfigMap, DotPath, HoloConfigValues, ValueAtPath } from '@holo-js/config';
|
|
6
|
-
import {
|
|
6
|
+
import { SerializedValidationException } from '@holo-js/validation';
|
|
7
7
|
import { serializeRateLimitError } from '@holo-js/adapter-shared/server-errors';
|
|
8
8
|
import { NextRequestLike } from '@holo-js/adapter-shared/next/request-context';
|
|
9
9
|
export { NextRequestLike } from '@holo-js/adapter-shared/next/request-context';
|
|
@@ -161,6 +161,7 @@ declare function createNextHoloHelpers<TCustom extends HoloConfigMap = HoloConfi
|
|
|
161
161
|
useConfig: <TPath extends DotPath<HoloConfigValues<TCustom>>>(path: TPath) => Promise<ValueAtPath<HoloConfigValues<TCustom>, TPath>>;
|
|
162
162
|
config: <TPath extends DotPath<HoloConfigValues<TCustom>>>(path: TPath) => Promise<ValueAtPath<HoloConfigValues<TCustom>, TPath>>;
|
|
163
163
|
};
|
|
164
|
+
declare const serializeValidationException: (value: unknown) => SerializedValidationException | undefined;
|
|
164
165
|
type ExpectedFailure = NonNullable<ReturnType<typeof serializeValidationException> | ReturnType<typeof serializeRateLimitError>>;
|
|
165
166
|
declare function routeHandler<TArgs extends readonly unknown[]>(handler: (...args: TArgs) => Response | Promise<Response>): (...args: TArgs) => Promise<Response>;
|
|
166
167
|
declare function serverAction<TArgs extends readonly unknown[], TResult>(action: (...args: TArgs) => Promise<TResult>): (...args: TArgs) => Promise<TResult | ExpectedFailure>;
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
rememberRenderedValidationFlash
|
|
3
|
+
} from "./chunk-ZPWXXNMV.mjs";
|
|
4
|
+
import {
|
|
5
|
+
VALIDATION_FLASH_COOKIE,
|
|
6
|
+
serializeValidationFlash,
|
|
7
|
+
validationFlashPage
|
|
8
|
+
} from "./chunk-755YLPDP.mjs";
|
|
9
|
+
|
|
1
10
|
// src/runtime.ts
|
|
2
11
|
import { AsyncLocalStorage } from "async_hooks";
|
|
3
|
-
import { createRequire } from "module";
|
|
4
|
-
import { resolve } from "path";
|
|
12
|
+
import { createRequire as createRequire2 } from "module";
|
|
13
|
+
import { resolve as resolve2 } from "path";
|
|
5
14
|
import { initializeHolo } from "@holo-js/core/runtime";
|
|
6
|
-
import { createCookieWriteUnavailableError } from "@holo-js/kernel";
|
|
15
|
+
import { createCookieWriteUnavailableError, resolveRequestUrl } from "@holo-js/kernel";
|
|
7
16
|
import { captureErrorReporter } from "@holo-js/kernel/error-reporting";
|
|
8
|
-
import {
|
|
17
|
+
import { validationInternals } from "@holo-js/validation";
|
|
9
18
|
import { serializeRateLimitError } from "@holo-js/adapter-shared/server-errors";
|
|
10
19
|
|
|
11
20
|
// src/request-context.ts
|
|
@@ -21,6 +30,24 @@ function setNextAuthRequestRunner(runner) {
|
|
|
21
30
|
globalThis.__holoNextAuthRequestRunner = runner;
|
|
22
31
|
}
|
|
23
32
|
|
|
33
|
+
// src/next-async-storage.ts
|
|
34
|
+
import { createRequire } from "module";
|
|
35
|
+
import { resolve } from "path";
|
|
36
|
+
function requireNextFromProject() {
|
|
37
|
+
return createRequire(resolve(process.cwd(), "package.json"));
|
|
38
|
+
}
|
|
39
|
+
function loadNextAsyncStorage(requireNext, name) {
|
|
40
|
+
try {
|
|
41
|
+
const storage = requireNext(`next/dist/server/app-render/${name}-async-storage.external.js`);
|
|
42
|
+
return storage[name === "action" ? "actionAsyncStorage" : "workUnitAsyncStorage"];
|
|
43
|
+
} catch {
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function currentWorkUnitStore() {
|
|
48
|
+
return loadNextAsyncStorage(requireNextFromProject(), "work-unit")?.getStore();
|
|
49
|
+
}
|
|
50
|
+
|
|
24
51
|
// src/shutdown.ts
|
|
25
52
|
import { constants } from "os";
|
|
26
53
|
var SHUTDOWN_DEADLINE_MS = 3e4;
|
|
@@ -186,14 +213,6 @@ function parseRequestCookies(header) {
|
|
|
186
213
|
function isMissingNextRequestScope(error) {
|
|
187
214
|
return error instanceof Error && error.message.includes("outside a request scope");
|
|
188
215
|
}
|
|
189
|
-
function loadNextAsyncStorage(requireNext, name) {
|
|
190
|
-
try {
|
|
191
|
-
const storage = requireNext(`next/dist/server/app-render/${name}-async-storage.external.js`);
|
|
192
|
-
return storage[name === "action" ? "actionAsyncStorage" : "workUnitAsyncStorage"];
|
|
193
|
-
} catch {
|
|
194
|
-
return void 0;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
216
|
function nextCookiesMutableInCurrentPhase(requireNext) {
|
|
198
217
|
const workUnitAsyncStorage = loadNextAsyncStorage(requireNext, "work-unit");
|
|
199
218
|
return !workUnitAsyncStorage || workUnitAsyncStorage.getStore()?.phase === "action";
|
|
@@ -220,7 +239,7 @@ function createNextRequestContext(request) {
|
|
|
220
239
|
};
|
|
221
240
|
}
|
|
222
241
|
function resolveNextAuthRequestAccessors(projectRoot = process.cwd()) {
|
|
223
|
-
const requireNext =
|
|
242
|
+
const requireNext = createRequire2(resolve2(projectRoot, "package.json"));
|
|
224
243
|
return {
|
|
225
244
|
async getCookie(name) {
|
|
226
245
|
const request = getCurrentNextRequest();
|
|
@@ -346,6 +365,7 @@ function createNextHoloHelpers(options) {
|
|
|
346
365
|
config: useConfig
|
|
347
366
|
};
|
|
348
367
|
}
|
|
368
|
+
var { serializeValidationException } = validationInternals;
|
|
349
369
|
function serializeExpectedFailure(error) {
|
|
350
370
|
const payload = serializeValidationException(error) ?? serializeRateLimitError(error);
|
|
351
371
|
if (!payload) throw error;
|
|
@@ -365,20 +385,57 @@ function routeHandler(handler) {
|
|
|
365
385
|
};
|
|
366
386
|
}
|
|
367
387
|
var runningServerAction = new AsyncLocalStorage();
|
|
368
|
-
function
|
|
369
|
-
const
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
if (!actionStore?.isAction || actionStore.isAppRoute || store?.type !== "request" || store.phase !== "action") return false;
|
|
388
|
+
function invokedServerActionRequest(action) {
|
|
389
|
+
const actionStore = loadNextAsyncStorage(requireNextFromProject(), "action")?.getStore();
|
|
390
|
+
const store = currentWorkUnitStore();
|
|
391
|
+
if (!actionStore?.isAction || actionStore.isAppRoute || store?.type !== "request" || store.phase !== "action") return void 0;
|
|
373
392
|
const invoked = store.headers?.get("next-action");
|
|
374
|
-
return
|
|
393
|
+
return !invoked || invoked === Reflect.get(action, "$$id") ? store : void 0;
|
|
394
|
+
}
|
|
395
|
+
function isSubmittedWithJavaScript(store) {
|
|
396
|
+
return Boolean(store.headers?.get("next-action"));
|
|
397
|
+
}
|
|
398
|
+
async function actionCookies() {
|
|
399
|
+
const { cookies } = requireNextFromProject()("next/headers.js");
|
|
400
|
+
return await cookies();
|
|
401
|
+
}
|
|
402
|
+
function isSecureRequest(store) {
|
|
403
|
+
const protocol = store.headers?.get("x-forwarded-proto") === "https" ? "https" : "http";
|
|
404
|
+
try {
|
|
405
|
+
return resolveRequestUrl({ url: `${protocol}://localhost/`, headers: store.headers }).protocol === "https:";
|
|
406
|
+
} catch {
|
|
407
|
+
return protocol === "https";
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
async function flashValidationErrors(store, failure) {
|
|
411
|
+
const flash = serializeValidationFlash({ bag: failure.bag, page: validationFlashPage(store.url?.pathname ?? "/"), errors: failure.errors });
|
|
412
|
+
if (!flash) return;
|
|
413
|
+
rememberRenderedValidationFlash(store, flash);
|
|
414
|
+
const cookies = await actionCookies();
|
|
415
|
+
cookies.set(VALIDATION_FLASH_COOKIE, flash, {
|
|
416
|
+
path: "/",
|
|
417
|
+
sameSite: "lax",
|
|
418
|
+
secure: isSecureRequest(store)
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
async function forgetValidationErrors() {
|
|
422
|
+
const cookies = await actionCookies();
|
|
423
|
+
if (cookies.get(VALIDATION_FLASH_COOKIE)) cookies.delete(VALIDATION_FLASH_COOKIE);
|
|
375
424
|
}
|
|
376
425
|
function serverAction(action) {
|
|
377
426
|
const invoke = async (...args) => {
|
|
378
|
-
|
|
427
|
+
const request = runningServerAction.getStore() ? void 0 : invokedServerActionRequest(invoke);
|
|
428
|
+
if (!request) return await action(...args);
|
|
429
|
+
await forgetValidationErrors();
|
|
379
430
|
try {
|
|
380
431
|
return await runningServerAction.run(true, () => action(...args));
|
|
381
432
|
} catch (error) {
|
|
433
|
+
const failure = serializeValidationException(error);
|
|
434
|
+
if (failure) {
|
|
435
|
+
await flashValidationErrors(request, failure);
|
|
436
|
+
return failure;
|
|
437
|
+
}
|
|
438
|
+
if (!isSubmittedWithJavaScript(request)) throw error;
|
|
382
439
|
return serializeExpectedFailure(error);
|
|
383
440
|
}
|
|
384
441
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { NextModuleInputSourceMap } from '@holo-js/adapter-shared/build';
|
|
2
|
+
import { M as ModuleTransformLoaderContext } from './module-transform-loader-B5slbWAk.js';
|
|
3
|
+
|
|
4
|
+
declare function serverActionLoader(this: ModuleTransformLoaderContext, source: string, inputMap?: NextModuleInputSourceMap | null): string | undefined;
|
|
5
5
|
|
|
6
6
|
export { serverActionLoader as default };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
runModuleTransform
|
|
3
|
+
} from "./chunk-RFEFJPTI.mjs";
|
|
4
|
+
|
|
1
5
|
// src/server-action-loader.ts
|
|
2
|
-
import {
|
|
3
|
-
function serverActionLoader(source) {
|
|
4
|
-
this
|
|
5
|
-
return compileNextServerActions(source, this.resourcePath);
|
|
6
|
+
import { transformNextServerActions } from "@holo-js/adapter-shared/build";
|
|
7
|
+
function serverActionLoader(source, inputMap) {
|
|
8
|
+
return runModuleTransform(this, transformNextServerActions, source, inputMap);
|
|
6
9
|
}
|
|
7
10
|
export {
|
|
8
11
|
serverActionLoader as default
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holo-js/adapter-next",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Holo-JS Framework - Next.js adapter",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"license": "MIT",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
@@ -25,6 +26,24 @@
|
|
|
25
26
|
"import": "./dist/client.mjs",
|
|
26
27
|
"default": "./dist/client.mjs"
|
|
27
28
|
},
|
|
29
|
+
"./internal/use-form": {
|
|
30
|
+
"types": "./dist/internal/use-form.d.ts",
|
|
31
|
+
"import": "./dist/internal/use-form.mjs",
|
|
32
|
+
"default": "./dist/internal/use-form.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./internal/request-validation-flash": {
|
|
35
|
+
"types": "./dist/internal/request-validation-flash.d.ts",
|
|
36
|
+
"edge-light": "./dist/internal/request-validation-flash.mjs",
|
|
37
|
+
"worker": "./dist/internal/request-validation-flash.mjs",
|
|
38
|
+
"browser": "./dist/internal/request-validation-flash.browser.mjs",
|
|
39
|
+
"import": "./dist/internal/request-validation-flash.mjs",
|
|
40
|
+
"default": "./dist/internal/request-validation-flash.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./internal/use-validation-errors": {
|
|
43
|
+
"types": "./dist/internal/use-validation-errors.d.ts",
|
|
44
|
+
"import": "./dist/internal/use-validation-errors.mjs",
|
|
45
|
+
"default": "./dist/internal/use-validation-errors.mjs"
|
|
46
|
+
},
|
|
28
47
|
"./realtime": {
|
|
29
48
|
"types": "./dist/realtime.d.ts",
|
|
30
49
|
"import": "./dist/realtime.mjs",
|
|
@@ -49,11 +68,11 @@
|
|
|
49
68
|
"test": "vitest --run"
|
|
50
69
|
},
|
|
51
70
|
"dependencies": {
|
|
52
|
-
"@holo-js/adapter-shared": "^0.5.
|
|
53
|
-
"@holo-js/config": "^0.5.
|
|
54
|
-
"@holo-js/core": "^0.5.
|
|
55
|
-
"@holo-js/kernel": "^0.5.
|
|
56
|
-
"@holo-js/validation": "^0.5.
|
|
71
|
+
"@holo-js/adapter-shared": "^0.5.2",
|
|
72
|
+
"@holo-js/config": "^0.5.2",
|
|
73
|
+
"@holo-js/core": "^0.5.2",
|
|
74
|
+
"@holo-js/kernel": "^0.5.2",
|
|
75
|
+
"@holo-js/validation": "^0.5.2"
|
|
57
76
|
},
|
|
58
77
|
"peerDependencies": {
|
|
59
78
|
"@holo-js/forms": ">=0.4.0",
|
|
@@ -70,7 +89,8 @@
|
|
|
70
89
|
}
|
|
71
90
|
},
|
|
72
91
|
"devDependencies": {
|
|
73
|
-
"@holo-js/realtime": "^0.5.
|
|
92
|
+
"@holo-js/realtime": "^0.5.2",
|
|
93
|
+
"@jridgewell/trace-mapping": "^0.3.31",
|
|
74
94
|
"@types/node": "^22.20.5",
|
|
75
95
|
"next": "^16.4.3",
|
|
76
96
|
"tsup": "^9.0.0",
|