weboptimizer 2.0.1169 → 2.0.1173

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/browser.d.ts CHANGED
@@ -4,6 +4,7 @@ export declare const browser: Browser;
4
4
  * Provides a generic browser api in node or web contexts.
5
5
  * @param replaceWindow - Indicates whether a potential existing window object
6
6
  * should be replaced or not.
7
+ *
7
8
  * @returns Determined environment.
8
9
  */
9
10
  export declare const getInitializedBrowser: (replaceWindow?: boolean) => Promise<InitializedBrowser>;
package/browser.js CHANGED
@@ -44,8 +44,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
44
44
 
45
45
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
46
46
 
47
- // endregion
48
- // region variables
47
+ // endregion
48
+ // region variables
49
49
  var onCreatedListener = [];
50
50
  var browser = {
51
51
  debug: false,
@@ -108,9 +108,31 @@ if (typeof TARGET_TECHNOLOGY === 'undefined' || TARGET_TECHNOLOGY === 'node')
108
108
  browser.initialized = true;
109
109
  browser.instance = new browser.DOM(template, {
110
110
  beforeParse: function beforeParse(window) {
111
+ var _global$window;
112
+
111
113
  // We want to use it in a polymorphic way.
112
- browser.window = window;
114
+ browser.window = (_global$window = global.window) !== null && _global$window !== void 0 ? _global$window : window;
113
115
  window.document.addEventListener('DOMContentLoaded', function () {
116
+ /*
117
+ Move template results into global
118
+ pre-defined dom.
119
+ */
120
+ if (global.window) {
121
+ var _iterator2 = _createForOfIteratorHelper(['head', 'body']),
122
+ _step2;
123
+
124
+ try {
125
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
126
+ var type = _step2.value;
127
+ global.window.document[type].innerHTML = window.document[type].innerHTML;
128
+ }
129
+ } catch (err) {
130
+ _iterator2.e(err);
131
+ } finally {
132
+ _iterator2.f();
133
+ }
134
+ }
135
+
114
136
  browser.domContentLoaded = true;
115
137
  });
116
138
  window.addEventListener('load', function () {
@@ -121,18 +143,18 @@ if (typeof TARGET_TECHNOLOGY === 'undefined' || TARGET_TECHNOLOGY === 'node')
121
143
  browser.domContentLoaded = browser.windowLoaded = true;
122
144
  });
123
145
 
124
- var _iterator2 = _createForOfIteratorHelper(onCreatedListener),
125
- _step2;
146
+ var _iterator3 = _createForOfIteratorHelper(onCreatedListener),
147
+ _step3;
126
148
 
127
149
  try {
128
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
129
- var callback = _step2.value;
150
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
151
+ var callback = _step3.value;
130
152
  callback();
131
153
  }
132
154
  } catch (err) {
133
- _iterator2.e(err);
155
+ _iterator3.e(err);
134
156
  } finally {
135
- _iterator2.f();
157
+ _iterator3.f();
136
158
  }
137
159
  },
138
160
  resources: 'usable',
@@ -206,18 +228,18 @@ if (typeof TARGET_TECHNOLOGY === 'undefined' || TARGET_TECHNOLOGY === 'node')
206
228
  browser.windowLoaded = true;
207
229
  });
208
230
  void _clientnode["default"].timeout(function () {
209
- var _iterator3 = _createForOfIteratorHelper(onCreatedListener),
210
- _step3;
231
+ var _iterator4 = _createForOfIteratorHelper(onCreatedListener),
232
+ _step4;
211
233
 
212
234
  try {
213
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
214
- var callback = _step3.value;
235
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
236
+ var callback = _step4.value;
215
237
  callback();
216
238
  }
217
239
  } catch (err) {
218
- _iterator3.e(err);
240
+ _iterator4.e(err);
219
241
  } finally {
220
- _iterator3.f();
242
+ _iterator4.f();
221
243
  }
222
244
  });
223
245
  } // endregion
@@ -226,6 +248,7 @@ if (typeof TARGET_TECHNOLOGY === 'undefined' || TARGET_TECHNOLOGY === 'node')
226
248
  * Provides a generic browser api in node or web contexts.
