@webqit/webflo 0.20.55 → 0.20.57

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/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "vanila-javascript"
13
13
  ],
14
14
  "homepage": "https://webqit.io/tooling/webflo",
15
- "version": "0.20.55",
15
+ "version": "0.20.57",
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",
@@ -47,17 +47,18 @@
47
47
  "dependencies": {
48
48
  "@octokit/webhooks": "^7.15.1",
49
49
  "@webqit/backpack": "^0.1.12",
50
- "@webqit/fetch-plus": "^0.1.24",
50
+ "@webqit/fetch-plus": "^0.1.29",
51
51
  "@webqit/keyval": "^0.2.17",
52
52
  "@webqit/observer": "^3.8.14",
53
53
  "@webqit/oohtml-ssr": "^2.2.4",
54
- "@webqit/port-plus": "^0.1.19",
55
- "@webqit/url-plus": "^0.1.4",
54
+ "@webqit/port-plus": "^0.1.22",
55
+ "@webqit/url-plus": "^0.1.8",
56
56
  "@webqit/use-live": "^0.5.49",
57
57
  "@webqit/util": "^0.8.11",
58
58
  "chokidar": "^4.0.3",
59
+ "cross-spawn": "^7.0.6",
59
60
  "dotenv": "^16.4.7",
60
- "esbuild": "^0.14.54",
61
+ "esbuild": "^0.27.3",
61
62
  "fast-glob": "^3.3.3",
62
63
  "idb": "^8.0.3",
63
64
  "mime-types": "^2.1.33",
package/src/util.js CHANGED
@@ -2,6 +2,7 @@ import { _wq as $wq } from '@webqit/util/js/index.js';
2
2
 
3
3
  export const _wq = (target, ...args) => $wq(target, 'webflo', ...args);
4
4
  export const _meta = (target, ...args) => $wq(target, 'webflo', 'meta', ...args);
5
+ export const _portPlusMeta = (target, ...args) => $wq(target, 'port+', 'meta', ...args);
5
6
 
6
7
  export const _await = (value, callback) => {
7
8
  if (value instanceof Promise) {
@@ -121,15 +121,18 @@ function writeScriptBody({ $context, $source, bootstrap, configExport, which })
121
121
 
122
122
  async function bundleScript({ $context, $source, which, outfile, asModule = true, ...restParams }) {
123
123
  const { flags: FLAGS, logger: LOGGER } = $context;
124
+
124
125
  // >> Show banner...
125
126
  LOGGER?.log(LOGGER.style.keyword(`---`));
126
127
  LOGGER?.log(`Bundling ${which} build`);
127
128
  LOGGER?.log(LOGGER.style.keyword(`---`));
129
+
128
130
  // Apply compression?
129
131
  const compression = !FLAGS.compression ? false : (
130
132
  FLAGS.compression === true ? ['gz'] : FLAGS.compression.split(',').map(s => s.trim())
131
133
  );
132
134
  const moduleFile = `${_beforeLast(outfile, '.')}.esm.js`;
135
+
133
136
  // >> Show waiting...
134
137
  if (LOGGER) {
135
138
  const waiting = LOGGER.waiting(
@@ -141,26 +144,34 @@ async function bundleScript({ $context, $source, which, outfile, asModule = true
141
144
  } else {
142
145
  jsFile.write($source, moduleFile, 'ES Module file');
143
146
  }
147
+
144
148
  // >> esbuild config
145
149
  const bundlingConfig = {
146
150
  entryPoints: [moduleFile],
147
151
  outfile,
152
+ bundle: true,
153
+ treeShaking: true,
148
154
  format: asModule ? 'esm' : 'iife',
149
- platform: which === 'server' ? 'node' : 'browser', // optional but good for clarity
150
- bundle: which === 'server' ? false : true,
151
- minify: which === 'server' ? false : true,
152
- treeShaking: true, // Important optimization
153
- banner: { js: '/** @webqit/webflo */', },
154
- footer: { js: '', },
155
+ ...(which === 'server' ? {
156
+ platform: 'node',
157
+ packages: 'external',
158
+ } : {
159
+ platform: 'browser',
160
+ minify: true,
161
+ banner: { js: '/** @webqit/webflo */', },
162
+ footer: { js: '', },
163
+ }),
155
164
  plugins: [UseLiveTransform()],
156
165
  ...(restParams.buildParams || {})
157
166
  };
167
+
158
168
  if (asModule && which !== 'server') {
159
169
  // Support top-level await
160
170
  // See: https://github.com/evanw/esbuild/issues/253#issuecomment-826147115
161
171
  bundlingConfig.banner.js += '(async () => {';
162
172
  bundlingConfig.footer.js += '})();';
163
173
  }
174
+
164
175
  // The bundling process
165
176
  let waiting;
166
177
  if (LOGGER) {
@@ -170,8 +181,10 @@ async function bundleScript({ $context, $source, which, outfile, asModule = true
170
181
  );
171
182
  waiting.start();
172
183
  }
184
+
173
185
  // Main
174
186
  await EsBuild.build(bundlingConfig);
187
+
175
188
  // Compress...
176
189
  const compressedFiles = [];
177
190
  const removals = [];
@@ -195,10 +208,12 @@ async function bundleScript({ $context, $source, which, outfile, asModule = true
195
208
  removals.push(bundlingConfig.outfile + '.gz');
196
209
  removals.push(bundlingConfig.outfile + '.br');
197
210
  }
211
+
198
212
  // Remove moduleFile build
199
213
  Fs.unlinkSync(bundlingConfig.entryPoints[0]);
200
214
  removals.forEach((file) => Fs.existsSync(file) && Fs.unlinkSync(file));
201
215
  if (waiting) waiting.stop();
216
+
202
217
  // ----------------
203
218
  // Stats
204
219
  if (LOGGER) {
@@ -208,6 +223,7 @@ async function bundleScript({ $context, $source, which, outfile, asModule = true
208
223
  });
209
224
  LOGGER.log('');
210
225
  }
226
+
211
227
  return [bundlingConfig.outfile].concat(compressedFiles);
212
228
  }
213
229
 
@@ -372,7 +388,7 @@ async function generateWorkerScript({ $context, bootstrap, ...restParams }) {
372
388
  const [urls, patterns] = configExport.WORKER[strategy].reduce(([urls, patterns], url) => {
373
389
  const patternInstance = new URLPatternPlus(url, 'http://localhost');
374
390
  const isPattern = patternInstance.isPattern();
375
-
391
+
376
392
  if (isPattern && (patternInstance.hostname !== 'localhost' || patternInstance.port)) {
377
393
  throw new Error(`Pattern URLs must have no origin part. Recieved "${url}".`);
378
394
  }
@@ -463,7 +479,7 @@ export async function build() {
463
479
  outfiles.push(..._outfiles);
464
480
  }
465
481
 
466
- if (false) { // TODO: WebfloServer needs to be buildable first
482
+ if ($context.flags.server && false) { // TODO: WebfloServer needs to be buildable first
467
483
  const bootstrap = await serverBootstrap($context);
468
484
  const _outfiles = await generateServerScript({ $context, bootstrap, buildParams });
469
485
  outfiles.push(..._outfiles);
@@ -26,8 +26,8 @@ export default class Client extends Dotfile {
26
26
  capabilities: {
27
27
  service_worker: false,
28
28
  webpush: false,
29
- custom_install: false,
30
- exposed: ['display-mode', 'notifications'],
29
+ pwa_install: false,
30
+ exposed: [],
31
31
  },
32
32
  }, config, 'patch');
33
33
  }
@@ -89,7 +89,7 @@ export default class Client extends Dotfile {
89
89
  inactive: 'NO',
90
90
  },
91
91
  {
92
- name: 'custom_install',
92
+ name: 'pwa_install',
93
93
  type: 'toggle',
94
94
  message: 'Enable custom PWA install prompt?',
95
95
  active: 'YES',