esoftplay 0.0.129-s → 0.0.129-u

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.
@@ -242,20 +242,24 @@ class m extends LibComponent<LibImageProps, LibImageState> {
242
242
  var wantedMaxSize = maxDimension || 1280
243
243
  var rawheight = result.height
244
244
  var rawwidth = result.width
245
- var ratio = rawwidth / rawheight
246
- if (rawheight > rawwidth) {
247
- var wantedwidth = wantedMaxSize * ratio;
248
- var wantedheight = wantedMaxSize;
249
- } else {
250
- var wantedwidth = wantedMaxSize;
251
- var wantedheight = wantedMaxSize / ratio;
245
+ let doResize = false
246
+ if (wantedMaxSize < Math.max(rawheight, rawwidth)) {
247
+ doResize = true
248
+ var ratio = rawwidth / rawheight
249
+ if (rawheight > rawwidth) {
250
+ var wantedwidth = wantedMaxSize * ratio;
251
+ var wantedheight = wantedMaxSize;
252
+ } else {
253
+ var wantedwidth = wantedMaxSize;
254
+ var wantedheight = wantedMaxSize / ratio;
255
+ }
252
256
  }
253
257
 
254
258
  setTimeout(async () => {
255
259
  const manipImage = await ImageManipulator.manipulateAsync(
256
260
  result.uri,
257
- [{ resize: { width: wantedwidth, height: wantedheight } }],
258
- { format: SaveFormat.JPEG }
261
+ doResize ? [{ resize: { width: wantedwidth, height: wantedheight } }] : [],
262
+ { format: SaveFormat.JPEG, compress: 1.0 }
259
263
  );
260
264
  new LibCurl().upload('image_upload', "image", String(manipImage.uri), 'image/jpeg',
261
265
  (res: any, msg: string) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.129-s",
3
+ "version": "0.0.129-u",
4
4
  "description": "embedding data from esoftplay framework (web based) into mobile app",
5
5
  "main": "cache/index.js",
6
6
  "types": "../../index.d.ts",
package/state.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import { useCallback, useEffect, useRef, useState } from 'react';
2
2
 
3
- type useSafeStateReturn<T> = [T | undefined, (value: T | undefined) => void, () => T];
3
+ type useSafeStateReturn<T> = [T | undefined, (value: T | undefined) => void, () => T | undefined];
4
4
 
5
5
  export default function useSafeState<T = any>(defaultValue?: T): useSafeStateReturn<T> {
6
6
  const isMountedRef = useRef<boolean>(true);
7
7
  const valueRef = useRef(defaultValue)
8
- const [state, setState] = useState<T | undefined>(defaultValue);
8
+ const [, rerender] = useState({})
9
9
 
10
10
  const updateState = useCallback((value: T | undefined) => {
11
11
  if (isMountedRef.current) {
12
12
  valueRef.current = value;
13
- setState(value)
13
+ rerender({})
14
14
  }
15
15
  }, []);
16
16
 
@@ -25,5 +25,5 @@ export default function useSafeState<T = any>(defaultValue?: T): useSafeStateRet
25
25
  };
26
26
  }, []);
27
27
 
28
- return [state, updateState, getter];
28
+ return [valueRef.current, updateState, getter];
29
29
  }