From 84432db7f95060b3bd29006aecb81dfa6cdc037a Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Mon, 10 Jan 2022 13:38:56 -0800 Subject: [PATCH] core: use npms cdn endpoint to avoid going through server. --- plugins/core/README.md | 16 ++-------------- plugins/core/package-lock.json | 4 ++-- plugins/core/package.json | 2 +- .../ui/src/components/plugin/InstallPlugin.vue | 2 +- plugins/core/ui/src/components/plugin/plugin.ts | 7 ++++++- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/plugins/core/README.md b/plugins/core/README.md index b63270f58..ca2941808 100644 --- a/plugins/core/README.md +++ b/plugins/core/README.md @@ -1,15 +1,3 @@ -# Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs. +# Scrypted Web UI Plugin -## npm commands - * npm run scrypted-webpack - * npm run scrypted-deploy - * npm run scrypted-debug - -## scrypted distribution via npm - 1. Ensure package.json is set up properly for publishing on npm. - 2. npm publish - -## Visual Studio Code configuration - -* If using a remote server, edit [.vscode/settings.json](blob/master/.vscode/settings.json) to specify the IP Address of the Scrypted server. -* Launch Scrypted Debugger from the launch menu. +The Core Plugin provides the web UI for Scrypted. diff --git a/plugins/core/package-lock.json b/plugins/core/package-lock.json index c171e015d..c627bf8f3 100644 --- a/plugins/core/package-lock.json +++ b/plugins/core/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/core", - "version": "0.0.172", + "version": "0.0.174", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/core", - "version": "0.0.172", + "version": "0.0.174", "license": "Apache-2.0", "dependencies": { "@koush/wrtc": "^0.5.0", diff --git a/plugins/core/package.json b/plugins/core/package.json index ea51f2b6a..50da7b929 100644 --- a/plugins/core/package.json +++ b/plugins/core/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/core", - "version": "0.0.172", + "version": "0.0.174", "description": "Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs.", "author": "Scrypted", "license": "Apache-2.0", diff --git a/plugins/core/ui/src/components/plugin/InstallPlugin.vue b/plugins/core/ui/src/components/plugin/InstallPlugin.vue index e9777856a..2ab740bef 100644 --- a/plugins/core/ui/src/components/plugin/InstallPlugin.vue +++ b/plugins/core/ui/src/components/plugin/InstallPlugin.vue @@ -100,7 +100,7 @@ export default { doSearch: debounce(function () { axios .get( - `${getComponentWebPath("script")}/search?text=keywords:scrypted+${ + `https://registry.npmjs.org/-/v1/search?text=keywords:scrypted+${ this.search }` ) diff --git a/plugins/core/ui/src/components/plugin/plugin.ts b/plugins/core/ui/src/components/plugin/plugin.ts index cc1a80839..31eaa1040 100644 --- a/plugins/core/ui/src/components/plugin/plugin.ts +++ b/plugins/core/ui/src/components/plugin/plugin.ts @@ -10,7 +10,12 @@ export interface PluginUpdateCheck { } export async function checkUpdate(npmPackage: string, npmPackageVersion: string): Promise { - const response = await axios.get(`${componentPath}/npm/${npmPackage}`); + // const response = await axios.get(`${componentPath}/npm/${npmPackage}`); + // registry.npmjs.org does not support CORS on the package endpoints. + // open issue: + // https://github.com/npm/feedback/discussions/117 + // npmjs.cf is an unofficial CDN that provides it + const response = await axios.get(`https://registry.npmjs.cf/${npmPackage}`); const { data } = response; const versions = Object.values(data.versions).sort((a: any, b: any) => semver.compare(a.version, b.version)).reverse(); let updateAvailable: any;