node-libcamera 0.1.0 → 0.1.6

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.
@@ -4,94 +4,805 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var child_process = require('child_process');
6
6
 
7
- var OPTIONS = {
8
- help: {
9
- "short": 'h',
10
- desc: 'Print help information for the application'
11
- },
12
- version: {
13
- desc: 'Print help information for the application'
14
- },
15
- timeout: {
16
- "short": 't',
17
- desc: 'Delay before application stops automatically <milliseconds>',
18
- validator: function validator(val) {
19
- return typeof val === 'number';
20
- },
21
- convert: function convert(val) {
22
- return val.toString();
7
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
8
+ try {
9
+ var info = gen[key](arg);
10
+ var value = info.value;
11
+ } catch (error) {
12
+ reject(error);
13
+ return;
14
+ }
15
+
16
+ if (info.done) {
17
+ resolve(value);
18
+ } else {
19
+ Promise.resolve(value).then(_next, _throw);
20
+ }
21
+ }
22
+
23
+ function _asyncToGenerator(fn) {
24
+ return function () {
25
+ var self = this,
26
+ args = arguments;
27
+ return new Promise(function (resolve, reject) {
28
+ var gen = fn.apply(self, args);
29
+
30
+ function _next(value) {
31
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
32
+ }
33
+
34
+ function _throw(err) {
35
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
36
+ }
37
+
38
+ _next(undefined);
39
+ });
40
+ };
41
+ }
42
+
43
+ function createCommonjsModule(fn, module) {
44
+ return module = { exports: {} }, fn(module, module.exports), module.exports;
45
+ }
46
+
47
+ var runtime_1 = createCommonjsModule(function (module) {
48
+ /**
49
+ * Copyright (c) 2014-present, Facebook, Inc.
50
+ *
51
+ * This source code is licensed under the MIT license found in the
52
+ * LICENSE file in the root directory of this source tree.
53
+ */
54
+
55
+ var runtime = (function (exports) {
56
+
57
+ var Op = Object.prototype;
58
+ var hasOwn = Op.hasOwnProperty;
59
+ var undefined$1; // More compressible than void 0.
60
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
61
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
62
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
63
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
64
+
65
+ function define(obj, key, value) {
66
+ Object.defineProperty(obj, key, {
67
+ value: value,
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true
71
+ });
72
+ return obj[key];
73
+ }
74
+ try {
75
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
76
+ define({}, "");
77
+ } catch (err) {
78
+ define = function(obj, key, value) {
79
+ return obj[key] = value;
80
+ };
81
+ }
82
+
83
+ function wrap(innerFn, outerFn, self, tryLocsList) {
84
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
85
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
86
+ var generator = Object.create(protoGenerator.prototype);
87
+ var context = new Context(tryLocsList || []);
88
+
89
+ // The ._invoke method unifies the implementations of the .next,
90
+ // .throw, and .return methods.
91
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
92
+
93
+ return generator;
94
+ }
95
+ exports.wrap = wrap;
96
+
97
+ // Try/catch helper to minimize deoptimizations. Returns a completion
98
+ // record like context.tryEntries[i].completion. This interface could
99
+ // have been (and was previously) designed to take a closure to be
100
+ // invoked without arguments, but in all the cases we care about we
101
+ // already have an existing method we want to call, so there's no need
102
+ // to create a new function object. We can even get away with assuming
103
+ // the method takes exactly one argument, since that happens to be true
104
+ // in every case, so we don't have to touch the arguments object. The
105
+ // only additional allocation required is the completion record, which
106
+ // has a stable shape and so hopefully should be cheap to allocate.
107
+ function tryCatch(fn, obj, arg) {
108
+ try {
109
+ return { type: "normal", arg: fn.call(obj, arg) };
110
+ } catch (err) {
111
+ return { type: "throw", arg: err };
23
112
  }
24
- },
25
- preview: {
26
- "short": 'p',
27
- desc: 'Preview window settings <x,y,w,h>',
28
- validator: function validator(val) {
29
- return typeof val === 'object' && Boolean((val == null ? void 0 : val.x) && (val == null ? void 0 : val.y) && (val == null ? void 0 : val.width) && (val == null ? void 0 : val.height));
30
- },
31
- convert: function convert(val) {
32
- return val.x + "," + val.y + "," + val.width + "," + val.height;
113
+ }
114
+
115
+ var GenStateSuspendedStart = "suspendedStart";
116
+ var GenStateSuspendedYield = "suspendedYield";
117
+ var GenStateExecuting = "executing";
118
+ var GenStateCompleted = "completed";
119
+
120
+ // Returning this object from the innerFn has the same effect as
121
+ // breaking out of the dispatch switch statement.
122
+ var ContinueSentinel = {};
123
+
124
+ // Dummy constructor functions that we use as the .constructor and
125
+ // .constructor.prototype properties for functions that return Generator
126
+ // objects. For full spec compliance, you may wish to configure your
127
+ // minifier not to mangle the names of these two functions.
128
+ function Generator() {}
129
+ function GeneratorFunction() {}
130
+ function GeneratorFunctionPrototype() {}
131
+
132
+ // This is a polyfill for %IteratorPrototype% for environments that
133
+ // don't natively support it.
134
+ var IteratorPrototype = {};
135
+ define(IteratorPrototype, iteratorSymbol, function () {
136
+ return this;
137
+ });
138
+
139
+ var getProto = Object.getPrototypeOf;
140
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
141
+ if (NativeIteratorPrototype &&
142
+ NativeIteratorPrototype !== Op &&
143
+ hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
144
+ // This environment has a native %IteratorPrototype%; use it instead
145
+ // of the polyfill.
146
+ IteratorPrototype = NativeIteratorPrototype;
147
+ }
148
+
149
+ var Gp = GeneratorFunctionPrototype.prototype =
150
+ Generator.prototype = Object.create(IteratorPrototype);
151
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
152
+ define(Gp, "constructor", GeneratorFunctionPrototype);
153
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
154
+ GeneratorFunction.displayName = define(
155
+ GeneratorFunctionPrototype,
156
+ toStringTagSymbol,
157
+ "GeneratorFunction"
158
+ );
159
+
160
+ // Helper for defining the .next, .throw, and .return methods of the
161
+ // Iterator interface in terms of a single ._invoke method.
162
+ function defineIteratorMethods(prototype) {
163
+ ["next", "throw", "return"].forEach(function(method) {
164
+ define(prototype, method, function(arg) {
165
+ return this._invoke(method, arg);
166
+ });
167
+ });
168
+ }
169
+
170
+ exports.isGeneratorFunction = function(genFun) {
171
+ var ctor = typeof genFun === "function" && genFun.constructor;
172
+ return ctor
173
+ ? ctor === GeneratorFunction ||
174
+ // For the native GeneratorFunction constructor, the best we can
175
+ // do is to check its .name property.
176
+ (ctor.displayName || ctor.name) === "GeneratorFunction"
177
+ : false;
178
+ };
179
+
180
+ exports.mark = function(genFun) {
181
+ if (Object.setPrototypeOf) {
182
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
183
+ } else {
184
+ genFun.__proto__ = GeneratorFunctionPrototype;
185
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
33
186
  }
34
- },
35
- fullscreen: {
36
- "short": 'f',
37
- desc: 'Fullscreen preview mode'
38
- },
39
- 'qt-preview': {
40
- desc: 'Use Qt-based preview window'
41
- },
42
- nopreview: {
43
- "short": 'n',
44
- desc: 'Do not display a preview window'
45
- },
46
- 'info-text': {
47
- desc: 'Set window title bar text <string>',
48
- validator: function validator(val) {
49
- return typeof val === 'string';
187
+ genFun.prototype = Object.create(Gp);
188
+ return genFun;
189
+ };
190
+
191
+ // Within the body of any async function, `await x` is transformed to
192
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
193
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
194
+ // meant to be awaited.
195
+ exports.awrap = function(arg) {
196
+ return { __await: arg };
197
+ };
198
+
199
+ function AsyncIterator(generator, PromiseImpl) {
200
+ function invoke(method, arg, resolve, reject) {
201
+ var record = tryCatch(generator[method], generator, arg);
202
+ if (record.type === "throw") {
203
+ reject(record.arg);
204
+ } else {
205
+ var result = record.arg;
206
+ var value = result.value;
207
+ if (value &&
208
+ typeof value === "object" &&
209
+ hasOwn.call(value, "__await")) {
210
+ return PromiseImpl.resolve(value.__await).then(function(value) {
211
+ invoke("next", value, resolve, reject);
212
+ }, function(err) {
213
+ invoke("throw", err, resolve, reject);
214
+ });
215
+ }
216
+
217
+ return PromiseImpl.resolve(value).then(function(unwrapped) {
218
+ // When a yielded Promise is resolved, its final value becomes
219
+ // the .value of the Promise<{value,done}> result for the
220
+ // current iteration.
221
+ result.value = unwrapped;
222
+ resolve(result);
223
+ }, function(error) {
224
+ // If a rejected Promise was yielded, throw the rejection back
225
+ // into the async generator function so it can be handled there.
226
+ return invoke("throw", error, resolve, reject);
227
+ });
228
+ }
50
229
  }
51
- },
52
- width: {
53
- desc: 'Capture image width <width>',
54
- validator: function validator(val) {
55
- return typeof val === 'number';
56
- },
57
- convert: function convert(val) {
58
- return val.toString();
230
+
231
+ var previousPromise;
232
+
233
+ function enqueue(method, arg) {
234
+ function callInvokeWithMethodAndArg() {
235
+ return new PromiseImpl(function(resolve, reject) {
236
+ invoke(method, arg, resolve, reject);
237
+ });
238
+ }
239
+
240
+ return previousPromise =
241
+ // If enqueue has been called before, then we want to wait until
242
+ // all previous Promises have been resolved before calling invoke,
243
+ // so that results are always delivered in the correct order. If
244
+ // enqueue has not been called before, then it is important to
245
+ // call invoke immediately, without waiting on a callback to fire,
246
+ // so that the async generator function has the opportunity to do
247
+ // any necessary setup in a predictable way. This predictability
248
+ // is why the Promise constructor synchronously invokes its
249
+ // executor callback, and why async functions synchronously
250
+ // execute code before the first await. Since we implement simple
251
+ // async functions in terms of async generators, it is especially
252
+ // important to get this right, even though it requires care.
253
+ previousPromise ? previousPromise.then(
254
+ callInvokeWithMethodAndArg,
255
+ // Avoid propagating failures to Promises returned by later
256
+ // invocations of the iterator.
257
+ callInvokeWithMethodAndArg
258
+ ) : callInvokeWithMethodAndArg();
59
259
  }
60
- },
61
- height: {
62
- desc: 'Capture image height <height>',
63
- validator: function validator(val) {
64
- return typeof val === 'number';
65
- },
66
- convert: function convert(val) {
67
- return val.toString();
260
+
261
+ // Define the unified helper method that is used to implement .next,
262
+ // .throw, and .return (see defineIteratorMethods).
263
+ this._invoke = enqueue;
264
+ }
265
+
266
+ defineIteratorMethods(AsyncIterator.prototype);
267
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
268
+ return this;
269
+ });
270
+ exports.AsyncIterator = AsyncIterator;
271
+
272
+ // Note that simple async functions are implemented on top of
273
+ // AsyncIterator objects; they just return a Promise for the value of
274
+ // the final result produced by the iterator.
275
+ exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
276
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
277
+
278
+ var iter = new AsyncIterator(
279
+ wrap(innerFn, outerFn, self, tryLocsList),
280
+ PromiseImpl
281
+ );
282
+
283
+ return exports.isGeneratorFunction(outerFn)
284
+ ? iter // If outerFn is a generator, return the full iterator.
285
+ : iter.next().then(function(result) {
286
+ return result.done ? result.value : iter.next();
287
+ });
288
+ };
289
+
290
+ function makeInvokeMethod(innerFn, self, context) {
291
+ var state = GenStateSuspendedStart;
292
+
293
+ return function invoke(method, arg) {
294
+ if (state === GenStateExecuting) {
295
+ throw new Error("Generator is already running");
296
+ }
297
+
298
+ if (state === GenStateCompleted) {
299
+ if (method === "throw") {
300
+ throw arg;
301
+ }
302
+
303
+ // Be forgiving, per 25.3.3.3.3 of the spec:
304
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
305
+ return doneResult();
306
+ }
307
+
308
+ context.method = method;
309
+ context.arg = arg;
310
+
311
+ while (true) {
312
+ var delegate = context.delegate;
313
+ if (delegate) {
314
+ var delegateResult = maybeInvokeDelegate(delegate, context);
315
+ if (delegateResult) {
316
+ if (delegateResult === ContinueSentinel) continue;
317
+ return delegateResult;
318
+ }
319
+ }
320
+
321
+ if (context.method === "next") {
322
+ // Setting context._sent for legacy support of Babel's
323
+ // function.sent implementation.
324
+ context.sent = context._sent = context.arg;
325
+
326
+ } else if (context.method === "throw") {
327
+ if (state === GenStateSuspendedStart) {
328
+ state = GenStateCompleted;
329
+ throw context.arg;
330
+ }
331
+
332
+ context.dispatchException(context.arg);
333
+
334
+ } else if (context.method === "return") {
335
+ context.abrupt("return", context.arg);
336
+ }
337
+
338
+ state = GenStateExecuting;
339
+
340
+ var record = tryCatch(innerFn, self, context);
341
+ if (record.type === "normal") {
342
+ // If an exception is thrown from innerFn, we leave state ===
343
+ // GenStateExecuting and loop back for another invocation.
344
+ state = context.done
345
+ ? GenStateCompleted
346
+ : GenStateSuspendedYield;
347
+
348
+ if (record.arg === ContinueSentinel) {
349
+ continue;
350
+ }
351
+
352
+ return {
353
+ value: record.arg,
354
+ done: context.done
355
+ };
356
+
357
+ } else if (record.type === "throw") {
358
+ state = GenStateCompleted;
359
+ // Dispatch the exception by looping back around to the
360
+ // context.dispatchException(context.arg) call above.
361
+ context.method = "throw";
362
+ context.arg = record.arg;
363
+ }
364
+ }
365
+ };
366
+ }
367
+
368
+ // Call delegate.iterator[context.method](context.arg) and handle the
369
+ // result, either by returning a { value, done } result from the
370
+ // delegate iterator, or by modifying context.method and context.arg,
371
+ // setting context.delegate to null, and returning the ContinueSentinel.
372
+ function maybeInvokeDelegate(delegate, context) {
373
+ var method = delegate.iterator[context.method];
374
+ if (method === undefined$1) {
375
+ // A .throw or .return when the delegate iterator has no .throw
376
+ // method always terminates the yield* loop.
377
+ context.delegate = null;
378
+
379
+ if (context.method === "throw") {
380
+ // Note: ["return"] must be used for ES3 parsing compatibility.
381
+ if (delegate.iterator["return"]) {
382
+ // If the delegate iterator has a return method, give it a
383
+ // chance to clean up.
384
+ context.method = "return";
385
+ context.arg = undefined$1;
386
+ maybeInvokeDelegate(delegate, context);
387
+
388
+ if (context.method === "throw") {
389
+ // If maybeInvokeDelegate(context) changed context.method from
390
+ // "return" to "throw", let that override the TypeError below.
391
+ return ContinueSentinel;
392
+ }
393
+ }
394
+
395
+ context.method = "throw";
396
+ context.arg = new TypeError(
397
+ "The iterator does not provide a 'throw' method");
398
+ }
399
+
400
+ return ContinueSentinel;
68
401
  }
69
- },
70
- 'viewfinder-width': {
71
- desc: 'Capture image width <width>',
72
- validator: function validator(val) {
73
- return typeof val === 'number';
74
- },
75
- convert: function convert(val) {
76
- return val.toString();
402
+
403
+ var record = tryCatch(method, delegate.iterator, context.arg);
404
+
405
+ if (record.type === "throw") {
406
+ context.method = "throw";
407
+ context.arg = record.arg;
408
+ context.delegate = null;
409
+ return ContinueSentinel;
77
410
  }
78
- },
79
- 'viewfinder-height': {
80
- desc: 'Capture image height <height>',
81
- validator: function validator(val) {
82
- return typeof val === 'number';
83
- },
84
- convert: function convert(val) {
85
- return val.toString();
411
+
412
+ var info = record.arg;
413
+
414
+ if (! info) {
415
+ context.method = "throw";
416
+ context.arg = new TypeError("iterator result is not an object");
417
+ context.delegate = null;
418
+ return ContinueSentinel;
419
+ }
420
+
421
+ if (info.done) {
422
+ // Assign the result of the finished delegate to the temporary
423
+ // variable specified by delegate.resultName (see delegateYield).
424
+ context[delegate.resultName] = info.value;
425
+
426
+ // Resume execution at the desired location (see delegateYield).
427
+ context.next = delegate.nextLoc;
428
+
429
+ // If context.method was "throw" but the delegate handled the
430
+ // exception, let the outer generator proceed normally. If
431
+ // context.method was "next", forget context.arg since it has been
432
+ // "consumed" by the delegate iterator. If context.method was
433
+ // "return", allow the original .return call to continue in the
434
+ // outer generator.
435
+ if (context.method !== "return") {
436
+ context.method = "next";
437
+ context.arg = undefined$1;
438
+ }
439
+
440
+ } else {
441
+ // Re-yield the result returned by the delegate method.
442
+ return info;
443
+ }
444
+
445
+ // The delegate iterator is finished, so forget it and continue with
446
+ // the outer generator.
447
+ context.delegate = null;
448
+ return ContinueSentinel;
449
+ }
450
+
451
+ // Define Generator.prototype.{next,throw,return} in terms of the
452
+ // unified ._invoke helper method.
453
+ defineIteratorMethods(Gp);
454
+
455
+ define(Gp, toStringTagSymbol, "Generator");
456
+
457
+ // A Generator should always return itself as the iterator object when the
458
+ // @@iterator function is called on it. Some browsers' implementations of the
459
+ // iterator prototype chain incorrectly implement this, causing the Generator
460
+ // object to not be returned from this call. This ensures that doesn't happen.
461
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
462
+ define(Gp, iteratorSymbol, function() {
463
+ return this;
464
+ });
465
+
466
+ define(Gp, "toString", function() {
467
+ return "[object Generator]";
468
+ });
469
+
470
+ function pushTryEntry(locs) {
471
+ var entry = { tryLoc: locs[0] };
472
+
473
+ if (1 in locs) {
474
+ entry.catchLoc = locs[1];
475
+ }
476
+
477
+ if (2 in locs) {
478
+ entry.finallyLoc = locs[2];
479
+ entry.afterLoc = locs[3];
86
480
  }
87
- },
88
- // ...
89
- output: {
90
- "short": 'o',
91
- desc: 'Output file name <string>',
92
- validator: function validator(val) {
93
- return typeof val === 'string';
481
+
482
+ this.tryEntries.push(entry);
483
+ }
484
+
485
+ function resetTryEntry(entry) {
486
+ var record = entry.completion || {};
487
+ record.type = "normal";
488
+ delete record.arg;
489
+ entry.completion = record;
490
+ }
491
+
492
+ function Context(tryLocsList) {
493
+ // The root entry object (effectively a try statement without a catch
494
+ // or a finally block) gives us a place to store values thrown from
495
+ // locations where there is no enclosing try statement.
496
+ this.tryEntries = [{ tryLoc: "root" }];
497
+ tryLocsList.forEach(pushTryEntry, this);
498
+ this.reset(true);
499
+ }
500
+
501
+ exports.keys = function(object) {
502
+ var keys = [];
503
+ for (var key in object) {
504
+ keys.push(key);
505
+ }
506
+ keys.reverse();
507
+
508
+ // Rather than returning an object with a next method, we keep
509
+ // things simple and return the next function itself.
510
+ return function next() {
511
+ while (keys.length) {
512
+ var key = keys.pop();
513
+ if (key in object) {
514
+ next.value = key;
515
+ next.done = false;
516
+ return next;
517
+ }
518
+ }
519
+
520
+ // To avoid creating an additional object, we just hang the .value
521
+ // and .done properties off the next function object itself. This
522
+ // also ensures that the minifier will not anonymize the function.
523
+ next.done = true;
524
+ return next;
525
+ };
526
+ };
527
+
528
+ function values(iterable) {
529
+ if (iterable) {
530
+ var iteratorMethod = iterable[iteratorSymbol];
531
+ if (iteratorMethod) {
532
+ return iteratorMethod.call(iterable);
533
+ }
534
+
535
+ if (typeof iterable.next === "function") {
536
+ return iterable;
537
+ }
538
+
539
+ if (!isNaN(iterable.length)) {
540
+ var i = -1, next = function next() {
541
+ while (++i < iterable.length) {
542
+ if (hasOwn.call(iterable, i)) {
543
+ next.value = iterable[i];
544
+ next.done = false;
545
+ return next;
546
+ }
547
+ }
548
+
549
+ next.value = undefined$1;
550
+ next.done = true;
551
+
552
+ return next;
553
+ };
554
+
555
+ return next.next = next;
556
+ }
557
+ }
558
+
559
+ // Return an iterator with no values.
560
+ return { next: doneResult };
561
+ }
562
+ exports.values = values;
563
+
564
+ function doneResult() {
565
+ return { value: undefined$1, done: true };
566
+ }
567
+
568
+ Context.prototype = {
569
+ constructor: Context,
570
+
571
+ reset: function(skipTempReset) {
572
+ this.prev = 0;
573
+ this.next = 0;
574
+ // Resetting context._sent for legacy support of Babel's
575
+ // function.sent implementation.
576
+ this.sent = this._sent = undefined$1;
577
+ this.done = false;
578
+ this.delegate = null;
579
+
580
+ this.method = "next";
581
+ this.arg = undefined$1;
582
+
583
+ this.tryEntries.forEach(resetTryEntry);
584
+
585
+ if (!skipTempReset) {
586
+ for (var name in this) {
587
+ // Not sure about the optimal order of these conditions:
588
+ if (name.charAt(0) === "t" &&
589
+ hasOwn.call(this, name) &&
590
+ !isNaN(+name.slice(1))) {
591
+ this[name] = undefined$1;
592
+ }
593
+ }
594
+ }
595
+ },
596
+
597
+ stop: function() {
598
+ this.done = true;
599
+
600
+ var rootEntry = this.tryEntries[0];
601
+ var rootRecord = rootEntry.completion;
602
+ if (rootRecord.type === "throw") {
603
+ throw rootRecord.arg;
604
+ }
605
+
606
+ return this.rval;
607
+ },
608
+
609
+ dispatchException: function(exception) {
610
+ if (this.done) {
611
+ throw exception;
612
+ }
613
+
614
+ var context = this;
615
+ function handle(loc, caught) {
616
+ record.type = "throw";
617
+ record.arg = exception;
618
+ context.next = loc;
619
+
620
+ if (caught) {
621
+ // If the dispatched exception was caught by a catch block,
622
+ // then let that catch block handle the exception normally.
623
+ context.method = "next";
624
+ context.arg = undefined$1;
625
+ }
626
+
627
+ return !! caught;
628
+ }
629
+
630
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
631
+ var entry = this.tryEntries[i];
632
+ var record = entry.completion;
633
+
634
+ if (entry.tryLoc === "root") {
635
+ // Exception thrown outside of any try block that could handle
636
+ // it, so set the completion value of the entire function to
637
+ // throw the exception.
638
+ return handle("end");
639
+ }
640
+
641
+ if (entry.tryLoc <= this.prev) {
642
+ var hasCatch = hasOwn.call(entry, "catchLoc");
643
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
644
+
645
+ if (hasCatch && hasFinally) {
646
+ if (this.prev < entry.catchLoc) {
647
+ return handle(entry.catchLoc, true);
648
+ } else if (this.prev < entry.finallyLoc) {
649
+ return handle(entry.finallyLoc);
650
+ }
651
+
652
+ } else if (hasCatch) {
653
+ if (this.prev < entry.catchLoc) {
654
+ return handle(entry.catchLoc, true);
655
+ }
656
+
657
+ } else if (hasFinally) {
658
+ if (this.prev < entry.finallyLoc) {
659
+ return handle(entry.finallyLoc);
660
+ }
661
+
662
+ } else {
663
+ throw new Error("try statement without catch or finally");
664
+ }
665
+ }
666
+ }
667
+ },
668
+
669
+ abrupt: function(type, arg) {
670
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
671
+ var entry = this.tryEntries[i];
672
+ if (entry.tryLoc <= this.prev &&
673
+ hasOwn.call(entry, "finallyLoc") &&
674
+ this.prev < entry.finallyLoc) {
675
+ var finallyEntry = entry;
676
+ break;
677
+ }
678
+ }
679
+
680
+ if (finallyEntry &&
681
+ (type === "break" ||
682
+ type === "continue") &&
683
+ finallyEntry.tryLoc <= arg &&
684
+ arg <= finallyEntry.finallyLoc) {
685
+ // Ignore the finally entry if control is not jumping to a
686
+ // location outside the try/catch block.
687
+ finallyEntry = null;
688
+ }
689
+
690
+ var record = finallyEntry ? finallyEntry.completion : {};
691
+ record.type = type;
692
+ record.arg = arg;
693
+
694
+ if (finallyEntry) {
695
+ this.method = "next";
696
+ this.next = finallyEntry.finallyLoc;
697
+ return ContinueSentinel;
698
+ }
699
+
700
+ return this.complete(record);
701
+ },
702
+
703
+ complete: function(record, afterLoc) {
704
+ if (record.type === "throw") {
705
+ throw record.arg;
706
+ }
707
+
708
+ if (record.type === "break" ||
709
+ record.type === "continue") {
710
+ this.next = record.arg;
711
+ } else if (record.type === "return") {
712
+ this.rval = this.arg = record.arg;
713
+ this.method = "return";
714
+ this.next = "end";
715
+ } else if (record.type === "normal" && afterLoc) {
716
+ this.next = afterLoc;
717
+ }
718
+
719
+ return ContinueSentinel;
720
+ },
721
+
722
+ finish: function(finallyLoc) {
723
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
724
+ var entry = this.tryEntries[i];
725
+ if (entry.finallyLoc === finallyLoc) {
726
+ this.complete(entry.completion, entry.afterLoc);
727
+ resetTryEntry(entry);
728
+ return ContinueSentinel;
729
+ }
730
+ }
731
+ },
732
+
733
+ "catch": function(tryLoc) {
734
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
735
+ var entry = this.tryEntries[i];
736
+ if (entry.tryLoc === tryLoc) {
737
+ var record = entry.completion;
738
+ if (record.type === "throw") {
739
+ var thrown = record.arg;
740
+ resetTryEntry(entry);
741
+ }
742
+ return thrown;
743
+ }
744
+ }
745
+
746
+ // The context.catch method must only be called with a location
747
+ // argument that corresponds to a known catch block.
748
+ throw new Error("illegal catch attempt");
749
+ },
750
+
751
+ delegateYield: function(iterable, resultName, nextLoc) {
752
+ this.delegate = {
753
+ iterator: values(iterable),
754
+ resultName: resultName,
755
+ nextLoc: nextLoc
756
+ };
757
+
758
+ if (this.method === "next") {
759
+ // Deliberately forget the last sent value so that we don't
760
+ // accidentally pass it on to the delegate.
761
+ this.arg = undefined$1;
762
+ }
763
+
764
+ return ContinueSentinel;
94
765
  }
766
+ };
767
+
768
+ // Regardless of whether this script is executing as a CommonJS module
769
+ // or not, return the runtime object so that we can declare the variable
770
+ // regeneratorRuntime in the outer scope, which allows this module to be
771
+ // injected easily by `bin/regenerator --include-runtime script.js`.
772
+ return exports;
773
+
774
+ }(
775
+ // If this script is executing as a CommonJS module, use module.exports
776
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
777
+ // object. Either way, the resulting object will be used to initialize
778
+ // the regeneratorRuntime variable at the top of this file.
779
+ module.exports
780
+ ));
781
+
782
+ try {
783
+ regeneratorRuntime = runtime;
784
+ } catch (accidentalStrictMode) {
785
+ // This module should not be running in strict mode, so the above
786
+ // assignment should always work unless something is misconfigured. Just
787
+ // in case runtime.js accidentally runs in strict mode, in modern engines
788
+ // we can explicitly access globalThis. In older engines we can escape
789
+ // strict mode using a global Function call. This could conceivably fail
790
+ // if a Content Security Policy forbids using Function, but in that case
791
+ // the proper solution is to fix the accidental strict mode problem. If
792
+ // you've misconfigured your bundler to force strict mode and applied a
793
+ // CSP to forbid Function, and you're not willing to fix either of those
794
+ // problems, please detail your unique predicament in a GitHub issue.
795
+ if (typeof globalThis === "object") {
796
+ globalThis.regeneratorRuntime = runtime;
797
+ } else {
798
+ Function("r", "regeneratorRuntime = r")(runtime);
799
+ }
800
+ }
801
+ });
802
+
803
+ var optionConverterMap = {
804
+ preview: function preview(val) {
805
+ return val.x + "," + val.y + "," + val.width + "," + val.height;
95
806
  }
96
807
  };
97
808
 
@@ -112,24 +823,61 @@ function convertOptionsToCmdArgs(options) {
112
823
  Object.entries(options).forEach(function (_ref) {
113
824
  var key = _ref[0],
114
825
  val = _ref[1];
115
- var opt = OPTIONS[key];
116
-
117
- if (typeof opt.validator === 'function' && !opt.validator(val)) {
118
- throw new Error("Invalid value for option \"" + key + "\"");
119
- }
120
-
121
- var value = typeof opt.convert === 'function' ? opt.convert(val) : val;
826
+ var converter = optionConverterMap[key];
827
+ var value = typeof converter === 'function' ? converter(val) : val;
122
828
  if (value) args.push("--" + key);
123
- if (value !== true) args.push(value);
829
+ if (value !== true && value != null && value.toString()) args.push(value == null ? void 0 : value.toString());
124
830
  }, true);
125
831
  return args;
126
832
  }
127
833
 
128
- function snap(options) {
129
- var args = convertOptionsToCmdArgs(options);
130
- var command = cmd('libcamera-still', args);
131
- return run(command);
834
+ function runLibCamera(_x, _x2) {
835
+ return _runLibCamera.apply(this, arguments);
836
+ }
837
+
838
+ function _runLibCamera() {
839
+ _runLibCamera = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(bin, options) {
840
+ var args, command;
841
+ return runtime_1.wrap(function _callee$(_context) {
842
+ while (1) {
843
+ switch (_context.prev = _context.next) {
844
+ case 0:
845
+ if (bin === void 0) {
846
+ bin = 'libcamera-still';
847
+ }
848
+
849
+ args = convertOptionsToCmdArgs(options);
850
+ command = cmd(bin, args);
851
+
852
+ {
853
+ _context.next = 6;
854
+ break;
855
+ }
856
+
857
+ case 6:
858
+ return _context.abrupt("return", run(command));
859
+
860
+ case 7:
861
+ case "end":
862
+ return _context.stop();
863
+ }
864
+ }
865
+ }, _callee);
866
+ }));
867
+ return _runLibCamera.apply(this, arguments);
868
+ }
869
+
870
+ function jpeg(options) {
871
+ return runLibCamera('libcamera-jpeg', options);
872
+ }
873
+ function still(options) {
874
+ return runLibCamera('libcamera-still', options);
875
+ }
876
+ function vid(options) {
877
+ return runLibCamera('libcamera-vid', options);
132
878
  }
133
879
 
134
- exports.snap = snap;
880
+ exports.jpeg = jpeg;
881
+ exports.still = still;
882
+ exports.vid = vid;
135
883
  //# sourceMappingURL=node-libcamera.cjs.development.js.map