@jsenv/core 29.2.0 → 29.3.0-alpha.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.
@@ -1,3 +1,3 @@
1
1
  export default function _objectDestructuringEmpty(obj) {
2
- if (obj == null) throw new TypeError("Cannot destructure undefined");
2
+ if (obj == null) throw new TypeError("Cannot destructure " + obj);
3
3
  }
@@ -0,0 +1,634 @@
1
+ /* @minVersion 7.18.0 */
2
+ /*
3
+ * This file is auto-generated! Do not modify it directly.
4
+ * To re-generate, update the regenerator-runtime dependency of
5
+ * @babel/helpers and run 'yarn gulp generate-runtime-helpers'.
6
+ */
7
+
8
+ /* eslint-disable */
9
+ export default function _regeneratorRuntime() {
10
+ "use strict";
11
+
12
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
13
+ _regeneratorRuntime = function () {
14
+ return exports;
15
+ };
16
+ var exports = {};
17
+ var Op = Object.prototype;
18
+ var hasOwn = Op.hasOwnProperty;
19
+ var undefined; // More compressible than void 0.
20
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
21
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
22
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
23
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
24
+ function define(obj, key, value) {
25
+ Object.defineProperty(obj, key, {
26
+ value: value,
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true
30
+ });
31
+ return obj[key];
32
+ }
33
+ try {
34
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
35
+ define({}, "");
36
+ } catch (err) {
37
+ define = function (obj, key, value) {
38
+ return obj[key] = value;
39
+ };
40
+ }
41
+ function wrap(innerFn, outerFn, self, tryLocsList) {
42
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
43
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
44
+ var generator = Object.create(protoGenerator.prototype);
45
+ var context = new Context(tryLocsList || []);
46
+
47
+ // The ._invoke method unifies the implementations of the .next,
48
+ // .throw, and .return methods.
49
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
50
+ return generator;
51
+ }
52
+ exports.wrap = wrap;
53
+
54
+ // Try/catch helper to minimize deoptimizations. Returns a completion
55
+ // record like context.tryEntries[i].completion. This interface could
56
+ // have been (and was previously) designed to take a closure to be
57
+ // invoked without arguments, but in all the cases we care about we
58
+ // already have an existing method we want to call, so there's no need
59
+ // to create a new function object. We can even get away with assuming
60
+ // the method takes exactly one argument, since that happens to be true
61
+ // in every case, so we don't have to touch the arguments object. The
62
+ // only additional allocation required is the completion record, which
63
+ // has a stable shape and so hopefully should be cheap to allocate.
64
+ function tryCatch(fn, obj, arg) {
65
+ try {
66
+ return {
67
+ type: "normal",
68
+ arg: fn.call(obj, arg)
69
+ };
70
+ } catch (err) {
71
+ return {
72
+ type: "throw",
73
+ arg: err
74
+ };
75
+ }
76
+ }
77
+ var GenStateSuspendedStart = "suspendedStart";
78
+ var GenStateSuspendedYield = "suspendedYield";
79
+ var GenStateExecuting = "executing";
80
+ var GenStateCompleted = "completed";
81
+
82
+ // Returning this object from the innerFn has the same effect as
83
+ // breaking out of the dispatch switch statement.
84
+ var ContinueSentinel = {};
85
+
86
+ // Dummy constructor functions that we use as the .constructor and
87
+ // .constructor.prototype properties for functions that return Generator
88
+ // objects. For full spec compliance, you may wish to configure your
89
+ // minifier not to mangle the names of these two functions.
90
+ function Generator() {}
91
+ function GeneratorFunction() {}
92
+ function GeneratorFunctionPrototype() {}
93
+
94
+ // This is a polyfill for %IteratorPrototype% for environments that
95
+ // don't natively support it.
96
+ var IteratorPrototype = {};
97
+ define(IteratorPrototype, iteratorSymbol, function () {
98
+ return this;
99
+ });
100
+ var getProto = Object.getPrototypeOf;
101
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
102
+ if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
103
+ // This environment has a native %IteratorPrototype%; use it instead
104
+ // of the polyfill.
105
+ IteratorPrototype = NativeIteratorPrototype;
106
+ }
107
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
108
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
109
+ define(Gp, "constructor", GeneratorFunctionPrototype);
110
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
111
+ GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
112
+
113
+ // Helper for defining the .next, .throw, and .return methods of the
114
+ // Iterator interface in terms of a single ._invoke method.
115
+ function defineIteratorMethods(prototype) {
116
+ ["next", "throw", "return"].forEach(function (method) {
117
+ define(prototype, method, function (arg) {
118
+ return this._invoke(method, arg);
119
+ });
120
+ });
121
+ }
122
+ exports.isGeneratorFunction = function (genFun) {
123
+ var ctor = typeof genFun === "function" && genFun.constructor;
124
+ return ctor ? ctor === GeneratorFunction ||
125
+ // For the native GeneratorFunction constructor, the best we can
126
+ // do is to check its .name property.
127
+ (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
128
+ };
129
+ exports.mark = function (genFun) {
130
+ if (Object.setPrototypeOf) {
131
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
132
+ } else {
133
+ genFun.__proto__ = GeneratorFunctionPrototype;
134
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
135
+ }
136
+ genFun.prototype = Object.create(Gp);
137
+ return genFun;
138
+ };
139
+
140
+ // Within the body of any async function, `await x` is transformed to
141
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
142
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
143
+ // meant to be awaited.
144
+ exports.awrap = function (arg) {
145
+ return {
146
+ __await: arg
147
+ };
148
+ };
149
+ function AsyncIterator(generator, PromiseImpl) {
150
+ function invoke(method, arg, resolve, reject) {
151
+ var record = tryCatch(generator[method], generator, arg);
152
+ if (record.type === "throw") {
153
+ reject(record.arg);
154
+ } else {
155
+ var result = record.arg;
156
+ var value = result.value;
157
+ if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
158
+ return PromiseImpl.resolve(value.__await).then(function (value) {
159
+ invoke("next", value, resolve, reject);
160
+ }, function (err) {
161
+ invoke("throw", err, resolve, reject);
162
+ });
163
+ }
164
+ return PromiseImpl.resolve(value).then(function (unwrapped) {
165
+ // When a yielded Promise is resolved, its final value becomes
166
+ // the .value of the Promise<{value,done}> result for the
167
+ // current iteration.
168
+ result.value = unwrapped;
169
+ resolve(result);
170
+ }, function (error) {
171
+ // If a rejected Promise was yielded, throw the rejection back
172
+ // into the async generator function so it can be handled there.
173
+ return invoke("throw", error, resolve, reject);
174
+ });
175
+ }
176
+ }
177
+ var previousPromise;
178
+ function enqueue(method, arg) {
179
+ function callInvokeWithMethodAndArg() {
180
+ return new PromiseImpl(function (resolve, reject) {
181
+ invoke(method, arg, resolve, reject);
182
+ });
183
+ }
184
+ return previousPromise =
185
+ // If enqueue has been called before, then we want to wait until
186
+ // all previous Promises have been resolved before calling invoke,
187
+ // so that results are always delivered in the correct order. If
188
+ // enqueue has not been called before, then it is important to
189
+ // call invoke immediately, without waiting on a callback to fire,
190
+ // so that the async generator function has the opportunity to do
191
+ // any necessary setup in a predictable way. This predictability
192
+ // is why the Promise constructor synchronously invokes its
193
+ // executor callback, and why async functions synchronously
194
+ // execute code before the first await. Since we implement simple
195
+ // async functions in terms of async generators, it is especially
196
+ // important to get this right, even though it requires care.
197
+ previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
198
+ // Avoid propagating failures to Promises returned by later
199
+ // invocations of the iterator.
200
+ callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
201
+ }
202
+
203
+ // Define the unified helper method that is used to implement .next,
204
+ // .throw, and .return (see defineIteratorMethods).
205
+ this._invoke = enqueue;
206
+ }
207
+ defineIteratorMethods(AsyncIterator.prototype);
208
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
209
+ return this;
210
+ });
211
+ exports.AsyncIterator = AsyncIterator;
212
+
213
+ // Note that simple async functions are implemented on top of
214
+ // AsyncIterator objects; they just return a Promise for the value of
215
+ // the final result produced by the iterator.
216
+ exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
217
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
218
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
219
+ return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
220
+ : iter.next().then(function (result) {
221
+ return result.done ? result.value : iter.next();
222
+ });
223
+ };
224
+ function makeInvokeMethod(innerFn, self, context) {
225
+ var state = GenStateSuspendedStart;
226
+ return function invoke(method, arg) {
227
+ if (state === GenStateExecuting) {
228
+ throw new Error("Generator is already running");
229
+ }
230
+ if (state === GenStateCompleted) {
231
+ if (method === "throw") {
232
+ throw arg;
233
+ }
234
+
235
+ // Be forgiving, per 25.3.3.3.3 of the spec:
236
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
237
+ return doneResult();
238
+ }
239
+ context.method = method;
240
+ context.arg = arg;
241
+ while (true) {
242
+ var delegate = context.delegate;
243
+ if (delegate) {
244
+ var delegateResult = maybeInvokeDelegate(delegate, context);
245
+ if (delegateResult) {
246
+ if (delegateResult === ContinueSentinel) continue;
247
+ return delegateResult;
248
+ }
249
+ }
250
+ if (context.method === "next") {
251
+ // Setting context._sent for legacy support of Babel's
252
+ // function.sent implementation.
253
+ context.sent = context._sent = context.arg;
254
+ } else if (context.method === "throw") {
255
+ if (state === GenStateSuspendedStart) {
256
+ state = GenStateCompleted;
257
+ throw context.arg;
258
+ }
259
+ context.dispatchException(context.arg);
260
+ } else if (context.method === "return") {
261
+ context.abrupt("return", context.arg);
262
+ }
263
+ state = GenStateExecuting;
264
+ var record = tryCatch(innerFn, self, context);
265
+ if (record.type === "normal") {
266
+ // If an exception is thrown from innerFn, we leave state ===
267
+ // GenStateExecuting and loop back for another invocation.
268
+ state = context.done ? GenStateCompleted : GenStateSuspendedYield;
269
+ if (record.arg === ContinueSentinel) {
270
+ continue;
271
+ }
272
+ return {
273
+ value: record.arg,
274
+ done: context.done
275
+ };
276
+ } else if (record.type === "throw") {
277
+ state = GenStateCompleted;
278
+ // Dispatch the exception by looping back around to the
279
+ // context.dispatchException(context.arg) call above.
280
+ context.method = "throw";
281
+ context.arg = record.arg;
282
+ }
283
+ }
284
+ };
285
+ }
286
+
287
+ // Call delegate.iterator[context.method](context.arg) and handle the
288
+ // result, either by returning a { value, done } result from the
289
+ // delegate iterator, or by modifying context.method and context.arg,
290
+ // setting context.delegate to null, and returning the ContinueSentinel.
291
+ function maybeInvokeDelegate(delegate, context) {
292
+ var method = delegate.iterator[context.method];
293
+ if (method === undefined) {
294
+ // A .throw or .return when the delegate iterator has no .throw
295
+ // method always terminates the yield* loop.
296
+ context.delegate = null;
297
+ if (context.method === "throw") {
298
+ // Note: ["return"] must be used for ES3 parsing compatibility.
299
+ if (delegate.iterator["return"]) {
300
+ // If the delegate iterator has a return method, give it a
301
+ // chance to clean up.
302
+ context.method = "return";
303
+ context.arg = undefined;
304
+ maybeInvokeDelegate(delegate, context);
305
+ if (context.method === "throw") {
306
+ // If maybeInvokeDelegate(context) changed context.method from
307
+ // "return" to "throw", let that override the TypeError below.
308
+ return ContinueSentinel;
309
+ }
310
+ }
311
+ context.method = "throw";
312
+ context.arg = new TypeError("The iterator does not provide a 'throw' method");
313
+ }
314
+ return ContinueSentinel;
315
+ }
316
+ var record = tryCatch(method, delegate.iterator, context.arg);
317
+ if (record.type === "throw") {
318
+ context.method = "throw";
319
+ context.arg = record.arg;
320
+ context.delegate = null;
321
+ return ContinueSentinel;
322
+ }
323
+ var info = record.arg;
324
+ if (!info) {
325
+ context.method = "throw";
326
+ context.arg = new TypeError("iterator result is not an object");
327
+ context.delegate = null;
328
+ return ContinueSentinel;
329
+ }
330
+ if (info.done) {
331
+ // Assign the result of the finished delegate to the temporary
332
+ // variable specified by delegate.resultName (see delegateYield).
333
+ context[delegate.resultName] = info.value;
334
+
335
+ // Resume execution at the desired location (see delegateYield).
336
+ context.next = delegate.nextLoc;
337
+
338
+ // If context.method was "throw" but the delegate handled the
339
+ // exception, let the outer generator proceed normally. If
340
+ // context.method was "next", forget context.arg since it has been
341
+ // "consumed" by the delegate iterator. If context.method was
342
+ // "return", allow the original .return call to continue in the
343
+ // outer generator.
344
+ if (context.method !== "return") {
345
+ context.method = "next";
346
+ context.arg = undefined;
347
+ }
348
+ } else {
349
+ // Re-yield the result returned by the delegate method.
350
+ return info;
351
+ }
352
+
353
+ // The delegate iterator is finished, so forget it and continue with
354
+ // the outer generator.
355
+ context.delegate = null;
356
+ return ContinueSentinel;
357
+ }
358
+
359
+ // Define Generator.prototype.{next,throw,return} in terms of the
360
+ // unified ._invoke helper method.
361
+ defineIteratorMethods(Gp);
362
+ define(Gp, toStringTagSymbol, "Generator");
363
+
364
+ // A Generator should always return itself as the iterator object when the
365
+ // @@iterator function is called on it. Some browsers' implementations of the
366
+ // iterator prototype chain incorrectly implement this, causing the Generator
367
+ // object to not be returned from this call. This ensures that doesn't happen.
368
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
369
+ define(Gp, iteratorSymbol, function () {
370
+ return this;
371
+ });
372
+ define(Gp, "toString", function () {
373
+ return "[object Generator]";
374
+ });
375
+ function pushTryEntry(locs) {
376
+ var entry = {
377
+ tryLoc: locs[0]
378
+ };
379
+ if (1 in locs) {
380
+ entry.catchLoc = locs[1];
381
+ }
382
+ if (2 in locs) {
383
+ entry.finallyLoc = locs[2];
384
+ entry.afterLoc = locs[3];
385
+ }
386
+ this.tryEntries.push(entry);
387
+ }
388
+ function resetTryEntry(entry) {
389
+ var record = entry.completion || {};
390
+ record.type = "normal";
391
+ delete record.arg;
392
+ entry.completion = record;
393
+ }
394
+ function Context(tryLocsList) {
395
+ // The root entry object (effectively a try statement without a catch
396
+ // or a finally block) gives us a place to store values thrown from
397
+ // locations where there is no enclosing try statement.
398
+ this.tryEntries = [{
399
+ tryLoc: "root"
400
+ }];
401
+ tryLocsList.forEach(pushTryEntry, this);
402
+ this.reset(true);
403
+ }
404
+ exports.keys = function (object) {
405
+ var keys = [];
406
+ for (var key in object) {
407
+ keys.push(key);
408
+ }
409
+ keys.reverse();
410
+
411
+ // Rather than returning an object with a next method, we keep
412
+ // things simple and return the next function itself.
413
+ return function next() {
414
+ while (keys.length) {
415
+ var key = keys.pop();
416
+ if (key in object) {
417
+ next.value = key;
418
+ next.done = false;
419
+ return next;
420
+ }
421
+ }
422
+
423
+ // To avoid creating an additional object, we just hang the .value
424
+ // and .done properties off the next function object itself. This
425
+ // also ensures that the minifier will not anonymize the function.
426
+ next.done = true;
427
+ return next;
428
+ };
429
+ };
430
+ function values(iterable) {
431
+ if (iterable) {
432
+ var iteratorMethod = iterable[iteratorSymbol];
433
+ if (iteratorMethod) {
434
+ return iteratorMethod.call(iterable);
435
+ }
436
+ if (typeof iterable.next === "function") {
437
+ return iterable;
438
+ }
439
+ if (!isNaN(iterable.length)) {
440
+ var i = -1,
441
+ next = function next() {
442
+ while (++i < iterable.length) {
443
+ if (hasOwn.call(iterable, i)) {
444
+ next.value = iterable[i];
445
+ next.done = false;
446
+ return next;
447
+ }
448
+ }
449
+ next.value = undefined;
450
+ next.done = true;
451
+ return next;
452
+ };
453
+ return next.next = next;
454
+ }
455
+ }
456
+
457
+ // Return an iterator with no values.
458
+ return {
459
+ next: doneResult
460
+ };
461
+ }
462
+ exports.values = values;
463
+ function doneResult() {
464
+ return {
465
+ value: undefined,
466
+ done: true
467
+ };
468
+ }
469
+ Context.prototype = {
470
+ constructor: Context,
471
+ reset: function (skipTempReset) {
472
+ this.prev = 0;
473
+ this.next = 0;
474
+ // Resetting context._sent for legacy support of Babel's
475
+ // function.sent implementation.
476
+ this.sent = this._sent = undefined;
477
+ this.done = false;
478
+ this.delegate = null;
479
+ this.method = "next";
480
+ this.arg = undefined;
481
+ this.tryEntries.forEach(resetTryEntry);
482
+ if (!skipTempReset) {
483
+ for (var name in this) {
484
+ // Not sure about the optimal order of these conditions:
485
+ if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
486
+ this[name] = undefined;
487
+ }
488
+ }
489
+ }
490
+ },
491
+ stop: function () {
492
+ this.done = true;
493
+ var rootEntry = this.tryEntries[0];
494
+ var rootRecord = rootEntry.completion;
495
+ if (rootRecord.type === "throw") {
496
+ throw rootRecord.arg;
497
+ }
498
+ return this.rval;
499
+ },
500
+ dispatchException: function (exception) {
501
+ if (this.done) {
502
+ throw exception;
503
+ }
504
+ var context = this;
505
+ function handle(loc, caught) {
506
+ record.type = "throw";
507
+ record.arg = exception;
508
+ context.next = loc;
509
+ if (caught) {
510
+ // If the dispatched exception was caught by a catch block,
511
+ // then let that catch block handle the exception normally.
512
+ context.method = "next";
513
+ context.arg = undefined;
514
+ }
515
+ return !!caught;
516
+ }
517
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
518
+ var entry = this.tryEntries[i];
519
+ var record = entry.completion;
520
+ if (entry.tryLoc === "root") {
521
+ // Exception thrown outside of any try block that could handle
522
+ // it, so set the completion value of the entire function to
523
+ // throw the exception.
524
+ return handle("end");
525
+ }
526
+ if (entry.tryLoc <= this.prev) {
527
+ var hasCatch = hasOwn.call(entry, "catchLoc");
528
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
529
+ if (hasCatch && hasFinally) {
530
+ if (this.prev < entry.catchLoc) {
531
+ return handle(entry.catchLoc, true);
532
+ } else if (this.prev < entry.finallyLoc) {
533
+ return handle(entry.finallyLoc);
534
+ }
535
+ } else if (hasCatch) {
536
+ if (this.prev < entry.catchLoc) {
537
+ return handle(entry.catchLoc, true);
538
+ }
539
+ } else if (hasFinally) {
540
+ if (this.prev < entry.finallyLoc) {
541
+ return handle(entry.finallyLoc);
542
+ }
543
+ } else {
544
+ throw new Error("try statement without catch or finally");
545
+ }
546
+ }
547
+ }
548
+ },
549
+ abrupt: function (type, arg) {
550
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
551
+ var entry = this.tryEntries[i];
552
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
553
+ var finallyEntry = entry;
554
+ break;
555
+ }
556
+ }
557
+ if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
558
+ // Ignore the finally entry if control is not jumping to a
559
+ // location outside the try/catch block.
560
+ finallyEntry = null;
561
+ }
562
+ var record = finallyEntry ? finallyEntry.completion : {};
563
+ record.type = type;
564
+ record.arg = arg;
565
+ if (finallyEntry) {
566
+ this.method = "next";
567
+ this.next = finallyEntry.finallyLoc;
568
+ return ContinueSentinel;
569
+ }
570
+ return this.complete(record);
571
+ },
572
+ complete: function (record, afterLoc) {
573
+ if (record.type === "throw") {
574
+ throw record.arg;
575
+ }
576
+ if (record.type === "break" || record.type === "continue") {
577
+ this.next = record.arg;
578
+ } else if (record.type === "return") {
579
+ this.rval = this.arg = record.arg;
580
+ this.method = "return";
581
+ this.next = "end";
582
+ } else if (record.type === "normal" && afterLoc) {
583
+ this.next = afterLoc;
584
+ }
585
+ return ContinueSentinel;
586
+ },
587
+ finish: function (finallyLoc) {
588
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
589
+ var entry = this.tryEntries[i];
590
+ if (entry.finallyLoc === finallyLoc) {
591
+ this.complete(entry.completion, entry.afterLoc);
592
+ resetTryEntry(entry);
593
+ return ContinueSentinel;
594
+ }
595
+ }
596
+ },
597
+ catch: function (tryLoc) {
598
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
599
+ var entry = this.tryEntries[i];
600
+ if (entry.tryLoc === tryLoc) {
601
+ var record = entry.completion;
602
+ if (record.type === "throw") {
603
+ var thrown = record.arg;
604
+ resetTryEntry(entry);
605
+ }
606
+ return thrown;
607
+ }
608
+ }
609
+
610
+ // The context.catch method must only be called with a location
611
+ // argument that corresponds to a known catch block.
612
+ throw new Error("illegal catch attempt");
613
+ },
614
+ delegateYield: function (iterable, resultName, nextLoc) {
615
+ this.delegate = {
616
+ iterator: values(iterable),
617
+ resultName: resultName,
618
+ nextLoc: nextLoc
619
+ };
620
+ if (this.method === "next") {
621
+ // Deliberately forget the last sent value so that we don't
622
+ // accidentally pass it on to the delegate.
623
+ this.arg = undefined;
624
+ }
625
+ return ContinueSentinel;
626
+ }
627
+ };
628
+
629
+ // Regardless of whether this script is executing as a CommonJS module
630
+ // or not, return the runtime object so that we can declare the variable
631
+ // regeneratorRuntime in the outer scope, which allows this module to be
632
+ // injected easily by `bin/regenerator --include-runtime script.js`.
633
+ return exports;
634
+ }
@@ -0,0 +1,53 @@
1
+ const injectRibbon = ({
2
+ text
3
+ }) => {
4
+ const css = /* css */`
5
+ #jsenv_ribbon_container {
6
+ position: absolute;
7
+ z-index: 1001;
8
+ top: 0;
9
+ right: 0;
10
+ width: 100px;
11
+ height: 100px;
12
+ overflow: hidden;
13
+ opacity: 0.5;
14
+ pointer-events: none;
15
+ }
16
+ #jsenv_ribbon {
17
+ position: absolute;
18
+ top: -10px;
19
+ right: -10px;
20
+ width: 100%;
21
+ height: 100%;
22
+ }
23
+ #jsenv_ribbon_text {
24
+ position: absolute;
25
+ left: 0px;
26
+ top: 20px;
27
+ transform: rotate(45deg);
28
+ display: block;
29
+ width: 125px;
30
+ line-height: 36px;
31
+ background-color: orange;
32
+ color: rgb(55, 7, 7);
33
+ box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
34
+ font-weight: 700;
35
+ font-size: 16px;
36
+ font-family: "Lato", sans-serif;
37
+ text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
38
+ text-align: center;
39
+ user-select: none;
40
+ }
41
+ `;
42
+ const html = /* html */`<div id="jsenv_ribbon_container">
43
+ <style>${css}</style>
44
+ <div id="jsenv_ribbon">
45
+ <div id="jsenv_ribbon_text">${text}</span>
46
+ </div>
47
+ </div>`;
48
+ const node = document.createElement("div");
49
+ node.innerHTML = html;
50
+ document.body.appendChild(node.firstChild);
51
+ };
52
+
53
+ export { injectRibbon };
package/dist/js/ws.js CHANGED
@@ -2762,17 +2762,17 @@ function initAsClient(websocket, address, protocols, options) {
2762
2762
  websocket._url = address;
2763
2763
  }
