You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
4.8 KiB

{"ast":null,"code":"import _asyncToGenerator from \"@babel/runtime/helpers/asyncToGenerator\";\nimport { useEffect } from 'react';\nimport ExpoKeepAwake from \"./ExpoKeepAwake\";\nexport var ExpoKeepAwakeTag = 'ExpoKeepAwakeDefaultTag';\nexport function useKeepAwake() {\n var tag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ExpoKeepAwakeTag;\n var options = arguments.length > 1 ? arguments[1] : undefined;\n useEffect(function () {\n activateKeepAwake(tag);\n return function () {\n if (options != null && options.suppressDeactivateWarnings) {\n deactivateKeepAwake(tag).catch(function () {});\n } else {\n deactivateKeepAwake(tag);\n }\n };\n }, [tag]);\n}\nexport function activateKeepAwake() {\n return _activateKeepAwake.apply(this, arguments);\n}\nfunction _activateKeepAwake() {\n _activateKeepAwake = _asyncToGenerator(function* () {\n var tag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ExpoKeepAwakeTag;\n yield ExpoKeepAwake.activate == null ? void 0 : ExpoKeepAwake.activate(tag);\n });\n return _activateKeepAwake.apply(this, arguments);\n}\nexport function deactivateKeepAwake() {\n return _deactivateKeepAwake.apply(this, arguments);\n}\nfunction _deactivateKeepAwake() {\n _deactivateKeepAwake = _asyncToGenerator(function* () {\n var tag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ExpoKeepAwakeTag;\n yield ExpoKeepAwake.deactivate == null ? void 0 : ExpoKeepAwake.deactivate(tag);\n });\n return _deactivateKeepAwake.apply(this, arguments);\n}","map":{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AAAA,SAAS,SAAS,QAAQ,OAAO;AAEjC,OAAO,aAAa;AAEpB,OAAO,IAAM,gBAAgB,GAAG,yBAAyB;AAgBzD,OAAM,SAAU,YAAY,GAIzB;EAAA,IAHD,GAAA,uEAAc,gBAAgB;EAAA,IAC9B,OAEC;EAED,SAAS,CAAC,YAAK;IACb,iBAAiB,CAAC,GAAG,CAAC;IACtB,OAAO,YAAK;MACV,IAAI,OAAO,YAAP,OAAO,CAAE,0BAA0B,EAAE;QACvC,mBAAmB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,YAAK,CAAE,CAAC,CAAC;OACzC,MAAM;QACL,mBAAmB,CAAC,GAAG,CAAC;MACzB;IACH,CAAC;EACH,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AACX;AAYA,gBAAsB,iBAAiB;EAAA;AAAA;AAEtC;EAAA,uCAFM,aAA+D;IAAA,IAA9B,GAAA,uEAAc,gBAAgB;IACpE,MAAM,aAAa,CAAC,QAAQ,oBAAtB,aAAa,CAAC,QAAQ,CAAG,GAAG,CAAC;EACrC,CAAC;EAAA;AAAA;AASD,gBAAsB,mBAAmB;EAAA;AAAA;AAExC;EAAA,yCAFM,aAAiE;IAAA,IAA9B,GAAA,uEAAc,gBAAgB;IACtE,MAAM,aAAa,CAAC,UAAU,oBAAxB,aAAa,CAAC,UAAU,CAAG,GAAG,CAAC;EACvC,CAAC;EAAA;AAAA","sourcesContent":["import { useEffect } from 'react';\n\nimport ExpoKeepAwake from './ExpoKeepAwake';\n\nexport const ExpoKeepAwakeTag = 'ExpoKeepAwakeDefaultTag';\n\n// @needsAudit\n/**\n * A React hook to keep the screen awake for as long as the owner component is mounted.\n * The optionally provided `tag` argument is used when activating and deactivating the keep-awake\n * feature. If unspecified, the default `tag` is used. See the documentation for `activateKeepAwake`\n * below to learn more about the `tag` argument.\n *\n * @param tag *Optional* - Tag to lock screen sleep prevention. If not provided, the default tag is used.\n * @param options *Optional*\n * - `suppressDeactivateWarnings` *Optional* -\n * The call will throw an unhandled promise rejection on Android\n * when the original Activity is dead or deactivated.\n * Set the value to true for suppressing the uncaught exception.\n */\nexport function useKeepAwake(\n tag: string = ExpoKeepAwakeTag,\n options?: {\n suppressDeactivateWarnings: boolean;\n }\n): void {\n useEffect(() => {\n activateKeepAwake(tag);\n return () => {\n if (options?.suppressDeactivateWarnings) {\n deactivateKeepAwake(tag).catch(() => {});\n } else {\n deactivateKeepAwake(tag);\n }\n };\n }, [tag]);\n}\n\n// @needsAudit\n/**\n * Prevents the screen from sleeping until `deactivateKeepAwake` is called with the same `tag` value.\n *\n * If the `tag` argument is specified, the screen will not sleep until you call `deactivateKeepAwake`\n * with the same `tag` argument. When using multiple `tags` for activation you'll have to deactivate\n * each one in order to re-enable screen sleep. If tag is unspecified, the default `tag` is used.\n * @param tag *Optional* - Tag to lock screen sleep prevention. If not provided, the default tag is used.\n */\n\nexport async function activateKeepAwake(tag: string = ExpoKeepAwakeTag): Promise<void> {\n await ExpoKeepAwake.activate?.(tag);\n}\n\n// @needsAudit\n/**\n * Releases the lock on screen-sleep prevention associated with the given `tag` value. If `tag`\n * is unspecified, it defaults to the same default tag that `activateKeepAwake` uses.\n * @param tag *Optional* - Tag to release the lock on screen sleep prevention. If not provided,\n * the default tag is used.\n */\nexport async function deactivateKeepAwake(tag: string = ExpoKeepAwakeTag): Promise<void> {\n await ExpoKeepAwake.deactivate?.(tag);\n}\n"],"sourceRoot":""},"metadata":{},"sourceType":"module"}