@cogitator-ai/wasm-tools 0.5.11 → 0.6.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 (119) hide show
  1. package/README.md +84 -25
  2. package/dist/index.d.ts +22 -3
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +81 -14
  5. package/dist/index.js.map +1 -1
  6. package/dist/manager/types.d.ts +2 -0
  7. package/dist/manager/types.d.ts.map +1 -1
  8. package/dist/manager/wasm-loader.d.ts.map +1 -1
  9. package/dist/manager/wasm-loader.js +11 -2
  10. package/dist/manager/wasm-loader.js.map +1 -1
  11. package/dist/manager/wasm-tool-manager.d.ts +1 -0
  12. package/dist/manager/wasm-tool-manager.d.ts.map +1 -1
  13. package/dist/manager/wasm-tool-manager.js +56 -13
  14. package/dist/manager/wasm-tool-manager.js.map +1 -1
  15. package/dist/runtime.d.ts +11 -0
  16. package/dist/runtime.d.ts.map +1 -0
  17. package/dist/runtime.js +104 -0
  18. package/dist/runtime.js.map +1 -0
  19. package/dist/wasm/base64.wasm +0 -0
  20. package/dist/wasm/calc.wasm +0 -0
  21. package/dist/wasm/compression.wasm +0 -0
  22. package/dist/wasm/csv.wasm +0 -0
  23. package/dist/wasm/datetime.wasm +0 -0
  24. package/dist/wasm/diff.wasm +0 -0
  25. package/dist/wasm/hash.wasm +0 -0
  26. package/dist/wasm/json.wasm +0 -0
  27. package/dist/wasm/markdown.wasm +0 -0
  28. package/dist/wasm/regex.wasm +0 -0
  29. package/dist/wasm/signing.wasm +0 -0
  30. package/dist/wasm/slug.wasm +0 -0
  31. package/dist/wasm/validation.wasm +0 -0
  32. package/dist/wasm/xml.wasm +0 -0
  33. package/package.json +5 -6
  34. package/dist/__tests__/file-watcher.test.d.ts +0 -2
  35. package/dist/__tests__/file-watcher.test.d.ts.map +0 -1
  36. package/dist/__tests__/file-watcher.test.js +0 -99
  37. package/dist/__tests__/file-watcher.test.js.map +0 -1
  38. package/dist/__tests__/index.test.d.ts +0 -2
  39. package/dist/__tests__/index.test.d.ts.map +0 -1
  40. package/dist/__tests__/index.test.js +0 -226
  41. package/dist/__tests__/index.test.js.map +0 -1
  42. package/dist/__tests__/wasm-loader.test.d.ts +0 -2
  43. package/dist/__tests__/wasm-loader.test.d.ts.map +0 -1
  44. package/dist/__tests__/wasm-loader.test.js +0 -68
  45. package/dist/__tests__/wasm-loader.test.js.map +0 -1
  46. package/dist/__tests__/wasm-tool-manager.test.d.ts +0 -2
  47. package/dist/__tests__/wasm-tool-manager.test.d.ts.map +0 -1
  48. package/dist/__tests__/wasm-tool-manager.test.js +0 -166
  49. package/dist/__tests__/wasm-tool-manager.test.js.map +0 -1
  50. package/dist/plugins/base64.d.ts +0 -12
  51. package/dist/plugins/base64.d.ts.map +0 -1
  52. package/dist/plugins/base64.js +0 -144
  53. package/dist/plugins/base64.js.map +0 -1
  54. package/dist/plugins/calc.d.ts +0 -12
  55. package/dist/plugins/calc.d.ts.map +0 -1
  56. package/dist/plugins/calc.js +0 -102
  57. package/dist/plugins/calc.js.map +0 -1
  58. package/dist/plugins/compression.d.ts +0 -2
  59. package/dist/plugins/compression.d.ts.map +0 -1
  60. package/dist/plugins/compression.js +0 -549
  61. package/dist/plugins/compression.js.map +0 -1
  62. package/dist/plugins/csv.d.ts +0 -2
  63. package/dist/plugins/csv.d.ts.map +0 -1
  64. package/dist/plugins/csv.js +0 -142
  65. package/dist/plugins/csv.js.map +0 -1
  66. package/dist/plugins/datetime.d.ts +0 -2
  67. package/dist/plugins/datetime.d.ts.map +0 -1
  68. package/dist/plugins/datetime.js +0 -199
  69. package/dist/plugins/datetime.js.map +0 -1
  70. package/dist/plugins/diff.d.ts +0 -2
  71. package/dist/plugins/diff.d.ts.map +0 -1
  72. package/dist/plugins/diff.js +0 -187
  73. package/dist/plugins/diff.js.map +0 -1
  74. package/dist/plugins/hash.d.ts +0 -12
  75. package/dist/plugins/hash.d.ts.map +0 -1
  76. package/dist/plugins/hash.js +0 -310
  77. package/dist/plugins/hash.js.map +0 -1
  78. package/dist/plugins/json.d.ts +0 -12
  79. package/dist/plugins/json.d.ts.map +0 -1
  80. package/dist/plugins/json.js +0 -70
  81. package/dist/plugins/json.js.map +0 -1
  82. package/dist/plugins/markdown.d.ts +0 -2
  83. package/dist/plugins/markdown.d.ts.map +0 -1
  84. package/dist/plugins/markdown.js +0 -213
  85. package/dist/plugins/markdown.js.map +0 -1
  86. package/dist/plugins/regex.d.ts +0 -2
  87. package/dist/plugins/regex.d.ts.map +0 -1
  88. package/dist/plugins/regex.js +0 -120
  89. package/dist/plugins/regex.js.map +0 -1
  90. package/dist/plugins/signing.d.ts +0 -2
  91. package/dist/plugins/signing.d.ts.map +0 -1
  92. package/dist/plugins/signing.js +0 -589
  93. package/dist/plugins/signing.js.map +0 -1
  94. package/dist/plugins/slug.d.ts +0 -2
  95. package/dist/plugins/slug.d.ts.map +0 -1
  96. package/dist/plugins/slug.js +0 -183
  97. package/dist/plugins/slug.js.map +0 -1
  98. package/dist/plugins/validation.d.ts +0 -2
  99. package/dist/plugins/validation.d.ts.map +0 -1
  100. package/dist/plugins/validation.js +0 -105
  101. package/dist/plugins/validation.js.map +0 -1
  102. package/dist/plugins/xml.d.ts +0 -2
  103. package/dist/plugins/xml.d.ts.map +0 -1
  104. package/dist/plugins/xml.js +0 -297
  105. package/dist/plugins/xml.js.map +0 -1
  106. package/dist/temp/base64.js +0 -149
  107. package/dist/temp/calc.js +0 -108
  108. package/dist/temp/compression.js +0 -742
  109. package/dist/temp/csv.js +0 -161
  110. package/dist/temp/datetime.js +0 -217
  111. package/dist/temp/diff.js +0 -198
  112. package/dist/temp/hash.js +0 -424
  113. package/dist/temp/json.js +0 -80
  114. package/dist/temp/markdown.js +0 -224
  115. package/dist/temp/regex.js +0 -141
  116. package/dist/temp/signing.js +0 -600
  117. package/dist/temp/slug.js +0 -201
  118. package/dist/temp/validation.js +0 -125
  119. package/dist/temp/xml.js +0 -295
