@cogitator-ai/wasm-tools 0.5.10 → 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 (123) 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/file-watcher.d.ts.map +1 -1
  7. package/dist/manager/file-watcher.js +6 -0
  8. package/dist/manager/file-watcher.js.map +1 -1
  9. package/dist/manager/types.d.ts +11 -3
  10. package/dist/manager/types.d.ts.map +1 -1
  11. package/dist/manager/wasm-loader.d.ts +1 -0
  12. package/dist/manager/wasm-loader.d.ts.map +1 -1
  13. package/dist/manager/wasm-loader.js +26 -5
  14. package/dist/manager/wasm-loader.js.map +1 -1
  15. package/dist/manager/wasm-tool-manager.d.ts +6 -0
  16. package/dist/manager/wasm-tool-manager.d.ts.map +1 -1
  17. package/dist/manager/wasm-tool-manager.js +115 -30
  18. package/dist/manager/wasm-tool-manager.js.map +1 -1
  19. package/dist/runtime.d.ts +11 -0
  20. package/dist/runtime.d.ts.map +1 -0
  21. package/dist/runtime.js +104 -0
  22. package/dist/runtime.js.map +1 -0
  23. package/dist/wasm/base64.wasm +0 -0
  24. package/dist/wasm/calc.wasm +0 -0
  25. package/dist/wasm/compression.wasm +0 -0
  26. package/dist/wasm/csv.wasm +0 -0
  27. package/dist/wasm/datetime.wasm +0 -0
  28. package/dist/wasm/diff.wasm +0 -0
  29. package/dist/wasm/hash.wasm +0 -0
  30. package/dist/wasm/json.wasm +0 -0
  31. package/dist/wasm/markdown.wasm +0 -0
  32. package/dist/wasm/regex.wasm +0 -0
  33. package/dist/wasm/signing.wasm +0 -0
  34. package/dist/wasm/slug.wasm +0 -0
  35. package/dist/wasm/validation.wasm +0 -0
  36. package/dist/wasm/xml.wasm +0 -0
  37. package/package.json +5 -6
  38. package/dist/__tests__/file-watcher.test.d.ts +0 -2
  39. package/dist/__tests__/file-watcher.test.d.ts.map +0 -1
  40. package/dist/__tests__/file-watcher.test.js +0 -99
  41. package/dist/__tests__/file-watcher.test.js.map +0 -1
  42. package/dist/__tests__/index.test.d.ts +0 -2
  43. package/dist/__tests__/index.test.d.ts.map +0 -1
  44. package/dist/__tests__/index.test.js +0 -226
  45. package/dist/__tests__/index.test.js.map +0 -1
  46. package/dist/__tests__/wasm-loader.test.d.ts +0 -2
  47. package/dist/__tests__/wasm-loader.test.d.ts.map +0 -1
  48. package/dist/__tests__/wasm-loader.test.js +0 -68
  49. package/dist/__tests__/wasm-loader.test.js.map +0 -1
  50. package/dist/__tests__/wasm-tool-manager.test.d.ts +0 -2
  51. package/dist/__tests__/wasm-tool-manager.test.d.ts.map +0 -1
  52. package/dist/__tests__/wasm-tool-manager.test.js +0 -166
  53. package/dist/__tests__/wasm-tool-manager.test.js.map +0 -1
  54. package/dist/plugins/base64.d.ts +0 -12
  55. package/dist/plugins/base64.d.ts.map +0 -1
  56. package/dist/plugins/base64.js +0 -95
  57. package/dist/plugins/base64.js.map +0 -1
  58. package/dist/plugins/calc.d.ts +0 -12
  59. package/dist/plugins/calc.d.ts.map +0 -1
  60. package/dist/plugins/calc.js +0 -95
  61. package/dist/plugins/calc.js.map +0 -1
  62. package/dist/plugins/compression.d.ts +0 -2
  63. package/dist/plugins/compression.d.ts.map +0 -1
  64. package/dist/plugins/compression.js +0 -545
  65. package/dist/plugins/compression.js.map +0 -1
  66. package/dist/plugins/csv.d.ts +0 -2
  67. package/dist/plugins/csv.d.ts.map +0 -1
  68. package/dist/plugins/csv.js +0 -136
  69. package/dist/plugins/csv.js.map +0 -1
  70. package/dist/plugins/datetime.d.ts +0 -2
  71. package/dist/plugins/datetime.d.ts.map +0 -1
  72. package/dist/plugins/datetime.js +0 -186
  73. package/dist/plugins/datetime.js.map +0 -1
  74. package/dist/plugins/diff.d.ts +0 -2
  75. package/dist/plugins/diff.d.ts.map +0 -1
  76. package/dist/plugins/diff.js +0 -187
  77. package/dist/plugins/diff.js.map +0 -1
  78. package/dist/plugins/hash.d.ts +0 -12
  79. package/dist/plugins/hash.d.ts.map +0 -1
  80. package/dist/plugins/hash.js +0 -309
  81. package/dist/plugins/hash.js.map +0 -1
  82. package/dist/plugins/json.d.ts +0 -12
  83. package/dist/plugins/json.d.ts.map +0 -1
  84. package/dist/plugins/json.js +0 -70
  85. package/dist/plugins/json.js.map +0 -1
  86. package/dist/plugins/markdown.d.ts +0 -2
  87. package/dist/plugins/markdown.d.ts.map +0 -1
  88. package/dist/plugins/markdown.js +0 -213
  89. package/dist/plugins/markdown.js.map +0 -1
  90. package/dist/plugins/regex.d.ts +0 -2
  91. package/dist/plugins/regex.d.ts.map +0 -1
  92. package/dist/plugins/regex.js +0 -120
  93. package/dist/plugins/regex.js.map +0 -1
  94. package/dist/plugins/signing.d.ts +0 -2
  95. package/dist/plugins/signing.d.ts.map +0 -1
  96. package/dist/plugins/signing.js +0 -576
  97. package/dist/plugins/signing.js.map +0 -1
  98. package/dist/plugins/slug.d.ts +0 -2
  99. package/dist/plugins/slug.d.ts.map +0 -1
  100. package/dist/plugins/slug.js +0 -180
  101. package/dist/plugins/slug.js.map +0 -1
  102. package/dist/plugins/validation.d.ts +0 -2
  103. package/dist/plugins/validation.d.ts.map +0 -1
  104. package/dist/plugins/validation.js +0 -105
  105. package/dist/plugins/validation.js.map +0 -1
  106. package/dist/plugins/xml.d.ts +0 -2
  107. package/dist/plugins/xml.d.ts.map +0 -1
  108. package/dist/plugins/xml.js +0 -297
  109. package/dist/plugins/xml.js.map +0 -1
  110. package/dist/temp/base64.js +0 -102
  111. package/dist/temp/calc.js +0 -102
  112. package/dist/temp/compression.js +0 -738
  113. package/dist/temp/csv.js +0 -155
  114. package/dist/temp/datetime.js +0 -201
  115. package/dist/temp/diff.js +0 -198
  116. package/dist/temp/hash.js +0 -423
  117. package/dist/temp/json.js +0 -80
  118. package/dist/temp/markdown.js +0 -224
  119. package/dist/temp/regex.js +0 -141
  120. package/dist/temp/signing.js +0 -584
  121. package/dist/temp/slug.js +0 -198
  122. package/dist/temp/validation.js +0 -125
  123. package/dist/temp/xml.js +0 -295