2764
2764
  const isSecure = parsedUrl.protocol === 'wss:';
2765
- const isUnixSocket = parsedUrl.protocol === 'ws+unix:';
2766
- let invalidURLMessage;
2767
- if (parsedUrl.protocol !== 'ws:' && !isSecure && !isUnixSocket) {
2768
- invalidURLMessage = 'The URL\'s protocol must be one of "ws:", "wss:", or "ws+unix:"';
2769
- } else if (isUnixSocket && !parsedUrl.pathname) {
2770
- invalidURLMessage = "The URL's pathname is empty";
2765
+ const isIpcUrl = parsedUrl.protocol === 'ws+unix:';
2766
+ let invalidUrlMessage;
2767
+ if (parsedUrl.protocol !== 'ws:' && !isSecure && !isIpcUrl) {
2768
+ invalidUrlMessage = 'The URL\'s protocol must be one of "ws:", "wss:", or "ws+unix:"';
2769
+ } else if (isIpcUrl && !parsedUrl.pathname) {
2770
+ invalidUrlMessage = "The URL's pathname is empty";
2771
2771
  } else if (parsedUrl.hash) {
2772
- invalidURLMessage = 'The URL contains a fragment identifier';
2772
+ invalidUrlMessage = 'The URL contains a fragment identifier';
2773
2773
  }
2774
- if (invalidURLMessage) {
2775
- const err = new SyntaxError(invalidURLMessage);
2774
+ if (invalidUrlMessage) {
2775
+ const err = new SyntaxError(invalidUrlMessage);
2776
2776
  if (websocket._redirects === 0) {
2777
2777
  throw err;
2778
2778
  } else {
@@ -2823,7 +2823,7 @@ function initAsClient(websocket, address, protocols, options) {
2823
2823
  if (parsedUrl.username || parsedUrl.password) {
2824
2824
  opts.auth = `${parsedUrl.username}:${parsedUrl.password}`;
2825
2825
  }
2826
- if (isUnixSocket) {
2826
+ if (isIpcUrl) {
2827
2827
  const parts = opts.path.split(':');
2828
2828
  opts.socketPath = parts[0];
2829
2829
  opts.path = parts[1];
@@ -2831,9 +2831,9 @@ function initAsClient(websocket, address, protocols, options) {
2831
2831
  let req;
2832
2832
  if (opts.followRedirects) {
2833
2833
  if (websocket._redirects === 0) {
2834
- websocket._originalUnixSocket = isUnixSocket;
2834
+ websocket._originalIpc = isIpcUrl;
2835
2835
  websocket._originalSecure = isSecure;
2836
- websocket._originalHostOrSocketPath = isUnixSocket ? opts.socketPath : parsedUrl.host;
2836
+ websocket._originalHostOrSocketPath = isIpcUrl ? opts.socketPath : parsedUrl.host;
2837
2837
  const headers = options && options.headers;
2838
2838
 
2839
2839
  //
@@ -2850,7 +2850,7 @@ function initAsClient(websocket, address, protocols, options) {
2850
2850
  }
2851
2851
  }
2852
2852
  } else if (websocket.listenerCount('redirect') === 0) {
2853
- const isSameHost = isUnixSocket ? websocket._originalUnixSocket ? opts.socketPath === websocket._originalHostOrSocketPath : false : websocket._originalUnixSocket ? false : parsedUrl.host === websocket._originalHostOrSocketPath;
2853
+ const isSameHost = isIpcUrl ? websocket._originalIpc ? opts.socketPath === websocket._originalHostOrSocketPath : false : websocket._originalIpc ? false : parsedUrl.host === websocket._originalHostOrSocketPath;
2854
2854
  if (!isSameHost || websocket._originalSecure && !isSecure) {
2855
2855
  //
2856
2856
  // Match curl 7.77.0 behavior and drop the following headers. These
package/dist/main.js CHANGED
@@ -16,7 +16,7 @@ import { Readable, Stream, Writable } from "node:stream";
16
16
  import { Http2ServerResponse } from "node:http2";
17
17
  import { lookup } from "node:dns";
18
18
  import { SOURCEMAP, generateSourcemapFileUrl, composeTwoSourcemaps, generateSourcemapDataUrl, createMagicSource, sourcemapConverter, getOriginalPosition } from "@jsenv/sourcemap";
19
- import { parseHtmlString, stringifyHtmlAst, getHtmlNodeAttribute, visitHtmlNodes, analyzeScriptNode, setHtmlNodeAttributes, parseSrcSet, getHtmlNodePosition, getHtmlNodeAttributePosition, applyPostCss, postCssPluginUrlVisitor, parseJsUrls, getHtmlNodeText, setHtmlNodeText, applyBabelPlugins, injectScriptNodeAsEarlyAsPossible, createHtmlNode, findHtmlNode, removeHtmlNode, removeHtmlNodeText, transpileWithParcel, injectJsImport, minifyWithParcel, analyzeLinkNode } from "@jsenv/ast";
19
+ import { parseHtmlString, stringifyHtmlAst, getHtmlNodeAttribute, visitHtmlNodes, analyzeScriptNode, setHtmlNodeAttributes, parseSrcSet, getHtmlNodePosition, getHtmlNodeAttributePosition, applyPostCss, postCssPluginUrlVisitor, parseJsUrls, getHtmlNodeText, setHtmlNodeText, applyBabelPlugins, injectScriptNodeAsEarlyAsPossible, createHtmlNode, findHtmlNode, removeHtmlNode, removeHtmlNodeText, transpileWithParcel, injectJsImport, minifyWithParcel, analyzeLinkNode, injectHtmlNode } from "@jsenv/ast";
20
20
  import { createRequire } from "node:module";
21
21
  import babelParser from "@babel/parser";
22
22
  import v8, { takeCoverage } from "node:v8";
@@ -20655,6 +20655,59 @@ const jsenvPluginExplorer = ({
20655
20655
  };
20656
20656
  };
20657
20657
 
20658
+ const jsenvPluginRibbon = ({
20659
+ htmlInclude = "**/*.html",
20660
+ allowDuringBuild = false,
20661
+ options = {}
20662
+ } = {}) => {
20663
+ const ribbonClientFileUrl = new URL("./js/ribbon.js", import.meta.url);
20664
+ const associations = URL_META.resolveAssociations({
20665
+ ribbon: {
20666
+ [htmlInclude]: true
20667
+ }
20668
+ }, "file://");
20669
+ return {
20670
+ name: "jsenv:ribbon",
20671
+ appliesDuring: "*",
20672
+ transformHtmlContent: {
20673
+ html: (urlInfo, context) => {
20674
+ if (context.scenarios.build && !allowDuringBuild) {
20675
+ return null;
20676
+ }
20677
+ const {
20678
+ ribbon
20679
+ } = URL_META.applyAssociations({
20680
+ url: urlInfo.url,
20681
+ associations
20682
+ });
20683
+ if (!ribbon) {
20684
+ return null;
20685
+ }
20686
+ const htmlAst = parseHtmlString(urlInfo.content);
20687
+ const [ribbonClientFileReference] = context.referenceUtils.inject({
20688
+ type: "script_src",
20689
+ subtype: "js_module",
20690
+ expectedType: "js_module",
20691
+ specifier: ribbonClientFileUrl
20692
+ });
20693
+ options = {
20694
+ text: context.scenarios.dev ? "DEV" : "BUILD",
20695
+ ...options
20696
+ };
20697
+ injectHtmlNode(htmlAst, createHtmlNode({
20698
+ tagName: "script",
20699
+ type: "module",
20700
+ content: `
20701
+ import { injectRibbon} from ${ribbonClientFileReference.generatedSpecifier}
20702
+
20703
+ injectRibbon(${JSON.stringify(options, null, " ")})`
20704
+ }));
20705
+ return stringifyHtmlAst(htmlAst);
20706
+ }
20707
+ }
20708
+ };
20709
+ };
20710
+
20658
20711
  const getCorePlugins = ({
20659
20712
  rootDirectoryUrl,
20660
20713
  runtimeCompat,
@@ -20670,7 +20723,8 @@ const getCorePlugins = ({
20670
20723
  clientAutoreload = false,
20671
20724
  clientFileChangeCallbackList,
20672
20725
  clientFilesPruneCallbackList,
20673
- explorer
20726
+ explorer,
20727
+ ribbon = false
20674
20728
  } = {}) => {
20675
20729
  if (explorer === true) {
20676
20730
  explorer = {};
@@ -20689,6 +20743,9 @@ const getCorePlugins = ({
20689
20743
  } else {
20690
20744
  clientMainFileUrl = String(clientMainFileUrl);
20691
20745
  }
20746
+ if (ribbon === true) {
20747
+ ribbon = {};
20748
+ }
20692
20749
  return [jsenvPluginUrlAnalysis({
20693
20750
  rootDirectoryUrl,
20694
20751
  ...urlAnalysis
@@ -20715,7 +20772,7 @@ const getCorePlugins = ({
20715
20772
  })] : []), jsenvPluginCacheControl(), ...(explorer ? [jsenvPluginExplorer({
20716
20773
  ...explorer,
20717
20774
  clientMainFileUrl
20718
- })] : [])];
20775
+ })] : []), ...(ribbon ? [jsenvPluginRibbon(ribbon)] : [])];
20719
20776
  };
20720
20777
 
20721
20778
  const GRAPH = {
@@ -21077,6 +21134,7 @@ const build = async ({
21077
21134
  versioningMethod = "search_param",
21078
21135
  // "filename", "search_param"
21079
21136
  lineBreakNormalization = process.platform === "win32",
21137
+ ribbon,
21080
21138
  clientFiles = {
21081
21139
  "./src/": true
21082
21140
  },
@@ -21166,7 +21224,8 @@ build ${entryPointKeys.length} entry points`);
21166
21224
  jsClassicFallback: false
21167
21225
  },
21168
21226
  minification,
21169
- bundling
21227
+ bundling,
21228
+ ribbon
21170
21229
  })],
21171
21230
  sourcemaps,
21172
21231
  sourcemapsSourcesContent,
@@ -22447,6 +22506,7 @@ const createFileService = ({
22447
22506
  clientMainFileUrl,
22448
22507
  cooldownBetweenFileEvents,
22449
22508
  explorer,
22509
+ ribbon,
22450
22510
  sourcemaps,
22451
22511
  sourcemapsSourcesProtocol,
22452
22512
  sourcemapsSourcesContent,
@@ -22550,7 +22610,8 @@ const createFileService = ({
22550
22610
  clientAutoreload,
22551
22611
  clientFileChangeCallbackList,
22552
22612
  clientFilesPruneCallbackList,
22553
- explorer
22613
+ explorer,
22614
+ ribbon
22554
22615
  })],
22555
22616
  sourcemaps,
22556
22617
  sourcemapsSourcesProtocol,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "29.2.0",
3
+ "version": "29.3.0-alpha.0",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -66,15 +66,15 @@
66
66
  "@c88/v8-coverage": "0.1.1",
67
67
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
68
68
  "@jsenv/abort": "4.2.4",
69
- "@jsenv/ast": "1.3.2",
70
- "@jsenv/babel-plugins": "1.0.7",
69
+ "@jsenv/ast": "1.3.3",
70
+ "@jsenv/babel-plugins": "1.0.8",
71
71
  "@jsenv/filesystem": "4.1.5",
72
72
  "@jsenv/importmap": "1.2.1",
73
73
  "@jsenv/integrity": "0.0.1",
74
74
  "@jsenv/log": "3.3.1",
75
75
  "@jsenv/node-esm-resolution": "0.1.1",
76
- "@jsenv/server": "14.1.7",
77
- "@jsenv/sourcemap": "1.0.5",
76
+ "@jsenv/server": "14.1.8",
77
+ "@jsenv/sourcemap": "1.0.6",
78
78
  "@jsenv/uneval": "1.6.0",
79
79
  "@jsenv/url-meta": "7.0.0",
80
80
  "@jsenv/urls": "1.2.7",
@@ -89,7 +89,7 @@
89
89
  "istanbul-reports": "3.1.5",
90
90
  "launch-editor": "2.6.0",
91
91
  "pidtree": "0.6.0",
92
- "rollup": "3.1.0",
92
+ "rollup": "3.2.2",
93
93
  "string-width": "5.1.2",
94
94
  "strip-ansi": "7.0.1",
95
95
  "terser": "5.15.1",
@@ -99,8 +99,8 @@
99
99
  "devDependencies": {
100
100
  "@babel/eslint-parser": "7.19.1",
101
101
  "@babel/plugin-syntax-import-assertions": "7.18.6",
102
- "@jsenv/assert": "2.7.0",
103
- "@jsenv/eslint-config": "16.2.5",
102
+ "@jsenv/assert": "./packages/assert/",
103
+ "@jsenv/eslint-config": "./packages/eslint-config/",
104
104
  "@jsenv/file-size-impact": "13.0.1",
105
105
  "@jsenv/https-local": "3.0.1",
106
106
  "@jsenv/package-workspace": "0.5.0",
@@ -132,6 +132,7 @@ export const build = async ({
132
132
  versioning = true,
133
133
  versioningMethod = "search_param", // "filename", "search_param"
134
134
  lineBreakNormalization = process.platform === "win32",
135
+ ribbon,
135
136
 
136
137
  clientFiles = {
137
138
  "./src/": true,
@@ -231,6 +232,7 @@ build ${entryPointKeys.length} entry points`)
231
232
  },
232
233
  minification,
233
234
  bundling,
235
+ ribbon,
234
236
  }),
235
237
  ],
236
238
  sourcemaps,
@@ -35,6 +35,7 @@ export const createFileService = ({
35
35
  clientMainFileUrl,
36
36
  cooldownBetweenFileEvents,
37
37
  explorer,
38
+ ribbon,
38
39
  sourcemaps,
39
40
  sourcemapsSourcesProtocol,
40
41
  sourcemapsSourcesContent,
@@ -138,6 +139,7 @@ export const createFileService = ({
138
139
  clientFileChangeCallbackList,
139
140
  clientFilesPruneCallbackList,
140
141
  explorer,
142
+ ribbon,
141
143
  }),
142
144
  ],
143
145
  sourcemaps,
@@ -22,6 +22,8 @@ import {
22
22
  explorerHtmlFileUrl,
23
23
  jsenvPluginExplorer,
24
24
  } from "./explorer/jsenv_plugin_explorer.js"
25
+ // other
26
+ import { jsenvPluginRibbon } from "./ribbon/jsenv_plugin_ribbon.js"
25
27
 
26
28
  export const getCorePlugins = ({
27
29
  rootDirectoryUrl,
@@ -41,6 +43,7 @@ export const getCorePlugins = ({
41
43
  clientFileChangeCallbackList,
42
44
  clientFilesPruneCallbackList,
43
45
  explorer,
46
+ ribbon = false,
44
47
  } = {}) => {
45
48
  if (explorer === true) {
46
49
  explorer = {}
@@ -61,6 +64,9 @@ export const getCorePlugins = ({
61
64
  } else {
62
65
  clientMainFileUrl = String(clientMainFileUrl)
63
66
  }
67
+ if (ribbon === true) {
68
+ ribbon = {}
69
+ }
64
70
 
65
71
  return [
66
72
  jsenvPluginUrlAnalysis({ rootDirectoryUrl, ...urlAnalysis }),
@@ -100,12 +106,8 @@ export const getCorePlugins = ({
100
106
  : []),
101
107
  jsenvPluginCacheControl(),
102
108
  ...(explorer
103
- ? [
104
- jsenvPluginExplorer({
105
- ...explorer,
106
- clientMainFileUrl,
107
- }),
108
- ]
109
+ ? [jsenvPluginExplorer({ ...explorer, clientMainFileUrl })]
109
110
  : []),
111
+ ...(ribbon ? [jsenvPluginRibbon(ribbon)] : []),
110
112
  ]
111
113
  }
@@ -0,0 +1,51 @@
1
+ export const injectRibbon = ({ text }) => {
2
+ const css = /* css */ `
3
+ #jsenv_ribbon_container {
4
+ position: absolute;
5
+ z-index: 1001;
6
+ top: 0;
7
+ right: 0;
8
+ width: 100px;
9
+ height: 100px;
10
+ overflow: hidden;
11
+ opacity: 0.5;
12
+ pointer-events: none;
13
+ }
14
+ #jsenv_ribbon {
15
+ position: absolute;
16
+ top: -10px;
17
+ right: -10px;
18
+ width: 100%;
19
+ height: 100%;
20
+ }
21
+ #jsenv_ribbon_text {
22
+ position: absolute;
23
+ left: 0px;
24
+ top: 20px;
25
+ transform: rotate(45deg);
26
+ display: block;
27
+ width: 125px;
28
+ line-height: 36px;
29
+ background-color: orange;
30
+ color: rgb(55, 7, 7);
31
+ box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
32
+ font-weight: 700;
33
+ font-size: 16px;
34
+ font-family: "Lato", sans-serif;
35
+ text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
36
+ text-align: center;
37
+ user-select: none;
38
+ }
39
+ `
40
+
41
+ const html = /* html */ `<div id="jsenv_ribbon_container">
42
+ <style>${css}</style>
43
+ <div id="jsenv_ribbon">
44
+ <div id="jsenv_ribbon_text">${text}</span>
45
+ </div>
46
+ </div>`
47
+
48
+ const node = document.createElement("div")
49
+ node.innerHTML = html
50
+ document.body.appendChild(node.firstChild)
51
+ }
@@ -0,0 +1,62 @@
1
+ import {
2
+ parseHtmlString,
3
+ stringifyHtmlAst,
4
+ createHtmlNode,
5
+ injectHtmlNode,
6
+ } from "@jsenv/ast"
7
+ import { URL_META } from "@jsenv/url-meta"
8
+
9
+ export const jsenvPluginRibbon = ({
10
+ htmlInclude = "**/*.html",
11
+ allowDuringBuild = false,
12
+ options = {},
13
+ } = {}) => {
14
+ const ribbonClientFileUrl = new URL("./client/ribbon.js", import.meta.url)
15
+ const associations = URL_META.resolveAssociations(
16
+ {
17
+ ribbon: { [htmlInclude]: true },
18
+ },
19
+ "file://",
20
+ )
21
+ return {
22
+ name: "jsenv:ribbon",
23
+ appliesDuring: "*",
24
+ transformHtmlContent: {
25
+ html: (urlInfo, context) => {
26
+ if (context.scenarios.build && !allowDuringBuild) {
27
+ return null
28
+ }
29
+ const { ribbon } = URL_META.applyAssociations({
30
+ url: urlInfo.url,
31
+ associations,
32
+ })
33
+ if (!ribbon) {
34
+ return null
35
+ }
36
+ const htmlAst = parseHtmlString(urlInfo.content)
37
+ const [ribbonClientFileReference] = context.referenceUtils.inject({
38
+ type: "script_src",
39
+ subtype: "js_module",
40
+ expectedType: "js_module",
41
+ specifier: ribbonClientFileUrl,
42
+ })
43
+ options = {
44
+ text: context.scenarios.dev ? "DEV" : "BUILD",
45
+ ...options,
46
+ }
47
+ injectHtmlNode(
48
+ htmlAst,
49
+ createHtmlNode({
50
+ tagName: "script",
51
+ type: "module",
52
+ content: `
53
+ import { injectRibbon} from ${ribbonClientFileReference.generatedSpecifier}
54
+
55
+ injectRibbon(${JSON.stringify(options, null, " ")})`,
56
+ }),
57
+ )
58
+ return stringifyHtmlAst(htmlAst)
59
+ },
60
+ },
61
+ }
62
+ }