one
Version:
One is a React framework for web, iOS, and Android apps.
194 lines (191 loc) • 6.83 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all) __defProp(target, name, {
get: all[name],
enumerable: true
});
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: () => from[key],
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var types_exports = {};
__export(types_exports, {
DEFAULT_ACTION_IDENTIFIER: () => DEFAULT_ACTION_IDENTIFIER,
assertCategoryActions: () => assertCategoryActions,
assertCategoryIdentifier: () => assertCategoryIdentifier,
assertCategoryOptions: () => assertCategoryOptions,
fromNativeAuthorizationStatus: () => fromNativeAuthorizationStatus,
fromNativeImportance: () => fromNativeImportance,
toNativeImportance: () => toNativeImportance
});
module.exports = __toCommonJS(types_exports);
function fromNativeAuthorizationStatus(status) {
if (typeof status === "string") return status;
switch (status) {
case 0: return "notDetermined";
case 1: return "denied";
case 2: return "authorized";
case 3: return "provisional";
case 4: return "ephemeral";
default: return "notDetermined";
}
}
var importanceToInt = {
none: 0,
min: 1,
low: 2,
default: 3,
high: 4,
max: 5
};
function toNativeImportance(value) {
if (typeof value === "number") {
if (!Number.isInteger(value) || value < 0 || value > 5) {
throw new Error("Notifications.setChannel: importance must be one of none, min, low, default, high, max");
}
return value;
}
var mapped = importanceToInt[value];
if (mapped === void 0) {
throw new Error("Notifications.setChannel: importance must be one of none, min, low, default, high, max");
}
return mapped;
}
function fromNativeImportance(value) {
switch (value) {
case 0: return "none";
case 1: return "min";
case 2: return "low";
case 3: return "default";
case 4: return "high";
case 5: return "max";
default: return "default";
}
}
var DEFAULT_ACTION_IDENTIFIER = "expo.modules.notifications.actions.DEFAULT";
function assertCategoryIdentifier(identifier, verb) {
if (typeof identifier !== "string" || identifier.length === 0) {
throw new Error(`Notifications.${verb}: identifier must be a non-empty string`);
}
if (identifier.includes(":") || identifier.includes("-")) {
throw new Error(`Notifications.${verb}: identifier must not contain ':' or '-'`);
}
}
function assertBooleans(verb, what, value, fields) {
if (value === void 0) return;
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
try {
for (var _iterator = fields[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var field = _step.value;
var entry = value[field];
if (entry !== void 0 && typeof entry !== "boolean") {
throw new Error(`Notifications.${verb}: ${what}.${field} must be a boolean`);
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
function assertCategoryActions(actions, verb) {
if (!Array.isArray(actions)) {
throw new Error(`Notifications.${verb}: actions must be an array`);
}
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
try {
for (var _iterator = actions[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var action = _step.value;
if (!action || typeof action !== "object") {
throw new Error(`Notifications.${verb}: each action must be an object`);
}
var { identifier, buttonTitle, options, textInput } = action;
if (typeof identifier !== "string" || identifier.length === 0) {
throw new Error(`Notifications.${verb}: each action needs a non-empty identifier`);
}
if (typeof buttonTitle !== "string" || buttonTitle.length === 0) {
throw new Error(`Notifications.${verb}: each action needs a non-empty buttonTitle`);
}
if (options !== void 0 && (typeof options !== "object" || options === null)) {
throw new Error(`Notifications.${verb}: action options must be an object`);
}
assertBooleans(verb, "action options", options, [
"isAuthenticationRequired",
"isDestructive",
"opensAppToForeground"
]);
if (textInput !== void 0) {
if (typeof textInput !== "object" || textInput === null) {
throw new Error(`Notifications.${verb}: action textInput must be an object`);
}
var { placeholder, submitButtonTitle } = textInput;
if (typeof placeholder !== "string" || placeholder.length === 0) {
throw new Error(`Notifications.${verb}: action textInput needs a non-empty placeholder`);
}
if (submitButtonTitle !== void 0 && typeof submitButtonTitle !== "string") {
throw new Error(`Notifications.${verb}: action textInput.submitButtonTitle must be a string`);
}
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
function assertCategoryOptions(options, verb) {
if (options === void 0) return;
if (!options || typeof options !== "object") {
throw new Error(`Notifications.${verb}: options must be an object`);
}
assertBooleans(verb, "options", options, [
"allowInCarPlay",
"allowAnnouncement",
"customDismissAction",
"showTitle",
"showSubtitle"
]);
if (options.categorySummaryFormat !== void 0 && typeof options.categorySummaryFormat !== "string") {
throw new Error(`Notifications.${verb}: options.categorySummaryFormat must be a string`);
}
if (options.previewPlaceholder !== void 0 && typeof options.previewPlaceholder !== "string") {
throw new Error(`Notifications.${verb}: options.previewPlaceholder must be a string`);
}
if (options.intentIdentifiers !== void 0) {
if (!Array.isArray(options.intentIdentifiers) || options.intentIdentifiers.some(function(entry) {
return typeof entry !== "string";
})) {
throw new Error(`Notifications.${verb}: options.intentIdentifiers must be string[]`);
}
}
}
//# sourceMappingURL=types.native.js.map