Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs/system apis #47

Open
knoopx opened this issue Nov 12, 2022 · 5 comments
Open

fs/system apis #47

knoopx opened this issue Nov 12, 2022 · 5 comments

Comments

@knoopx
Copy link

knoopx commented Nov 12, 2022

i see there's some fs module but I can't figure how to use. are fs/system apis supported in any way? what about running in a nodejs context? also what about CORS?

@GordonSmith
Copy link
Owner

In general if you:

import {xxx} from "@yyy/zzz";

... OR ...

data = FileAttachment("athletes.csv").csv({typed: true})

It will resolve back to ObservableHQ.com

But if you use relative paths:

import {xxx} from "./otherNotebook.ojsnb";

... OR ...

data = FileAttachment("./data/athletes.csv").csv({typed: true})

It will resolve locally.

Finally you can use "fetch" to get local files with relative paths or full URLs to get remote ones.

@GordonSmith
Copy link
Owner

You can also access all Observable StdLib functions: https://github.com/observablehq/stdlib

@knoopx
Copy link
Author

knoopx commented Nov 13, 2022

in ojb/omd preview neither local or remote fetch works, local throws permission error and remote cors errors. FileAttachment works but you can't glob/list directories. unlocking net/fs/system apis will definitely make this project way more useful. have you tried mixing electron renderer+node integration with @hpcc-js/observable-md? about to try myself as this has same limitations as https://github.com/asg017/dataflow

@GordonSmith
Copy link
Owner

Sorry - I assumed you were using the ObservableJS Notebook feature (create a file with a ".ojsnb" file extension)...

If you give me a code snippet as an example, I will see what I can come up with - it should be relativly easy enough to find a workaround with the built in preview, but when exported to a standalone html page then you will be at the mercy of the usual CORs rules between hosting web server and API server.

@GordonSmith
Copy link
Owner

@knoopx FYI @hpcc-js/observable-md is being deprecated soon, you should switch to @hpcc-js/obersvablehq-compiler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants