Skip to content

Commit 556d139

Browse files
authored
Fix runner forgetting about initial values (commontoolsinc#480)
1 parent 8960076 commit 556d139

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

typescript/packages/common-charm/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ export {
99
compileRecipe,
1010
} from "./iterate.js";
1111
export { getIframeRecipe, type IFrameRecipe } from "./iframe/recipe.js";
12+
export { storage } from "./storage.js";

typescript/packages/common-charm/src/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { isStatic, markAsStatic } from "@commontools/builder";
1818
import { StorageProvider, StorageValue } from "./storage/base.js";
1919
import { RemoteStorageProvider } from "./storage/remote.js";
2020
import { debug } from "@commontools/html"; // FIXME(ja): can we move debug to somewhere else?
21-
import { Space } from "@commontools/runner/src/space.js";
21+
import { Space } from "@commontools/runner";
2222
import { InMemoryStorageProvider } from "./storage/memory.js";
2323

2424
export function log(fn: () => any[]) {

typescript/packages/common-runner/src/builtins/map.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ export function map(
9494
},
9595
resultCell,
9696
);
97-
console.log("map", initializedUpTo, resultCell);
9897
resultCell.sourceCell!.sourceCell = parentDoc;
9998

10099
// TODO: Have `run` return cancel, once we make resultCell required

typescript/packages/common-runner/src/runner.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,11 @@ export function run<T, R = any>(
184184
}
185185
}
186186

187-
const internal = processCell.get()?.internal ?? (recipe.initial as { internal: any })?.internal;
187+
const internal = {
188+
...(deepCopy(defaults) as { internal: any })?.internal,
189+
...recipe.initial?.internal,
190+
...processCell.get()?.internal,
191+
};
188192

189193
// Ensure static data is converted to cell references, e.g. for arrays
190194
argument = staticDataToNestedCells(processCell, argument, undefined, resultCell);
@@ -195,7 +199,7 @@ export function run<T, R = any>(
195199
processCell.send({
196200
[TYPE]: recipeId,
197201
argument,
198-
...(internal ? { internal: deepCopy(internal) } : {}),
202+
internal,
199203
resultRef: { cell: resultCell, path: [] },
200204
});
201205

0 commit comments

Comments
 (0)