@maravilla-labs/adapter-sveltekit 0.8.3 → 1.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.
- package/LICENSE +12 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/merge-functions.d.ts +5 -0
- package/dist/merge-functions.d.ts.map +1 -0
- package/dist/worker-template.d.ts +2 -0
- package/dist/worker-template.d.ts.map +1 -0
- package/dist/worker-template.js.map +1 -0
- package/package.json +11 -19
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Proprietary License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 SOLUTAS GmbH, Switzerland. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation (the "Software") are the confidential and proprietary information of SOLUTAS GmbH ("SOLUTAS"). By using, copying, or accessing the Software, you agree that:
|
|
6
|
+
|
|
7
|
+
- No rights are granted except as expressly set forth in a separate written agreement with SOLUTAS.
|
|
8
|
+
- You may not copy, modify, distribute, sublicense, reverse engineer, or create derivative works of the Software except as permitted in such agreement.
|
|
9
|
+
- The Software is provided "as is" without warranty of any kind; SOLUTAS disclaims all implied warranties to the maximum extent permitted by law.
|
|
10
|
+
- In no event shall SOLUTAS be liable for any damages arising from use of the Software except as expressly provided in an applicable agreement.
|
|
11
|
+
|
|
12
|
+
For licensing inquiries, contact: legal@solutas.ch
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { writeFileSync } from 'node:fs';
|
|
2
|
-
import { bundleServerEntry, analyzeBundle, generateManifest, writeManifest, collectAssets, buildAndIntegrateFunctions, buildAndIntegrateEvents, buildAndIntegrateWorkflows, loadMaravillaConfig, } from '@maravilla-labs/adapter-core';
|
|
2
|
+
import { bundleServerEntry, analyzeBundle, generateManifest, writeManifest, collectAssets, buildAndIntegrateFunctions, buildAndIntegrateEvents, buildAndIntegrateWorkflows, buildAndIntegrateMcp, loadMaravillaConfig, } from '@maravilla-labs/adapter-core';
|
|
3
3
|
// Import the worker template from separate file for maintainability
|
|
4
4
|
import { WORKER_TEMPLATE } from './worker-template.js';
|
|
5
5
|
export default function adapter(options = {}) {
|
|
@@ -91,6 +91,8 @@ 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
96
|
builder.log.minor(`Build complete. Output written to ${out}`);
|
|
95
97
|
builder.log.minor('');
|
|
96
98
|
builder.log.minor('Deploy: push to a branch listed in .maravilla/pipeline/*.yml');
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,0BAA0B,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C;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-functions.d.ts","sourceRoot":"","sources":["../src/merge-functions.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAmBrD"}
|
|
@@ -0,0 +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";
|
|
2
|
+
//# sourceMappingURL=worker-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-template.d.ts","sourceRoot":"","sources":["../src/worker-template.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,urUA8R3B,CAAC"}
|
|
@@ -0,0 +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"}
|
package/package.json
CHANGED
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maravilla-labs/adapter-sveltekit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "SvelteKit adapter for Maravilla Runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
|
-
"dist
|
|
10
|
-
"dist/index.js.map",
|
|
11
|
-
"dist/index.d.ts",
|
|
12
|
-
"dist/index.d.ts.map",
|
|
13
|
-
"dist/merge-functions.js",
|
|
14
|
-
"dist/merge-functions.js.map",
|
|
15
|
-
"dist/worker.js",
|
|
16
|
-
"worker-template.js"
|
|
9
|
+
"dist"
|
|
17
10
|
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "tsc",
|
|
20
|
-
"dev": "tsc --watch",
|
|
21
|
-
"test": "vitest",
|
|
22
|
-
"prepublishOnly": "npm run build"
|
|
23
|
-
},
|
|
24
11
|
"keywords": [
|
|
25
12
|
"sveltekit",
|
|
26
13
|
"adapter",
|
|
@@ -40,7 +27,7 @@
|
|
|
40
27
|
},
|
|
41
28
|
"peerDependencies": {
|
|
42
29
|
"@sveltejs/kit": "^2.0.0",
|
|
43
|
-
"@maravilla-labs/functions": "^0.
|
|
30
|
+
"@maravilla-labs/functions": "^0.9.0"
|
|
44
31
|
},
|
|
45
32
|
"peerDependenciesMeta": {
|
|
46
33
|
"@maravilla-labs/functions": {
|
|
@@ -54,8 +41,13 @@
|
|
|
54
41
|
"vitest": "^1.0.0"
|
|
55
42
|
},
|
|
56
43
|
"dependencies": {
|
|
57
|
-
"@maravilla-labs/adapter-core": "^0.8.3",
|
|
58
44
|
"esbuild": "^0.25.0",
|
|
59
|
-
"set-cookie-parser": "^2.6.0"
|
|
45
|
+
"set-cookie-parser": "^2.6.0",
|
|
46
|
+
"@maravilla-labs/adapter-core": "^1.0.0"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsc",
|
|
50
|
+
"dev": "tsc --watch",
|
|
51
|
+
"test": "vitest"
|
|
60
52
|
}
|
|
61
|
-
}
|
|
53
|
+
}
|