JavaScript-Minifier-1.14/0000775000175000017500000000000012516250677014656 5ustar zoffixzoffixJavaScript-Minifier-1.14/Makefile.PL0000644000175000017500000000243712516250677016634 0ustar zoffixzoffix# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.035. use strict; use warnings; use 5.006; use ExtUtils::MakeMaker; my %WriteMakefileArgs = ( "ABSTRACT" => "Perl extension for minifying JavaScript code", "AUTHOR" => "Zoffix Znet ", "CONFIGURE_REQUIRES" => { "ExtUtils::MakeMaker" => 0 }, "DISTNAME" => "JavaScript-Minifier", "EXE_FILES" => [], "LICENSE" => "perl", "MIN_PERL_VERSION" => "5.006", "NAME" => "JavaScript::Minifier", "PREREQ_PM" => { "Exporter" => 0, "strict" => 0, "warnings" => 0 }, "TEST_REQUIRES" => { "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => 0 }, "VERSION" => "1.14", "test" => { "TESTS" => "t/*.t" } ); my %FallbackPrereqs = ( "Exporter" => 0, "ExtUtils::MakeMaker" => 0, "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => 0, "strict" => 0, "warnings" => 0 ); unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; delete $WriteMakefileArgs{BUILD_REQUIRES}; $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; } delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); JavaScript-Minifier-1.14/t/0000775000175000017500000000000012516250677015121 5ustar zoffixzoffixJavaScript-Minifier-1.14/t/scripts/0000775000175000017500000000000012516250677016610 5ustar zoffixzoffixJavaScript-Minifier-1.14/t/scripts/s3.js0000644000175000017500000000020112516250677017462 0ustar zoffixzoffixvar x = 1//@a / 2//@a / //@a 2 /a/a;//@a /regexp/ //@a /regexp/;//@a a +//@a ++a;//@a a -//@a --a;a//@a a;a3//@a .aJavaScript-Minifier-1.14/t/scripts/s2-got.js0000644000175000017500000000004012516250677020251 0ustar zoffixzoffixfunction(){var x=21 var y=33 []}JavaScript-Minifier-1.14/t/scripts/s16-expected.js0000644000175000017500000000003212516250677021347 0ustar zoffixzoffixfunction(s){alert("Foo");}JavaScript-Minifier-1.14/t/scripts/s4-expected.js0000644000175000017500000000020312516250677021264 0ustar zoffixzoffixvar x=1/*@a*/ /2/*@a*/ / /*@a*/ 2 /a/a;/*@a*/ 2/*@a*//2;/regexp/ /*@a*/ /regexp/;/*@a*/ a+/*@a*/++a;a-/*@a*/--a;a/*@a*/a;a3/*@a*/.aJavaScript-Minifier-1.14/t/scripts/s2-expected.js0000644000175000017500000000004012516250677021261 0ustar zoffixzoffixfunction(){var x=21 var y=33 []}JavaScript-Minifier-1.14/t/scripts/s11-got.js0000644000175000017500000000006012516250677020333 0ustar zoffixzoffix" a \" a \n \\\\" ' a \' a \n \\\\' /a \. a\\\\/JavaScript-Minifier-1.14/t/scripts/s6.js0000644000175000017500000000022612516250677017474 0ustar zoffixzoffixvar x = 1/*a*/ / 2/*a*/ / /*a*/ 2/*a*/ /a/a;/*a*/ 2 /*a*/ / 2; /regexp/ /*a*/ /regexp/;/*a*/ a +/*a*/++a;a -/*a*/--a;a/*a*/a;a3/*a*/.aJavaScript-Minifier-1.14/t/scripts/s15-got.js0000644000175000017500000000003312516250677020337 0ustar zoffixzoffixfunction(s){alert("Foo");} JavaScript-Minifier-1.14/t/scripts/s14-expected.js0000644000175000017500000000001112516250677021342 0ustar zoffixzoffixfoo[5]/14JavaScript-Minifier-1.14/t/scripts/s7-expected.js0000644000175000017500000000006312516250677021273 0ustar zoffixzoffixvar x=1;//@ a //@ a //@ a /*@*//*@*/ /*@*/ var x=1;JavaScript-Minifier-1.14/t/scripts/s13.js0000644000175000017500000000002612516250677017550 0ustar zoffixzoffix/* foo */ var x = 2;JavaScript-Minifier-1.14/t/scripts/s13-got.js0000644000175000017500000000001012516250677020330 0ustar zoffixzoffixvar x=2;JavaScript-Minifier-1.14/t/scripts/s8-got.js0000644000175000017500000000001112516250677020255 0ustar zoffixzoffix- --+ ++-JavaScript-Minifier-1.14/t/scripts/s10-expected.js0000644000175000017500000000003612516250677021345 0ustar zoffixzoffix}}]})}/*@cc_on asdf */))]}]]])JavaScript-Minifier-1.14/t/scripts/s5.js0000644000175000017500000000017112516250677017472 0ustar zoffixzoffixvar x = foo//a / 2//a / //a 2 /a/a;//a /regexp/ //a /regexp/;//a a +//a ++a;//a a -//a --a;a//a a;a3//a .aJavaScript-Minifier-1.14/t/scripts/s9-expected.js0000644000175000017500000000003112516250677021270 0ustar zoffixzoffixasdf asdf 12 .toString();JavaScript-Minifier-1.14/t/scripts/s15.js0000644000175000017500000000003712516250677017554 0ustar zoffixzoffixfunction (s) { alert("Foo"); } JavaScript-Minifier-1.14/t/scripts/s4-got.js0000644000175000017500000000020312516250677020254 0ustar zoffixzoffixvar x=1/*@a*/ /2/*@a*/ / /*@a*/ 2 /a/a;/*@a*/ 2/*@a*//2;/regexp/ /*@a*/ /regexp/;/*@a*/ a+/*@a*/++a;a-/*@a*/--a;a/*@a*/a;a3/*@a*/.aJavaScript-Minifier-1.14/t/scripts/s16-got.js0000644000175000017500000000003212516250677020337 0ustar zoffixzoffixfunction(s){alert("Foo");}JavaScript-Minifier-1.14/t/scripts/s11-expected.js0000644000175000017500000000006012516250677021343 0ustar zoffixzoffix" a \" a \n \\\\" ' a \' a \n \\\\' /a \. a\\\\/JavaScript-Minifier-1.14/t/scripts/s6-expected.js0000644000175000017500000000010112516250677021263 0ustar zoffixzoffixvar x=1 /2 / 2 /a/a;2/2;/regexp/ /regexp/;a+ ++a;a- --a;a a;a3 .aJavaScript-Minifier-1.14/t/scripts/s12.js0000644000175000017500000000010412516250677017544 0ustar zoffixzoffix ! ^ & * ( { [ = | : < > ? ~ JavaScript-Minifier-1.14/t/scripts/s10-got.js0000644000175000017500000000003612516250677020335 0ustar zoffixzoffix}}]})}/*@cc_on asdf */))]}]]])JavaScript-Minifier-1.14/t/scripts/s15-expected.js0000644000175000017500000000003312516250677021347 0ustar zoffixzoffixfunction(s){alert("Foo");} JavaScript-Minifier-1.14/t/scripts/s3-expected.js0000644000175000017500000000016712516250677021274 0ustar zoffixzoffixvar x=1//@a /2//@a / //@a 2 /a/a;//@a /regexp/ //@a /regexp/;//@a a+//@a ++a;//@a a-//@a --a;a//@a a;a3//@a .aJavaScript-Minifier-1.14/t/scripts/s9.js0000644000175000017500000000003512516250677017475 0ustar zoffixzoffix asdf asdf 12 .toString();JavaScript-Minifier-1.14/t/scripts/s11.js0000644000175000017500000000007512516250677017552 0ustar zoffixzoffix " a \" a \n \\\\" ' a \' a \n \\\\' /a \. a\\\\/ JavaScript-Minifier-1.14/t/scripts/s12-got.js0000644000175000017500000000001612516250677020335 0ustar zoffixzoffix!^&*({[=|:<>?~JavaScript-Minifier-1.14/t/scripts/s8-expected.js0000644000175000017500000000001112516250677021265 0ustar zoffixzoffix- --+ ++-JavaScript-Minifier-1.14/t/scripts/s14-got.js0000644000175000017500000000001112516250677020332 0ustar zoffixzoffixfoo[5]/14JavaScript-Minifier-1.14/t/scripts/s13-expected.js0000644000175000017500000000001012516250677021340 0ustar zoffixzoffixvar x=2;JavaScript-Minifier-1.14/t/scripts/s5-expected.js0000644000175000017500000000007712516250677021276 0ustar zoffixzoffixvar x=foo /2 / 2 /a/a;/regexp/ /regexp/;a+ ++a;a- --a;a a;a3 .aJavaScript-Minifier-1.14/t/scripts/s10.js0000644000175000017500000000006512516250677017550 0ustar zoffixzoffix} } ] } /*asdf*/ ) } /*@cc_on asdf */ ) ) ] } ] ] ] )JavaScript-Minifier-1.14/t/scripts/s3-got.js0000644000175000017500000000016712516250677020264 0ustar zoffixzoffixvar x=1//@a /2//@a / //@a 2 /a/a;//@a /regexp/ //@a /regexp/;//@a a+//@a ++a;//@a a-//@a --a;a//@a a;a3//@a .aJavaScript-Minifier-1.14/t/scripts/s7.js0000644000175000017500000000044512516250677017500 0ustar zoffixzoffixvar x = 1; /*asdf*/ /*asdf*/ /*asdf*/ /*asdf*/ // aaaaa //@ a /**/ // //@ a //@ a /*@*//**//*@*/ /*@*/ /* asdfasdf asdf asdf * asdfasdfa * asdfasdfa *//**/ /* asdfasdf asdf asdf * asdfasdfa * asdfasdfa */ var x = 1; JavaScript-Minifier-1.14/t/scripts/s2.js0000644000175000017500000000010512516250677017464 0ustar zoffixzoffix// missing semi-colons function () { var x = 21 var y = 33 [] }JavaScript-Minifier-1.14/t/scripts/s14.js0000644000175000017500000000001312516250677017545 0ustar zoffixzoffixfoo[5] / 14JavaScript-Minifier-1.14/t/scripts/s16.js0000644000175000017500000000003612516250677017554 0ustar zoffixzoffixfunction (s) { alert("Foo"); }JavaScript-Minifier-1.14/t/scripts/s6-got.js0000644000175000017500000000010112516250677020253 0ustar zoffixzoffixvar x=1 /2 / 2 /a/a;2/2;/regexp/ /regexp/;a+ ++a;a- --a;a a;a3 .aJavaScript-Minifier-1.14/t/scripts/s12-expected.js0000644000175000017500000000001612516250677021345 0ustar zoffixzoffix!^&*({[=|:<>?~JavaScript-Minifier-1.14/t/scripts/s7-got.js0000644000175000017500000000006312516250677020263 0ustar zoffixzoffixvar x=1;//@ a //@ a //@ a /*@*//*@*/ /*@*/ var x=1;JavaScript-Minifier-1.14/t/scripts/s4.js0000644000175000017500000000022712516250677017473 0ustar zoffixzoffixvar x = 1/*@a*/ / 2/*@a*/ / /*@a*/ 2 /a/a;/*@a*/ 2 /*@a*/ / 2; /regexp/ /*@a*/ /regexp/;/*@a*/ a +/*@a*/++a;a -/*@a*/--a;a/*@a*/a;a3/*@a*/.aJavaScript-Minifier-1.14/t/scripts/s5-got.js0000644000175000017500000000007712516250677020266 0ustar zoffixzoffixvar x=foo /2 / 2 /a/a;/regexp/ /regexp/;a+ ++a;a- --a;a a;a3 .aJavaScript-Minifier-1.14/t/scripts/s8.js0000644000175000017500000000001312516250677017470 0ustar zoffixzoffix- -- + ++ -JavaScript-Minifier-1.14/t/scripts/s9-got.js0000644000175000017500000000003112516250677020260 0ustar zoffixzoffixasdf asdf 12 .toString();JavaScript-Minifier-1.14/t/00-compile.t0000644000175000017500000000212712516250677017153 0ustar zoffixzoffixuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.052 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'JavaScript/Minifier.pm' ); # no fake home requested my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; JavaScript-Minifier-1.14/t/JavaScript-Minifier.t0000644000175000017500000000422312516250677021113 0ustar zoffixzoffix#!perl -T ######################### use Test::More tests => 19; use JavaScript::Minifier qw(minify); ### This is mainly to align the tests to 's' scripts, because s1 is ### somehow missing can_ok('JavaScript::Minifier', 'minify'); ######################### sub filesMatch { my $file1 = shift; my $file2 = shift; my $a; my $b; while (1) { $a = getc($file1); $b = getc($file2); if (!defined($a) && !defined($b)) { # both files end at same place return 1; } elsif (!defined($b) || # file2 ends first !defined($a) || # file1 ends first $a ne $b) { # a and b not the same return 0; } } } sub minTest { my $filename = shift; open(INFILE, 't/scripts/' . $filename . '.js') or die("couldn't open file"); open(GOTFILE, '>t/scripts/' . $filename . '-got.js') or die("couldn't open file"); minify(input => *INFILE, outfile => *GOTFILE); close(INFILE); close(GOTFILE); open(EXPECTEDFILE, 't/scripts/' . $filename . '-expected.js') or die("couldn't open file"); open(GOTFILE, 't/scripts/' . $filename . '-got.js') or die("couldn't open file"); ok(filesMatch(GOTFILE, EXPECTEDFILE), 'testing ' . $filename); close(EXPECTEDFILE); close(GOTFILE); } minTest('s2'); # missing semi-colons minTest('s3'); # //@ minTest('s4'); # /*@*/ minTest('s5'); # // minTest('s6'); # /**/ minTest('s7'); # blocks of comments minTest('s8'); # + + - - minTest('s9'); # alphanum minTest('s10'); # }]) minTest('s11'); # string and regexp literals minTest('s12'); # other characters minTest('s13'); # comment at start minTest('s14'); # slash following square bracket # ... is division not RegExp minTest('s15'); # newline-at-end-of-file # -> not there so don't add minTest('s16'); # newline-at-end-of-file # -> it's there so leave it alone is(minify(input => 'var x = 2;'), 'var x=2;', 'string literal input and ouput'); is(minify(input => "var x = 2;\n;;;alert('hi');\nvar x = 2;", stripDebug => 1), 'var x=2;var x=2;', 'scriptDebug option'); is(minify(input => 'var x = 2;', copyright => "BSD"), '/* BSD */var x=2;', 'copyright option'); JavaScript-Minifier-1.14/t/01-newline-at-end.t0000644000175000017500000000123412516250677020331 0ustar zoffixzoffix#!perl -T use strict; use warnings FATAL => 'all'; use Test::More; plan tests => 2; ##### ##### This test ensures that if the file contains a new line at the end ##### then that newline will be preserved ##### The read-from-file tests for this are in JavaScript-Minifier.t ##### use JavaScript::Minifier; my $js_with_new_line = <<'END'; function (s) { alert("Foo"); } END chomp( my $js_without_new_line = $js_with_new_line ); like( minify(input => $js_with_new_line), qr/\n\z/, 'Last new line was preserved', ); like( minify(input => $js_without_new_line), qr/[^\n]\z/, 'Last new line was not added because it was absent originally', );JavaScript-Minifier-1.14/t/00-load.t0000644000175000017500000000037612516250677016446 0ustar zoffixzoffix#!perl -T use 5.006; use strict; use warnings FATAL => 'all'; use Test::More; plan tests => 1; BEGIN { use_ok( 'JavaScript::Minifier' ) || print "Bail out!\n"; } diag( "Testing JavaScript::Minifier $JavaScript::Minifier::VERSION, Perl $], $^X" ); JavaScript-Minifier-1.14/Changes0000644000175000017500000000234112516250677016147 0ustar zoffixzoffixRevision history for Perl extension JavaScript::Minifier. 1.14 2015-04-23 - Fixed error in SYNOPSIS 1.13 2015-03-19 [Changes by vti] - Fixed Issue #4 (Error in the docs) - Updated Synopsis to use modern code 1.12 2014-10-04 - Fixed Issue #3 (warnings for empty files) 1.11 2014-01-30 - Added my dzil author plugin bundle and fixed up some packaging issues 1.10 2014-01-22 - Added missing test prereqs - Fixed up wrong year in the latest versions in the change log 1.09 2014-01-22 - Made some changes to dzil plugins and added git repos for this module 1.08 2014-01-19 - Fixed RT#76800 (preserve "\n" at the end of file) 1.07 2014-01-19 - Fixed license issue (RT#92298) - Converted to Dist::Zilla for packaging 1.06 2014-01-18 - Zoffix Znet took over maintenance - Applied user-submitted bug patches - Modified the build system - Added pod and kwalitee tests - Added examples/minify.pl - Fixed RT#85899 (superfluous perl 5.8 requirement) - Fixed RT#91292 and RT#91291 (optimizations) 1.05 2014-01-18 - This and previous 'Changes' are lost 0.01 2007-05-19 - original version; created by h2xs 1.23 with options -X -n JavaScript::Minifier JavaScript-Minifier-1.14/README0000644000175000017500000000063512516250677015540 0ustar zoffixzoffix This archive contains the distribution JavaScript-Minifier, version 1.14: Perl extension for minifying JavaScript code This software is copyright (c) 2015 by Peter Michaux . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. This README file was generated by Dist::Zilla::Plugin::Readme v5.035. JavaScript-Minifier-1.14/META.yml0000644000175000017500000002657412516250677016143 0ustar zoffixzoffix--- abstract: 'Perl extension for minifying JavaScript code' author: - 'Zoffix Znet ' build_requires: File::Spec: '0' IO::Handle: '0' IPC::Open3: '0' Test::More: '0' perl: '5.006' configure_requires: ExtUtils::MakeMaker: '0' perl: '5.006' dynamic_config: 0 generated_by: 'Dist::Zilla version 5.035, CPAN::Meta::Converter version 2.150001' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: JavaScript-Minifier provides: JavaScript::Minifier: file: lib/JavaScript/Minifier.pm version: '1.14' requires: Exporter: '0' perl: '5.006' strict: '0' warnings: '0' resources: bugtracker: https://github.com/zoffixznet/javascript-minifier/issues homepage: http://metacpan.org/release/JavaScript-Minifier repository: git://github.com/zoffixznet/javascript-minifier.git version: '1.14' x_Dist_Zilla: perl: version: '5.020001' plugins: - class: Dist::Zilla::Plugin::OurPkgVersion name: '@Author::ZOFFIX/OurPkgVersion' version: '0.005001' - class: Dist::Zilla::Plugin::Pod::Spiffy name: '@Author::ZOFFIX/Pod::Spiffy' version: '1.001007' - class: Dist::Zilla::Plugin::PromptIfStale config: Dist::Zilla::Plugin::PromptIfStale: check_all_plugins: '1' check_all_prereqs: '1' modules: [] phase: release skip: - strict - warnings - base - ExtUtils::MakeMaker - IPC::Open3 - File::Copy name: '@Author::ZOFFIX/PromptIfStale' version: '0.042' - class: Dist::Zilla::Plugin::GatherDir config: Dist::Zilla::Plugin::GatherDir: exclude_filename: [] exclude_match: [] follow_symlinks: '0' include_dotfiles: '0' prefix: '' prune_directory: [] root: . name: '@Author::ZOFFIX/GatherDir' version: '5.035' - class: Dist::Zilla::Plugin::PruneCruft name: '@Author::ZOFFIX/PruneCruft' version: '5.035' - class: Dist::Zilla::Plugin::ManifestSkip name: '@Author::ZOFFIX/ManifestSkip' version: '5.035' - class: Dist::Zilla::Plugin::MetaYAML name: '@Author::ZOFFIX/MetaYAML' version: '5.035' - class: Dist::Zilla::Plugin::License name: '@Author::ZOFFIX/License' version: '5.035' - class: Dist::Zilla::Plugin::Readme name: '@Author::ZOFFIX/Readme' version: '5.035' - class: Dist::Zilla::Plugin::ExecDir name: '@Author::ZOFFIX/ExecDir' version: '5.035' - class: Dist::Zilla::Plugin::ShareDir name: '@Author::ZOFFIX/ShareDir' version: '5.035' - class: Dist::Zilla::Plugin::MakeMaker config: Dist::Zilla::Role::TestRunner: default_jobs: 1 name: '@Author::ZOFFIX/MakeMaker' version: '5.035' - class: Dist::Zilla::Plugin::Manifest name: '@Author::ZOFFIX/Manifest' version: '5.035' - class: Dist::Zilla::Plugin::AutoPrereqs name: '@Author::ZOFFIX/AutoPrereqs' version: '5.035' - class: Dist::Zilla::Plugin::MetaConfig name: '@Author::ZOFFIX/MetaConfig' version: '5.035' - class: Dist::Zilla::Plugin::Prereqs::AuthorDeps name: '@Author::ZOFFIX/Prereqs::AuthorDeps' version: '0.004' - class: Dist::Zilla::Plugin::MinimumPerl name: '@Author::ZOFFIX/MinimumPerl' version: '1.006' - class: Dist::Zilla::Plugin::MetaProvides::Package config: Dist::Zilla::Plugin::MetaProvides::Package: finder_objects: - class: Dist::Zilla::Plugin::FinderCode name: '@Author::ZOFFIX/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '5.035' Dist::Zilla::Role::MetaProvider::Provider: inherit_missing: '1' inherit_version: '1' meta_noindex: '1' name: '@Author::ZOFFIX/MetaProvides::Package' version: '2.003001' - class: Dist::Zilla::Plugin::InstallGuide name: '@Author::ZOFFIX/InstallGuide' version: '1.200006' - class: Dist::Zilla::Plugin::ReadmeAnyFromPod name: '@Author::ZOFFIX/ReadmeAnyFromPod' version: '0.150250' - class: Dist::Zilla::Plugin::Test::Compile config: Dist::Zilla::Plugin::Test::Compile: bail_out_on_fail: '0' fail_on_warning: author fake_home: '0' filename: t/00-compile.t module_finder: - ':InstallModules' needs_display: '0' phase: test script_finder: - ':ExecFiles' skips: [] name: '@Author::ZOFFIX/Test::Compile' version: '2.052' - class: Dist::Zilla::Plugin::Test::DistManifest name: '@Author::ZOFFIX/Test::DistManifest' version: '2.000005' - class: Dist::Zilla::Plugin::Test::Version name: '@Author::ZOFFIX/Test::Version' version: '0.003001' - class: Dist::Zilla::Plugin::Test::Kwalitee config: Dist::Zilla::Plugin::Test::Kwalitee: filename: xt/release/kwalitee.t skiptest: [] name: '@Author::ZOFFIX/Test::Kwalitee' version: '2.11' - class: Dist::Zilla::Plugin::MetaTests name: '@Author::ZOFFIX/MetaTests' version: '5.035' - class: Dist::Zilla::Plugin::Test::CPAN::Meta::JSON name: '@Author::ZOFFIX/Test::CPAN::Meta::JSON' version: '0.004' - class: Dist::Zilla::Plugin::MojibakeTests name: '@Author::ZOFFIX/MojibakeTests' version: '0.7' - class: Dist::Zilla::Plugin::Test::NoTabs config: Dist::Zilla::Plugin::Test::NoTabs: filename: xt/author/no-tabs.t finder: - ':InstallModules' - ':ExecFiles' - ':TestFiles' name: '@Author::ZOFFIX/Test::NoTabs' version: '0.14' - class: Dist::Zilla::Plugin::PodSyntaxTests name: '@Author::ZOFFIX/PodSyntaxTests' version: '5.035' - class: Dist::Zilla::Plugin::Test::Portability name: '@Author::ZOFFIX/Test::Portability' version: '2.000006' - class: Dist::Zilla::Plugin::Test::UnusedVars name: '@Author::ZOFFIX/Test::UnusedVars' version: '2.000007' - class: Dist::Zilla::Plugin::Test::Pod::LinkCheck name: '@Author::ZOFFIX/Test::Pod::LinkCheck' version: '1.001' - class: Dist::Zilla::Plugin::Test::CPAN::Changes name: '@Author::ZOFFIX/Test::CPAN::Changes' version: '0.009' - class: Dist::Zilla::Plugin::Test::PodSpelling name: '@Author::ZOFFIX/Test::PodSpelling' version: '2.006008' - class: Dist::Zilla::Plugin::CheckSelfDependency config: Dist::Zilla::Plugin::CheckSelfDependency: finder: - ':InstallModules' Dist::Zilla::Role::ModuleMetadata: Module::Metadata: '1.000026' version: '0.003' name: '@Author::ZOFFIX/CheckSelfDependency' version: '0.011' - class: Dist::Zilla::Plugin::CheckPrereqsIndexed name: '@Author::ZOFFIX/CheckPrereqsIndexed' version: '0.015' - class: Dist::Zilla::Plugin::Test::MinimumVersion name: '@Author::ZOFFIX/Test::MinimumVersion' version: '2.000006' - class: Dist::Zilla::Plugin::Git::NextVersion config: Dist::Zilla::Plugin::Git::NextVersion: first_version: '1.001001' version_by_branch: '0' version_regexp: (?^:^v(.+)$) Dist::Zilla::Role::Git::Repo: repo_root: . name: '@Author::ZOFFIX/Git::NextVersion' version: '2.033' - class: Dist::Zilla::Plugin::AutoMetaResources name: '@Author::ZOFFIX/AutoMetaResources' version: '1.20' - class: Dist::Zilla::Plugin::CopyFilesFromRelease config: Dist::Zilla::Plugin::CopyFilesFromRelease: filename: - README.md match: [] name: '@Author::ZOFFIX/CopyFilesFromRelease' version: '0.005' - class: Dist::Zilla::Plugin::TestRelease name: '@Author::ZOFFIX/TestRelease' version: '5.035' - class: Dist::Zilla::Plugin::InstallRelease name: '@Author::ZOFFIX/InstallRelease' version: '0.008' - class: Dist::Zilla::Plugin::ConfirmRelease name: '@Author::ZOFFIX/ConfirmRelease' version: '5.035' - class: Dist::Zilla::Plugin::Git::Check config: Dist::Zilla::Plugin::Git::Check: untracked_files: die Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - dist.ini - Changes allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . name: '@Author::ZOFFIX/Git::Check' version: '2.033' - class: Dist::Zilla::Plugin::Git::Commit config: Dist::Zilla::Plugin::Git::Commit: add_files_in: [] commit_msg: v%v%n%n%c time_zone: local Dist::Zilla::Role::Git::DirtyFiles: allow_dirty: - dist.ini - Changes allow_dirty_match: [] changelog: Changes Dist::Zilla::Role::Git::Repo: repo_root: . name: '@Author::ZOFFIX/Git::Commit' version: '2.033' - class: Dist::Zilla::Plugin::Git::Tag config: Dist::Zilla::Plugin::Git::Tag: branch: ~ signed: 0 tag: v1.14 tag_format: v%v tag_message: v%v time_zone: local Dist::Zilla::Role::Git::Repo: repo_root: . name: '@Author::ZOFFIX/Git::Tag' version: '2.033' - class: Dist::Zilla::Plugin::Git::Push config: Dist::Zilla::Plugin::Git::Push: push_to: - origin remotes_must_exist: 1 Dist::Zilla::Role::Git::Repo: repo_root: . name: '@Author::ZOFFIX/Git::Push' version: '2.033' - class: Dist::Zilla::Plugin::UploadToCPAN name: '@Author::ZOFFIX/UploadToCPAN' version: '5.035' - class: Dist::Zilla::Plugin::Encoding name: Encoding version: '5.035' - class: Dist::Zilla::Plugin::Meta::Contributors name: Meta::Contributors version: '0.002' - class: Dist::Zilla::Plugin::FinderCode name: ':InstallModules' version: '5.035' - class: Dist::Zilla::Plugin::FinderCode name: ':IncModules' version: '5.035' - class: Dist::Zilla::Plugin::FinderCode name: ':TestFiles' version: '5.035' - class: Dist::Zilla::Plugin::FinderCode name: ':ExecFiles' version: '5.035' - class: Dist::Zilla::Plugin::FinderCode name: ':ShareFiles' version: '5.035' - class: Dist::Zilla::Plugin::FinderCode name: ':MainModule' version: '5.035' - class: Dist::Zilla::Plugin::FinderCode name: ':AllFiles' version: '5.035' - class: Dist::Zilla::Plugin::FinderCode name: ':NoFiles' version: '5.035' - class: Dist::Zilla::Plugin::FinderCode name: '@Author::ZOFFIX/MetaProvides::Package/AUTOVIV/:InstallModulesPM' version: '5.035' zilla: class: Dist::Zilla::Dist::Builder config: is_trial: '' version: '5.035' x_contributors: - "Miller 'tmhall' Hall" - "Вячеслав 'vti' Тихановский" JavaScript-Minifier-1.14/INSTALL0000644000175000017500000000175212516250677015712 0ustar zoffixzoffixThis is the Perl distribution JavaScript-Minifier. Installing JavaScript-Minifier is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm JavaScript::Minifier If you are installing into a system-wide directory, you may need to pass the "-S" flag to cpanm, which uses sudo to install the module: % cpanm -S JavaScript::Minifier ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan JavaScript::Minifier ## Manual installation As a last resort, you can manually install it. Download the tarball, untar it, then build it: % perl Makefile.PL % make && make test Then install it: % make install If you are installing into a system-wide directory, you may need to run: % sudo make install ## Documentation JavaScript-Minifier documentation is available as POD. You can run perldoc from a shell to read the documentation: % perldoc JavaScript::Minifier JavaScript-Minifier-1.14/README.md0000644000175000017500000000611612516250677016137 0ustar zoffixzoffix# NAME JavaScript::Minifier - Perl extension for minifying JavaScript code # SYNOPSIS To minify a JavaScript file and have the output written directly to another file use JavaScript::Minifier qw(minify); open(my $in, 'myScript.js') or die; open(my $out, '>', 'myScript-min.js') or die; minify(input => $in, outfile => $out); close($in); close($out); To minify a JavaScript string literal. Note that by omitting the outfile parameter a the minified code is returned as a string. my $minifiedJavaScript = minify(input => 'var x = 2;'); To include a copyright comment at the top of the minified code. minify(input => 'var x = 2;', copyright => 'BSD License'); To treat ';;;' as '//' so that debugging code can be removed. This is a common JavaScript convention for minification. minify(input => 'var x = 2;', stripDebug => 1); The "input" parameter is mandatory. The "output", "copyright", and "stripDebug" parameters are optional and can be used in any combination. # DESCRIPTION This module removes unnecessary whitespace from JavaScript code. The primary requirement developing this module is to not break working code: if working JavaScript is in input then working JavaScript is output. It is ok if the input has missing semi-colons, snips like '++ +' or '12 .toString()', for example. Internet Explorer conditional comments are copied to the output but the code inside these comments will not be minified. The ECMAScript specifications allow for many different whitespace characters: space, horizontal tab, vertical tab, new line, carriage return, form feed, and paragraph separator. This module understands all of these as whitespace except for vertical tab and paragraph separator. These two types of whitespace are not minimized. For static JavaScript files, it is recommended that you minify during the build stage of web deployment. If you minify on-the-fly then it might be a good idea to cache the minified file. Minifying static files on-the-fly repeatedly is wasteful. ## EXPORT Exported by default: `minifiy()` # SEE ALSO This module is inspired by Douglas Crockford's JSMin: [http://www.crockford.com/javascript/jsmin.html](http://www.crockford.com/javascript/jsmin.html) You may also be interested in the [CSS::Minifier](https://metacpan.org/pod/CSS::Minifier) module also available on CPAN. # REPOSITORY You can obtain the latest source code and submit bug reports on the github repository for this module: [https://github.com/zoffixznet/JavaScript-Minifier](https://github.com/zoffixznet/JavaScript-Minifier) # MAINTAINER Zoffix Znet `` [https://metacpan.org/author/ZOFFIX](https://metacpan.org/author/ZOFFIX) # AUTHORS Peter Michaux, Eric Herrera, # CONTRIBUTORS Miller 'tmhall' Hall Вячеслав 'vti' Тихановский # COPYRIGHT AND LICENSE Copyright (C) 2007 by Peter Michaux This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available. JavaScript-Minifier-1.14/xt/0000775000175000017500000000000012516250677015311 5ustar zoffixzoffixJavaScript-Minifier-1.14/xt/release/0000775000175000017500000000000012516250677016731 5ustar zoffixzoffixJavaScript-Minifier-1.14/xt/release/pod-linkcheck.t0000644000175000017500000000053712516250677021634 0ustar zoffixzoffix#!perl use strict; use warnings; use Test::More; foreach my $env_skip ( qw( SKIP_POD_LINKCHECK ) ){ plan skip_all => "\$ENV{$env_skip} is set, skipping" if $ENV{$env_skip}; } eval "use Test::Pod::LinkCheck"; if ( $@ ) { plan skip_all => 'Test::Pod::LinkCheck required for testing POD'; } else { Test::Pod::LinkCheck->new->all_pod_ok; } JavaScript-Minifier-1.14/xt/release/kwalitee.t0000644000175000017500000000027512516250677020725 0ustar zoffixzoffix# this test was generated with Dist::Zilla::Plugin::Test::Kwalitee 2.11 use strict; use warnings; use Test::More 0.88; use Test::Kwalitee 1.21 'kwalitee_ok'; kwalitee_ok(); done_testing; JavaScript-Minifier-1.14/xt/release/cpan-changes.t0000644000175000017500000000026312516250677021444 0ustar zoffixzoffix#!perl use strict; use warnings; use Test::More 0.96 tests => 2; use_ok('Test::CPAN::Changes'); subtest 'changes_ok' => sub { changes_file_ok('Changes'); }; done_testing(); JavaScript-Minifier-1.14/xt/release/test-version.t0000644000175000017500000000060412516250677021556 0ustar zoffixzoffixuse strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::Version 0.003001 use Test::Version; my @imports = ( 'version_all_ok' ); my $params = { is_strict => 0, has_version => 1, }; push @imports, $params if version->parse( $Test::Version::VERSION ) >= version->parse('1.002'); Test::Version->import(@imports); version_all_ok; done_testing; JavaScript-Minifier-1.14/xt/release/portability.t0000644000175000017500000000027712516250677021464 0ustar zoffixzoffix#!perl use strict; use warnings; use Test::More; eval 'use Test::Portability::Files'; plan skip_all => 'Test::Portability::Files required for testing portability' if $@; run_tests(); JavaScript-Minifier-1.14/xt/release/distmeta.t0000644000175000017500000000017212516250677020726 0ustar zoffixzoffix#!perl # This file was automatically generated by Dist::Zilla::Plugin::MetaTests. use Test::CPAN::Meta; meta_yaml_ok(); JavaScript-Minifier-1.14/xt/release/dist-manifest.t0000644000175000017500000000023012516250677021656 0ustar zoffixzoffix#!perl use Test::More; eval "use Test::DistManifest"; plan skip_all => "Test::DistManifest required for testing the manifest" if $@; manifest_ok(); JavaScript-Minifier-1.14/xt/release/unused-vars.t0000644000175000017500000000036212516250677021371 0ustar zoffixzoffix#!perl use Test::More 0.96 tests => 1; eval { require Test::Vars }; SKIP: { skip 1 => 'Test::Vars required for testing for unused vars' if $@; Test::Vars->import; subtest 'unused vars' => sub { all_vars_ok(); }; }; JavaScript-Minifier-1.14/xt/release/pod-syntax.t0000644000175000017500000000022012516250677021214 0ustar zoffixzoffix#!perl # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. use Test::More; use Test::Pod 1.41; all_pod_files_ok(); JavaScript-Minifier-1.14/xt/release/mojibake.t0000644000175000017500000000040612516250677020675 0ustar zoffixzoffix#!perl use strict; use warnings qw(all); use Test::More; ## no critic (ProhibitStringyEval, RequireCheckingReturnValueOfEval) eval q(use Test::Mojibake); plan skip_all => q(Test::Mojibake required for source encoding testing) if $@; all_files_encoding_ok(); JavaScript-Minifier-1.14/xt/release/minimum-version.t0000644000175000017500000000027112516250677022252 0ustar zoffixzoffix#!perl use Test::More; eval "use Test::MinimumVersion"; plan skip_all => "Test::MinimumVersion required for testing minimum versions" if $@; all_minimum_version_ok( qq{5.008008} ); JavaScript-Minifier-1.14/xt/kwalitee.t0000644000175000017500000000030612516250677017300 0ustar zoffixzoffix#!/usr/bin/env perl BEGIN { unless ($ENV{RELEASE_TESTING}) { use Test::More; plan(skip_all => 'these tests are for release candidate testing'); } } use Test::Kwalitee;JavaScript-Minifier-1.14/xt/pod.t0000644000175000017500000000040112516250677016251 0ustar zoffixzoffix#!perl -T use 5.006; use strict; use warnings FATAL => 'all'; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok(); JavaScript-Minifier-1.14/xt/pod-coverage.t0000644000175000017500000000113612516250677020050 0ustar zoffixzoffix#!perl -T use 5.006; use strict; use warnings FATAL => 'all'; use Test::More; # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval "use Test::Pod::Coverage $min_tpc"; plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; all_pod_coverage_ok({trustme=>[qr/^/]}); JavaScript-Minifier-1.14/xt/author/0000775000175000017500000000000012516250677016613 5ustar zoffixzoffixJavaScript-Minifier-1.14/xt/author/pod-spell.t0000644000175000017500000000055012516250677020675 0ustar zoffixzoffixuse strict; use warnings; use Test::More; # generated by Dist::Zilla::Plugin::Test::PodSpelling 2.006008 use Test::Spelling 0.12; use Pod::Wordlist; add_stopwords(); all_pod_files_spelling_ok( qw( bin lib ) ); __DATA__ Zoffix Znet cpan Peter Michaux petermichaux Miller tmhall Hall Вячеслав vti Тихановский lib JavaScript Minifier JavaScript-Minifier-1.14/xt/author/no-tabs.t0000644000175000017500000000051612516250677020343 0ustar zoffixzoffixuse strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::NoTabs 0.14 use Test::More 0.88; use Test::NoTabs; my @files = ( 'lib/JavaScript/Minifier.pm', 't/00-compile.t', 't/00-load.t', 't/01-newline-at-end.t', 't/JavaScript-Minifier.t' ); notabs_ok($_) foreach @files; done_testing; JavaScript-Minifier-1.14/MANIFEST0000644000175000017500000000304612516250677016010 0ustar zoffixzoffix# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.035. Changes INSTALL LICENSE MANIFEST META.yml Makefile.PL README README.md dist.ini examples/minify.pl lib/JavaScript/Minifier.pm t/00-compile.t t/00-load.t t/01-newline-at-end.t t/JavaScript-Minifier.t t/scripts/s10-expected.js t/scripts/s10-got.js t/scripts/s10.js t/scripts/s11-expected.js t/scripts/s11-got.js t/scripts/s11.js t/scripts/s12-expected.js t/scripts/s12-got.js t/scripts/s12.js t/scripts/s13-expected.js t/scripts/s13-got.js t/scripts/s13.js t/scripts/s14-expected.js t/scripts/s14-got.js t/scripts/s14.js t/scripts/s15-expected.js t/scripts/s15-got.js t/scripts/s15.js t/scripts/s16-expected.js t/scripts/s16-got.js t/scripts/s16.js t/scripts/s2-expected.js t/scripts/s2-got.js t/scripts/s2.js t/scripts/s3-expected.js t/scripts/s3-got.js t/scripts/s3.js t/scripts/s4-expected.js t/scripts/s4-got.js t/scripts/s4.js t/scripts/s5-expected.js t/scripts/s5-got.js t/scripts/s5.js t/scripts/s6-expected.js t/scripts/s6-got.js t/scripts/s6.js t/scripts/s7-expected.js t/scripts/s7-got.js t/scripts/s7.js t/scripts/s8-expected.js t/scripts/s8-got.js t/scripts/s8.js t/scripts/s9-expected.js t/scripts/s9-got.js t/scripts/s9.js xt/author/no-tabs.t xt/author/pod-spell.t xt/kwalitee.t xt/pod-coverage.t xt/pod.t xt/release/cpan-changes.t xt/release/dist-manifest.t xt/release/distmeta.t xt/release/kwalitee.t xt/release/minimum-version.t xt/release/mojibake.t xt/release/pod-linkcheck.t xt/release/pod-syntax.t xt/release/portability.t xt/release/test-version.t xt/release/unused-vars.t JavaScript-Minifier-1.14/lib/0000775000175000017500000000000012516250677015424 5ustar zoffixzoffixJavaScript-Minifier-1.14/lib/JavaScript/0000775000175000017500000000000012516250677017472 5ustar zoffixzoffixJavaScript-Minifier-1.14/lib/JavaScript/Minifier.pm0000644000175000017500000003336512516250677021602 0ustar zoffixzoffixpackage JavaScript::Minifier; use strict; use warnings; our $VERSION = '1.14'; # VERSION require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(minify); #return true if the character is allowed in identifier. sub isAlphanum { return ($_[0] =~ /[\w\$\\]/ || ord($_[0]) > 126); } sub isEndspace { return ($_[0] eq "\n" || $_[0] eq "\r" || $_[0] eq "\f"); } sub isWhitespace { return ($_[0] eq ' ' || $_[0] eq "\t" || $_[0] eq "\n" || $_[0] eq "\r" || $_[0] eq "\f"); } # New line characters before or after these characters can be removed. # Not + - / in this list because they require special care. sub isInfix { $_[0] =~ /[,;:=&%*<>\?\|\n]/; } # New line characters after these characters can be removed. sub isPrefix { return ($_[0] =~ /[\{\(\[!]/ || isInfix($_[0])); } # New line characters before these characters can removed. sub isPostfix { return ($_[0] =~ /[\}\)\]]/ || isInfix($_[0])); } # ----------------------------------------------------------------------------- sub _get { my $s = shift; if ($s->{inputType} eq 'file') { my $char = getc($s->{input}); $s->{last_read_char} = $char if defined $char; return $char; } elsif ($s->{inputType} eq 'string') { if ($s->{'inputPos'} < length($s->{input})) { return $s->{last_read_char} = substr($s->{input}, $s->{inputPos}++, 1); } else { # Simulate getc() when off the end of the input string. return undef; } } else { die "no input"; } } sub _put { my $s = shift; my $x = shift; my $outfile = ($s->{outfile}); if (defined($s->{outfile})) { print $outfile $x; } else { $s->{output} .= $x; } } # ----------------------------------------------------------------------------- # print a # move b to a # move c to b # move d to c # new d # # i.e. print a and advance sub action1 { my $s = shift; if (!isWhitespace($s->{a})) { $s->{lastnws} = $s->{a}; } $s->{last} = $s->{a}; action2($s); } # sneeky output $s->{a} for comments sub action2 { my $s = shift; _put($s, $s->{a}); action3($s); } # move b to a # move c to b # move d to c # new d # # i.e. delete a sub action3 { my $s = shift; $s->{a} = $s->{b}; action4($s); } # move c to b # move d to c # new d # # i.e. delete b sub action4 { my $s = shift; $s->{b} = $s->{c}; $s->{c} = $s->{d}; $s->{d} = _get($s); } # ----------------------------------------------------------------------------- # put string and regexp literals # when this sub is called, $s->{a} is on the opening delimiter character sub putLiteral { my $s = shift; my $delimiter = $s->{a}; # ', " or / action1($s); do { while (defined($s->{a}) && $s->{a} eq '\\') { # escape character only escapes only the next one character action1($s); action1($s); } action1($s); } until ($s->{last} eq $delimiter || !defined($s->{a})); if ($s->{last} ne $delimiter) { # ran off end of file before printing the closing delimiter die 'unterminated ' . ($delimiter eq '\'' ? 'single quoted string' : $delimiter eq '"' ? 'double quoted string' : 'regular expression') . ' literal, stopped'; } } # ----------------------------------------------------------------------------- # If $s->{a} is a whitespace then collapse all following whitespace. # If any of the whitespace is a new line then ensure $s->{a} is a new line # when this function ends. sub collapseWhitespace { my $s = shift; while (defined($s->{a}) && isWhitespace($s->{a}) && defined($s->{b}) && isWhitespace($s->{b})) { if (isEndspace($s->{a}) || isEndspace($s->{b})) { $s->{a} = "\n"; } action4($s); # delete b } } # Advance $s->{a} to non-whitespace or end of file. # Doesn't print any of this whitespace. sub skipWhitespace { my $s = shift; while (defined($s->{a}) && isWhitespace($s->{a})) { action3($s); } } # Advance $s->{a} to non-whitespace or end of file # If any of the whitespace is a new line then print one new line. sub preserveEndspace { my $s = shift; collapseWhitespace($s); if (defined($s->{a}) && isEndspace($s->{a}) && defined($s->{b}) && !isPostfix($s->{b}) ) { action1($s); } skipWhitespace($s); } sub onWhitespaceConditionalComment { my $s = shift; return (defined($s->{a}) && isWhitespace($s->{a}) && defined($s->{b}) && $s->{b} eq '/' && defined($s->{c}) && ($s->{c} eq '/' || $s->{c} eq '*') && defined($s->{d}) && $s->{d} eq '@'); } # ----------------------------------------------------------------------------- sub minify { my %h = @_; # Immediately turn hash into a hash reference so that notation is the same in this function # as others. Easier refactoring. my $s = \%h; # hash reference for "state". This module is functional programming and the state is passed between functions. # determine if the the input is a string or a file handle. my $ref = \$s->{input}; if (defined($ref) && ref($ref) eq 'SCALAR'){ $s->{inputPos} = 0; $s->{inputType} = 'string'; } else { $s->{inputType} = 'file'; } # Determine if the output is to a string or a file. if (!defined($s->{outfile})) { $s->{output} = ''; } # Print the copyright notice first if ($s->{copyright}) { _put($s, '/* ' . $s->{copyright} . ' */'); } # Initialize the buffer. do { $s->{a} = _get($s); } while (defined($s->{a}) && isWhitespace($s->{a})); $s->{b} = _get($s); $s->{c} = _get($s); $s->{d} = _get($s); $s->{last} = undef; # assign for safety $s->{lastnws} = undef; # assign for safety # local variables my $ccFlag; # marks if a comment is an Internet Explorer conditional comment and should be printed to output while (defined($s->{a})) { # on this line $s->{a} should always be a non-whitespace character or undef (i.e. end of file) if (isWhitespace($s->{a})) { # check that this program is running correctly die 'minifier bug: minify while loop starting with whitespace, stopped'; } # Each branch handles trailing whitespace and ensures $s->{a} is on non-whitespace or undef when branch finishes if ($s->{a} eq '/') { # a division, comment, or regexp literal if (defined($s->{b}) && $s->{b} eq '/') { # slash-slash comment $ccFlag = defined($s->{c}) && $s->{c} eq '@'; # tests in IE7 show no space allowed between slashes and at symbol do { $ccFlag ? action2($s) : action3($s); } until (!defined($s->{a}) || isEndspace($s->{a})); if (defined($s->{a})) { # $s->{a} is a new line if ($ccFlag) { action1($s); # cannot use preserveEndspace($s) here because it might not print the new line skipWhitespace($s); } elsif (defined($s->{last}) && !isEndspace($s->{last}) && !isPrefix($s->{last})) { preserveEndspace($s); } else { skipWhitespace($s); } } } elsif (defined($s->{b}) && $s->{b} eq '*') { # slash-star comment $ccFlag = defined($s->{c}) && $s->{c} eq '@'; # test in IE7 shows no space allowed between star and at symbol do { $ccFlag ? action2($s) : action3($s); } until (!defined($s->{b}) || ($s->{a} eq '*' && $s->{b} eq '/')); if (defined($s->{b})) { # $s->{a} is asterisk and $s->{b} is foreslash if ($ccFlag) { action2($s); # the * action2($s); # the / # inside the conditional comment there may be a missing terminal semi-colon preserveEndspace($s); } else { # the comment is being removed action3($s); # the * $s->{a} = ' '; # the / collapseWhitespace($s); if (defined($s->{last}) && defined($s->{b}) && ((isAlphanum($s->{last}) && (isAlphanum($s->{b})||$s->{b} eq '.')) || ($s->{last} eq '+' && $s->{b} eq '+') || ($s->{last} eq '-' && $s->{b} eq '-'))) { # for a situation like 5-/**/-2 or a/**/a # When entering this block $s->{a} is whitespace. # The comment represented whitespace that cannot be removed. Therefore replace the now gone comment with a whitespace. action1($s); } elsif (defined($s->{last}) && !isPrefix($s->{last})) { preserveEndspace($s); } else { skipWhitespace($s); } } } else { die 'unterminated comment, stopped'; } } elsif (defined($s->{lastnws}) && ($s->{lastnws} eq ')' || $s->{lastnws} eq ']' || $s->{lastnws} eq '.' || isAlphanum($s->{lastnws}))) { # division action1($s); collapseWhitespace($s); # don't want a division to become a slash-slash comment with following conditional comment onWhitespaceConditionalComment($s) ? action1($s) : preserveEndspace($s); } else { # regexp literal putLiteral($s); collapseWhitespace($s); # don't want closing delimiter to become a slash-slash comment with following conditional comment onWhitespaceConditionalComment($s) ? action1($s) : preserveEndspace($s); } } elsif ($s->{a} eq '\'' || $s->{a} eq '"' ) { # string literal putLiteral($s); preserveEndspace($s); } elsif ($s->{a} eq '+' || $s->{a} eq '-') { # careful with + + and - - action1($s); collapseWhitespace($s); if (defined($s->{a}) && isWhitespace($s->{a})) { (defined($s->{b}) && $s->{b} eq $s->{last}) ? action1($s) : preserveEndspace($s); } } elsif (isAlphanum($s->{a})) { # keyword, identifiers, numbers action1($s); collapseWhitespace($s); if (defined($s->{a}) && isWhitespace($s->{a})) { # if $s->{b} is '.' could be (12 .toString()) which is property invocation. If space removed becomes decimal point and error. (defined($s->{b}) && (isAlphanum($s->{b}) || $s->{b} eq '.')) ? action1($s) : preserveEndspace($s); } } elsif ($s->{a} eq ']' || $s->{a} eq '}' || $s->{a} eq ')') { # no need to be followed by space but maybe needs following new line action1($s); preserveEndspace($s); } elsif ($s->{stripDebug} && $s->{a} eq ';' && defined($s->{b}) && $s->{b} eq ';' && defined($s->{c}) && $s->{c} eq ';') { action3($s); # delete one of the semi-colons $s->{a} = '/'; # replace the other two semi-colons $s->{b} = '/'; # so the remainder of line is removed } else { # anything else just prints and trailing whitespace discarded action1($s); skipWhitespace($s); } } if ( defined $s->{last_read_char} and $s->{last_read_char} =~ /\n/ ) { _put($s, "\n"); } if (!defined($s->{outfile})) { return $s->{output}; } } # minify() 1; __END__ =encoding utf8 =for stopwords Crockford ECMAScript JSMin stripDebug Minifying minification minifying minified minify =head1 NAME JavaScript::Minifier - Perl extension for minifying JavaScript code =head1 SYNOPSIS To minify a JavaScript file and have the output written directly to another file use JavaScript::Minifier qw(minify); open(my $in, 'myScript.js') or die; open(my $out, '>', 'myScript-min.js') or die; minify(input => $in, outfile => $out); close($in); close($out); To minify a JavaScript string literal. Note that by omitting the outfile parameter a the minified code is returned as a string. my $minifiedJavaScript = minify(input => 'var x = 2;'); To include a copyright comment at the top of the minified code. minify(input => 'var x = 2;', copyright => 'BSD License'); To treat ';;;' as '//' so that debugging code can be removed. This is a common JavaScript convention for minification. minify(input => 'var x = 2;', stripDebug => 1); The "input" parameter is mandatory. The "output", "copyright", and "stripDebug" parameters are optional and can be used in any combination. =head1 DESCRIPTION This module removes unnecessary whitespace from JavaScript code. The primary requirement developing this module is to not break working code: if working JavaScript is in input then working JavaScript is output. It is ok if the input has missing semi-colons, snips like '++ +' or '12 .toString()', for example. Internet Explorer conditional comments are copied to the output but the code inside these comments will not be minified. The ECMAScript specifications allow for many different whitespace characters: space, horizontal tab, vertical tab, new line, carriage return, form feed, and paragraph separator. This module understands all of these as whitespace except for vertical tab and paragraph separator. These two types of whitespace are not minimized. For static JavaScript files, it is recommended that you minify during the build stage of web deployment. If you minify on-the-fly then it might be a good idea to cache the minified file. Minifying static files on-the-fly repeatedly is wasteful. =head2 EXPORT Exported by default: C =head1 SEE ALSO This module is inspired by Douglas Crockford's JSMin: L You may also be interested in the L module also available on CPAN. =head1 REPOSITORY You can obtain the latest source code and submit bug reports on the github repository for this module: L =head1 MAINTAINER Zoffix Znet C<< >> L =head1 AUTHORS Peter Michaux, Epetermichaux@gmail.comE Eric Herrera, Eherrera@10east.comE =head1 CONTRIBUTORS Miller 'tmhall' Hall Вячеслав 'vti' Тихановский =head1 COPYRIGHT AND LICENSE Copyright (C) 2007 by Peter Michaux This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available. JavaScript-Minifier-1.14/examples/0000775000175000017500000000000012516250677016474 5ustar zoffixzoffixJavaScript-Minifier-1.14/examples/minify.pl0000755000175000017500000000315112516250677020325 0ustar zoffixzoffix#!/usr/bin/env perl use strict; use warnings; # VERSION use lib qw{lib ../lib}; use JavaScript::Minifier qw/minify/; my $JS = get_js(); print minify(input => $JS) . "\n"; sub get_js { return <<'END_JS'; function setup_sample_form_data() { var els, i, l; els = $$('.sample_form_data'); for ( i = 0, l = els.length; i < l; i++ ) { els[i].set( 'data-sample-form-data', els[i].get('data-sample-form-data').replace('\\n', "\n") ); if ( els[i].get('value') == '' ) { els[i].set('value', els[i].get('data-sample-form-data')); } else if ( els[i].get('value') != els[i].get('data-sample-form-data') ) { els[i].removeClass('sample_form_data'); } var funct_clear_sample_data = function() { var i, l, els = this.getElements('.sample_form_data'); for ( i = 0, l = els.length; i < l; i++ ) { els[i].set('value', ''); } } els[i].getParent('form').removeEvent('submit', funct_clear_sample_data ); els[i].getParent('form').addEvent('submit', funct_clear_sample_data ); els[i].addEvent('focus', function() { if ( this.get('value') == this.get('data-sample-form-data') ) { this.set('value', ''); this.removeClass('sample_form_data'); } }); els[i].addEvent('blur', function() { if ( this.value == '' ) { this.set('value', this.get('data-sample-form-data')); this.addClass('sample_form_data'); } }); } } END_JS }JavaScript-Minifier-1.14/LICENSE0000644000175000017500000004377312516250677015677 0ustar zoffixzoffixThis software is copyright (c) 2015 by Peter Michaux . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2015 by Peter Michaux . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2015 by Peter Michaux . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End JavaScript-Minifier-1.14/dist.ini0000644000175000017500000000062412516250677016322 0ustar zoffixzoffixname = JavaScript-Minifier author = Zoffix Znet license = Perl_5 copyright_holder = Peter Michaux [@Author::ZOFFIX] -remove = Test::Synopsis -remove = PodCoverageTests -remove = Test::EOL [Encoding] encoding = bytes match = ^t/scripts [Meta::Contributors] contributor = Miller 'tmhall' Hall contributor = Вячеслав 'vti' Тихановский