esoftplay 0.0.119-r → 0.0.119-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.
package/bin/router.js CHANGED
@@ -385,7 +385,7 @@ import { AntDesignTypes, EntypoTypes, EvilIconsTypes, FeatherTypes, FontAwesomeT
385
385
 
386
386
  declare module "esoftplay" {
387
387
  var _global: any;
388
- function useGlobalState<S>(initialState?: S, option?: useGlobalOption): useGlobalReturn<S>;
388
+ // function useGlobalState<S>(initialState?: S, option?: useGlobalOption): useGlobalReturn<S>;
389
389
  function usePersistState<S>(key: string, initialState?: S | (() => S)): [S, (a: S | ((b: S )=> S)) => S | undefined, (a?: (x: S) => void) => void, () => void];
390
390
  function useSafeState<S>(initialState?: S | (() => S)): [S, (a: S | ((b: S )=> S)) => S | undefined];
391
391
  function applyStyle<T>(style: T): T;
package/global.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import AsyncStorage from '@react-native-async-storage/async-storage';
2
+ import { UserData } from 'esoftplay/cache/user/data.import';
2
3
  import * as R from 'react';
3
4
  import { fastFilter, fastLoop } from './fast';
4
5
  const _global = require('./_global')
@@ -25,21 +26,21 @@ export interface useGlobalConnect<T> {
25
26
  }
26
27
 
27
28
  _global.useGlobalUserDelete = {}
28
- let useGlobalSubscriber = {}
29
+ let useGlobalSubscriber: any = {}
29
30
 
30
- class Context {
31
- idx = 0
32
- increment = () => this.idx++
33
- reset = () => {
34
- this.idx = 0
35
- }
31
+ let idx = 0
32
+ const Context = {
33
+ reset: () => idx = 0
36
34
  }
37
35
 
38
- export const globalIdx = new Context()
36
+ export const globalIdx = Context
39
37
  export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): useGlobalReturn<T> {
40
38
  const Storage = require('./storage').default;
41
39
  const STORAGE = o?.inFile ? new Storage() : AsyncStorage
42
- const _idx = globalIdx.idx
40
+ const _idx = idx
41
+ if (!useGlobalSubscriber) {
42
+ useGlobalSubscriber = {}
43
+ }
43
44
  if (!useGlobalSubscriber[_idx])
44
45
  useGlobalSubscriber[_idx] = [];
45
46
  let value: T = initValue;
@@ -67,8 +68,6 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
67
68
  set(initValue)
68
69
  }
69
70
  if (o?.persistKey) {
70
- const esp = require('./esp').default;
71
- const UserData = esp.mod('user/data')
72
71
  if (UserData)
73
72
  UserData?.register?.(o?.persistKey)
74
73
  }
@@ -157,6 +156,6 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
157
156
  return children ? R.cloneElement(children) : null
158
157
  }
159
158
 
160
- globalIdx.increment()
159
+ idx++
161
160
  return { useState, get, set, useSelector, reset: del, connect: _connect };
162
161
  }
@@ -1,12 +1,13 @@
1
1
  import fs from 'fs'
2
2
  const pattern = new RegExp(/\n{0,}import ((.*)) from (?:"esoftplay"|'esoftplay');?/gs)
3
+ const globalPattern = new RegExp(/((?:, useGlobalState|useGlobalState,|\{\s{0,}useGlobalState\s{0,}\}))/gs)
3
4
  if (fs.existsSync('./modules')) {
4
5
  fs.readdirSync('./modules').forEach((module) => {
5
6
  if (!module.startsWith('.')) {
6
7
  fs.readdirSync('./modules/' + module).forEach((task) => {
7
- // if (task == 'card.tsx') {
8
8
  var dFile = fs.readFileSync('./modules/' + module + '/' + task, { encoding: 'utf8' })
9
9
  const matchs = dFile.match(pattern)
10
+ const matchGlobal = dFile.match(globalPattern)
10
11
  if (matchs) {
11
12
  let espMod = []
12
13
  let nonEspMod = []
@@ -33,11 +34,10 @@ if (fs.existsSync('./modules')) {
33
34
  })
34
35
  }
35
36
  dFile = dFile.replace(cmatch, "\nimport { " + espMod.join(", ") + " } from 'esoftplay';\n" + adder)
37
+ if (matchGlobal)
38
+ dFile = dFile.replace(matchGlobal, "\nimport useGlobalState from 'esoftplay/global';\n")
36
39
  fs.writeFileSync('./modules/' + module + '/' + task, dFile, { encoding: 'utf8' })
37
- // }
38
-
39
40
  }
40
- // return
41
41
  })
42
42
  }
43
43
  })
