{"version":3,"sources":["../../node_modules/node-libs-browser/node_modules/process/browser.js","../src/logger.ts","../src/index.ts","../common/util.ts","register.ts"],"names":["cachedSetTimeout","cachedClearTimeout","process","module","exports","defaultSetTimout","Error","defaultClearTimeout","runTimeout","fun","setTimeout","e","call","runClearTimeout","marker","clearTimeout","currentQueue","queue","draining","queueIndex","cleanUpNextTick","length","concat","drainQueue","timeout","len","run","Item","array","noop","nextTick","args","Array","arguments","i","push","prototype","apply","title","env","argv","version","versions","on","addListener","once","off","removeListener","removeAllListeners","emit","prependListener","prependOnceListener","listeners","name","binding","cwd","chdir","dir","umask"],"mappings":";;AACA,IAOIA,EACAC,EARAC,EAAUC,OAAOC,QAAU,GAU/B,SAASC,IACC,MAAA,IAAIC,MAAM,mCAEpB,SAASC,IACC,MAAA,IAAID,MAAM,qCAsBpB,SAASE,EAAWC,GACZT,GAAAA,IAAqBU,WAEdA,OAAAA,WAAWD,EAAK,GAGvB,IAACT,IAAqBK,IAAqBL,IAAqBU,WAEzDA,OADPV,EAAmBU,WACZA,WAAWD,EAAK,GAEvB,IAEOT,OAAAA,EAAiBS,EAAK,GAC/B,MAAME,GACA,IAEOX,OAAAA,EAAiBY,KAAK,KAAMH,EAAK,GAC1C,MAAME,GAEGX,OAAAA,EAAiBY,KAAK,KAAMH,EAAK,KAMpD,SAASI,EAAgBC,GACjBb,GAAAA,IAAuBc,aAEhBA,OAAAA,aAAaD,GAGpB,IAACb,IAAuBM,IAAwBN,IAAuBc,aAEhEA,OADPd,EAAqBc,aACdA,aAAaD,GAEpB,IAEOb,OAAAA,EAAmBa,GAC5B,MAAOH,GACD,IAEOV,OAAAA,EAAmBW,KAAK,KAAME,GACvC,MAAOH,GAGEV,OAAAA,EAAmBW,KAAK,KAAME,MAjEhD,WACO,IAEId,EADsB,mBAAfU,WACYA,WAEAL,EAEzB,MAAOM,GACLX,EAAmBK,EAEnB,IAEIJ,EADwB,mBAAjBc,aACcA,aAEAR,EAE3B,MAAOI,GACLV,EAAqBM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M,KAM5D,QAAA,WAAa,WACpB,IAAA,EACA,IACI,IAAA,EAAK,SAAS,eAAe,iBAC/B,IAAC,EACG,MAAA,IAAI,MAAM,sBAEZ,IAAA,EAAQ,EAAG,aAAa,iBAC1B,IAAC,EACG,MAAA,IAAI,MAAM,oBAElB,EAAU,KAAK,MAAM,GACrB,MAAO,GACP,EAAU,GAGN,IACA,EADS,IAAI,gBAAgB,SAAS,QACnB,IAAI,WAWzB,GAVA,IACF,EAAO,EAAA,EAAA,GACF,GACA,KAAK,MAAM,UAIc,IAArB,EAAQ,WACjB,EAAA,OAAO,MAAQ,EAAQ,UAErB,EAAQ,KAAM,CACV,IAAA,EAAQ,SAAS,SAAS,QAAQ,OAAQ,IAAI,MAAM,KAC1D,EAAM,EAAM,OAAS,GAAK,EAAQ,KAC5B,IAAA,EAAM,IAAI,IAAI,SAAS,OAAS,IAAM,EAAM,KAAK,MACvD,EAAQ,KAAO,QAAA,UAAU,EAAI,UAAU,GAKlC,OAFP,EAAA,OAAO,MAAM,cAAe,EAAA,MAAM,UAAW,IAEtC;;AC9DR,aAAA,OAAA,eAAA,QAAA,aAAA,CAAA,OAAA,IAbD,IAAA,EAAA,QAAA,kBAEM,EAAU,EAAA,aAEhB,GAAI,kBAAmB,UAAW,CAC1B,IAAA,EAAO,EAAA,UAAa,EAAQ,KAAI,WAAW,EAAQ,OAAM,0BAC/D,UAAU,cACP,SAAS,EAAM,CACd,MAAO,EAAQ,MAAQ,MAExB,KAAK,WACJ,QAAQ,IAAI","file":"register.js","sourceRoot":"../src/browser","sourcesContent":["// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // 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\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // 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.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","// tslint:disable no-console\n\nexport enum Level {\n\tTrace,\n\tDebug,\n\tInfo,\n\tWarning,\n\tError,\n}\n\nexport class Field {\n\tpublic constructor(\n\t\tpublic readonly identifier: string,\n\t\tpublic readonly value: T,\n\t) { }\n\n\tpublic toJSON(): object {\n\t\treturn {\n\t\t\tidentifier: this.identifier,\n\t\t\tvalue: this.value,\n\t\t};\n\t}\n}\n\nexport class Time {\n\tpublic constructor(\n\t\tpublic readonly expected: number,\n\t\tpublic readonly ms: number,\n\t) { }\n}\n\nexport type Argument = any; // tslint:disable-line no-any\n\n/**\n * `undefined` is allowed to make it easier to conditionally display a field.\n * For example: `error && field(\"error\", error)`\n */\nexport type FieldArray = Array | undefined>;\n\n/**\n * Functions can be used to remove the need to perform operations when the\n * logging level won't output the result anyway.\n */\nexport type LogCallback = () => [string, ...FieldArray];\n\nexport const time = (expected: number): Time => {\n\treturn new Time(expected, Date.now());\n};\n\nexport const field = (name: string, value: T): Field => {\n\treturn new Field(name, value);\n};\n\nexport type Extender = (msg: {\n\tmessage: string,\n\tlevel: Level,\n\ttype: \"trace\" | \"info\" | \"warn\" | \"debug\" | \"error\",\n\tfields?: FieldArray,\n\tsection?: string,\n}) => void;\n\n/**\n * Format and build a *single* log entry at a time.\n */\nexport abstract class Formatter {\n\tprivate format = \"\";\n\tprivate args = [];\n\tprivate fields = []>[];\n\tprivate readonly minimumTagWidth = 5;\n\n\t/**\n\t * formatType is used for the strings returned from style() and reset().\n\t */\n\tpublic constructor(\n\t\tprivate readonly formatType: string = \"%s\",\n\t\tprivate readonly colors: boolean = true,\n\t) {}\n\n\t/**\n\t * Add a tag.\n\t */\n\tpublic tag(name: string, color: string): void {\n\t\tfor (let i = name.length; i < this.minimumTagWidth; ++i) {\n\t\t\tname += \" \";\n\t\t}\n\t\tthis.push(name + \" \", color);\n\t}\n\n\t/**\n\t * Add a field or an argument. Arguments will display inline in the order they\n\t * were pushed. Fields will display differently based on the formatter. Fields\n\t * cannot have custom colors.\n\t */\n\tpublic push(fields: Field[]): void;\n\tpublic push(arg: Argument, color?: string, weight?: string): void;\n\tpublic push(arg: Argument | Field[], color?: string, weight?: string): void {\n\t\tif (Array.isArray(arg) && arg.every((a) => a instanceof Field)) {\n\t\t\treturn void this.fields.push(...arg);\n\t\t}\n\t\tif (this.colors) {\n\t\t\tthis.format += `${this.formatType}${this.getType(arg)}${this.formatType}`;\n\t\t\tthis.args.push(this.style(color, weight), arg, this.reset());\n\t\t} else {\n\t\t\tthis.format += `${this.getType(arg)}`;\n\t\t\tthis.args.push(arg);\n\t\t}\n\t}\n\n\t/**\n\t * Write everything out and reset state.\n\t */\n\tpublic write(): void {\n\t\tthis.doWrite(...this.flush());\n\t}\n\n\t/**\n\t * Return current values and reset state.\n\t */\n\tprotected flush(): [string, string[], Field[]] {\n\t\tconst args = [this.format, this.args, this.fields] as [string, string[], Field[]];\n\t\tthis.format = \"\";\n\t\tthis.args = [];\n\t\tthis.fields = [];\n\t\treturn args;\n\t}\n\n\t/**\n\t * Return a string that applies the specified color and weight.\n\t */\n\tprotected abstract style(color?: string, weight?: string): string;\n\n\t/**\n\t * Return a string that resets all styles.\n\t */\n\tprotected abstract reset(): string;\n\n\t/**\n\t * Write everything out.\n\t */\n\tprotected abstract doWrite(format: string, args: string[], fields: Field[]): void;\n\n\t/**\n\t * Get the format string for the value type.\n\t */\n\tprivate getType(arg: Argument): string {\n\t\tswitch (typeof arg) {\n\t\t\tcase \"object\": return \"%o\";\n\t\t\tcase \"number\": return \"%d\";\n\t\t\tdefault: return \"%s\";\n\t\t}\n\t}\n}\n\n/**\n * Display logs in the browser using CSS in the output. Fields are displayed on\n * individual lines within a group.\n */\nexport class BrowserFormatter extends Formatter {\n\tpublic constructor() {\n\t\tsuper(\"%c\");\n\t}\n\n\tprotected style(color?: string, weight?: string): string {\n\t\treturn (color ? `color: ${color};` : \"\")\n\t\t\t+ (weight ? `font-weight: ${weight};` : \"\");\n\t}\n\n\tprotected reset(): string {\n\t\treturn this.style(\"inherit\", \"normal\");\n\t}\n\n\tpublic doWrite(format: string, args: string[], fields: Array>): void {\n\t\tconsole.groupCollapsed(format, ...args);\n\t\tfields.forEach((field) => {\n\t\t\tthis.push(field.identifier, \"#3794ff\", \"bold\");\n\t\t\tif (typeof field.value !== \"undefined\" && field.value.constructor && field.value.constructor.name) {\n\t\t\t\tthis.push(` (${field.value.constructor.name})`);\n\t\t\t}\n\t\t\tthis.push(\": \");\n\t\t\tthis.push(field.value);\n\t\t\tconst flushed = this.flush();\n\t\t\tconsole.log(flushed[0], ...flushed[1]);\n\t\t});\n\t\tconsole.groupEnd();\n\t}\n}\n\n/**\n * Display logs on the command line using ANSI color codes. Fields are displayed\n * in a single stringified object inline.\n */\nexport class ServerFormatter extends Formatter {\n\tpublic constructor() {\n\t\tsuper(\"%s\", !!process.stdout.isTTY);\n\t}\n\n\tprotected style(color?: string, weight?: string): string {\n\t\treturn (weight === \"bold\" ? \"\\u001B[1m\" : \"\")\n\t\t\t+ (color ? this.hex(color) : \"\");\n\t}\n\n\tprotected reset(): string {\n\t\treturn \"\\u001B[0m\";\n\t}\n\n\tprivate hex(hex: string): string {\n\t\tconst [r, g, b] = this.hexToRgb(hex);\n\t\treturn `\\u001B[38;2;${r};${g};${b}m`;\n\t}\n\n\tprivate hexToRgb(hex: string): [number, number, number] {\n\t\tconst integer = parseInt(hex.substr(1), 16);\n\t\treturn [\n\t\t\t(integer >> 16) & 0xFF,\n\t\t\t(integer >> 8) & 0xFF,\n\t\t\tinteger & 0xFF,\n\t\t];\n\t}\n\n\tprotected doWrite(format: string, args: string[], fields: Array>): void {\n\t\tif (fields.length === 0) {\n\t\t\treturn console.log(format, ...args);\n\t\t}\n\t\tconst obj: { [key: string]: Argument} = {};\n\t\tfields.forEach((field) => obj[field.identifier] = field.value);\n\t\tconsole.log(format + \" %s%s%s\", ...args, this.style(\"#8c8c8c\"), JSON.stringify(obj), this.reset());\n\t}\n}\n\nexport class Logger {\n\tpublic level = Level.Info;\n\n\tprivate readonly nameColor?: string;\n\tprivate muted: boolean = false;\n\n\tpublic constructor(\n\t\tprivate _formatter: Formatter,\n\t\tprivate readonly name?: string,\n\t\tprivate readonly defaultFields?: FieldArray,\n\t\tprivate readonly extenders: Extender[] = [],\n\t) {\n\t\tif (name) {\n\t\t\tthis.nameColor = this.hashStringToColor(name);\n\t\t}\n\t\tif (typeof process !== \"undefined\" && typeof process.env !== \"undefined\") {\n\t\t\tswitch (process.env.LOG_LEVEL) {\n\t\t\t\tcase \"trace\": this.level = Level.Trace; break;\n\t\t\t\tcase \"debug\": this.level = Level.Debug; break;\n\t\t\t\tcase \"info\": this.level = Level.Info; break;\n\t\t\t\tcase \"warn\": this.level = Level.Warning; break;\n\t\t\t\tcase \"error\": this.level = Level.Error; break;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic set formatter(formatter: Formatter) {\n\t\tthis._formatter = formatter;\n\t}\n\n\t/**\n\t * Supresses all output\n\t */\n\tpublic mute(): void {\n\t\tthis.muted = true;\n\t}\n\n\tpublic extend(extender: Extender): void {\n\t\tthis.extenders.push(extender);\n\t}\n\n\tpublic info(fn: LogCallback): void;\n\tpublic info(message: string, ...fields: FieldArray): void;\n\tpublic info(message: LogCallback | string, ...fields: FieldArray): void {\n\t\tthis.handle({\n\t\t\ttype: \"info\",\n\t\t\tmessage,\n\t\t\tfields,\n\t\t\ttagColor: \"#008FBF\",\n\t\t\tlevel: Level.Info,\n\t\t});\n\t}\n\n\tpublic warn(fn: LogCallback): void;\n\tpublic warn(message: string, ...fields: FieldArray): void;\n\tpublic warn(message: LogCallback | string, ...fields: FieldArray): void {\n\t\tthis.handle({\n\t\t\ttype: \"warn\",\n\t\t\tmessage,\n\t\t\tfields,\n\t\t\ttagColor: \"#FF9D00\",\n\t\t\tlevel: Level.Warning,\n\t\t});\n\t}\n\n\tpublic trace(fn: LogCallback): void;\n\tpublic trace(message: string, ...fields: FieldArray): void;\n\tpublic trace(message: LogCallback | string, ...fields: FieldArray): void {\n\t\tthis.handle({\n\t\t\ttype: \"trace\",\n\t\t\tmessage,\n\t\t\tfields,\n\t\t\ttagColor: \"#888888\",\n\t\t\tlevel: Level.Trace,\n\t\t});\n\t}\n\n\tpublic debug(fn: LogCallback): void;\n\tpublic debug(message: string, ...fields: FieldArray): void;\n\tpublic debug(message: LogCallback | string, ...fields: FieldArray): void {\n\t\tthis.handle({\n\t\t\ttype: \"debug\",\n\t\t\tmessage,\n\t\t\tfields,\n\t\t\ttagColor: \"#84009E\",\n\t\t\tlevel: Level.Debug,\n\t\t});\n\t}\n\n\tpublic error(fn: LogCallback): void;\n\tpublic error(message: string, ...fields: FieldArray): void;\n\tpublic error(message: LogCallback | string, ...fields: FieldArray): void {\n\t\tthis.handle({\n\t\t\ttype: \"error\",\n\t\t\tmessage,\n\t\t\tfields,\n\t\t\ttagColor: \"#B00000\",\n\t\t\tlevel: Level.Error,\n\t\t});\n\t}\n\n\t/**\n\t * Returns a sub-logger with a name.\n\t * Each name is deterministically generated a color.\n\t */\n\tpublic named(name: string, ...fields: FieldArray): Logger {\n\t\tconst l = new Logger(this._formatter, name, fields, this.extenders);\n\t\tif (this.muted) {\n\t\t\tl.mute();\n\t\t}\n\t\treturn l;\n\t}\n\n\tprivate handle(options: {\n\t\ttype: \"trace\" | \"info\" | \"warn\" | \"debug\" | \"error\";\n\t\tmessage: string | LogCallback;\n\t\tfields?: FieldArray;\n\t\tlevel: Level;\n\t\ttagColor: string;\n\t}): void {\n\t\tif (this.level > options.level || this.muted) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet passedFields = options.fields || [];\n\t\tif (typeof options.message === \"function\") {\n\t\t\tconst values = options.message();\n\t\t\toptions.message = values.shift() as string;\n\t\t\tpassedFields = values as FieldArray;\n\t\t}\n\n\t\tconst fields = (this.defaultFields\n\t\t\t? passedFields.filter((f) => !!f).concat(this.defaultFields)\n\t\t\t: passedFields.filter((f) => !!f)) as Array>;\n\n\t\tconst now = Date.now();\n\t\tlet times: Array> = [];\n\t\tconst hasFields = fields && fields.length > 0;\n\t\tif (hasFields) {\n\t\t\ttimes = fields.filter((f) => f.value instanceof Time);\n\t\t\tthis._formatter.push(fields);\n\t\t}\n\n\t\tthis._formatter.tag(options.type, options.tagColor);\n\t\tif (this.name && this.nameColor) {\n\t\t\tthis._formatter.tag(this.name, this.nameColor);\n\t\t}\n\t\tthis._formatter.push(options.message);\n\t\tif (times.length > 0) {\n\t\t\ttimes.forEach((time) => {\n\t\t\t\tconst diff = now - time.value.ms;\n\t\t\t\tconst expPer = diff / time.value.expected;\n\t\t\t\tconst min = 125 * (1 - expPer);\n\t\t\t\tconst max = 125 + min;\n\t\t\t\tconst green = expPer < 1 ? max : min;\n\t\t\t\tconst red = expPer >= 1 ? max : min;\n\t\t\t\tthis._formatter.push(` ${time.identifier}=`, \"#3794ff\");\n\t\t\t\tthis._formatter.push(`${diff}ms`, this.rgbToHex(red > 0 ? red : 0, green > 0 ? green : 0, 0));\n\t\t\t});\n\t\t}\n\n\t\tthis._formatter.write();\n\n\t\tthis.extenders.forEach((extender) => {\n\t\t\textender({\n\t\t\t\tsection: this.name,\n\t\t\t\tfields: options.fields,\n\t\t\t\tlevel: options.level,\n\t\t\t\tmessage: options.message as string,\n\t\t\t\ttype: options.type,\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Hashes a string.\n\t */\n\tprivate djb2(str: string): number {\n\t\tlet hash = 5381;\n\t\tfor (let i = 0; i < str.length; i++) {\n\t\t\thash = ((hash << 5) + hash) + str.charCodeAt(i); /* hash * 33 + c */\n\t\t}\n\t\treturn hash;\n\t}\n\n\tprivate rgbToHex(r: number, g: number, b: number): string {\n\t\tconst integer = ((Math.round(r) & 0xFF) << 16)\n\t\t\t+ ((Math.round(g) & 0xFF) << 8)\n\t\t\t+ (Math.round(b) & 0xFF);\n\t\tconst str = integer.toString(16);\n\t\treturn \"#\" + \"000000\".substring(str.length) + str;\n\t}\n\n\t/**\n\t * Generates a deterministic color from a string using hashing.\n\t */\n\tprivate hashStringToColor(str: string): string {\n\t\tconst hash = this.djb2(str);\n\t\treturn this.rgbToHex(\n\t\t\t(hash & 0xFF0000) >> 16,\n\t\t\t(hash & 0x00FF00) >> 8,\n\t\t\thash & 0x0000FF,\n\t\t);\n\t}\n}\n\nexport const logger = new Logger(\n\ttypeof process === \"undefined\" || typeof process.stdout === \"undefined\"\n\t\t? new BrowserFormatter()\n\t\t: new ServerFormatter(),\n);\n","export * from \"./logger\";\n","import { logger, field } from \"@coder/logger\"\n\nexport interface Options {\n base: string\n commit: string\n logLevel: number\n pid?: number\n}\n\n/**\n * Split a string up to the delimiter. If the delimiter doesn't exist the first\n * item will have all the text and the second item will be an empty string.\n */\nexport const split = (str: string, delimiter: string): [string, string] => {\n const index = str.indexOf(delimiter)\n return index !== -1 ? [str.substring(0, index).trim(), str.substring(index + 1)] : [str, \"\"]\n}\n\nexport const plural = (count: number): string => (count === 1 ? \"\" : \"s\")\n\nexport const generateUuid = (length = 24): string => {\n const possible = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n return Array(length)\n .fill(1)\n .map(() => possible[Math.floor(Math.random() * possible.length)])\n .join(\"\")\n}\n\n/**\n * Remove extra slashes in a URL.\n */\nexport const normalize = (url: string, keepTrailing = false): string => {\n return url.replace(/\\/\\/+/g, \"/\").replace(/\\/+$/, keepTrailing ? \"/\" : \"\")\n}\n\n/**\n * Get options embedded in the HTML or query params.\n */\nexport const getOptions = (): T => {\n let options: T\n try {\n const el = document.getElementById(\"coder-options\")\n if (!el) {\n throw new Error(\"no options element\")\n }\n const value = el.getAttribute(\"data-settings\")\n if (!value) {\n throw new Error(\"no options value\")\n }\n options = JSON.parse(value)\n } catch (error) {\n options = {} as T\n }\n\n const params = new URLSearchParams(location.search)\n const queryOpts = params.get(\"options\")\n if (queryOpts) {\n options = {\n ...options,\n ...JSON.parse(queryOpts),\n }\n }\n\n if (typeof options.logLevel !== \"undefined\") {\n logger.level = options.logLevel\n }\n if (options.base) {\n const parts = location.pathname.replace(/^\\//g, \"\").split(\"/\")\n parts[parts.length - 1] = options.base\n const url = new URL(location.origin + \"/\" + parts.join(\"/\"))\n options.base = normalize(url.pathname, true)\n }\n\n logger.debug(\"got options\", field(\"options\", options))\n\n return options\n}\n","import { getOptions, normalize } from \"../common/util\"\n\nconst options = getOptions()\n\nif (\"serviceWorker\" in navigator) {\n const path = normalize(`${options.base}/static/${options.commit}/dist/serviceWorker.js`)\n navigator.serviceWorker\n .register(path, {\n scope: options.base || \"/\",\n })\n .then(function () {\n console.log(\"[Service Worker] registered\")\n })\n}\n"]}