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.
Files changed (161) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1574 -597
  3. package/bin/novac +468 -171
  4. package/bin/nvc +522 -0
  5. package/bin/nvml +78 -17
  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 +69 -0
  10. package/examples/math.nv +21 -0
  11. package/kits/birdAPI/kitdef.js +954 -0
  12. package/kits/kitRNG/kitdef.js +740 -0
  13. package/kits/kitSSH/kitdef.js +1272 -0
  14. package/kits/kitadb/kitdef.js +606 -0
  15. package/kits/kitai/kitdef.js +2185 -0
  16. package/kits/kitansi/kitdef.js +1402 -0
  17. package/kits/kitcanvas/kitdef.js +914 -0
  18. package/kits/kitclippy/kitdef.js +925 -0
  19. package/kits/kitformat/kitdef.js +1485 -0
  20. package/kits/kitgps/kitdef.js +1862 -0
  21. package/kits/kitlibproc/kitdef.js +3 -2
  22. package/kits/kitmatrix/ex.js +19 -0
  23. package/kits/kitmatrix/kitdef.js +960 -0
  24. package/kits/kitmorse/kitdef.js +229 -0
  25. package/kits/kitmpatch/kitdef.js +906 -0
  26. package/kits/kitnet/kitdef.js +1401 -0
  27. package/kits/kitnovacweb/README.md +1416 -143
  28. package/kits/kitnovacweb/kitdef.js +92 -2
  29. package/kits/kitnovacweb/nvml/executor.js +578 -176
  30. package/kits/kitnovacweb/nvml/index.js +2 -2
  31. package/kits/kitnovacweb/nvml/lexer.js +72 -69
  32. package/kits/kitnovacweb/nvml/parser.js +328 -159
  33. package/kits/kitnovacweb/nvml/renderer.js +770 -270
  34. package/kits/kitparse/kitdef.js +1688 -0
  35. package/kits/kitproto/kitdef.js +613 -0
  36. package/kits/kitqr/kitdef.js +637 -0
  37. package/kits/kitregex++/kitdef.js +1353 -0
  38. package/kits/kitrequire/kitdef.js +1599 -0
  39. package/kits/kitx11/kitdef.js +1 -0
  40. package/kits/kitx11/kitx11.js +2472 -0
  41. package/kits/kitx11/kitx11_conn.js +948 -0
  42. package/kits/kitx11/kitx11_worker.js +121 -0
  43. package/kits/libtea/kitdef.js +2691 -0
  44. package/kits/libterm/ex.js +285 -0
  45. package/kits/libterm/kitdef.js +1927 -0
  46. package/novac/LICENSE +21 -0
  47. package/novac/README.md +1823 -0
  48. package/novac/bin/novac +950 -0
  49. package/novac/bin/nvc +522 -0
  50. package/novac/bin/nvml +542 -0
  51. package/novac/demo.nv +245 -0
  52. package/novac/demo_builtins.nv +209 -0
  53. package/novac/demo_http.nv +62 -0
  54. package/novac/examples/bf.nv +69 -0
  55. package/novac/examples/math.nv +21 -0
  56. package/novac/kits/kitai/kitdef.js +2185 -0
  57. package/novac/kits/kitansi/kitdef.js +1402 -0
  58. package/novac/kits/kitformat/kitdef.js +1485 -0
  59. package/novac/kits/kitgps/kitdef.js +1862 -0
  60. package/novac/kits/kitlibfs/kitdef.js +231 -0
  61. package/{examples/example-project/nova_modules → novac/kits}/kitlibproc/kitdef.js +3 -2
  62. package/novac/kits/kitmatrix/ex.js +19 -0
  63. package/novac/kits/kitmatrix/kitdef.js +960 -0
  64. package/novac/kits/kitmpatch/kitdef.js +906 -0
  65. package/novac/kits/kitnovacweb/README.md +1572 -0
  66. package/novac/kits/kitnovacweb/demo.nv +12 -0
  67. package/novac/kits/kitnovacweb/demo.nvml +71 -0
  68. package/novac/kits/kitnovacweb/index.nova +12 -0
  69. package/novac/kits/kitnovacweb/kitdef.js +692 -0
  70. package/novac/kits/kitnovacweb/nova.kit.json +8 -0
  71. package/novac/kits/kitnovacweb/nvml/executor.js +739 -0
  72. package/novac/kits/kitnovacweb/nvml/index.js +67 -0
  73. package/novac/kits/kitnovacweb/nvml/lexer.js +263 -0
  74. package/novac/kits/kitnovacweb/nvml/parser.js +508 -0
  75. package/novac/kits/kitnovacweb/nvml/renderer.js +924 -0
  76. package/novac/kits/kitparse/kitdef.js +1688 -0
  77. package/novac/kits/kitregex++/kitdef.js +1353 -0
  78. package/novac/kits/kitrequire/kitdef.js +1599 -0
  79. package/novac/kits/kitx11/kitdef.js +1 -0
  80. package/novac/kits/kitx11/kitx11.js +2472 -0
  81. package/novac/kits/kitx11/kitx11_conn.js +948 -0
  82. package/novac/kits/kitx11/kitx11_worker.js +121 -0
  83. package/novac/kits/libtea/tf.js +2691 -0
  84. package/novac/kits/libterm/ex.js +285 -0
  85. package/novac/kits/libterm/kitdef.js +1927 -0
  86. package/novac/node_modules/chalk/license +9 -0
  87. package/novac/node_modules/chalk/package.json +83 -0
  88. package/novac/node_modules/chalk/readme.md +297 -0
  89. package/novac/node_modules/chalk/source/index.d.ts +325 -0
  90. package/novac/node_modules/chalk/source/index.js +225 -0
  91. package/novac/node_modules/chalk/source/utilities.js +33 -0
  92. package/novac/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
  93. package/novac/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
  94. package/novac/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
  95. package/novac/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
  96. package/novac/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
  97. package/novac/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
  98. package/novac/node_modules/commander/LICENSE +22 -0
  99. package/novac/node_modules/commander/Readme.md +1176 -0
  100. package/novac/node_modules/commander/esm.mjs +16 -0
  101. package/novac/node_modules/commander/index.js +24 -0
  102. package/novac/node_modules/commander/lib/argument.js +150 -0
  103. package/novac/node_modules/commander/lib/command.js +2777 -0
  104. package/novac/node_modules/commander/lib/error.js +39 -0
  105. package/novac/node_modules/commander/lib/help.js +747 -0
  106. package/novac/node_modules/commander/lib/option.js +380 -0
  107. package/novac/node_modules/commander/lib/suggestSimilar.js +101 -0
  108. package/novac/node_modules/commander/package-support.json +19 -0
  109. package/novac/node_modules/commander/package.json +82 -0
  110. package/novac/node_modules/commander/typings/esm.d.mts +3 -0
  111. package/novac/node_modules/commander/typings/index.d.ts +1113 -0
  112. package/novac/node_modules/node-addon-api/LICENSE.md +9 -0
  113. package/novac/node_modules/node-addon-api/README.md +95 -0
  114. package/novac/node_modules/node-addon-api/common.gypi +21 -0
  115. package/novac/node_modules/node-addon-api/except.gypi +25 -0
  116. package/novac/node_modules/node-addon-api/index.js +14 -0
  117. package/novac/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
  118. package/novac/node_modules/node-addon-api/napi-inl.h +7165 -0
  119. package/novac/node_modules/node-addon-api/napi.h +3364 -0
  120. package/novac/node_modules/node-addon-api/node_addon_api.gyp +42 -0
  121. package/novac/node_modules/node-addon-api/node_api.gyp +9 -0
  122. package/novac/node_modules/node-addon-api/noexcept.gypi +26 -0
  123. package/novac/node_modules/node-addon-api/package-support.json +21 -0
  124. package/novac/node_modules/node-addon-api/package.json +480 -0
  125. package/novac/node_modules/node-addon-api/tools/README.md +73 -0
  126. package/novac/node_modules/node-addon-api/tools/check-napi.js +99 -0
  127. package/novac/node_modules/node-addon-api/tools/clang-format.js +71 -0
  128. package/novac/node_modules/node-addon-api/tools/conversion.js +301 -0
  129. package/novac/node_modules/serialize-javascript/LICENSE +27 -0
  130. package/novac/node_modules/serialize-javascript/README.md +149 -0
  131. package/novac/node_modules/serialize-javascript/index.js +297 -0
  132. package/novac/node_modules/serialize-javascript/package.json +33 -0
  133. package/novac/package.json +27 -0
  134. package/novac/scripts/update-bin.js +24 -0
  135. package/novac/src/core/bstd.js +1035 -0
  136. package/novac/src/core/config.js +155 -0
  137. package/novac/src/core/describe.js +187 -0
  138. package/novac/src/core/emitter.js +499 -0
  139. package/novac/src/core/error.js +86 -0
  140. package/novac/src/core/executor.js +5606 -0
  141. package/novac/src/core/formatter.js +686 -0
  142. package/novac/src/core/lexer.js +1026 -0
  143. package/novac/src/core/nova_builtins.js +717 -0
  144. package/novac/src/core/nova_thread_worker.js +166 -0
  145. package/novac/src/core/parser.js +2181 -0
  146. package/novac/src/core/types.js +112 -0
  147. package/novac/src/index.js +28 -0
  148. package/novac/src/runtime/stdlib.js +244 -0
  149. package/package.json +6 -3
  150. package/scripts/update-bin.js +0 -0
  151. package/src/core/bstd.js +838 -362
  152. package/src/core/executor.js +2578 -170
  153. package/src/core/lexer.js +502 -54
  154. package/src/core/nova_builtins.js +21 -3
  155. package/src/core/parser.js +413 -72
  156. package/src/core/types.js +30 -2
  157. package/src/index.js +0 -0
  158. package/examples/example-project/README.md +0 -3
  159. package/examples/example-project/src/main.nova +0 -3
  160. package/src/core/environment.js +0 -0
  161. /package/{examples/example-project/bin/example-project.nv → novac/node_modules/node-addon-api/nothing.c} +0 -0
