@maravilla-labs/adapter-sveltekit 2.0.0 → 3.0.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAW,MAAM,eAAe,CAAC;AACtD,OAAO,EAWL,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAKtC,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAuIrE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAW,MAAM,eAAe,CAAC;AACtD,OAAO,EAWL,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAKtC,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CA6IrE"}
package/dist/index.js CHANGED
@@ -91,8 +91,14 @@ export default function adapter(options = {}) {
91
91
  });
92
92
  // Build and integrate workflows (workflows.ts / workflows/**/*.ts)
93
93
  await buildAndIntegrateWorkflows(process.cwd(), out, builder.log);
94
- // Build and integrate MCP tools (mcp.ts / mcp/**/*.ts)
95
- await buildAndIntegrateMcp(process.cwd(), out, builder.log);
94
+ // Build and integrate MCP tools (mcp.ts / mcp/**/*.ts). `framework: 'svelte'`
95
+ // lets buildMcp auto-build MCP UI widgets from mcp-ui/<name>/ source using
96
+ // the app's @sveltejs/vite-plugin-svelte; `staticDir: 'static'` matches the
97
+ // deploy static dir written above.
98
+ await buildAndIntegrateMcp(process.cwd(), out, builder.log, {
99
+ framework: 'svelte',
100
+ staticDir: 'static',
101
+ });
96
102
  builder.log.minor(`Build complete. Output written to ${out}`);
97
103
  builder.log.minor('');
