@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
@@ -1,149 +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 stringToUtf8Bytes(str) {
29
- const bytes = [];
30
- for (let i = 0; i < str.length; i++) {
31
- let c = str.charCodeAt(i);
32
- if (c < 128) {
33
- bytes.push(c);
34
- } else if (c < 2048) {
35
- bytes.push(192 | c >> 6, 128 | c & 63);
36
- } else if (c >= 55296 && c < 56320 && i + 1 < str.length) {
37
- const c2 = str.charCodeAt(++i);
38
- c = 65536 + ((c & 1023) << 10) + (c2 & 1023);
39
- bytes.push(
40
- 240 | c >> 18,
41
- 128 | c >> 12 & 63,
42
- 128 | c >> 6 & 63,
43
- 128 | c & 63
44
- );
45
- } else {
46
- bytes.push(224 | c >> 12, 128 | c >> 6 & 63, 128 | c & 63);
47
- }
48
- }
49
- return bytes;
50
- }
51
- function utf8BytesToString(bytes) {
52
- let result = "";
53
- let i = 0;
54
- while (i < bytes.length) {
55
- const b = bytes[i++];
56
- if (b < 128) {
57
- result += String.fromCharCode(b);
58
- } else if (b < 224) {
59
- result += String.fromCharCode((b & 31) << 6 | bytes[i++] & 63);
60
- } else if (b < 240) {
61
- result += String.fromCharCode(
62
- (b & 15) << 12 | (bytes[i++] & 63) << 6 | bytes[i++] & 63
63
- );
64
- } else {
65
- const cp = (b & 7) << 18 | (bytes[i++] & 63) << 12 | (bytes[i++] & 63) << 6 | bytes[i++] & 63;
66
- result += String.fromCodePoint(cp);
67
- }
68
- }
69
- return result;
70
- }
71
- function encodeBase64(input, urlSafe) {
72
- const chars = urlSafe ? URL_SAFE_CHARS : STANDARD_CHARS;
73
- const inputBytes = stringToUtf8Bytes(input);
74
- let result = "";
75
- let i = 0;
76
- while (i < inputBytes.length) {
77
- const a = inputBytes[i++];
78
- const b = i < inputBytes.length ? inputBytes[i++] : 0;
79
- const c = i < inputBytes.length ? inputBytes[i++] : 0;
80
- const bitmap = a << 16 | b << 8 | c;
81
- result += chars.charAt(bitmap >> 18 & 63) + chars.charAt(bitmap >> 12 & 63) + chars.charAt(bitmap >> 6 & 63) + chars.charAt(bitmap & 63);
82
- }
83
- const padding = inputBytes.length % 3;
84
- if (padding === 1) {
85
- result = result.slice(0, -2) + (urlSafe ? "" : "==");
86
- } else if (padding === 2) {
87
- result = result.slice(0, -1) + (urlSafe ? "" : "=");
88
- }
89
- return result;
90
- }
91
- function decodeBase64(input, urlSafe) {
92
- let chars = urlSafe ? URL_SAFE_CHARS : STANDARD_CHARS;
93
- let normalized = input;
94
- if (!urlSafe && (input.includes("-") || input.includes("_"))) {
95
- chars = URL_SAFE_CHARS;
96
- normalized = input;
97
- }
98
- normalized = normalized.replace(/[=]/g, "");
99
- const lookup = {};
100
- for (let i = 0; i < chars.length; i++) {
101
- lookup[chars[i]] = i;
102
- }
103
- const decodedBytes = [];
104
- let buffer = 0;
105
- let bits = 0;
106
- for (const char of normalized) {
107
- const value = lookup[char];
108
- if (value === void 0) {
109
- continue;
110
- }
111
- buffer = buffer << 6 | value;
112
- bits += 6;
113
- if (bits >= 8) {
114
- bits -= 8;
115
- decodedBytes.push(buffer >> bits & 255);
116
- }
117
- }
118
- return utf8BytesToString(decodedBytes);
119
- }
120
- function base64() {
121
- try {
122
- const inputStr = Host.inputString();
123
- const input = JSON.parse(inputStr);
124
- const urlSafe = input.urlSafe ?? false;
125
- if (input.operation !== "encode" && input.operation !== "decode") {
126
- throw new Error(`Unknown operation: ${input.operation}`);
127
- }
128
- let result;
129
- if (input.operation === "encode") {
130
- result = encodeBase64(input.text, urlSafe);
131
- } else {
132
- result = decodeBase64(input.text, urlSafe);
133
- }
134
- const output = {
135
- result,
136
- operation: input.operation
137
- };
138
- Host.outputString(JSON.stringify(output));
139
- return 0;
140
- } catch (error) {
141
- const output = {
142
- result: "",
143
- operation: "unknown",
144
- error: error instanceof Error ? error.message : String(error)
145
- };
146
- Host.outputString(JSON.stringify(output));
147
- return 1;
148
- }
149
- }
package/dist/temp/calc.js DELETED
@@ -1,108 +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
- if (right === 0) throw new Error("Modulo by zero");
57
- left %= right;
58
- }
59
- }
60
- return left;
61
- }
62
- function parseFactor() {
63
- if (tokens[pos] === "(") {
64
- pos++;
65
- const val = parseExpr();
66
- if (tokens[pos] !== ")") throw new Error("Missing closing parenthesis");
67
- pos++;
68
- return val;
69
- }
70
- if (tokens[pos] === "-") {
71
- pos++;
72
- return -parseFactor();
73
- }
74
- if (tokens[pos] === "+") {
75
- pos++;
76
- return parseFactor();
77
- }
78
- const num = parseFloat(tokens[pos++]);
79
- if (isNaN(num)) throw new Error("Invalid expression");
80
- return num;
81
- }
82
- const result = parseExpr();
83
- if (pos < tokens.length) {
84
- throw new Error(`Unexpected token: ${tokens[pos]}`);
85
- }
86
- return result;
87
- }
88
- function calculate() {
89
- try {
90
- const inputStr = Host.inputString();
91
- const input = JSON.parse(inputStr);
92
- const result = safeEval(input.expression);
93
- const output = {
94
- result,
95
- expression: input.expression
96
- };
97
- Host.outputString(JSON.stringify(output));
98
- return 0;
99
- } catch (error) {
100
- const output = {
101
- result: NaN,
102
- expression: "",
103
- error: error instanceof Error ? error.message : String(error)
104
- };
105
- Host.outputString(JSON.stringify(output));
106
- return 1;
107
- }
108
- }