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