UNPKG

n8n

Version:

n8n Workflow Automation Tool

2 lines (1 loc) 2.84 kB
export declare const SANDBOX_POLYFILLS = "\nif (typeof TransformStream === 'undefined') {\n\tglobalThis.TransformStream = function() {};\n\tglobalThis.ReadableStream = function() {};\n\tglobalThis.WritableStream = function() {};\n\tglobalThis.TextEncoder = function() { this.encode = function(s) { return s; }; };\n\tglobalThis.TextDecoder = function() { this.decode = function(s) { return s; }; };\n}\nif (typeof URL === 'undefined') {\n\tglobalThis.URL = function(u) { this.href = u; this.toString = function() { return u; }; };\n}\nif (typeof AbortController === 'undefined') {\n\tglobalThis.AbortController = function() { this.signal = {}; this.abort = function() {}; };\n}\nif (typeof Event === 'undefined') {\n\tglobalThis.Event = function(type) { this.type = type; };\n}\nif (typeof EventTarget === 'undefined') {\n\tglobalThis.EventTarget = function() {\n\t\tthis._listeners = {};\n\t};\n\tEventTarget.prototype.addEventListener = function(type, fn) {\n\t\tif (!this._listeners[type]) this._listeners[type] = [];\n\t\tthis._listeners[type].push(fn);\n\t};\n\tEventTarget.prototype.removeEventListener = function(type, fn) {\n\t\tif (!this._listeners[type]) return;\n\t\tthis._listeners[type] = this._listeners[type].filter(function(f) { return f !== fn; });\n\t};\n\tEventTarget.prototype.dispatchEvent = function() { return true; };\n}\nif (typeof CustomEvent === 'undefined') {\n\tglobalThis.CustomEvent = function(type, opts) {\n\t\tthis.type = type;\n\t\tthis.detail = opts && opts.detail;\n\t};\n}\nif (typeof MessageEvent === 'undefined') {\n\tglobalThis.MessageEvent = function(type, opts) {\n\t\tthis.type = type;\n\t\tthis.data = opts && opts.data;\n\t};\n}\nif (typeof Headers === 'undefined') {\n\tglobalThis.Headers = function(init) {\n\t\tthis._headers = {};\n\t\tif (init) for (var k in init) this._headers[k.toLowerCase()] = init[k];\n\t};\n\tHeaders.prototype.get = function(k) { return this._headers[k.toLowerCase()] || null; };\n\tHeaders.prototype.set = function(k, v) { this._headers[k.toLowerCase()] = v; };\n\tHeaders.prototype.has = function(k) { return k.toLowerCase() in this._headers; };\n}\nif (typeof Request === 'undefined') {\n\tglobalThis.Request = function(url) { this.url = url; };\n}\nif (typeof Response === 'undefined') {\n\tglobalThis.Response = function(body) { this.body = body; };\n\tResponse.json = function(data) { return new Response(JSON.stringify(data)); };\n}\nif (typeof console === 'undefined') {\n\tglobalThis.console = { log: function() {}, warn: function() {}, error: function() {} };\n}\nif (typeof setTimeout === 'undefined') {\n\tglobalThis.setTimeout = function(fn) { fn(); return 0; };\n\tglobalThis.clearTimeout = function() {};\n}\nif (typeof fetch === 'undefined') {\n\tglobalThis.fetch = function() { throw new Error('fetch is not available in the sandbox'); };\n}\n";