esoftplay 0.0.137 → 0.0.138-b
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/build.js +23 -17
- package/bin/cli.js +78 -41
- package/bin/gen.js +9 -0
- package/global.ts +22 -17
- package/modules/lib/image.tsx +26 -12
- package/modules/lib/notification.ts +41 -1
- package/modules/lib/toast.tsx +1 -3
- package/modules/lib/utils.ts +12 -5
- package/modules/lib/worker.tsx +102 -0
- package/modules/main/index.tsx +4 -4
- package/modules/user/class.ts +2 -1
- package/modules/user/index.tsx +6 -43
- package/package.json +1 -1
- package/modules/lib/worker.ts +0 -38
package/bin/build.js
CHANGED
|
@@ -297,6 +297,7 @@ export default UserIndex`;
|
|
|
297
297
|
'expo-dev-client',
|
|
298
298
|
'expo-file-system',
|
|
299
299
|
'expo-font',
|
|
300
|
+
'expo-image',
|
|
300
301
|
'expo-image-manipulator',
|
|
301
302
|
'expo-image-picker',
|
|
302
303
|
'expo-linear-gradient',
|
|
@@ -311,7 +312,6 @@ export default UserIndex`;
|
|
|
311
312
|
'react-fast-compare',
|
|
312
313
|
'react-native-gesture-handler',
|
|
313
314
|
'react-native-awesome-gallery',
|
|
314
|
-
'react-native-fast-image',
|
|
315
315
|
'react-native-mmkv',
|
|
316
316
|
'react-native-pan-pinch-view',
|
|
317
317
|
'react-native-reanimated',
|
|
@@ -371,23 +371,29 @@ export default UserIndex`;
|
|
|
371
371
|
// execSync("cd ../../ && eas update:configure || true")
|
|
372
372
|
console.log('App.js has been replace to App.tsx');
|
|
373
373
|
if (appjson)
|
|
374
|
-
|
|
375
|
-
if (fs.existsSync('../@
|
|
376
|
-
let
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
dfiles.map((dfile, i) => {
|
|
380
|
-
const rdfile = fs.readFileSync('../@expo/vector-icons/build/' + dfile, { encoding: 'utf8' })
|
|
381
|
-
const names = (/import\("\.\/createIconSet"\)\.Icon<((.*))\,.*>/g).exec(rdfile);
|
|
382
|
-
if (names && names[1].includes('|')) {
|
|
383
|
-
esoftplayIcon += 'export type ' + dfile.replace('.d.ts', 'Types') + ' = ' + names[1] + '\n';
|
|
384
|
-
}
|
|
385
|
-
})
|
|
386
|
-
fs.writeFileSync('../@expo/vector-icons/build/esoftplay_icons.ts', esoftplayIcon)
|
|
387
|
-
})
|
|
388
|
-
} else {
|
|
389
|
-
console.log("@expo/vector-icons not installed")
|
|
374
|
+
/* bugfix AsyncStorage @firebase, remove this section if firebase has update the AsyncStorage */
|
|
375
|
+
if (fs.existsSync('../@firebase/app/dist/index.rn.cjs.js')) {
|
|
376
|
+
let firebaseText = fs.readFileSync('../@firebase/app/dist/index.rn.cjs.js', 'utf8')
|
|
377
|
+
firebaseText = firebaseText.replace("var AsyncStorage = require('react-native').AsyncStorage;", "var AsyncStorage = require('@react-native-async-storage/async-storage').default;")
|
|
378
|
+
fs.writeFileSync('../@firebase/app/dist/index.rn.cjs.js', firebaseText)
|
|
390
379
|
}
|
|
380
|
+
/* end AsyncStorage @firebase section */
|
|
381
|
+
if (fs.existsSync('../@expo/vector-icons')) {
|
|
382
|
+
let esoftplayIcon = ''
|
|
383
|
+
fs.readdir('../@expo/vector-icons/build', (err, files) => {
|
|
384
|
+
const dfiles = files.filter((file) => file.includes('d.ts'))
|
|
385
|
+
dfiles.map((dfile, i) => {
|
|
386
|
+
const rdfile = fs.readFileSync('../@expo/vector-icons/build/' + dfile, { encoding: 'utf8' })
|
|
387
|
+
const names = (/import\("\.\/createIconSet"\)\.Icon<((.*))\,.*>/g).exec(rdfile);
|
|
388
|
+
if (names && names[1].includes('|')) {
|
|
389
|
+
esoftplayIcon += 'export type ' + dfile.replace('.d.ts', 'Types') + ' = ' + names[1] + '\n';
|
|
390
|
+
}
|
|
391
|
+
})
|
|
392
|
+
fs.writeFileSync('../@expo/vector-icons/build/esoftplay_icons.ts', esoftplayIcon)
|
|
393
|
+
})
|
|
394
|
+
} else {
|
|
395
|
+
console.log("@expo/vector-icons not installed")
|
|
396
|
+
}
|
|
391
397
|
console.log('Please wait until processes has finished...');
|
|
392
398
|
});
|
|
393
399
|
}
|
package/bin/cli.js
CHANGED
|
@@ -24,8 +24,9 @@ var args = process.argv.slice(2);
|
|
|
24
24
|
|
|
25
25
|
// console.log(modpath, "sdofsjdofjsd")
|
|
26
26
|
function execution() {
|
|
27
|
-
const cmd = `watchman watch-del ./ && watchman watch ./ && watchman -j <<< '["trigger","./",{"name":"esp","expression":["allof",["not",["dirname","node_modules"]],["not",["name","index.d.ts"]]],"command":["bun","./node_modules/esoftplay/bin/router.js"],"append_files":true}]' && bun ./node_modules/esoftplay/bin/run.js && bun ./node_modules/esoftplay/bin/router.js`
|
|
27
|
+
const cmd = `watchman watch-del ./ && watchman watch ./ && watchman -j <<< '["trigger","./",{"name":"esp","expression":["allof",["not",["dirname","node_modules"]],["not",["name","index.d.ts"]]],"command":["bun","./node_modules/esoftplay/bin/router.js"],"append_files":true}]' && bun ./node_modules/esoftplay/bin/run.js && bun ./node_modules/esoftplay/bin/gen.js && bun ./node_modules/esoftplay/bin/router.js`
|
|
28
28
|
command(cmd)
|
|
29
|
+
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
if (args.length == 0) {
|
|
@@ -38,7 +39,7 @@ switch (args[0]) {
|
|
|
38
39
|
command('bun ./node_modules/esoftplay/bin/analyze.js')
|
|
39
40
|
break
|
|
40
41
|
case "ac":
|
|
41
|
-
case "analyze
|
|
42
|
+
case "analyze-clear":
|
|
42
43
|
command('bun ./node_modules/esoftplay/bin/analyze.js clear')
|
|
43
44
|
break;
|
|
44
45
|
case "fr":
|
|
@@ -46,7 +47,7 @@ switch (args[0]) {
|
|
|
46
47
|
command('bun ./node_modules/esoftplay/bin/perf.js')
|
|
47
48
|
break
|
|
48
49
|
case "frc":
|
|
49
|
-
case "fastrefresh
|
|
50
|
+
case "fastrefresh-clear":
|
|
50
51
|
command('bun ./node_modules/esoftplay/bin/perf.js clear')
|
|
51
52
|
break;
|
|
52
53
|
case "font":
|
|
@@ -153,9 +154,8 @@ switch (args[0]) {
|
|
|
153
154
|
break;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
function
|
|
157
|
-
|
|
158
|
-
const easconfg = `{
|
|
157
|
+
function easconfg() {
|
|
158
|
+
return `{
|
|
159
159
|
"cli": {
|
|
160
160
|
"version": ">= 0.52.0"
|
|
161
161
|
},
|
|
@@ -195,7 +195,46 @@ function setupUpdate() {
|
|
|
195
195
|
"production": {}
|
|
196
196
|
}
|
|
197
197
|
}`
|
|
198
|
-
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
function setupUpdate() {
|
|
203
|
+
command("eas update:configure")
|
|
204
|
+
fs.writeFileSync(easjson, easconfg(), { encoding: 'utf8' })
|
|
205
|
+
fs.writeFileSync(isDebug() ? appdebug : applive, JSON.stringify(readToJSON(appjson), undefined, 2))
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function isDebug() {
|
|
209
|
+
let cjson = readToJSON(confjson)
|
|
210
|
+
let status
|
|
211
|
+
let clive
|
|
212
|
+
let cdebug
|
|
213
|
+
let alive
|
|
214
|
+
let adebug
|
|
215
|
+
if (fs.existsSync(conflive)) {
|
|
216
|
+
clive = readToJSON(conflive)
|
|
217
|
+
}
|
|
218
|
+
if (fs.existsSync(applive)) {
|
|
219
|
+
alive = readToJSON(applive)
|
|
220
|
+
}
|
|
221
|
+
if (fs.existsSync(confdebug)) {
|
|
222
|
+
cdebug = readToJSON(confdebug)
|
|
223
|
+
}
|
|
224
|
+
if (fs.existsSync(appdebug)) {
|
|
225
|
+
adebug = readToJSON(appdebug)
|
|
226
|
+
}
|
|
227
|
+
if (clive) {
|
|
228
|
+
if (clive.config.domain == cjson.config.domain) {
|
|
229
|
+
status = "live"
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (cdebug) {
|
|
233
|
+
if (cdebug.config.domain == cjson.config.domain) {
|
|
234
|
+
status = "debug"
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return status == "debug"
|
|
199
238
|
}
|
|
200
239
|
|
|
201
240
|
function createFontConfig() {
|
|
@@ -233,24 +272,6 @@ function createFontConfig() {
|
|
|
233
272
|
}
|
|
234
273
|
|
|
235
274
|
function switchStatusAssets(status) {
|
|
236
|
-
|
|
237
|
-
const iconpng = DIR + "assets/icon.png"
|
|
238
|
-
const icondebug = DIR + "assets/icon.debug.png"
|
|
239
|
-
const iconlive = DIR + "assets/icon.live.png"
|
|
240
|
-
|
|
241
|
-
const icon_iospng = DIR + "assets/icon_ios.png"
|
|
242
|
-
const icon_iosdebug = DIR + "assets/icon_ios.debug.png"
|
|
243
|
-
const icon_ioslive = DIR + "assets/icon_ios.live.png"
|
|
244
|
-
|
|
245
|
-
const iconNotifpng = DIR + "assets/iconNotif.png"
|
|
246
|
-
const iconNotifdebug = DIR + "assets/iconNotif.debug.png"
|
|
247
|
-
const iconNotiflive = DIR + "assets/iconNotif.live.png"
|
|
248
|
-
|
|
249
|
-
const splashpng = DIR + "assets/splash.png"
|
|
250
|
-
const splashdebug = DIR + "assets/splash.debug.png"
|
|
251
|
-
const splashlive = DIR + "assets/splash.live.png"
|
|
252
|
-
|
|
253
|
-
|
|
254
275
|
function copyFileFromTo(from, to) {
|
|
255
276
|
if (fs.existsSync(from)) {
|
|
256
277
|
if (fs.existsSync(to))
|
|
@@ -258,18 +279,6 @@ function switchStatusAssets(status) {
|
|
|
258
279
|
command('cp ' + from + ' ' + to)
|
|
259
280
|
}
|
|
260
281
|
}
|
|
261
|
-
if (status.includes('l')) {
|
|
262
|
-
copyFileFromTo(iconlive, iconpng)
|
|
263
|
-
copyFileFromTo(icon_ioslive, icon_iospng)
|
|
264
|
-
copyFileFromTo(splashlive, splashpng)
|
|
265
|
-
copyFileFromTo(iconNotiflive, iconNotifpng)
|
|
266
|
-
}
|
|
267
|
-
if (status.includes('d')) {
|
|
268
|
-
copyFileFromTo(icondebug, iconpng)
|
|
269
|
-
copyFileFromTo(icon_iosdebug, icon_iospng)
|
|
270
|
-
copyFileFromTo(splashdebug, splashpng)
|
|
271
|
-
copyFileFromTo(iconNotifdebug, iconNotifpng)
|
|
272
|
-
}
|
|
273
282
|
|
|
274
283
|
fs.readdirSync(DIR + '/modules/').forEach((mod) => {
|
|
275
284
|
const path = DIR + '/modules/' + mod
|
|
@@ -285,7 +294,17 @@ function switchStatusAssets(status) {
|
|
|
285
294
|
}
|
|
286
295
|
})
|
|
287
296
|
})
|
|
288
|
-
|
|
297
|
+
fs.readdirSync(DIR + '/assets/').forEach((file) => {
|
|
298
|
+
const path = DIR + '/assets/'
|
|
299
|
+
if (status.includes('d'))
|
|
300
|
+
if (file.match(/^.*.debug.*/g)) {
|
|
301
|
+
copyFileFromTo(path + '/' + file, path + '/' + file.replace('.debug.', '.'))
|
|
302
|
+
}
|
|
303
|
+
if (status.includes('l'))
|
|
304
|
+
if (file.match(/^.*.live.*/g)) {
|
|
305
|
+
copyFileFromTo(path + '/' + file, path + '/' + file.replace('.live.', '.'))
|
|
306
|
+
}
|
|
307
|
+
})
|
|
289
308
|
}
|
|
290
309
|
|
|
291
310
|
function excludeModules() {
|
|
@@ -504,6 +523,10 @@ function readToJSON(path) {
|
|
|
504
523
|
return isJSON ? JSON.parse(txt) : txt
|
|
505
524
|
}
|
|
506
525
|
|
|
526
|
+
function isCustomUpdates() {
|
|
527
|
+
let ajson = readToJSON(appjson)
|
|
528
|
+
return ajson.expo.updates.hasOwnProperty('url') && !ajson.expo.updates.url.includes("https://u.expo.dev")
|
|
529
|
+
}
|
|
507
530
|
|
|
508
531
|
function publish(notes) {
|
|
509
532
|
let status = "-"
|
|
@@ -682,6 +705,7 @@ Pastikan data sudah benar sebelum anda melanjutkan, lanjut publish ketikkan runt
|
|
|
682
705
|
fs.writeFileSync(appjson, JSON.stringify(ajson, undefined, 2))
|
|
683
706
|
consoleSucces("start publishing " + status.toUpperCase() + " - PUBLISH_ID : " + (last_id + 1))
|
|
684
707
|
command(`eas update --branch default --message "${notes}"`)
|
|
708
|
+
command("rm -rf ./dist")
|
|
685
709
|
consoleSucces("Berhasil")
|
|
686
710
|
const os = require('os')
|
|
687
711
|
var d = new Date();
|
|
@@ -842,6 +866,15 @@ function buildPrepare(include = true) {
|
|
|
842
866
|
});
|
|
843
867
|
consoleSucces("BUILD PREPARE SUCCESS..!")
|
|
844
868
|
}
|
|
869
|
+
if (isCustomUpdates()) {
|
|
870
|
+
let ejson = readToJSON(easjson)
|
|
871
|
+
delete ejson.build.development.channel
|
|
872
|
+
delete ejson.build.development_build.channel
|
|
873
|
+
delete ejson.build.preview.channel
|
|
874
|
+
delete ejson.build.preview_build.channel
|
|
875
|
+
delete ejson.build.production.channel
|
|
876
|
+
fs.writeFileSync(easjson, JSON.stringify(ejson, undefined, 2))
|
|
877
|
+
}
|
|
845
878
|
} else {
|
|
846
879
|
excludeOnBuild('ios', false)
|
|
847
880
|
if (fs.existsSync('./assets/esoftplaymodules')) {
|
|
@@ -850,6 +883,9 @@ function buildPrepare(include = true) {
|
|
|
850
883
|
}
|
|
851
884
|
else
|
|
852
885
|
consoleError('')
|
|
886
|
+
if (isCustomUpdates()) {
|
|
887
|
+
fs.writeFileSync(easjson, easconfg())
|
|
888
|
+
}
|
|
853
889
|
}
|
|
854
890
|
}
|
|
855
891
|
|
|
@@ -1201,12 +1237,13 @@ function help() {
|
|
|
1201
1237
|
"\n\n OPTIONS :",
|
|
1202
1238
|
"\n - help : panduan penggunaan",
|
|
1203
1239
|
"\n - a|analyze : untuk menambahkan view render counter di semua component",
|
|
1204
|
-
"\n - ac|analyze
|
|
1240
|
+
"\n - ac|analyze-clear : untuk menghapus view render counter di semua component",
|
|
1205
1241
|
"\n - font : untuk mengaktifkan font dari ./assets/fonts",
|
|
1206
1242
|
"\n - fr|fastrefresh : untuk mengaktfikan fast refresh di semua component",
|
|
1207
|
-
"\n - frc|fastrefresh
|
|
1243
|
+
"\n - frc|fastrefresh-clear : untuk menonaktifkan fast refresh di semua component",
|
|
1244
|
+
"\n - su|setup-update : untuk setup update esp module dengan EAS UPDATE SERVICES",
|
|
1208
1245
|
"\n - u|update : untuk update esp module ke versi terakhir",
|
|
1209
|
-
"\n -
|
|
1246
|
+
"\n - update all : untuk update semua esp module ke versi terakhir",
|
|
1210
1247
|
"\n - start : start esoftplay framework",
|
|
1211
1248
|
"\n - b|build : untuk build app .ipa .apk .aab",
|
|
1212
1249
|
"\n - bp|build-prepare : untuk prepare for esp b",
|
package/bin/gen.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
|
|
3
|
+
let functions = []
|
|
4
|
+
if (fs.existsSync('./worker')) {
|
|
5
|
+
fs.readdirSync('./worker').forEach((file) => {
|
|
6
|
+
functions.push(fs.readFileSync('./worker/' + file).toString())
|
|
7
|
+
})
|
|
8
|
+
}
|
|
9
|
+
fs.writeFileSync('./node_modules/esoftplay/modules/lib/out.js', "// useLibs \n //noPage \n\nmodule.exports = \`\n" + functions.join('\n') + "\n\`")
|
package/global.ts
CHANGED
|
@@ -60,23 +60,28 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
|
|
|
60
60
|
const LibCurl = esp.mod("lib/curl")
|
|
61
61
|
const UseTasks = esp.mod("use/tasks")
|
|
62
62
|
sync = UseTasks()((item) => new Promise((next) => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
63
|
+
const { isOnline, isInternetReachable } = esp.mod("lib/net_status").state().get()
|
|
64
|
+
if (isOnline && isInternetReachable) {
|
|
65
|
+
if (o?.useAutoSync) {
|
|
66
|
+
o?.useAutoSync?.isSyncing?.(true)
|
|
67
|
+
new LibCurl(o.useAutoSync.url, o.useAutoSync?.post?.(item),
|
|
68
|
+
(res, msg) => {
|
|
69
|
+
set((old: T) => {
|
|
70
|
+
if (Array.isArray(old)) {
|
|
71
|
+
const index = old?.indexOf(item)
|
|
72
|
+
return esp.mod("lib/object").set(old, 1)(index, 'synced')
|
|
73
|
+
} else {
|
|
74
|
+
return old
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
next()
|
|
78
|
+
}, () => {
|
|
79
|
+
next()
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
next()
|
|
80
85
|
}
|
|
81
86
|
}), () => {
|
|
82
87
|
o?.useAutoSync?.isSyncing?.(false)
|
package/modules/lib/image.tsx
CHANGED
|
@@ -104,7 +104,7 @@ class m extends LibComponent<LibImageProps, LibImageState> {
|
|
|
104
104
|
|
|
105
105
|
static fromCamera(options?: LibImageCameraOptions): Promise<string> {
|
|
106
106
|
return new Promise((_r) => {
|
|
107
|
-
|
|
107
|
+
const timer = setTimeout(async () => {
|
|
108
108
|
const cameraPermission = await ImagePicker.getCameraPermissionsAsync();
|
|
109
109
|
var finalStatus = cameraPermission.status
|
|
110
110
|
if (finalStatus !== 'granted') {
|
|
@@ -127,10 +127,17 @@ class m extends LibComponent<LibImageProps, LibImageState> {
|
|
|
127
127
|
aspect: options?.crop?.ratio?.split(':').map((x) => Number(x)),
|
|
128
128
|
quality: 1,
|
|
129
129
|
presentationStyle: ImagePicker.UIImagePickerPresentationStyle.FULL_SCREEN
|
|
130
|
-
}).then(async (
|
|
131
|
-
if (!
|
|
132
|
-
|
|
133
|
-
if (!
|
|
130
|
+
}).then(async (res: any) => {
|
|
131
|
+
if (!res)
|
|
132
|
+
res = ImagePicker?.getPendingResultAsync()
|
|
133
|
+
if (!res?.cancelled) {
|
|
134
|
+
let result: any = undefined
|
|
135
|
+
let hasUri = res?.uri
|
|
136
|
+
if (hasUri) {
|
|
137
|
+
result = res
|
|
138
|
+
} else if (res?.assets?.[0]) {
|
|
139
|
+
result = { ...res, ...res.assets[0] }
|
|
140
|
+
}
|
|
134
141
|
if (Platform.OS == 'ios' && options && options.crop) {
|
|
135
142
|
m.showCropper(result?.uri, options?.crop?.forceCrop, options?.crop?.ratio, options?.crop?.message, async (x) => {
|
|
136
143
|
let imageUri = await m.processImage(x, options?.maxDimension)
|
|
@@ -151,7 +158,7 @@ class m extends LibComponent<LibImageProps, LibImageState> {
|
|
|
151
158
|
|
|
152
159
|
static fromGallery(options?: LibImageGalleryOptions): Promise<string | string[]> {
|
|
153
160
|
return new Promise((_r) => {
|
|
154
|
-
|
|
161
|
+
const timer = setTimeout(async () => {
|
|
155
162
|
const { status } = await ImagePicker.getMediaLibraryPermissionsAsync();
|
|
156
163
|
var finalStatus = status
|
|
157
164
|
if (finalStatus !== 'granted') {
|
|
@@ -174,8 +181,15 @@ class m extends LibComponent<LibImageProps, LibImageState> {
|
|
|
174
181
|
allowsEditing: Platform.OS != 'ios' && options && options.crop ? true : false,
|
|
175
182
|
aspect: options?.crop?.ratio?.split(':').map((x) => Number(x)),
|
|
176
183
|
quality: 1,
|
|
177
|
-
}).then(async (
|
|
178
|
-
if (!
|
|
184
|
+
}).then(async (z: any) => {
|
|
185
|
+
if (!z.cancelled) {
|
|
186
|
+
let x: any = undefined
|
|
187
|
+
let hasUri = z?.uri
|
|
188
|
+
if (hasUri) {
|
|
189
|
+
x = z
|
|
190
|
+
} else if (z?.assets?.[0]) {
|
|
191
|
+
x = { ...z, ...z.assets[0] }
|
|
192
|
+
}
|
|
179
193
|
if (Platform.OS == 'ios' && options && options.crop) {
|
|
180
194
|
m.showCropper(x.uri, options.crop.forceCrop, options.crop.ratio, options.crop?.message, async (x) => {
|
|
181
195
|
let imageUri = await m.processImage(x, options?.maxDimension)
|
|
@@ -257,7 +271,7 @@ class m extends LibComponent<LibImageProps, LibImageState> {
|
|
|
257
271
|
}
|
|
258
272
|
}
|
|
259
273
|
|
|
260
|
-
|
|
274
|
+
const timer = setTimeout(async () => {
|
|
261
275
|
const manipImage = await ImageManipulator.manipulateAsync(
|
|
262
276
|
result.uri,
|
|
263
277
|
doResize ? [{ resize: { width: wantedwidth, height: wantedheight } }] : [],
|
|
@@ -272,7 +286,7 @@ class m extends LibComponent<LibImageProps, LibImageState> {
|
|
|
272
286
|
LibProgress.hide()
|
|
273
287
|
r(msg.message);
|
|
274
288
|
}, 1)
|
|
275
|
-
|
|
289
|
+
clearTimeout(timer)
|
|
276
290
|
}, 1);
|
|
277
291
|
}
|
|
278
292
|
})
|
|
@@ -348,12 +362,12 @@ class m extends LibComponent<LibImageProps, LibImageState> {
|
|
|
348
362
|
</TouchableOpacity>
|
|
349
363
|
:
|
|
350
364
|
<TouchableOpacity onPress={() => {
|
|
351
|
-
|
|
365
|
+
const timer = setTimeout(
|
|
352
366
|
async () => {
|
|
353
367
|
m.hide()
|
|
354
368
|
this.setState({ image: null })
|
|
355
369
|
});
|
|
356
|
-
|
|
370
|
+
clearTimeout(timer)
|
|
357
371
|
}} >
|
|
358
372
|
<LibIcon.Ionicons name='ios-close-circle' style={{ fontSize: 40, color: 'white' }} />
|
|
359
373
|
</TouchableOpacity>
|
|
@@ -45,6 +45,19 @@ Notifications.setNotificationHandler({
|
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
export interface notificationTrigger {
|
|
49
|
+
delayInMinutes: number,
|
|
50
|
+
repeats?: boolean
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface notificationContent {
|
|
54
|
+
title: string,
|
|
55
|
+
message: string,
|
|
56
|
+
module?: string,
|
|
57
|
+
url?: string
|
|
58
|
+
arguments?: any
|
|
59
|
+
}
|
|
60
|
+
|
|
48
61
|
const lastUrlState = useGlobalState<any>(undefined)
|
|
49
62
|
|
|
50
63
|
function mainUrl(): string {
|
|
@@ -258,7 +271,7 @@ export default {
|
|
|
258
271
|
if (String(experienceId).includes('/')) {
|
|
259
272
|
expoToken = await Notifications.getExpoPushTokenAsync({ experienceId })
|
|
260
273
|
} else {
|
|
261
|
-
expoToken = await Notifications.getExpoPushTokenAsync()
|
|
274
|
+
expoToken = await Notifications.getExpoPushTokenAsync({ projectId: experienceId })
|
|
262
275
|
}
|
|
263
276
|
}
|
|
264
277
|
if (expoToken) {
|
|
@@ -269,6 +282,33 @@ export default {
|
|
|
269
282
|
}
|
|
270
283
|
})
|
|
271
284
|
},
|
|
285
|
+
cancelLocalNotification(notif_id: string) {
|
|
286
|
+
Notifications.cancelScheduledNotificationAsync(notif_id)
|
|
287
|
+
},
|
|
288
|
+
setLocalNotification(action: "alert" | "default" | "update", content: notificationContent, trigger: notificationTrigger, callback?: (notif_id: string) => void): void {
|
|
289
|
+
const triggerSeconds = Number(trigger?.delayInMinutes) * 60
|
|
290
|
+
const _trigger = {
|
|
291
|
+
seconds: triggerSeconds,
|
|
292
|
+
repeats: !!trigger?.repeats,
|
|
293
|
+
}
|
|
294
|
+
const params = { status: 3, url: content?.url, ...content?.arguments }
|
|
295
|
+
Notifications.scheduleNotificationAsync({
|
|
296
|
+
content: {
|
|
297
|
+
title: content?.title,
|
|
298
|
+
body: content?.message,
|
|
299
|
+
data: {
|
|
300
|
+
action: action,
|
|
301
|
+
module: content.module,
|
|
302
|
+
title: content?.title,
|
|
303
|
+
message: content?.message,
|
|
304
|
+
params,
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
trigger: _trigger,
|
|
308
|
+
}).then((notifId) => {
|
|
309
|
+
callback?.(notifId)
|
|
310
|
+
}).catch((r) => { })
|
|
311
|
+
},
|
|
272
312
|
openPushNotif(data: any): void {
|
|
273
313
|
if (!data) return
|
|
274
314
|
if (typeof data == 'string')
|
package/modules/lib/toast.tsx
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// withHooks
|
|
2
2
|
// noPage
|
|
3
3
|
|
|
4
|
-
// nunggu update master, margin sebelah kanan kegeser
|
|
5
|
-
|
|
6
4
|
import { LibStyle } from 'esoftplay/cache/lib/style/import';
|
|
7
5
|
import useGlobalState from 'esoftplay/global';
|
|
8
6
|
import React, { useEffect } from 'react';
|
|
@@ -47,7 +45,7 @@ export default function m(props: LibToastProps): any {
|
|
|
47
45
|
|
|
48
46
|
const style = useAnimatedProps(() => ({
|
|
49
47
|
transform: [{
|
|
50
|
-
translateY: interpolate(anim.value, [0, 1], [-
|
|
48
|
+
translateY: interpolate(anim.value, [0, 1], [-200, 0])
|
|
51
49
|
}],
|
|
52
50
|
opacity: interpolate(anim.value, [0, 0.8, 1], [0, 0, 1])
|
|
53
51
|
}))
|
package/modules/lib/utils.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// noPage
|
|
2
2
|
// withObject
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
//moveup for formatting currency with lang
|
|
5
|
+
import { LibLocale } from 'esoftplay/cache/lib/locale/import';
|
|
4
6
|
import esp from 'esoftplay/esp';
|
|
5
7
|
import useGlobalState from 'esoftplay/global';
|
|
6
8
|
import moment from "esoftplay/moment";
|
|
@@ -118,8 +120,13 @@ export default {
|
|
|
118
120
|
} else {
|
|
119
121
|
val = parseInt(value)?.toFixed?.(0)?.replace?.(/(\d)(?=(\d{3})+$)/g, "$1,")
|
|
120
122
|
}
|
|
123
|
+
const locale = LibLocale.state().get()
|
|
121
124
|
if (!currency) {
|
|
122
|
-
|
|
125
|
+
if (locale == "id") {
|
|
126
|
+
currency = "Rp"
|
|
127
|
+
} else {
|
|
128
|
+
currency = "IDR"
|
|
129
|
+
}
|
|
123
130
|
}
|
|
124
131
|
if (typeof val === "number") {
|
|
125
132
|
return currency?.replace?.(/\./g, "") + " " + String(val)?.replace?.(/,/g, ".");
|
|
@@ -251,10 +258,10 @@ export default {
|
|
|
251
258
|
},
|
|
252
259
|
mapDirectionTo(latlongFrom: string, latlongTo: string, travelmode: LibUtilsTravelMode): void {
|
|
253
260
|
if (!this.isValidLatLong(latlongFrom)) {
|
|
254
|
-
return
|
|
261
|
+
return esp.modProp("lib/toast").show(esp.lang("lib/utils", "toas_latlongfrom"))
|
|
255
262
|
}
|
|
256
263
|
if (!this.isValidLatLong(latlongTo)) {
|
|
257
|
-
return
|
|
264
|
+
return esp.modProp("lib/toast").show(esp.lang("lib/utils", "toas_latlongto"))
|
|
258
265
|
}
|
|
259
266
|
Linking.openURL("https://www.google.com/maps/dir/?api=1&travelmode="
|
|
260
267
|
+ travelmode
|
|
@@ -307,7 +314,7 @@ export default {
|
|
|
307
314
|
let out = installationId.get()
|
|
308
315
|
if (!out) {
|
|
309
316
|
if (Platform.OS == "android")
|
|
310
|
-
resolve(String(Application.androidId))
|
|
317
|
+
resolve(String(Application.androidId || Application.getAndroidId()))
|
|
311
318
|
if (Platform.OS == "ios") {
|
|
312
319
|
let code = await SecureStore.getItemAsync('installationId');
|
|
313
320
|
if (!code) {
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// withHooks
|
|
2
|
+
import esp from 'esoftplay/esp';
|
|
3
|
+
import useGlobalSubscriber from 'esoftplay/subscribe';
|
|
4
|
+
import { createTimeout } from 'esoftplay/timeout';
|
|
5
|
+
import React, { useEffect, useRef } from 'react';
|
|
6
|
+
import { View } from 'react-native';
|
|
7
|
+
import WebView from 'react-native-webview';
|
|
8
|
+
|
|
9
|
+
export interface LibUseworkerArgs {
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
export interface LibUseworkerProps {
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const subs = useGlobalSubscriber()
|
|
17
|
+
|
|
18
|
+
export function createTask(functionName: string, ...params: string[]): (res: (data: string) => void) => void {
|
|
19
|
+
return (res: (data: string) => void) => {
|
|
20
|
+
subs.trigger({
|
|
21
|
+
functionName,
|
|
22
|
+
params,
|
|
23
|
+
res
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function m(props: LibUseworkerProps): any {
|
|
29
|
+
let ref = useRef<WebView>(null)
|
|
30
|
+
let isReady = useRef<number>(0)
|
|
31
|
+
let workerIds = useRef<number>(1)
|
|
32
|
+
let tasks = useRef(new Map())
|
|
33
|
+
|
|
34
|
+
const dispatch = (task: (id: number) => string, result: (r: string) => void): void => {
|
|
35
|
+
if (isReady.current > 0 && typeof ref.current?.injectJavaScript == 'function') {
|
|
36
|
+
const idx = workerIds.current
|
|
37
|
+
const _task = task(idx)
|
|
38
|
+
tasks.current.set(String(idx), {
|
|
39
|
+
task: _task,
|
|
40
|
+
result: result
|
|
41
|
+
})
|
|
42
|
+
ref.current?.injectJavaScript(_task)
|
|
43
|
+
workerIds.current = idx + 1
|
|
44
|
+
} else {
|
|
45
|
+
createTimeout().set(() => {
|
|
46
|
+
dispatch(task, result)
|
|
47
|
+
}, 1000)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
ref.current?.injectJavaScript(`\n${require('./out')}\n`)
|
|
53
|
+
}, [])
|
|
54
|
+
|
|
55
|
+
subs.useSubscribe(() => {
|
|
56
|
+
const { functionName, params, res } = subs.getValue()
|
|
57
|
+
dispatch((id: number) => `
|
|
58
|
+
(async () => {
|
|
59
|
+
const dt = await ${functionName}(${params.map((x: string) => JSON.stringify(x)).join(", ")});
|
|
60
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
61
|
+
data: dt,
|
|
62
|
+
id: ${id}
|
|
63
|
+
}))
|
|
64
|
+
})();`, res)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
const deleteTask = (taskId: string): void => {
|
|
68
|
+
tasks.current.delete(String(taskId))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const onMessage = (withRefName: string): any => {
|
|
72
|
+
return (e: any) => {
|
|
73
|
+
if (e.nativeEvent.data == withRefName) {
|
|
74
|
+
isReady.current = 1
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
const dt = e.nativeEvent.data
|
|
78
|
+
const x = JSON.parse(dt)
|
|
79
|
+
const itemTask = tasks.current.get(String(x.id))
|
|
80
|
+
if (itemTask) {
|
|
81
|
+
itemTask.result(x.data)
|
|
82
|
+
deleteTask(x.id)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<View style={{ height: 0, width: 0 }} >
|
|
89
|
+
<WebView
|
|
90
|
+
ref={ref}
|
|
91
|
+
style={{ height: 0, width: 0 }}
|
|
92
|
+
incognito
|
|
93
|
+
javaScriptEnabled={true}
|
|
94
|
+
injectedJavaScript={`\nwindow.ReactNativeWebView.postMessage("BaseWorkerIsReady")\n${require('./out')}\n`}
|
|
95
|
+
originWhitelist={["*"]}
|
|
96
|
+
source={{ uri: esp.config("protocol") + "://" + esp.config("domain") + esp.config("uri") + "dummyPageToBypassCORS" }}
|
|
97
|
+
onMessage={onMessage('BaseWorkerIsReady')}
|
|
98
|
+
/>
|
|
99
|
+
</View>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
package/modules/main/index.tsx
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// withHooks
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Text, View } from 'react-native';
|
|
4
|
-
export interface
|
|
4
|
+
export interface MainIndexArgs {
|
|
5
5
|
|
|
6
6
|
}
|
|
7
|
-
export interface
|
|
7
|
+
export interface MainIndexProps {
|
|
8
8
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export default function m(props:
|
|
11
|
+
export default function m(props: MainIndexProps): any {
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<View style={{ flex: 1, backgroundColor: "white", justifyContent: 'center', alignItems: 'center' }} >
|
|
15
|
-
<Text>Hellow Esoftplay Developer, jangan lupa bismillah dulu</Text>
|
|
15
|
+
<Text>{`Hellow Esoftplay Developer, jangan lupa bismillah dulu ଘ(੭ˊᵕˋ)੭*`}</Text>
|
|
16
16
|
</View>
|
|
17
17
|
)
|
|
18
18
|
}
|
package/modules/user/class.ts
CHANGED
|
@@ -70,7 +70,7 @@ export default {
|
|
|
70
70
|
return
|
|
71
71
|
}
|
|
72
72
|
esp.mod("lib/notification").requestPermission(async (token) => {
|
|
73
|
-
if (token
|
|
73
|
+
if (token) {
|
|
74
74
|
const config = esp.config();
|
|
75
75
|
const LibCrypt = esp.mod("lib/crypt")
|
|
76
76
|
var post: any = {
|
|
@@ -81,6 +81,7 @@ export default {
|
|
|
81
81
|
push_id: "",
|
|
82
82
|
is_app: Constants.appOwnership == 'expo' ? 0 : 1,
|
|
83
83
|
os: Platform.OS,
|
|
84
|
+
installation_id: await esp.mod("lib/utils").getInstallationID(),
|
|
84
85
|
device: Constants.deviceName,
|
|
85
86
|
secretkey: new LibCrypt().encode(config.salt + "|" + moment().format("YYYY-MM-DD hh:mm:ss"))
|
|
86
87
|
}
|
package/modules/user/index.tsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// withHooks
|
|
2
2
|
// noPage
|
|
3
|
-
import { esp, useSafeState } from 'esoftplay';
|
|
4
3
|
import { LibDialog } from 'esoftplay/cache/lib/dialog/import';
|
|
5
4
|
import { LibImage } from 'esoftplay/cache/lib/image/import';
|
|
6
5
|
import { LibLocale } from 'esoftplay/cache/lib/locale/import';
|
|
@@ -10,6 +9,7 @@ import { LibStyle } from 'esoftplay/cache/lib/style/import';
|
|
|
10
9
|
import { LibToast } from 'esoftplay/cache/lib/toast/import';
|
|
11
10
|
import { LibUpdaterProperty } from 'esoftplay/cache/lib/updater/import';
|
|
12
11
|
import { LibVersion } from 'esoftplay/cache/lib/version/import';
|
|
12
|
+
import { LibWorker } from 'esoftplay/cache/lib/worker/import';
|
|
13
13
|
import { LibWorkloop } from 'esoftplay/cache/lib/workloop/import';
|
|
14
14
|
import Navs from 'esoftplay/cache/navs';
|
|
15
15
|
import { UseDeeplink } from 'esoftplay/cache/use/deeplink/import';
|
|
@@ -17,7 +17,9 @@ import { UserClass } from 'esoftplay/cache/user/class/import';
|
|
|
17
17
|
import { UserHook } from 'esoftplay/cache/user/hook/import';
|
|
18
18
|
import { UserLoading } from 'esoftplay/cache/user/loading/import';
|
|
19
19
|
import * as ErrorReport from 'esoftplay/error';
|
|
20
|
+
import esp from 'esoftplay/esp';
|
|
20
21
|
import moment from 'esoftplay/moment';
|
|
22
|
+
import useSafeState from 'esoftplay/state';
|
|
21
23
|
import { useFonts } from 'expo-font';
|
|
22
24
|
import React, { useLayoutEffect } from 'react';
|
|
23
25
|
import { View } from 'react-native';
|
|
@@ -63,12 +65,13 @@ export default function m(props: UserIndexProps): any {
|
|
|
63
65
|
}
|
|
64
66
|
}, [fontLoaded])
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
|
|
67
69
|
//esoftplay-chatting
|
|
68
70
|
|
|
69
71
|
return (
|
|
70
72
|
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
71
73
|
<View style={{ flex: 1 }}>
|
|
74
|
+
<LibWorker />
|
|
72
75
|
{
|
|
73
76
|
loading ?
|
|
74
77
|
<UserLoading />
|
|
@@ -82,50 +85,10 @@ export default function m(props: UserIndexProps): any {
|
|
|
82
85
|
<LibProgress />
|
|
83
86
|
<LibToast />
|
|
84
87
|
<UserHook />
|
|
85
|
-
{/* {__DEV__ && <Draggable />} */}
|
|
86
88
|
</>
|
|
87
89
|
}
|
|
88
90
|
</View>
|
|
89
91
|
<View style={{ backgroundColor: LibStyle?.colorNavigationBar || 'white', height: LibStyle.isIphoneX ? 35 : 0 }} />
|
|
90
92
|
</GestureHandlerRootView>
|
|
91
93
|
)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// const Draggable = () => {
|
|
98
|
-
// const translateX = useSharedValue(0);
|
|
99
|
-
// const translateY = useSharedValue(0);
|
|
100
|
-
// const lastOffset = { x: 0, y: 0 };
|
|
101
|
-
// const handleGestureEvent = useAnimatedGestureHandler({
|
|
102
|
-
// onStart: (_, ctx: any) => {
|
|
103
|
-
// ctx.offsetX = translateX.value;
|
|
104
|
-
// ctx.offsetY = translateY.value;
|
|
105
|
-
// },
|
|
106
|
-
// onActive: (event, ctx) => {
|
|
107
|
-
// translateX.value = ctx.offsetX + event.translationX;
|
|
108
|
-
// translateY.value = ctx.offsetY + event.translationY;
|
|
109
|
-
// },
|
|
110
|
-
// onEnd: (event) => {
|
|
111
|
-
// lastOffset.x += event.translationX;
|
|
112
|
-
// lastOffset.y += event.translationY;
|
|
113
|
-
// },
|
|
114
|
-
// });
|
|
115
|
-
// const animatedStyle = useAnimatedStyle(() => {
|
|
116
|
-
// return {
|
|
117
|
-
// transform: [{ translateX: translateX.value }, { translateY: translateY.value }],
|
|
118
|
-
// };
|
|
119
|
-
// });
|
|
120
|
-
// return (
|
|
121
|
-
// <View style={{ position: 'absolute', right: 10 }}>
|
|
122
|
-
// <PanGestureHandler onGestureEvent={handleGestureEvent}>
|
|
123
|
-
// <Animated.View style={[animatedStyle]} >
|
|
124
|
-
// <Pressable onPress={() => { route.reset(); LibNavigation.backToRoot() }} style={{ right: 10, top: LibStyle.height * 0.5, padding: 10, backgroundColor: 'indigo', alignItems: 'center', justifyContent: 'center', borderRadius: 50 }} >
|
|
125
|
-
// <LibIcon name='delete-variant' color='white' />
|
|
126
|
-
// </Pressable>
|
|
127
|
-
// </Animated.View>
|
|
128
|
-
// </PanGestureHandler>
|
|
129
|
-
// </View>
|
|
130
|
-
// );
|
|
131
|
-
// };
|
|
94
|
+
}
|
package/package.json
CHANGED
package/modules/lib/worker.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// useLibs
|
|
2
|
-
// noPage
|
|
3
|
-
import { runOnJS, runOnUI } from "react-native-reanimated";
|
|
4
|
-
|
|
5
|
-
export interface LibWorkerProps {
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
const run = LibWorker((arg: any[], cb: (out: any) => void) => {
|
|
11
|
-
"worklet";
|
|
12
|
-
let out = 0
|
|
13
|
-
for (let i = 0; i < arg[0]; i++) {
|
|
14
|
-
out += i
|
|
15
|
-
}
|
|
16
|
-
cb(out)
|
|
17
|
-
})
|
|
18
|
-
run([99999999], res => {
|
|
19
|
-
setState(res)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
export default function m(func: (args: any[], cb: (res: any) => void) => void): (args: any[], cb: (res: any) => void) => void {
|
|
25
|
-
return (args: any[], cb: (res: any) => void) => {
|
|
26
|
-
function callback(out: any) {
|
|
27
|
-
"worklet"
|
|
28
|
-
runOnJS(cb)(out)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function run() {
|
|
32
|
-
"worklet"
|
|
33
|
-
func(args, callback)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
runOnUI(run)()
|
|
37
|
-
}
|
|
38
|
-
}
|