From 83a1888c511b280c88e51aa14b66c6813237a093 Mon Sep 17 00:00:00 2001 From: Mikhail Kireev <29187880+kireevmp@users.noreply.github.com> Date: Tue, 31 Mar 2026 11:52:24 +0200 Subject: [PATCH] feat: tag & wire rename --- packages/app-compose/package.json | 2 +- packages/app-compose/src/__tests__/is.test.ts | 6 +- .../src/compose/__tests__/compose.bench.ts | 18 ++-- .../src/compose/__tests__/compose.test.ts | 28 +++--- .../src/compose/__tests__/graph.test.ts | 28 +++--- .../src/compose/__tests__/guard.test.ts | 87 +++++++++---------- .../src/compose/__tests__/observer.test.ts | 8 +- .../src/compose/__tests__/runner.test.ts | 8 +- packages/app-compose/src/compose/analyze.ts | 4 +- packages/app-compose/src/compose/compose.ts | 2 +- .../app-compose/src/compose/definition.ts | 2 +- packages/app-compose/src/compose/guard.ts | 6 +- packages/app-compose/src/index.ts | 6 +- packages/app-compose/src/runnable/index.ts | 2 +- packages/app-compose/src/runnable/tag.ts | 19 ++-- 15 files changed, 111 insertions(+), 115 deletions(-) diff --git a/packages/app-compose/package.json b/packages/app-compose/package.json index 279dca5..9f91b47 100644 --- a/packages/app-compose/package.json +++ b/packages/app-compose/package.json @@ -1,6 +1,6 @@ { "name": "@grlt-hub/app-compose", - "version": "3.0.0-alpha.12", + "version": "3.0.0-alpha.13", "private": false, "publishConfig": { "access": "public" diff --git a/packages/app-compose/src/__tests__/is.test.ts b/packages/app-compose/src/__tests__/is.test.ts index b73f0d7..65c4c26 100644 --- a/packages/app-compose/src/__tests__/is.test.ts +++ b/packages/app-compose/src/__tests__/is.test.ts @@ -1,12 +1,12 @@ -import { createTag, createTask } from "@runnable" +import { createTask, tag } from "@runnable" import { describe, expect, it } from "vitest" import { is } from "../is" describe("is.tag", () => { it("returns true for a tag", () => { - const tag = createTag({ name: "_" }) + const value = tag("_") - expect(is.tag(tag)).toBe(true) + expect(is.tag(value)).toBe(true) }) it("returns false for a non object", () => { diff --git a/packages/app-compose/src/compose/__tests__/compose.bench.ts b/packages/app-compose/src/compose/__tests__/compose.bench.ts index 59f3ee1..a8763a0 100644 --- a/packages/app-compose/src/compose/__tests__/compose.bench.ts +++ b/packages/app-compose/src/compose/__tests__/compose.bench.ts @@ -1,26 +1,26 @@ import { literal, shape, type Spot } from "@computable" -import { bind, createTag, createTask } from "@runnable" +import { createWire, tag, createTask } from "@runnable" import { bench, describe, vi } from "vitest" import { compose } from "../compose" const double = (x: number) => x * 2 describe("multi layer, compute shapes", () => { - const rootTag = createTag({ name: "root" }) + const rootTag = tag("root") let app = compose() .meta({ name: "bench" }) - .step(bind(rootTag, literal(1))) + .step(createWire(rootTag, literal(1))) let previous: Spot = rootTag.value for (let layer = 0; layer < 20; layer++) { const l = shape({ layer: literal(layer), previous }, ({ layer, previous }) => layer + previous) - const a = createTag({ name: `${layer}:a` }) - const b = createTag({ name: `${layer}:b` }) - const c = createTag({ name: `${layer}:c` }) - const d = createTag({ name: `${layer}:d` }) + const a = tag(`${layer}:a`) + const b = tag(`${layer}:b`) + const c = tag(`${layer}:c`) + const d = tag(`${layer}:d`) const task = createTask({ name: `${layer}:task`, @@ -31,8 +31,8 @@ describe("multi layer, compute shapes", () => { }) app = app - .step([bind(a, shape(l, double)), bind(b, shape(l, double))]) - .step([bind(c, shape(l, double)), bind(d, shape(l, double))]) + .step([createWire(a, shape(l, double)), createWire(b, shape(l, double))]) + .step([createWire(c, shape(l, double)), createWire(d, shape(l, double))]) .step(task) previous = task.result diff --git a/packages/app-compose/src/compose/__tests__/compose.test.ts b/packages/app-compose/src/compose/__tests__/compose.test.ts index c52d637..40729b2 100644 --- a/packages/app-compose/src/compose/__tests__/compose.test.ts +++ b/packages/app-compose/src/compose/__tests__/compose.test.ts @@ -1,5 +1,5 @@ import { literal } from "@computable" -import { bind, createTag, createTask } from "@runnable" +import { createTask, createWire, tag } from "@runnable" import { LIBRARY_NAME } from "@shared" import { describe, expect, it } from "vitest" import { compose } from "../compose" @@ -19,22 +19,24 @@ describe("compose", () => { describe("guard", () => { it("throws on warning graph", () => { - const tag = createTag({ name: "alpha" }) - const app = compose().step(bind(tag, literal(1))) + const alpha = tag("alpha") + const wire = createWire(alpha, literal(1)) - const message = `Unused Binding found with name Tag[alpha] in step root > #1.` + const app = compose().step(wire) + + const message = `Unused Wire found with name Tag[alpha] in step root > #1.` expect(() => app.guard()).toThrowError(message) }) it("throws on error graph", () => { - const tag = createTag({ name: "alpha" }) + const alpha = tag("alpha") const app = compose() - .step(bind(tag, literal(1))) - .step(bind(tag, literal(2))) + .step(createWire(alpha, literal(1))) + .step(createWire(alpha, literal(2))) - const message = `A duplicate Binding found with name Tag[alpha] in step root > #2.` + const message = `A duplicate Wire found with name Tag[alpha] in step root > #2.` expect(() => app.guard()).toThrowError(message) }) @@ -42,14 +44,12 @@ describe("compose", () => { describe("graph", () => { it("provides correct graph structure", () => { + const alpha = tag("alpha") + const task = createTask({ name: "task", run: { fn: () => {} } }) - const tag = createTag({ name: "alpha" }) + const wire = createWire(alpha, literal(1)) - const graph = compose() - .meta({ name: "app" }) - .step(bind(tag, literal(1))) - .step(task) - .graph() + const graph = compose().meta({ name: "app" }).step(wire).step(task).graph() const result = { type: "seq", meta: { name: "app" }, children: [{ type: "run" }, { type: "run" }] } expect(graph).toMatchObject(result) diff --git a/packages/app-compose/src/compose/__tests__/graph.test.ts b/packages/app-compose/src/compose/__tests__/graph.test.ts index f6c264b..0602c9f 100644 --- a/packages/app-compose/src/compose/__tests__/graph.test.ts +++ b/packages/app-compose/src/compose/__tests__/graph.test.ts @@ -1,5 +1,5 @@ import { literal, optional } from "@computable" -import { bind, createTag, createTask } from "@runnable" +import { createTask, createWire, tag } from "@runnable" import { describe, expect, it, vi } from "vitest" import { compose, Node$ } from "../compose" import { graph } from "../graph" @@ -135,10 +135,10 @@ describe("graph", () => { describe("tags", () => { it("dependency on a task via a tag", () => { - const valueTag = createTag({ name: "value" }) + const valueTag = tag("value") const betaTask = createTask({ name: "beta", run: { fn: vi.fn(), context: valueTag.value } }) - const app = compose().step(alphaTask).step(bind(valueTag, alphaTask.result.value)).step(betaTask) + const app = compose().step(alphaTask).step(createWire(valueTag, alphaTask.result.value)).step(betaTask) const result = graph(app[Node$]) const expected = { @@ -154,7 +154,7 @@ describe("graph", () => { { type: "run", id: 1, - meta: { name: "value", kind: "binding" }, + meta: { name: "value", kind: "wire" }, dependencies: { required: [0], optional: [] }, }, { @@ -170,12 +170,12 @@ describe("graph", () => { }) it("dependency on a task via a tag [optional]", () => { - const valueTag = createTag({ name: "value" }) + const valueTag = tag("value") const betaTask = createTask({ name: "beta", run: { fn: vi.fn(), context: optional(valueTag.value) } }) const app = compose() .step(alphaTask) - .step(bind(valueTag, optional(alphaTask.result.value))) + .step(createWire(valueTag, optional(alphaTask.result.value))) .step(betaTask) const result = graph(app[Node$]) @@ -193,7 +193,7 @@ describe("graph", () => { { type: "run", id: 1, - meta: { name: "value", kind: "binding" }, + meta: { name: "value", kind: "wire" }, dependencies: { required: [], optional: [0] }, }, { @@ -209,11 +209,11 @@ describe("graph", () => { }) it("task depends on a literal via tag", () => { - const valueTag = createTag({ name: "value" }) + const valueTag = tag("value") const betaTask = createTask({ name: "beta", run: { fn: vi.fn(), context: valueTag.value } }) const app = compose() - .step(bind(valueTag, literal(false))) + .step(createWire(valueTag, literal(false))) .step(betaTask) const result = graph(app[Node$]) @@ -225,7 +225,7 @@ describe("graph", () => { { type: "run", id: 0, - meta: { name: "value", kind: "binding" }, + meta: { name: "value", kind: "wire" }, dependencies: { required: [], optional: [] }, }, { @@ -262,19 +262,19 @@ describe("graph", () => { describe("mixed dependencies", () => { it("required and optional", () => { - const fnTag = createTag<() => void>({ name: "fn" }) + const fn = tag<() => void>("fn") const betaTask = createTask({ name: "beta", run: { - context: { value: alphaTask.result.value, fn: optional(fnTag.value) }, + context: { value: alphaTask.result.value, fn: optional(fn.value) }, fn: vi.fn(), }, }) const app = compose() .step(alphaTask) - .step(bind(fnTag, literal(vi.fn()))) + .step(createWire(fn, literal(vi.fn()))) .step(betaTask) const result = graph(app[Node$]) @@ -292,7 +292,7 @@ describe("graph", () => { { type: "run", id: 1, - meta: { name: "fn", kind: "binding" }, + meta: { name: "fn", kind: "wire" }, dependencies: { required: [], optional: [] }, }, { diff --git a/packages/app-compose/src/compose/__tests__/guard.test.ts b/packages/app-compose/src/compose/__tests__/guard.test.ts index f754e43..39bccca 100644 --- a/packages/app-compose/src/compose/__tests__/guard.test.ts +++ b/packages/app-compose/src/compose/__tests__/guard.test.ts @@ -1,5 +1,5 @@ import { literal, reference } from "@computable" -import { bind, createTag, createTask } from "@runnable" +import { createTask, createWire, tag } from "@runnable" import { beforeEach, describe, expect, it, vi } from "vitest" import { compose, Node$ } from "../compose" import { createGuard } from "../guard" @@ -13,26 +13,26 @@ describe("duplicate guard", () => { const fn = vi.fn<() => void>() const task = createTask({ name: "beta", run: { fn } }) - const tag = createTag({ name: "alpha" }) + const alpha = tag("alpha") - describe("calls error on duplicate binding", () => { + describe("calls error on duplicate wire", () => { it("in the same step (concurrent)", () => { - const app = compose().step([bind(tag, literal(1)), bind(tag, literal(2))]) + const app = compose().step([createWire(alpha, literal(1)), createWire(alpha, literal(2))]) guard(app[Node$]) - const message = "A duplicate Binding found with name Tag[alpha] in step root > #1 > #2." + const message = "A duplicate Wire found with name Tag[alpha] in step root > #1 > #2." expect(handler.error).toHaveBeenCalledExactlyOnceWith(message) }) it("in different steps (sequential)", () => { const app = compose() - .step(bind(tag, literal(1))) - .step(bind(tag, literal(2))) + .step(createWire(alpha, literal(1))) + .step(createWire(alpha, literal(2))) guard(app[Node$]) - const message = "A duplicate Binding found with name Tag[alpha] in step root > #2." + const message = "A duplicate Wire found with name Tag[alpha] in step root > #2." expect(handler.error).toHaveBeenCalledExactlyOnceWith(message) }) }) @@ -60,27 +60,27 @@ describe("duplicate guard", () => { it("provides rich path", () => { const app = compose() .meta({ name: "MyApp" }) - .step(bind(tag, literal(1))) + .step(createWire(alpha, literal(1))) .step([ compose() .meta({ name: "Layout" }) - .step(bind(tag, literal(2))), + .step(createWire(alpha, literal(2))), ]) guard(app[Node$]) - const message = "A duplicate Binding found with name Tag[alpha] in step MyApp > #2 > #1 (Layout) > #1." + const message = "A duplicate Wire found with name Tag[alpha] in step MyApp > #2 > #1 (Layout) > #1." expect(handler.error).toHaveBeenCalledExactlyOnceWith(message) }) it("passes with no duplicates", () => { const fn = vi.fn<(n: number) => void>() - const tag = createTag({ name: "alpha" }) - const task = createTask({ name: "beta", run: { fn, context: tag.value } }) + const alpha = tag("alpha") + const task = createTask({ name: "beta", run: { fn, context: alpha.value } }) const app = compose() - .step(bind(tag, literal(1))) + .step(createWire(alpha, literal(1))) .step(task) guard(app[Node$]) @@ -92,8 +92,8 @@ describe("duplicate guard", () => { describe("unsatisfied guard", () => { const fn = vi.fn<(n: number) => void>() - it("calls error on task missing binding context", () => { - const provider = createTag({ name: "alpha" }) + it("calls error on task missing wire context", () => { + const provider = tag("alpha") const consumer = createTask({ name: "beta", run: { fn, context: provider.value } }) const app = compose().step(consumer) @@ -118,41 +118,40 @@ describe("unsatisfied guard", () => { expect(handler.error).toHaveBeenCalledExactlyOnceWith(message) }) - it("calls error on binding missing binding context", () => { - const provider = createTag({ name: "alpha" }) - const intermediate = createTag({ name: "beta" }) + it("calls error on wire missing wire context", () => { + const alpha = tag("alpha") + const beta = tag("beta") - const app = compose().step(bind(intermediate, provider.value)) + const app = compose().step(createWire(beta, alpha.value)) guard(app[Node$]) - const message = - "Unsatisfied dependencies found for Binding with name Tag[beta] in step root > #1: missing Tag[alpha]." + const message = "Unsatisfied dependencies found for Wire with name Tag[beta] in step root > #1: missing Tag[alpha]." expect(handler.error).toHaveBeenCalledExactlyOnceWith(message) }) - it("calls error on binding missing task context", () => { + it("calls error on wire missing task context", () => { const provider = createTask({ name: "alpha", run: { fn: () => 0 } }) - const intermediate = createTag({ name: "beta" }) + const intermediate = tag("beta") - const app = compose().step(bind(intermediate, provider.status)) + const app = compose().step(createWire(intermediate, provider.status)) guard(app[Node$]) const message = - "Unsatisfied dependencies found for Binding with name Tag[beta] in step root > #1: missing Task[alpha]::status." + "Unsatisfied dependencies found for Wire with name Tag[beta] in step root > #1: missing Task[alpha]::status." expect(handler.error).toHaveBeenCalledExactlyOnceWith(message) }) it("calls error on task missing context in its local con thread", () => { - const provider = createTag({ name: "alpha" }) + const provider = tag("alpha") const taskA = createTask({ name: "A", run: { fn: vi.fn(), context: provider.value } }) const taskB = createTask({ name: "B", run: { fn: vi.fn(), context: provider.value } }) const app = compose().step([ compose() - .step(bind(provider, literal(1))) + .step(createWire(provider, literal(1))) .step(taskA), compose().step(taskB), ]) @@ -165,8 +164,8 @@ describe("unsatisfied guard", () => { }) describe("missing list", () => { - const alpha = createTag({ name: "alpha" }) - const beta = createTag({ name: "beta" }) + const alpha = tag("alpha") + const beta = tag("beta") const task = createTask({ name: "beta", run: { fn: vi.fn(), context: [alpha.value, beta.value] } }) @@ -182,7 +181,7 @@ describe("unsatisfied guard", () => { it("only reports missing dependencies for the task", () => { const app = compose() - .step(bind(alpha, literal(1))) + .step(createWire(alpha, literal(1))) .step(task) guard(app[Node$]) @@ -194,7 +193,7 @@ describe("unsatisfied guard", () => { }) it("provides rich path", () => { - const provider = createTag({ name: "alpha" }) + const provider = tag("alpha") const consumer = createTask({ name: "beta", run: { fn, context: provider.value } }) const app = compose() @@ -209,11 +208,11 @@ describe("unsatisfied guard", () => { }) it("passes when satisfied", () => { - const provider = createTag({ name: "alpha" }) + const provider = tag("alpha") const consumer = createTask({ name: "beta", run: { fn, context: provider.value } }) const app = compose() - .step(bind(provider, literal(1))) + .step(createWire(provider, literal(1))) .step(consumer) guard(app[Node$]) @@ -236,28 +235,28 @@ describe("unsatisfied guard", () => { }) describe("unused guard", () => { - const alpha = createTag({ name: "alpha" }) + const alpha = tag("alpha") - it("warns on unused binding (seq)", () => { - const node = compose().step(bind(alpha, literal(1))) + it("warns on unused wire (seq)", () => { + const node = compose().step(createWire(alpha, literal(1))) guard(node[Node$]) - const message = "Unused Binding found with name Tag[alpha] in step root > #1." + const message = "Unused Wire found with name Tag[alpha] in step root > #1." expect(handler.warn).toHaveBeenCalledWith(message) }) - it("warns on unused binding (con)", () => { - const beta = createTag({ name: "alpha" }) + it("warns on unused wire (con)", () => { + const beta = tag("alpha") const task = createTask({ name: "test", run: { fn: vi.fn(), context: beta.value } }) const node = compose() - .step([bind(alpha, literal(1)), bind(beta, literal(2))]) + .step([createWire(alpha, literal(1)), createWire(beta, literal(2))]) .step(task) guard(node[Node$]) - const message = "Unused Binding found with name Tag[alpha] in step root > #1 > #1." + const message = "Unused Wire found with name Tag[alpha] in step root > #1 > #1." expect(handler.warn).toHaveBeenCalledWith(message) }) @@ -267,12 +266,12 @@ describe("unused guard", () => { .step( compose() .meta({ name: "Layout" }) - .step(bind(alpha, literal(2))), + .step(createWire(alpha, literal(2))), ) guard(node[Node$]) - const message = "Unused Binding found with name Tag[alpha] in step MyApp > #1 (Layout) > #1." + const message = "Unused Wire found with name Tag[alpha] in step MyApp > #1 (Layout) > #1." expect(handler.warn).toHaveBeenCalledWith(message) }) }) diff --git a/packages/app-compose/src/compose/__tests__/observer.test.ts b/packages/app-compose/src/compose/__tests__/observer.test.ts index 5189c8e..de5ebfa 100644 --- a/packages/app-compose/src/compose/__tests__/observer.test.ts +++ b/packages/app-compose/src/compose/__tests__/observer.test.ts @@ -1,5 +1,5 @@ import { literal, shape } from "@computable" -import { bind, createTag, createTask } from "@runnable" +import { createTask, createWire, tag } from "@runnable" import { describe, expect, it, vi } from "vitest" import { compose } from "../compose" import type { ComposeHookMap } from "../observer" @@ -31,14 +31,14 @@ describe("observer", () => { it("is not called when another runnable fails", async () => { const onTaskFail = vi.fn() - const tag = createTag({ name: "test" }) - const task = createTask({ name: "alpha", run: { fn: () => "okay", context: tag.value } }) + const test = tag("test") + const task = createTask({ name: "alpha", run: { fn: () => "okay", context: test.value } }) const value = shape(literal(1), () => { throw new Error("error") }) - const app = compose().meta({ name: "app", hooks: { onTaskFail } }).step(bind(tag, value)).step(task) + const app = compose().meta({ name: "app", hooks: { onTaskFail } }).step(createWire(test, value)).step(task) await app.run() diff --git a/packages/app-compose/src/compose/__tests__/runner.test.ts b/packages/app-compose/src/compose/__tests__/runner.test.ts index 4bf024d..a0ec5c8 100644 --- a/packages/app-compose/src/compose/__tests__/runner.test.ts +++ b/packages/app-compose/src/compose/__tests__/runner.test.ts @@ -1,5 +1,5 @@ import { literal, optional } from "@computable" -import { bind, createTag, createTask, type TaskStatus } from "@runnable" +import { createTask, createWire, tag, type TaskStatus } from "@runnable" import { describe, expect, it, vi } from "vitest" import { compose, Node$ } from "../compose" import { run } from "../runner" @@ -239,12 +239,12 @@ describe("runner", () => { }) it("can read tag value from scope", async () => { - const tag = createTag({ name: "test" }) - const app = compose().step(bind(tag, literal("value"))) + const test = tag("test") + const app = compose().step(createWire(test, literal("value"))) const scope = await run(app[Node$]) - expect(scope.get(tag.value)).toBe("value") + expect(scope.get(test.value)).toBe("value") }) }) diff --git a/packages/app-compose/src/compose/analyze.ts b/packages/app-compose/src/compose/analyze.ts index cc5e1c0..085e4fb 100644 --- a/packages/app-compose/src/compose/analyze.ts +++ b/packages/app-compose/src/compose/analyze.ts @@ -1,4 +1,4 @@ -import { Context$, Dispatch$, type Binding, type Runnable, type RunnableInternal, type Task } from "@runnable" +import { Context$, Dispatch$, type Runnable, type RunnableInternal, type Task, type Wire } from "@runnable" import type { ComposableKind } from "./definition" import { resolve, type Dependency } from "./resolver" @@ -9,7 +9,7 @@ type ComposeAnalyzer = { } const analyze = (runnable: RunnableInternal): RunnableMeta => { - const internal = runnable as RunnableInternal & (Task | Binding) + const internal = runnable as RunnableInternal & (Task | Wire) const writes = Object.getOwnPropertySymbols(internal[Dispatch$]) const dependencies = resolve(internal[Context$]) diff --git a/packages/app-compose/src/compose/compose.ts b/packages/app-compose/src/compose/compose.ts index 923dbc3..552a014 100644 --- a/packages/app-compose/src/compose/compose.ts +++ b/packages/app-compose/src/compose/compose.ts @@ -44,7 +44,7 @@ const builder = (node: ComposeInner): Composer => { step: (arg) => { if (Array.isArray(arg)) return builder({ ...node, children: [...node.children, { type: "con", children: arg.map(normalize) }] }) - return builder({ ...node, children: [...node.children, normalize(arg)] }) + else return builder({ ...node, children: [...node.children, normalize(arg)] }) }, run: () => { diff --git a/packages/app-compose/src/compose/definition.ts b/packages/app-compose/src/compose/definition.ts index 7bc85f3..8859dbe 100644 --- a/packages/app-compose/src/compose/definition.ts +++ b/packages/app-compose/src/compose/definition.ts @@ -11,6 +11,6 @@ type ComposeNode = ComposeNodeSeq | ComposeNodeCon | ComposeNodeRun type ComposeInner = ComposeNodeCon | ComposeNodeSeq type Registry = Map -type ComposableKind = "task" | "binding" +type ComposableKind = "task" | "wire" export type { ComposableKind, ComposeInner, ComposeMeta, ComposeNode, Registry } diff --git a/packages/app-compose/src/compose/guard.ts b/packages/app-compose/src/compose/guard.ts index c1063d2..705d1ca 100644 --- a/packages/app-compose/src/compose/guard.ts +++ b/packages/app-compose/src/compose/guard.ts @@ -9,8 +9,8 @@ type GuardHandler = Record<"warn" | "error", (message: string) => void> const UNKNOWN_NAME = "" -const TypeMap = { task: "Task", binding: "Binding" } satisfies Record -const NameMap = { task: "Task", binding: "Tag" } satisfies Record +const TypeMap = { task: "Task", wire: "Wire" } satisfies Record +const NameMap = { task: "Task", wire: "Tag" } satisfies Record const metaOf = (node: ComposeNode, key: K): ComposeMeta[K] => "meta" in node && node.meta?.[key] ? node.meta[key] : undefined @@ -82,7 +82,7 @@ const createGuard = ({ handler }: GuardConfig) => { if (current.type === "run") { const { type, display, writes, dependencies } = analyzer.get(current.value as RunnableInternal) - if (type === "binding") writes.forEach((id) => candidates.set(id, { type, name: display.name, stack })) + if (type === "wire") writes.forEach((id) => candidates.set(id, { type, name: display.name, stack })) dependencies.required.forEach((id) => candidates.delete(id)) dependencies.optional.forEach((id) => candidates.delete(id)) diff --git a/packages/app-compose/src/index.ts b/packages/app-compose/src/index.ts index d3f0252..cf6a81d 100644 --- a/packages/app-compose/src/index.ts +++ b/packages/app-compose/src/index.ts @@ -1,13 +1,13 @@ export { compose, type ComposeHookMap, type Composer } from "@compose" export { literal, optional, shape, type Spot, type SpotValue } from "@computable" export { - bind, - createTag, createTask, - type Binding, + createWire, + tag, type Tag, type Task, type TaskResult, type TaskStatus, + type Wire, } from "@runnable" export { is } from "./is" diff --git a/packages/app-compose/src/runnable/index.ts b/packages/app-compose/src/runnable/index.ts index e7bf7ff..3a523bd 100644 --- a/packages/app-compose/src/runnable/index.ts +++ b/packages/app-compose/src/runnable/index.ts @@ -1,3 +1,3 @@ export { Context$, Dispatch$, Execute$, type Runnable, type RunnableInternal, type RunnableKind } from "./definition" -export { Tag$, bind, createTag, type Binding, type Tag } from "./tag" +export { Tag$, createWire, tag, type Tag, type Wire } from "./tag" export { Task$, createTask, type Task, type TaskExecutionValue, type TaskResult, type TaskStatus } from "./task" diff --git a/packages/app-compose/src/runnable/tag.ts b/packages/app-compose/src/runnable/tag.ts index 8eb8360..5deccdf 100644 --- a/packages/app-compose/src/runnable/tag.ts +++ b/packages/app-compose/src/runnable/tag.ts @@ -6,22 +6,19 @@ import { Context$, Dispatch$, Execute$, type Runnable, type RunnableInternal, ty const Tag$ = Symbol("$tag") type Tag = { [Tag$]: symbol; name: string; value: SpotProvider } -type TagConfig = { name: string } -const createTag = (config: TagConfig): Tag => { - const id = Symbol(`Tag[${config.name}]`) +const tag = (name: string): Tag => { + const id = Symbol(`Tag[${name}]`) - const tag: Tag = { [Tag$]: id, name: config.name, value: reference.lensed(id) } - - return tag + return { [Tag$]: id, name, value: reference.lensed(id) } } -type Binding = { name: string } & Runnable & RunnableKind<"binding"> +type Wire = { name: string } & Runnable & RunnableKind<"wire"> -const bind = (tag: Tag, value: ContextToSpot): Binding => { - const runnable: RunnableInternal & Binding = { +const createWire = (tag: Tag, value: ContextToSpot): Wire => { + const runnable: RunnableInternal & Wire = { name: tag.name, - kind: "binding", + kind: "wire", [Context$]: build(value), [Execute$]: identity, @@ -31,4 +28,4 @@ const bind = (tag: Tag, value: ContextToSpot): Binding => { return runnable } -export { bind, createTag, Tag$, type Binding, type Tag, } +export { createWire, tag, Tag$, type Tag, type Wire }