featurely-site-manager 1.1.15 → 1.1.17
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.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +20 -10
- package/dist/index.mjs +20 -10
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -98,8 +98,7 @@ var _SiteManager = class _SiteManager {
|
|
|
98
98
|
// 1 hour
|
|
99
99
|
onUpdateAvailable: config.onUpdateAvailable,
|
|
100
100
|
onUpdateRequired: config.onUpdateRequired,
|
|
101
|
-
debugMode: (_f = config.debugMode) != null ? _f : false
|
|
102
|
-
environment: config.environment
|
|
101
|
+
debugMode: (_f = config.debugMode) != null ? _f : false
|
|
103
102
|
};
|
|
104
103
|
this.loadDismissedMessages();
|
|
105
104
|
}
|
|
@@ -107,7 +106,6 @@ var _SiteManager = class _SiteManager {
|
|
|
107
106
|
* Initialize and start the site manager
|
|
108
107
|
*/
|
|
109
108
|
async init() {
|
|
110
|
-
var _a;
|
|
111
109
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
112
110
|
console.warn(
|
|
113
111
|
"Featurely Site Manager: Can only be initialized in a browser environment"
|
|
@@ -117,7 +115,7 @@ var _SiteManager = class _SiteManager {
|
|
|
117
115
|
if (this.config.debugMode) {
|
|
118
116
|
this.setupDebugOverlay();
|
|
119
117
|
}
|
|
120
|
-
this.debugLog("info", `[init] v1.1.
|
|
118
|
+
this.debugLog("info", `[init] v1.1.16 | project: ${this.config.projectId} | hostname: ${typeof window !== "undefined" ? window.location.hostname : "\u2014"}`);
|
|
121
119
|
this.debugLog("info", `[init] analytics: ${this.config.enableAnalytics ? "on" : "off"} | poll: ${this.config.pollInterval}ms | debug: ${this.config.debugMode ? "on" : "off"}`);
|
|
122
120
|
if (this.config.enableAnalytics) {
|
|
123
121
|
this.debugLog("info", "[init] starting analytics + page tracking");
|
|
@@ -366,10 +364,12 @@ var _SiteManager = class _SiteManager {
|
|
|
366
364
|
if (newConfig.debugMode === true && !this.debugOverlayEl) {
|
|
367
365
|
this.setupDebugOverlay();
|
|
368
366
|
}
|
|
369
|
-
if (!this.debugOverlayEl
|
|
367
|
+
if (!this.debugOverlayEl) {
|
|
368
|
+
const hostname = typeof window !== "undefined" ? window.location.hostname : "";
|
|
370
369
|
const envs = newConfig.environments;
|
|
371
|
-
const
|
|
372
|
-
if ((
|
|
370
|
+
const matchedEnv = hostname ? envs == null ? void 0 : envs.find((e) => typeof e.url === "string" && e.url !== "" && e.url === hostname) : void 0;
|
|
371
|
+
if ((matchedEnv == null ? void 0 : matchedEnv.debugEnabled) === true) {
|
|
372
|
+
this.debugLog("info", `[env] matched environment "${matchedEnv.name}" (${hostname})`);
|
|
373
373
|
this.setupDebugOverlay();
|
|
374
374
|
}
|
|
375
375
|
}
|
|
@@ -629,9 +629,9 @@ var _SiteManager = class _SiteManager {
|
|
|
629
629
|
const flagCount = (_c = (_b = sc == null ? void 0 : sc.featureFlags) == null ? void 0 : _b.length) != null ? _c : 0;
|
|
630
630
|
const msgCount = (_e = (_d = sc == null ? void 0 : sc.messages) == null ? void 0 : _d.length) != null ? _e : 0;
|
|
631
631
|
content = `
|
|
632
|
-
${row("SDK Version", "1.1.
|
|
632
|
+
${row("SDK Version", "1.1.16")}
|
|
633
633
|
${row("Project", cfg.projectId)}
|
|
634
|
-
${row("
|
|
634
|
+
${row("Hostname", typeof window !== "undefined" ? window.location.hostname : "\u2014")}
|
|
635
635
|
${row("API URL", cfg.apiUrl)}
|
|
636
636
|
${row("Maintenance", maintenance)}
|
|
637
637
|
${row("Feature Flags", `${flagCount} active`)}
|
|
@@ -656,8 +656,9 @@ var _SiteManager = class _SiteManager {
|
|
|
656
656
|
const logs = this.debugLogs.slice(0, 50);
|
|
657
657
|
const errorsInLog = logs.filter((l) => l.level === "error").length;
|
|
658
658
|
const clearBtn = `<button data-action="clear-logs" style="background:rgba(255,255,255,0.08);border:none;color:${MUTED};cursor:pointer;font-size:9px;font-family:inherit;padding:2px 7px;border-radius:3px">Clear</button>`;
|
|
659
|
+
const copyBtn = `<button data-action="copy-logs" style="background:rgba(255,255,255,0.08);border:none;color:${MUTED};cursor:pointer;font-size:9px;font-family:inherit;padding:2px 7px;border-radius:3px">Copy</button>`;
|
|
659
660
|
const errBadge = errorsInLog > 0 ? `<span style="font-size:9px;color:${RED}">${errorsInLog} error${errorsInLog > 1 ? "s" : ""}</span>` : "";
|
|
660
|
-
const logHeader = `<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px">${errBadge || `<span></span>`}${clearBtn}</div>`;
|
|
661
|
+
const logHeader = `<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px">${errBadge || `<span></span>`}<div style="display:flex;gap:4px">${copyBtn}${clearBtn}</div></div>`;
|
|
661
662
|
if (logs.length === 0) {
|
|
662
663
|
content = logHeader + `<div style="color:${MUTED};padding:12px;text-align:center">No logs yet</div>`;
|
|
663
664
|
} else {
|
|
@@ -817,6 +818,15 @@ var _SiteManager = class _SiteManager {
|
|
|
817
818
|
await this.fetchConfig();
|
|
818
819
|
feedback("Config refreshed", true);
|
|
819
820
|
break;
|
|
821
|
+
case "copy-logs": {
|
|
822
|
+
const text = this.debugLogs.slice().reverse().map((l) => `[${l.ts}] [${l.level.toUpperCase()}] ${l.msg}`).join("\n");
|
|
823
|
+
void navigator.clipboard.writeText(text).then(() => {
|
|
824
|
+
feedback(`Copied ${this.debugLogs.length} log line${this.debugLogs.length !== 1 ? "s" : ""}`, true);
|
|
825
|
+
}).catch(() => {
|
|
826
|
+
feedback("Copy failed \u2014 clipboard not available", false);
|
|
827
|
+
});
|
|
828
|
+
break;
|
|
829
|
+
}
|
|
820
830
|
case "clear-logs":
|
|
821
831
|
this.debugLogs = [];
|
|
822
832
|
this.testFeedback = [];
|
package/dist/index.mjs
CHANGED
|
@@ -63,8 +63,7 @@ var _SiteManager = class _SiteManager {
|
|
|
63
63
|
// 1 hour
|
|
64
64
|
onUpdateAvailable: config.onUpdateAvailable,
|
|
65
65
|
onUpdateRequired: config.onUpdateRequired,
|
|
66
|
-
debugMode: (_f = config.debugMode) != null ? _f : false
|
|
67
|
-
environment: config.environment
|
|
66
|
+
debugMode: (_f = config.debugMode) != null ? _f : false
|
|
68
67
|
};
|
|
69
68
|
this.loadDismissedMessages();
|
|
70
69
|
}
|
|
@@ -72,7 +71,6 @@ var _SiteManager = class _SiteManager {
|
|
|
72
71
|
* Initialize and start the site manager
|
|
73
72
|
*/
|
|
74
73
|
async init() {
|
|
75
|
-
var _a;
|
|
76
74
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
77
75
|
console.warn(
|
|
78
76
|
"Featurely Site Manager: Can only be initialized in a browser environment"
|
|
@@ -82,7 +80,7 @@ var _SiteManager = class _SiteManager {
|
|
|
82
80
|
if (this.config.debugMode) {
|
|
83
81
|
this.setupDebugOverlay();
|
|
84
82
|
}
|
|
85
|
-
this.debugLog("info", `[init] v1.1.
|
|
83
|
+
this.debugLog("info", `[init] v1.1.16 | project: ${this.config.projectId} | hostname: ${typeof window !== "undefined" ? window.location.hostname : "\u2014"}`);
|
|
86
84
|
this.debugLog("info", `[init] analytics: ${this.config.enableAnalytics ? "on" : "off"} | poll: ${this.config.pollInterval}ms | debug: ${this.config.debugMode ? "on" : "off"}`);
|
|
87
85
|
if (this.config.enableAnalytics) {
|
|
88
86
|
this.debugLog("info", "[init] starting analytics + page tracking");
|
|
@@ -331,10 +329,12 @@ var _SiteManager = class _SiteManager {
|
|
|
331
329
|
if (newConfig.debugMode === true && !this.debugOverlayEl) {
|
|
332
330
|
this.setupDebugOverlay();
|
|
333
331
|
}
|
|
334
|
-
if (!this.debugOverlayEl
|
|
332
|
+
if (!this.debugOverlayEl) {
|
|
333
|
+
const hostname = typeof window !== "undefined" ? window.location.hostname : "";
|
|
335
334
|
const envs = newConfig.environments;
|
|
336
|
-
const
|
|
337
|
-
if ((
|
|
335
|
+
const matchedEnv = hostname ? envs == null ? void 0 : envs.find((e) => typeof e.url === "string" && e.url !== "" && e.url === hostname) : void 0;
|
|
336
|
+
if ((matchedEnv == null ? void 0 : matchedEnv.debugEnabled) === true) {
|
|
337
|
+
this.debugLog("info", `[env] matched environment "${matchedEnv.name}" (${hostname})`);
|
|
338
338
|
this.setupDebugOverlay();
|
|
339
339
|
}
|
|
340
340
|
}
|
|
@@ -594,9 +594,9 @@ var _SiteManager = class _SiteManager {
|
|
|
594
594
|
const flagCount = (_c = (_b = sc == null ? void 0 : sc.featureFlags) == null ? void 0 : _b.length) != null ? _c : 0;
|
|
595
595
|
const msgCount = (_e = (_d = sc == null ? void 0 : sc.messages) == null ? void 0 : _d.length) != null ? _e : 0;
|
|
596
596
|
content = `
|
|
597
|
-
${row("SDK Version", "1.1.
|
|
597
|
+
${row("SDK Version", "1.1.16")}
|
|
598
598
|
${row("Project", cfg.projectId)}
|
|
599
|
-
${row("
|
|
599
|
+
${row("Hostname", typeof window !== "undefined" ? window.location.hostname : "\u2014")}
|
|
600
600
|
${row("API URL", cfg.apiUrl)}
|
|
601
601
|
${row("Maintenance", maintenance)}
|
|
602
602
|
${row("Feature Flags", `${flagCount} active`)}
|
|
@@ -621,8 +621,9 @@ var _SiteManager = class _SiteManager {
|
|
|
621
621
|
const logs = this.debugLogs.slice(0, 50);
|
|
622
622
|
const errorsInLog = logs.filter((l) => l.level === "error").length;
|
|
623
623
|
const clearBtn = `<button data-action="clear-logs" style="background:rgba(255,255,255,0.08);border:none;color:${MUTED};cursor:pointer;font-size:9px;font-family:inherit;padding:2px 7px;border-radius:3px">Clear</button>`;
|
|
624
|
+
const copyBtn = `<button data-action="copy-logs" style="background:rgba(255,255,255,0.08);border:none;color:${MUTED};cursor:pointer;font-size:9px;font-family:inherit;padding:2px 7px;border-radius:3px">Copy</button>`;
|
|
624
625
|
const errBadge = errorsInLog > 0 ? `<span style="font-size:9px;color:${RED}">${errorsInLog} error${errorsInLog > 1 ? "s" : ""}</span>` : "";
|
|
625
|
-
const logHeader = `<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px">${errBadge || `<span></span>`}${clearBtn}</div>`;
|
|
626
|
+
const logHeader = `<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px">${errBadge || `<span></span>`}<div style="display:flex;gap:4px">${copyBtn}${clearBtn}</div></div>`;
|
|
626
627
|
if (logs.length === 0) {
|
|
627
628
|
content = logHeader + `<div style="color:${MUTED};padding:12px;text-align:center">No logs yet</div>`;
|
|
628
629
|
} else {
|
|
@@ -782,6 +783,15 @@ var _SiteManager = class _SiteManager {
|
|
|
782
783
|
await this.fetchConfig();
|
|
783
784
|
feedback("Config refreshed", true);
|
|
784
785
|
break;
|
|
786
|
+
case "copy-logs": {
|
|
787
|
+
const text = this.debugLogs.slice().reverse().map((l) => `[${l.ts}] [${l.level.toUpperCase()}] ${l.msg}`).join("\n");
|
|
788
|
+
void navigator.clipboard.writeText(text).then(() => {
|
|
789
|
+
feedback(`Copied ${this.debugLogs.length} log line${this.debugLogs.length !== 1 ? "s" : ""}`, true);
|
|
790
|
+
}).catch(() => {
|
|
791
|
+
feedback("Copy failed \u2014 clipboard not available", false);
|
|
792
|
+
});
|
|
793
|
+
break;
|
|
794
|
+
}
|
|
785
795
|
case "clear-logs":
|
|
786
796
|
this.debugLogs = [];
|
|
787
797
|
this.testFeedback = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "featurely-site-manager",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.17",
|
|
4
4
|
"description": "Complete site management SDK for maintenance mode, status messages, feature flags, version checking, and analytics",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|