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,231 @@
1
+ const { kStringMaxLength } = require('buffer');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ const filesystem = {
6
+ //note:this implementation is completely synchronous, It is only intended for use in development and testing environments.
7
+ //it should have all fs methods, but synchronous versions only.
8
+ read: (filePath, encoding = 'utf8') => {
9
+ const absolutePath = path.resolve(filePath);
10
+ if (!fs.existsSync(absolutePath)) {
11
+ throw new Error(`File not found: ${filePath}`);
12
+ }
13
+ return fs.readFileSync(absolutePath, encoding);
14
+ },
15
+ write: (filePath, content, encoding = 'utf8') => {
16
+ const absolutePath = path.resolve(filePath);
17
+ fs.writeFileSync(absolutePath, content, encoding);
18
+ },
19
+ exists: (filePath) => {
20
+ const absolutePath = path.resolve(filePath);
21
+ return fs.existsSync(absolutePath);
22
+ },
23
+ delete: (filePath) => {
24
+ const absolutePath = path.resolve(filePath);
25
+ if (fs.existsSync(absolutePath)) {
26
+ fs.unlinkSync(absolutePath);
27
+ }
28
+ },
29
+ list: (directoryPath) => {
30
+ const absolutePath = path.resolve(directoryPath);
31
+ return fs.readdirSync(absolutePath);
32
+ },
33
+ isDirectory: (filePath) => {
34
+ const absolutePath = path.resolve(filePath);
35
+ return fs.statSync(absolutePath).isDirectory();
36
+ },
37
+ createDirectory: (directoryPath) => {
38
+ const absolutePath = path.resolve(directoryPath);
39
+ fs.mkdirSync(absolutePath);
40
+ },
41
+ deleteDirectory: (directoryPath) => {
42
+ const absolutePath = path.resolve(directoryPath);
43
+ if (fs.existsSync(absolutePath)) {
44
+ fs.rmdirSync(absolutePath);
45
+ }
46
+ },
47
+ stats: (filePath) => {
48
+ const absolutePath = path.resolve(filePath);
49
+ return fs.statSync(absolutePath);
50
+ },
51
+ cp: (sourcePath, destinationPath) => {
52
+ const absoluteSourcePath = path.resolve(sourcePath);
53
+ const absoluteDestinationPath = path.resolve(destinationPath);
54
+ fs.copyFileSync(absoluteSourcePath, absoluteDestinationPath);
55
+ },
56
+ cpDir: (sourceDir, destinationDir) => {
57
+ const absoluteSourceDir = path.resolve(sourceDir);
58
+ const absoluteDestinationDir = path.resolve(destinationDir);
59
+ if (!fs.existsSync(absoluteDestinationDir)) {
60
+ fs.mkdirSync(absoluteDestinationDir);
61
+ }
62
+ const items = fs.readdirSync(absoluteSourceDir);
63
+ items.forEach(item => {
64
+ const sourceItemPath = path.join(absoluteSourceDir, item);
65
+ const destinationItemPath = path.join(absoluteDestinationDir, item);
66
+ if (fs.statSync(sourceItemPath).isDirectory()) {
67
+ filesystem.cpDir(sourceItemPath, destinationItemPath);
68
+ } else {
69
+ fs.copyFileSync(sourceItemPath, destinationItemPath);
70
+ }
71
+ });
72
+ },
73
+ appendFile: (filePath, content, encoding = 'utf8') => {
74
+ const absolutePath = path.resolve(filePath);
75
+ fs.appendFileSync(absolutePath, content, encoding);
76
+ },
77
+ rename: (oldPath, newPath) => {
78
+ const absoluteOldPath = path.resolve(oldPath);
79
+ const absoluteNewPath = path.resolve(newPath);
80
+ fs.renameSync(absoluteOldPath, absoluteNewPath);
81
+ },
82
+ access: (filePath, mode = fs.constants.F_OK) => {
83
+ const absolutePath = path.resolve(filePath);
84
+ try {
85
+ fs.accessSync(absolutePath, mode);
86
+ return true;
87
+ } catch {
88
+ return false;
89
+ }
90
+ },
91
+ chmod: (filePath, mode) => {
92
+ const absolutePath = path.resolve(filePath);
93
+ fs.chmodSync(absolutePath, mode);
94
+ },
95
+ readlink: (filePath) => {
96
+ const absolutePath = path.resolve(filePath);
97
+ return fs.readlinkSync(absolutePath);
98
+ },
99
+ symlink: (target, filePath, type = 'file') => {
100
+ const absoluteTarget = path.resolve(target);
101
+ const absolutePath = path.resolve(filePath);
102
+ fs.symlinkSync(absoluteTarget, absolutePath, type);
103
+ },
104
+ link: (existingPath, newPath) => {
105
+ const absoluteExistingPath = path.resolve(existingPath);
106
+ const absoluteNewPath = path.resolve(newPath);
107
+ fs.linkSync(absoluteExistingPath, absoluteNewPath);
108
+ },
109
+ lstat: (filePath) => {
110
+ const absolutePath = path.resolve(filePath);
111
+ return fs.lstatSync(absolutePath);
112
+ },
113
+ realpath: (filePath) => {
114
+ const absolutePath = path.resolve(filePath);
115
+ return fs.realpathSync(absolutePath);
116
+ },
117
+ isFile: (filePath) => {
118
+ const absolutePath = path.resolve(filePath);
119
+ if (!fs.existsSync(absolutePath)) return false;
120
+ return fs.statSync(absolutePath).isFile();
121
+ },
122
+ isSymbolicLink: (filePath) => {
123
+ const absolutePath = path.resolve(filePath);
124
+ if (!fs.existsSync(absolutePath)) return false;
125
+ return fs.lstatSync(absolutePath).isSymbolicLink();
126
+ },
127
+ truncate: (filePath, len = 0) => {
128
+ const absolutePath = path.resolve(filePath);
129
+ fs.truncateSync(absolutePath, len);
130
+ },
131
+ mkdtemp: (prefix) => {
132
+ return fs.mkdtempSync(prefix);
133
+ },
134
+ rm: (filePath, options = {}) => {
135
+ const absolutePath = path.resolve(filePath);
136
+ if (fs.existsSync(absolutePath)) {
137
+ const stat = fs.statSync(absolutePath);
138
+ if (stat.isDirectory()) {
139
+ if (options.recursive) {
140
+ fs.rmSync(absolutePath, { recursive: true });
141
+ } else {
142
+ fs.rmdirSync(absolutePath);
143
+ }
144
+ } else {
145
+ fs.unlinkSync(absolutePath);
146
+ }
147
+ }
148
+ },
149
+ dirents: (directoryPath) => {
150
+ const absolutePath = path.resolve(directoryPath);
151
+ return fs.readdirSync(absolutePath, { withFileTypes: true });
152
+ },
153
+ // Path utilities
154
+ pathDirname: (filePath) => {
155
+ return path.dirname(filePath);
156
+ },
157
+ pathBasename: (filePath, ext = '') => {
158
+ return path.basename(filePath, ext);
159
+ },
160
+ pathExtname: (filePath) => {
161
+ return path.extname(filePath);
162
+ },
163
+ pathJoin: (...paths) => {
164
+ return path.join(...paths);
165
+ },
166
+ pathResolve: (...paths) => {
167
+ return path.resolve(...paths);
168
+ },
169
+ pathRelative: (from, to) => {
170
+ return path.relative(from, to);
171
+ },
172
+ pathNormalize: (filePath) => {
173
+ return path.normalize(filePath);
174
+ },
175
+ pathParse: (filePath) => {
176
+ return path.parse(filePath);
177
+ },
178
+ pathFormat: (pathObj) => {
179
+ return path.format(pathObj);
180
+ },
181
+ pathIsAbsolute: (filePath) => {
182
+ return path.isAbsolute(filePath);
183
+ },
184
+ getSize: (filePath) => {
185
+ const absolutePath = path.resolve(filePath);
186
+ return fs.statSync(absolutePath).size;
187
+ },
188
+ isReadable: (filePath) => {
189
+ const absolutePath = path.resolve(filePath);
190
+ try {
191
+ fs.accessSync(absolutePath, fs.constants.R_OK);
192
+ return true;
193
+ } catch {
194
+ return false;
195
+ }
196
+ },
197
+ isWritable: (filePath) => {
198
+ const absolutePath = path.resolve(filePath);
199
+ try {
200
+ fs.accessSync(absolutePath, fs.constants.W_OK);
201
+ return true;
202
+ } catch {
203
+ return false;
204
+ }
205
+ },
206
+ isExecutable: (filePath) => {
207
+ const absolutePath = path.resolve(filePath);
208
+ try {
209
+ fs.accessSync(absolutePath, fs.constants.X_OK);
210
+ return true;
211
+ } catch {
212
+ return false;
213
+ }
214
+ },
215
+ getModifiedTime: (filePath) => {
216
+ const absolutePath = path.resolve(filePath);
217
+ return fs.statSync(absolutePath).mtime;
218
+ },
219
+ getCreatedTime: (filePath) => {
220
+ const absolutePath = path.resolve(filePath);
221
+ return fs.statSync(absolutePath).birthtime;
222
+ },
223
+ getAccessedTime: (filePath) => {
224
+ const absolutePath = path.resolve(filePath);
225
+ return fs.statSync(absolutePath).atime;
226
+ },
227
+ };
228
+
229
+ module.exports = {
230
+ kitdef: filesystem
231
+ };
@@ -54,7 +54,7 @@ const proc = {
54
54
 
55
55
  // Temp file helpers
56
56
  tmpFile(ext = '.tmp') {
57
- return path.join(os.tmpdir(), `nova_${Date.now()}${ext}`);
57
+ return path.join(os.tmpdir(), `nv_tmp_${Date.now()}${ext}`);
58
58
  },
59
59
  tmpDir() {
60
60
  const d = fs.mkdtempSync(path.join(os.tmpdir(), 'nova_'));
@@ -62,7 +62,7 @@ const proc = {
62
62
  },
63
63
 
64
64
  // Sleep (blocking) in ms
65
- sleep(ms) {
65
+ sleepSync(ms) {
66
66
  const t = Date.now() + ms;
67
67
  while (Date.now() < t) { /* spin */ }
68
68
  },
@@ -72,6 +72,7 @@ const proc = {
72
72
 
73
73
  // argv passthrough
74
74
  argv() { return process.argv.slice(2); },
75
+ ...process
75
76
  };
76
77
 
77
78
  module.exports = { kitdef: proc };
@@ -0,0 +1,19 @@
1
+ const { Matrix } = require("./kitdef").kitdef;
2
+
3
+ const m = new Matrix(20, 20);
4
+
5
+ const grid = m.grid(10, 10, 0, 0, 2, 2);
6
+
7
+ const player = grid.at(2, 2)
8
+ .clone()
9
+ .withLabel("@");
10
+
11
+ const target = grid.at(8, 7)
12
+ .clone()
13
+ .withLabel("X");
14
+
15
+ console.log(player.distanceTo(target));
16
+
17
+ const neighbors = grid.neighbors(2, 2, true);
18
+
19
+ m.render.frame()