Repository: Siorki/RegPack Branch: master Commit: a710c19a4ebe Files: 133 Total size: 423.1 KB Directory structure: gitextract_zqrzria2/ ├── .gitattributes ├── .gitignore ├── .gitignore.default ├── .npmignore ├── LICENSE ├── README.md ├── TestCases/ │ ├── audioContext_create1.js │ ├── audioContext_create2.js │ ├── audioContext_create3.js │ ├── audioContext_create4.js │ ├── double_renaming.js │ ├── gitHub#17-multipleContexts.js │ ├── gitHub#19-setInterval_declarationAlone.js │ ├── gitHub#19-setInterval_declarationAtBegin1.js │ ├── gitHub#19-setInterval_declarationAtBegin2.js │ ├── gitHub#19-setInterval_declarationAtEnd1.js │ ├── gitHub#19-setInterval_declarationAtEnd2.js │ ├── gitHub#19-setInterval_declarationChained1.js │ ├── gitHub#19-setInterval_declarationChained2.js │ ├── gitHub#19-setInterval_declarationInArray1.js │ ├── gitHub#19-setInterval_declarationInArray2.js │ ├── gitHub#19-setInterval_declarationInFunction1.js │ ├── gitHub#19-setInterval_declarationInFunction2.js │ ├── gitHub#19-setInterval_declarationInFunction3.js │ ├── gitHub#2-unicode.js │ ├── gitHub#30-webglContext_create_charset.js │ ├── gitHub#31-direct-hyphenBeginsBlock.js │ ├── gitHub#31-direct-hyphenEndsBlock.js │ ├── gitHub#31-direct-singleHyphen.js │ ├── gitHub#31-negated-hyphenBeginsBlock.js │ ├── gitHub#31-negated-hyphenEndsBlock.js │ ├── gitHub#31-negated-singleHyphen.js │ ├── gitHub#44-setInterval_arrowFunctionMultiParam.js │ ├── gitHub#44-setInterval_arrowFunctionNoParam.js │ ├── gitHub#44-setInterval_arrowFunctionSingleParam.js │ ├── gitHub#47-packer_from92AndReplace.js │ ├── gitHub#47-packer_from92NoReplace.js │ ├── gitHub#47-packer_from92ReplaceFails.js │ ├── gitHub#47-packer_from93AndReplace.js │ ├── gitHub#47-packer_from93NoReplace.js │ ├── gitHub#47-packer_rangesBeyond.js │ ├── gitHub#47-packer_to92AndReplace.js │ ├── gitHub#47-packer_to92NoReplace.js │ ├── gitHub#47-packer_to93AndReplace.js │ ├── gitHub#47-packer_to93NoReplace.js │ ├── gitHub#47-packer_to93ReplaceFails.js │ ├── gitHub#55-bothQuotesInUse.js │ ├── gitHub#55-quotesAsOnlyTokens.js │ ├── gitHub#55-sameStringInAllQuotes.js │ ├── gitHub#56-setInterval_arrowComplexValues.js │ ├── gitHub#56-setInterval_arrowMultipleValues.js │ ├── gitHub#56-setInterval_arrowNoValue.js │ ├── gitHub#56-setInterval_arrowOneValue.js │ ├── gitHub#56-setInterval_arrowSingleValue.js │ ├── gitHub#56-setInterval_standardComplexValues.js │ ├── gitHub#56-setInterval_standardMultipleValues.js │ ├── gitHub#56-setInterval_standardNoValue.js │ ├── gitHub#56-setInterval_standardOneValue.js │ ├── gitHub#56-setInterval_standardSingleValue.js │ ├── gitHub#57-templateLiteralOneVariable.js │ ├── gitHub#58-lettersOnly.js │ ├── gitHub#58-numberAsMostFrequent.js │ ├── gitHub#59-negatedRangeMerge-1vs3.js │ ├── gitHub#63-backtick2DContext.js │ ├── gitHub#63-backtickWebGLContext.js │ ├── gitHub#64-URIError.js │ ├── gitHub#65-backslash_invalidEscapeSequence.js │ ├── gitHub#73-backslash_unexpandedToken.js │ ├── gitHub#83-backslash_largerOutput.js │ ├── gitHub#83-packer_9Alone.js │ ├── gitHub#85-backslashSequence.js │ ├── gitHub#85-flappyDragon.js │ ├── gitHub#9-hashloop.js │ ├── hash_using_length.js │ ├── webglContext_create1.js │ ├── webglContext_create2.js │ ├── webglContext_create3.js │ ├── webglContext_create4.js │ ├── webglContext_create5.js │ ├── webglContext_create6.js │ └── webglContext_substringHash.js ├── bin/ │ └── regpack ├── changelog.txt ├── contextDescriptor_browser.js ├── contextDescriptor_node.js ├── package.json ├── packerData.js ├── patternViewer.js ├── regPack.html ├── regPack.js ├── shapeShifter.js ├── stringHelper.js ├── tests/ │ ├── allTests.js │ ├── documentMock.js │ ├── runBenchmark.js │ ├── testAudioContextCreate.js │ ├── testIssue0002_UnicodeSupport.js │ ├── testIssue0009_HashLoopVariable.js │ ├── testIssue0017_MultipleContexts.js │ ├── testIssue0019_setInterval.js │ ├── testIssue0030_webGLContextCreate.js │ ├── testIssue0031_hyphenInRegex.js │ ├── testIssue0042_patternViewer.js │ ├── testIssue0044_setIntervalArrowFunction.js │ ├── testIssue0045_closingBracket.js │ ├── testIssue0047_EscapeInCharClass.js │ ├── testIssue0050_unicodeSurrogate.js │ ├── testIssue0055_stringDelimiters.js │ ├── testIssue0056_setIntervalDefaultParams.js │ ├── testIssue0057_replacementInString.js │ ├── testIssue0058_numberAsLoopVariable.js │ ├── testIssue0059_negatedRangeMerge.js │ ├── testIssue0063_backtickFunctionParam.js │ ├── testIssue0064_utf8EncodeURI.js │ ├── testIssue0065_invalidEscapeSequence.js │ ├── testIssue0072_setIntervalNoInitCode.js │ ├── testIssue0074_keepWhiteSpaceSeparator.js │ ├── testIssue0076_listVariablesInString.js │ ├── testIssue0079_CandXMLComments.js │ ├── testIssue0082_backticksInTemplateLiterals.js │ ├── testIssue0083_backslashToken.js │ ├── testIssue0085_backslashSequenceLength.js │ ├── testIssue0087_firstCharacterInPattern.js │ ├── testIssue0088_setIntervalAllocateVariable.js │ ├── testIssue0089_emptyThermalMapping.js │ ├── testIssue0094_missingVariableBlock.js │ ├── testIssue0096_multiLineMinification.js │ ├── testPackingConsistency.js │ ├── testStringHelper.js │ └── testWebGLContextCreate.js ├── thermalViewer.js └── wiki_images/ ├── thermal_view2.xcf └── thermal_view4.xcf ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitattributes ================================================ # Auto detect text files and perform LF normalization * text=auto # Custom for Visual Studio *.cs diff=csharp *.sln merge=union *.csproj merge=union *.vbproj merge=union *.fsproj merge=union *.dbproj merge=union # Standard to msysgit *.doc diff=astextplain *.DOC diff=astextplain *.docx diff=astextplain *.DOCX diff=astextplain *.dot diff=astextplain *.DOT diff=astextplain *.pdf diff=astextplain *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain bin/regpack -crlf ================================================ FILE: .gitignore ================================================ node_modules ================================================ FILE: .gitignore.default ================================================ ################# ## Eclipse ################# *.pydevproject .project .metadata bin/ tmp/ *.tmp *.bak *.swp *~.nib local.properties .classpath .settings/ .loadpath # External tool builders .externalToolBuilders/ # Locally stored "Eclipse launch configurations" *.launch # CDT-specific .cproject # PDT-specific .buildpath ################# ## Visual Studio ################# ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. # User-specific files *.suo *.user *.sln.docstates # Build results [Dd]ebug/ [Rr]elease/ *_i.c *_p.c *.ilk *.meta *.obj *.pch *.pdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp *.vspscc .builds *.dotCover ## TODO: If you have NuGet Package Restore enabled, uncomment this #packages/ # Visual C++ cache files ipch/ *.aps *.ncb *.opensdf *.sdf # Visual Studio profiler *.psess *.vsp # ReSharper is a .NET coding add-in _ReSharper* # Installshield output folder [Ee]xpress # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish # Others [Bb]in [Oo]bj sql TestResults *.Cache ClientBin stylecop.* ~$* *.dbmdl Generated_Code #added for RIA/Silverlight projects # Backup & report files from converting an old project file to a newer # Visual Studio version. Backup files are not needed, because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML ############ ## Windows ############ # Windows image file caches Thumbs.db # Folder config file Desktop.ini ############# ## Python ############# *.py[co] # Packages *.egg *.egg-info dist build eggs parts bin var sdist develop-eggs .installed.cfg # Installer logs pip-log.txt # Unit test / coverage reports .coverage .tox #Translations *.mo #Mr Developer .mr.developer.cfg # Mac crap .DS_Store ================================================ FILE: .npmignore ================================================ TestCases tests ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2012-2016 Siorki Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ Code produced by RegPack, including the hashing (if included) and unpacking routines, is not affected by this license. No restriction to its usage or redistribution arise from its compression by RegPack. ================================================ FILE: README.md ================================================ **RegPack** is a packer intended for use on minified Javascript code. Current revision is 5.0.4 It is mostly suited to small size constraints (1kb, up to 4kb). The current version works in seven stages : - *(if enabled)* 2D, WebGL and Audio contexts method shortcuts are defined and used instead of the long, original names. - *(if enabled)* variables are renamed in order to reduce character footprint and free tokens for compression. - *(if enabled)* Initialization code is pushed inside the main loop, with conditional execution on the time variable, so that the unpacker can execute everything through ``setInterval()`` - string quotes are altered in order to minimize escaping inside the strings - redundancies are eliminated and replaced by tokens, as done by JS Crush (by Aivo Paas) and First Crush (by Tim Down). - the token list is turned into a regular expression consisting in a character class. - the tokens are rearranged to create a negated character class (starting with a hyphen ^ then listing nontoken characters) The text boxes show intermediate stage results. Best one gets a green highlight : - Preprocessed : after the first four stages. Hidden if no change was brought to the initial code. - Crushed : after the fifth stage - RegPack'ed : best between last two stages. Depends on how the characters present in the string are spread in the ASCII table. -- ## Usage tips - Toggle method hashing for any type of context you use. If the method renaming yields a longer code, RegPack will revert to the original one. - "Assume global .. is a context" is for environments where the canvas is declared before your code. If entering [js1k](http://www.js1k.com), keep this on, variable is c for classic and g for webgl. - Variable renaming is also performed inside strings, RegPack does not infer whether they are eval()ed or not. Disable if facing issues with this. Only one-letter variables are considered, others are ignored. - Crusher settings alter the choice of strings to compress. 1/0/0 is a good allrounder, although more exotic values can yield better results depending on your code. - Some preprocessing options negatively affect the performance and should be used with caution. Always test your packed code for speed after using these. - "Encapsulate with(Math)" get rid of all "Math." references in the code and enclose the evaluation with(Math). - "run with setInterval()" executes the unpacked code with ``setInterval()`` instead of ``eval()`` (meaning the evaluation is performed every frame). [Use it online](http://siorki.github.io/regPack.html) or integrate it into your Node workflow (thanks to kanaka) ## CLI usage ``` regpack input.js > output.js regpack input.js --crushGainFactor 1 --crushLengthFactor 0 --crushCopiesFactor 0 > output.js ``` From STDIN ``` cat input.js | regpack - > output.js ``` -- ## Running unit tests with Node ``` cd tests node AllTests ``` -- ## License Licensed under [MIT license](http://opensource.org/licenses/mit-license.html). Code produced by RegPack, including the hashing (if included) and unpacking routines, is not affected by the license. No restriction to its usage or redistribution arise from its compression by RegPack. -- Any feedback or improvement suggestions appreciated. Contributions welcome. @Siorki on Twitter ================================================ FILE: TestCases/audioContext_create1.js ================================================ try { this.webAudioSupport = true; if (typeof AudioContext !== "undefined") { this.audioContext = new AudioContext() } else if (typeof webkitAudioContext !== "undefined") { this.audioContext = new webkitAudioContext() } else { this.webAudioSupport = false } } catch (e) { this.webAudioSupport = false } } this.audioContext.createBuffer(2,22050,22050); ================================================ FILE: TestCases/audioContext_create2.js ================================================ var stdContext=null, webkitContext=null; if (typeof AudioContext !== "undefined") { stdContext = new AudioContext() } if (typeof webkitAudioContext !== "undefined") { webkitContext = new webkitAudioContext() } stdContext.createBuffer(1, 22050, 22050); stdContext.createGain(); webkitContext.createChannelMerger(2); var c=15; var d=7; ================================================ FILE: TestCases/audioContext_create3.js ================================================ var stdContext=null, webkitContext=null; if (typeof webkitAudioContext !== "undefined") { webkitContext = new webkitAudioContext() } if (typeof AudioContext !== "undefined") { stdContext = new AudioContext() } stdContext.createBuffer(1, 22050, 22050); stdContext.createGain(); webkitContext.createChannelMerger(2); var c=15; var d=7; ================================================ FILE: TestCases/audioContext_create4.js ================================================ m=[];s=[0,3,5,7,10];pl=0;for(i=0;16>i;i++)m[i]=0;ac=new webkitAudioContext()||new AudioContext();var nb=ac.createBuffer(1,16384,ac.sampleRate);d=nb.getChannelData(0);for(i=0;16384>i;i++)d[i]=2*Math.random()-1;d=ac.createDelay();d.delayTime.value=60/138;g=ac.createGain();g.gain.value=0.5;c=ac.createDynamicsCompressor();d.connect(g);g.connect(d);g.connect(c);c.connect(ac.destination);setInterval(function(){t=ac.currentTime;n=m[pl];0!=n&&(o=ac.createOscillator(),o.frequency.value=440*Math.pow(2,(n-69)/12),o.type="sawtooth",a=ac.createGain(),g=a.gain,g.setValueAtTime(1,t),g.linearRampToValueAtTime(0,t+1),f=ac.createBiquadFilter(),p=f.frequency,p.setValueAtTime(3E3+2E3*Math.random(),t),p.exponentialRampToValueAtTime(20,t+0.6),f.Q.value=5,o.connect(a),a.connect(f),f.connect(d),o.start(t),o.stop(t+0.5));0==pl%4?(o=ac.createOscillator(),f=o.frequency,f.setValueAtTime(200,t),f.exponentialRampToValueAtTime(10,t+0.25),a=ac.createGain(),g=a.gain,g.setValueAtTime(1.25,t),g.linearRampToValueAtTime(0,t+0.5),o.connect(a),a.connect(c),o.start(t),o.stop(t+0.5)):0==(pl+2)%4?(n=ac.createBufferSource(),n.buffer=nb,n.loop=!0,a=ac.createGain(),g=a.gain,g.setValueAtTime(1.25,t),g.linearRampToValueAtTime(0,t+0.2),f=ac.createBiquadFilter(),p=f.frequency,p.setValueAtTime(2500,t),p.exponentialRampToValueAtTime(500,t+0.1),n.connect(a),a.connect(f),f.connect(c),n.start(t),n.stop(t+1)):(o=ac.createBufferSource(),o.buffer=nb,o.loop=!0,f=ac.createBiquadFilter(),f.type="highpass",f.frequency.value=8E3+2E3*Math.random(),f.Q.value=5,o.connect(f),f.connect(c),o.start(t),o.stop(t+0.02));0==pl&&(i=Math.floor(16*Math.random()),0.1>Math.random()?m[i]=0:(j=Math.floor(Math.random()*s.length),o=Math.floor(Math.random()*Math.random()*3),m[i]=40+s[j]+12*o));pl=(pl+1)%16},60/138*1E3/2); ================================================ FILE: TestCases/double_renaming.js ================================================ a.fillRect(0,0,91,91); setInterval( function () { k = 2+2*Math.cos(3.1416*t/64); i=0; while(i<300) { a.strokeStyle = "hsl(20,0%,"+(k*x.charCodeAt(i+300)+(4-k)*x.charCodeAt(i++)-140)/4+"%)"; a.lineWidth=0|(k*x.charCodeAt(i+300)+(4-k)*x.charCodeAt(i++)-140); a.beginPath(); a.moveTo(k*x.charCodeAt(i+300)+(4-k)*x.charCodeAt(i++)-140, k*x.charCodeAt(i+300)+(4-k)*x.charCodeAt(i++)-140); a.lineTo(k*x.charCodeAt(i+300)+(4-k)*x.charCodeAt(i++)-140, k*x.charCodeAt(i+300)+(4-k)*x.charCodeAt(i++)-140); a.stroke(); } w=w?--w:(++t&63)?w:64; }, 40); ================================================ FILE: TestCases/gitHub#17-multipleContexts.js ================================================ a=a.cloneNode(p=[]);cc=a.getContext("2d");cc.fillStyle=n=cc.createRadialGradient(225,75,40,225,75,60);n.addColorStop(t=0,"#332");n.addColorStop(1,"#000");cc.fillRect(150,0,150,150);e=cc.getImageData(0,0,150,150);d=e.data;setInterval(function(){if(t%1200<1){for(x=y=f=s=0;f<256*256;++f)p[f]=Math.min(0,3*Math.cos((f&255)/40)-4*Math.sin(f/12800)-3);for(n=5e5;--n;s=13*s+2+9*Math.cos(s)|0)for(x+=[0,1,0,-1][s&3],y+=[0,1,0,-1][3-s&3],t=-6;++t;)for(i=-6;++i;)p[256*(y+t&255)+(x+i&255)]+=.01}f=Math.cos(t/200);for(y=-75;++y<75;)for(u=Math.sqrt(75*75-y*y)|0,q=4*((y+75)*150+75-u),x=-u;++x
XnO
XnO3D
Find4
Reversi
";g=function(l,h,n){c=e=1;i=0;d=[];f||(d[27]=d[36]=-1,d[28]=d[35]=1);for(B.innerHTML="";l--;){a="
| "+"X\xa0O"[d[i++]+1];B.innerHTML+=a}C.innerHTML="O"}; m=function(l,h){if(e&&!d[h]){if(1==f)for(l.innerHTML="XnO"[c+1],a=3*(d[h]=c),i=3;i--;)for(j=3;j--;){if(d[9*i+j]+d[9*i+j+3]+d[9*i+j+6]==a||d[9*i+3*j]+d[9*i+3*j+1]+d[9*i+3*j+2]==a||d[9*i+0]+d[9*i+4]+d[9*i+8]==a||d[9*i+2]+d[9*i+4]+d[9*i+6]==a||d[3*i]+d[3*i+10]+d[3*i+20]==a||d[3*i+2]+d[3*i+10]+d[18+3*i]==a||d[i]+d[9+i+3]+d[18+i+6]==a||d[i+6]+d[9+i+3]+d[18+i]==a||d[0]+d[13]+d[26]==a||d[2]+d[13]+d[24]==a||d[8]+d[13]+d[18]==a||d[6]+d[13]+d[20]==a||d[3*i+j]+d[9+3*i+j]+d[18+3*i+j]==a){C.innerHTML="XnO"[c+ 1]+"✌";e=0;return}}else if(2==f&&34 |
|---|