1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var environment = require('./environment.js');
|
6 |
|
7 | function getGlobal() {
|
8 | if (typeof globalThis !== 'undefined') {
|
9 | return globalThis;
|
10 | }
|
11 |
|
12 | if (typeof self !== 'undefined') {
|
13 | return self;
|
14 | }
|
15 |
|
16 | if (typeof window !== 'undefined') {
|
17 | return window;
|
18 | }
|
19 |
|
20 | if (typeof global !== 'undefined') {
|
21 | return global;
|
22 | }
|
23 |
|
24 | if (!environment.IS_PRODUCTION) {
|
25 | console.warn('XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues');
|
26 | }
|
27 | }
|
28 |
|
29 | function getDevTools() {
|
30 | var global = getGlobal();
|
31 |
|
32 | if (global && '__xstate__' in global) {
|
33 | return global.__xstate__;
|
34 | }
|
35 |
|
36 | return undefined;
|
37 | }
|
38 |
|
39 | function registerService(service) {
|
40 | if (!getGlobal()) {
|
41 | return;
|
42 | }
|
43 |
|
44 | var devTools = getDevTools();
|
45 |
|
46 | if (devTools) {
|
47 | devTools.register(service);
|
48 | }
|
49 | }
|
50 |
|
51 | exports.getGlobal = getGlobal;
|
52 | exports.registerService = registerService;
|