Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// // instead of doing the sane code of being able to just use import.meta.url
// // (Edge doesn't work) (safari mobile, chrome, opera, firefox all do)
// //
// // I will use stacktrace-js library to get the current file name
// //
// try {
// // @ts-ignore
// let packageUrl = import.meta.url;
// currentJavascriptURL = packageUrl;
// } catch (error) {
// // eat
// }
//
//
{
let stacktrace = StackTrace.getSync();
currentJavascriptURL = stacktrace[0].fileName;
}
const magickWorkerUrl = GetCurrentUrlDifferentFilename('magick.js')
function GenerateMagickWorkerText(magickUrl){
// generates code for the following
// var magickJsCurrentPath = 'magickUrl';
// importScripts(magickJsCurrentPath);
return "var magickJsCurrentPath = '" + magickUrl +"';\n" +
'importScripts(magickJsCurrentPath);'
}
let magickWorker;
if(currentJavascriptURL.startsWith('http'))
{
// // instead of doing the sane code of being able to just use import.meta.url
// // (Edge doesn't work) (safari mobile, chrome, opera, firefox all do)
// //
// // I will use stacktrace-js library to get the current file name
// //
// try {
// // @ts-ignore
// let packageUrl = import.meta.url;
// currentJavascriptURL = packageUrl;
// } catch (error) {
// // eat
// }
//
//
{
let stacktrace = StackTrace.getSync();
currentJavascriptURL = stacktrace[0].fileName;
}
const magickWorkerUrl = GetCurrentUrlDifferentFilename('magick.js')
function GenerateMagickWorkerText(magickUrl){
// generates code for the following
// var magickJsCurrentPath = 'magickUrl';
// importScripts(magickJsCurrentPath);
return "var magickJsCurrentPath = '" + magickUrl +"';\n" +
'importScripts(magickJsCurrentPath);'
}
let magickWorker;
if(currentJavascriptURL.startsWith('http'))
{
function getDefinitionLineAndUri(cwd) {
let line = 'unknown'
let uri = 'unknown'
const stackframes = StackTrace.getSync()
const stackframe = _.find(stackframes, frame => {
return !isFileNameInCucumber(frame.getFileName())
})
if (stackframe) {
line = stackframe.getLineNumber()
uri = stackframe.getFileName()
if (uri) {
uri = path.relative(cwd, uri)
}
}
return { line, uri }
}
function getStackframe() {
var stackframes = StackTrace.getSync();
if (stackframes.length > 2) {
return stackframes[2];
} else {
return stackframes[0];
}
}
static getStackTrace(deep: number = 2): ContextTrace {
const stackList: StackTrace.StackFrame[] = StackTrace.getSync();
const stackInfo: StackTrace.StackFrame = stackList[deep];
const lineNumber: number = stackInfo.lineNumber;
const columnNumber: number = stackInfo.columnNumber;
const fileName: string = stackInfo.fileName;
const extnameLength: number = Path.extname(fileName).length;
let basename: string = Path.basename(fileName);
basename = basename.substr(0, basename.length - extnameLength);
const context: string = _.upperFirst(_.camelCase(basename));
return new ContextTrace(context, fileName, lineNumber, columnNumber);
}
const shouldSkipProxy = () => {
if (global.reduxReport.__inProgress || global.reduxReport.__reducerInProgress) return true
if (!global.reduxReport.__skipAccessOriginCheck) {
const stackFrames = StackTrace.getSync()
const initiatingFunc =
stackFrames[stackFrames.findIndex(s => s.functionName === "Object.get") + 1]
const initiatingFuncNotLocal =
!!initiatingFunc &&
initiatingFunc.fileName &&
(initiatingFunc.fileName.match(/\.\/~\/|\/node_modules\//) ||
initiatingFunc.fileName.match(/extension:\/\//))
if (!!initiatingFuncNotLocal) return true
}
return false
}
export function _warning(
{
warn,
errorHandling,
formatErrors
}: {
warn: Print,
errorHandling: "warn" | "throw",
formatErrors: boolean
},
msg: string[]
): void {
if (errorHandling === "throw") error(msg);
const trace = Stacktrace.getSync()
.map(f => formatStackFrame(["file", "func", "line", "col"], f))
.slice(1);
formatErrors ? warn(formatWarnFmt(msg, trace)) : warn(formatWarn(msg));
}