@shopify/app-bridge-core
Version:
**[Join our team and work on libraries like this one.](https://www.shopify.ca/careers)**
61 lines (58 loc) • 1.4 kB
JavaScript
import { actionWrapper } from '../helper.js';
import { ActionSet } from '../ActionSet.js';
import { Group } from '../types.js';
/**
* Action Types for the Features group
* @public
*/
var Action;
(function (Action) {
Action["OPEN_CAMERA"] = "APP::SCANNER::OPEN::CAMERA";
Action["CAPTURE"] = "APP::SCANNER::CAPTURE";
})(Action || (Action = {}));
/**
* A set of Actions for displaying a Camera Scanner component
* @public
*/
class Scanner extends ActionSet {
constructor(app, options) {
super(app, Group.Scanner, Group.Scanner, options ? options.id : undefined);
}
/**
* @public
*/
dispatch(action) {
switch (action) {
case Action.OPEN_CAMERA:
this.dispatchScannerAction(Action.OPEN_CAMERA);
break;
}
return this;
}
/**
* @internal
*/
dispatchScannerAction(type) {
this.app.dispatch(actionWrapper({
type,
group: Group.Scanner,
payload: {
id: this.id,
},
}));
}
}
function openCamera() {
return actionWrapper({
group: Group.Scanner,
type: Action.OPEN_CAMERA,
});
}
function capture(payload) {
return actionWrapper({
group: Group.Scanner,
type: Action.CAPTURE,
payload,
});
}
export { Action, Scanner, capture, openCamera };