@schematichq/schematic-react 1.2.1 → 1.2.3
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.
@@ -773,6 +773,7 @@ function contextString(context) {
|
|
773
773
|
}, {});
|
774
774
|
return JSON.stringify(sortedContext);
|
775
775
|
}
|
776
|
+
var version = "1.2.1";
|
776
777
|
var anonymousIdKey = "schematicId";
|
777
778
|
var Schematic = class {
|
778
779
|
additionalHeaders = {};
|
@@ -794,9 +795,10 @@ var Schematic = class {
|
|
794
795
|
this.apiKey = apiKey;
|
795
796
|
this.eventQueue = [];
|
796
797
|
this.useWebSocket = options?.useWebSocket ?? false;
|
797
|
-
|
798
|
-
|
799
|
-
|
798
|
+
this.additionalHeaders = {
|
799
|
+
"X-Schematic-Client-Version": `schematic-js@${version}`,
|
800
|
+
...options?.additionalHeaders ?? {}
|
801
|
+
};
|
800
802
|
if (options?.storage) {
|
801
803
|
this.storage = options.storage;
|
802
804
|
} else if (typeof localStorage !== "undefined") {
|
@@ -1065,7 +1067,7 @@ var Schematic = class {
|
|
1065
1067
|
// Open a websocket connection
|
1066
1068
|
wsConnect = () => {
|
1067
1069
|
return new Promise((resolve, reject) => {
|
1068
|
-
const wsUrl = `${this.webSocketUrl}/flags/bootstrap`;
|
1070
|
+
const wsUrl = `${this.webSocketUrl}/flags/bootstrap?apiKey=${this.apiKey}`;
|
1069
1071
|
const webSocket = new WebSocket(wsUrl);
|
1070
1072
|
webSocket.onopen = () => {
|
1071
1073
|
resolve(webSocket);
|
@@ -1109,6 +1111,7 @@ var Schematic = class {
|
|
1109
1111
|
socket.send(
|
1110
1112
|
JSON.stringify({
|
1111
1113
|
apiKey: this.apiKey,
|
1114
|
+
clientVersion: `schematic-js@${version}`,
|
1112
1115
|
data: context
|
1113
1116
|
})
|
1114
1117
|
);
|
@@ -1205,6 +1208,11 @@ var notifyFlagValueListener = (listener, value) => {
|
|
1205
1208
|
|
1206
1209
|
// src/context/schematic.tsx
|
1207
1210
|
var import_react = __toESM(require("react"));
|
1211
|
+
|
1212
|
+
// src/version.ts
|
1213
|
+
var version2 = "1.2.3";
|
1214
|
+
|
1215
|
+
// src/context/schematic.tsx
|
1208
1216
|
var import_jsx_runtime = require("react/jsx-runtime");
|
1209
1217
|
var SchematicContext = (0, import_react.createContext)(
|
1210
1218
|
null
|
@@ -1218,6 +1226,9 @@ var SchematicProvider = ({
|
|
1218
1226
|
const initialOptsRef = (0, import_react.useRef)({
|
1219
1227
|
publishableKey,
|
1220
1228
|
useWebSocket: clientOpts.useWebSocket ?? true,
|
1229
|
+
additionalHeaders: {
|
1230
|
+
"X-Schematic-Client-Version": `schematic-react@${version2}`
|
1231
|
+
},
|
1221
1232
|
...clientOpts
|
1222
1233
|
});
|
1223
1234
|
const client = (0, import_react.useMemo)(() => {
|
@@ -1297,7 +1308,7 @@ var useSchematicFlag = (key, opts) => {
|
|
1297
1308
|
const value = client.getFlagValue(key);
|
1298
1309
|
return typeof value === "undefined" ? fallback : value;
|
1299
1310
|
}, [client, key, fallback]);
|
1300
|
-
return (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot);
|
1311
|
+
return (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot, () => fallback);
|
1301
1312
|
};
|
1302
1313
|
var useSchematicEntitlement = (key, opts) => {
|
1303
1314
|
const client = useSchematicClient(opts);
|
@@ -1318,7 +1329,7 @@ var useSchematicEntitlement = (key, opts) => {
|
|
1318
1329
|
const check = client.getFlagCheck(key);
|
1319
1330
|
return check ?? fallbackCheck;
|
1320
1331
|
}, [client, key, fallbackCheck]);
|
1321
|
-
return (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot);
|
1332
|
+
return (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot, () => fallbackCheck);
|
1322
1333
|
};
|
1323
1334
|
var useSchematicIsPending = (opts) => {
|
1324
1335
|
const client = useSchematicClient(opts);
|
@@ -1327,7 +1338,7 @@ var useSchematicIsPending = (opts) => {
|
|
1327
1338
|
[client]
|
1328
1339
|
);
|
1329
1340
|
const getSnapshot = (0, import_react2.useCallback)(() => client.getIsPending(), [client]);
|
1330
|
-
return (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot);
|
1341
|
+
return (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot, () => true);
|
1331
1342
|
};
|
1332
1343
|
/*! Bundled license information:
|
1333
1344
|
|
@@ -728,6 +728,7 @@ function contextString(context) {
|
|
728
728
|
}, {});
|
729
729
|
return JSON.stringify(sortedContext);
|
730
730
|
}
|
731
|
+
var version = "1.2.1";
|
731
732
|
var anonymousIdKey = "schematicId";
|
732
733
|
var Schematic = class {
|
733
734
|
additionalHeaders = {};
|
@@ -749,9 +750,10 @@ var Schematic = class {
|
|
749
750
|
this.apiKey = apiKey;
|
750
751
|
this.eventQueue = [];
|
751
752
|
this.useWebSocket = options?.useWebSocket ?? false;
|
752
|
-
|
753
|
-
|
754
|
-
|
753
|
+
this.additionalHeaders = {
|
754
|
+
"X-Schematic-Client-Version": `schematic-js@${version}`,
|
755
|
+
...options?.additionalHeaders ?? {}
|
756
|
+
};
|
755
757
|
if (options?.storage) {
|
756
758
|
this.storage = options.storage;
|
757
759
|
} else if (typeof localStorage !== "undefined") {
|
@@ -1020,7 +1022,7 @@ var Schematic = class {
|
|
1020
1022
|
// Open a websocket connection
|
1021
1023
|
wsConnect = () => {
|
1022
1024
|
return new Promise((resolve, reject) => {
|
1023
|
-
const wsUrl = `${this.webSocketUrl}/flags/bootstrap`;
|
1025
|
+
const wsUrl = `${this.webSocketUrl}/flags/bootstrap?apiKey=${this.apiKey}`;
|
1024
1026
|
const webSocket = new WebSocket(wsUrl);
|
1025
1027
|
webSocket.onopen = () => {
|
1026
1028
|
resolve(webSocket);
|
@@ -1064,6 +1066,7 @@ var Schematic = class {
|
|
1064
1066
|
socket.send(
|
1065
1067
|
JSON.stringify({
|
1066
1068
|
apiKey: this.apiKey,
|
1069
|
+
clientVersion: `schematic-js@${version}`,
|
1067
1070
|
data: context
|
1068
1071
|
})
|
1069
1072
|
);
|
@@ -1160,6 +1163,11 @@ var notifyFlagValueListener = (listener, value) => {
|
|
1160
1163
|
|
1161
1164
|
// src/context/schematic.tsx
|
1162
1165
|
import React, { createContext, useEffect, useMemo, useRef } from "react";
|
1166
|
+
|
1167
|
+
// src/version.ts
|
1168
|
+
var version2 = "1.2.3";
|
1169
|
+
|
1170
|
+
// src/context/schematic.tsx
|
1163
1171
|
import { jsx } from "react/jsx-runtime";
|
1164
1172
|
var SchematicContext = createContext(
|
1165
1173
|
null
|
@@ -1173,6 +1181,9 @@ var SchematicProvider = ({
|
|
1173
1181
|
const initialOptsRef = useRef({
|
1174
1182
|
publishableKey,
|
1175
1183
|
useWebSocket: clientOpts.useWebSocket ?? true,
|
1184
|
+
additionalHeaders: {
|
1185
|
+
"X-Schematic-Client-Version": `schematic-react@${version2}`
|
1186
|
+
},
|
1176
1187
|
...clientOpts
|
1177
1188
|
});
|
1178
1189
|
const client = useMemo(() => {
|
@@ -1252,7 +1263,7 @@ var useSchematicFlag = (key, opts) => {
|
|
1252
1263
|
const value = client.getFlagValue(key);
|
1253
1264
|
return typeof value === "undefined" ? fallback : value;
|
1254
1265
|
}, [client, key, fallback]);
|
1255
|
-
return useSyncExternalStore(subscribe, getSnapshot);
|
1266
|
+
return useSyncExternalStore(subscribe, getSnapshot, () => fallback);
|
1256
1267
|
};
|
1257
1268
|
var useSchematicEntitlement = (key, opts) => {
|
1258
1269
|
const client = useSchematicClient(opts);
|
@@ -1273,7 +1284,7 @@ var useSchematicEntitlement = (key, opts) => {
|
|
1273
1284
|
const check = client.getFlagCheck(key);
|
1274
1285
|
return check ?? fallbackCheck;
|
1275
1286
|
}, [client, key, fallbackCheck]);
|
1276
|
-
return useSyncExternalStore(subscribe, getSnapshot);
|
1287
|
+
return useSyncExternalStore(subscribe, getSnapshot, () => fallbackCheck);
|
1277
1288
|
};
|
1278
1289
|
var useSchematicIsPending = (opts) => {
|
1279
1290
|
const client = useSchematicClient(opts);
|
@@ -1282,7 +1293,7 @@ var useSchematicIsPending = (opts) => {
|
|
1282
1293
|
[client]
|
1283
1294
|
);
|
1284
1295
|
const getSnapshot = useCallback(() => client.getIsPending(), [client]);
|
1285
|
-
return useSyncExternalStore(subscribe, getSnapshot);
|
1296
|
+
return useSyncExternalStore(subscribe, getSnapshot, () => true);
|
1286
1297
|
};
|
1287
1298
|
export {
|
1288
1299
|
RuleType,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@schematichq/schematic-react",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.3",
|
4
4
|
"main": "dist/schematic-react.cjs.js",
|
5
5
|
"module": "dist/schematic-react.esm.js",
|
6
6
|
"types": "dist/schematic-react.d.ts",
|
@@ -17,7 +17,7 @@
|
|
17
17
|
},
|
18
18
|
"scripts": {
|
19
19
|
"dev": "yarn tsc --watch",
|
20
|
-
"build": "yarn tsc && yarn format && yarn lint && yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
|
20
|
+
"build": "./version.sh && yarn tsc && yarn format && yarn lint && yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
|
21
21
|
"build:cjs": "npx esbuild src/index.ts --bundle --external:react --format=cjs --outfile=dist/schematic-react.cjs.js",
|
22
22
|
"build:esm": "npx esbuild src/index.ts --bundle --external:react --format=esm --outfile=dist/schematic-react.esm.js",
|
23
23
|
"build:types": "npx tsc && npx api-extractor run",
|
@@ -28,7 +28,7 @@
|
|
28
28
|
"tsc": "npx tsc"
|
29
29
|
},
|
30
30
|
"dependencies": {
|
31
|
-
"@schematichq/schematic-js": "^1.2.
|
31
|
+
"@schematichq/schematic-js": "^1.2.1"
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
34
34
|
"@microsoft/api-extractor": "^7.49.2",
|