@@ -1,12 +1,10 @@
1
1
  // noPage
2
- import { useGlobalState } from 'esoftplay';
3
-
4
2
  import { LibComponent } from 'esoftplay/cache/lib/component.import';
5
- import { LibIcon } from 'esoftplay/cache/lib/icon.import';
6
- import { LibIconStyle } from 'esoftplay/cache/lib/icon.import';
3
+ import { LibIcon, LibIconStyle } from 'esoftplay/cache/lib/icon.import';
7
4
  import { LibStyle } from 'esoftplay/cache/lib/style.import';
8
5
  import { LibTextstyle } from 'esoftplay/cache/lib/textstyle.import';
9
6
  import { LibTheme } from 'esoftplay/cache/lib/theme.import';
7
+ import useGlobalState from 'esoftplay/global';
10
8
 
11
9
  import React from 'react';
12
10
  import { BackHandler, Keyboard, TouchableOpacity, View } from 'react-native';
@@ -1,12 +1,12 @@
1
1
  // noPage
2
- import { esp, useGlobalState } from 'esoftplay';
2
+ import { esp } from 'esoftplay';
3
3
  import { LibComponent } from 'esoftplay/cache/lib/component.import';
4
4
  import { LibCurl } from 'esoftplay/cache/lib/curl.import';
5
5
  import { LibIcon } from 'esoftplay/cache/lib/icon.import';
6
6
  import { LibNavigation } from 'esoftplay/cache/lib/navigation.import';
7
7
  import { LibProgress } from 'esoftplay/cache/lib/progress.import';
8
8
  import { LibStyle } from 'esoftplay/cache/lib/style.import';
9
-
9
+ import useGlobalState from 'esoftplay/global';
10
10
  import { Camera } from 'expo-camera';
11
11
  import * as ImageManipulator from 'expo-image-manipulator';
12
12
  import { SaveFormat } from 'expo-image-manipulator';
@@ -1,6 +1,7 @@
1
1
  // noPage
2
- import { useGlobalReturn, useGlobalState } from 'esoftplay';
2
+ import { useGlobalReturn } from 'esoftplay';
3
3
  import { LibNavigation } from 'esoftplay/cache/lib/navigation.import';
4
+ import useGlobalState from 'esoftplay/global';
4
5
 
5
6
 
6
7
 
@@ -1,6 +1,7 @@
1
1
  // noPage
2
- import { useGlobalReturn, useGlobalState } from 'esoftplay';
2
+ import { useGlobalReturn } from 'esoftplay';
3
3
  import { LibComponent } from 'esoftplay/cache/lib/component.import';
4
+ import useGlobalState from 'esoftplay/global';
4
5
 
5
6
  import React from "react";
6
7
  import { Animated, Text } from "react-native";
@@ -2,13 +2,14 @@
2
2
  import { useGlobalReturn } from 'esoftplay';
3
3
  // noPage
4
4
 
5
- import { esp, useGlobalState } from 'esoftplay';
5
+ import { esp } from 'esoftplay';
6
6
  import { LibCrypt } from 'esoftplay/cache/lib/crypt.import';
7
7
  import { LibCurl } from 'esoftplay/cache/lib/curl.import';
8
8
  import { LibNavigation } from 'esoftplay/cache/lib/navigation.import';
9
9
  import { LibObject } from 'esoftplay/cache/lib/object.import';
10
10
  import { UserClass } from 'esoftplay/cache/user/class.import';
11
11
  import { UserNotification } from 'esoftplay/cache/user/notification.import';
12
+ import useGlobalState from 'esoftplay/global';
12
13
 
13
14
  import { fastFilter } from "esoftplay/fast";
14
15
  import Constants from 'expo-constants';
@@ -1,7 +1,7 @@
1
1
  // useLibs
2
- import { useGlobalState } from 'esoftplay';
3
2
  import { LibCrypt } from 'esoftplay/cache/lib/crypt.import';
4
3
  import { LibObject } from 'esoftplay/cache/lib/object.import';
4
+ import useGlobalState from 'esoftplay/global';
5
5
 
6
6
 
