@schematichq/schematic-react 1.2.13 → 1.2.15
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/schematic-react.cjs.js +39 -15
- package/dist/schematic-react.esm.js +39 -15
- package/package.json +5 -5
|
@@ -799,7 +799,7 @@ function contextString(context) {
|
|
|
799
799
|
}, {});
|
|
800
800
|
return JSON.stringify(sortedContext);
|
|
801
801
|
}
|
|
802
|
-
var version = "1.2.
|
|
802
|
+
var version = "1.2.15";
|
|
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.
|
|
952
|
-
* 3.
|
|
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(
|
|
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] ?? {};
|
|
@@ -1273,14 +1280,12 @@ var Schematic = class {
|
|
|
1273
1280
|
*/
|
|
1274
1281
|
identify = (body) => {
|
|
1275
1282
|
this.debug(`identify:`, body);
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
});
|
|
1281
|
-
} catch (error) {
|
|
1283
|
+
this.setContext({
|
|
1284
|
+
company: body.company?.keys,
|
|
1285
|
+
user: body.keys
|
|
1286
|
+
}).catch((error) => {
|
|
1282
1287
|
console.warn("Error setting context:", error);
|
|
1283
|
-
}
|
|
1288
|
+
});
|
|
1284
1289
|
return this.handleEvent("identify", body);
|
|
1285
1290
|
};
|
|
1286
1291
|
/**
|
|
@@ -2071,12 +2076,31 @@ var Schematic = class {
|
|
|
2071
2076
|
getFlagCheck = (flagKey) => {
|
|
2072
2077
|
const contextStr = contextString(this.context);
|
|
2073
2078
|
const checks = this.checks[contextStr] ?? {};
|
|
2074
|
-
|
|
2079
|
+
const check = checks[flagKey];
|
|
2080
|
+
if (check !== void 0) {
|
|
2081
|
+
return check;
|
|
2082
|
+
}
|
|
2083
|
+
if (flagKey in this.flagCheckDefaults || flagKey in this.flagValueDefaults) {
|
|
2084
|
+
return this.resolveFallbackCheckFlagReturn(
|
|
2085
|
+
flagKey,
|
|
2086
|
+
void 0,
|
|
2087
|
+
"Default value used"
|
|
2088
|
+
);
|
|
2089
|
+
}
|
|
2090
|
+
return void 0;
|
|
2075
2091
|
};
|
|
2076
2092
|
// flagValues state
|
|
2077
2093
|
getFlagValue = (flagKey) => {
|
|
2078
|
-
const
|
|
2079
|
-
|
|
2094
|
+
const contextStr = contextString(this.context);
|
|
2095
|
+
const checks = this.checks[contextStr] ?? {};
|
|
2096
|
+
const check = checks[flagKey];
|
|
2097
|
+
if (check?.value !== void 0) {
|
|
2098
|
+
return check.value;
|
|
2099
|
+
}
|
|
2100
|
+
if (flagKey in this.flagCheckDefaults || flagKey in this.flagValueDefaults) {
|
|
2101
|
+
return this.resolveFallbackValue(flagKey);
|
|
2102
|
+
}
|
|
2103
|
+
return void 0;
|
|
2080
2104
|
};
|
|
2081
2105
|
/** Register an event listener that will be notified with the boolean value for a given flag when this value changes */
|
|
2082
2106
|
addFlagValueListener = (flagKey, listener) => {
|
|
@@ -2173,7 +2197,7 @@ var notifyFlagValueListener = (listener, value) => {
|
|
|
2173
2197
|
var import_react = __toESM(require("react"));
|
|
2174
2198
|
|
|
2175
2199
|
// src/version.ts
|
|
2176
|
-
var version2 = "1.2.
|
|
2200
|
+
var version2 = "1.2.15";
|
|
2177
2201
|
|
|
2178
2202
|
// src/context/schematic.tsx
|
|
2179
2203
|
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.
|
|
757
|
+
var version = "1.2.15";
|
|
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.
|
|
907
|
-
* 3.
|
|
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(
|
|
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] ?? {};
|
|
@@ -1228,14 +1235,12 @@ var Schematic = class {
|
|
|
1228
1235
|
*/
|
|
1229
1236
|
identify = (body) => {
|
|
1230
1237
|
this.debug(`identify:`, body);
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
});
|
|
1236
|
-
} catch (error) {
|
|
1238
|
+
this.setContext({
|
|
1239
|
+
company: body.company?.keys,
|
|
1240
|
+
user: body.keys
|
|
1241
|
+
}).catch((error) => {
|
|
1237
1242
|
console.warn("Error setting context:", error);
|
|
1238
|
-
}
|
|
1243
|
+
});
|
|
1239
1244
|
return this.handleEvent("identify", body);
|
|
1240
1245
|
};
|
|
1241
1246
|
/**
|
|
@@ -2026,12 +2031,31 @@ var Schematic = class {
|
|
|
2026
2031
|
getFlagCheck = (flagKey) => {
|
|
2027
2032
|
const contextStr = contextString(this.context);
|
|
2028
2033
|
const checks = this.checks[contextStr] ?? {};
|
|
2029
|
-
|
|
2034
|
+
const check = checks[flagKey];
|
|
2035
|
+
if (check !== void 0) {
|
|
2036
|
+
return check;
|
|
2037
|
+
}
|
|
2038
|
+
if (flagKey in this.flagCheckDefaults || flagKey in this.flagValueDefaults) {
|
|
2039
|
+
return this.resolveFallbackCheckFlagReturn(
|
|
2040
|
+
flagKey,
|
|
2041
|
+
void 0,
|
|
2042
|
+
"Default value used"
|
|
2043
|
+
);
|
|
2044
|
+
}
|
|
2045
|
+
return void 0;
|
|
2030
2046
|
};
|
|
2031
2047
|
// flagValues state
|
|
2032
2048
|
getFlagValue = (flagKey) => {
|
|
2033
|
-
const
|
|
2034
|
-
|
|
2049
|
+
const contextStr = contextString(this.context);
|
|
2050
|
+
const checks = this.checks[contextStr] ?? {};
|
|
2051
|
+
const check = checks[flagKey];
|
|
2052
|
+
if (check?.value !== void 0) {
|
|
2053
|
+
return check.value;
|
|
2054
|
+
}
|
|
2055
|
+
if (flagKey in this.flagCheckDefaults || flagKey in this.flagValueDefaults) {
|
|
2056
|
+
return this.resolveFallbackValue(flagKey);
|
|
2057
|
+
}
|
|
2058
|
+
return void 0;
|
|
2035
2059
|
};
|
|
2036
2060
|
/** Register an event listener that will be notified with the boolean value for a given flag when this value changes */
|
|
2037
2061
|
addFlagValueListener = (flagKey, listener) => {
|
|
@@ -2128,7 +2152,7 @@ var notifyFlagValueListener = (listener, value) => {
|
|
|
2128
2152
|
import React, { createContext, useEffect, useMemo, useRef } from "react";
|
|
2129
2153
|
|
|
2130
2154
|
// src/version.ts
|
|
2131
|
-
var version2 = "1.2.
|
|
2155
|
+
var version2 = "1.2.15";
|
|
2132
2156
|
|
|
2133
2157
|
// src/context/schematic.tsx
|
|
2134
2158
|
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.
|
|
3
|
+
"version": "1.2.15",
|
|
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,10 +31,10 @@
|
|
|
31
31
|
"prepare": "husky"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@schematichq/schematic-js": "^1.2.
|
|
34
|
+
"@schematichq/schematic-js": "^1.2.15"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@eslint/js": "^9.39.
|
|
37
|
+
"@eslint/js": "^9.39.2",
|
|
38
38
|
"@microsoft/api-extractor": "^7.55.0",
|
|
39
39
|
"@testing-library/dom": "^10.4.1",
|
|
40
40
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@types/react": "^19.2.6",
|
|
43
43
|
"@vitest/browser": "^4.0.8",
|
|
44
44
|
"esbuild": "^0.27.0",
|
|
45
|
-
"eslint": "^9.39.
|
|
45
|
+
"eslint": "^9.39.2",
|
|
46
46
|
"eslint-plugin-import": "^2.32.0",
|
|
47
47
|
"eslint-plugin-react": "^7.37.5",
|
|
48
48
|
"eslint-plugin-react-hooks": "^7.0.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.
|
|
53
|
+
"prettier": "^3.7.4",
|
|
54
54
|
"react": "^19.2.0",
|
|
55
55
|
"react-dom": "^19.2.0",
|
|
56
56
|
"typescript": "^5.9.3",
|