@workflow/sveltekit 4.0.0-beta.5 → 4.0.0-beta.50
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/builder.d.ts.map +1 -1
- package/dist/builder.js +50 -39
- package/dist/builder.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +14 -106
- package/dist/plugin.js.map +1 -1
- package/package.json +10 -9
package/dist/builder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,WAAW,EAEX,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAS5B,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;IAe9B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YA0DvB,eAAe;YAuCf,mBAAmB;YAuCnB,iBAAiB;YAqDjB,mBAAmB;CA8BlC"}
|
package/dist/builder.js
CHANGED
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
import { constants } from 'node:fs';
|
|
2
|
-
import { access, mkdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { access, copyFile, mkdir, readFile, stat, writeFile, } from 'node:fs/promises';
|
|
3
3
|
import { join, resolve } from 'node:path';
|
|
4
|
-
import { BaseBuilder } from '@workflow/builders';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
if (!['GET', 'HEAD', 'OPTIONS', 'TRACE', 'CONNECT'].includes(request.method)) {
|
|
13
|
-
options.body = await request.arrayBuffer();
|
|
14
|
-
}
|
|
15
|
-
return new Request(request.url, options);
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
4
|
+
import { BaseBuilder, NORMALIZE_REQUEST_CODE, } from '@workflow/builders';
|
|
5
|
+
const SVELTEKIT_VIRTUAL_MODULES = [
|
|
6
|
+
'$env/*', // All $env subpaths
|
|
7
|
+
'$lib', // Exact $lib import
|
|
8
|
+
'$lib/*', // All $lib subpaths
|
|
9
|
+
'$app/*', // All $app subpaths
|
|
10
|
+
];
|
|
18
11
|
export class SvelteKitBuilder extends BaseBuilder {
|
|
19
12
|
constructor(config) {
|
|
13
|
+
const workingDir = config?.workingDir || process.cwd();
|
|
20
14
|
super({
|
|
21
15
|
...config,
|
|
22
|
-
dirs: ['workflows'],
|
|
16
|
+
dirs: ['workflows', 'src/workflows', 'routes', 'src/routes'],
|
|
23
17
|
buildTarget: 'sveltekit',
|
|
24
18
|
stepsBundlePath: '', // unused in base
|
|
25
19
|
workflowsBundlePath: '', // unused in base
|
|
26
20
|
webhookBundlePath: '', // unused in base
|
|
27
|
-
workingDir
|
|
21
|
+
workingDir,
|
|
22
|
+
externalPackages: [...SVELTEKIT_VIRTUAL_MODULES],
|
|
28
23
|
});
|
|
29
24
|
}
|
|
30
25
|
async build() {
|
|
@@ -39,63 +34,82 @@ export class SvelteKitBuilder extends BaseBuilder {
|
|
|
39
34
|
}
|
|
40
35
|
// Get workflow and step files to bundle
|
|
41
36
|
const inputFiles = await this.getInputFiles();
|
|
42
|
-
const
|
|
37
|
+
const tsconfigPath = await this.findTsConfigPath();
|
|
43
38
|
const options = {
|
|
44
39
|
inputFiles,
|
|
45
40
|
workflowGeneratedDir,
|
|
46
|
-
|
|
47
|
-
tsPaths: tsConfig.paths,
|
|
41
|
+
tsconfigPath,
|
|
48
42
|
};
|
|
49
43
|
// Generate the three SvelteKit route handlers
|
|
50
|
-
await this.buildStepsRoute(options);
|
|
51
|
-
await this.buildWorkflowsRoute(options);
|
|
44
|
+
const stepsManifest = await this.buildStepsRoute(options);
|
|
45
|
+
const workflowsManifest = await this.buildWorkflowsRoute(options);
|
|
52
46
|
await this.buildWebhookRoute({ workflowGeneratedDir });
|
|
47
|
+
// Merge manifests from both bundles
|
|
48
|
+
const manifest = {
|
|
49
|
+
steps: { ...stepsManifest.steps, ...workflowsManifest.steps },
|
|
50
|
+
workflows: { ...stepsManifest.workflows, ...workflowsManifest.workflows },
|
|
51
|
+
classes: { ...stepsManifest.classes, ...workflowsManifest.classes },
|
|
52
|
+
};
|
|
53
|
+
// Generate unified manifest
|
|
54
|
+
const workflowBundlePath = join(workflowGeneratedDir, 'flow/+server.js');
|
|
55
|
+
const manifestJson = await this.createManifest({
|
|
56
|
+
workflowBundlePath,
|
|
57
|
+
manifestDir: workflowGeneratedDir,
|
|
58
|
+
manifest,
|
|
59
|
+
});
|
|
60
|
+
// Expose manifest as a static file when WORKFLOW_PUBLIC_MANIFEST=1.
|
|
61
|
+
// SvelteKit serves files from static/ at the root URL.
|
|
62
|
+
if (this.shouldExposePublicManifest && manifestJson) {
|
|
63
|
+
const staticManifestDir = join(this.config.workingDir, 'static/.well-known/workflow/v1');
|
|
64
|
+
await mkdir(staticManifestDir, { recursive: true });
|
|
65
|
+
await copyFile(join(workflowGeneratedDir, 'manifest.json'), join(staticManifestDir, 'manifest.json'));
|
|
66
|
+
}
|
|
53
67
|
}
|
|
54
|
-
async buildStepsRoute({ inputFiles, workflowGeneratedDir,
|
|
68
|
+
async buildStepsRoute({ inputFiles, workflowGeneratedDir, tsconfigPath, }) {
|
|
55
69
|
// Create steps route: .well-known/workflow/v1/step/+server.js
|
|
56
70
|
const stepsRouteDir = join(workflowGeneratedDir, 'step');
|
|
57
71
|
await mkdir(stepsRouteDir, { recursive: true });
|
|
58
|
-
await this.createStepsBundle({
|
|
72
|
+
const { manifest } = await this.createStepsBundle({
|
|
59
73
|
format: 'esm',
|
|
60
74
|
inputFiles,
|
|
61
75
|
outfile: join(stepsRouteDir, '+server.js'),
|
|
62
76
|
externalizeNonSteps: true,
|
|
63
|
-
|
|
64
|
-
tsPaths,
|
|
77
|
+
tsconfigPath,
|
|
65
78
|
});
|
|
66
79
|
// Post-process the generated file to wrap with SvelteKit request converter
|
|
67
80
|
const stepsRouteFile = join(stepsRouteDir, '+server.js');
|
|
68
81
|
let stepsRouteContent = await readFile(stepsRouteFile, 'utf-8');
|
|
69
82
|
// Replace the default export with SvelteKit-compatible handler
|
|
70
|
-
stepsRouteContent = stepsRouteContent.replace(/export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\}\s*;?$/m, `${
|
|
83
|
+
stepsRouteContent = stepsRouteContent.replace(/export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\}\s*;?$/m, `${NORMALIZE_REQUEST_CODE}
|
|
71
84
|
export const POST = async ({request}) => {
|
|
72
|
-
const normalRequest = await
|
|
85
|
+
const normalRequest = await normalizeRequest(request);
|
|
73
86
|
return stepEntrypoint(normalRequest);
|
|
74
87
|
}`);
|
|
75
88
|
await writeFile(stepsRouteFile, stepsRouteContent);
|
|
89
|
+
return manifest;
|
|
76
90
|
}
|
|
77
|
-
async buildWorkflowsRoute({ inputFiles, workflowGeneratedDir,
|
|
91
|
+
async buildWorkflowsRoute({ inputFiles, workflowGeneratedDir, tsconfigPath, }) {
|
|
78
92
|
// Create workflows route: .well-known/workflow/v1/flow/+server.js
|
|
79
93
|
const workflowsRouteDir = join(workflowGeneratedDir, 'flow');
|
|
80
94
|
await mkdir(workflowsRouteDir, { recursive: true });
|
|
81
|
-
await this.createWorkflowsBundle({
|
|
95
|
+
const { manifest } = await this.createWorkflowsBundle({
|
|
82
96
|
format: 'esm',
|
|
83
97
|
outfile: join(workflowsRouteDir, '+server.js'),
|
|
84
98
|
bundleFinalOutput: false,
|
|
85
99
|
inputFiles,
|
|
86
|
-
|
|
87
|
-
tsPaths,
|
|
100
|
+
tsconfigPath,
|
|
88
101
|
});
|
|
89
102
|
// Post-process the generated file to wrap with SvelteKit request converter
|
|
90
103
|
const workflowsRouteFile = join(workflowsRouteDir, '+server.js');
|
|
91
104
|
let workflowsRouteContent = await readFile(workflowsRouteFile, 'utf-8');
|
|
92
105
|
// Replace the default export with SvelteKit-compatible handler
|
|
93
|
-
workflowsRouteContent = workflowsRouteContent.replace(/export const POST = workflowEntrypoint\(workflowCode\);?$/m, `${
|
|
106
|
+
workflowsRouteContent = workflowsRouteContent.replace(/export const POST = workflowEntrypoint\(workflowCode\);?$/m, `${NORMALIZE_REQUEST_CODE}
|
|
94
107
|
export const POST = async ({request}) => {
|
|
95
|
-
const normalRequest = await
|
|
108
|
+
const normalRequest = await normalizeRequest(request);
|
|
96
109
|
return workflowEntrypoint(workflowCode)(normalRequest);
|
|
97
110
|
}`);
|
|
98
111
|
await writeFile(workflowsRouteFile, workflowsRouteContent);
|
|
112
|
+
return manifest;
|
|
99
113
|
}
|
|
100
114
|
async buildWebhookRoute({ workflowGeneratedDir, }) {
|
|
101
115
|
// Create webhook route: .well-known/workflow/v1/webhook/[token]/+server.js
|
|
@@ -106,17 +120,14 @@ export const POST = async ({request}) => {
|
|
|
106
120
|
});
|
|
107
121
|
// Post-process the generated file to wrap with SvelteKit request converter
|
|
108
122
|
let webhookRouteContent = await readFile(webhookRouteFile, 'utf-8');
|
|
109
|
-
// NOTE: This is a workaround to avoid crashing in local dev when context isn't set for waitUntil()
|
|
110
|
-
webhookRouteContent = `process.on('unhandledRejection', (reason) => { if (reason !== undefined) console.error('Unhandled rejection detected', reason); });
|
|
111
|
-
${webhookRouteContent}`;
|
|
112
123
|
// Update handler signature to accept token as parameter
|
|
113
124
|
webhookRouteContent = webhookRouteContent.replace(/async function handler\(request\) \{[\s\S]*?const token = decodeURIComponent\(pathParts\[pathParts\.length - 1\]\);/, `async function handler(request, token) {`);
|
|
114
125
|
// Remove the URL parsing code since we get token from params
|
|
115
126
|
webhookRouteContent = webhookRouteContent.replace(/const url = new URL\(request\.url\);[\s\S]*?const pathParts = url\.pathname\.split\('\/'\);[\s\S]*?\n/, '');
|
|
116
127
|
// Replace all HTTP method exports with SvelteKit-compatible handlers
|
|
117
|
-
webhookRouteContent = webhookRouteContent.replace(/export const GET = handler;\nexport const POST = handler;\nexport const PUT = handler;\nexport const PATCH = handler;\nexport const DELETE = handler;\nexport const HEAD = handler;\nexport const OPTIONS = handler;/, `${
|
|
128
|
+
webhookRouteContent = webhookRouteContent.replace(/export const GET = handler;\nexport const POST = handler;\nexport const PUT = handler;\nexport const PATCH = handler;\nexport const DELETE = handler;\nexport const HEAD = handler;\nexport const OPTIONS = handler;/, `${NORMALIZE_REQUEST_CODE}
|
|
118
129
|
const createSvelteKitHandler = (method) => async ({ request, params, platform }) => {
|
|
119
|
-
const normalRequest = await
|
|
130
|
+
const normalRequest = await normalizeRequest(request);
|
|
120
131
|
const response = await handler(normalRequest, params.token);
|
|
121
132
|
return response;
|
|
122
133
|
};
|
package/dist/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,MAAM,EACN,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,WAAW,EACX,sBAAsB,GAEvB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,yBAAyB,GAAG;IAChC,QAAQ,EAAE,oBAAoB;IAC9B,MAAM,EAAE,oBAAoB;IAC5B,QAAQ,EAAE,oBAAoB;IAC9B,QAAQ,EAAE,oBAAoB;CAC/B,CAAC;AAEF,MAAM,OAAO,gBAAiB,SAAQ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AAC;YACH,MAAM,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;YACxC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC;YAC1C,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,uCAAuC,SAAS,EAAE,CAAC,CAAC;YACtE,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,yBAAyB;YACzB,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;gBAC5C,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC;gBAClD,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,EAAE,CAAC;oBACnC,MAAM,IAAI,KAAK,CACb,uCAAuC,aAAa,EAAE,CACvD,CAAC;gBACJ,CAAC;gBACD,OAAO,aAAa,CAAC;YACvB,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,IAAI,KAAK,CACb,+FAA+F,CAChG,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ process.on('beforeExit', () => {
|
|
|
17
17
|
config: {
|
|
18
18
|
experimentalTriggers: [
|
|
19
19
|
{
|
|
20
|
-
type: 'queue/
|
|
20
|
+
type: 'queue/v2beta',
|
|
21
21
|
topic: '__wkf_workflow_*',
|
|
22
22
|
consumer: 'default',
|
|
23
23
|
maxDeliveries: 64,
|
|
@@ -32,7 +32,7 @@ process.on('beforeExit', () => {
|
|
|
32
32
|
config: {
|
|
33
33
|
experimentalTriggers: [
|
|
34
34
|
{
|
|
35
|
-
type: 'queue/
|
|
35
|
+
type: 'queue/v2beta',
|
|
36
36
|
topic: '__wkf_step_*',
|
|
37
37
|
consumer: 'default',
|
|
38
38
|
maxDeliveries: 64,
|
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAczC"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,111 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { createBuildQueue } from '@workflow/builders';
|
|
2
|
+
import { workflowTransformPlugin } from '@workflow/rollup';
|
|
3
|
+
import { workflowHotUpdatePlugin } from '@workflow/vite';
|
|
4
4
|
import { SvelteKitBuilder } from './builder.js';
|
|
5
5
|
export function workflowPlugin() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// Only apply the transform if file needs it
|
|
13
|
-
if (!code.match(/(use step|use workflow)/)) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
const isTypeScript = id.endsWith('.ts') || id.endsWith('.tsx');
|
|
17
|
-
const isTsx = id.endsWith('.tsx');
|
|
18
|
-
const swcPlugin = resolveModulePath('@workflow/swc-plugin', {
|
|
19
|
-
from: [import.meta.url],
|
|
20
|
-
});
|
|
21
|
-
// Calculate relative filename for SWC plugin
|
|
22
|
-
// The SWC plugin uses filename to generate workflowId, so it must be relative
|
|
23
|
-
const workingDir = process.cwd();
|
|
24
|
-
const normalizedWorkingDir = workingDir
|
|
25
|
-
.replace(/\\/g, '/')
|
|
26
|
-
.replace(/\/$/, '');
|
|
27
|
-
const normalizedFilepath = id.replace(/\\/g, '/');
|
|
28
|
-
// Windows fix: Use case-insensitive comparison to work around drive letter casing issues
|
|
29
|
-
const lowerWd = normalizedWorkingDir.toLowerCase();
|
|
30
|
-
const lowerPath = normalizedFilepath.toLowerCase();
|
|
31
|
-
let relativeFilename;
|
|
32
|
-
if (lowerPath.startsWith(lowerWd + '/')) {
|
|
33
|
-
// File is under working directory - manually calculate relative path
|
|
34
|
-
relativeFilename = normalizedFilepath.substring(normalizedWorkingDir.length + 1);
|
|
35
|
-
}
|
|
36
|
-
else if (lowerPath === lowerWd) {
|
|
37
|
-
// File IS the working directory (shouldn't happen)
|
|
38
|
-
relativeFilename = '.';
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// Use relative() for files outside working directory
|
|
42
|
-
relativeFilename = relative(workingDir, id).replace(/\\/g, '/');
|
|
43
|
-
if (relativeFilename.startsWith('../')) {
|
|
44
|
-
relativeFilename = relativeFilename
|
|
45
|
-
.split('/')
|
|
46
|
-
.filter((part) => part !== '..')
|
|
47
|
-
.join('/');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// Final safety check - ensure we never pass an absolute path to SWC
|
|
51
|
-
if (relativeFilename.includes(':') || relativeFilename.startsWith('/')) {
|
|
52
|
-
// This should rarely happen, but use filename split as last resort
|
|
53
|
-
relativeFilename = normalizedFilepath.split('/').pop() || 'unknown.ts';
|
|
54
|
-
}
|
|
55
|
-
// Transform with SWC
|
|
56
|
-
const result = await transform(code, {
|
|
57
|
-
filename: relativeFilename,
|
|
58
|
-
jsc: {
|
|
59
|
-
parser: {
|
|
60
|
-
syntax: isTypeScript ? 'typescript' : 'ecmascript',
|
|
61
|
-
tsx: isTsx,
|
|
62
|
-
},
|
|
63
|
-
target: 'es2022',
|
|
64
|
-
experimental: {
|
|
65
|
-
plugins: [[swcPlugin, { mode: 'client' }]],
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
minify: false,
|
|
69
|
-
sourceMaps: true,
|
|
70
|
-
inlineSourcesContent: true,
|
|
71
|
-
});
|
|
72
|
-
return {
|
|
73
|
-
code: result.code,
|
|
74
|
-
map: result.map ? JSON.parse(result.map) : null,
|
|
75
|
-
};
|
|
6
|
+
const builder = new SvelteKitBuilder();
|
|
7
|
+
const enqueue = createBuildQueue();
|
|
8
|
+
return [
|
|
9
|
+
workflowTransformPlugin(),
|
|
10
|
+
{
|
|
11
|
+
name: 'workflow:sveltekit',
|
|
76
12
|
},
|
|
77
|
-
|
|
78
|
-
builder
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
// TODO: Move this to @workflow/vite or something since this is vite specific
|
|
84
|
-
async handleHotUpdate(ctx) {
|
|
85
|
-
const { file, server, read } = ctx;
|
|
86
|
-
// Check if this is a TS/JS file that might contain workflow directives
|
|
87
|
-
const jsTsRegex = /\.(ts|tsx|js|jsx|mjs|cjs)$/;
|
|
88
|
-
if (!jsTsRegex.test(file)) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
// Read the file to check for workflow/step directives
|
|
92
|
-
const content = await read();
|
|
93
|
-
const useWorkflowPattern = /^\s*(['"])use workflow\1;?\s*$/m;
|
|
94
|
-
const useStepPattern = /^\s*(['"])use step\1;?\s*$/m;
|
|
95
|
-
if (!useWorkflowPattern.test(content) && !useStepPattern.test(content)) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
// Rebuild everything - simpler and more reliable than tracking individual files
|
|
99
|
-
console.log('Workflow file changed, regenerating routes...');
|
|
100
|
-
await builder.build();
|
|
101
|
-
// Trigger full reload of workflow routes
|
|
102
|
-
server.ws.send({
|
|
103
|
-
type: 'full-reload',
|
|
104
|
-
path: '*',
|
|
105
|
-
});
|
|
106
|
-
// Let Vite handle the normal HMR for the changed file
|
|
107
|
-
return;
|
|
108
|
-
},
|
|
109
|
-
};
|
|
13
|
+
workflowHotUpdatePlugin({
|
|
14
|
+
builder,
|
|
15
|
+
enqueue,
|
|
16
|
+
}),
|
|
17
|
+
];
|
|
110
18
|
}
|
|
111
19
|
//# sourceMappingURL=plugin.js.map
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,IAAI,gBAAgB,EAAE,CAAC;IACvC,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IAEnC,OAAO;QACL,uBAAuB,EAAY;QACnC;YACE,IAAI,EAAE,oBAAoB;SAC3B;QACD,uBAAuB,CAAC;YACtB,OAAO;YACP,OAAO;SACR,CAAC;KACH,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workflow/sveltekit",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.50",
|
|
4
4
|
"description": "SvelteKit integration for Workflow DevKit",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"license": "
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "https://github.com/vercel/workflow.git",
|
|
@@ -20,18 +20,19 @@
|
|
|
20
20
|
".": "./dist/index.js"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@swc/core": "1.
|
|
24
|
-
"@sveltejs/kit": "^2.48.2",
|
|
25
|
-
"fs-extra": "^11.3.2",
|
|
23
|
+
"@swc/core": "1.15.3",
|
|
26
24
|
"exsolve": "^1.0.7",
|
|
25
|
+
"fs-extra": "^11.3.2",
|
|
27
26
|
"pathe": "^2.0.3",
|
|
28
|
-
"@workflow/builders": "4.0.1-beta.
|
|
29
|
-
"@workflow/
|
|
27
|
+
"@workflow/builders": "4.0.1-beta.52",
|
|
28
|
+
"@workflow/rollup": "4.0.0-beta.18",
|
|
29
|
+
"@workflow/swc-plugin": "4.1.0-beta.18",
|
|
30
|
+
"@workflow/vite": "4.0.0-beta.11"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@types/fs-extra": "
|
|
33
|
+
"@types/fs-extra": "11.0.4",
|
|
33
34
|
"@types/node": "22.19.0",
|
|
34
|
-
"vite": "
|
|
35
|
+
"vite": "7.1.12",
|
|
35
36
|
"@workflow/tsconfig": "4.0.1-beta.0"
|
|
36
37
|
},
|
|
37
38
|
"scripts": {
|