Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
manage-libs-versions
Advanced tools
Readme
Easily create a list of Radio Inputs to let user choose Library Versions, retrieve the selection and prepare a list of Assets to be dynamically loaded.
The Assets list can be directly passed to
loadJsCss.list()
function.
This library uses a UMD wrapper.
If directly loaded into a browser, it assigns the manageLibsVersions
global variable.
HTML
<script src="manage-libs-versions.js"></script>
JavaScript
var lib1PathTemplateCss = 'https://unpkg.com/lib1@{{VERSION}}/dist/lib1.css';
var lib1PathTemplateJS = 'https://unpkg.com/lib1@{{VERSION}}/dist/lib1.js';
var lib2PathTemplateJs = 'https://unpkg.com/lib2@{{VERSION}}/dist/lib2.js';
var bundle = new manageLibsVersions.Bundle({
name: 'bundle',
libs: [{
name: 'lib1',
mandatory: true,
versions: [{
name: 'v2.0.0',
defaultVersion: true, // If no Version is specified, or the specified one is unknown, use this Version instead.
assets: [
manageLibsVersions.makeStylesheet(lib1PathTemplateCss, '2.0.0'),
manageLibsVersions.makeScript(lib1PathTemplateJS, '2.0.0')
]
}, {
name: 'v1.0.0',
defaultVersion: false,
disabled: true, // This will make the Radio Input disabled.
assets: [
manageLibsVersions.makeStylesheet(lib1PathTemplateCss, '1.0.0'),
manageLibsVersions.makeScript(lib1PathTemplateJS, '1.0.0')
]
}]
}, {
name: 'lib2',
versions: [{
name: 'dev',
assets: [{
type: 'script',
path: '../dist/bundle.js'
}]
}, {
name: 'v0.15.2',
assets: [
manageLibsVersions.makeScript(lib2PathTemplateJs, '0.15.2')
]
}]
}]
});
HTML
<p>Choose a version for lib1:</p>
<!-- Versions names can be separated by whitespace, comma (,) and/or semi-colon (;) -->
<div data-manage-lib="lib1" data-manage-versions="v2.0.0, v1.0.0"></div>
<p>Choose a version for lib2:</p>
<div data-manage-lib="lib2" data-manage-versions="dev, v0.15.2"></div>
<button id="reload">Reload with the above selected Versions</button>
<script src="https://unpkg.com/urijs@1.18.12/src/URI.min.js"></script>
<script src="https://unpkg.com/load-js-css@0.0.1/index.js"></script>
JavaScript
// Fill manage placeholders with Radio Inputs.
bundle.fillPlaceholders();
// Make sure lib2 dev version assets are available.
// If not, it will automatically disable the Radio Input and remove
// the defaultVersion flag.
bundle.getLibVersion('lib2', 'dev').checkAssetsAvailability(true)
.then(function () {
loadDependenciesAndPageScript();
})
.catch(function () {
bundle.getLibVersion('lib2', 'v0.15.2').defaultVersion = true;
loadDependenciesAndPageScript();
});
function loadDependenciesAndPageScript() {
// Read in the URL which Libraries Versions are requested.
var url = window.location.href;
// https://github.com/medialize/URI.js
var urlParts = URI.parse(url);
var queryStringParts = URI.parseQuery(urlParts.query);
// Get the Libraries Versions assets list and select the Radio Inputs,
// so that the user sees which Versions will be loaded.
var list = bundle.getAndSelectVersionsAssetsList(queryStringParts);
// Finally include the page script, now that lib1 and lib2 dependencies
// are available.
list.push({
type: 'script',
path: './index.js'
});
// https://github.com/ghybs/load-js-css
loadJsCss.list(list, {
// Load scripts after stylesheets, delayed by this duration (in ms).
// Typically if a Library expects that its stylesheet is applied
// when its script executes.
delayScripts: 500
});
}
document.getElementById('reload').addEventListener('click', function (event) {
event.preventDefault();
// Read the checked Radio Inputs (i.e. which Versions the user has selected).
var bundleVersions = bundle.readSelectedVersionsNames();
// Build a new URL including those Versions requests as Query part.
var url = new URI(window.location.href).setQuery(bundleVersions);
// Reload the page with the new requested Versions.
window.location.href = url.toString();
});
Manage Libs Versions library is distributed under the ISC License.
FAQs
Easily create a list of Radio Inputs to let user choose Library Versions, retrieve the selection and prepare a list of Assets to be dynamically loaded.
The npm package manage-libs-versions receives a total of 75 weekly downloads. As such, manage-libs-versions popularity was classified as not popular.
We found that manage-libs-versions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.