@uxf/velo 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/velo",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "TypeScript dependency tree generator using Rust WebAssembly",
5
5
  "main": "./pkg/velo.js",
6
6
  "types": "./pkg/velo.d.ts",
package/pkg/README.md ADDED
@@ -0,0 +1,80 @@
1
+ # @uxf/velo
2
+
3
+ A TypeScript dependency tree generator using Rust and WebAssembly.
4
+
5
+ ## Features
6
+ - Fast TypeScript/TSX parsing using `swc`.
7
+ - Aggregates i18n namespaces from components and their dependencies.
8
+ - Generates an optimized route-to-namespace map.
9
+ - Can be published to npm and used as a CLI.
10
+
11
+ ## Installation
12
+ ```bash
13
+ npm install -g @uxf/velo
14
+ ```
15
+
16
+ ## Usage
17
+ ```bash
18
+ uxf-velo <project-dir>
19
+ ```
20
+
21
+ Starting from the `src/pages/` directory (standard for Next.js), it builds a dependency graph and extracts i18n namespaces (e.g., from `t("ns:key")` or `<Trans i18nKey="ns:key" />`).
22
+
23
+ ## Build from Source
24
+ Requirements:
25
+ - Rust (latest)
26
+ - wasm-pack
27
+
28
+ ### Initialization
29
+ Before the first build, run:
30
+ ```bash
31
+ npm run init
32
+ ```
33
+ This ensures the Rust target for WebAssembly is installed and all dependencies are present.
34
+
35
+ ### Building
36
+ To build the package:
37
+ ```bash
38
+ npm run build
39
+ ```
40
+
41
+ ## Production Release and Publishing
42
+ This package includes a full publish pipeline:
43
+
44
+ 1. **Test the package**:
45
+ ```bash
46
+ npm run test
47
+ ```
48
+
49
+ 2. **Full Release (Automated)**:
50
+ ```bash
51
+ npm run release
52
+ ```
53
+ This script performs the following steps:
54
+ - Sets the Rust target for WebAssembly.
55
+ - Builds the WebAssembly package.
56
+ - Runs all tests.
57
+ - Increments the version (patch).
58
+ - Publishes to npm with public access.
59
+
60
+ Alternatively, you can manually run `npm publish`. The `prepublishOnly` script will automatically ensure the package is built and tested before being sent to the npm registry.
61
+
62
+ ## Output Format
63
+ The tool outputs a sorted JSON object mapping route keys to an array of unique, aggregated namespaces:
64
+ ```json
65
+ {
66
+ "*": [
67
+ "common",
68
+ "auth"
69
+ ],
70
+ "/": [
71
+ "auth",
72
+ "common",
73
+ "uxf-form-text-input"
74
+ ],
75
+ "/about": [
76
+ "about",
77
+ "common"
78
+ ]
79
+ }
80
+ ```
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "velo",
3
+ "collaborators": [
4
+ "UXF"
5
+ ],
6
+ "description": "TypeScript dependency tree generator using Rust WebAssembly",
7
+ "version": "0.1.0",
8
+ "license": "MIT",
9
+ "files": [
10
+ "velo_bg.wasm",
11
+ "velo.js",
12
+ "velo.d.ts"
13
+ ],
14
+ "main": "velo.js",
15
+ "types": "velo.d.ts"
16
+ }
package/pkg/velo.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function build_tree_map_js(entrypoints: any, project_root: string, read_file_cb: Function, resolve_cb: Function): any;
5
+
6
+ export function extract_imports_js(content: string, file_name: string): any;
package/pkg/velo.js ADDED
@@ -0,0 +1,400 @@
1
+ /* @ts-self-types="./velo.d.ts" */
2
+
3
+ /**
4
+ * @param {any} entrypoints
5
+ * @param {string} project_root
6
+ * @param {Function} read_file_cb
7
+ * @param {Function} resolve_cb
8
+ * @returns {any}
9
+ */
10
+ function build_tree_map_js(entrypoints, project_root, read_file_cb, resolve_cb) {
11
+ const ptr0 = passStringToWasm0(project_root, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
12
+ const len0 = WASM_VECTOR_LEN;
13
+ const ret = wasm.build_tree_map_js(entrypoints, ptr0, len0, read_file_cb, resolve_cb);
14
+ if (ret[2]) {
15
+ throw takeFromExternrefTable0(ret[1]);
16
+ }
17
+ return takeFromExternrefTable0(ret[0]);
18
+ }
19
+ exports.build_tree_map_js = build_tree_map_js;
20
+
21
+ /**
22
+ * @param {string} content
23
+ * @param {string} file_name
24
+ * @returns {any}
25
+ */
26
+ function extract_imports_js(content, file_name) {
27
+ const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
28
+ const len0 = WASM_VECTOR_LEN;
29
+ const ptr1 = passStringToWasm0(file_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
30
+ const len1 = WASM_VECTOR_LEN;
31
+ const ret = wasm.extract_imports_js(ptr0, len0, ptr1, len1);
32
+ if (ret[2]) {
33
+ throw takeFromExternrefTable0(ret[1]);
34
+ }
35
+ return takeFromExternrefTable0(ret[0]);
36
+ }
37
+ exports.extract_imports_js = extract_imports_js;
38
+
39
+ function __wbg_get_imports() {
40
+ const import0 = {
41
+ __proto__: null,
42
+ __wbg_Error_2e59b1b37a9a34c3: function(arg0, arg1) {
43
+ const ret = Error(getStringFromWasm0(arg0, arg1));
44
+ return ret;
45
+ },
46
+ __wbg___wbindgen_boolean_get_a86c216575a75c30: function(arg0) {
47
+ const v = arg0;
48
+ const ret = typeof(v) === 'boolean' ? v : undefined;
49
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
50
+ },
51
+ __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57: function(arg0, arg1) {
52
+ const ret = debugString(arg1);
53
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
54
+ const len1 = WASM_VECTOR_LEN;
55
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
56
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
57
+ },
58
+ __wbg___wbindgen_is_function_49868bde5eb1e745: function(arg0) {
59
+ const ret = typeof(arg0) === 'function';
60
+ return ret;
61
+ },
62
+ __wbg___wbindgen_is_null_344c8750a8525473: function(arg0) {
63
+ const ret = arg0 === null;
64
+ return ret;
65
+ },
66
+ __wbg___wbindgen_is_object_40c5a80572e8f9d3: function(arg0) {
67
+ const val = arg0;
68
+ const ret = typeof(val) === 'object' && val !== null;
69
+ return ret;
70
+ },
71
+ __wbg___wbindgen_is_string_b29b5c5a8065ba1a: function(arg0) {
72
+ const ret = typeof(arg0) === 'string';
73
+ return ret;
74
+ },
75
+ __wbg___wbindgen_is_undefined_c0cca72b82b86f4d: function(arg0) {
76
+ const ret = arg0 === undefined;
77
+ return ret;
78
+ },
79
+ __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944: function(arg0, arg1) {
80
+ const ret = arg0 == arg1;
81
+ return ret;
82
+ },
83
+ __wbg___wbindgen_number_get_7579aab02a8a620c: function(arg0, arg1) {
84
+ const obj = arg1;
85
+ const ret = typeof(obj) === 'number' ? obj : undefined;
86
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
87
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
88
+ },
89
+ __wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
90
+ const obj = arg1;
91
+ const ret = typeof(obj) === 'string' ? obj : undefined;
92
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
93
+ var len1 = WASM_VECTOR_LEN;
94
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
95
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
96
+ },
97
+ __wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
98
+ throw new Error(getStringFromWasm0(arg0, arg1));
99
+ },
100
+ __wbg_call_368fa9c372d473ba: function() { return handleError(function (arg0, arg1, arg2, arg3) {
101
+ const ret = arg0.call(arg1, arg2, arg3);
102
+ return ret;
103
+ }, arguments); },
104
+ __wbg_call_7f2987183bb62793: function() { return handleError(function (arg0, arg1) {
105
+ const ret = arg0.call(arg1);
106
+ return ret;
107
+ }, arguments); },
108
+ __wbg_call_d578befcc3145dee: function() { return handleError(function (arg0, arg1, arg2) {
109
+ const ret = arg0.call(arg1, arg2);
110
+ return ret;
111
+ }, arguments); },
112
+ __wbg_done_547d467e97529006: function(arg0) {
113
+ const ret = arg0.done;
114
+ return ret;
115
+ },
116
+ __wbg_get_ed0642c4b9d31ddf: function() { return handleError(function (arg0, arg1) {
117
+ const ret = Reflect.get(arg0, arg1);
118
+ return ret;
119
+ }, arguments); },
120
+ __wbg_get_unchecked_7d7babe32e9e6a54: function(arg0, arg1) {
121
+ const ret = arg0[arg1 >>> 0];
122
+ return ret;
123
+ },
124
+ __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a: function(arg0) {
125
+ let result;
126
+ try {
127
+ result = arg0 instanceof ArrayBuffer;
128
+ } catch (_) {
129
+ result = false;
130
+ }
131
+ const ret = result;
132
+ return ret;
133
+ },
134
+ __wbg_instanceof_Uint8Array_4b8da683deb25d72: function(arg0) {
135
+ let result;
136
+ try {
137
+ result = arg0 instanceof Uint8Array;
138
+ } catch (_) {
139
+ result = false;
140
+ }
141
+ const ret = result;
142
+ return ret;
143
+ },
144
+ __wbg_isArray_db61795ad004c139: function(arg0) {
145
+ const ret = Array.isArray(arg0);
146
+ return ret;
147
+ },
148
+ __wbg_iterator_de403ef31815a3e6: function() {
149
+ const ret = Symbol.iterator;
150
+ return ret;
151
+ },
152
+ __wbg_length_0c32cb8543c8e4c8: function(arg0) {
153
+ const ret = arg0.length;
154
+ return ret;
155
+ },
156
+ __wbg_length_6e821edde497a532: function(arg0) {
157
+ const ret = arg0.length;
158
+ return ret;
159
+ },
160
+ __wbg_new_4f9fafbb3909af72: function() {
161
+ const ret = new Object();
162
+ return ret;
163
+ },
164
+ __wbg_new_99cabae501c0a8a0: function() {
165
+ const ret = new Map();
166
+ return ret;
167
+ },
168
+ __wbg_new_a560378ea1240b14: function(arg0) {
169
+ const ret = new Uint8Array(arg0);
170
+ return ret;
171
+ },
172
+ __wbg_new_f3c9df4f38f3f798: function() {
173
+ const ret = new Array();
174
+ return ret;
175
+ },
176
+ __wbg_next_01132ed6134b8ef5: function(arg0) {
177
+ const ret = arg0.next;
178
+ return ret;
179
+ },
180
+ __wbg_next_b3713ec761a9dbfd: function() { return handleError(function (arg0) {
181
+ const ret = arg0.next();
182
+ return ret;
183
+ }, arguments); },
184
+ __wbg_prototypesetcall_3e05eb9545565046: function(arg0, arg1, arg2) {
185
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
186
+ },
187
+ __wbg_set_08463b1df38a7e29: function(arg0, arg1, arg2) {
188
+ const ret = arg0.set(arg1, arg2);
189
+ return ret;
190
+ },
191
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
192
+ arg0[arg1] = arg2;
193
+ },
194
+ __wbg_set_6c60b2e8ad0e9383: function(arg0, arg1, arg2) {
195
+ arg0[arg1 >>> 0] = arg2;
196
+ },
197
+ __wbg_value_7f6052747ccf940f: function(arg0) {
198
+ const ret = arg0.value;
199
+ return ret;
200
+ },
201
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
202
+ // Cast intrinsic for `Ref(String) -> Externref`.
203
+ const ret = getStringFromWasm0(arg0, arg1);
204
+ return ret;
205
+ },
206
+ __wbindgen_init_externref_table: function() {
207
+ const table = wasm.__wbindgen_externrefs;
208
+ const offset = table.grow(4);
209
+ table.set(0, undefined);
210
+ table.set(offset + 0, undefined);
211
+ table.set(offset + 1, null);
212
+ table.set(offset + 2, true);
213
+ table.set(offset + 3, false);
214
+ },
215
+ };
216
+ return {
217
+ __proto__: null,
218
+ "./velo_bg.js": import0,
219
+ };
220
+ }
221
+
222
+ function addToExternrefTable0(obj) {
223
+ const idx = wasm.__externref_table_alloc();
224
+ wasm.__wbindgen_externrefs.set(idx, obj);
225
+ return idx;
226
+ }
227
+
228
+ function debugString(val) {
229
+ // primitive types
230
+ const type = typeof val;
231
+ if (type == 'number' || type == 'boolean' || val == null) {
232
+ return `${val}`;
233
+ }
234
+ if (type == 'string') {
235
+ return `"${val}"`;
236
+ }
237
+ if (type == 'symbol') {
238
+ const description = val.description;
239
+ if (description == null) {
240
+ return 'Symbol';
241
+ } else {
242
+ return `Symbol(${description})`;
243
+ }
244
+ }
245
+ if (type == 'function') {
246
+ const name = val.name;
247
+ if (typeof name == 'string' && name.length > 0) {
248
+ return `Function(${name})`;
249
+ } else {
250
+ return 'Function';
251
+ }
252
+ }
253
+ // objects
254
+ if (Array.isArray(val)) {
255
+ const length = val.length;
256
+ let debug = '[';
257
+ if (length > 0) {
258
+ debug += debugString(val[0]);
259
+ }
260
+ for(let i = 1; i < length; i++) {
261
+ debug += ', ' + debugString(val[i]);
262
+ }
263
+ debug += ']';
264
+ return debug;
265
+ }
266
+ // Test for built-in
267
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
268
+ let className;
269
+ if (builtInMatches && builtInMatches.length > 1) {
270
+ className = builtInMatches[1];
271
+ } else {
272
+ // Failed to match the standard '[object ClassName]'
273
+ return toString.call(val);
274
+ }
275
+ if (className == 'Object') {
276
+ // we're a user defined class or Object
277
+ // JSON.stringify avoids problems with cycles, and is generally much
278
+ // easier than looping through ownProperties of `val`.
279
+ try {
280
+ return 'Object(' + JSON.stringify(val) + ')';
281
+ } catch (_) {
282
+ return 'Object';
283
+ }
284
+ }
285
+ // errors
286
+ if (val instanceof Error) {
287
+ return `${val.name}: ${val.message}\n${val.stack}`;
288
+ }
289
+ // TODO we could test for more things here, like `Set`s and `Map`s.
290
+ return className;
291
+ }
292
+
293
+ function getArrayU8FromWasm0(ptr, len) {
294
+ ptr = ptr >>> 0;
295
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
296
+ }
297
+
298
+ let cachedDataViewMemory0 = null;
299
+ function getDataViewMemory0() {
300
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
301
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
302
+ }
303
+ return cachedDataViewMemory0;
304
+ }
305
+
306
+ function getStringFromWasm0(ptr, len) {
307
+ ptr = ptr >>> 0;
308
+ return decodeText(ptr, len);
309
+ }
310
+
311
+ let cachedUint8ArrayMemory0 = null;
312
+ function getUint8ArrayMemory0() {
313
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
314
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
315
+ }
316
+ return cachedUint8ArrayMemory0;
317
+ }
318
+
319
+ function handleError(f, args) {
320
+ try {
321
+ return f.apply(this, args);
322
+ } catch (e) {
323
+ const idx = addToExternrefTable0(e);
324
+ wasm.__wbindgen_exn_store(idx);
325
+ }
326
+ }
327
+
328
+ function isLikeNone(x) {
329
+ return x === undefined || x === null;
330
+ }
331
+
332
+ function passStringToWasm0(arg, malloc, realloc) {
333
+ if (realloc === undefined) {
334
+ const buf = cachedTextEncoder.encode(arg);
335
+ const ptr = malloc(buf.length, 1) >>> 0;
336
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
337
+ WASM_VECTOR_LEN = buf.length;
338
+ return ptr;
339
+ }
340
+
341
+ let len = arg.length;
342
+ let ptr = malloc(len, 1) >>> 0;
343
+
344
+ const mem = getUint8ArrayMemory0();
345
+
346
+ let offset = 0;
347
+
348
+ for (; offset < len; offset++) {
349
+ const code = arg.charCodeAt(offset);
350
+ if (code > 0x7F) break;
351
+ mem[ptr + offset] = code;
352
+ }
353
+ if (offset !== len) {
354
+ if (offset !== 0) {
355
+ arg = arg.slice(offset);
356
+ }
357
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
358
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
359
+ const ret = cachedTextEncoder.encodeInto(arg, view);
360
+
361
+ offset += ret.written;
362
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
363
+ }
364
+
365
+ WASM_VECTOR_LEN = offset;
366
+ return ptr;
367
+ }
368
+
369
+ function takeFromExternrefTable0(idx) {
370
+ const value = wasm.__wbindgen_externrefs.get(idx);
371
+ wasm.__externref_table_dealloc(idx);
372
+ return value;
373
+ }
374
+
375
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
376
+ cachedTextDecoder.decode();
377
+ function decodeText(ptr, len) {
378
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
379
+ }
380
+
381
+ const cachedTextEncoder = new TextEncoder();
382
+
383
+ if (!('encodeInto' in cachedTextEncoder)) {
384
+ cachedTextEncoder.encodeInto = function (arg, view) {
385
+ const buf = cachedTextEncoder.encode(arg);
386
+ view.set(buf);
387
+ return {
388
+ read: arg.length,
389
+ written: buf.length
390
+ };
391
+ };
392
+ }
393
+
394
+ let WASM_VECTOR_LEN = 0;
395
+
396
+ const wasmPath = `${__dirname}/velo_bg.wasm`;
397
+ const wasmBytes = require('fs').readFileSync(wasmPath);
398
+ const wasmModule = new WebAssembly.Module(wasmBytes);
399
+ let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
400
+ wasm.__wbindgen_start();
Binary file
@@ -0,0 +1,12 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const build_tree_map_js: (a: any, b: number, c: number, d: any, e: any) => [number, number, number];
5
+ export const extract_imports_js: (a: number, b: number, c: number, d: number) => [number, number, number];
6
+ export const __wbindgen_malloc: (a: number, b: number) => number;
7
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
8
+ export const __wbindgen_exn_store: (a: number) => void;
9
+ export const __externref_table_alloc: () => number;
10
+ export const __wbindgen_externrefs: WebAssembly.Table;
11
+ export const __externref_table_dealloc: (a: number) => void;
12
+ export const __wbindgen_start: () => void;