Initial commit

This commit is contained in:
Spencer Pincott
2024-07-15 22:20:13 -04:00
commit 97737ca1ae
16618 changed files with 934131 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
# browser-resolve Change Log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 2.0.0 - 2020-08-03
* Update `resolve` to 1.17.0+.
Technically, this is a bugfix and feature update. However, older browserify versions rely on a `resolve` bug, and would break if this was published as a minor version update.

21
themes/keepit/node_modules/browser-resolve/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2013-2015 Roman Shtylman <shtylman@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

165
themes/keepit/node_modules/browser-resolve/README.md generated vendored Normal file
View File

@@ -0,0 +1,165 @@
# browser-resolve [![Build Status](https://travis-ci.org/browserify/browser-resolve.png?branch=master)](https://travis-ci.org/browserify/browser-resolve)
node.js resolve algorithm with [browser field](https://github.com/defunctzombie/package-browser-field-spec) support.
## api
### bresolve(id, opts={}, cb)
Resolve a module path and call `cb(err, path [, pkg])`
Options:
* `basedir` - directory to begin resolving from
* `browser` - the 'browser' property to use from package.json (defaults to 'browser')
* `filename` - the calling filename where the `require()` call originated (in the source)
* `modules` - object with module id/name -> path mappings to consult before doing manual resolution (use to provide core modules)
* `packageFilter` - transform the parsed `package.json` contents before looking at the `main` field
* `paths` - `require.paths` array to use if nothing is found on the normal `node_modules` recursive walk
Additionally, options supported by [node-resolve](https://github.com/browserify/resolve#resolveid-opts-cb) can be used.
### bresolve.sync(id, opts={})
Same as the async resolve, just uses sync methods.
Additionally, options supported by [node-resolve](https://github.com/browserify/resolve#resolvesyncid-opts-cb) can be used.
## basic usage
you can resolve files like `require.resolve()`:
``` js
var bresolve = require('browser-resolve');
bresolve('../', { filename: __filename }, function(err, path) {
console.log(path);
});
```
```
$ node example/resolve.js
/home/substack/projects/browser-resolve/index.js
```
## core modules
By default, core modules (http, dgram, etc) will return their same name as the path. If you want to have specific paths returned, specify a `modules` property in the options object.
``` js
var shims = {
http: '/your/path/to/http.js'
};
var bresolve = require('browser-resolve');
bresolve('http', { modules: shims }, function(err, path) {
console.log(path);
});
```
```
$ node example/builtin.js
/home/substack/projects/browser-resolve/builtin/http.js
```
## browser field
browser-specific versions of modules
``` json
{
"name": "custom",
"version": "0.0.0",
"browser": {
"./main.js": "custom.js"
}
}
```
``` js
var bresolve = require('browser-resolve');
var parent = { filename: __dirname + '/custom/file.js' };
bresolve('./main.js', parent, function(err, path) {
console.log(path);
});
```
```
$ node example/custom.js
/home/substack/projects/browser-resolve/example/custom/custom.js
```
You can use different package.json properties for the resolution, if you want to allow packages to target different environments for example:
``` json
{
"browser": { "./main.js": "custom.js" },
"chromeapp": { "./main.js": "custom-chromeapp.js" }
}
```
``` js
var bresolve = require('browser-resolve');
var parent = { filename: __dirname + '/custom/file.js', browser: 'chromeapp' };
bresolve('./main.js', parent, function(err, path) {
console.log(path);
});
```
```
$ node example/custom.js
/home/substack/projects/browser-resolve/example/custom/custom-chromeapp.js
```
## skip
You can skip over dependencies by setting a
[browser field](https://gist.github.com/defunctzombie/4339901)
value to `false`:
``` json
{
"name": "skip",
"version": "0.0.0",
"browser": {
"tar": false
}
}
```
This is handy if you have code like:
``` js
var tar = require('tar');
exports.add = function (a, b) {
return a + b;
};
exports.parse = function () {
return tar.Parse();
};
```
so that `require('tar')` will just return `{}` in the browser because you don't
intend to support the `.parse()` export in a browser environment.
``` js
var bresolve = require('browser-resolve');
var parent = { filename: __dirname + '/skip/main.js' };
bresolve('tar', parent, function(err, path) {
console.log(path);
});
```
```
$ node example/skip.js
/home/substack/projects/browser-resolve/empty.js
```
# license
MIT
# upgrade notes
Prior to v1.x this library provided shims for node core modules. These have since been removed. If you want to have alternative core modules provided, use the `modules` option when calling `bresolve()`.
This was done to allow package managers to choose which shims they want to use without browser-resolve being the central point of update.

0
themes/keepit/node_modules/browser-resolve/empty.js generated vendored Normal file
View File

345
themes/keepit/node_modules/browser-resolve/index.js generated vendored Normal file
View File

@@ -0,0 +1,345 @@
// builtin
var fs = require('fs');
var path = require('path');
// vendor
var resv = require('resolve');
// given a path, create an array of node_module paths for it
// borrowed from substack/resolve
function nodeModulesPaths (start, cb) {
var splitRe = process.platform === 'win32' ? /[\/\\]/ : /\/+/;
var parts = start.split(splitRe);
var dirs = [];
for (var i = parts.length - 1; i >= 0; i--) {
if (parts[i] === 'node_modules') continue;
var dir = path.join.apply(
path, parts.slice(0, i + 1).concat(['node_modules'])
);
if (!parts[0].match(/([A-Za-z]:)/)) {
dir = '/' + dir;
}
dirs.push(dir);
}
return dirs;
}
function find_shims_in_package(pkgJson, cur_path, shims, browser) {
try {
var info = JSON.parse(pkgJson);
}
catch (err) {
err.message = pkgJson + ' : ' + err.message
throw err;
}
var replacements = getReplacements(info, browser);
// no replacements, skip shims
if (!replacements) {
return;
}
// if browser mapping is a string
// then it just replaces the main entry point
if (typeof replacements === 'string') {
var key = path.resolve(cur_path, info.main || 'index.js');
shims[key] = path.resolve(cur_path, replacements);
return;
}
// http://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders
Object.keys(replacements).forEach(function(key) {
var val;
if (replacements[key] === false) {
val = path.normalize(__dirname + '/empty.js');
}
else {
val = replacements[key];
// if target is a relative path, then resolve
// otherwise we assume target is a module
if (val[0] === '.') {
val = path.resolve(cur_path, val);
}
}
if (key[0] === '/' || key[0] === '.') {
// if begins with / ../ or ./ then we must resolve to a full path
key = path.resolve(cur_path, key);
}
shims[key] = val;
});
[ '.js', '.json' ].forEach(function (ext) {
Object.keys(shims).forEach(function (key) {
if (!shims[key + ext]) {
shims[key + ext] = shims[key];
}
});
});
}
// paths is mutated
// load shims from first package.json file found
function load_shims(paths, browser, cb) {
// identify if our file should be replaced per the browser field
// original filename|id -> replacement
var shims = Object.create(null);
(function next() {
var cur_path = paths.shift();
if (!cur_path) {
return cb(null, shims);
}
var pkg_path = path.join(cur_path, 'package.json');
fs.readFile(pkg_path, 'utf8', function(err, data) {
if (err) {
// ignore paths we can't open
// avoids an exists check
if (err.code === 'ENOENT') {
return next();
}
return cb(err);
}
try {
find_shims_in_package(data, cur_path, shims, browser);
return cb(null, shims);
}
catch (err) {
return cb(err);
}
});
})();
};
// paths is mutated
// synchronously load shims from first package.json file found
function load_shims_sync(paths, browser) {
// identify if our file should be replaced per the browser field
// original filename|id -> replacement
var shims = Object.create(null);
var cur_path;
while (cur_path = paths.shift()) {
var pkg_path = path.join(cur_path, 'package.json');
try {
var data = fs.readFileSync(pkg_path, 'utf8');
find_shims_in_package(data, cur_path, shims, browser);
return shims;
}
catch (err) {
// ignore paths we can't open
// avoids an exists check
if (err.code === 'ENOENT') {
continue;
}
throw err;
}
}
return shims;
}
function build_resolve_opts(opts, base) {
var packageFilter = opts.packageFilter;
var browser = normalizeBrowserFieldName(opts.browser)
opts.basedir = base;
opts.packageFilter = function (info, pkgdir) {
if (packageFilter) info = packageFilter(info, pkgdir);
var replacements = getReplacements(info, browser);
// no browser field, keep info unchanged
if (!replacements) {
return info;
}
info[browser] = replacements;
// replace main
if (typeof replacements === 'string') {
info.main = replacements;
return info;
}
var replace_main = replacements[info.main || './index.js'] ||
replacements['./' + info.main || './index.js'];
info.main = replace_main || info.main;
return info;
};
var pathFilter = opts.pathFilter;
opts.pathFilter = function(info, resvPath, relativePath) {
if (relativePath[0] != '.') {
relativePath = './' + relativePath;
}
var mappedPath;
if (pathFilter) {
mappedPath = pathFilter.apply(this, arguments);
}
if (mappedPath) {
return mappedPath;
}
var replacements = info[browser];
if (!replacements) {
return;
}
mappedPath = replacements[relativePath];
if (!mappedPath && path.extname(relativePath) === '') {
mappedPath = replacements[relativePath + '.js'];
if (!mappedPath) {
mappedPath = replacements[relativePath + '.json'];
}
}
return mappedPath;
};
return opts;
}
function resolve(id, opts, cb) {
// opts.filename
// opts.paths
// opts.modules
// opts.packageFilter
opts = opts || {};
opts.filename = opts.filename || '';
var base = path.dirname(opts.filename);
if (opts.basedir) {
base = opts.basedir;
}
var paths = nodeModulesPaths(base);
if (opts.paths) {
paths.push.apply(paths, opts.paths);
}
paths = paths.map(function(p) {
return path.dirname(p);
});
// we must always load shims because the browser field could shim out a module
load_shims(paths, opts.browser, function(err, shims) {
if (err) {
return cb(err);
}
var resid = path.resolve(opts.basedir || path.dirname(opts.filename), id);
if (shims[id] || shims[resid]) {
var xid = shims[id] ? id : resid;
// if the shim was is an absolute path, it was fully resolved
if (shims[xid][0] === '/') {
return resv(shims[xid], build_resolve_opts(opts, base), function(err, full, pkg) {
cb(null, full, pkg);
});
}
// module -> alt-module shims
id = shims[xid];
}
var modules = opts.modules || Object.create(null);
var shim_path = modules[id];
if (shim_path) {
return cb(null, shim_path);
}
// our browser field resolver
// if browser field is an object tho?
var full = resv(id, build_resolve_opts(opts, base), function(err, full, pkg) {
if (err) {
return cb(err);
}
var resolved = (shims) ? shims[full] || full : full;
cb(null, resolved, pkg);
});
});
};
resolve.sync = function (id, opts) {
// opts.filename
// opts.paths
// opts.modules
// opts.packageFilter
opts = opts || {};
opts.filename = opts.filename || '';
var base = path.dirname(opts.filename);
if (opts.basedir) {
base = opts.basedir;
}
var paths = nodeModulesPaths(base);
if (opts.paths) {
paths.push.apply(paths, opts.paths);
}
paths = paths.map(function(p) {
return path.dirname(p);
});
// we must always load shims because the browser field could shim out a module
var shims = load_shims_sync(paths, opts.browser);
var resid = path.resolve(opts.basedir || path.dirname(opts.filename), id);
if (shims[id] || shims[resid]) {
var xid = shims[id] ? id : resid;
// if the shim was is an absolute path, it was fully resolved
if (shims[xid][0] === '/') {
return resv.sync(shims[xid], build_resolve_opts(opts, base));
}
// module -> alt-module shims
id = shims[xid];
}
var modules = opts.modules || Object.create(null);
var shim_path = modules[id];
if (shim_path) {
return shim_path;
}
// our browser field resolver
// if browser field is an object tho?
var full = resv.sync(id, build_resolve_opts(opts, base));
return (shims) ? shims[full] || full : full;
};
function normalizeBrowserFieldName(browser) {
return browser || 'browser';
}
function getReplacements(info, browser) {
browser = normalizeBrowserFieldName(browser);
var replacements = info[browser] || info.browser;
// support legacy browserify field for easier migration from legacy
// many packages used this field historically
if (typeof info.browserify === 'string' && !replacements) {
replacements = info.browserify;
}
return replacements;
}
module.exports = resolve;

View File

@@ -0,0 +1,29 @@
{
"name": "browser-resolve",
"version": "2.0.0",
"description": "resolve which handles browser field support in package.json",
"main": "index.js",
"files": [
"index.js",
"empty.js"
],
"scripts": {
"test": "node scripts/setup-symlinks.js && mocha --reporter list test/*.js"
},
"repository": {
"type": "git",
"url": "git://github.com/browserify/browser-resolve.git"
},
"keywords": [
"resolve",
"browser"
],
"author": "Roman Shtylman <shtylman@gmail.com>",
"license": "MIT",
"dependencies": {
"resolve": "^1.17.0"
},
"devDependencies": {
"mocha": "^2.5.3"
}
}