@arcblock/did-connect-service 4.1.41 → 4.1.42
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/_generated/asset-bytes.js +1 -1
- package/dist/_generated/asset-manifest.js +2 -2
- package/dist/app-identity.d.ts +83 -11
- package/dist/app-identity.d.ts.map +1 -1
- package/dist/app-identity.js +108 -20
- package/dist/app-identity.js.map +1 -1
- package/dist/assets/{admin-extra.c7a0720f.js → admin-extra.da2c9785.js} +164 -10
- package/dist/assets/{admin.ab0009f2.css → admin.d99b416e.css} +23 -0
- package/dist/blocklet-service.d.ts +7 -0
- package/dist/blocklet-service.d.ts.map +1 -1
- package/dist/blocklet-service.js +17 -1
- package/dist/blocklet-service.js.map +1 -1
- package/dist/branding-sources.d.ts +60 -0
- package/dist/branding-sources.d.ts.map +1 -0
- package/dist/branding-sources.js +55 -0
- package/dist/branding-sources.js.map +1 -0
- package/dist/embedded.d.ts +11 -0
- package/dist/embedded.d.ts.map +1 -1
- package/dist/embedded.js +42 -32
- package/dist/embedded.js.map +1 -1
- package/dist/handlers/auth-handler.d.ts +18 -0
- package/dist/handlers/auth-handler.d.ts.map +1 -1
- package/dist/handlers/auth-handler.js +5 -0
- package/dist/handlers/auth-handler.js.map +1 -1
- package/dist/handlers/blocklet-js-handler.d.ts.map +1 -1
- package/dist/handlers/blocklet-js-handler.js +30 -18
- package/dist/handlers/blocklet-js-handler.js.map +1 -1
- package/dist/handlers/branding-handler.d.ts +67 -0
- package/dist/handlers/branding-handler.d.ts.map +1 -1
- package/dist/handlers/branding-handler.js +142 -57
- package/dist/handlers/branding-handler.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/logo-paths.d.ts +23 -0
- package/dist/logo-paths.d.ts.map +1 -1
- package/dist/logo-paths.js +57 -2
- package/dist/logo-paths.js.map +1 -1
- package/dist/package-branding.d.ts +95 -0
- package/dist/package-branding.d.ts.map +1 -1
- package/dist/package-branding.js +85 -4
- package/dist/package-branding.js.map +1 -1
- package/dist/pages/admin/i18n.d.ts.map +1 -1
- package/dist/pages/admin/i18n.js +32 -0
- package/dist/pages/admin/i18n.js.map +1 -1
- package/dist/pages/admin/styles.d.ts +1 -1
- package/dist/pages/admin/styles.d.ts.map +1 -1
- package/dist/pages/admin/styles.js +23 -0
- package/dist/pages/admin/styles.js.map +1 -1
- package/dist/pages/admin/tab-branding.d.ts.map +1 -1
- package/dist/pages/admin/tab-branding.js +180 -15
- package/dist/pages/admin/tab-branding.js.map +1 -1
- package/dist/theme-utils.d.ts +21 -0
- package/dist/theme-utils.d.ts.map +1 -1
- package/dist/theme-utils.js +62 -0
- package/dist/theme-utils.js.map +1 -1
- package/package.json +3 -3
|
@@ -46,6 +46,10 @@ function logoGridHTML(t) {
|
|
|
46
46
|
<div class="logo-item-footer">
|
|
47
47
|
<div class="logo-name">${t(l.nameKey)}</div>
|
|
48
48
|
<div class="logo-subtitle">${t(l.subKey)}</div>
|
|
49
|
+
<div class="br-src-row"><span class="br-src-slot" id="br-src-logo-${l.type}"></span>${
|
|
50
|
+
// The CF Worker OG renderer drops uploaded backgrounds (og/worker.ts), so this
|
|
51
|
+
// slot only takes effect on Node — say so, and never claim the package layer.
|
|
52
|
+
l.type === "og-image" ? `<span class="br-src br-src-note">${t("branding.sourceNodeOnly")}</span>` : ""}</div>
|
|
49
53
|
</div>
|
|
50
54
|
<label class="logo-hover-upload" id="br-logo-actions-${l.type}">
|
|
51
55
|
<span class="logo-hover-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg></span>
|
|
@@ -54,6 +58,13 @@ function logoGridHTML(t) {
|
|
|
54
58
|
</label>
|
|
55
59
|
</div>`).join("\n");
|
|
56
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Where the per-field source badge (did#249) and its restore action render. Filled by
|
|
63
|
+
* the client from `GET /api/branding`'s `sources`; empty until then.
|
|
64
|
+
*/
|
|
65
|
+
function sourceSlotHTML(field) {
|
|
66
|
+
return ` <span class="br-src-slot" id="br-src-${field}"></span><button type="button" class="btn-text br-restore" id="br-restore-${field}" hidden onclick="restoreBrandingField('${field}')"></button>`;
|
|
67
|
+
}
|
|
57
68
|
export function brandingTabHtml(t) {
|
|
58
69
|
return /* html */ `
|
|
59
70
|
<div data-panel="branding" class="hidden tab-panel">
|
|
@@ -81,8 +92,8 @@ export function brandingTabHtml(t) {
|
|
|
81
92
|
<div class="br-panel">
|
|
82
93
|
<div style="display:grid;grid-template-columns:1fr 1fr;gap:16px;">
|
|
83
94
|
<div class="form-group">
|
|
84
|
-
<label class="form-label">${t("branding.name")} <span class="info-tip" data-tip="${t("branding.nameHint")}">i</span
|
|
85
|
-
<input class="input" type="text" id="br-name" placeholder="${t("branding.namePlaceholder")}" oninput="
|
|
95
|
+
<label class="form-label">${t("branding.name")} <span class="info-tip" data-tip="${t("branding.nameHint")}">i</span>${sourceSlotHTML("name")}</label>
|
|
96
|
+
<input class="input" type="text" id="br-name" placeholder="${t("branding.namePlaceholder")}" oninput="onBrandingFieldInput('name')" />
|
|
86
97
|
</div>
|
|
87
98
|
<div class="form-group">
|
|
88
99
|
<label class="form-label">${t("branding.url")} <span class="info-tip" data-tip="${t("branding.urlHint")}">i</span></label>
|
|
@@ -90,8 +101,8 @@ export function brandingTabHtml(t) {
|
|
|
90
101
|
</div>
|
|
91
102
|
</div>
|
|
92
103
|
<div class="form-group">
|
|
93
|
-
<label class="form-label">${t("branding.description")} <span class="info-tip" data-tip="${t("branding.descHint")}">i</span
|
|
94
|
-
<textarea class="input" id="br-desc" placeholder="${t("branding.descPlaceholder")}" rows="3" oninput="
|
|
104
|
+
<label class="form-label">${t("branding.description")} <span class="info-tip" data-tip="${t("branding.descHint")}">i</span>${sourceSlotHTML("description")}</label>
|
|
105
|
+
<textarea class="input" id="br-desc" placeholder="${t("branding.descPlaceholder")}" rows="3" oninput="onBrandingFieldInput('description')"></textarea>
|
|
95
106
|
</div>
|
|
96
107
|
</div>
|
|
97
108
|
</div>
|
|
@@ -127,7 +138,7 @@ export function brandingTabHtml(t) {
|
|
|
127
138
|
</div>
|
|
128
139
|
</div>
|
|
129
140
|
<div class="form-group">
|
|
130
|
-
<label class="form-label">${t("branding.accentSection")}</label>
|
|
141
|
+
<label class="form-label">${t("branding.accentSection")}${sourceSlotHTML("passportColor")}</label>
|
|
131
142
|
<div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap;">
|
|
132
143
|
<input type="color" id="br-accent-picker" value="#1DC1C7" style="width:32px;height:32px;border:none;border-radius:50%;cursor:pointer;background:none;" oninput="onAccentInput(this.value)" />
|
|
133
144
|
<input class="input" type="text" id="br-accent-hex" value="#1DC1C7" style="width:100px;margin-bottom:0;" oninput="onAccentInput(this.value)" />
|
|
@@ -202,6 +213,124 @@ async function brandingApi(method, path, body) {
|
|
|
202
213
|
var __brandingData = {};
|
|
203
214
|
var __brandingDirty = false;
|
|
204
215
|
var __pendingLogos = {}; // { camelType: r2Key } for new uploads, { camelType: null } for deletions
|
|
216
|
+
// Fields whose instance override is to be removed on save ("restore default" — did#249).
|
|
217
|
+
// Saved as "null", which DELETES the stored key; the inherited value is never written.
|
|
218
|
+
var __pendingRestore = {};
|
|
219
|
+
// The passport color the picker showed on load when it was not overridden (inherited
|
|
220
|
+
// or built-in) — saving it back unchanged must not turn it into an override.
|
|
221
|
+
var __brShownPassportColor = "";
|
|
222
|
+
|
|
223
|
+
// ─── Per-field source badges (did#249) ───────────────────────────────
|
|
224
|
+
// Every origin "resolveAppIdentity" can report maps to a label, so a new layer
|
|
225
|
+
// (the package layer of S5/S8) lights up here without a client change.
|
|
226
|
+
var __BR_SOURCE_LABELS = {
|
|
227
|
+
instance: "branding.sourceOverridden",
|
|
228
|
+
"package": "branding.sourcePackage",
|
|
229
|
+
deployment: "branding.sourceDeployment",
|
|
230
|
+
"default": "branding.sourceDefault"
|
|
231
|
+
};
|
|
232
|
+
var __BR_LOGO_SLOT_TYPES = ${JSON.stringify(LOGO_TYPES.map((l) => ({ type: l.type, nameKey: l.nameKey, subKey: l.subKey })))};
|
|
233
|
+
|
|
234
|
+
function brCamelType(type) {
|
|
235
|
+
return type.replace(/-([a-z])/g, function(_, c) { return c.toUpperCase(); });
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function brSlotLabel(camelSlot) {
|
|
239
|
+
for (var i = 0; i < __BR_LOGO_SLOT_TYPES.length; i++) {
|
|
240
|
+
var l = __BR_LOGO_SLOT_TYPES[i];
|
|
241
|
+
if (brCamelType(l.type) === camelSlot) return __t(l.nameKey) + " \u00B7 " + __t(l.subKey);
|
|
242
|
+
}
|
|
243
|
+
return camelSlot;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The badge for one slot: { key, from, params } — "slot" is "name" / "description" /
|
|
248
|
+
* "passportColor" or a logo type ("square", "og-image", …); "source" is its entry in
|
|
249
|
+
* the API's "sources". Null when there is nothing to label.
|
|
250
|
+
*/
|
|
251
|
+
function brSourceBadge(slot, source) {
|
|
252
|
+
var from = source && source.from ? source.from : "default";
|
|
253
|
+
if (!Object.prototype.hasOwnProperty.call(__BR_SOURCE_LABELS, from)) from = "default";
|
|
254
|
+
if (slot === "og-image") {
|
|
255
|
+
// The og-image slot never claims the app package (it does not render on CF — its
|
|
256
|
+
// "Node deployments only" note is static); only an override is worth a badge.
|
|
257
|
+
return from === "instance" ? { key: __BR_SOURCE_LABELS.instance, from: "instance" } : null;
|
|
258
|
+
}
|
|
259
|
+
// A logo slot answered through its fallback chain by another OVERRIDDEN slot
|
|
260
|
+
// ("favicon" served by "square") is not itself overridden — name the slot it uses.
|
|
261
|
+
if (from === "instance" && source && source.slot && source.slot !== brCamelType(slot)) {
|
|
262
|
+
return { key: "branding.sourceFollows", from: "follows", params: { slot: brSlotLabel(source.slot) } };
|
|
263
|
+
}
|
|
264
|
+
return { key: __BR_SOURCE_LABELS[from], from: from };
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function brSourceBadgeHtml(slot, source) {
|
|
268
|
+
var b = brSourceBadge(slot, source);
|
|
269
|
+
if (!b) return "";
|
|
270
|
+
return '<span class="br-src br-src-' + b.from + '">' + __t(b.key, b.params) + "</span>";
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** The restore action's label key, or null when the slot is not overridden (nothing to restore). */
|
|
274
|
+
function brRestoreLabelKey(source) {
|
|
275
|
+
if (!source || source.from !== "instance") return null;
|
|
276
|
+
return source.restoreTo && source.restoreTo.from === "package" ? "branding.restorePackage" : "branding.restoreDefault";
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* The value to send for one inheritable field on save:
|
|
281
|
+
* null → restore (delete the stored key)
|
|
282
|
+
* undefined → omit (the field keeps inheriting; nothing is written)
|
|
283
|
+
* string → the operator's value (an override)
|
|
284
|
+
*/
|
|
285
|
+
function brFieldPatch(field, inputValue, stored, restore, shownDefault) {
|
|
286
|
+
if (restore) return null;
|
|
287
|
+
if (stored !== undefined && stored !== null) return inputValue;
|
|
288
|
+
if (field === "passportColor") return inputValue && inputValue !== shownDefault ? inputValue : undefined;
|
|
289
|
+
return inputValue !== "" ? inputValue : undefined;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function renderFieldSource(field, source) {
|
|
293
|
+
var slot = document.getElementById("br-src-" + field);
|
|
294
|
+
if (slot) slot.innerHTML = brSourceBadgeHtml(field, source);
|
|
295
|
+
var btn = document.getElementById("br-restore-" + field);
|
|
296
|
+
if (btn) {
|
|
297
|
+
var key = __pendingRestore[field] ? null : brRestoreLabelKey(source);
|
|
298
|
+
btn.hidden = !key;
|
|
299
|
+
btn.textContent = key ? __t(key) : "";
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function renderLogoSource(type, source) {
|
|
304
|
+
var slot = document.getElementById("br-src-logo-" + type);
|
|
305
|
+
if (slot) slot.innerHTML = brSourceBadgeHtml(type, source);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function onBrandingFieldInput(field) {
|
|
309
|
+
delete __pendingRestore[field];
|
|
310
|
+
markBrandingDirty();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function restoreBrandingField(field) {
|
|
314
|
+
var sources = __brandingData.sources || {};
|
|
315
|
+
var source = sources[field];
|
|
316
|
+
if (!source) return;
|
|
317
|
+
var restoreTo = source.restoreTo || { from: "default" };
|
|
318
|
+
__pendingRestore[field] = true;
|
|
319
|
+
if (field === "name") {
|
|
320
|
+
var nameEl = document.getElementById("br-name");
|
|
321
|
+
nameEl.value = "";
|
|
322
|
+
nameEl.placeholder = restoreTo.value || __t("branding.namePlaceholder");
|
|
323
|
+
} else if (field === "description") {
|
|
324
|
+
var descEl = document.getElementById("br-desc");
|
|
325
|
+
descEl.value = "";
|
|
326
|
+
descEl.placeholder = restoreTo.value || __t("branding.descPlaceholder");
|
|
327
|
+
} else if (field === "passportColor") {
|
|
328
|
+
updateAccentUI(restoreTo.value || "#1DC1C7");
|
|
329
|
+
}
|
|
330
|
+
// Show where the field lands once saved.
|
|
331
|
+
renderFieldSource(field, { from: restoreTo.from });
|
|
332
|
+
markBrandingDirty();
|
|
333
|
+
}
|
|
205
334
|
|
|
206
335
|
function markBrandingDirty() {
|
|
207
336
|
__brandingDirty = true;
|
|
@@ -217,6 +346,7 @@ function hideSaveBar() {
|
|
|
217
346
|
|
|
218
347
|
async function discardBrandingChanges() {
|
|
219
348
|
__pendingLogos = {};
|
|
349
|
+
__pendingRestore = {};
|
|
220
350
|
await loadBranding();
|
|
221
351
|
}
|
|
222
352
|
|
|
@@ -227,10 +357,21 @@ async function loadBranding() {
|
|
|
227
357
|
|
|
228
358
|
// App Info
|
|
229
359
|
var br = data.branding || {};
|
|
230
|
-
|
|
231
|
-
|
|
360
|
+
var sources = data.sources || {};
|
|
361
|
+
__pendingRestore = {};
|
|
362
|
+
var nameEl = document.getElementById("br-name");
|
|
363
|
+
nameEl.value = br.name || "";
|
|
364
|
+
// Not overridden → the input stays empty and shows the inherited value it falls back to.
|
|
365
|
+
nameEl.placeholder = (sources.name && sources.name.from !== "instance" && sources.name.value) || __t("branding.namePlaceholder");
|
|
366
|
+
var descEl = document.getElementById("br-desc");
|
|
367
|
+
descEl.value = br.description || "";
|
|
368
|
+
descEl.placeholder = (sources.description && sources.description.from !== "instance" && sources.description.value) || __t("branding.descPlaceholder");
|
|
232
369
|
document.getElementById("br-url").value = br.url || "";
|
|
233
|
-
var pc = br.passportColor || "#1DC1C7";
|
|
370
|
+
var pc = br.passportColor || (sources.passportColor && sources.passportColor.value) || "#1DC1C7";
|
|
371
|
+
__brShownPassportColor = br.passportColor ? "" : pc;
|
|
372
|
+
renderFieldSource("name", sources.name);
|
|
373
|
+
renderFieldSource("description", sources.description);
|
|
374
|
+
renderFieldSource("passportColor", sources.passportColor);
|
|
234
375
|
document.getElementById("br-passport-color").value = pc;
|
|
235
376
|
document.getElementById("br-copyright-owner").value = (br.copyright && br.copyright.owner) || "";
|
|
236
377
|
document.getElementById("br-copyright-year").value = (br.copyright && br.copyright.year) || "";
|
|
@@ -240,8 +381,11 @@ async function loadBranding() {
|
|
|
240
381
|
|
|
241
382
|
// Logos
|
|
242
383
|
var logos = data.logos || {};
|
|
384
|
+
var logoSources = sources.logos || {};
|
|
243
385
|
${JSON.stringify(LOGO_TYPES)}.forEach(function(l) {
|
|
244
386
|
var key = l.type.replace(/-([a-z])/g, function(_, c) { return c.toUpperCase(); });
|
|
387
|
+
var logoSource = logoSources[key];
|
|
388
|
+
renderLogoSource(l.type, logoSource);
|
|
245
389
|
var preview = document.getElementById("br-logo-preview-" + l.type);
|
|
246
390
|
var actions = document.getElementById("br-logo-actions-" + l.type);
|
|
247
391
|
var item = document.getElementById("br-logo-" + l.type);
|
|
@@ -273,7 +417,10 @@ async function loadBranding() {
|
|
|
273
417
|
replaceLabel.appendChild(replaceInput);
|
|
274
418
|
var discardBtn = document.createElement("button");
|
|
275
419
|
discardBtn.className = "logo-overlay-btn logo-overlay-btn-discard";
|
|
276
|
-
|
|
420
|
+
// Removing the override deletes the slot's stored key; when the app package
|
|
421
|
+
// supplies this slot, say that is where it goes back to.
|
|
422
|
+
var restoreKey = brRestoreLabelKey(logoSource);
|
|
423
|
+
discardBtn.textContent = __t(restoreKey === "branding.restorePackage" ? restoreKey : "branding.removeLogo");
|
|
277
424
|
(function(logoType) {
|
|
278
425
|
discardBtn.onclick = function() { deleteLogo(logoType); };
|
|
279
426
|
})(l.type);
|
|
@@ -281,6 +428,11 @@ async function loadBranding() {
|
|
|
281
428
|
overlay.appendChild(discardBtn);
|
|
282
429
|
item.appendChild(overlay);
|
|
283
430
|
}
|
|
431
|
+
} else if (logoSource && logoSource.from !== "default") {
|
|
432
|
+
// Not set on this slot, but served from another layer or another slot (the app
|
|
433
|
+
// package, or "square" behind "favicon"): show what the public path serves,
|
|
434
|
+
// through the same no-store alias.
|
|
435
|
+
preview.innerHTML = '<img src="${LOGO_PREVIEW_BASE}/' + l.type + '?t=' + Date.now() + '" />';
|
|
284
436
|
} else {
|
|
285
437
|
preview.innerHTML = '';
|
|
286
438
|
}
|
|
@@ -337,12 +489,12 @@ function updateAccentUI(color) {
|
|
|
337
489
|
function onAccentInput(color) {
|
|
338
490
|
if (!color || !color.match(/^#[0-9a-fA-F]{6}$/)) return;
|
|
339
491
|
updateAccentUI(color);
|
|
340
|
-
|
|
492
|
+
onBrandingFieldInput("passportColor");
|
|
341
493
|
}
|
|
342
494
|
|
|
343
495
|
function pickAccent(color) {
|
|
344
496
|
updateAccentUI(color);
|
|
345
|
-
|
|
497
|
+
onBrandingFieldInput("passportColor");
|
|
346
498
|
}
|
|
347
499
|
|
|
348
500
|
async function saveBrandingInfo() {
|
|
@@ -352,15 +504,24 @@ async function saveBrandingInfo() {
|
|
|
352
504
|
if (owner) copyright.owner = owner;
|
|
353
505
|
if (year) copyright.year = year;
|
|
354
506
|
|
|
507
|
+
var stored = __brandingData.branding || {};
|
|
355
508
|
var body = {
|
|
356
509
|
branding: {
|
|
357
|
-
name: document.getElementById("br-name").value.trim(),
|
|
358
|
-
description: document.getElementById("br-desc").value.trim(),
|
|
359
510
|
url: document.getElementById("br-url").value.trim(),
|
|
360
|
-
passportColor: document.getElementById("br-passport-color").value,
|
|
361
511
|
copyright: copyright
|
|
362
512
|
}
|
|
363
513
|
};
|
|
514
|
+
// Inheritable fields (did#249): an untouched inherited field is omitted so it keeps
|
|
515
|
+
// inheriting; a restored one is sent as null so the server deletes its key.
|
|
516
|
+
var inheritable = {
|
|
517
|
+
name: document.getElementById("br-name").value.trim(),
|
|
518
|
+
description: document.getElementById("br-desc").value.trim(),
|
|
519
|
+
passportColor: document.getElementById("br-passport-color").value
|
|
520
|
+
};
|
|
521
|
+
Object.keys(inheritable).forEach(function(field) {
|
|
522
|
+
var patch = brFieldPatch(field, inheritable[field], stored[field], !!__pendingRestore[field], __brShownPassportColor);
|
|
523
|
+
if (patch !== undefined) body.branding[field] = patch;
|
|
524
|
+
});
|
|
364
525
|
|
|
365
526
|
// Also save languages
|
|
366
527
|
var langs = [];
|
|
@@ -387,6 +548,7 @@ async function saveBrandingInfo() {
|
|
|
387
548
|
var res = await brandingApi("PUT", "/branding", body);
|
|
388
549
|
if (res && res.ok) {
|
|
389
550
|
__pendingLogos = {};
|
|
551
|
+
__pendingRestore = {};
|
|
390
552
|
showToast(__t("branding.updated"));
|
|
391
553
|
// Refresh favicon and header logo through the no-store preview alias
|
|
392
554
|
var cacheBust = "?t=" + Date.now();
|
|
@@ -415,6 +577,7 @@ async function doUploadLogo(type, file) {
|
|
|
415
577
|
// Store in pending state — not saved to D1 yet
|
|
416
578
|
var camelType = type.replace(/-([a-z])/g, function(_, c) { return c.toUpperCase(); });
|
|
417
579
|
__pendingLogos[camelType] = data.r2Key;
|
|
580
|
+
renderLogoSource(type, { from: "instance", slot: camelType });
|
|
418
581
|
// Preview the pending upload from the local file — it is in R2 but not
|
|
419
582
|
// yet in D1, so no logo endpoint would serve it until Save.
|
|
420
583
|
var preview = document.getElementById("br-logo-preview-" + type);
|
|
@@ -458,7 +621,9 @@ async function doUploadLogo(type, file) {
|
|
|
458
621
|
async function deleteLogo(type) {
|
|
459
622
|
if (!confirm(__t("branding.deleteLogo"))) return;
|
|
460
623
|
var camelType = type.replace(/-([a-z])/g, function(_, c) { return c.toUpperCase(); });
|
|
461
|
-
__pendingLogos[camelType] = null; // mark for deletion on save
|
|
624
|
+
__pendingLogos[camelType] = null; // mark for deletion on save — deletes the slot's key
|
|
625
|
+
var logoSource = ((__brandingData.sources || {}).logos || {})[camelType];
|
|
626
|
+
renderLogoSource(type, logoSource && logoSource.restoreTo ? logoSource.restoreTo : { from: "default" });
|
|
462
627
|
// Clear preview
|
|
463
628
|
var preview = document.getElementById("br-logo-preview-" + type);
|
|
464
629
|
if (preview) preview.innerHTML = '';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-branding.js","sourceRoot":"","sources":["../../../src/pages/admin/tab-branding.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD,oDAAoD;AACpD,MAAM,QAAQ,GAAG,weAAwe,CAAC;AAC1f,MAAM,SAAS,GAAG,wKAAwK,CAAC;AAC3L,MAAM,WAAW,GAAG,sOAAsO,CAAC;AAC3P,MAAM,YAAY,GAAG,2OAA2O,CAAC;AACjQ,MAAM,aAAa,GAAG,0KAA0K,CAAC;AACjM,MAAM,eAAe,GAAG,+NAA+N,CAAC;AACxP,MAAM,cAAc,GAAG,+NAA+N,CAAC;AACvP,MAAM,UAAU,GAAG,yRAAyR,CAAC;AAE7S,MAAM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;;mBAqF3B,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;;;;;;;;;;;;;;;CAe3C,CAAC,EAAE,CAAC"}
|
package/dist/theme-utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PackageTheme } from "./package-branding.js";
|
|
1
2
|
/**
|
|
2
3
|
* Theme format conversion: concepts-based storage → frontend output format.
|
|
3
4
|
*
|
|
@@ -191,5 +192,25 @@ export declare const BLOCKLET_THEME_DARK_PALETTE: {
|
|
|
191
192
|
secondary: string;
|
|
192
193
|
};
|
|
193
194
|
};
|
|
195
|
+
/** Strip every character outside the theme-color whitelist (styles.css output). */
|
|
196
|
+
export declare function sanitizeThemeColor(value: string): string;
|
|
197
|
+
/**
|
|
198
|
+
* Whether a host-supplied package color is acceptable: ≤ 64 UTF-8 bytes, within the
|
|
199
|
+
* styles.css whitelist, and a form MUI's `decomposeColor` understands — hex
|
|
200
|
+
* (3/4/6/8 digits) or `rgb`/`rgba`/`hsl`/`hsla` with 3–4 comma-separated numeric
|
|
201
|
+
* arguments (literal ASCII spaces only). `__blocklet__.js` hands the palette to MUI
|
|
202
|
+
* clients, which throw on anything else.
|
|
203
|
+
*/
|
|
204
|
+
export declare function isPackageThemeColor(value: unknown): value is string;
|
|
194
205
|
export declare function formatThemeForOutput(rawTheme: any): any;
|
|
206
|
+
/**
|
|
207
|
+
* The output theme for a host-supplied package palette (S8): deep-merged over the
|
|
208
|
+
* default palettes like any stored theme, EXCEPT that in every group whose `main` the
|
|
209
|
+
* package sets, the default `light` / `dark` (and `contrastText`, unless the package
|
|
210
|
+
* sent one) are dropped. Those defaults belong to the default teal `main`; kept, MUI
|
|
211
|
+
* would use them as-is instead of deriving them from the package's `main`, so hover /
|
|
212
|
+
* active states of e.g. a gold app would stay teal. MUI's `augmentColor` derives
|
|
213
|
+
* whatever is absent. Instance-configured themes do not go through here.
|
|
214
|
+
*/
|
|
215
|
+
export declare function formatPackageThemeForOutput(theme: PackageTheme): any;
|
|
195
216
|
//# sourceMappingURL=theme-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-utils.d.ts","sourceRoot":"","sources":["../src/theme-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BxC,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BvC,CAAC;
|
|
1
|
+
{"version":3,"file":"theme-utils.d.ts","sourceRoot":"","sources":["../src/theme-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;;;;;;GAQG;AAIH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BxC,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BvC,CAAC;AAgCF,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD;AAYD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAQnE;AAID,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,CAgDvD;AAKD;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,YAAY,GAAG,GAAG,CAgBpE"}
|
package/dist/theme-utils.js
CHANGED
|
@@ -84,6 +84,38 @@ function deepMerge(target, source) {
|
|
|
84
84
|
}
|
|
85
85
|
return result;
|
|
86
86
|
}
|
|
87
|
+
// ─── Color whitelist ──────────────────────────────────────────────────────
|
|
88
|
+
/**
|
|
89
|
+
* Characters a theme color may contain once it is written into CSS. `serveThemeStyles`
|
|
90
|
+
* strips everything else from the colors it emits; package colors must consist of
|
|
91
|
+
* these characters only (they are rejected, not stripped).
|
|
92
|
+
*/
|
|
93
|
+
const THEME_COLOR_UNSAFE_CHARS = /[^a-zA-Z0-9#(),.\s%]/g;
|
|
94
|
+
/** Strip every character outside the theme-color whitelist (styles.css output). */
|
|
95
|
+
export function sanitizeThemeColor(value) {
|
|
96
|
+
return value.replace(THEME_COLOR_UNSAFE_CHARS, "");
|
|
97
|
+
}
|
|
98
|
+
/** A numeric color argument: `12`, `12.5`, `.5`, optionally `%`. */
|
|
99
|
+
const COLOR_NUMBER = "(?:\\d+(?:\\.\\d+)?|\\.\\d+)%?";
|
|
100
|
+
/** Separators are a comma with optional LITERAL ASCII spaces — never `\s` (U+2028, NBSP, CR…). */
|
|
101
|
+
const COLOR_ARGS = ` *${COLOR_NUMBER}(?: *, *${COLOR_NUMBER}){2,3} *`;
|
|
102
|
+
const PACKAGE_THEME_COLOR_SHAPE = new RegExp(`^(?:#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})|(?:rgba?|hsla?)\\(${COLOR_ARGS}\\))$`);
|
|
103
|
+
const PACKAGE_THEME_COLOR_MAX_BYTES = 64;
|
|
104
|
+
const utf8 = new TextEncoder();
|
|
105
|
+
/**
|
|
106
|
+
* Whether a host-supplied package color is acceptable: ≤ 64 UTF-8 bytes, within the
|
|
107
|
+
* styles.css whitelist, and a form MUI's `decomposeColor` understands — hex
|
|
108
|
+
* (3/4/6/8 digits) or `rgb`/`rgba`/`hsl`/`hsla` with 3–4 comma-separated numeric
|
|
109
|
+
* arguments (literal ASCII spaces only). `__blocklet__.js` hands the palette to MUI
|
|
110
|
+
* clients, which throw on anything else.
|
|
111
|
+
*/
|
|
112
|
+
export function isPackageThemeColor(value) {
|
|
113
|
+
return (typeof value === "string" &&
|
|
114
|
+
value.length > 0 &&
|
|
115
|
+
utf8.encode(value).byteLength <= PACKAGE_THEME_COLOR_MAX_BYTES &&
|
|
116
|
+
sanitizeThemeColor(value) === value &&
|
|
117
|
+
PACKAGE_THEME_COLOR_SHAPE.test(value));
|
|
118
|
+
}
|
|
87
119
|
// ─── Public API ───────────────────────────────────────────────────────────
|
|
88
120
|
export function formatThemeForOutput(rawTheme) {
|
|
89
121
|
if (!rawTheme || typeof rawTheme !== "object") {
|
|
@@ -129,4 +161,34 @@ export function formatThemeForOutput(rawTheme) {
|
|
|
129
161
|
// Always merge with default palettes — clients receive a complete theme
|
|
130
162
|
return deepMerge({ light: { palette: BLOCKLET_THEME_LIGHT_PALETTE }, dark: { palette: BLOCKLET_THEME_DARK_PALETTE }, prefer: "system" }, themeConfig);
|
|
131
163
|
}
|
|
164
|
+
/** Palette groups whose `light` / `dark` / `contrastText` MUI derives from `main`. */
|
|
165
|
+
const DERIVED_COLOR_GROUPS = ["primary", "success", "error", "warning"];
|
|
166
|
+
/**
|
|
167
|
+
* The output theme for a host-supplied package palette (S8): deep-merged over the
|
|
168
|
+
* default palettes like any stored theme, EXCEPT that in every group whose `main` the
|
|
169
|
+
* package sets, the default `light` / `dark` (and `contrastText`, unless the package
|
|
170
|
+
* sent one) are dropped. Those defaults belong to the default teal `main`; kept, MUI
|
|
171
|
+
* would use them as-is instead of deriving them from the package's `main`, so hover /
|
|
172
|
+
* active states of e.g. a gold app would stay teal. MUI's `augmentColor` derives
|
|
173
|
+
* whatever is absent. Instance-configured themes do not go through here.
|
|
174
|
+
*/
|
|
175
|
+
export function formatPackageThemeForOutput(theme) {
|
|
176
|
+
const output = formatThemeForOutput({
|
|
177
|
+
...(theme.light ? { light: { palette: theme.light } } : {}),
|
|
178
|
+
...(theme.dark ? { dark: { palette: theme.dark } } : {}),
|
|
179
|
+
});
|
|
180
|
+
for (const mode of ["light", "dark"]) {
|
|
181
|
+
const palette = theme[mode];
|
|
182
|
+
if (!palette)
|
|
183
|
+
continue;
|
|
184
|
+
for (const group of DERIVED_COLOR_GROUPS) {
|
|
185
|
+
const own = palette[group];
|
|
186
|
+
if (!own?.main)
|
|
187
|
+
continue;
|
|
188
|
+
const { light: _light, dark: _dark, contrastText, ...rest } = output[mode].palette[group];
|
|
189
|
+
output[mode].palette[group] = { ...rest, ...(own.contrastText ? { contrastText } : {}) };
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return output;
|
|
193
|
+
}
|
|
132
194
|
//# sourceMappingURL=theme-utils.js.map
|
package/dist/theme-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-utils.js","sourceRoot":"","sources":["../src/theme-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"theme-utils.js","sourceRoot":"","sources":["../src/theme-utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,6EAA6E;AAE7E,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,IAAI,EAAE,OAAgB;IACtB,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IACrF,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IACvF,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IACnF,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,E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IACH,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,CAAU,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC,OAAO;YAAE,SAAS;QACvB,KAAK,MAAM,KAAK,IAAI,oBAAoB,EAAE,CAAC;YACzC,MAAM,GAAG,GAAyD,OAAO,CAAC,KAAK,CAAC,CAAC;YACjF,IAAI,CAAC,GAAG,EAAE,IAAI;gBAAE,SAAS;YACzB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC1F,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QAC3F,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/did-connect-service",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.42",
|
|
4
4
|
"description": "Multi-runtime authentication service framework — Passkey, DID Connect, OAuth, Email, Team, RBAC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"sharp": "^0.35.4",
|
|
62
62
|
"ufo": "^1.6.4",
|
|
63
63
|
"valibot": "^1.4.2",
|
|
64
|
-
"@arcblock/did-connect-core": "^4.1.
|
|
65
|
-
"@arcblock/did-connect-js": "^4.1.
|
|
64
|
+
"@arcblock/did-connect-core": "^4.1.42",
|
|
65
|
+
"@arcblock/did-connect-js": "^4.1.42"
|
|
66
66
|
},
|
|
67
67
|
"optionalDependencies": {
|
|
68
68
|
"@aigne/afs": "^1.11.0-beta.13"
|