joopjs 2.0.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/CHANGELOG.md +678 -0
- package/README.md +583 -0
- package/dist/a11y.service-C-DQQfgO.d.mts +143 -0
- package/dist/a11y.service-CauEJrJe.d.ts +143 -0
- package/dist/adapters-B6slG6hQ.d.mts +84 -0
- package/dist/adapters-B6slG6hQ.d.ts +84 -0
- package/dist/aes.service-CkoupAww.d.mts +95 -0
- package/dist/aes.service-CkoupAww.d.ts +95 -0
- package/dist/ai/index.d.mts +99 -0
- package/dist/ai/index.d.ts +99 -0
- package/dist/ai/index.js +307 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/index.mjs +304 -0
- package/dist/ai/index.mjs.map +1 -0
- package/dist/analytics/index.d.mts +42 -0
- package/dist/analytics/index.d.ts +42 -0
- package/dist/analytics/index.js +139 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics/index.mjs +136 -0
- package/dist/analytics/index.mjs.map +1 -0
- package/dist/angular/index.d.mts +148 -0
- package/dist/angular/index.d.ts +148 -0
- package/dist/angular/index.js +122 -0
- package/dist/angular/index.js.map +1 -0
- package/dist/angular/index.mjs +101 -0
- package/dist/angular/index.mjs.map +1 -0
- package/dist/api/index.d.mts +128 -0
- package/dist/api/index.d.ts +128 -0
- package/dist/api/index.js +1358 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/index.mjs +1332 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/auth/index.d.mts +105 -0
- package/dist/auth/index.d.ts +105 -0
- package/dist/auth/index.js +989 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/index.mjs +979 -0
- package/dist/auth/index.mjs.map +1 -0
- package/dist/auth.service-DNVB-L4U.d.mts +16 -0
- package/dist/auth.service-PjUUSUIt.d.ts +16 -0
- package/dist/banking/index.d.mts +1530 -0
- package/dist/banking/index.d.ts +1530 -0
- package/dist/banking/index.js +4739 -0
- package/dist/banking/index.js.map +1 -0
- package/dist/banking/index.mjs +4661 -0
- package/dist/banking/index.mjs.map +1 -0
- package/dist/cache/index.d.mts +40 -0
- package/dist/cache/index.d.ts +40 -0
- package/dist/cache/index.js +174 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/index.mjs +172 -0
- package/dist/cache/index.mjs.map +1 -0
- package/dist/client-profile.service-BuPeXVp5.d.mts +28 -0
- package/dist/client-profile.service-D5bRRYQp.d.ts +28 -0
- package/dist/config.models-Cqg04fAQ.d.mts +84 -0
- package/dist/config.models-Cqg04fAQ.d.ts +84 -0
- package/dist/config.service-CrCvI-JS.d.ts +31 -0
- package/dist/config.service-Cz4QQLlf.d.mts +31 -0
- package/dist/core/index.d.mts +4 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +631 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/index.mjs +619 -0
- package/dist/core/index.mjs.map +1 -0
- package/dist/crypto-utils-DriNhLdx.d.mts +30 -0
- package/dist/crypto-utils-DriNhLdx.d.ts +30 -0
- package/dist/data-storage.service-DT6xaTxE.d.ts +51 -0
- package/dist/data-storage.service-LvhGRCmw.d.mts +51 -0
- package/dist/deeplink/index.d.mts +39 -0
- package/dist/deeplink/index.d.ts +39 -0
- package/dist/deeplink/index.js +268 -0
- package/dist/deeplink/index.js.map +1 -0
- package/dist/deeplink/index.mjs +265 -0
- package/dist/deeplink/index.mjs.map +1 -0
- package/dist/deeplink.service-Ctd5u243.d.mts +35 -0
- package/dist/deeplink.service-uUuTnY9_.d.ts +35 -0
- package/dist/dev/index.d.mts +20 -0
- package/dist/dev/index.d.ts +20 -0
- package/dist/dev/index.js +51 -0
- package/dist/dev/index.js.map +1 -0
- package/dist/dev/index.mjs +49 -0
- package/dist/dev/index.mjs.map +1 -0
- package/dist/device/index.d.mts +108 -0
- package/dist/device/index.d.ts +108 -0
- package/dist/device/index.js +960 -0
- package/dist/device/index.js.map +1 -0
- package/dist/device/index.mjs +951 -0
- package/dist/device/index.mjs.map +1 -0
- package/dist/differential-privacy-BcAv1G80.d.mts +210 -0
- package/dist/differential-privacy-C8mAUjZr.d.ts +210 -0
- package/dist/encryption/index.d.mts +75 -0
- package/dist/encryption/index.d.ts +75 -0
- package/dist/encryption/index.js +605 -0
- package/dist/encryption/index.js.map +1 -0
- package/dist/encryption/index.mjs +598 -0
- package/dist/encryption/index.mjs.map +1 -0
- package/dist/form-validator-3tkmzr_o.d.mts +72 -0
- package/dist/form-validator-3tkmzr_o.d.ts +72 -0
- package/dist/forms/index.d.mts +59 -0
- package/dist/forms/index.d.ts +59 -0
- package/dist/forms/index.js +446 -0
- package/dist/forms/index.js.map +1 -0
- package/dist/forms/index.mjs +442 -0
- package/dist/forms/index.mjs.map +1 -0
- package/dist/i18n/index.d.mts +37 -0
- package/dist/i18n/index.d.ts +37 -0
- package/dist/i18n/index.js +147 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/index.mjs +145 -0
- package/dist/i18n/index.mjs.map +1 -0
- package/dist/idempotency.service-_6LqhivP.d.mts +372 -0
- package/dist/idempotency.service-eOKoISRD.d.ts +372 -0
- package/dist/index-B_ksKpS1.d.mts +202 -0
- package/dist/index-CqDKWTUP.d.mts +28 -0
- package/dist/index-CqDKWTUP.d.ts +28 -0
- package/dist/index-DFqEoX_l.d.ts +202 -0
- package/dist/index-Dz0gOur2.d.mts +36 -0
- package/dist/index-Dz0gOur2.d.ts +36 -0
- package/dist/index.d.mts +1336 -0
- package/dist/index.d.ts +1336 -0
- package/dist/index.js +19464 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +19155 -0
- package/dist/index.mjs.map +1 -0
- package/dist/india/index.d.mts +75 -0
- package/dist/india/index.d.ts +75 -0
- package/dist/india/index.js +325 -0
- package/dist/india/index.js.map +1 -0
- package/dist/india/index.mjs +303 -0
- package/dist/india/index.mjs.map +1 -0
- package/dist/joop-Bx7Iwj5p.d.mts +155 -0
- package/dist/joop-CA3DMeOO.d.ts +155 -0
- package/dist/native-bridge/index.d.mts +27 -0
- package/dist/native-bridge/index.d.ts +27 -0
- package/dist/native-bridge/index.js +98 -0
- package/dist/native-bridge/index.js.map +1 -0
- package/dist/native-bridge/index.mjs +96 -0
- package/dist/native-bridge/index.mjs.map +1 -0
- package/dist/network/index.d.mts +85 -0
- package/dist/network/index.d.ts +85 -0
- package/dist/network/index.js +454 -0
- package/dist/network/index.js.map +1 -0
- package/dist/network/index.mjs +451 -0
- package/dist/network/index.mjs.map +1 -0
- package/dist/network-monitor-BIwPSXme.d.mts +179 -0
- package/dist/network-monitor-Bqp2hvZr.d.ts +179 -0
- package/dist/notification.service-Dm4fvfZf.d.mts +25 -0
- package/dist/notification.service-tEMKatWJ.d.ts +25 -0
- package/dist/observability/index.d.mts +179 -0
- package/dist/observability/index.d.ts +179 -0
- package/dist/observability/index.js +559 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/index.mjs +552 -0
- package/dist/observability/index.mjs.map +1 -0
- package/dist/oidc-client-DIJcClmB.d.mts +190 -0
- package/dist/oidc-client-DxhyE59t.d.ts +190 -0
- package/dist/platform/index.d.mts +73 -0
- package/dist/platform/index.d.ts +73 -0
- package/dist/platform/index.js +127 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/index.mjs +125 -0
- package/dist/platform/index.mjs.map +1 -0
- package/dist/pwa/index.d.mts +31 -0
- package/dist/pwa/index.d.ts +31 -0
- package/dist/pwa/index.js +247 -0
- package/dist/pwa/index.js.map +1 -0
- package/dist/pwa/index.mjs +244 -0
- package/dist/pwa/index.mjs.map +1 -0
- package/dist/react/index.d.mts +133 -0
- package/dist/react/index.d.ts +133 -0
- package/dist/react/index.js +632 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +630 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/router/index.d.mts +39 -0
- package/dist/router/index.d.ts +39 -0
- package/dist/router/index.js +168 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/index.mjs +166 -0
- package/dist/router/index.mjs.map +1 -0
- package/dist/security/index.d.mts +206 -0
- package/dist/security/index.d.ts +206 -0
- package/dist/security/index.js +1297 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/index.mjs +1285 -0
- package/dist/security/index.mjs.map +1 -0
- package/dist/session/index.d.mts +115 -0
- package/dist/session/index.d.ts +115 -0
- package/dist/session/index.js +297 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/index.mjs +292 -0
- package/dist/session/index.mjs.map +1 -0
- package/dist/state/index.d.mts +43 -0
- package/dist/state/index.d.ts +43 -0
- package/dist/state/index.js +156 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/index.mjs +152 -0
- package/dist/state/index.mjs.map +1 -0
- package/dist/statement-parser-BHQtXwCM.d.ts +260 -0
- package/dist/statement-parser-C2qNmb49.d.mts +260 -0
- package/dist/storage/index.d.mts +40 -0
- package/dist/storage/index.d.ts +40 -0
- package/dist/storage/index.js +256 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/index.mjs +252 -0
- package/dist/storage/index.mjs.map +1 -0
- package/dist/sync/index.d.mts +69 -0
- package/dist/sync/index.d.ts +69 -0
- package/dist/sync/index.js +330 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/index.mjs +323 -0
- package/dist/sync/index.mjs.map +1 -0
- package/dist/sync-engine-DCIMRG5s.d.ts +61 -0
- package/dist/sync-engine-DZqyKHkK.d.mts +61 -0
- package/dist/theme/index.d.mts +53 -0
- package/dist/theme/index.d.ts +53 -0
- package/dist/theme/index.js +169 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/index.mjs +167 -0
- package/dist/theme/index.mjs.map +1 -0
- package/dist/ui/index.d.mts +66 -0
- package/dist/ui/index.d.ts +66 -0
- package/dist/ui/index.js +811 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/index.mjs +803 -0
- package/dist/ui/index.mjs.map +1 -0
- package/dist/utilities/index.d.mts +199 -0
- package/dist/utilities/index.d.ts +199 -0
- package/dist/utilities/index.js +1991 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/index.mjs +1923 -0
- package/dist/utilities/index.mjs.map +1 -0
- package/dist/validation/index.d.mts +60 -0
- package/dist/validation/index.d.ts +60 -0
- package/dist/validation/index.js +460 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/index.mjs +455 -0
- package/dist/validation/index.mjs.map +1 -0
- package/dist/vue/index.d.mts +135 -0
- package/dist/vue/index.d.ts +135 -0
- package/dist/vue/index.js +621 -0
- package/dist/vue/index.js.map +1 -0
- package/dist/vue/index.mjs +619 -0
- package/dist/vue/index.mjs.map +1 -0
- package/dist/watermark.service-Detur5tq.d.ts +235 -0
- package/dist/watermark.service-QNegMeQZ.d.mts +235 -0
- package/dist/workers/index.d.mts +42 -0
- package/dist/workers/index.d.ts +42 -0
- package/dist/workers/index.js +359 -0
- package/dist/workers/index.js.map +1 -0
- package/dist/workers/index.mjs +356 -0
- package/dist/workers/index.mjs.map +1 -0
- package/dist/workflow/index.d.mts +99 -0
- package/dist/workflow/index.d.ts +99 -0
- package/dist/workflow/index.js +282 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/index.mjs +279 -0
- package/dist/workflow/index.mjs.map +1 -0
- package/package.json +226 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// src/events/index.ts
|
|
2
|
+
var JoopSubject = class {
|
|
3
|
+
_listeners = [];
|
|
4
|
+
subscribe(listener) {
|
|
5
|
+
this._listeners.push(listener);
|
|
6
|
+
return () => {
|
|
7
|
+
this._listeners = this._listeners.filter((l) => l !== listener);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
next(value) {
|
|
11
|
+
for (const listener of this._listeners) {
|
|
12
|
+
listener(value);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
asObservable() {
|
|
16
|
+
return new JoopObservable((listener) => this.subscribe(listener));
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var JoopObservable = class {
|
|
20
|
+
constructor(_subscribeFn) {
|
|
21
|
+
this._subscribeFn = _subscribeFn;
|
|
22
|
+
}
|
|
23
|
+
_subscribeFn;
|
|
24
|
+
subscribe(listener) {
|
|
25
|
+
return this._subscribeFn(listener);
|
|
26
|
+
}
|
|
27
|
+
/** Returns the current value without subscribing (only meaningful for BehaviorSubject-backed observables). */
|
|
28
|
+
getOnce() {
|
|
29
|
+
let result;
|
|
30
|
+
const unsub = this.subscribe((v) => {
|
|
31
|
+
result = v;
|
|
32
|
+
});
|
|
33
|
+
unsub();
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/analytics/analytics.service.ts
|
|
39
|
+
var JoopAnalyticsService = class {
|
|
40
|
+
_adapters = [];
|
|
41
|
+
_context = {};
|
|
42
|
+
_userId = "";
|
|
43
|
+
_sessionId = "";
|
|
44
|
+
_event$ = new JoopSubject();
|
|
45
|
+
_queue = [];
|
|
46
|
+
_enabled = true;
|
|
47
|
+
addAdapter(adapter) {
|
|
48
|
+
if (!this._adapters.find((a) => a.name === adapter.name)) {
|
|
49
|
+
this._adapters.push(adapter);
|
|
50
|
+
for (const ev of this._queue) adapter.track?.(ev);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
removeAdapter(name) {
|
|
54
|
+
this._adapters = this._adapters.filter((a) => a.name !== name);
|
|
55
|
+
}
|
|
56
|
+
enable() {
|
|
57
|
+
this._enabled = true;
|
|
58
|
+
}
|
|
59
|
+
disable() {
|
|
60
|
+
this._enabled = false;
|
|
61
|
+
}
|
|
62
|
+
setContext(ctx) {
|
|
63
|
+
this._context = { ...this._context, ...ctx };
|
|
64
|
+
}
|
|
65
|
+
setUser(userId, traits) {
|
|
66
|
+
this._userId = userId;
|
|
67
|
+
this._adapters.forEach((a) => a.identify?.(userId, traits));
|
|
68
|
+
}
|
|
69
|
+
setSession(sessionId) {
|
|
70
|
+
this._sessionId = sessionId;
|
|
71
|
+
}
|
|
72
|
+
track(name, properties) {
|
|
73
|
+
if (!this._enabled) return;
|
|
74
|
+
const event = {
|
|
75
|
+
name,
|
|
76
|
+
properties: { ...this._context, ...properties },
|
|
77
|
+
timestamp: Date.now(),
|
|
78
|
+
userId: this._userId || void 0,
|
|
79
|
+
sessionId: this._sessionId || void 0
|
|
80
|
+
};
|
|
81
|
+
this._event$.next(event);
|
|
82
|
+
if (this._adapters.length === 0) {
|
|
83
|
+
this._queue.push(event);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this._adapters.forEach((a) => {
|
|
87
|
+
try {
|
|
88
|
+
a.track?.(event);
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
page(name, properties) {
|
|
94
|
+
if (!this._enabled) return;
|
|
95
|
+
const merged = { ...this._context, ...properties };
|
|
96
|
+
this._adapters.forEach((a) => {
|
|
97
|
+
try {
|
|
98
|
+
a.page?.(name, merged);
|
|
99
|
+
} catch {
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
this.track(`page:${name}`, merged);
|
|
103
|
+
}
|
|
104
|
+
identify(userId, traits) {
|
|
105
|
+
this.setUser(userId, traits);
|
|
106
|
+
}
|
|
107
|
+
/** Subscribe to all tracked events (useful for debugging) */
|
|
108
|
+
events$() {
|
|
109
|
+
return this._event$.asObservable();
|
|
110
|
+
}
|
|
111
|
+
/** Flush the pre-adapter queue (e.g. after lazy-loading analytics) */
|
|
112
|
+
flush() {
|
|
113
|
+
for (const ev of this._queue) {
|
|
114
|
+
this._adapters.forEach((a) => {
|
|
115
|
+
try {
|
|
116
|
+
a.track?.(ev);
|
|
117
|
+
} catch {
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
this._queue = [];
|
|
122
|
+
}
|
|
123
|
+
getQueueSize() {
|
|
124
|
+
return this._queue.length;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
var consoleAnalyticsAdapter = {
|
|
128
|
+
name: "console",
|
|
129
|
+
track: (e) => console.log(`[analytics:track] ${e.name}`, e.properties),
|
|
130
|
+
page: (name) => console.log(`[analytics:page] ${name}`),
|
|
131
|
+
identify: (id) => console.log(`[analytics:identify] ${id}`)
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export { JoopAnalyticsService, consoleAnalyticsAdapter };
|
|
135
|
+
//# sourceMappingURL=index.mjs.map
|
|
136
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/events/index.ts","../../src/analytics/analytics.service.ts"],"names":[],"mappings":";AAOO,IAAM,cAAN,MAAqB;AAAA,EAClB,aAA4B,EAAC;AAAA,EAErC,UAAU,QAAA,EAAoC;AAC5C,IAAA,IAAA,CAAK,UAAA,CAAW,KAAK,QAAQ,CAAA;AAC7B,IAAA,OAAO,MAAM;AACX,MAAA,IAAA,CAAK,aAAa,IAAA,CAAK,UAAA,CAAW,MAAA,CAAO,CAAA,CAAA,KAAK,MAAM,QAAQ,CAAA;AAAA,IAC9D,CAAA;AAAA,EACF;AAAA,EAEA,KAAK,KAAA,EAAgB;AACnB,IAAA,KAAA,MAAW,QAAA,IAAY,KAAK,UAAA,EAAY;AACtC,MAAA,QAAA,CAAS,KAAK,CAAA;AAAA,IAChB;AAAA,EACF;AAAA,EAEA,YAAA,GAAkC;AAChC,IAAA,OAAO,IAAI,cAAA,CAAkB,CAAA,QAAA,KAAY,IAAA,CAAK,SAAA,CAAU,QAAQ,CAAC,CAAA;AAAA,EACnE;AACF,CAAA;AAoCO,IAAM,iBAAN,MAAwB;AAAA,EAC7B,YAAoB,YAAA,EAAsD;AAAtD,IAAA,IAAA,CAAA,YAAA,GAAA,YAAA;AAAA,EAAuD;AAAA,EAAvD,YAAA;AAAA,EAEpB,UAAU,QAAA,EAAoC;AAC5C,IAAA,OAAO,IAAA,CAAK,aAAa,QAAQ,CAAA;AAAA,EACnC;AAAA;AAAA,EAGA,OA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AAU,CAAC,EAAA,KAAO,QAAQ,GAAA,CAAI,CAAA,qBAAA,EAAwB,EAAE,CAAA,CAAE;AAC5D","file":"index.mjs","sourcesContent":["export type Unsubscribe = () => void;\nexport type Listener<T> = (value: T) => void;\n\n/**\n * Lightweight pub/sub subject — emits to all current subscribers.\n * Replaces RxJS Subject without pulling in the full RxJS dependency.\n */\nexport class JoopSubject<T> {\n private _listeners: Listener<T>[] = [];\n\n subscribe(listener: Listener<T>): Unsubscribe {\n this._listeners.push(listener);\n return () => {\n this._listeners = this._listeners.filter(l => l !== listener);\n };\n }\n\n next(value: T): void {\n for (const listener of this._listeners) {\n listener(value);\n }\n }\n\n asObservable(): JoopObservable<T> {\n return new JoopObservable<T>(listener => this.subscribe(listener));\n }\n}\n\n/**\n * Stateful subject — replays the current value to any new subscriber immediately.\n * Replaces RxJS BehaviorSubject.\n */\nexport class JoopBehaviorSubject<T> extends JoopSubject<T> {\n private _value: T;\n\n constructor(initialValue: T) {\n super();\n this._value = initialValue;\n }\n\n getValue(): T {\n return this._value;\n }\n\n override next(value: T): void {\n this._value = value;\n super.next(value);\n }\n\n override subscribe(listener: Listener<T>): Unsubscribe {\n listener(this._value);\n return super.subscribe(listener);\n }\n\n override asObservable(): JoopObservable<T> {\n return new JoopObservable<T>(listener => this.subscribe(listener));\n }\n}\n\n/**\n * Read-only observable handle returned from asObservable().\n */\nexport class JoopObservable<T> {\n constructor(private _subscribeFn: (listener: Listener<T>) => Unsubscribe) {}\n\n subscribe(listener: Listener<T>): Unsubscribe {\n return this._subscribeFn(listener);\n }\n\n /** Returns the current value without subscribing (only meaningful for BehaviorSubject-backed observables). */\n getOnce(): T | undefined {\n let result: T | undefined;\n const unsub = this.subscribe(v => { result = v; });\n unsub();\n return result;\n }\n}\n","import { JoopSubject } from '../events';\n\nexport interface JoopAnalyticsEvent {\n name: string;\n properties?: Record<string, unknown>;\n timestamp: number;\n sessionId?: string;\n userId?: string;\n}\n\nexport interface JoopAnalyticsAdapter {\n name: string;\n track?(event: JoopAnalyticsEvent): void;\n page?(name: string, properties?: Record<string, unknown>): void;\n identify?(userId: string, traits?: Record<string, unknown>): void;\n}\n\nexport class JoopAnalyticsService {\n private _adapters: JoopAnalyticsAdapter[] = [];\n private _context: Record<string, unknown> = {};\n private _userId = '';\n private _sessionId = '';\n private _event$ = new JoopSubject<JoopAnalyticsEvent>();\n private _queue: JoopAnalyticsEvent[] = [];\n private _enabled = true;\n\n addAdapter(adapter: JoopAnalyticsAdapter): void {\n if (!this._adapters.find(a => a.name === adapter.name)) {\n this._adapters.push(adapter);\n // drain queued events to new adapter\n for (const ev of this._queue) adapter.track?.(ev);\n }\n }\n\n removeAdapter(name: string): void {\n this._adapters = this._adapters.filter(a => a.name !== name);\n }\n\n enable(): void { this._enabled = true; }\n disable(): void { this._enabled = false; }\n\n setContext(ctx: Record<string, unknown>): void {\n this._context = { ...this._context, ...ctx };\n }\n\n setUser(userId: string, traits?: Record<string, unknown>): void {\n this._userId = userId;\n this._adapters.forEach(a => a.identify?.(userId, traits));\n }\n\n setSession(sessionId: string): void { this._sessionId = sessionId; }\n\n track(name: string, properties?: Record<string, unknown>): void {\n if (!this._enabled) return;\n const event: JoopAnalyticsEvent = {\n name,\n properties: { ...this._context, ...properties },\n timestamp: Date.now(),\n userId: this._userId || undefined,\n sessionId: this._sessionId || undefined,\n };\n this._event$.next(event);\n if (this._adapters.length === 0) { this._queue.push(event); return; }\n this._adapters.forEach(a => { try { a.track?.(event); } catch { /* isolate adapter errors */ } });\n }\n\n page(name: string, properties?: Record<string, unknown>): void {\n if (!this._enabled) return;\n const merged = { ...this._context, ...properties };\n this._adapters.forEach(a => { try { a.page?.(name, merged); } catch { /* */ } });\n this.track(`page:${name}`, merged);\n }\n\n identify(userId: string, traits?: Record<string, unknown>): void {\n this.setUser(userId, traits);\n }\n\n /** Subscribe to all tracked events (useful for debugging) */\n events$() { return this._event$.asObservable(); }\n\n /** Flush the pre-adapter queue (e.g. after lazy-loading analytics) */\n flush(): void {\n for (const ev of this._queue) {\n this._adapters.forEach(a => { try { a.track?.(ev); } catch { /* */ } });\n }\n this._queue = [];\n }\n\n getQueueSize(): number { return this._queue.length; }\n}\n\n// ── Built-in console adapter (for development) ────────────────────────────\nexport const consoleAnalyticsAdapter: JoopAnalyticsAdapter = {\n name: 'console',\n track: (e) => console.log(`[analytics:track] ${e.name}`, e.properties),\n page: (name) => console.log(`[analytics:page] ${name}`),\n identify: (id) => console.log(`[analytics:identify] ${id}`),\n};\n"]}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { J as JoopInstance } from '../joop-Bx7Iwj5p.mjs';
|
|
2
|
+
import { J as JoopObservable } from '../index-Dz0gOur2.mjs';
|
|
3
|
+
import '../config.service-Cz4QQLlf.mjs';
|
|
4
|
+
import '../config.models-Cqg04fAQ.mjs';
|
|
5
|
+
import '../index-B_ksKpS1.mjs';
|
|
6
|
+
import '../data-storage.service-LvhGRCmw.mjs';
|
|
7
|
+
import '../index-CqDKWTUP.mjs';
|
|
8
|
+
import '../auth.service-DNVB-L4U.mjs';
|
|
9
|
+
import '../oidc-client-DIJcClmB.mjs';
|
|
10
|
+
import '../adapters-B6slG6hQ.mjs';
|
|
11
|
+
import '../client-profile.service-BuPeXVp5.mjs';
|
|
12
|
+
import '../idempotency.service-_6LqhivP.mjs';
|
|
13
|
+
import '../aes.service-CkoupAww.mjs';
|
|
14
|
+
import '../encryption/index.mjs';
|
|
15
|
+
import '../crypto-utils-DriNhLdx.mjs';
|
|
16
|
+
import '../session/index.mjs';
|
|
17
|
+
import '../observability/index.mjs';
|
|
18
|
+
import '../network-monitor-BIwPSXme.mjs';
|
|
19
|
+
import '../dev/index.mjs';
|
|
20
|
+
import '../statement-parser-C2qNmb49.mjs';
|
|
21
|
+
import '../theme/index.mjs';
|
|
22
|
+
import '../i18n/index.mjs';
|
|
23
|
+
import '../a11y.service-C-DQQfgO.mjs';
|
|
24
|
+
import '../native-bridge/index.mjs';
|
|
25
|
+
import '../deeplink.service-Ctd5u243.mjs';
|
|
26
|
+
import '../cache/index.mjs';
|
|
27
|
+
import '../network/index.mjs';
|
|
28
|
+
import '../analytics/index.mjs';
|
|
29
|
+
import '../form-validator-3tkmzr_o.mjs';
|
|
30
|
+
import '../watermark.service-QNegMeQZ.mjs';
|
|
31
|
+
import '../storage/index.mjs';
|
|
32
|
+
import '../forms/index.mjs';
|
|
33
|
+
import '../notification.service-Dm4fvfZf.mjs';
|
|
34
|
+
import '../router/index.mjs';
|
|
35
|
+
import '../pwa/index.mjs';
|
|
36
|
+
import '../ai/index.mjs';
|
|
37
|
+
import '../differential-privacy-BcAv1G80.mjs';
|
|
38
|
+
import '../workers/index.mjs';
|
|
39
|
+
import '../state/index.mjs';
|
|
40
|
+
import '../sync-engine-DZqyKHkK.mjs';
|
|
41
|
+
import '../workflow/index.mjs';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* joopjs/angular — Angular integration
|
|
45
|
+
*
|
|
46
|
+
* @angular/core 17+ is a required peer dependency.
|
|
47
|
+
*
|
|
48
|
+
* Standalone (recommended):
|
|
49
|
+
* bootstrapApplication(AppComponent, {
|
|
50
|
+
* providers: [provideJoop(joopInstance)]
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* NgModule (legacy):
|
|
54
|
+
* @NgModule({ imports: [JoopModule.forRoot(joopInstance)] })
|
|
55
|
+
*
|
|
56
|
+
* Inject anywhere:
|
|
57
|
+
* constructor(@Inject(JOOP) private joop: JoopInstance) {}
|
|
58
|
+
*
|
|
59
|
+
* RxJS bridge:
|
|
60
|
+
* readonly theme$ = fromJoop(this.joop.theme.active$());
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* InjectionToken for the JoopInstance.
|
|
65
|
+
* Angular's DI accepts any object as a token — use this with @Inject(JOOP).
|
|
66
|
+
*
|
|
67
|
+
* Example with @angular/core InjectionToken (recommended):
|
|
68
|
+
* import { InjectionToken } from '@angular/core';
|
|
69
|
+
* const JOOP = new InjectionToken<JoopInstance>('JoopInstance');
|
|
70
|
+
*
|
|
71
|
+
* The string form below works for both class-based and object-literal tokens.
|
|
72
|
+
*/
|
|
73
|
+
declare const JOOP: "JOOP_INSTANCE";
|
|
74
|
+
declare const JOOP_AUTH: "JOOP_AUTH";
|
|
75
|
+
declare const JOOP_THEME: "JOOP_THEME";
|
|
76
|
+
declare const JOOP_I18N: "JOOP_I18N";
|
|
77
|
+
declare const JOOP_HTTP: "JOOP_HTTP";
|
|
78
|
+
declare const JOOP_LOADER: "JOOP_LOADER";
|
|
79
|
+
declare const JOOP_ALERT: "JOOP_ALERT";
|
|
80
|
+
declare const JOOP_ROUTER: "JOOP_ROUTER";
|
|
81
|
+
declare const JOOP_ANALYTICS: "JOOP_ANALYTICS";
|
|
82
|
+
declare const JOOP_FEATURE_FLAGS: "JOOP_FEATURE_FLAGS";
|
|
83
|
+
declare const JOOP_AUDIT_LOG: "JOOP_AUDIT_LOG";
|
|
84
|
+
declare const JOOP_STORE: "JOOP_STORE";
|
|
85
|
+
declare const JOOP_KEY_VAULT: "JOOP_KEY_VAULT";
|
|
86
|
+
declare const JOOP_NETWORK: "JOOP_NETWORK";
|
|
87
|
+
declare const JOOP_LIFECYCLE: "JOOP_LIFECYCLE";
|
|
88
|
+
interface JoopProvider {
|
|
89
|
+
provide: string;
|
|
90
|
+
useValue: unknown;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns an array of Angular providers for the JoopInstance and its services.
|
|
94
|
+
* Use with bootstrapApplication() or provideEnvironmentInitializer().
|
|
95
|
+
*
|
|
96
|
+
* providers: [...provideJoop(await createJoop(config))]
|
|
97
|
+
*/
|
|
98
|
+
declare function provideJoop(instance: JoopInstance): JoopProvider[];
|
|
99
|
+
/**
|
|
100
|
+
* Minimal NgModule descriptor for use with @NgModule imports.
|
|
101
|
+
* Call JoopModule.forRoot(instance) and spread the result into the imports array.
|
|
102
|
+
*
|
|
103
|
+
* @NgModule({ imports: [...JoopModule.forRoot(instance).providers ?? []] })
|
|
104
|
+
*
|
|
105
|
+
* For proper Angular NgModule integration, use the returned providers array
|
|
106
|
+
* directly in your app's providers:
|
|
107
|
+
*
|
|
108
|
+
* @NgModule({ providers: JoopModule.forRoot(instance) })
|
|
109
|
+
*/
|
|
110
|
+
declare const JoopModule: {
|
|
111
|
+
readonly forRoot: (instance: JoopInstance) => {
|
|
112
|
+
providers: JoopProvider[];
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Converts a JoopObservable (JoopBehaviorSubject) into an RxJS-compatible
|
|
117
|
+
* Observable. The returned object implements the Observable contract:
|
|
118
|
+
* subscribe(observer) returns a Subscription with unsubscribe().
|
|
119
|
+
*
|
|
120
|
+
* readonly loading$ = fromJoop(this.joop.loader.isLoading$());
|
|
121
|
+
* readonly theme$ = fromJoop(this.joop.theme.active$());
|
|
122
|
+
*/
|
|
123
|
+
declare function fromJoop<T>(joopObs: JoopObservable<T>): RxJSLike<T>;
|
|
124
|
+
/**
|
|
125
|
+
* Converts an RxJS Observable into a JoopObservable-compatible object.
|
|
126
|
+
* Useful for bridging existing RxJS streams into JoopJS services.
|
|
127
|
+
*/
|
|
128
|
+
declare function toJoop<T>(rxjsObs: RxJSLike<T>): JoopObservable<T>;
|
|
129
|
+
interface RxJSLike<T> {
|
|
130
|
+
subscribe(observerOrNext: ((value: T) => void) | {
|
|
131
|
+
next?: (v: T) => void;
|
|
132
|
+
error?: (e: unknown) => void;
|
|
133
|
+
complete?: () => void;
|
|
134
|
+
}): {
|
|
135
|
+
unsubscribe(): void;
|
|
136
|
+
};
|
|
137
|
+
pipe(...operators: Array<(obs: RxJSLike<T>) => RxJSLike<unknown>>): RxJSLike<unknown>;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Returns a factory for wrapping JoopObservable subscriptions inside Angular's
|
|
141
|
+
* change detection zone. Pass NgZone.run as the runner.
|
|
142
|
+
*
|
|
143
|
+
* const zonedFromJoop = createZonedFromJoop(zone.run.bind(zone));
|
|
144
|
+
* readonly theme$ = zonedFromJoop(this.joop.theme.active$());
|
|
145
|
+
*/
|
|
146
|
+
declare function createZonedFromJoop(zoneRun: <T>(fn: () => T) => T): <T>(obs: JoopObservable<T>) => RxJSLike<T>;
|
|
147
|
+
|
|
148
|
+
export { JOOP, JOOP_ALERT, JOOP_ANALYTICS, JOOP_AUDIT_LOG, JOOP_AUTH, JOOP_FEATURE_FLAGS, JOOP_HTTP, JOOP_I18N, JOOP_KEY_VAULT, JOOP_LIFECYCLE, JOOP_LOADER, JOOP_NETWORK, JOOP_ROUTER, JOOP_STORE, JOOP_THEME, JoopModule, type JoopProvider, type RxJSLike, createZonedFromJoop, fromJoop, provideJoop, toJoop };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { J as JoopInstance } from '../joop-CA3DMeOO.js';
|
|
2
|
+
import { J as JoopObservable } from '../index-Dz0gOur2.js';
|
|
3
|
+
import '../config.service-CrCvI-JS.js';
|
|
4
|
+
import '../config.models-Cqg04fAQ.js';
|
|
5
|
+
import '../index-DFqEoX_l.js';
|
|
6
|
+
import '../data-storage.service-DT6xaTxE.js';
|
|
7
|
+
import '../index-CqDKWTUP.js';
|
|
8
|
+
import '../auth.service-PjUUSUIt.js';
|
|
9
|
+
import '../oidc-client-DxhyE59t.js';
|
|
10
|
+
import '../adapters-B6slG6hQ.js';
|
|
11
|
+
import '../client-profile.service-D5bRRYQp.js';
|
|
12
|
+
import '../idempotency.service-eOKoISRD.js';
|
|
13
|
+
import '../aes.service-CkoupAww.js';
|
|
14
|
+
import '../encryption/index.js';
|
|
15
|
+
import '../crypto-utils-DriNhLdx.js';
|
|
16
|
+
import '../session/index.js';
|
|
17
|
+
import '../observability/index.js';
|
|
18
|
+
import '../network-monitor-Bqp2hvZr.js';
|
|
19
|
+
import '../dev/index.js';
|
|
20
|
+
import '../statement-parser-BHQtXwCM.js';
|
|
21
|
+
import '../theme/index.js';
|
|
22
|
+
import '../i18n/index.js';
|
|
23
|
+
import '../a11y.service-CauEJrJe.js';
|
|
24
|
+
import '../native-bridge/index.js';
|
|
25
|
+
import '../deeplink.service-uUuTnY9_.js';
|
|
26
|
+
import '../cache/index.js';
|
|
27
|
+
import '../network/index.js';
|
|
28
|
+
import '../analytics/index.js';
|
|
29
|
+
import '../form-validator-3tkmzr_o.js';
|
|
30
|
+
import '../watermark.service-Detur5tq.js';
|
|
31
|
+
import '../storage/index.js';
|
|
32
|
+
import '../forms/index.js';
|
|
33
|
+
import '../notification.service-tEMKatWJ.js';
|
|
34
|
+
import '../router/index.js';
|
|
35
|
+
import '../pwa/index.js';
|
|
36
|
+
import '../ai/index.js';
|
|
37
|
+
import '../differential-privacy-C8mAUjZr.js';
|
|
38
|
+
import '../workers/index.js';
|
|
39
|
+
import '../state/index.js';
|
|
40
|
+
import '../sync-engine-DCIMRG5s.js';
|
|
41
|
+
import '../workflow/index.js';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* joopjs/angular — Angular integration
|
|
45
|
+
*
|
|
46
|
+
* @angular/core 17+ is a required peer dependency.
|
|
47
|
+
*
|
|
48
|
+
* Standalone (recommended):
|
|
49
|
+
* bootstrapApplication(AppComponent, {
|
|
50
|
+
* providers: [provideJoop(joopInstance)]
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* NgModule (legacy):
|
|
54
|
+
* @NgModule({ imports: [JoopModule.forRoot(joopInstance)] })
|
|
55
|
+
*
|
|
56
|
+
* Inject anywhere:
|
|
57
|
+
* constructor(@Inject(JOOP) private joop: JoopInstance) {}
|
|
58
|
+
*
|
|
59
|
+
* RxJS bridge:
|
|
60
|
+
* readonly theme$ = fromJoop(this.joop.theme.active$());
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* InjectionToken for the JoopInstance.
|
|
65
|
+
* Angular's DI accepts any object as a token — use this with @Inject(JOOP).
|
|
66
|
+
*
|
|
67
|
+
* Example with @angular/core InjectionToken (recommended):
|
|
68
|
+
* import { InjectionToken } from '@angular/core';
|
|
69
|
+
* const JOOP = new InjectionToken<JoopInstance>('JoopInstance');
|
|
70
|
+
*
|
|
71
|
+
* The string form below works for both class-based and object-literal tokens.
|
|
72
|
+
*/
|
|
73
|
+
declare const JOOP: "JOOP_INSTANCE";
|
|
74
|
+
declare const JOOP_AUTH: "JOOP_AUTH";
|
|
75
|
+
declare const JOOP_THEME: "JOOP_THEME";
|
|
76
|
+
declare const JOOP_I18N: "JOOP_I18N";
|
|
77
|
+
declare const JOOP_HTTP: "JOOP_HTTP";
|
|
78
|
+
declare const JOOP_LOADER: "JOOP_LOADER";
|
|
79
|
+
declare const JOOP_ALERT: "JOOP_ALERT";
|
|
80
|
+
declare const JOOP_ROUTER: "JOOP_ROUTER";
|
|
81
|
+
declare const JOOP_ANALYTICS: "JOOP_ANALYTICS";
|
|
82
|
+
declare const JOOP_FEATURE_FLAGS: "JOOP_FEATURE_FLAGS";
|
|
83
|
+
declare const JOOP_AUDIT_LOG: "JOOP_AUDIT_LOG";
|
|
84
|
+
declare const JOOP_STORE: "JOOP_STORE";
|
|
85
|
+
declare const JOOP_KEY_VAULT: "JOOP_KEY_VAULT";
|
|
86
|
+
declare const JOOP_NETWORK: "JOOP_NETWORK";
|
|
87
|
+
declare const JOOP_LIFECYCLE: "JOOP_LIFECYCLE";
|
|
88
|
+
interface JoopProvider {
|
|
89
|
+
provide: string;
|
|
90
|
+
useValue: unknown;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Returns an array of Angular providers for the JoopInstance and its services.
|
|
94
|
+
* Use with bootstrapApplication() or provideEnvironmentInitializer().
|
|
95
|
+
*
|
|
96
|
+
* providers: [...provideJoop(await createJoop(config))]
|
|
97
|
+
*/
|
|
98
|
+
declare function provideJoop(instance: JoopInstance): JoopProvider[];
|
|
99
|
+
/**
|
|
100
|
+
* Minimal NgModule descriptor for use with @NgModule imports.
|
|
101
|
+
* Call JoopModule.forRoot(instance) and spread the result into the imports array.
|
|
102
|
+
*
|
|
103
|
+
* @NgModule({ imports: [...JoopModule.forRoot(instance).providers ?? []] })
|
|
104
|
+
*
|
|
105
|
+
* For proper Angular NgModule integration, use the returned providers array
|
|
106
|
+
* directly in your app's providers:
|
|
107
|
+
*
|
|
108
|
+
* @NgModule({ providers: JoopModule.forRoot(instance) })
|
|
109
|
+
*/
|
|
110
|
+
declare const JoopModule: {
|
|
111
|
+
readonly forRoot: (instance: JoopInstance) => {
|
|
112
|
+
providers: JoopProvider[];
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Converts a JoopObservable (JoopBehaviorSubject) into an RxJS-compatible
|
|
117
|
+
* Observable. The returned object implements the Observable contract:
|
|
118
|
+
* subscribe(observer) returns a Subscription with unsubscribe().
|
|
119
|
+
*
|
|
120
|
+
* readonly loading$ = fromJoop(this.joop.loader.isLoading$());
|
|
121
|
+
* readonly theme$ = fromJoop(this.joop.theme.active$());
|
|
122
|
+
*/
|
|
123
|
+
declare function fromJoop<T>(joopObs: JoopObservable<T>): RxJSLike<T>;
|
|
124
|
+
/**
|
|
125
|
+
* Converts an RxJS Observable into a JoopObservable-compatible object.
|
|
126
|
+
* Useful for bridging existing RxJS streams into JoopJS services.
|
|
127
|
+
*/
|
|
128
|
+
declare function toJoop<T>(rxjsObs: RxJSLike<T>): JoopObservable<T>;
|
|
129
|
+
interface RxJSLike<T> {
|
|
130
|
+
subscribe(observerOrNext: ((value: T) => void) | {
|
|
131
|
+
next?: (v: T) => void;
|
|
132
|
+
error?: (e: unknown) => void;
|
|
133
|
+
complete?: () => void;
|
|
134
|
+
}): {
|
|
135
|
+
unsubscribe(): void;
|
|
136
|
+
};
|
|
137
|
+
pipe(...operators: Array<(obs: RxJSLike<T>) => RxJSLike<unknown>>): RxJSLike<unknown>;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Returns a factory for wrapping JoopObservable subscriptions inside Angular's
|
|
141
|
+
* change detection zone. Pass NgZone.run as the runner.
|
|
142
|
+
*
|
|
143
|
+
* const zonedFromJoop = createZonedFromJoop(zone.run.bind(zone));
|
|
144
|
+
* readonly theme$ = zonedFromJoop(this.joop.theme.active$());
|
|
145
|
+
*/
|
|
146
|
+
declare function createZonedFromJoop(zoneRun: <T>(fn: () => T) => T): <T>(obs: JoopObservable<T>) => RxJSLike<T>;
|
|
147
|
+
|
|
148
|
+
export { JOOP, JOOP_ALERT, JOOP_ANALYTICS, JOOP_AUDIT_LOG, JOOP_AUTH, JOOP_FEATURE_FLAGS, JOOP_HTTP, JOOP_I18N, JOOP_KEY_VAULT, JOOP_LIFECYCLE, JOOP_LOADER, JOOP_NETWORK, JOOP_ROUTER, JOOP_STORE, JOOP_THEME, JoopModule, type JoopProvider, type RxJSLike, createZonedFromJoop, fromJoop, provideJoop, toJoop };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/angular/index.ts
|
|
4
|
+
var JOOP = "JOOP_INSTANCE";
|
|
5
|
+
var JOOP_AUTH = "JOOP_AUTH";
|
|
6
|
+
var JOOP_THEME = "JOOP_THEME";
|
|
7
|
+
var JOOP_I18N = "JOOP_I18N";
|
|
8
|
+
var JOOP_HTTP = "JOOP_HTTP";
|
|
9
|
+
var JOOP_LOADER = "JOOP_LOADER";
|
|
10
|
+
var JOOP_ALERT = "JOOP_ALERT";
|
|
11
|
+
var JOOP_ROUTER = "JOOP_ROUTER";
|
|
12
|
+
var JOOP_ANALYTICS = "JOOP_ANALYTICS";
|
|
13
|
+
var JOOP_FEATURE_FLAGS = "JOOP_FEATURE_FLAGS";
|
|
14
|
+
var JOOP_AUDIT_LOG = "JOOP_AUDIT_LOG";
|
|
15
|
+
var JOOP_STORE = "JOOP_STORE";
|
|
16
|
+
var JOOP_KEY_VAULT = "JOOP_KEY_VAULT";
|
|
17
|
+
var JOOP_NETWORK = "JOOP_NETWORK";
|
|
18
|
+
var JOOP_LIFECYCLE = "JOOP_LIFECYCLE";
|
|
19
|
+
function provideJoop(instance) {
|
|
20
|
+
return [
|
|
21
|
+
{ provide: JOOP, useValue: instance },
|
|
22
|
+
{ provide: JOOP_AUTH, useValue: instance.auth },
|
|
23
|
+
{ provide: JOOP_THEME, useValue: instance.theme },
|
|
24
|
+
{ provide: JOOP_I18N, useValue: instance.i18n },
|
|
25
|
+
{ provide: JOOP_HTTP, useValue: instance.http },
|
|
26
|
+
{ provide: JOOP_LOADER, useValue: instance.loader },
|
|
27
|
+
{ provide: JOOP_ALERT, useValue: instance.alert },
|
|
28
|
+
{ provide: JOOP_ROUTER, useValue: instance.router },
|
|
29
|
+
{ provide: JOOP_ANALYTICS, useValue: instance.analytics },
|
|
30
|
+
{ provide: JOOP_FEATURE_FLAGS, useValue: instance.featureFlags },
|
|
31
|
+
{ provide: JOOP_AUDIT_LOG, useValue: instance.auditLog },
|
|
32
|
+
{ provide: JOOP_STORE, useValue: instance.store },
|
|
33
|
+
{ provide: JOOP_KEY_VAULT, useValue: instance.keyVault },
|
|
34
|
+
{ provide: JOOP_NETWORK, useValue: instance.network },
|
|
35
|
+
{ provide: JOOP_LIFECYCLE, useValue: instance.lifecycle }
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
var JoopModule = {
|
|
39
|
+
forRoot(instance) {
|
|
40
|
+
return { providers: provideJoop(instance) };
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function fromJoop(joopObs) {
|
|
44
|
+
return {
|
|
45
|
+
subscribe(observerOrNext) {
|
|
46
|
+
const next = typeof observerOrNext === "function" ? observerOrNext : observerOrNext.next?.bind(observerOrNext) ?? ((_) => {
|
|
47
|
+
});
|
|
48
|
+
const unsubscribe = joopObs.subscribe(next);
|
|
49
|
+
return { unsubscribe };
|
|
50
|
+
},
|
|
51
|
+
pipe(...operators) {
|
|
52
|
+
return operators.reduce((acc, op) => op(acc), this);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function toJoop(rxjsObs) {
|
|
57
|
+
const handlers = /* @__PURE__ */ new Set();
|
|
58
|
+
let rxSub = null;
|
|
59
|
+
return {
|
|
60
|
+
subscribe(fn) {
|
|
61
|
+
handlers.add(fn);
|
|
62
|
+
if (!rxSub) {
|
|
63
|
+
rxSub = rxjsObs.subscribe((v) => handlers.forEach((h) => h(v)));
|
|
64
|
+
}
|
|
65
|
+
return () => {
|
|
66
|
+
handlers.delete(fn);
|
|
67
|
+
if (handlers.size === 0) {
|
|
68
|
+
rxSub?.unsubscribe();
|
|
69
|
+
rxSub = null;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
pipe(transform) {
|
|
74
|
+
return toJoop({
|
|
75
|
+
subscribe: (obs) => rxjsObs.subscribe({
|
|
76
|
+
next: (v) => typeof obs === "function" ? obs(transform(v)) : obs.next?.(transform(v))
|
|
77
|
+
}),
|
|
78
|
+
pipe: () => {
|
|
79
|
+
throw new Error("pipe chaining not supported in toJoop bridge");
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function createZonedFromJoop(zoneRun) {
|
|
86
|
+
return (obs) => {
|
|
87
|
+
return {
|
|
88
|
+
subscribe(observerOrNext) {
|
|
89
|
+
const next = typeof observerOrNext === "function" ? observerOrNext : observerOrNext.next?.bind(observerOrNext) ?? ((_) => {
|
|
90
|
+
});
|
|
91
|
+
const unsubscribe = obs.subscribe((v) => zoneRun(() => next(v)));
|
|
92
|
+
return { unsubscribe };
|
|
93
|
+
},
|
|
94
|
+
pipe(...operators) {
|
|
95
|
+
return operators.reduce((acc, op) => op(acc), this);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
exports.JOOP = JOOP;
|
|
102
|
+
exports.JOOP_ALERT = JOOP_ALERT;
|
|
103
|
+
exports.JOOP_ANALYTICS = JOOP_ANALYTICS;
|
|
104
|
+
exports.JOOP_AUDIT_LOG = JOOP_AUDIT_LOG;
|
|
105
|
+
exports.JOOP_AUTH = JOOP_AUTH;
|
|
106
|
+
exports.JOOP_FEATURE_FLAGS = JOOP_FEATURE_FLAGS;
|
|
107
|
+
exports.JOOP_HTTP = JOOP_HTTP;
|
|
108
|
+
exports.JOOP_I18N = JOOP_I18N;
|
|
109
|
+
exports.JOOP_KEY_VAULT = JOOP_KEY_VAULT;
|
|
110
|
+
exports.JOOP_LIFECYCLE = JOOP_LIFECYCLE;
|
|
111
|
+
exports.JOOP_LOADER = JOOP_LOADER;
|
|
112
|
+
exports.JOOP_NETWORK = JOOP_NETWORK;
|
|
113
|
+
exports.JOOP_ROUTER = JOOP_ROUTER;
|
|
114
|
+
exports.JOOP_STORE = JOOP_STORE;
|
|
115
|
+
exports.JOOP_THEME = JOOP_THEME;
|
|
116
|
+
exports.JoopModule = JoopModule;
|
|
117
|
+
exports.createZonedFromJoop = createZonedFromJoop;
|
|
118
|
+
exports.fromJoop = fromJoop;
|
|
119
|
+
exports.provideJoop = provideJoop;
|
|
120
|
+
exports.toJoop = toJoop;
|
|
121
|
+
//# sourceMappingURL=index.js.map
|
|
122
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/angular/index.ts"],"names":[],"mappings":";;;AAmCO,IAAM,IAAA,GAAO;AACb,IAAM,SAAA,GAAqB;AAC3B,IAAM,UAAA,GAAqB;AAC3B,IAAM,SAAA,GAAqB;AAC3B,IAAM,SAAA,GAAqB;AAC3B,IAAM,WAAA,GAAqB;AAC3B,IAAM,UAAA,GAAqB;AAC3B,IAAM,WAAA,GAAqB;AAC3B,IAAM,cAAA,GAAqB;AAC3B,IAAM,kBAAA,GAAqB;AAC3B,IAAM,cAAA,GAAqB;AAC3B,IAAM,UAAA,GAAqB;AAC3B,IAAM,cAAA,GAAqB;AAC3B,IAAM,YAAA,GAAqB;AAC3B,IAAM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AA,IACA,KAAK,SAAA,EAAuD;AAC1D,MAAA,OAAO,MAAA,CAAO;AAAA,QACZ,SAAA,EAAW,CAAC,GAAA,KAAQ,OAAA,CAAQ,SAAA,CAAU;AAAA,UACpC,IAAA,EAAM,CAAC,CAAA,KAAM,OAAO,QAAQ,UAAA,GAAa,GAAA,CAAI,SAAA,CAAU,CAAC,CAAC,CAAA,GAAI,GAAA,CAAI,IAAA,GAAO,SAAA,CAAU,CAAC,CAAU;AAAA,SAC9F,CAAA;AAAA,QACD,MAAM,MAAM;AAAE,UAAA,MAAM,IAAI,MAAM,8CAA8C,CAAA;AAAA,QAAG;AAAA,OAChF,CAAA;AAAA,IACH;AAAA,GACF;AACF;AAsBO,SAAS,oBACd,OAAA,EAC4C;AAC5C,EAAA,OAAO,CAAI,GAAA,KAAwC;AACjD,IAAA,OAAO;AAAA,MACL,UAAU,cAAA,EAAgB;AACxB,QAAA,MAAM,IAAA,GACJ,OAAO,cAAA,KAAmB,UAAA,GACtB,cAAA,GACC,cAAA,CAAe,IAAA,EAAM,IAAA,CAAK,cAAc,CAAA,KAAM,CAAC,CAAA,KAAS;AAAA,QAAC,CAAA,CAAA;AAChE,QAAA,MAAM,WAAA,GAAc,IAAI,SAAA,CAAU,CAAA,CAAA,KAAK,QAAQ,MAAM,IAAA,CAAK,CAAC,CAAC,CAAC,CAAA;AAC7D,QAAA,OAAO,EAAE,WAAA,EAAY;AAAA,MACvB,CAAA;AAAA,MACA,QAAQ,SAAA,EAAW;AACjB,QAAA,OAAO,SAAA,CAAU,OAAO,CAAC,GAAA,EAAK,OAAO,EAAA,CAAG,GAAG,GAAG,IAAyB,CAAA;AAAA,MACzE;AAAA,KACF;AAAA,EACF,CAAA;AACF","file":"index.js","sourcesContent":["/**\n * joopjs/angular — Angular integration\n *\n * @angular/core 17+ is a required peer dependency.\n *\n * Standalone (recommended):\n * bootstrapApplication(AppComponent, {\n * providers: [provideJoop(joopInstance)]\n * });\n *\n * NgModule (legacy):\n * @NgModule({ imports: [JoopModule.forRoot(joopInstance)] })\n *\n * Inject anywhere:\n * constructor(@Inject(JOOP) private joop: JoopInstance) {}\n *\n * RxJS bridge:\n * readonly theme$ = fromJoop(this.joop.theme.active$());\n */\n\nimport type { JoopInstance } from '../joop';\nimport type { JoopObservable } from '../events';\n\n// ── Injection token ───────────────────────────────────────────────────────────\n\n/**\n * InjectionToken for the JoopInstance.\n * Angular's DI accepts any object as a token — use this with @Inject(JOOP).\n *\n * Example with @angular/core InjectionToken (recommended):\n * import { InjectionToken } from '@angular/core';\n * const JOOP = new InjectionToken<JoopInstance>('JoopInstance');\n *\n * The string form below works for both class-based and object-literal tokens.\n */\nexport const JOOP = 'JOOP_INSTANCE' as const;\nexport const JOOP_AUTH = 'JOOP_AUTH' as const;\nexport const JOOP_THEME = 'JOOP_THEME' as const;\nexport const JOOP_I18N = 'JOOP_I18N' as const;\nexport const JOOP_HTTP = 'JOOP_HTTP' as const;\nexport const JOOP_LOADER = 'JOOP_LOADER' as const;\nexport const JOOP_ALERT = 'JOOP_ALERT' as const;\nexport const JOOP_ROUTER = 'JOOP_ROUTER' as const;\nexport const JOOP_ANALYTICS = 'JOOP_ANALYTICS' as const;\nexport const JOOP_FEATURE_FLAGS = 'JOOP_FEATURE_FLAGS' as const;\nexport const JOOP_AUDIT_LOG = 'JOOP_AUDIT_LOG' as const;\nexport const JOOP_STORE = 'JOOP_STORE' as const;\nexport const JOOP_KEY_VAULT = 'JOOP_KEY_VAULT' as const;\nexport const JOOP_NETWORK = 'JOOP_NETWORK' as const;\nexport const JOOP_LIFECYCLE = 'JOOP_LIFECYCLE' as const;\n\n// ── Provider types ────────────────────────────────────────────────────────────\n\nexport interface JoopProvider {\n provide: string;\n useValue: unknown;\n}\n\n// ── Provider factory ──────────────────────────────────────────────────────────\n\n/**\n * Returns an array of Angular providers for the JoopInstance and its services.\n * Use with bootstrapApplication() or provideEnvironmentInitializer().\n *\n * providers: [...provideJoop(await createJoop(config))]\n */\nexport function provideJoop(instance: JoopInstance): JoopProvider[] {\n return [\n { provide: JOOP, useValue: instance },\n { provide: JOOP_AUTH, useValue: instance.auth },\n { provide: JOOP_THEME, useValue: instance.theme },\n { provide: JOOP_I18N, useValue: instance.i18n },\n { provide: JOOP_HTTP, useValue: instance.http },\n { provide: JOOP_LOADER, useValue: instance.loader },\n { provide: JOOP_ALERT, useValue: instance.alert },\n { provide: JOOP_ROUTER, useValue: instance.router },\n { provide: JOOP_ANALYTICS, useValue: instance.analytics },\n { provide: JOOP_FEATURE_FLAGS,useValue: instance.featureFlags },\n { provide: JOOP_AUDIT_LOG, useValue: instance.auditLog },\n { provide: JOOP_STORE, useValue: instance.store },\n { provide: JOOP_KEY_VAULT, useValue: instance.keyVault },\n { provide: JOOP_NETWORK, useValue: instance.network },\n { provide: JOOP_LIFECYCLE, useValue: instance.lifecycle },\n ];\n}\n\n// ── NgModule helper ───────────────────────────────────────────────────────────\n\n/**\n * Minimal NgModule descriptor for use with @NgModule imports.\n * Call JoopModule.forRoot(instance) and spread the result into the imports array.\n *\n * @NgModule({ imports: [...JoopModule.forRoot(instance).providers ?? []] })\n *\n * For proper Angular NgModule integration, use the returned providers array\n * directly in your app's providers:\n *\n * @NgModule({ providers: JoopModule.forRoot(instance) })\n */\nexport const JoopModule = {\n forRoot(instance: JoopInstance): { providers: JoopProvider[] } {\n return { providers: provideJoop(instance) };\n },\n} as const;\n\n// ── RxJS bridge ───────────────────────────────────────────────────────────────\n\n/**\n * Converts a JoopObservable (JoopBehaviorSubject) into an RxJS-compatible\n * Observable. The returned object implements the Observable contract:\n * subscribe(observer) returns a Subscription with unsubscribe().\n *\n * readonly loading$ = fromJoop(this.joop.loader.isLoading$());\n * readonly theme$ = fromJoop(this.joop.theme.active$());\n */\nexport function fromJoop<T>(joopObs: JoopObservable<T>): RxJSLike<T> {\n return {\n subscribe(\n observerOrNext:\n | ((value: T) => void)\n | { next?: (v: T) => void; error?: (e: unknown) => void; complete?: () => void },\n ): { unsubscribe(): void } {\n const next =\n typeof observerOrNext === 'function'\n ? observerOrNext\n : (observerOrNext.next?.bind(observerOrNext) ?? ((_: T) => {}));\n const unsubscribe = joopObs.subscribe(next);\n return { unsubscribe };\n },\n pipe(...operators: Array<(obs: RxJSLike<T>) => RxJSLike<unknown>>): RxJSLike<unknown> {\n return operators.reduce((acc, op) => op(acc), this as RxJSLike<unknown>);\n },\n };\n}\n\n/**\n * Converts an RxJS Observable into a JoopObservable-compatible object.\n * Useful for bridging existing RxJS streams into JoopJS services.\n */\nexport function toJoop<T>(rxjsObs: RxJSLike<T>): JoopObservable<T> {\n const handlers = new Set<(v: T) => void>();\n let rxSub: { unsubscribe(): void } | null = null;\n\n return {\n subscribe(fn: (v: T) => void): () => void {\n handlers.add(fn);\n if (!rxSub) {\n rxSub = rxjsObs.subscribe(v => handlers.forEach(h => h(v)));\n }\n return () => {\n handlers.delete(fn);\n if (handlers.size === 0) { rxSub?.unsubscribe(); rxSub = null; }\n };\n },\n pipe(transform: (v: T) => unknown): JoopObservable<unknown> {\n return toJoop({\n subscribe: (obs) => rxjsObs.subscribe({\n next: (v) => typeof obs === 'function' ? obs(transform(v)) : obs.next?.(transform(v) as never),\n }),\n pipe: () => { throw new Error('pipe chaining not supported in toJoop bridge'); },\n }) as JoopObservable<unknown>;\n },\n } as unknown as JoopObservable<T>;\n}\n\n// ── Minimal RxJS-compatible Observable type ───────────────────────────────────\n\nexport interface RxJSLike<T> {\n subscribe(\n observerOrNext:\n | ((value: T) => void)\n | { next?: (v: T) => void; error?: (e: unknown) => void; complete?: () => void },\n ): { unsubscribe(): void };\n pipe(...operators: Array<(obs: RxJSLike<T>) => RxJSLike<unknown>>): RxJSLike<unknown>;\n}\n\n// ── Change detection helper ───────────────────────────────────────────────────\n\n/**\n * Returns a factory for wrapping JoopObservable subscriptions inside Angular's\n * change detection zone. Pass NgZone.run as the runner.\n *\n * const zonedFromJoop = createZonedFromJoop(zone.run.bind(zone));\n * readonly theme$ = zonedFromJoop(this.joop.theme.active$());\n */\nexport function createZonedFromJoop(\n zoneRun: <T>(fn: () => T) => T,\n): <T>(obs: JoopObservable<T>) => RxJSLike<T> {\n return <T>(obs: JoopObservable<T>): RxJSLike<T> => {\n return {\n subscribe(observerOrNext) {\n const next =\n typeof observerOrNext === 'function'\n ? observerOrNext\n : (observerOrNext.next?.bind(observerOrNext) ?? ((_: T) => {}));\n const unsubscribe = obs.subscribe(v => zoneRun(() => next(v)));\n return { unsubscribe };\n },\n pipe(...operators) {\n return operators.reduce((acc, op) => op(acc), this as RxJSLike<unknown>);\n },\n };\n };\n}\n"]}
|