@holo-js/adapter-sveltekit 0.1.4 → 0.1.5

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.
@@ -0,0 +1,49 @@
1
+ // src/transport.ts
2
+ function isHoloModelEntityLike(value) {
3
+ return Boolean(
4
+ value && typeof value === "object" && typeof value.getRepository === "function" && typeof value.toAttributes === "function" && typeof value.toJSON === "function"
5
+ );
6
+ }
7
+ function isHoloModelCollectionLike(value) {
8
+ const candidate = value;
9
+ return Boolean(
10
+ Array.isArray(value) && typeof candidate.modelKeys === "function" && typeof candidate.toQuery === "function" && typeof candidate.toJSON === "function"
11
+ );
12
+ }
13
+ function serializeSvelteKitData(value) {
14
+ if (isHoloModelEntityLike(value) || isHoloModelCollectionLike(value)) {
15
+ return value.toJSON();
16
+ }
17
+ if (Array.isArray(value)) {
18
+ return value.map((item) => serializeSvelteKitData(item));
19
+ }
20
+ if (value instanceof Date || value === null || typeof value !== "object") {
21
+ return value;
22
+ }
23
+ return Object.fromEntries(
24
+ Object.entries(value).map(([key, entry]) => [key, serializeSvelteKitData(entry)])
25
+ );
26
+ }
27
+ var holoSvelteKitTransport = {
28
+ HoloModel: {
29
+ encode(value) {
30
+ return isHoloModelEntityLike(value) ? value.toJSON() : false;
31
+ },
32
+ decode(value) {
33
+ return value;
34
+ }
35
+ },
36
+ HoloCollection: {
37
+ encode(value) {
38
+ return isHoloModelCollectionLike(value) ? value.toJSON() : false;
39
+ },
40
+ decode(value) {
41
+ return value;
42
+ }
43
+ }
44
+ };
45
+
46
+ export {
47
+ serializeSvelteKitData,
48
+ holoSvelteKitTransport
49
+ };
package/dist/client.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { InferSchemaData } from '@holo-js/forms';
2
- import { useForm as useForm$1, UseFormOptions, UseFormResult } from '@holo-js/forms/client';
3
- export { ClientSubmitContext, ClientSubmitResult, FormFieldState, FormFieldTree, UseFormOptions, UseFormResult, ValidateOnMode } from '@holo-js/forms/client';
1
+ import { FormSchema, InferFormData, ValidationErrorBag } from '@holo-js/forms';
2
+ import { UseFormOptions, UseFormResult, InferFormFieldTree } from '@holo-js/forms/internal/client';
3
+ export { ClientSubmitContext, ClientSubmitResult, FormFieldState, FormFieldTree, UseFormOptions, UseFormResult, ValidateOnMode } from '@holo-js/forms/internal/client';
4
4
 
5
- declare function useForm<TSchema extends Parameters<typeof useForm$1>[0]>(schemaDefinition: TSchema, options?: UseFormOptions<InferSchemaData<TSchema['fields']>>): UseFormResult<InferSchemaData<TSchema['fields']>>;
5
+ declare function useForm<TSchema extends FormSchema, TSuccess = unknown>(schemaDefinition: TSchema, options?: UseFormOptions<InferFormData<TSchema>, TSuccess>): UseFormResult<InferFormData<TSchema>, TSuccess, InferFormFieldTree<TSchema>>;
6
+ declare function useValidationErrors<TData = Record<string, unknown>>(bag?: string): ValidationErrorBag<TData>;
6
7
 
7
- export { useForm };
8
+ export { useForm, useValidationErrors };
package/dist/client.mjs CHANGED
@@ -1,11 +1,380 @@
1
1
  // src/client.ts
2
2
  import { createSubscriber } from "svelte/reactivity";
3
3
  import {
4
- useForm as createForm
5
- } from "@holo-js/forms/client";
4
+ DEFAULT_VALIDATION_BAG,
5
+ createErrorBag
6
+ } from "@holo-js/forms";
7
+ import {
8
+ createFormClient,
9
+ runWithBrowserFormElement
10
+ } from "@holo-js/forms/internal/client";
11
+ var registeredForms = /* @__PURE__ */ new Set();
12
+ var invalidActionFailureMessage = "Unable to read the form response. Please try again.";
13
+ var validationFlashCookie = "HOLO-SVELTEKIT-VALIDATION";
14
+ var submitListenerTarget;
6
15
  function isPlainObject(value) {
7
16
  return !!value && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof Blob);
8
17
  }
