UNPKG

@shopify/app-bridge-core

Version:

**[Join our team and work on libraries like this one.](https://www.shopify.ca/careers)**

81 lines (80 loc) 2.61 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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); 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.Scanner = exports.Action = void 0; exports.openCamera = openCamera; exports.capture = capture; var helper_1 = require("../helper"); var ActionSet_1 = require("../ActionSet"); 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 = 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((0, helper_1.actionWrapper)({ type: type, group: types_1.Group.Scanner, payload: { id: this.id, }, })); }; return Scanner; }(ActionSet_1.ActionSet)); exports.Scanner = Scanner; function openCamera() { return (0, helper_1.actionWrapper)({ group: types_1.Group.Scanner, type: Action.OPEN_CAMERA, }); } function capture(payload) { return (0, helper_1.actionWrapper)({ group: types_1.Group.Scanner, type: Action.CAPTURE, payload: payload, }); }