@cogitator-ai/wasm-tools 0.5.5 → 0.5.9

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 (60) hide show
  1. package/README.md +0 -1
  2. package/dist/__tests__/index.test.d.ts +2 -0
  3. package/dist/__tests__/index.test.d.ts.map +1 -0
  4. package/dist/__tests__/index.test.js +226 -0
  5. package/dist/__tests__/index.test.js.map +1 -0
  6. package/dist/index.d.ts +1 -3
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +2 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/manager/wasm-tool-manager.d.ts.map +1 -1
  11. package/dist/manager/wasm-tool-manager.js +16 -7
  12. package/dist/manager/wasm-tool-manager.js.map +1 -1
  13. package/dist/plugins/base64.js +1 -1
  14. package/dist/plugins/base64.js.map +1 -1
  15. package/dist/plugins/calc.d.ts.map +1 -1
  16. package/dist/plugins/calc.js +48 -33
  17. package/dist/plugins/calc.js.map +1 -1
  18. package/dist/plugins/compression.d.ts.map +1 -1
  19. package/dist/plugins/compression.js +69 -54
  20. package/dist/plugins/compression.js.map +1 -1
  21. package/dist/plugins/csv.d.ts.map +1 -1
  22. package/dist/plugins/csv.js +2 -1
  23. package/dist/plugins/csv.js.map +1 -1
  24. package/dist/plugins/hash.d.ts.map +1 -1
  25. package/dist/plugins/hash.js +15 -1
  26. package/dist/plugins/hash.js.map +1 -1
  27. package/dist/plugins/regex.js +2 -2
  28. package/dist/plugins/regex.js.map +1 -1
  29. package/dist/plugins/signing.d.ts.map +1 -1
  30. package/dist/plugins/signing.js +15 -4
  31. package/dist/plugins/signing.js.map +1 -1
  32. package/dist/plugins/slug.js +1 -1
  33. package/dist/plugins/slug.js.map +1 -1
  34. package/dist/plugins/xml.d.ts.map +1 -1
  35. package/dist/plugins/xml.js +7 -3
  36. package/dist/plugins/xml.js.map +1 -1
  37. package/dist/temp/base64.js +1 -1
  38. package/dist/temp/calc.js +45 -30
  39. package/dist/temp/compression.js +173 -49
  40. package/dist/temp/csv.js +2 -1
  41. package/dist/temp/hash.js +17 -1
  42. package/dist/temp/regex.js +2 -2
  43. package/dist/temp/signing.js +19 -4
  44. package/dist/temp/slug.js +1 -1
  45. package/dist/temp/xml.js +7 -1
  46. package/dist/wasm/base64.wasm +0 -0
  47. package/dist/wasm/calc.wasm +0 -0
  48. package/dist/wasm/compression.wasm +0 -0
  49. package/dist/wasm/csv.wasm +0 -0
  50. package/dist/wasm/datetime.wasm +0 -0
  51. package/dist/wasm/diff.wasm +0 -0
  52. package/dist/wasm/hash.wasm +0 -0
  53. package/dist/wasm/json.wasm +0 -0
  54. package/dist/wasm/markdown.wasm +0 -0
  55. package/dist/wasm/regex.wasm +0 -0
  56. package/dist/wasm/signing.wasm +0 -0
  57. package/dist/wasm/slug.wasm +0 -0
  58. package/dist/wasm/validation.wasm +0 -0
  59. package/dist/wasm/xml.wasm +0 -0
  60. package/package.json +1 -1
