@plusscommunities/pluss-core-app 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -145,16 +145,18 @@ class AutoOffsetImage extends Component {
145
145
 
146
146
  render() {
147
147
  if (this.state.disabled) {
148
- return /*#__PURE__*/React.createElement(Image, {
148
+ return /*#__PURE__*/React.createElement(View, {
149
+ style: [styles.container, {
150
+ width: this.props.width,
151
+ height: this.props.height
152
+ }, this.props.style]
153
+ }, /*#__PURE__*/React.createElement(Image, {
149
154
  source: {
150
155
  uri: this.state.imageSource
151
156
  },
152
- style: [styles.container, styles.staticImage, {
153
- width: this.props.width,
154
- height: this.props.height
155
- }, this.props.style],
157
+ style: [styles.image, this.state.imageStyle],
156
158
  onLoad: this.onLoad
157
- });
159
+ }), this.props.children);
158
160
  }
159
161
 
160
162
  return /*#__PURE__*/React.createElement(View, {
@@ -1 +1 @@
1
- {"version":3,"sources":["AutoOffsetImage.js"],"names":["React","Component","View","Image","Animated","StyleSheet","connect","moment","findLandmarkRange","getScaledOffset","get300","detectFaces","saveImagePosition","AutoOffsetImage","constructor","props","event","nativeEvent","source","uri","setState","imageSource","state","disabled","startTime","valueOf","cachedValues","imagePositions","response","stringActions","getString","encodeURIComponent","data","e","console","log","faces","image","_","isEmpty","add","timestamp","targetWidth","width","targetHeight","height","scaledOffset","start","landmarkStart","end","landmarkEnd","bounds","imageBounds","offset","y","Math","max","paddingFactor","x","imageStyle","top","left","endTime","timing","blurRadius","toValue","duration","useNativeDriver","Value","componentDidMount","positionImage","componentDidUpdate","prevProps","render","styles","container","staticImage","style","onLoad","children","create","overflow","position","resizeMode","mapStateToProps","media","positions","autoOffsetImage"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,IAAT,EAAeC,KAAf,EAAsBC,QAAtB,EAAgCC,UAAhC,QAAkD,cAAlD;AACA,SAASC,OAAT,QAAwB,aAA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U,CAAC2E,MAAX,CAAkB;AAC/BL,EAAAA,SAAS,EAAE;AACTM,IAAAA,QAAQ,EAAE;AADD,GADoB;AAI/B5C,EAAAA,KAAK,EAAE;AACL6C,IAAAA,QAAQ,EAAE,UADL;AAELtB,IAAAA,GAAG,EAAE,CAFA;AAGLC,IAAAA,IAAI,EAAE,CAHD;AAILsB,IAAAA,UAAU,EAAE;AAJP,GAJwB;AAU/BP,EAAAA,WAAW,EAAE;AACXO,IAAAA,UAAU,EAAE;AADD;AAVkB,CAAlB,CAAf;;AAeA,MAAMC,eAAe,GAAG9D,KAAK,IAAI;AAC/B,SAAO;AACLK,IAAAA,cAAc,EAAEL,KAAK,CAAC+D,KAAN,CAAYC;AADvB,GAAP;AAGD,CAJD;;AAMA,MAAMC,eAAe,GAAGjF,OAAO,CAAC8E,eAAD,EAAkB;AAAExE,EAAAA;AAAF,CAAlB,CAAP,CAAgDC,eAAhD,CAAxB;AACA,SAAS0E,eAAe,IAAI1E,eAA5B","sourcesContent":["import React, { Component } from 'react';\nimport { View, Image, Animated, StyleSheet } from 'react-native';\nimport { connect } from 'react-redux';\nimport moment from 'moment';\nimport { findLandmarkRange, getScaledOffset, get300, detectFaces } from '../helper';\nimport { saveImagePosition } from '../actions';\n\nclass AutoOffsetImage extends Component {\n constructor(props) {\n super(props);\n\n this.paddingFactor = this.props.paddingFactor || 0.1;\n\n this.state = {\n imageStyle: {\n width: this.props.width,\n height: this.props.height,\n },\n blurRadius: new Animated.Value(100),\n imageSource: get300(this.props.uri),\n disabled: true,\n };\n }\n\n componentDidMount() {\n this.positionImage();\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.uri !== this.props.uri || prevProps.height !== this.props.height || prevProps.width !== this.props.width) {\n this.positionImage();\n }\n }\n\n onLoad = event => {\n if (event.nativeEvent.source.uri !== this.props.uri) {\n this.setState({\n imageSource: this.props.uri,\n });\n }\n // if (event.nativeEvent.source.uri === this.props.uri && !this.state.imageLoaded) {\n // //unblur\n // this.setState({\n // imageLoaded: true,\n // });\n // Animated.sequence([\n // Animated.delay(200),\n // Animated.timing(this.state.blurRadius, {\n // toValue: 0,\n // duration: 500,\n // useNativeDriver: false,\n // }),\n // ]).start();\n // }\n };\n\n positionImage = async () => {\n if (this.state.disabled) {\n return;\n }\n try {\n const startTime = moment().valueOf();\n\n let cachedValues;\n // check local cache\n if (this.props.imagePositions && this.props.imagePositions[this.props.uri]) {\n cachedValues = this.props.imagePositions[this.props.uri];\n }\n // check remote cache\n if (!cachedValues) {\n try {\n const response = await stringActions.getString('plussSpace', `imagefaces_${encodeURIComponent(this.props.uri)}`);\n cachedValues = response.data;\n } catch (e) {\n console.log('errored from cache');\n }\n // run face detection locally\n if (\n !cachedValues ||\n !cachedValues.faces ||\n !cachedValues.image ||\n (_.isEmpty(cachedValues.faces) &&\n moment()\n .add(-1, 'w')\n .valueOf() > moment(cachedValues.timestamp).valueOf())\n ) {\n cachedValues = await detectFaces(this.props.uri);\n }\n this.props.saveImagePosition(this.props.uri, cachedValues);\n }\n\n const image = await findLandmarkRange(this.props.uri, {\n targetWidth: this.props.width,\n targetHeight: this.props.height,\n cachedValues,\n });\n const scaledOffset = getScaledOffset(image.width, image.height, this.props.width, this.props.height);\n\n const { start: landmarkStart, end: landmarkEnd } = image;\n const { bounds: imageBounds, offset, width, height } = scaledOffset;\n\n if (landmarkStart.y < imageBounds.start.y) {\n // move up\n offset.y = -Math.max(landmarkStart.y - this.props.height * this.paddingFactor, 0); // move top to 5% above start of landmark\n } else if (landmarkEnd.y > imageBounds.end.y) {\n // move down\n offset.y = -Math.max(landmarkEnd.y + this.props.height * this.paddingFactor - this.props.height, 0); // move bottom to 5% below end of landmark\n }\n\n if (landmarkStart.x < imageBounds.start.x) {\n // move right\n offset.x = -Math.max(landmarkStart.x - this.props.width * this.paddingFactor, 0); // move left edge to 5% left of start of landmark\n } else if (landmarkEnd.x > imageBounds.end.x) {\n // move left\n offset.x = -Math.max(landmarkEnd.x + this.props.width * this.paddingFactor - this.props.width, 0); // move right edge to 5% left of end of landmark\n }\n\n this.setState({\n imageStyle: {\n width,\n height,\n top: offset.y,\n left: offset.x,\n },\n imageSource: this.props.uri,\n });\n\n const endTime = moment().valueOf();\n if (endTime - startTime < 500) {\n Animated.timing(this.state.blurRadius, {\n toValue: 0,\n duration: 0,\n useNativeDriver: false,\n }).start();\n }\n } catch (e) {\n this.setState({\n imageSource: this.props.uri,\n });\n }\n };\n\n render() {\n if (this.state.disabled) {\n return (\n <Image\n source={{ uri: this.state.imageSource }}\n style={[\n styles.container,\n styles.staticImage,\n {\n width: this.props.width,\n height: this.props.height,\n },\n this.props.style,\n ]}\n onLoad={this.onLoad}\n />\n );\n }\n return (\n <View\n style={[\n styles.container,\n {\n width: this.props.width,\n height: this.props.height,\n },\n this.props.style,\n ]}\n >\n <Animated.Image\n blurRadius={this.state.blurRadius}\n source={{ uri: this.state.imageSource }}\n style={[styles.image, this.state.imageStyle]}\n onLoad={this.onLoad}\n />\n {this.props.children}\n </View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n overflow: 'hidden',\n },\n image: {\n position: 'absolute',\n top: 0,\n left: 0,\n resizeMode: 'cover',\n },\n staticImage: {\n resizeMode: 'cover',\n },\n});\n\nconst mapStateToProps = state => {\n return {\n imagePositions: state.media.positions,\n };\n};\n\nconst autoOffsetImage = connect(mapStateToProps, { saveImagePosition })(AutoOffsetImage);\nexport { autoOffsetImage as AutoOffsetImage };\n"]}
1
+ {"version":3,"sources":["AutoOffsetImage.js"],"names":["React","Component","View","Image","Animated","StyleSheet","connect","moment","findLandmarkRange","getScaledOffset","get300","detectFaces","saveImagePosition","AutoOffsetImage","constructor","props","event","nativeEvent","source","uri","setState","imageSource","state","disabled","startTime","valueOf","cachedValues","imagePositions","response","stringActions","getString","encodeURIComponent","data","e","console","log","faces","image","_","isEmpty","add","timestamp","targetWidth","width","targetHeight","height","scaledOffset","start","landmarkStart","end","landmarkEnd","bounds","imageBounds","offset","y","Math","max","paddingFactor","x","imageStyle","top","left","endTime","timing","blurRadius","toValue","duration","useNativeDriver","Value","componentDidMount","positionImage","componentDidUpdate","prevProps","render","styles","container","style","onLoad","children","create","overflow","position","resizeMode","staticImage","mapStateToProps","media","positions","autoOffsetImage"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;AACA,SAASC,IAAT,EAAeC,KAAf,EAAsBC,QAAtB,EAAgCC,UAAhC,QAAkD,cAAlD;AACA,SAASC,OAAT,QAAwB,aAAxB;AACA,OAAOC,MAAP,MAAmB,QAAnB;AACA,SAASC,iBAAT,EAA4BC,eAA5B,EAA6CC,MAA7C,EAAqDC,WAArD,QAAwE,WAAxE;AACA,SAASC,iBAAT,QAAkC,YAAlC;;AAEA,MAAMC,eAAN,SAA8BZ,SAA9B,CAAwC;AACtCa,EAAAA,WAAW,CAACC,KAAD,EAAQ;AACjB,UAAMA,KAAN;;AADiB,oCA0BVC,KAAK,IAAI;AAChB,UAAIA,KAAK,CAACC,WAAN,CAAkBC,MAAlB,CAAyBC,GAAzB,KAAiC,KAAKJ,KAAL,CAAWI,GAAhD,EAAqD;AACnD,aAAKC,QAAL,CAAc;AACZC,UAAAA,WAAW,EAAE,KAAKN,KAAL,CAAWI;AADZ,SAAd;AAGD,OALe,CAMhB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACD,KA9CkB;;AAAA,2CAgDH,YAAY;AAC1B,UAAI,KAAKG,KAAL,CAAWC,QAAf,EAAyB;AACvB;AACD;;AACD,UAAI;AACF,cAAMC,SAAS,GAAGjB,MAAM,GAAGkB,OAAT,EAAlB;AAEA,YAAIC,YAAJ,CAHE,CAIF;;AACA,YAAI,KAAKX,KAAL,CAAWY,cAAX,IAA6B,KAAKZ,KAAL,CAAWY,cAAX,CAA0B,KAAKZ,KAAL,CAAWI,GAArC,CAAjC,EAA4E;AAC1EO,UAAAA,YAAY,GAAG,KAAKX,KAAL,CAAWY,cAAX,CA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B,OAFK,EAML,KAAK9B,KAAL,CAAW6D,KANN;AADT,oBAUE,oBAAC,QAAD,CAAU,KAAV;AACE,MAAA,UAAU,EAAE,KAAKtD,KAAL,CAAW0C,UADzB;AAEE,MAAA,MAAM,EAAE;AAAE7C,QAAAA,GAAG,EAAE,KAAKG,KAAL,CAAWD;AAAlB,OAFV;AAGE,MAAA,KAAK,EAAE,CAACqD,MAAM,CAACrC,KAAR,EAAe,KAAKf,KAAL,CAAWqC,UAA1B,CAHT;AAIE,MAAA,MAAM,EAAE,KAAKkB;AAJf,MAVF,EAgBG,KAAK9D,KAAL,CAAW+D,QAhBd,CADF;AAoBD;;AA7KqC;;AAgLxC,MAAMJ,MAAM,GAAGrE,UAAU,CAAC0E,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AACTK,IAAAA,QAAQ,EAAE;AADD,GADoB;AAI/B3C,EAAAA,KAAK,EAAE;AACL4C,IAAAA,QAAQ,EAAE,UADL;AAELrB,IAAAA,GAAG,EAAE,CAFA;AAGLC,IAAAA,IAAI,EAAE,CAHD;AAILqB,IAAAA,UAAU,EAAE;AAJP,GAJwB;AAU/BC,EAAAA,WAAW,EAAE;AACXD,IAAAA,UAAU,EAAE;AADD;AAVkB,CAAlB,CAAf;;AAeA,MAAME,eAAe,GAAG9D,KAAK,IAAI;AAC/B,SAAO;AACLK,IAAAA,cAAc,EAAEL,KAAK,CAAC+D,KAAN,CAAYC;AADvB,GAAP;AAGD,CAJD;;AAMA,MAAMC,eAAe,GAAGjF,OAAO,CAAC8E,eAAD,EAAkB;AAAExE,EAAAA;AAAF,CAAlB,CAAP,CAAgDC,eAAhD,CAAxB;AACA,SAAS0E,eAAe,IAAI1E,eAA5B","sourcesContent":["import React, { Component } from 'react';\nimport { View, Image, Animated, StyleSheet } from 'react-native';\nimport { connect } from 'react-redux';\nimport moment from 'moment';\nimport { findLandmarkRange, getScaledOffset, get300, detectFaces } from '../helper';\nimport { saveImagePosition } from '../actions';\n\nclass AutoOffsetImage extends Component {\n constructor(props) {\n super(props);\n\n this.paddingFactor = this.props.paddingFactor || 0.1;\n\n this.state = {\n imageStyle: {\n width: this.props.width,\n height: this.props.height,\n },\n blurRadius: new Animated.Value(100),\n imageSource: get300(this.props.uri),\n disabled: true,\n };\n }\n\n componentDidMount() {\n this.positionImage();\n }\n\n componentDidUpdate(prevProps) {\n if (prevProps.uri !== this.props.uri || prevProps.height !== this.props.height || prevProps.width !== this.props.width) {\n this.positionImage();\n }\n }\n\n onLoad = event => {\n if (event.nativeEvent.source.uri !== this.props.uri) {\n this.setState({\n imageSource: this.props.uri,\n });\n }\n // if (event.nativeEvent.source.uri === this.props.uri && !this.state.imageLoaded) {\n // //unblur\n // this.setState({\n // imageLoaded: true,\n // });\n // Animated.sequence([\n // Animated.delay(200),\n // Animated.timing(this.state.blurRadius, {\n // toValue: 0,\n // duration: 500,\n // useNativeDriver: false,\n // }),\n // ]).start();\n // }\n };\n\n positionImage = async () => {\n if (this.state.disabled) {\n return;\n }\n try {\n const startTime = moment().valueOf();\n\n let cachedValues;\n // check local cache\n if (this.props.imagePositions && this.props.imagePositions[this.props.uri]) {\n cachedValues = this.props.imagePositions[this.props.uri];\n }\n // check remote cache\n if (!cachedValues) {\n try {\n const response = await stringActions.getString('plussSpace', `imagefaces_${encodeURIComponent(this.props.uri)}`);\n cachedValues = response.data;\n } catch (e) {\n console.log('errored from cache');\n }\n // run face detection locally\n if (\n !cachedValues ||\n !cachedValues.faces ||\n !cachedValues.image ||\n (_.isEmpty(cachedValues.faces) &&\n moment()\n .add(-1, 'w')\n .valueOf() > moment(cachedValues.timestamp).valueOf())\n ) {\n cachedValues = await detectFaces(this.props.uri);\n }\n this.props.saveImagePosition(this.props.uri, cachedValues);\n }\n\n const image = await findLandmarkRange(this.props.uri, {\n targetWidth: this.props.width,\n targetHeight: this.props.height,\n cachedValues,\n });\n const scaledOffset = getScaledOffset(image.width, image.height, this.props.width, this.props.height);\n\n const { start: landmarkStart, end: landmarkEnd } = image;\n const { bounds: imageBounds, offset, width, height } = scaledOffset;\n\n if (landmarkStart.y < imageBounds.start.y) {\n // move up\n offset.y = -Math.max(landmarkStart.y - this.props.height * this.paddingFactor, 0); // move top to 5% above start of landmark\n } else if (landmarkEnd.y > imageBounds.end.y) {\n // move down\n offset.y = -Math.max(landmarkEnd.y + this.props.height * this.paddingFactor - this.props.height, 0); // move bottom to 5% below end of landmark\n }\n\n if (landmarkStart.x < imageBounds.start.x) {\n // move right\n offset.x = -Math.max(landmarkStart.x - this.props.width * this.paddingFactor, 0); // move left edge to 5% left of start of landmark\n } else if (landmarkEnd.x > imageBounds.end.x) {\n // move left\n offset.x = -Math.max(landmarkEnd.x + this.props.width * this.paddingFactor - this.props.width, 0); // move right edge to 5% left of end of landmark\n }\n\n this.setState({\n imageStyle: {\n width,\n height,\n top: offset.y,\n left: offset.x,\n },\n imageSource: this.props.uri,\n });\n\n const endTime = moment().valueOf();\n if (endTime - startTime < 500) {\n Animated.timing(this.state.blurRadius, {\n toValue: 0,\n duration: 0,\n useNativeDriver: false,\n }).start();\n }\n } catch (e) {\n this.setState({\n imageSource: this.props.uri,\n });\n }\n };\n\n render() {\n if (this.state.disabled) {\n return (\n <View\n style={[\n styles.container,\n {\n width: this.props.width,\n height: this.props.height,\n },\n this.props.style,\n ]}\n >\n <Image source={{ uri: this.state.imageSource }} style={[styles.image, this.state.imageStyle]} onLoad={this.onLoad} />\n {this.props.children}\n </View>\n );\n }\n return (\n <View\n style={[\n styles.container,\n {\n width: this.props.width,\n height: this.props.height,\n },\n this.props.style,\n ]}\n >\n <Animated.Image\n blurRadius={this.state.blurRadius}\n source={{ uri: this.state.imageSource }}\n style={[styles.image, this.state.imageStyle]}\n onLoad={this.onLoad}\n />\n {this.props.children}\n </View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: {\n overflow: 'hidden',\n },\n image: {\n position: 'absolute',\n top: 0,\n left: 0,\n resizeMode: 'cover',\n },\n staticImage: {\n resizeMode: 'cover',\n },\n});\n\nconst mapStateToProps = state => {\n return {\n imagePositions: state.media.positions,\n };\n};\n\nconst autoOffsetImage = connect(mapStateToProps, { saveImagePosition })(AutoOffsetImage);\nexport { autoOffsetImage as AutoOffsetImage };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-app",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "main": "dist/module/index.js",
6
6
  "module": "dist/module/index.js",
@@ -143,19 +143,19 @@ class AutoOffsetImage extends Component {
143
143
  render() {
144
144
  if (this.state.disabled) {
145
145
  return (
146
- <Image
147
- source={{ uri: this.state.imageSource }}
146
+ <View
148
147
  style={[
149
148
  styles.container,
150
- styles.staticImage,
151
149
  {
152
150
  width: this.props.width,
153
151
  height: this.props.height,
154
152
  },
155
153
  this.props.style,
156
154
  ]}
157
- onLoad={this.onLoad}
158
- />
155
+ >
156
+ <Image source={{ uri: this.state.imageSource }} style={[styles.image, this.state.imageStyle]} onLoad={this.onLoad} />
157
+ {this.props.children}
158
+ </View>
159
159
  );
160
160
  }
161
161
  return (