asg017 / unofficial-observablehq-compiler

An unofficial compiler for Observable notebook syntax
https://www.npmjs.com/package/@alex.garcia/unofficial-observablehq-compiler
112 stars 23 forks source link

Cell compile ret var #23

Open a10k opened 3 years ago

a10k commented 3 years ago

When compiling cells to implement an editor like interface, deleting a cell needs a reference to the variable created, to call variable.delete()

bryangingechen commented 3 years ago

This looks reasonable, though I haven't done a full review yet.

Do you mind updating the README and adding a test or two?

a10k commented 3 years ago

Hi, sure, I’ll update and resubmit. Thanks!

On Tue, 16 Feb 2021 at 11:36 AM, Bryan Gin-ge Chen notifications@github.com wrote:

This looks reasonable, though I haven't done a full review yet.

Do you mind updating the README and adding a test or two?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/asg017/unofficial-observablehq-compiler/pull/23#issuecomment-779605641, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALEFHJFT5VNLQLPWXOWOXDS7IDMTANCNFSM4XVB367A .

asg017 commented 3 years ago

Havent taken a full look either, but once tests are in I like these changes!

re needing to get cell references after defining, another option is poking through the properties of the returned module. It's a little hard to do, but here's a notebook explaining what I mean: https://observablehq.com/d/ee6ef766304de2e9

a10k commented 3 years ago

Yes, the main issue was editing an import statement, there are multiple ones created, I'm trying out a file based observable editor using chokidar +socketio, so each cell is a file.ojs as they are modified the events and code is sent to the browser where they are compiled and added to a div, the order of the div is controlled using flex order. so, I'm associating each file with all variables created for it, this way when the non named cells/files are edited, I just remove those variables from my runtime and define them again (this way its easier as I have a reference to the cells when I'm creating them), hope this makes sense.

a10k commented 3 years ago

@asg017 & @bryangingechen Hey! sorry for the long delay, I added the tests and updated readme now! Also, here is the link to the PoC I have been building, it uses VS code like editor, enables users to hide/show cells, drag them around to compose dashboard like layouts and runs totally offline using localstorage: https://on.wishyoulization.com/fieldbook