7
7
  export interface LibNotifyItem {
@@ -1,9 +1,9 @@
1
1
  // noPage
2
- import { useGlobalState } from 'esoftplay';
3
2
  import { LibComponent } from 'esoftplay/cache/lib/component.import';
4
3
  import { LibStyle } from 'esoftplay/cache/lib/style.import';
5
4
  import { LibTextstyle } from 'esoftplay/cache/lib/textstyle.import';
6
5
  import { LibTheme } from 'esoftplay/cache/lib/theme.import';
6
+ import useGlobalState from 'esoftplay/global';
7
7
 
8
8
  import React from 'react';
9
9
  import { ActivityIndicator, BackHandler, View } from 'react-native';
@@ -1,7 +1,8 @@
1
1
  // noPage
2
- import { esp, useGlobalState } from 'esoftplay';
2
+ import { esp } from 'esoftplay';
3
3
  import { LibNavigation } from 'esoftplay/cache/lib/navigation.import';
4
4
  import { LibStyle } from 'esoftplay/cache/lib/style.import';
5
+ import useGlobalState from 'esoftplay/global';
5
6
 
6
7
  import AsyncStorage from '@react-native-async-storage/async-storage';
7
8
  const { colorPrimary, colorAccent } = LibStyle
@@ -1,8 +1,7 @@
1
1
  // withHooks
2
2
  // noPage
3
- import { useGlobalState } from 'esoftplay';
4
3
  import { LibStyle } from 'esoftplay/cache/lib/style.import';
5
-
4
+ import useGlobalState from 'esoftplay/global';
6
5
  import React, { useEffect } from 'react';
7
6
  import { Text } from 'react-native';
8
7
  import Animated, { interpolate, useAnimatedProps, useSharedValue, withTiming } from 'react-native-reanimated';
@@ -1,7 +1,8 @@
1
1
  // noPage
2
- import { esp, useGlobalState } from 'esoftplay';
2
+ import { esp } from 'esoftplay';
3
3
  import { LibToastProperty } from 'esoftplay/cache/lib/toast.import';
4
4
  import { fastFilter, fastLoop } from 'esoftplay/fast';
5
+ import useGlobalState from 'esoftplay/global';
5
6
  import moment from "esoftplay/moment";
6
7
  import * as Application from 'expo-application';
7
8
  import * as Clipboard from 'expo-clipboard';
@@ -7,10 +7,10 @@ import { LibNotification } from 'esoftplay/cache/lib/notification.import';
7
7
  import { UserClass } from 'esoftplay/cache/user/class.import';
8
8
  import { UserData } from 'esoftplay/cache/user/data.import';
9
9
 
10
+ import useGlobalState from 'esoftplay/global';
10
11
  import Constants from 'expo-constants';
11
12
  import * as Notifications from 'expo-notifications';
12
13
  import { Platform } from 'react-native';
13
- import useGlobalState from '../../global';
14
14
  import moment from "../../moment";
15
15
 
16
16
  const state = useGlobalState?.(null, { persistKey: "user" })
@@ -1,6 +1,6 @@
1
1
  // withHooks
2
2
  // noPage
3
- import { esp, useSafeState } from 'esoftplay';
3
+ import { esp, useSafeState, _global } from 'esoftplay';
4
4
  import { LibDialog } from 'esoftplay/cache/lib/dialog.import';
5
5
  import { LibImage } from 'esoftplay/cache/lib/image.import';
6
6
  import { LibNet_status } from 'esoftplay/cache/lib/net_status.import';
@@ -1,5 +1,5 @@
1
1
  //
2
- import { useGlobalReturn, useGlobalState } from 'esoftplay';
2
+ import { useGlobalReturn } from 'esoftplay';
3
3
  import { LibComponent } from 'esoftplay/cache/lib/component.import';
4
4
  import { LibIcon } from 'esoftplay/cache/lib/icon.import';
5
5
  import { LibList } from 'esoftplay/cache/lib/list.import';
@@ -7,6 +7,7 @@ import { LibNotification } from 'esoftplay/cache/lib/notification.import';
7
7
  import { LibStatusbar } from 'esoftplay/cache/lib/statusbar.import';
8
8
  import { LibStyle } from 'esoftplay/cache/lib/style.import';
9
9
  import { UserNotification_item } from 'esoftplay/cache/user/notification_item.import';
10
+ import useGlobalState from 'esoftplay/global';
10
11
 
11
12
  import { Pressable, Text, TouchableOpacity, View } from "react-native";
12
13
  //@ts-ignore
@@ -1,6 +1,6 @@
1
1
  // noPage
2
- import { useGlobalReturn, useGlobalState } from 'esoftplay';
3
-
2
+ import { useGlobalReturn } from 'esoftplay';
3
+ import useGlobalState from 'esoftplay/global';
4
4
 
5
5
  const state = useGlobalState(undefined)
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.119-r",
3
+ "version": "0.0.119-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",