@workflow/sveltekit 4.0.0-beta.9 → 5.0.0-beta.0
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 +47 -35
- package/dist/builder.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +14 -127
- package/dist/plugin.js.map +1 -1
- package/package.json +10 -8
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,20 +1,13 @@
|
|
|
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) {
|
|
20
13
|
const workingDir = config?.workingDir || process.cwd();
|
|
@@ -26,6 +19,7 @@ export class SvelteKitBuilder extends BaseBuilder {
|
|
|
26
19
|
workflowsBundlePath: '', // unused in base
|
|
27
20
|
webhookBundlePath: '', // unused in base
|
|
28
21
|
workingDir,
|
|
22
|
+
externalPackages: [...SVELTEKIT_VIRTUAL_MODULES],
|
|
29
23
|
});
|
|
30
24
|
}
|
|
31
25
|
async build() {
|
|
@@ -40,63 +34,82 @@ export class SvelteKitBuilder extends BaseBuilder {
|
|
|
40
34
|
}
|
|
41
35
|
// Get workflow and step files to bundle
|
|
42
36
|
const inputFiles = await this.getInputFiles();
|
|
43
|
-
const
|
|
37
|
+
const tsconfigPath = await this.findTsConfigPath();
|
|
44
38
|
const options = {
|
|
45
39
|
inputFiles,
|
|
46
40
|
workflowGeneratedDir,
|
|
47
|
-
|
|
48
|
-
tsPaths: tsConfig.paths,
|
|
41
|
+
tsconfigPath,
|
|
49
42
|
};
|
|
50
43
|
// Generate the three SvelteKit route handlers
|
|
51
|
-
await this.buildStepsRoute(options);
|
|
52
|
-
await this.buildWorkflowsRoute(options);
|
|
44
|
+
const stepsManifest = await this.buildStepsRoute(options);
|
|
45
|
+
const workflowsManifest = await this.buildWorkflowsRoute(options);
|
|
53
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
|
+
}
|
|
54
67
|
}
|
|
55
|
-
async buildStepsRoute({ inputFiles, workflowGeneratedDir,
|
|
68
|
+
async buildStepsRoute({ inputFiles, workflowGeneratedDir, tsconfigPath, }) {
|
|
56
69
|
// Create steps route: .well-known/workflow/v1/step/+server.js
|
|
57
70
|
const stepsRouteDir = join(workflowGeneratedDir, 'step');
|
|
58
71
|
await mkdir(stepsRouteDir, { recursive: true });
|
|
59
|
-
await this.createStepsBundle({
|
|
72
|
+
const { manifest } = await this.createStepsBundle({
|
|
60
73
|
format: 'esm',
|
|
61
74
|
inputFiles,
|
|
62
75
|
outfile: join(stepsRouteDir, '+server.js'),
|
|
63
76
|
externalizeNonSteps: true,
|
|
64
|
-
|
|
65
|
-
tsPaths,
|
|
77
|
+
tsconfigPath,
|
|
66
78
|
});
|
|
67
79
|
// Post-process the generated file to wrap with SvelteKit request converter
|
|
68
80
|
const stepsRouteFile = join(stepsRouteDir, '+server.js');
|
|
69
81
|
let stepsRouteContent = await readFile(stepsRouteFile, 'utf-8');
|
|
70
82
|
// Replace the default export with SvelteKit-compatible handler
|
|
71
|
-
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}
|
|
72
84
|
export const POST = async ({request}) => {
|
|
73
|
-
const normalRequest = await
|
|
85
|
+
const normalRequest = await normalizeRequest(request);
|
|
74
86
|
return stepEntrypoint(normalRequest);
|
|
75
87
|
}`);
|
|
76
88
|
await writeFile(stepsRouteFile, stepsRouteContent);
|
|
89
|
+
return manifest;
|
|
77
90
|
}
|
|
78
|
-
async buildWorkflowsRoute({ inputFiles, workflowGeneratedDir,
|
|
91
|
+
async buildWorkflowsRoute({ inputFiles, workflowGeneratedDir, tsconfigPath, }) {
|
|
79
92
|
// Create workflows route: .well-known/workflow/v1/flow/+server.js
|
|
80
93
|
const workflowsRouteDir = join(workflowGeneratedDir, 'flow');
|
|
81
94
|
await mkdir(workflowsRouteDir, { recursive: true });
|
|
82
|
-
await this.createWorkflowsBundle({
|
|
95
|
+
const { manifest } = await this.createWorkflowsBundle({
|
|
83
96
|
format: 'esm',
|
|
84
97
|
outfile: join(workflowsRouteDir, '+server.js'),
|
|
85
98
|
bundleFinalOutput: false,
|
|
86
99
|
inputFiles,
|
|
87
|
-
|
|
88
|
-
tsPaths,
|
|
100
|
+
tsconfigPath,
|
|
89
101
|
});
|
|
90
102
|
// Post-process the generated file to wrap with SvelteKit request converter
|
|
91
103
|
const workflowsRouteFile = join(workflowsRouteDir, '+server.js');
|
|
92
104
|
let workflowsRouteContent = await readFile(workflowsRouteFile, 'utf-8');
|
|
93
105
|
// Replace the default export with SvelteKit-compatible handler
|
|
94
|
-
workflowsRouteContent = workflowsRouteContent.replace(/export const POST = workflowEntrypoint\(workflowCode\);?$/m, `${
|
|
106
|
+
workflowsRouteContent = workflowsRouteContent.replace(/export const POST = workflowEntrypoint\(workflowCode\);?$/m, `${NORMALIZE_REQUEST_CODE}
|
|
95
107
|
export const POST = async ({request}) => {
|
|
96
|
-
const normalRequest = await
|
|
108
|
+
const normalRequest = await normalizeRequest(request);
|
|
97
109
|
return workflowEntrypoint(workflowCode)(normalRequest);
|
|
98
110
|
}`);
|
|
99
111
|
await writeFile(workflowsRouteFile, workflowsRouteContent);
|
|
112
|
+
return manifest;
|
|
100
113
|
}
|
|
101
114
|
async buildWebhookRoute({ workflowGeneratedDir, }) {
|
|
102
115
|
// Create webhook route: .well-known/workflow/v1/webhook/[token]/+server.js
|
|
@@ -104,7 +117,6 @@ export const POST = async ({request}) => {
|
|
|
104
117
|
await this.createWebhookBundle({
|
|
105
118
|
outfile: webhookRouteFile,
|
|
106
119
|
bundle: false, // SvelteKit will handle bundling
|
|
107
|
-
suppressUndefinedRejections: true,
|
|
108
120
|
});
|
|
109
121
|
// Post-process the generated file to wrap with SvelteKit request converter
|
|
110
122
|
let webhookRouteContent = await readFile(webhookRouteFile, 'utf-8');
|
|
@@ -113,9 +125,9 @@ export const POST = async ({request}) => {
|
|
|
113
125
|
// Remove the URL parsing code since we get token from params
|
|
114
126
|
webhookRouteContent = webhookRouteContent.replace(/const url = new URL\(request\.url\);[\s\S]*?const pathParts = url\.pathname\.split\('\/'\);[\s\S]*?\n/, '');
|
|
115
127
|
// Replace all HTTP method exports with SvelteKit-compatible handlers
|
|
116
|
-
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}
|
|
117
129
|
const createSvelteKitHandler = (method) => async ({ request, params, platform }) => {
|
|
118
|
-
const normalRequest = await
|
|
130
|
+
const normalRequest = await normalizeRequest(request);
|
|
119
131
|
const response = await handler(normalRequest, params.token);
|
|
120
132
|
return response;
|
|
121
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,WAAW;IAC/C,YAAY,MAAiC;QAC3C,MAAM,UAAU,GAAG,MAAM,EAAE,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAEvD,KAAK,CAAC;YACJ,GAAG,MAAM;YACT,IAAI,EAAE,CAAC,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,CAAC;YAC5D,WAAW,EAAE,WAAoB;YACjC,eAAe,EAAE,EAAE,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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
|
@@ -15,12 +15,12 @@ process.on('beforeExit', () => {
|
|
|
15
15
|
{
|
|
16
16
|
file: '.vercel/output/functions/.well-known/workflow/v1/flow.func/.vc-config.json',
|
|
17
17
|
config: {
|
|
18
|
+
maxDuration: 'max',
|
|
18
19
|
experimentalTriggers: [
|
|
19
20
|
{
|
|
20
|
-
type: 'queue/
|
|
21
|
+
type: 'queue/v2beta',
|
|
21
22
|
topic: '__wkf_workflow_*',
|
|
22
23
|
consumer: 'default',
|
|
23
|
-
maxDeliveries: 64,
|
|
24
24
|
retryAfterSeconds: 5,
|
|
25
25
|
initialDelaySeconds: 0,
|
|
26
26
|
},
|
|
@@ -30,12 +30,12 @@ process.on('beforeExit', () => {
|
|
|
30
30
|
{
|
|
31
31
|
file: '.vercel/output/functions/.well-known/workflow/v1/step.func/.vc-config.json',
|
|
32
32
|
config: {
|
|
33
|
+
maxDuration: 'max',
|
|
33
34
|
experimentalTriggers: [
|
|
34
35
|
{
|
|
35
|
-
type: 'queue/
|
|
36
|
+
type: 'queue/v2beta',
|
|
36
37
|
topic: '__wkf_step_*',
|
|
37
38
|
consumer: 'default',
|
|
38
|
-
maxDeliveries: 64,
|
|
39
39
|
retryAfterSeconds: 5,
|
|
40
40
|
initialDelaySeconds: 0,
|
|
41
41
|
},
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,OAAO,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAEvC,+DAA+D;AAC/D,6DAA6D;AAC7D,uDAAuD;AACvD,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;AAEtB,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;IAC5B,wDAAwD;IACxD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,CAAC;QACtC,OAAO;IACT,CAAC;IACD,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI;QAC7B;YACE,IAAI,EAAE,4EAA4E;YAClF,MAAM,EAAE;gBACN,oBAAoB,EAAE;oBACpB;wBACE,IAAI,EAAE,cAAc;wBACpB,KAAK,EAAE,kBAAkB;wBACzB,QAAQ,EAAE,SAAS;wBACnB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,OAAO,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAEvC,+DAA+D;AAC/D,6DAA6D;AAC7D,uDAAuD;AACvD,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;AAEtB,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;IAC5B,wDAAwD;IACxD,IA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C,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CACpC,CAAC;QACJ,CAAC;QAED,mEAAmE;QACnE,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QACjE,EAAE,CAAC,aAAa,CACd,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC;YACb,GAAG,cAAc;YACjB,GAAG,MAAM;SACV,CAAC,CACH,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
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,132 +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
|
-
const { file, server, read } = options;
|
|
83
|
-
// Check if this is a TS/JS file that might contain workflow directives
|
|
84
|
-
const jsTsRegex = /\.(ts|tsx|js|jsx|mjs|cjs)$/;
|
|
85
|
-
if (!jsTsRegex.test(file)) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
// Read the file to check for workflow/step directives
|
|
89
|
-
let content;
|
|
90
|
-
try {
|
|
91
|
-
content = await read();
|
|
92
|
-
}
|
|
93
|
-
catch {
|
|
94
|
-
// File might have been deleted - trigger rebuild to update generated routes
|
|
95
|
-
console.log('Workflow file deleted, regenerating routes...');
|
|
96
|
-
try {
|
|
97
|
-
await builder.build();
|
|
98
|
-
}
|
|
99
|
-
catch (buildError) {
|
|
100
|
-
// Build might fail if files are being deleted during test cleanup
|
|
101
|
-
// Log but don't crash - the next successful change will trigger a rebuild
|
|
102
|
-
console.error('Build failed during file deletion:', buildError);
|
|
103
|
-
}
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
const useWorkflowPattern = /^\s*(['"])use workflow\1;?\s*$/m;
|
|
107
|
-
const useStepPattern = /^\s*(['"])use step\1;?\s*$/m;
|
|
108
|
-
if (!useWorkflowPattern.test(content) && !useStepPattern.test(content)) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
// Rebuild everything - simpler and more reliable than tracking individual files
|
|
112
|
-
console.log('Workflow file changed, regenerating routes...');
|
|
113
|
-
try {
|
|
114
|
-
await builder.build();
|
|
115
|
-
}
|
|
116
|
-
catch (buildError) {
|
|
117
|
-
// Build might fail if files are being modified/deleted during test cleanup
|
|
118
|
-
// Log but don't crash - the next successful change will trigger a rebuild
|
|
119
|
-
console.error('Build failed during HMR:', buildError);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
// Trigger full reload of workflow routes
|
|
123
|
-
server.ws.send({
|
|
124
|
-
type: 'full-reload',
|
|
125
|
-
path: '*',
|
|
126
|
-
});
|
|
127
|
-
// Let Vite handle the normal HMR for the changed file
|
|
128
|
-
return;
|
|
129
|
-
},
|
|
130
|
-
};
|
|
13
|
+
workflowHotUpdatePlugin({
|
|
14
|
+
builder,
|
|
15
|
+
enqueue,
|
|
16
|
+
}),
|
|
17
|
+
];
|
|
131
18
|
}
|
|
132
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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workflow/sveltekit",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "SvelteKit integration for Workflow
|
|
3
|
+
"version": "5.0.0-beta.0",
|
|
4
|
+
"description": "SvelteKit integration for Workflow SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"files": [
|
|
@@ -20,18 +20,20 @@
|
|
|
20
20
|
".": "./dist/index.js"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@swc/core": "1.
|
|
23
|
+
"@swc/core": "1.15.3",
|
|
24
|
+
"exsolve": "^1.0.8",
|
|
24
25
|
"fs-extra": "^11.3.2",
|
|
25
|
-
"exsolve": "^1.0.7",
|
|
26
26
|
"pathe": "^2.0.3",
|
|
27
|
-
"@workflow/
|
|
28
|
-
"@workflow/
|
|
27
|
+
"@workflow/builders": "5.0.0-beta.0",
|
|
28
|
+
"@workflow/rollup": "5.0.0-beta.0",
|
|
29
|
+
"@workflow/swc-plugin": "5.0.0-beta.0",
|
|
30
|
+
"@workflow/vite": "5.0.0-beta.0"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
33
|
"@types/fs-extra": "11.0.4",
|
|
32
34
|
"@types/node": "22.19.0",
|
|
33
|
-
"vite": "7.1.
|
|
34
|
-
"@workflow/tsconfig": "
|
|
35
|
+
"vite": "7.1.12",
|
|
36
|
+
"@workflow/tsconfig": "5.0.0-beta.0"
|
|
35
37
|
},
|
|
36
38
|
"scripts": {
|
|
37
39
|
"build": "tsc",
|