11import type { Displayable , Renderable } from '../index.ts'
2- import { assert , is_renderable } from '../shared.ts'
2+ import { assert , is_renderable , type Key } from '../shared.ts'
33import { type Cleanup } from './util.ts'
44
5- export type Key = string | number | bigint | boolean | symbol | object | null
6-
75export interface Controller {
86 _mount_callbacks : ( ( ) => Cleanup ) [ ]
97 _unmount_callbacks : Cleanup [ ]
@@ -26,8 +24,6 @@ export function get_controller(renderable: Renderable): Controller {
2624 return controller
2725}
2826
29- const keys : WeakMap < Displayable & object , Key > = new WeakMap ( )
30-
3127export function invalidate ( renderable : Renderable ) : void {
3228 const controller = controllers . get ( renderable )
3329 assert ( controller , 'the renderable has not been rendered' )
@@ -47,14 +43,3 @@ export function onMount(renderable: Renderable, callback: () => Cleanup): void {
4743export function onUnmount ( renderable : Renderable , callback : ( ) => void ) : void {
4844 onMount ( renderable , ( ) => callback )
4945}
50-
51- export function keyed < T extends Displayable & object > ( displayable : T , key : Key ) : T {
52- assert ( ! keys . has ( displayable ) , 'renderable already has a key' )
53- keys . set ( displayable , key )
54- return displayable
55- }
56-
57- export function get_key ( displayable : unknown ) : unknown {
58- // the cast is fine because getting any non-object will return null
59- return keys . get ( displayable as object ) ?? displayable
60- }
0 commit comments