clientside-require
Advanced tools
Comparing version 3.9.5 to 3.9.6
(function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){ | ||
// shim for using process in browser | ||
var process = module.exports = {}; | ||
// cached from whatever global is present so that test runners that stub it | ||
// don't break things. But we need to wrap it in a try catch in case it is | ||
// wrapped in strict mode code which doesn't define any globals. It's inside a | ||
// function because try/catches deoptimize in certain engines. | ||
var cachedSetTimeout; | ||
var cachedClearTimeout; | ||
function defaultSetTimout() { | ||
throw new Error('setTimeout has not been defined'); | ||
} | ||
function defaultClearTimeout () { | ||
throw new Error('clearTimeout has not been defined'); | ||
} | ||
(function () { | ||
try { | ||
if (typeof setTimeout === 'function') { | ||
cachedSetTimeout = setTimeout; | ||
} else { | ||
cachedSetTimeout = defaultSetTimout; | ||
} | ||
} catch (e) { | ||
cachedSetTimeout = defaultSetTimout; | ||
} | ||
try { | ||
if (typeof clearTimeout === 'function') { | ||
cachedClearTimeout = clearTimeout; | ||
} else { | ||
cachedClearTimeout = defaultClearTimeout; | ||
} | ||
} catch (e) { | ||
cachedClearTimeout = defaultClearTimeout; | ||
} | ||
} ()) | ||
function runTimeout(fun) { | ||
if (cachedSetTimeout === setTimeout) { | ||
//normal enviroments in sane situations | ||
return setTimeout(fun, 0); | ||
} | ||
// if setTimeout wasn't available but was latter defined | ||
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { | ||
cachedSetTimeout = setTimeout; | ||
return setTimeout(fun, 0); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedSetTimeout(fun, 0); | ||
} catch(e){ | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedSetTimeout.call(null, fun, 0); | ||
} catch(e){ | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error | ||
return cachedSetTimeout.call(this, fun, 0); | ||
} | ||
} | ||
} | ||
function runClearTimeout(marker) { | ||
if (cachedClearTimeout === clearTimeout) { | ||
//normal enviroments in sane situations | ||
return clearTimeout(marker); | ||
} | ||
// if clearTimeout wasn't available but was latter defined | ||
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { | ||
cachedClearTimeout = clearTimeout; | ||
return clearTimeout(marker); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedClearTimeout(marker); | ||
} catch (e){ | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedClearTimeout.call(null, marker); | ||
} catch (e){ | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. | ||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout | ||
return cachedClearTimeout.call(this, marker); | ||
} | ||
} | ||
} | ||
var queue = []; | ||
var draining = false; | ||
var currentQueue; | ||
var queueIndex = -1; | ||
function cleanUpNextTick() { | ||
if (!draining || !currentQueue) { | ||
return; | ||
} | ||
draining = false; | ||
if (currentQueue.length) { | ||
queue = currentQueue.concat(queue); | ||
} else { | ||
queueIndex = -1; | ||
} | ||
if (queue.length) { | ||
drainQueue(); | ||
} | ||
} | ||
function drainQueue() { | ||
if (draining) { | ||
return; | ||
} | ||
var timeout = runTimeout(cleanUpNextTick); | ||
draining = true; | ||
var len = queue.length; | ||
while(len) { | ||
currentQueue = queue; | ||
queue = []; | ||
while (++queueIndex < len) { | ||
if (currentQueue) { | ||
currentQueue[queueIndex].run(); | ||
} | ||
} | ||
queueIndex = -1; | ||
len = queue.length; | ||
} | ||
currentQueue = null; | ||
draining = false; | ||
runClearTimeout(timeout); | ||
} | ||
process.nextTick = function (fun) { | ||
var args = new Array(arguments.length - 1); | ||
if (arguments.length > 1) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
} | ||
queue.push(new Item(fun, args)); | ||
if (queue.length === 1 && !draining) { | ||
runTimeout(drainQueue); | ||
} | ||
}; | ||
// v8 likes predictible objects | ||
function Item(fun, array) { | ||
this.fun = fun; | ||
this.array = array; | ||
} | ||
Item.prototype.run = function () { | ||
this.fun.apply(null, this.array); | ||
}; | ||
process.title = 'browser'; | ||
process.browser = true; | ||
process.env = {}; | ||
process.argv = []; | ||
process.version = ''; // empty string to avoid regexp issues | ||
process.versions = {}; | ||
function noop() {} | ||
process.on = noop; | ||
process.addListener = noop; | ||
process.once = noop; | ||
process.off = noop; | ||
process.removeListener = noop; | ||
process.removeAllListeners = noop; | ||
process.emit = noop; | ||
process.prependListener = noop; | ||
process.prependOnceListener = noop; | ||
process.listeners = function (name) { return [] } | ||
process.binding = function (name) { | ||
throw new Error('process.binding is not supported'); | ||
}; | ||
process.cwd = function () { return '/' }; | ||
process.chdir = function (dir) { | ||
throw new Error('process.chdir is not supported'); | ||
}; | ||
process.umask = function() { return 0; }; | ||
},{}],2:[function(require,module,exports){ | ||
var normalize_path = require("./utilities/request_analysis/normalize_path.js"); | ||
@@ -35,2 +221,5 @@ | ||
}) | ||
.catch((error)=>{ // remove self from cache if there was an error | ||
delete this._data.promise[cache_path]; | ||
}) | ||
return true; | ||
@@ -44,3 +233,3 @@ }, | ||
},{"./utilities/request_analysis/normalize_path.js":9}],2:[function(require,module,exports){ | ||
},{"./utilities/request_analysis/normalize_path.js":10}],3:[function(require,module,exports){ | ||
/* | ||
@@ -129,3 +318,3 @@ Clientside Require Module | ||
},{"./cache.js":1,"./retreive.js":3,"./utilities/normalize_request_options":7}],3:[function(require,module,exports){ | ||
},{"./cache.js":2,"./retreive.js":4,"./utilities/normalize_request_options":8}],4:[function(require,module,exports){ | ||
/* | ||
@@ -217,3 +406,3 @@ retreival_manager handles placing requests to load content. handles sync and async requires. | ||
},{"./utilities/content_loading/scoped.js":6,"./utilities/request_analysis/decompose_request.js":8}],4:[function(require,module,exports){ | ||
},{"./utilities/content_loading/scoped.js":7,"./utilities/request_analysis/decompose_request.js":9}],5:[function(require,module,exports){ | ||
/* | ||
@@ -225,3 +414,3 @@ basic resource loading methods that do not nessesarily preserve scope | ||
if(typeof target_document == "undefined") target_document = window.document; // if no document is specified, assume its the window's document | ||
return new Promise((resolve, reject)=>{ | ||
var loading_promise = new Promise((resolve, reject)=>{ | ||
var script = target_document.createElement('script'); | ||
@@ -232,24 +421,9 @@ script.setAttribute("src", script_src); | ||
}; | ||
script.onerror = function(error){ | ||
reject(error); | ||
} | ||
target_document.getElementsByTagName('head')[0].appendChild(script); | ||
}) | ||
return loading_promise; | ||
}, | ||
promise_to_retreive_json : function(json_source){ | ||
return new Promise((resolve, reject)=>{ | ||
var xhr = new window.XMLHttpRequest(); | ||
xhr.open("GET", json_source, true); | ||
xhr.onload = function(){ | ||
if(this.status == "404") throw {type : "404"}; | ||
try { | ||
resolve(JSON.parse(this.responseText)); | ||
} catch (err){ | ||
throw (err); | ||
} | ||
}; | ||
xhr.onerror = function(error){ | ||
if(typeof error == "undefined") error = this.statusText; // if error is not defined, atleast resolve with status text | ||
throw (error); | ||
}; | ||
xhr.send(); | ||
}) | ||
}, | ||
promise_to_load_css_into_document : function(styles_href, target_document){ | ||
@@ -267,3 +441,3 @@ if(typeof target_document == "undefined") target_document = window.document; // if no document is specified, assume its the window's document | ||
styles.onerror = function(error){ | ||
throw error; | ||
reject(error); | ||
}; | ||
@@ -278,2 +452,5 @@ target_document.getElementsByTagName('head')[0].appendChild(styles); | ||
xhr.onload = function(){ | ||
var status_string = this.status + ""; | ||
if(status_string[0] == "4") return reject(new Error(this.status)); | ||
if(status_string[0] == "5") return reject(new Error(this.status)); | ||
resolve(this.responseText) | ||
@@ -283,3 +460,4 @@ }; | ||
if(typeof error == "undefined") error = this.statusText; // if error is not defined, atleast resolve with status text | ||
throw (error); | ||
if(error.code == "ENOENT") return reject(new Error("404")); // maps not found node file:/// requests to 404 response | ||
return reject(error); | ||
}; | ||
@@ -289,5 +467,20 @@ xhr.send(); | ||
}, | ||
promise_to_retreive_json : async function(json_source){ | ||
// get text from file | ||
var content = await this.promise_to_get_content_from_file(json_source); | ||
// cast data to json | ||
try { | ||
var data = (JSON.parse(content)); | ||
} catch (err){ | ||
throw (err); | ||
} | ||
// resolve with response | ||
return data; | ||
}, | ||
} | ||
},{}],5:[function(require,module,exports){ | ||
},{}],6:[function(require,module,exports){ | ||
(function (process){ | ||
var basic_loaders = require("./basic.js"); | ||
@@ -337,3 +530,3 @@ /* | ||
// destroy the frame now that we have the exports | ||
this.helpers.remove_frame(frame); | ||
if(typeof process == "undefined") this.helpers.remove_frame(frame); // do not remove iframe if we are using in node context (meaning we are using jsdom). TODO (#29) - figure how to preserve the window object (specifically window.document) after iframe is removed from parent | ||
@@ -416,3 +609,4 @@ // return the exports | ||
},{"./basic.js":4}],6:[function(require,module,exports){ | ||
}).call(this,require('_process')) | ||
},{"./basic.js":5,"_process":1}],7:[function(require,module,exports){ | ||
var basic_loaders = require("./basic.js"); | ||
@@ -433,3 +627,3 @@ var commonjs_loader = require("./commonjs.js"); | ||
},{"./basic.js":4,"./commonjs.js":5}],7:[function(require,module,exports){ | ||
},{"./basic.js":5,"./commonjs.js":6}],8:[function(require,module,exports){ | ||
module.exports = function(options){ | ||
@@ -447,3 +641,3 @@ if(typeof options == "undefined") options = {}; // ensure options are defined | ||
},{}],8:[function(require,module,exports){ | ||
},{}],9:[function(require,module,exports){ | ||
var basic_loaders = require("./../content_loading/basic.js"); | ||
@@ -543,3 +737,3 @@ var normalize_path = require("./normalize_path.js"); | ||
},{"./../content_loading/basic.js":4,"./normalize_path.js":9}],9:[function(require,module,exports){ | ||
},{"./../content_loading/basic.js":5,"./normalize_path.js":10}],10:[function(require,module,exports){ | ||
/* | ||
@@ -626,2 +820,2 @@ analyze and normalize path | ||
},{}]},{},[2]); | ||
},{}]},{},[3]); |
{ | ||
"name": "clientside-require", | ||
"version": "3.9.5", | ||
"version": "3.9.6", | ||
"description": "require() modules, js, css, html, and json in the browser with as little effort as loading jquery", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
111942
1264
3