98
104
  builder.log.minor('Deploy: push to a branch listed in .maravilla/pip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,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;gBAC1D,SAAS,EAAE,QAAQ;gBACnB,SAAS,EAAE,QAAQ;aACpB,CAAC,CAAC;YAEH,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,qCAAqC,GAAG,EAAE,CAAC,CAAC;YAC9D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAC;YAClF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACtB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,uBAAuB,GAAG,EAAE,CAAC,CAAC;QAClD,CAAC;QAED,QAAQ,EAAE;YACR,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI;SACjB;KACF,CAAC;AACJ,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const WORKER_TEMPLATE = "// Maravilla Runtime Worker for SvelteKit\n// This runs inside the Deno isolate with access to platform APIs\n\n// Store the original fetch and Request for internal use\nconst originalFetch = globalThis.fetch;\nconst OriginalRequest = globalThis.Request;\n\n// Create an enhanced Request that properly handles SvelteKit's usage patterns\nclass EnhancedRequest extends OriginalRequest {\n constructor(input, init) {\n // Handle the case where SvelteKit passes a string URL\n if (typeof input === 'string') {\n try {\n super(input, init);\n } catch (e) {\n // If it fails, it might be a relative URL - try to resolve it\n if (globalThis.location && e.message && e.message.includes('relative')) {\n try {\n const absoluteUrl = new URL(input, globalThis.location.href);\n super(absoluteUrl.href, init);\n } catch (e2) {\n // If that also fails, throw the original error\n throw e;\n }\n } else {\n throw e;\n }\n }\n return;\n }\n \n // Handle plain objects with url property (SvelteKit sometimes does this)\n if (input && typeof input === 'object' && !(input instanceof OriginalRequest)) {\n // Extract URL from the object\n const url = input.url || input.href || input.toString();\n if (!url) {\n throw new TypeError('Request must have a URL');\n }\n \n // Build init options from the object\n const newInit = {\n method: input.method || init?.method || 'GET',\n headers: input.headers || init?.headers,\n body: input.body || init?.body,\n mode: input.mode || init?.mode,\n credentials: input.credentials || init?.credentials,\n cache: input.cache || init?.cache,\n redirect: input.redirect || init?.redirect,\n referrer: input.referrer || init?.referrer,\n referrerPolicy: input.referrerPolicy || init?.referrerPolicy,\n integrity: input.integrity || init?.integrity,\n keepalive: input.keepalive || init?.keepalive,\n signal: input.signal || init?.signal,\n ...init\n };\n \n // Create the Request with the extracted URL\n super(url, newInit);\n return;\n }\n \n // Otherwise use the original constructor normally\n super(input, init);\n }\n}\n\n// Replace global Request with our enhanced version\nglobalThis.Request = EnhancedRequest;\n\n// Create an enhanced fetch that handles relative URLs and special cases\nglobalThis.fetch = function enhancedFetch(input, init) {\n // Convert input to a Request if needed\n let request;\n \n if (input instanceof Request) {\n request = input;\n } else if (typeof input === 'string') {\n // Check if it's already absolute\n if (input.startsWith('http://') || input.startsWith('https://')) {\n request = new Request(input, init);\n } else if (globalThis.location) {\n // It's relative - resolve it\n try {\n const absoluteUrl = new URL(input, globalThis.location.href);\n request = new Request(absoluteUrl.href, init);\n } catch (e) {\n console.error('Failed to resolve relative URL:', input, 'against', globalThis.location.href);\n throw e;\n }\n } else {\n console.error('Cannot resolve relative URL without globalThis.location:', input);\n throw new Error('Cannot resolve relative URL without a base URL');\n }\n } else if (input && typeof input === 'object') {\n // Handle plain objects by converting to Request\n request = new Request(input, init);\n } else {\n throw new TypeError('First argument must be a string, Request, or URL');\n }\n \n // Call the original fetch with the normalized request\n return originalFetch(request);\n};\n\n// Import SvelteKit server - these will be replaced by esbuild\nimport { Server } from '__SERVER__';\nimport { manifest, prerendered, base } from '__MANIFEST__';\n\n// Initialize the SvelteKit server\nconst server = new Server(manifest);\n\n// Initialize server with platform-specific read function\nconst initialized = server.init({\n env: globalThis.platform?.env || {},\n read: async (file) => {\n // For now, return empty stream for any file read attempts\n // This is a placeholder until we implement proper static file serving\n // console.log('Read function called for file:', file);\n \n // Return an empty ReadableStream to prevent errors\n return new ReadableStream({\n start(controller) {\n // Just close the stream immediately\n controller.close();\n }\n });\n }\n});\n\n/**\n * Main request handler for the Maravilla runtime\n * This function is called by the runtime for each incoming request\n */\nasync function handleRequest(request) {\n // Apply our fetch/Request overrides when first called\n if (globalThis.Request !== EnhancedRequest) {\n // console.log('Applying EnhancedRequest override');\n globalThis.Request = EnhancedRequest;\n globalThis.fetch = enhancedFetch;\n }\n // Ensure server is initialized\n await initialized;\n\n // The runtime should have already set globalThis.location by now\n // Log it for debugging\n if (globalThis.location) {\n // console.log('globalThis.location is available:', globalThis.location.origin);\n } else {\n console.warn('WARNING: globalThis.location not set by runtime - this may cause URL resolution issues');\n }\n\n // Check if request is already a Web API Request object\n let webRequest;\n if (request instanceof Request) {\n // It's already a proper Request object from the runtime\n // console.log('Request is already a Web API Request object');\n webRequest = request;\n } else {\n // It's a plain object, convert it to a Request (fallback for older runtime)\n // console.log('Converting plain object to Request');\n const url = new URL(request.url, 'http://localhost');\n \n // Prepare the body - handle different types\n let requestBody = undefined;\n if (request.body !== null && request.body !== undefined) {\n // If body is already a string, use it directly\n if (typeof request.body === 'string') {\n requestBody = request.body;\n } else {\n // Otherwise stringify it\n requestBody = JSON.stringify(request.body);\n }\n }\n \n // Create a standard Request object\n webRequest = new Request(url.toString(), {\n method: request.method,\n headers: request.headers || {},\n body: requestBody\n });\n }\n\n // Check if this is a static asset request\n // Use a base URL to avoid \"relative URL without a base\" errors\n const requestUrl = new URL(webRequest.url, webRequest.url.startsWith('http') ? undefined : 'http://localhost');\n const pathname = requestUrl.pathname;\n const stripped_pathname = pathname.replace(/\\/$/, '');\n\n // Debug: verify URL.pathname setter works for data requests\n if (pathname.endsWith('/__data.json') || pathname.endsWith('.html__data.json')) {\n try {\n const test = new URL(webRequest.url, webRequest.url.startsWith('http') ? undefined : 'http://localhost');\n const before = test.pathname;\n const candidate = pathname.endsWith('/__data.json')\n ? pathname.slice(0, -'/__data.json'.length)\n : pathname.slice(0, -'.html__data.json'.length) + '.html';\n test.pathname = candidate;\n // console.log('Data URL normalization test', { before, candidate, after: test.pathname, href: test.href });\n } catch (e) {\n console.error('Data URL normalization error', e);\n }\n }\n \n // Check if path is prerendered\n if (prerendered.has(pathname)) {\n // For prerendered pages, we could serve from static storage\n // but for now, let SvelteKit handle it\n }\n\n // Handle trailing slash redirects for prerendered pages\n const location = pathname.at(-1) === '/' ? stripped_pathname : pathname + '/';\n if (location && prerendered.has(location)) {\n const urlObj = new URL(webRequest.url, webRequest.url.startsWith('http') ? undefined : 'http://localhost');\n return new Response('', {\n status: 308,\n headers: {\n location: location + urlObj.search\n }\n });\n }\n\n // Let SvelteKit handle the request\n try {\n // console.log('SvelteKit server.respond called with:', {\n // url: webRequest.url,\n // method: webRequest.method,\n // hasBody: webRequest.body !== null,\n // platform: {\n // hasEnv: !!globalThis.platform?.env,\n // hasKv: !!globalThis.platform?.kv,\n // hasDb: !!globalThis.platform?.db\n // }\n // });\n \n const response = await server.respond(webRequest, {\n platform: {\n // Expose Maravilla platform APIs to SvelteKit\n env: globalThis.platform?.env || {},\n context: {\n waitUntil: (promise) => {\n // In Maravilla, we can queue background work\n if (globalThis.platform?.queue) {\n globalThis.platform.queue.send({ type: 'background', promise });\n }\n },\n passThroughOnException: () => {\n // Not applicable in Maravilla runtime\n }\n },\n // Expose platform services\n kv: globalThis.platform?.kv,\n db: globalThis.platform?.db,\n storage: globalThis.platform?.storage,\n queue: globalThis.platform?.queue\n },\n getClientAddress: () => {\n // Get client IP from request headers\n const forwarded = webRequest.headers.get('x-forwarded-for');\n if (forwarded) {\n return forwarded.split(',')[0].trim();\n }\n // Fallback for plain object format (shouldn't happen with proper Request)\n return request.headers?.['x-real-ip'] || '127.0.0.1';\n }\n });\n\n // Log response details\n if (response.status >= 400) {\n console.error('SvelteKit returned error:', {\n status: response.status,\n statusText: response.statusText,\n url: webRequest.url\n });\n }\n\n // Return the response in a format the runtime expects\n return response;\n } catch (error) {\n console.error('Error in server.respond:', error);\n console.error('Error stack:', error.stack);\n throw error;\n }\n}\n\n// Export for the Maravilla runtime\nglobalThis.handleRequest = handleRequest;\n";
1
+ export declare const WORKER_TEMPLATE = "// Maravilla Runtime Worker for SvelteKit\n// This runs inside the Deno isolate with access to platform APIs\n\n// Store the original fetch and Request for internal use\nconst originalFetch = globalThis.fetch;\nconst OriginalRequest = globalThis.Request;\n\n// Create an enhanced Request that properly handles SvelteKit's usage patterns\nclass EnhancedRequest extends OriginalRequest {\n constructor(input, init) {\n // Handle the case where SvelteKit passes a string URL\n if (typeof input === 'string') {\n try {\n super(input, init);\n } catch (e) {\n // If it fails, it might be a relative URL - try to resolve it\n if (globalThis.location && e.message && e.message.includes('relative')) {\n try {\n const absoluteUrl = new URL(input, globalThis.location.href);\n super(absoluteUrl.href, init);\n } catch (e2) {\n // If that also fails, throw the original error\n throw e;\n }\n } else {\n throw e;\n }\n }\n return;\n }\n \n // Handle plain objects with url property (SvelteKit sometimes does this)\n if (input && typeof input === 'object' && !(input instanceof OriginalRequest)) {\n // Extract URL from the object\n const url = input.url || input.href || input.toString();\n if (!url) {\n throw new TypeError('Request must have a URL');\n }\n \n // Build init options from the object\n const newInit = {\n method: input.method || init?.method || 'GET',\n headers: input.headers || init?.headers,\n body: input.body || init?.body,\n mode: input.mode || init?.mode,\n credentials: input.credentials || init?.credentials,\n cache: input.cache || init?.cache,\n redirect: input.redirect || init?.redirect,\n referrer: input.referrer || init?.referrer,\n referrerPolicy: input.referrerPolicy || init?.referrerPolicy,\n integrity: input.integrity || init?.integrity,\n keepalive: input.keepalive || init?.keepalive,\n signal: input.signal || init?.signal,\n ...init\n };\n \n // Create the Request with the extracted URL\n super(url, newInit);\n return;\n }\n \n // Otherwise use the original constructor normally\n super(input, init);\n }\n}\n\n// Replace global Request with our enhanced version\nglobalThis.Request = EnhancedRequest;\n\n// Create an enhanced fetch that handles relative URLs and special cases\nglobalThis.fetch = function enhancedFetch(input, init) {\n // Convert input to a Request if needed\n let request;\n \n if (input instanceof Request) {\n request = input;\n } else if (typeof input === 'string') {\n // Check if it's already absolute\n if (input.startsWith('http://') || input.startsWith('https://')) {\n request = new Request(input, init);\n } else if (globalThis.location) {\n // It's relative - resolve it\n try {\n const absoluteUrl = new URL(input, globalThis.location.href);\n request = new Request(absoluteUrl.href, init);\n } catch (e) {\n console.error('Failed to resolve relative URL:', input, 'against', globalThis.location.href);\n throw e;\n }\n } else {\n console.error('Cannot resolve relative URL without globalThis.location:', input);\n throw new Error('Cannot resolve relative URL without a base URL');\n }\n } else if (input && typeof input === 'object') {\n // Handle plain objects by converting to Request\n request = new Request(input, init);\n } else {\n throw new TypeError('First argument must be a string, Request, or URL');\n }\n \n // Call the original fetch with the normalized request\n return originalFetch(request);\n};\n\n// Import SvelteKit server - these will be replaced by esbuild\nimport { Server } from '__SERVER__';\nimport { manifest, prerendered, base } from '__MANIFEST__';\n\n// Initialize the SvelteKit server\nconst server = new Server(manifest);\n\n// Initialize server with platform-specific read function\nconst initialized = server.init({\n env: globalThis.platform?.env || {},\n read: async (file) => {\n // For now, return empty stream for any file read attempts\n // This is a placeholder until we implement proper static file serving\n // console.log('Read function called for file:', file);\n \n // Return an empty ReadableStream to prevent errors\n return new ReadableStream({\n start(controller) {\n // Just close the stream immediately\n controller.close();\n }\n });\n }\n});\n\n/**\n * Main request handler for the Maravilla runtime\n * This function is called by the runtime for each incoming request\n */\nasync function handleRequest(request) {\n // Apply our fetch/Request overrides when first called\n if (globalThis.Request !== EnhancedRequest) {\n // console.log('Applying EnhancedRequest override');\n globalThis.Request = EnhancedRequest;\n globalThis.fetch = enhancedFetch;\n }\n // Ensure server is initialized\n await initialized;\n\n // The runtime should have already set globalThis.location by now\n // Log it for debugging\n if (globalThis.location) {\n // console.log('globalThis.location is available:', globalThis.location.origin);\n } else {\n console.warn('WARNING: globalThis.location not set by runtime - this may cause URL resolution issues');\n }\n\n // Check if request is already a Web API Request object\n let webRequest;\n if (request instanceof Request) {\n // It's already a proper Request object from the runtime\n // console.log('Request is already a Web API Request object');\n webRequest = request;\n } else {\n // Last-resort fallback: the runtime handed us a plain object instead of a\n // Web API Request. The modern runtime always reconstructs a real Request\n // (preferring raw bytes), so this branch is only reached if that\n // reconstruction threw upstream. Preserve raw bytes verbatim whenever they\n // are present so HMAC/signature verification over the raw body keeps working.\n const url = new URL(request.url, 'http://localhost');\n\n let requestBody = undefined;\n if (request.raw_body !== null && request.raw_body !== undefined) {\n // Exact original bytes \u2014 never re-encode these.\n requestBody = new Uint8Array(request.raw_body);\n } else if (request.body !== null && request.body !== undefined) {\n if (typeof request.body === 'string') {\n requestBody = request.body;\n } else {\n // No raw bytes available and the body is an already-parsed object: this\n // is inherently lossy (re-serialization changes key order / whitespace)\n // and can break raw-body signature checks. There is nothing left to\n // recover the original bytes from here \u2014 the fix lives upstream, where\n // raw_body is now always preserved.\n requestBody = JSON.stringify(request.body);\n }\n }\n\n // Create a standard Request object\n webRequest = new Request(url.toString(), {\n method: request.method,\n headers: request.headers || {},\n body: requestBody\n });\n }\n\n // Check if this is a static asset request\n // Use a base URL to avoid \"relative URL without a base\" errors\n const requestUrl = new URL(webRequest.url, webRequest.url.startsWith('http') ? undefined : 'http://localhost');\n const pathname = requestUrl.pathname;\n const stripped_pathname = pathname.replace(/\\/$/, '');\n\n // Debug: verify URL.pathname setter works for data requests\n if (pathname.endsWith('/__data.json') || pathname.endsWith('.html__data.json')) {\n try {\n const test = new URL(webRequest.url, webRequest.url.startsWith('http') ? undefined : 'http://localhost');\n const before = test.pathname;\n const candidate = pathname.endsWith('/__data.json')\n ? pathname.slice(0, -'/__data.json'.length)\n : pathname.slice(0, -'.html__data.json'.length) + '.html';\n test.pathname = candidate;\n // console.log('Data URL normalization test', { before, candidate, after: test.pathname, href: test.href });\n } catch (e) {\n console.error('Data URL normalization error', e);\n }\n }\n \n // Check if path is prerendered\n if (prerendered.has(pathname)) {\n // For prerendered pages, we could serve from static storage\n // but for now, let SvelteKit handle it\n }\n\n // Handle trailing slash redirects for prerendered pages\n const location = pathname.at(-1) === '/' ? stripped_pathname : pathname + '/';\n if (location && prerendered.has(location)) {\n const urlObj = new URL(webRequest.url, webRequest.url.startsWith('http') ? undefined : 'http://localhost');\n return new Response('', {\n status: 308,\n headers: {\n location: location + urlObj.search\n }\n });\n }\n\n // Let SvelteKit handle the request\n try {\n // console.log('SvelteKit server.respond called with:', {\n // url: webRequest.url,\n // method: webRequest.method,\n // hasBody: webRequest.body !== null,\n // platform: {\n // hasEnv: !!globalThis.platform?.env,\n // hasKv: !!globalThis.platform?.kv,\n // hasDb: !!globalThis.platform?.db\n // }\n // });\n \n const response = await server.respond(webRequest, {\n platform: {\n // Expose Maravilla platform APIs to SvelteKit\n env: globalThis.platform?.env || {},\n context: {\n waitUntil: (promise) => {\n // In Maravilla, we can queue background work\n if (globalThis.platform?.queue) {\n globalThis.platform.queue.send({ type: 'background', promise });\n }\n },\n passThroughOnException: () => {\n // Not applicable in Maravilla runtime\n }\n },\n // Expose platform services\n kv: globalThis.platform?.kv,\n db: globalThis.platform?.db,\n storage: globalThis.platform?.storage,\n queue: globalThis.platform?.queue\n },\n getClientAddress: () => {\n // Get client IP from request headers\n const forwarded = webRequest.headers.get('x-forwarded-for');\n if (forwarded) {\n return forwarded.split(',')[0].trim();\n }\n // Fallback for plain object format (shouldn't happen with proper Request)\n return request.headers?.['x-real-ip'] || '127.0.0.1';\n }\n });\n\n // Log response details\n if (response.status >= 400) {\n console.error('SvelteKit returned error:', {\n status: response.status,\n statusText: response.statusText,\n url: webRequest.url\n });\n }\n\n // Return the response in a format the runtime expects\n return response;\n } catch (error) {\n console.error('Error in server.respond:', error);\n console.error('Error stack:', error.stack);\n throw error;\n }\n}\n\n// Export for the Maravilla runtime\nglobalThis.handleRequest = handleRequest;\n";
2
2
  //# sourceMappingURL=worker-template.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worker-template.d.ts","sourceRoot":"","sources":["../src/worker-template.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,urUA8R3B,CAAC"}
1
+ {"version":3,"file":"worker-template.d.ts","sourceRoot":"","sources":["../src/worker-template.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,01VAsS3B,CAAC"}
@@ -158,22 +158,30 @@ async function handleRequest(request) {
158
158
  // console.log('Request is already a Web API Request object');
159
159
  webRequest = request;
160
160
  } else {
161
- // It's a plain object, convert it to a Request (fallback for older runtime)
162
- // console.log('Converting plain object to Request');
161
+ // Last-resort fallback: the runtime handed us a plain object instead of a
162
+ // Web API Request. The modern runtime always reconstructs a real Request
163
+ // (preferring raw bytes), so this branch is only reached if that
164
+ // reconstruction threw upstream. Preserve raw bytes verbatim whenever they
165
+ // are present so HMAC/signature verification over the raw body keeps working.
163
166
  const url = new URL(request.url, 'http://localhost');
164
-
165
- // Prepare the body - handle different types
167
+
166
168
  let requestBody = undefined;
167
- if (request.body !== null && request.body !== undefined) {
168
- // If body is already a string, use it directly
169
+ if (request.raw_body !== null && request.raw_body !== undefined) {
170
+ // Exact original bytes never re-encode these.
171
+ requestBody = new Uint8Array(request.raw_body);
172
+ } else if (request.body !== null && request.body !== undefined) {
169
173
  if (typeof request.body === 'string') {
170
174
  requestBody = request.body;
171
175
  } else {
172
- // Otherwise stringify it
176
+ // No raw bytes available and the body is an already-parsed object: this
177
+ // is inherently lossy (re-serialization changes key order / whitespace)
178
+ // and can break raw-body signature checks. There is nothing left to
179
+ // recover the original bytes from here — the fix lives upstream, where
180
+ // raw_body is now always preserved.
173
181
  requestBody = JSON.stringify(request.body);
174
182
  }
175
183
  }
176
-
184
+
177
185
  // Create a standard Request object
178
186
  webRequest = new Request(url.toString(), {
179
187
  method: request.method,
@@ -1 +1 @@
1
- {"version":3,"file":"worker-template.js","sourceRoot":"","sources":["../src/worker-template.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,oDAAoD;AAEpD,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8R9B,CAAC"}
1
+ {"version":3,"file":"worker-template.js","sourceRoot":"","sources":["../src/worker-template.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,oDAAoD;AAEpD,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsS9B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maravilla-labs/adapter-sveltekit",
3
- "version": "2.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "SvelteKit adapter for Maravilla Runtime",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@sveltejs/kit": "^2.0.0",
30
- "@maravilla-labs/functions": "^0.10.0"
30
+ "@maravilla-labs/functions": "^0.11.0"
31
31
  },
32
32
  "peerDependenciesMeta": {
33
33
  "@maravilla-labs/functions": {
@@ -43,7 +43,7 @@
43
43
  "dependencies": {
44
44
  "esbuild": "^0.25.0",
45
45
  "set-cookie-parser": "^2.6.0",
46
- "@maravilla-labs/adapter-core": "^2.0.0"
46
+ "@maravilla-labs/adapter-core": "^3.0.0"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "tsc",