svgo 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.MD +31 -4
- data/bin/svgo-ruby +7 -11
- data/lib/svgo.rb +45 -9
- data/lib/version.rb +2 -2
- data/svgo-js/svgo-built.js +76 -71
- data/svgo-js/svgo-wrapper.js +7 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10dfbd259d4a4a204ee6a9635cbc6edf3a200b8a
|
4
|
+
data.tar.gz: 314b094be9673d0bd72afed713004c235d003dcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8ceccb4be1b9960125d8e12b92af6d3295ff591701e3d94995d99ca7b69f71f8f4adcbe5b6b636078fc1daf825a52d6bf88b2c3e541b1380b3ef4bc73070dfc
|
7
|
+
data.tar.gz: 3d4098f895e94a52d86b9ad00e961a85c7877386e97e6b0ef6fbdf95ea755e974617fa97abdde08d8c7e2d56d506cd550a40e549b3af9c520482306db3fdd25e
|
data/README.MD
CHANGED
@@ -1,8 +1,31 @@
|
|
1
1
|
# A Ruby wrapper for Node SVGO
|
2
2
|
|
3
3
|
Removes metadata and editor data elements and attributes that are redundant
|
4
|
-
from SVG files. Can strip files so they are optimised for web use. Go to
|
5
|
-
(https://github.com/svg/svgo) for more documentation on features.
|
4
|
+
from SVG files. Can strip files so they are optimised for web use. Go to
|
5
|
+
[SVGO](https://github.com/svg/svgo) for more documentation on features.
|
6
|
+
|
7
|
+
## How this works
|
8
|
+
|
9
|
+
[`execjs`](https://github.com/rails/execjs) is used to run the Node SVGO as a
|
10
|
+
library. The SVGO library returns a JavaScript Promise, which is currently not
|
11
|
+
supported by `execjs` and probably never will be. `setTimeout` and sleep-like
|
12
|
+
functions are also disabled in `execjs` so we can't wait for the Promise to get
|
13
|
+
fulfilled. Therefore there is a small wrapper JavaScript in this repository
|
14
|
+
that calls all the components that SVGO is made up of, but without the
|
15
|
+
`Promise`. It also wraps up the configuration of plugins the way it is expected
|
16
|
+
by SVGO's components. Lastly `require` is not supported by `execjs` so all of
|
17
|
+
this is transpiled to one monolithic JavaScript file - that is completely
|
18
|
+
self-contained, using [browserify](http://browserify.org/).
|
19
|
+
|
20
|
+
__NOTE:__ `execjs` supports a variety of JavaSript runtimes, notably
|
21
|
+
[`therubyracer`](https://github.com/cowboyd/therubyracer), but `therubyracer`
|
22
|
+
depends on an ancient [`libv8`](https://github.com/cowboyd/libv8), which
|
23
|
+
doesn't support some of the modern syntax used in SVGO. Therefore `mini_racer`
|
24
|
+
(a drop in replacement for `therubyracer`) is a dependency, which uses a much
|
25
|
+
more recent `libv8`.
|
26
|
+
|
27
|
+
If you have [Node](https://nodejs.org/) installed you could also use that as a
|
28
|
+
runtime.
|
6
29
|
|
7
30
|
## How to use?
|
8
31
|
|
@@ -29,8 +52,8 @@ svgo.optimize(File.read(svg_file))
|
|
29
52
|
|
30
53
|
#### Method 2
|
31
54
|
|
32
|
-
You can manually pass options to the class that correspond to
|
33
|
-
(https://github.com/svg/svgo)'s documentation.
|
55
|
+
You can manually pass options to the class that correspond to
|
56
|
+
[SVGO](https://github.com/svg/svgo)'s documentation.
|
34
57
|
|
35
58
|
```ruby
|
36
59
|
require('svgo')
|
@@ -100,3 +123,7 @@ docker run -i svgo < test/fixtures/ruby.svg > test/fixtures/ruby.optim.svg
|
|
100
123
|
-rw-r--r-- 1 user staff 9.5K Nov 5 22:16 ruby.optim.svg
|
101
124
|
-rw-r--r-- 1 user staff 23K Nov 5 22:12 ruby.svg
|
102
125
|
```
|
126
|
+
|
127
|
+
## Building Node SVGO from source
|
128
|
+
|
129
|
+
Because `execjs`
|
data/bin/svgo-ruby
CHANGED
@@ -202,23 +202,19 @@ else
|
|
202
202
|
puts parser.banner
|
203
203
|
exit 2
|
204
204
|
else
|
205
|
-
|
205
|
+
begin
|
206
|
+
data_out = svgo.optimize_file(input_file)
|
207
|
+
rescue => err
|
208
|
+
puts err.message
|
209
|
+
exit(1)
|
210
|
+
end
|
206
211
|
end
|
207
212
|
end
|
208
213
|
|
209
|
-
if result['errors'].length > 0
|
210
|
-
if result['errors'].length > 1
|
211
|
-
puts %Q(Errors occurred: \n - #{result['errors'].join("\n - s")})
|
212
|
-
else
|
213
|
-
puts "An error occurred: #{result['errors'][0]}"
|
214
|
-
end
|
215
|
-
exit(1)
|
216
|
-
end
|
217
|
-
|
218
214
|
unless output_file
|
219
215
|
puts result['data']
|
220
216
|
else
|
221
|
-
File.new(output_file, 'w').write(
|
217
|
+
File.new(output_file, 'w').write(data_out)
|
222
218
|
end
|
223
219
|
|
224
220
|
|
data/lib/svgo.rb
CHANGED
@@ -68,37 +68,45 @@ class SvgoOptions
|
|
68
68
|
@options.js2svg
|
69
69
|
end
|
70
70
|
|
71
|
-
def js2svg=(
|
72
|
-
@options.js2svg =
|
71
|
+
def js2svg=(js2svg)
|
72
|
+
@options.js2svg = js2svg
|
73
73
|
end
|
74
74
|
|
75
75
|
def plugins
|
76
76
|
@options.plugins
|
77
77
|
end
|
78
78
|
|
79
|
-
def plugins=(
|
80
|
-
@options.plugins =
|
79
|
+
def plugins=(plugins)
|
80
|
+
@options.plugins = plugins
|
81
81
|
end
|
82
82
|
|
83
83
|
def floatPrecision
|
84
84
|
@options.floatPrecision
|
85
85
|
end
|
86
86
|
|
87
|
-
def floatPrecision=(
|
88
|
-
@options.floatPrecision =
|
87
|
+
def floatPrecision=(floatPrecision)
|
88
|
+
@options.floatPrecision = floatPrecision
|
89
89
|
end
|
90
90
|
|
91
91
|
def multipass
|
92
92
|
@options.multipass
|
93
93
|
end
|
94
94
|
|
95
|
-
def multipass=(
|
96
|
-
@options.multipass =
|
95
|
+
def multipass=(multipass)
|
96
|
+
@options.multipass = multipass
|
97
97
|
end
|
98
98
|
|
99
99
|
def [](key)
|
100
100
|
@options[key.to_sym]
|
101
101
|
end
|
102
|
+
|
103
|
+
def runtime
|
104
|
+
@options.runtime
|
105
|
+
end
|
106
|
+
|
107
|
+
def runtime=(runtime)
|
108
|
+
@options.runtime = runtime
|
109
|
+
end
|
102
110
|
end
|
103
111
|
|
104
112
|
class SvgOptimizer
|
@@ -109,6 +117,26 @@ class SvgOptimizer
|
|
109
117
|
else
|
110
118
|
@options = options
|
111
119
|
end
|
120
|
+
|
121
|
+
runtime = @options.delete "runtime"
|
122
|
+
unless runtime
|
123
|
+
# therubyracer is a first choice for execjs but its libv8 is too
|
124
|
+
# old for the svgo library and its dependencies.
|
125
|
+
runtimes = [
|
126
|
+
# MacOS only system component
|
127
|
+
ExecJS::Runtimes::JavaScriptCore,
|
128
|
+
ExecJS::Runtimes::MiniRacer,
|
129
|
+
ExecJS::Runtimes::Node
|
130
|
+
]
|
131
|
+
runtime = runtimes.select {|r| r.available?}.first
|
132
|
+
unless runtime
|
133
|
+
raise ExecJS::RuntimeUnavailable.new(
|
134
|
+
"No supported runtime available please install " \
|
135
|
+
"`mini_racer` or `NodeJS`."
|
136
|
+
)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
ExecJS.runtime = runtime
|
112
140
|
if not @options[:plugins]
|
113
141
|
@options[:plugins] = PLUGINS_DEFAULT
|
114
142
|
end
|
@@ -121,7 +149,15 @@ class SvgOptimizer
|
|
121
149
|
end
|
122
150
|
|
123
151
|
def optimize(svg_data)
|
124
|
-
@context.call("svgo", @options.to_json, svg_data.to_s);
|
152
|
+
result = @context.call("svgo", @options.to_json, svg_data.to_s);
|
153
|
+
if result['errors'].length > 0
|
154
|
+
if result['errors'].length > 1
|
155
|
+
err = %Q(Errors occurred: \n - #{result['errors'].join("\n - s")})
|
156
|
+
else
|
157
|
+
err = "An error occurred: #{result['errors'][0]}"
|
158
|
+
end
|
159
|
+
raise StandardError.new(err)
|
160
|
+
end
|
125
161
|
end
|
126
162
|
|
127
163
|
def optimize_file(svg_file)
|
data/lib/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module SvgoVersion
|
2
|
-
VERSION = '0.1.
|
3
|
-
end
|
2
|
+
VERSION = '0.1.2'
|
3
|
+
end
|
data/svgo-js/svgo-built.js
CHANGED
@@ -3248,7 +3248,7 @@ module.exports = {
|
|
3248
3248
|
pseudos: pseudos
|
3249
3249
|
};
|
3250
3250
|
|
3251
|
-
},{"./attributes.js":9,"boolbase":2,"nth-check":
|
3251
|
+
},{"./attributes.js":9,"boolbase":2,"nth-check":346}],14:[function(require,module,exports){
|
3252
3252
|
module.exports = sortByProcedure;
|
3253
3253
|
|
3254
3254
|
/*
|
@@ -18849,7 +18849,7 @@ defineProperties.supportsDescriptors = !!supportsDescriptors;
|
|
18849
18849
|
|
18850
18850
|
module.exports = defineProperties;
|
18851
18851
|
|
18852
|
-
},{"object-keys":
|
18852
|
+
},{"object-keys":348}],269:[function(require,module,exports){
|
18853
18853
|
/*
|
18854
18854
|
Module dependencies
|
18855
18855
|
*/
|
@@ -22001,13 +22001,6 @@ if (hasSymbols) {
|
|
22001
22001
|
}
|
22002
22002
|
|
22003
22003
|
},{"has-symbols":305}],315:[function(require,module,exports){
|
22004
|
-
var toString = {}.toString;
|
22005
|
-
|
22006
|
-
module.exports = Array.isArray || function (arr) {
|
22007
|
-
return toString.call(arr) == '[object Array]';
|
22008
|
-
};
|
22009
|
-
|
22010
|
-
},{}],316:[function(require,module,exports){
|
22011
22004
|
'use strict';
|
22012
22005
|
|
22013
22006
|
|
@@ -22016,7 +22009,7 @@ var yaml = require('./lib/js-yaml.js');
|
|
22016
22009
|
|
22017
22010
|
module.exports = yaml;
|
22018
22011
|
|
22019
|
-
},{"./lib/js-yaml.js":
|
22012
|
+
},{"./lib/js-yaml.js":316}],316:[function(require,module,exports){
|
22020
22013
|
'use strict';
|
22021
22014
|
|
22022
22015
|
|
@@ -22057,7 +22050,7 @@ module.exports.parse = deprecated('parse');
|
|
22057
22050
|
module.exports.compose = deprecated('compose');
|
22058
22051
|
module.exports.addConstructor = deprecated('addConstructor');
|
22059
22052
|
|
22060
|
-
},{"./js-yaml/dumper":
|
22053
|
+
},{"./js-yaml/dumper":318,"./js-yaml/exception":319,"./js-yaml/loader":320,"./js-yaml/schema":322,"./js-yaml/schema/core":323,"./js-yaml/schema/default_full":324,"./js-yaml/schema/default_safe":325,"./js-yaml/schema/failsafe":326,"./js-yaml/schema/json":327,"./js-yaml/type":328}],317:[function(require,module,exports){
|
22061
22054
|
'use strict';
|
22062
22055
|
|
22063
22056
|
|
@@ -22118,7 +22111,7 @@ module.exports.repeat = repeat;
|
|
22118
22111
|
module.exports.isNegativeZero = isNegativeZero;
|
22119
22112
|
module.exports.extend = extend;
|
22120
22113
|
|
22121
|
-
},{}],
|
22114
|
+
},{}],318:[function(require,module,exports){
|
22122
22115
|
'use strict';
|
22123
22116
|
|
22124
22117
|
/*eslint-disable no-use-before-define*/
|
@@ -22945,7 +22938,7 @@ function safeDump(input, options) {
|
|
22945
22938
|
module.exports.dump = dump;
|
22946
22939
|
module.exports.safeDump = safeDump;
|
22947
22940
|
|
22948
|
-
},{"./common":
|
22941
|
+
},{"./common":317,"./exception":319,"./schema/default_full":324,"./schema/default_safe":325}],319:[function(require,module,exports){
|
22949
22942
|
// YAML error class. http://stackoverflow.com/questions/8458984
|
22950
22943
|
//
|
22951
22944
|
'use strict';
|
@@ -22990,7 +22983,7 @@ YAMLException.prototype.toString = function toString(compact) {
|
|
22990
22983
|
|
22991
22984
|
module.exports = YAMLException;
|
22992
22985
|
|
22993
|
-
},{}],
|
22986
|
+
},{}],320:[function(require,module,exports){
|
22994
22987
|
'use strict';
|
22995
22988
|
|
22996
22989
|
/*eslint-disable max-len,no-use-before-define*/
|
@@ -24590,7 +24583,7 @@ module.exports.load = load;
|
|
24590
24583
|
module.exports.safeLoadAll = safeLoadAll;
|
24591
24584
|
module.exports.safeLoad = safeLoad;
|
24592
24585
|
|
24593
|
-
},{"./common":
|
24586
|
+
},{"./common":317,"./exception":319,"./mark":321,"./schema/default_full":324,"./schema/default_safe":325}],321:[function(require,module,exports){
|
24594
24587
|
'use strict';
|
24595
24588
|
|
24596
24589
|
|
@@ -24668,7 +24661,7 @@ Mark.prototype.toString = function toString(compact) {
|
|
24668
24661
|
|
24669
24662
|
module.exports = Mark;
|
24670
24663
|
|
24671
|
-
},{"./common":
|
24664
|
+
},{"./common":317}],322:[function(require,module,exports){
|
24672
24665
|
'use strict';
|
24673
24666
|
|
24674
24667
|
/*eslint-disable max-len*/
|
@@ -24778,7 +24771,7 @@ Schema.create = function createSchema() {
|
|
24778
24771
|
|
24779
24772
|
module.exports = Schema;
|
24780
24773
|
|
24781
|
-
},{"./common":
|
24774
|
+
},{"./common":317,"./exception":319,"./type":328}],323:[function(require,module,exports){
|
24782
24775
|
// Standard YAML's Core schema.
|
24783
24776
|
// http://www.yaml.org/spec/1.2/spec.html#id2804923
|
24784
24777
|
//
|
@@ -24798,7 +24791,7 @@ module.exports = new Schema({
|
|
24798
24791
|
]
|
24799
24792
|
});
|
24800
24793
|
|
24801
|
-
},{"../schema":
|
24794
|
+
},{"../schema":322,"./json":327}],324:[function(require,module,exports){
|
24802
24795
|
// JS-YAML's default schema for `load` function.
|
24803
24796
|
// It is not described in the YAML specification.
|
24804
24797
|
//
|
@@ -24825,7 +24818,7 @@ module.exports = Schema.DEFAULT = new Schema({
|
|
24825
24818
|
]
|
24826
24819
|
});
|
24827
24820
|
|
24828
|
-
},{"../schema":
|
24821
|
+
},{"../schema":322,"../type/js/function":333,"../type/js/regexp":334,"../type/js/undefined":335,"./default_safe":325}],325:[function(require,module,exports){
|
24829
24822
|
// JS-YAML's default schema for `safeLoad` function.
|
24830
24823
|
// It is not described in the YAML specification.
|
24831
24824
|
//
|
@@ -24855,7 +24848,7 @@ module.exports = new Schema({
|
|
24855
24848
|
]
|
24856
24849
|
});
|
24857
24850
|
|
24858
|
-
},{"../schema":
|
24851
|
+
},{"../schema":322,"../type/binary":329,"../type/merge":337,"../type/omap":339,"../type/pairs":340,"../type/set":342,"../type/timestamp":344,"./core":323}],326:[function(require,module,exports){
|
24859
24852
|
// Standard YAML's Failsafe schema.
|
24860
24853
|
// http://www.yaml.org/spec/1.2/spec.html#id2802346
|
24861
24854
|
|
@@ -24874,7 +24867,7 @@ module.exports = new Schema({
|
|
24874
24867
|
]
|
24875
24868
|
});
|
24876
24869
|
|
24877
|
-
},{"../schema":
|
24870
|
+
},{"../schema":322,"../type/map":336,"../type/seq":341,"../type/str":343}],327:[function(require,module,exports){
|
24878
24871
|
// Standard YAML's JSON schema.
|
24879
24872
|
// http://www.yaml.org/spec/1.2/spec.html#id2803231
|
24880
24873
|
//
|
@@ -24901,7 +24894,7 @@ module.exports = new Schema({
|
|
24901
24894
|
]
|
24902
24895
|
});
|
24903
24896
|
|
24904
|
-
},{"../schema":
|
24897
|
+
},{"../schema":322,"../type/bool":330,"../type/float":331,"../type/int":332,"../type/null":338,"./failsafe":326}],328:[function(require,module,exports){
|
24905
24898
|
'use strict';
|
24906
24899
|
|
24907
24900
|
var YAMLException = require('./exception');
|
@@ -24964,7 +24957,7 @@ function Type(tag, options) {
|
|
24964
24957
|
|
24965
24958
|
module.exports = Type;
|
24966
24959
|
|
24967
|
-
},{"./exception":
|
24960
|
+
},{"./exception":319}],329:[function(require,module,exports){
|
24968
24961
|
'use strict';
|
24969
24962
|
|
24970
24963
|
/*eslint-disable no-bitwise*/
|
@@ -25104,7 +25097,7 @@ module.exports = new Type('tag:yaml.org,2002:binary', {
|
|
25104
25097
|
represent: representYamlBinary
|
25105
25098
|
});
|
25106
25099
|
|
25107
|
-
},{"../type":
|
25100
|
+
},{"../type":328}],330:[function(require,module,exports){
|
25108
25101
|
'use strict';
|
25109
25102
|
|
25110
25103
|
var Type = require('../type');
|
@@ -25141,7 +25134,7 @@ module.exports = new Type('tag:yaml.org,2002:bool', {
|
|
25141
25134
|
defaultStyle: 'lowercase'
|
25142
25135
|
});
|
25143
25136
|
|
25144
|
-
},{"../type":
|
25137
|
+
},{"../type":328}],331:[function(require,module,exports){
|
25145
25138
|
'use strict';
|
25146
25139
|
|
25147
25140
|
var common = require('../common');
|
@@ -25259,7 +25252,7 @@ module.exports = new Type('tag:yaml.org,2002:float', {
|
|
25259
25252
|
defaultStyle: 'lowercase'
|
25260
25253
|
});
|
25261
25254
|
|
25262
|
-
},{"../common":
|
25255
|
+
},{"../common":317,"../type":328}],332:[function(require,module,exports){
|
25263
25256
|
'use strict';
|
25264
25257
|
|
25265
25258
|
var common = require('../common');
|
@@ -25434,7 +25427,7 @@ module.exports = new Type('tag:yaml.org,2002:int', {
|
|
25434
25427
|
}
|
25435
25428
|
});
|
25436
25429
|
|
25437
|
-
},{"../common":
|
25430
|
+
},{"../common":317,"../type":328}],333:[function(require,module,exports){
|
25438
25431
|
'use strict';
|
25439
25432
|
|
25440
25433
|
var esprima;
|
@@ -25528,7 +25521,7 @@ module.exports = new Type('tag:yaml.org,2002:js/function', {
|
|
25528
25521
|
represent: representJavascriptFunction
|
25529
25522
|
});
|
25530
25523
|
|
25531
|
-
},{"../../type":
|
25524
|
+
},{"../../type":328}],334:[function(require,module,exports){
|
25532
25525
|
'use strict';
|
25533
25526
|
|
25534
25527
|
var Type = require('../../type');
|
@@ -25590,7 +25583,7 @@ module.exports = new Type('tag:yaml.org,2002:js/regexp', {
|
|
25590
25583
|
represent: representJavascriptRegExp
|
25591
25584
|
});
|
25592
25585
|
|
25593
|
-
},{"../../type":
|
25586
|
+
},{"../../type":328}],335:[function(require,module,exports){
|
25594
25587
|
'use strict';
|
25595
25588
|
|
25596
25589
|
var Type = require('../../type');
|
@@ -25620,7 +25613,7 @@ module.exports = new Type('tag:yaml.org,2002:js/undefined', {
|
|
25620
25613
|
represent: representJavascriptUndefined
|
25621
25614
|
});
|
25622
25615
|
|
25623
|
-
},{"../../type":
|
25616
|
+
},{"../../type":328}],336:[function(require,module,exports){
|
25624
25617
|
'use strict';
|
25625
25618
|
|
25626
25619
|
var Type = require('../type');
|
@@ -25630,7 +25623,7 @@ module.exports = new Type('tag:yaml.org,2002:map', {
|
|
25630
25623
|
construct: function (data) { return data !== null ? data : {}; }
|
25631
25624
|
});
|
25632
25625
|
|
25633
|
-
},{"../type":
|
25626
|
+
},{"../type":328}],337:[function(require,module,exports){
|
25634
25627
|
'use strict';
|
25635
25628
|
|
25636
25629
|
var Type = require('../type');
|
@@ -25644,7 +25637,7 @@ module.exports = new Type('tag:yaml.org,2002:merge', {
|
|
25644
25637
|
resolve: resolveYamlMerge
|
25645
25638
|
});
|
25646
25639
|
|
25647
|
-
},{"../type":
|
25640
|
+
},{"../type":328}],338:[function(require,module,exports){
|
25648
25641
|
'use strict';
|
25649
25642
|
|
25650
25643
|
var Type = require('../type');
|
@@ -25680,7 +25673,7 @@ module.exports = new Type('tag:yaml.org,2002:null', {
|
|
25680
25673
|
defaultStyle: 'lowercase'
|
25681
25674
|
});
|
25682
25675
|
|
25683
|
-
},{"../type":
|
25676
|
+
},{"../type":328}],339:[function(require,module,exports){
|
25684
25677
|
'use strict';
|
25685
25678
|
|
25686
25679
|
var Type = require('../type');
|
@@ -25726,7 +25719,7 @@ module.exports = new Type('tag:yaml.org,2002:omap', {
|
|
25726
25719
|
construct: constructYamlOmap
|
25727
25720
|
});
|
25728
25721
|
|
25729
|
-
},{"../type":
|
25722
|
+
},{"../type":328}],340:[function(require,module,exports){
|
25730
25723
|
'use strict';
|
25731
25724
|
|
25732
25725
|
var Type = require('../type');
|
@@ -25781,7 +25774,7 @@ module.exports = new Type('tag:yaml.org,2002:pairs', {
|
|
25781
25774
|
construct: constructYamlPairs
|
25782
25775
|
});
|
25783
25776
|
|
25784
|
-
},{"../type":
|
25777
|
+
},{"../type":328}],341:[function(require,module,exports){
|
25785
25778
|
'use strict';
|
25786
25779
|
|
25787
25780
|
var Type = require('../type');
|
@@ -25791,7 +25784,7 @@ module.exports = new Type('tag:yaml.org,2002:seq', {
|
|
25791
25784
|
construct: function (data) { return data !== null ? data : []; }
|
25792
25785
|
});
|
25793
25786
|
|
25794
|
-
},{"../type":
|
25787
|
+
},{"../type":328}],342:[function(require,module,exports){
|
25795
25788
|
'use strict';
|
25796
25789
|
|
25797
25790
|
var Type = require('../type');
|
@@ -25822,7 +25815,7 @@ module.exports = new Type('tag:yaml.org,2002:set', {
|
|
25822
25815
|
construct: constructYamlSet
|
25823
25816
|
});
|
25824
25817
|
|
25825
|
-
},{"../type":
|
25818
|
+
},{"../type":328}],343:[function(require,module,exports){
|
25826
25819
|
'use strict';
|
25827
25820
|
|
25828
25821
|
var Type = require('../type');
|
@@ -25832,7 +25825,7 @@ module.exports = new Type('tag:yaml.org,2002:str', {
|
|
25832
25825
|
construct: function (data) { return data !== null ? data : ''; }
|
25833
25826
|
});
|
25834
25827
|
|
25835
|
-
},{"../type":
|
25828
|
+
},{"../type":328}],344:[function(require,module,exports){
|
25836
25829
|
'use strict';
|
25837
25830
|
|
25838
25831
|
var Type = require('../type');
|
@@ -25922,7 +25915,7 @@ module.exports = new Type('tag:yaml.org,2002:timestamp', {
|
|
25922
25915
|
represent: representYamlTimestamp
|
25923
25916
|
});
|
25924
25917
|
|
25925
|
-
},{"../type":
|
25918
|
+
},{"../type":328}],345:[function(require,module,exports){
|
25926
25919
|
module.exports = compile;
|
25927
25920
|
|
25928
25921
|
var BaseFuncs = require("boolbase"),
|
@@ -25963,7 +25956,7 @@ function compile(parsed){
|
|
25963
25956
|
return pos <= b && pos % a === bMod;
|
25964
25957
|
};
|
25965
25958
|
}
|
25966
|
-
},{"boolbase":2}],
|
25959
|
+
},{"boolbase":2}],346:[function(require,module,exports){
|
25967
25960
|
var parse = require("./parse.js"),
|
25968
25961
|
compile = require("./compile.js");
|
25969
25962
|
|
@@ -25973,7 +25966,7 @@ module.exports = function nthCheck(formula){
|
|
25973
25966
|
|
25974
25967
|
module.exports.parse = parse;
|
25975
25968
|
module.exports.compile = compile;
|
25976
|
-
},{"./compile.js":
|
25969
|
+
},{"./compile.js":345,"./parse.js":347}],347:[function(require,module,exports){
|
25977
25970
|
module.exports = parse;
|
25978
25971
|
|
25979
25972
|
//following http://www.w3.org/TR/css3-selectors/#nth-child-pseudo
|
@@ -26015,7 +26008,7 @@ function parse(formula){
|
|
26015
26008
|
}
|
26016
26009
|
}
|
26017
26010
|
|
26018
|
-
},{}],
|
26011
|
+
},{}],348:[function(require,module,exports){
|
26019
26012
|
'use strict';
|
26020
26013
|
|
26021
26014
|
// modified from https://github.com/es-shims/es5-shim
|
@@ -26158,7 +26151,7 @@ keysShim.shim = function shimObjectKeys() {
|
|
26158
26151
|
|
26159
26152
|
module.exports = keysShim;
|
26160
26153
|
|
26161
|
-
},{"./isArguments":
|
26154
|
+
},{"./isArguments":349}],349:[function(require,module,exports){
|
26162
26155
|
'use strict';
|
26163
26156
|
|
26164
26157
|
var toStr = Object.prototype.toString;
|
@@ -26177,7 +26170,7 @@ module.exports = function isArguments(value) {
|
|
26177
26170
|
return isArgs;
|
26178
26171
|
};
|
26179
26172
|
|
26180
|
-
},{}],
|
26173
|
+
},{}],350:[function(require,module,exports){
|
26181
26174
|
'use strict';
|
26182
26175
|
|
26183
26176
|
var ES = require('es-abstract/es7');
|
@@ -26196,7 +26189,7 @@ module.exports = function values(O) {
|
|
26196
26189
|
return vals;
|
26197
26190
|
};
|
26198
26191
|
|
26199
|
-
},{"es-abstract/es7":291,"function-bind":304,"has":307}],
|
26192
|
+
},{"es-abstract/es7":291,"function-bind":304,"has":307}],351:[function(require,module,exports){
|
26200
26193
|
'use strict';
|
26201
26194
|
|
26202
26195
|
var define = require('define-properties');
|
@@ -26215,7 +26208,7 @@ define(polyfill, {
|
|
26215
26208
|
|
26216
26209
|
module.exports = polyfill;
|
26217
26210
|
|
26218
|
-
},{"./implementation":
|
26211
|
+
},{"./implementation":350,"./polyfill":352,"./shim":353,"define-properties":268}],352:[function(require,module,exports){
|
26219
26212
|
'use strict';
|
26220
26213
|
|
26221
26214
|
var implementation = require('./implementation');
|
@@ -26224,7 +26217,7 @@ module.exports = function getPolyfill() {
|
|
26224
26217
|
return typeof Object.values === 'function' ? Object.values : implementation;
|
26225
26218
|
};
|
26226
26219
|
|
26227
|
-
},{"./implementation":
|
26220
|
+
},{"./implementation":350}],353:[function(require,module,exports){
|
26228
26221
|
'use strict';
|
26229
26222
|
|
26230
26223
|
var getPolyfill = require('./polyfill');
|
@@ -26240,7 +26233,7 @@ module.exports = function shimValues() {
|
|
26240
26233
|
return polyfill;
|
26241
26234
|
};
|
26242
26235
|
|
26243
|
-
},{"./polyfill":
|
26236
|
+
},{"./polyfill":352,"define-properties":268}],354:[function(require,module,exports){
|
26244
26237
|
exports.endianness = function () { return 'LE' };
|
26245
26238
|
|
26246
26239
|
exports.hostname = function () {
|
@@ -26291,7 +26284,7 @@ exports.homedir = function () {
|
|
26291
26284
|
return '/'
|
26292
26285
|
};
|
26293
26286
|
|
26294
|
-
},{}],
|
26287
|
+
},{}],355:[function(require,module,exports){
|
26295
26288
|
(function (process){
|
26296
26289
|
// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
|
26297
26290
|
// backported and transplited with Babel, with backwards-compat fixes
|
@@ -26597,7 +26590,7 @@ var substr = 'ab'.substr(-1) === 'b'
|
|
26597
26590
|
;
|
26598
26591
|
|
26599
26592
|
}).call(this,require('_process'))
|
26600
|
-
},{"_process":
|
26593
|
+
},{"_process":357}],356:[function(require,module,exports){
|
26601
26594
|
(function (process){
|
26602
26595
|
'use strict';
|
26603
26596
|
|
@@ -26645,7 +26638,7 @@ function nextTick(fn, arg1, arg2, arg3) {
|
|
26645
26638
|
|
26646
26639
|
|
26647
26640
|
}).call(this,require('_process'))
|
26648
|
-
},{"_process":
|
26641
|
+
},{"_process":357}],357:[function(require,module,exports){
|
26649
26642
|
// shim for using process in browser
|
26650
26643
|
var process = module.exports = {};
|
26651
26644
|
|
@@ -26831,10 +26824,10 @@ process.chdir = function (dir) {
|
|
26831
26824
|
};
|
26832
26825
|
process.umask = function() { return 0; };
|
26833
26826
|
|
26834
|
-
},{}],
|
26827
|
+
},{}],358:[function(require,module,exports){
|
26835
26828
|
module.exports = require('./lib/_stream_duplex.js');
|
26836
26829
|
|
26837
|
-
},{"./lib/_stream_duplex.js":
|
26830
|
+
},{"./lib/_stream_duplex.js":359}],359:[function(require,module,exports){
|
26838
26831
|
// Copyright Joyent, Inc. and other Node contributors.
|
26839
26832
|
//
|
26840
26833
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
@@ -26966,7 +26959,7 @@ Duplex.prototype._destroy = function (err, cb) {
|
|
26966
26959
|
|
26967
26960
|
pna.nextTick(cb, err);
|
26968
26961
|
};
|
26969
|
-
},{"./_stream_readable":
|
26962
|
+
},{"./_stream_readable":361,"./_stream_writable":363,"core-util-is":6,"inherits":309,"process-nextick-args":356}],360:[function(require,module,exports){
|
26970
26963
|
// Copyright Joyent, Inc. and other Node contributors.
|
26971
26964
|
//
|
26972
26965
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
@@ -27014,7 +27007,7 @@ function PassThrough(options) {
|
|
27014
27007
|
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
27015
27008
|
cb(null, chunk);
|
27016
27009
|
};
|
27017
|
-
},{"./_stream_transform":
|
27010
|
+
},{"./_stream_transform":362,"core-util-is":6,"inherits":309}],361:[function(require,module,exports){
|
27018
27011
|
(function (process,global){
|
27019
27012
|
// Copyright Joyent, Inc. and other Node contributors.
|
27020
27013
|
//
|
@@ -28036,7 +28029,7 @@ function indexOf(xs, x) {
|
|
28036
28029
|
return -1;
|
28037
28030
|
}
|
28038
28031
|
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
28039
|
-
},{"./_stream_duplex":
|
28032
|
+
},{"./_stream_duplex":359,"./internal/streams/BufferList":364,"./internal/streams/destroy":365,"./internal/streams/stream":366,"_process":357,"core-util-is":6,"events":302,"inherits":309,"isarray":367,"process-nextick-args":356,"safe-buffer":372,"string_decoder/":387,"util":3}],362:[function(require,module,exports){
|
28040
28033
|
// Copyright Joyent, Inc. and other Node contributors.
|
28041
28034
|
//
|
28042
28035
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
@@ -28251,7 +28244,7 @@ function done(stream, er, data) {
|
|
28251
28244
|
|
28252
28245
|
return stream.push(null);
|
28253
28246
|
}
|
28254
|
-
},{"./_stream_duplex":
|
28247
|
+
},{"./_stream_duplex":359,"core-util-is":6,"inherits":309}],363:[function(require,module,exports){
|
28255
28248
|
(function (process,global,setImmediate){
|
28256
28249
|
// Copyright Joyent, Inc. and other Node contributors.
|
28257
28250
|
//
|
@@ -28941,7 +28934,7 @@ Writable.prototype._destroy = function (err, cb) {
|
|
28941
28934
|
cb(err);
|
28942
28935
|
};
|
28943
28936
|
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").setImmediate)
|
28944
|
-
},{"./_stream_duplex":
|
28937
|
+
},{"./_stream_duplex":359,"./internal/streams/destroy":365,"./internal/streams/stream":366,"_process":357,"core-util-is":6,"inherits":309,"process-nextick-args":356,"safe-buffer":372,"timers":444,"util-deprecate":446}],364:[function(require,module,exports){
|
28945
28938
|
'use strict';
|
28946
28939
|
|
28947
28940
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
@@ -29021,7 +29014,7 @@ if (util && util.inspect && util.inspect.custom) {
|
|
29021
29014
|
return this.constructor.name + ' ' + obj;
|
29022
29015
|
};
|
29023
29016
|
}
|
29024
|
-
},{"safe-buffer":372,"util":3}],
|
29017
|
+
},{"safe-buffer":372,"util":3}],365:[function(require,module,exports){
|
29025
29018
|
'use strict';
|
29026
29019
|
|
29027
29020
|
/*<replacement>*/
|
@@ -29096,10 +29089,17 @@ module.exports = {
|
|
29096
29089
|
destroy: destroy,
|
29097
29090
|
undestroy: undestroy
|
29098
29091
|
};
|
29099
|
-
},{"process-nextick-args":
|
29092
|
+
},{"process-nextick-args":356}],366:[function(require,module,exports){
|
29100
29093
|
module.exports = require('events').EventEmitter;
|
29101
29094
|
|
29102
|
-
},{"events":302}],
|
29095
|
+
},{"events":302}],367:[function(require,module,exports){
|
29096
|
+
var toString = {}.toString;
|
29097
|
+
|
29098
|
+
module.exports = Array.isArray || function (arr) {
|
29099
|
+
return toString.call(arr) == '[object Array]';
|
29100
|
+
};
|
29101
|
+
|
29102
|
+
},{}],368:[function(require,module,exports){
|
29103
29103
|
module.exports = require('./readable').PassThrough
|
29104
29104
|
|
29105
29105
|
},{"./readable":369}],369:[function(require,module,exports){
|
@@ -29111,13 +29111,13 @@ exports.Duplex = require('./lib/_stream_duplex.js');
|
|
29111
29111
|
exports.Transform = require('./lib/_stream_transform.js');
|
29112
29112
|
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
29113
29113
|
|
29114
|
-
},{"./lib/_stream_duplex.js":
|
29114
|
+
},{"./lib/_stream_duplex.js":359,"./lib/_stream_passthrough.js":360,"./lib/_stream_readable.js":361,"./lib/_stream_transform.js":362,"./lib/_stream_writable.js":363}],370:[function(require,module,exports){
|
29115
29115
|
module.exports = require('./readable').Transform
|
29116
29116
|
|
29117
29117
|
},{"./readable":369}],371:[function(require,module,exports){
|
29118
29118
|
module.exports = require('./lib/_stream_writable.js');
|
29119
29119
|
|
29120
|
-
},{"./lib/_stream_writable.js":
|
29120
|
+
},{"./lib/_stream_writable.js":363}],372:[function(require,module,exports){
|
29121
29121
|
/* eslint-disable node/no-deprecated-api */
|
29122
29122
|
var buffer = require('buffer')
|
29123
29123
|
var Buffer = buffer.Buffer
|
@@ -33980,7 +33980,7 @@ Stream.prototype.pipe = function(dest, options) {
|
|
33980
33980
|
return dest;
|
33981
33981
|
};
|
33982
33982
|
|
33983
|
-
},{"events":302,"inherits":309,"readable-stream/duplex.js":
|
33983
|
+
},{"events":302,"inherits":309,"readable-stream/duplex.js":358,"readable-stream/passthrough.js":368,"readable-stream/readable.js":369,"readable-stream/transform.js":370,"readable-stream/writable.js":371}],387:[function(require,module,exports){
|
33984
33984
|
// Copyright Joyent, Inc. and other Node contributors.
|
33985
33985
|
//
|
33986
33986
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
@@ -34719,7 +34719,7 @@ function optimizePluginsArray(plugins) {
|
|
34719
34719
|
}
|
34720
34720
|
|
34721
34721
|
}).call(this,"/node_modules/svgo/lib/svgo")
|
34722
|
-
},{"fs":4,"js-yaml":
|
34722
|
+
},{"fs":4,"js-yaml":315}],390:[function(require,module,exports){
|
34723
34723
|
'use strict';
|
34724
34724
|
|
34725
34725
|
var values = require('object.values');
|
@@ -34858,7 +34858,7 @@ CSSClassList.prototype.contains = function(className) {
|
|
34858
34858
|
|
34859
34859
|
|
34860
34860
|
module.exports = CSSClassList;
|
34861
|
-
},{"object.values":
|
34861
|
+
},{"object.values":351}],391:[function(require,module,exports){
|
34862
34862
|
'use strict';
|
34863
34863
|
|
34864
34864
|
var baseCssAdapter = require('css-select-base-adapter');
|
@@ -35550,7 +35550,7 @@ JS2SVG.prototype.createText = function(text) {
|
|
35550
35550
|
|
35551
35551
|
};
|
35552
35552
|
|
35553
|
-
},{"../../plugins/_collections.js":398,"os":
|
35553
|
+
},{"../../plugins/_collections.js":398,"os":354}],394:[function(require,module,exports){
|
35554
35554
|
'use strict';
|
35555
35555
|
|
35556
35556
|
var cssSelect = require('css-select');
|
@@ -43669,7 +43669,7 @@ exports.fn = function(node, opts, extra) {
|
|
43669
43669
|
return node;
|
43670
43670
|
};
|
43671
43671
|
|
43672
|
-
},{"./_collections.js":398,"css-tree":19,"css-url-regex":119,"path":
|
43672
|
+
},{"./_collections.js":398,"css-tree":19,"css-url-regex":119,"path":355,"unquote":445}],420:[function(require,module,exports){
|
43673
43673
|
'use strict';
|
43674
43674
|
|
43675
43675
|
exports.type = 'perItem';
|
@@ -45167,7 +45167,7 @@ exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate :
|
|
45167
45167
|
delete immediateIds[id];
|
45168
45168
|
};
|
45169
45169
|
}).call(this,require("timers").setImmediate,require("timers").clearImmediate)
|
45170
|
-
},{"process/browser.js":
|
45170
|
+
},{"process/browser.js":357,"timers":444}],445:[function(require,module,exports){
|
45171
45171
|
var reg = /[\'\"]/
|
45172
45172
|
|
45173
45173
|
module.exports = function unquote(str) {
|
@@ -45335,7 +45335,7 @@ function SVGO(options) {
|
|
45335
45335
|
var lastSize = Number.POSITIVE_INFINITY;
|
45336
45336
|
var newSize = 0;
|
45337
45337
|
var counter = 0;
|
45338
|
-
|
45338
|
+
self.svgjs = undefined;
|
45339
45339
|
SVG2JS(svgstr, function(svgjs) {
|
45340
45340
|
if (svgjs.error) {
|
45341
45341
|
// If we don't have anything yet, throw an exception.
|
@@ -45363,8 +45363,12 @@ function SVGO(options) {
|
|
45363
45363
|
self.svgjs = svgjs;
|
45364
45364
|
}
|
45365
45365
|
});
|
45366
|
+
var xml;
|
45367
|
+
if (self.svgjs !== undefined && typeof self.svgjs.content !== "undefined") {
|
45368
|
+
xml = JS2SVG(self.svgjs, self.options.js2svg).data;
|
45369
|
+
}
|
45366
45370
|
return {
|
45367
|
-
data:
|
45371
|
+
data: xml,
|
45368
45372
|
errors: errors,
|
45369
45373
|
passes: counter
|
45370
45374
|
};
|
@@ -45388,5 +45392,6 @@ module.exports = function(options, data) {
|
|
45388
45392
|
var svgoContext = new SVGO(options);
|
45389
45393
|
return svgoContext.optimize(data);
|
45390
45394
|
};
|
45395
|
+
|
45391
45396
|
},{"../node_modules/svgo/lib/svgo/config.js":389,"../node_modules/svgo/lib/svgo/js2svg.js":393,"../node_modules/svgo/lib/svgo/plugins.js":395,"../node_modules/svgo/lib/svgo/svg2js.js":396,"../node_modules/svgo/plugins/addAttributesToSVGElement":401,"../node_modules/svgo/plugins/addClassesToSVGElement":402,"../node_modules/svgo/plugins/cleanupAttrs":403,"../node_modules/svgo/plugins/cleanupEnableBackground":404,"../node_modules/svgo/plugins/cleanupIDs":405,"../node_modules/svgo/plugins/cleanupListOfValues":406,"../node_modules/svgo/plugins/cleanupNumericValues":407,"../node_modules/svgo/plugins/collapseGroups":408,"../node_modules/svgo/plugins/convertColors":409,"../node_modules/svgo/plugins/convertPathData":410,"../node_modules/svgo/plugins/convertShapeToPath":411,"../node_modules/svgo/plugins/convertStyleToAttrs":412,"../node_modules/svgo/plugins/convertTransform":413,"../node_modules/svgo/plugins/inlineStyles":414,"../node_modules/svgo/plugins/mergePaths":415,"../node_modules/svgo/plugins/minifyStyles":416,"../node_modules/svgo/plugins/moveElemsAttrsToGroup":417,"../node_modules/svgo/plugins/moveGroupAttrsToElems":418,"../node_modules/svgo/plugins/prefixIds":419,"../node_modules/svgo/plugins/removeComments":420,"../node_modules/svgo/plugins/removeDesc":421,"../node_modules/svgo/plugins/removeDimensions":422,"../node_modules/svgo/plugins/removeDoctype":423,"../node_modules/svgo/plugins/removeEditorsNSData":424,"../node_modules/svgo/plugins/removeElementsByAttr":425,"../node_modules/svgo/plugins/removeEmptyAttrs":426,"../node_modules/svgo/plugins/removeEmptyContainers":427,"../node_modules/svgo/plugins/removeEmptyText":428,"../node_modules/svgo/plugins/removeHiddenElems":429,"../node_modules/svgo/plugins/removeMetadata":430,"../node_modules/svgo/plugins/removeNonInheritableGroupAttrs":431,"../node_modules/svgo/plugins/removeRasterImages":432,"../node_modules/svgo/plugins/removeScriptElement":433,"../node_modules/svgo/plugins/removeStyleElement":434,"../node_modules/svgo/plugins/removeTitle":435,"../node_modules/svgo/plugins/removeUnknownsAndDefaults":436,"../node_modules/svgo/plugins/removeUnusedNS":437,"../node_modules/svgo/plugins/removeUselessDefs":438,"../node_modules/svgo/plugins/removeUselessStrokeAndFill":439,"../node_modules/svgo/plugins/removeViewBox":440,"../node_modules/svgo/plugins/removeXMLNS":441,"../node_modules/svgo/plugins/removeXMLProcInst":442,"../node_modules/svgo/plugins/sortAttrs":443}]},{},[447])(447)
|
45392
45397
|
});
|
data/svgo-js/svgo-wrapper.js
CHANGED
@@ -78,7 +78,7 @@ function SVGO(options) {
|
|
78
78
|
var lastSize = Number.POSITIVE_INFINITY;
|
79
79
|
var newSize = 0;
|
80
80
|
var counter = 0;
|
81
|
-
|
81
|
+
self.svgjs = undefined;
|
82
82
|
SVG2JS(svgstr, function(svgjs) {
|
83
83
|
if (svgjs.error) {
|
84
84
|
// If we don't have anything yet, throw an exception.
|
@@ -106,8 +106,12 @@ function SVGO(options) {
|
|
106
106
|
self.svgjs = svgjs;
|
107
107
|
}
|
108
108
|
});
|
109
|
+
var xml;
|
110
|
+
if (self.svgjs !== undefined && typeof self.svgjs.content !== "undefined") {
|
111
|
+
xml = JS2SVG(self.svgjs, self.options.js2svg).data;
|
112
|
+
}
|
109
113
|
return {
|
110
|
-
data:
|
114
|
+
data: xml,
|
111
115
|
errors: errors,
|
112
116
|
passes: counter
|
113
117
|
};
|
@@ -130,4 +134,4 @@ module.exports = function(options, data) {
|
|
130
134
|
options.full = true;
|
131
135
|
var svgoContext = new SVGO(options);
|
132
136
|
return svgoContext.optimize(data);
|
133
|
-
};
|
137
|
+
};
|