@cdfrd/publish-notification-plugin 0.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,1148 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ UpdateNoticeManager: () => UpdateNoticeManager,
24
+ createUpdateNotice: () => createUpdateNotice,
25
+ getUpdateNotice: () => getUpdateNotice
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // node_modules/.pnpm/tsup@8.5.1_postcss@8.5.26_typescript@5.9.3/node_modules/tsup/assets/cjs_shims.js
30
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
31
+ var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
32
+
33
+ // src/constants.ts
34
+ var DIRECTORY_NAME = "update-notice";
35
+ var JSON_FILE_NAME = "version";
36
+ var INJECT_STYLE_TAG_ID = "_cdfrd_un_styles_";
37
+ var CUSTOM_UPDATE_EVENT_NAME = "web_update_notice";
38
+ var NOTIFICATION_ANCHOR_CLASS_NAME = "cdfrd-update-notice-anchor";
39
+ var NOTIFICATION_REFRESH_BTN_CLASS = "cdfrd-update-notice-refresh-btn";
40
+ var NOTIFICATION_DISMISS_BTN_CLASS = "cdfrd-update-notice-dismiss-btn";
41
+ var NOTIFICATION_CLOSE_BTN_CLASS = "cdfrd-update-notice-close-btn";
42
+ var DISMISS_STORAGE_PREFIX = "cdfrd_update_notice_dismiss_";
43
+ var MAX_DISMISSED_VERSIONS = 3;
44
+ var STANDALONE_APP_ID = "__standalone__";
45
+ var DEFAULT_PRIMARY_COLOR = "#1677ff";
46
+ var THEME_RETRY_MAX = 3;
47
+ var THEME_WATCH_DEBOUNCE_MS = 150;
48
+ var PLACEMENT_STYLES = {
49
+ topLeft: "top:16px;left:24px",
50
+ topRight: "top:16px;right:24px",
51
+ bottomLeft: "bottom:16px;left:24px",
52
+ bottomRight: "bottom:16px;right:24px"
53
+ };
54
+ var DEFAULT_CHECK_INTERVAL = 10 * 60 * 1e3;
55
+
56
+ // src/build/validate-options.ts
57
+ var MUTUAL_EXCLUSIVE_MSG = "[publish-notification] disableNotification \u4E0E hiddenDefaultNotice \u4E0D\u5F97\u540C\u65F6\u4E3A true\uFF0C\u8BF7\u4E8C\u9009\u4E00\u3002";
58
+ function validateOptions(options = {}) {
59
+ if (options.disableNotification && options.hiddenDefaultNotice) {
60
+ throw new Error(MUTUAL_EXCLUSIVE_MSG);
61
+ }
62
+ if (options.microApp?.enabled && !options.microApp.appId) {
63
+ throw new Error("[publish-notification] microApp.enabled \u4E3A true \u65F6\u5FC5\u987B\u63D0\u4F9B microApp.appId");
64
+ }
65
+ return options;
66
+ }
67
+ function resolveAppId(options) {
68
+ if (options.microApp?.enabled) return options.microApp.appId;
69
+ return void 0;
70
+ }
71
+ function isNotificationFullyDisabled(options) {
72
+ return options.disableNotification === true;
73
+ }
74
+ function shouldUseCustomEvent(options) {
75
+ return options.hiddenDefaultNotice === true && !isNotificationFullyDisabled(options);
76
+ }
77
+ function shouldShowDefaultUi(options) {
78
+ return !options.disableNotification && !options.hiddenDefaultNotice;
79
+ }
80
+
81
+ // src/core/check-gate.ts
82
+ function isTabVisible() {
83
+ return typeof document !== "undefined" && document.visibilityState === "visible" && !document.hidden;
84
+ }
85
+ function isAppActive(options, context) {
86
+ if (!options.microApp?.enabled) return true;
87
+ return context.activeApp === options.microApp.appId;
88
+ }
89
+ function canCheckUpdate(options, context) {
90
+ if (isNotificationFullyDisabled(options)) return false;
91
+ if (options.check?.onTabVisible !== false && !isTabVisible()) return false;
92
+ if (!isAppActive(options, context)) return false;
93
+ return true;
94
+ }
95
+ function getRuntimeKey(options) {
96
+ return resolveAppId(options) ?? STANDALONE_APP_ID;
97
+ }
98
+ function getDismissAppId(options) {
99
+ return resolveAppId(options) ?? STANDALONE_APP_ID;
100
+ }
101
+
102
+ // src/core/dismiss-storage.ts
103
+ var DISMISS_STORAGE_KEY = `${DISMISS_STORAGE_PREFIX}entries`;
104
+ function toDismissEntry(appId, version) {
105
+ return `${appId}+${version}`;
106
+ }
107
+ function readDismissEntries() {
108
+ try {
109
+ const raw = localStorage.getItem(DISMISS_STORAGE_KEY);
110
+ if (!raw) return [];
111
+ const parsed = JSON.parse(raw);
112
+ return Array.isArray(parsed) ? parsed.filter((v) => typeof v === "string") : [];
113
+ } catch {
114
+ return [];
115
+ }
116
+ }
117
+ function writeDismissEntries(entries) {
118
+ try {
119
+ localStorage.setItem(DISMISS_STORAGE_KEY, JSON.stringify(entries));
120
+ } catch {
121
+ }
122
+ }
123
+ function isVersionDismissed(appId, version) {
124
+ return readDismissEntries().includes(toDismissEntry(appId, version));
125
+ }
126
+ function rememberDismissedVersion(appId, version) {
127
+ const entry = toDismissEntry(appId, version);
128
+ const entries = readDismissEntries().filter((item) => item !== entry);
129
+ const sameAppEntries = entries.filter((item) => item.startsWith(`${appId}+`));
130
+ const otherAppEntries = entries.filter((item) => !item.startsWith(`${appId}+`));
131
+ const nextSameAppEntries = [entry, ...sameAppEntries].slice(0, MAX_DISMISSED_VERSIONS);
132
+ writeDismissEntries([...otherAppEntries, ...nextSameAppEntries]);
133
+ }
134
+
135
+ // src/core/version-compare.ts
136
+ function hasNewVersion(localVersion, remoteVersion) {
137
+ return localVersion !== remoteVersion;
138
+ }
139
+
140
+ // src/core/version-url.ts
141
+ var import_meta = {};
142
+ function normalizeBase(base) {
143
+ if (!base) return "";
144
+ return base.endsWith("/") ? base : `${base}/`;
145
+ }
146
+ function isAbsoluteHttpBase(base) {
147
+ return /^https?:\/\//i.test(base);
148
+ }
149
+ function readViteBaseUrl() {
150
+ try {
151
+ const base = import_meta.env.BASE_URL;
152
+ if (typeof base === "string") return base;
153
+ } catch {
154
+ }
155
+ return void 0;
156
+ }
157
+ function readRuntimePublicPath() {
158
+ if (typeof window === "undefined") return void 0;
159
+ const w = window;
160
+ const raw = w.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ || w.proxy?.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ || w.__webpack_public_path__ || w.proxy?.__webpack_public_path__;
161
+ if (typeof raw !== "string" || !raw.trim()) return void 0;
162
+ try {
163
+ const href = new URL(
164
+ raw,
165
+ typeof location !== "undefined" ? location.href : "http://localhost/"
166
+ ).href;
167
+ return normalizeBase(href);
168
+ } catch {
169
+ return normalizeBase(raw);
170
+ }
171
+ }
172
+ function vitePathPrefix(viteBase) {
173
+ if (!viteBase || viteBase === "/" || viteBase === "./") return "/";
174
+ if (isAbsoluteHttpBase(viteBase)) {
175
+ try {
176
+ const path = new URL(viteBase).pathname;
177
+ return normalizeBase(path || "/");
178
+ } catch {
179
+ return "/";
180
+ }
181
+ }
182
+ return normalizeBase(viteBase);
183
+ }
184
+ function readModuleOriginBase(pathBase) {
185
+ try {
186
+ const moduleUrl = new URL(importMetaUrl);
187
+ if (moduleUrl.protocol !== "http:" && moduleUrl.protocol !== "https:") return void 0;
188
+ if (!moduleUrl.origin) return void 0;
189
+ const prefix = pathBase === "/" ? "/" : pathBase;
190
+ return normalizeBase(`${moduleUrl.origin}${prefix === "/" ? "/" : prefix}`);
191
+ } catch {
192
+ return void 0;
193
+ }
194
+ }
195
+ function resolveMicroVersionBase(explicit) {
196
+ if (explicit !== void 0 && explicit !== null) {
197
+ return normalizeBase(explicit);
198
+ }
199
+ const runtime = readRuntimePublicPath();
200
+ if (runtime && isAbsoluteHttpBase(runtime)) return runtime;
201
+ const viteBase = readViteBaseUrl() ?? "";
202
+ if (isAbsoluteHttpBase(viteBase)) return normalizeBase(viteBase);
203
+ return readModuleOriginBase(vitePathPrefix(viteBase));
204
+ }
205
+ function resolveVersionBase(explicit) {
206
+ if (explicit !== void 0 && explicit !== null) {
207
+ return normalizeBase(explicit);
208
+ }
209
+ const viteBase = readViteBaseUrl() ?? "";
210
+ if (isAbsoluteHttpBase(viteBase)) {
211
+ return normalizeBase(viteBase);
212
+ }
213
+ const pathBase = vitePathPrefix(viteBase);
214
+ return pathBase === "/" ? "" : pathBase;
215
+ }
216
+ function buildVersionJsonUrl(versionBase) {
217
+ const base = resolveVersionBase(versionBase);
218
+ return `${base}${DIRECTORY_NAME}/${JSON_FILE_NAME}.json`;
219
+ }
220
+
221
+ // src/core/UpdateNoticeRuntime.ts
222
+ var UpdateNoticeRuntime = class {
223
+ constructor(manager, options) {
224
+ /** Baseline version for this page session; set on first successful fetch */
225
+ this.localVersion = null;
226
+ this.pendingUpdate = null;
227
+ this.manager = manager;
228
+ this.options = options;
229
+ this.appId = resolveAppId(options);
230
+ this.appKey = getRuntimeKey(options);
231
+ }
232
+ bootstrap() {
233
+ if (isNotificationFullyDisabled(this.options)) return;
234
+ this.setupScheduler();
235
+ }
236
+ destroy() {
237
+ if (this.intervalId) {
238
+ clearInterval(this.intervalId);
239
+ this.intervalId = void 0;
240
+ }
241
+ if (this.onVisibilityChange) {
242
+ document.removeEventListener("visibilitychange", this.onVisibilityChange);
243
+ this.onVisibilityChange = void 0;
244
+ }
245
+ if (this.onWindowFocus) {
246
+ window.removeEventListener("focus", this.onWindowFocus);
247
+ this.onWindowFocus = void 0;
248
+ }
249
+ if (this.onResourceError) {
250
+ window.removeEventListener("error", this.onResourceError, true);
251
+ this.onResourceError = void 0;
252
+ }
253
+ }
254
+ checkUpdate() {
255
+ if (isNotificationFullyDisabled(this.options)) return;
256
+ if (!canCheckUpdate(this.options, { activeApp: this.manager.activeApp })) {
257
+ if (this.pendingUpdate) this.tryNotify(this.pendingUpdate);
258
+ return;
259
+ }
260
+ const poweredByQiankun = Boolean(
261
+ window.__POWERED_BY_QIANKUN__
262
+ );
263
+ const versionBase = this.options.versionBase !== void 0 && this.options.versionBase !== null ? this.options.versionBase : this.options.microApp?.enabled && poweredByQiankun ? resolveMicroVersionBase() ?? resolveVersionBase() : resolveVersionBase();
264
+ const url = `${buildVersionJsonUrl(versionBase)}?t=${Date.now()}`;
265
+ fetch(url).then((res) => {
266
+ if (!res.ok) throw new Error("version fetch failed");
267
+ return res.json();
268
+ }).then((remote) => {
269
+ if (!remote?.version) return;
270
+ if (this.localVersion == null) {
271
+ this.localVersion = remote.version;
272
+ return;
273
+ }
274
+ if (!hasNewVersion(this.localVersion, remote.version)) {
275
+ this.pendingUpdate = null;
276
+ return;
277
+ }
278
+ if (!canCheckUpdate(this.options, { activeApp: this.manager.activeApp })) {
279
+ this.pendingUpdate = remote.version;
280
+ return;
281
+ }
282
+ this.handleUpdateDetected(remote.version);
283
+ }).catch(() => {
284
+ });
285
+ }
286
+ flushPendingUpdate() {
287
+ if (this.pendingUpdate) this.tryNotify(this.pendingUpdate);
288
+ }
289
+ handleUpdateDetected(version) {
290
+ const dismissKey = getDismissAppId(this.options);
291
+ if (isVersionDismissed(dismissKey, version)) return;
292
+ this.pendingUpdate = null;
293
+ this.manager.notifyUpdate(this, version);
294
+ if (shouldUseCustomEvent(this.options)) {
295
+ window.dispatchEvent(
296
+ new CustomEvent(CUSTOM_UPDATE_EVENT_NAME, {
297
+ detail: { appId: this.appId, version, options: this.options }
298
+ })
299
+ );
300
+ return;
301
+ }
302
+ if (shouldShowDefaultUi(this.options)) {
303
+ const shown = this.manager.showDefaultNotice(this, version);
304
+ if (!shown) this.pendingUpdate = version;
305
+ }
306
+ }
307
+ tryNotify(version) {
308
+ if (canCheckUpdate(this.options, { activeApp: this.manager.activeApp })) {
309
+ this.handleUpdateDetected(version);
310
+ }
311
+ }
312
+ dismissVersion(version) {
313
+ rememberDismissedVersion(getDismissAppId(this.options), version);
314
+ }
315
+ setupScheduler() {
316
+ const check = this.options.check ?? {};
317
+ const checkInterval = check.interval ?? DEFAULT_CHECK_INTERVAL;
318
+ const onWindowActive = check.onWindowActive !== false;
319
+ const onResourceError = check.onResourceError !== false;
320
+ const checkImmediately = !this.options.microApp?.enabled;
321
+ const run = () => this.checkUpdate();
322
+ const flushPending = () => this.flushPendingUpdate();
323
+ if (checkImmediately) {
324
+ setTimeout(run, 0);
325
+ }
326
+ const startPolling = () => {
327
+ if (this.intervalId) clearInterval(this.intervalId);
328
+ if (checkInterval > 0) {
329
+ this.intervalId = setInterval(run, checkInterval);
330
+ }
331
+ };
332
+ startPolling();
333
+ this.onVisibilityChange = () => {
334
+ if (document.visibilityState === "visible") {
335
+ startPolling();
336
+ flushPending();
337
+ if (onWindowActive) run();
338
+ } else if (this.intervalId) {
339
+ clearInterval(this.intervalId);
340
+ this.intervalId = void 0;
341
+ }
342
+ };
343
+ document.addEventListener("visibilitychange", this.onVisibilityChange);
344
+ if (onWindowActive) {
345
+ this.onWindowFocus = () => {
346
+ flushPending();
347
+ run();
348
+ };
349
+ window.addEventListener("focus", this.onWindowFocus);
350
+ }
351
+ if (onResourceError) {
352
+ this.onResourceError = (event) => {
353
+ const tag = event.target?.tagName;
354
+ if (tag === "SCRIPT" || tag === "LINK") run();
355
+ };
356
+ window.addEventListener("error", this.onResourceError, true);
357
+ }
358
+ }
359
+ };
360
+ function ensureNotificationAnchor() {
361
+ if (typeof document === "undefined") return;
362
+ const existing = document.body?.querySelector(`:scope > .${NOTIFICATION_ANCHOR_CLASS_NAME}`);
363
+ if (existing) return;
364
+ const mount = () => {
365
+ if (document.body?.querySelector(`:scope > .${NOTIFICATION_ANCHOR_CLASS_NAME}`)) return;
366
+ if (!document.body) return;
367
+ const anchor = document.createElement("div");
368
+ anchor.className = NOTIFICATION_ANCHOR_CLASS_NAME;
369
+ document.body.appendChild(anchor);
370
+ };
371
+ if (!document.body) {
372
+ document.addEventListener("DOMContentLoaded", mount, { once: true });
373
+ return;
374
+ }
375
+ mount();
376
+ }
377
+
378
+ // src/core/locale.ts
379
+ var PRESET_LOCALE = {
380
+ zh_CN: {
381
+ title: "\u53D1\u73B0\u65B0\u7248\u672C",
382
+ description: "\u8BF7\u5237\u65B0\u540E\u7EE7\u7EED\u3002",
383
+ forcedTitle: "\u53D1\u73B0\u65B0\u7248\u672C",
384
+ forcedDescription: "\u8BF7\u5237\u65B0\u540E\u7EE7\u7EED\u3002",
385
+ buttonText: "\u5237\u65B0",
386
+ dismissButtonText: "\u7A0D\u540E"
387
+ },
388
+ en_US: {
389
+ title: "Update available",
390
+ description: "Please refresh to continue.",
391
+ forcedTitle: "Update required",
392
+ forcedDescription: "Please refresh to continue.",
393
+ buttonText: "Refresh",
394
+ dismissButtonText: "Later"
395
+ }
396
+ };
397
+ function resolveNotificationCopy(options, locale) {
398
+ const builtin = PRESET_LOCALE[locale] ?? PRESET_LOCALE.zh_CN;
399
+ const fromData = options.locale?.data?.[locale] ?? {};
400
+ return {
401
+ title: fromData.title ?? builtin.title,
402
+ description: fromData.description ?? builtin.description,
403
+ forcedTitle: fromData.title ?? builtin.forcedTitle,
404
+ forcedDescription: fromData.forcedDescription ?? builtin.forcedDescription,
405
+ buttonText: fromData.buttonText ?? builtin.buttonText,
406
+ dismissButtonText: fromData.dismissButtonText ?? builtin.dismissButtonText
407
+ };
408
+ }
409
+
410
+ // src/notification/default-styles.ts
411
+ var DEFAULT_NOTICE_CSS = `
412
+ .cdfrd-update-notice[data-update-notice-theme='light'] {
413
+ --update-bg: #ffffff;
414
+ --update-text: rgba(0, 0, 0, 0.88);
415
+ --update-text-secondary: rgba(0, 0, 0, 0.65);
416
+ --update-border: #f0f0f0;
417
+ --update-btn-border: #d9d9d9;
418
+ --update-btn-hover-bg: rgba(0, 0, 0, 0.04);
419
+ --update-primary: #1677ff;
420
+ --update-primary-hover: #4096ff;
421
+ --update-mask: rgba(0, 0, 0, 0.45);
422
+ --update-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12),
423
+ 0 9px 28px 8px rgba(0, 0, 0, 0.05);
424
+ }
425
+
426
+ .cdfrd-update-notice[data-update-notice-theme='dark'] {
427
+ --update-bg: #1f1f1f;
428
+ --update-text: rgba(255, 255, 255, 0.85);
429
+ --update-text-secondary: rgba(255, 255, 255, 0.65);
430
+ --update-border: #303030;
431
+ --update-btn-border: #424242;
432
+ --update-btn-hover-bg: rgba(255, 255, 255, 0.08);
433
+ --update-primary: #1668dc;
434
+ --update-primary-hover: #3c89e8;
435
+ --update-mask: rgba(0, 0, 0, 0.65);
436
+ --update-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.32), 0 3px 6px -4px rgba(0, 0, 0, 0.48),
437
+ 0 9px 28px 8px rgba(0, 0, 0, 0.2);
438
+ }
439
+
440
+ .cdfrd-update-notice {
441
+ position: fixed;
442
+ z-index: 99999;
443
+ box-sizing: border-box;
444
+ max-width: calc(100vw - 48px);
445
+ user-select: none;
446
+ pointer-events: none;
447
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
448
+ 'Noto Sans', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
449
+ }
450
+
451
+ .cdfrd-update-notice:not(.cdfrd-update-notice--forced) {
452
+ width: 384px;
453
+ }
454
+
455
+ .cdfrd-update-notice-panel {
456
+ pointer-events: auto;
457
+ position: relative;
458
+ box-sizing: border-box;
459
+ width: 100%;
460
+ padding: 16px 24px;
461
+ border-radius: 8px;
462
+ background: var(--update-bg);
463
+ color: var(--update-text);
464
+ border: 1px solid var(--update-border);
465
+ box-shadow: var(--update-shadow);
466
+ }
467
+
468
+ .cdfrd-update-notice-header {
469
+ display: flex;
470
+ align-items: flex-start;
471
+ gap: 8px;
472
+ margin-bottom: 4px;
473
+ }
474
+
475
+ .cdfrd-update-notice-title {
476
+ flex: 1;
477
+ min-width: 0;
478
+ font-size: 16px;
479
+ font-weight: 600;
480
+ line-height: 1.5;
481
+ color: var(--update-text);
482
+ }
483
+
484
+ .cdfrd-update-notice-close {
485
+ flex-shrink: 0;
486
+ cursor: pointer;
487
+ width: 22px;
488
+ height: 22px;
489
+ padding: 0;
490
+ border: none;
491
+ border-radius: 4px;
492
+ background: transparent;
493
+ color: var(--update-text-secondary);
494
+ font-size: 16px;
495
+ line-height: 22px;
496
+ }
497
+
498
+ .cdfrd-update-notice-close:hover {
499
+ color: var(--update-text);
500
+ background: var(--update-btn-hover-bg);
501
+ }
502
+
503
+ .cdfrd-update-notice-desc {
504
+ font-size: 14px;
505
+ line-height: 1.5714;
506
+ color: var(--update-text-secondary);
507
+ margin: 0 0 12px;
508
+ }
509
+
510
+ .cdfrd-update-notice-actions {
511
+ display: flex;
512
+ align-items: center;
513
+ justify-content: flex-end;
514
+ gap: 8px;
515
+ }
516
+
517
+ .cdfrd-update-notice-btn {
518
+ cursor: pointer;
519
+ font-size: 14px;
520
+ line-height: 1.5714;
521
+ height: 32px;
522
+ padding: 4px 15px;
523
+ border: 1px solid var(--update-btn-border);
524
+ border-radius: 6px;
525
+ background: var(--update-bg);
526
+ color: var(--update-text);
527
+ box-sizing: border-box;
528
+ transition: all 0.2s;
529
+ }
530
+
531
+ .cdfrd-update-notice-btn:hover {
532
+ color: var(--update-primary);
533
+ border-color: var(--update-primary);
534
+ }
535
+
536
+ .cdfrd-update-notice-btn-primary {
537
+ background: var(--update-primary);
538
+ border-color: var(--update-primary);
539
+ color: #fff;
540
+ }
541
+
542
+ .cdfrd-update-notice-btn-primary:hover {
543
+ background: var(--update-primary-hover);
544
+ border-color: var(--update-primary-hover);
545
+ color: #fff;
546
+ }
547
+
548
+ /* Forced centered modal \u2014 Ant Design Modal */
549
+ .cdfrd-update-notice--forced {
550
+ inset: 0;
551
+ max-width: none;
552
+ width: 100%;
553
+ height: 100%;
554
+ display: flex;
555
+ align-items: center;
556
+ justify-content: center;
557
+ pointer-events: auto;
558
+ background: var(--update-mask);
559
+ padding: 24px;
560
+ }
561
+
562
+ .cdfrd-update-notice--forced .cdfrd-update-notice-panel {
563
+ width: min(416px, 100%);
564
+ padding: 20px 24px;
565
+ border: none;
566
+ text-align: left;
567
+ }
568
+
569
+ .cdfrd-update-notice--forced .cdfrd-update-notice-title {
570
+ margin-bottom: 8px;
571
+ }
572
+
573
+ .cdfrd-update-notice--forced .cdfrd-update-notice-desc {
574
+ margin-bottom: 0;
575
+ }
576
+
577
+ .cdfrd-update-notice--forced .cdfrd-update-notice-actions {
578
+ margin-top: 12px;
579
+ justify-content: flex-end;
580
+ }
581
+ `.trim();
582
+
583
+ // src/notification/inject-styles.ts
584
+ function ensureDefaultStyles() {
585
+ if (typeof document === "undefined") return;
586
+ if (document.getElementById(INJECT_STYLE_TAG_ID)) return;
587
+ if (!document.head) return;
588
+ const style = document.createElement("style");
589
+ style.id = INJECT_STYLE_TAG_ID;
590
+ style.textContent = DEFAULT_NOTICE_CSS;
591
+ document.head.appendChild(style);
592
+ }
593
+
594
+ // src/theme/resolve-primary.ts
595
+ var ANT_PRIMARY_VARS = [
596
+ "--ant-color-primary",
597
+ "--ant-primary-color",
598
+ "--colorPrimary"
599
+ ];
600
+ function isInvalidColor(color) {
601
+ if (!color) return true;
602
+ const c = color.trim().toLowerCase();
603
+ if (!c || c === "transparent" || c === "rgba(0, 0, 0, 0)" || c === "rgba(0,0,0,0)") return true;
604
+ if (c === "buttonface" || c === "canvas" || c === "rgba(239, 239, 239, 1)" || c === "rgb(239, 239, 239)") {
605
+ return true;
606
+ }
607
+ return false;
608
+ }
609
+ function readCssVarFromElement(el2) {
610
+ try {
611
+ const style = getComputedStyle(el2);
612
+ for (const name of ANT_PRIMARY_VARS) {
613
+ const value = style.getPropertyValue(name)?.trim();
614
+ if (!isInvalidColor(value)) return value;
615
+ }
616
+ } catch {
617
+ return null;
618
+ }
619
+ return null;
620
+ }
621
+ function readCssVariablePrimary() {
622
+ if (typeof document === "undefined") return null;
623
+ const btn = document.querySelector(".ant-btn-primary");
624
+ if (btn) {
625
+ let el2 = btn;
626
+ while (el2) {
627
+ const value = readCssVarFromElement(el2);
628
+ if (value) return value;
629
+ el2 = el2.parentElement;
630
+ }
631
+ }
632
+ for (const root of [document.documentElement, document.body]) {
633
+ if (!root) continue;
634
+ const value = readCssVarFromElement(root);
635
+ if (value) return value;
636
+ }
637
+ return null;
638
+ }
639
+ function readExistingPrimaryButtonBg() {
640
+ if (typeof document === "undefined") return null;
641
+ const btn = document.querySelector(".ant-btn-primary");
642
+ if (!btn) return null;
643
+ try {
644
+ const color = getComputedStyle(btn).backgroundColor;
645
+ return isInvalidColor(color) ? null : color;
646
+ } catch {
647
+ return null;
648
+ }
649
+ }
650
+ var suppressThemeWatch = 0;
651
+ function beginSuppressThemeWatch() {
652
+ suppressThemeWatch += 1;
653
+ }
654
+ function endSuppressThemeWatch() {
655
+ void Promise.resolve().then(() => {
656
+ suppressThemeWatch = Math.max(0, suppressThemeWatch - 1);
657
+ });
658
+ }
659
+ function probePrimaryButton() {
660
+ if (typeof document === "undefined" || !document.body) return null;
661
+ beginSuppressThemeWatch();
662
+ try {
663
+ const probe = document.createElement("button");
664
+ probe.className = "ant-btn ant-btn-primary";
665
+ probe.setAttribute("aria-hidden", "true");
666
+ probe.tabIndex = -1;
667
+ probe.style.cssText = "position:absolute;left:0;top:0;opacity:0;pointer-events:none;width:0;height:0;overflow:hidden;";
668
+ document.body.appendChild(probe);
669
+ const color = getComputedStyle(probe).backgroundColor;
670
+ probe.remove();
671
+ return isInvalidColor(color) ? null : color;
672
+ } catch {
673
+ return null;
674
+ } finally {
675
+ endSuppressThemeWatch();
676
+ }
677
+ }
678
+ function tryResolveAntdPrimaryDetailed(options) {
679
+ try {
680
+ const allowProbe = options?.allowProbe !== false;
681
+ const cssVar = readCssVariablePrimary();
682
+ if (cssVar) return { color: cssVar, source: "cssVar" };
683
+ const btnBg = readExistingPrimaryButtonBg();
684
+ if (btnBg) return { color: btnBg, source: "btnBg" };
685
+ if (allowProbe) {
686
+ const probed = probePrimaryButton();
687
+ if (probed) return { color: probed, source: "probe" };
688
+ }
689
+ return null;
690
+ } catch {
691
+ return null;
692
+ }
693
+ }
694
+ function tryResolveAntdPrimaryColor(options) {
695
+ return tryResolveAntdPrimaryDetailed(options)?.color ?? null;
696
+ }
697
+ function resolveCssVariablePrimary(config, theme) {
698
+ const primary = config?.primaryColor;
699
+ if (!primary) return DEFAULT_PRIMARY_COLOR;
700
+ if (typeof primary === "string") return primary;
701
+ return primary[theme] || primary.light || DEFAULT_PRIMARY_COLOR;
702
+ }
703
+ function scheduleFrame(cb) {
704
+ if (typeof requestAnimationFrame === "function") {
705
+ requestAnimationFrame(() => cb());
706
+ } else {
707
+ setTimeout(cb, 0);
708
+ }
709
+ }
710
+ function resolvePrimaryColorLazy(config, theme, onDone, maxAttempts = THEME_RETRY_MAX, allowProbe = true) {
711
+ const type = config?.type ?? "antd";
712
+ if (type === "cssVariable") {
713
+ onDone(resolveCssVariablePrimary(config, theme));
714
+ return;
715
+ }
716
+ let attempts = 0;
717
+ const run = () => {
718
+ attempts += 1;
719
+ const found = tryResolveAntdPrimaryColor({ allowProbe });
720
+ if (found) {
721
+ onDone(found);
722
+ return;
723
+ }
724
+ if (attempts < maxAttempts) {
725
+ scheduleFrame(run);
726
+ return;
727
+ }
728
+ onDone(DEFAULT_PRIMARY_COLOR);
729
+ };
730
+ run();
731
+ }
732
+ function isUpdateNoticeMutationTarget(node) {
733
+ if (!node || node.nodeType !== Node.ELEMENT_NODE) return false;
734
+ const el2 = node;
735
+ if (el2.id === INJECT_STYLE_TAG_ID) return true;
736
+ return Boolean(
737
+ el2.closest?.(".cdfrd-update-notice") || el2.closest?.(`.${NOTIFICATION_ANCHOR_CLASS_NAME}`)
738
+ );
739
+ }
740
+ function mutationsOnlyAffectNotice(mutations) {
741
+ if (!mutations.length) return false;
742
+ return mutations.every((m) => {
743
+ if (isUpdateNoticeMutationTarget(m.target)) return true;
744
+ if (m.type === "childList") {
745
+ const nodes = [...Array.from(m.addedNodes), ...Array.from(m.removedNodes)];
746
+ return nodes.length > 0 && nodes.every((n) => isUpdateNoticeMutationTarget(n));
747
+ }
748
+ return false;
749
+ });
750
+ }
751
+ function watchThemeChanges(config, getTheme, onChange) {
752
+ if (typeof document === "undefined") {
753
+ return () => void 0;
754
+ }
755
+ const adapterType = config?.type ?? "antd";
756
+ if (adapterType === "cssVariable") {
757
+ return () => void 0;
758
+ }
759
+ if (typeof MutationObserver === "undefined") {
760
+ return () => void 0;
761
+ }
762
+ let last = "";
763
+ let btnBgCandidate = "";
764
+ let debounceTimer;
765
+ let settleTimer;
766
+ const clearTimers = () => {
767
+ if (debounceTimer !== void 0) clearTimeout(debounceTimer);
768
+ if (settleTimer !== void 0) clearTimeout(settleTimer);
769
+ debounceTimer = void 0;
770
+ settleTimer = void 0;
771
+ };
772
+ const evaluate = () => {
773
+ const found = tryResolveAntdPrimaryDetailed({ allowProbe: false });
774
+ if (!found) return;
775
+ const { color, source } = found;
776
+ if (color === last) {
777
+ btnBgCandidate = "";
778
+ return;
779
+ }
780
+ if (source === "btnBg" && color !== btnBgCandidate) {
781
+ btnBgCandidate = color;
782
+ if (settleTimer !== void 0) clearTimeout(settleTimer);
783
+ settleTimer = setTimeout(() => {
784
+ settleTimer = void 0;
785
+ evaluate();
786
+ }, THEME_WATCH_DEBOUNCE_MS);
787
+ return;
788
+ }
789
+ last = color;
790
+ btnBgCandidate = "";
791
+ onChange(color);
792
+ };
793
+ const schedule = (mutations) => {
794
+ if (suppressThemeWatch > 0) return;
795
+ if (mutations && mutationsOnlyAffectNotice(mutations)) return;
796
+ if (debounceTimer !== void 0) clearTimeout(debounceTimer);
797
+ debounceTimer = setTimeout(() => {
798
+ debounceTimer = void 0;
799
+ btnBgCandidate = "";
800
+ evaluate();
801
+ }, THEME_WATCH_DEBOUNCE_MS);
802
+ };
803
+ const observer = new MutationObserver((mutations) => schedule(mutations));
804
+ const attrFilter = ["class", "style", "data-theme", "data-update-notice-theme"];
805
+ observer.observe(document.documentElement, {
806
+ attributes: true,
807
+ attributeFilter: attrFilter
808
+ });
809
+ if (document.body) {
810
+ observer.observe(document.body, {
811
+ attributes: true,
812
+ attributeFilter: attrFilter,
813
+ childList: true,
814
+ subtree: true
815
+ });
816
+ }
817
+ if (document.head) {
818
+ observer.observe(document.head, { childList: true, subtree: true });
819
+ }
820
+ schedule();
821
+ return () => {
822
+ clearTimers();
823
+ observer.disconnect();
824
+ };
825
+ }
826
+
827
+ // src/notification/NotificationManager.ts
828
+ var visible = false;
829
+ var lastShowOptions = null;
830
+ var lastLocale = "zh_CN";
831
+ var currentPrimary = "";
832
+ function el(tag, className, text) {
833
+ const node = document.createElement(tag);
834
+ node.className = className;
835
+ if (text !== void 0) node.textContent = text;
836
+ return node;
837
+ }
838
+ function applyPrimaryToNode(node, primary) {
839
+ if (!primary) return;
840
+ node.style.setProperty("--update-primary", primary);
841
+ node.style.setProperty("--update-primary-hover", primary);
842
+ }
843
+ function applyTheme(theme) {
844
+ ensureDefaultStyles();
845
+ document.documentElement.setAttribute("data-update-notice-theme", theme);
846
+ document.querySelectorAll(".cdfrd-update-notice").forEach((node) => {
847
+ node.setAttribute("data-update-notice-theme", theme);
848
+ });
849
+ }
850
+ function applyPrimaryColor(primary) {
851
+ beginSuppressThemeWatch();
852
+ try {
853
+ currentPrimary = primary;
854
+ document.querySelectorAll(".cdfrd-update-notice").forEach((node) => {
855
+ applyPrimaryToNode(node, primary);
856
+ });
857
+ } finally {
858
+ endSuppressThemeWatch();
859
+ }
860
+ }
861
+ function closeDefaultNotice() {
862
+ document.querySelector(".cdfrd-update-notice")?.remove();
863
+ visible = false;
864
+ lastShowOptions = null;
865
+ }
866
+ function applyLocale(locale) {
867
+ const wrap = document.querySelector(".cdfrd-update-notice");
868
+ if (!wrap || !lastShowOptions) return;
869
+ lastLocale = locale;
870
+ const copy = resolveNotificationCopy(lastShowOptions, locale);
871
+ const forced = lastShowOptions.forcedUpdate === true;
872
+ const titleEl = wrap.querySelector(".cdfrd-update-notice-title");
873
+ const descEl = wrap.querySelector(".cdfrd-update-notice-desc");
874
+ const refreshEl = wrap.querySelector(`.${NOTIFICATION_REFRESH_BTN_CLASS}`);
875
+ const dismissEl = wrap.querySelector(`.${NOTIFICATION_DISMISS_BTN_CLASS}`);
876
+ if (titleEl) titleEl.textContent = forced ? copy.forcedTitle : copy.title;
877
+ if (descEl) descEl.textContent = forced ? copy.forcedDescription : copy.description;
878
+ if (refreshEl) refreshEl.textContent = copy.buttonText;
879
+ if (dismissEl) dismissEl.textContent = copy.dismissButtonText;
880
+ }
881
+ function showDefaultNotice(options) {
882
+ ensureDefaultStyles();
883
+ const existing = document.querySelector(".cdfrd-update-notice");
884
+ if (visible && existing) return false;
885
+ if (visible && !existing) visible = false;
886
+ const copy = resolveNotificationCopy(options.options, options.locale);
887
+ const placement = options.options.placement ?? "topRight";
888
+ const forced = options.options.forcedUpdate === true;
889
+ const theme = options.theme ?? "light";
890
+ const primary = options.primaryColor || currentPrimary;
891
+ const wrap = document.createElement("div");
892
+ wrap.className = forced ? "cdfrd-update-notice cdfrd-update-notice--forced" : "cdfrd-update-notice";
893
+ wrap.setAttribute("data-update-notice-theme", theme);
894
+ if (!forced) {
895
+ wrap.style.cssText = PLACEMENT_STYLES[placement] ?? PLACEMENT_STYLES.topRight;
896
+ }
897
+ if (primary) applyPrimaryToNode(wrap, primary);
898
+ const panel = el("div", "cdfrd-update-notice-panel");
899
+ if (forced) {
900
+ panel.appendChild(el("div", "cdfrd-update-notice-title", copy.forcedTitle));
901
+ panel.appendChild(el("div", "cdfrd-update-notice-desc", copy.forcedDescription));
902
+ const actions = el("div", "cdfrd-update-notice-actions");
903
+ const refreshBtn = el(
904
+ "button",
905
+ `cdfrd-update-notice-btn cdfrd-update-notice-btn-primary ${NOTIFICATION_REFRESH_BTN_CLASS}`,
906
+ copy.buttonText
907
+ );
908
+ refreshBtn.setAttribute("type", "button");
909
+ actions.appendChild(refreshBtn);
910
+ panel.appendChild(actions);
911
+ } else {
912
+ const header = el("div", "cdfrd-update-notice-header");
913
+ header.appendChild(el("div", "cdfrd-update-notice-title", copy.title));
914
+ const closeBtn = el("button", `cdfrd-update-notice-close ${NOTIFICATION_CLOSE_BTN_CLASS}`, "\xD7");
915
+ closeBtn.setAttribute("type", "button");
916
+ closeBtn.setAttribute("aria-label", "close");
917
+ header.appendChild(closeBtn);
918
+ panel.appendChild(header);
919
+ panel.appendChild(el("div", "cdfrd-update-notice-desc", copy.description));
920
+ const actions = el("div", "cdfrd-update-notice-actions");
921
+ const dismissBtn = el(
922
+ "button",
923
+ `cdfrd-update-notice-btn ${NOTIFICATION_DISMISS_BTN_CLASS}`,
924
+ copy.dismissButtonText
925
+ );
926
+ dismissBtn.setAttribute("type", "button");
927
+ actions.appendChild(dismissBtn);
928
+ const refreshBtn = el(
929
+ "button",
930
+ `cdfrd-update-notice-btn cdfrd-update-notice-btn-primary ${NOTIFICATION_REFRESH_BTN_CLASS}`,
931
+ copy.buttonText
932
+ );
933
+ refreshBtn.setAttribute("type", "button");
934
+ actions.appendChild(refreshBtn);
935
+ panel.appendChild(actions);
936
+ }
937
+ wrap.appendChild(panel);
938
+ let anchor = document.body.querySelector(`:scope > .cdfrd-update-notice-anchor`);
939
+ if (!anchor) {
940
+ anchor = document.createElement("div");
941
+ anchor.className = "cdfrd-update-notice-anchor";
942
+ document.body.appendChild(anchor);
943
+ }
944
+ anchor.appendChild(wrap);
945
+ visible = true;
946
+ lastShowOptions = options.options;
947
+ lastLocale = options.locale;
948
+ wrap.querySelector(`.${NOTIFICATION_REFRESH_BTN_CLASS}`)?.addEventListener("click", () => {
949
+ options.onRefresh();
950
+ });
951
+ wrap.querySelector(`.${NOTIFICATION_DISMISS_BTN_CLASS}`)?.addEventListener("click", () => {
952
+ options.onDismiss();
953
+ closeDefaultNotice();
954
+ });
955
+ wrap.querySelector(`.${NOTIFICATION_CLOSE_BTN_CLASS}`)?.addEventListener("click", () => {
956
+ options.onClose?.();
957
+ closeDefaultNotice();
958
+ });
959
+ return true;
960
+ }
961
+
962
+ // src/manager/UpdateNoticeManager.ts
963
+ var UpdateNoticeManager = class _UpdateNoticeManager {
964
+ constructor() {
965
+ this.activeApp = null;
966
+ this.locale = "zh_CN";
967
+ this.theme = "light";
968
+ this.primaryColor = "";
969
+ /** Bumped on each setTheme so late antd resolve callbacks cannot overwrite newer results. */
970
+ this.primaryResolveGen = 0;
971
+ this.runtimes = /* @__PURE__ */ new Map();
972
+ }
973
+ static getOrCreate() {
974
+ if (!window.updateNoticeManager) {
975
+ window.updateNoticeManager = new _UpdateNoticeManager();
976
+ }
977
+ return window.updateNoticeManager;
978
+ }
979
+ /** First create applies Manager-level defaults; later creates only register runtimes */
980
+ register(options, isFirstCreate) {
981
+ validateOptions(options);
982
+ if (isFirstCreate) {
983
+ this.themeAdapter = options.themeAdapter;
984
+ if (options.locale?.default) this.locale = options.locale.default;
985
+ applyTheme(this.theme);
986
+ this.startThemeWatch();
987
+ }
988
+ const runtime = new UpdateNoticeRuntime(this, options);
989
+ const previous = this.runtimes.get(runtime.appKey);
990
+ if (previous && previous !== runtime) previous.destroy();
991
+ this.runtimes.set(runtime.appKey, runtime);
992
+ runtime.bootstrap();
993
+ if (shouldShowDefaultUi(options)) {
994
+ ensureNotificationAnchor();
995
+ }
996
+ if (this.isRuntimeActive(runtime)) {
997
+ runtime.checkUpdate();
998
+ }
999
+ return runtime;
1000
+ }
1001
+ setActiveApp(appId, options = { immediateCheck: true }) {
1002
+ const changed = this.activeApp !== appId;
1003
+ this.activeApp = appId;
1004
+ if (changed) {
1005
+ closeDefaultNotice();
1006
+ this.startThemeWatch();
1007
+ this.refreshPrimaryColor();
1008
+ }
1009
+ this.flushPendingForActiveApp();
1010
+ const immediateCheck = options.immediateCheck ?? true;
1011
+ if (immediateCheck && changed) {
1012
+ for (const runtime of this.runtimes.values()) {
1013
+ if (this.isRuntimeActive(runtime)) runtime.checkUpdate();
1014
+ }
1015
+ }
1016
+ }
1017
+ checkUpdate() {
1018
+ for (const runtime of this.runtimes.values()) runtime.checkUpdate();
1019
+ }
1020
+ isRuntimeActive(runtime) {
1021
+ if (!runtime.appId) return true;
1022
+ return runtime.appId === this.activeApp;
1023
+ }
1024
+ /** Prefer the active runtime's adapter; fall back to Manager default (first create). */
1025
+ getActiveThemeAdapter() {
1026
+ for (const runtime of this.runtimes.values()) {
1027
+ if (this.isRuntimeActive(runtime)) {
1028
+ return runtime.options.themeAdapter ?? this.themeAdapter;
1029
+ }
1030
+ }
1031
+ return this.themeAdapter;
1032
+ }
1033
+ setLocale(locale) {
1034
+ this.locale = locale;
1035
+ applyLocale(locale);
1036
+ }
1037
+ setTheme(theme) {
1038
+ this.theme = theme;
1039
+ applyTheme(theme);
1040
+ const gen = ++this.primaryResolveGen;
1041
+ const adapter = this.getActiveThemeAdapter();
1042
+ const detailed = (adapter?.type ?? "antd") === "antd" ? tryResolveAntdPrimaryDetailed() : null;
1043
+ if (detailed?.source === "btnBg") {
1044
+ return;
1045
+ }
1046
+ this.refreshPrimaryColor(gen);
1047
+ }
1048
+ notifyUpdate(_runtime, _version) {
1049
+ void _runtime;
1050
+ void _version;
1051
+ }
1052
+ showDefaultNotice(runtime, version) {
1053
+ ensureNotificationAnchor();
1054
+ const adapter = runtime.options.themeAdapter ?? this.themeAdapter;
1055
+ const gen = this.primaryResolveGen;
1056
+ resolvePrimaryColorLazy(adapter, this.theme, (color) => {
1057
+ if (gen !== this.primaryResolveGen) return;
1058
+ this.primaryColor = color;
1059
+ applyPrimaryColor(color);
1060
+ showDefaultNotice({
1061
+ options: runtime.options,
1062
+ version,
1063
+ locale: this.locale,
1064
+ theme: this.theme,
1065
+ primaryColor: color,
1066
+ onRefresh: () => {
1067
+ if (this.onClickRefresh) {
1068
+ this.onClickRefresh(version, runtime.appId);
1069
+ return;
1070
+ }
1071
+ window.location.reload();
1072
+ },
1073
+ onDismiss: () => {
1074
+ if (this.onClickDismiss) {
1075
+ this.onClickDismiss(version, runtime.appId);
1076
+ return;
1077
+ }
1078
+ runtime.dismissVersion(version);
1079
+ }
1080
+ });
1081
+ });
1082
+ return true;
1083
+ }
1084
+ refreshPrimaryColor(gen = this.primaryResolveGen) {
1085
+ const adapter = this.getActiveThemeAdapter();
1086
+ resolvePrimaryColorLazy(adapter, this.theme, (color) => {
1087
+ if (gen !== this.primaryResolveGen) return;
1088
+ this.primaryColor = color;
1089
+ applyPrimaryColor(color);
1090
+ });
1091
+ }
1092
+ startThemeWatch() {
1093
+ this.stopWatchTheme?.();
1094
+ const adapter = this.getActiveThemeAdapter();
1095
+ this.stopWatchTheme = watchThemeChanges(adapter, () => this.theme, (color) => {
1096
+ this.primaryResolveGen += 1;
1097
+ this.primaryColor = color;
1098
+ applyPrimaryColor(color);
1099
+ });
1100
+ }
1101
+ destroy() {
1102
+ this.stopWatchTheme?.();
1103
+ this.stopWatchTheme = void 0;
1104
+ for (const runtime of this.runtimes.values()) runtime.destroy();
1105
+ this.runtimes.clear();
1106
+ closeDefaultNotice();
1107
+ delete window.updateNoticeManager;
1108
+ }
1109
+ flushPendingForActiveApp() {
1110
+ for (const runtime of this.runtimes.values()) runtime.flushPendingUpdate();
1111
+ }
1112
+ };
1113
+ function createUpdateNotice(options = {}) {
1114
+ validateOptions(options);
1115
+ const stamped = { ...options };
1116
+ if (options.versionBase === void 0 || options.versionBase === null) {
1117
+ const poweredByQiankun = Boolean(
1118
+ window.__POWERED_BY_QIANKUN__ || window.proxy?.__POWERED_BY_QIANKUN__
1119
+ );
1120
+ if (options.microApp?.enabled && poweredByQiankun) {
1121
+ const microBase = resolveMicroVersionBase();
1122
+ if (microBase) stamped.versionBase = microBase;
1123
+ } else if (options.microApp?.enabled) {
1124
+ const microBase = resolveMicroVersionBase();
1125
+ if (microBase && /^https?:\/\//i.test(microBase) && typeof location !== "undefined" && new URL(microBase).origin !== location.origin) {
1126
+ stamped.versionBase = microBase;
1127
+ } else {
1128
+ stamped.versionBase = resolveVersionBase();
1129
+ }
1130
+ } else {
1131
+ stamped.versionBase = resolveVersionBase();
1132
+ }
1133
+ }
1134
+ const existed = Boolean(window.updateNoticeManager);
1135
+ const manager = UpdateNoticeManager.getOrCreate();
1136
+ manager.register(stamped, !existed);
1137
+ return manager;
1138
+ }
1139
+ function getUpdateNotice() {
1140
+ return window.updateNoticeManager;
1141
+ }
1142
+ // Annotate the CommonJS export names for ESM import in node:
1143
+ 0 && (module.exports = {
1144
+ UpdateNoticeManager,
1145
+ createUpdateNotice,
1146
+ getUpdateNotice
1147
+ });
1148
+ //# sourceMappingURL=index.cjs.map