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SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const { type } = require('os');\nvar path = require('path');\n//var addon = require(path.join(__dirname, 'build', 'Release', 'rpi-ws281x.node'));\nvar addon = require('bindings')('rpi-ws281x.node');\n\nclass Module {\n\tconstructor() {\n\t\tthis.map = undefined;\n\t\tthis.leds = undefined;\n\n\t\tfunction cleanup() {\n\t\t\taddon.reset();\n\t\t\tprocess.exit();\n\t\t}\n\n\t\tprocess.on('SIGUSR1', cleanup);\n\t\tprocess.on('SIGUSR2', cleanup);\n\t\tprocess.on('SIGINT', cleanup);\n\t\tprocess.on('SIGTERM', cleanup);\n\t}\n\n\tconfigure(options) {\n\t\tvar { width, height, map, gamma, leds, ...options } = options;\n\n\t\tthis.leds = undefined;\n\t\tthis.map = undefined;\n\n\t\tlet isIntArray = a => {\n\t\t\treturn a instanceof Uint8Array || a instanceof Uint16Array || a instanceof Uint32Array;\n\t\t};\n\n\t\t// Generate a gamma table for a specific gamma value\n\t\tlet gammaTable = gamma => {\n\t\t\tconst table = new Uint8Array(256);\n\n\t\t\tfor (let i = 0; i < 256; i++) {\n\t\t\t\ttable[i] = Math.min(255, Math.round(Math.pow(i / 255, gamma) * 255));\n\t\t\t}\n\n\t\t\treturn table;\n\t\t};\n\n\t\tlet convertToUint8Array = input => {\n\t\t\tif (input instanceof Uint8Array) {\n\t\t\t\treturn input;\n\t\t\t}\n\n\t\t\tif (input instanceof Uint32Array) {\n\t\t\t\treturn new Uint8Array(input);\n\t\t\t}\n\n\t\t\tif (input instanceof Uint16Array) {\n\t\t\t\treturn new Uint8Array(input);\n\t\t\t}\n\n\t\t\treturn null;\n\t\t};\n\n\t\tif (map instanceof Uint32Array) {\n\t\t\tif (map.length != leds) {\n\t\t\t\tthrow new Error('Pixel mapping array must be of the same size as the number of leds.');\n\t\t\t}\n\n\t\t\tthis.map = map;\n\t\t}\n\n\t\tif (width != undefined || height != undefined) {\n\t\t\tif (width == undefined || height == undefined) {\n\t\t\t\tthrow new Error('Must specify both width and height.');\n\t\t\t}\n\n\t\t\tif (leds != undefined) {\n\t\t\t\tthrow new Error('Please do not specify leds when both width and height are specified.');\n\t\t\t}\n\n\t\t\tleds = width * height;\n\n\t\t\tif (this.map == undefined && typeof map == 'string') {\n\t\t\t\tif (map == 'alternating-matrix' || map == 'serpentine') {\n\t\t\t\t\tmap = new Uint32Array(width * height);\n\n\t\t\t\t\tfor (var i = 0; i < map.length; i++) {\n\t\t\t\t\t\tvar row = Math.floor(i / width),\n\t\t\t\t\t\t\tcol = i % width;\n\n\t\t\t\t\t\tif (row % 2 === 0) {\n\t\t\t\t\t\t\tmap[i] = i;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmap[i] = (row + 1) * width - (col + 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.map = map;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Make sure the number of leds are specified\n\t\tif (leds == undefined) {\n\t\t\tthrow new Error('Number of leds must be defined. Either by leds or by width and height.');\n\t\t}\n\n\t\t// Handle gamma correction. Either a number or a an array with 256 entries.\n\t\tif (gamma != undefined) {\n\t\t\tif (typeof gamma === 'number') {\n\t\t\t\tif (gamma < 0) {\n\t\t\t\t\tthrow new Error('Gamma must be a positive number.');\n\t\t\t\t}\n\t\t\t\toptions.gamma = gammaTable(gamma);\n\t\t\t} else if (gamma instanceof Uint8Array || gamma instanceof Uint32Array || gamma instanceof Uint16Array) {\n\t\t\t\tif (gamma.length != 256) {\n\t\t\t\t\tthrow new Error('Gamma table must have 256 entries.');\n\t\t\t\t}\n\t\t\t\toptions.gamma = convertToUint8Array(gamma);\n\t\t\t}\n\t\t}\n\n\t\t// Final check that the gamma table is a Uint8Array\n\t\tif (options.gamma) {\n\t\t\tif (!(options.gamma instanceof Uint8Array)) {\n\t\t\t\tthrow new Error('Gamma table must be a Uint8Array with 256 entries.');\n\t\t\t}\n\t\t}\n\n\n\t\tthis.leds = leds;\n\n\t\taddon.configure({ ...options, leds: leds });\n\t}\n\n\treset() {\n\t\tif (this.leds == undefined) {\n\t\t\tthrow new Error('ws281x not configured.');\n\t\t}\n\t\taddon.reset();\n\t}\n\n\tsleep(ms) {\n\t\taddon.sleep(ms);\n\t}\n\n\trender(pixels) {\n\t\tif (this.leds == undefined) {\n\t\t\tthrow new Error('ws281x not configured.');\n\t\t}\n\n\t\tif (!(pixels instanceof Uint32Array)) {\n\t\t\tthrow new Error('Pixels must be of type Uint32Array in render()');\n\t\t}\n\n\t\tif (this.leds != pixels.length) {\n\t\t\tthrow new Error('Pixels must be of same length as number of leds in render()');\n\t\t}\n\n\t\tif (this.map && this.map instanceof Uint32Array) {\n\t\t\tvar mapped = new Uint32Array(this.map.length);\n\n\t\t\tfor (var i = 0; i < mapped.length; i++) {\n\t\t\t\tmapped[i] = pixels[this.map[i]];\n\t\t\t}\n\n\t\t\taddon.render(mapped);\n\t\t} else {\n\t\t\taddon.render(pixels);\n\t\t}\n\t}\n}\n\nmodule.exports = new Module();\n"]}