package/dist/temp/hash.js DELETED
@@ -1,424 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/plugins/hash.ts
21
- var hash_exports = {};
22
- __export(hash_exports, {
23
- hash: () => hash
24
- });
25
- module.exports = __toCommonJS(hash_exports);
26
- function rotateLeft(n, b) {
27
- return (n << b | n >>> 32 - b) >>> 0;
28
- }
29
- function toHex(arr) {
30
- return arr.map((b) => b.toString(16).padStart(2, "0")).join("");
31
- }
32
- function stringToBytes(str) {
33
- const bytes = [];
34
- for (let i = 0; i < str.length; i++) {
35
- let c = str.charCodeAt(i);
36
- if (c < 128) {
37
- bytes.push(c);
38
- } else if (c < 2048) {
39
- bytes.push(192 | c >> 6, 128 | c & 63);
40
- } else if (c >= 55296 && c < 56320 && i + 1 < str.length) {
41
- const c2 = str.charCodeAt(++i);
42
- c = 65536 + ((c & 1023) << 10) + (c2 & 1023);
43
- bytes.push(
44
- 240 | c >> 18,
45
- 128 | c >> 12 & 63,
46
- 128 | c >> 6 & 63,
47
- 128 | c & 63
48
- );
49
- } else {
50
- bytes.push(224 | c >> 12, 128 | c >> 6 & 63, 128 | c & 63);
51
- }
52
- }
53
- return bytes;
54
- }
55
- function md5(message) {
56
- const bytes = stringToBytes(message);
57
- const originalLength = bytes.length;
58
- const bitLength = BigInt(originalLength) * 8n;
59
- bytes.push(128);
60
- while (bytes.length % 64 !== 56) {
61
- bytes.push(0);
62
- }
63
- for (let i = 0; i < 8; i++) {
64
- bytes.push(Number(bitLength >> BigInt(i * 8) & 0xffn));
65
- }
66
- const s = [
67
- 7,
68
- 12,
69
- 17,
70
- 22,
71
- 7,
72
- 12,
73
- 17,
74
- 22,
75
- 7,
76
- 12,
77
- 17,
78
- 22,
79
- 7,
80
- 12,
81
- 17,
82
- 22,
83
- 5,
84
- 9,
85
- 14,
86
- 20,
87
- 5,
88
- 9,
89
- 14,
90
- 20,
91
- 5,
92
- 9,
93
- 14,
94
- 20,
95
- 5,
96
- 9,
97
- 14,
98
- 20,
99
- 4,
100
- 11,
101
- 16,
102
- 23,
103
- 4,
104
- 11,
105
- 16,
106
- 23,
107
- 4,
108
- 11,
109
- 16,
110
- 23,
111
- 4,
112
- 11,
113
- 16,
114
- 23,
115
- 6,
116
- 10,
117
- 15,
118
- 21,
119
- 6,
120
- 10,
121
- 15,
122
- 21,
123
- 6,
124
- 10,
125
- 15,
126
- 21,
127
- 6,
128
- 10,
129
- 15,
130
- 21
131
- ];
132
- const K = new Array(64);
133
- for (let i = 0; i < 64; i++) {
134
- K[i] = Math.floor(Math.abs(Math.sin(i + 1)) * 4294967296) >>> 0;
135
- }
136
- let a0 = 1732584193;
137
- let b0 = 4023233417;
138
- let c0 = 2562383102;
139
- let d0 = 271733878;
140
- for (let chunkStart = 0; chunkStart < bytes.length; chunkStart += 64) {
141
- const M = new Array(16);
142
- for (let j = 0; j < 16; j++) {
143
- const offset = chunkStart + j * 4;
144
- M[j] = bytes[offset] | bytes[offset + 1] << 8 | bytes[offset + 2] << 16 | bytes[offset + 3] << 24;
145
- M[j] = M[j] >>> 0;
146
- }
147
- let A = a0;
148
- let B = b0;
149
- let C = c0;
150
- let D = d0;
151
- for (let i = 0; i < 64; i++) {
152
- let F, g;
153
- if (i < 16) {
154
- F = B & C | ~B & D;
155
- g = i;
156
- } else if (i < 32) {
157
- F = D & B | ~D & C;
158
- g = (5 * i + 1) % 16;
159
- } else if (i < 48) {
160
- F = B ^ C ^ D;
161
- g = (3 * i + 5) % 16;
162
- } else {
163
- F = C ^ (B | ~D);
164
- g = 7 * i % 16;
165
- }
166
- F = F + A + K[i] + M[g] >>> 0;
167
- A = D;
168
- D = C;
169
- C = B;
170
- B = B + rotateLeft(F, s[i]) >>> 0;
171
- }
172
- a0 = a0 + A >>> 0;
173
- b0 = b0 + B >>> 0;
174
- c0 = c0 + C >>> 0;
175
- d0 = d0 + D >>> 0;
176
- }
177
- const result = [];
178
- [a0, b0, c0, d0].forEach((val) => {
179
- for (let i = 0; i < 4; i++) {
180
- result.push(val >>> i * 8 & 255);
181
- }
182
- });
183
- return toHex(result);
184
- }
185
- function sha1(message) {
186
- const bytes = stringToBytes(message);
187
- const originalLength = bytes.length;
188
- const bitLength = BigInt(originalLength * 8);
189
- bytes.push(128);
190
- while (bytes.length % 64 !== 56) {
191
- bytes.push(0);
192
- }
193
- for (let i = 7; i >= 0; i--) {
194
- bytes.push(Number(bitLength >> BigInt(i * 8) & BigInt(255)));
195
- }
196
- let h0 = 1732584193;
197
- let h1 = 4023233417;
198
- let h2 = 2562383102;
199
- let h3 = 271733878;
200
- let h4 = 3285377520;
201
- for (let chunkStart = 0; chunkStart < bytes.length; chunkStart += 64) {
202
- const w = new Array(80);
203
- for (let i = 0; i < 16; i++) {
204
- const offset = chunkStart + i * 4;
205
- w[i] = bytes[offset] << 24 | bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3];
206
- w[i] = w[i] >>> 0;
207
- }
208
- for (let i = 16; i < 80; i++) {
209
- w[i] = rotateLeft(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
210
- }
211
- let a = h0;
212
- let b = h1;
213
- let c = h2;
214
- let d = h3;
215
- let e = h4;
216
- for (let i = 0; i < 80; i++) {
217
- let f, k;
218
- if (i < 20) {
219
- f = b & c | ~b & d;
220
- k = 1518500249;
221
- } else if (i < 40) {
222
- f = b ^ c ^ d;
223
- k = 1859775393;
224
- } else if (i < 60) {
225
- f = b & c | b & d | c & d;
226
- k = 2400959708;
227
- } else {
228
- f = b ^ c ^ d;
229
- k = 3395469782;
230
- }
231
- const temp = rotateLeft(a, 5) + f + e + k + w[i] >>> 0;
232
- e = d;
233
- d = c;
234
- c = rotateLeft(b, 30);
235
- b = a;
236
- a = temp;
237
- }
238
- h0 = h0 + a >>> 0;
239
- h1 = h1 + b >>> 0;
240
- h2 = h2 + c >>> 0;
241
- h3 = h3 + d >>> 0;
242
- h4 = h4 + e >>> 0;
243
- }
244
- const result = [];
245
- [h0, h1, h2, h3, h4].forEach((val) => {
246
- for (let i = 3; i >= 0; i--) {
247
- result.push(val >>> i * 8 & 255);
248
- }
249
- });
250
- return toHex(result);
251
- }
252
- function sha256(message) {
253
- const K = [
254
- 1116352408,
255
- 1899447441,
256
- 3049323471,
257
- 3921009573,
258
- 961987163,
259
- 1508970993,
260
- 2453635748,
261
- 2870763221,
262
- 3624381080,
263
- 310598401,
264
- 607225278,
265
- 1426881987,
266
- 1925078388,
267
- 2162078206,
268
- 2614888103,
269
- 3248222580,
270
- 3835390401,
271
- 4022224774,
272
- 264347078,
273
- 604807628,
274
- 770255983,
275
- 1249150122,
276
- 1555081692,
277
- 1996064986,
278
- 2554220882,
279
- 2821834349,
280
- 2952996808,
281
- 3210313671,
282
- 3336571891,
283
- 3584528711,
284
- 113926993,
285
- 338241895,
286
- 666307205,
287
- 773529912,
288
- 1294757372,
289
- 1396182291,
290
- 1695183700,
291
- 1986661051,
292
- 2177026350,
293
- 2456956037,
294
- 2730485921,
295
- 2820302411,
296
- 3259730800,
297
- 3345764771,
298
- 3516065817,
299
- 3600352804,
300
- 4094571909,
301
- 275423344,
302
- 430227734,
303
- 506948616,
304
- 659060556,
305
- 883997877,
306
- 958139571,
307
- 1322822218,
308
- 1537002063,
309
- 1747873779,
310
- 1955562222,
311
- 2024104815,
312
- 2227730452,
313
- 2361852424,
314
- 2428436474,
315
- 2756734187,
316
- 3204031479,
317
- 3329325298
318
- ];
319
- const bytes = stringToBytes(message);
320
- const originalLength = bytes.length;
321
- const bitLength = BigInt(originalLength * 8);
322
- bytes.push(128);
323
- while (bytes.length % 64 !== 56) {
324
- bytes.push(0);
325
- }
326
- for (let i = 7; i >= 0; i--) {
327
- bytes.push(Number(bitLength >> BigInt(i * 8) & BigInt(255)));
328
- }
329
- let h0 = 1779033703;
330
- let h1 = 3144134277;
331
- let h2 = 1013904242;
332
- let h3 = 2773480762;
333
- let h4 = 1359893119;
334
- let h5 = 2600822924;
335
- let h6 = 528734635;
336
- let h7 = 1541459225;
337
- const rotr = (x, n) => (x >>> n | x << 32 - n) >>> 0;
338
- for (let chunkStart = 0; chunkStart < bytes.length; chunkStart += 64) {
339
- const w = new Array(64);
340
- for (let i = 0; i < 16; i++) {
341
- const offset = chunkStart + i * 4;
342
- w[i] = bytes[offset] << 24 | bytes[offset + 1] << 16 | bytes[offset + 2] << 8 | bytes[offset + 3];
343
- w[i] = w[i] >>> 0;
344
- }
345
- for (let i = 16; i < 64; i++) {
346
- const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ w[i - 15] >>> 3;
347
- const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ w[i - 2] >>> 10;
348
- w[i] = w[i - 16] + s0 + w[i - 7] + s1 >>> 0;
349
- }
350
- let a = h0;
351
- let b = h1;
352
- let c = h2;
353
- let d = h3;
354
- let e = h4;
355
- let f = h5;
356
- let g = h6;
357
- let h = h7;
358
- for (let i = 0; i < 64; i++) {
359
- const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
360
- const ch = e & f ^ ~e & g;
361
- const temp1 = h + S1 + ch + K[i] + w[i] >>> 0;
362
- const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
363
- const maj = a & b ^ a & c ^ b & c;
364
- const temp2 = S0 + maj >>> 0;
365
- h = g;
366
- g = f;
367
- f = e;
368
- e = d + temp1 >>> 0;
369
- d = c;
370
- c = b;
371
- b = a;
372
- a = temp1 + temp2 >>> 0;
373
- }
374
- h0 = h0 + a >>> 0;
375
- h1 = h1 + b >>> 0;
376
- h2 = h2 + c >>> 0;
377
- h3 = h3 + d >>> 0;
378
- h4 = h4 + e >>> 0;
379
- h5 = h5 + f >>> 0;
380
- h6 = h6 + g >>> 0;
381
- h7 = h7 + h >>> 0;
382
- }
383
- const result = [];
384
- [h0, h1, h2, h3, h4, h5, h6, h7].forEach((val) => {
385
- for (let i = 3; i >= 0; i--) {
386
- result.push(val >>> i * 8 & 255);
387
- }
388
- });
389
- return toHex(result);
390
- }
391
- function hash() {
392
- try {
393
- const inputStr = Host.inputString();
394
- const input = JSON.parse(inputStr);
395
- let hashResult;
396
- switch (input.algorithm) {
397
- case "md5":
398
- hashResult = md5(input.text);
399
- break;
400
- case "sha1":
401
- hashResult = sha1(input.text);
402
- break;
403
- case "sha256":
404
- hashResult = sha256(input.text);
405
- break;
406
- default:
407
- throw new Error(`Unsupported algorithm: ${input.algorithm}`);
408
- }
409
- const output = {
410
- hash: hashResult,
411
- algorithm: input.algorithm
412
- };
413
- Host.outputString(JSON.stringify(output));
414
- return 0;
415
- } catch (error) {
416
- const output = {
417
- hash: "",
418
- algorithm: "unknown",
419
- error: error instanceof Error ? error.message : String(error)
420
- };
421
- Host.outputString(JSON.stringify(output));
422
- return 1;
423
- }
424
- }
package/dist/temp/json.js DELETED
@@ -1,80 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/plugins/json.ts
21
- var json_exports = {};
22
- __export(json_exports, {
23
- process: () => process
24
- });
25
- module.exports = __toCommonJS(json_exports);
26
- function isRecord(value) {
27
- return value !== null && typeof value === "object" && !Array.isArray(value);
28
- }
29
- function getByPath(obj, path) {
30
- if (!path || path === "$") return obj;
31
- const parts = path.replace(/^\$\.?/, "").split(".");
32
- let current = obj;
33
- for (const part of parts) {
34
- if (current === null || current === void 0) {
35
- return void 0;
36
- }
37
- const arrayMatch = /^(\w+)\[(\d+)\]$/.exec(part);
38
- if (arrayMatch) {
39
- const [, key, indexStr] = arrayMatch;
40
- const index = parseInt(indexStr, 10);
41
- if (!isRecord(current)) {
42
- return void 0;
43
- }
44
- current = current[key];
45
- if (Array.isArray(current)) {
46
- current = current[index];
47
- } else {
48
- return void 0;
49
- }
50
- } else {
51
- if (!isRecord(current)) {
52
- return void 0;
53
- }
54
- current = current[part];
55
- }
56
- }
57
- return current;
58
- }
59
- function process() {
60
- try {
61
- const inputStr = Host.inputString();
62
- const input = JSON.parse(inputStr);
63
- const parsed = JSON.parse(input.json);
64
- const result = input.query ? getByPath(parsed, input.query) : parsed;
65
- const output = {
66
- result,
67
- type: Array.isArray(result) ? "array" : typeof result
68
- };
69
- Host.outputString(JSON.stringify(output));
70
- return 0;
71
- } catch (error) {
72
- const output = {
73
- result: null,
74
- type: "error",
75
- error: error instanceof Error ? error.message : String(error)
76
- };
77
- Host.outputString(JSON.stringify(output));
78
- return 1;
79
- }
80
- }