Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@giscus/preact

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@giscus/preact - npm Package Compare versions

Comparing version 2.0.0-beta.3 to 2.0.0-beta.4

dist/index.cjs.js

999

dist/giscus.es.js

@@ -1,38 +0,965 @@

import { useEffect } from "preact/compat";
import { jsx } from "preact/jsx-runtime";
function Giscus({
id,
repo,
repoId,
category,
categoryId,
mapping,
term,
reactionsEnabled,
emitMetadata,
inputPosition,
theme,
lang,
loading
}) {
useEffect(() => {
import("./giscus.es2.js");
}, []);
const widget = jsx("giscus-widget", {
id,
repo,
repoid: repoId,
category,
categoryid: categoryId,
mapping,
term,
reactionsenabled: reactionsEnabled,
emitmetadata: emitMetadata,
inputposition: inputPosition,
theme,
lang,
loading
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a2, b2) => {
for (var prop in b2 || (b2 = {}))
if (__hasOwnProp.call(b2, prop))
__defNormalProp(a2, prop, b2[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b2)) {
if (__propIsEnum.call(b2, prop))
__defNormalProp(a2, prop, b2[prop]);
}
return a2;
};
var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const t$2 = window.ShadowRoot && (window.ShadyCSS === void 0 || window.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, e$6 = Symbol(), n$7 = /* @__PURE__ */ new Map();
class s$3 {
constructor(t2, n2) {
if (this._$cssResult$ = true, n2 !== e$6)
throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
this.cssText = t2;
}
get styleSheet() {
let e2 = n$7.get(this.cssText);
return t$2 && e2 === void 0 && (n$7.set(this.cssText, e2 = new CSSStyleSheet()), e2.replaceSync(this.cssText)), e2;
}
toString() {
return this.cssText;
}
}
const o$5 = (t2) => new s$3(typeof t2 == "string" ? t2 : t2 + "", e$6), r$4 = (t2, ...n2) => {
const o2 = t2.length === 1 ? t2[0] : n2.reduce((e2, n3, s2) => e2 + ((t3) => {
if (t3._$cssResult$ === true)
return t3.cssText;
if (typeof t3 == "number")
return t3;
throw Error("Value passed to 'css' function must be a 'css' function result: " + t3 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
})(n3) + t2[s2 + 1], t2[0]);
return new s$3(o2, e$6);
}, i$3 = (e2, n2) => {
t$2 ? e2.adoptedStyleSheets = n2.map((t2) => t2 instanceof CSSStyleSheet ? t2 : t2.styleSheet) : n2.forEach((t2) => {
const n3 = document.createElement("style"), s2 = window.litNonce;
s2 !== void 0 && n3.setAttribute("nonce", s2), n3.textContent = t2.cssText, e2.appendChild(n3);
});
return widget;
}, S$1 = t$2 ? (t2) => t2 : (t2) => t2 instanceof CSSStyleSheet ? ((t3) => {
let e2 = "";
for (const n2 of t3.cssRules)
e2 += n2.cssText;
return o$5(e2);
})(t2) : t2;
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
var s$2;
const e$5 = window.trustedTypes, r$3 = e$5 ? e$5.emptyScript : "", h$3 = window.reactiveElementPolyfillSupport, o$4 = { toAttribute(t2, i2) {
switch (i2) {
case Boolean:
t2 = t2 ? r$3 : null;
break;
case Object:
case Array:
t2 = t2 == null ? t2 : JSON.stringify(t2);
}
return t2;
}, fromAttribute(t2, i2) {
let s2 = t2;
switch (i2) {
case Boolean:
s2 = t2 !== null;
break;
case Number:
s2 = t2 === null ? null : Number(t2);
break;
case Object:
case Array:
try {
s2 = JSON.parse(t2);
} catch (t3) {
s2 = null;
}
}
return s2;
} }, n$6 = (t2, i2) => i2 !== t2 && (i2 == i2 || t2 == t2), l$3 = { attribute: true, type: String, converter: o$4, reflect: false, hasChanged: n$6 };
class a$1 extends HTMLElement {
constructor() {
super(), this._$Et = /* @__PURE__ */ new Map(), this.isUpdatePending = false, this.hasUpdated = false, this._$Ei = null, this.o();
}
static addInitializer(t2) {
var i2;
(i2 = this.l) !== null && i2 !== void 0 || (this.l = []), this.l.push(t2);
}
static get observedAttributes() {
this.finalize();
const t2 = [];
return this.elementProperties.forEach((i2, s2) => {
const e2 = this._$Eh(s2, i2);
e2 !== void 0 && (this._$Eu.set(e2, s2), t2.push(e2));
}), t2;
}
static createProperty(t2, i2 = l$3) {
if (i2.state && (i2.attribute = false), this.finalize(), this.elementProperties.set(t2, i2), !i2.noAccessor && !this.prototype.hasOwnProperty(t2)) {
const s2 = typeof t2 == "symbol" ? Symbol() : "__" + t2, e2 = this.getPropertyDescriptor(t2, s2, i2);
e2 !== void 0 && Object.defineProperty(this.prototype, t2, e2);
}
}
static getPropertyDescriptor(t2, i2, s2) {
return { get() {
return this[i2];
}, set(e2) {
const r2 = this[t2];
this[i2] = e2, this.requestUpdate(t2, r2, s2);
}, configurable: true, enumerable: true };
}
static getPropertyOptions(t2) {
return this.elementProperties.get(t2) || l$3;
}
static finalize() {
if (this.hasOwnProperty("finalized"))
return false;
this.finalized = true;
const t2 = Object.getPrototypeOf(this);
if (t2.finalize(), this.elementProperties = new Map(t2.elementProperties), this._$Eu = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) {
const t3 = this.properties, i2 = [...Object.getOwnPropertyNames(t3), ...Object.getOwnPropertySymbols(t3)];
for (const s2 of i2)
this.createProperty(s2, t3[s2]);
}
return this.elementStyles = this.finalizeStyles(this.styles), true;
}
static finalizeStyles(i2) {
const s2 = [];
if (Array.isArray(i2)) {
const e2 = new Set(i2.flat(1 / 0).reverse());
for (const i3 of e2)
s2.unshift(S$1(i3));
} else
i2 !== void 0 && s2.push(S$1(i2));
return s2;
}
static _$Eh(t2, i2) {
const s2 = i2.attribute;
return s2 === false ? void 0 : typeof s2 == "string" ? s2 : typeof t2 == "string" ? t2.toLowerCase() : void 0;
}
o() {
var t2;
this._$Ep = new Promise((t3) => this.enableUpdating = t3), this._$AL = /* @__PURE__ */ new Map(), this._$Em(), this.requestUpdate(), (t2 = this.constructor.l) === null || t2 === void 0 || t2.forEach((t3) => t3(this));
}
addController(t2) {
var i2, s2;
((i2 = this._$Eg) !== null && i2 !== void 0 ? i2 : this._$Eg = []).push(t2), this.renderRoot !== void 0 && this.isConnected && ((s2 = t2.hostConnected) === null || s2 === void 0 || s2.call(t2));
}
removeController(t2) {
var i2;
(i2 = this._$Eg) === null || i2 === void 0 || i2.splice(this._$Eg.indexOf(t2) >>> 0, 1);
}
_$Em() {
this.constructor.elementProperties.forEach((t2, i2) => {
this.hasOwnProperty(i2) && (this._$Et.set(i2, this[i2]), delete this[i2]);
});
}
createRenderRoot() {
var t2;
const s2 = (t2 = this.shadowRoot) !== null && t2 !== void 0 ? t2 : this.attachShadow(this.constructor.shadowRootOptions);
return i$3(s2, this.constructor.elementStyles), s2;
}
connectedCallback() {
var t2;
this.renderRoot === void 0 && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(true), (t2 = this._$Eg) === null || t2 === void 0 || t2.forEach((t3) => {
var i2;
return (i2 = t3.hostConnected) === null || i2 === void 0 ? void 0 : i2.call(t3);
});
}
enableUpdating(t2) {
}
disconnectedCallback() {
var t2;
(t2 = this._$Eg) === null || t2 === void 0 || t2.forEach((t3) => {
var i2;
return (i2 = t3.hostDisconnected) === null || i2 === void 0 ? void 0 : i2.call(t3);
});
}
attributeChangedCallback(t2, i2, s2) {
this._$AK(t2, s2);
}
_$ES(t2, i2, s2 = l$3) {
var e2, r2;
const h2 = this.constructor._$Eh(t2, s2);
if (h2 !== void 0 && s2.reflect === true) {
const n2 = ((r2 = (e2 = s2.converter) === null || e2 === void 0 ? void 0 : e2.toAttribute) !== null && r2 !== void 0 ? r2 : o$4.toAttribute)(i2, s2.type);
this._$Ei = t2, n2 == null ? this.removeAttribute(h2) : this.setAttribute(h2, n2), this._$Ei = null;
}
}
_$AK(t2, i2) {
var s2, e2, r2;
const h2 = this.constructor, n2 = h2._$Eu.get(t2);
if (n2 !== void 0 && this._$Ei !== n2) {
const t3 = h2.getPropertyOptions(n2), l2 = t3.converter, a2 = (r2 = (e2 = (s2 = l2) === null || s2 === void 0 ? void 0 : s2.fromAttribute) !== null && e2 !== void 0 ? e2 : typeof l2 == "function" ? l2 : null) !== null && r2 !== void 0 ? r2 : o$4.fromAttribute;
this._$Ei = n2, this[n2] = a2(i2, t3.type), this._$Ei = null;
}
}
requestUpdate(t2, i2, s2) {
let e2 = true;
t2 !== void 0 && (((s2 = s2 || this.constructor.getPropertyOptions(t2)).hasChanged || n$6)(this[t2], i2) ? (this._$AL.has(t2) || this._$AL.set(t2, i2), s2.reflect === true && this._$Ei !== t2 && (this._$EC === void 0 && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t2, s2))) : e2 = false), !this.isUpdatePending && e2 && (this._$Ep = this._$E_());
}
async _$E_() {
this.isUpdatePending = true;
try {
await this._$Ep;
} catch (t3) {
Promise.reject(t3);
}
const t2 = this.scheduleUpdate();
return t2 != null && await t2, !this.isUpdatePending;
}
scheduleUpdate() {
return this.performUpdate();
}
performUpdate() {
var t2;
if (!this.isUpdatePending)
return;
this.hasUpdated, this._$Et && (this._$Et.forEach((t3, i3) => this[i3] = t3), this._$Et = void 0);
let i2 = false;
const s2 = this._$AL;
try {
i2 = this.shouldUpdate(s2), i2 ? (this.willUpdate(s2), (t2 = this._$Eg) === null || t2 === void 0 || t2.forEach((t3) => {
var i3;
return (i3 = t3.hostUpdate) === null || i3 === void 0 ? void 0 : i3.call(t3);
}), this.update(s2)) : this._$EU();
} catch (t3) {
throw i2 = false, this._$EU(), t3;
}
i2 && this._$AE(s2);
}
willUpdate(t2) {
}
_$AE(t2) {
var i2;
(i2 = this._$Eg) === null || i2 === void 0 || i2.forEach((t3) => {
var i3;
return (i3 = t3.hostUpdated) === null || i3 === void 0 ? void 0 : i3.call(t3);
}), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t2)), this.updated(t2);
}
_$EU() {
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false;
}
get updateComplete() {
return this.getUpdateComplete();
}
getUpdateComplete() {
return this._$Ep;
}
shouldUpdate(t2) {
return true;
}
update(t2) {
this._$EC !== void 0 && (this._$EC.forEach((t3, i2) => this._$ES(i2, this[i2], t3)), this._$EC = void 0), this._$EU();
}
updated(t2) {
}
firstUpdated(t2) {
}
}
export { Giscus as default };
a$1.finalized = true, a$1.elementProperties = /* @__PURE__ */ new Map(), a$1.elementStyles = [], a$1.shadowRootOptions = { mode: "open" }, h$3 == null || h$3({ ReactiveElement: a$1 }), ((s$2 = globalThis.reactiveElementVersions) !== null && s$2 !== void 0 ? s$2 : globalThis.reactiveElementVersions = []).push("1.3.1");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
var t$1;
const i$2 = globalThis.trustedTypes, s$1 = i$2 ? i$2.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, e$4 = `lit$${(Math.random() + "").slice(9)}$`, o$3 = "?" + e$4, n$5 = `<${o$3}>`, l$2 = document, h$2 = (t2 = "") => l$2.createComment(t2), r$2 = (t2) => t2 === null || typeof t2 != "object" && typeof t2 != "function", d$1 = Array.isArray, u = (t2) => {
var i2;
return d$1(t2) || typeof ((i2 = t2) === null || i2 === void 0 ? void 0 : i2[Symbol.iterator]) == "function";
}, c = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, v = /-->/g, a = />/g, f = />|[ \n \r](?:([^\s"'>=/]+)([ \n \r]*=[ \n \r]*(?:[^ \n \r"'`<>=]|("|')|))|$)/g, _ = /'/g, m = /"/g, g = /^(?:script|style|textarea|title)$/i, p = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), $ = p(1), b = Symbol.for("lit-noChange"), w = Symbol.for("lit-nothing"), T = /* @__PURE__ */ new WeakMap(), x = (t2, i2, s2) => {
var e2, o2;
const n2 = (e2 = s2 == null ? void 0 : s2.renderBefore) !== null && e2 !== void 0 ? e2 : i2;
let l2 = n2._$litPart$;
if (l2 === void 0) {
const t3 = (o2 = s2 == null ? void 0 : s2.renderBefore) !== null && o2 !== void 0 ? o2 : null;
n2._$litPart$ = l2 = new N(i2.insertBefore(h$2(), t3), t3, void 0, s2 != null ? s2 : {});
}
return l2._$AI(t2), l2;
}, A = l$2.createTreeWalker(l$2, 129, null, false), C = (t2, i2) => {
const o2 = t2.length - 1, l2 = [];
let h2, r2 = i2 === 2 ? "<svg>" : "", d2 = c;
for (let i3 = 0; i3 < o2; i3++) {
const s2 = t2[i3];
let o3, u3, p2 = -1, $2 = 0;
for (; $2 < s2.length && (d2.lastIndex = $2, u3 = d2.exec(s2), u3 !== null); )
$2 = d2.lastIndex, d2 === c ? u3[1] === "!--" ? d2 = v : u3[1] !== void 0 ? d2 = a : u3[2] !== void 0 ? (g.test(u3[2]) && (h2 = RegExp("</" + u3[2], "g")), d2 = f) : u3[3] !== void 0 && (d2 = f) : d2 === f ? u3[0] === ">" ? (d2 = h2 != null ? h2 : c, p2 = -1) : u3[1] === void 0 ? p2 = -2 : (p2 = d2.lastIndex - u3[2].length, o3 = u3[1], d2 = u3[3] === void 0 ? f : u3[3] === '"' ? m : _) : d2 === m || d2 === _ ? d2 = f : d2 === v || d2 === a ? d2 = c : (d2 = f, h2 = void 0);
const y = d2 === f && t2[i3 + 1].startsWith("/>") ? " " : "";
r2 += d2 === c ? s2 + n$5 : p2 >= 0 ? (l2.push(o3), s2.slice(0, p2) + "$lit$" + s2.slice(p2) + e$4 + y) : s2 + e$4 + (p2 === -2 ? (l2.push(void 0), i3) : y);
}
const u2 = r2 + (t2[o2] || "<?>") + (i2 === 2 ? "</svg>" : "");
if (!Array.isArray(t2) || !t2.hasOwnProperty("raw"))
throw Error("invalid template strings array");
return [s$1 !== void 0 ? s$1.createHTML(u2) : u2, l2];
};
class E {
constructor({ strings: t2, _$litType$: s2 }, n2) {
let l2;
this.parts = [];
let r2 = 0, d2 = 0;
const u2 = t2.length - 1, c2 = this.parts, [v2, a2] = C(t2, s2);
if (this.el = E.createElement(v2, n2), A.currentNode = this.el.content, s2 === 2) {
const t3 = this.el.content, i2 = t3.firstChild;
i2.remove(), t3.append(...i2.childNodes);
}
for (; (l2 = A.nextNode()) !== null && c2.length < u2; ) {
if (l2.nodeType === 1) {
if (l2.hasAttributes()) {
const t3 = [];
for (const i2 of l2.getAttributeNames())
if (i2.endsWith("$lit$") || i2.startsWith(e$4)) {
const s3 = a2[d2++];
if (t3.push(i2), s3 !== void 0) {
const t4 = l2.getAttribute(s3.toLowerCase() + "$lit$").split(e$4), i3 = /([.?@])?(.*)/.exec(s3);
c2.push({ type: 1, index: r2, name: i3[2], strings: t4, ctor: i3[1] === "." ? M : i3[1] === "?" ? H : i3[1] === "@" ? I : S });
} else
c2.push({ type: 6, index: r2 });
}
for (const i2 of t3)
l2.removeAttribute(i2);
}
if (g.test(l2.tagName)) {
const t3 = l2.textContent.split(e$4), s3 = t3.length - 1;
if (s3 > 0) {
l2.textContent = i$2 ? i$2.emptyScript : "";
for (let i2 = 0; i2 < s3; i2++)
l2.append(t3[i2], h$2()), A.nextNode(), c2.push({ type: 2, index: ++r2 });
l2.append(t3[s3], h$2());
}
}
} else if (l2.nodeType === 8)
if (l2.data === o$3)
c2.push({ type: 2, index: r2 });
else {
let t3 = -1;
for (; (t3 = l2.data.indexOf(e$4, t3 + 1)) !== -1; )
c2.push({ type: 7, index: r2 }), t3 += e$4.length - 1;
}
r2++;
}
}
static createElement(t2, i2) {
const s2 = l$2.createElement("template");
return s2.innerHTML = t2, s2;
}
}
function P(t2, i2, s2 = t2, e2) {
var o2, n2, l2, h2;
if (i2 === b)
return i2;
let d2 = e2 !== void 0 ? (o2 = s2._$Cl) === null || o2 === void 0 ? void 0 : o2[e2] : s2._$Cu;
const u2 = r$2(i2) ? void 0 : i2._$litDirective$;
return (d2 == null ? void 0 : d2.constructor) !== u2 && ((n2 = d2 == null ? void 0 : d2._$AO) === null || n2 === void 0 || n2.call(d2, false), u2 === void 0 ? d2 = void 0 : (d2 = new u2(t2), d2._$AT(t2, s2, e2)), e2 !== void 0 ? ((l2 = (h2 = s2)._$Cl) !== null && l2 !== void 0 ? l2 : h2._$Cl = [])[e2] = d2 : s2._$Cu = d2), d2 !== void 0 && (i2 = P(t2, d2._$AS(t2, i2.values), d2, e2)), i2;
}
class V {
constructor(t2, i2) {
this.v = [], this._$AN = void 0, this._$AD = t2, this._$AM = i2;
}
get parentNode() {
return this._$AM.parentNode;
}
get _$AU() {
return this._$AM._$AU;
}
p(t2) {
var i2;
const { el: { content: s2 }, parts: e2 } = this._$AD, o2 = ((i2 = t2 == null ? void 0 : t2.creationScope) !== null && i2 !== void 0 ? i2 : l$2).importNode(s2, true);
A.currentNode = o2;
let n2 = A.nextNode(), h2 = 0, r2 = 0, d2 = e2[0];
for (; d2 !== void 0; ) {
if (h2 === d2.index) {
let i3;
d2.type === 2 ? i3 = new N(n2, n2.nextSibling, this, t2) : d2.type === 1 ? i3 = new d2.ctor(n2, d2.name, d2.strings, this, t2) : d2.type === 6 && (i3 = new L(n2, this, t2)), this.v.push(i3), d2 = e2[++r2];
}
h2 !== (d2 == null ? void 0 : d2.index) && (n2 = A.nextNode(), h2++);
}
return o2;
}
m(t2) {
let i2 = 0;
for (const s2 of this.v)
s2 !== void 0 && (s2.strings !== void 0 ? (s2._$AI(t2, s2, i2), i2 += s2.strings.length - 2) : s2._$AI(t2[i2])), i2++;
}
}
class N {
constructor(t2, i2, s2, e2) {
var o2;
this.type = 2, this._$AH = w, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cg = (o2 = e2 == null ? void 0 : e2.isConnected) === null || o2 === void 0 || o2;
}
get _$AU() {
var t2, i2;
return (i2 = (t2 = this._$AM) === null || t2 === void 0 ? void 0 : t2._$AU) !== null && i2 !== void 0 ? i2 : this._$Cg;
}
get parentNode() {
let t2 = this._$AA.parentNode;
const i2 = this._$AM;
return i2 !== void 0 && t2.nodeType === 11 && (t2 = i2.parentNode), t2;
}
get startNode() {
return this._$AA;
}
get endNode() {
return this._$AB;
}
_$AI(t2, i2 = this) {
t2 = P(this, t2, i2), r$2(t2) ? t2 === w || t2 == null || t2 === "" ? (this._$AH !== w && this._$AR(), this._$AH = w) : t2 !== this._$AH && t2 !== b && this.$(t2) : t2._$litType$ !== void 0 ? this.T(t2) : t2.nodeType !== void 0 ? this.k(t2) : u(t2) ? this.S(t2) : this.$(t2);
}
A(t2, i2 = this._$AB) {
return this._$AA.parentNode.insertBefore(t2, i2);
}
k(t2) {
this._$AH !== t2 && (this._$AR(), this._$AH = this.A(t2));
}
$(t2) {
this._$AH !== w && r$2(this._$AH) ? this._$AA.nextSibling.data = t2 : this.k(l$2.createTextNode(t2)), this._$AH = t2;
}
T(t2) {
var i2;
const { values: s2, _$litType$: e2 } = t2, o2 = typeof e2 == "number" ? this._$AC(t2) : (e2.el === void 0 && (e2.el = E.createElement(e2.h, this.options)), e2);
if (((i2 = this._$AH) === null || i2 === void 0 ? void 0 : i2._$AD) === o2)
this._$AH.m(s2);
else {
const t3 = new V(o2, this), i3 = t3.p(this.options);
t3.m(s2), this.k(i3), this._$AH = t3;
}
}
_$AC(t2) {
let i2 = T.get(t2.strings);
return i2 === void 0 && T.set(t2.strings, i2 = new E(t2)), i2;
}
S(t2) {
d$1(this._$AH) || (this._$AH = [], this._$AR());
const i2 = this._$AH;
let s2, e2 = 0;
for (const o2 of t2)
e2 === i2.length ? i2.push(s2 = new N(this.A(h$2()), this.A(h$2()), this, this.options)) : s2 = i2[e2], s2._$AI(o2), e2++;
e2 < i2.length && (this._$AR(s2 && s2._$AB.nextSibling, e2), i2.length = e2);
}
_$AR(t2 = this._$AA.nextSibling, i2) {
var s2;
for ((s2 = this._$AP) === null || s2 === void 0 || s2.call(this, false, true, i2); t2 && t2 !== this._$AB; ) {
const i3 = t2.nextSibling;
t2.remove(), t2 = i3;
}
}
setConnected(t2) {
var i2;
this._$AM === void 0 && (this._$Cg = t2, (i2 = this._$AP) === null || i2 === void 0 || i2.call(this, t2));
}
}
class S {
constructor(t2, i2, s2, e2, o2) {
this.type = 1, this._$AH = w, this._$AN = void 0, this.element = t2, this.name = i2, this._$AM = e2, this.options = o2, s2.length > 2 || s2[0] !== "" || s2[1] !== "" ? (this._$AH = Array(s2.length - 1).fill(new String()), this.strings = s2) : this._$AH = w;
}
get tagName() {
return this.element.tagName;
}
get _$AU() {
return this._$AM._$AU;
}
_$AI(t2, i2 = this, s2, e2) {
const o2 = this.strings;
let n2 = false;
if (o2 === void 0)
t2 = P(this, t2, i2, 0), n2 = !r$2(t2) || t2 !== this._$AH && t2 !== b, n2 && (this._$AH = t2);
else {
const e3 = t2;
let l2, h2;
for (t2 = o2[0], l2 = 0; l2 < o2.length - 1; l2++)
h2 = P(this, e3[s2 + l2], i2, l2), h2 === b && (h2 = this._$AH[l2]), n2 || (n2 = !r$2(h2) || h2 !== this._$AH[l2]), h2 === w ? t2 = w : t2 !== w && (t2 += (h2 != null ? h2 : "") + o2[l2 + 1]), this._$AH[l2] = h2;
}
n2 && !e2 && this.C(t2);
}
C(t2) {
t2 === w ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t2 != null ? t2 : "");
}
}
class M extends S {
constructor() {
super(...arguments), this.type = 3;
}
C(t2) {
this.element[this.name] = t2 === w ? void 0 : t2;
}
}
const k = i$2 ? i$2.emptyScript : "";
class H extends S {
constructor() {
super(...arguments), this.type = 4;
}
C(t2) {
t2 && t2 !== w ? this.element.setAttribute(this.name, k) : this.element.removeAttribute(this.name);
}
}
class I extends S {
constructor(t2, i2, s2, e2, o2) {
super(t2, i2, s2, e2, o2), this.type = 5;
}
_$AI(t2, i2 = this) {
var s2;
if ((t2 = (s2 = P(this, t2, i2, 0)) !== null && s2 !== void 0 ? s2 : w) === b)
return;
const e2 = this._$AH, o2 = t2 === w && e2 !== w || t2.capture !== e2.capture || t2.once !== e2.once || t2.passive !== e2.passive, n2 = t2 !== w && (e2 === w || o2);
o2 && this.element.removeEventListener(this.name, this, e2), n2 && this.element.addEventListener(this.name, this, t2), this._$AH = t2;
}
handleEvent(t2) {
var i2, s2;
typeof this._$AH == "function" ? this._$AH.call((s2 = (i2 = this.options) === null || i2 === void 0 ? void 0 : i2.host) !== null && s2 !== void 0 ? s2 : this.element, t2) : this._$AH.handleEvent(t2);
}
}
class L {
constructor(t2, i2, s2) {
this.element = t2, this.type = 6, this._$AN = void 0, this._$AM = i2, this.options = s2;
}
get _$AU() {
return this._$AM._$AU;
}
_$AI(t2) {
P(this, t2);
}
}
const z = window.litHtmlPolyfillSupport;
z == null || z(E, N), ((t$1 = globalThis.litHtmlVersions) !== null && t$1 !== void 0 ? t$1 : globalThis.litHtmlVersions = []).push("2.2.1");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
var l$1, o$2;
class s extends a$1 {
constructor() {
super(...arguments), this.renderOptions = { host: this }, this._$Dt = void 0;
}
createRenderRoot() {
var t2, e2;
const i2 = super.createRenderRoot();
return (t2 = (e2 = this.renderOptions).renderBefore) !== null && t2 !== void 0 || (e2.renderBefore = i2.firstChild), i2;
}
update(t2) {
const i2 = this.render();
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t2), this._$Dt = x(i2, this.renderRoot, this.renderOptions);
}
connectedCallback() {
var t2;
super.connectedCallback(), (t2 = this._$Dt) === null || t2 === void 0 || t2.setConnected(true);
}
disconnectedCallback() {
var t2;
super.disconnectedCallback(), (t2 = this._$Dt) === null || t2 === void 0 || t2.setConnected(false);
}
render() {
return b;
}
}
s.finalized = true, s._$litElement$ = true, (l$1 = globalThis.litElementHydrateSupport) === null || l$1 === void 0 || l$1.call(globalThis, { LitElement: s });
const n$4 = globalThis.litElementPolyfillSupport;
n$4 == null || n$4({ LitElement: s });
((o$2 = globalThis.litElementVersions) !== null && o$2 !== void 0 ? o$2 : globalThis.litElementVersions = []).push("3.2.0");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const n$3 = (n2) => (e2) => typeof e2 == "function" ? ((n3, e3) => (window.customElements.define(n3, e3), e3))(n2, e2) : ((n3, e3) => {
const { kind: t2, elements: i2 } = e3;
return { kind: t2, elements: i2, finisher(e4) {
window.customElements.define(n3, e4);
} };
})(n2, e2);
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const i$1 = (i2, e2) => e2.kind === "method" && e2.descriptor && !("value" in e2.descriptor) ? __spreadProps(__spreadValues({}, e2), { finisher(n2) {
n2.createProperty(e2.key, i2);
} }) : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: e2.key, initializer() {
typeof e2.initializer == "function" && (this[e2.key] = e2.initializer.call(this));
}, finisher(n2) {
n2.createProperty(e2.key, i2);
} };
function e$3(e2) {
return (n2, t2) => t2 !== void 0 ? ((i2, e3, n3) => {
e3.constructor.createProperty(n3, i2);
})(e2, n2, t2) : i$1(e2, n2);
}
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
var n$2;
((n$2 = window.HTMLSlotElement) === null || n$2 === void 0 ? void 0 : n$2.prototype.assignedElements) != null ? (o2, n2) => o2.assignedElements(n2) : (o2, n2) => o2.assignedNodes(n2).filter((o3) => o3.nodeType === Node.ELEMENT_NODE);
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const r$1 = (o2) => o2.strings === void 0;
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const t = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 }, e$2 = (t2) => (...e2) => ({ _$litDirective$: t2, values: e2 });
class i {
constructor(t2) {
}
get _$AU() {
return this._$AM._$AU;
}
_$AT(t2, e2, i2) {
this._$Ct = t2, this._$AM = e2, this._$Ci = i2;
}
_$AS(t2, e2) {
return this.update(t2, e2);
}
update(t2, e2) {
return this.render(...e2);
}
}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const e$1 = (i2, t2) => {
var s2, o2;
const n2 = i2._$AN;
if (n2 === void 0)
return false;
for (const i3 of n2)
(o2 = (s2 = i3)._$AO) === null || o2 === void 0 || o2.call(s2, t2, false), e$1(i3, t2);
return true;
}, o$1 = (i2) => {
let t2, s2;
do {
if ((t2 = i2._$AM) === void 0)
break;
s2 = t2._$AN, s2.delete(i2), i2 = t2;
} while ((s2 == null ? void 0 : s2.size) === 0);
}, n$1 = (i2) => {
for (let t2; t2 = i2._$AM; i2 = t2) {
let s2 = t2._$AN;
if (s2 === void 0)
t2._$AN = s2 = /* @__PURE__ */ new Set();
else if (s2.has(i2))
break;
s2.add(i2), l(t2);
}
};
function r(i2) {
this._$AN !== void 0 ? (o$1(this), this._$AM = i2, n$1(this)) : this._$AM = i2;
}
function h$1(i2, t2 = false, s2 = 0) {
const n2 = this._$AH, r2 = this._$AN;
if (r2 !== void 0 && r2.size !== 0)
if (t2)
if (Array.isArray(n2))
for (let i3 = s2; i3 < n2.length; i3++)
e$1(n2[i3], false), o$1(n2[i3]);
else
n2 != null && (e$1(n2, false), o$1(n2));
else
e$1(this, i2);
}
const l = (i2) => {
var t$12, e2, o2, n2;
i2.type == t.CHILD && ((t$12 = (o2 = i2)._$AP) !== null && t$12 !== void 0 || (o2._$AP = h$1), (e2 = (n2 = i2)._$AQ) !== null && e2 !== void 0 || (n2._$AQ = r));
};
class d extends i {
constructor() {
super(...arguments), this._$AN = void 0;
}
_$AT(i2, t2, s2) {
super._$AT(i2, t2, s2), n$1(this), this.isConnected = i2._$AU;
}
_$AO(i2, t2 = true) {
var s2, n2;
i2 !== this.isConnected && (this.isConnected = i2, i2 ? (s2 = this.reconnected) === null || s2 === void 0 || s2.call(this) : (n2 = this.disconnected) === null || n2 === void 0 || n2.call(this)), t2 && (e$1(this, i2), o$1(this));
}
setValue(t2) {
if (r$1(this._$Ct))
this._$Ct._$AI(t2, this);
else {
const i2 = [...this._$Ct._$AH];
i2[this._$Ci] = t2, this._$Ct._$AI(i2, this, 0);
}
}
disconnected() {
}
reconnected() {
}
}
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const e = () => new o();
class o {
}
const h = /* @__PURE__ */ new WeakMap(), n = e$2(class extends d {
render(i2) {
return w;
}
update(i2, [s2]) {
var e2;
const o2 = s2 !== this.U;
return o2 && this.U !== void 0 && this.ot(void 0), (o2 || this.rt !== this.lt) && (this.U = s2, this.ht = (e2 = i2.options) === null || e2 === void 0 ? void 0 : e2.host, this.ot(this.lt = i2.element)), w;
}
ot(t2) {
typeof this.U == "function" ? (h.get(this.U) !== void 0 && this.U.call(this.ht, void 0), h.set(this.U, t2), t2 !== void 0 && this.U.call(this.ht, t2)) : this.U.value = t2;
}
get rt() {
var t2;
return typeof this.U == "function" ? h.get(this.U) : (t2 = this.U) === null || t2 === void 0 ? void 0 : t2.value;
}
disconnected() {
this.rt === this.lt && this.ot(void 0);
}
reconnected() {
this.ot(this.lt);
}
});
var __defProp2 = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
for (var i2 = decorators.length - 1, decorator; i2 >= 0; i2--)
if (decorator = decorators[i2])
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
if (kind && result)
__defProp2(target, key, result);
return result;
};
let GiscusWidget = class extends s {
constructor() {
super();
this.GISCUS_SESSION_KEY = "giscus-session";
this.GISCUS_ORIGIN = "https://giscus.app";
this.ERROR_SUGGESTION = `Please consider reporting this error at https://github.com/laymonage/giscus/issues/new.`;
this.__session = "";
this._iframeRef = e();
this.messageEventHandler = this.handleMessageEvent.bind(this);
this.reactionsEnabled = "1";
this.emitMetadata = "0";
this.inputPosition = "bottom";
this.theme = "light";
this.lang = "en";
this.loading = "eager";
this.setupSession();
window.addEventListener("message", this.messageEventHandler);
}
get iframeRef() {
return this._iframeRef.value;
}
connectedCallback() {
super.connectedCallback();
}
disconnectedCallback() {
super.disconnectedCallback();
window.removeEventListener("message", this.messageEventHandler);
}
_formatError(message) {
return `[giscus] An error occurred. Error message: "${message}".`;
}
setupSession() {
const origin2 = location.href;
const url = new URL(origin2);
const savedSession = localStorage.getItem(this.GISCUS_SESSION_KEY);
const urlSession = url.searchParams.get("giscus") || "";
if (urlSession) {
localStorage.setItem(this.GISCUS_SESSION_KEY, JSON.stringify(urlSession));
this.__session = urlSession;
url.searchParams.delete("giscus");
history.replaceState(void 0, document.title, url.toString());
return;
}
if (savedSession) {
try {
this.__session = JSON.parse(savedSession || "") || "";
} catch (e2) {
this.__session = "";
localStorage.removeItem(this.GISCUS_SESSION_KEY);
console.warn(`${this._formatError(e2 == null ? void 0 : e2.message)} Session has been cleared.`);
}
}
}
handleMessageEvent(event) {
if (event.origin !== this.GISCUS_ORIGIN)
return;
const { data } = event;
if (!(typeof data === "object" && data.giscus))
return;
if (this.iframeRef && data.giscus.resizeHeight) {
this.iframeRef.style.height = `${data.giscus.resizeHeight}px`;
}
if (!data.giscus.error)
return;
const message = data.giscus.error;
if (message.includes("Bad credentials") || message.includes("Invalid state value")) {
if (localStorage.getItem(this.GISCUS_SESSION_KEY) !== null) {
localStorage.removeItem(this.GISCUS_SESSION_KEY);
this.__session = "";
console.warn(`${this._formatError(message)} Session has been cleared.`);
this.update(/* @__PURE__ */ new Map());
return;
}
console.error(`${this._formatError(message)} No session is stored initially. ${this.ERROR_SUGGESTION}`);
}
if (message.includes("Discussion not found")) {
console.warn(`[giscus] ${message}. A new discussion will be created if a comment/reaction is submitted.`);
return;
}
console.error(`${this._formatError(message)} ${this.ERROR_SUGGESTION}`);
}
sendMessage(message) {
var _a, _b;
(_b = (_a = this.iframeRef) == null ? void 0 : _a.contentWindow) == null ? void 0 : _b.postMessage({ giscus: message }, this.GISCUS_ORIGIN);
}
updateConfig() {
const setConfig = {
setConfig: {
repo: this.repo,
repoId: this.repoId,
category: this.category,
categoryId: this.categoryId,
term: this.getTerm(),
number: +this.getNumber(),
reactionsEnabled: this.reactionsEnabled === "1",
emitMetadata: this.emitMetadata === "1",
inputPosition: this.inputPosition,
theme: this.theme,
lang: this.lang
}
};
this.sendMessage(setConfig);
}
requestUpdate(name, oldValue, options) {
if (!this.hasUpdated) {
super.requestUpdate(name, oldValue, options);
return;
}
this.updateConfig();
}
_getOgMetaContent(property2) {
const element = document.querySelector(`meta[property='og:${property2}'],meta[name='${property2}']`);
return element ? element.content : "";
}
getTerm() {
switch (this.mapping) {
case "url":
return origin;
case "title":
return document.title;
case "og:title":
return this._getOgMetaContent("title");
case "specific":
return this.term || "";
case "number":
return "";
case "pathname":
default:
return location.pathname.length < 2 ? "index" : location.pathname.substring(1).replace(/\.\w+$/, "");
}
}
getNumber() {
return this.mapping === "number" && this.term || "";
}
getIframeSrc() {
const url = new URL(location.href);
url.searchParams.delete("giscus");
const origin2 = `${url}${this.id ? "#" + this.id : ""}`;
const description = this._getOgMetaContent("description");
const params = {
origin: origin2,
session: this.__session,
repo: this.repo,
repoId: this.repoId || "",
category: this.category || "",
categoryId: this.categoryId || "",
term: this.getTerm(),
number: this.getNumber(),
reactionsEnabled: this.reactionsEnabled,
emitMetadata: this.emitMetadata,
inputPosition: this.inputPosition,
theme: this.theme,
description
};
const locale = this.lang ? `/${this.lang}` : "";
const searchParams = new URLSearchParams(params);
return `${this.GISCUS_ORIGIN}${locale}/widget?${searchParams}`;
}
render() {
return $`
<iframe
scrolling="no"
${n(this._iframeRef)}
src=${this.getIframeSrc()}
loading=${this.loading}
></iframe>
`;
}
};
GiscusWidget.styles = r$4`
:host,
iframe {
width: 100%;
border: none;
}
`;
__decorateClass([
e$3({ reflect: true })
], GiscusWidget.prototype, "repo", 2);
__decorateClass([
e$3({ reflect: true })
], GiscusWidget.prototype, "repoId", 2);
__decorateClass([
e$3({ reflect: true })
], GiscusWidget.prototype, "category", 2);
__decorateClass([
e$3({ reflect: true })
], GiscusWidget.prototype, "categoryId", 2);
__decorateClass([
e$3({ reflect: true })
], GiscusWidget.prototype, "mapping", 2);
__decorateClass([
e$3({ reflect: true })
], GiscusWidget.prototype, "term", 2);
__decorateClass([
e$3({ reflect: true })
], GiscusWidget.prototype, "reactionsEnabled", 2);
__decorateClass([
e$3({ reflect: true })
], GiscusWidget.prototype, "emitMetadata", 2);
__decorateClass([
e$3({ reflect: true })
], GiscusWidget.prototype, "inputPosition", 2);
__decorateClass([
e$3({ reflect: true })
], GiscusWidget.prototype, "theme", 2);
__decorateClass([
e$3({ reflect: true })
], GiscusWidget.prototype, "lang", 2);
__decorateClass([
e$3({ reflect: true })
], GiscusWidget.prototype, "loading", 2);
GiscusWidget = __decorateClass([
n$3("giscus-widget")
], GiscusWidget);
export { GiscusWidget };

10

package.json
{
"name": "@giscus/preact",
"version": "2.0.0-beta.3",
"main": "dist/giscus.cjs.js",
"module": "dist/giscus.es.js",
"version": "2.0.0-beta.4",
"main": "dist/index.cjs.js",
"module": "dist/index.es.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"require": "./dist/giscus.cjs.js",
"import": "./dist/giscus.es.js"
"require": "./dist/index.cjs.js",
"import": "./dist/index.es.js"
}

@@ -12,0 +12,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc