Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions docs/specs/recipe-construction/rollout-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,25 @@
- [ ] Make passing the output of the second into the first work. Tricky
because we're doing almost opposite expansions on the type.
- [ ] Add ability to create a cell without a link yet.
- [ ] Change constructor for RegularCell to make link optional
- [ ] Add .for method to set a cause (within current context)
- [ ] second parameter to make it optional/flexible:
- [ ] ignores the .for if link already exists
- [x] Merge StreamCell into RegularCell and rename RegularCell to CellImpl
- [x] Primarily this means changing `.set` to first read the resolved value
to see whether we have a stream and then use the stream behavior instead
of regular set.
- [x] Change constructor for RegularCell to make link optional
- [x] Add .for method to set a cause (within current context)
- [x] second parameter to make it optional/flexible:
- [x] ignores the .for if link already exists
- [ ] adds extension if cause already exists (see tracker below)
- [ ] Make .key work even if there is no cause yet.
- [ ] Add some method to force creation of cause, which errors if in
- [x] Make .key work even if there is no cause yet.
- [x] Add some method to force creation of cause, which errors if in
non-handler context and no other information was given (as e.g. deriving
nodes, which do have ids, after asking for them -- this walks the graph up
until it hits the passed in cells)
- [ ] For now though throw in non-handler context when needing a link and it
- [x] For now though throw in non-handler context when needing a link and it
isn't there, e.g. because we need to create a link to the cell (when passed
into `anotherCell.set()` for example). We want to encourage .for use in
ambiguous cases.
- [x] Add space and event to Frame
- [ ] First merge of OpaqueRef and RegularCell
- [ ] Add methods that allow linking to node invocations
- [ ] `setPreExisting` can be deprecated (used in toOpaqueRef which itself
Expand Down
8 changes: 7 additions & 1 deletion packages/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ type IsThisArray =
* IAnyCell is an interface that is used by all calls and to which the runner
* attaches the internal methods..
*/
// deno-lint-ignore no-empty-interface
export interface IAnyCell<T> {
/**
* Set a cause for this cell. Used to create a link when the cell doesn't have
* one yet.
* @param cause - The cause to associate with this cell
* @returns This cell for method chaining
*/
for(cause: unknown): Cell<T>;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/html/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
convertCellsToLinks,
effect,
isCell,
isStream,
type JSONSchema,
UI,
useCancelGroup,
Expand Down Expand Up @@ -269,7 +268,7 @@ const bindProps = (
const setProperty = options.setProp ?? setProp;
const [cancel, addCancel] = useCancelGroup();
for (const [propKey, propValue] of Object.entries(props)) {
if (isCell(propValue) || isStream(propValue)) {
if (isCell(propValue)) {
// If prop is an event, we need to add an event listener
if (isEventProp(propKey)) {
const key = cleanEventProp(propKey);
Expand Down
4 changes: 4 additions & 0 deletions packages/runner/src/builder/recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,17 @@ export function pushFrame(frame?: Frame): Frame {
export function pushFrameFromCause(
cause: any,
unsafe_binding?: UnsafeBinding,
inHandler: boolean = false,
): Frame {
const frame = {
parent: getTopFrame(),
cause,
generatedIdCounter: 0,
opaqueRefs: new Set(),
// Extract space from unsafe_binding if available and set it on frame
...(unsafe_binding?.space && { space: unsafe_binding.space }),
...(unsafe_binding ? { unsafe_binding } : {}),
...(inHandler && { inHandler }),
};
frames.push(frame);
return frame;
Expand Down
2 changes: 2 additions & 0 deletions packages/runner/src/builder/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ export type Frame = {
parent?: Frame;
cause?: unknown;
generatedIdCounter: number;
space?: MemorySpace;
inHandler?: boolean;
opaqueRefs: Set<OpaqueRef<any>>;
unsafe_binding?: UnsafeBinding;
};
Expand Down
Loading