{"id":25617793,"url":"https://github.com/terrablue/flog","last_synced_at":"2025-04-13T23:44:27.268Z","repository":{"id":278383681,"uuid":"549605290","full_name":"terrablue/flog","owner":"terrablue","description":"Minimal JavaScript runtime","archived":false,"fork":false,"pushed_at":"2023-03-29T18:22:02.000Z","size":100,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T13:51:16.723Z","etag":null,"topics":["flog","javascript","minimal","quickjs","runtime"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terrablue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-11T12:55:51.000Z","updated_at":"2024-12-15T17:43:21.000Z","dependencies_parsed_at":"2025-02-19T13:46:34.634Z","dependency_job_id":"f0c8f4b3-6947-46b5-94eb-01d4178dccba","html_url":"https://github.com/terrablue/flog","commit_stats":null,"previous_names":["terrablue/flog"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terrablue%2Fflog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terrablue%2Fflog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terrablue%2Fflog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terrablue%2Fflog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terrablue","download_url":"https://codeload.github.com/terrablue/flog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799670,"owners_count":21163398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flog","javascript","minimal","quickjs","runtime"],"created_at":"2025-02-22T05:28:54.514Z","updated_at":"2025-04-13T23:44:27.243Z","avatar_url":"https://github.com/terrablue.png","language":"C","readme":"# Flog\n\nFlog is a **JavaScript** runtime. Written on top of QuickJS in C, it has a\nminimal core.\n\n## Design goals\n\n* Minimal core as a thin wrapper around QuickJS ✓\n* Executable and module manager in one WIP\n* Namespaced, officially supported standard library ([flogjs/std][std])\n* Third-party, scoped module area TODO\n* Sandboxing of applications (directory-level scoping) TODO\n\n### Prerequisites\n\nFlog uses `zig build` to manage dependencies and build the project. \n\nAt best, [download and install Zig master](https://ziglang.org/download).\nHowever, we can currently only guarantee that the build works on Linux x86_64\nwith the tag [0.11.0-dev.1646+3f7e9ff59][dl].\n\n### Getting started\n\nTo build flog, run `zig build`. This will result in a `flog` executable in the\n`zig-out/bin` directory.\n\nCreate an `app.js` file in the same directory.\n\n```js\nimport console from \"std/console\";\n\nconsole.log(\"Hello, world!\");\n```\n\nYou can now run flog with this file as the first argument.\n\n```sh\nzig-out/bin/flog app.js\n```\n\nFlog will download and install the standard module `console` and will execute\nthe file.\n\nStandard modules are automatically installed the first time they are used in a\nfile. In the case of non-standard (third-party) modules encountered in a file,\nyou will be prompted if you wish to download and install them.\n\nIf you wish to explicitly install modules before use (both standard and\nthird-party), run `flog install [module]`.\n\n```sh\nzig-out/bin/flog install std/console\n\n```\n\nIn addition to normal JavaScript syntax, you can use `import` and `export`\ndeclarations to import and export code via modules. Currently supported are\n`.js`, `.json` and `.so` imports.\n\n### Creating a C module\n\nDefine a `flog_module_init` function with the given signature. This is an\nexample for a module that emulates `console.log`.\n\n```c\n#include \u003cstdio.h\u003e\n#include \"../flog/src/flog.h\"\n\nstatic JSValue print(JSContext* context,\n                     JSValueConst target,\n                     int argc,\n                     JSValueConst* argv) {\n  if (argc \u003c 1) return JS_UNDEFINED;\n  const char* str = JS_ToCString(context, * argv);\n  printf(\"%s\\n\", str);\n  return JS_UNDEFINED;\n}\n\nstatic const JSCFunctionListEntry funcs[] = {\n  JS_CFUNC_DEF(\"log\", 1, print),\n};\n\nstatic int module_init(JSContext* context, JSModuleDef* module_def) {\n  JSValue console = JS_NewObjectProto(context, JS_NULL);\n  JS_SetPropertyFunctionList(context, console, funcs, countof(funcs));\n  return JS_SetModuleExport(context, module_def, \"default\", console);\n}\n\nJSModuleDef* flog_module_init(JSContext* context, const char* name) {\n  JSModuleDef* module_def = JS_NewCModule(context, name, module_init);\n  if (!module_def) {\n    return NULL;\n  }\n\n  JS_AddModuleExport(context, module_def, \"default\");\n\n  return module_def;\n}\n```\n\nCompile with a `Makefile` that references the original `libqjs.a` artefact\ncreated when having compiled `flog`.\n\n```Makefile\nconsole:\n  gcc -c -L../flog -llibqjs -o console.o console.c\n  gcc -o console.so -shared -Wl,-soname=console.so -Wl,--start-group console.o -Wl,--end-group\n```\n\nThen in your .js file, import and use.\n\n```js\nimport console from \"console.so\";\n\nconsole.log(\"Hi!\");\n```\n\n### Resources\n\n* IRC: Join the `#flog` channel on `irc.libera.chat`.\n\n### License\n\nMIT\n\n[rfcs]: https://github.com/flogjs/rfcs\n[std]: https://github.com/flogjs/std\n[dl]: https://ziglang.org/builds/zig-linux-x86_64-0.11.0-dev.1646+3f7e9ff59.tar.xz\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterrablue%2Fflog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterrablue%2Fflog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterrablue%2Fflog/lists"}