@jsenv/url-meta
Advanced tools
Comparing version 2.0.0 to 3.0.0
@@ -5,17 +5,8 @@ 'use strict'; | ||
function _typeof(obj) { | ||
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { | ||
_typeof = function (obj) { | ||
return typeof obj; | ||
}; | ||
} else { | ||
_typeof = function (obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
} | ||
return _typeof(obj); | ||
} | ||
function _defineProperty(obj, key, value) { | ||
var _defineProperty = (function (obj, key, value) { | ||
// Shortcircuit the slow defineProperty path when possible. | ||
// We are trying to avoid issues where setters defined on the | ||
// prototype cause side effects under the fast path of simple | ||
// assignment. By checking for existence of the property with | ||
// the in operator, we can optimize most of this overhead away. | ||
if (key in obj) { | ||
@@ -33,23 +24,11 @@ Object.defineProperty(obj, key, { | ||
return obj; | ||
} | ||
}); | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
keys.push.apply(keys, symbols); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
function _objectSpread (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
// eslint-disable-next-line prefer-rest-params | ||
var source = arguments[i] === null ? {} : arguments[i]; | ||
if (i % 2) { | ||
// eslint-disable-next-line no-loop-func | ||
ownKeys(source, true).forEach(function (key) { | ||
@@ -61,2 +40,3 @@ _defineProperty(target, key, source[key]); | ||
} else { | ||
// eslint-disable-next-line no-loop-func | ||
ownKeys(source).forEach(function (key) { | ||
@@ -69,65 +49,61 @@ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
return target; | ||
} | ||
} // This function is different to "Reflect.ownKeys". The enumerableOnly | ||
// filters on symbol properties only. Returned string properties are always | ||
// enumerable. It is good to use in objectSpread. | ||
// eslint-disable-next-line no-undef | ||
if ((typeof globalThis === "undefined" ? "undefined" : _typeof(globalThis)) !== "object") { | ||
var globalObject; | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
if (undefined) { | ||
globalObject = undefined; | ||
} else { | ||
// eslint-disable-next-line no-extend-native | ||
Object.defineProperty(Object.prototype, "__global__", { | ||
get: function get() { | ||
return this; | ||
}, | ||
configurable: true | ||
}); // eslint-disable-next-line no-undef | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); // eslint-disable-next-line prefer-spread | ||
globalObject = __global__; | ||
delete Object.prototype.__global__; | ||
keys.push.apply(keys, symbols); | ||
} | ||
globalObject.globalThis = globalObject; | ||
return keys; | ||
} | ||
var hrefToScheme = function hrefToScheme(href) { | ||
var colonIndex = href.indexOf(":"); | ||
if (colonIndex === -1) return ""; | ||
return href.slice(0, colonIndex); | ||
}; | ||
var assertUrlLike = function assertUrlLike(value) { | ||
var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "url"; | ||
var urlMatch = function urlMatch(_ref) { | ||
var pattern = _ref.pattern, | ||
url = _ref.url; | ||
if (typeof pattern !== "string") { | ||
throw new TypeError("pattern must be a string, got ".concat(pattern)); | ||
if (typeof value !== "string") { | ||
throw new TypeError("".concat(name, " must be a url string, got ").concat(value)); | ||
} | ||
var patternScheme = hrefToScheme(pattern); | ||
if (!patternScheme) { | ||
throw new Error("pattern must have a scheme, got ".concat(pattern)); | ||
if (isWindowsPathnameSpecifier(value)) { | ||
throw new TypeError("".concat(name, " must be a url but looks like a windows pathname, got ").concat(value)); | ||
} | ||
if (typeof url !== "string") { | ||
throw new TypeError("url must be a string, got ".concat(url)); | ||
if (!hasScheme(value)) { | ||
throw new TypeError("".concat(name, " must be a url and no scheme found, got ").concat(value)); | ||
} | ||
}; | ||
var urlScheme = hrefToScheme(url); | ||
var isWindowsPathnameSpecifier = function isWindowsPathnameSpecifier(specifier) { | ||
var firstChar = specifier[0]; | ||
if (!/[a-zA-Z]/.test(firstChar)) return false; | ||
var secondChar = specifier[1]; | ||
if (secondChar !== ":") return false; | ||
var thirdChar = specifier[2]; | ||
return thirdChar === "/"; | ||
}; | ||
if (!urlScheme) { | ||
throw new Error("url must have a scheme, got ".concat(url)); | ||
} | ||
var hasScheme = function hasScheme(specifier) { | ||
return /^[a-zA-Z]+:/.test(specifier); | ||
}; | ||
return match({ | ||
pattern: pattern, | ||
string: url | ||
}); | ||
var applySpecifierPatternMatching = function applySpecifierPatternMatching() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
specifier = _ref.specifier, | ||
url = _ref.url; | ||
assertUrlLike(specifier, "specifier"); | ||
assertUrlLike(url, "url"); | ||
return applyPatternMatching(specifier, url); | ||
}; | ||
var match = function match(_ref2) { | ||
var pattern = _ref2.pattern, | ||
string = _ref2.string; | ||
var applyPatternMatching = function applyPatternMatching(pattern, string) { | ||
var patternIndex = 0; | ||
@@ -282,9 +258,9 @@ var index = 0; | ||
var skipUntilMatch = function skipUntilMatch(_ref3) { | ||
var pattern = _ref3.pattern, | ||
string = _ref3.string, | ||
_ref3$skippablePredic = _ref3.skippablePredicate, | ||
skippablePredicate = _ref3$skippablePredic === void 0 ? function () { | ||
var skipUntilMatch = function skipUntilMatch(_ref2) { | ||
var pattern = _ref2.pattern, | ||
string = _ref2.string, | ||
_ref2$skippablePredic = _ref2.skippablePredicate, | ||
skippablePredicate = _ref2$skippablePredic === void 0 ? function () { | ||
return true; | ||
} : _ref3$skippablePredic; | ||
} : _ref2$skippablePredic; | ||
var index = 0; | ||
@@ -295,6 +271,3 @@ var remainingString = string; | ||
while (true) { | ||
var matchAttempt = match({ | ||
pattern: pattern, | ||
string: remainingString | ||
}); | ||
var matchAttempt = applyPatternMatching(pattern, remainingString); | ||
@@ -321,3 +294,3 @@ if (matchAttempt.matched) { | ||
if (remainingString === "") { | ||
bestMatch = _objectSpread2({}, bestMatch, { | ||
bestMatch = _objectSpread({}, bestMatch, { | ||
index: string.length | ||
@@ -334,5 +307,5 @@ }); | ||
var pass = function pass(_ref4) { | ||
var patternIndex = _ref4.patternIndex, | ||
index = _ref4.index; | ||
var pass = function pass(_ref3) { | ||
var patternIndex = _ref3.patternIndex, | ||
index = _ref3.index; | ||
return { | ||
@@ -345,5 +318,5 @@ matched: true, | ||
var fail = function fail(_ref5) { | ||
var patternIndex = _ref5.patternIndex, | ||
index = _ref5.index; | ||
var fail = function fail(_ref4) { | ||
var patternIndex = _ref4.patternIndex, | ||
index = _ref4.index; | ||
return { | ||
@@ -356,26 +329,273 @@ matched: false, | ||
var urlToMeta = function urlToMeta(_ref) { | ||
var url = _ref.url, | ||
metaMap = _ref.metaMap; | ||
return Object.keys(metaMap).reduce(function (previousMeta, metaPattern) { | ||
var _urlMatch = urlMatch({ | ||
url: url, | ||
pattern: metaPattern | ||
}), | ||
matched = _urlMatch.matched; | ||
var nativeTypeOf = function nativeTypeOf(obj) { | ||
return typeof obj; | ||
}; | ||
return matched ? _objectSpread2({}, previousMeta, {}, metaMap[metaPattern]) : previousMeta; | ||
}, {}); | ||
var customTypeOf = function customTypeOf(obj) { | ||
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; | ||
}; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? nativeTypeOf : customTypeOf; | ||
var isPlainObject = function isPlainObject(value) { | ||
if (value === null) { | ||
return false; | ||
} | ||
if (_typeof(value) === "object") { | ||
if (Array.isArray(value)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
return false; | ||
}; | ||
var metaMapToSpecifierMetaMap = function metaMapToSpecifierMetaMap(metaMap) { | ||
if (!isPlainObject(metaMap)) { | ||
throw new TypeError("metaMap must be a plain object, got ".concat(metaMap)); | ||
} | ||
var specifierMetaMap = {}; | ||
Object.keys(metaMap).forEach(function (metaKey) { | ||
var specifierValueMap = metaMap[metaKey]; | ||
if (!isPlainObject(specifierValueMap)) { | ||
throw new TypeError("metaMap value must be plain object, got ".concat(specifierValueMap, " for ").concat(metaKey)); | ||
} | ||
Object.keys(specifierValueMap).forEach(function (specifier) { | ||
var metaValue = specifierValueMap[specifier]; | ||
var meta = _defineProperty({}, metaKey, metaValue); | ||
specifierMetaMap[specifier] = specifier in specifierMetaMap ? _objectSpread({}, specifierMetaMap[specifier], {}, meta) : meta; | ||
}); | ||
}); | ||
return specifierMetaMap; | ||
}; | ||
// https://url.spec.whatwg.org/#example-start-with-a-widows-drive-letter | ||
var isWindowsDriveLetter = function isWindowsDriveLetter(specifier) { | ||
var firstChar = specifier[0]; | ||
if (!/[a-zA-Z]/.test(firstChar)) return false; | ||
var secondChar = specifier[1]; | ||
if (secondChar !== ":") return false; | ||
var thirdChar = specifier[2]; | ||
return thirdChar === "/"; | ||
}; | ||
// "file:///folder/file.js" | ||
// "chrome://folder/file.js" | ||
var isAbsoluteSpecifier = function isAbsoluteSpecifier(specifier) { | ||
// window drive letter could are not protocol yep | ||
// something like `C:/folder/file.js` | ||
// will be considered as a bare import | ||
if (isWindowsDriveLetter(specifier.slice(0, 3))) return false; | ||
return /^[a-zA-Z]+:/.test(specifier); | ||
}; | ||
var resolveAbsoluteSpecifier = function resolveAbsoluteSpecifier(specifier) { | ||
return specifier; | ||
}; | ||
var hrefToScheme = function hrefToScheme(href) { | ||
var colonIndex = href.indexOf(":"); | ||
if (colonIndex === -1) return ""; | ||
return href.slice(0, colonIndex); | ||
}; | ||
var hrefToOrigin = function hrefToOrigin(href) { | ||
var scheme = hrefToScheme(href); | ||
if (scheme === "file") { | ||
return "file://"; | ||
} | ||
if (scheme === "http" || scheme === "https") { | ||
var secondProtocolSlashIndex = scheme.length + "://".length; | ||
var pathnameSlashIndex = href.indexOf("/", secondProtocolSlashIndex); | ||
if (pathnameSlashIndex === -1) return href; | ||
return href.slice(0, pathnameSlashIndex); | ||
} | ||
return href.slice(0, scheme.length + 1); | ||
}; | ||
var hrefToPathname = function hrefToPathname(href) { | ||
return ressourceToPathname(hrefToRessource(href)); | ||
}; | ||
var hrefToRessource = function hrefToRessource(href) { | ||
var scheme = hrefToScheme(href); | ||
if (scheme === "file") { | ||
return href.slice("file://".length); | ||
} | ||
if (scheme === "https" || scheme === "http") { | ||
// remove origin | ||
var afterProtocol = href.slice(scheme.length + "://".length); | ||
var pathnameSlashIndex = afterProtocol.indexOf("/", "://".length); | ||
return afterProtocol.slice(pathnameSlashIndex); | ||
} | ||
return href.slice(scheme.length + 1); | ||
}; | ||
var ressourceToPathname = function ressourceToPathname(ressource) { | ||
var searchSeparatorIndex = ressource.indexOf("?"); | ||
return searchSeparatorIndex === -1 ? ressource : ressource.slice(0, searchSeparatorIndex); | ||
}; | ||
var pathnameToDirname = function pathnameToDirname(pathname) { | ||
var slashLastIndex = pathname.lastIndexOf("/"); | ||
if (slashLastIndex === -1) return ""; | ||
return pathname.slice(0, slashLastIndex); | ||
}; | ||
var isSchemeRelativeSpecifier = function isSchemeRelativeSpecifier(specifier) { | ||
return specifier.slice(0, 2) === "//"; | ||
}; | ||
var resolveSchemeRelativeSpecifier = function resolveSchemeRelativeSpecifier(specifier, importer) { | ||
return "".concat(hrefToScheme(importer), ":").concat(specifier); | ||
}; | ||
var isOriginRelativeSpecifier = function isOriginRelativeSpecifier(specifier) { | ||
var firstChar = specifier[0]; | ||
if (firstChar !== "/") return false; | ||
var secondChar = specifier[1]; | ||
if (secondChar === "/") return false; | ||
return true; | ||
}; | ||
var resolveOriginRelativeSpecifier = function resolveOriginRelativeSpecifier(specifier, importer) { | ||
var importerOrigin = hrefToOrigin(importer); | ||
return "".concat(importerOrigin, "/").concat(specifier.slice(1)); | ||
}; | ||
// https://github.com/systemjs/systemjs/blob/master/src/common.js | ||
// "../folder/file.js" | ||
var isPathnameRelativeSpecifier = function isPathnameRelativeSpecifier(specifier) { | ||
if (specifier.slice(0, 2) === "./") return true; | ||
if (specifier.slice(0, 3) === "../") return true; | ||
return false; | ||
}; | ||
var resolvePathnameRelativeSpecifier = function resolvePathnameRelativeSpecifier(specifier, importer) { | ||
var importerPathname = hrefToPathname(importer); // ./foo.js on /folder/file.js -> /folder/foo.js | ||
// ./foo/bar.js on /folder/file.js -> /folder/foo/bar.js | ||
// ./foo.js on /folder/subfolder/file.js -> /folder/subfolder/foo.js | ||
if (specifier.slice(0, 2) === "./") { | ||
var _importerOrigin = hrefToOrigin(importer); | ||
var importerDirname = pathnameToDirname(importerPathname); | ||
return "".concat(_importerOrigin).concat(importerDirname, "/").concat(specifier.slice(2)); | ||
} // ../foo/bar.js on /folder/file.js -> /foo/bar.js | ||
// ../foo/bar.js on /folder/subfolder/file.js -> /folder/foo/bar.js | ||
// ../../foo/bar.js on /folder/file.js -> /foo/bar.js | ||
// ../bar.js on / -> /bar.js | ||
var unresolvedPathname = specifier; | ||
var importerFolders = importerPathname.split("/"); | ||
importerFolders.pop(); // remove file, it is not a folder | ||
while (unresolvedPathname.slice(0, 3) === "../") { | ||
// when there is no folder left to resolved | ||
// we just ignore '../' | ||
if (importerFolders.length) { | ||
importerFolders.pop(); | ||
} | ||
unresolvedPathname = unresolvedPathname.slice(3); | ||
} | ||
var importerOrigin = hrefToOrigin(importer); | ||
var resolvedPathname = "".concat(importerFolders.join("/"), "/").concat(unresolvedPathname); | ||
return "".concat(importerOrigin).concat(resolvedPathname); | ||
}; | ||
var resolveBareSpecifier = function resolveBareSpecifier(specifier, importer) { | ||
var importerOrigin = hrefToOrigin(importer); | ||
return "".concat(importerOrigin, "/").concat(specifier); | ||
}; | ||
// could be useful: https://url.spec.whatwg.org/#url-miscellaneous | ||
var resolveSpecifier = function resolveSpecifier(specifier, importer) { | ||
if (isAbsoluteSpecifier(specifier)) { | ||
return resolveAbsoluteSpecifier(specifier); | ||
} | ||
if (!importer) { | ||
throw new Error(createMissingImporterMessage(specifier, importer)); | ||
} | ||
if (isSchemeRelativeSpecifier(specifier)) { | ||
return resolveSchemeRelativeSpecifier(specifier, importer); | ||
} | ||
if (isOriginRelativeSpecifier(specifier)) { | ||
return resolveOriginRelativeSpecifier(specifier, importer); | ||
} | ||
if (isPathnameRelativeSpecifier(specifier)) { | ||
return resolvePathnameRelativeSpecifier(specifier, importer); | ||
} | ||
return resolveBareSpecifier(specifier, importer); | ||
}; | ||
var createMissingImporterMessage = function createMissingImporterMessage(specifier, importer) { | ||
return "missing importer to resolve relative specifier.\n--- specifier ---\n".concat(specifier, "\n--- importer ---\n").concat(importer); | ||
}; | ||
var assertSpecifierMetaMap = function assertSpecifierMetaMap(value) { | ||
if (!isPlainObject(value)) { | ||
throw new TypeError("specifierMetaMap must be a plain object, got ".concat(value)); | ||
} // we could ensure it's key/value pair of url like key/object or null values | ||
}; | ||
var FAKE_HTTP_ORIGIN_UNLIKELY_TO_COLLIDE = "http://fake_origin_unlikely_to_collide.ext"; | ||
var normalizeSpecifierMetaMap = function normalizeSpecifierMetaMap(specifierMetaMap, url) { | ||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
_ref$forceHttpResolut = _ref.forceHttpResolutionForFile, | ||
forceHttpResolutionForFile = _ref$forceHttpResolut === void 0 ? false : _ref$forceHttpResolut; | ||
assertSpecifierMetaMap(specifierMetaMap); | ||
var resolveSpecifierScoped = forceHttpResolutionForFile && url.startsWith("file:///") ? function (specifier, url) { | ||
var specifierResolvedAgainstHttp = resolveSpecifier(specifier, FAKE_HTTP_ORIGIN_UNLIKELY_TO_COLLIDE); | ||
if (specifierResolvedAgainstHttp.startsWith("".concat(FAKE_HTTP_ORIGIN_UNLIKELY_TO_COLLIDE, "/"))) { | ||
var specifierPathname = specifierResolvedAgainstHttp.slice(FAKE_HTTP_ORIGIN_UNLIKELY_TO_COLLIDE.length); | ||
return "".concat(url).concat(specifierPathname); | ||
} | ||
return specifierResolvedAgainstHttp; | ||
} : resolveSpecifier; | ||
var specifierMetaMapNormalized = {}; | ||
Object.keys(specifierMetaMap).forEach(function (specifier) { | ||
var specifierResolved = resolveSpecifierScoped(specifier, url); | ||
specifierMetaMapNormalized[specifierResolved] = specifierMetaMap[specifier]; | ||
}); | ||
return specifierMetaMapNormalized; | ||
}; | ||
var urlCanContainsMetaMatching = function urlCanContainsMetaMatching(_ref) { | ||
var url = _ref.url, | ||
metaMap = _ref.metaMap, | ||
specifierMetaMap = _ref.specifierMetaMap, | ||
predicate = _ref.predicate; | ||
if (typeof url !== "string") throw new TypeError("pathname must be a string, got ".concat(url)); | ||
if (_typeof(metaMap) !== "object") throw new TypeError("metaMap must be an object, got ".concat(metaMap)); | ||
if (typeof predicate !== "function") throw new TypeError("predicate must be a function, got ".concat(predicate)); // we add a trailing slash because we are intested into what will be inside | ||
assertUrlLike(url, "url"); | ||
assertSpecifierMetaMap(specifierMetaMap); | ||
if (typeof predicate !== "function") { | ||
throw new TypeError("predicate must be a function, got ".concat(predicate)); | ||
} // we add a trailing slash because we are intested into what will be inside | ||
// this url, not the url itself | ||
// it allows to match pattern for what is inside | ||
var urlWithTrailingSlash = "".concat(url, "/"); // for full match we must create an object to allow pattern to override previous ones | ||
@@ -388,18 +608,24 @@ | ||
var partialMatchMetaArray = []; | ||
Object.keys(metaMap).forEach(function (pattern) { | ||
var _urlMatch = urlMatch({ | ||
url: urlWithTrailingSlash, | ||
pattern: pattern | ||
Object.keys(specifierMetaMap).forEach(function (specifier) { | ||
var meta = specifierMetaMap[specifier]; | ||
var _applySpecifierPatter = applySpecifierPatternMatching({ | ||
specifier: specifier, | ||
url: urlWithTrailingSlash | ||
}), | ||
matched = _urlMatch.matched, | ||
index = _urlMatch.index; | ||
matched = _applySpecifierPatter.matched, | ||
index = _applySpecifierPatter.index; | ||
if (matched) { | ||
someFullMatch = true; | ||
fullMatchMeta = _objectSpread2({}, fullMatchMeta, {}, metaMap[pattern]); | ||
fullMatchMeta = _objectSpread({}, fullMatchMeta, {}, meta); | ||
} else if (someFullMatch === false && index >= url.length) { | ||
partialMatchMetaArray.push(metaMap[pattern]); | ||
partialMatchMetaArray.push(meta); | ||
} | ||
}); | ||
if (someFullMatch) return Boolean(predicate(fullMatchMeta)); | ||
if (someFullMatch) { | ||
return Boolean(predicate(fullMatchMeta)); | ||
} | ||
return partialMatchMetaArray.some(function (partialMatchMeta) { | ||
@@ -410,43 +636,25 @@ return predicate(partialMatchMeta); | ||
var namedMetaToMetaMap = function namedMetaToMetaMap(namedMeta) { | ||
var metaMap = {}; | ||
Object.keys(namedMeta).forEach(function (metaName) { | ||
var valueMap = namedMeta[metaName]; | ||
Object.keys(valueMap).forEach(function (pattern) { | ||
var value = valueMap[pattern]; | ||
var urlToMeta = function urlToMeta() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
url = _ref.url, | ||
specifierMetaMap = _ref.specifierMetaMap; | ||
var meta = _defineProperty({}, metaName, value); | ||
assertUrlLike(url); | ||
assertSpecifierMetaMap(specifierMetaMap); | ||
return Object.keys(specifierMetaMap).reduce(function (previousMeta, specifier) { | ||
var _applySpecifierPatter = applySpecifierPatternMatching({ | ||
specifier: specifier, | ||
url: url | ||
}), | ||
matched = _applySpecifierPatter.matched; | ||
metaMap[pattern] = pattern in metaMap ? _objectSpread2({}, metaMap[pattern], {}, meta) : meta; | ||
}); | ||
}); | ||
return metaMap; | ||
return matched ? _objectSpread({}, previousMeta, {}, specifierMetaMap[specifier]) : previousMeta; | ||
}, {}); | ||
}; | ||
var resolveMetaMapPatterns = function resolveMetaMapPatterns(metaMap, href) { | ||
if (typeof href !== "string") { | ||
throw new TypeError("href must be a string, got ".concat(href)); | ||
} | ||
if (!hrefToScheme(href)) { | ||
throw new TypeError("href must have a scheme, got ".concat(href)); | ||
} | ||
var resolvedMetaMap = {}; | ||
Object.keys(metaMap).forEach(function (pattern) { | ||
if (hrefToScheme(pattern)) { | ||
resolvedMetaMap[pattern] = metaMap[pattern]; | ||
} else { | ||
var resolvedPattern = "".concat(href).concat(pattern); | ||
resolvedMetaMap[resolvedPattern] = metaMap[pattern]; | ||
} | ||
}); | ||
return resolvedMetaMap; | ||
}; | ||
exports.namedMetaToMetaMap = namedMetaToMetaMap; | ||
exports.resolveMetaMapPatterns = resolveMetaMapPatterns; | ||
exports.applySpecifierPatternMatching = applySpecifierPatternMatching; | ||
exports.metaMapToSpecifierMetaMap = metaMapToSpecifierMetaMap; | ||
exports.normalizeSpecifierMetaMap = normalizeSpecifierMetaMap; | ||
exports.urlCanContainsMetaMatching = urlCanContainsMetaMatching; | ||
exports.urlMatch = urlMatch; | ||
exports.urlToMeta = urlToMeta; | ||
//# sourceMappingURL=main.js.map |
18
index.js
@@ -1,5 +0,13 @@ | ||
export { urlMatch } from "./src/urlMatch.js" | ||
export { urlToMeta } from "./src/urlToMeta.js" | ||
export { urlCanContainsMetaMatching } from "./src/urlCanContainsMetaMatching.js" | ||
export { namedMetaToMetaMap } from "./src/namedMetaToMetaMap.js" | ||
export { resolveMetaMapPatterns } from "./src/resolveMetaMapPatterns.js" | ||
export { | ||
applySpecifierPatternMatching, | ||
} from "./src/applySpecifierPatternMatching/applySpecifierPatternMatching.js" | ||
export { | ||
metaMapToSpecifierMetaMap, | ||
} from "./src/metaMapToSpecifierMetaMap/metaMapToSpecifierMetaMap.js" | ||
export { | ||
normalizeSpecifierMetaMap, | ||
} from "./src/normalizeSpecifierMetaMap/normalizeSpecifierMetaMap.js" | ||
export { | ||
urlCanContainsMetaMatching, | ||
} from "./src/urlCanContainsMetaMatching/urlCanContainsMetaMatching.js" | ||
export { urlToMeta } from "./src/urlToMeta/urlToMeta.js" |
{ | ||
"name": "@jsenv/url-meta", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"license": "MIT", | ||
@@ -28,3 +28,2 @@ "repository": { | ||
"generate-commonjs-bundle": "node ./script/generate-commonjs-bundle/generate-commonjs-bundle.js", | ||
"generate-signature-file": "node ./script/run-node/run-node.js src/server/generate-signature-file.js", | ||
"generate-import-map": "node ./script/generate-import-map/generate-import-map.js", | ||
@@ -38,17 +37,17 @@ "dist": "npm run clean && npm run generate-commonjs-bundle", | ||
"dependencies": { | ||
"@jsenv/module-resolution": "3.5.0" | ||
"@jsenv/import-map": "5.2.0" | ||
}, | ||
"devDependencies": { | ||
"@jsenv/execution": "2.0.0", | ||
"@jsenv/testing": "2.0.0", | ||
"@jsenv/bundling": "2.1.0", | ||
"@jsenv/exploring-server": "2.17.0", | ||
"@jsenv/node-launcher": "2.1.0", | ||
"@jsenv/node-module-import-map": "4.4.0", | ||
"@jsenv/eslint-config": "9.9.0", | ||
"@dmail/assert": "3.14.0", | ||
"@jsenv/bundling": "6.1.0", | ||
"@jsenv/codecov-upload": "1.8.0", | ||
"@jsenv/eslint-config": "10.1.0", | ||
"@jsenv/execution": "5.12.0", | ||
"@jsenv/exploring-server": "3.10.0", | ||
"@jsenv/node-launcher": "4.16.0", | ||
"@jsenv/node-module-import-map": "7.0.0", | ||
"@jsenv/prettier-check-project": "3.4.0", | ||
"@jsenv/prettier-config": "1.0.0", | ||
"@jsenv/prettier-check-project": "3.3.0", | ||
"@jsenv/codecov-upload": "1.7.0", | ||
"@dmail/assert": "3.14.0", | ||
"eslint": "6.2.2", | ||
"@jsenv/testing": "3.3.0", | ||
"eslint": "6.4.0", | ||
"prettier": "1.18.2", | ||
@@ -55,0 +54,0 @@ "rimraf": "3.0.0" |
@@ -14,3 +14,3 @@ # Url meta | ||
const metaMap = { | ||
const specifierMetaMap = { | ||
"file:///**/*.js": { | ||
@@ -27,4 +27,4 @@ extension: "js", | ||
urlToMeta({ url: "file:///file.js", metaMap }) // { extension: "js", foo: true } | ||
urlToMeta({ url: "file:///file.json", metaMap }) // { extension: "json" } | ||
urlToMeta({ url: "file:///file.js", specifierMetaMap }) // { extension: "js", foo: true } | ||
urlToMeta({ url: "file:///file.json", specifierMetaMap }) // { extension: "json" } | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14
865
76454
1
+ Added@jsenv/import-map@5.2.0
+ Added@jsenv/href@1.0.0(transitive)
+ Added@jsenv/import-map@5.2.0(transitive)
- Removed@jsenv/module-resolution@3.5.0
- Removed@jsenv/module-resolution@3.5.0(transitive)