@ferscloud/fers-calculation 0.1.68

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,20 @@
1
+ # FERS_calculations
2
+
3
+ `FERS_calculations` is a high-performance library for Rust-backed calculations in mechanical engineering. It can process JSON input files to deliver fast and accurate results. While it can be run as a standalone tool, integration with `FERS_core` simplifies input creation and workflow management.
4
+
5
+ ## Features
6
+
7
+ - **Standalone Functionality:** Run directly by providing a valid JSON input file.
8
+ - **Rust-Powered Performance:** Designed for speed and reliability in computational tasks.
9
+ - **Python Integration:** Seamless integration with `FERS_core` for easy preprocessing and result handling.
10
+ - **Engineer-Friendly Design:** Minimal coding effort required for complex structural engineering calculations.
11
+
12
+ ---
13
+
14
+ ## Usage
15
+
16
+ ### Standalone
17
+ You can run `FERS_calculations` without `FERS_core` by preparing a JSON input file and running the binary directly.
18
+
19
+ ```bash
20
+ # TODO: Add example of how to run FERS_calculations with a JSON input
@@ -0,0 +1,4 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export function calculate_from_json(json_data: string): string;
4
+ export function load_fers_from_file(path: string): string;
@@ -0,0 +1,5 @@
1
+ import * as wasm from "./fers_calculations_bg.wasm";
2
+ export * from "./fers_calculations_bg.js";
3
+ import { __wbg_set_wasm } from "./fers_calculations_bg.js";
4
+ __wbg_set_wasm(wasm);
5
+ wasm.__wbindgen_start();
@@ -0,0 +1,138 @@
1
+ let wasm;
2
+ export function __wbg_set_wasm(val) {
3
+ wasm = val;
4
+ }
5
+
6
+
7
+ let WASM_VECTOR_LEN = 0;
8
+
9
+ let cachedUint8ArrayMemory0 = null;
10
+
11
+ function getUint8ArrayMemory0() {
12
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
13
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
14
+ }
15
+ return cachedUint8ArrayMemory0;
16
+ }
17
+
18
+ const cachedTextEncoder = new TextEncoder();
19
+
20
+ if (!('encodeInto' in cachedTextEncoder)) {
21
+ cachedTextEncoder.encodeInto = function (arg, view) {
22
+ const buf = cachedTextEncoder.encode(arg);
23
+ view.set(buf);
24
+ return {
25
+ read: arg.length,
26
+ written: buf.length
27
+ };
28
+ }
29
+ }
30
+
31
+ function passStringToWasm0(arg, malloc, realloc) {
32
+
33
+ if (realloc === undefined) {
34
+ const buf = cachedTextEncoder.encode(arg);
35
+ const ptr = malloc(buf.length, 1) >>> 0;
36
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
37
+ WASM_VECTOR_LEN = buf.length;
38
+ return ptr;
39
+ }
40
+
41
+ let len = arg.length;
42
+ let ptr = malloc(len, 1) >>> 0;
43
+
44
+ const mem = getUint8ArrayMemory0();
45
+
46
+ let offset = 0;
47
+
48
+ for (; offset < len; offset++) {
49
+ const code = arg.charCodeAt(offset);
50
+ if (code > 0x7F) break;
51
+ mem[ptr + offset] = code;
52
+ }
53
+
54
+ if (offset !== len) {
55
+ if (offset !== 0) {
56
+ arg = arg.slice(offset);
57
+ }
58
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
59
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
60
+ const ret = cachedTextEncoder.encodeInto(arg, view);
61
+
62
+ offset += ret.written;
63
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
64
+ }
65
+
66
+ WASM_VECTOR_LEN = offset;
67
+ return ptr;
68
+ }
69
+
70
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
71
+
72
+ cachedTextDecoder.decode();
73
+
74
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
75
+ let numBytesDecoded = 0;
76
+ function decodeText(ptr, len) {
77
+ numBytesDecoded += len;
78
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
79
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
80
+ cachedTextDecoder.decode();
81
+ numBytesDecoded = len;
82
+ }
83
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
84
+ }
85
+
86
+ function getStringFromWasm0(ptr, len) {
87
+ ptr = ptr >>> 0;
88
+ return decodeText(ptr, len);
89
+ }
90
+ /**
91
+ * @param {string} json_data
92
+ * @returns {string}
93
+ */
94
+ export function calculate_from_json(json_data) {
95
+ let deferred2_0;
96
+ let deferred2_1;
97
+ try {
98
+ const ptr0 = passStringToWasm0(json_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
99
+ const len0 = WASM_VECTOR_LEN;
100
+ const ret = wasm.calculate_from_json(ptr0, len0);
101
+ deferred2_0 = ret[0];
102
+ deferred2_1 = ret[1];
103
+ return getStringFromWasm0(ret[0], ret[1]);
104
+ } finally {
105
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
106
+ }
107
+ }
108
+
109
+ /**
110
+ * @param {string} path
111
+ * @returns {string}
112
+ */
113
+ export function load_fers_from_file(path) {
114
+ let deferred2_0;
115
+ let deferred2_1;
116
+ try {
117
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
118
+ const len0 = WASM_VECTOR_LEN;
119
+ const ret = wasm.load_fers_from_file(ptr0, len0);
120
+ deferred2_0 = ret[0];
121
+ deferred2_1 = ret[1];
122
+ return getStringFromWasm0(ret[0], ret[1]);
123
+ } finally {
124
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
125
+ }
126
+ }
127
+
128
+ export function __wbindgen_init_externref_table() {
129
+ const table = wasm.__wbindgen_export_0;
130
+ const offset = table.grow(4);
131
+ table.set(0, undefined);
132
+ table.set(offset + 0, undefined);
133
+ table.set(offset + 1, null);
134
+ table.set(offset + 2, true);
135
+ table.set(offset + 3, false);
136
+ ;
137
+ };
138
+
Binary file
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@ferscloud/fers-calculation",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "type": "module",
7
+ "version": "0.1.68",
8
+ "files": [
9
+ "fers_calculations_bg.wasm",
10
+ "fers_calculations.js",
11
+ "fers_calculations_bg.js",
12
+ "fers_calculations.d.ts"
13
+ ],
14
+ "main": "fers_calculations.js",
15
+ "types": "fers_calculations.d.ts",
16
+ "sideEffects": [
17
+ "./fers_calculations.js",
18
+ "./snippets/*"
19
+ ]
20
+ }