227
249
  * @param replaceWindow - Indicates whether a potential existing window object
228
250
  * should be replaced or not.
251
+ *
229
252
  * @returns Determined environment.
230
253
  */
231
254
 
package/declarations.d.ts CHANGED
@@ -25,7 +25,12 @@ declare module 'postcss-fontpath' {
25
25
  declare module 'postcss-sprites' {
26
26
  export default function(options:Partial<{
27
27
  filterBy:() => Promise<void>
28
- hooks:{onSaveSpritesheet:(_image:Mapping) => string}
28
+ hooks:{
29
+ onSaveSpritesheet:(_image:Mapping<unknown>) => string
30
+ onUpdateRule:(
31
+ _rule:PostcssNode, _token:PostcssNode, _image:Mapping<unknown>
32
+ ) => void
33
+ }
29
34
  spritePath:string
30
35
  stylesheetPath:null|string
31
36
  verbose:boolean
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "weboptimizer",
3
- "version": "2.0.1169",
3
+ "version": "2.0.1173",
4
4
  "description": "A generic web optimizer, (module) bundler and development environment.",
5
5
  "keywords": [
6
6
  "webpack",
@@ -111,7 +111,6 @@
111
111
  "devDependencies": {
112
112
  "@babel/cli": "*",
113
113
  "@babel/eslint-parser": "*",
114
- "@types/cssnano": "*",
115
114
  "@types/ejs": "*",
116
115
  "@types/favicons": "*",
117
116
  "@types/html-minifier": "*",
@@ -925,7 +924,7 @@
925
924
  "#": "The autoprefixer has to be disabled in this context since it would remove all needed vendor prefixes from the preceding processing (every prefix should be needed here).",
926
925
  "preset": [
927
926
  {
928
- "__evaluate__": "require('cssnano-preset-default')"
927
+ "__evaluate__": "optionalRequire('cssnano-preset-default')"
929
928
  },
930
929
  {
931
930
  "autoprefixer": false,
package/readme.md CHANGED
@@ -99,15 +99,15 @@ Installation
99
99
 
100
100
  Edit your **package.json** to add **one** dependency:
101
101
 
102
- #!JSON
103
-
102
+ ```JSON
103
+ ...
104
+ "dependencies": {
104
105
  ...
105
- "dependencies": {
106
- ...
107
- "weboptimizer": "latest",
108
- ...
109
- },
106
+ "weboptimizer": "latest",
110
107
  ...
108
+ },
109
+ ...
110
+ ```
111
111
 
112
112
  Update your **packages** via npm and have fun:
113
113
 
@@ -120,79 +120,79 @@ First you should specify some tasks/use-cases you want to use in you project.
120
120
  You can do this in your **package.json**. All supported scripts and some useful
121
121
  compositions are listed below:
122
122
 
123
- #!JSON
124
-
123
+ ```JSON
124
+ ...
125
+ "scripts": {
125
126
  ...
126
- "scripts": {
127
- ...
128
- "build": "weboptimizer build",
129
- "build:stats": "weboptimizer build --profile --json >/tmp/stat.json && echo 'Results successfully written to \"/tmp/stat.json\".'",
130
- "check": "yarn check:types; yarn lint",
131
- "check:types": "weboptimizer check:types",
132
- "clear": "weboptimizer clear",
133
- "document": "weboptimizer document",
134
- "lint": "weboptimizer lint",
135
- "postinstall": "weboptimizer build",
136
- "preinstall": "weboptimizer preinstall",
137
- "serve": "weboptimizer serve",
138
- "start": "npm run serve",
139
- "test": "weboptimizer test",
140
- "test:browser": "weboptimizer test:browser",
141
- "watch": "weboptimizer build --watch",
142
- ...
143
- },
127
+ "build": "weboptimizer build",
128
+ "build:stats": "weboptimizer build --profile --json >/tmp/stat.json && echo 'Results successfully written to \"/tmp/stat.json\".'",
129
+ "check": "yarn check:types; yarn lint",
130
+ "check:types": "weboptimizer check:types",
131
+ "clear": "weboptimizer clear",
132
+ "document": "weboptimizer document",
133
+ "lint": "weboptimizer lint",
134
+ "postinstall": "weboptimizer build",
135
+ "preinstall": "weboptimizer preinstall",
136
+ "serve": "weboptimizer serve",
137
+ "start": "npm run serve",
138
+ "test": "weboptimizer test",
139
+ "test:browser": "weboptimizer test:browser",
140
+ "watch": "weboptimizer build --watch",
144
141
  ...
142
+ },
143
+ ...
144
+ ```
145
145
 
146
146
  You can easily run any specified script via npm's command lint interface:
147
147
 
148
- #!bash
149
-
150
- npm run build -debug
151
- npm run lint
152
- npm run watch -debug
153
- npm run serve
154
- ...
148
+ ```bash
149
+ npm run build -debug
150
+ npm run lint
151
+ npm run watch -debug
152
+ npm run serve
153
+ ...
154
+ ```
155
155
 
156
156
  If you want to configure your application to change any of the expected
157
157
  default source, target, asset or build paths do it in your **package.json**:
158
158
 
159
- #!JSON
160
-
159
+ ```JSON
160
+ ...
161
+ "webOptimizer": {
161
162
  ...
162
- "webOptimizer": {
163
+ "path": {
163
164
  ...
164
- "path": {
165
+ "apiDocumentation": "apiDocumentation/",
166
+ "source": {
165
167
  ...
166
- "apiDocumentation": "apiDocumentation/",
167
- "source": {
168
- ...
169
- "asset": {
170
- ...
171
- "cascadingStyleSheet": "cascadingStyleSheet/",
172
- "data": "data/",
173
- "favicon": "favicon.png",
174
- "font": "font/",
175
- "image": "image/",
176
- "javaScript": "javaScript/",
177
- "publicTarget": "",
178
- "template": "template/"
179
- ..
180
- },
168
+ "asset": {
181
169
  ...
170
+ "cascadingStyleSheet": "cascadingStyleSheet/",
171
+ "data": "data/",
172
+ "favicon": "favicon.png",
173
+ "font": "font/",
174
+ "image": "image/",
175
+ "javaScript": "javaScript/",
176
+ "publicTarget": "",
177
+ "template": "template/"
178
+ ..
182
179
  },
183
- "ignore": ["node_modules", ".git"],
184
- "manifest": "manifest.appcache",
185
- "target": {
186
- ...
187
- "base": "build/",
188
- ...
189
- },
190
- "tidyUp": ["crap"],
191
180
  ...
192
181
  },
182
+ "ignore": ["node_modules", ".git"],
183
+ "manifest": "manifest.appcache",
184
+ "target": {
185
+ ...
186
+ "base": "build/",
187
+ ...
188
+ },
189
+ "tidyUp": ["crap"],
193
190
  ...
194
191
  },
195
192
  ...
193
+ },
194
+ ...
195
+ ```
196
196
 
197
197
  It's recommended to first specify if you're writing a library (preserve
198
198
  external dependencies not managed within current project) or an application
@@ -200,75 +200,71 @@ external dependencies not managed within current project) or an application
200
200
  preconfigurations are targeting on this two different use cases. Anyway you can
201
201
  customize each configuration preset by hand.
202
202
 
203
- #!JSON
204
-
203
+ ```JSON
204
+ ...
205
+ "webOptimizer": {
205
206
  ...
206
- "webOptimizer": {
207
- ...
208
- "library": false,
209
- ...
210
- },
207
+ "library": false,
211
208
  ...
209
+ },
210
+ ...
211
+ ```
212
212
 
213
213
  You can even reference any value or evaluate any configuration value
214
214
  dynamically though a complete javaScript compatible evaluation mechanism:
215
215
 
216
-
217
- #!JSON
218
-
216
+ ```JSON
217
+ ...
218
+ "webOptimizer": {
219
219
  ...
220
- "webOptimizer": {
220
+ "path": {
221
221
  ...
222
- "path": {
222
+ "source": {
223
223
  ...
224
- "source": {
224
+ "base": "/",
225
+ "asset": {
225
226
  ...
226
- "base": "/",
227
- "asset": {
228
- ...
229
- "cascadingStyleSheet": "cascadingStyleSheet/",
230
- "template": {
231
- "__evaluate__": "self.debug ? '' : self.path.source.base"
232
- },
233
- ...
227
+ "cascadingStyleSheet": "cascadingStyleSheet/",
228
+ "template": {
229
+ "__evaluate__": "self.debug ? '' : self.path.source.base"
234
230
  },
235
231
  ...
236
232
  },
237
233
  ...
238
234
  },
239
235
  ...
240
- "offline": {
236
+ },
237
+ ...
238
+ "offline": {
239
+ ...
240
+ "externals": [
241
241
  ...
242
- "externals": [
243
- ...
244
- {"__evaluate__": "self.path.source.asset.cascadingStyleSheet"},
245
- "onlineAvailable.txt",
246
- ...
247
- ],
242
+ {"__evaluate__": "self.path.source.asset.cascadingStyleSheet"},
243
+ "onlineAvailable.txt",
248
244
  ...
249
- },
245
+ ],
250
246
  ...
251
247
  },
252
248
  ...
249
+ },
250
+ ...
251
+ ```
253
252
 
254
253
  You can even execute scripts to determine a value:
255
254
 
256
- #!JSON
257
-
255
+ ``JSON
256
+ ...
257
+ "webOptimizer": {
258
258
  ...
259
- "webOptimizer": {
259
+ "path": {
260
260
  ...
261
- "path": {
261
+ "source": {
262
262
  ...
263
- "source": {
263
+ "base": "/",
264
+ "asset": {
264
265
  ...
265
- "base": "/",
266
- "asset": {
267
- ...
268
- "template": {
269
- "__execute__": "test = self.path.source.base; if (test.endsWith('js')) return 'bar/';return 'foo/'"
270
- },
271
- ...
266
+ "template": {
267
+ "__execute__": "test = self.path.source.base; if (test.endsWith('js')) return 'bar/';return 'foo/'"
272
268
  },
273
269
  ...
274
270
  },
@@ -277,6 +273,9 @@ You can even execute scripts to determine a value:
277
273
  ...
278
274
  },
279
275
  ...
276
+ },
277
+ ...
278
+ ```
280
279
 
281
280
  For all available configuration possibilities please have a look at the
282
281
  **package.json** file in this project since these values will be extended on
@@ -287,16 +286,12 @@ complete generic command line interface: The last argument should evaluate to
287
286
  a javaScript object which will be used as source for extending the default
288
287
  behavior. Any javaScript will be supported:
289
288
 
290
- #!JSON
291
-
292
289
  npm run build '{module:{preprocessor:{javaScript:{loader:"babel"}}}}'
293
290
 
294
291
  If you're using weboptimizer in a toolchain were none printable or none unicode
295
292
  compatible symbols should be used (for example content which should replace
296
293
  placeholder) you can encode your javaScript expression as base64 code:
297
294
 
298
- #!bash
299
-
300
295
  npm run build '{module:{preprocessor:{ejs:{locals:{name:'häns'}}}}}'
301
296
 
302
297
  # is the same as:
@@ -307,15 +302,15 @@ There is a static tool [clientnode](https://torben.website/clientNode) and
307
302
  helper instance provided to each evaluation or execution context within the
308
303
  package.json (see the API-Documentation, link above, for more details):
309
304
 
310
- #!JSON
311
-
305
+ ```JSON
306
+ ...
307
+ "webOptimizer": {
312
308
  ...
313
- "webOptimizer": {
314
- ...
315
- "libraryName": {"__evaluate__": Tools.isPlainObject(self.name) ? helper.stripLoader(self.request) : 'random'},
316
- ...
317
- },
309
+ "libraryName": {"__evaluate__": Tools.isPlainObject(self.name) ? helper.stripLoader(self.request) : 'random'},
318
310
  ...
311
+ },
312
+ ...
313
+ ```
319
314
 
320
315
  <!-- region modline
321
316
  vim: set tabstop=4 shiftwidth=4 expandtab: