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
@@ -12,7 +12,7 @@
12
12
 
13
13
  const { Lexer } = require('./lexer');
14
14
  const { Parser } = require('./parser');
15
- const { Executor, NvmlDocument } = require('./executor');
15
+ const { Executor, NvmlDocument, makeBfObject } = require('./executor');
16
16
  const { Renderer } = require('./renderer');
17
17
 
18
18
  /**
@@ -64,4 +64,4 @@ function run(source, opts = {}) {
64
64
  return { doc, html, ast };
65
65
  }
66
66
 
67
- module.exports = { parse, executeAst, renderDoc, compile, run, NvmlDocument };
67
+ module.exports = { parse, executeAst, renderDoc, compile, run, NvmlDocument, makeBfObject };
@@ -1,21 +1,21 @@
1
1
  'use strict';
2
2
 
3
- // ══════════════════════════════════════════════════════════
4
- // NVML Lexer
5
- // Tokens:
6
- // AT_IDENT @config @visual @ss
7
- // ELEMENT {h1} {div} {element.button} {script}
8
- // LBRACKET [ RBRACKET ]
9
- // LPAREN ( RPAREN )
10
- // COLONCOLON ::
11
- // EQ =
12
- // COMMA ,
13
- // PIPE |
14
- // STRING 'text' "text" (multiline...)
15
- // IDENT bare word
16
- // NUMBER numeric literal
17
- // EOF
18
- // ══════════════════════════════════════════════════════════
3
+ // ══════════════════════════════════════════════════════════════════════
4
+ // NVML Lexer v2
5
+ // New tokens:
6
+ // HASH #signal-name (reactive signal ref)
7
+ // BANG_IDENT !event (event emit shorthand)
8
+ // AT_IDENT @config @visual @ss @component @state @computed @effect @route @slot @use
9
+ // ELEMENT {tag} {element.tag} {component.Name}
10
+ // LBRACKET [ RBRACKET ]
11
+ // LPAREN ( (multiline string / expression)
12
+ // COLONCOLON ::
13
+ // ARROW -> (one-way binding)
14
+ // DARROW <-> (two-way binding)
15
+ // QUESTION ? (conditional render)
16
+ // TILDE ~ (transition/animation hint)
17
+ // EQ = COMMA , PIPE | STRING IDENT NUMBER DOT DOTDOT EOF
18
+ // ══════════════════════════════════════════════════════════════════════
19
19
 
20
20
  const TT = {
21
21
  AT_IDENT: 'AT_IDENT',
@@ -25,6 +25,12 @@ const TT = {
25
25
  LPAREN: 'LPAREN',
26
26
  RPAREN: 'RPAREN',
27
27
  COLONCOLON: 'COLONCOLON',
28
+ ARROW: 'ARROW', // ->
29
+ DARROW: 'DARROW', // <->
30
+ QUESTION: 'QUESTION', // ?
31
+ TILDE: 'TILDE', // ~
32
+ HASH: 'HASH', // #signalName
33
+ BANG_IDENT: 'BANG_IDENT', // !eventName
28
34
  EQ: 'EQ',
29
35
  COMMA: 'COMMA',
30
36
  PIPE: 'PIPE',
@@ -32,7 +38,7 @@ const TT = {
32
38
  IDENT: 'IDENT',
33
39
  NUMBER: 'NUMBER',
34
40
  DOT: 'DOT',
35
- DOTDOT: 'DOTDOT', // [..] parent ref
41
+ DOTDOT: 'DOTDOT',
36
42
  EOF: 'EOF',
37
43
  };
38
44
 
@@ -55,15 +61,13 @@ class LexError extends Error {
55
61
 
56
62
  class Lexer {
57
63
  constructor(source) {
58
- this.src = source;
59
- this.pos = 0;
60
- this.line = 1;
61
- this.col = 1;
64
+ this.src = source;
65
+ this.pos = 0;
66
+ this.line = 1;
67
+ this.col = 1;
62
68
  this.tokens = [];
63
69
  }
64
70
 
65
- // ── helpers ──────────────────────────────────────────────
66
-
67
71
  peek(offset = 0) { return this.src[this.pos + offset] ?? '\0'; }
68
72
  isAtEnd() { return this.pos >= this.src.length; }
69
73
 
@@ -82,16 +86,13 @@ class Lexer {
82
86
  skipWhitespaceAndComments() {
83
87
  while (!this.isAtEnd()) {
84
88
  const ch = this.peek();
85
- // whitespace
86
- if (ch === ' ' || ch === '\t' || ch === '\r' || ch === '\n') {
87
- this.advance(); continue;
88
- }
89
- // line comment // ...
89
+ if (ch === ' ' || ch === '\t' || ch === '\r' || ch === '\n') { this.advance(); continue; }
90
+ // line comment
90
91
  if (ch === '/' && this.peek(1) === '/') {
91
92
  while (!this.isAtEnd() && this.peek() !== '\n') this.advance();
92
93
  continue;
93
94
  }
94
- // block comment /* ... */
95
+ // block comment
95
96
  if (ch === '/' && this.peek(1) === '*') {
96
97
  this.advance(); this.advance();
97
98
  while (!this.isAtEnd()) {
@@ -104,21 +105,16 @@ class Lexer {
104
105
  }
105
106
  }
106
107
 
107
- // ── string readers ───────────────────────────────────────
108
-
109
108
  readQuotedString(quote) {
110
- // already consumed opening quote
111
109
  let val = '';
112
110
  while (!this.isAtEnd()) {
113
111
  const ch = this.advance();
114
112
  if (ch === '\\') {
115
113
  const esc = this.advance();
116
114
  switch (esc) {
117
- case 'n': val += '\n'; break;
118
- case 't': val += '\t'; break;
119
- case 'r': val += '\r'; break;
120
- case '\\': val += '\\'; break;
121
- default: val += esc;
115
+ case 'n': val += '\n'; break; case 't': val += '\t'; break;
116
+ case 'r': val += '\r'; break; case '\\': val += '\\'; break;
117
+ default: val += esc;
122
118
  }
123
119
  continue;
124
120
  }
@@ -129,11 +125,7 @@ class Lexer {
129
125
  }
130
126
 
131
127
  readParenString() {
132
- // already consumed '('
133
- // multiline string, terminated by matching ')'
134
- // we track depth so nested parens inside code are fine
135
- let val = '';
136
- let depth = 1;
128
+ let val = '', depth = 1;
137
129
  while (!this.isAtEnd()) {
138
130
  const ch = this.advance();
139
131
  if (ch === '(') { depth++; val += ch; continue; }
@@ -143,39 +135,26 @@ class Lexer {
143
135
  return val;
144
136
  }
145
137
 
146
- // ── element token {name} {element.name} {..} ──────────
147
-
148
138
  readElement() {
149
- // already consumed '{'
150
139
  let name = '';
151
140
  while (!this.isAtEnd() && this.peek() !== '}') name += this.advance();
152
141
  if (this.isAtEnd()) this.error("Unterminated element name, expected '}'");
153
- this.advance(); // consume '}'
154
- name = name.trim();
155
- return name;
142
+ this.advance();
143
+ return name.trim();
156
144
  }
157
145
 
158
- // ── identifier ───────────────────────────────────────────
159
-
160
146
  readIdent(firstChar) {
161
147
  let val = firstChar;
162
- while (!this.isAtEnd()) {
163
- const ch = this.peek();
164
- if (/[a-zA-Z0-9_\-]/.test(ch)) { val += this.advance(); } else break;
165
- }
148
+ while (!this.isAtEnd() && /[a-zA-Z0-9_\-]/.test(this.peek())) val += this.advance();
166
149
  return val;
167
150
  }
168
151
 
169
- // ── number ───────────────────────────────────────────────
170
-
171
152
  readNumber(firstChar) {
172
153
  let val = firstChar;
173
154
  while (!this.isAtEnd() && /[0-9\.]/.test(this.peek())) val += this.advance();
174
155
  return parseFloat(val);
175
156
  }
176
157
 
177
- // ── main tokenize ─────────────────────────────────────────
178
-
179
158
  tokenize() {
180
159
  while (true) {
181
160
  this.skipWhitespaceAndComments();
@@ -186,15 +165,12 @@ class Lexer {
186
165
 
187
166
  switch (ch) {
188
167
  case '[': {
189
- // check for [..] parent ref
190
168
  if (this.peek() === '.' && this.peek(1) === '.') {
191
- this.advance(); this.advance(); // consume ..
169
+ this.advance(); this.advance();
192
170
  if (this.peek() === ']') {
193
- this.advance(); // consume ]
171
+ this.advance();
194
172
  this.tokens.push(new Token(TT.DOTDOT, '..', line, col));
195
- } else {
196
- this.error("Expected ']' after '..'");
197
- }
173
+ } else { this.error("Expected ']' after '..'"); }
198
174
  } else {
199
175
  this.tokens.push(new Token(TT.LBRACKET, '[', line, col));
200
176
  }
@@ -202,7 +178,6 @@ class Lexer {
202
178
  }
203
179
  case ']': this.tokens.push(new Token(TT.RBRACKET, ']', line, col)); break;
204
180
  case '(': {
205
- // multiline string
206
181
  const val = this.readParenString();
207
182
  this.tokens.push(new Token(TT.STRING, val, line, col));
208
183
  break;
@@ -211,9 +186,23 @@ class Lexer {
211
186
  case ',': this.tokens.push(new Token(TT.COMMA, ',', line, col)); break;
212
187
  case '|': this.tokens.push(new Token(TT.PIPE, '|', line, col)); break;
213
188
  case '=': this.tokens.push(new Token(TT.EQ, '=', line, col)); break;
189
+ case '?': this.tokens.push(new Token(TT.QUESTION, '?', line, col)); break;
190
+ case '~': this.tokens.push(new Token(TT.TILDE, '~', line, col)); break;
191
+ case '-': {
192
+ if (this.peek() === '>') { this.advance(); this.tokens.push(new Token(TT.ARROW, '->', line, col)); }
193
+ else this.error("Unexpected '-', did you mean '->'?");
194
+ break;
195
+ }
196
+ case '<': {
197
+ if (this.peek() === '-' && this.peek(1) === '>') {
198
+ this.advance(); this.advance();
199
+ this.tokens.push(new Token(TT.DARROW, '<->', line, col));
200
+ } else { this.error("Unexpected '<', did you mean '<->'?"); }
201
+ break;
202
+ }
214
203
  case ':': {
215
204
  if (this.peek() === ':') { this.advance(); this.tokens.push(new Token(TT.COLONCOLON, '::', line, col)); }
216
- else this.error("Unexpected ':' did you mean '::'?");
205
+ else this.error("Unexpected ':', did you mean '::'?");
217
206
  break;
218
207
  }
219
208
  case '.': {
@@ -221,13 +210,27 @@ class Lexer {
221
210
  else this.tokens.push(new Token(TT.DOT, '.', line, col));
222
211
  break;
223
212
  }
213
+ case '#': {
214
+ // #signalName — reactive signal reference
215
+ if (/[a-zA-Z_]/.test(this.peek())) {
216
+ const name = this.readIdent(this.advance());
217
+ this.tokens.push(new Token(TT.HASH, name, line, col));
218
+ } else { this.error("Expected signal name after '#'"); }
219
+ break;
220
+ }
221
+ case '!': {
222
+ // !eventName — event emit shorthand
223
+ if (/[a-zA-Z_]/.test(this.peek())) {
224
+ const name = this.readIdent(this.advance());
225
+ this.tokens.push(new Token(TT.BANG_IDENT, name, line, col));
226
+ } else { this.error("Expected event name after '!'"); }
227
+ break;
228
+ }
224
229
  case '@': {
225
230
  if (/[a-zA-Z_]/.test(this.peek())) {
226
231
  const name = this.readIdent(this.advance());
227
232
  this.tokens.push(new Token(TT.AT_IDENT, name, line, col));
228
- } else {
229
- this.error("Expected identifier after '@'");
230
- }
233
+ } else { this.error("Expected identifier after '@'"); }
231
234
  break;
232
235
  }
233
236
  case '{': {