jsdelivr / extension-chrome Goto Github PK
View Code? Open in Web Editor NEWLicense: Open Software License 3.0
License: Open Software License 3.0
This is a discussion on jsDelivr Extension features and how we can implement it.
To form a project's CDN link (https://cdn.jsdelivr.net/npm/package@version/file
) we need 3 parameters:
package
version
file
package
name from repository URLGitHub repository URL has below patterns:
/:user/:repo
/:org/:repo
We can assume that a repository's package name would be same as repository's name and evaluate it from URL.
Example:
For jQuery's GitHub repository with URL - https://github.com/jquery/jquery
; its package name would be jquery
.
Problems
This proposal fails for scoped package names and when package name differ from their repository name.
Example 1:
For Slick Carousel's GitHub repository with URL - https://github.com/kenwheeler/slick
; we would evaluate its package name as slick
.
But its name defined in package.json
file is slick-carousel
.
Example 2:
For a scoped package like - @sindresorhus/class-names
; we won't be able to correctly evaluate its package name from its GitHub URL - https://github.com/sindresorhus/class-names
Conclusion: Not a good approach.
package
name by fetching repository's package.json
file from jsDelivr CDNWe can fetch repository's package.json
file from CDN with URL - https://cdn.jsdelivr.net/gh/:user/:repo@:version/package.json
, for which we will require user
, repo
and version
. We can get user
and repo
from URL, but not version
parameter, so we will have to call an API to get version
and then fetch package.json
file.
The steps will be:
Step 1: Get version
from v1/package/gh/:user/:repo
API
Step 2: Fetch package.json
file
Step 3: Read name
, version
and default file
name from package.json
file
Step 4: Generate a CDN URL
And if a user wants a specific version of project from GitHub's Release tags, we can skip Step 1 and get version
from its GitHub URL.
Example:
For Slick Carousel version 1.5.8, its GitHub URL is - https://github.com/kenwheeler/slick/tree/1.5.8
.
From this URL we can evaluate version
parameter to be 1.5.8
.
package
name by fetching repository's package.json
file from GitHub repositoryWe can fetch a RAW package.json
file from GitHub repository itself.
The steps will be:
Step 1: Fetch RAW package.json
file from https://raw.githubusercontent.com/:user/:repo/master/package.json
file
Step 2: Read name
, version
and default file
name from package.json
file
Step 3: Generate a CDN URL
And if a user wants a specific version of project from GitHub's Release tags, we can get version
from its GitHub URL and fetch its package.json
file.
Example:
For Slick Carousel version 1.5.8, its GitHub URL is - https://github.com/kenwheeler/slick/tree/1.5.8
.
And its RAW package.json
file URL will be - https://raw.githubusercontent.com/kenwheeler/slick/1.5.8/package.json
.
Question: Proposal 2 and 3 provides us with default file name as well. So should we use it and rename it with minified file name convention or call jsDelivr API (/package/npm/:name@:version/:structure?
) to get the default file name?
Note: Both Proposal 2 and 3 fails for repositories that use Lerna tool. Popular repositories using Lerna: React, Babel.
We have to think for an approach to handle such scenario.
To form a project's CDN link (https://cdn.jsdelivr.net/npm/package@version/file
) we need 3 parameters:
package
version
file
We can get package
name from URL and version
from sidebar under "version" heading.
And then get default file name from jsDelivr API - /package/npm/:name@:version/:structure?
.
To generate a project's download link (https://registry.npmjs.org/package/-/package-version.tgz
) we need 2 parameters:
package
version
We can re-use package
and version
parameters which we got while generating CDN link from Feature 1.
And then generate a download link.
The difference between this link and GitHub's own download link is that it will not have Git instance.
https://developer.chrome.com/docs/extensions/mv3/mv3-migration-checklist/
@dutiyesh Please check if you can do this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.