@screeb/sdk-react 0.1.4 → 0.1.6
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.cjs.js +364 -0
- package/dist/{es/index.js → index.es.js} +2 -2
- package/package.json +15 -6
- /package/dist/{es/context.d.ts → context.d.ts} +0 -0
- /package/dist/{es/index.d.ts → index.d.ts} +0 -0
- /package/dist/{es/logger.d.ts → logger.d.ts} +0 -0
- /package/dist/{es/provider.d.ts → provider.d.ts} +0 -0
- /package/dist/{es/types.d.ts → types.d.ts} +0 -0
- /package/dist/{es/useScreeb.d.ts → useScreeb.d.ts} +0 -0
- /package/dist/{es/utils.d.ts → utils.d.ts} +0 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var Screeb = require('@screeb/sdk-browser');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var Screeb__namespace = /*#__PURE__*/_interopNamespaceDefault(Screeb);
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
|
+
|
|
27
|
+
/******************************************************************************
|
|
28
|
+
Copyright (c) Microsoft Corporation.
|
|
29
|
+
|
|
30
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
31
|
+
purpose with or without fee is hereby granted.
|
|
32
|
+
|
|
33
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
34
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
35
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
36
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
37
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
38
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
39
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
40
|
+
***************************************************************************** */
|
|
41
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
function __rest(s, e) {
|
|
45
|
+
var t = {};
|
|
46
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
47
|
+
t[p] = s[p];
|
|
48
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
49
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
50
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
51
|
+
t[p[i]] = s[p[i]];
|
|
52
|
+
}
|
|
53
|
+
return t;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
57
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
58
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
59
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
60
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
61
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
62
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function __generator(thisArg, body) {
|
|
67
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
68
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
69
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
70
|
+
function step(op) {
|
|
71
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
72
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
73
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
74
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
75
|
+
switch (op[0]) {
|
|
76
|
+
case 0: case 1: t = op; break;
|
|
77
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
78
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
79
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
80
|
+
default:
|
|
81
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
82
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
83
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
84
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
85
|
+
if (t[2]) _.ops.pop();
|
|
86
|
+
_.trys.pop(); continue;
|
|
87
|
+
}
|
|
88
|
+
op = body.call(thisArg, _);
|
|
89
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
90
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
95
|
+
var e = new Error(message);
|
|
96
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
var ScreebContext = React__namespace.createContext(undefined);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Logs messages in the console with a corresponding urgency
|
|
103
|
+
*
|
|
104
|
+
* @param level the urgency of the message
|
|
105
|
+
* @param message the message to log in the console
|
|
106
|
+
*/
|
|
107
|
+
var log = function (level, message) {
|
|
108
|
+
var packageName = "[@screeb/react-sdk]";
|
|
109
|
+
switch (level) {
|
|
110
|
+
case "info":
|
|
111
|
+
// eslint-disable-next-line no-console
|
|
112
|
+
console.log("".concat(packageName, " ").concat(message));
|
|
113
|
+
break;
|
|
114
|
+
case "warn":
|
|
115
|
+
// eslint-disable-next-line no-console
|
|
116
|
+
console.warn("".concat(packageName, " ").concat(message));
|
|
117
|
+
break;
|
|
118
|
+
case "error":
|
|
119
|
+
// eslint-disable-next-line no-console
|
|
120
|
+
console.error("".concat(packageName, " ").concat(message));
|
|
121
|
+
break;
|
|
122
|
+
default:
|
|
123
|
+
// eslint-disable-next-line no-console
|
|
124
|
+
console.log("".concat(packageName, " ").concat(message));
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
var isSSR = typeof window === "undefined";
|
|
129
|
+
|
|
130
|
+
var isInitialized = false;
|
|
131
|
+
var ScreebProvider = function (_a) {
|
|
132
|
+
var websiteId = _a.websiteId, userId = _a.userId, userProperties = _a.userProperties, hooks = _a.hooks, children = _a.children, _b = _a.shouldLoad, shouldLoad = _b === void 0 ? !isSSR : _b, _c = _a.autoInit, autoInit = _c === void 0 ? false : _c, options = _a.options, rest = __rest(_a, ["websiteId", "userId", "userProperties", "hooks", "children", "shouldLoad", "autoInit", "options"]);
|
|
133
|
+
var isLoaded = React__namespace.useRef(Screeb__namespace.isLoaded());
|
|
134
|
+
// Allow data-x attributes, see https://github.com/devrnt/react-use-screeb/issues/478
|
|
135
|
+
var invalidPropKeys = Object.keys(rest).filter(function (key) { return !key.startsWith("data-"); });
|
|
136
|
+
if (invalidPropKeys.length > 0) {
|
|
137
|
+
log("warn", [
|
|
138
|
+
"some invalid props were passed to ScreebProvider. ",
|
|
139
|
+
"Please check following props: ".concat(invalidPropKeys.join(", "), "."),
|
|
140
|
+
].join(""));
|
|
141
|
+
}
|
|
142
|
+
var ensureScreeb = React__namespace.useCallback(
|
|
143
|
+
// eslint-disable-next-line no-unused-vars
|
|
144
|
+
function (functionName, callback, onlyLoaded) {
|
|
145
|
+
if (onlyLoaded === void 0) { onlyLoaded = false; }
|
|
146
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
147
|
+
var message, message;
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
if (!Screeb__namespace.isLoaded() && !shouldLoad) {
|
|
150
|
+
message = "Screeb instance is not loaded because `shouldLoad` is set to `false` in `ScreebProvider`";
|
|
151
|
+
log("warn", message);
|
|
152
|
+
return [2 /*return*/, Promise.reject(message)];
|
|
153
|
+
}
|
|
154
|
+
if (!isInitialized && !onlyLoaded) {
|
|
155
|
+
message = [
|
|
156
|
+
"\"".concat(functionName, "\" was called but Screeb has not been initialized yet. "),
|
|
157
|
+
"Please call 'init' before calling '".concat(functionName, "' or "),
|
|
158
|
+
"set 'autoInit' to true in the ScreebProvider.",
|
|
159
|
+
].join("");
|
|
160
|
+
log("warn", message);
|
|
161
|
+
return [2 /*return*/, Promise.reject(message)];
|
|
162
|
+
}
|
|
163
|
+
return [2 /*return*/, Promise.resolve(callback())];
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
}, [shouldLoad]);
|
|
167
|
+
var close = React__namespace.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
168
|
+
return __generator(this, function (_a) {
|
|
169
|
+
switch (_a.label) {
|
|
170
|
+
case 0:
|
|
171
|
+
if (!isLoaded.current) return [3 /*break*/, 2];
|
|
172
|
+
return [4 /*yield*/, Screeb__namespace.close()];
|
|
173
|
+
case 1:
|
|
174
|
+
_a.sent();
|
|
175
|
+
isLoaded.current = false;
|
|
176
|
+
_a.label = 2;
|
|
177
|
+
case 2: return [2 /*return*/];
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}); }, [isLoaded.current]);
|
|
181
|
+
var debug = React__namespace.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
182
|
+
switch (_a.label) {
|
|
183
|
+
case 0: return [4 /*yield*/, ensureScreeb("debug", function () { return Screeb__namespace.debug(); })];
|
|
184
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
185
|
+
}
|
|
186
|
+
}); }); }, []);
|
|
187
|
+
var eventTrack = React__namespace.useCallback(function (eventName, eventProperties) { return __awaiter(void 0, void 0, void 0, function () {
|
|
188
|
+
return __generator(this, function (_a) {
|
|
189
|
+
switch (_a.label) {
|
|
190
|
+
case 0: return [4 /*yield*/, ensureScreeb("eventTrack", function () {
|
|
191
|
+
return Screeb__namespace.eventTrack(eventName, eventProperties);
|
|
192
|
+
})];
|
|
193
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}); }, []);
|
|
197
|
+
var identity = React__namespace.useCallback(function (userId, userProperties) { return __awaiter(void 0, void 0, void 0, function () {
|
|
198
|
+
return __generator(this, function (_a) {
|
|
199
|
+
switch (_a.label) {
|
|
200
|
+
case 0: return [4 /*yield*/, ensureScreeb("identity", function () {
|
|
201
|
+
return Screeb__namespace.identity(userId, userProperties);
|
|
202
|
+
})];
|
|
203
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}); }, []);
|
|
207
|
+
var identityGet = React__namespace.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
208
|
+
switch (_a.label) {
|
|
209
|
+
case 0: return [4 /*yield*/, ensureScreeb("identityGet", function () { return Screeb__namespace.identityGet(); })];
|
|
210
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
211
|
+
}
|
|
212
|
+
}); }); }, []);
|
|
213
|
+
var identityGroupAssign = React__namespace.useCallback(function (groupName, groupType, groupProperties) { return __awaiter(void 0, void 0, void 0, function () {
|
|
214
|
+
return __generator(this, function (_a) {
|
|
215
|
+
switch (_a.label) {
|
|
216
|
+
case 0: return [4 /*yield*/, ensureScreeb("identityGroupAssign", function () {
|
|
217
|
+
return Screeb__namespace.identityGroupAssign(groupName, groupType, groupProperties);
|
|
218
|
+
})];
|
|
219
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}); }, []);
|
|
223
|
+
var identityGroupUnassign = React__namespace.useCallback(function (groupName, groupType) { return __awaiter(void 0, void 0, void 0, function () {
|
|
224
|
+
return __generator(this, function (_a) {
|
|
225
|
+
switch (_a.label) {
|
|
226
|
+
case 0: return [4 /*yield*/, ensureScreeb("identityGroupUnassign", function () {
|
|
227
|
+
return Screeb__namespace.identityGroupUnassign(groupName, groupType);
|
|
228
|
+
})];
|
|
229
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}); }, []);
|
|
233
|
+
var identityProperties = React__namespace.useCallback(function (userProperties) { return __awaiter(void 0, void 0, void 0, function () {
|
|
234
|
+
return __generator(this, function (_a) {
|
|
235
|
+
switch (_a.label) {
|
|
236
|
+
case 0: return [4 /*yield*/, ensureScreeb("identityProperties", function () {
|
|
237
|
+
return Screeb__namespace.identityProperties(userProperties);
|
|
238
|
+
})];
|
|
239
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}); }, []);
|
|
243
|
+
var identityReset = React__namespace.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
244
|
+
switch (_a.label) {
|
|
245
|
+
case 0: return [4 /*yield*/, ensureScreeb("identityReset", function () { return Screeb__namespace.identityReset(); })];
|
|
246
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
247
|
+
}
|
|
248
|
+
}); }); }, []);
|
|
249
|
+
var init = React__namespace.useCallback(function (websiteId, userId, userProperties, hooks) { return __awaiter(void 0, void 0, void 0, function () {
|
|
250
|
+
return __generator(this, function (_a) {
|
|
251
|
+
switch (_a.label) {
|
|
252
|
+
case 0: return [4 /*yield*/, ensureScreeb("init", function () {
|
|
253
|
+
if (!isInitialized) {
|
|
254
|
+
Screeb__namespace.init(websiteId, userId, userProperties, hooks);
|
|
255
|
+
isInitialized = true;
|
|
256
|
+
}
|
|
257
|
+
}, true)];
|
|
258
|
+
case 1:
|
|
259
|
+
_a.sent();
|
|
260
|
+
return [2 /*return*/];
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}); }, [ensureScreeb, websiteId, shouldLoad]);
|
|
264
|
+
var load = React__namespace.useCallback(function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
265
|
+
return __generator(this, function (_a) {
|
|
266
|
+
switch (_a.label) {
|
|
267
|
+
case 0:
|
|
268
|
+
if (!!isLoaded.current) return [3 /*break*/, 3];
|
|
269
|
+
Screeb__namespace.load(options);
|
|
270
|
+
isLoaded.current = true;
|
|
271
|
+
if (!autoInit) return [3 /*break*/, 3];
|
|
272
|
+
if (!websiteId) return [3 /*break*/, 2];
|
|
273
|
+
return [4 /*yield*/, init(websiteId, userId, userProperties, hooks)];
|
|
274
|
+
case 1:
|
|
275
|
+
_a.sent();
|
|
276
|
+
return [3 /*break*/, 3];
|
|
277
|
+
case 2:
|
|
278
|
+
log("warn", "autoInit is set to true, but no websiteId have been provided.");
|
|
279
|
+
_a.label = 3;
|
|
280
|
+
case 3: return [2 /*return*/];
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}); }, [isLoaded.current, autoInit]);
|
|
284
|
+
var surveyClose = React__namespace.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
285
|
+
switch (_a.label) {
|
|
286
|
+
case 0: return [4 /*yield*/, ensureScreeb("surveyClose", function () { return Screeb__namespace.surveyClose(); })];
|
|
287
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
288
|
+
}
|
|
289
|
+
}); }); }, []);
|
|
290
|
+
var surveyStart = React__namespace.useCallback(function (surveyId, allowMultipleResponses, hiddenFields, hooks) { return __awaiter(void 0, void 0, void 0, function () {
|
|
291
|
+
return __generator(this, function (_a) {
|
|
292
|
+
switch (_a.label) {
|
|
293
|
+
case 0: return [4 /*yield*/, ensureScreeb("surveyStart", function () {
|
|
294
|
+
return Screeb__namespace.surveyStart(surveyId, allowMultipleResponses, hiddenFields, hooks);
|
|
295
|
+
})];
|
|
296
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}); }, []);
|
|
300
|
+
var targetingCheck = React__namespace.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
301
|
+
switch (_a.label) {
|
|
302
|
+
case 0: return [4 /*yield*/, ensureScreeb("targetingCheck", function () { return Screeb__namespace.targetingCheck(); })];
|
|
303
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
304
|
+
}
|
|
305
|
+
}); }); }, []);
|
|
306
|
+
var targetingDebug = React__namespace.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
307
|
+
switch (_a.label) {
|
|
308
|
+
case 0: return [4 /*yield*/, ensureScreeb("targetingDebug", function () { return Screeb__namespace.targetingDebug(); })];
|
|
309
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
310
|
+
}
|
|
311
|
+
}); }); }, []);
|
|
312
|
+
var providerValue = React__namespace.useMemo(function () { return ({
|
|
313
|
+
close: close,
|
|
314
|
+
debug: debug,
|
|
315
|
+
eventTrack: eventTrack,
|
|
316
|
+
identity: identity,
|
|
317
|
+
identityGet: identityGet,
|
|
318
|
+
identityGroupAssign: identityGroupAssign,
|
|
319
|
+
identityGroupUnassign: identityGroupUnassign,
|
|
320
|
+
identityProperties: identityProperties,
|
|
321
|
+
identityReset: identityReset,
|
|
322
|
+
init: init,
|
|
323
|
+
load: load,
|
|
324
|
+
surveyClose: surveyClose,
|
|
325
|
+
surveyStart: surveyStart,
|
|
326
|
+
targetingCheck: targetingCheck,
|
|
327
|
+
targetingDebug: targetingDebug,
|
|
328
|
+
}); }, [
|
|
329
|
+
close,
|
|
330
|
+
debug,
|
|
331
|
+
eventTrack,
|
|
332
|
+
identity,
|
|
333
|
+
identityGet,
|
|
334
|
+
identityGroupAssign,
|
|
335
|
+
identityGroupUnassign,
|
|
336
|
+
identityProperties,
|
|
337
|
+
identityReset,
|
|
338
|
+
init,
|
|
339
|
+
load,
|
|
340
|
+
surveyClose,
|
|
341
|
+
surveyStart,
|
|
342
|
+
targetingCheck,
|
|
343
|
+
targetingDebug,
|
|
344
|
+
]);
|
|
345
|
+
if (!isSSR && shouldLoad) {
|
|
346
|
+
load(options);
|
|
347
|
+
}
|
|
348
|
+
return (jsxRuntime.jsx(ScreebContext.Provider, { value: providerValue, children: children }));
|
|
349
|
+
};
|
|
350
|
+
var useScreebContext = function () {
|
|
351
|
+
var context = React__namespace.useContext(ScreebContext);
|
|
352
|
+
if (context === undefined) {
|
|
353
|
+
// eslint-disable-next-line no-console
|
|
354
|
+
console.warn("`useScreeb` must be used within `ScreebProvider`.");
|
|
355
|
+
}
|
|
356
|
+
return context;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
var useScreeb = function () {
|
|
360
|
+
return useScreebContext();
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
exports.ScreebProvider = ScreebProvider;
|
|
364
|
+
exports.useScreeb = useScreeb;
|
|
@@ -328,8 +328,8 @@ var ScreebProvider = function (_a) {
|
|
|
328
328
|
var useScreebContext = function () {
|
|
329
329
|
var context = React.useContext(ScreebContext);
|
|
330
330
|
if (context === undefined) {
|
|
331
|
-
// eslint-disable-next-line
|
|
332
|
-
|
|
331
|
+
// eslint-disable-next-line no-console
|
|
332
|
+
console.warn("`useScreeb` must be used within `ScreebProvider`.");
|
|
333
333
|
}
|
|
334
334
|
return context;
|
|
335
335
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@screeb/sdk-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Screeb's browser sdk, optimized for React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"product discovery",
|
|
@@ -28,11 +28,20 @@
|
|
|
28
28
|
"exports": {
|
|
29
29
|
"./package.json": "./package.json",
|
|
30
30
|
".": {
|
|
31
|
-
"import":
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.es.js"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"default": "./dist/index.cjs.js"
|
|
38
|
+
}
|
|
32
39
|
}
|
|
33
40
|
},
|
|
34
|
-
"module": "dist/
|
|
35
|
-
"
|
|
41
|
+
"module": "dist/index.es.js",
|
|
42
|
+
"main": "dist/index.cjs.js",
|
|
43
|
+
"jsnext:main": "dist/index.es.js",
|
|
44
|
+
"types": "dist/index.d.ts",
|
|
36
45
|
"files": [
|
|
37
46
|
"dist",
|
|
38
47
|
"docs",
|
|
@@ -46,12 +55,12 @@
|
|
|
46
55
|
"test": "echo '@TODO'"
|
|
47
56
|
},
|
|
48
57
|
"dependencies": {
|
|
49
|
-
"@screeb/sdk-browser": "^0.1.
|
|
58
|
+
"@screeb/sdk-browser": "^0.1.12"
|
|
50
59
|
},
|
|
51
60
|
"devDependencies": {
|
|
52
61
|
"@screeb/eslint-config": "^0.1.6",
|
|
53
62
|
"@screeb/sdk-browser": "^0.1.6",
|
|
54
|
-
"@screeb/typescript-config": "^0.1.
|
|
63
|
+
"@screeb/typescript-config": "^0.1.7",
|
|
55
64
|
"@types/jest": "^29.5.5",
|
|
56
65
|
"@types/node": "^20.8.4",
|
|
57
66
|
"@types/react": "^18.2.28",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|