emnapi 1.7.1 → 1.8.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.
@@ -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
  */
@@ -7353,6 +7391,9 @@ function _napi_get_version(env, result) {
7353
7391
  node_api_post_finalizer: _node_api_post_finalizer,
7354
7392
  node_api_post_finalizer__deps: ["$emnapiCtx"],
7355
7393
  node_api_post_finalizer__sig: "ipppp",
7394
+ node_api_set_prototype: _node_api_set_prototype,
7395
+ node_api_set_prototype__deps: ["$emnapiCtx"],
7396
+ node_api_set_prototype__sig: "ippp",
7356
7397
  node_api_symbol_for: _node_api_symbol_for,
7357
7398
  node_api_symbol_for__deps: ["$emnapiCtx", "$emnapiString"],
7358
7399
  node_api_symbol_for__sig: "ipppp",
@@ -6,8 +6,8 @@
6
6
  #include "emnapi_common.h"
7
7
 
8
8
  #define EMNAPI_MAJOR_VERSION 1
9
- #define EMNAPI_MINOR_VERSION 7
10
- #define EMNAPI_PATCH_VERSION 1
9
+ #define EMNAPI_MINOR_VERSION 8
10
+ #define EMNAPI_PATCH_VERSION 0
11
11
 
12
12
  typedef enum {
13
13
  emnapi_runtime,
@@ -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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emnapi",
3
- "version": "1.7.1",
3
+ "version": "1.8.0",
4
4
  "description": "Node-API implementation for Emscripten",
5
5
  "main": "index.js",
6
6
  "gypfile": false,