@memberjunction/global 0.9.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/ClassFactory.d.ts +20 -0
- package/dist/ClassFactory.js +70 -0
- package/dist/ClassFactory.js.map +1 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +117 -0
- package/dist/index.js.map +1 -0
- package/dist/interface.d.ts +22 -0
- package/dist/interface.js +21 -0
- package/dist/interface.js.map +1 -0
- package/dist/util.d.ts +1 -0
- package/dist/util.js +34 -0
- package/dist/util.js.map +1 -0
- package/package.json +23 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*******************************************************************************************************
|
|
2
|
+
* MJ Global Class Factory handles both the registration and instantiation of any class that we need to create across any MJ Project
|
|
3
|
+
*
|
|
4
|
+
* The idea is to have a global place where we can register a subclass for a given base class and then call a simple class factory method to
|
|
5
|
+
* instantiate whatever class we need. This allows any module at any time to register their new class for a given base class as a sub-class
|
|
6
|
+
* and we will dynamically instantiate that sub-class from that point forward
|
|
7
|
+
******************************************************************************************************/
|
|
8
|
+
export declare class ClassRegistration {
|
|
9
|
+
BaseClass: any;
|
|
10
|
+
SubClass: any;
|
|
11
|
+
Key: string;
|
|
12
|
+
Priority: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class ClassFactory {
|
|
15
|
+
private _registrations;
|
|
16
|
+
Register(baseClass: any, subClass: any, key?: string, priority?: number): void;
|
|
17
|
+
CreateInstance<T>(baseClass: any, key?: string, ...params: any[]): T | null;
|
|
18
|
+
GetAllRegistrations(baseClass: any, key?: string): ClassRegistration[];
|
|
19
|
+
GetRegistration(baseClass: any, key?: string): ClassRegistration;
|
|
20
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*******************************************************************************************************
|
|
3
|
+
* MJ Global Class Factory handles both the registration and instantiation of any class that we need to create across any MJ Project
|
|
4
|
+
*
|
|
5
|
+
* The idea is to have a global place where we can register a subclass for a given base class and then call a simple class factory method to
|
|
6
|
+
* instantiate whatever class we need. This allows any module at any time to register their new class for a given base class as a sub-class
|
|
7
|
+
* and we will dynamically instantiate that sub-class from that point forward
|
|
8
|
+
******************************************************************************************************/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ClassFactory = exports.ClassRegistration = void 0;
|
|
11
|
+
class ClassRegistration {
|
|
12
|
+
}
|
|
13
|
+
exports.ClassRegistration = ClassRegistration;
|
|
14
|
+
class ClassFactory {
|
|
15
|
+
constructor() {
|
|
16
|
+
this._registrations = [];
|
|
17
|
+
}
|
|
18
|
+
Register(baseClass, subClass, key = null, priority = 0) {
|
|
19
|
+
if (baseClass && subClass) {
|
|
20
|
+
let reg = new ClassRegistration();
|
|
21
|
+
reg.BaseClass = baseClass;
|
|
22
|
+
reg.SubClass = subClass;
|
|
23
|
+
reg.Key = key;
|
|
24
|
+
reg.Priority = priority;
|
|
25
|
+
this._registrations.push(reg);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
CreateInstance(baseClass, key = null, ...params) {
|
|
29
|
+
if (baseClass) {
|
|
30
|
+
let reg = this.GetRegistration(baseClass, key);
|
|
31
|
+
if (reg) {
|
|
32
|
+
let instance = null;
|
|
33
|
+
if (params !== undefined)
|
|
34
|
+
instance = new reg.SubClass(...params);
|
|
35
|
+
else
|
|
36
|
+
instance = new reg.SubClass(); // dont pass in anything if we got undefined for that parameter into our function because it is different to call a function with no params than to pass in a single null/undefined param
|
|
37
|
+
return instance;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
GetAllRegistrations(baseClass, key = undefined) {
|
|
43
|
+
if (baseClass) {
|
|
44
|
+
return this._registrations.filter(r => {
|
|
45
|
+
return r.BaseClass.name === baseClass.name && // we use the name of the class instead of the class itself because JS is finicky about this since a given module can be loaded in various places (like from multiple other modules) and the class itself will be different in each case
|
|
46
|
+
(key === undefined ? true : r.Key.trim().toLowerCase() === key.trim().toLowerCase());
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
GetRegistration(baseClass, key = undefined) {
|
|
53
|
+
let matches = this.GetAllRegistrations(baseClass, key);
|
|
54
|
+
if (matches && matches.length > 0) {
|
|
55
|
+
// figure out the highest priority for all the matching registrations
|
|
56
|
+
let highestPriority = 0;
|
|
57
|
+
for (let i = 0; i < matches.length; i++) {
|
|
58
|
+
if (matches[i].Priority > highestPriority)
|
|
59
|
+
highestPriority = matches[i].Priority;
|
|
60
|
+
}
|
|
61
|
+
// now filter the matches to only those that have the highest priority
|
|
62
|
+
const highest = matches.filter(r => r.Priority === highestPriority);
|
|
63
|
+
// return the last one in the list, which will be the last one registered - so that if everyone has the same priority number, we use the LAST one registered
|
|
64
|
+
return highest[highest.length - 1];
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.ClassFactory = ClassFactory;
|
|
70
|
+
//# sourceMappingURL=ClassFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClassFactory.js","sourceRoot":"","sources":["../src/ClassFactory.ts"],"names":[],"mappings":";AAAA;;;;;;wGAMwG;;;AAGxG,MAAa,iBAAiB;CAM7B;AAND,8CAMC;AAGD,MAAa,YAAY;IAAzB;QACY,mBAAc,GAAwB,EAAE,CAAC;IA6DrD,CAAC;IA3DU,QAAQ,CAAC,SAAc,EAAE,QAAa,EAAE,MAAc,IAAI,EAAE,WAAmB,CAAC;QACnF,IAAI,SAAS,IAAI,QAAQ,EAAE;YACvB,IAAI,GAAG,GAAG,IAAI,iBAAiB,EAAE,CAAC;YAClC,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC;YAC1B,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;YACxB,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC;YACd,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AAM,GAAG,CAAC,EAAE;YAC/B,qEAAqE;YACrE,IAAI,eAAe,GAAG,CAAC,CAAC;YACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACrC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,eAAe;oBACrC,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;aAC7C;YAED,sEAAsE;YACtE,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,eAAe,CAAC,CAAC;YAEpE,4JAA4J;YAC5J,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SACtC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA9DD,oCA8DC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as MJ from './interface';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { ClassFactory } from './ClassFactory';
|
|
4
|
+
export { ClassFactory, ClassRegistration } from './ClassFactory';
|
|
5
|
+
export * from './interface';
|
|
6
|
+
/**
|
|
7
|
+
* Global class used for coordinating events and components across MemberJunction
|
|
8
|
+
*/
|
|
9
|
+
export declare class MJGlobal {
|
|
10
|
+
private _eventsSubject;
|
|
11
|
+
private _eventsReplaySubject;
|
|
12
|
+
private _events$;
|
|
13
|
+
private _eventsReplay$;
|
|
14
|
+
private _globalObjectKey;
|
|
15
|
+
private _components;
|
|
16
|
+
private static _instance;
|
|
17
|
+
private _classFactory;
|
|
18
|
+
private _properties;
|
|
19
|
+
constructor();
|
|
20
|
+
RegisterComponent(component: MJ.IMJComponent): void;
|
|
21
|
+
Reset(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Use this method to raise an event to all component who are listening for the event.
|
|
24
|
+
* @param event
|
|
25
|
+
*/
|
|
26
|
+
RaiseEvent(event: MJ.MJEvent): void;
|
|
27
|
+
/**
|
|
28
|
+
* Use this method to get an observable that will fire when an event is raised.
|
|
29
|
+
* @param withReplay
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
GetEventListener(withReplay?: boolean): Observable<MJ.MJEvent>;
|
|
33
|
+
static get Instance(): MJGlobal;
|
|
34
|
+
get ClassFactory(): ClassFactory;
|
|
35
|
+
/**
|
|
36
|
+
* Global property bag
|
|
37
|
+
*/
|
|
38
|
+
get Properties(): MJ.MJGlobalProperty[];
|
|
39
|
+
GetGlobalObjectStore(): any;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Decorate your class with this to register it with the MJGlobal class factory.
|
|
43
|
+
* @param baseClass
|
|
44
|
+
* @param key a string that is later used to retrieve a given registration - this should be unique for each baseClass/key combination, if multiple registrations exist for a given baseClass/key combination, the highest priority registration will be used to create class instances
|
|
45
|
+
* @param priority the higher the number the more priority a registration has. If there are multiple registrations for a given combination of baseClass/key the highest priority registration will be used to create class instances
|
|
46
|
+
* @returns an instance of the class that was registered for the combination of baseClass/key (with highest priority if more than one)
|
|
47
|
+
*/
|
|
48
|
+
export declare function RegisterClass(baseClass: any, key?: string, priority?: number): (constructor: Function) => void;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.RegisterClass = exports.MJGlobal = exports.ClassRegistration = exports.ClassFactory = void 0;
|
|
18
|
+
const util_1 = require("./util");
|
|
19
|
+
const rxjs_1 = require("rxjs");
|
|
20
|
+
const ClassFactory_1 = require("./ClassFactory");
|
|
21
|
+
var ClassFactory_2 = require("./ClassFactory");
|
|
22
|
+
Object.defineProperty(exports, "ClassFactory", { enumerable: true, get: function () { return ClassFactory_2.ClassFactory; } });
|
|
23
|
+
Object.defineProperty(exports, "ClassRegistration", { enumerable: true, get: function () { return ClassFactory_2.ClassRegistration; } });
|
|
24
|
+
__exportStar(require("./interface"), exports);
|
|
25
|
+
/**
|
|
26
|
+
* Global class used for coordinating events and components across MemberJunction
|
|
27
|
+
*/
|
|
28
|
+
class MJGlobal {
|
|
29
|
+
constructor() {
|
|
30
|
+
// subjects for observables to handle eventing
|
|
31
|
+
this._eventsSubject = new rxjs_1.Subject();
|
|
32
|
+
this._eventsReplaySubject = new rxjs_1.ReplaySubject();
|
|
33
|
+
// Convert the Subjects to Observables for public use.
|
|
34
|
+
this._events$ = this._eventsSubject.asObservable();
|
|
35
|
+
this._eventsReplay$ = this._eventsReplaySubject.asObservable();
|
|
36
|
+
this._globalObjectKey = 'MJGlobalInstance';
|
|
37
|
+
this._classFactory = new ClassFactory_1.ClassFactory();
|
|
38
|
+
this._properties = [];
|
|
39
|
+
if (MJGlobal._instance)
|
|
40
|
+
return MJGlobal._instance;
|
|
41
|
+
else {
|
|
42
|
+
const g = (0, util_1.GetGlobalObjectStore)();
|
|
43
|
+
if (g && g[this._globalObjectKey]) {
|
|
44
|
+
MJGlobal._instance = g[this._globalObjectKey];
|
|
45
|
+
return MJGlobal._instance;
|
|
46
|
+
}
|
|
47
|
+
// finally, if we get here, we are the first instance of this class, so create it
|
|
48
|
+
if (!MJGlobal._instance) {
|
|
49
|
+
MJGlobal._instance = this;
|
|
50
|
+
// try to put this in global object store if there is a window/e.g. we're in a browser, a global object, we're in node, etc...
|
|
51
|
+
if (g)
|
|
52
|
+
g[this._globalObjectKey] = MJGlobal._instance;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
RegisterComponent(component) {
|
|
58
|
+
this._components.push(component);
|
|
59
|
+
}
|
|
60
|
+
Reset() {
|
|
61
|
+
this._components = [];
|
|
62
|
+
this._eventsSubject = new rxjs_1.Subject();
|
|
63
|
+
this._eventsReplaySubject = new rxjs_1.ReplaySubject();
|
|
64
|
+
// Convert the Subjects to Observables for public use.
|
|
65
|
+
this._events$ = this._eventsSubject.asObservable();
|
|
66
|
+
this._eventsReplay$ = this._eventsReplaySubject.asObservable();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Use this method to raise an event to all component who are listening for the event.
|
|
70
|
+
* @param event
|
|
71
|
+
*/
|
|
72
|
+
RaiseEvent(event) {
|
|
73
|
+
this._eventsSubject.next(event);
|
|
74
|
+
this._eventsReplaySubject.next(event);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Use this method to get an observable that will fire when an event is raised.
|
|
78
|
+
* @param withReplay
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
GetEventListener(withReplay = false) {
|
|
82
|
+
return withReplay ? this._eventsReplay$ : this._events$;
|
|
83
|
+
}
|
|
84
|
+
static get Instance() {
|
|
85
|
+
if (!MJGlobal._instance)
|
|
86
|
+
MJGlobal._instance = new MJGlobal();
|
|
87
|
+
return MJGlobal._instance;
|
|
88
|
+
}
|
|
89
|
+
get ClassFactory() {
|
|
90
|
+
return this._classFactory;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Global property bag
|
|
94
|
+
*/
|
|
95
|
+
get Properties() {
|
|
96
|
+
return this._properties;
|
|
97
|
+
}
|
|
98
|
+
GetGlobalObjectStore() {
|
|
99
|
+
return (0, util_1.GetGlobalObjectStore)(); // wrap the function in a method here so that other modules can use it easily.
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.MJGlobal = MJGlobal;
|
|
103
|
+
/**
|
|
104
|
+
* Decorate your class with this to register it with the MJGlobal class factory.
|
|
105
|
+
* @param baseClass
|
|
106
|
+
* @param key a string that is later used to retrieve a given registration - this should be unique for each baseClass/key combination, if multiple registrations exist for a given baseClass/key combination, the highest priority registration will be used to create class instances
|
|
107
|
+
* @param priority the higher the number the more priority a registration has. If there are multiple registrations for a given combination of baseClass/key the highest priority registration will be used to create class instances
|
|
108
|
+
* @returns an instance of the class that was registered for the combination of baseClass/key (with highest priority if more than one)
|
|
109
|
+
*/
|
|
110
|
+
function RegisterClass(baseClass, key = null, priority = 0) {
|
|
111
|
+
return function (constructor) {
|
|
112
|
+
// Invoke the registration method
|
|
113
|
+
MJGlobal.Instance.ClassFactory.Register(baseClass, constructor, key, priority);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
exports.RegisterClass = RegisterClass;
|
|
117
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,iCAA8C;AAC9C,+BAA0D;AAC1D,iDAAgE;AAEhE,+CAAgE;AAAvD,4GAAA,YAAY,OAAA;AAAE,iHAAA,iBAAiB,OAAA;AACxC,8CAA2B;AAE3B;;GAEG;AACH,MAAa,QAAQ;IAiBjB;QAhBA,8CAA8C;QACtC,mBAAc,GAAwB,IAAI,cAAO,EAAE,CAAC;QACpD,yBAAoB,GAA8B,IAAI,oBAAa,EAAE,CAAC;QAE9E,sDAAsD;QAC9C,aAAQ,G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
8
|
+
eventCode?: string;
|
|
9
|
+
args: any;
|
|
10
|
+
}
|
|
11
|
+
export interface IMJComponent {
|
|
12
|
+
}
|
|
13
|
+
export declare enum MJEventType {
|
|
14
|
+
ComponentRegistered = 0,
|
|
15
|
+
ComponentUnregistered = 1,
|
|
16
|
+
ComponentEvent = 2,
|
|
17
|
+
LoggedIn = 3,
|
|
18
|
+
LoggedOut = 4,
|
|
19
|
+
LoginFailed = 5,
|
|
20
|
+
LogoutFailed = 6,
|
|
21
|
+
ManualResizeRequest = 7
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MJEventType = exports.MJEvent = exports.MJGlobalProperty = void 0;
|
|
4
|
+
class MJGlobalProperty {
|
|
5
|
+
}
|
|
6
|
+
exports.MJGlobalProperty = MJGlobalProperty;
|
|
7
|
+
class MJEvent {
|
|
8
|
+
}
|
|
9
|
+
exports.MJEvent = MJEvent;
|
|
10
|
+
var MJEventType;
|
|
11
|
+
(function (MJEventType) {
|
|
12
|
+
MJEventType[MJEventType["ComponentRegistered"] = 0] = "ComponentRegistered";
|
|
13
|
+
MJEventType[MJEventType["ComponentUnregistered"] = 1] = "ComponentUnregistered";
|
|
14
|
+
MJEventType[MJEventType["ComponentEvent"] = 2] = "ComponentEvent";
|
|
15
|
+
MJEventType[MJEventType["LoggedIn"] = 3] = "LoggedIn";
|
|
16
|
+
MJEventType[MJEventType["LoggedOut"] = 4] = "LoggedOut";
|
|
17
|
+
MJEventType[MJEventType["LoginFailed"] = 5] = "LoginFailed";
|
|
18
|
+
MJEventType[MJEventType["LogoutFailed"] = 6] = "LogoutFailed";
|
|
19
|
+
MJEventType[MJEventType["ManualResizeRequest"] = 7] = "ManualResizeRequest";
|
|
20
|
+
})(MJEventType = exports.MJEventType || (exports.MJEventType = {}));
|
|
21
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;CAI5B;AAJD,4CAIC;AAED,MAAa,OAAO;CAMnB;AAND,0BAMC;AAOD,IAAY,WAUX;AAVD,WAAY,WAAW;IAEnB,2EAAmB,CAAA;IACnB,+EAAqB,CAAA;IACrB,iEAAc,CAAA;IACd,qDAAQ,CAAA;IACR,uDAAS,CAAA;IACT,2DAAW,CAAA;IACX,6DAAY,CAAA;IACZ,2EAAmB,CAAA;AACvB,CAAC,EAVW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAUtB"}
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function GetGlobalObjectStore(): typeof globalThis;
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetGlobalObjectStore = void 0;
|
|
4
|
+
function GetGlobalObjectStore() {
|
|
5
|
+
try {
|
|
6
|
+
// we might be running in a browser, in that case, we use the window object for our global stuff
|
|
7
|
+
if (window)
|
|
8
|
+
return window;
|
|
9
|
+
else {
|
|
10
|
+
// if we get here, we don't have a window object, so try the global object (node environment)
|
|
11
|
+
// won't get here typically because attempting to access the global object will throw an exception if it doesn't exist
|
|
12
|
+
if (global)
|
|
13
|
+
return global;
|
|
14
|
+
else
|
|
15
|
+
return null; // won't get here typically because attempting to access the global object will throw an exception if it doesn't exist
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
try {
|
|
20
|
+
// if we get here, we don't have a window object, so try the global object (node environment)
|
|
21
|
+
if (global)
|
|
22
|
+
return global;
|
|
23
|
+
else
|
|
24
|
+
return null; // won't get here typically because attempting to access the global object will throw an exception if it doesn't exist
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
// if we get here, we don't have a global object either, so we're not running in a browser or node, so we're probably running in a unit test
|
|
28
|
+
// in that case, we don't have a provider saved, return null, we need to be either in node or a browser
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.GetGlobalObjectStore = GetGlobalObjectStore;
|
|
34
|
+
//# sourceMappingURL=util.js.map
|
package/dist/util.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB;IAChC,IAAO;QACH,gGAAgG;QAChG,IAAI,MAAM;YACN,OAAO,MAAM,CAAC;aACb;YACD,8FAA8F;YAC9F,sHAAsH;YACtH,IAAI,MAAM;gBACN,OAAO,MAAM,CAAC;;gBAEd,OAAO,IAAI,CAAC,CAAC,sHAAsH;SAC1I;KACJ;IACD,OAAO,CAAC,EAAE;QACN,IAAI;YACA,6FAA6F;YAC7F,IAAI,MAAM;gBACN,OAAO,MAAM,CAAC;;gBAEd,OAAO,IAAI,CAAC,CAAC,sHAAsH;SAC1I;QACD,OAAO,CAAC,EAAE;YACN,4IAA4I;YAC5I,uGAAuG;YACvG,OAAO,IAAI,CAAC;SACf;KACJ;AACL,CAAC;AA5BD,oDA4BC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@memberjunction/global",
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "MemberJunction: Global Object - Needed for ALL other MJ components",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"/dist"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "ts-node-dev src/index.ts",
|
|
12
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
|
+
},
|
|
14
|
+
"author": "MemberJunction.com",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"ts-node-dev": "^2.0.0",
|
|
18
|
+
"typescript": "^5.0.3"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"rxjs": "^7.8.1"
|
|
22
|
+
}
|
|
23
|
+
}
|