novac 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1574 -597
- package/bin/novac +468 -171
- package/bin/nvc +522 -0
- package/bin/nvml +78 -17
- package/demo.nv +0 -0
- package/demo_builtins.nv +0 -0
- package/demo_http.nv +0 -0
- package/examples/bf.nv +69 -0
- package/examples/math.nv +21 -0
- package/kits/birdAPI/kitdef.js +954 -0
- package/kits/kitRNG/kitdef.js +740 -0
- package/kits/kitSSH/kitdef.js +1272 -0
- package/kits/kitadb/kitdef.js +606 -0
- package/kits/kitai/kitdef.js +2185 -0
- package/kits/kitansi/kitdef.js +1402 -0
- package/kits/kitcanvas/kitdef.js +914 -0
- package/kits/kitclippy/kitdef.js +925 -0
- package/kits/kitformat/kitdef.js +1485 -0
- package/kits/kitgps/kitdef.js +1862 -0
- package/kits/kitlibproc/kitdef.js +3 -2
- package/kits/kitmatrix/ex.js +19 -0
- package/kits/kitmatrix/kitdef.js +960 -0
- package/kits/kitmorse/kitdef.js +229 -0
- package/kits/kitmpatch/kitdef.js +906 -0
- package/kits/kitnet/kitdef.js +1401 -0
- package/kits/kitnovacweb/README.md +1416 -143
- package/kits/kitnovacweb/kitdef.js +92 -2
- package/kits/kitnovacweb/nvml/executor.js +578 -176
- package/kits/kitnovacweb/nvml/index.js +2 -2
- package/kits/kitnovacweb/nvml/lexer.js +72 -69
- package/kits/kitnovacweb/nvml/parser.js +328 -159
- package/kits/kitnovacweb/nvml/renderer.js +770 -270
- package/kits/kitparse/kitdef.js +1688 -0
- package/kits/kitproto/kitdef.js +613 -0
- package/kits/kitqr/kitdef.js +637 -0
- package/kits/kitregex++/kitdef.js +1353 -0
- package/kits/kitrequire/kitdef.js +1599 -0
- package/kits/kitx11/kitdef.js +1 -0
- package/kits/kitx11/kitx11.js +2472 -0
- package/kits/kitx11/kitx11_conn.js +948 -0
- package/kits/kitx11/kitx11_worker.js +121 -0
- package/kits/libtea/kitdef.js +2691 -0
- package/kits/libterm/ex.js +285 -0
- package/kits/libterm/kitdef.js +1927 -0
- package/novac/LICENSE +21 -0
- package/novac/README.md +1823 -0
- package/novac/bin/novac +950 -0
- package/novac/bin/nvc +522 -0
- package/novac/bin/nvml +542 -0
- package/novac/demo.nv +245 -0
- package/novac/demo_builtins.nv +209 -0
- package/novac/demo_http.nv +62 -0
- package/novac/examples/bf.nv +69 -0
- package/novac/examples/math.nv +21 -0
- package/novac/kits/kitai/kitdef.js +2185 -0
- package/novac/kits/kitansi/kitdef.js +1402 -0
- package/novac/kits/kitformat/kitdef.js +1485 -0
- package/novac/kits/kitgps/kitdef.js +1862 -0
- package/novac/kits/kitlibfs/kitdef.js +231 -0
- package/{examples/example-project/nova_modules → novac/kits}/kitlibproc/kitdef.js +3 -2
- package/novac/kits/kitmatrix/ex.js +19 -0
- package/novac/kits/kitmatrix/kitdef.js +960 -0
- package/novac/kits/kitmpatch/kitdef.js +906 -0
- package/novac/kits/kitnovacweb/README.md +1572 -0
- package/novac/kits/kitnovacweb/demo.nv +12 -0
- package/novac/kits/kitnovacweb/demo.nvml +71 -0
- package/novac/kits/kitnovacweb/index.nova +12 -0
- package/novac/kits/kitnovacweb/kitdef.js +692 -0
- package/novac/kits/kitnovacweb/nova.kit.json +8 -0
- package/novac/kits/kitnovacweb/nvml/executor.js +739 -0
- package/novac/kits/kitnovacweb/nvml/index.js +67 -0
- package/novac/kits/kitnovacweb/nvml/lexer.js +263 -0
- package/novac/kits/kitnovacweb/nvml/parser.js +508 -0
- package/novac/kits/kitnovacweb/nvml/renderer.js +924 -0
- package/novac/kits/kitparse/kitdef.js +1688 -0
- package/novac/kits/kitregex++/kitdef.js +1353 -0
- package/novac/kits/kitrequire/kitdef.js +1599 -0
- package/novac/kits/kitx11/kitdef.js +1 -0
- package/novac/kits/kitx11/kitx11.js +2472 -0
- package/novac/kits/kitx11/kitx11_conn.js +948 -0
- package/novac/kits/kitx11/kitx11_worker.js +121 -0
- package/novac/kits/libtea/tf.js +2691 -0
- package/novac/kits/libterm/ex.js +285 -0
- package/novac/kits/libterm/kitdef.js +1927 -0
- package/novac/node_modules/chalk/license +9 -0
- package/novac/node_modules/chalk/package.json +83 -0
- package/novac/node_modules/chalk/readme.md +297 -0
- package/novac/node_modules/chalk/source/index.d.ts +325 -0
- package/novac/node_modules/chalk/source/index.js +225 -0
- package/novac/node_modules/chalk/source/utilities.js +33 -0
- package/novac/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/novac/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/novac/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/novac/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
- package/novac/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/novac/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
- package/novac/node_modules/commander/LICENSE +22 -0
- package/novac/node_modules/commander/Readme.md +1176 -0
- package/novac/node_modules/commander/esm.mjs +16 -0
- package/novac/node_modules/commander/index.js +24 -0
- package/novac/node_modules/commander/lib/argument.js +150 -0
- package/novac/node_modules/commander/lib/command.js +2777 -0
- package/novac/node_modules/commander/lib/error.js +39 -0
- package/novac/node_modules/commander/lib/help.js +747 -0
- package/novac/node_modules/commander/lib/option.js +380 -0
- package/novac/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/novac/node_modules/commander/package-support.json +19 -0
- package/novac/node_modules/commander/package.json +82 -0
- package/novac/node_modules/commander/typings/esm.d.mts +3 -0
- package/novac/node_modules/commander/typings/index.d.ts +1113 -0
- package/novac/node_modules/node-addon-api/LICENSE.md +9 -0
- package/novac/node_modules/node-addon-api/README.md +95 -0
- package/novac/node_modules/node-addon-api/common.gypi +21 -0
- package/novac/node_modules/node-addon-api/except.gypi +25 -0
- package/novac/node_modules/node-addon-api/index.js +14 -0
- package/novac/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
- package/novac/node_modules/node-addon-api/napi-inl.h +7165 -0
- package/novac/node_modules/node-addon-api/napi.h +3364 -0
- package/novac/node_modules/node-addon-api/node_addon_api.gyp +42 -0
- package/novac/node_modules/node-addon-api/node_api.gyp +9 -0
- package/novac/node_modules/node-addon-api/noexcept.gypi +26 -0
- package/novac/node_modules/node-addon-api/package-support.json +21 -0
- package/novac/node_modules/node-addon-api/package.json +480 -0
- package/novac/node_modules/node-addon-api/tools/README.md +73 -0
- package/novac/node_modules/node-addon-api/tools/check-napi.js +99 -0
- package/novac/node_modules/node-addon-api/tools/clang-format.js +71 -0
- package/novac/node_modules/node-addon-api/tools/conversion.js +301 -0
- package/novac/node_modules/serialize-javascript/LICENSE +27 -0
- package/novac/node_modules/serialize-javascript/README.md +149 -0
- package/novac/node_modules/serialize-javascript/index.js +297 -0
- package/novac/node_modules/serialize-javascript/package.json +33 -0
- package/novac/package.json +27 -0
- package/novac/scripts/update-bin.js +24 -0
- package/novac/src/core/bstd.js +1035 -0
- package/novac/src/core/config.js +155 -0
- package/novac/src/core/describe.js +187 -0
- package/novac/src/core/emitter.js +499 -0
- package/novac/src/core/error.js +86 -0
- package/novac/src/core/executor.js +5606 -0
- package/novac/src/core/formatter.js +686 -0
- package/novac/src/core/lexer.js +1026 -0
- package/novac/src/core/nova_builtins.js +717 -0
- package/novac/src/core/nova_thread_worker.js +166 -0
- package/novac/src/core/parser.js +2181 -0
- package/novac/src/core/types.js +112 -0
- package/novac/src/index.js +28 -0
- package/novac/src/runtime/stdlib.js +244 -0
- package/package.json +6 -3
- package/scripts/update-bin.js +0 -0
- package/src/core/bstd.js +838 -362
- package/src/core/executor.js +2578 -170
- package/src/core/lexer.js +502 -54
- package/src/core/nova_builtins.js +21 -3
- package/src/core/parser.js +413 -72
- package/src/core/types.js +30 -2
- package/src/index.js +0 -0
- package/examples/example-project/README.md +0 -3
- package/examples/example-project/src/main.nova +0 -3
- package/src/core/environment.js +0 -0
- /package/{examples/example-project/bin/example-project.nv → novac/node_modules/node-addon-api/nothing.c} +0 -0
|
@@ -92,9 +92,11 @@ function makeNovaRunner() {
|
|
|
92
92
|
* request — the HTTP request context object
|
|
93
93
|
*/
|
|
94
94
|
const runner = (code, doc, reqCtx) => {
|
|
95
|
+
const { makeBfObject } = require('./nvml/executor');
|
|
95
96
|
const scope = {
|
|
96
97
|
document: makeDocumentProxy(doc),
|
|
97
98
|
request: reqCtx || {},
|
|
99
|
+
bf: makeBfObject(),
|
|
98
100
|
};
|
|
99
101
|
novaRun(code, scope);
|
|
100
102
|
};
|
|
@@ -103,7 +105,11 @@ function makeNovaRunner() {
|
|
|
103
105
|
* exec(code, scope) — run Nova with a fully custom scope object.
|
|
104
106
|
* Used by /_nvml/run to pass a mutation-capturing proxy directly.
|
|
105
107
|
*/
|
|
106
|
-
const exec = (code, scope) =>
|
|
108
|
+
const exec = (code, scope) => {
|
|
109
|
+
const { makeBfObject } = require('./nvml/executor');
|
|
110
|
+
if (!scope.bf) scope.bf = makeBfObject();
|
|
111
|
+
novaRun(code, scope);
|
|
112
|
+
};
|
|
107
113
|
|
|
108
114
|
return { runner, exec, emitter: null }; // emitter intentionally null: server-side only
|
|
109
115
|
}
|
|
@@ -354,6 +360,11 @@ class KitDocument {
|
|
|
354
360
|
return this._handleNvRun(req, res);
|
|
355
361
|
}
|
|
356
362
|
|
|
363
|
+
// ── /_nvml/run-node — Node.js server script execution endpoint ──
|
|
364
|
+
if (urlPath === '/_nvml/run-node' && req.method === 'POST') {
|
|
365
|
+
return this._handleNodeRun(req, res);
|
|
366
|
+
}
|
|
367
|
+
|
|
357
368
|
// ── static file serving ────────────────────────────────
|
|
358
369
|
for (const mount of this._staticMounts) {
|
|
359
370
|
if (urlPath.startsWith(mount.urlPath)) {
|
|
@@ -541,7 +552,86 @@ class KitDocument {
|
|
|
541
552
|
});
|
|
542
553
|
}
|
|
543
554
|
|
|
544
|
-
|
|
555
|
+
// ── /_nvml/run-node — run Node.js server script, return mutations ──
|
|
556
|
+
|
|
557
|
+
_handleNodeRun(req, res) {
|
|
558
|
+
let rawBody = '';
|
|
559
|
+
req.on('data', chunk => { rawBody += chunk; });
|
|
560
|
+
req.on('end', () => {
|
|
561
|
+
let code, live;
|
|
562
|
+
try {
|
|
563
|
+
const body = JSON.parse(rawBody);
|
|
564
|
+
code = String(body.code || '');
|
|
565
|
+
live = body.live || {};
|
|
566
|
+
} catch (e) {
|
|
567
|
+
return this._sendJSON(res, 400, { error: 'Invalid JSON body' });
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (!code.trim()) {
|
|
571
|
+
return this._sendJSON(res, 200, { mutations: [] });
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
const vm = require('vm');
|
|
575
|
+
const { makeBfObject } = require('./nvml/executor');
|
|
576
|
+
const mutations = [];
|
|
577
|
+
|
|
578
|
+
// Same mutation-capturing document proxy as _handleNvRun
|
|
579
|
+
const docProxy = {
|
|
580
|
+
setConfig: (k, v) => mutations.push({ type: 'setConfig', key: String(k), value: v }),
|
|
581
|
+
setTitle: (t) => mutations.push({ type: 'setConfig', key: 'title', value: t }),
|
|
582
|
+
setMeta: (k, v) => mutations.push({ type: 'setConfig', key: String(k), value: v }),
|
|
583
|
+
set: (id, val) => mutations.push({ type: 'setText', id: String(id), value: String(val) }),
|
|
584
|
+
setHTML: (id, val) => mutations.push({ type: 'setHTML', id: String(id), value: String(val) }),
|
|
585
|
+
setProp: (id, k, v)=> mutations.push({ type: 'setProp', id: String(id), key: String(k), value: String(v) }),
|
|
586
|
+
addClass: (id, cls) => mutations.push({ type: 'addClass', id: String(id), value: String(cls) }),
|
|
587
|
+
setClass: (id, cls) => mutations.push({ type: 'setClass', id: String(id), value: String(cls) }),
|
|
588
|
+
addStyle: (css) => mutations.push({ type: 'addStyle', value: String(css) }),
|
|
589
|
+
addElementStyle: (id, css) => mutations.push({ type: 'addStyle', id: String(id), value: String(css) }),
|
|
590
|
+
hide: (id, tr) => mutations.push({ type: 'hide', id: String(id), transition: tr }),
|
|
591
|
+
show: (id, d, tr)=> mutations.push({ type: 'show', id: String(id), value: d||'block', transition: tr }),
|
|
592
|
+
remove: (id, tr) => mutations.push({ type: 'remove', id: String(id), transition: tr }),
|
|
593
|
+
alert: (msg) => mutations.push({ type: 'alert', value: String(msg) }),
|
|
594
|
+
toast: (msg, dur, typ) => mutations.push({ type: 'toast', value: String(msg), duration: dur, type: typ }),
|
|
595
|
+
console: (msg, lv) => mutations.push({ type: 'console', value: String(msg), level: lv || 'log' }),
|
|
596
|
+
setSignal: (n, v) => mutations.push({ type: 'setSignal', name: String(n), value: v }),
|
|
597
|
+
navigate: (p) => mutations.push({ type: 'navigate', path: String(p) }),
|
|
598
|
+
reload: () => mutations.push({ type: 'reload' }),
|
|
599
|
+
redirect: (url) => mutations.push({ type: 'redirect', url: String(url) }),
|
|
600
|
+
setStyle: (id, k, v)=> mutations.push({ type: 'setStyle', id: String(id), key: String(k), value: String(v) }),
|
|
601
|
+
setCSSVar: (n, v) => mutations.push({ type: 'setCSSVar', name: String(n), value: String(v) }),
|
|
602
|
+
setAttr: (id, k, v)=> mutations.push({ type: 'setAttr', id: String(id), key: String(k), value: String(v) }),
|
|
603
|
+
removeAttr:(id, k) => mutations.push({ type: 'removeAttr',id: String(id), key: String(k) }),
|
|
604
|
+
focus: (id) => mutations.push({ type: 'focus', id: String(id) }),
|
|
605
|
+
blur: (id) => mutations.push({ type: 'blur', id: String(id) }),
|
|
606
|
+
scroll: (id, beh) => mutations.push({ type: 'scroll', id: String(id), behavior: beh }),
|
|
607
|
+
// reads from live snapshot
|
|
608
|
+
get: (id) => (live.elements && live.elements[id]) ? live.elements[id].text : null,
|
|
609
|
+
getSignal: (n) => (live.state && live.state[n]) !== undefined ? live.state[n] : null,
|
|
610
|
+
getConfig: (k) => live[k] ?? null,
|
|
611
|
+
config: live,
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
try {
|
|
615
|
+
const ctx = vm.createContext({
|
|
616
|
+
document: docProxy,
|
|
617
|
+
bf: makeBfObject(),
|
|
618
|
+
request: live,
|
|
619
|
+
console,
|
|
620
|
+
require,
|
|
621
|
+
process,
|
|
622
|
+
__dirname: process.cwd(),
|
|
623
|
+
__filename: '',
|
|
624
|
+
});
|
|
625
|
+
vm.runInContext(code, ctx, { timeout: 10000 });
|
|
626
|
+
return this._sendJSON(res, 200, { mutations });
|
|
627
|
+
} catch (e) {
|
|
628
|
+
process.stderr.write(`[kitnovacweb] /_nvml/run-node error: ${e.message}\n`);
|
|
629
|
+
return this._sendJSON(res, 500, { error: e.message, mutations });
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
|
|
545
635
|
const body = JSON.stringify(obj);
|
|
546
636
|
res.writeHead(code, {
|
|
547
637
|
'Content-Type': 'application/json; charset=UTF-8',
|