[READ-ONLY] Mirror of https://github.com/bombshell-dev/playground.
0

Configure Feed

Select the types of activity you want to include in your feed.

🎨 adopt house const style and disable require-yield in freedom

Charles Lowell (Jun 24, 2026, 11:47 PM -0500) ad68ce08 1ffe7b75

+61 -59
+2 -1
packages/freedom/src/lib/dispatch.ts
··· 1 + // oxlint-disable require-yield 1 2 import type { Api, Operation, Result } from "effection"; 2 3 import { createApi } from "effection/experimental"; 3 4 import type { Node } from "./types.ts"; ··· 16 17 }, 17 18 18 19 *getNodeById(id: string): Operation<Node | undefined> { 19 - let tree = yield* TreeContext.expect(); 20 + const tree = yield* TreeContext.expect(); 20 21 return tree.nodes.get(id); 21 22 }, 22 23 },
+23 -23
packages/freedom/src/lib/focus.ts
··· 21 21 } 22 22 23 23 function focusChain(node: Node): Node[] { 24 - let result: Node[] = []; 24 + const result: Node[] = []; 25 25 if ("focused" in node.props) { 26 26 result.push(node); 27 27 } 28 - for (let child of node.children) { 28 + for (const child of node.children) { 29 29 result.push(...focusChain(child)); 30 30 } 31 31 return result; ··· 45 45 46 46 export const FocusApi: Api<Focus> = createApi<Focus>("freedom:focus", { 47 47 *focusable() { 48 - let node = yield* NodeContext.expect(); 48 + const node = yield* NodeContext.expect(); 49 49 if (!("focused" in node.props)) { 50 50 yield* set("focused", false); 51 51 } 52 52 }, 53 53 54 54 *advance() { 55 - let self = yield* NodeContext.expect(); 56 - let r = findRoot(self); 57 - let nodes = focusChain(r); 55 + const self = yield* NodeContext.expect(); 56 + const r = findRoot(self); 57 + const nodes = focusChain(r); 58 58 if (nodes.length <= 1) return; 59 59 60 - let idx = nodes.findIndex((n) => n.props.focused === true); 60 + const idx = nodes.findIndex((n) => n.props.focused === true); 61 61 if (idx === -1) return; 62 62 63 - let old = nodes[idx]; 64 - let next = nodes[(idx + 1) % nodes.length]; 63 + const old = nodes[idx]; 64 + const next = nodes[(idx + 1) % nodes.length]; 65 65 66 66 yield* setFocused(old, false, self); 67 67 yield* setFocused(next, true, self); 68 68 }, 69 69 70 70 *retreat() { 71 - let self = yield* NodeContext.expect(); 72 - let r = findRoot(self); 73 - let nodes = focusChain(r); 71 + const self = yield* NodeContext.expect(); 72 + const r = findRoot(self); 73 + const nodes = focusChain(r); 74 74 if (nodes.length <= 1) return; 75 75 76 - let idx = nodes.findIndex((n) => n.props.focused === true); 76 + const idx = nodes.findIndex((n) => n.props.focused === true); 77 77 if (idx === -1) return; 78 78 79 - let old = nodes[idx]; 80 - let prev = nodes[(idx - 1 + nodes.length) % nodes.length]; 79 + const old = nodes[idx]; 80 + const prev = nodes[(idx - 1 + nodes.length) % nodes.length]; 81 81 82 82 yield* setFocused(old, false, self); 83 83 yield* setFocused(prev, true, self); ··· 89 89 } 90 90 if (target.props.focused === true) return; 91 91 92 - let self = yield* NodeContext.expect(); 93 - let r = findRoot(target); 94 - let nodes = focusChain(r); 95 - let old = nodes.find((n) => n.props.focused === true); 92 + const self = yield* NodeContext.expect(); 93 + const r = findRoot(target); 94 + const nodes = focusChain(r); 95 + const old = nodes.find((n) => n.props.focused === true); 96 96 97 97 if (old) { 98 98 yield* setFocused(old, false, self); ··· 101 101 }, 102 102 103 103 *current() { 104 - let node = yield* NodeContext.expect(); 105 - let r = findRoot(node); 106 - let nodes = focusChain(r); 107 - let focused = nodes.find((n) => n.props.focused === true); 104 + const node = yield* NodeContext.expect(); 105 + const r = findRoot(node); 106 + const nodes = focusChain(r); 107 + const focused = nodes.find((n) => n.props.focused === true); 108 108 if (focused) { 109 109 return focused; 110 110 } else {
+14 -13
packages/freedom/src/lib/freedom.ts
··· 1 + // oxlint-disable require-yield 1 2 import { 2 3 type Api, 3 4 type Operation, ··· 41 42 useNode: () => NodeContext.expect(), 42 43 43 44 *get(key: string): Operation<JsonValue | undefined> { 44 - let node = yield* NodeContext.expect(); 45 + const node = yield* NodeContext.expect(); 45 46 return node._props[key]; 46 47 }, 47 48 48 49 *set(key: string, value: JsonValue) { 49 50 validateJsonValue(value); 50 - let node = yield* NodeContext.expect(); 51 + const node = yield* NodeContext.expect(); 51 52 node._props[key] = value; 52 53 }, 53 54 54 55 *update(key: string, fn: (prev: JsonValue | undefined) => JsonValue) { 55 - let node = yield* NodeContext.expect(); 56 - let prev = node._props[key]; 57 - let next = fn(prev); 56 + const node = yield* NodeContext.expect(); 57 + const prev = node._props[key]; 58 + const next = fn(prev); 58 59 validateJsonValue(next); 59 60 node._props[key] = next; 60 61 }, 61 62 62 63 *unset(key: string) { 63 - let node = yield* NodeContext.expect(); 64 + const node = yield* NodeContext.expect(); 64 65 if (key in node._props) { 65 66 delete node._props[key]; 66 67 } 67 68 }, 68 69 69 70 *append(name: string, component: Component): Operation<Node> { 70 - let parent = yield* NodeContext.expect(); 71 - let tree = yield* TreeContext.expect(); 72 - let child = new NodeImpl(tree.nextId(), name, parent); 73 - let ready = withResolvers<void>(); 71 + const parent = yield* NodeContext.expect(); 72 + const tree = yield* TreeContext.expect(); 73 + const child = new NodeImpl(tree.nextId(), name, parent); 74 + const ready = withResolvers<void>(); 74 75 75 - let task = yield* spawn(function* () { 76 + const task = yield* spawn(function* () { 76 77 parent._children.add(child); 77 78 tree.nodes.set(child.id, child); 78 79 yield* NodeContext.set(child); ··· 95 96 }, 96 97 97 98 *remove(node: Node) { 98 - let halt = node.data.expect(Halt); 99 + const halt = node.data.expect(Halt); 99 100 yield* halt(); 100 101 }, 101 102 102 103 *sort(fn: ((a: Node, b: Node) => number) | undefined) { 103 - let node = yield* NodeContext.expect(); 104 + const node = yield* NodeContext.expect(); 104 105 node._sortFn = fn; 105 106 }, 106 107 });
+10 -10
packages/freedom/src/lib/node.ts
··· 25 25 } 26 26 27 27 expect<T>(key: NodeDataKey<T>): T { 28 - let val = this._map.get(key.symbol); 28 + const val = this._map.get(key.symbol); 29 29 if (val !== undefined) { 30 30 return val as T; 31 31 } else if (key.defaultValue !== undefined) { ··· 72 72 73 73 get children(): Iterable<Node> { 74 74 if (this._sortFn) { 75 - let fn = this._sortFn; 76 - let indexed = [...this._children].map((c, i) => [c, i] as const); 75 + const fn = this._sortFn; 76 + const indexed = [...this._children].map((c, i) => [c, i] as const); 77 77 indexed.sort(([a, ai], [b, bi]) => { 78 - let result = fn(a, b); 78 + const result = fn(a, b); 79 79 if (result !== 0) { 80 80 return result; 81 81 } else { ··· 93 93 } 94 94 95 95 *eval<T>(op: () => Operation<T>): Operation<Result<T>> { 96 - let resolver = withResolvers<Result<T>>(); 96 + const resolver = withResolvers<Result<T>>(); 97 97 yield* this._channel.send({ 98 98 resolve: resolver.resolve as (result: Result<unknown>) => void, 99 99 operation: op as () => Operation<unknown>, ··· 109 109 export function* spawnEvalLoop( 110 110 channel: Channel<CallEval, never>, 111 111 ): Operation<void> { 112 - let ready = withResolvers<void>(); 112 + const ready = withResolvers<void>(); 113 113 114 114 yield* spawn(function* () { 115 - let sub = yield* channel as Stream<CallEval, never>; 115 + const sub = yield* channel as Stream<CallEval, never>; 116 116 ready.resolve(); 117 117 118 118 while (true) { 119 - let next = yield* sub.next(); 119 + const next = yield* sub.next(); 120 120 if (next.done) { 121 121 break; 122 122 } 123 - let call = next.value; 124 - let result = yield* box(call.operation); 123 + const call = next.value; 124 + const result = yield* box(call.operation); 125 125 call.resolve(result); 126 126 } 127 127 });
+10 -10
packages/freedom/src/lib/tree.ts
··· 14 14 15 15 export function useTree(root: Component): Operation<Tree> { 16 16 return resource<Tree>(function* (provide) { 17 - let output = createSignal<void, never>(); 18 - let events = createSignal<unknown, void>(); 17 + const output = createSignal<void, never>(); 18 + const events = createSignal<unknown, void>(); 19 19 20 20 let counter = 0; 21 - let state: TreeState = { 21 + const state: TreeState = { 22 22 dirty: false, 23 23 output, 24 24 events, ··· 33 33 34 34 yield* TreeContext.set(state); 35 35 36 - let rootNode = new NodeImpl(state.nextId(), "", undefined); 36 + const rootNode = new NodeImpl(state.nextId(), "", undefined); 37 37 rootNode.remove = () => FreedomApi.operations.remove(rootNode); 38 38 state.nodes.set(rootNode.id, rootNode); 39 39 40 - let ready = withResolvers<void>(); 40 + const ready = withResolvers<void>(); 41 41 42 42 // Spawn root node scope 43 43 yield* spawn(function* () { ··· 58 58 state.markDirty(); 59 59 }, 60 60 *append(args, next) { 61 - let node = yield* next(...args); 61 + const node = yield* next(...args); 62 62 state.markDirty(); 63 63 return node; 64 64 }, ··· 75 75 yield* spawnEvalLoop(rootNode._channel); 76 76 77 77 // Subscribe to events, then spawn the event loop 78 - let sub = yield* events; 78 + const sub = yield* events; 79 79 yield* spawn(function* () { 80 80 while (true) { 81 - let next = yield* sub.next(); 81 + const next = yield* sub.next(); 82 82 if (next.done) { 83 83 break; 84 84 } 85 - let event = next.value; 85 + const event = next.value; 86 86 state.dirty = false; 87 87 yield* rootNode.eval(() => DispatchApi.operations.dispatch(event)); 88 88 if (state.dirty) { ··· 99 99 100 100 yield* ready.operation; 101 101 102 - let tree: Tree = { 102 + const tree: Tree = { 103 103 dispatch(event: unknown) { 104 104 events.send(event); 105 105 },
+2 -2
packages/freedom/src/lib/validate.ts
··· 40 40 throw new Error("RegExp instances are not valid JsonValues"); 41 41 } 42 42 if (Array.isArray(value)) { 43 - for (let item of value) { 43 + for (const item of value) { 44 44 validateJsonValue(item); 45 45 } 46 46 return; 47 47 } 48 48 if (typeof value === "object" && value !== null) { 49 - for (let key of Object.keys(value)) { 49 + for (const key of Object.keys(value)) { 50 50 validateJsonValue((value as Record<string, unknown>)[key]); 51 51 } 52 52 return;