g-comments 0.2.0 → 0.2.1

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/react.js CHANGED
@@ -351,12 +351,15 @@ function forumThemeCss(theme) {
351
351
  }
352
352
  function forumFontFacesCss(theme) {
353
353
  let css = "";
354
+ const seen = /* @__PURE__ */ new Set();
354
355
  for (const font of Object.values(theme.fonts)) {
355
356
  for (const face of font?.faces ?? []) {
356
357
  const weight = String(face.weight);
357
- if (SAFE_FAMILY.test(face.family) && FONT_SOURCE.test(face.src) && FONT_WEIGHT.test(weight)) {
358
- css += `@font-face{font-family:"${face.family}";src:${face.src};font-weight:${weight};font-display:swap;}
358
+ const rule = `@font-face{font-family:"${face.family}";src:${face.src};font-weight:${weight};font-display:swap;}
359
359
  `;
360
+ if (SAFE_FAMILY.test(face.family) && FONT_SOURCE.test(face.src) && FONT_WEIGHT.test(weight) && !seen.has(rule)) {
361
+ seen.add(rule);
362
+ css += rule;
360
363
  }
361
364
  }
362
365
  }
@@ -378,6 +381,14 @@ function forumStylesheetUrls(theme, forum) {
378
381
  }
379
382
  return urls;
380
383
  }
384
+ function forumThemeStyleText(theme, forum) {
385
+ const imports = forumStylesheetUrls(theme, forum).map((href) => `@import url(${JSON.stringify(href)}) layer(gc-forum);
386
+ `).join("");
387
+ return `@layer gc-defaults, gc-forum;
388
+ ${imports}@layer gc-forum{
389
+ ${forumThemeCss(theme)}}
390
+ `;
391
+ }
381
392
  function documentOf(root) {
382
393
  return root.nodeType === 9 ? root : root.ownerDocument;
383
394
  }
@@ -402,15 +413,8 @@ function applyForumTheme(root, theme, forum) {
402
413
  replaceNodes(container, STYLE_ATTRIBUTE, forum, key, () => {
403
414
  const style = doc.createElement("style");
404
415
  style.setAttribute(STYLE_ATTRIBUTE, key);
405
- style.textContent = forumThemeCss(theme);
406
- const links = forumStylesheetUrls(theme, forum).map((href) => {
407
- const link = doc.createElement("link");
408
- link.rel = "stylesheet";
409
- link.href = href;
410
- link.setAttribute(STYLE_ATTRIBUTE, key);
411
- return link;
412
- });
413
- return [style, ...links];
416
+ style.textContent = forumThemeStyleText(theme, forum);
417
+ return [style];
414
418
  });
415
419
  const faces = forumFontFacesCss(theme);
416
420
  if (faces) {