18
+ function isSchemaField(value) {
19
+ return isPlainObject(value) && value.kind === "field" && isPlainObject(value.definition);
20
+ }
21
+ function collectSchemaPaths(value, prefix = "") {
22
+ if (isSchemaField(value)) {
23
+ return [prefix].filter(Boolean);
24
+ }
25
+ if (!isPlainObject(value)) {
26
+ return [];
27
+ }
28
+ return Object.entries(value).flatMap(([key, nested]) => {
29
+ const next = prefix ? `${prefix}.${key}` : key;
30
+ return collectSchemaPaths(nested, next);
31
+ });
32
+ }
33
+ function collectValuePaths(value, prefix = "") {
34
+ if (!isPlainObject(value)) {
35
+ return [prefix].filter(Boolean);
36
+ }
37
+ return Object.entries(value).flatMap(([key, nested]) => {
38
+ const next = prefix ? `${prefix}.${key}` : key;
39
+ return collectValuePaths(nested, next);
40
+ });
41
+ }
42
+ function flattenRestorableValues(value, prefix = "") {
43
+ if (typeof value === "undefined" || value instanceof Blob) {
44
+ return [];
45
+ }
46
+ if (Array.isArray(value)) {
47
+ return value.flatMap((item) => flattenRestorableValues(item, prefix));
48
+ }
49
+ if (isPlainObject(value)) {
50
+ return Object.entries(value).flatMap(([key, nested]) => {
51
+ const next = prefix ? `${prefix}.${key}` : key;
52
+ return flattenRestorableValues(nested, next);
53
+ });
54
+ }
55
+ return prefix ? [[prefix, String(value)]] : [];
56
+ }
57
+ function restoreBrowserFormValues(values) {
58
+ const controls = globalThis.document?.querySelectorAll?.("input[name], textarea[name], select[name]");
59
+ if (!controls) {
60
+ return;
61
+ }
62
+ const valuesByName = /* @__PURE__ */ new Map();
63
+ for (const [name, value] of flattenRestorableValues(values)) {
64
+ valuesByName.set(name, [...valuesByName.get(name) ?? [], value]);
65
+ }
66
+ for (const control of Array.from(controls)) {
67
+ const name = control.name;
68
+ const nextValues = name ? valuesByName.get(name) : void 0;
69
+ if (!name || !nextValues) {
70
+ continue;
71
+ }
72
+ const type = control.type?.toLowerCase();
73
+ if (type === "file") {
74
+ continue;
75
+ }
76
+ if (type === "checkbox" || type === "radio") {
77
+ control.checked = nextValues.includes(control.value ?? "on");
78
+ continue;
79
+ }
80
+ control.value = nextValues[0] ?? "";
81
+ }
82
+ }
83
+ function scheduleBrowserFormValueRestore(values) {
84
+ restoreBrowserFormValues(values);
85
+ const browserWindow = globalThis.window;
86
+ const restore = () => restoreBrowserFormValues(values);
87
+ queueMicrotask(restore);
88
+ if (typeof browserWindow?.requestAnimationFrame === "function") {
89
+ browserWindow.requestAnimationFrame(restore);
90
+ return;
91
+ }
92
+ browserWindow?.setTimeout?.(restore, 0);
93
+ }
94
+ function isFormState(value) {
95
+ return isPlainObject(value) && typeof value.valid === "boolean" && isPlainObject(value.values) && isPlainObject(value.errors);
96
+ }
97
+ function stateMatchesSchema(schemaDefinition, state) {
98
+ const schemaPaths = collectSchemaPaths(schemaDefinition.fields);
99
+ const statePaths = [
100
+ ...Object.keys(state.errors),
101
+ ...collectValuePaths(state.values)
102
+ ];
103
+ return statePaths.every((path) => path === "_root" || schemaPaths.includes(path));
104
+ }
105
+ function parseJsonObject(value) {
106
+ try {
107
+ return JSON.parse(value);
108
+ } catch {
109
+ return void 0;
110
+ }
111
+ }
112
+ function createInvalidActionFailure(values, status) {
113
+ return {
114
+ ok: false,
115
+ status,
116
+ valid: false,
117
+ values,
118
+ errors: {
119
+ _root: [invalidActionFailureMessage]
120
+ }
121
+ };
122
+ }
123
+ function safeDecodeURIComponent(value) {
124
+ try {
125
+ return decodeURIComponent(value);
126
+ } catch {
127
+ return value;
128
+ }
129
+ }
130
+ function isFormFailurePayload(value) {
131
+ return isPlainObject(value) && value.ok === false && typeof value.status === "number" && value.valid === false && isPlainObject(value.values) && isPlainObject(value.errors);
132
+ }
133
+ function parseValidationFlashCookie(value) {
134
+ if (!value) {
135
+ return void 0;
136
+ }
137
+ const parsed = parseJsonObject(value) ?? parseJsonObject(safeDecodeURIComponent(value));
138
+ if (!isFormFailurePayload(parsed)) {
139
+ return void 0;
140
+ }
141
+ return parsed;
142
+ }
143
+ function readBrowserCookie(name) {
144
+ const cookie = globalThis.document?.cookie;
145
+ if (!cookie) {
146
+ return void 0;
147
+ }
148
+ for (const segment of cookie.split(";")) {
149
+ const trimmed = segment.trim();
150
+ const separator = trimmed.indexOf("=");
151
+ if (separator <= 0 || trimmed.slice(0, separator) !== name) {
152
+ continue;
153
+ }
154
+ return trimmed.slice(separator + 1);
155
+ }
156
+ return void 0;
157
+ }
158
+ function clearBrowserCookie(name) {
159
+ const document = globalThis.document;
160
+ if (!document) {
161
+ return;
162
+ }
163
+ document.cookie = `${name}=; Max-Age=0; Path=${getBrowserCookiePath()}; SameSite=Lax`;
164
+ }
165
+ function getSvelteKitRequestEvent() {
166
+ const store = globalThis.__holoSvelteKitRequestEventStore;
167
+ return store?.getStore();
168
+ }
169
+ function takeFlashedValidationState(schemaDefinition) {
170
+ if (typeof globalThis.window !== "undefined") {
171
+ return void 0;
172
+ }
173
+ const event = getSvelteKitRequestEvent();
174
+ const payload = parseValidationFlashCookie(event?.cookies.get(validationFlashCookie));
175
+ if (!event || !payload || !stateMatchesSchema(schemaDefinition, payload)) {
176
+ return void 0;
177
+ }
178
+ event.cookies.set(validationFlashCookie, "", {
179
+ path: event.url?.pathname || "/",
180
+ maxAge: 0,
181
+ sameSite: "lax",
182
+ httpOnly: true
183
+ });
184
+ return payload;
185
+ }
186
+ function takeValidationErrors(bag) {
187
+ const event = getSvelteKitRequestEvent();
188
+ const payload = event ? parseValidationFlashCookie(event.cookies.get(validationFlashCookie)) : parseValidationFlashCookie(readBrowserCookie(validationFlashCookie));
189
+ if (!payload || (payload.bag ?? DEFAULT_VALIDATION_BAG) !== bag) {
190
+ return void 0;
191
+ }
192
+ if (event) {
193
+ return payload;
194
+ }
195
+ scheduleBrowserFormValueRestore(payload.values);
196
+ clearBrowserCookie(validationFlashCookie);
197
+ return payload;
198
+ }
199
+ function isSvelteKitActionResult(value) {
200
+ return isPlainObject(value) && typeof value.type === "string" && (value.type === "failure" || value.type === "error" || value.type === "redirect" || value.type === "success");
201
+ }
202
+ function isJsonResponse(response) {
203
+ const contentType = response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase();
204
+ return contentType === "application/json" || contentType?.endsWith("+json") === true;
205
+ }
206
+ function normalizeFormDataName(name) {
207
+ return name.endsWith("[]") ? name.slice(0, -2) : name;
208
+ }
209
+ function countMatchingFormFields(form, paths) {
210
+ let formData;
211
+ try {
212
+ formData = Reflect.construct(FormData, [form]);
213
+ } catch {
214
+ return 0;
215
+ }
216
+ const names = new Set(Array.from(formData.entries(), ([name]) => normalizeFormDataName(name)));
217
+ return paths.filter((path) => names.has(path)).length;
218
+ }
219
+ function resolveSubmittedForm(target) {
220
+ if (target && typeof target === "object" && "tagName" in target && target.tagName === "FORM") {
221
+ return target;
222
+ }
223
+ return void 0;
224
+ }
225
+ function isNativePostForm(form) {
226
+ return (form.method || "get").toLowerCase() === "post";
227
+ }
228
+ function resolveRegisteredForm(form) {
229
+ if (!isNativePostForm(form)) {
230
+ return void 0;
231
+ }
232
+ let match;
233
+ let matchedFields = 0;
234
+ for (const candidate of registeredForms) {
235
+ const count = countMatchingFormFields(form, candidate.paths);
236
+ if (count > 0 && count >= matchedFields) {
237
+ match = candidate;
238
+ matchedFields = count;
239
+ }
240
+ }
241
+ return match;
242
+ }
243
+ function ensureSubmitListener() {
244
+ const document = globalThis.document;
245
+ const browserWindow = globalThis.window;
246
+ const target = typeof browserWindow?.addEventListener === "function" ? browserWindow : document && "addEventListener" in document && typeof document.addEventListener === "function" ? document : void 0;
247
+ if (!target) {
248
+ return;
249
+ }
250
+ if (submitListenerTarget === target) {
251
+ return;
252
+ }
253
+ submitListenerTarget = target;
254
+ target.addEventListener("submit", (event) => {
255
+ const form = resolveSubmittedForm(event.target);
256
+ const registeredForm = form ? resolveRegisteredForm(form) : void 0;
257
+ if (!form || !registeredForm) {
258
+ return;
259
+ }
260
+ event.preventDefault();
261
+ event.stopImmediatePropagation();
262
+ void registeredForm.submit(form);
263
+ }, true);
264
+ }
265
+ function registerForm(schemaDefinition, form) {
266
+ if (typeof globalThis.window === "undefined") {
267
+ return () => {
268
+ };
269
+ }
270
+ const registeredForm = {
271
+ paths: collectSchemaPaths(schemaDefinition.fields),
272
+ async submit(liveForm) {
273
+ await runWithBrowserFormElement(form, liveForm);
274
+ }
275
+ };
276
+ registeredForms.add(registeredForm);
277
+ ensureSubmitListener();
278
+ let registered = true;
279
+ return () => {
280
+ if (!registered) {
281
+ return;
282
+ }
283
+ registered = false;
284
+ registeredForms.delete(registeredForm);
285
+ };
286
+ }
287
+ function currentLocationHref() {
288
+ const location = globalThis.window?.location;
289
+ return location?.href;
290
+ }
291
+ function redirectBrowser(location) {
292
+ const browserLocation = globalThis.window?.location;
293
+ if (typeof browserLocation?.assign === "function") {
294
+ browserLocation.assign(location);
295
+ return;
296
+ }
297
+ if (browserLocation && "href" in browserLocation) {
298
+ browserLocation.href = location;
299
+ }
300
+ }
301
+ function getBrowserCookiePath() {
302
+ const pathname = globalThis.window?.location?.pathname;
303
+ return (pathname || "/").replace(/[;\r\n]/g, "") || "/";
304
+ }
305
+ async function submitSvelteKitAction(context) {
306
+ const action = context.action ?? currentLocationHref();
307
+ if (typeof fetch !== "function" || !action) {
308
+ return {
309
+ ok: true,
310
+ status: 200,
311
+ data: context.values
312
+ };
313
+ }
314
+ const method = context.method.toUpperCase();
315
+ const init = method === "GET" || method === "HEAD" ? {
316
+ method,
317
+ credentials: "same-origin",
318
+ headers: {
319
+ accept: "application/json"
320
+ }
321
+ } : {
322
+ method,
323
+ credentials: "same-origin",
324
+ body: context.formData,
325
+ headers: {
326
+ accept: "application/json",
327
+ "x-sveltekit-action": "true"
328
+ }
329
+ };
330
+ const response = await fetch(action, init);
331
+ if (!isJsonResponse(response)) {
332
+ return {
333
+ ok: response.ok,
334
+ status: response.status,
335
+ data: void 0
336
+ };
337
+ }
338
+ const result = await response.json();
339
+ if (!isSvelteKitActionResult(result)) {
340
+ return result;
341
+ }
342
+ if (result.type === "failure") {
343
+ const parsed = parseJsonObject(result.data);
344
+ return isPlainObject(parsed) ? parsed : createInvalidActionFailure(context.values, result.status);
345
+ }
346
+ if (result.type === "error") {
347
+ return result.error;
348
+ }
349
+ if (result.type === "redirect") {
350
+ redirectBrowser(result.location);
351
+ return {
352
+ ok: true,
353
+ status: result.status,
354
+ data: void 0
355
+ };
356
+ }
357
+ return {
358
+ ok: true,
359
+ status: result.status,
360
+ data: result.data
361
+ };
362
+ }
363
+ async function hydrateActionFormState(form, schemaDefinition) {
364
+ if (typeof globalThis.window === "undefined") {
365
+ return;
366
+ }
367
+ const stores = await import("$app/stores");
368
+ let unsubscribe = () => {
369
+ };
370
+ unsubscribe = stores.page.subscribe((value) => {
371
+ const state = value.form;
372
+ if (isFormState(state) && stateMatchesSchema(schemaDefinition, state)) {
373
+ form.applyServerState(state);
374
+ }
375
+ queueMicrotask(unsubscribe);
376
+ });
377
+ }
9
378
  function createReactiveView(target, subscribe, cache) {
10
379
  const cached = cache.get(target);
11
380
  if (cached) {
@@ -50,11 +419,30 @@ function createReactiveView(target, subscribe, cache) {
50
419
  return proxy;
51
420
  }
52
421
  function useForm(schemaDefinition, options = {}) {
53
- const form = createForm(schemaDefinition, options);
54
- const subscribe = createSubscriber((update) => form.subscribe(update));
422
+ const formOptions = {
423
+ ...options,
424
+ action: options.action ?? currentLocationHref(),
425
+ initialState: options.initialState ?? takeFlashedValidationState(schemaDefinition),
426
+ submitter: options.submitter ?? submitSvelteKitAction
427
+ };
428
+ const form = createFormClient(schemaDefinition, formOptions);
429
+ void hydrateActionFormState(form, schemaDefinition);
430
+ const unregisterForm = registerForm(schemaDefinition, form);
431
+ const subscribe = createSubscriber((update) => {
432
+ const unsubscribe = form.subscribe(update);
433
+ return () => {
434
+ unsubscribe();
435
+ unregisterForm();
436
+ };
437
+ });
55
438
  const cache = /* @__PURE__ */ new WeakMap();
56
439
  return createReactiveView(form, subscribe, cache);
57
440
  }
441
+ function useValidationErrors(bag = DEFAULT_VALIDATION_BAG) {
442
+ const payload = takeValidationErrors(bag);
443
+ return createErrorBag(payload?.errors ?? {});
444
+ }
58
445
  export {
59
- useForm
446
+ useForm,
447
+ useValidationErrors
60
448
  };
@@ -0,0 +1,5 @@
1
+ import { Config } from '@sveltejs/kit';
2
+
3
+ declare function withHoloSvelteKit<TConfig extends Config = Config>(config?: TConfig): TConfig;
4
+
5
+ export { withHoloSvelteKit };
@@ -0,0 +1,253 @@
1
+ // src/preprocess.ts
2
+ var clientImportPattern = /import\s*\{([^}]*)\}\s*from\s*['"]@holo-js\/adapter-sveltekit\/client['"]/g;
3
+ var identifier = String.raw`[$A-Z_a-z][$\w]*`;
4
+ var HOLO_SVELTE_PREPROCESS_NAME = "holo-sveltekit";
5
+ function collectUseFormAliases(script) {
6
+ const aliases = /* @__PURE__ */ new Set();
7
+ for (const match of script.matchAll(clientImportPattern)) {
8
+ const imports = match[1] ?? "";
9
+ for (const rawSpecifier of imports.split(",")) {
10
+ const specifier = rawSpecifier.trim();
11
+ const aliased = specifier.match(new RegExp(String.raw`^useForm\s+as\s+(${identifier})$`));
12
+ if (specifier === "useForm") {
13
+ aliases.add("useForm");
14
+ } else if (aliased?.[1]) {
15
+ aliases.add(aliased[1]);
16
+ }
17
+ }
18
+ }
19
+ return [...aliases];
20
+ }
21
+ function collectScriptBlocks(content) {
22
+ const blocks = [];
23
+ const pattern = /<script\b[^>]*>/g;
24
+ for (const match of content.matchAll(pattern)) {
25
+ const contentStart = match.index + match[0].length;
26
+ const closeIndex = content.indexOf("</script>", contentStart);
27
+ if (closeIndex === -1) {
28
+ continue;
29
+ }
30
+ blocks.push({
31
+ contentStart,
32
+ contentEnd: closeIndex,
33
+ content: content.slice(contentStart, closeIndex)
34
+ });
35
+ }
36
+ return blocks;
37
+ }
38
+ function skipString(source, index, quote) {
39
+ let cursor = index + 1;
40
+ while (cursor < source.length) {
41
+ const char = source[cursor];
42
+ if (char === "\\") {
43
+ cursor += 2;
44
+ continue;
45
+ }
46
+ if (char === quote) {
47
+ return cursor + 1;
48
+ }
49
+ cursor += 1;
50
+ }
51
+ return cursor;
52
+ }
53
+ function skipLineComment(source, index) {
54
+ const end = source.indexOf("\n", index + 2);
55
+ return end === -1 ? source.length : end + 1;
56
+ }
57
+ function skipBlockComment(source, index) {
58
+ const end = source.indexOf("*/", index + 2);
59
+ return end === -1 ? source.length : end + 2;
60
+ }
61
+ function skipTypeArguments(source, index) {
62
+ if (source[index] !== "<") {
63
+ return index;
64
+ }
65
+ let depth = 0;
66
+ let cursor = index;
67
+ while (cursor < source.length) {
68
+ const char = source[cursor];
69
+ const next = source[cursor + 1];
70
+ if (char === '"' || char === "'" || char === "`") {
71
+ cursor = skipString(source, cursor, char);
72
+ continue;
73
+ }
74
+ if (char === "/" && next === "/") {
75
+ cursor = skipLineComment(source, cursor);
76
+ continue;
77
+ }
78
+ if (char === "/" && next === "*") {
79
+ cursor = skipBlockComment(source, cursor);
80
+ continue;
81
+ }
82
+ if (char === "<") {
83
+ depth += 1;
84
+ } else if (char === ">") {
85
+ depth -= 1;
86
+ if (depth === 0) {
87
+ return cursor + 1;
88
+ }
89
+ }
90
+ cursor += 1;
91
+ }
92
+ return index;
93
+ }
94
+ function findOpeningParen(source, index) {
95
+ let cursor = index;
96
+ while (/\s/.test(source[cursor] ?? "")) {
97
+ cursor += 1;
98
+ }
99
+ cursor = skipTypeArguments(source, cursor);
100
+ while (/\s/.test(source[cursor] ?? "")) {
101
+ cursor += 1;
102
+ }
103
+ return source[cursor] === "(" ? cursor : -1;
104
+ }
105
+ function findClosingParen(source, index) {
106
+ let depth = 0;
107
+ let cursor = index;
108
+ while (cursor < source.length) {
109
+ const char = source[cursor];
110
+ const next = source[cursor + 1];
111
+ if (char === '"' || char === "'" || char === "`") {
112
+ cursor = skipString(source, cursor, char);
113
+ continue;
114
+ }
115
+ if (char === "/" && next === "/") {
116
+ cursor = skipLineComment(source, cursor);
117
+ continue;
118
+ }
119
+ if (char === "/" && next === "*") {
120
+ cursor = skipBlockComment(source, cursor);
121
+ continue;
122
+ }
123
+ if (char === "(") {
124
+ depth += 1;
125
+ } else if (char === ")") {
126
+ depth -= 1;
127
+ if (depth === 0) {
128
+ return cursor;
129
+ }
130
+ }
131
+ cursor += 1;
132
+ }
133
+ return -1;
134
+ }
135
+ function applyReplacements(source, replacements) {
136
+ if (replacements.length === 0) {
137
+ return source;
138
+ }
139
+ let output = "";
140
+ let cursor = 0;
141
+ const orderedReplacements = [...replacements].sort((left, right) => left.start - right.start);
142
+ for (const replacement of orderedReplacements) {
143
+ output += source.slice(cursor, replacement.start);
144
+ output += replacement.text;
145
+ cursor = replacement.end;
146
+ }
147
+ return output + source.slice(cursor);
148
+ }
149
+ function transformScript(script) {
150
+ const aliases = collectUseFormAliases(script);
151
+ if (aliases.length === 0) {
152
+ return script;
153
+ }
154
+ const aliasPattern = aliases.map((alias) => alias.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
155
+ const declarationPattern = new RegExp(
156
+ String.raw`(^|\n)([ \t]*)const\s+(${identifier})\s*=\s*(${aliasPattern})\b`,
157
+ "g"
158
+ );
159
+ const replacements = [];
160
+ for (const match of script.matchAll(declarationPattern)) {
161
+ const indentation = match[2] ?? "";
162
+ const variable = match[3];
163
+ if (!variable || script.includes(`${variable}.subscribe(() => { ${variable} = ${variable} })`)) {
164
+ continue;
165
+ }
166
+ const constStart = match.index + (match[1]?.length ?? 0) + indentation.length;
167
+ const calleeEnd = match.index + match[0].length;
168
+ const openingParen = findOpeningParen(script, calleeEnd);
169
+ if (openingParen === -1) {
170
+ continue;
171
+ }
172
+ const closingParen = findClosingParen(script, openingParen);
173
+ if (closingParen === -1) {
174
+ continue;
175
+ }
176
+ replacements.push({
177
+ start: constStart,
178
+ end: constStart + "const".length,
179
+ text: "let"
180
+ }, {
181
+ start: closingParen + 1,
182
+ end: closingParen + 1,
183
+ text: `
184
+ ${indentation}${variable}.subscribe(() => { ${variable} = ${variable} })`
185
+ });
186
+ }
187
+ return applyReplacements(script, replacements);
188
+ }
189
+ function transformSvelteUseFormReactivity(content) {
190
+ const replacements = collectScriptBlocks(content).flatMap((block) => {
191
+ const transformed = transformScript(block.content);
192
+ return transformed === block.content ? [] : [{
193
+ start: block.contentStart,
194
+ end: block.contentEnd,
195
+ text: transformed
196
+ }];
197
+ });
198
+ return applyReplacements(content, replacements);
199
+ }
200
+ function holoSveltePreprocess() {
201
+ return {
202
+ name: HOLO_SVELTE_PREPROCESS_NAME,
203
+ markup({ content }) {
204
+ return {
205
+ code: transformSvelteUseFormReactivity(content)
206
+ };
207
+ }
208
+ };
209
+ }
210
+
211
+ // src/config.ts
212
+ var managedServerHooksPath = ".holo-js/generated/hooks.server";
213
+ var managedUniversalHooksPath = ".holo-js/generated/hooks";
214
+ function toPreprocessorArray(preprocess) {
215
+ if (!preprocess) {
216
+ return [];
217
+ }
218
+ return Array.isArray(preprocess) ? [...preprocess] : [preprocess];
219
+ }
220
+ function hasHoloPreprocess(preprocessors) {
221
+ return preprocessors.some((preprocessor) => preprocessor.name === HOLO_SVELTE_PREPROCESS_NAME);
222
+ }
223
+ function assertNoCustomManagedHooks(config) {
224
+ const hooks = config.kit?.files?.hooks;
225
+ const customServerHook = hooks?.server && hooks.server !== managedServerHooksPath;
226
+ const customUniversalHook = hooks?.universal && hooks.universal !== managedUniversalHooksPath;
227
+ if (customServerHook || customUniversalHook) {
228
+ throw new Error("[@holo-js/adapter-sveltekit] Custom SvelteKit server or universal hook entrypoints are not supported. Move user hook code to src/hooks.ts and src/hooks.server.ts so Holo can manage the hook bridge.");
229
+ }
230
+ }
231
+ function withHoloSvelteKit(config = {}) {
232
+ assertNoCustomManagedHooks(config);
233
+ const preprocessors = toPreprocessorArray(config.preprocess);
234
+ const mergedPreprocessors = hasHoloPreprocess(preprocessors) ? preprocessors : [...preprocessors, holoSveltePreprocess()];
235
+ return {
236
+ ...config,
237
+ preprocess: mergedPreprocessors,
238
+ kit: {
239
+ ...config.kit ?? {},
240
+ files: {
241
+ ...config.kit?.files ?? {},
242
+ hooks: {
243
+ ...config.kit?.files?.hooks ?? {},
244
+ server: managedServerHooksPath,
245
+ universal: managedUniversalHooksPath
246
+ }
247
+ }
248
+ }
249
+ };
250
+ }
251
+ export {
252
+ withHoloSvelteKit
253
+ };
package/dist/index.d.ts CHANGED
@@ -1,17 +1,50 @@
1
1
  import * as _holo_js_core from '@holo-js/core';
2
2
  import { HoloFrameworkOptions, HoloAdapterProject } from '@holo-js/core';
3
+ import { SerializedValidationException } from '@holo-js/forms/schema';
3
4
  import { HoloConfigMap } from '@holo-js/config';
5
+ export { SvelteKitTransportDefinition, holoSvelteKitTransport } from './transport.js';
4
6
 
5
7
  type SvelteKitHoloOptions = HoloFrameworkOptions;
6
8
  type SvelteKitHoloProject<TCustom extends HoloConfigMap = HoloConfigMap> = HoloAdapterProject<TCustom>;
9
+ type SvelteKitRequestEvent = {
10
+ readonly url?: URL;
11
+ readonly cookies: {
12
+ get(name: string): string | undefined;
13
+ set(name: string, value: string, options: SvelteKitCookieOptions): void;
14
+ };
15
+ readonly request: {
16
+ readonly method?: string;
17
+ readonly headers: Headers;
18
+ };
19
+ };
20
+ type SvelteKitCookieOptions = {
21
+ path: string;
22
+ domain?: string;
23
+ maxAge?: number;
24
+ expires?: Date;
25
+ secure?: boolean;
26
+ httpOnly?: boolean;
27
+ sameSite?: 'lax' | 'strict' | 'none';
28
+ partitioned?: boolean;
29
+ };
30
+ declare function isApiEvent(event: SvelteKitRequestEvent): boolean;
31
+ declare function serializeValidationException(error: unknown): SerializedValidationException | undefined;
32
+ declare function mapValidationActionResponse(event: SvelteKitRequestEvent, response: Response): Promise<Response>;
33
+ declare function rememberValidationActionFailure(event: SvelteKitRequestEvent, payload: SerializedValidationException): void;
7
34
  declare const svelteKitHoloCapabilities: Readonly<_holo_js_core.HoloAdapterCapabilities>;
35
+ declare function runWithSvelteKitRequestEvent<TValue>(event: SvelteKitRequestEvent, callback: () => TValue): TValue;
8
36
  declare function createSvelteKitHoloProject<TCustom extends HoloConfigMap = HoloConfigMap>(options?: SvelteKitHoloOptions): Promise<SvelteKitHoloProject<TCustom>>;
9
37
  declare function initializeSvelteKitHoloProject<TCustom extends HoloConfigMap = HoloConfigMap>(options?: SvelteKitHoloOptions): Promise<SvelteKitHoloProject<TCustom>>;
10
38
  declare function createSvelteKitHoloHelpers<TCustom extends HoloConfigMap = HoloConfigMap>(options?: SvelteKitHoloOptions): _holo_js_core.HoloAdapterProjectAccessors<TCustom>;
11
39
  declare function resetSvelteKitHoloProject(): Promise<void>;
12
40
  declare const adapterSvelteKitInternals: {
41
+ mapValidationActionResponse: typeof mapValidationActionResponse;
42
+ rememberValidationActionFailure: typeof rememberValidationActionFailure;
43
+ isApiEvent: typeof isApiEvent;
44
+ serializeValidationException: typeof serializeValidationException;
45
+ validationFlashCookie: string;
13
46
  getState: () => _holo_js_core.HoloFrameworkAdapterState<HoloAdapterProject<object>>;
14
47
  resolveOptions: (projectOptions?: HoloFrameworkOptions) => _holo_js_core.ResolvedHoloFrameworkOptions;
15
48
  };
16
49
 
17
- export { type SvelteKitHoloOptions, type SvelteKitHoloProject, adapterSvelteKitInternals, createSvelteKitHoloHelpers, createSvelteKitHoloProject, initializeSvelteKitHoloProject, resetSvelteKitHoloProject, svelteKitHoloCapabilities };
50
+ export { type SvelteKitHoloOptions, type SvelteKitHoloProject, adapterSvelteKitInternals, createSvelteKitHoloHelpers, createSvelteKitHoloProject, initializeSvelteKitHoloProject, resetSvelteKitHoloProject, runWithSvelteKitRequestEvent, svelteKitHoloCapabilities };
package/dist/index.mjs CHANGED
@@ -1,30 +1,355 @@
1
+ import {
2
+ holoSvelteKitTransport
3
+ } from "./chunk-FZXR22V2.mjs";
4
+
1
5
  // src/index.ts
6
+ import { AsyncLocalStorage } from "async_hooks";
7
+ import { error as svelteKitError } from "@sveltejs/kit";
2
8
  import {
3
9
  createHoloFrameworkAdapter
4
10
  } from "@holo-js/core";
11
+ import {
12
+ isValidationException,
13
+ validationInternals
14
+ } from "@holo-js/forms/schema";
5
15
  var svelteKitAdapter = createHoloFrameworkAdapter({
6
16
  stateKey: "__holoSvelteKitAdapter__",
7
17
  displayName: "SvelteKit"
8
18
  });
19
+ var validationFlashCookie = "HOLO-SVELTEKIT-VALIDATION";
20
+ var validationExceptionThrowerRegistered = false;
21
+ var validationActionFailures = /* @__PURE__ */ new WeakMap();
22
+ var validationActionFailureKeys = /* @__PURE__ */ new Map();
23
+ function getSvelteKitRequestEventStore() {
24
+ const runtimeGlobal = globalThis;
25
+ runtimeGlobal.__holoSvelteKitRequestEventStore ??= new AsyncLocalStorage();
26
+ return runtimeGlobal.__holoSvelteKitRequestEventStore;
27
+ }
28
+ function toSvelteKitErrorStatus(status) {
29
+ return status >= 400 && status <= 599 ? status : 500;
30
+ }
31
+ function isApiEvent(event) {
32
+ return event.url?.pathname.startsWith("/api/") === true;
33
+ }
34
+ function isPlainObject(value) {
35
+ return !!value && typeof value === "object" && !Array.isArray(value);
36
+ }
37
+ function isSerializedValidationException(value) {
38
+ return isPlainObject(value) && value.ok === false && typeof value.status === "number" && value.valid === false && typeof value.message === "string" && typeof value.bag === "string" && isPlainObject(value.values) && isPlainObject(value.errors);
39
+ }
40
+ function serializeValidationException(error) {
41
+ return isValidationException(error) ? error.toJSON() : void 0;
42
+ }
43
+ function toSvelteKitValidationBody(payload) {
44
+ return payload;
45
+ }
46
+ function isSvelteKitActionJsonRequest(event) {
47
+ return event.request.method?.toUpperCase() === "POST" && event.request.headers.get("accept")?.toLowerCase().includes("application/json") === true;
48
+ }
49
+ async function mapValidationActionResponse(event, response) {
50
+ if (isApiEvent(event)) {
51
+ const apiPayload = takeValidationActionFailure(event);
52
+ if (apiPayload) {
53
+ return Response.json(apiPayload, { status: apiPayload.status });
54
+ }
55
+ return response;
56
+ }
57
+ const flashedPayload = takeValidationActionFailure(event);
58
+ if (flashedPayload) {
59
+ return isSvelteKitActionJsonRequest(event) ? createValidationActionFailureResponse(flashedPayload, response, true) : createValidationActionRedirectResponse(event, flashedPayload);
60
+ }
61
+ if (!isSvelteKitActionJsonRequest(event)) {
62
+ return response;
63
+ }
64
+ const contentType = response.headers.get("content-type") ?? "";
65
+ if (!contentType.toLowerCase().includes("application/json")) {
66
+ return response;
67
+ }
68
+ let actionResult;
69
+ try {
70
+ actionResult = await response.clone().json();
71
+ } catch {
72
+ return response;
73
+ }
74
+ if (actionResult.type !== "error" || !isSerializedValidationException(actionResult.error)) {
75
+ return response;
76
+ }
77
+ return createValidationActionFailureResponse(actionResult.error, response, false);
78
+ }
79
+ function encodeValidationFlashPayload(payload) {
80
+ return encodeURIComponent(JSON.stringify({
81
+ ...payload,
82
+ values: filterFlashValues(payload.values)
83
+ }));
84
+ }
85
+ function isSensitiveFlashKey(key) {
86
+ const normalized = key.toLowerCase().replace(/[-_\s]/g, "");
87
+ return normalized.startsWith("_") || normalized.includes("password") || normalized.includes("token") || normalized.includes("secret") || normalized.includes("credential");
88
+ }
89
+ function filterFlashValue(value) {
90
+ if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
91
+ return value;
92
+ }
93
+ if (Array.isArray(value)) {
94
+ return value.map((item) => filterFlashValue(item)).filter((item) => typeof item !== "undefined");
95
+ }
96
+ if (!isPlainObject(value)) {
97
+ return void 0;
98
+ }
99
+ return filterFlashValues(value);
100
+ }
101
+ function filterFlashValues(values) {
102
+ const filtered = {};
103
+ for (const [key, value] of Object.entries(values)) {
104
+ if (isSensitiveFlashKey(key)) {
105
+ continue;
106
+ }
107
+ const next = filterFlashValue(value);
108
+ if (typeof next !== "undefined") {
109
+ filtered[key] = next;
110
+ }
111
+ }
112
+ return filtered;
113
+ }
114
+ function flashValidationPayload(event, payload) {
115
+ if (!event.url) {
116
+ return;
117
+ }
118
+ event.cookies.set(validationFlashCookie, encodeValidationFlashPayload(payload), {
119
+ path: normalizeCookiePath(event),
120
+ maxAge: 60,
121
+ sameSite: "lax"
122
+ });
123
+ }
124
+ function normalizeCookiePath(event) {
125
+ return (event.url?.pathname || "/").replace(/[;\r\n]/g, "") || "/";
126
+ }
127
+ function createValidationFlashCookie(event, payload) {
128
+ return [
129
+ `${validationFlashCookie}=${encodeValidationFlashPayload(payload)}`,
130
+ "Max-Age=60",
131
+ `Path=${normalizeCookiePath(event)}`,
132
+ "SameSite=Lax"
133
+ ].join("; ");
134
+ }
135
+ function createValidationActionFailureResponse(payload, response, reloadWithFlash) {
136
+ const headers = new Headers(response.headers);
137
+ headers.delete("content-length");
138
+ headers.set("content-type", "application/json");
139
+ if (reloadWithFlash) {
140
+ headers.set("x-holo-validation-flash", "1");
141
+ }
142
+ return Response.json({
143
+ type: "failure",
144
+ status: payload.status,
145
+ data: JSON.stringify(payload)
146
+ }, {
147
+ status: 200,
148
+ headers
149
+ });
150
+ }
151
+ function createValidationActionRedirectResponse(event, payload) {
152
+ return new Response(null, {
153
+ status: 303,
154
+ headers: {
155
+ location: event.url?.pathname || "/",
156
+ "cache-control": "no-store",
157
+ "set-cookie": createValidationFlashCookie(event, payload)
158
+ }
159
+ });
160
+ }
161
+ function getValidationActionFailureKey(event) {
162
+ if (!event.url) {
163
+ return void 0;
164
+ }
165
+ return `${event.request.method?.toUpperCase() ?? "GET"} ${event.url.href}`;
166
+ }
167
+ function takeValidationActionFailure(event) {
168
+ const key = getValidationActionFailureKey(event);
169
+ const eventPayload = validationActionFailures.get(event);
170
+ if (eventPayload) {
171
+ validationActionFailures.delete(event);
172
+ validationActionFailures.delete(event.request);
173
+ if (key) {
174
+ validationActionFailureKeys.delete(key);
175
+ }
176
+ return eventPayload;
177
+ }
178
+ const requestPayload = validationActionFailures.get(event.request);
179
+ if (requestPayload) {
180
+ validationActionFailures.delete(event);
181
+ validationActionFailures.delete(event.request);
182
+ if (key) {
183
+ validationActionFailureKeys.delete(key);
184
+ }
185
+ return requestPayload;
186
+ }
187
+ if (!key) {
188
+ return void 0;
189
+ }
190
+ const keyedPayload = validationActionFailureKeys.get(key);
191
+ validationActionFailureKeys.delete(key);
192
+ return keyedPayload;
193
+ }
194
+ function rememberValidationActionFailure(event, payload) {
195
+ flashValidationPayload(event, payload);
196
+ validationActionFailures.set(event, payload);
197
+ validationActionFailures.set(event.request, payload);
198
+ const key = getValidationActionFailureKey(event);
199
+ if (key) {
200
+ validationActionFailureKeys.set(key, payload);
201
+ }
202
+ }
203
+ function registerValidationExceptionThrower() {
204
+ if (validationExceptionThrowerRegistered) {
205
+ return;
206
+ }
207
+ validationExceptionThrowerRegistered = true;
208
+ validationInternals.setValidationExceptionThrower((exception) => {
209
+ const event = getSvelteKitRequestEventStore().getStore();
210
+ if (!event) {
211
+ return;
212
+ }
213
+ const payload = exception.toJSON();
214
+ if (!isApiEvent(event)) {
215
+ rememberValidationActionFailure(event, payload);
216
+ }
217
+ svelteKitError(toSvelteKitErrorStatus(payload.status), toSvelteKitValidationBody(payload));
218
+ });
219
+ }
220
+ function safeDecodeCookieSegment(value) {
221
+ try {
222
+ return decodeURIComponent(value);
223
+ } catch {
224
+ return value;
225
+ }
226
+ }
227
+ function parseResponseCookie(cookie) {
228
+ const [nameValue = "", ...attributes] = cookie.split(";");
229
+ const separator = nameValue.indexOf("=");
230
+ if (!nameValue || separator <= 0) {
231
+ return null;
232
+ }
233
+ const options = { path: "/" };
234
+ for (const rawAttribute of attributes) {
235
+ const attribute = rawAttribute.trim();
236
+ if (!attribute) {
237
+ continue;
238
+ }
239
+ const attributeSeparator = attribute.indexOf("=");
240
+ const key = (attributeSeparator === -1 ? attribute : attribute.slice(0, attributeSeparator)).trim().toLowerCase();
241
+ const value = attributeSeparator === -1 ? "" : attribute.slice(attributeSeparator + 1).trim();
242
+ switch (key) {
243
+ case "path":
244
+ options.path = value || "/";
245
+ break;
246
+ case "domain":
247
+ options.domain = value;
248
+ break;
249
+ case "max-age": {
250
+ const maxAge = Number(value);
251
+ if (Number.isFinite(maxAge)) {
252
+ options.maxAge = maxAge;
253
+ }
254
+ break;
255
+ }
256
+ case "expires": {
257
+ const expires = new Date(value);
258
+ if (!Number.isNaN(expires.getTime())) {
259
+ options.expires = expires;
260
+ }
261
+ break;
262
+ }
263
+ case "secure":
264
+ options.secure = true;
265
+ break;
266
+ case "httponly":
267
+ options.httpOnly = true;
268
+ break;
269
+ case "samesite":
270
+ if (value.toLowerCase() === "lax" || value.toLowerCase() === "strict" || value.toLowerCase() === "none") {
271
+ options.sameSite = value.toLowerCase();
272
+ }
273
+ break;
274
+ case "partitioned":
275
+ options.partitioned = value ? value.toLowerCase() === "true" : true;
276
+ break;
277
+ }
278
+ }
279
+ return {
280
+ name: safeDecodeCookieSegment(nameValue.slice(0, separator)),
281
+ value: safeDecodeCookieSegment(nameValue.slice(separator + 1)),
282
+ options
283
+ };
284
+ }
285
+ function resolveSvelteKitAuthRequestAccessors() {
286
+ return {
287
+ async getCookie(name) {
288
+ const event = getSvelteKitRequestEventStore().getStore();
289
+ return event?.cookies.get(name) ?? void 0;
290
+ },
291
+ async getHeader(name) {
292
+ const event = getSvelteKitRequestEventStore().getStore();
293
+ return event?.request.headers.get(name) ?? void 0;
294
+ },
295
+ appendResponseCookie(cookie) {
296
+ const event = getSvelteKitRequestEventStore().getStore();
297
+ const parsed = parseResponseCookie(cookie);
298
+ if (!event || !parsed) {
299
+ return;
300
+ }
301
+ event.cookies.set(parsed.name, parsed.value, parsed.options);
302
+ },
303
+ async redirectResponse(url, status = 307) {
304
+ const { redirect } = await import("@sveltejs/kit");
305
+ redirect(status, url);
306
+ }
307
+ };
308
+ }
309
+ function resolveSvelteKitOptions(options) {
310
+ return {
311
+ ...options,
312
+ authRequest: options.authRequest ?? resolveSvelteKitAuthRequestAccessors(),
313
+ authorizationError: options.authorizationError ?? {
314
+ createError(decision) {
315
+ const status = decision.status === 404 ? 404 : 403;
316
+ svelteKitError(status, decision.message ?? "You are not authorized to perform this action.");
317
+ }
318
+ }
319
+ };
320
+ }
9
321
  var svelteKitHoloCapabilities = svelteKitAdapter.capabilities;
322
+ function runWithSvelteKitRequestEvent(event, callback) {
323
+ registerValidationExceptionThrower();
324
+ return getSvelteKitRequestEventStore().run(event, callback);
325
+ }
10
326
  async function createSvelteKitHoloProject(options = {}) {
11
- return svelteKitAdapter.createProject(options);
327
+ return svelteKitAdapter.createProject(resolveSvelteKitOptions(options));
12
328
  }
13
329
  async function initializeSvelteKitHoloProject(options = {}) {
14
- return svelteKitAdapter.initializeProject(options);
330
+ return svelteKitAdapter.initializeProject(resolveSvelteKitOptions(options));
15
331
  }
16
332
  function createSvelteKitHoloHelpers(options = {}) {
17
- return svelteKitAdapter.createHelpers(options);
333
+ return svelteKitAdapter.createHelpers(resolveSvelteKitOptions(options));
18
334
  }
19
335
  async function resetSvelteKitHoloProject() {
20
336
  await svelteKitAdapter.resetProject();
21
337
  }
22
- var adapterSvelteKitInternals = svelteKitAdapter.internals;
338
+ var adapterSvelteKitInternals = {
339
+ ...svelteKitAdapter.internals,
340
+ mapValidationActionResponse,
341
+ rememberValidationActionFailure,
342
+ isApiEvent,
343
+ serializeValidationException,
344
+ validationFlashCookie
345
+ };
23
346
  export {
24
347
  adapterSvelteKitInternals,
25
348
  createSvelteKitHoloHelpers,
26
349
  createSvelteKitHoloProject,
350
+ holoSvelteKitTransport,
27
351
  initializeSvelteKitHoloProject,
28
352
  resetSvelteKitHoloProject,
353
+ runWithSvelteKitRequestEvent,
29
354
  svelteKitHoloCapabilities
30
355
  };
@@ -0,0 +1,18 @@
1
+ type JsonSerializable = {
2
+ toJSON(): unknown;
3
+ };
4
+ type SerializedSvelteKitData<TValue> = TValue extends Date ? Date : TValue extends JsonSerializable ? ReturnType<TValue['toJSON']> : TValue extends readonly (infer TItem)[] ? SerializedSvelteKitData<TItem>[] : TValue extends object ? {
5
+ [K in keyof TValue]: SerializedSvelteKitData<TValue[K]>;
6
+ } : TValue;
7
+ type HoloTransportEncoder = {
8
+ encode: (value: unknown) => false | unknown[] | Record<string, unknown>;
9
+ decode: (value: unknown[] | Record<string, unknown>) => unknown;
10
+ };
11
+ type SvelteKitTransportDefinition = Readonly<{
12
+ HoloModel: HoloTransportEncoder;
13
+ HoloCollection: HoloTransportEncoder;
14
+ }>;
15
+ declare function serializeSvelteKitData<TValue>(value: TValue): SerializedSvelteKitData<TValue>;
16
+ declare const holoSvelteKitTransport: SvelteKitTransportDefinition;
17
+
18
+ export { type SerializedSvelteKitData, type SvelteKitTransportDefinition, holoSvelteKitTransport, serializeSvelteKitData };
@@ -0,0 +1,8 @@
1
+ import {
2
+ holoSvelteKitTransport,
3
+ serializeSvelteKitData
4
+ } from "./chunk-FZXR22V2.mjs";
5
+ export {
6
+ holoSvelteKitTransport,
7
+ serializeSvelteKitData
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holo-js/adapter-sveltekit",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Holo-JS Framework - SvelteKit adapter",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -10,10 +10,20 @@
10
10
  "import": "./dist/index.mjs",
11
11
  "default": "./dist/index.mjs"
12
12
  },
13
+ "./config": {
14
+ "types": "./dist/config.d.ts",
15
+ "import": "./dist/config.mjs",
16
+ "default": "./dist/config.mjs"
17
+ },
13
18
  "./client": {
14
19
  "types": "./dist/client.d.ts",
15
20
  "import": "./dist/client.mjs",
16
21
  "default": "./dist/client.mjs"
22
+ },
23
+ "./transport": {
24
+ "types": "./dist/transport.d.ts",
25
+ "import": "./dist/transport.mjs",
26
+ "default": "./dist/transport.mjs"
17
27
  }
18
28
  },
19
29
  "main": "./dist/index.mjs",
@@ -28,21 +38,19 @@
28
38
  "test": "vitest --run"
29
39
  },
30
40
  "dependencies": {
31
- "@holo-js/config": "^0.1.4",
32
- "@holo-js/core": "^0.1.4"
41
+ "@holo-js/config": "^0.1.5",
42
+ "@holo-js/core": "^0.1.5",
43
+ "svelte": "^5.55.5"
33
44
  },
34
45
  "peerDependencies": {
35
- "@holo-js/forms": "^0.1.4"
36
- },
37
- "peerDependenciesMeta": {
38
- "@holo-js/forms": {
39
- "optional": true
40
- }
46
+ "@holo-js/forms": "^0.1.5",
47
+ "@sveltejs/kit": "^2.59.1"
41
48
  },
42
49
  "devDependencies": {
50
+ "@sveltejs/kit": "^2.59.1",
43
51
  "@types/node": "^22.10.2",
44
52
  "tsup": "^8.3.5",
45
53
  "typescript": "^5.7.2",
46
- "vitest": "^2.1.8"
54
+ "vitest": "^4.1.5"
47
55
  }
48
56
  }