novac 2.2.0 → 2.2.2

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.
Files changed (122) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +0 -0
  3. package/bin/novac +6 -3
  4. package/bin/nvc +0 -0
  5. package/bin/nvml +0 -0
  6. package/demo.nv +0 -0
  7. package/demo_builtins.nv +0 -0
  8. package/demo_http.nv +0 -0
  9. package/examples/bf.nv +5 -13
  10. package/examples/math.nv +2 -2
  11. package/kits/kitffmpeg/kitdef.js +1174 -0
  12. package/kits/libos/kitdef.js +3135 -0
  13. package/kits/libtasker/kitdef.js +125 -0
  14. package/package.json +1 -1
  15. package/scripts/update-bin.js +0 -0
  16. package/src/core/executor.js +7 -4
  17. package/src/core/lexer.js +2 -2
  18. package/src/index.js +0 -0
  19. package/novac/LICENSE +0 -21
  20. package/novac/README.md +0 -1823
  21. package/novac/bin/novac +0 -950
  22. package/novac/bin/nvc +0 -522
  23. package/novac/bin/nvml +0 -542
  24. package/novac/demo.nv +0 -245
  25. package/novac/demo_builtins.nv +0 -209
  26. package/novac/demo_http.nv +0 -62
  27. package/novac/examples/bf.nv +0 -69
  28. package/novac/examples/math.nv +0 -21
  29. package/novac/kits/kitai/kitdef.js +0 -2185
  30. package/novac/kits/kitansi/kitdef.js +0 -1402
  31. package/novac/kits/kitformat/kitdef.js +0 -1485
  32. package/novac/kits/kitgps/kitdef.js +0 -1862
  33. package/novac/kits/kitlibfs/kitdef.js +0 -231
  34. package/novac/kits/kitlibproc/kitdef.js +0 -78
  35. package/novac/kits/kitmatrix/ex.js +0 -19
  36. package/novac/kits/kitmatrix/kitdef.js +0 -960
  37. package/novac/kits/kitmpatch/kitdef.js +0 -906
  38. package/novac/kits/kitnovacweb/README.md +0 -1572
  39. package/novac/kits/kitnovacweb/demo.nv +0 -12
  40. package/novac/kits/kitnovacweb/demo.nvml +0 -71
  41. package/novac/kits/kitnovacweb/index.nova +0 -12
  42. package/novac/kits/kitnovacweb/kitdef.js +0 -692
  43. package/novac/kits/kitnovacweb/nova.kit.json +0 -8
  44. package/novac/kits/kitnovacweb/nvml/executor.js +0 -739
  45. package/novac/kits/kitnovacweb/nvml/index.js +0 -67
  46. package/novac/kits/kitnovacweb/nvml/lexer.js +0 -263
  47. package/novac/kits/kitnovacweb/nvml/parser.js +0 -508
  48. package/novac/kits/kitnovacweb/nvml/renderer.js +0 -924
  49. package/novac/kits/kitparse/kitdef.js +0 -1688
  50. package/novac/kits/kitregex++/kitdef.js +0 -1353
  51. package/novac/kits/kitrequire/kitdef.js +0 -1599
  52. package/novac/kits/kitx11/kitdef.js +0 -1
  53. package/novac/kits/kitx11/kitx11.js +0 -2472
  54. package/novac/kits/kitx11/kitx11_conn.js +0 -948
  55. package/novac/kits/kitx11/kitx11_worker.js +0 -121
  56. package/novac/kits/libtea/tf.js +0 -2691
  57. package/novac/kits/libterm/ex.js +0 -285
  58. package/novac/kits/libterm/kitdef.js +0 -1927
  59. package/novac/node_modules/chalk/license +0 -9
  60. package/novac/node_modules/chalk/package.json +0 -83
  61. package/novac/node_modules/chalk/readme.md +0 -297
  62. package/novac/node_modules/chalk/source/index.d.ts +0 -325
  63. package/novac/node_modules/chalk/source/index.js +0 -225
  64. package/novac/node_modules/chalk/source/utilities.js +0 -33
  65. package/novac/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +0 -236
  66. package/novac/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -223
  67. package/novac/node_modules/chalk/source/vendor/supports-color/browser.d.ts +0 -1
  68. package/novac/node_modules/chalk/source/vendor/supports-color/browser.js +0 -34
  69. package/novac/node_modules/chalk/source/vendor/supports-color/index.d.ts +0 -55
  70. package/novac/node_modules/chalk/source/vendor/supports-color/index.js +0 -190
  71. package/novac/node_modules/commander/LICENSE +0 -22
  72. package/novac/node_modules/commander/Readme.md +0 -1176
  73. package/novac/node_modules/commander/esm.mjs +0 -16
  74. package/novac/node_modules/commander/index.js +0 -24
  75. package/novac/node_modules/commander/lib/argument.js +0 -150
  76. package/novac/node_modules/commander/lib/command.js +0 -2777
  77. package/novac/node_modules/commander/lib/error.js +0 -39
  78. package/novac/node_modules/commander/lib/help.js +0 -747
  79. package/novac/node_modules/commander/lib/option.js +0 -380
  80. package/novac/node_modules/commander/lib/suggestSimilar.js +0 -101
  81. package/novac/node_modules/commander/package-support.json +0 -19
  82. package/novac/node_modules/commander/package.json +0 -82
  83. package/novac/node_modules/commander/typings/esm.d.mts +0 -3
  84. package/novac/node_modules/commander/typings/index.d.ts +0 -1113
  85. package/novac/node_modules/node-addon-api/LICENSE.md +0 -9
  86. package/novac/node_modules/node-addon-api/README.md +0 -95
  87. package/novac/node_modules/node-addon-api/common.gypi +0 -21
  88. package/novac/node_modules/node-addon-api/except.gypi +0 -25
  89. package/novac/node_modules/node-addon-api/index.js +0 -14
  90. package/novac/node_modules/node-addon-api/napi-inl.deprecated.h +0 -186
  91. package/novac/node_modules/node-addon-api/napi-inl.h +0 -7165
  92. package/novac/node_modules/node-addon-api/napi.h +0 -3364
  93. package/novac/node_modules/node-addon-api/node_addon_api.gyp +0 -42
  94. package/novac/node_modules/node-addon-api/node_api.gyp +0 -9
  95. package/novac/node_modules/node-addon-api/noexcept.gypi +0 -26
  96. package/novac/node_modules/node-addon-api/nothing.c +0 -0
  97. package/novac/node_modules/node-addon-api/package-support.json +0 -21
  98. package/novac/node_modules/node-addon-api/package.json +0 -480
  99. package/novac/node_modules/node-addon-api/tools/README.md +0 -73
  100. package/novac/node_modules/node-addon-api/tools/check-napi.js +0 -99
  101. package/novac/node_modules/node-addon-api/tools/clang-format.js +0 -71
  102. package/novac/node_modules/node-addon-api/tools/conversion.js +0 -301
  103. package/novac/node_modules/serialize-javascript/LICENSE +0 -27
  104. package/novac/node_modules/serialize-javascript/README.md +0 -149
  105. package/novac/node_modules/serialize-javascript/index.js +0 -297
  106. package/novac/node_modules/serialize-javascript/package.json +0 -33
  107. package/novac/package.json +0 -27
  108. package/novac/scripts/update-bin.js +0 -24
  109. package/novac/src/core/bstd.js +0 -1035
  110. package/novac/src/core/config.js +0 -155
  111. package/novac/src/core/describe.js +0 -187
  112. package/novac/src/core/emitter.js +0 -499
  113. package/novac/src/core/error.js +0 -86
  114. package/novac/src/core/executor.js +0 -5606
  115. package/novac/src/core/formatter.js +0 -686
  116. package/novac/src/core/lexer.js +0 -1026
  117. package/novac/src/core/nova_builtins.js +0 -717
  118. package/novac/src/core/nova_thread_worker.js +0 -166
  119. package/novac/src/core/parser.js +0 -2181
  120. package/novac/src/core/types.js +0 -112
  121. package/novac/src/index.js +0 -28
  122. package/novac/src/runtime/stdlib.js +0 -244
