@earthyscience/netcdf4-wasm 0.2.1 → 0.2.2

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,4 +1,4 @@
1
- # netcdf4-wasm [![Demo](https://img.shields.io/badge/Demo-Online-654FF0)](https://earthyscience.github.io/netcdf4-wasm/next-js/)
1
+ # netcdf4-wasm [![viewer](https://img.shields.io/badge/Viewer-Online-654FF0)](https://earthyscience.github.io/netcdf4-wasm/viewer/)
2
2
 
3
3
 
4
4
  [![npm version](https://img.shields.io/npm/v/@earthyscience/netcdf4-wasm.svg)](https://www.npmjs.com/package/@earthyscience/netcdf4-wasm)
Binary file
@@ -442,11 +442,11 @@ export class WasmModuleLoader {
442
442
  //---- Variable Getters ----//
443
443
  nc_get_vara_short: (ncid, varid, start, count) => {
444
444
  const totalLength = count.reduce((a, b) => a * b, 1);
445
- const dataPtr = module._malloc(totalLength * 4);
446
- const startPtr = module._malloc(start.length * 8);
447
- const countPtr = module._malloc(count.length * 8);
448
- start.forEach((val, i) => module.setValue(startPtr + i * 8, val, 'i64'));
449
- count.forEach((val, i) => module.setValue(countPtr + i * 8, val, 'i64'));
445
+ const dataPtr = module._malloc(totalLength * 2);
446
+ const startPtr = module._malloc(start.length * 4);
447
+ const countPtr = module._malloc(count.length * 4);
448
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
449
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
450
450
  const result = nc_get_vara_short_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
451
451
  const data = result === NC_CONSTANTS.NC_NOERR
452
452
  ? new Int16Array(module.HEAP16.buffer, dataPtr, totalLength).slice()
@@ -458,11 +458,11 @@ export class WasmModuleLoader {
458
458
  },
459
459
  nc_get_vara_int: (ncid, varid, start, count) => {
460
460
  const totalLength = count.reduce((a, b) => a * b, 1);
461
- const dataPtr = module._malloc(totalLength * 8);
462
- const startPtr = module._malloc(start.length * 8);
463
- const countPtr = module._malloc(count.length * 8);
464
- start.forEach((val, i) => module.setValue(startPtr + i * 8, val, 'i64'));
465
- count.forEach((val, i) => module.setValue(countPtr + i * 8, val, 'i64'));
461
+ const dataPtr = module._malloc(totalLength * 4);
462
+ const startPtr = module._malloc(start.length * 4);
463
+ const countPtr = module._malloc(count.length * 4);
464
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
465
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
466
466
  const result = nc_get_vara_int_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
467
467
  const data = result === NC_CONSTANTS.NC_NOERR
468
468
  ? new Int32Array(module.HEAP32.buffer, dataPtr, totalLength).slice()
@@ -491,10 +491,10 @@ export class WasmModuleLoader {
491
491
  nc_get_vara_double: (ncid, varid, start, count) => {
492
492
  const totalLength = count.reduce((a, b) => a * b, 1);
493
493
  const dataPtr = module._malloc(totalLength * 8);
494
- const startPtr = module._malloc(start.length * 8);
495
- const countPtr = module._malloc(count.length * 8);
496
- start.forEach((val, i) => module.setValue(startPtr + i * 8, val, 'i64'));
497
- count.forEach((val, i) => module.setValue(countPtr + i * 8, val, 'i64'));
494
+ const startPtr = module._malloc(start.length * 4);
495
+ const countPtr = module._malloc(count.length * 4);
496
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
497
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
498
498
  const result = nc_get_vara_double_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
499
499
  const data = result === NC_CONSTANTS.NC_NOERR
500
500
  ? new Float64Array(module.HEAPF64.buffer, dataPtr, totalLength).slice()
@@ -507,10 +507,10 @@ export class WasmModuleLoader {
507
507
  nc_get_vara_longlong: (ncid, varid, start, count) => {
508
508
  const totalLength = count.reduce((a, b) => a * b, 1);
509
509
  const dataPtr = module._malloc(totalLength * 8);
510
- const startPtr = module._malloc(start.length * 8);
511
- const countPtr = module._malloc(count.length * 8);
512
- start.forEach((val, i) => module.setValue(startPtr + i * 8, val, 'i64'));
513
- count.forEach((val, i) => module.setValue(countPtr + i * 8, val, 'i64'));
510
+ const startPtr = module._malloc(start.length * 4);
511
+ const countPtr = module._malloc(count.length * 4);
512
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
513
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
514
514
  const result = nc_get_vara_longlong_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
515
515
  const data = result === NC_CONSTANTS.NC_NOERR
516
516
  ? new BigInt64Array(module.HEAP64.buffer, dataPtr, totalLength).slice()
@@ -523,10 +523,10 @@ export class WasmModuleLoader {
523
523
  nc_get_vara_schar: (ncid, varid, start, count) => {
524
524
  const totalLength = count.reduce((a, b) => a * b, 1);
525
525
  const dataPtr = module._malloc(totalLength * 1);
526
- const startPtr = module._malloc(start.length * 8);
527
- const countPtr = module._malloc(count.length * 8);
528
- start.forEach((val, i) => module.setValue(startPtr + i * 8, val, 'i64'));
529
- count.forEach((val, i) => module.setValue(countPtr + i * 8, val, 'i64'));
526
+ const startPtr = module._malloc(start.length * 4);
527
+ const countPtr = module._malloc(count.length * 4);
528
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
529
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
530
530
  const result = nc_get_vara_schar_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
531
531
  const data = result === NC_CONSTANTS.NC_NOERR
532
532
  ? new Int8Array(module.HEAP8.buffer, dataPtr, totalLength).slice()
@@ -539,10 +539,10 @@ export class WasmModuleLoader {
539
539
  nc_get_vara_uchar: (ncid, varid, start, count) => {
540
540
  const totalLength = count.reduce((a, b) => a * b, 1);
541
541
  const dataPtr = module._malloc(totalLength * 1);
542
- const startPtr = module._malloc(start.length * 8);
543
- const countPtr = module._malloc(count.length * 8);
544
- start.forEach((val, i) => module.setValue(startPtr + i * 8, val, 'i64'));
545
- count.forEach((val, i) => module.setValue(countPtr + i * 8, val, 'i64'));
542
+ const startPtr = module._malloc(start.length * 4);
543
+ const countPtr = module._malloc(count.length * 4);
544
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
545
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
546
546
  const result = nc_get_vara_uchar_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
547
547
  const data = result === NC_CONSTANTS.NC_NOERR
548
548
  ? new Uint8Array(module.HEAPU8.buffer, dataPtr, totalLength).slice()
@@ -555,10 +555,10 @@ export class WasmModuleLoader {
555
555
  nc_get_vara_ushort: (ncid, varid, start, count) => {
556
556
  const totalLength = count.reduce((a, b) => a * b, 1);
557
557
  const dataPtr = module._malloc(totalLength * 2);
558
- const startPtr = module._malloc(start.length * 8);
559
- const countPtr = module._malloc(count.length * 8);
560
- start.forEach((val, i) => module.setValue(startPtr + i * 8, val, 'i64'));
561
- count.forEach((val, i) => module.setValue(countPtr + i * 8, val, 'i64'));
558
+ const startPtr = module._malloc(start.length * 4);
559
+ const countPtr = module._malloc(count.length * 4);
560
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
561
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
562
562
  const result = nc_get_vara_ushort_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
563
563
  const data = result === NC_CONSTANTS.NC_NOERR
564
564
  ? new Uint16Array(module.HEAPU16.buffer, dataPtr, totalLength).slice()
@@ -571,10 +571,10 @@ export class WasmModuleLoader {
571
571
  nc_get_vara_uint: (ncid, varid, start, count) => {
572
572
  const totalLength = count.reduce((a, b) => a * b, 1);
573
573
  const dataPtr = module._malloc(totalLength * 4);
574
- const startPtr = module._malloc(start.length * 8);
575
- const countPtr = module._malloc(count.length * 8);
576
- start.forEach((val, i) => module.setValue(startPtr + i * 8, val, 'i64'));
577
- count.forEach((val, i) => module.setValue(countPtr + i * 8, val, 'i64'));
574
+ const startPtr = module._malloc(start.length * 4);
575
+ const countPtr = module._malloc(count.length * 4);
576
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
577
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
578
578
  const result = nc_get_vara_uint_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
579
579
  const data = result === NC_CONSTANTS.NC_NOERR
580
580
  ? new Uint32Array(module.HEAPU32.buffer, dataPtr, totalLength).slice()
@@ -587,10 +587,10 @@ export class WasmModuleLoader {
587
587
  nc_get_vara_ulonglong: (ncid, varid, start, count) => {
588
588
  const totalLength = count.reduce((a, b) => a * b, 1);
589
589
  const dataPtr = module._malloc(totalLength * 8);
590
- const startPtr = module._malloc(start.length * 8);
591
- const countPtr = module._malloc(count.length * 8);
592
- start.forEach((val, i) => module.setValue(startPtr + i * 8, val, 'i64'));
593
- count.forEach((val, i) => module.setValue(countPtr + i * 8, val, 'i64'));
590
+ const startPtr = module._malloc(start.length * 4);
591
+ const countPtr = module._malloc(count.length * 4);
592
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
593
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
594
594
  const result = nc_get_vara_ulonglong_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
595
595
  const data = result === NC_CONSTANTS.NC_NOERR
596
596
  ? new BigUint64Array(module.HEAP64.buffer, dataPtr, totalLength).slice()
@@ -603,10 +603,10 @@ export class WasmModuleLoader {
603
603
  nc_get_vara_string: (ncid, varid, start, count) => {
604
604
  const totalLength = count.reduce((a, b) => a * b, 1);
605
605
  const dataPtr = module._malloc(totalLength * 4);
606
- const startPtr = module._malloc(start.length * 8);
607
- const countPtr = module._malloc(count.length * 8);
608
- start.forEach((val, i) => module.setValue(startPtr + i * 8, val, 'i64'));
609
- count.forEach((val, i) => module.setValue(countPtr + i * 8, val, 'i64'));
606
+ const startPtr = module._malloc(start.length * 4);
607
+ const countPtr = module._malloc(count.length * 4);
608
+ start.forEach((val, i) => module.setValue(startPtr + i * 4, val, 'i32'));
609
+ count.forEach((val, i) => module.setValue(countPtr + i * 4, val, 'i32'));
610
610
  const result = nc_get_vara_string_wrapper(ncid, varid, startPtr, countPtr, dataPtr);
611
611
  let data;
612
612
  if (result === NC_CONSTANTS.NC_NOERR) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earthyscience/netcdf4-wasm",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Partial compilation of NetCDF4 library to WebAssembly with TypeScript bindings",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,9 +24,9 @@
24
24
  "prepublishOnly": "npm run clean && npm run install-emscripten && npm run build && npm run test",
25
25
  "install-emscripten": "bash scripts/install-emscripten.sh",
26
26
  "check-deps": "bash scripts/check-dependencies.sh",
27
- "clean:docs": "rimraf docs/next-js/node_modules/@earthyscience/netcdf4-wasm/dist docs/next-js/public/netcdf4-wasm.wasm",
28
- "copy:docs-dist": "cpx \"dist/**/*\" docs/next-js/node_modules/@earthyscience/netcdf4-wasm/dist",
29
- "copy:docs-wasm": "cpx \"dist/*.wasm\" docs/next-js/public",
27
+ "clean:docs": "rimraf docs/viewer/node_modules/@earthyscience/netcdf4-wasm/dist docs/viewer/public/netcdf4-wasm.wasm",
28
+ "copy:docs-dist": "cpx \"dist/**/*\" docs/viewer/node_modules/@earthyscience/netcdf4-wasm/dist",
29
+ "copy:docs-wasm": "cpx \"dist/*.wasm\" docs/viewer/public",
30
30
  "sync-docs": "npm run clean:docs && npm run copy:docs-dist && npm run copy:docs-wasm",
31
31
  "build-and-sync": "npm run build && npm run sync-docs"
32
32
  },
@@ -54,7 +54,10 @@
54
54
  "devDependencies": {
55
55
  "@types/jest": "^29.0.0",
56
56
  "@types/node": "^20.0.0",
57
+ "cpx2": "^8.0.0",
58
+ "cross-env": "^10.1.0",
57
59
  "jest": "^29.0.0",
60
+ "rimraf": "^6.1.2",
58
61
  "ts-jest": "^29.0.0",
59
62
  "typescript": "^5.0.0"
60
63
  },
@@ -71,10 +74,5 @@
71
74
  "homepage": "https://github.com/EarthyScience/netcdf4-wasm/",
72
75
  "bugs": {
73
76
  "url": "https://github.com/EarthyScience/netcdf4-wasm/issues"
74
- },
75
- "dependencies": {
76
- "cpx2": "^8.0.0",
77
- "cross-env": "^10.1.0",
78
- "rimraf": "^6.1.2"
79
77
  }
80
78
  }