{"_id":"@andrewray/glsl-token-descope","_rev":"2-763952ad0304847bc87e8e190abbd3e1","name":"@andrewray/glsl-token-descope","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.2":{"name":"@andrewray/glsl-token-descope","version":"1.0.2","description":"\"Descope\" an array of GLSL tokens such that they can be safely inlined alongside within another shader without causing any global variable conflicts.","main":"index.js","license":"MIT","scripts":{"test":"node test/index.js | tap-spec","eyeball":"node test/eyeball.js"},"author":{"name":"Hugh Kennedy","email":"hughskennedy@gmail.com","url":"http://hughsk.io/"},"dependencies":{"@andrewray/glsl-token-assignments":"^2.0.2","glsl-token-depth":"^1.1.0","glsl-token-properties":"^1.0.0","glsl-token-scope":"^1.1.0"},"devDependencies":{"6to5":"^2.5.0","chalk":"^0.5.1","glsl-token-string":"^1.0.0","glsl-tokenizer":"^2.0.0","tap-spec":"^2.1.2","tape":"^3.0.3"},"repository":{"type":"git","url":"git+https://github.com/AndrewRayCode/glsl-token-descope.git"},"keywords":["ecosystem:stackgl"],"homepage":"https://github.com/stackgl/glsl-token-descope","bugs":{"url":"https://github.com/stackgl/glsl-token-descope/issues"},"gitHead":"d7e1f73bdf24a492de3f4de1511b4fc076c27972","_id":"@andrewray/glsl-token-descope@1.0.2","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"andrewray","email":"me@andrewray.me"},"dist":{"integrity":"sha512-Uv6Blf13I4pxMWxHuQBr6YxHAFbOZNmTbAPorH7PgawrcHc5LU2a5Ich2vkQUWJCkHS3J4fWzORKQipp483PAg==","shasum":"749ba8ed03c79f464c5c628720505b2c9f54e949","tarball":"https://registry.npmjs.org/@andrewray/glsl-token-descope/-/glsl-token-descope-1.0.2.tgz","fileCount":7,"unpackedSize":7707,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcK/rhCRA9TVsSAnZWagAAwI0P/2BrDFeIousaGL57AJyX\n3DtvV6bnj0kukqMfwc03RcCVpuMCKscDxWIk+AOkwzxg4jUXZZQBUOcEJMD8\n267bAe9GGKjk+03KbzGP4GTCHuoyiXdZ6xqrqL1gtgoUrVzOH3LizEaaarT7\no8LTS0R7xHaTM4EHSIlBnTVgxXnUgdyB8JIj0TixNFJxFei/y7lfxIWAp9A6\nny+k+7ONF/QcrFXhTAl8pjos2tdsD+aHRcloU1r1j3CZYji8Y8fJX190Zp/A\nATi8mO0aoKI07fm/hGwz/9mZ7ybrgm9EpWyGLObN3UuPRSho09JcVXcIL9B2\n/yBlq1odGZZAWOk4LtalWiBioUJUbWkyaPJqLEojDmPY1kwtLV2WEiB8Fnj8\n5vUdWkVl9ZeCknEmGUmSetJ/R3sPvi55Gg1AnWSasl9kRzRqEPmb6iUTOUU/\ngybF7lYqbfTgnxtJC0k7cBdX2VglBoEkdxo62ioEMl7Qf+mv5BRWga0+NZ7Y\nHZ0+PewlkYiDaAs89I/6eBIDBKirsfxne6jYlr8VMrjR/ggiX9eRwtQ3mXls\nla4/d/Tx/6C8UrjA9F78ipxNdbffITwXQ3x7CpVte0eeJId18A/2HcpdhORu\nskQUsyYCTJCGzQ5JAjhn83FLbImhym4EnOcWLtEHGg9wCDDeuk3Gkn9KSAIW\ndB0V\r\n=w4SA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICOkfhQMW/P+WKMS4OrgoaASztrNtwL3HcWNI8H7VvwnAiAHmhQWvhC30kB1S4r6JWwDNs0Ic8zn0lKWlwDThK0i9A=="}]},"maintainers":[{"name":"andrewray","email":"me@andrewray.me"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/glsl-token-descope_1.0.2_1546386144409_0.1513607313433396"},"_hasShrinkwrap":false},"1.0.3":{"name":"@andrewray/glsl-token-descope","version":"1.0.3","description":"\"Descope\" an array of GLSL tokens such that they can be safely inlined alongside within another shader without causing any global variable conflicts.","main":"index.js","license":"MIT","scripts":{"test":"node test/index.js | tap-spec","eyeball":"node test/eyeball.js"},"author":{"name":"Hugh Kennedy","email":"hughskennedy@gmail.com","url":"http://hughsk.io/"},"dependencies":{"@andrewray/glsl-token-assignments":"^2.0.2","glsl-token-depth":"^1.1.0","glsl-token-properties":"^1.0.0","glsl-token-scope":"^1.1.0"},"devDependencies":{"6to5":"^2.5.0","chalk":"^0.5.1","glsl-token-string":"^1.0.0","glsl-tokenizer":"^2.0.0","tap-spec":"^2.1.2","tape":"^3.0.3"},"repository":{"type":"git","url":"git+https://github.com/AndrewRayCode/glsl-token-descope.git"},"keywords":["ecosystem:stackgl"],"homepage":"https://github.com/stackgl/glsl-token-descope","bugs":{"url":"https://github.com/stackgl/glsl-token-descope/issues"},"gitHead":"1b64ea90e5218ad4cb7ab0a615c901505ff0b773","_id":"@andrewray/glsl-token-descope@1.0.3","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"andrewray","email":"me@andrewray.me"},"dist":{"integrity":"sha512-J2ML0VhdxrfEsiOIr/bzFNWNiBxE8Pv1F3PywifZmGLwBfbXZ5Nt8axHo6BpJHT47ElJOCaT0/3EogUTdgRBEw==","shasum":"e5096a2e297b46d32abca5e3390c23795cfdd7c7","tarball":"https://registry.npmjs.org/@andrewray/glsl-token-descope/-/glsl-token-descope-1.0.3.tgz","fileCount":7,"unpackedSize":7718,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcK/xfCRA9TVsSAnZWagAAmwcQAIH1u9yMIU+jjWGuraKp\nx+FRzyIrm2KLqk2gA/tUadz7oYgKSi3huKPMNLn4Bk/izrPJw6aOg1ojSKWm\nbWjcr4m/0uZgXOz2EgMZKCrHhozvuI3vXFIW+gD8hATntqMIjF1rcMIZ2sXx\nPpnkViE35xRJV8LG+5uMdDDxZjg9PnPiaszD4/jr1LrsqXakhRdGyc4FXdTT\nxo0iRFFkX6RMJp40/pO0W5vXVw5jaN6HzM76zkgXolL91uNkXEpfWEoatSrU\nrhWEcyARd1Ab0gjPxmltkbeaYdvu0LhTIAjRYHybUmLDkewi9Y6c2F+9XxX9\nrMtn3dvCUxIdmlILl7/Ia8eu8tpd4lPNYNHFVDg3xwnIcwjfbS89ncDujOaY\n+nxGUYUqMDzf60h+iea32CzSf9mgC1usWyshU8glPO+f/KIfwHSBcTd/x2vU\ndnHDaTACxvbsX28QT3LnUaX68ftiu3NruX13XG4oAauo1tUSo9y2ebitLQGh\nxMboehEymR1fWVF12g4Kug7rcNRH/i2EPyrbkM8eh6bt3zeG3zCxGvXtaxg+\n7fzInLkVxdGOMrB4lSb1ml8oPoiUfn6Rtt+jTcOxcVfxOphJDESXHG7STFX6\nkgNXh3wPAaPTeCOoVJYqVVGuhARZ14lh0v2OI/3keKDm8auHj+/P5zX5Yy98\neHPv\r\n=GqPD\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC91Lo2+ilPbygJYQ7D1H1rGFu+nNPx+LpUbTspQaq4SgIgB5S4dNlPH2Qik/aE5y7SI9F8WuSlnuEHaWslFGbPtho="}]},"maintainers":[{"name":"andrewray","email":"me@andrewray.me"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/glsl-token-descope_1.0.3_1546386526451_0.7173220459527176"},"_hasShrinkwrap":false}},"time":{"created":"2019-01-01T23:42:24.231Z","1.0.2":"2019-01-01T23:42:24.562Z","modified":"2022-04-04T14:01:49.744Z","1.0.3":"2019-01-01T23:48:46.655Z"},"maintainers":[{"name":"andrewray","email":"me@andrewray.me"}],"description":"\"Descope\" an array of GLSL tokens such that they can be safely inlined alongside within another shader without causing any global variable conflicts.","homepage":"https://github.com/stackgl/glsl-token-descope","keywords":["ecosystem:stackgl"],"repository":{"type":"git","url":"git+https://github.com/AndrewRayCode/glsl-token-descope.git"},"author":{"name":"Hugh Kennedy","email":"hughskennedy@gmail.com","url":"http://hughsk.io/"},"bugs":{"url":"https://github.com/stackgl/glsl-token-descope/issues"},"license":"MIT","readme":"# glsl-token-descope\n\n[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)\n\n\"Descope\" an array of GLSL tokens such that they can be safely inlined alongside\nwithin another shader without causing any global variable conflicts.\n\nUseful for modularising GLSL source files, e.g. as is done in\n[glslify](http://github.com/stackgl/glslify), but should be useful in other\ntools too.\n\nWritten with WebGL's GLSL syntax in mind – all the same, pull requests to\nsupport other variants would be much appreciated :)\n\n## Usage\n\n[![NPM](https://nodei.co/npm/glsl-token-descope.png)](https://nodei.co/npm/glsl-token-descope/)\n\n### `descope(tokens, [rename(name)])`\n\nTakes an array of GLSL `tokens` produced by\n[glsl-tokenizer](http://github.com/stackgl/glsl-tokenizer) and renames variables\nto avoid global conflicts by modifying their \"data\" property in-place.\n\nFor example:\n\n``` javascript\nvar tokenize  = require('glsl-tokenizer/string')\nvar descope   = require('glsl-token-descope')\nvar stringify = require('glsl-token-string')\n\nvar src = `\nprecision mediump float;\n\nuniform mat4  top1;\nuniform float top2;\n\nvoid main() {\n  float x = 1.0;\n  gl_FragColor = vec4(vec3(x), top2);\n}\n`.trim()\n\nvar tokens = tokenize(src)\n\nconsole.log(stringify(descope(tokens)))\n```\n\nWhich should rename `main`, `top1` and `top2` to result in this output:\n\n``` glsl\nprecision mediump float;\n\nuniform mat4  top1_0;\nuniform float top2_1;\n\nvoid main_2() {\n  float x = 1.0;\n  gl_FragColor = vec4(vec3(x), top2_1);\n}\n```\n\nOptionally, you may pass in a custom `rename` function as `descope`'s second\nargument to choose how you rename your variables. For example, adding a custom\n`rename` function to the previous function:\n\n``` javascript\ndescope(tokens, function(name) {\n  return 'a_' + name\n})\n```\n\nWould result in the following shader:\n\n``` glsl\nprecision mediump float;\n\nuniform mat4  a_top1;\nuniform float a_top2;\n\nvoid a_main() {\n  float x = 1.0;\n  gl_FragColor = vec4(vec3(x), a_top2);\n}\n```\n\n## See Also\n\n* [glslify](http://github.com/stackgl/glslify)\n* [glsl-token-scope](http://github.com/stackgl/glsl-token-scope)\n* [glsl-token-depth](http://github.com/stackgl/glsl-token-depth)\n* [glsl-token-properties](http://github.com/stackgl/glsl-token-properties)\n* [glsl-token-assignments](http://github.com/stackgl/glsl-token-assignments)\n* [glsl-token-string](http://github.com/stackgl/glsl-token-string)\n\n## License\n\nMIT. See [LICENSE.md](http://github.com/stackgl/glsl-token-descope/blob/master/LICENSE.md) for details.\n","readmeFilename":"README.md"}