@schematichq/schematic-react 1.2.13 → 1.2.14

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.
@@ -799,7 +799,7 @@ function contextString(context) {
799
799
  }, {});
800
800
  return JSON.stringify(sortedContext);
801
801
  }
802
- var version = "1.2.13";
802
+ var version = "1.2.14";
803
803
  var anonymousIdKey = "schematicId";
804
804
  var Schematic = class {
805
805
  additionalHeaders = {};
@@ -948,13 +948,17 @@ var Schematic = class {
948
948
  /**
949
949
  * Resolve fallback value according to priority order:
950
950
  * 1. Callsite fallback value (if provided)
951
- * 2. Initialization fallback value (flagValueDefaults)
952
- * 3. Default to false
951
+ * 2. Boolean value from flagCheckDefaults initialization option
952
+ * 3. Boolean value from flagValueDefaults initialization option
953
+ * 4. Default to false
953
954
  */
954
955
  resolveFallbackValue(key, callsiteFallback) {
955
956
  if (callsiteFallback !== void 0) {
956
957
  return callsiteFallback;
957
958
  }
959
+ if (key in this.flagCheckDefaults) {
960
+ return this.flagCheckDefaults[key].value;
961
+ }
958
962
  if (key in this.flagValueDefaults) {
959
963
  return this.flagValueDefaults[key];
960
964
  }
@@ -1073,7 +1077,10 @@ var Schematic = class {
1073
1077
  try {
1074
1078
  await this.setContext(context);
1075
1079
  } catch (error) {
1076
- console.warn("WebSocket connection failed, falling back to REST:", error);
1080
+ console.warn(
1081
+ "WebSocket connection failed, falling back to REST:",
1082
+ error
1083
+ );
1077
1084
  return this.fallbackToRest(key, context, fallback);
1078
1085
  }
1079
1086
  const contextVals = this.checks[contextStr] ?? {};
@@ -2071,12 +2078,31 @@ var Schematic = class {
2071
2078
  getFlagCheck = (flagKey) => {
2072
2079
  const contextStr = contextString(this.context);
2073
2080
  const checks = this.checks[contextStr] ?? {};
2074
- return checks[flagKey];
2081
+ const check = checks[flagKey];
2082
+ if (check !== void 0) {
2083
+ return check;
2084
+ }
2085
+ if (flagKey in this.flagCheckDefaults || flagKey in this.flagValueDefaults) {
2086
+ return this.resolveFallbackCheckFlagReturn(
2087
+ flagKey,
2088
+ void 0,
2089
+ "Default value used"
2090
+ );
2091
+ }
2092
+ return void 0;
2075
2093
  };
2076
2094
  // flagValues state
2077
2095
  getFlagValue = (flagKey) => {
2078
- const check = this.getFlagCheck(flagKey);
2079
- return check?.value;
2096
+ const contextStr = contextString(this.context);
2097
+ const checks = this.checks[contextStr] ?? {};
2098
+ const check = checks[flagKey];
2099
+ if (check?.value !== void 0) {
2100
+ return check.value;
2101
+ }
2102
+ if (flagKey in this.flagCheckDefaults || flagKey in this.flagValueDefaults) {
2103
+ return this.resolveFallbackValue(flagKey);
2104
+ }
2105
+ return void 0;
2080
2106
  };
2081
2107
  /** Register an event listener that will be notified with the boolean value for a given flag when this value changes */
2082
2108
  addFlagValueListener = (flagKey, listener) => {
@@ -2173,7 +2199,7 @@ var notifyFlagValueListener = (listener, value) => {
2173
2199
  var import_react = __toESM(require("react"));
2174
2200
 
2175
2201
  // src/version.ts
2176
- var version2 = "1.2.13";
2202
+ var version2 = "1.2.14";
2177
2203
 
2178
2204
  // src/context/schematic.tsx
2179
2205
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -754,7 +754,7 @@ function contextString(context) {
754
754
  }, {});
755
755
  return JSON.stringify(sortedContext);
756
756
  }
757
- var version = "1.2.13";
757
+ var version = "1.2.14";
758
758
  var anonymousIdKey = "schematicId";
759
759
  var Schematic = class {
760
760
  additionalHeaders = {};
@@ -903,13 +903,17 @@ var Schematic = class {
903
903
  /**
904
904
  * Resolve fallback value according to priority order:
905
905
  * 1. Callsite fallback value (if provided)
906
- * 2. Initialization fallback value (flagValueDefaults)
907
- * 3. Default to false
906
+ * 2. Boolean value from flagCheckDefaults initialization option
907
+ * 3. Boolean value from flagValueDefaults initialization option
908
+ * 4. Default to false
908
909
  */
909
910
  resolveFallbackValue(key, callsiteFallback) {
910
911
  if (callsiteFallback !== void 0) {
911
912
  return callsiteFallback;
912
913
  }
914
+ if (key in this.flagCheckDefaults) {
915
+ return this.flagCheckDefaults[key].value;
916
+ }
913
917
  if (key in this.flagValueDefaults) {
914
918
  return this.flagValueDefaults[key];
915
919
  }
@@ -1028,7 +1032,10 @@ var Schematic = class {
1028
1032
  try {
1029
1033
  await this.setContext(context);
1030
1034
  } catch (error) {
1031
- console.warn("WebSocket connection failed, falling back to REST:", error);
1035
+ console.warn(
1036
+ "WebSocket connection failed, falling back to REST:",
1037
+ error
1038
+ );
1032
1039
  return this.fallbackToRest(key, context, fallback);
1033
1040
  }
1034
1041
  const contextVals = this.checks[contextStr] ?? {};
@@ -2026,12 +2033,31 @@ var Schematic = class {
2026
2033
  getFlagCheck = (flagKey) => {
2027
2034
  const contextStr = contextString(this.context);
2028
2035
  const checks = this.checks[contextStr] ?? {};
2029
- return checks[flagKey];
2036
+ const check = checks[flagKey];
2037
+ if (check !== void 0) {
2038
+ return check;
2039
+ }
2040
+ if (flagKey in this.flagCheckDefaults || flagKey in this.flagValueDefaults) {
2041
+ return this.resolveFallbackCheckFlagReturn(
2042
+ flagKey,
2043
+ void 0,
2044
+ "Default value used"
2045
+ );
2046
+ }
2047
+ return void 0;
2030
2048
  };
2031
2049
  // flagValues state
2032
2050
  getFlagValue = (flagKey) => {
2033
- const check = this.getFlagCheck(flagKey);
2034
- return check?.value;
2051
+ const contextStr = contextString(this.context);
2052
+ const checks = this.checks[contextStr] ?? {};
2053
+ const check = checks[flagKey];
2054
+ if (check?.value !== void 0) {
2055
+ return check.value;
2056
+ }
2057
+ if (flagKey in this.flagCheckDefaults || flagKey in this.flagValueDefaults) {
2058
+ return this.resolveFallbackValue(flagKey);
2059
+ }
2060
+ return void 0;
2035
2061
  };
2036
2062
  /** Register an event listener that will be notified with the boolean value for a given flag when this value changes */
2037
2063
  addFlagValueListener = (flagKey, listener) => {
@@ -2128,7 +2154,7 @@ var notifyFlagValueListener = (listener, value) => {
2128
2154
  import React, { createContext, useEffect, useMemo, useRef } from "react";
2129
2155
 
2130
2156
  // src/version.ts
2131
- var version2 = "1.2.13";
2157
+ var version2 = "1.2.14";
2132
2158
 
2133
2159
  // src/context/schematic.tsx
2134
2160
  import { jsx } from "react/jsx-runtime";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-react",
3
- "version": "1.2.13",
3
+ "version": "1.2.14",
4
4
  "main": "dist/schematic-react.cjs.js",
5
5
  "module": "dist/schematic-react.esm.js",
6
6
  "types": "dist/schematic-react.d.ts",
@@ -31,7 +31,7 @@
31
31
  "prepare": "husky"
32
32
  },
33
33
  "dependencies": {
34
- "@schematichq/schematic-js": "^1.2.13"
34
+ "@schematichq/schematic-js": "^1.2.14"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@eslint/js": "^9.39.1",
@@ -50,7 +50,7 @@
50
50
  "happy-dom": "^20.0.10",
51
51
  "husky": "^9.1.7",
52
52
  "jsdom": "^27.2.0",
53
- "prettier": "^3.6.2",
53
+ "prettier": "^3.7.4",
54
54
  "react": "^19.2.0",
55
55
  "react-dom": "^19.2.0",
56
56
  "typescript": "^5.9.3",