diff --git a/.prettierrc b/.prettierrc
index 6b51545e..d0308401 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -2,5 +2,6 @@
"useTabs": false,
"singleQuote": true,
"trailingComma": "es5",
- "printWidth": 80
+ "printWidth": 80,
+ "svelteStrictMode": true
}
diff --git a/react/package-lock.json b/react/package-lock.json
index 88c71ca5..00fe3247 100644
--- a/react/package-lock.json
+++ b/react/package-lock.json
@@ -1,14 +1,14 @@
{
"name": "@giscus/react",
- "version": "2.2.8",
+ "version": "2.3.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@giscus/react",
- "version": "2.2.8",
+ "version": "2.3.0",
"dependencies": {
- "giscus": "^1.2.8"
+ "giscus": "^1.3.0"
},
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.1",
@@ -2377,11 +2377,11 @@
}
},
"node_modules/giscus": {
- "version": "1.2.8",
- "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.2.8.tgz",
- "integrity": "sha512-pufrgQYt1W+4ztiWp/PilLPN8NdyKvpbQ8jNqbAa1g84t6qqyevXHfkOYCi4x4d+y191vJAUc6seL1Dq74yUeA==",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.3.0.tgz",
+ "integrity": "sha512-A3tVLgSmpnh2sX9uGjo9MbzmTTEJirSyFUPRvkipvy37y9rhxUYDoh9kO37QVrP7Sc7QuJ+gihB6apkO0yDyTw==",
"dependencies": {
- "lit": "^2.6.1"
+ "lit": "^2.7.5"
}
},
"node_modules/glob": {
@@ -5665,11 +5665,11 @@
}
},
"giscus": {
- "version": "1.2.8",
- "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.2.8.tgz",
- "integrity": "sha512-pufrgQYt1W+4ztiWp/PilLPN8NdyKvpbQ8jNqbAa1g84t6qqyevXHfkOYCi4x4d+y191vJAUc6seL1Dq74yUeA==",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.3.0.tgz",
+ "integrity": "sha512-A3tVLgSmpnh2sX9uGjo9MbzmTTEJirSyFUPRvkipvy37y9rhxUYDoh9kO37QVrP7Sc7QuJ+gihB6apkO0yDyTw==",
"requires": {
- "lit": "^2.6.1"
+ "lit": "^2.7.5"
}
},
"glob": {
diff --git a/react/package.json b/react/package.json
index 9e007d3f..faabd79e 100644
--- a/react/package.json
+++ b/react/package.json
@@ -1,6 +1,6 @@
{
"name": "@giscus/react",
- "version": "2.2.8",
+ "version": "2.3.0",
"main": "dist/index.js",
"module": "dist/wrapper.mjs",
"types": "dist/index.d.ts",
@@ -29,7 +29,7 @@
"format:fix": "prettier src --write"
},
"dependencies": {
- "giscus": "^1.2.8"
+ "giscus": "^1.3.0"
},
"peerDependencies": {
"react": "^16 || ^17 || ^18",
diff --git a/react/src/lib/types.ts b/react/src/lib/types.ts
index 0b5ac57d..266e4a4d 100644
--- a/react/src/lib/types.ts
+++ b/react/src/lib/types.ts
@@ -24,17 +24,23 @@ export type Theme =
| 'dark_protanopia'
| 'dark_tritanopia'
| 'dark_dimmed'
- | 'transparent_dark'
| 'preferred_color_scheme'
+ | 'transparent_dark'
+ | 'noborder_light'
+ | 'noborder_dark'
+ | 'cobalt'
| `https://${string}`
| GenericString;
export type AvailableLanguage =
+ | 'ar'
+ | 'ca'
| 'de'
- | 'gsw'
| 'en'
| 'es'
+ | 'fa'
| 'fr'
+ | 'he'
| 'id'
| 'it'
| 'ja'
@@ -44,8 +50,10 @@ export type AvailableLanguage =
| 'pt'
| 'ro'
| 'ru'
+ | 'th'
| 'tr'
| 'vi'
+ | 'uk'
| 'zh-CN'
| 'zh-TW'
| GenericString;
diff --git a/solid/package-lock.json b/solid/package-lock.json
index 86319396..ca8ea5d8 100644
--- a/solid/package-lock.json
+++ b/solid/package-lock.json
@@ -1,14 +1,14 @@
{
"name": "@giscus/solid",
- "version": "2.2.8",
+ "version": "2.3.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@giscus/solid",
- "version": "2.2.8",
+ "version": "2.3.0",
"dependencies": {
- "giscus": "^1.2.8"
+ "giscus": "^1.3.0"
},
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.2",
@@ -2490,11 +2490,11 @@
}
},
"node_modules/giscus": {
- "version": "1.2.8",
- "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.2.8.tgz",
- "integrity": "sha512-pufrgQYt1W+4ztiWp/PilLPN8NdyKvpbQ8jNqbAa1g84t6qqyevXHfkOYCi4x4d+y191vJAUc6seL1Dq74yUeA==",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.3.0.tgz",
+ "integrity": "sha512-A3tVLgSmpnh2sX9uGjo9MbzmTTEJirSyFUPRvkipvy37y9rhxUYDoh9kO37QVrP7Sc7QuJ+gihB6apkO0yDyTw==",
"dependencies": {
- "lit": "^2.6.1"
+ "lit": "^2.7.5"
}
},
"node_modules/glob": {
@@ -5881,11 +5881,11 @@
}
},
"giscus": {
- "version": "1.2.8",
- "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.2.8.tgz",
- "integrity": "sha512-pufrgQYt1W+4ztiWp/PilLPN8NdyKvpbQ8jNqbAa1g84t6qqyevXHfkOYCi4x4d+y191vJAUc6seL1Dq74yUeA==",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.3.0.tgz",
+ "integrity": "sha512-A3tVLgSmpnh2sX9uGjo9MbzmTTEJirSyFUPRvkipvy37y9rhxUYDoh9kO37QVrP7Sc7QuJ+gihB6apkO0yDyTw==",
"requires": {
- "lit": "^2.6.1"
+ "lit": "^2.7.5"
}
},
"glob": {
diff --git a/solid/package.json b/solid/package.json
index 67ef466b..3f4697a3 100644
--- a/solid/package.json
+++ b/solid/package.json
@@ -1,6 +1,6 @@
{
"name": "@giscus/solid",
- "version": "2.2.8",
+ "version": "2.3.0",
"main": "dist/index.js",
"module": "dist/wrapper.mjs",
"types": "dist/index.d.ts",
@@ -29,7 +29,7 @@
"format:fix": "prettier src --write"
},
"dependencies": {
- "giscus": "^1.2.8"
+ "giscus": "^1.3.0"
},
"peerDependencies": {
"solid-js": "^1.3 || ^1.4 || ^1.5 || ^1.6"
diff --git a/solid/src/lib/types.ts b/solid/src/lib/types.ts
index 0b5ac57d..266e4a4d 100644
--- a/solid/src/lib/types.ts
+++ b/solid/src/lib/types.ts
@@ -24,17 +24,23 @@ export type Theme =
| 'dark_protanopia'
| 'dark_tritanopia'
| 'dark_dimmed'
- | 'transparent_dark'
| 'preferred_color_scheme'
+ | 'transparent_dark'
+ | 'noborder_light'
+ | 'noborder_dark'
+ | 'cobalt'
| `https://${string}`
| GenericString;
export type AvailableLanguage =
+ | 'ar'
+ | 'ca'
| 'de'
- | 'gsw'
| 'en'
| 'es'
+ | 'fa'
| 'fr'
+ | 'he'
| 'id'
| 'it'
| 'ja'
@@ -44,8 +50,10 @@ export type AvailableLanguage =
| 'pt'
| 'ro'
| 'ru'
+ | 'th'
| 'tr'
| 'vi'
+ | 'uk'
| 'zh-CN'
| 'zh-TW'
| GenericString;
diff --git a/svelte/package-lock.json b/svelte/package-lock.json
index 35a89ae5..1fe88882 100644
--- a/svelte/package-lock.json
+++ b/svelte/package-lock.json
@@ -1,14 +1,14 @@
{
"name": "@giscus/svelte",
- "version": "2.2.8",
+ "version": "2.3.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@giscus/svelte",
- "version": "2.2.8",
+ "version": "2.3.0",
"dependencies": {
- "giscus": "^1.2.8"
+ "giscus": "^1.3.0"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^2.1.0",
@@ -30,7 +30,7 @@
"vite": "^4.3.9"
},
"peerDependencies": {
- "svelte": "^3"
+ "svelte": "^3 || ^4"
}
},
"node_modules/@aashutoshrathi/word-wrap": {
@@ -1612,11 +1612,11 @@
}
},
"node_modules/giscus": {
- "version": "1.2.8",
- "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.2.8.tgz",
- "integrity": "sha512-pufrgQYt1W+4ztiWp/PilLPN8NdyKvpbQ8jNqbAa1g84t6qqyevXHfkOYCi4x4d+y191vJAUc6seL1Dq74yUeA==",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.3.0.tgz",
+ "integrity": "sha512-A3tVLgSmpnh2sX9uGjo9MbzmTTEJirSyFUPRvkipvy37y9rhxUYDoh9kO37QVrP7Sc7QuJ+gihB6apkO0yDyTw==",
"dependencies": {
- "lit": "^2.6.1"
+ "lit": "^2.7.5"
}
},
"node_modules/glob": {
@@ -3974,11 +3974,11 @@
"optional": true
},
"giscus": {
- "version": "1.2.8",
- "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.2.8.tgz",
- "integrity": "sha512-pufrgQYt1W+4ztiWp/PilLPN8NdyKvpbQ8jNqbAa1g84t6qqyevXHfkOYCi4x4d+y191vJAUc6seL1Dq74yUeA==",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.3.0.tgz",
+ "integrity": "sha512-A3tVLgSmpnh2sX9uGjo9MbzmTTEJirSyFUPRvkipvy37y9rhxUYDoh9kO37QVrP7Sc7QuJ+gihB6apkO0yDyTw==",
"requires": {
- "lit": "^2.6.1"
+ "lit": "^2.7.5"
}
},
"glob": {
diff --git a/svelte/package.json b/svelte/package.json
index c8cce697..84e007f5 100644
--- a/svelte/package.json
+++ b/svelte/package.json
@@ -1,7 +1,6 @@
{
"name": "@giscus/svelte",
- "version": "2.2.8",
- "types": "./index.d.ts",
+ "version": "2.3.0",
"repository": {
"type": "git",
"url": "https://github.com/giscus/giscus-component.git",
@@ -38,10 +37,10 @@
},
"type": "module",
"dependencies": {
- "giscus": "^1.2.8"
+ "giscus": "^1.3.0"
},
"peerDependencies": {
- "svelte": "^3"
+ "svelte": "^3 || ^4"
},
"exports": {
"./package.json": "./package.json",
@@ -61,5 +60,6 @@
"files": [
"package"
],
- "svelte": "./package/index.js"
+ "svelte": "./package/index.js",
+ "types": "./package/index.d.ts"
}
diff --git a/svelte/src/lib/Giscus.svelte b/svelte/src/lib/Giscus.svelte
index 22e0a051..b37a866e 100644
--- a/svelte/src/lib/Giscus.svelte
+++ b/svelte/src/lib/Giscus.svelte
@@ -35,20 +35,19 @@
{#if mounted}
+ id="{id}"
+ host="{host}"
+ repo="{repo}"
+ repoid="{repoId}"
+ category="{category}"
+ categoryid="{categoryId}"
+ mapping="{mapping}"
+ term="{term}"
+ strict="{strict}"
+ reactionsenabled="{reactionsEnabled}"
+ emitmetadata="{emitMetadata}"
+ inputposition="{inputPosition}"
+ theme="{theme}"
+ lang="{lang}"
+ loading="{loading}">
{/if}
diff --git a/svelte/src/lib/index.ts b/svelte/src/lib/index.ts
index 621d5eb2..f14b660d 100644
--- a/svelte/src/lib/index.ts
+++ b/svelte/src/lib/index.ts
@@ -24,17 +24,23 @@ export type Theme =
| 'dark_protanopia'
| 'dark_tritanopia'
| 'dark_dimmed'
- | 'transparent_dark'
| 'preferred_color_scheme'
+ | 'transparent_dark'
+ | 'noborder_light'
+ | 'noborder_dark'
+ | 'cobalt'
| `https://${string}`
| GenericString;
export type AvailableLanguage =
+ | 'ar'
+ | 'ca'
| 'de'
- | 'gsw'
| 'en'
| 'es'
+ | 'fa'
| 'fr'
+ | 'he'
| 'id'
| 'it'
| 'ja'
@@ -44,8 +50,10 @@ export type AvailableLanguage =
| 'pt'
| 'ro'
| 'ru'
+ | 'th'
| 'tr'
| 'vi'
+ | 'uk'
| 'zh-CN'
| 'zh-TW'
| GenericString;
diff --git a/vue/package-lock.json b/vue/package-lock.json
index 7ed9c910..031de591 100644
--- a/vue/package-lock.json
+++ b/vue/package-lock.json
@@ -1,14 +1,14 @@
{
"name": "@giscus/vue",
- "version": "2.2.8",
+ "version": "2.3.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@giscus/vue",
- "version": "2.2.8",
+ "version": "2.3.0",
"dependencies": {
- "giscus": "^1.2.8"
+ "giscus": "^1.3.0"
},
"devDependencies": {
"@types/node": "^18.16.19",
@@ -1608,11 +1608,11 @@
}
},
"node_modules/giscus": {
- "version": "1.2.8",
- "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.2.8.tgz",
- "integrity": "sha512-pufrgQYt1W+4ztiWp/PilLPN8NdyKvpbQ8jNqbAa1g84t6qqyevXHfkOYCi4x4d+y191vJAUc6seL1Dq74yUeA==",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.3.0.tgz",
+ "integrity": "sha512-A3tVLgSmpnh2sX9uGjo9MbzmTTEJirSyFUPRvkipvy37y9rhxUYDoh9kO37QVrP7Sc7QuJ+gihB6apkO0yDyTw==",
"dependencies": {
- "lit": "^2.6.1"
+ "lit": "^2.7.5"
}
},
"node_modules/glob": {
@@ -3734,11 +3734,11 @@
"optional": true
},
"giscus": {
- "version": "1.2.8",
- "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.2.8.tgz",
- "integrity": "sha512-pufrgQYt1W+4ztiWp/PilLPN8NdyKvpbQ8jNqbAa1g84t6qqyevXHfkOYCi4x4d+y191vJAUc6seL1Dq74yUeA==",
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/giscus/-/giscus-1.3.0.tgz",
+ "integrity": "sha512-A3tVLgSmpnh2sX9uGjo9MbzmTTEJirSyFUPRvkipvy37y9rhxUYDoh9kO37QVrP7Sc7QuJ+gihB6apkO0yDyTw==",
"requires": {
- "lit": "^2.6.1"
+ "lit": "^2.7.5"
}
},
"glob": {
diff --git a/vue/package.json b/vue/package.json
index 744b0057..97c77458 100644
--- a/vue/package.json
+++ b/vue/package.json
@@ -1,6 +1,6 @@
{
"name": "@giscus/vue",
- "version": "2.2.8",
+ "version": "2.3.0",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
@@ -30,7 +30,7 @@
"format:fix": "prettier src --write"
},
"dependencies": {
- "giscus": "^1.2.8"
+ "giscus": "^1.3.0"
},
"peerDependencies": {
"vue": ">=3.2.0"
diff --git a/vue/src/lib/types.ts b/vue/src/lib/types.ts
index 0b5ac57d..266e4a4d 100644
--- a/vue/src/lib/types.ts
+++ b/vue/src/lib/types.ts
@@ -24,17 +24,23 @@ export type Theme =
| 'dark_protanopia'
| 'dark_tritanopia'
| 'dark_dimmed'
- | 'transparent_dark'
| 'preferred_color_scheme'
+ | 'transparent_dark'
+ | 'noborder_light'
+ | 'noborder_dark'
+ | 'cobalt'
| `https://${string}`
| GenericString;
export type AvailableLanguage =
+ | 'ar'
+ | 'ca'
| 'de'
- | 'gsw'
| 'en'
| 'es'
+ | 'fa'
| 'fr'
+ | 'he'
| 'id'
| 'it'
| 'ja'
@@ -44,8 +50,10 @@ export type AvailableLanguage =
| 'pt'
| 'ro'
| 'ru'
+ | 'th'
| 'tr'
| 'vi'
+ | 'uk'
| 'zh-CN'
| 'zh-TW'
| GenericString;
diff --git a/web/package-lock.json b/web/package-lock.json
index 873bf6cd..e0237202 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "giscus",
- "version": "1.2.8",
+ "version": "1.3.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "giscus",
- "version": "1.2.8",
+ "version": "1.3.0",
"license": "MIT",
"dependencies": {
"lit": "^2.7.5"
diff --git a/web/package.json b/web/package.json
index 108045a1..7e2e29de 100644
--- a/web/package.json
+++ b/web/package.json
@@ -1,6 +1,6 @@
{
"name": "giscus",
- "version": "1.2.8",
+ "version": "1.3.0",
"type": "module",
"main": "dist/giscus.mjs",
"module": "dist/giscus.mjs",
diff --git a/web/src/giscus.ts b/web/src/giscus.ts
index 4835b3e7..871ba517 100644
--- a/web/src/giscus.ts
+++ b/web/src/giscus.ts
@@ -2,10 +2,17 @@ import { html, css, LitElement, PropertyDeclaration } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { createRef, ref, Ref } from 'lit/directives/ref.js';
+function safeCustomElement(tagName: string) {
+ // Prevents re-registering an element.
+ return customElements.get(tagName)
+ ? (v: ReturnType>) => v
+ : customElement(tagName);
+}
+
/**
* Widget element for giscus.
*/
-@customElement('giscus-widget')
+@safeCustomElement('giscus-widget')
export class GiscusWidget extends LitElement {
private GISCUS_SESSION_KEY = 'giscus-session';
private GISCUS_DEFAULT_HOST = 'https://giscus.app';
@@ -40,6 +47,17 @@ export class GiscusWidget extends LitElement {
@property({ reflect: true })
host: string = this.GISCUS_DEFAULT_HOST;
+ get _host() {
+ // Ensure that the host is always a valid URL even if the attribute
+ // has been set to an invalid value.
+ try {
+ new URL(this.host);
+ return this.host;
+ } catch {
+ return this.GISCUS_DEFAULT_HOST;
+ }
+ }
+
/**
* Repo where the discussion is stored.
*/
@@ -169,7 +187,7 @@ export class GiscusWidget extends LitElement {
}
private handleMessageEvent(event: MessageEvent) {
- if (event.origin !== this.host) return;
+ if (event.origin !== this._host) return;
const { data } = event;
if (!(typeof data === 'object' && data.giscus)) return;
@@ -220,7 +238,8 @@ export class GiscusWidget extends LitElement {
private sendMessage(message: T) {
if (!this.iframeRef || !this.iframeRef.contentWindow || !this.hasLoaded)
return;
- this.iframeRef.contentWindow.postMessage({ giscus: message }, this.host);
+ console.log({ host: this.host, _host: this._host });
+ this.iframeRef.contentWindow.postMessage({ giscus: message }, this._host);
}
private updateConfig() {
@@ -333,7 +352,7 @@ export class GiscusWidget extends LitElement {
backLink,
};
- const host = this.host || this.GISCUS_DEFAULT_HOST;
+ const host = this._host;
const locale = this.lang ? `/${this.lang}` : '';
const searchParams = new URLSearchParams(params);
@@ -388,17 +407,23 @@ type Theme =
| 'dark_protanopia'
| 'dark_tritanopia'
| 'dark_dimmed'
- | 'transparent_dark'
| 'preferred_color_scheme'
+ | 'transparent_dark'
+ | 'noborder_light'
+ | 'noborder_dark'
+ | 'cobalt'
| `https://${string}`
| GenericString;
type Lang =
+ | 'ar'
+ | 'ca'
| 'de'
- | 'gsw'
| 'en'
| 'es'
+ | 'fa'
| 'fr'
+ | 'he'
| 'id'
| 'it'
| 'ja'
@@ -408,8 +433,10 @@ type Lang =
| 'pt'
| 'ro'
| 'ru'
+ | 'th'
| 'tr'
| 'vi'
+ | 'uk'
| 'zh-CN'
| 'zh-TW'
| GenericString;