Loading dummy.js 0 → 100644 +1 −0 Original line number Diff line number Diff line module.exports = { metadata() { return { name: 'Dummy', can_have_children: true }; } }; No newline at end of file editor/src/node_embedded.h +6 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ inline constexpr const char *kEmbeddedBootstrapScript = R"JS( 'use strict'; const fs = require('fs'); const path = require('path'); const { createRequire } = require('module'); const cwdReq = createRequire(process.cwd() + '/'); const loaded = new Map(); function resolveHook(mod, hook) { Loading @@ -42,7 +44,7 @@ function resolveHook(mod, hook) { function getMod(scriptPath) { const p = path.resolve(scriptPath); if (loaded.has(p)) return { mod: loaded.get(p), p }; const mod = require(p); const mod = cwdReq(p); loaded.set(p, mod); return { mod, p }; } Loading Loading @@ -90,7 +92,7 @@ globalThis.__blogiEmbeddedRun = function(reqPath, resPath) { try { fs.writeFileSync(resPath, JSON.stringify({ status: 'error', message: msg }), 'utf8'); } catch (_) { process.stderr.write(msg + '\n'); try { fs.writeSync(2, msg + '\n'); } catch (__) {} } return false; } Loading @@ -113,6 +115,7 @@ public: auto context = setup_->context(); v8::Context::Scope contextScope(context); v8::TryCatch tryCatch(isolate); node::AsyncResource asyncResource(isolate, context->Global(), "blogi-editor-embedded"); auto fn = runFunction_.Get(isolate); v8::Local<v8::Value> argv[2] = { Loading @@ -120,7 +123,7 @@ public: v8::String::NewFromUtf8(isolate, resPath.c_str()).ToLocalChecked() }; if (fn->Call(context, context->Global(), 2, argv).IsEmpty()) { if (asyncResource.MakeCallback(fn, 2, argv).IsEmpty()) { if (tryCatch.HasCaught()) { v8::String::Utf8Value exceptionUtf8(isolate, tryCatch.Exception()); const char *msg = *exceptionUtf8 ? *exceptionUtf8 : "unknown JS exception"; Loading req.json 0 → 100644 +1 −0 Original line number Diff line number Diff line {"script_path": "./dummy.js", "hook": "metadata"} No newline at end of file res.json 0 → 100644 +1 −0 Original line number Diff line number Diff line {"status":"error","message":"Widget Dummy has no hardcoded UUID (type_id/getUUID missing)"} No newline at end of file test_call 0 → 100755 +501 KiB File added.No diff preview for this file type. View file Loading
dummy.js 0 → 100644 +1 −0 Original line number Diff line number Diff line module.exports = { metadata() { return { name: 'Dummy', can_have_children: true }; } }; No newline at end of file
editor/src/node_embedded.h +6 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ inline constexpr const char *kEmbeddedBootstrapScript = R"JS( 'use strict'; const fs = require('fs'); const path = require('path'); const { createRequire } = require('module'); const cwdReq = createRequire(process.cwd() + '/'); const loaded = new Map(); function resolveHook(mod, hook) { Loading @@ -42,7 +44,7 @@ function resolveHook(mod, hook) { function getMod(scriptPath) { const p = path.resolve(scriptPath); if (loaded.has(p)) return { mod: loaded.get(p), p }; const mod = require(p); const mod = cwdReq(p); loaded.set(p, mod); return { mod, p }; } Loading Loading @@ -90,7 +92,7 @@ globalThis.__blogiEmbeddedRun = function(reqPath, resPath) { try { fs.writeFileSync(resPath, JSON.stringify({ status: 'error', message: msg }), 'utf8'); } catch (_) { process.stderr.write(msg + '\n'); try { fs.writeSync(2, msg + '\n'); } catch (__) {} } return false; } Loading @@ -113,6 +115,7 @@ public: auto context = setup_->context(); v8::Context::Scope contextScope(context); v8::TryCatch tryCatch(isolate); node::AsyncResource asyncResource(isolate, context->Global(), "blogi-editor-embedded"); auto fn = runFunction_.Get(isolate); v8::Local<v8::Value> argv[2] = { Loading @@ -120,7 +123,7 @@ public: v8::String::NewFromUtf8(isolate, resPath.c_str()).ToLocalChecked() }; if (fn->Call(context, context->Global(), 2, argv).IsEmpty()) { if (asyncResource.MakeCallback(fn, 2, argv).IsEmpty()) { if (tryCatch.HasCaught()) { v8::String::Utf8Value exceptionUtf8(isolate, tryCatch.Exception()); const char *msg = *exceptionUtf8 ? *exceptionUtf8 : "unknown JS exception"; Loading
req.json 0 → 100644 +1 −0 Original line number Diff line number Diff line {"script_path": "./dummy.js", "hook": "metadata"} No newline at end of file
res.json 0 → 100644 +1 −0 Original line number Diff line number Diff line {"status":"error","message":"Widget Dummy has no hardcoded UUID (type_id/getUUID missing)"} No newline at end of file