@@ -0,0 +1,229 @@
1
+ // kitmorse — novac Morse code kit
2
+ // Encode/decode text ↔ Morse, audio timing, visual representations,
3
+ // multi-standard support (ITU, American, prosigns).
4
+
5
+ 'use strict';
6
+
7
+ // ─── CODE TABLES ─────────────────────────────────────────────────────────────
8
+
9
+ // ITU/International Morse Code
10
+ const ITU = {
11
+ // Letters
12
+ 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..',
13
+ 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....',
14
+ 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..',
15
+ 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.',
16
+ 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-',
17
+ 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-',
18
+ 'Y': '-.--', 'Z': '--..',
19
+ // Digits
20
+ '0': '-----', '1': '.----', '2': '..---', '3': '...--',
21
+ '4': '....-', '5': '.....', '6': '-....', '7': '--...',
22
+ '8': '---..', '9': '----.',
23
+ // Punctuation
24
+ '.': '.-.-.-', ',': '--..--', '?': '..--..', "'": '.----.',
25
+ '!': '-.-.--', '/': '-..-.', '(': '-.--.', ')': '-.--.-',
26
+ '&': '.-...', ':': '---...', ';': '-.-.-.', '=': '-...-',
27
+ '+': '.-.-.', '-': '-....-', '_': '..--.-', '"': '.-..-.',
28
+ '$': '...-..-','@': '.--.-.',
29
+ };
30
+
31
+ // American Morse Code (original Morse, used in North America historically)
32
+ const AMERICAN = {
33
+ 'A': '.-', 'B': '-...', 'C': '.. .', 'D': '-..',
34
+ 'E': '.', 'F': '.-.', 'G': '--.', 'H': '....',
35
+ 'I': '..', 'J': '-.-.', 'K': '-.-', 'L': '---',
36
+ 'M': '--', 'N': '-.', 'O': '. .', 'P': '.....',
37
+ 'Q': '..-.', 'R': '. ..', 'S': '...', 'T': '-',
38
+ 'U': '..-', 'V': '...-', 'W': '.--', 'X': '.-..',
39
+ 'Y': '.. ..', 'Z': '... .',
40
+ '0': '-----', '1': '.----', '2': '..---', '3': '...--',
41
+ '4': '....-', '5': '.....', '6': '-....', '7': '--...',
42
+ '8': '---..', '9': '----.',
43
+ '.': '.-.-.-', ',': '.-.-', '?': '-..-.',
44
+ };
45
+
46
+ // ITU Prosigns (procedural signals — sent as single characters)
47
+ const PROSIGNS = {
48
+ '<AR>': '.-.-.', // End of message
49
+ '<AS>': '.-...', // Wait
50
+ '<BK>': '-...-.-', // Break
51
+ '<BT>': '-...-', // New paragraph / separator
52
+ '<CL>': '-.-..-..',// Closing station
53
+ '<CT>': '-.-.-', // Start copying
54
+ '<DO>': '-..---', // Change to wabun code
55
+ '<HH>': '........',// Error
56
+ '<KN>': '-.--.', // Go ahead specific station
57
+ '<NJ>': '--.---', // Shift to wabun code
58
+ '<SK>': '...-.-', // End of contact
59
+ '<SN>': '...-.', // Understood
60
+ '<SOS>':'...---...', // Distress signal
61
+ };
62
+
63
+ // Reverse lookup tables
64
+ const ITU_REV = Object.fromEntries(Object.entries(ITU).map(([k,v]) => [v,k]));
65
+ const AMERICAN_REV = Object.fromEntries(Object.entries(AMERICAN).map(([k,v]) => [v,k]));
66
+ const PROSIGN_REV = Object.fromEntries(Object.entries(PROSIGNS).map(([k,v]) => [v,k]));
67
+
68
+ // Visual representations
69
+ const VISUAL = {
70
+ dot: '·',
71
+ dash: '−',
72
+ letterSep: ' ',
73
+ wordSep: ' / ',
74
+ };
75
+
76
+ // ─── ENCODE ───────────────────────────────────────────────────────────────────
77
+
78
+ function encode(text, opts = {}) {
79
+ const standard = opts.standard ?? 'itu'; // 'itu' | 'american'
80
+ const wordSep = opts.wordSep ?? ' / ';
81
+ const letterSep = opts.letterSep ?? ' ';
82
+ const visual = opts.visual ?? false; // use · and − instead of . and -
83
+ const table = standard === 'american' ? AMERICAN : ITU;
84
+
85
+ const dot = visual ? '·' : '.';
86
+ const dash = visual ? '−' : '-';
87
+
88
+ // Replace prosigns first
89
+ let input = text.toUpperCase();
90
+ const prosignMatches = [];
91
+ for (const ps of Object.keys(PROSIGNS)) {
92
+ const re = new RegExp(ps.replace(/[<>]/g,'\\$&'), 'g');
93
+ input = input.replace(re, (m) => { prosignMatches.push(m); return `\x00${prosignMatches.length - 1}\x00`; });
94
+ }
95
+
96
+ const words = input.split(' ');
97
+ const encodedWords = words.map(word => {
98
+ if (!word) return '';
99
+ const chars = [];
100
+ let i = 0;
101
+ while (i < word.length) {
102
+ // Check prosign placeholder
103
+ if (word[i] === '\x00') {
104
+ const end = word.indexOf('\x00', i + 1);
105
+ const idx = parseInt(word.slice(i + 1, end));
106
+ const ps = prosignMatches[idx];
107
+ chars.push(PROSIGNS[ps].replace(/\./g, dot).replace(/-/g, dash));
108
+ i = end + 1;
109
+ continue;
110
+ }
111
+ const ch = word[i];
112
+ const code = table[ch];
113
+ if (code) {
114
+ chars.push(code.replace(/\./g, dot).replace(/-/g, dash));
115
+ } else {
116
+ chars.push('?'); // unknown char
117
+ }
118
+ i++;
119
+ }
120
+ return chars.join(letterSep);
121
+ });
122
+
123
+ return encodedWords.filter(Boolean).join(wordSep);
124
+ }
125
+
126
+ // ─── DECODE ───────────────────────────────────────────────────────────────────
127
+
128
+ function decode(morse, opts = {}) {
129
+ const standard = opts.standard ?? 'itu';
130
+ const wordSep = opts.wordSep ?? ' / ';
131
+ const letterSep = opts.letterSep ?? ' ';
132
+ const table = standard === 'american' ? AMERICAN_REV : ITU_REV;
133
+
134
+ // Normalise visual chars
135
+ const normalised = morse
136
+ .replace(/·/g, '.')
137
+ .replace(/−/g, '-')
138
+ .replace(/\u2014/g, '-'); // em dash
139
+
140
+ const words = normalised.split(wordSep);
141
+ const decoded = words.map(word => {
142
+ const letters = word.trim().split(letterSep);
143
+ return letters.map(code => {
144
+ if (!code) return '';
145
+ // Check prosign
146
+ if (PROSIGN_REV[code]) return PROSIGN_REV[code];
147
+ return table[code] ?? `[${code}]`;
148
+ }).join('');
149
+ });
150
+
151
+ return decoded.join(' ');
152
+ }
153
+
154
+ // ─── TIMING ───────────────────────────────────────────────────────────────────
155
+
156
+ // Returns an array of {type, duration} objects for audio/light generation
157
+ // type: 'dot' | 'dash' | 'symbol-gap' | 'letter-gap' | 'word-gap' | 'silence'
158
+ function timing(text, opts = {}) {
159
+ const wpm = opts.wpm ?? 20; // words per minute (PARIS standard)
160
+ const standard = opts.standard ?? 'itu';
161
+
162
+ // PARIS standard: 1 dit = 1200 / wpm ms
163
+ const dit = 1200 / wpm;
164
+ const dah = dit * 3;
165
+ const symbolGap = dit;
166
+ const letterGap = dit * 3;
167
+ const wordGap = dit * 7;
168
+
169
+ const morseStr = encode(text, { standard, letterSep: '|', wordSep: '||' });
170
+ const events = [];
171
+
172
+ const words = morseStr.split('||');
173
+ for (let wi = 0; wi < words.length; wi++) {
174
+ const letters = words[wi].split('|');
175
+ for (let li = 0; li < letters.length; li++) {
176
+ const syms = letters[li];
177
+ for (let si = 0; si < syms.length; si++) {
178
+ const s = syms[si];
179
+ if (s === '.') events.push({ type: 'dot', duration: dit, on: true });
180
+ else if (s === '-') events.push({ type: 'dash', duration: dah, on: true });
181
+ else continue;
182
+ if (si < syms.length - 1) events.push({ type: 'symbol-gap', duration: symbolGap, on: false });
183
+ }
184
+ if (li < letters.length - 1) events.push({ type: 'letter-gap', duration: letterGap, on: false });
185
+ }
186
+ if (wi < words.length - 1) events.push({ type: 'word-gap', duration: wordGap, on: false });
187
+ }
188
+
189
+ return events;
190
+ }
191
+
192
+ // ─── ANALYSIS ─────────────────────────────────────────────────────────────────
193
+
194
+ function analyze(morse) {
195
+ const normalised = morse.replace(/·/g, '.').replace(/−/g, '-');
196
+ const dots = (normalised.match(/\./g) || []).length;
197
+ const dashes = (normalised.match(/-/g) || []).length;
198
+ const chars = normalised.replace(/ \/ /g, ' ').split(' ').length;
199
+ const words = (normalised.match(/ \/ /g) || []).length + 1;
200
+ return { dots, dashes, chars, words, length: normalised.length };
201
+ }
202
+
203
+ // ─── ALPHABET ─────────────────────────────────────────────────────────────────
204
+
205
+ function alphabet(opts = {}) {
206
+ const standard = opts.standard ?? 'itu';
207
+ const table = standard === 'american' ? AMERICAN : ITU;
208
+ return Object.entries(table).map(([char, code]) => ({ char, code }));
209
+ }
210
+
211
+ // ─── EXPORTS ─────────────────────────────────────────────────────────────────
212
+
213
+ module.exports = {
214
+ kitdef: {
215
+ encode,
216
+ decode,
217
+ timing,
218
+ analyze,
219
+ alphabet,
220
+ // Raw tables for advanced use
221
+ ITU,
222
+ AMERICAN,
223
+ PROSIGNS,
224
+ ITU_REV,
225
+ AMERICAN_REV,
226
+ PROSIGN_REV,
227
+ VISUAL,
228
+ }
229
+ };