@eventop/sdk 1.0.8 → 1.1.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/index.cjs +321 -64
- package/dist/index.js +299 -42
- package/dist/react/index.cjs +321 -64
- package/dist/react/index.js +299 -42
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var require$$0 = require('react');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Root context — holds the global feature registry.
|
|
7
7
|
* Set by EventopAIProvider at the root of the app.
|
|
8
8
|
*/
|
|
9
|
-
const EventopRegistryContext = /*#__PURE__*/
|
|
9
|
+
const EventopRegistryContext = /*#__PURE__*/require$$0.createContext(null);
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Feature scope context — set by EventopTarget.
|
|
@@ -15,14 +15,14 @@ const EventopRegistryContext = /*#__PURE__*/react.createContext(null);
|
|
|
15
15
|
* the feature id. Also supports explicit feature="id" on EventopStep
|
|
16
16
|
* for steps that live outside their parent EventopTarget in the tree.
|
|
17
17
|
*/
|
|
18
|
-
const EventopFeatureScopeContext = /*#__PURE__*/
|
|
18
|
+
const EventopFeatureScopeContext = /*#__PURE__*/require$$0.createContext(null);
|
|
19
19
|
function useRegistry() {
|
|
20
|
-
const ctx =
|
|
20
|
+
const ctx = require$$0.useContext(EventopRegistryContext);
|
|
21
21
|
if (!ctx) throw new Error('[EventopAI] Must be used inside <EventopAIProvider>.');
|
|
22
22
|
return ctx;
|
|
23
23
|
}
|
|
24
24
|
function useFeatureScope() {
|
|
25
|
-
return
|
|
25
|
+
return require$$0.useContext(EventopFeatureScopeContext); // null is fine — steps can declare feature explicitly
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -187,25 +187,290 @@ function createFeatureRegistry() {
|
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
var jsxRuntime = {exports: {}};
|
|
191
|
+
|
|
192
|
+
var reactJsxRuntime_production = {};
|
|
193
|
+
|
|
190
194
|
/**
|
|
191
|
-
*
|
|
195
|
+
* @license React
|
|
196
|
+
* react-jsx-runtime.production.js
|
|
192
197
|
*
|
|
193
|
-
*
|
|
194
|
-
* Every EventopTarget and EventopStep anywhere in the tree will
|
|
195
|
-
* register with this provider automatically.
|
|
198
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
196
199
|
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* provider={myServerFetcher}
|
|
200
|
-
* appName="PixelCraft"
|
|
201
|
-
* assistantName="Pixel AI"
|
|
202
|
-
* suggestions={['Add a shadow', 'Export design']}
|
|
203
|
-
* theme={{ mode: 'dark', tokens: { accent: '#6366f1' } }}
|
|
204
|
-
* position={{ corner: 'bottom-right' }}
|
|
205
|
-
* >
|
|
206
|
-
* <App />
|
|
207
|
-
* </EventopProvider>
|
|
200
|
+
* This source code is licensed under the MIT license found in the
|
|
201
|
+
* LICENSE file in the root directory of this source tree.
|
|
208
202
|
*/
|
|
203
|
+
var hasRequiredReactJsxRuntime_production;
|
|
204
|
+
function requireReactJsxRuntime_production() {
|
|
205
|
+
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
|
|
206
|
+
hasRequiredReactJsxRuntime_production = 1;
|
|
207
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
208
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
209
|
+
function jsxProd(type, config, maybeKey) {
|
|
210
|
+
var key = null;
|
|
211
|
+
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
212
|
+
void 0 !== config.key && (key = "" + config.key);
|
|
213
|
+
if ("key" in config) {
|
|
214
|
+
maybeKey = {};
|
|
215
|
+
for (var propName in config) "key" !== propName && (maybeKey[propName] = config[propName]);
|
|
216
|
+
} else maybeKey = config;
|
|
217
|
+
config = maybeKey.ref;
|
|
218
|
+
return {
|
|
219
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
220
|
+
type: type,
|
|
221
|
+
key: key,
|
|
222
|
+
ref: void 0 !== config ? config : null,
|
|
223
|
+
props: maybeKey
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
227
|
+
reactJsxRuntime_production.jsx = jsxProd;
|
|
228
|
+
reactJsxRuntime_production.jsxs = jsxProd;
|
|
229
|
+
return reactJsxRuntime_production;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
var reactJsxRuntime_development = {};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @license React
|
|
236
|
+
* react-jsx-runtime.development.js
|
|
237
|
+
*
|
|
238
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
239
|
+
*
|
|
240
|
+
* This source code is licensed under the MIT license found in the
|
|
241
|
+
* LICENSE file in the root directory of this source tree.
|
|
242
|
+
*/
|
|
243
|
+
var hasRequiredReactJsxRuntime_development;
|
|
244
|
+
function requireReactJsxRuntime_development() {
|
|
245
|
+
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
246
|
+
hasRequiredReactJsxRuntime_development = 1;
|
|
247
|
+
"production" !== process.env.NODE_ENV && function () {
|
|
248
|
+
function getComponentNameFromType(type) {
|
|
249
|
+
if (null == type) return null;
|
|
250
|
+
if ("function" === typeof type) return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
|
|
251
|
+
if ("string" === typeof type) return type;
|
|
252
|
+
switch (type) {
|
|
253
|
+
case REACT_FRAGMENT_TYPE:
|
|
254
|
+
return "Fragment";
|
|
255
|
+
case REACT_PROFILER_TYPE:
|
|
256
|
+
return "Profiler";
|
|
257
|
+
case REACT_STRICT_MODE_TYPE:
|
|
258
|
+
return "StrictMode";
|
|
259
|
+
case REACT_SUSPENSE_TYPE:
|
|
260
|
+
return "Suspense";
|
|
261
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
262
|
+
return "SuspenseList";
|
|
263
|
+
case REACT_ACTIVITY_TYPE:
|
|
264
|
+
return "Activity";
|
|
265
|
+
}
|
|
266
|
+
if ("object" === typeof type) switch ("number" === typeof type.tag && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), type.$$typeof) {
|
|
267
|
+
case REACT_PORTAL_TYPE:
|
|
268
|
+
return "Portal";
|
|
269
|
+
case REACT_CONTEXT_TYPE:
|
|
270
|
+
return type.displayName || "Context";
|
|
271
|
+
case REACT_CONSUMER_TYPE:
|
|
272
|
+
return (type._context.displayName || "Context") + ".Consumer";
|
|
273
|
+
case REACT_FORWARD_REF_TYPE:
|
|
274
|
+
var innerType = type.render;
|
|
275
|
+
type = type.displayName;
|
|
276
|
+
type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
|
|
277
|
+
return type;
|
|
278
|
+
case REACT_MEMO_TYPE:
|
|
279
|
+
return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
|
|
280
|
+
case REACT_LAZY_TYPE:
|
|
281
|
+
innerType = type._payload;
|
|
282
|
+
type = type._init;
|
|
283
|
+
try {
|
|
284
|
+
return getComponentNameFromType(type(innerType));
|
|
285
|
+
} catch (x) {}
|
|
286
|
+
}
|
|
287
|
+
return null;
|
|
288
|
+
}
|
|
289
|
+
function testStringCoercion(value) {
|
|
290
|
+
return "" + value;
|
|
291
|
+
}
|
|
292
|
+
function checkKeyStringCoercion(value) {
|
|
293
|
+
try {
|
|
294
|
+
testStringCoercion(value);
|
|
295
|
+
var JSCompiler_inline_result = !1;
|
|
296
|
+
} catch (e) {
|
|
297
|
+
JSCompiler_inline_result = true;
|
|
298
|
+
}
|
|
299
|
+
if (JSCompiler_inline_result) {
|
|
300
|
+
JSCompiler_inline_result = console;
|
|
301
|
+
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
302
|
+
var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
|
303
|
+
JSCompiler_temp_const.call(JSCompiler_inline_result, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", JSCompiler_inline_result$jscomp$0);
|
|
304
|
+
return testStringCoercion(value);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function getTaskName(type) {
|
|
308
|
+
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
309
|
+
if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE) return "<...>";
|
|
310
|
+
try {
|
|
311
|
+
var name = getComponentNameFromType(type);
|
|
312
|
+
return name ? "<" + name + ">" : "<...>";
|
|
313
|
+
} catch (x) {
|
|
314
|
+
return "<...>";
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function getOwner() {
|
|
318
|
+
var dispatcher = ReactSharedInternals.A;
|
|
319
|
+
return null === dispatcher ? null : dispatcher.getOwner();
|
|
320
|
+
}
|
|
321
|
+
function UnknownOwner() {
|
|
322
|
+
return Error("react-stack-top-frame");
|
|
323
|
+
}
|
|
324
|
+
function hasValidKey(config) {
|
|
325
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
326
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
327
|
+
if (getter && getter.isReactWarning) return false;
|
|
328
|
+
}
|
|
329
|
+
return void 0 !== config.key;
|
|
330
|
+
}
|
|
331
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
332
|
+
function warnAboutAccessingKey() {
|
|
333
|
+
specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error("%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)", displayName));
|
|
334
|
+
}
|
|
335
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
336
|
+
Object.defineProperty(props, "key", {
|
|
337
|
+
get: warnAboutAccessingKey,
|
|
338
|
+
configurable: true
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
function elementRefGetterWithDeprecationWarning() {
|
|
342
|
+
var componentName = getComponentNameFromType(this.type);
|
|
343
|
+
didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error("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."));
|
|
344
|
+
componentName = this.props.ref;
|
|
345
|
+
return void 0 !== componentName ? componentName : null;
|
|
346
|
+
}
|
|
347
|
+
function ReactElement(type, key, props, owner, debugStack, debugTask) {
|
|
348
|
+
var refProp = props.ref;
|
|
349
|
+
type = {
|
|
350
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
351
|
+
type: type,
|
|
352
|
+
key: key,
|
|
353
|
+
props: props,
|
|
354
|
+
_owner: owner
|
|
355
|
+
};
|
|
356
|
+
null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
|
|
357
|
+
enumerable: false,
|
|
358
|
+
get: elementRefGetterWithDeprecationWarning
|
|
359
|
+
}) : Object.defineProperty(type, "ref", {
|
|
360
|
+
enumerable: false,
|
|
361
|
+
value: null
|
|
362
|
+
});
|
|
363
|
+
type._store = {};
|
|
364
|
+
Object.defineProperty(type._store, "validated", {
|
|
365
|
+
configurable: false,
|
|
366
|
+
enumerable: false,
|
|
367
|
+
writable: true,
|
|
368
|
+
value: 0
|
|
369
|
+
});
|
|
370
|
+
Object.defineProperty(type, "_debugInfo", {
|
|
371
|
+
configurable: false,
|
|
372
|
+
enumerable: false,
|
|
373
|
+
writable: true,
|
|
374
|
+
value: null
|
|
375
|
+
});
|
|
376
|
+
Object.defineProperty(type, "_debugStack", {
|
|
377
|
+
configurable: false,
|
|
378
|
+
enumerable: false,
|
|
379
|
+
writable: true,
|
|
380
|
+
value: debugStack
|
|
381
|
+
});
|
|
382
|
+
Object.defineProperty(type, "_debugTask", {
|
|
383
|
+
configurable: false,
|
|
384
|
+
enumerable: false,
|
|
385
|
+
writable: true,
|
|
386
|
+
value: debugTask
|
|
387
|
+
});
|
|
388
|
+
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
389
|
+
return type;
|
|
390
|
+
}
|
|
391
|
+
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, debugStack, debugTask) {
|
|
392
|
+
var children = config.children;
|
|
393
|
+
if (void 0 !== children) if (isStaticChildren) {
|
|
394
|
+
if (isArrayImpl(children)) {
|
|
395
|
+
for (isStaticChildren = 0; isStaticChildren < children.length; isStaticChildren++) validateChildKeys(children[isStaticChildren]);
|
|
396
|
+
Object.freeze && Object.freeze(children);
|
|
397
|
+
} else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
398
|
+
} else validateChildKeys(children);
|
|
399
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
400
|
+
children = getComponentNameFromType(type);
|
|
401
|
+
var keys = Object.keys(config).filter(function (k) {
|
|
402
|
+
return "key" !== k;
|
|
403
|
+
});
|
|
404
|
+
isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
405
|
+
didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error('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} />', isStaticChildren, children, keys, children), didWarnAboutKeySpread[children + isStaticChildren] = true);
|
|
406
|
+
}
|
|
407
|
+
children = null;
|
|
408
|
+
void 0 !== maybeKey && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
|
|
409
|
+
hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
|
|
410
|
+
if ("key" in config) {
|
|
411
|
+
maybeKey = {};
|
|
412
|
+
for (var propName in config) "key" !== propName && (maybeKey[propName] = config[propName]);
|
|
413
|
+
} else maybeKey = config;
|
|
414
|
+
children && defineKeyPropWarningGetter(maybeKey, "function" === typeof type ? type.displayName || type.name || "Unknown" : type);
|
|
415
|
+
return ReactElement(type, children, maybeKey, getOwner(), debugStack, debugTask);
|
|
416
|
+
}
|
|
417
|
+
function validateChildKeys(node) {
|
|
418
|
+
isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
|
|
419
|
+
}
|
|
420
|
+
function isValidElement(object) {
|
|
421
|
+
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
422
|
+
}
|
|
423
|
+
var React = require$$0,
|
|
424
|
+
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
425
|
+
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
426
|
+
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
427
|
+
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
428
|
+
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
|
|
429
|
+
REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
430
|
+
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
431
|
+
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
432
|
+
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
433
|
+
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
|
|
434
|
+
REACT_MEMO_TYPE = Symbol.for("react.memo"),
|
|
435
|
+
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
|
436
|
+
REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
|
|
437
|
+
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
|
|
438
|
+
ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
439
|
+
hasOwnProperty = Object.prototype.hasOwnProperty,
|
|
440
|
+
isArrayImpl = Array.isArray,
|
|
441
|
+
createTask = console.createTask ? console.createTask : function () {
|
|
442
|
+
return null;
|
|
443
|
+
};
|
|
444
|
+
React = {
|
|
445
|
+
react_stack_bottom_frame: function (callStackForError) {
|
|
446
|
+
return callStackForError();
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
var specialPropKeyWarningShown;
|
|
450
|
+
var didWarnAboutElementRef = {};
|
|
451
|
+
var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(React, UnknownOwner)();
|
|
452
|
+
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
453
|
+
var didWarnAboutKeySpread = {};
|
|
454
|
+
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
455
|
+
reactJsxRuntime_development.jsx = function (type, config, maybeKey) {
|
|
456
|
+
var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
457
|
+
return jsxDEVImpl(type, config, maybeKey, false, trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack, trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
|
|
458
|
+
};
|
|
459
|
+
reactJsxRuntime_development.jsxs = function (type, config, maybeKey) {
|
|
460
|
+
var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
461
|
+
return jsxDEVImpl(type, config, maybeKey, true, trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack, trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
|
|
462
|
+
};
|
|
463
|
+
}();
|
|
464
|
+
return reactJsxRuntime_development;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (process.env.NODE_ENV === 'production') {
|
|
468
|
+
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
469
|
+
} else {
|
|
470
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
471
|
+
}
|
|
472
|
+
var jsxRuntimeExports = jsxRuntime.exports;
|
|
473
|
+
|
|
209
474
|
function EventopProvider({
|
|
210
475
|
children,
|
|
211
476
|
provider,
|
|
@@ -217,15 +482,15 @@ function EventopProvider({
|
|
|
217
482
|
}) {
|
|
218
483
|
if (!provider) throw new Error('[Eventop] <EventopProvider> requires a provider prop.');
|
|
219
484
|
if (!appName) throw new Error('[Eventop] <EventopProvider> requires an appName prop.');
|
|
220
|
-
const registry =
|
|
221
|
-
const sdkReady =
|
|
222
|
-
const syncToSDK =
|
|
485
|
+
const registry = require$$0.useRef(createFeatureRegistry()).current;
|
|
486
|
+
const sdkReady = require$$0.useRef(false);
|
|
487
|
+
const syncToSDK = require$$0.useCallback(() => {
|
|
223
488
|
if (!sdkReady.current || !window.Eventop) return;
|
|
224
489
|
window.Eventop._updateConfig?.({
|
|
225
490
|
features: registry.snapshot()
|
|
226
491
|
});
|
|
227
492
|
}, [registry]);
|
|
228
|
-
|
|
493
|
+
require$$0.useEffect(() => {
|
|
229
494
|
function boot() {
|
|
230
495
|
window.Eventop.init({
|
|
231
496
|
provider,
|
|
@@ -256,17 +521,12 @@ function EventopProvider({
|
|
|
256
521
|
unregisterStep: registry.unregisterStep,
|
|
257
522
|
isRegistered: registry.isRegistered
|
|
258
523
|
};
|
|
259
|
-
return /*#__PURE__*/
|
|
260
|
-
value: ctx
|
|
261
|
-
|
|
524
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(EventopRegistryContext.Provider, {
|
|
525
|
+
value: ctx,
|
|
526
|
+
children: children
|
|
527
|
+
});
|
|
262
528
|
}
|
|
263
529
|
|
|
264
|
-
/**
|
|
265
|
-
* EventopTarget
|
|
266
|
-
*
|
|
267
|
-
* Wraps any component and registers it as an Eventop feature at the call site.
|
|
268
|
-
* The wrapped component does not need to know about Eventop.
|
|
269
|
-
*/
|
|
270
530
|
function EventopTarget({
|
|
271
531
|
children,
|
|
272
532
|
id,
|
|
@@ -279,10 +539,10 @@ function EventopTarget({
|
|
|
279
539
|
...rest
|
|
280
540
|
}) {
|
|
281
541
|
const registry = useRegistry();
|
|
282
|
-
const ref =
|
|
542
|
+
const ref = require$$0.useRef(null);
|
|
283
543
|
const dataAttr = `data-evtp-${id}`;
|
|
284
544
|
const selector = `[${dataAttr}]`;
|
|
285
|
-
|
|
545
|
+
require$$0.useEffect(() => {
|
|
286
546
|
if (!id || !name) {
|
|
287
547
|
console.warn('[Eventop] <EventopTarget> requires id and name props.');
|
|
288
548
|
return;
|
|
@@ -302,10 +562,10 @@ function EventopTarget({
|
|
|
302
562
|
});
|
|
303
563
|
return () => registry.unregisterFeature(id);
|
|
304
564
|
}, [id, name, description]);
|
|
305
|
-
const child =
|
|
565
|
+
const child = require$$0.Children.only(children);
|
|
306
566
|
let wrapped;
|
|
307
567
|
try {
|
|
308
|
-
wrapped = /*#__PURE__*/
|
|
568
|
+
wrapped = /*#__PURE__*/require$$0.cloneElement(child, {
|
|
309
569
|
[dataAttr]: '',
|
|
310
570
|
ref: node => {
|
|
311
571
|
ref.current = node;
|
|
@@ -314,25 +574,21 @@ function EventopTarget({
|
|
|
314
574
|
}
|
|
315
575
|
});
|
|
316
576
|
} catch {
|
|
317
|
-
wrapped = /*#__PURE__*/
|
|
577
|
+
wrapped = /*#__PURE__*/jsxRuntimeExports.jsx("span", {
|
|
318
578
|
[dataAttr]: '',
|
|
319
579
|
ref: ref,
|
|
320
580
|
style: {
|
|
321
581
|
display: 'contents'
|
|
322
|
-
}
|
|
323
|
-
|
|
582
|
+
},
|
|
583
|
+
children: child
|
|
584
|
+
});
|
|
324
585
|
}
|
|
325
|
-
return /*#__PURE__*/
|
|
326
|
-
value: id
|
|
327
|
-
|
|
586
|
+
return /*#__PURE__*/jsxRuntimeExports.jsx(EventopFeatureScopeContext.Provider, {
|
|
587
|
+
value: id,
|
|
588
|
+
children: wrapped
|
|
589
|
+
});
|
|
328
590
|
}
|
|
329
591
|
|
|
330
|
-
/**
|
|
331
|
-
* EventopStep
|
|
332
|
-
*
|
|
333
|
-
* Registers one step in a multi-step flow. Can live anywhere in the tree.
|
|
334
|
-
* Steps self-assemble into order via the `index` prop.
|
|
335
|
-
*/
|
|
336
592
|
function EventopStep({
|
|
337
593
|
children,
|
|
338
594
|
feature,
|
|
@@ -344,7 +600,7 @@ function EventopStep({
|
|
|
344
600
|
const registry = useRegistry();
|
|
345
601
|
const featureScope = useFeatureScope();
|
|
346
602
|
const featureId = feature || featureScope;
|
|
347
|
-
const ref =
|
|
603
|
+
const ref = require$$0.useRef(null);
|
|
348
604
|
if (!featureId) {
|
|
349
605
|
console.warn('[Eventop] <EventopStep> needs either a feature prop or an <EventopTarget> ancestor.');
|
|
350
606
|
}
|
|
@@ -353,7 +609,7 @@ function EventopStep({
|
|
|
353
609
|
}
|
|
354
610
|
const dataAttr = `data-evtp-step-${featureId}-${parentStep != null ? `${parentStep}-` : ''}${index}`;
|
|
355
611
|
const selector = `[${dataAttr}]`;
|
|
356
|
-
|
|
612
|
+
require$$0.useEffect(() => {
|
|
357
613
|
if (!featureId || index == null) return;
|
|
358
614
|
registry.registerStep(featureId, index, parentStep ?? null, {
|
|
359
615
|
selector,
|
|
@@ -365,10 +621,10 @@ function EventopStep({
|
|
|
365
621
|
});
|
|
366
622
|
return () => registry.unregisterStep(featureId, index, parentStep ?? null);
|
|
367
623
|
}, [featureId, index, parentStep]);
|
|
368
|
-
const child =
|
|
624
|
+
const child = require$$0.Children.only(children);
|
|
369
625
|
let wrapped;
|
|
370
626
|
try {
|
|
371
|
-
wrapped = /*#__PURE__*/
|
|
627
|
+
wrapped = /*#__PURE__*/require$$0.cloneElement(child, {
|
|
372
628
|
[dataAttr]: '',
|
|
373
629
|
ref: node => {
|
|
374
630
|
ref.current = node;
|
|
@@ -377,13 +633,14 @@ function EventopStep({
|
|
|
377
633
|
}
|
|
378
634
|
});
|
|
379
635
|
} catch {
|
|
380
|
-
wrapped = /*#__PURE__*/
|
|
636
|
+
wrapped = /*#__PURE__*/jsxRuntimeExports.jsx("span", {
|
|
381
637
|
[dataAttr]: '',
|
|
382
638
|
ref: ref,
|
|
383
639
|
style: {
|
|
384
640
|
display: 'contents'
|
|
385
|
-
}
|
|
386
|
-
|
|
641
|
+
},
|
|
642
|
+
children: child
|
|
643
|
+
});
|
|
387
644
|
}
|
|
388
645
|
return wrapped;
|
|
389
646
|
}
|
|
@@ -406,7 +663,7 @@ function EventopStep({
|
|
|
406
663
|
// }
|
|
407
664
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
408
665
|
|
|
409
|
-
function
|
|
666
|
+
function useEventopAI() {
|
|
410
667
|
const sdk = () => window.Eventop;
|
|
411
668
|
return {
|
|
412
669
|
open: () => sdk()?.open(),
|
|
@@ -441,11 +698,11 @@ function useEventop() {
|
|
|
441
698
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
442
699
|
|
|
443
700
|
function useEventopTour() {
|
|
444
|
-
const [state, setState] =
|
|
701
|
+
const [state, setState] = require$$0.useState({
|
|
445
702
|
isActive: false,
|
|
446
703
|
isPaused: false
|
|
447
704
|
});
|
|
448
|
-
|
|
705
|
+
require$$0.useEffect(() => {
|
|
449
706
|
const id = setInterval(() => {
|
|
450
707
|
const sdk = window.Eventop;
|
|
451
708
|
if (!sdk) return;
|
|
@@ -459,15 +716,15 @@ function useEventopTour() {
|
|
|
459
716
|
}, []);
|
|
460
717
|
return {
|
|
461
718
|
...state,
|
|
462
|
-
resume:
|
|
463
|
-
cancel:
|
|
464
|
-
open:
|
|
465
|
-
close:
|
|
719
|
+
resume: require$$0.useCallback(() => window.Eventop?.resumeTour(), []),
|
|
720
|
+
cancel: require$$0.useCallback(() => window.Eventop?.cancelTour(), []),
|
|
721
|
+
open: require$$0.useCallback(() => window.Eventop?.open(), []),
|
|
722
|
+
close: require$$0.useCallback(() => window.Eventop?.close(), [])
|
|
466
723
|
};
|
|
467
724
|
}
|
|
468
725
|
|
|
469
726
|
exports.EventopAIProvider = EventopProvider;
|
|
470
727
|
exports.EventopStep = EventopStep;
|
|
471
728
|
exports.EventopTarget = EventopTarget;
|
|
472
|
-
exports.
|
|
729
|
+
exports.useEventopAI = useEventopAI;
|
|
473
730
|
exports.useEventopTour = useEventopTour;
|