@ajitems/devtools 0.1.0 → 0.3.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 ADDED
@@ -0,0 +1,70 @@
1
+ # devtools
2
+
3
+ Headless engines for common developer utilities, implemented in Rust and compiled to **WebAssembly**. Use them in the browser or any JS runtime that can load WASM (for example via [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen)).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @ajitems/devtools
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ The package is built with `wasm-pack` for the **`web`** target. Initialize the module once, then call the exported functions. Each engine returns a JSON-shaped object with `ok`, optional `data`, and optional `error` (see `ToolResult` in the sources).
14
+
15
+ ```javascript
16
+ import init, { base64_encode, jwt_decode } from "@ajitems/devtools";
17
+
18
+ await init(); // WASM start (e.g. panic hook)
19
+
20
+ const encoded = base64_encode("hello", false);
21
+ // { ok: true, data: { output: "...", inputBytes: 5, outputBytes: ... }, error: null }
22
+
23
+ const decoded = jwt_decode("eyJ...");
24
+ // { ok: true | false, data: ..., error: ... }
25
+ ```
26
+
27
+ Exact import paths depend on how you bundle or serve the `.wasm` file; follow the [wasm-pack web workflow](https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html) for your toolchain.
28
+
29
+ ## What’s included
30
+
31
+ | Area | Functions (high level) |
32
+ |------|-------------------------|
33
+ | Encoding | `base64_encode`, `base64_decode` |
34
+ | JSON | `json_format`, `json_diff` |
35
+ | JWT | `jwt_decode` |
36
+ | URL | `url_process` |
37
+ | Regex | `regex_test` |
38
+ | Env files | `env_validate` |
39
+ | Docker | `docker_convert` |
40
+ | Tokens / prompts | `tokens_estimate`, `prompt_analyse` |
41
+ | SLA | `sla_calculate` |
42
+ | Payroll / tax (India-oriented) | `ctc_calculate`, `freelance_calculate`, `gst_calculate`, `gstin_validate`, `pan_validate` |
43
+ | India utilities | `validate_ifsc`, `estimate_cloud_cost`, `calculate_working_days`, `calculate_automation_roi`, `calculate_sprint_velocity`, `calculate_retry_budget` |
44
+
45
+ With the **`cron`** feature (enabled in published builds): `cron_parse`.
46
+
47
+ ## Build from source
48
+
49
+ Prerequisites: stable Rust, `wasm32-unknown-unknown`, and [wasm-pack](https://rustwasm.github.io/wasm-pack/).
50
+
51
+ ```bash
52
+ rustup target add wasm32-unknown-unknown
53
+ wasm-pack build --target web --release -- --features cron
54
+ cp package.npm.json pkg/package.json
55
+ ```
56
+
57
+ Optional Cargo features:
58
+
59
+ - **`cron`** — cron expression parsing (`cron_parse`).
60
+ - **`minify`** — pulls in minify/CSS dependencies (see `Cargo.toml`; not required for the default npm build).
61
+
62
+ CI runs `cargo clippy`, `cargo fmt --check`, `cargo test --all-features`, and the WASM build above.
63
+
64
+ ## Publish
65
+
66
+ Releases are published to npm when a version tag `v*` is pushed (see `.github/workflows/publish.yml`).
67
+
68
+ ## License
69
+
70
+ MIT. See [LICENSE](LICENSE).
package/devtools.d.ts CHANGED
@@ -5,6 +5,16 @@ export function base64_decode(input: string, url_safe: boolean): any;
5
5
 
6
6
  export function base64_encode(input: string, url_safe: boolean): any;
7
7
 
8
+ /**
9
+ * WASM: JSON `CtcInput` → JSON `ToolResult<CtcResult>`.
10
+ */
11
+ export function calculateCtc(input: any): any;
12
+
13
+ /**
14
+ * WASM: JSON [`SalaryHikeInput`] → JSON [`ToolResult<SalaryHikeResult>`].
15
+ */
16
+ export function calculateHike(input: any): any;
17
+
8
18
  export function calculate_automation_roi(input: any): any;
9
19
 
10
20
  export function calculate_retry_budget(input: any): any;
@@ -13,6 +23,11 @@ export function calculate_sprint_velocity(input: any): any;
13
23
 
14
24
  export function calculate_working_days(input: any): any;
15
25
 
26
+ /**
27
+ * WASM: JSON [`RegimeCompareInput`] → JSON [`ToolResult<RegimeCompareResult>`].
28
+ */
29
+ export function compareTaxRegimes(input: any): any;
30
+
16
31
  export function cron_parse(expression: string): any;
17
32
 
18
33
  export function ctc_calculate(annual_ctc: number, is_metro: boolean, regime: string): any;
@@ -57,10 +72,13 @@ export interface InitOutput {
57
72
  readonly memory: WebAssembly.Memory;
58
73
  readonly base64_decode: (a: number, b: number, c: number) => number;
59
74
  readonly base64_encode: (a: number, b: number, c: number) => number;
75
+ readonly calculateCtc: (a: number) => number;
76
+ readonly calculateHike: (a: number) => number;
60
77
  readonly calculate_automation_roi: (a: number) => number;
61
78
  readonly calculate_retry_budget: (a: number) => number;
62
79
  readonly calculate_sprint_velocity: (a: number) => number;
63
80
  readonly calculate_working_days: (a: number) => number;
81
+ readonly compareTaxRegimes: (a: number) => number;
64
82
  readonly cron_parse: (a: number, b: number) => number;
65
83
  readonly ctc_calculate: (a: number, b: number, c: number, d: number) => number;
66
84
  readonly docker_convert: (a: number, b: number) => number;
package/devtools.js CHANGED
@@ -24,6 +24,26 @@ export function base64_encode(input, url_safe) {
24
24
  return takeObject(ret);
25
25
  }
26
26
 
27
+ /**
28
+ * WASM: JSON `CtcInput` → JSON `ToolResult<CtcResult>`.
29
+ * @param {any} input
30
+ * @returns {any}
31
+ */
32
+ export function calculateCtc(input) {
33
+ const ret = wasm.calculateCtc(addHeapObject(input));
34
+ return takeObject(ret);
35
+ }
36
+
37
+ /**
38
+ * WASM: JSON [`SalaryHikeInput`] → JSON [`ToolResult<SalaryHikeResult>`].
39
+ * @param {any} input
40
+ * @returns {any}
41
+ */
42
+ export function calculateHike(input) {
43
+ const ret = wasm.calculateHike(addHeapObject(input));
44
+ return takeObject(ret);
45
+ }
46
+
27
47
  /**
28
48
  * @param {any} input
29
49
  * @returns {any}
@@ -60,6 +80,16 @@ export function calculate_working_days(input) {
60
80
  return takeObject(ret);
61
81
  }
62
82
 
83
+ /**
84
+ * WASM: JSON [`RegimeCompareInput`] → JSON [`ToolResult<RegimeCompareResult>`].
85
+ * @param {any} input
86
+ * @returns {any}
87
+ */
88
+ export function compareTaxRegimes(input) {
89
+ const ret = wasm.compareTaxRegimes(addHeapObject(input));
90
+ return takeObject(ret);
91
+ }
92
+
63
93
  /**
64
94
  * @param {string} expression
65
95
  * @returns {any}
@@ -291,6 +321,13 @@ function __wbg_get_imports() {
291
321
  const ret = Number(getObject(arg0));
292
322
  return ret;
293
323
  },
324
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
325
+ const ret = String(getObject(arg1));
326
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
327
+ const len1 = WASM_VECTOR_LEN;
328
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
329
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
330
+ },
294
331
  __wbg___wbindgen_boolean_get_a86c216575a75c30: function(arg0) {
295
332
  const v = getObject(arg0);
296
333
  const ret = typeof(v) === 'boolean' ? v : undefined;
package/devtools_bg.wasm CHANGED
Binary file
@@ -0,0 +1,36 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const base64_decode: (a: number, b: number, c: number) => number;
5
+ export const base64_encode: (a: number, b: number, c: number) => number;
6
+ export const calculateCtc: (a: number) => number;
7
+ export const calculateHike: (a: number) => number;
8
+ export const calculate_automation_roi: (a: number) => number;
9
+ export const calculate_retry_budget: (a: number) => number;
10
+ export const calculate_sprint_velocity: (a: number) => number;
11
+ export const calculate_working_days: (a: number) => number;
12
+ export const compareTaxRegimes: (a: number) => number;
13
+ export const cron_parse: (a: number, b: number) => number;
14
+ export const ctc_calculate: (a: number, b: number, c: number, d: number) => number;
15
+ export const docker_convert: (a: number, b: number) => number;
16
+ export const env_validate: (a: number, b: number) => number;
17
+ export const estimate_cloud_cost: (a: number) => number;
18
+ export const freelance_calculate: (a: number, b: number, c: number, d: number) => number;
19
+ export const gst_calculate: (a: number, b: number, c: number, d: number, e: number) => number;
20
+ export const gstin_validate: (a: number, b: number) => number;
21
+ export const init: () => void;
22
+ export const json_diff: (a: number, b: number, c: number, d: number) => number;
23
+ export const json_format: (a: number, b: number, c: number) => number;
24
+ export const jwt_decode: (a: number, b: number) => number;
25
+ export const pan_validate: (a: number, b: number) => number;
26
+ export const prompt_analyse: (a: number, b: number) => number;
27
+ export const regex_test: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
28
+ export const sla_calculate: (a: number) => number;
29
+ export const tokens_estimate: (a: number, b: number) => number;
30
+ export const url_process: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
31
+ export const validate_ifsc: (a: number, b: number) => number;
32
+ export const __wbindgen_export: (a: number, b: number) => number;
33
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
34
+ export const __wbindgen_export3: (a: number) => void;
35
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;
36
+ export const __wbindgen_start: () => void;
package/package.json CHANGED
@@ -1,24 +1,35 @@
1
1
  {
2
2
  "name": "@ajitems/devtools",
3
- "type": "module",
4
- "collaborators": [
5
- "Ajitem Sahasrabuddhe"
6
- ],
3
+ "version": "0.3.0",
7
4
  "description": "Headless engines for common developer utilities. Compiled to WASM.",
8
- "version": "0.1.0",
9
- "license": "MIT",
5
+ "main": "devtools.js",
6
+ "types": "devtools.d.ts",
7
+ "files": [
8
+ "devtools_bg.wasm",
9
+ "devtools_bg.wasm.d.ts",
10
+ "devtools.js",
11
+ "devtools.d.ts",
12
+ "package.json"
13
+ ],
14
+ "sideEffects": false,
10
15
  "repository": {
11
16
  "type": "git",
12
17
  "url": "https://github.com/asahasrabuddhe/devtools"
13
18
  },
14
- "files": [
15
- "devtools_bg.wasm",
16
- "devtools.js",
17
- "devtools.d.ts"
19
+ "keywords": [
20
+ "devtools",
21
+ "wasm",
22
+ "webassembly",
23
+ "jwt",
24
+ "base64",
25
+ "regex",
26
+ "cron",
27
+ "json",
28
+ "prompt",
29
+ "docker",
30
+ "env",
31
+ "url"
18
32
  ],
19
- "main": "devtools.js",
20
- "types": "devtools.d.ts",
21
- "sideEffects": [
22
- "./snippets/*"
23
- ]
24
- }
33
+ "author": "Ajitem Sahasrabuddhe",
34
+ "license": "MIT"
35
+ }