11import { makeDatabaseClient } from "./database.js" ;
2+ import { inspect , inspectError } from "./inspect.js" ;
23import { makeLibrary } from "./library.js" ;
3- import { Inspector , Runtime } from "./runtime.js" ;
4+ import { Runtime } from "./runtime.js" ;
45
56const library = makeLibrary ( ) ;
67const { Generators} = library ;
@@ -36,24 +37,23 @@ export function define(cell) {
3637 const root = document . querySelector ( `#cell-${ id } ` ) ;
3738 let reset = null ;
3839 const clear = ( ) => ( ( root . innerHTML = "" ) , ( reset = null ) ) ;
39- const inspector = ( ) => new Inspector ( root . appendChild ( document . createElement ( "SPAN" ) ) ) ;
4040 const display = inline
4141 ? ( v ) => {
4242 reset ?. ( ) ;
43- if ( v instanceof Node || typeof v === "string" || ! v ?. [ Symbol . iterator ] ) root . append ( v ) ;
43+ if ( isNode ( v ) || typeof v === "string" || ! v ?. [ Symbol . iterator ] ) root . append ( v ) ;
4444 else root . append ( ...v ) ;
4545 return v ;
4646 }
4747 : ( v ) => {
4848 reset ?. ( ) ;
49- inspector ( ) . fulfilled ( v ) ;
49+ root . append ( isNode ( v ) ? v : inspect ( v ) ) ;
5050 return v ;
5151 } ;
5252 const v = main . variable (
5353 {
5454 pending : ( ) => ( reset = clear ) ,
5555 fulfilled : ( ) => reset ?. ( ) ,
56- rejected : ( error ) => ( reset ?. ( ) , inspector ( ) . rejected ( error ) )
56+ rejected : ( error ) => ( reset ?. ( ) , root . append ( inspectError ( error ) ) )
5757 } ,
5858 {
5959 shadow : {
@@ -68,3 +68,8 @@ export function define(cell) {
6868 for ( const f of files ) attachedFiles . set ( f . name , { url : f . path , mimeType : f . mimeType } ) ;
6969 for ( const d of databases ) databaseTokens . set ( d . name , d ) ;
7070}
71+
72+ // Note: Element.prototype is instanceof Node, but cannot be inserted!
73+ function isNode ( value ) {
74+ return value instanceof Node && value instanceof value . constructor ;
75+ }
0 commit comments