UNPKG

@shopify/app-bridge

Version:

**Shopify is doubling our engineering staff in 2021! [Join our team and work on libraries like this one.](https://smrtr.io/5GGrc)**

85 lines (84 loc) 2.55 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.capture = exports.openCamera = exports.create = exports.Scanner = exports.Action = void 0; var helper_1 = require("../helper"); var types_1 = require("../types"); /** * Action Types for the Features group * @public */ var Action; (function (Action) { Action["OPEN_CAMERA"] = "APP::SCANNER::OPEN::CAMERA"; Action["CAPTURE"] = "APP::SCANNER::CAPTURE"; })(Action = exports.Action || (exports.Action = {})); /** * A set of Actions for displaying a Camera Scanner component * @public */ var Scanner = /** @class */ (function (_super) { __extends(Scanner, _super); function Scanner(app, options) { return _super.call(this, app, types_1.Group.Scanner, types_1.Group.Scanner, options ? options.id : undefined) || this; } /** * @public */ Scanner.prototype.dispatch = function (action) { switch (action) { case Action.OPEN_CAMERA: this.dispatchScannerAction(Action.OPEN_CAMERA); break; } return this; }; /** * @internal */ Scanner.prototype.dispatchScannerAction = function (type) { this.app.dispatch(helper_1.actionWrapper({ type: type, group: types_1.Group.Scanner, payload: { id: this.id, }, })); }; return Scanner; }(helper_1.ActionSet)); exports.Scanner = Scanner; /** * @public */ function create(app, options) { return new Scanner(app, options); } exports.create = create; function openCamera() { return helper_1.actionWrapper({ group: types_1.Group.Scanner, type: Action.OPEN_CAMERA, }); } exports.openCamera = openCamera; function capture(payload) { return helper_1.actionWrapper({ group: types_1.Group.Scanner, type: Action.CAPTURE, payload: payload, }); } exports.capture = capture;