@@ -1,166 +0,0 @@
1
- /**
2
- * nova_thread_worker.js
3
- * Spawned by Executor._initThread() via worker_threads.Worker.
4
- *
5
- * workerData shape:
6
- * executorPath — absolute path to executor.js
7
- * scopeSnapshot — structured-clone of the caller's scope variables
8
- * (Nova class instances arrive as prototype-stripped plain
9
- * objects; rehydrate() restores the right constructors)
10
- * fnNode — structured-clone of the Nova AST function node to run
11
- * rawsrc — original source string (for error messages)
12
- *
13
- * Message protocol (parentPort):
14
- *
15
- * Worker → Main
16
- * { kind:'set', name, value } thread.set(name, val) — scope mutation
17
- * { kind:'print', text } stdout relay
18
- * { kind:'msg', value } thread.send(val)
19
- * { kind:'done', result } normal exit
20
- * { kind:'error', message } uncaught throw
21
- *
22
- * Main → Worker
23
- * { kind:'msg', value } t.send(val) from main side
24
- */
25
-
26
- 'use strict';
27
- const { parentPort, workerData, isMainThread } = require('worker_threads');
28
-
29
- // Guard: this file must only execute as a spawned Worker, never require()'d directly.
30
- if (isMainThread || !workerData) { module.exports = {}; return; }
31
-
32
- const { executorPath, scopeSnapshot, fnNode, rawsrc } = workerData;
33
-
34
- // ── load types from the same directory as executor ────────────────────────────
35
- const path = require('path');
36
- const typesPath = path.join(path.dirname(executorPath), 'types.js');
37
- const {
38
- NovaValue, NovaNumber, NovaString, NovaArray, NovaObject,
39
- NovaBool, NovaNull, NovaRange, NovaStruct, NovaEnum,
40
- } = require(typesPath);
41
-
42
- // ── rehydrate ─────────────────────────────────────────────────────────────────
43
- // structured-clone strips prototypes but preserves own properties.
44
- // We reconstruct the right Nova class from the shape of what arrived.
45
- function rehydrate(v) {
46
- if (v === null || v === undefined) return v;
47
- const t = typeof v;
48
- if (t === 'number' || t === 'string' || t === 'boolean') return v;
49
- if (t !== 'object') return v;
50
- if (Array.isArray(v)) return v.map(rehydrate);
51
-
52
- // NovaBool / NovaNumber / NovaString / NovaNull — all have _v
53
- if ('_v' in v) {
54
- if (v._v === null) return new NovaNull();
55
- if (typeof v._v === 'boolean') return new NovaBool(v._v);
56
- if (typeof v._v === 'number') return new NovaNumber(v._v);
57
- if (typeof v._v === 'string') return new NovaString(v._v);
58
- return v._v; // fallback
59
- }
60
-
61
- // NovaRange — { start, end }
62
- if ('start' in v && 'end' in v && Object.keys(v).length === 2)
63
- return new NovaRange(v.start, v.end);
64
-
65
- // NovaStruct — { typeName, inner: {} }
66
- if ('typeName' in v && 'inner' in v && typeof v.inner === 'object' && !Array.isArray(v.inner)) {
67
- const inner = {};
68
- for (const [k, val] of Object.entries(v.inner)) inner[k] = rehydrate(val);
69
- return new NovaStruct(v.typeName, inner);
70
- }
71
-
72
- // NovaArray — { inner: [] }
73
- if ('inner' in v && Array.isArray(v.inner))
74
- return new NovaArray(v.inner.map(rehydrate));
75
-
76
- // NovaObject — { inner: {} }
77
- if ('inner' in v && typeof v.inner === 'object' && !Array.isArray(v.inner)) {
78
- const inner = {};
79
- for (const [k, val] of Object.entries(v.inner)) inner[k] = rehydrate(val);
80
- return new NovaObject(inner);
81
- }
82
-
83
- // Nova AST function node — plain object with kind:'function', args, body
84
- // These pass through structured clone perfectly; return as-is.
85
- if ('kind' in v) return v;
86
-
87
- // Native JS functions were serialized to source strings by the main thread
88
- // and tagged { __jsfn__: '<source>' }
89
- if ('__jsfn__' in v) {
90
- try { return eval('(' + v.__jsfn__ + ')'); } catch { return null; }
91
- }
92
-
93
- // generic plain object — recurse
94
- const out = {};
95
- for (const [k, val] of Object.entries(v)) out[k] = rehydrate(val);
96
- return out;
97
- }
98
-
99
- // ── boot executor ─────────────────────────────────────────────────────────────
100
- const { Executor, Scope } = require(executorPath);
101
- const exe = new Executor(rawsrc || '');
102
-
103
- // relay stdout to main thread
104
- process.stdout.write = (text) => {
105
- parentPort.postMessage({ kind: 'print', text: String(text) });
106
- return true;
107
- };
108
-
109
- // ── hydrate scope ─────────────────────────────────────────────────────────────
110
- const workerScope = new Scope('thread', null, exe.globalScope);
111
- for (const [name, frozen] of Object.entries(scopeSnapshot || {})) {
112
- workerScope.set(name, rehydrate(frozen));
113
- }
114
-
115
- // ── inbox for thread.recv() ───────────────────────────────────────────────────
116
- const inbox = [];
117
- let inboxWaker = null;
118
- parentPort.on('message', (msg) => {
119
- if (msg.kind !== 'msg') return;
120
- const val = rehydrate(msg.value);
121
- if (inboxWaker) { const w = inboxWaker; inboxWaker = null; w(val); }
122
- else inbox.push(val);
123
- });
124
-
125
- // ── thread control object exposed as 'thread' inside the worker ───────────────
126
- const threadObj = new NovaObject({
127
- // Mutate a variable back in the main thread's scope (applied on join())
128
- set: (name, value) => {
129
- parentPort.postMessage({ kind: 'set', name: String(name), value });
130
- workerScope.set(String(name), value);
131
- return value;
132
- },
133
- // Non-blocking send to main
134
- send: (value) => {
135
- parentPort.postMessage({ kind: 'msg', value });
136
- return value;
137
- },
138
- // Sync-blocking receive from main (Atomics.wait)
139
- recv: () => {
140
- if (inbox.length) return inbox.shift();
141
- const sab = new SharedArrayBuffer(8);
142
- const flag = new Int32Array(sab);
143
- let result;
144
- inboxWaker = (v) => { result = v; Atomics.store(flag, 0, 1); Atomics.notify(flag, 0); };
145
- Atomics.wait(flag, 0, 0);
146
- return result;
147
- },
148
- print: (v) => {
149
- parentPort.postMessage({ kind: 'print', text: exe.stringify(v) + '\n' });
150
- },
151
- id: require('worker_threads').threadId,
152
- });
153
- workerScope.set('thread', threadObj);
154
-
155
- // ── run ───────────────────────────────────────────────────────────────────────
156
- const rehydratedFn = rehydrate(fnNode);
157
- try {
158
- const result = rehydratedFn && rehydratedFn.body
159
- ? exe.runFunctionNode(rehydratedFn, workerScope, [])
160
- : null;
161
- // result goes back raw via structured clone — main side rehydrates it too
162
- parentPort.postMessage({ kind: 'done', result });
163
- } catch (e) {
164
- const msg = e && e.message ? e.message : String(e);
165
- parentPort.postMessage({ kind: 'error', message: msg });
166
- }