@notifizz/vanilla 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 ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function L(e,d){const n=document.head;if(document.querySelector('script[data-widget="notifizz"]')){d();return}const o=document.createElement("script");window.notifizzCallback=d,o.type="module",o.dataset.widget="notifizz",o.textContent=`(function (n, o, t, i, f) {
2
+ (n._notifizz = n._notifizz || {}),
3
+ (n._notifizz._queue = n._notifizz._queue || []),
4
+ (n.notifizz =
5
+ n.notifizz ||
6
+ function () {
7
+ let args = [];
8
+ for (i = 0; i < arguments.length; i++) args.push(arguments[i]);
9
+ n._notifizz._queue.push(args);
10
+ }),
11
+ (n._notifizz._notifizzSettings = {
12
+ apiKey: "${e.apiKey}",
13
+ loaderVersion: "1",
14
+ server: t,
15
+ apiUrl: "${e.apiUrl}"
16
+ }),
17
+ (f = o.getElementsByTagName("head")[0]);
18
+ let r = o.createElement("script");
19
+ r.type = 'module';
20
+ r.onload = n.notifizzCallback;
21
+ (r.async = !0), (r.src = t + i), f.appendChild(r);
22
+ })(window, document, "${e.serverUrl}", "${e.widgetPath}")`,n.appendChild(o)}function b(e){if(e.authType==="firebase"){window.notifizz("authenticateWithFirebase",e.token,{},()=>{});return}if(e.authType==="backendToken"){if(!e.userEmail||!e.userId)throw new Error("Missing required options: userEmail and userId are required for backendToken");window.notifizz("authenticateWithBackendToken",e.token,{user:{email:e.userEmail,id:e.userId}},()=>{})}}function k(e){["top-right","top-left","bottom-right","bottom-left"].includes(e)&&window.notifizz("setPosition",e)}function R(e){window.notifizz("setNotificationCenterStyles",e)}function I(e){window.notifizz("setBellStyles",e)}const B="https://widget.notifizz.com",O="https://eu.api.notifizz.com/v1",x="/v1/widget.js",q="notifizz-notifications";function A(e){if(!e.apiKey||!e.authType)throw new Error("Missing required options: apiKey and authType are required");const d=e.mountId??q;let n={isReady:!1,isOpen:!1,unreadCount:0,lastUpdated:0};const l=[],o=[],u=[];let a=null,s=null,w=!1,m=!1,c=!1;const z=(t,...i)=>{typeof window<"u"&&window.notifizz&&window.notifizz(t,...i)},p=()=>z("toggle"),g=()=>z("open"),E=()=>z("close"),y=()=>{p()},C=()=>({unreadCount:n.unreadCount,isOpen:n.isOpen,isReady:n.isReady,toggle:p,open:g,close:E}),v=()=>{const t=C();u.forEach(i=>i(t)),a&&a.setAttribute("data-unread",String(n.unreadCount))},U=()=>{b({apiKey:e.apiKey,token:e.token,authType:e.authType,userEmail:e.userEmail,userId:e.userId}),e.position&&k(e.position),e.notificationCenterStyles&&R(e.notificationCenterStyles),e.bellStyles&&I(e.bellStyles)},h=()=>{m||(m=!0,U(),n={...n,isReady:!0,lastUpdated:Date.now()},l.forEach(t=>t()),v())},S=t=>{const r=t.detail;r&&typeof r=="object"&&(n={...n,isReady:r.isReady??n.isReady,isOpen:r.isOpen??n.isOpen,unreadCount:typeof r.unreadCount=="number"?r.unreadCount:n.unreadCount,lastUpdated:r.lastUpdated??n.lastUpdated,hasError:r.hasError,errorCode:r.errorCode},o.forEach(_=>_(n)),v())},T=()=>{if(w||c)return;w=!0,window.addEventListener("notifizz:ready",h),window.addEventListener("notifizz:state",S);const t=e.serverUrl??B,i=e.apiUrl??O,r=e.widgetPath??x;L({apiKey:e.apiKey,serverUrl:t,apiUrl:i,widgetPath:r},()=>{typeof window.notifizz=="function"&&window.notifizz("getState",f=>{f&&typeof f=="object"&&(n={...n,...f,lastUpdated:f.lastUpdated??n.lastUpdated}),f?.isReady&&h()}),document.getElementById(d)&&U()})};return{mount(t){let i;if(t)i=t,i.id||(i.id=d);else{const r=document.getElementById(d);if(r)return s=r,T(),r;i=document.createElement("div"),i.id=d,document.body.appendChild(i)}return s=i,T(),i},getState(){return{...n}},onReady(t){return l.push(t),n.isReady&&t(),()=>{const i=l.indexOf(t);i!==-1&&l.splice(i,1)}},onStateChange(t){return o.push(t),()=>{const i=o.indexOf(t);i!==-1&&o.splice(i,1)}},onBellUpdate(t){return u.push(t),t(C()),()=>{const i=u.indexOf(t);i!==-1&&u.splice(i,1)}},open:g,close:E,toggle:p,setBellElement(t){a&&a.removeEventListener("click",y),a=t,a&&(a.addEventListener("click",y),a.setAttribute("data-unread",String(n.unreadCount)))},destroy(){c||(c=!0,window.removeEventListener("notifizz:ready",h),window.removeEventListener("notifizz:state",S),a&&(a.removeEventListener("click",y),a=null),l.length=0,o.length=0,u.length=0,s&&s.parentNode&&(s.parentNode.removeChild(s),s=null))}}}exports.createNotifizz=A;
23
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../notifizz-shared/src/scriptLoader.ts","../src/createNotifizz.ts"],"sourcesContent":["export interface NotifizzConfig {\n apiKey: string;\n apiUrl: string;\n serverUrl: string;\n widgetPath: string;\n}\n\nexport function importScriptInBrowser(\n config: NotifizzConfig,\n callback: () => void\n): void {\n const head = document.head;\n const existingScript = document.querySelector(\n 'script[data-widget=\"notifizz\"]'\n );\n if (existingScript) {\n callback();\n return;\n }\n const script = document.createElement('script');\n (window as Window & { notifizzCallback?: () => void }).notifizzCallback =\n callback;\n script.type = 'module';\n script.dataset['widget'] = 'notifizz';\n script.textContent = `(function (n, o, t, i, f) {\n (n._notifizz = n._notifizz || {}),\n (n._notifizz._queue = n._notifizz._queue || []),\n (n.notifizz =\n n.notifizz ||\n function () {\n let args = [];\n for (i = 0; i < arguments.length; i++) args.push(arguments[i]);\n n._notifizz._queue.push(args);\n }),\n (n._notifizz._notifizzSettings = {\n apiKey: \"${config.apiKey}\",\n loaderVersion: \"1\",\n server: t,\n apiUrl: \"${config.apiUrl}\"\n }),\n (f = o.getElementsByTagName(\"head\")[0]);\n let r = o.createElement(\"script\");\n r.type = 'module';\n r.onload = n.notifizzCallback;\n (r.async = !0), (r.src = t + i), f.appendChild(r);\n })(window, document, \"${config.serverUrl}\", \"${config.widgetPath}\")`;\n head.appendChild(script);\n}\n\nexport interface AuthOptions {\n apiKey: string;\n token: string;\n authType: 'firebase' | 'backendToken';\n userEmail?: string;\n userId?: string;\n}\n\nexport function authenticate(options: AuthOptions): void {\n if (options.authType === 'firebase') {\n window.notifizz('authenticateWithFirebase', options.token, {}, () => {});\n return;\n }\n if (options.authType === 'backendToken') {\n if (!options.userEmail || !options.userId) {\n throw new Error(\n 'Missing required options: userEmail and userId are required for backendToken'\n );\n }\n window.notifizz(\n 'authenticateWithBackendToken',\n options.token,\n { user: { email: options.userEmail, id: options.userId } },\n () => {}\n );\n }\n}\n\nexport function applyPosition(\n position: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'\n): void {\n const valid = ['top-right', 'top-left', 'bottom-right', 'bottom-left'];\n if (valid.includes(position)) {\n window.notifizz('setPosition', position);\n }\n}\n\nexport function applyNotificationCenterStyles(styles: {\n marginTop?: string;\n}): void {\n window.notifizz('setNotificationCenterStyles', styles);\n}\n\nexport function applyBellStyles(styles: {\n marginRight?: string;\n marginLeft?: string;\n}): void {\n window.notifizz('setBellStyles', styles);\n}\n","import type { NotifizzState, NotifizzBellContext } from '../../notifizz-shared/src/types';\nimport type { NotifizzOptions, NotifizzVanillaApi } from './types';\nimport {\n importScriptInBrowser,\n authenticate,\n applyPosition,\n applyNotificationCenterStyles,\n applyBellStyles,\n} from '../../notifizz-shared/src/scriptLoader';\n\nconst DEFAULT_SERVER_URL = 'https://widget.notifizz.com';\nconst DEFAULT_API_URL = 'https://eu.api.notifizz.com/v1';\nconst DEFAULT_WIDGET_PATH = '/v1/widget.js';\nconst DEFAULT_MOUNT_ID = 'notifizz-notifications';\n\nexport function createNotifizz(options: NotifizzOptions): NotifizzVanillaApi {\n if (!options.apiKey || !options.authType) {\n throw new Error(\n 'Missing required options: apiKey and authType are required'\n );\n }\n\n const mountId = options.mountId ?? DEFAULT_MOUNT_ID;\n let state: NotifizzState = {\n isReady: false,\n isOpen: false,\n unreadCount: 0,\n lastUpdated: 0,\n };\n const readyListeners: (() => void)[] = [];\n const stateChangeListeners: ((s: NotifizzState) => void)[] = [];\n const bellUpdateListeners: ((ctx: NotifizzBellContext) => void)[] = [];\n let bellElement: HTMLElement | null = null;\n let mountElement: HTMLElement | null = null;\n let initDone = false;\n let readyFired = false;\n let destroyed = false;\n\n const send = (command: string, ...args: unknown[]): void => {\n if (typeof window !== 'undefined' && window.notifizz) {\n window.notifizz(command, ...args);\n }\n };\n\n const toggle = (): void => send('toggle');\n const open = (): void => send('open');\n const close = (): void => send('close');\n\n const onBellClick = (): void => {\n toggle();\n };\n\n const buildBellContext = (): NotifizzBellContext => ({\n unreadCount: state.unreadCount,\n isOpen: state.isOpen,\n isReady: state.isReady,\n toggle,\n open,\n close,\n });\n\n const notifyBellListeners = (): void => {\n const ctx = buildBellContext();\n bellUpdateListeners.forEach((cb) => cb(ctx));\n if (bellElement) {\n bellElement.setAttribute('data-unread', String(state.unreadCount));\n }\n };\n\n const applyOptions = (): void => {\n authenticate({\n apiKey: options.apiKey,\n token: options.token,\n authType: options.authType,\n userEmail: options.userEmail,\n userId: options.userId,\n });\n if (options.position) applyPosition(options.position);\n if (options.notificationCenterStyles) {\n applyNotificationCenterStyles(options.notificationCenterStyles);\n }\n if (options.bellStyles) applyBellStyles(options.bellStyles);\n };\n\n const handleReady = (): void => {\n if (readyFired) return;\n readyFired = true;\n applyOptions();\n state = { ...state, isReady: true, lastUpdated: Date.now() };\n readyListeners.forEach((cb) => cb());\n notifyBellListeners();\n };\n\n const handleState = (e: Event): void => {\n const ev = e as CustomEvent<NotifizzState>;\n const detail = ev.detail;\n if (detail && typeof detail === 'object') {\n state = {\n ...state,\n isReady: detail.isReady ?? state.isReady,\n isOpen: detail.isOpen ?? state.isOpen,\n unreadCount:\n typeof detail.unreadCount === 'number'\n ? detail.unreadCount\n : state.unreadCount,\n lastUpdated: detail.lastUpdated ?? state.lastUpdated,\n hasError: detail.hasError,\n errorCode: detail.errorCode,\n };\n stateChangeListeners.forEach((cb) => cb(state));\n notifyBellListeners();\n }\n };\n\n const init = (): void => {\n if (initDone || destroyed) return;\n initDone = true;\n window.addEventListener('notifizz:ready', handleReady);\n window.addEventListener('notifizz:state', handleState);\n\n const serverUrl = options.serverUrl ?? DEFAULT_SERVER_URL;\n const apiUrl = options.apiUrl ?? DEFAULT_API_URL;\n const widgetPath = options.widgetPath ?? DEFAULT_WIDGET_PATH;\n\n importScriptInBrowser(\n { apiKey: options.apiKey, serverUrl, apiUrl, widgetPath },\n () => {\n if (typeof window.notifizz === 'function') {\n window.notifizz('getState', (current: NotifizzState) => {\n if (current && typeof current === 'object') {\n state = {\n ...state,\n ...current,\n lastUpdated: current.lastUpdated ?? state.lastUpdated,\n };\n }\n if (current?.isReady) handleReady();\n });\n }\n const el = document.getElementById(mountId);\n if (el) applyOptions();\n }\n );\n };\n\n return {\n mount(element?: HTMLElement): HTMLElement {\n let el: HTMLElement;\n if (element) {\n el = element;\n if (!el.id) el.id = mountId;\n } else {\n const existing = document.getElementById(mountId);\n if (existing) {\n mountElement = existing;\n init();\n return existing;\n }\n el = document.createElement('div');\n el.id = mountId;\n document.body.appendChild(el);\n }\n mountElement = el;\n init();\n return el;\n },\n\n getState(): NotifizzState {\n return { ...state };\n },\n\n onReady(cb: () => void): () => void {\n readyListeners.push(cb);\n if (state.isReady) cb();\n return () => {\n const i = readyListeners.indexOf(cb);\n if (i !== -1) readyListeners.splice(i, 1);\n };\n },\n\n onStateChange(cb: (s: NotifizzState) => void): () => void {\n stateChangeListeners.push(cb);\n return () => {\n const i = stateChangeListeners.indexOf(cb);\n if (i !== -1) stateChangeListeners.splice(i, 1);\n };\n },\n\n onBellUpdate(cb: (ctx: NotifizzBellContext) => void): () => void {\n bellUpdateListeners.push(cb);\n cb(buildBellContext());\n return () => {\n const i = bellUpdateListeners.indexOf(cb);\n if (i !== -1) bellUpdateListeners.splice(i, 1);\n };\n },\n\n open,\n close,\n toggle,\n\n setBellElement(el: HTMLElement | null): void {\n if (bellElement) {\n bellElement.removeEventListener('click', onBellClick);\n }\n bellElement = el;\n if (bellElement) {\n bellElement.addEventListener('click', onBellClick);\n bellElement.setAttribute('data-unread', String(state.unreadCount));\n }\n },\n\n destroy(): void {\n if (destroyed) return;\n destroyed = true;\n window.removeEventListener('notifizz:ready', handleReady);\n window.removeEventListener('notifizz:state', handleState);\n if (bellElement) {\n bellElement.removeEventListener('click', onBellClick);\n bellElement = null;\n }\n readyListeners.length = 0;\n stateChangeListeners.length = 0;\n bellUpdateListeners.length = 0;\n if (mountElement && mountElement.parentNode) {\n mountElement.parentNode.removeChild(mountElement);\n mountElement = null;\n }\n },\n };\n}\n"],"names":["importScriptInBrowser","config","callback","head","script","authenticate","options","applyPosition","position","applyNotificationCenterStyles","styles","applyBellStyles","DEFAULT_SERVER_URL","DEFAULT_API_URL","DEFAULT_WIDGET_PATH","DEFAULT_MOUNT_ID","createNotifizz","mountId","state","readyListeners","stateChangeListeners","bellUpdateListeners","bellElement","mountElement","initDone","readyFired","destroyed","send","command","args","toggle","open","close","onBellClick","buildBellContext","notifyBellListeners","ctx","cb","applyOptions","handleReady","handleState","e","detail","init","serverUrl","apiUrl","widgetPath","current","element","el","existing"],"mappings":"gFAOO,SAASA,EACdC,EACAC,EACM,CACN,MAAMC,EAAO,SAAS,KAItB,GAHuB,SAAS,cAC9B,gCAAA,EAEkB,CAClBD,EAAA,EACA,MACF,CACA,MAAME,EAAS,SAAS,cAAc,QAAQ,EAC7C,OAAsD,iBACrDF,EACFE,EAAO,KAAO,SACdA,EAAO,QAAQ,OAAY,WAC3BA,EAAO,YAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAWJH,EAAO,MAAM;AAAA;AAAA;AAAA,mBAGbA,EAAO,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAONA,EAAO,SAAS,OAAOA,EAAO,UAAU,KAChEE,EAAK,YAAYC,CAAM,CACzB,CAUO,SAASC,EAAa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rC,IAAM,IAAIjB,EAAqB,OAAO,EAAG,CAAC,CAChD,CACF,EAEA,aAAaiB,EAAoD,CAC/D,OAAAhB,EAAoB,KAAKgB,CAAE,EAC3BA,EAAGH,GAAkB,EACd,IAAM,CACX,MAAM,EAAIb,EAAoB,QAAQgB,CAAE,EACpC,IAAM,IAAIhB,EAAoB,OAAO,EAAG,CAAC,CAC/C,CACF,EAEA,KAAAU,EACA,MAAAC,EACA,OAAAF,EAEA,eAAemB,EAA8B,CACvC3B,GACFA,EAAY,oBAAoB,QAASW,CAAW,EAEtDX,EAAc2B,EACV3B,IACFA,EAAY,iBAAiB,QAASW,CAAW,EACjDX,EAAY,aAAa,cAAe,OAAOJ,EAAM,WAAW,CAAC,EAErE,EAEA,SAAgB,CACVQ,IACJA,EAAY,GACZ,OAAO,oBAAoB,iBAAkBa,CAAW,EACxD,OAAO,oBAAoB,iBAAkBC,CAAW,EACpDlB,IACFA,EAAY,oBAAoB,QAASW,CAAW,EACpDX,EAAc,MAEhBH,EAAe,OAAS,EACxBC,EAAqB,OAAS,EAC9BC,EAAoB,OAAS,EACzBE,GAAgBA,EAAa,aAC/BA,EAAa,WAAW,YAAYA,CAAY,EAChDA,EAAe,MAEnB,CAAA,CAEJ"}
@@ -0,0 +1,46 @@
1
+ import { NotifizzBellContext } from '../../notifizz-shared/src/types';
2
+ import { NotifizzPosition } from '../../notifizz-shared/src/types';
3
+ import { NotifizzState } from '../../notifizz-shared/src/types';
4
+
5
+ export declare function createNotifizz(options: NotifizzOptions): NotifizzVanillaApi;
6
+
7
+ export { NotifizzBellContext }
8
+
9
+ export declare interface NotifizzOptions {
10
+ apiKey: string;
11
+ token: string;
12
+ authType: 'firebase' | 'backendToken';
13
+ userEmail?: string;
14
+ userId?: string;
15
+ position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
16
+ notificationCenterStyles?: {
17
+ marginTop?: string;
18
+ };
19
+ bellStyles?: {
20
+ marginRight?: string;
21
+ marginLeft?: string;
22
+ };
23
+ serverUrl?: string;
24
+ apiUrl?: string;
25
+ widgetPath?: string;
26
+ mountId?: string;
27
+ }
28
+
29
+ export { NotifizzPosition }
30
+
31
+ export { NotifizzState }
32
+
33
+ export declare interface NotifizzVanillaApi {
34
+ mount(element?: HTMLElement): HTMLElement;
35
+ getState(): NotifizzState;
36
+ onReady(cb: () => void): () => void;
37
+ onStateChange(cb: (state: NotifizzState) => void): () => void;
38
+ onBellUpdate(cb: (ctx: NotifizzBellContext) => void): () => void;
39
+ open(): void;
40
+ close(): void;
41
+ toggle(): void;
42
+ setBellElement(el: HTMLElement | null): void;
43
+ destroy(): void;
44
+ }
45
+
46
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,177 @@
1
+ function T(e, d) {
2
+ const n = document.head;
3
+ if (document.querySelector(
4
+ 'script[data-widget="notifizz"]'
5
+ )) {
6
+ d();
7
+ return;
8
+ }
9
+ const o = document.createElement("script");
10
+ window.notifizzCallback = d, o.type = "module", o.dataset.widget = "notifizz", o.textContent = `(function (n, o, t, i, f) {
11
+ (n._notifizz = n._notifizz || {}),
12
+ (n._notifizz._queue = n._notifizz._queue || []),
13
+ (n.notifizz =
14
+ n.notifizz ||
15
+ function () {
16
+ let args = [];
17
+ for (i = 0; i < arguments.length; i++) args.push(arguments[i]);
18
+ n._notifizz._queue.push(args);
19
+ }),
20
+ (n._notifizz._notifizzSettings = {
21
+ apiKey: "${e.apiKey}",
22
+ loaderVersion: "1",
23
+ server: t,
24
+ apiUrl: "${e.apiUrl}"
25
+ }),
26
+ (f = o.getElementsByTagName("head")[0]);
27
+ let r = o.createElement("script");
28
+ r.type = 'module';
29
+ r.onload = n.notifizzCallback;
30
+ (r.async = !0), (r.src = t + i), f.appendChild(r);
31
+ })(window, document, "${e.serverUrl}", "${e.widgetPath}")`, n.appendChild(o);
32
+ }
33
+ function k(e) {
34
+ if (e.authType === "firebase") {
35
+ window.notifizz("authenticateWithFirebase", e.token, {}, () => {
36
+ });
37
+ return;
38
+ }
39
+ if (e.authType === "backendToken") {
40
+ if (!e.userEmail || !e.userId)
41
+ throw new Error(
42
+ "Missing required options: userEmail and userId are required for backendToken"
43
+ );
44
+ window.notifizz(
45
+ "authenticateWithBackendToken",
46
+ e.token,
47
+ { user: { email: e.userEmail, id: e.userId } },
48
+ () => {
49
+ }
50
+ );
51
+ }
52
+ }
53
+ function R(e) {
54
+ ["top-right", "top-left", "bottom-right", "bottom-left"].includes(e) && window.notifizz("setPosition", e);
55
+ }
56
+ function b(e) {
57
+ window.notifizz("setNotificationCenterStyles", e);
58
+ }
59
+ function I(e) {
60
+ window.notifizz("setBellStyles", e);
61
+ }
62
+ const B = "https://widget.notifizz.com", O = "https://eu.api.notifizz.com/v1", x = "/v1/widget.js", q = "notifizz-notifications";
63
+ function A(e) {
64
+ if (!e.apiKey || !e.authType)
65
+ throw new Error(
66
+ "Missing required options: apiKey and authType are required"
67
+ );
68
+ const d = e.mountId ?? q;
69
+ let n = {
70
+ isReady: !1,
71
+ isOpen: !1,
72
+ unreadCount: 0,
73
+ lastUpdated: 0
74
+ };
75
+ const l = [], o = [], u = [];
76
+ let a = null, s = null, w = !1, m = !1, c = !1;
77
+ const p = (t, ...i) => {
78
+ typeof window < "u" && window.notifizz && window.notifizz(t, ...i);
79
+ }, z = () => p("toggle"), g = () => p("open"), E = () => p("close"), y = () => {
80
+ z();
81
+ }, C = () => ({
82
+ unreadCount: n.unreadCount,
83
+ isOpen: n.isOpen,
84
+ isReady: n.isReady,
85
+ toggle: z,
86
+ open: g,
87
+ close: E
88
+ }), U = () => {
89
+ const t = C();
90
+ u.forEach((i) => i(t)), a && a.setAttribute("data-unread", String(n.unreadCount));
91
+ }, v = () => {
92
+ k({
93
+ apiKey: e.apiKey,
94
+ token: e.token,
95
+ authType: e.authType,
96
+ userEmail: e.userEmail,
97
+ userId: e.userId
98
+ }), e.position && R(e.position), e.notificationCenterStyles && b(e.notificationCenterStyles), e.bellStyles && I(e.bellStyles);
99
+ }, h = () => {
100
+ m || (m = !0, v(), n = { ...n, isReady: !0, lastUpdated: Date.now() }, l.forEach((t) => t()), U());
101
+ }, S = (t) => {
102
+ const r = t.detail;
103
+ r && typeof r == "object" && (n = {
104
+ ...n,
105
+ isReady: r.isReady ?? n.isReady,
106
+ isOpen: r.isOpen ?? n.isOpen,
107
+ unreadCount: typeof r.unreadCount == "number" ? r.unreadCount : n.unreadCount,
108
+ lastUpdated: r.lastUpdated ?? n.lastUpdated,
109
+ hasError: r.hasError,
110
+ errorCode: r.errorCode
111
+ }, o.forEach((L) => L(n)), U());
112
+ }, _ = () => {
113
+ if (w || c) return;
114
+ w = !0, window.addEventListener("notifizz:ready", h), window.addEventListener("notifizz:state", S);
115
+ const t = e.serverUrl ?? B, i = e.apiUrl ?? O, r = e.widgetPath ?? x;
116
+ T(
117
+ { apiKey: e.apiKey, serverUrl: t, apiUrl: i, widgetPath: r },
118
+ () => {
119
+ typeof window.notifizz == "function" && window.notifizz("getState", (f) => {
120
+ f && typeof f == "object" && (n = {
121
+ ...n,
122
+ ...f,
123
+ lastUpdated: f.lastUpdated ?? n.lastUpdated
124
+ }), f?.isReady && h();
125
+ }), document.getElementById(d) && v();
126
+ }
127
+ );
128
+ };
129
+ return {
130
+ mount(t) {
131
+ let i;
132
+ if (t)
133
+ i = t, i.id || (i.id = d);
134
+ else {
135
+ const r = document.getElementById(d);
136
+ if (r)
137
+ return s = r, _(), r;
138
+ i = document.createElement("div"), i.id = d, document.body.appendChild(i);
139
+ }
140
+ return s = i, _(), i;
141
+ },
142
+ getState() {
143
+ return { ...n };
144
+ },
145
+ onReady(t) {
146
+ return l.push(t), n.isReady && t(), () => {
147
+ const i = l.indexOf(t);
148
+ i !== -1 && l.splice(i, 1);
149
+ };
150
+ },
151
+ onStateChange(t) {
152
+ return o.push(t), () => {
153
+ const i = o.indexOf(t);
154
+ i !== -1 && o.splice(i, 1);
155
+ };
156
+ },
157
+ onBellUpdate(t) {
158
+ return u.push(t), t(C()), () => {
159
+ const i = u.indexOf(t);
160
+ i !== -1 && u.splice(i, 1);
161
+ };
162
+ },
163
+ open: g,
164
+ close: E,
165
+ toggle: z,
166
+ setBellElement(t) {
167
+ a && a.removeEventListener("click", y), a = t, a && (a.addEventListener("click", y), a.setAttribute("data-unread", String(n.unreadCount)));
168
+ },
169
+ destroy() {
170
+ c || (c = !0, window.removeEventListener("notifizz:ready", h), window.removeEventListener("notifizz:state", S), a && (a.removeEventListener("click", y), a = null), l.length = 0, o.length = 0, u.length = 0, s && s.parentNode && (s.parentNode.removeChild(s), s = null));
171
+ }
172
+ };
173
+ }
174
+ export {
175
+ A as createNotifizz
176
+ };
177
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../notifizz-shared/src/scriptLoader.ts","../src/createNotifizz.ts"],"sourcesContent":["export interface NotifizzConfig {\n apiKey: string;\n apiUrl: string;\n serverUrl: string;\n widgetPath: string;\n}\n\nexport function importScriptInBrowser(\n config: NotifizzConfig,\n callback: () => void\n): void {\n const head = document.head;\n const existingScript = document.querySelector(\n 'script[data-widget=\"notifizz\"]'\n );\n if (existingScript) {\n callback();\n return;\n }\n const script = document.createElement('script');\n (window as Window & { notifizzCallback?: () => void }).notifizzCallback =\n callback;\n script.type = 'module';\n script.dataset['widget'] = 'notifizz';\n script.textContent = `(function (n, o, t, i, f) {\n (n._notifizz = n._notifizz || {}),\n (n._notifizz._queue = n._notifizz._queue || []),\n (n.notifizz =\n n.notifizz ||\n function () {\n let args = [];\n for (i = 0; i < arguments.length; i++) args.push(arguments[i]);\n n._notifizz._queue.push(args);\n }),\n (n._notifizz._notifizzSettings = {\n apiKey: \"${config.apiKey}\",\n loaderVersion: \"1\",\n server: t,\n apiUrl: \"${config.apiUrl}\"\n }),\n (f = o.getElementsByTagName(\"head\")[0]);\n let r = o.createElement(\"script\");\n r.type = 'module';\n r.onload = n.notifizzCallback;\n (r.async = !0), (r.src = t + i), f.appendChild(r);\n })(window, document, \"${config.serverUrl}\", \"${config.widgetPath}\")`;\n head.appendChild(script);\n}\n\nexport interface AuthOptions {\n apiKey: string;\n token: string;\n authType: 'firebase' | 'backendToken';\n userEmail?: string;\n userId?: string;\n}\n\nexport function authenticate(options: AuthOptions): void {\n if (options.authType === 'firebase') {\n window.notifizz('authenticateWithFirebase', options.token, {}, () => {});\n return;\n }\n if (options.authType === 'backendToken') {\n if (!options.userEmail || !options.userId) {\n throw new Error(\n 'Missing required options: userEmail and userId are required for backendToken'\n );\n }\n window.notifizz(\n 'authenticateWithBackendToken',\n options.token,\n { user: { email: options.userEmail, id: options.userId } },\n () => {}\n );\n }\n}\n\nexport function applyPosition(\n position: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'\n): void {\n const valid = ['top-right', 'top-left', 'bottom-right', 'bottom-left'];\n if (valid.includes(position)) {\n window.notifizz('setPosition', position);\n }\n}\n\nexport function applyNotificationCenterStyles(styles: {\n marginTop?: string;\n}): void {\n window.notifizz('setNotificationCenterStyles', styles);\n}\n\nexport function applyBellStyles(styles: {\n marginRight?: string;\n marginLeft?: string;\n}): void {\n window.notifizz('setBellStyles', styles);\n}\n","import type { NotifizzState, NotifizzBellContext } from '../../notifizz-shared/src/types';\nimport type { NotifizzOptions, NotifizzVanillaApi } from './types';\nimport {\n importScriptInBrowser,\n authenticate,\n applyPosition,\n applyNotificationCenterStyles,\n applyBellStyles,\n} from '../../notifizz-shared/src/scriptLoader';\n\nconst DEFAULT_SERVER_URL = 'https://widget.notifizz.com';\nconst DEFAULT_API_URL = 'https://eu.api.notifizz.com/v1';\nconst DEFAULT_WIDGET_PATH = '/v1/widget.js';\nconst DEFAULT_MOUNT_ID = 'notifizz-notifications';\n\nexport function createNotifizz(options: NotifizzOptions): NotifizzVanillaApi {\n if (!options.apiKey || !options.authType) {\n throw new Error(\n 'Missing required options: apiKey and authType are required'\n );\n }\n\n const mountId = options.mountId ?? DEFAULT_MOUNT_ID;\n let state: NotifizzState = {\n isReady: false,\n isOpen: false,\n unreadCount: 0,\n lastUpdated: 0,\n };\n const readyListeners: (() => void)[] = [];\n const stateChangeListeners: ((s: NotifizzState) => void)[] = [];\n const bellUpdateListeners: ((ctx: NotifizzBellContext) => void)[] = [];\n let bellElement: HTMLElement | null = null;\n let mountElement: HTMLElement | null = null;\n let initDone = false;\n let readyFired = false;\n let destroyed = false;\n\n const send = (command: string, ...args: unknown[]): void => {\n if (typeof window !== 'undefined' && window.notifizz) {\n window.notifizz(command, ...args);\n }\n };\n\n const toggle = (): void => send('toggle');\n const open = (): void => send('open');\n const close = (): void => send('close');\n\n const onBellClick = (): void => {\n toggle();\n };\n\n const buildBellContext = (): NotifizzBellContext => ({\n unreadCount: state.unreadCount,\n isOpen: state.isOpen,\n isReady: state.isReady,\n toggle,\n open,\n close,\n });\n\n const notifyBellListeners = (): void => {\n const ctx = buildBellContext();\n bellUpdateListeners.forEach((cb) => cb(ctx));\n if (bellElement) {\n bellElement.setAttribute('data-unread', String(state.unreadCount));\n }\n };\n\n const applyOptions = (): void => {\n authenticate({\n apiKey: options.apiKey,\n token: options.token,\n authType: options.authType,\n userEmail: options.userEmail,\n userId: options.userId,\n });\n if (options.position) applyPosition(options.position);\n if (options.notificationCenterStyles) {\n applyNotificationCenterStyles(options.notificationCenterStyles);\n }\n if (options.bellStyles) applyBellStyles(options.bellStyles);\n };\n\n const handleReady = (): void => {\n if (readyFired) return;\n readyFired = true;\n applyOptions();\n state = { ...state, isReady: true, lastUpdated: Date.now() };\n readyListeners.forEach((cb) => cb());\n notifyBellListeners();\n };\n\n const handleState = (e: Event): void => {\n const ev = e as CustomEvent<NotifizzState>;\n const detail = ev.detail;\n if (detail && typeof detail === 'object') {\n state = {\n ...state,\n isReady: detail.isReady ?? state.isReady,\n isOpen: detail.isOpen ?? state.isOpen,\n unreadCount:\n typeof detail.unreadCount === 'number'\n ? detail.unreadCount\n : state.unreadCount,\n lastUpdated: detail.lastUpdated ?? state.lastUpdated,\n hasError: detail.hasError,\n errorCode: detail.errorCode,\n };\n stateChangeListeners.forEach((cb) => cb(state));\n notifyBellListeners();\n }\n };\n\n const init = (): void => {\n if (initDone || destroyed) return;\n initDone = true;\n window.addEventListener('notifizz:ready', handleReady);\n window.addEventListener('notifizz:state', handleState);\n\n const serverUrl = options.serverUrl ?? DEFAULT_SERVER_URL;\n const apiUrl = options.apiUrl ?? DEFAULT_API_URL;\n const widgetPath = options.widgetPath ?? DEFAULT_WIDGET_PATH;\n\n importScriptInBrowser(\n { apiKey: options.apiKey, serverUrl, apiUrl, widgetPath },\n () => {\n if (typeof window.notifizz === 'function') {\n window.notifizz('getState', (current: NotifizzState) => {\n if (current && typeof current === 'object') {\n state = {\n ...state,\n ...current,\n lastUpdated: current.lastUpdated ?? state.lastUpdated,\n };\n }\n if (current?.isReady) handleReady();\n });\n }\n const el = document.getElementById(mountId);\n if (el) applyOptions();\n }\n );\n };\n\n return {\n mount(element?: HTMLElement): HTMLElement {\n let el: HTMLElement;\n if (element) {\n el = element;\n if (!el.id) el.id = mountId;\n } else {\n const existing = document.getElementById(mountId);\n if (existing) {\n mountElement = existing;\n init();\n return existing;\n }\n el = document.createElement('div');\n el.id = mountId;\n document.body.appendChild(el);\n }\n mountElement = el;\n init();\n return el;\n },\n\n getState(): NotifizzState {\n return { ...state };\n },\n\n onReady(cb: () => void): () => void {\n readyListeners.push(cb);\n if (state.isReady) cb();\n return () => {\n const i = readyListeners.indexOf(cb);\n if (i !== -1) readyListeners.splice(i, 1);\n };\n },\n\n onStateChange(cb: (s: NotifizzState) => void): () => void {\n stateChangeListeners.push(cb);\n return () => {\n const i = stateChangeListeners.indexOf(cb);\n if (i !== -1) stateChangeListeners.splice(i, 1);\n };\n },\n\n onBellUpdate(cb: (ctx: NotifizzBellContext) => void): () => void {\n bellUpdateListeners.push(cb);\n cb(buildBellContext());\n return () => {\n const i = bellUpdateListeners.indexOf(cb);\n if (i !== -1) bellUpdateListeners.splice(i, 1);\n };\n },\n\n open,\n close,\n toggle,\n\n setBellElement(el: HTMLElement | null): void {\n if (bellElement) {\n bellElement.removeEventListener('click', onBellClick);\n }\n bellElement = el;\n if (bellElement) {\n bellElement.addEventListener('click', onBellClick);\n bellElement.setAttribute('data-unread', String(state.unreadCount));\n }\n },\n\n destroy(): void {\n if (destroyed) return;\n destroyed = true;\n window.removeEventListener('notifizz:ready', handleReady);\n window.removeEventListener('notifizz:state', handleState);\n if (bellElement) {\n bellElement.removeEventListener('click', onBellClick);\n bellElement = null;\n }\n readyListeners.length = 0;\n stateChangeListeners.length = 0;\n bellUpdateListeners.length = 0;\n if (mountElement && mountElement.parentNode) {\n mountElement.parentNode.removeChild(mountElement);\n mountElement = null;\n }\n },\n };\n}\n"],"names":["importScriptInBrowser","config","callback","head","script","authenticate","options","applyPosition","position","applyNotificationCenterStyles","styles","applyBellStyles","DEFAULT_SERVER_URL","DEFAULT_API_URL","DEFAULT_WIDGET_PATH","DEFAULT_MOUNT_ID","createNotifizz","mountId","state","readyListeners","stateChangeListeners","bellUpdateListeners","bellElement","mountElement","initDone","readyFired","destroyed","send","command","args","toggle","open","close","onBellClick","buildBellContext","notifyBellListeners","ctx","cb","applyOptions","handleReady","handleState","e","detail","init","serverUrl","apiUrl","widgetPath","current","element","el","existing"],"mappings":"AAOO,SAASA,EACdC,GACAC,GACM;AACN,QAAMC,IAAO,SAAS;AAItB,MAHuB,SAAS;AAAA,IAC9B;AAAA,EAAA,GAEkB;AAClB,IAAAD,EAAA;AACA;AAAA,EACF;AACA,QAAME,IAAS,SAAS,cAAc,QAAQ;AAC7C,SAAsD,mBACrDF,GACFE,EAAO,OAAO,UACdA,EAAO,QAAQ,SAAY,YAC3BA,EAAO,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAWJH,EAAO,MAAM;AAAA;AAAA;AAAA,mBAGbA,EAAO,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAONA,EAAO,SAAS,OAAOA,EAAO,UAAU,MAChEE,EAAK,YAAY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ACpDX,IAAc,OAEhBH,EAAe,SAAS,GACxBC,EAAqB,SAAS,GAC9BC,EAAoB,SAAS,GACzBE,KAAgBA,EAAa,eAC/BA,EAAa,WAAW,YAAYA,CAAY,GAChDA,IAAe;AAAA,IAEnB;AAAA,EAAA;AAEJ;"}
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@notifizz/vanilla",
3
+ "version": "1.1.0",
4
+ "publishConfig": {
5
+ "access": "public",
6
+ "registry": "https://registry.npmjs.org"
7
+ },
8
+ "license": "ISC",
9
+ "author": "damiencosset",
10
+ "type": "module",
11
+ "main": "./dist/index.cjs",
12
+ "module": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js",
18
+ "require": "./dist/index.cjs"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "scripts": {
25
+ "build": "vite build"
26
+ },
27
+ "devDependencies": {
28
+ "typescript": "^5.7.3",
29
+ "vite": "^7.1.9",
30
+ "vite-plugin-dts": "^4.5.4"
31
+ }
32
+ }