904b3bf50100ef3add5347513b628989.json 6.8 KB
{"ast":null,"code":"var _interopRequireWildcard=require(\"@babel/runtime/helpers/interopRequireWildcard\");var _interopRequireDefault=require(\"@babel/runtime/helpers/interopRequireDefault\");Object.defineProperty(exports,\"__esModule\",{value:true});exports.useKeepAwake=useKeepAwake;exports.activateKeepAwake=activateKeepAwake;exports.deactivateKeepAwake=deactivateKeepAwake;exports.activate=activate;exports.deactivate=deactivate;exports.default=void 0;var _classCallCheck2=_interopRequireDefault(require(\"@babel/runtime/helpers/classCallCheck\"));var _createClass2=_interopRequireDefault(require(\"@babel/runtime/helpers/createClass\"));var _possibleConstructorReturn2=_interopRequireDefault(require(\"@babel/runtime/helpers/possibleConstructorReturn\"));var _getPrototypeOf2=_interopRequireDefault(require(\"@babel/runtime/helpers/getPrototypeOf\"));var _inherits2=_interopRequireDefault(require(\"@babel/runtime/helpers/inherits\"));var _react=_interopRequireWildcard(require(\"react\"));var _ExpoKeepAwake=_interopRequireDefault(require(\"./ExpoKeepAwake\"));var __keepAwakeMountedCount=0;var ExpoKeepAwakeTag='ExpoKeepAwakeDefaultTag';var KeepAwake=function(_React$PureComponent){(0,_inherits2.default)(KeepAwake,_React$PureComponent);function KeepAwake(){(0,_classCallCheck2.default)(this,KeepAwake);return(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(KeepAwake).apply(this,arguments));}(0,_createClass2.default)(KeepAwake,[{key:\"componentDidMount\",value:function componentDidMount(){console.warn(\"The KeepAwake component has been deprecated in favor of the useKeepAwake hook and will be removed in SDK 35\");__keepAwakeMountedCount++;if(__keepAwakeMountedCount===1){activateKeepAwake();}}},{key:\"componentWillUnmount\",value:function componentWillUnmount(){__keepAwakeMountedCount--;if(__keepAwakeMountedCount===0){deactivateKeepAwake();}}},{key:\"render\",value:function render(){return null;}}]);return KeepAwake;}(_react.default.PureComponent);exports.default=KeepAwake;KeepAwake.activate=function(tag){console.warn(\"The \\\"KeepAwake.activate\\\" static method has been deprecated in favor of the \\\"activateKeepAwake\\\" function exported from expo-keep-awake and will be removed in SDK 35\");activateKeepAwake(tag);};KeepAwake.deactivate=function(tag){console.warn(\"The \\\"KeepAwake.deactivate\\\" static method has been deprecated in favor of the \\\"deactivateKeepAwake\\\" function exported from expo-keep-awake and will be removed in SDK 35\");deactivateKeepAwake(tag);};function useKeepAwake(){var tag=arguments.length>0&&arguments[0]!==undefined?arguments[0]:ExpoKeepAwakeTag;(0,_react.useEffect)(function(){activateKeepAwake(tag);return function(){return deactivateKeepAwake(tag);};},[tag]);}function activateKeepAwake(){var tag=arguments.length>0&&arguments[0]!==undefined?arguments[0]:ExpoKeepAwakeTag;_ExpoKeepAwake.default.activate(tag);}function deactivateKeepAwake(){var tag=arguments.length>0&&arguments[0]!==undefined?arguments[0]:ExpoKeepAwakeTag;_ExpoKeepAwake.default.deactivate(tag);}function activate(tag){console.warn(\"\\\"activate\\\" from expo-keep-awake has been deprecated in favor of \\\"activateKeepAwake\\\" and will be removed in SDK 35\");activateKeepAwake(tag);}function deactivate(tag){console.warn(\"\\\"deactivate\\\" from expo-keep-awake has been deprecated in favor of \\\"deactivateKeepAwake\\\" and will be removed in SDK 35\");deactivateKeepAwake(tag);}","map":{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"w4BAAA,qDACA,sEAIA,GAAI,CAAA,uBAAuB,CAAG,CAA9B,CACA,GAAM,CAAA,gBAAgB,CAAG,yBAAzB,C,GAEqB,CAAA,S,4WAeF,CACf,OAAO,CAAC,IAAR,gHAGA,uBAAuB,GACvB,GAAI,uBAAuB,GAAK,CAAhC,CAAmC,CACjC,iBAAiB,GAClB,CACF,C,mEAEmB,CAClB,uBAAuB,GACvB,GAAI,uBAAuB,GAAK,CAAhC,CAAmC,CACjC,mBAAmB,GACpB,CACF,C,uCAEK,CACJ,MAAO,KAAP,CACD,C,uBAlCoC,eAAM,a,4BACpC,SAAA,CAAA,QAAA,CAAW,SAAC,GAAD,CAAuB,CACvC,OAAO,CAAC,IAAR,4KAGA,iBAAiB,CAAC,GAAD,CAAjB,CACD,CALM,CAOA,SAAA,CAAA,UAAA,CAAa,SAAC,GAAD,CAAuB,CACzC,OAAO,CAAC,IAAR,gLAGA,mBAAmB,CAAC,GAAD,CAAnB,CACD,CALM,CA6BH,QAAU,CAAA,YAAV,EAAqD,IAA9B,CAAA,GAA8B,2DAAhB,gBAAgB,CACzD,qBAAU,UAAK,CACb,iBAAiB,CAAC,GAAD,CAAjB,CACA,MAAO,kBAAM,CAAA,mBAAmB,CAAC,GAAD,CAAzB,EAAP,CACD,CAHD,CAGG,CAAC,GAAD,CAHH,EAID,CAEK,QAAU,CAAA,iBAAV,EAA0D,IAA9B,CAAA,GAA8B,2DAAhB,gBAAgB,CAC9D,uBAAc,QAAd,CAAuB,GAAvB,EACD,CAEK,QAAU,CAAA,mBAAV,EAA4D,IAA9B,CAAA,GAA8B,2DAAhB,gBAAgB,CAChE,uBAAc,UAAd,CAAyB,GAAzB,EACD,CAEK,QAAU,CAAA,QAAV,CAAmB,GAAnB,CAA+B,CACnC,OAAO,CAAC,IAAR,0HAGA,iBAAiB,CAAC,GAAD,CAAjB,CACD,CAEK,QAAU,CAAA,UAAV,CAAqB,GAArB,CAAiC,CACrC,OAAO,CAAC,IAAR,8HAGA,mBAAmB,CAAC,GAAD,CAAnB,CACD","sourcesContent":["import React, { useEffect } from 'react';\nimport ExpoKeepAwake from './ExpoKeepAwake';\n\n// NOTE(brentvatne): in tests this value won't be reset because we can render a component and never\n// unmount it.\nlet __keepAwakeMountedCount = 0;\nconst ExpoKeepAwakeTag = 'ExpoKeepAwakeDefaultTag';\n\nexport default class KeepAwake extends React.PureComponent {\n  static activate = (tag?: string): void => {\n    console.warn(\n      `The \"KeepAwake.activate\" static method has been deprecated in favor of the \"activateKeepAwake\" function exported from expo-keep-awake and will be removed in SDK 35`\n    );\n    activateKeepAwake(tag);\n  };\n\n  static deactivate = (tag?: string): void => {\n    console.warn(\n      `The \"KeepAwake.deactivate\" static method has been deprecated in favor of the \"deactivateKeepAwake\" function exported from expo-keep-awake and will be removed in SDK 35`\n    );\n    deactivateKeepAwake(tag);\n  };\n\n  componentDidMount() {\n    console.warn(\n      `The KeepAwake component has been deprecated in favor of the useKeepAwake hook and will be removed in SDK 35`\n    );\n    __keepAwakeMountedCount++;\n    if (__keepAwakeMountedCount === 1) {\n      activateKeepAwake();\n    }\n  }\n\n  componentWillUnmount() {\n    __keepAwakeMountedCount--;\n    if (__keepAwakeMountedCount === 0) {\n      deactivateKeepAwake();\n    }\n  }\n\n  render() {\n    return null;\n  }\n}\n\nexport function useKeepAwake(tag: string = ExpoKeepAwakeTag): void {\n  useEffect(() => {\n    activateKeepAwake(tag);\n    return () => deactivateKeepAwake(tag);\n  }, [tag]);\n}\n\nexport function activateKeepAwake(tag: string = ExpoKeepAwakeTag): void {\n  ExpoKeepAwake.activate(tag);\n}\n\nexport function deactivateKeepAwake(tag: string = ExpoKeepAwakeTag): void {\n  ExpoKeepAwake.deactivate(tag);\n}\n\nexport function activate(tag?: string): void {\n  console.warn(\n    `\"activate\" from expo-keep-awake has been deprecated in favor of \"activateKeepAwake\" and will be removed in SDK 35`\n  );\n  activateKeepAwake(tag);\n}\n\nexport function deactivate(tag?: string): void {\n  console.warn(\n    `\"deactivate\" from expo-keep-awake has been deprecated in favor of \"deactivateKeepAwake\" and will be removed in SDK 35`\n  );\n  deactivateKeepAwake(tag);\n}\n"],"sourceRoot":""},"metadata":{},"sourceType":"script"}