UNPKG

@lcap/nasl

Version:

NetEase Application Specific Language

51 lines 1.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFetchURL = exports.getFilePathFromManifest = exports.checkLibraryManifest = exports.BASIC_PREFIX = exports.DEPENDENCY_PREFIX = void 0; const dependency_1 = require("./dependency"); exports.DEPENDENCY_PREFIX = '/packages/extension'; exports.BASIC_PREFIX = '/packages'; const checkLibraryManifest = (dep, filePath) => { const manifestFiles = []; const manifest = (0, dependency_1.getDepMainfiest)(dep); Object.keys(manifest).forEach((k) => { if (!k || !manifest[k]) { return; } const fileList = Array.isArray(manifest[k]) ? manifest[k] : [manifest[k]]; if (fileList.length > 0) { manifestFiles.push(...fileList); } }); return manifestFiles.includes(filePath); }; exports.checkLibraryManifest = checkLibraryManifest; const getFilePathFromManifest = (manifest, type, fileName) => { if (!manifest || !manifest[type] || !Array.isArray(manifest[type])) { return ''; } return manifest[type].find((str) => str.endsWith(fileName)) || ''; }; exports.getFilePathFromManifest = getFilePathFromManifest; function getFetchURL(type, fileName, pkgInfo) { const filePath = (0, exports.getFilePathFromManifest)(pkgInfo.manifest, type, fileName); if (!filePath) { return ''; } const params = []; const hash = pkgInfo.manifest.hashMap && pkgInfo.manifest.hashMap[filePath]; if (hash) { params.push(`h=${hash}`); } else if (!pkgInfo.extension) { params.push(`t=${Date.now()}`); } return [ pkgInfo.staticURL, pkgInfo.extension ? exports.DEPENDENCY_PREFIX : exports.BASIC_PREFIX, `/${pkgInfo.name}@${pkgInfo.version}/`, filePath, params.length > 0 ? `?${params.join('&')}` : '', ].join(''); } exports.getFetchURL = getFetchURL; //# sourceMappingURL=manifest.js.map