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
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
|
|
3
|
+
Copyrights licensed under the New BSD License.
|
|
4
|
+
See the accompanying LICENSE file for terms.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
// Generate an internal UID to make the regexp pattern harder to guess.
|
|
10
|
+
var UID_LENGTH = 16;
|
|
11
|
+
var UID = generateUID();
|
|
12
|
+
var PLACE_HOLDER_REGEXP = new RegExp('(\\\\)?"@__(F|R|D|M|S|A|U|I|B|L)-' + UID + '-(\\d+)__@"', 'g');
|
|
13
|
+
|
|
14
|
+
var IS_NATIVE_CODE_REGEXP = /\{\s*\[native code\]\s*\}/g;
|
|
15
|
+
var IS_PURE_FUNCTION = /function.*?\(/;
|
|
16
|
+
var IS_ARROW_FUNCTION = /.*?=>.*?/;
|
|
17
|
+
var UNSAFE_CHARS_REGEXP = /[<>\/\u2028\u2029]/g;
|
|
18
|
+
// Regex to match </script> and variations (case-insensitive) for XSS protection
|
|
19
|
+
// Matches </script followed by optional whitespace/attributes and >
|
|
20
|
+
var SCRIPT_CLOSE_REGEXP = /<\/script[^>]*>/gi;
|
|
21
|
+
|
|
22
|
+
var RESERVED_SYMBOLS = ['*', 'async'];
|
|
23
|
+
|
|
24
|
+
// Mapping of unsafe HTML and invalid JavaScript line terminator chars to their
|
|
25
|
+
// Unicode char counterparts which are safe to use in JavaScript strings.
|
|
26
|
+
var ESCAPED_CHARS = {
|
|
27
|
+
'<' : '\\u003C',
|
|
28
|
+
'>' : '\\u003E',
|
|
29
|
+
'/' : '\\u002F',
|
|
30
|
+
'\u2028': '\\u2028',
|
|
31
|
+
'\u2029': '\\u2029'
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function escapeUnsafeChars(unsafeChar) {
|
|
35
|
+
return ESCAPED_CHARS[unsafeChar];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Escape function body for XSS protection while preserving arrow function syntax
|
|
39
|
+
function escapeFunctionBody(str) {
|
|
40
|
+
// Escape </script> sequences and variations (case-insensitive) - the main XSS risk
|
|
41
|
+
// Matches </script followed by optional whitespace/attributes and >
|
|
42
|
+
// This must be done first before other replacements
|
|
43
|
+
str = str.replace(SCRIPT_CLOSE_REGEXP, function(match) {
|
|
44
|
+
// Escape all <, /, and > characters in the closing script tag
|
|
45
|
+
return match.replace(/</g, '\\u003C').replace(/\//g, '\\u002F').replace(/>/g, '\\u003E');
|
|
46
|
+
});
|
|
47
|
+
// Escape line terminators (these are always unsafe)
|
|
48
|
+
str = str.replace(/\u2028/g, '\\u2028');
|
|
49
|
+
str = str.replace(/\u2029/g, '\\u2029');
|
|
50
|
+
return str;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function generateUID() {
|
|
54
|
+
var bytes = crypto.getRandomValues(new Uint8Array(UID_LENGTH));
|
|
55
|
+
var result = '';
|
|
56
|
+
for(var i=0; i<UID_LENGTH; ++i) {
|
|
57
|
+
result += bytes[i].toString(16);
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function deleteFunctions(obj){
|
|
63
|
+
var functionKeys = [];
|
|
64
|
+
for (var key in obj) {
|
|
65
|
+
if (typeof obj[key] === "function") {
|
|
66
|
+
functionKeys.push(key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (var i = 0; i < functionKeys.length; i++) {
|
|
70
|
+
delete obj[functionKeys[i]];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = function serialize(obj, options) {
|
|
75
|
+
options || (options = {});
|
|
76
|
+
|
|
77
|
+
// Backwards-compatibility for `space` as the second argument.
|
|
78
|
+
if (typeof options === 'number' || typeof options === 'string') {
|
|
79
|
+
options = {space: options};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var functions = [];
|
|
83
|
+
var regexps = [];
|
|
84
|
+
var dates = [];
|
|
85
|
+
var maps = [];
|
|
86
|
+
var sets = [];
|
|
87
|
+
var arrays = [];
|
|
88
|
+
var undefs = [];
|
|
89
|
+
var infinities= [];
|
|
90
|
+
var bigInts = [];
|
|
91
|
+
var urls = [];
|
|
92
|
+
|
|
93
|
+
// Returns placeholders for functions and regexps (identified by index)
|
|
94
|
+
// which are later replaced by their string representation.
|
|
95
|
+
function replacer(key, value) {
|
|
96
|
+
|
|
97
|
+
// For nested function
|
|
98
|
+
if(options.ignoreFunction){
|
|
99
|
+
deleteFunctions(value);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!value && value !== undefined && value !== BigInt(0)) {
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// If the value is an object w/ a toJSON method, toJSON is called before
|
|
107
|
+
// the replacer runs, so we use this[key] to get the non-toJSONed value.
|
|
108
|
+
var origValue = this[key];
|
|
109
|
+
var type = typeof origValue;
|
|
110
|
+
|
|
111
|
+
if (type === 'object') {
|
|
112
|
+
if(origValue instanceof RegExp) {
|
|
113
|
+
return '@__R-' + UID + '-' + (regexps.push(origValue) - 1) + '__@';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if(origValue instanceof Date) {
|
|
117
|
+
return '@__D-' + UID + '-' + (dates.push(origValue) - 1) + '__@';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if(origValue instanceof Map) {
|
|
121
|
+
return '@__M-' + UID + '-' + (maps.push(origValue) - 1) + '__@';
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if(origValue instanceof Set) {
|
|
125
|
+
return '@__S-' + UID + '-' + (sets.push(origValue) - 1) + '__@';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if(Array.isArray(origValue)) {
|
|
129
|
+
var isSparse = Object.keys(origValue).length !== origValue.length;
|
|
130
|
+
if (isSparse) {
|
|
131
|
+
return '@__A-' + UID + '-' + (arrays.push(origValue) - 1) + '__@';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if(origValue instanceof URL) {
|
|
136
|
+
return '@__L-' + UID + '-' + (urls.push(origValue) - 1) + '__@';
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (type === 'function') {
|
|
141
|
+
return '@__F-' + UID + '-' + (functions.push(origValue) - 1) + '__@';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (type === 'undefined') {
|
|
145
|
+
return '@__U-' + UID + '-' + (undefs.push(origValue) - 1) + '__@';
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (type === 'number' && !isNaN(origValue) && !isFinite(origValue)) {
|
|
149
|
+
return '@__I-' + UID + '-' + (infinities.push(origValue) - 1) + '__@';
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (type === 'bigint') {
|
|
153
|
+
return '@__B-' + UID + '-' + (bigInts.push(origValue) - 1) + '__@';
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function serializeFunc(fn, options) {
|
|
160
|
+
var serializedFn = fn.toString();
|
|
161
|
+
if (IS_NATIVE_CODE_REGEXP.test(serializedFn)) {
|
|
162
|
+
throw new TypeError('Serializing native function: ' + fn.name);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Escape unsafe HTML characters in function body for XSS protection
|
|
166
|
+
// This must preserve arrow function syntax (=>) while escaping </script>
|
|
167
|
+
if (options && options.unsafe !== true) {
|
|
168
|
+
serializedFn = escapeFunctionBody(serializedFn);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// pure functions, example: {key: function() {}}
|
|
172
|
+
if(IS_PURE_FUNCTION.test(serializedFn)) {
|
|
173
|
+
return serializedFn;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// arrow functions, example: arg1 => arg1+5
|
|
177
|
+
if(IS_ARROW_FUNCTION.test(serializedFn)) {
|
|
178
|
+
return serializedFn;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
var argsStartsAt = serializedFn.indexOf('(');
|
|
182
|
+
var def = serializedFn.substr(0, argsStartsAt)
|
|
183
|
+
.trim()
|
|
184
|
+
.split(' ')
|
|
185
|
+
.filter(function(val) { return val.length > 0 });
|
|
186
|
+
|
|
187
|
+
var nonReservedSymbols = def.filter(function(val) {
|
|
188
|
+
return RESERVED_SYMBOLS.indexOf(val) === -1
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// enhanced literal objects, example: {key() {}}
|
|
192
|
+
if(nonReservedSymbols.length > 0) {
|
|
193
|
+
return (def.indexOf('async') > -1 ? 'async ' : '') + 'function'
|
|
194
|
+
+ (def.join('').indexOf('*') > -1 ? '*' : '')
|
|
195
|
+
+ serializedFn.substr(argsStartsAt);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// arrow functions
|
|
199
|
+
return serializedFn;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Check if the parameter is function
|
|
203
|
+
if (options.ignoreFunction && typeof obj === "function") {
|
|
204
|
+
obj = undefined;
|
|
205
|
+
}
|
|
206
|
+
// Protects against `JSON.stringify()` returning `undefined`, by serializing
|
|
207
|
+
// to the literal string: "undefined".
|
|
208
|
+
if (obj === undefined) {
|
|
209
|
+
return String(obj);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
var str;
|
|
213
|
+
|
|
214
|
+
// Creates a JSON string representation of the value.
|
|
215
|
+
// NOTE: Node 0.12 goes into slow mode with extra JSON.stringify() args.
|
|
216
|
+
if (options.isJSON && !options.space) {
|
|
217
|
+
str = JSON.stringify(obj);
|
|
218
|
+
} else {
|
|
219
|
+
str = JSON.stringify(obj, options.isJSON ? null : replacer, options.space);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Protects against `JSON.stringify()` returning `undefined`, by serializing
|
|
223
|
+
// to the literal string: "undefined".
|
|
224
|
+
if (typeof str !== 'string') {
|
|
225
|
+
return String(str);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Replace unsafe HTML and invalid JavaScript line terminator chars with
|
|
229
|
+
// their safe Unicode char counterpart. This _must_ happen before the
|
|
230
|
+
// regexps and functions are serialized and added back to the string.
|
|
231
|
+
if (options.unsafe !== true) {
|
|
232
|
+
str = str.replace(UNSAFE_CHARS_REGEXP, escapeUnsafeChars);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (functions.length === 0 && regexps.length === 0 && dates.length === 0 && maps.length === 0 && sets.length === 0 && arrays.length === 0 && undefs.length === 0 && infinities.length === 0 && bigInts.length === 0 && urls.length === 0) {
|
|
236
|
+
return str;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// Replaces all occurrences of function, regexp, date, map and set placeholders in the
|
|
240
|
+
// JSON string with their string representations. If the original value can
|
|
241
|
+
// not be found, then `undefined` is used.
|
|
242
|
+
return str.replace(PLACE_HOLDER_REGEXP, function (match, backSlash, type, valueIndex) {
|
|
243
|
+
// The placeholder may not be preceded by a backslash. This is to prevent
|
|
244
|
+
// replacing things like `"a\"@__R-<UID>-0__@"` and thus outputting
|
|
245
|
+
// invalid JS.
|
|
246
|
+
if (backSlash) {
|
|
247
|
+
return match;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (type === 'D') {
|
|
251
|
+
// Validate ISO string format to prevent code injection via spoofed toISOString()
|
|
252
|
+
var isoStr = String(dates[valueIndex].toISOString());
|
|
253
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/.test(isoStr)) {
|
|
254
|
+
throw new TypeError('Invalid Date ISO string');
|
|
255
|
+
}
|
|
256
|
+
return "new Date(\"" + isoStr + "\")";
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (type === 'R') {
|
|
260
|
+
// Sanitize flags to prevent code injection (only allow valid RegExp flag characters)
|
|
261
|
+
var flags = String(regexps[valueIndex].flags).replace(/[^gimsuydv]/g, '');
|
|
262
|
+
return "new RegExp(" + serialize(regexps[valueIndex].source) + ", \"" + flags + "\")";
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (type === 'M') {
|
|
266
|
+
return "new Map(" + serialize(Array.from(maps[valueIndex].entries()), options) + ")";
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (type === 'S') {
|
|
270
|
+
return "new Set(" + serialize(Array.from(sets[valueIndex].values()), options) + ")";
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (type === 'A') {
|
|
274
|
+
return "Array.prototype.slice.call(" + serialize(Object.assign({ length: arrays[valueIndex].length }, arrays[valueIndex]), options) + ")";
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (type === 'U') {
|
|
278
|
+
return 'undefined'
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (type === 'I') {
|
|
282
|
+
return infinities[valueIndex];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (type === 'B') {
|
|
286
|
+
return "BigInt(\"" + bigInts[valueIndex] + "\")";
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (type === 'L') {
|
|
290
|
+
return "new URL(" + serialize(urls[valueIndex].toString(), options) + ")";
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
var fn = functions[valueIndex];
|
|
294
|
+
|
|
295
|
+
return serializeFunc(fn, options);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "serialize-javascript",
|
|
3
|
+
"version": "7.0.5",
|
|
4
|
+
"description": "Serialize JavaScript to a superset of JSON that includes regular expressions and functions.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"benchmark": "node -v && node test/benchmark/serialize.js",
|
|
8
|
+
"test": "node --test test/unit/*.js"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/yahoo/serialize-javascript.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"serialize",
|
|
16
|
+
"serialization",
|
|
17
|
+
"javascript",
|
|
18
|
+
"js",
|
|
19
|
+
"json"
|
|
20
|
+
],
|
|
21
|
+
"author": "Eric Ferraiuolo <edf@ericf.me>",
|
|
22
|
+
"license": "BSD-3-Clause",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/yahoo/serialize-javascript/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/yahoo/serialize-javascript",
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"benchmark": "^2.1.4"
|
|
29
|
+
},
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=20.0.0"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "novac",
|
|
3
|
+
"version": "2.1.1",
|
|
4
|
+
"description": "a rewrite version of my package nvlang",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "purcwix",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "./bin/novac",
|
|
9
|
+
"bin": {
|
|
10
|
+
"novac": "./bin/novac",
|
|
11
|
+
"nvml": "./bin/nvml",
|
|
12
|
+
"nvc": "./bin/nvc"
|
|
13
|
+
},
|
|
14
|
+
"directories": {
|
|
15
|
+
"example": "examples",
|
|
16
|
+
"test": "tests"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"chalk": "^5.6.2",
|
|
23
|
+
"commander": "^14.0.2",
|
|
24
|
+
"serialize-javascript": "^7.0.5",
|
|
25
|
+
"node-addon-api": "latest"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const pkgPath = path.join(__dirname, '..', 'package.json');
|
|
6
|
+
const binDir = path.join(__dirname, '..', 'bin');
|
|
7
|
+
|
|
8
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
9
|
+
pkg.bin = pkg.bin || {};
|
|
10
|
+
|
|
11
|
+
if (fs.existsSync(binDir)) {
|
|
12
|
+
const files = fs.readdirSync(binDir);
|
|
13
|
+
for (const file of files) {
|
|
14
|
+
const fullPath = `./bin/${file}`;
|
|
15
|
+
const name = path.parse(file).name;
|
|
16
|
+
pkg.bin[name] = fullPath;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// sort keys (optional, just for tidiness)
|
|
21
|
+
pkg.bin = Object.fromEntries(Object.entries(pkg.bin).sort(([a], [b]) => a.localeCompare(b)));
|
|
22
|
+
|
|
23
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
24
|
+
console.log('✅ package.json bin field updated automatically.');
|