@ekairos/story 1.21.39-beta.0 → 1.21.41-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/next.d.ts +4 -2
- package/dist/next.js +78 -21
- package/package.json +2 -2
package/dist/next.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type NextConfigLike = {
|
|
2
|
-
webpack?: (config: any, options: any) => any;
|
|
2
|
+
webpack?: ((config: any, options: any) => any) | null;
|
|
3
|
+
turbopack?: any;
|
|
3
4
|
};
|
|
4
5
|
type WithEkairosRuntimeOptions = {
|
|
5
6
|
/**
|
|
@@ -10,6 +11,7 @@ type WithEkairosRuntimeOptions = {
|
|
|
10
11
|
*/
|
|
11
12
|
bootstrapModule: string;
|
|
12
13
|
};
|
|
14
|
+
type NextConfigFnLike = (phase: string, ctx: any) => Promise<any> | any;
|
|
13
15
|
/**
|
|
14
16
|
* Next.js helper to ensure the story runtime factory is registered in *every* server bundle.
|
|
15
17
|
*
|
|
@@ -18,5 +20,5 @@ type WithEkairosRuntimeOptions = {
|
|
|
18
20
|
* - No "magic" root bootstrap file
|
|
19
21
|
* - Works for step runtimes because the server entry will always evaluate your bootstrap module
|
|
20
22
|
*/
|
|
21
|
-
export declare function withEkairosRuntime(
|
|
23
|
+
export declare function withEkairosRuntime(nextConfigOrFn: NextConfigLike | NextConfigFnLike, opts: WithEkairosRuntimeOptions): any;
|
|
22
24
|
export {};
|
package/dist/next.js
CHANGED
|
@@ -1,4 +1,42 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, relative, resolve } from "node:path";
|
|
4
|
+
function patchWorkflowStepRouteToImportBootstrap(bootstrapModule) {
|
|
5
|
+
const cwd = process.cwd();
|
|
6
|
+
const candidates = [
|
|
7
|
+
resolve(cwd, "app/.well-known/workflow/v1/step/route.js"),
|
|
8
|
+
resolve(cwd, "src/app/.well-known/workflow/v1/step/route.js"),
|
|
9
|
+
];
|
|
10
|
+
const bootstrapAbs = resolve(cwd, bootstrapModule);
|
|
11
|
+
for (const routeFile of candidates) {
|
|
12
|
+
let contents;
|
|
13
|
+
try {
|
|
14
|
+
contents = readFileSync(routeFile, "utf8");
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const routeDir = dirname(routeFile);
|
|
20
|
+
let spec = relative(routeDir, bootstrapAbs).replace(/\\/g, "/");
|
|
21
|
+
if (!spec.startsWith("."))
|
|
22
|
+
spec = `./${spec}`;
|
|
23
|
+
const importLine = `import "${spec}";`;
|
|
24
|
+
if (contents.includes(importLine))
|
|
25
|
+
continue;
|
|
26
|
+
const lines = contents.split(/\r?\n/);
|
|
27
|
+
let insertAt = 0;
|
|
28
|
+
for (let i = 0; i < lines.length; i++) {
|
|
29
|
+
const t = lines[i].trim();
|
|
30
|
+
const isComment = t.startsWith("//") || t.startsWith("/*") || t.startsWith("*") || t.startsWith("*/");
|
|
31
|
+
if (t === "" || isComment)
|
|
32
|
+
continue;
|
|
33
|
+
insertAt = i;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
lines.splice(insertAt, 0, importLine);
|
|
37
|
+
writeFileSync(routeFile, lines.join("\n"));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
2
40
|
function injectBootstrapIntoEntries(entries, bootstrap) {
|
|
3
41
|
for (const key of Object.keys(entries)) {
|
|
4
42
|
const entry = entries[key];
|
|
@@ -34,28 +72,47 @@ function injectBootstrapIntoEntries(entries, bootstrap) {
|
|
|
34
72
|
* - No "magic" root bootstrap file
|
|
35
73
|
* - Works for step runtimes because the server entry will always evaluate your bootstrap module
|
|
36
74
|
*/
|
|
37
|
-
export function withEkairosRuntime(
|
|
75
|
+
export function withEkairosRuntime(nextConfigOrFn, opts) {
|
|
38
76
|
const bootstrapModule = opts.bootstrapModule;
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
77
|
+
const apply = (nextConfig) => {
|
|
78
|
+
const userWebpack = nextConfig.webpack ?? undefined;
|
|
79
|
+
return {
|
|
80
|
+
...nextConfig,
|
|
81
|
+
webpack: (config, options) => {
|
|
82
|
+
const out = userWebpack ? userWebpack(config, options) : config;
|
|
83
|
+
// NOTE:
|
|
84
|
+
// - We still attempt the patch here for webpack builds.
|
|
85
|
+
// - But for Turbopack builds, this hook may never run, so we ALSO patch
|
|
86
|
+
// in the config-function wrapper below (after withWorkflow generates the file).
|
|
87
|
+
patchWorkflowStepRouteToImportBootstrap(bootstrapModule);
|
|
88
|
+
if (!options?.isServer)
|
|
89
|
+
return out;
|
|
90
|
+
const req = createRequire(import.meta.url);
|
|
91
|
+
const contextDir = (out && out.context) || process.cwd();
|
|
92
|
+
// Resolve relative to the app project (webpack context), not to this package.
|
|
93
|
+
const resolvedBootstrap = req.resolve(bootstrapModule, {
|
|
94
|
+
paths: [contextDir],
|
|
95
|
+
});
|
|
96
|
+
const originalEntry = out.entry;
|
|
97
|
+
out.entry = async () => {
|
|
98
|
+
const entries = typeof originalEntry === "function" ? await originalEntry() : originalEntry;
|
|
99
|
+
injectBootstrapIntoEntries(entries, resolvedBootstrap);
|
|
100
|
+
return entries;
|
|
101
|
+
};
|
|
45
102
|
return out;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// Resolve relative to the app project (webpack context), not to this package.
|
|
49
|
-
const resolvedBootstrap = req.resolve(bootstrapModule, {
|
|
50
|
-
paths: [contextDir],
|
|
51
|
-
});
|
|
52
|
-
const originalEntry = out.entry;
|
|
53
|
-
out.entry = async () => {
|
|
54
|
-
const entries = typeof originalEntry === "function" ? await originalEntry() : originalEntry;
|
|
55
|
-
injectBootstrapIntoEntries(entries, resolvedBootstrap);
|
|
56
|
-
return entries;
|
|
57
|
-
};
|
|
58
|
-
return out;
|
|
59
|
-
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
60
105
|
};
|
|
106
|
+
// Critical path for Vercel/Turbopack:
|
|
107
|
+
// `@workflow/next` generates `src/app/.well-known/workflow/v1/step/route.js` inside its config function.
|
|
108
|
+
// So we must patch AFTER that function runs (not inside webpack).
|
|
109
|
+
if (typeof nextConfigOrFn === "function") {
|
|
110
|
+
return async (phase, ctx) => {
|
|
111
|
+
const cfg = await nextConfigOrFn(phase, ctx);
|
|
112
|
+
patchWorkflowStepRouteToImportBootstrap(bootstrapModule);
|
|
113
|
+
return apply(cfg);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
// Object config: best-effort patch (file may not exist yet here)
|
|
117
|
+
return apply(nextConfigOrFn);
|
|
61
118
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ekairos/story",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.41-beta.0",
|
|
4
4
|
"description": "Pulzar Story - Workflow-based AI Stories",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@ai-sdk/openai": "^2.0.52",
|
|
51
|
-
"@ekairos/domain": "^1.21.
|
|
51
|
+
"@ekairos/domain": "^1.21.41-beta.0",
|
|
52
52
|
"@instantdb/admin": "^0.22.13",
|
|
53
53
|
"@instantdb/core": "^0.22.13",
|
|
54
54
|
"@vercel/sandbox": "^0.0.23",
|