esoftplay 0.0.129-t → 0.0.129-v

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.
package/bin/analyze.js ADDED
@@ -0,0 +1,52 @@
1
+ const fs = require('fs');
2
+
3
+ const importer = `\nimport useRenderCounter from 'esoftplay/render';`
4
+ const hook = (module) => `\n\tconst RC = useRenderCounter('${module}')`
5
+ const tag = `\t\t\t<RC />\n`
6
+ const param = process.argv[2]
7
+
8
+ if (param == 'clear') {
9
+ fs.readdirSync('./modules/').forEach((module) => {
10
+ if (fs.statSync('./modules/' + module).isDirectory()) {
11
+ fs.readdirSync('./modules/' + module).forEach((task) => {
12
+ let text = fs.readFileSync('./modules/' + module + '/' + task, { encoding: 'utf8' })
13
+ text = text.replace(importer, "")
14
+ text = text.replace(hook(module + '/' + task), "")
15
+ text = text.replace(tag, "")
16
+ fs.writeFileSync('./modules/' + module + '/' + task, text, { encoding: 'utf8' })
17
+ })
18
+ }
19
+ })
20
+ } else {
21
+
22
+ fs.readdirSync('./modules/').forEach((module) => {
23
+ if (fs.statSync('./modules/' + module).isDirectory()) {
24
+ fs.readdirSync('./modules/' + module).forEach((task) => {
25
+ let text = fs.readFileSync('./modules/' + module + '/' + task, { encoding: 'utf8' })
26
+ const importText = (/\n(import .*)\n/g).exec(text)
27
+ if (importText && importText.length > 1) {
28
+ const firstImport = importText[1]
29
+ text = text.replace(importer, "")
30
+ text = text.replace(firstImport, firstImport + importer)
31
+ const hooks = (/\n(export default function.*)\n/g).exec(text)
32
+ if (hooks && hooks.length > 1) {
33
+ const mainFunction = hooks[1]
34
+ text = text.replace(hook(module + '/' + task), "")
35
+ text = text.replace(mainFunction, mainFunction + hook(module + '/' + task))
36
+ let subText = (/(export default function.*\n})/gs).exec(text)
37
+ const render = (/(\n\s{2}return.*\n.*\>\n)/g).exec(subText)
38
+ if (subText && subText.length > 1 && render && render.length > 1) {
39
+ const mainRender = render[1]
40
+ let newSubText = subText[1].replace(tag, "")
41
+ newSubText = newSubText.replace(mainRender, mainRender + tag)
42
+ text = text.replace(subText[1], newSubText)
43
+ fs.writeFileSync('./modules/' + module + '/' + task, text, { encoding: 'utf8' })
44
+ }
45
+ }
46
+ } else {
47
+ console.log('SKIP => ' + module + '/' + task)
48
+ }
49
+ })
50
+ }
51
+ })
52
+ }
package/bin/cli.js CHANGED
@@ -32,6 +32,14 @@ if (args.length == 0) {
32
32
  return
33
33
  }
34
34
  switch (args[0]) {
35
+ case "a":
36
+ case "analyze":
37
+ command('node ./node_modules/esoftplay/bin/analyze.js')
38
+ break
39
+ case "ac":
40
+ case "analyze clear":
41
+ command('node ./node_modules/esoftplay/bin/analyze.js clear')
42
+ break;
35
43
  case "help":
36
44
  help()
37
45
  break;
@@ -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-t",
3
+ "version": "0.0.129-v",
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/render.tsx ADDED
@@ -0,0 +1,17 @@
1
+ // useLibs
2
+ // noPage
3
+
4
+ import { useEffect, useRef } from 'react';
5
+ import { Text } from 'react-native';
6
+
7
+ export default function useRenderCounter(module: string): any {
8
+ const counter = useRef(1)
9
+
10
+ useEffect(() => {
11
+ counter.current += 1
12
+ })
13
+
14
+ return () => (
15
+ <Text style={{ position: 'absolute', fontSize: 7, zIndex: 999, color: 'white', backgroundColor: 'black', bottom: 0, left: 0 }} >{module}: {counter.current}</Text>
16
+ )
17
+ }