superposition-provider 0.93.2 → 0.94.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/dist/index.esm.js CHANGED
@@ -15906,11 +15906,9 @@ class NativeResolver {
15906
15906
  try {
15907
15907
  this.lib = koffi.load(libPath || this.getDefaultLibPath());
15908
15908
  // Define the core resolution functions with CORRECT 8 parameters each
15909
- this.lib.core_get_resolved_config = this.lib.func("char* core_get_resolved_config(const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*)");
15910
- this.lib.core_get_resolved_config_with_reasoning = this.lib.func("char* core_get_resolved_config_with_reasoning(const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*)");
15909
+ this.lib.core_get_resolved_config = this.lib.func("char* core_get_resolved_config(const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*)");
15910
+ this.lib.core_get_resolved_config_with_reasoning = this.lib.func("char* core_get_resolved_config_with_reasoning(const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*, const char*)");
15911
15911
  this.lib.core_free_string = this.lib.func("void core_free_string(char*)");
15912
- this.lib.core_last_error_message = this.lib.func("char* core_last_error_message()");
15913
- this.lib.core_last_error_length = this.lib.func("int core_last_error_length()");
15914
15912
  this.lib.core_get_applicable_variants = this.lib.func("char* core_get_applicable_variants(const char*, const char*, const char*, const char*, const char*)");
15915
15913
  this.lib.core_test_connection = this.lib.func("int core_test_connection()");
15916
15914
  this.isAvailable = true;
@@ -15990,10 +15988,12 @@ class NativeResolver {
15990
15988
  queryDataJson === "undefined") {
15991
15989
  throw new Error("queryData serialization failed");
15992
15990
  }
15993
- const result = this.lib.core_get_resolved_config(defaultConfigsJson, contextsJson, overridesJson, dimensionsJson, queryDataJson, mergeStrategy, filterPrefixesJson, experimentationJson);
15991
+ const ebuf = Buffer$1.alloc(256);
15992
+ const result = this.lib.core_get_resolved_config(defaultConfigsJson, contextsJson, overridesJson, dimensionsJson, queryDataJson, mergeStrategy, filterPrefixesJson, experimentationJson, ebuf);
15994
15993
  console.log("🔧 FFI call completed, result:", result);
15995
- if (!result) {
15996
- this.throwLastError("Failed to resolve config");
15994
+ const err = ebuf.toString('utf8').split('\0')[0];
15995
+ if (err.length !== 0) {
15996
+ this.throwFFIError(err);
15997
15997
  }
15998
15998
  const configStr = typeof result === "string"
15999
15999
  ? result
@@ -16020,9 +16020,11 @@ class NativeResolver {
16020
16020
  const experimentationJson = experimentation
16021
16021
  ? JSON.stringify(experimentation)
16022
16022
  : null;
16023
- const result = this.lib.core_get_resolved_config_with_reasoning(JSON.stringify(defaultConfigs || {}), JSON.stringify(contexts), JSON.stringify(overrides), JSON.stringify(dimensions), JSON.stringify(queryData), mergeStrategy, filterPrefixesJson, experimentationJson);
16024
- if (!result) {
16025
- this.throwLastError("Failed to resolve config with reasoning");
16023
+ const ebuf = Buffer$1.alloc(256);
16024
+ const result = this.lib.core_get_resolved_config_with_reasoning(JSON.stringify(defaultConfigs || {}), JSON.stringify(contexts), JSON.stringify(overrides), JSON.stringify(dimensions), JSON.stringify(queryData), mergeStrategy, filterPrefixesJson, experimentationJson, ebuf);
16025
+ const err = ebuf.toString('utf8').split('\0')[0];
16026
+ if (err.length !== 0) {
16027
+ this.throwFFIError(err);
16026
16028
  }
16027
16029
  const configStr = typeof result === "string"
16028
16030
  ? result
@@ -16060,10 +16062,12 @@ class NativeResolver {
16060
16062
  console.log(" userContext:", userContext);
16061
16063
  console.log(" identifier:", identifier);
16062
16064
  console.log(" filterPrefixes:", filterPrefixes);
16065
+ const ebuf = Buffer$1.alloc(256);
16063
16066
  const result = this.lib.core_get_applicable_variants(experimentsJson, experimentGroupsJson, dimensionsJson, userContextJson, identifier, filterPrefixesJson);
16064
16067
  console.log("FFI getApplicableVariants call completed, result:", result);
16065
- if (!result) {
16066
- this.throwLastError("Failed to get applicable variants");
16068
+ const err = ebuf.toString('utf8').split('\0')[0];
16069
+ if (err.length !== 0) {
16070
+ this.throwFFIError(err);
16067
16071
  }
16068
16072
  const resultStr = typeof result === "string"
16069
16073
  ? result
@@ -16147,22 +16151,8 @@ class NativeResolver {
16147
16151
  return false;
16148
16152
  }
16149
16153
  }
16150
- throwLastError(prefix) {
16151
- if (!this.isAvailable) {
16152
- throw new Error(`${prefix}: Native resolver not available`);
16153
- }
16154
- const errorLength = this.lib.core_last_error_length();
16155
- if (errorLength > 0) {
16156
- const errorPtr = this.lib.core_last_error_message();
16157
- const errorMsg = typeof errorPtr === "string"
16158
- ? errorPtr
16159
- : this.lib.decode(errorPtr, "string");
16160
- if (typeof errorPtr !== "string") {
16161
- this.lib.core_free_string(errorPtr);
16162
- }
16163
- throw new Error(`${prefix}: ${errorMsg}`);
16164
- }
16165
- throw new Error(`${prefix}: Unknown error`);
16154
+ throwFFIError(err) {
16155
+ throw new Error("ffi: " + err);
16166
16156
  }
16167
16157
  }
16168
16158