@@ -24,6 +24,12 @@ __export(signing_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(signing_exports);
26
26
  function hexToBytes(hex) {
27
+ if (hex.length % 2 !== 0) {
28
+ throw new Error("Hex string must have even length");
29
+ }
30
+ if (!/^[0-9a-fA-F]*$/.test(hex)) {
31
+ throw new Error("Invalid hex characters");
32
+ }
27
33
  const bytes = new Uint8Array(hex.length / 2);
28
34
  for (let i = 0; i < hex.length; i += 2) {
29
35
  bytes[i / 2] = parseInt(hex.substr(i, 2), 16);
@@ -43,10 +49,10 @@ function base64ToBytes(b64) {
43
49
  for (let i = 0; i < B64.length; i++) lookup[B64[i]] = i;
44
50
  let j = 0;
45
51
  for (let i = 0; i < len; i += 4) {
46
- const a = lookup[clean[i]] || 0;
47
- const b = lookup[clean[i + 1]] || 0;
48
- const c = lookup[clean[i + 2]] || 0;
49
- const d = lookup[clean[i + 3]] || 0;
52
+ const a = lookup[clean[i]] ?? 0;
53
+ const b = lookup[clean[i + 1]] ?? 0;
54
+ const c = lookup[clean[i + 2]] ?? 0;
55
+ const d = lookup[clean[i + 3]] ?? 0;
50
56
  out[j++] = a << 2 | b >> 4;
51
57
  if (j < outLen) out[j++] = (b & 15) << 4 | c >> 2;
52
58
  if (j < outLen) out[j++] = (c & 3) << 6 | d;
@@ -560,6 +566,15 @@ var TextEncoder = class {
560
566
  bytes.push(c);
561
567
  } else if (c < 2048) {
562
568
  bytes.push(192 | c >> 6, 128 | c & 63);
569
+ } else if (c >= 55296 && c < 56320 && i + 1 < str.length) {
570
+ const c2 = str.charCodeAt(++i);
571
+ c = 65536 + ((c & 1023) << 10) + (c2 & 1023);
572
+ bytes.push(
573
+ 240 | c >> 18,
574
+ 128 | c >> 12 & 63,
575
+ 128 | c >> 6 & 63,
576
+ 128 | c & 63
577
+ );
563
578
  } else {
564
579
  bytes.push(224 | c >> 12, 128 | c >> 6 & 63, 128 | c & 63);
565
580
  }
package/dist/temp/slug.js CHANGED
@@ -160,7 +160,7 @@ function generateSlug(text, separator, lowercase, maxLength) {
160
160
  slug2 = slug2.toLowerCase();
161
161
  }
162
162
  slug2 = slug2.replace(/[^a-zA-Z0-9\s-]/g, "").replace(/\s+/g, separator).replace(new RegExp(`${escapeRegex(separator)}+`, "g"), separator).replace(new RegExp(`^${escapeRegex(separator)}|${escapeRegex(separator)}$`, "g"), "");
163
- if (maxLength && slug2.length > maxLength) {
163
+ if (maxLength !== void 0 && maxLength > 0 && slug2.length > maxLength) {
164
164
  slug2 = slug2.substring(0, maxLength);
165
165
  const lastSep = slug2.lastIndexOf(separator);
166
166
  if (lastSep > maxLength * 0.5) {
package/dist/temp/xml.js CHANGED
@@ -198,7 +198,13 @@ function queryXml(node, query) {
198
198
  if (part.startsWith("@")) {
199
199
  const attrName = part.slice(1);
200
200
  if (Array.isArray(current)) {
201
- return current.filter((n) => n.type === "element" && n.attributes?.[attrName]).map((n) => n.attributes[attrName]);
201
+ const attrs = [];
202
+ for (const n of current) {
203
+ if (typeof n !== "string" && n.type === "element" && n.attributes?.[attrName]) {
204
+ attrs.push(n.attributes[attrName]);
205
+ }
206
+ }
207
+ return attrs.length > 0 ? attrs : null;
202
208
  }
203
209
  if (current.type === "element" && current.attributes?.[attrName]) {
204
210
  return current.attributes[attrName];
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cogitator-ai/wasm-tools",
3
- "version": "0.5.5",
3
+ "version": "0.5.9",
4
4
  "description": "WASM-based tools for Cogitator agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",