From b8800aaef44758a67db0d7f7142387a9d89ea01f Mon Sep 17 00:00:00 2001 From: HEIGE-PCloud Date: Wed, 22 Dec 2021 20:04:59 +0000 Subject: [PATCH 1/7] refactor: seperate waline --- assets/js/lib/waline.js | 6 ++++++ assets/js/shims/waline.js | 1 + assets/js/theme.js | 1 - layouts/partials/comment.html | 10 +++++++++- package-lock.json | 6 ++++++ package.json | 1 + 6 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 assets/js/lib/waline.js create mode 100644 assets/js/shims/waline.js diff --git a/assets/js/lib/waline.js b/assets/js/lib/waline.js new file mode 100644 index 000000000..5b01fa36d --- /dev/null +++ b/assets/js/lib/waline.js @@ -0,0 +1,6 @@ +/* eslint-disable no-new */ +import Waline from '@waline/client' + +if (window.config.comment.waline) { + new Waline(window.config.comment.waline) +} diff --git a/assets/js/shims/waline.js b/assets/js/shims/waline.js new file mode 100644 index 000000000..e3d0c9d79 --- /dev/null +++ b/assets/js/shims/waline.js @@ -0,0 +1 @@ +module.exports = window.Waline diff --git a/assets/js/theme.js b/assets/js/theme.js index b5a40047f..e0c61d53b 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -750,7 +750,6 @@ function initComment () { gitalk.render('gitalk') } if (window.config.comment.valine) new Valine(window.config.comment.valine) - if (window.config.comment.waline) new Waline(window.config.comment.waline) if (window.config.comment.utterances) { const utterancesConfig = window.config.comment.utterances const script = document.createElement('script') diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index 5d0e3ab2e..eb7e9bc01 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -65,7 +65,7 @@ {{- if $waline.enable -}}
{{- $source := $cdn.walineJS | default "lib/waline/Waline.min.js" -}} - {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}} + {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}} {{- $commentConfig = dict "el" "#waline" "serverURL" $waline.serverURL "lang" .Lang "dark" "body[theme='dark'], body[theme='black']" "copyright" true | dict "waline" | merge $commentConfig -}} {{- with $waline.visitor -}} {{- $commentConfig = dict "visitor" . | dict "waline" | merge $commentConfig -}} @@ -97,6 +97,14 @@ {{- with $waline.mathTagSupport -}} {{- $commentConfig = dict "mathTagSupport" . | dict "waline" | merge $commentConfig -}} {{- end -}} + {{- $shims := dict "@waline/client" "js/shims/waline.js" -}} + {{- $options := dict -}} + {{- $options = dict "targetPath" "js/waline.min.js" | merge $options -}} + {{- $options = dict "minify" true | merge $options -}} + {{- $options = dict "shims" $shims | merge $options -}} + {{- $js := resources.Get "js/lib/waline.js" | js.Build $options -}} + {{- $_ := $js.RelPermalink -}} + {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}} diff --git a/package-lock.json b/package-lock.json index b61a5d1c3..e55971457 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2321,6 +2321,12 @@ "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", "dev": true }, + "@waline/client": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@waline/client/-/client-1.5.2.tgz", + "integrity": "sha512-3OT1/FqyqBn2py6pIOfoDK3Rt/kqaRivZDJ+Ol6aqqUj5uj2pBcLzyrAFu0KIKODJydModjnKa9RSlTIYbN78Q==", + "dev": true + }, "acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", diff --git a/package.json b/package.json index e2c33785c..b3039c473 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "DoIt theme source file", "private": true, "devDependencies": { + "@waline/client": "^1.5.2", "eslint": "^7.32.0", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "^2.25.3", From 0b016de7445b89621f0c5009bf42710d5ffb5e3d Mon Sep 17 00:00:00 2001 From: HEIGE-PCloud Date: Wed, 22 Dec 2021 20:13:36 +0000 Subject: [PATCH 2/7] refactor: separate valine --- assets/js/lib/valine.js | 6 + assets/js/shims/valine.js | 1 + assets/js/theme.js | 1 - layouts/partials/comment.html | 12 +- package-lock.json | 806 +++++++++++++++++++++++++++++++++- package.json | 3 +- 6 files changed, 819 insertions(+), 10 deletions(-) create mode 100644 assets/js/lib/valine.js create mode 100644 assets/js/shims/valine.js diff --git a/assets/js/lib/valine.js b/assets/js/lib/valine.js new file mode 100644 index 000000000..1d97f578f --- /dev/null +++ b/assets/js/lib/valine.js @@ -0,0 +1,6 @@ +/* eslint-disable no-new */ +import Valine from 'valine' + +if (window.config.comment.valine) { + new Valine(window.config.comment.valine) +} diff --git a/assets/js/shims/valine.js b/assets/js/shims/valine.js new file mode 100644 index 000000000..d8ebf941b --- /dev/null +++ b/assets/js/shims/valine.js @@ -0,0 +1 @@ +module.exports = window.Valine diff --git a/assets/js/theme.js b/assets/js/theme.js index e0c61d53b..48e164664 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -749,7 +749,6 @@ function initComment () { const gitalk = new Gitalk(window.config.comment.gitalk) gitalk.render('gitalk') } - if (window.config.comment.valine) new Valine(window.config.comment.valine) if (window.config.comment.utterances) { const utterancesConfig = window.config.comment.utterances const script = document.createElement('script') diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index eb7e9bc01..5ad411712 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -40,7 +40,7 @@ {{- $options := dict "targetPath" "lib/valine/valine.min.css" -}} {{- dict "Source" "lib/valine/Valine.scss" "ToCSS" $options | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxStyle.html" -}} {{- $source := $cdn.valineJS | default "lib/valine/Valine.min.js" -}} - {{- dict "Source" $source "Fingerprint" $fingerprint | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}} + {{- dict "Source" $source "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}} {{- $commentConfig = dict "el" "#valine" "appId" $valine.appId "appKey" $valine.appKey "lang" ($valine.lang | default (T "valineLang")) "visitor" $valine.visitor "recordIP" $valine.recordIP "placeholder" ($valine.placeholder | default (T "valinePlaceholder")) "highlight" (ne $valine.highlight false) "enableQQ" $valine.enableQQ | dict "valine" | merge $commentConfig -}} {{- with $valine.avatar -}} {{- $commentConfig = dict "avatar" . | dict "valine" | merge $commentConfig -}} @@ -55,6 +55,14 @@ {{- $commentConfig = dict "serverURLs" . | dict "valine" | merge $commentConfig -}} {{- end -}} {{- $commentConfig = $valine.emoji | default "google.yml" | printf "data/emoji/%v" | resources.Get | transform.Unmarshal | dict "valine" | merge $commentConfig -}} + {{- $shims := dict "valine" "js/shims/valine.js" -}} + {{- $options := dict -}} + {{- $options = dict "targetPath" "js/valine.min.js" | merge $options -}} + {{- $options = dict "minify" true | merge $options -}} + {{- $options = dict "shims" $shims | merge $options -}} + {{- $js := resources.Get "js/lib/valine.js" | js.Build $options -}} + {{- $_ := $js.RelPermalink -}} + {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}} @@ -194,7 +202,7 @@ {{- $options = dict "shims" $shims | merge $options -}} {{- $js := resources.Get "js/lib/twikoo.js" | js.Build $options -}} {{- $_ := $js.RelPermalink -}} - {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}} + {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}} {{- $commentConfig = dict "el" "#twikoo" "envId" $twikoo.envId | dict "twikoo" | merge $commentConfig -}} {{- $commentConfig = dict "lang" .Lang | dict "twikoo" | merge $commentConfig -}} {{- with $twikoo.region -}} diff --git a/package-lock.json b/package-lock.json index e55971457..a231a7f4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2309,18 +2309,165 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, + "@leancloud/adapter-types": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@leancloud/adapter-types/-/adapter-types-3.0.0.tgz", + "integrity": "sha512-/1l2PWJ6pXizHphBorMN7B0d2YjmxZJf1s+bitvLALt7wBid5qbGpHqGGKE/yRdNlCKwl9FbXG1x5wUFZfQwHQ==" + }, + "@leancloud/adapter-utils": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@leancloud/adapter-utils/-/adapter-utils-1.2.2.tgz", + "integrity": "sha512-B/bZM6WGN+sxMdZJeTWLAN/Gin00LX0E/M0MoygZhtrgCfCZSz47wgziOq5Fvl6yPifyvYBGaobydhyr7vxjxg==" + }, + "@leancloud/adapters-superagent": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@leancloud/adapters-superagent/-/adapters-superagent-1.4.2.tgz", + "integrity": "sha512-UpawevTXaIIFEpvtW6rm6PKH28i3OCIjgdJUmcFWbI8lezHz6bBznKB9g0aCRX8/c2h6SJThzjgqNlPny8I32g==", + "requires": { + "@leancloud/adapter-types": "^5.0.0", + "@leancloud/adapter-utils": "^1.2.2", + "@types/superagent": "^4.1.7", + "superagent": "^5.2.2" + }, + "dependencies": { + "@leancloud/adapter-types": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@leancloud/adapter-types/-/adapter-types-5.0.0.tgz", + "integrity": "sha512-psnPaa4ONaA6X9y9xsjLmJXH+2spySH/YQUz59S0cZUTWVbZaUFwLQyHkv8OzZFixKqs+eV3xnWl7nUxCCCIeg==" + }, + "debug": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", + "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "requires": { + "lru-cache": "^6.0.0" + } + }, + "superagent": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-5.3.1.tgz", + "integrity": "sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==", + "requires": { + "component-emitter": "^1.3.0", + "cookiejar": "^2.1.2", + "debug": "^4.1.1", + "fast-safe-stringify": "^2.0.7", + "form-data": "^3.0.0", + "formidable": "^1.2.2", + "methods": "^1.1.2", + "mime": "^2.4.6", + "qs": "^6.9.4", + "readable-stream": "^3.6.0", + "semver": "^7.3.2" + } + } + } + }, + "@leancloud/platform-adapters-browser": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@leancloud/platform-adapters-browser/-/platform-adapters-browser-1.5.2.tgz", + "integrity": "sha512-O7FRG4KvH20tiIP+dUbb7FE7kgkwEZifu7XmSRdPB5yO/+wR61BKykVQggQUdqJE6T9HZVSrqqbWWNqcMdJK6g==", + "requires": { + "@leancloud/adapter-types": "^5.0.0", + "@leancloud/adapters-superagent": "^1.4.2" + }, + "dependencies": { + "@leancloud/adapter-types": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@leancloud/adapter-types/-/adapter-types-5.0.0.tgz", + "integrity": "sha512-psnPaa4ONaA6X9y9xsjLmJXH+2spySH/YQUz59S0cZUTWVbZaUFwLQyHkv8OzZFixKqs+eV3xnWl7nUxCCCIeg==" + } + } + }, + "@leancloud/platform-adapters-node": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/@leancloud/platform-adapters-node/-/platform-adapters-node-1.5.2.tgz", + "integrity": "sha512-FhvL6u0CXG33M5UCla2Rfja6Rrv8Sj1mrRWCZvI6m5sW4A7RyWFICW8akBL++uHUNP8WDc7szfrBz8TJHQWDcg==", + "requires": { + "@leancloud/adapter-types": "^5.0.0", + "@leancloud/adapters-superagent": "^1.4.2", + "@types/ws": "^7.2.2", + "localstorage-memory": "^1.0.2", + "ws": "^5.2.2" + }, + "dependencies": { + "@leancloud/adapter-types": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@leancloud/adapter-types/-/adapter-types-5.0.0.tgz", + "integrity": "sha512-psnPaa4ONaA6X9y9xsjLmJXH+2spySH/YQUz59S0cZUTWVbZaUFwLQyHkv8OzZFixKqs+eV3xnWl7nUxCCCIeg==" + } + } + }, + "@leancloud/platform-adapters-weapp": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@leancloud/platform-adapters-weapp/-/platform-adapters-weapp-1.6.1.tgz", + "integrity": "sha512-/Pxj0Zk9829OTQdt1KdfglqVBiOteber8gUzw5Kgjws1+hlPJ7x8x5VZcdPM3lnTh6UsP4f6CkOtS/QOeLu6JA==", + "requires": { + "@leancloud/adapter-types": "^5.0.0", + "@leancloud/adapter-utils": "^1.2.2", + "event-target-shim": "^5.0.1", + "miniprogram-api-typings": "^2.10.2" + }, + "dependencies": { + "@leancloud/adapter-types": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@leancloud/adapter-types/-/adapter-types-5.0.0.tgz", + "integrity": "sha512-psnPaa4ONaA6X9y9xsjLmJXH+2spySH/YQUz59S0cZUTWVbZaUFwLQyHkv8OzZFixKqs+eV3xnWl7nUxCCCIeg==" + } + } + }, "@nicolo-ribaudo/chokidar-2": { "version": "2.1.8-no-fsevents.3", "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/chokidar-2/-/chokidar-2-2.1.8-no-fsevents.3.tgz", "integrity": "sha512-s88O1aVtXftvp5bCPB7WnmXc5IwOZZ7YPuwNPt+GtOOXpPvad1LfbmjYv+qII7zP6RU2QGnqve27dnLycEnyEQ==", "optional": true }, + "@types/cookiejar": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.2.tgz", + "integrity": "sha512-t73xJJrvdTjXrn4jLS9VSGRbz0nUY3cl2DMGDU48lKl+HR9dbbjW2A9r3g40VA++mQpy6uuHg33gy7du2BKpog==" + }, "@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", "dev": true }, + "@types/node": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.2.tgz", + "integrity": "sha512-JepeIUPFDARgIs0zD/SKPgFsJEAF0X5/qO80llx59gOxFTboS9Amv3S+QfB7lqBId5sFXJ99BN0J6zFRvL9dDA==" + }, + "@types/superagent": { + "version": "4.1.13", + "resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-4.1.13.tgz", + "integrity": "sha512-YIGelp3ZyMiH0/A09PMAORO0EBGlF5xIKfDpK74wdYvWUs2o96b5CItJcWPdH409b7SAXIIG6p8NdU/4U2Maww==", + "requires": { + "@types/cookiejar": "*", + "@types/node": "*" + } + }, + "@types/ws": { + "version": "7.4.7", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz", + "integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==", + "requires": { + "@types/node": "*" + } + }, "@waline/client": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/@waline/client/-/client-1.5.2.tgz", @@ -2463,12 +2610,36 @@ "es-abstract": "^1.19.0" } }, + "ascli": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/ascli/-/ascli-1.0.1.tgz", + "integrity": "sha1-vPpZdKYvGOgcq660lzKrSoj5Brw=", + "requires": { + "colour": "~0.7.1", + "optjs": "~3.2.2" + } + }, + "assignment": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/assignment/-/assignment-2.0.0.tgz", + "integrity": "sha1-/9F7Ib9dayLnd7mJaBqBVFaj3T4=" + }, "astral-regex": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", "dev": true }, + "async-limiter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==" + }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, "atomic-algolia": { "version": "0.3.19", "resolved": "https://registry.npmjs.org/atomic-algolia/-/atomic-algolia-0.3.19.tgz", @@ -2544,6 +2715,16 @@ "@babel/helper-define-polyfill-provider": "^0.2.0" } }, + "balajs": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/balajs/-/balajs-1.0.10.tgz", + "integrity": "sha512-dcpjzNfZ9W+RzCz4YpESesw77Qx+U2dZiP+hwSlobcHRrnbEBHFWuxipXGZsMDJbD6SG1hC2S0OHHVkU+JY+iw==" + }, + "balalaika": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/balalaika/-/balalaika-1.0.1.tgz", + "integrity": "sha1-BmQUeiV+oq1K5mRRcR5SZoMNUdk=" + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -2554,6 +2735,11 @@ "resolved": "https://registry.npmjs.org/balloon-css/-/balloon-css-0.5.2.tgz", "integrity": "sha512-zheJpzwyNrG4t39vusA67v3BYg1HTVXOF8cErPEHzWK88PEOFwgo6Ea9VHOgOWNMgeuOtFVtB73NE2NWl9uDyQ==" }, + "base64-arraybuffer": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz", + "integrity": "sha1-c5JncZI7Whl0etZmqlzUv5xunOg=" + }, "binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -2590,6 +2776,14 @@ "picocolors": "^1.0.0" } }, + "bytebuffer": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/bytebuffer/-/bytebuffer-5.0.1.tgz", + "integrity": "sha1-WC7qSxqHO20CCkjVjfhfC7ps/d0=", + "requires": { + "long": "~3" + } + }, "call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", @@ -2605,6 +2799,11 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, + "camelcase": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", + "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=" + }, "caniuse-lite": { "version": "1.0.30001282", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001282.tgz", @@ -2641,6 +2840,54 @@ "readdirp": "~3.6.0" } }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -2654,11 +2901,29 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, + "colour": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/colour/-/colour-0.7.1.tgz", + "integrity": "sha1-nLFpkX7F0SwHNtPoaFdG3xyt93g=" + }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, "commander": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==" }, + "component-emitter": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==" + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2677,6 +2942,11 @@ "resolved": "https://registry.npmjs.org/cookieconsent/-/cookieconsent-3.1.1.tgz", "integrity": "sha512-v8JWLJcI7Zs9NWrs8hiVldVtm3EBF70TJI231vxn6YToBGj0c9dvdnYwltydkAnrbBMOM/qX1xLFrnTfm5wTag==" }, + "cookiejar": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.3.tgz", + "integrity": "sha512-JxbCBUdrfr6AQjOXrxoTvAMJO4HBTUIlBzslcJPAz+/KT8yk53fXun51u+RenNYvad/+Vc2DIz5o9UxlCDymFQ==" + }, "core-js-compat": { "version": "3.19.1", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.19.1.tgz", @@ -2693,6 +2963,11 @@ } } }, + "core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -2709,6 +2984,11 @@ "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=" }, + "cssfilter": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/cssfilter/-/cssfilter-0.0.10.tgz", + "integrity": "sha1-xtJnJjKi5cg+AT5oZKQs6N79IK4=" + }, "d3": { "version": "7.2.1", "resolved": "https://registry.npmjs.org/d3/-/d3-7.2.1.tgz", @@ -3286,6 +3566,11 @@ "ms": "2.0.0" } }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + }, "deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -3308,6 +3593,11 @@ "robust-predicates": "^3.0.0" } }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -3346,6 +3636,11 @@ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.900.tgz", "integrity": "sha512-SuXbQD8D4EjsaBaJJxySHbC+zq8JrFfxtb4GIr4E9n1BcROyMcRrJCYQNpJ9N+Wjf5mFp7Wp0OHykd14JNEzzQ==" }, + "element-closest": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/element-closest/-/element-closest-3.0.2.tgz", + "integrity": "sha512-JxKQiJKX0Zr5Q2/bCaTx8P+UbfyMET1OQd61qu5xQFeWr1km3fGaxelSJtnfT27XQ5Uoztn2yIyeamAc/VX13g==" + }, "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -3802,6 +4097,21 @@ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" }, + "event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" + }, + "eventemitter3": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-2.0.3.tgz", + "integrity": "sha1-teEHm1n7XhuidxwKmTvgYKWMmbo=" + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -3820,6 +4130,11 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, + "fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" + }, "file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", @@ -3868,6 +4183,21 @@ "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=" }, + "form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, + "formidable": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.6.tgz", + "integrity": "sha512-KcpbcpuLNOwrEjnbpMC0gS+X8ciDoZE1kkqzat4a8vrprf+s9pKNQ/QIwWfbfs4ltgmFl3MD177SNTkve3BwGQ==" + }, "fs-extra": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", @@ -4021,6 +4351,11 @@ "has-symbols": "^1.0.2" } }, + "he": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/he/-/he-0.5.0.tgz", + "integrity": "sha1-LAX/rvkLaOhg8/0rVO9YCYknfuI=" + }, "iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", @@ -4065,6 +4400,15 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "insane": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/insane/-/insane-2.6.2.tgz", + "integrity": "sha1-wqtouz4AarRRVg0bRGkXMpwKgSA=", + "requires": { + "assignment": "2.0.0", + "he": "0.5.0" + } + }, "internal-slot": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.3.tgz", @@ -4081,6 +4425,11 @@ "resolved": "https://registry.npmjs.org/internmap/-/internmap-2.0.3.tgz", "integrity": "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==" }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" + }, "is-bigint": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.1.tgz", @@ -4210,12 +4559,22 @@ "call-bind": "^1.0.0" } }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, + "javascript-state-machine": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/javascript-state-machine/-/javascript-state-machine-2.4.0.tgz", + "integrity": "sha1-2L4x7DjySsGhgy8LZy/DzV95yW4=" + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -4285,6 +4644,109 @@ "resolved": "https://registry.npmjs.org/khroma/-/khroma-1.4.1.tgz", "integrity": "sha512-+GmxKvmiRuCcUYDgR7g5Ngo0JEDeOsGdNONdU2zsiBQaK4z19Y2NvXqfEDE0ZiIrg45GTZyAnPLVsLZZACYm3Q==" }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "requires": { + "invert-kv": "^1.0.0" + } + }, + "leancloud-realtime": { + "version": "5.0.0-rc.7", + "resolved": "https://registry.npmjs.org/leancloud-realtime/-/leancloud-realtime-5.0.0-rc.7.tgz", + "integrity": "sha512-T5D12cvONg/eLlMKO+J31CdolM0ydgCnRpcTwWaCq1KrboROOvwgovKQpfeSKm4MxKNIio5gEKf41xAbE3K5dA==", + "requires": { + "@babel/runtime": "^7.10.2", + "@leancloud/adapter-types": "^3.0.0", + "@leancloud/platform-adapters-browser": "^1.1.0", + "@leancloud/platform-adapters-node": "^1.1.0", + "@leancloud/platform-adapters-weapp": "^1.2.0", + "base64-arraybuffer": "^0.1.5", + "debug": "^3.1.0", + "eventemitter3": "^3.0.0", + "javascript-state-machine": "^2.3.5", + "lodash": "^4.17.10", + "promise-timeout": "^1.3.0", + "protobufjs": "^5.0.1", + "uuid": "^3.0.0" + }, + "dependencies": { + "@babel/runtime": { + "version": "7.16.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.16.5.tgz", + "integrity": "sha512-TXWihFIS3Pyv5hzR7j6ihmeLkZfrXGxAr5UfSl8CHf+6q/wpiYDkUau0czckpYG8QmnCIuPpdLtuA9VmuGGyMA==", + "requires": { + "regenerator-runtime": "^0.13.4" + } + }, + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "eventemitter3": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", + "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==" + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "regenerator-runtime": { + "version": "0.13.9", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", + "integrity": "sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==" + } + } + }, + "leancloud-realtime-plugin-live-query": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/leancloud-realtime-plugin-live-query/-/leancloud-realtime-plugin-live-query-1.2.0.tgz", + "integrity": "sha512-eJooIH8/FyUoozr3Eeby2DpDnmX39m1bfxfxlYPuojkio+i/DLwPD+aTHnRDH6QXJcT6tNTt85RcxVR/Txg98Q==" + }, + "leancloud-storage": { + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/leancloud-storage/-/leancloud-storage-3.15.0.tgz", + "integrity": "sha512-UbR6pLA0tVYPcY7AND0pey45iFsB2PkIo8Wz0DZ9BabKyqndA1ey2LKzYpFDGNh3ODrmT3fValVn9yY4bgf9Uw==", + "requires": { + "debug": "^3.1.0", + "es6-promise": "4.2.3", + "eventemitter3": "^2.0.3", + "leancloud-realtime": "^5.0.0-alpha.3", + "leancloud-realtime-plugin-live-query": "^1.2.0", + "localstorage-memory": "^1.0.1", + "md5": "^2.0.0", + "superagent": "^3.3.1", + "underscore": "^1.8.3", + "uuid": "^3.3.2" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "es6-promise": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.3.tgz", + "integrity": "sha512-vLf5iali3jKqlJoo6SryDwe3nxCmiueNjbjLWDIpNbAcKnQXAsAdZk+pM17nSYp3AQMbTmAQVCQSeDLfA87SNA==" + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + } + } + }, "levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", @@ -4300,6 +4762,11 @@ "resolved": "https://registry.npmjs.org/load-script/-/load-script-1.0.0.tgz", "integrity": "sha1-BJGTngvuVkPuSUp+PaPSuscMbKQ=" }, + "localstorage-memory": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/localstorage-memory/-/localstorage-memory-1.0.3.tgz", + "integrity": "sha512-t9P8WB6DcVttbw/W4PIE8HOqum8Qlvx5SjR6oInwR9Uia0EEmyUeBh7S+weKByW+l/f45Bj4L/dgZikGFDM6ng==" + }, "locate-path": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", @@ -4332,11 +4799,15 @@ "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", "dev": true }, + "long": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", + "integrity": "sha1-2CG3E4yhy1gcFymQ7xTbIAtcR0s=" + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, "requires": { "yallist": "^4.0.0" } @@ -4376,6 +4847,29 @@ "stylis": "^4.0.10" } }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==" + }, + "mime-db": { + "version": "1.51.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", + "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" + }, + "mime-types": { + "version": "2.1.34", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", + "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", + "requires": { + "mime-db": "1.51.0" + } + }, "min-document": { "version": "2.19.0", "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", @@ -4397,6 +4891,11 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==" }, + "miniprogram-api-typings": { + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/miniprogram-api-typings/-/miniprogram-api-typings-2.12.0.tgz", + "integrity": "sha512-ibvbqeslVFur0IAvTxLMvsbtvVcMo6gwvOnj0YZHV7aeDLu091VQRrETT2QuiG9P6aZWRcxeNGJChRKVPCp9VQ==" + }, "moment-mini": { "version": "2.24.0", "resolved": "https://registry.npmjs.org/moment-mini/-/moment-mini-2.24.0.tgz", @@ -4424,11 +4923,15 @@ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", "optional": true }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, "object-inspect": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.1.tgz", - "integrity": "sha512-If7BjFlpkzzBeV1cqgT3OSWT3azyoxDGajR+iGnFBfVV2EWyDyWaZZW2ERDjUaY2QM8i5jI3Sj7mhsM4DDAqWA==", - "dev": true + "integrity": "sha512-If7BjFlpkzzBeV1cqgT3OSWT3azyoxDGajR+iGnFBfVV2EWyDyWaZZW2ERDjUaY2QM8i5jI3Sj7mhsM4DDAqWA==" }, "object-keys": { "version": "1.1.1", @@ -4479,6 +4982,19 @@ "word-wrap": "^1.2.3" } }, + "optjs": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/optjs/-/optjs-3.2.2.tgz", + "integrity": "sha1-aabOicRCpEQDFBrS+bNwvVu29O4=" + }, + "os-locale": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "requires": { + "lcid": "^1.0.0" + } + }, "p-limit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", @@ -4575,6 +5091,11 @@ "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -4586,11 +5107,45 @@ "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-7.1.0.tgz", "integrity": "sha512-P6NJ2wU/8fac44ENORsuqT8TiolKGB2u0fEClPtXezn7w5cmLIjM/7mhPlTebke2EPr6tmqZbXvnX0TxwykGrg==" }, + "promise-timeout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/promise-timeout/-/promise-timeout-1.3.0.tgz", + "integrity": "sha512-5yANTE0tmi5++POym6OgtFmwfDvOXABD9oj/jLQr5GPEyuNEb7jH4wbbANJceJid49jwhi1RddxnhnEAb/doqg==" + }, + "protobufjs": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-5.0.3.tgz", + "integrity": "sha512-55Kcx1MhPZX0zTbVosMQEO5R6/rikNXd9b6RQK4KSPcrSIIwoXTtebIczUrXlwaSrbz4x8XUVThGPob1n8I4QA==", + "requires": { + "ascli": "~1", + "bytebuffer": "~5", + "glob": "^7.0.5", + "yargs": "^3.10.0" + } + }, + "qs": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.2.tgz", + "integrity": "sha512-mSIdjzqznWgfd4pMii7sHtaYF8rx8861hBO80SraY5GT0XQibWZWJSid0avzHGkDIZLImux2S5mXO0Hfct2QCw==", + "requires": { + "side-channel": "^1.0.4" + } + }, "querystring-es3": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=" }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, "readdirp": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", @@ -4747,7 +5302,6 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dev": true, "requires": { "call-bind": "^1.0.0", "get-intrinsic": "^1.0.2", @@ -4812,6 +5366,11 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "storejs": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/storejs/-/storejs-1.1.0.tgz", + "integrity": "sha512-RCQ7dhTmaRJ8IYW6zprhESmSij6Dy4lGvAaRFgHhhYvhIb8B+WHmvim+ELub07AuF7vHgB79pYgsTQBRLtEOew==" + }, "string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -4843,6 +5402,21 @@ "define-properties": "^1.1.3" } }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "requires": { + "safe-buffer": "~5.2.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + } + } + }, "strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -4869,6 +5443,75 @@ "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.0.13.tgz", "integrity": "sha512-xGPXiFVl4YED9Jh7Euv2V220mriG9u4B2TA6Ybjc1catrstKD2PpIdU3U0RKpkVBC2EhmL/F0sPCr9vrFTNRag==" }, + "superagent": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.3.tgz", + "integrity": "sha512-GLQtLMCoEIK4eDv6OGtkOoSMt3D+oq0y3dsxMuYuDvaNUvuT8eFBuLmfR0iYYzHC1e8hpzC6ZsxbuP6DIalMFA==", + "requires": { + "component-emitter": "^1.2.0", + "cookiejar": "^2.1.0", + "debug": "^3.1.0", + "extend": "^3.0.0", + "form-data": "^2.3.1", + "formidable": "^1.2.0", + "methods": "^1.1.1", + "mime": "^1.4.1", + "qs": "^6.5.1", + "readable-stream": "^2.3.5" + }, + "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "requires": { + "ms": "^2.1.1" + } + }, + "form-data": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + } + } + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -5019,6 +5662,11 @@ "which-boxed-primitive": "^1.0.2" } }, + "underscore": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.2.tgz", + "integrity": "sha512-ekY1NhRzq0B08g4bGuX4wd2jZx5GnKz6mKSqFL4nqBlfyMGiG10gDFhDTMEfYmDL6Jy0FUIZp7wiRB+0BP7J2g==" + }, "unicode-canonical-property-names-ecmascript": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", @@ -5065,12 +5713,36 @@ } } }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" + }, "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "dev": true }, + "valine": { + "version": "1.4.16", + "resolved": "https://registry.npmjs.org/valine/-/valine-1.4.16.tgz", + "integrity": "sha512-gKmVzOAYrHNKt2Oswu6+UFiR+qJfTuVjPj6XrqtoPNZFcoJaITftGI6qw/n//YhWMd/75E4WTL6WeZ5CHhADdA==", + "requires": { + "balajs": "^1.0.7", + "balalaika": "^1.0.1", + "element-closest": "^3.0.2", + "insane": "^2.6.2", + "leancloud-storage": "^3.0.4", + "storejs": "^1.0.25", + "xss": "^1.0.6" + } + }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -5093,22 +5765,144 @@ "is-symbol": "^1.0.3" } }, + "window-size": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.4.tgz", + "integrity": "sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY=" + }, "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", "dev": true }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, + "ws": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.3.tgz", + "integrity": "sha512-jZArVERrMsKUatIdnLzqvcfydI85dvd/Fp1u/VOpfdDWQ4c9qWXe+VIeAbQ5FrDwciAkr+lzofXLz3Kuf26AOA==", + "requires": { + "async-limiter": "~1.0.0" + } + }, + "xss": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/xss/-/xss-1.0.10.tgz", + "integrity": "sha512-qmoqrRksmzqSKvgqzN0055UFWY7OKx1/9JWeRswwEVX9fCG5jcYRxa/A2DHcmZX6VJvjzHRQ2STeeVcQkrmLSw==", + "requires": { + "commander": "^2.20.3", + "cssfilter": "0.0.10" + }, + "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" + } + } + }, + "y18n": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.2.tgz", + "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==" + }, "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, + "yargs": { + "version": "3.32.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.32.0.tgz", + "integrity": "sha1-AwiOnr+edWtpdRYR0qXvWRSCyZU=", + "requires": { + "camelcase": "^2.0.1", + "cliui": "^3.0.3", + "decamelize": "^1.1.1", + "os-locale": "^1.4.0", + "string-width": "^1.0.1", + "window-size": "^0.1.4", + "y18n": "^3.2.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + } + } }, "zrender": { "version": "5.2.1", diff --git a/package.json b/package.json index b3039c473..ca9e0afd0 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "katex": "^0.15.1", "mermaid": "^8.13.6", "twemoji": "^13.1.0", - "twikoo": "^1.4.14" + "twikoo": "^1.4.14", + "valine": "^1.4.16" } } From f87e81de9254507d9d3c28f8a40e02873dbb29ec Mon Sep 17 00:00:00 2001 From: HEIGE-PCloud Date: Wed, 22 Dec 2021 20:52:48 +0000 Subject: [PATCH 3/7] refactor: separate giscus --- assets/js/lib/giscus.js | 29 +++++++++++++++++++++++++++++ assets/js/theme.js | 29 ----------------------------- layouts/partials/comment.html | 4 ++++ 3 files changed, 33 insertions(+), 29 deletions(-) create mode 100644 assets/js/lib/giscus.js diff --git a/assets/js/lib/giscus.js b/assets/js/lib/giscus.js new file mode 100644 index 000000000..62644c408 --- /dev/null +++ b/assets/js/lib/giscus.js @@ -0,0 +1,29 @@ +if (window.config.comment.giscus) { + const giscusConfig = window.config.comment.giscus + const script = document.createElement('script') + script.src = 'https://giscus.app/client.js' + script.type = 'text/javascript' + script.setAttribute('data-repo', giscusConfig.dataRepo) + script.setAttribute('data-repo-id', giscusConfig.dataRepoId) + if (giscusConfig.dataCategory) script.setAttribute('data-category', giscusConfig.dataCategory) + script.setAttribute('data-category-id', giscusConfig.dataCategoryId) + script.setAttribute('data-mapping', giscusConfig.dataMapping) + script.setAttribute('data-reactions-enabled', giscusConfig.dataReactionsEnabled) + script.setAttribute('data-emit-metadata', giscusConfig.dataEmitMetadata) + script.setAttribute('data-theme', window.isDark ? giscusConfig.darkTheme : giscusConfig.lightTheme) + script.crossOrigin = 'anonymous' + script.async = true + document.getElementById('giscus').appendChild(script) + window._giscusOnSwitchTheme = () => { + const message = { + giscus: { + setConfig: { + theme: window.isDark ? giscusConfig.darkTheme : giscusConfig.lightTheme + } + } + } + const iframe = document.querySelector('.giscus-frame') + iframe.contentWindow.postMessage(message, 'https://giscus.app') + } + window.switchThemeEventSet.add(window._giscusOnSwitchTheme) +} diff --git a/assets/js/theme.js b/assets/js/theme.js index 48e164664..454bc6e67 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -814,35 +814,6 @@ function initComment () { } window.switchThemeEventSet.add(window._remark42OnSwitchTheme) } - if (window.config.comment.giscus) { - const giscusConfig = window.config.comment.giscus - const script = document.createElement('script') - script.src = 'https://giscus.app/client.js' - script.type = 'text/javascript' - script.setAttribute('data-repo', giscusConfig.dataRepo) - script.setAttribute('data-repo-id', giscusConfig.dataRepoId) - if (giscusConfig.dataCategory) script.setAttribute('data-category', giscusConfig.dataCategory) - script.setAttribute('data-category-id', giscusConfig.dataCategoryId) - script.setAttribute('data-mapping', giscusConfig.dataMapping) - script.setAttribute('data-reactions-enabled', giscusConfig.dataReactionsEnabled) - script.setAttribute('data-emit-metadata', giscusConfig.dataEmitMetadata) - script.setAttribute('data-theme', window.isDark ? giscusConfig.darkTheme : giscusConfig.lightTheme) - script.crossOrigin = 'anonymous' - script.async = true - document.getElementById('giscus').appendChild(script) - window._giscusOnSwitchTheme = () => { - const message = { - giscus: { - setConfig: { - theme: window.isDark ? giscusConfig.darkTheme : giscusConfig.lightTheme - } - } - } - const iframe = document.querySelector('.giscus-frame') - iframe.contentWindow.postMessage(message, 'https://giscus.app') - } - window.switchThemeEventSet.add(window._giscusOnSwitchTheme) - } } } diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index 5ad411712..fb024ef5a 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -293,6 +293,10 @@ {{- $commentConfig = $giscus.dataEmitMetadata | default "0" | dict "dataEmitMetadata" | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = $giscus.lightTheme | default "light" | dict "lightTheme" | dict "giscus" | merge $commentConfig -}} {{- $commentConfig = $giscus.darkTheme | default "dark" | dict "darkTheme" | dict "giscus" | merge $commentConfig -}} + {{- $options := dict "targetPath" "js/giscus.min.js" "minify" true -}} + {{- $js := resources.Get "js/lib/giscus.js" | js.Build $options -}} + {{- $_ := $js.RelPermalink -}} + {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}} From 586e26fb497d6b1e2a1a6275e0b718e9de1b7d03 Mon Sep 17 00:00:00 2001 From: HEIGE-PCloud Date: Wed, 22 Dec 2021 21:04:20 +0000 Subject: [PATCH 4/7] refactor: separate remark42 --- assets/js/lib/remark42.js | 26 ++++++++++++++++++++++++++ assets/js/theme.js | 26 -------------------------- layouts/partials/comment.html | 4 ++++ 3 files changed, 30 insertions(+), 26 deletions(-) create mode 100644 assets/js/lib/remark42.js diff --git a/assets/js/lib/remark42.js b/assets/js/lib/remark42.js new file mode 100644 index 000000000..64ab0e8c0 --- /dev/null +++ b/assets/js/lib/remark42.js @@ -0,0 +1,26 @@ +if (window.config.comment.remark42) { + const remark42 = window.config.comment.remark42 + // eslint-disable-next-line camelcase + const remark_config = { + host: remark42.host, + site_id: remark42.site_id, + components: ['embed'], + max_shown_comments: remark42.max_shown_comments, + theme: window.isDark ? 'dark' : 'light', + locale: remark42.locale, + show_email_subscription: remark42.show_email_subscription, + simple_view: remark42.simple_view + } + // eslint-disable-next-line camelcase + window.remark_config = remark_config + // eslint-disable-next-line no-sequences, no-unused-expressions + !(function (e, n) { for (let o = 0; o < e.length; o++) { const r = n.createElement('script'); let c = '.js'; const d = n.head || n.body; 'noModule' in r ? (r.type = 'module', c = '.mjs') : r.async = !0, r.defer = !0, r.src = remark_config.host + '/web/' + e[o] + c, d.appendChild(r) } }(remark_config.components || ['embed'], document)) + window._remark42OnSwitchTheme = () => { + if (window.isDark) { + window.REMARK42.changeTheme('dark') + } else { + window.REMARK42.changeTheme('light') + } + } + window.switchThemeEventSet.add(window._remark42OnSwitchTheme) +} diff --git a/assets/js/theme.js b/assets/js/theme.js index 454bc6e67..a0a709957 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -788,32 +788,6 @@ function initComment () { }) }) } - if (window.config.comment.remark42) { - const remark42 = window.config.comment.remark42 - // eslint-disable-next-line camelcase - const remark_config = { - host: remark42.host, - site_id: remark42.site_id, - components: ['embed'], - max_shown_comments: remark42.max_shown_comments, - theme: window.isDark ? 'dark' : 'light', - locale: remark42.locale, - show_email_subscription: remark42.show_email_subscription, - simple_view: remark42.simple_view - } - // eslint-disable-next-line camelcase - window.remark_config = remark_config - // eslint-disable-next-line no-sequences, no-unused-expressions - !(function (e, n) { for (let o = 0; o < e.length; o++) { const r = n.createElement('script'); let c = '.js'; const d = n.head || n.body; 'noModule' in r ? (r.type = 'module', c = '.mjs') : r.async = !0, r.defer = !0, r.src = remark_config.host + '/web/' + e[o] + c, d.appendChild(r) } }(remark_config.components || ['embed'], document)) - window._remark42OnSwitchTheme = () => { - if (window.isDark) { - window.REMARK42.changeTheme('dark') - } else { - window.REMARK42.changeTheme('light') - } - } - window.switchThemeEventSet.add(window._remark42OnSwitchTheme) - } } } diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index fb024ef5a..9f9caa899 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -275,6 +275,10 @@ {{- with $remark42.simple_view -}} {{- $commentConfig = dict "simple_view" . | dict "remark42" | merge $commentConfig -}} {{- end -}} + {{- $options := dict "targetPath" "js/remark42.min.js" "minify" true -}} + {{- $js := resources.Get "js/lib/remark42.js" | js.Build $options -}} + {{- $_ := $js.RelPermalink -}} + {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}} From 22fd26a331b1d6ebc31f3922a5dc50be6833fd82 Mon Sep 17 00:00:00 2001 From: HEIGE-PCloud Date: Wed, 22 Dec 2021 21:06:23 +0000 Subject: [PATCH 5/7] refactor: separate utterances --- assets/js/lib/utterances.js | 22 ++++++++++++++++++++++ assets/js/theme.js | 22 ---------------------- layouts/partials/comment.html | 4 ++++ 3 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 assets/js/lib/utterances.js diff --git a/assets/js/lib/utterances.js b/assets/js/lib/utterances.js new file mode 100644 index 000000000..26414836b --- /dev/null +++ b/assets/js/lib/utterances.js @@ -0,0 +1,22 @@ +if (window.config.comment.utterances) { + const utterancesConfig = window.config.comment.utterances + const script = document.createElement('script') + script.src = 'https://utteranc.es/client.js' + script.type = 'text/javascript' + script.setAttribute('repo', utterancesConfig.repo) + script.setAttribute('issue-term', utterancesConfig.issueTerm) + if (utterancesConfig.label) script.setAttribute('label', utterancesConfig.label) + script.setAttribute('theme', window.isDark ? utterancesConfig.darkTheme : utterancesConfig.lightTheme) + script.crossOrigin = 'anonymous' + script.async = true + document.getElementById('utterances').appendChild(script) + window._utterancesOnSwitchTheme = () => { + const message = { + type: 'set-theme', + theme: window.isDark ? utterancesConfig.darkTheme : utterancesConfig.lightTheme + } + const iframe = document.querySelector('.utterances-frame') + iframe.contentWindow.postMessage(message, 'https://utteranc.es') + } + window.switchThemeEventSet.add(window._utterancesOnSwitchTheme) +} diff --git a/assets/js/theme.js b/assets/js/theme.js index a0a709957..3c7450d98 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -749,28 +749,6 @@ function initComment () { const gitalk = new Gitalk(window.config.comment.gitalk) gitalk.render('gitalk') } - if (window.config.comment.utterances) { - const utterancesConfig = window.config.comment.utterances - const script = document.createElement('script') - script.src = 'https://utteranc.es/client.js' - script.type = 'text/javascript' - script.setAttribute('repo', utterancesConfig.repo) - script.setAttribute('issue-term', utterancesConfig.issueTerm) - if (utterancesConfig.label) script.setAttribute('label', utterancesConfig.label) - script.setAttribute('theme', window.isDark ? utterancesConfig.darkTheme : utterancesConfig.lightTheme) - script.crossOrigin = 'anonymous' - script.async = true - document.getElementById('utterances').appendChild(script) - window._utterancesOnSwitchTheme = () => { - const message = { - type: 'set-theme', - theme: window.isDark ? utterancesConfig.darkTheme : utterancesConfig.lightTheme - } - const iframe = document.querySelector('.utterances-frame') - iframe.contentWindow.postMessage(message, 'https://utteranc.es') - } - window.switchThemeEventSet.add(window._utterancesOnSwitchTheme) - } if (window.config.comment.vssue) { const vssue = window.config.comment.vssue new Vue({ diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index 9f9caa899..b22560de8 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -184,6 +184,10 @@ {{- $commentConfig = dict "label" $utterances.label | dict "utterances" | merge $commentConfig -}} {{- $commentConfig = $utterances.lightTheme | default "github-light" | dict "lightTheme" | dict "utterances" | merge $commentConfig -}} {{- $commentConfig = $utterances.darkTheme | default "github-dark" | dict "darkTheme" | dict "utterances" | merge $commentConfig -}} + {{- $options := dict "targetPath" "js/utterances.min.js" "minify" true -}} + {{- $js := resources.Get "js/lib/utterances.js" | js.Build $options -}} + {{- $_ := $js.RelPermalink -}} + {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}} From f54b1e40c3a95c8c7f0d37921e76145791a9a371 Mon Sep 17 00:00:00 2001 From: HEIGE-PCloud Date: Wed, 22 Dec 2021 21:15:40 +0000 Subject: [PATCH 6/7] refactor: separate vssue --- assets/js/lib/cookieconsent.js | 2 +- assets/js/lib/giscus.js | 2 +- assets/js/lib/katex.js | 2 +- assets/js/lib/remark42.js | 2 +- assets/js/lib/twemoji.js | 2 +- assets/js/lib/twikoo.js | 2 +- assets/js/lib/utterances.js | 2 +- assets/js/lib/valine.js | 2 +- assets/js/lib/vssue.js | 19 +++++++++++++++++++ assets/js/lib/waline.js | 2 +- assets/js/theme.js | 17 ----------------- layouts/partials/comment.html | 4 ++++ 12 files changed, 32 insertions(+), 26 deletions(-) create mode 100644 assets/js/lib/vssue.js diff --git a/assets/js/lib/cookieconsent.js b/assets/js/lib/cookieconsent.js index cbe93d1f6..ce638fe5a 100644 --- a/assets/js/lib/cookieconsent.js +++ b/assets/js/lib/cookieconsent.js @@ -1,6 +1,6 @@ import cookieconsent from 'cookieconsent' -if (window.config.cookieconsent) { +if (window.config?.cookieconsent) { const container = document.getElementById('cookieconsent-container') // if there is nothing in the container, then init the cookieconsent if (container.innerHTML === '') { diff --git a/assets/js/lib/giscus.js b/assets/js/lib/giscus.js index 62644c408..5c2943360 100644 --- a/assets/js/lib/giscus.js +++ b/assets/js/lib/giscus.js @@ -1,4 +1,4 @@ -if (window.config.comment.giscus) { +if (window.config?.comment?.giscus) { const giscusConfig = window.config.comment.giscus const script = document.createElement('script') script.src = 'https://giscus.app/client.js' diff --git a/assets/js/lib/katex.js b/assets/js/lib/katex.js index a76e19383..104cc2e2d 100644 --- a/assets/js/lib/katex.js +++ b/assets/js/lib/katex.js @@ -1,3 +1,3 @@ import renderMathInElement from 'katex/dist/contrib/auto-render' -if (window.config.math) renderMathInElement(document.body, window.config.math) +if (window.config?.math) renderMathInElement(document.body, window.config.math) diff --git a/assets/js/lib/remark42.js b/assets/js/lib/remark42.js index 64ab0e8c0..de23ec998 100644 --- a/assets/js/lib/remark42.js +++ b/assets/js/lib/remark42.js @@ -1,4 +1,4 @@ -if (window.config.comment.remark42) { +if (window.config?.comment?.remark42) { const remark42 = window.config.comment.remark42 // eslint-disable-next-line camelcase const remark_config = { diff --git a/assets/js/lib/twemoji.js b/assets/js/lib/twemoji.js index 85a2fcbb7..990430bb7 100644 --- a/assets/js/lib/twemoji.js +++ b/assets/js/lib/twemoji.js @@ -1,3 +1,3 @@ import twemoji from 'twemoji' -if (window.config.twemoji) twemoji.parse(document.body) +if (window.config?.twemoji) twemoji.parse(document.body) diff --git a/assets/js/lib/twikoo.js b/assets/js/lib/twikoo.js index 95cb73d51..f82a877ab 100644 --- a/assets/js/lib/twikoo.js +++ b/assets/js/lib/twikoo.js @@ -1,6 +1,6 @@ const twikoo = require('twikoo') -if (window.config.comment) { +if (window.config?.comment) { const config = window.config.comment.twikoo if (config) { twikoo.init(config) diff --git a/assets/js/lib/utterances.js b/assets/js/lib/utterances.js index 26414836b..2888768f0 100644 --- a/assets/js/lib/utterances.js +++ b/assets/js/lib/utterances.js @@ -1,4 +1,4 @@ -if (window.config.comment.utterances) { +if (window.config?.comment?.utterances) { const utterancesConfig = window.config.comment.utterances const script = document.createElement('script') script.src = 'https://utteranc.es/client.js' diff --git a/assets/js/lib/valine.js b/assets/js/lib/valine.js index 1d97f578f..9a6bae653 100644 --- a/assets/js/lib/valine.js +++ b/assets/js/lib/valine.js @@ -1,6 +1,6 @@ /* eslint-disable no-new */ import Valine from 'valine' -if (window.config.comment.valine) { +if (window.config?.comment?.valine) { new Valine(window.config.comment.valine) } diff --git a/assets/js/lib/vssue.js b/assets/js/lib/vssue.js new file mode 100644 index 000000000..b4df48d73 --- /dev/null +++ b/assets/js/lib/vssue.js @@ -0,0 +1,19 @@ +/* eslint-disable no-undef */ +/* eslint-disable no-new */ +if (window.config?.comment?.vssue) { + const vssue = window.config.comment.vssue + new Vue({ + el: vssue.el, + render: h => h('Vssue', { + props: { + title: vssue.title, + options: { + owner: vssue.owner, + repo: vssue.repo, + clientId: vssue.clientId, + clientSecret: vssue.clientSecret + } + } + }) + }) +} diff --git a/assets/js/lib/waline.js b/assets/js/lib/waline.js index 5b01fa36d..051379b9a 100644 --- a/assets/js/lib/waline.js +++ b/assets/js/lib/waline.js @@ -1,6 +1,6 @@ /* eslint-disable no-new */ import Waline from '@waline/client' -if (window.config.comment.waline) { +if (window.config?.comment?.waline) { new Waline(window.config.comment.waline) } diff --git a/assets/js/theme.js b/assets/js/theme.js index 3c7450d98..2ffe545c4 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -749,23 +749,6 @@ function initComment () { const gitalk = new Gitalk(window.config.comment.gitalk) gitalk.render('gitalk') } - if (window.config.comment.vssue) { - const vssue = window.config.comment.vssue - new Vue({ - el: vssue.el, - render: h => h('Vssue', { - props: { - title: vssue.title, - options: { - owner: vssue.owner, - repo: vssue.repo, - clientId: vssue.clientId, - clientSecret: vssue.clientSecret - } - } - }) - }) - } } } diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index b22560de8..405cd14cc 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -260,6 +260,10 @@ {{- with $vssue.clientSecret -}} {{- $commentConfig = dict "clientSecret" . | dict "vssue" | merge $commentConfig -}} {{- end -}} + {{- $options := dict "targetPath" "js/vssue.min.js" "minify" true -}} + {{- $js := resources.Get "js/lib/vssue.js" | js.Build $options -}} + {{- $_ := $js.RelPermalink -}} + {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}} From a61c088d1b8aeec777e084504a943db97dfa38e7 Mon Sep 17 00:00:00 2001 From: HEIGE-PCloud Date: Wed, 22 Dec 2021 21:26:12 +0000 Subject: [PATCH 7/7] refactor: separate gitalk --- assets/js/lib/gitalk.js | 6 ++++++ assets/js/theme.js | 11 ----------- layouts/partials/comment.html | 4 ++++ 3 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 assets/js/lib/gitalk.js diff --git a/assets/js/lib/gitalk.js b/assets/js/lib/gitalk.js new file mode 100644 index 000000000..7019574f2 --- /dev/null +++ b/assets/js/lib/gitalk.js @@ -0,0 +1,6 @@ +/* eslint-disable no-undef */ +if (window.config?.comment?.gitalk) { + window.config.comment.gitalk.body = decodeURI(window.location.href) + const gitalk = new Gitalk(window.config.comment.gitalk) + gitalk.render('gitalk') +} diff --git a/assets/js/theme.js b/assets/js/theme.js index 2ffe545c4..21cf3925f 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -742,16 +742,6 @@ function initTypeit () { } } -function initComment () { - if (window.config.comment) { - if (window.config.comment.gitalk) { - window.config.comment.gitalk.body = decodeURI(window.location.href) - const gitalk = new Gitalk(window.config.comment.gitalk) - gitalk.render('gitalk') - } - } -} - function initMeta () { function getMeta (metaName) { const metas = document.getElementsByTagName('meta') @@ -869,7 +859,6 @@ function init () { initTypeit() initMapbox() initToc() - initComment() onScroll() onResize() onClickMask() diff --git a/layouts/partials/comment.html b/layouts/partials/comment.html index 405cd14cc..4b76fa473 100644 --- a/layouts/partials/comment.html +++ b/layouts/partials/comment.html @@ -28,6 +28,10 @@ {{- with $gitalk.proxy -}} {{- $commentConfig = dict "proxy" . | dict "gitalk" | merge $commentConfig -}} {{- end -}} + {{- $options := dict "targetPath" "js/gitalk.min.js" "minify" true -}} + {{- $js := resources.Get "js/lib/gitalk.js" | js.Build $options -}} + {{- $_ := $js.RelPermalink -}} + {{- dict "Link" $js.RelPermalink "Fingerprint" $fingerprint "Defer" true | dict "Scratch" .Scratch "Data" | partial "scratch/pjaxScript.html" -}}