@ferscloud/fers-calculation-web 0.1.76 → 0.1.77

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 CHANGED
@@ -1,59 +1,10 @@
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
- ## Installation
15
-
16
- ```bash
17
- pip install fers_calculations
18
- ```
19
-
20
- This installs the pre-built Rust bindings -- no Rust toolchain required.
21
-
22
- ## Usage
23
-
24
- ### Standalone (Python)
25
-
26
- You can call `fers_calculations` directly from Python without `FERS_core`:
27
-
28
- ```python
29
- import fers_calculations
30
-
31
- # Load your JSON input
32
- with open("001_cantilever_with_end_load.json") as f:
33
- json_data = f.read()
34
-
35
- # Run the analysis
36
- results_json = fers_calculations.calculate_from_json(json_data)
37
-
38
- # Save the results
39
- with open("results.json", "w") as f:
40
- f.write(results_json)
41
- ```
42
-
43
- ### With FERS_core (recommended)
44
-
45
- For a more ergonomic workflow, use `FERS_core` which handles model creation, calling the Rust engine, and post-processing / visualisation:
46
-
47
- ```bash
48
- pip install fers-core
49
- ```
50
-
51
- ```python
52
- from fers_core import FERS
53
-
54
- model = FERS.from_json("001_cantilever_with_end_load.json")
55
- model.calculate()
56
- model.plot_results_3d()
57
- ```
58
-
59
- See the [FERS_core README](https://pypi.org/project/FERS/) for full documentation.
1
+ # @ferscloud/fers-calculation
2
+
3
+ High-performance structural / mechanical engineering calculations compiled from Rust to WebAssembly.
4
+
5
+ This package is the WebAssembly build of your Rust solver so it can be used from JavaScript and TypeScript (browser apps with a bundler, and in some Node.js setups). It is designed to take structured input (for example JSON) and return results efficiently.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @ferscloud/fers-calculation
@@ -1,4 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
+
3
4
  export function calculate_from_json(json_data: string): string;
5
+
4
6
  export function load_fers_from_file(path: string): string;
@@ -1,5 +1,9 @@
1
+ /* @ts-self-types="./fers_calculations.d.ts" */
2
+
1
3
  import * as wasm from "./fers_calculations_bg.wasm";
2
- export * from "./fers_calculations_bg.js";
3
4
  import { __wbg_set_wasm } from "./fers_calculations_bg.js";
4
5
  __wbg_set_wasm(wasm);
5
6
  wasm.__wbindgen_start();
7
+ export {
8
+ calculate_from_json, load_fers_from_file
9
+ } from "./fers_calculations_bg.js";
@@ -1,13 +1,55 @@
1
- let wasm;
2
- export function __wbg_set_wasm(val) {
3
- wasm = val;
1
+ /**
2
+ * @param {string} json_data
3
+ * @returns {string}
4
+ */
5
+ export function calculate_from_json(json_data) {
6
+ let deferred2_0;
7
+ let deferred2_1;
8
+ try {
9
+ const ptr0 = passStringToWasm0(json_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
10
+ const len0 = WASM_VECTOR_LEN;
11
+ const ret = wasm.calculate_from_json(ptr0, len0);
12
+ deferred2_0 = ret[0];
13
+ deferred2_1 = ret[1];
14
+ return getStringFromWasm0(ret[0], ret[1]);
15
+ } finally {
16
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
17
+ }
4
18
  }
5
19
 
6
-
7
- let WASM_VECTOR_LEN = 0;
20
+ /**
21
+ * @param {string} path
22
+ * @returns {string}
23
+ */
24
+ export function load_fers_from_file(path) {
25
+ let deferred2_0;
26
+ let deferred2_1;
27
+ try {
28
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
29
+ const len0 = WASM_VECTOR_LEN;
30
+ const ret = wasm.load_fers_from_file(ptr0, len0);
31
+ deferred2_0 = ret[0];
32
+ deferred2_1 = ret[1];
33
+ return getStringFromWasm0(ret[0], ret[1]);
34
+ } finally {
35
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
36
+ }
37
+ }
38
+ export function __wbindgen_init_externref_table() {
39
+ const table = wasm.__wbindgen_externrefs;
40
+ const offset = table.grow(4);
41
+ table.set(0, undefined);
42
+ table.set(offset + 0, undefined);
43
+ table.set(offset + 1, null);
44
+ table.set(offset + 2, true);
45
+ table.set(offset + 3, false);
46
+ }
47
+ function getStringFromWasm0(ptr, len) {
48
+ ptr = ptr >>> 0;
49
+ return decodeText(ptr, len);
50
+ }
8
51
 
9
52
  let cachedUint8ArrayMemory0 = null;
10
-
11
53
  function getUint8ArrayMemory0() {
12
54
  if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
13
55
  cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
@@ -15,21 +57,7 @@ function getUint8ArrayMemory0() {
15
57
  return cachedUint8ArrayMemory0;
16
58
  }
17
59
 
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
60
  function passStringToWasm0(arg, malloc, realloc) {
32
-
33
61
  if (realloc === undefined) {
34
62
  const buf = cachedTextEncoder.encode(arg);
35
63
  const ptr = malloc(buf.length, 1) >>> 0;
@@ -50,7 +78,6 @@ function passStringToWasm0(arg, malloc, realloc) {
50
78
  if (code > 0x7F) break;
51
79
  mem[ptr + offset] = code;
52
80
  }
53
-
54
81
  if (offset !== len) {
55
82
  if (offset !== 0) {
56
83
  arg = arg.slice(offset);
@@ -68,9 +95,7 @@ function passStringToWasm0(arg, malloc, realloc) {
68
95
  }
69
96
 
70
97
  let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
71
-
72
98
  cachedTextDecoder.decode();
73
-
74
99
  const MAX_SAFARI_DECODE_BYTES = 2146435072;
75
100
  let numBytesDecoded = 0;
76
101
  function decodeText(ptr, len) {
@@ -83,56 +108,23 @@ function decodeText(ptr, len) {
83
108
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
84
109
  }
85
110
 
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
- }
111
+ const cachedTextEncoder = new TextEncoder();
108
112
 
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
- }
113
+ if (!('encodeInto' in cachedTextEncoder)) {
114
+ cachedTextEncoder.encodeInto = function (arg, view) {
115
+ const buf = cachedTextEncoder.encode(arg);
116
+ view.set(buf);
117
+ return {
118
+ read: arg.length,
119
+ written: buf.length
120
+ };
121
+ };
126
122
  }
127
123
 
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
- };
124
+ let WASM_VECTOR_LEN = 0;
125
+
138
126
 
127
+ let wasm;
128
+ export function __wbg_set_wasm(val) {
129
+ wasm = val;
130
+ }
Binary file
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
- {
2
- "name": "@ferscloud/fers-calculation-web",
3
- "type": "module",
4
- "version": "0.1.76",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/Jeroen124/FERS_core"
8
- },
9
- "files": [
10
- "fers_calculations_bg.wasm",
11
- "fers_calculations.js",
12
- "fers_calculations_bg.js",
13
- "fers_calculations.d.ts"
14
- ],
15
- "main": "fers_calculations.js",
16
- "homepage": "https://ferscloud.com",
17
- "types": "fers_calculations.d.ts",
18
- "sideEffects": [
19
- "./fers_calculations.js",
20
- "./snippets/*"
21
- ],
22
- "publishConfig": {
23
- "access": "public"
24
- }
25
- }
1
+ {
2
+ "name": "@ferscloud/fers-calculation-web",
3
+ "type": "module",
4
+ "version": "0.1.77",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/Jeroen124/FERS_calculations.git"
8
+ },
9
+ "files": [
10
+ "fers_calculations_bg.wasm",
11
+ "fers_calculations.js",
12
+ "fers_calculations_bg.js",
13
+ "fers_calculations.d.ts"
14
+ ],
15
+ "main": "fers_calculations.js",
16
+ "homepage": "https://ferscloud.com",
17
+ "types": "fers_calculations.d.ts",
18
+ "sideEffects": [
19
+ "./fers_calculations.js",
20
+ "./snippets/*"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ }
25
+ }