emnapi 1.7.1 → 1.8.1

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.
@@ -1143,6 +1143,44 @@ function _napi_get_arraybuffer_info(env, arraybuffer, data, byte_length) {
1143
1143
  }
1144
1144
  return envObject.clearLastError();
1145
1145
  }
1146
+ /**
1147
+ * @__sig ippp
1148
+ */
1149
+ function _node_api_set_prototype(env, object, value) {
1150
+ if (!env)
1151
+ return 1 /* napi_status.napi_invalid_arg */;
1152
+ // @ts-expect-error
1153
+ var envObject = emnapiCtx.envStore.get(env);
1154
+ envObject.checkGCAccess();
1155
+ if (!envObject.tryCatch.isEmpty())
1156
+ return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
1157
+ if (!envObject.canCallIntoJs())
1158
+ return envObject.setLastError(envObject.moduleApiVersion >= 10 ? 23 /* napi_status.napi_cannot_run_js */ : 10 /* napi_status.napi_pending_exception */);
1159
+ envObject.clearLastError();
1160
+ try {
1161
+ if (!value)
1162
+ return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
1163
+ var obj = emnapiCtx.handleStore.get(object).value;
1164
+ if (obj == null) {
1165
+ throw new TypeError('Cannot convert undefined or null to object');
1166
+ }
1167
+ var type = typeof obj;
1168
+ var v = void 0;
1169
+ try {
1170
+ v = (type === 'object' && obj !== null) || type === 'function' ? obj : Object(obj);
1171
+ }
1172
+ catch (_) {
1173
+ return envObject.setLastError(2 /* napi_status.napi_object_expected */);
1174
+ }
1175
+ var val = emnapiCtx.handleStore.get(value).value;
1176
+ Object.setPrototypeOf(v, val);
1177
+ return envObject.getReturnStatus();
1178
+ }
1179
+ catch (err) {
1180
+ envObject.tryCatch.setError(err);
1181
+ return envObject.setLastError(10 /* napi_status.napi_pending_exception */);
1182
+ }
1183
+ }
1146
1184
  /**
1147
1185
  * @__sig ippp
1148
1186
  */
@@ -1224,6 +1262,9 @@ function _napi_get_typedarray_info(env, typedarray, type, length, data, arraybuf
1224
1262
  else if (v instanceof Uint32Array) {
1225
1263
  t = 6 /* napi_typedarray_type.napi_uint32_array */;
1226
1264
  }
1265
+ else if (typeof Float16Array === 'function' && v instanceof Float16Array) {
1266
+ t = 11 /* napi_typedarray_type.napi_float16_array */;
1267
+ }
1227
1268
  else if (v instanceof Float32Array) {
1228
1269
  t = 7 /* napi_typedarray_type.napi_float32_array */;
1229
1270
  }
@@ -2574,6 +2615,12 @@ function _emnapi_create_memory_view(env, typedarray_type, external_data, byte_le
2574
2615
  case -1 /* emnapi_memory_view_type.emnapi_data_view */:
2575
2616
  viewDescriptor = { Ctor: DataView, address: external_data, length: byte_length, ownership: 1 /* ReferenceOwnership.kUserland */, runtimeAllocated: 0 };
2576
2617
  break;
2618
+ case 11 /* emnapi_memory_view_type.emnapi_float16_array */:
2619
+ if (typeof Float16Array !== 'function') {
2620
+ return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
2621
+ }
2622
+ viewDescriptor = { Ctor: Float16Array, address: external_data, length: byte_length >> 1, ownership: 1 /* ReferenceOwnership.kUserland */, runtimeAllocated: 0 };
2623
+ break;
2577
2624
  case -2 /* emnapi_memory_view_type.emnapi_buffer */: {
2578
2625
  if (!emnapiCtx.feature.Buffer) {
2579
2626
  throw emnapiCtx.createNotSupportBufferError('emnapi_create_memory_view', '');
@@ -3236,6 +3283,11 @@ function _napi_create_typedarray(env, type, length, arraybuffer, byte_offset, re
3236
3283
  return createTypedArray(envObject, BigInt64Array, 8, buffer, byte_offset, length);
3237
3284
  case 10 /* napi_typedarray_type.napi_biguint64_array */:
3238
3285
  return createTypedArray(envObject, BigUint64Array, 8, buffer, byte_offset, length);
3286
+ case 11 /* napi_typedarray_type.napi_float16_array */:
3287
+ if (typeof Float16Array !== 'function') {
3288
+ return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
3289
+ }
3290
+ return createTypedArray(envObject, Float16Array, 2, buffer, byte_offset, length);
3239
3291
  default:
3240
3292
  return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
3241
3293
  }
@@ -7353,6 +7405,9 @@ function _napi_get_version(env, result) {
7353
7405
  node_api_post_finalizer: _node_api_post_finalizer,
7354
7406
  node_api_post_finalizer__deps: ["$emnapiCtx"],
7355
7407
  node_api_post_finalizer__sig: "ipppp",
7408
+ node_api_set_prototype: _node_api_set_prototype,
7409
+ node_api_set_prototype__deps: ["$emnapiCtx"],
7410
+ node_api_set_prototype__sig: "ippp",
7356
7411
  node_api_symbol_for: _node_api_symbol_for,
7357
7412
  node_api_symbol_for__deps: ["$emnapiCtx", "$emnapiString"],
7358
7413
  node_api_symbol_for__sig: "ipppp",
@@ -6,7 +6,7 @@
6
6
  #include "emnapi_common.h"
7
7
 
8
8
  #define EMNAPI_MAJOR_VERSION 1
9
- #define EMNAPI_MINOR_VERSION 7
9
+ #define EMNAPI_MINOR_VERSION 8
10
10
  #define EMNAPI_PATCH_VERSION 1
11
11
 
12
12
  typedef enum {
@@ -26,6 +26,7 @@ typedef enum {
26
26
  emnapi_float64_array,
27
27
  emnapi_bigint64_array,
28
28
  emnapi_biguint64_array,
29
+ emnapi_float16_array,
29
30
  emnapi_data_view = -1,
30
31
  emnapi_buffer = -2,
31
32
  } emnapi_memory_view_type;
@@ -203,6 +203,12 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_coerce_to_string(napi_env env,
203
203
  napi_value* result);
204
204
 
205
205
  // Methods to work with Objects
206
+ #ifdef NAPI_EXPERIMENTAL
207
+ #define NODE_API_EXPERIMENTAL_HAS_SET_PROTOTYPE
208
+ NAPI_EXTERN napi_status NAPI_CDECL node_api_set_prototype(napi_env env,
209
+ napi_value object,
210
+ napi_value value);
211
+ #endif
206
212
  NAPI_EXTERN napi_status NAPI_CDECL napi_get_prototype(napi_env env,
207
213
  napi_value object,
208
214
  napi_value* result);
@@ -133,6 +133,8 @@ typedef enum {
133
133
  napi_float64_array,
134
134
  napi_bigint64_array,
135
135
  napi_biguint64_array,
136
+ #define NODE_API_HAS_FLOAT16_ARRAY
137
+ napi_float16_array,
136
138
  } napi_typedarray_type;
137
139
 
138
140
  typedef enum {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emnapi",
3
- "version": "1.7.1",
3
+ "version": "1.8.1",
4
4
  "description": "Node-API implementation for Emscripten",
5
5
  "main": "index.js",
6
6
  "gypfile": false,