@enquio/popup-core 1.0.2

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.
@@ -0,0 +1 @@
1
+ export * from './loader';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './loader';
@@ -0,0 +1,6 @@
1
+ declare global {
2
+ interface Window {
3
+ __ENQUIO_SCRIPT_PROMISE__?: Promise<void>;
4
+ }
5
+ }
6
+ export declare function loadEnquioScript(): Promise<void>;
package/dist/loader.js ADDED
@@ -0,0 +1,23 @@
1
+ const SCRIPT_URL = 'https://public.newapp.enquio.eu/popup.js';
2
+ export function loadEnquioScript() {
3
+ if (typeof window === 'undefined') {
4
+ return Promise.resolve();
5
+ }
6
+ if (!window.__ENQUIO_SCRIPT_PROMISE__) {
7
+ window.__ENQUIO_SCRIPT_PROMISE__ = new Promise((resolve, reject) => {
8
+ const existing = document.getElementById('enquio-popup-script');
9
+ if (existing) {
10
+ resolve();
11
+ return;
12
+ }
13
+ const script = document.createElement('script');
14
+ script.src = SCRIPT_URL;
15
+ script.async = true;
16
+ script.id = 'enquio-popup-script';
17
+ script.onload = () => resolve();
18
+ script.onerror = () => reject(new Error('Failed to load Enquio popup'));
19
+ document.body.appendChild(script);
20
+ });
21
+ }
22
+ return window.__ENQUIO_SCRIPT_PROMISE__;
23
+ }
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@enquio/popup-core",
3
+ "version": "1.0.2",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "scripts": {
10
+ "build": "tsc"
11
+ }
12
+ }