@@ -1,102 +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/base64.ts
21
- var base64_exports = {};
22
- __export(base64_exports, {
23
- base64: () => base64
24
- });
25
- module.exports = __toCommonJS(base64_exports);
26
- var STANDARD_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
27
- var URL_SAFE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
28
- function encodeBase64(input, urlSafe) {
29
- const chars = urlSafe ? URL_SAFE_CHARS : STANDARD_CHARS;
30
- let result = "";
31
- let i = 0;
32
- while (i < input.length) {
33
- const a = input.charCodeAt(i++);
34
- const b = i < input.length ? input.charCodeAt(i++) : 0;
35
- const c = i < input.length ? input.charCodeAt(i++) : 0;
36
- const bitmap = a << 16 | b << 8 | c;
37
- result += chars.charAt(bitmap >> 18 & 63) + chars.charAt(bitmap >> 12 & 63) + chars.charAt(bitmap >> 6 & 63) + chars.charAt(bitmap & 63);
38
- }
39
- const padding = input.length % 3;
40
- if (padding === 1) {
41
- result = result.slice(0, -2) + (urlSafe ? "" : "==");
42
- } else if (padding === 2) {
43
- result = result.slice(0, -1) + (urlSafe ? "" : "=");
44
- }
45
- return result;
46
- }
47
- function decodeBase64(input, urlSafe) {
48
- let chars = urlSafe ? URL_SAFE_CHARS : STANDARD_CHARS;
49
- let normalized = input;
50
- if (!urlSafe && (input.includes("-") || input.includes("_"))) {
51
- chars = URL_SAFE_CHARS;
52
- normalized = input;
53
- }
54
- normalized = normalized.replace(/[=]/g, "");
55
- const lookup = {};
56
- for (let i = 0; i < chars.length; i++) {
57
- lookup[chars[i]] = i;
58
- }
59
- let result = "";
60
- let buffer = 0;
61
- let bits = 0;
62
- for (const char of normalized) {
63
- const value = lookup[char];
64
- if (value === void 0) {
65
- continue;
66
- }
67
- buffer = buffer << 6 | value;
68
- bits += 6;
69
- if (bits >= 8) {
70
- bits -= 8;
71
- result += String.fromCharCode(buffer >> bits & 255);
72
- }
73
- }
74
- return result;
75
- }
76
- function base64() {
77
- try {
78
- const inputStr = Host.inputString();
79
- const input = JSON.parse(inputStr);
80
- const urlSafe = input.urlSafe ?? false;
81
- let result;
82
- if (input.operation === "encode") {
83
- result = encodeBase64(input.text, urlSafe);
84
- } else {
85
- result = decodeBase64(input.text, urlSafe);
86
- }
87
- const output = {
88
- result,
89
- operation: input.operation
90
- };
91
- Host.outputString(JSON.stringify(output));
92
- return 0;
93
- } catch (error) {
94
- const output = {
95
- result: "",
96
- operation: "unknown",
97
- error: error instanceof Error ? error.message : String(error)
98
- };
99
- Host.outputString(JSON.stringify(output));
100
- return 1;
101
- }
102
- }
package/dist/temp/calc.js DELETED
@@ -1,102 +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/calc.ts
21
- var calc_exports = {};
22
- __export(calc_exports, {
23
- calculate: () => calculate
24
- });
25
- module.exports = __toCommonJS(calc_exports);
26
- function safeEval(expression) {
27
- const sanitized = expression.replace(/[^0-9+\-*/().%\s]/g, "");
28
- if (sanitized !== expression.trim()) {
29
- throw new Error("Invalid characters in expression");
30
- }
31
- const matched = sanitized.match(/(\d*\.?\d+|[+\-*/()%])/g);
32
- if (!matched) {
33
- throw new Error("No valid tokens in expression");
34
- }
35
- const tokens = matched;
36
- let pos = 0;
37
- function parseExpr() {
38
- let left = parseTerm();
39
- while (pos < tokens.length && (tokens[pos] === "+" || tokens[pos] === "-")) {
40
- const op = tokens[pos++];
41
- const right = parseTerm();
42
- left = op === "+" ? left + right : left - right;
43
- }
44
- return left;
45
- }
46
- function parseTerm() {
47
- let left = parseFactor();
48
- while (pos < tokens.length && (tokens[pos] === "*" || tokens[pos] === "/" || tokens[pos] === "%")) {
49
- const op = tokens[pos++];
50
- const right = parseFactor();
51
- if (op === "*") left *= right;
52
- else if (op === "/") {
53
- if (right === 0) throw new Error("Division by zero");
54
- left /= right;
55
- } else {
56
- left %= right;
57
- }
58
- }
59
- return left;
60
- }
61
- function parseFactor() {
62
- if (tokens[pos] === "(") {
63
- pos++;
64
- const val = parseExpr();
65
- if (tokens[pos] === ")") pos++;
66
- return val;
67
- }
68
- if (tokens[pos] === "-") {
69
- pos++;
70
- return -parseFactor();
71
- }
72
- if (tokens[pos] === "+") {
73
- pos++;
74
- return parseFactor();
75
- }
76
- const num = parseFloat(tokens[pos++]);
77
- if (isNaN(num)) throw new Error("Invalid expression");
78
- return num;
79
- }
80
- return parseExpr();
81
- }
82
- function calculate() {
83
- try {
84
- const inputStr = Host.inputString();
85
- const input = JSON.parse(inputStr);
86
- const result = safeEval(input.expression);
87
- const output = {
88
- result,
89
- expression: input.expression
90
- };
91
- Host.outputString(JSON.stringify(output));
92
- return 0;
93
- } catch (error) {
94
- const output = {
95
- result: NaN,
96
- expression: "",
97
- error: error instanceof Error ? error.message : String(error)
98
- };
99
- Host.outputString(JSON.stringify(output));
100
- return 1;
101
- }
102
- }