google-closure-compiler 20250412.0.0-nightly → 20250413.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -30
- package/cli.js +3 -4
- package/externs/browser/decorators.js +276 -0
- package/externs/browser/deprecated.js +58 -0
- package/externs/browser/es6_proxy.js +143 -0
- package/externs/browser/fetchapi.js +449 -0
- package/externs/browser/fido.js +94 -0
- package/externs/browser/flash.js +226 -0
- package/externs/browser/gecko_css.js +126 -0
- package/externs/browser/gecko_dom.js +479 -0
- package/externs/browser/gecko_event.js +86 -0
- package/externs/browser/gecko_xml.js +73 -0
- package/externs/browser/google_legacy.js +31 -0
- package/externs/browser/html5.js +6647 -0
- package/externs/browser/ie_css.js +270 -0
- package/externs/browser/ie_dom.js +1232 -0
- package/externs/browser/ie_event.js +310 -0
- package/externs/browser/ie_vml.js +77 -0
- package/externs/browser/intersection_observer.js +178 -0
- package/externs/browser/intl.js +602 -0
- package/externs/browser/iphone.js +204 -0
- package/externs/browser/mediakeys.js +305 -0
- package/externs/browser/mediasource.js +155 -0
- package/externs/browser/nonstandard_anim_timing.js +97 -0
- package/externs/browser/nonstandard_audio.js +82 -0
- package/externs/browser/nonstandard_console.js +75 -0
- package/externs/browser/nonstandard_fileapi.js +1066 -0
- package/externs/browser/nonstandard_indexeddb.js +78 -0
- package/externs/browser/nonstandard_navigation_timing.js +38 -0
- package/externs/browser/nonstandard_selection.js +80 -0
- package/externs/browser/page_visibility.js +28 -0
- package/externs/browser/streamsapi.js +593 -0
- package/externs/browser/svg.js +10016 -0
- package/externs/browser/url.js +202 -0
- package/externs/browser/v8.js +134 -0
- package/externs/browser/w3c_abort.js +89 -0
- package/externs/browser/w3c_anim_timing.js +49 -0
- package/externs/browser/w3c_aria_mixin.js +286 -0
- package/externs/browser/w3c_audio.js +1660 -0
- package/externs/browser/w3c_batterystatus.js +85 -0
- package/externs/browser/w3c_clipboard.js +74 -0
- package/externs/browser/w3c_clipboardevent.js +47 -0
- package/externs/browser/w3c_composition_event.js +93 -0
- package/externs/browser/w3c_css.js +3790 -0
- package/externs/browser/w3c_css3d.js +199 -0
- package/externs/browser/w3c_device_sensor_event.js +122 -0
- package/externs/browser/w3c_dom1.js +1160 -0
- package/externs/browser/w3c_dom2.js +3151 -0
- package/externs/browser/w3c_dom3.js +555 -0
- package/externs/browser/w3c_dom4.js +289 -0
- package/externs/browser/w3c_elementtraversal.js +116 -0
- package/externs/browser/w3c_event.js +607 -0
- package/externs/browser/w3c_event3.js +77 -0
- package/externs/browser/w3c_eventsource.js +110 -0
- package/externs/browser/w3c_fileapi.js +302 -0
- package/externs/browser/w3c_gamepad.js +113 -0
- package/externs/browser/w3c_geolocation.js +130 -0
- package/externs/browser/w3c_geometry1.js +899 -0
- package/externs/browser/w3c_indexeddb.js +771 -0
- package/externs/browser/w3c_keyboardlock.js +47 -0
- package/externs/browser/w3c_mediacapabilities.js +206 -0
- package/externs/browser/w3c_midi.js +301 -0
- package/externs/browser/w3c_navigation.js +72 -0
- package/externs/browser/w3c_navigation_timing.js +437 -0
- package/externs/browser/w3c_netinfo.js +85 -0
- package/externs/browser/w3c_payment_request.js +401 -0
- package/externs/browser/w3c_permissions.js +112 -0
- package/externs/browser/w3c_permissions_policy.js +78 -0
- package/externs/browser/w3c_pointer_events.js +163 -0
- package/externs/browser/w3c_pointerlock.js +63 -0
- package/externs/browser/w3c_range.js +284 -0
- package/externs/browser/w3c_referrer_policy.js +36 -0
- package/externs/browser/w3c_requestidlecallback.js +76 -0
- package/externs/browser/w3c_rtc.js +3882 -0
- package/externs/browser/w3c_screen_orientation.js +53 -0
- package/externs/browser/w3c_screen_wake_lock.js +58 -0
- package/externs/browser/w3c_selection.js +209 -0
- package/externs/browser/w3c_selectors.js +113 -0
- package/externs/browser/w3c_serviceworker.js +739 -0
- package/externs/browser/w3c_speech.js +426 -0
- package/externs/browser/w3c_touch_event.js +296 -0
- package/externs/browser/w3c_trusted_types.js +142 -0
- package/externs/browser/w3c_vibration.js +38 -0
- package/externs/browser/w3c_webcodecs.js +1473 -0
- package/externs/browser/w3c_webcrypto.js +839 -0
- package/externs/browser/w3c_worklets.js +54 -0
- package/externs/browser/w3c_xml.js +533 -0
- package/externs/browser/web_animations.js +452 -0
- package/externs/browser/web_app_manifest.js +50 -0
- package/externs/browser/webassembly.js +223 -0
- package/externs/browser/webgl.js +3409 -0
- package/externs/browser/webgl2.js +2727 -0
- package/externs/browser/webgl2_compute.js +1609 -0
- package/externs/browser/webkit_css.js +456 -0
- package/externs/browser/webkit_dom.js +118 -0
- package/externs/browser/webkit_event.js +46 -0
- package/externs/browser/webkit_notifications.js +258 -0
- package/externs/browser/webkit_usercontent.js +55 -0
- package/externs/browser/weblocksapi.js +125 -0
- package/externs/browser/webstorage.js +171 -0
- package/externs/browser/whatwg_bitmap_context.js +37 -0
- package/externs/browser/whatwg_console.js +152 -0
- package/externs/browser/whatwg_encoding.js +99 -0
- package/externs/browser/whatwg_file_system.js +296 -0
- package/externs/browser/wicg_attribution_reporting.js +42 -0
- package/externs/browser/wicg_compression_stream.js +60 -0
- package/externs/browser/wicg_constructable_stylesheets.js +60 -0
- package/externs/browser/wicg_entries.js +169 -0
- package/externs/browser/wicg_file_handling.js +41 -0
- package/externs/browser/wicg_file_system_access.js +191 -0
- package/externs/browser/wicg_floc.js +41 -0
- package/externs/browser/wicg_ink.js +89 -0
- package/externs/browser/wicg_resizeobserver.js +100 -0
- package/externs/browser/wicg_scheduler.js +62 -0
- package/externs/browser/wicg_trust_token.js +89 -0
- package/externs/browser/wicg_uach.js +100 -0
- package/externs/browser/window.js +190 -0
- package/externs/es3.js +2716 -0
- package/externs/es5.js +284 -0
- package/externs/es6.js +2554 -0
- package/externs/es6_collections.js +323 -0
- package/index.js +13 -16
- package/lib/grunt/index.js +71 -92
- package/lib/grunt/vinyl-stream.js +12 -18
- package/lib/gulp/concat-to-json.js +30 -18
- package/lib/gulp/index.js +174 -181
- package/lib/gulp/json-to-vinyl.js +8 -8
- package/lib/node/{closure-compiler.js → index.js} +27 -51
- package/lib/utils.js +16 -14
- package/package.json +19 -16
- package/lib/logger.js +0 -89
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2014 The Closure Compiler Authors
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @fileoverview Definitions for ECMAScript 6.
|
|
19
|
+
* @see http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts
|
|
20
|
+
* @externs
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
// TODO(johnlenz): Use Tuples for the Map and Set iterators where appropriate.
|
|
24
|
+
/**
|
|
25
|
+
* @interface
|
|
26
|
+
* @extends {Iterable<!Array<K|V>>}
|
|
27
|
+
* @template K, V
|
|
28
|
+
*/
|
|
29
|
+
function ReadonlyMap() {}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @return {!IteratorIterable<!Array<K|V>>}
|
|
33
|
+
* @nosideeffects
|
|
34
|
+
*/
|
|
35
|
+
ReadonlyMap.prototype.entries = function() {};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param {function(this:THIS, V, K, MAP): ?} callback
|
|
39
|
+
* @param {THIS=} opt_thisArg
|
|
40
|
+
* @this {MAP}
|
|
41
|
+
* @template MAP, THIS
|
|
42
|
+
* @return {undefined}
|
|
43
|
+
*/
|
|
44
|
+
ReadonlyMap.prototype.forEach = function(callback, opt_thisArg) {};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @param {K} key
|
|
48
|
+
* @return {V|undefined}
|
|
49
|
+
* @nosideeffects
|
|
50
|
+
*/
|
|
51
|
+
ReadonlyMap.prototype.get = function(key) {};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {K} key
|
|
55
|
+
* @return {boolean}
|
|
56
|
+
* @nosideeffects
|
|
57
|
+
*/
|
|
58
|
+
ReadonlyMap.prototype.has = function(key) {};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @return {!IteratorIterable<K>}
|
|
62
|
+
* @nosideeffects
|
|
63
|
+
*/
|
|
64
|
+
ReadonlyMap.prototype.keys = function() {};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @const {number}
|
|
68
|
+
* @nosideeffects
|
|
69
|
+
*/
|
|
70
|
+
ReadonlyMap.prototype.size;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @return {!IteratorIterable<V>}
|
|
74
|
+
* @nosideeffects
|
|
75
|
+
*/
|
|
76
|
+
ReadonlyMap.prototype.values = function() {};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @return {!Iterator<!Array<K|V>>}
|
|
80
|
+
* @nosideeffects
|
|
81
|
+
*/
|
|
82
|
+
ReadonlyMap.prototype[Symbol.iterator] = function() {};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @constructor @struct
|
|
86
|
+
* @param {Iterable<!Array<K|V>>|!Array<!Array<K|V>>=} opt_iterable
|
|
87
|
+
* @implements {ReadonlyMap<K, V>}
|
|
88
|
+
* @template K, V
|
|
89
|
+
* @nosideeffects
|
|
90
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
|
|
91
|
+
*/
|
|
92
|
+
function Map(opt_iterable) {}
|
|
93
|
+
|
|
94
|
+
/** @return {void} */
|
|
95
|
+
Map.prototype.clear = function() {};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @param {K} key
|
|
99
|
+
* @return {boolean}
|
|
100
|
+
*/
|
|
101
|
+
Map.prototype.delete = function(key) {};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @override
|
|
105
|
+
* @return {!IteratorIterable<!Array<K|V>>}
|
|
106
|
+
* @nosideeffects
|
|
107
|
+
*/
|
|
108
|
+
Map.prototype.entries = function() {};
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @override
|
|
112
|
+
* @param {function(this:THIS, V, K, MAP): ?} callback
|
|
113
|
+
* @param {THIS=} opt_thisArg
|
|
114
|
+
* @this {MAP}
|
|
115
|
+
* @template MAP,THIS
|
|
116
|
+
* @return {undefined}
|
|
117
|
+
*/
|
|
118
|
+
Map.prototype.forEach = function(callback, opt_thisArg) {};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @override
|
|
122
|
+
* @param {K} key
|
|
123
|
+
* @return {V}
|
|
124
|
+
* @nosideeffects
|
|
125
|
+
*/
|
|
126
|
+
Map.prototype.get = function(key) {};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @override
|
|
130
|
+
* @param {K} key
|
|
131
|
+
* @return {boolean}
|
|
132
|
+
* @nosideeffects
|
|
133
|
+
*/
|
|
134
|
+
Map.prototype.has = function(key) {};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @override
|
|
138
|
+
* @return {!IteratorIterable<K>}
|
|
139
|
+
* @nosideeffects
|
|
140
|
+
*/
|
|
141
|
+
Map.prototype.keys = function() {};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @param {K} key
|
|
145
|
+
* @param {V} value
|
|
146
|
+
* @return {THIS}
|
|
147
|
+
* @this {THIS}
|
|
148
|
+
* @template THIS
|
|
149
|
+
*/
|
|
150
|
+
Map.prototype.set = function(key, value) {};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @override
|
|
154
|
+
* @type {number}
|
|
155
|
+
* @nosideeffects
|
|
156
|
+
*/
|
|
157
|
+
Map.prototype.size;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @override
|
|
161
|
+
* @return {!IteratorIterable<V>}
|
|
162
|
+
* @nosideeffects
|
|
163
|
+
*/
|
|
164
|
+
Map.prototype.values = function() {};
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @override
|
|
168
|
+
* @return {!Iterator<!Array<K|V>>}
|
|
169
|
+
* @nosideeffects
|
|
170
|
+
*/
|
|
171
|
+
Map.prototype[Symbol.iterator] = function() {};
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @constructor @struct
|
|
176
|
+
* @param {Iterable<!Array<K|V>>|!Array<!Array<K|V>>=} opt_iterable
|
|
177
|
+
* @template K, V
|
|
178
|
+
* @nosideeffects
|
|
179
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap
|
|
180
|
+
*/
|
|
181
|
+
function WeakMap(opt_iterable) {}
|
|
182
|
+
|
|
183
|
+
/** @return {void} */
|
|
184
|
+
WeakMap.prototype.clear = function() {};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @param {K} key
|
|
188
|
+
* @return {boolean}
|
|
189
|
+
*/
|
|
190
|
+
WeakMap.prototype.delete = function(key) {};
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @param {K} key
|
|
194
|
+
* @return {V}
|
|
195
|
+
* @nosideeffects
|
|
196
|
+
*/
|
|
197
|
+
WeakMap.prototype.get = function(key) {};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @param {K} key
|
|
201
|
+
* @return {boolean}
|
|
202
|
+
* @nosideeffects
|
|
203
|
+
*/
|
|
204
|
+
WeakMap.prototype.has = function(key) {};
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @param {K} key
|
|
208
|
+
* @param {V} value
|
|
209
|
+
* @return {THIS}
|
|
210
|
+
* @this {THIS}
|
|
211
|
+
* @template THIS
|
|
212
|
+
*/
|
|
213
|
+
WeakMap.prototype.set = function(key, value) {};
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @constructor @struct
|
|
217
|
+
* @param {Iterable<VALUE>|Array<VALUE>=} opt_iterable
|
|
218
|
+
* @implements {Iterable<VALUE>}
|
|
219
|
+
* @template VALUE
|
|
220
|
+
* @nosideeffects
|
|
221
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
222
|
+
*/
|
|
223
|
+
function Set(opt_iterable) {}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* @param {VALUE} value
|
|
227
|
+
* @return {THIS}
|
|
228
|
+
* @this {THIS}
|
|
229
|
+
* @template THIS
|
|
230
|
+
*/
|
|
231
|
+
Set.prototype.add = function(value) {};
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @return {void}
|
|
235
|
+
*/
|
|
236
|
+
Set.prototype.clear = function() {};
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @param {VALUE} value
|
|
240
|
+
* @return {boolean}
|
|
241
|
+
*/
|
|
242
|
+
Set.prototype.delete = function(value) {};
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @return {!IteratorIterable<!Array<VALUE>>} Where each array has two entries:
|
|
246
|
+
* [value, value]
|
|
247
|
+
* @nosideeffects
|
|
248
|
+
*/
|
|
249
|
+
Set.prototype.entries = function() {};
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* @param {function(this: THIS, VALUE, VALUE, SET)} callback
|
|
253
|
+
* @param {THIS=} opt_thisArg
|
|
254
|
+
* @this {SET}
|
|
255
|
+
* @template SET,THIS
|
|
256
|
+
*/
|
|
257
|
+
Set.prototype.forEach = function(callback, opt_thisArg) {};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* @param {VALUE} value
|
|
261
|
+
* @return {boolean}
|
|
262
|
+
* @nosideeffects
|
|
263
|
+
*/
|
|
264
|
+
Set.prototype.has = function(value) {};
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @type {number} (readonly)
|
|
268
|
+
*/
|
|
269
|
+
Set.prototype.size;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* @return {!IteratorIterable<VALUE>}
|
|
273
|
+
* @nosideeffects
|
|
274
|
+
*/
|
|
275
|
+
Set.prototype.keys = function() {};
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* @return {!IteratorIterable<VALUE>}
|
|
279
|
+
* @nosideeffects
|
|
280
|
+
*/
|
|
281
|
+
Set.prototype.values = function() {};
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @return {!Iterator<VALUE>}
|
|
285
|
+
*/
|
|
286
|
+
Set.prototype[Symbol.iterator] = function() {};
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* @constructor @struct
|
|
292
|
+
* @param {Iterable<VALUE>|Array<VALUE>=} opt_iterable
|
|
293
|
+
* @template VALUE
|
|
294
|
+
* @nosideeffects
|
|
295
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
296
|
+
*/
|
|
297
|
+
function WeakSet(opt_iterable) {}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* @param {VALUE} value
|
|
301
|
+
* @return {THIS}
|
|
302
|
+
* @this {THIS}
|
|
303
|
+
* @template THIS
|
|
304
|
+
*/
|
|
305
|
+
WeakSet.prototype.add = function(value) {};
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @return {void}
|
|
309
|
+
*/
|
|
310
|
+
WeakSet.prototype.clear = function() {};
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* @param {VALUE} value
|
|
314
|
+
* @return {boolean}
|
|
315
|
+
*/
|
|
316
|
+
WeakSet.prototype.delete = function(value) {};
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @param {VALUE} value
|
|
320
|
+
* @return {boolean}
|
|
321
|
+
* @nosideeffects
|
|
322
|
+
*/
|
|
323
|
+
WeakSet.prototype.has = function(value) {};
|
package/index.js
CHANGED
|
@@ -20,21 +20,18 @@
|
|
|
20
20
|
* @author Chad Killingsworth (chadkillingsworth@gmail.com)
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
import {fileURLToPath, URL} from 'node:url';
|
|
25
|
+
export {default as JAR_PATH} from 'google-closure-compiler-java';
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return require('./lib/grunt');
|
|
29
|
-
}
|
|
27
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
28
|
+
export const CONTRIB_PATH = path.resolve(__dirname, './contrib');
|
|
29
|
+
export const EXTERNS_PATH = path.resolve(__dirname, './externs');
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = Main;
|
|
31
|
+
export {default as grunt} from './lib/grunt/index.js';
|
|
32
|
+
export {default as gulp} from './lib/gulp/index.js';
|
|
33
|
+
export {
|
|
34
|
+
default as compiler,
|
|
35
|
+
default,
|
|
36
|
+
javaPath,
|
|
37
|
+
} from './lib/node/index.js';
|
package/lib/grunt/index.js
CHANGED
|
@@ -23,36 +23,30 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @author Chad Killingsworth (chadkillingsworth@gmail.com)
|
|
25
25
|
*/
|
|
26
|
+
import {Transform} from 'node:stream';
|
|
27
|
+
import chalk from 'chalk';
|
|
28
|
+
import gulpCompiler from '../gulp/index.js';
|
|
29
|
+
import {getFirstSupportedPlatform} from '../utils.js';
|
|
30
|
+
import VinylStream from './vinyl-stream.js';
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
module.exports = (grunt, pluginOptions) => {
|
|
30
|
-
const chalk = require('chalk');
|
|
31
|
-
const VinylStream = require('./vinyl-stream');
|
|
32
|
-
const Transform = require('stream').Transform;
|
|
32
|
+
export default (grunt, pluginOptions) => {
|
|
33
33
|
const gulpCompilerOptions = {};
|
|
34
|
-
const {getFirstSupportedPlatform} = require('../utils');
|
|
35
|
-
|
|
36
34
|
let extraArguments;
|
|
37
35
|
let platforms;
|
|
38
36
|
let maxParallelCompilations = false;
|
|
39
37
|
if (pluginOptions) {
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
if (typeof pluginOptions.max_parallel_compilations === 'number' && pluginOptions.max_parallel_compilations > 0) {
|
|
54
|
-
maxParallelCompilations = pluginOptions.max_parallel_compilations;
|
|
55
|
-
}
|
|
38
|
+
if (pluginOptions.platform) {
|
|
39
|
+
platforms = Array.isArray(pluginOptions.platform) ? pluginOptions.platform : [pluginOptions.platform];
|
|
40
|
+
}
|
|
41
|
+
if (pluginOptions.extraArguments) {
|
|
42
|
+
extraArguments = pluginOptions.extraArguments;
|
|
43
|
+
}
|
|
44
|
+
if (pluginOptions.compile_in_batches && pluginOptions.max_parallel_compilations === undefined) {
|
|
45
|
+
pluginOptions.max_parallel_compilations = pluginOptions.compile_in_batches;
|
|
46
|
+
grunt.log.warn('DEPRECATED: compile_in_batches is deprecated. Use max_parallel_compilations.');
|
|
47
|
+
}
|
|
48
|
+
if (typeof pluginOptions.max_parallel_compilations === 'number' && pluginOptions.max_parallel_compilations > 0) {
|
|
49
|
+
maxParallelCompilations = pluginOptions.max_parallel_compilations;
|
|
56
50
|
}
|
|
57
51
|
}
|
|
58
52
|
|
|
@@ -60,31 +54,18 @@ module.exports = (grunt, pluginOptions) => {
|
|
|
60
54
|
platforms = ['native', 'java'];
|
|
61
55
|
}
|
|
62
56
|
const platform = getFirstSupportedPlatform(platforms);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
constructor() {
|
|
66
|
-
super({objectMode: true});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
_transform(file, enc, cb) {
|
|
70
|
-
grunt.file.write(file.path, file.contents);
|
|
71
|
-
this.push(file);
|
|
72
|
-
cb();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function compilationPromiseGenerator(files, options, pluginOpts) {
|
|
77
|
-
return () => compilationPromise(files, options, pluginOpts);
|
|
78
|
-
}
|
|
57
|
+
const compilationPromiseGenerator =
|
|
58
|
+
(files, options, pluginOpts) => () => compilationPromise(files, options, pluginOpts);
|
|
79
59
|
|
|
80
60
|
/**
|
|
81
|
-
* @param {Array<string
|
|
61
|
+
* @param {Array<string>|null} files
|
|
82
62
|
* @param {Object<string,string|boolean|Array<string>>|Array<string>} options
|
|
63
|
+
* @param {?} pluginOpts
|
|
83
64
|
* @return {Promise}
|
|
84
65
|
*/
|
|
85
|
-
|
|
66
|
+
const compilationPromise = (files, options, pluginOpts) => {
|
|
86
67
|
let hadError = false;
|
|
87
|
-
|
|
68
|
+
const logFile = (cb) => {
|
|
88
69
|
// If an error was encoutered, it will have already been logged
|
|
89
70
|
if (!hadError) {
|
|
90
71
|
if (options.js_output_file) {
|
|
@@ -94,7 +75,7 @@ module.exports = (grunt, pluginOptions) => {
|
|
|
94
75
|
}
|
|
95
76
|
}
|
|
96
77
|
cb();
|
|
97
|
-
}
|
|
78
|
+
};
|
|
98
79
|
|
|
99
80
|
const loggingStream = new Transform({
|
|
100
81
|
objectMode: true,
|
|
@@ -102,20 +83,20 @@ module.exports = (grunt, pluginOptions) => {
|
|
|
102
83
|
flush: logFile
|
|
103
84
|
});
|
|
104
85
|
|
|
105
|
-
return new Promise(
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
106
87
|
let stream;
|
|
107
|
-
|
|
108
|
-
|
|
88
|
+
let gulpOpts = {
|
|
89
|
+
...gulpCompilerOptions,
|
|
109
90
|
streamMode: 'IN',
|
|
110
91
|
logger: grunt.log,
|
|
111
92
|
pluginName: 'grunt-google-closure-compiler',
|
|
112
93
|
requireStreamInput: false
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
94
|
+
};
|
|
95
|
+
const compilerOpts = {
|
|
96
|
+
...gulpOpts,
|
|
97
|
+
...pluginOpts,
|
|
98
|
+
...(extraArguments ? { extraArguments } : {}),
|
|
99
|
+
};
|
|
119
100
|
if (files) {
|
|
120
101
|
// Source files were provided by grunt. Read these
|
|
121
102
|
// in to a stream of vinyl files and pipe them through
|
|
@@ -141,15 +122,41 @@ module.exports = (grunt, pluginOptions) => {
|
|
|
141
122
|
stream.pipe(loggingStream);
|
|
142
123
|
stream.resume(); //logging stream doesn't output files, so we have to manually resume;
|
|
143
124
|
});
|
|
144
|
-
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Grabs `ps` as array of promise-returning functions, separates it in `maxParallelCount`
|
|
129
|
+
* count of sequential processing consumers and runs these consumers in parallel to process
|
|
130
|
+
* all promises.
|
|
131
|
+
*
|
|
132
|
+
* @param {!Array<function():!Promise<undefined>>} ps functions returning promises
|
|
133
|
+
* @param {!number} maxParallelCount Maximum promises running in parallel
|
|
134
|
+
* @return {!Promise<undefined>|undefined}
|
|
135
|
+
*/
|
|
136
|
+
const processPromisesParallel = (ps, maxParallelCount) => {
|
|
137
|
+
// While ps is not empty grab one function, run promise from it, then repeat. Else resolve to true.
|
|
138
|
+
const goInSequence = async () => {
|
|
139
|
+
if (!ps.length) {
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
await ps.shift()();
|
|
143
|
+
return goInSequence();
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
let bulk = [];
|
|
147
|
+
// run `maxParallelCount` or lesser (if array of promises lesser) count of goInSequence
|
|
148
|
+
for (let i = 0; i < Math.min(maxParallelCount, ps.length); i++) {
|
|
149
|
+
bulk.push(goInSequence());
|
|
150
|
+
}
|
|
151
|
+
return Promise.all(bulk);
|
|
152
|
+
};
|
|
145
153
|
|
|
146
154
|
function closureCompilerGruntTask() {
|
|
147
|
-
const taskObject = this;
|
|
148
155
|
const asyncDone = this.async();
|
|
149
156
|
const compileTasks = [];
|
|
150
157
|
|
|
151
|
-
|
|
152
|
-
const opts =
|
|
158
|
+
const getCompilerOptions = () => {
|
|
159
|
+
const opts = this.options({
|
|
153
160
|
args: undefined
|
|
154
161
|
});
|
|
155
162
|
|
|
@@ -164,12 +171,12 @@ module.exports = (grunt, pluginOptions) => {
|
|
|
164
171
|
}
|
|
165
172
|
|
|
166
173
|
// Invoke the compiler once for each set of source files
|
|
167
|
-
|
|
174
|
+
for (const f of this.files) {
|
|
168
175
|
const options = getCompilerOptions();
|
|
169
176
|
|
|
170
177
|
const src = f.src.filter(filepath => {
|
|
171
178
|
if (!grunt.file.exists(filepath)) {
|
|
172
|
-
grunt.log.warn(
|
|
179
|
+
grunt.log.warn(`Source file ${chalk.cyan(filepath)} not found`);
|
|
173
180
|
return false;
|
|
174
181
|
}
|
|
175
182
|
return true;
|
|
@@ -177,19 +184,18 @@ module.exports = (grunt, pluginOptions) => {
|
|
|
177
184
|
|
|
178
185
|
// Require source files
|
|
179
186
|
if (src.length === 0) {
|
|
180
|
-
grunt.log.warn(
|
|
181
|
-
|
|
182
|
-
return;
|
|
187
|
+
grunt.log.warn(`Destination ${chalk.cyan(f.dest)} not written because src files were empty`);
|
|
188
|
+
continue;
|
|
183
189
|
} else {
|
|
184
190
|
options.compilerOpts.js_output_file = f.dest;
|
|
185
191
|
}
|
|
186
192
|
|
|
187
193
|
compileTasks.push(compilationPromiseGenerator(src, options.args || options.compilerOpts, {platform}));
|
|
188
|
-
}
|
|
194
|
+
}
|
|
189
195
|
|
|
190
196
|
// If the task was invoked without any files provided by grunt, assume that
|
|
191
197
|
// --js flags are present and we want to run the compiler anyway.
|
|
192
|
-
if (
|
|
198
|
+
if (this.files.length === 0) {
|
|
193
199
|
const options = getCompilerOptions();
|
|
194
200
|
compileTasks.push(compilationPromiseGenerator(null, options.args || options.compilerOpts, {platform}));
|
|
195
201
|
}
|
|
@@ -197,7 +203,7 @@ module.exports = (grunt, pluginOptions) => {
|
|
|
197
203
|
// Multiple invocations of the compiler can occur for a single task target. Wait until
|
|
198
204
|
// they are all completed before calling the "done" method.
|
|
199
205
|
|
|
200
|
-
return (maxParallelCompilations ? processPromisesParallel(compileTasks, maxParallelCompilations) : Promise.all(compileTasks.map(t => t())))
|
|
206
|
+
return (maxParallelCompilations ? processPromisesParallel(compileTasks, maxParallelCompilations) : Promise.all(compileTasks.map((t) => t())))
|
|
201
207
|
.then(() => asyncDone())
|
|
202
208
|
.catch((err) => {
|
|
203
209
|
grunt.log.warn(err.message);
|
|
@@ -206,33 +212,6 @@ module.exports = (grunt, pluginOptions) => {
|
|
|
206
212
|
});
|
|
207
213
|
}
|
|
208
214
|
|
|
209
|
-
/**
|
|
210
|
-
* Grabs `ps` as array of promise-returning functions, separates it in `maxParallelCount`
|
|
211
|
-
* count of sequential processing consumers and runs these consumers in parallel to process
|
|
212
|
-
* all promises.
|
|
213
|
-
*
|
|
214
|
-
* @param {!Array<function():!Promise<undefined>>} ps functions returning promises
|
|
215
|
-
* @param {!number} maxParallelCount Maximum promises running in parallel
|
|
216
|
-
* @return {!Promise<undefined>|undefined}
|
|
217
|
-
*/
|
|
218
|
-
function processPromisesParallel(ps, maxParallelCount) {
|
|
219
|
-
// While ps is not empty grab one function, run promise from it, then repeat. Else resolve to true.
|
|
220
|
-
async function goInSequence() {
|
|
221
|
-
if (!ps.length) {
|
|
222
|
-
return true;
|
|
223
|
-
}
|
|
224
|
-
await ps.shift()();
|
|
225
|
-
return goInSequence();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
let bulk = [];
|
|
229
|
-
// run `maxParallelCount` or lesser (if array of promises lesser) count of goInSequence
|
|
230
|
-
for (let i = 0; i < Math.min(maxParallelCount, ps.length); i++) {
|
|
231
|
-
bulk.push(goInSequence());
|
|
232
|
-
}
|
|
233
|
-
return Promise.all(bulk);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
215
|
grunt.registerMultiTask('closure-compiler',
|
|
237
216
|
'Minify files with Google Closure Compiler',
|
|
238
217
|
closureCompilerGruntTask);
|
|
@@ -20,14 +20,12 @@
|
|
|
20
20
|
*
|
|
21
21
|
* @author Chad Killingsworth (chadkillingsworth@gmail.com)
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
import fs from 'node:fs/promises';
|
|
24
|
+
import path from 'node:path';
|
|
25
|
+
import {Readable} from 'node:stream';
|
|
26
|
+
import File from 'vinyl';
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
const path = require('path');
|
|
27
|
-
const Readable = require('stream').Readable;
|
|
28
|
-
const File = require('vinyl');
|
|
29
|
-
|
|
30
|
-
class VinylStream extends Readable {
|
|
28
|
+
export default class VinylStream extends Readable {
|
|
31
29
|
constructor(files, opts) {
|
|
32
30
|
super({objectMode: true});
|
|
33
31
|
this._base = path.resolve(opts.base || process.cwd());
|
|
@@ -35,26 +33,22 @@ class VinylStream extends Readable {
|
|
|
35
33
|
this.resume();
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
_read() {
|
|
36
|
+
async _read() {
|
|
39
37
|
if (this._files.length === 0) {
|
|
40
38
|
this.push(null);
|
|
41
39
|
return;
|
|
42
40
|
}
|
|
43
41
|
const filepath = this._files.shift();
|
|
44
42
|
const fullpath = path.resolve(this._base, filepath);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this.emit('error', err);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
43
|
+
try {
|
|
44
|
+
const data = await fs.readFile(fullpath);
|
|
51
45
|
this.push(new File({
|
|
52
46
|
base: this._base,
|
|
53
47
|
path: fullpath,
|
|
54
48
|
contents: data
|
|
55
49
|
}));
|
|
56
|
-
})
|
|
50
|
+
} catch (err) {
|
|
51
|
+
this.emit('error', err);
|
|
52
|
+
}
|
|
57
53
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
module.exports = VinylStream;
|
|
54
|
+
};
|