@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.
- package/README.md +84 -25
- package/dist/index.d.ts +22 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +81 -14
- package/dist/index.js.map +1 -1
- package/dist/manager/types.d.ts +2 -0
- package/dist/manager/types.d.ts.map +1 -1
- package/dist/manager/wasm-loader.d.ts.map +1 -1
- package/dist/manager/wasm-loader.js +11 -2
- package/dist/manager/wasm-loader.js.map +1 -1
- package/dist/manager/wasm-tool-manager.d.ts +1 -0
- package/dist/manager/wasm-tool-manager.d.ts.map +1 -1
- package/dist/manager/wasm-tool-manager.js +56 -13
- package/dist/manager/wasm-tool-manager.js.map +1 -1
- package/dist/runtime.d.ts +11 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +104 -0
- package/dist/runtime.js.map +1 -0
- package/dist/wasm/base64.wasm +0 -0
- package/dist/wasm/calc.wasm +0 -0
- package/dist/wasm/compression.wasm +0 -0
- package/dist/wasm/csv.wasm +0 -0
- package/dist/wasm/datetime.wasm +0 -0
- package/dist/wasm/diff.wasm +0 -0
- package/dist/wasm/hash.wasm +0 -0
- package/dist/wasm/json.wasm +0 -0
- package/dist/wasm/markdown.wasm +0 -0
- package/dist/wasm/regex.wasm +0 -0
- package/dist/wasm/signing.wasm +0 -0
- package/dist/wasm/slug.wasm +0 -0
- package/dist/wasm/validation.wasm +0 -0
- package/dist/wasm/xml.wasm +0 -0
- package/package.json +5 -6
- package/dist/__tests__/file-watcher.test.d.ts +0 -2
- package/dist/__tests__/file-watcher.test.d.ts.map +0 -1
- package/dist/__tests__/file-watcher.test.js +0 -99
- package/dist/__tests__/file-watcher.test.js.map +0 -1
- package/dist/__tests__/index.test.d.ts +0 -2
- package/dist/__tests__/index.test.d.ts.map +0 -1
- package/dist/__tests__/index.test.js +0 -226
- package/dist/__tests__/index.test.js.map +0 -1
- package/dist/__tests__/wasm-loader.test.d.ts +0 -2
- package/dist/__tests__/wasm-loader.test.d.ts.map +0 -1
- package/dist/__tests__/wasm-loader.test.js +0 -68
- package/dist/__tests__/wasm-loader.test.js.map +0 -1
- package/dist/__tests__/wasm-tool-manager.test.d.ts +0 -2
- package/dist/__tests__/wasm-tool-manager.test.d.ts.map +0 -1
- package/dist/__tests__/wasm-tool-manager.test.js +0 -166
- package/dist/__tests__/wasm-tool-manager.test.js.map +0 -1
- package/dist/plugins/base64.d.ts +0 -12
- package/dist/plugins/base64.d.ts.map +0 -1
- package/dist/plugins/base64.js +0 -144
- package/dist/plugins/base64.js.map +0 -1
- package/dist/plugins/calc.d.ts +0 -12
- package/dist/plugins/calc.d.ts.map +0 -1
- package/dist/plugins/calc.js +0 -102
- package/dist/plugins/calc.js.map +0 -1
- package/dist/plugins/compression.d.ts +0 -2
- package/dist/plugins/compression.d.ts.map +0 -1
- package/dist/plugins/compression.js +0 -549
- package/dist/plugins/compression.js.map +0 -1
- package/dist/plugins/csv.d.ts +0 -2
- package/dist/plugins/csv.d.ts.map +0 -1
- package/dist/plugins/csv.js +0 -142
- package/dist/plugins/csv.js.map +0 -1
- package/dist/plugins/datetime.d.ts +0 -2
- package/dist/plugins/datetime.d.ts.map +0 -1
- package/dist/plugins/datetime.js +0 -199
- package/dist/plugins/datetime.js.map +0 -1
- package/dist/plugins/diff.d.ts +0 -2
- package/dist/plugins/diff.d.ts.map +0 -1
- package/dist/plugins/diff.js +0 -187
- package/dist/plugins/diff.js.map +0 -1
- package/dist/plugins/hash.d.ts +0 -12
- package/dist/plugins/hash.d.ts.map +0 -1
- package/dist/plugins/hash.js +0 -310
- package/dist/plugins/hash.js.map +0 -1
- package/dist/plugins/json.d.ts +0 -12
- package/dist/plugins/json.d.ts.map +0 -1
- package/dist/plugins/json.js +0 -70
- package/dist/plugins/json.js.map +0 -1
- package/dist/plugins/markdown.d.ts +0 -2
- package/dist/plugins/markdown.d.ts.map +0 -1
- package/dist/plugins/markdown.js +0 -213
- package/dist/plugins/markdown.js.map +0 -1
- package/dist/plugins/regex.d.ts +0 -2
- package/dist/plugins/regex.d.ts.map +0 -1
- package/dist/plugins/regex.js +0 -120
- package/dist/plugins/regex.js.map +0 -1
- package/dist/plugins/signing.d.ts +0 -2
- package/dist/plugins/signing.d.ts.map +0 -1
- package/dist/plugins/signing.js +0 -589
- package/dist/plugins/signing.js.map +0 -1
- package/dist/plugins/slug.d.ts +0 -2
- package/dist/plugins/slug.d.ts.map +0 -1
- package/dist/plugins/slug.js +0 -183
- package/dist/plugins/slug.js.map +0 -1
- package/dist/plugins/validation.d.ts +0 -2
- package/dist/plugins/validation.d.ts.map +0 -1
- package/dist/plugins/validation.js +0 -105
- package/dist/plugins/validation.js.map +0 -1
- package/dist/plugins/xml.d.ts +0 -2
- package/dist/plugins/xml.d.ts.map +0 -1
- package/dist/plugins/xml.js +0 -297
- package/dist/plugins/xml.js.map +0 -1
- package/dist/temp/base64.js +0 -149
- package/dist/temp/calc.js +0 -108
- package/dist/temp/compression.js +0 -742
- package/dist/temp/csv.js +0 -161
- package/dist/temp/datetime.js +0 -217
- package/dist/temp/diff.js +0 -198
- package/dist/temp/hash.js +0 -424
- package/dist/temp/json.js +0 -80
- package/dist/temp/markdown.js +0 -224
- package/dist/temp/regex.js +0 -141
- package/dist/temp/signing.js +0 -600
- package/dist/temp/slug.js +0 -201
- package/dist/temp/validation.js +0 -125
- package/dist/temp/xml.js +0 -295
package/dist/temp/base64.js
DELETED
|
@@ -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
|
-
}
|