humanbehavior-js 0.1.8 → 0.2.0
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/.tsbuildinfo +1 -0
- package/dist/cjs/index.js +145 -71
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react/index.js +492 -26
- package/dist/cjs/react/index.js.map +1 -1
- package/dist/esm/index.js +145 -72
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react/index.js +474 -10
- package/dist/esm/react/index.js.map +1 -1
- package/dist/index.min.js +1 -15
- package/dist/index.min.js.map +1 -1
- package/dist/types/index.d.ts +23 -8
- package/dist/types/react/index.d.ts +18 -3
- package/package.json +33 -10
- package/readme.md +2 -0
- package/src/api.ts +75 -16
- package/src/index.ts +2 -2
- package/src/react/index.tsx +49 -4
- package/src/tracker.ts +81 -51
- package/rollup.config.js +0 -106
- package/simple-demo.html +0 -26
- package/simple-spa.html +0 -594
- package/tsconfig.json +0 -24
package/dist/cjs/react/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var require$$0 = require('react');
|
|
4
4
|
var src = require('..');
|
|
5
5
|
|
|
6
6
|
/******************************************************************************
|
|
@@ -35,6 +35,433 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
35
35
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
var jsxRuntime = {exports: {}};
|
|
39
|
+
|
|
40
|
+
var reactJsxRuntime_production = {};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @license React
|
|
44
|
+
* react-jsx-runtime.production.js
|
|
45
|
+
*
|
|
46
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
47
|
+
*
|
|
48
|
+
* This source code is licensed under the MIT license found in the
|
|
49
|
+
* LICENSE file in the root directory of this source tree.
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
var hasRequiredReactJsxRuntime_production;
|
|
53
|
+
|
|
54
|
+
function requireReactJsxRuntime_production () {
|
|
55
|
+
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
|
|
56
|
+
hasRequiredReactJsxRuntime_production = 1;
|
|
57
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
58
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
59
|
+
function jsxProd(type, config, maybeKey) {
|
|
60
|
+
var key = null;
|
|
61
|
+
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
62
|
+
void 0 !== config.key && (key = "" + config.key);
|
|
63
|
+
if ("key" in config) {
|
|
64
|
+
maybeKey = {};
|
|
65
|
+
for (var propName in config)
|
|
66
|
+
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
67
|
+
} else maybeKey = config;
|
|
68
|
+
config = maybeKey.ref;
|
|
69
|
+
return {
|
|
70
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
71
|
+
type: type,
|
|
72
|
+
key: key,
|
|
73
|
+
ref: void 0 !== config ? config : null,
|
|
74
|
+
props: maybeKey
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
78
|
+
reactJsxRuntime_production.jsx = jsxProd;
|
|
79
|
+
reactJsxRuntime_production.jsxs = jsxProd;
|
|
80
|
+
return reactJsxRuntime_production;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
var reactJsxRuntime_development = {};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @license React
|
|
87
|
+
* react-jsx-runtime.development.js
|
|
88
|
+
*
|
|
89
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
90
|
+
*
|
|
91
|
+
* This source code is licensed under the MIT license found in the
|
|
92
|
+
* LICENSE file in the root directory of this source tree.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
var hasRequiredReactJsxRuntime_development;
|
|
96
|
+
|
|
97
|
+
function requireReactJsxRuntime_development () {
|
|
98
|
+
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
99
|
+
hasRequiredReactJsxRuntime_development = 1;
|
|
100
|
+
"production" !== process.env.NODE_ENV &&
|
|
101
|
+
(function () {
|
|
102
|
+
function getComponentNameFromType(type) {
|
|
103
|
+
if (null == type) return null;
|
|
104
|
+
if ("function" === typeof type)
|
|
105
|
+
return type.$$typeof === REACT_CLIENT_REFERENCE
|
|
106
|
+
? null
|
|
107
|
+
: type.displayName || type.name || null;
|
|
108
|
+
if ("string" === typeof type) return type;
|
|
109
|
+
switch (type) {
|
|
110
|
+
case REACT_FRAGMENT_TYPE:
|
|
111
|
+
return "Fragment";
|
|
112
|
+
case REACT_PROFILER_TYPE:
|
|
113
|
+
return "Profiler";
|
|
114
|
+
case REACT_STRICT_MODE_TYPE:
|
|
115
|
+
return "StrictMode";
|
|
116
|
+
case REACT_SUSPENSE_TYPE:
|
|
117
|
+
return "Suspense";
|
|
118
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
119
|
+
return "SuspenseList";
|
|
120
|
+
case REACT_ACTIVITY_TYPE:
|
|
121
|
+
return "Activity";
|
|
122
|
+
}
|
|
123
|
+
if ("object" === typeof type)
|
|
124
|
+
switch (
|
|
125
|
+
("number" === typeof type.tag &&
|
|
126
|
+
console.error(
|
|
127
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
128
|
+
),
|
|
129
|
+
type.$$typeof)
|
|
130
|
+
) {
|
|
131
|
+
case REACT_PORTAL_TYPE:
|
|
132
|
+
return "Portal";
|
|
133
|
+
case REACT_CONTEXT_TYPE:
|
|
134
|
+
return (type.displayName || "Context") + ".Provider";
|
|
135
|
+
case REACT_CONSUMER_TYPE:
|
|
136
|
+
return (type._context.displayName || "Context") + ".Consumer";
|
|
137
|
+
case REACT_FORWARD_REF_TYPE:
|
|
138
|
+
var innerType = type.render;
|
|
139
|
+
type = type.displayName;
|
|
140
|
+
type ||
|
|
141
|
+
((type = innerType.displayName || innerType.name || ""),
|
|
142
|
+
(type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
|
|
143
|
+
return type;
|
|
144
|
+
case REACT_MEMO_TYPE:
|
|
145
|
+
return (
|
|
146
|
+
(innerType = type.displayName || null),
|
|
147
|
+
null !== innerType
|
|
148
|
+
? innerType
|
|
149
|
+
: getComponentNameFromType(type.type) || "Memo"
|
|
150
|
+
);
|
|
151
|
+
case REACT_LAZY_TYPE:
|
|
152
|
+
innerType = type._payload;
|
|
153
|
+
type = type._init;
|
|
154
|
+
try {
|
|
155
|
+
return getComponentNameFromType(type(innerType));
|
|
156
|
+
} catch (x) {}
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
function testStringCoercion(value) {
|
|
161
|
+
return "" + value;
|
|
162
|
+
}
|
|
163
|
+
function checkKeyStringCoercion(value) {
|
|
164
|
+
try {
|
|
165
|
+
testStringCoercion(value);
|
|
166
|
+
var JSCompiler_inline_result = !1;
|
|
167
|
+
} catch (e) {
|
|
168
|
+
JSCompiler_inline_result = true;
|
|
169
|
+
}
|
|
170
|
+
if (JSCompiler_inline_result) {
|
|
171
|
+
JSCompiler_inline_result = console;
|
|
172
|
+
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
173
|
+
var JSCompiler_inline_result$jscomp$0 =
|
|
174
|
+
("function" === typeof Symbol &&
|
|
175
|
+
Symbol.toStringTag &&
|
|
176
|
+
value[Symbol.toStringTag]) ||
|
|
177
|
+
value.constructor.name ||
|
|
178
|
+
"Object";
|
|
179
|
+
JSCompiler_temp_const.call(
|
|
180
|
+
JSCompiler_inline_result,
|
|
181
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
182
|
+
JSCompiler_inline_result$jscomp$0
|
|
183
|
+
);
|
|
184
|
+
return testStringCoercion(value);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
function getTaskName(type) {
|
|
188
|
+
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
189
|
+
if (
|
|
190
|
+
"object" === typeof type &&
|
|
191
|
+
null !== type &&
|
|
192
|
+
type.$$typeof === REACT_LAZY_TYPE
|
|
193
|
+
)
|
|
194
|
+
return "<...>";
|
|
195
|
+
try {
|
|
196
|
+
var name = getComponentNameFromType(type);
|
|
197
|
+
return name ? "<" + name + ">" : "<...>";
|
|
198
|
+
} catch (x) {
|
|
199
|
+
return "<...>";
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function getOwner() {
|
|
203
|
+
var dispatcher = ReactSharedInternals.A;
|
|
204
|
+
return null === dispatcher ? null : dispatcher.getOwner();
|
|
205
|
+
}
|
|
206
|
+
function UnknownOwner() {
|
|
207
|
+
return Error("react-stack-top-frame");
|
|
208
|
+
}
|
|
209
|
+
function hasValidKey(config) {
|
|
210
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
211
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
212
|
+
if (getter && getter.isReactWarning) return false;
|
|
213
|
+
}
|
|
214
|
+
return void 0 !== config.key;
|
|
215
|
+
}
|
|
216
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
217
|
+
function warnAboutAccessingKey() {
|
|
218
|
+
specialPropKeyWarningShown ||
|
|
219
|
+
((specialPropKeyWarningShown = true),
|
|
220
|
+
console.error(
|
|
221
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
222
|
+
displayName
|
|
223
|
+
));
|
|
224
|
+
}
|
|
225
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
226
|
+
Object.defineProperty(props, "key", {
|
|
227
|
+
get: warnAboutAccessingKey,
|
|
228
|
+
configurable: true
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function elementRefGetterWithDeprecationWarning() {
|
|
232
|
+
var componentName = getComponentNameFromType(this.type);
|
|
233
|
+
didWarnAboutElementRef[componentName] ||
|
|
234
|
+
((didWarnAboutElementRef[componentName] = true),
|
|
235
|
+
console.error(
|
|
236
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
237
|
+
));
|
|
238
|
+
componentName = this.props.ref;
|
|
239
|
+
return void 0 !== componentName ? componentName : null;
|
|
240
|
+
}
|
|
241
|
+
function ReactElement(
|
|
242
|
+
type,
|
|
243
|
+
key,
|
|
244
|
+
self,
|
|
245
|
+
source,
|
|
246
|
+
owner,
|
|
247
|
+
props,
|
|
248
|
+
debugStack,
|
|
249
|
+
debugTask
|
|
250
|
+
) {
|
|
251
|
+
self = props.ref;
|
|
252
|
+
type = {
|
|
253
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
254
|
+
type: type,
|
|
255
|
+
key: key,
|
|
256
|
+
props: props,
|
|
257
|
+
_owner: owner
|
|
258
|
+
};
|
|
259
|
+
null !== (void 0 !== self ? self : null)
|
|
260
|
+
? Object.defineProperty(type, "ref", {
|
|
261
|
+
enumerable: false,
|
|
262
|
+
get: elementRefGetterWithDeprecationWarning
|
|
263
|
+
})
|
|
264
|
+
: Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
265
|
+
type._store = {};
|
|
266
|
+
Object.defineProperty(type._store, "validated", {
|
|
267
|
+
configurable: false,
|
|
268
|
+
enumerable: false,
|
|
269
|
+
writable: true,
|
|
270
|
+
value: 0
|
|
271
|
+
});
|
|
272
|
+
Object.defineProperty(type, "_debugInfo", {
|
|
273
|
+
configurable: false,
|
|
274
|
+
enumerable: false,
|
|
275
|
+
writable: true,
|
|
276
|
+
value: null
|
|
277
|
+
});
|
|
278
|
+
Object.defineProperty(type, "_debugStack", {
|
|
279
|
+
configurable: false,
|
|
280
|
+
enumerable: false,
|
|
281
|
+
writable: true,
|
|
282
|
+
value: debugStack
|
|
283
|
+
});
|
|
284
|
+
Object.defineProperty(type, "_debugTask", {
|
|
285
|
+
configurable: false,
|
|
286
|
+
enumerable: false,
|
|
287
|
+
writable: true,
|
|
288
|
+
value: debugTask
|
|
289
|
+
});
|
|
290
|
+
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
291
|
+
return type;
|
|
292
|
+
}
|
|
293
|
+
function jsxDEVImpl(
|
|
294
|
+
type,
|
|
295
|
+
config,
|
|
296
|
+
maybeKey,
|
|
297
|
+
isStaticChildren,
|
|
298
|
+
source,
|
|
299
|
+
self,
|
|
300
|
+
debugStack,
|
|
301
|
+
debugTask
|
|
302
|
+
) {
|
|
303
|
+
var children = config.children;
|
|
304
|
+
if (void 0 !== children)
|
|
305
|
+
if (isStaticChildren)
|
|
306
|
+
if (isArrayImpl(children)) {
|
|
307
|
+
for (
|
|
308
|
+
isStaticChildren = 0;
|
|
309
|
+
isStaticChildren < children.length;
|
|
310
|
+
isStaticChildren++
|
|
311
|
+
)
|
|
312
|
+
validateChildKeys(children[isStaticChildren]);
|
|
313
|
+
Object.freeze && Object.freeze(children);
|
|
314
|
+
} else
|
|
315
|
+
console.error(
|
|
316
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
317
|
+
);
|
|
318
|
+
else validateChildKeys(children);
|
|
319
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
320
|
+
children = getComponentNameFromType(type);
|
|
321
|
+
var keys = Object.keys(config).filter(function (k) {
|
|
322
|
+
return "key" !== k;
|
|
323
|
+
});
|
|
324
|
+
isStaticChildren =
|
|
325
|
+
0 < keys.length
|
|
326
|
+
? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
|
|
327
|
+
: "{key: someKey}";
|
|
328
|
+
didWarnAboutKeySpread[children + isStaticChildren] ||
|
|
329
|
+
((keys =
|
|
330
|
+
0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
|
|
331
|
+
console.error(
|
|
332
|
+
'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
|
|
333
|
+
isStaticChildren,
|
|
334
|
+
children,
|
|
335
|
+
keys,
|
|
336
|
+
children
|
|
337
|
+
),
|
|
338
|
+
(didWarnAboutKeySpread[children + isStaticChildren] = true));
|
|
339
|
+
}
|
|
340
|
+
children = null;
|
|
341
|
+
void 0 !== maybeKey &&
|
|
342
|
+
(checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
|
|
343
|
+
hasValidKey(config) &&
|
|
344
|
+
(checkKeyStringCoercion(config.key), (children = "" + config.key));
|
|
345
|
+
if ("key" in config) {
|
|
346
|
+
maybeKey = {};
|
|
347
|
+
for (var propName in config)
|
|
348
|
+
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
349
|
+
} else maybeKey = config;
|
|
350
|
+
children &&
|
|
351
|
+
defineKeyPropWarningGetter(
|
|
352
|
+
maybeKey,
|
|
353
|
+
"function" === typeof type
|
|
354
|
+
? type.displayName || type.name || "Unknown"
|
|
355
|
+
: type
|
|
356
|
+
);
|
|
357
|
+
return ReactElement(
|
|
358
|
+
type,
|
|
359
|
+
children,
|
|
360
|
+
self,
|
|
361
|
+
source,
|
|
362
|
+
getOwner(),
|
|
363
|
+
maybeKey,
|
|
364
|
+
debugStack,
|
|
365
|
+
debugTask
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
function validateChildKeys(node) {
|
|
369
|
+
"object" === typeof node &&
|
|
370
|
+
null !== node &&
|
|
371
|
+
node.$$typeof === REACT_ELEMENT_TYPE &&
|
|
372
|
+
node._store &&
|
|
373
|
+
(node._store.validated = 1);
|
|
374
|
+
}
|
|
375
|
+
var React = require$$0,
|
|
376
|
+
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
377
|
+
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
378
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
379
|
+
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
380
|
+
REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
381
|
+
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
382
|
+
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
383
|
+
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
384
|
+
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
385
|
+
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
|
|
386
|
+
REACT_MEMO_TYPE = Symbol.for("react.memo"),
|
|
387
|
+
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
|
388
|
+
REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
|
|
389
|
+
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
|
|
390
|
+
ReactSharedInternals =
|
|
391
|
+
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
392
|
+
hasOwnProperty = Object.prototype.hasOwnProperty,
|
|
393
|
+
isArrayImpl = Array.isArray,
|
|
394
|
+
createTask = console.createTask
|
|
395
|
+
? console.createTask
|
|
396
|
+
: function () {
|
|
397
|
+
return null;
|
|
398
|
+
};
|
|
399
|
+
React = {
|
|
400
|
+
"react-stack-bottom-frame": function (callStackForError) {
|
|
401
|
+
return callStackForError();
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
var specialPropKeyWarningShown;
|
|
405
|
+
var didWarnAboutElementRef = {};
|
|
406
|
+
var unknownOwnerDebugStack = React["react-stack-bottom-frame"].bind(
|
|
407
|
+
React,
|
|
408
|
+
UnknownOwner
|
|
409
|
+
)();
|
|
410
|
+
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
411
|
+
var didWarnAboutKeySpread = {};
|
|
412
|
+
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
413
|
+
reactJsxRuntime_development.jsx = function (type, config, maybeKey, source, self) {
|
|
414
|
+
var trackActualOwner =
|
|
415
|
+
1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
416
|
+
return jsxDEVImpl(
|
|
417
|
+
type,
|
|
418
|
+
config,
|
|
419
|
+
maybeKey,
|
|
420
|
+
false,
|
|
421
|
+
source,
|
|
422
|
+
self,
|
|
423
|
+
trackActualOwner
|
|
424
|
+
? Error("react-stack-top-frame")
|
|
425
|
+
: unknownOwnerDebugStack,
|
|
426
|
+
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
427
|
+
);
|
|
428
|
+
};
|
|
429
|
+
reactJsxRuntime_development.jsxs = function (type, config, maybeKey, source, self) {
|
|
430
|
+
var trackActualOwner =
|
|
431
|
+
1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
432
|
+
return jsxDEVImpl(
|
|
433
|
+
type,
|
|
434
|
+
config,
|
|
435
|
+
maybeKey,
|
|
436
|
+
true,
|
|
437
|
+
source,
|
|
438
|
+
self,
|
|
439
|
+
trackActualOwner
|
|
440
|
+
? Error("react-stack-top-frame")
|
|
441
|
+
: unknownOwnerDebugStack,
|
|
442
|
+
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
443
|
+
);
|
|
444
|
+
};
|
|
445
|
+
})();
|
|
446
|
+
return reactJsxRuntime_development;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
var hasRequiredJsxRuntime;
|
|
450
|
+
|
|
451
|
+
function requireJsxRuntime () {
|
|
452
|
+
if (hasRequiredJsxRuntime) return jsxRuntime.exports;
|
|
453
|
+
hasRequiredJsxRuntime = 1;
|
|
454
|
+
|
|
455
|
+
if (process.env.NODE_ENV === 'production') {
|
|
456
|
+
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
457
|
+
} else {
|
|
458
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
459
|
+
}
|
|
460
|
+
return jsxRuntime.exports;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
var jsxRuntimeExports = requireJsxRuntime();
|
|
464
|
+
|
|
38
465
|
var LogLevel;
|
|
39
466
|
(function (LogLevel) {
|
|
40
467
|
LogLevel[LogLevel["NONE"] = 0] = "NONE";
|
|
@@ -152,34 +579,34 @@ const logDebug = (message, ...args) => logger.debug(message, ...args);
|
|
|
152
579
|
|
|
153
580
|
// Check if we're in a browser environment
|
|
154
581
|
const isBrowser = () => typeof window !== 'undefined';
|
|
155
|
-
const HumanBehaviorContext =
|
|
582
|
+
const HumanBehaviorContext = require$$0.createContext(null);
|
|
156
583
|
const HumanBehaviorProvider = ({ apiKey, client, children, options }) => {
|
|
157
|
-
const [humanBehavior, setHumanBehavior] =
|
|
158
|
-
const [eventQueue, setEventQueue] =
|
|
159
|
-
const [isMounted, setIsMounted] =
|
|
160
|
-
const [isInitialized, setIsInitialized] =
|
|
584
|
+
const [humanBehavior, setHumanBehavior] = require$$0.useState(client || null);
|
|
585
|
+
const [eventQueue, setEventQueue] = require$$0.useState([]);
|
|
586
|
+
const [isMounted, setIsMounted] = require$$0.useState(false);
|
|
587
|
+
const [isInitialized, setIsInitialized] = require$$0.useState(false);
|
|
161
588
|
// Use refs to avoid dependency issues in useEffect
|
|
162
|
-
const apiKeyRef =
|
|
163
|
-
const clientRef =
|
|
164
|
-
const eventQueueRef =
|
|
589
|
+
const apiKeyRef = require$$0.useRef(apiKey);
|
|
590
|
+
const clientRef = require$$0.useRef(client);
|
|
591
|
+
const eventQueueRef = require$$0.useRef(eventQueue);
|
|
165
592
|
// Update refs when props change
|
|
166
|
-
|
|
593
|
+
require$$0.useEffect(() => {
|
|
167
594
|
apiKeyRef.current = apiKey;
|
|
168
595
|
clientRef.current = client;
|
|
169
596
|
}, [apiKey, client]);
|
|
170
597
|
// Update eventQueue ref when queue changes
|
|
171
|
-
|
|
598
|
+
require$$0.useEffect(() => {
|
|
172
599
|
eventQueueRef.current = eventQueue;
|
|
173
600
|
}, [eventQueue]);
|
|
174
601
|
// Memoized queueEvent function to prevent unnecessary re-renders
|
|
175
|
-
|
|
602
|
+
require$$0.useCallback((event) => {
|
|
176
603
|
setEventQueue(prev => [...prev, event]);
|
|
177
604
|
}, []);
|
|
178
605
|
// Handle mounting state
|
|
179
|
-
|
|
606
|
+
require$$0.useEffect(() => {
|
|
180
607
|
setIsMounted(true);
|
|
181
608
|
}, []);
|
|
182
|
-
|
|
609
|
+
require$$0.useEffect(() => {
|
|
183
610
|
var _a;
|
|
184
611
|
// Only run in browser
|
|
185
612
|
if (!(isBrowser())) {
|
|
@@ -208,21 +635,25 @@ const HumanBehaviorProvider = ({ apiKey, client, children, options }) => {
|
|
|
208
635
|
setHumanBehavior(tracker);
|
|
209
636
|
// Wait for initialization to complete
|
|
210
637
|
(_a = tracker.initializationPromise) === null || _a === void 0 ? void 0 : _a.then(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
211
|
-
// Start the tracker to enable event flushing and recording
|
|
212
638
|
yield tracker.start();
|
|
213
639
|
setIsInitialized(true);
|
|
214
640
|
// Process any queued events
|
|
215
641
|
const currentQueue = eventQueueRef.current;
|
|
216
642
|
if (currentQueue.length > 0) {
|
|
217
|
-
|
|
643
|
+
for (const event of currentQueue) {
|
|
218
644
|
if (event.type === 'identify') {
|
|
219
645
|
logDebug('Processing queued identify event', event.userProperties);
|
|
220
|
-
|
|
646
|
+
try {
|
|
647
|
+
yield tracker.addUserInfo(event.userProperties);
|
|
648
|
+
}
|
|
649
|
+
catch (error) {
|
|
650
|
+
logError('Failed to process queued user info:', error);
|
|
651
|
+
}
|
|
221
652
|
}
|
|
222
653
|
else {
|
|
223
654
|
tracker.addEvent(event);
|
|
224
655
|
}
|
|
225
|
-
}
|
|
656
|
+
}
|
|
226
657
|
setEventQueue([]); // Clear the queue
|
|
227
658
|
}
|
|
228
659
|
})).catch(error => {
|
|
@@ -230,7 +661,7 @@ const HumanBehaviorProvider = ({ apiKey, client, children, options }) => {
|
|
|
230
661
|
});
|
|
231
662
|
}, [isMounted, humanBehavior]); // Removed apiKey, client, eventQueue from dependencies
|
|
232
663
|
// Memoized context value to prevent unnecessary re-renders
|
|
233
|
-
const contextValue =
|
|
664
|
+
const contextValue = require$$0.useMemo(() => {
|
|
234
665
|
if (!isMounted) {
|
|
235
666
|
return null;
|
|
236
667
|
}
|
|
@@ -241,23 +672,56 @@ const HumanBehaviorProvider = ({ apiKey, client, children, options }) => {
|
|
|
241
672
|
}, [isMounted, isInitialized, humanBehavior]);
|
|
242
673
|
// If not in browser, render children without context
|
|
243
674
|
if (!(isBrowser())) {
|
|
244
|
-
return
|
|
675
|
+
return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: children });
|
|
245
676
|
}
|
|
246
|
-
return (
|
|
247
|
-
React.createElement(HumanBehaviorPageView, null),
|
|
248
|
-
children));
|
|
677
|
+
return (jsxRuntimeExports.jsxs(HumanBehaviorContext.Provider, { value: contextValue, children: [jsxRuntimeExports.jsx(HumanBehaviorPageView, {}), children] }));
|
|
249
678
|
};
|
|
250
679
|
const useHumanBehavior = () => {
|
|
251
|
-
const tracker =
|
|
680
|
+
const tracker = require$$0.useContext(HumanBehaviorContext);
|
|
252
681
|
if (!tracker) {
|
|
253
682
|
throw new Error('useHumanBehavior must be used within a HumanBehaviorProvider');
|
|
254
683
|
}
|
|
255
684
|
return tracker;
|
|
256
685
|
};
|
|
686
|
+
// Custom hook for managing redaction fields dynamically
|
|
687
|
+
const useRedaction = () => {
|
|
688
|
+
const tracker = useHumanBehavior();
|
|
689
|
+
const setRedactedFields = require$$0.useCallback((fields) => {
|
|
690
|
+
tracker.setRedactedFields(fields);
|
|
691
|
+
}, [tracker]);
|
|
692
|
+
const isRedactionActive = require$$0.useCallback(() => {
|
|
693
|
+
return tracker.isRedactionActive();
|
|
694
|
+
}, [tracker]);
|
|
695
|
+
const getRedactedFields = require$$0.useCallback(() => {
|
|
696
|
+
return tracker.getRedactedFields();
|
|
697
|
+
}, [tracker]);
|
|
698
|
+
return {
|
|
699
|
+
setRedactedFields,
|
|
700
|
+
isRedactionActive,
|
|
701
|
+
getRedactedFields
|
|
702
|
+
};
|
|
703
|
+
};
|
|
704
|
+
// Custom hook for managing user info
|
|
705
|
+
const useUserTracking = () => {
|
|
706
|
+
const tracker = useHumanBehavior();
|
|
707
|
+
const addUserInfo = require$$0.useCallback((userId, userProperties) => __awaiter(void 0, void 0, void 0, function* () {
|
|
708
|
+
try {
|
|
709
|
+
yield tracker.addUserInfo({ userId, userProperties });
|
|
710
|
+
return { success: true };
|
|
711
|
+
}
|
|
712
|
+
catch (error) {
|
|
713
|
+
logError('Failed to add user info:', error);
|
|
714
|
+
return { success: false, error };
|
|
715
|
+
}
|
|
716
|
+
}), [tracker]);
|
|
717
|
+
return {
|
|
718
|
+
addUserInfo
|
|
719
|
+
};
|
|
720
|
+
};
|
|
257
721
|
// Automatic page tracking component (similar to PostHog's PostHogPageView)
|
|
258
722
|
function HumanBehaviorPageView() {
|
|
259
|
-
const tracker =
|
|
260
|
-
|
|
723
|
+
const tracker = require$$0.useContext(HumanBehaviorContext);
|
|
724
|
+
require$$0.useEffect(() => {
|
|
261
725
|
if (tracker && typeof window !== 'undefined') {
|
|
262
726
|
// Track initial page load
|
|
263
727
|
tracker.trackPageView();
|
|
@@ -294,4 +758,6 @@ Object.defineProperty(exports, "HumanBehaviorTracker", {
|
|
|
294
758
|
});
|
|
295
759
|
exports.HumanBehaviorProvider = HumanBehaviorProvider;
|
|
296
760
|
exports.useHumanBehavior = useHumanBehavior;
|
|
761
|
+
exports.useRedaction = useRedaction;
|
|
762
|
+
exports.useUserTracking = useUserTracking;
|
|
297
763
|
//# sourceMappingURL=index.js.map
|