Skip to content

Commit 6d4eb06

Browse files
committed
0.0.6
1 parent c107437 commit 6d4eb06

File tree

6 files changed

+213
-22
lines changed

6 files changed

+213
-22
lines changed

README.md

+27-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,34 @@
55
[![Gitpod](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/deep-foundation/deepmemo-app)
66
[![Discord](https://badgen.net/badge/icon/discord?icon=discord&label&color=purple)](https://discord.gg/deep-foundation)
77

8-
## envs
8+
## ENVS
99

1010
```
1111
export NEXT_PUBLIC_GQL_PATH=localhost:3006/gql;
1212
export NEXT_PUBLIC_GQL_SSL=0;
13-
```
13+
```
14+
15+
## Description
16+
17+
All features from `deepmemo-imports` enabled and visulized in app.
18+
19+
Application support:
20+
21+
| Feature | web-chrome | web-safari | web-ios | web-android | app-ios | app-android | app-mac | app-win | app-linux |
22+
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
23+
| Device | 🟢 | 🟢 | 🟢 | 🔵 | 🔵 | 🔵 | 🟢 | 🔵 | 🔵 | 🔵 |
24+
| Geolocation | 🟢 | 🟢 | 🟢 | 🔵 | 🔵 | 🔵 | 🟢 | [🟠](https://github.com/ionic-team/capacitor/issues/1858) | [🟠](https://github.com/ionic-team/capacitor/issues/1858) | [🟠](https://github.com/ionic-team/capacitor/issues/1858) |
25+
| Voice | 🟢 | 🔵 | 🔵 | 🔵 | 🔵 | 🔵 | 🔵 | 🔵 | 🔵 | 🔵 |
26+
| Contacts | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 |
27+
| Camera | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 |
28+
| Action | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 |
29+
| Haptics | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 |
30+
| Motion | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 |
31+
| Network | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 |
32+
| Reader | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 | 🔴 |
33+
34+
- 🔴 not realized
35+
- 🟣 in process
36+
- 🟠 has problem, may be link to issue
37+
- 🔵 realized but not tested
38+
- 🟢 tested

next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const config = {
1717

1818
transpilePackages: ['@deep-foundation/deepmemo-imports'],
1919

20-
webpack: (config) => {
20+
webpack: (config) => {
2121
config.resolve.fallback = {
2222
"buffer":false,
2323
"events": false,

package-lock.json

+91
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@deep-foundation/deepmemo-app",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "",
55
"license": "Unlicense",
66
"main": "./bin/server.js",
@@ -37,6 +37,8 @@
3737
"@deep-foundation/deeplinks": "^0.0.343",
3838
"@deep-foundation/deepmemo-imports": "^0.0.6",
3939
"@solid-primitives/geolocation": "^1.4.14",
40+
"base64-blob": "^1.4.1",
41+
"capacitor-voice-recorder": "^5.0.0",
4042
"dotenv-load": "^2.0.1",
4143
"next": "^14.2.2",
4244
"next-env": "^1.1.1",

pages/_app.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { appWithTranslation } from 'next-i18next';
22
import { Provider } from '../src/provider';
3+
import c from 'crypto';
4+
import { v4 as uuidv4 } from 'uuid';
5+
6+
if (typeof(crypto) === 'object') {
7+
crypto.__proto__randomUUID = uuidv4;
8+
}
39

410
function App({ Component, pageProps }) {
511
return (

pages/index.tsx

+85-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {
2-
Box, Button, CircularProgress, CircularProgressLabel, FormControl, FormLabel, Heading, SimpleGrid,
2+
Box, Button, CircularProgress, CircularProgressLabel, FormControl, FormLabel, Heading, Input, SimpleGrid,
33
Slider,
44
SliderFilledTrack,
55
SliderMark,
@@ -16,6 +16,10 @@ import {
1616
DeviceProvider,
1717
useDevice
1818
} from '@deep-foundation/deepmemo-imports/imports/device';
19+
import {
20+
VoiceProvider,
21+
useVoice
22+
} from '@deep-foundation/deepmemo-imports/imports/voice';
1923
import {
2024
GeolocationProvider,
2125
useGeolocation
@@ -24,6 +28,7 @@ import React, { useEffect, useRef, useState } from 'react';
2428
import { Connection } from '../src/connection';
2529
import { i18nGetStaticProps } from '../src/i18n';
2630
import { SaverProvider } from '@deep-foundation/deepmemo-imports/imports/saver';
31+
import { useLocalStore } from '@deep-foundation/store/local';
2732

2833
const Loading = React.memo(function Loading({ factor, interval }: { factor: any, interval: number }) {
2934
const [value, setValue] = useState(0);
@@ -117,6 +122,58 @@ const GeolocationView = React.memo(function GeolocationView({ interval }: { inte
117122
</>;
118123
});
119124

125+
const VoiceView = React.memo(function VoiceView() {
126+
const deep = useDeep();
127+
const voice = useVoice();
128+
const [voices, setVoices] = useState([]);
129+
const [active, setActive] = useState(-1);
130+
return <>
131+
<Heading>Voice</Heading>
132+
<Box>
133+
{voices.map((v, i) => <Button key={i}
134+
onClick={() => setActive(id => i === id ? -1 : i)}
135+
variant={active === i ? 'solid' : 'outline'}
136+
>{v?.id || i}</Button>)}
137+
<Box>
138+
</Box>
139+
{active >= 0 && <audio controls>
140+
<source src={`data:audio/mpeg;base64,${voices[active]?.record}`} type="audio/mpeg"></source>
141+
</audio>}
142+
</Box>
143+
{voice.status ? (
144+
voice.recording ? (<>
145+
<Button onClick={async () => {
146+
const record = await voice.stop();
147+
setVoices(v => [...v, record]);
148+
}}>stop</Button>
149+
{voice.paused ? (
150+
<Button onClick={() => voice.pause()}>pause</Button>
151+
) : (
152+
<Button onClick={() => voice.resume()}>resume</Button>
153+
)}
154+
</>) : (
155+
<Button onClick={() => voice.start()}>start</Button>
156+
)
157+
) : (
158+
<Button onClick={() => voice.request()}>request</Button>
159+
)}
160+
</>;
161+
});
162+
163+
export function Syncing({ title, value, setValue }) {
164+
const deep = useDeep();
165+
return <FormControl display='flex' alignItems='center'>
166+
<FormLabel htmlFor='syncing' mb='0'>
167+
{title}
168+
</FormLabel>
169+
<Switch id='syncing'
170+
isChecked={value}
171+
onChange={() => setValue(s => !s)}
172+
disabled={!deep?.id}
173+
/>
174+
</FormControl>;
175+
}
176+
120177
export default function Page() {
121178
const deep = useDeep();
122179
const toast = useToast();
@@ -125,39 +182,49 @@ export default function Page() {
125182
if (typeof(window) === 'object') window.deep = deep;
126183
console.log('deep', deep);
127184

185+
const [containerId, setContainerId] = useLocalStore('deepmemo-app-containerId', null);
128186
const [deviceInterval, setDeviceInterval] = useState(5000);
187+
const [deviceSaver, setDeviceSaver] = useState(true);
129188
const [geolocationInterval, setGeolocationInterval] = useState(5000);
189+
const [geolocationSaver, setGeolocationSaver] = useState(true);
130190
const [saver, setSaver] = useState<boolean>(false);
131191
useEffect(() => {
132192
if (!deep) setSaver(false);
193+
else deep.local = false;
133194
}, [deep]);
134195

135196
return (<>
136197
<Connection/>
137198
<Box p={4}>
138-
<FormControl display='flex' alignItems='center'>
139-
<FormLabel htmlFor='syncing' mb='0'>
140-
Enable syncing with deep backend?
141-
</FormLabel>
142-
<Switch id='syncing'
143-
isChecked={saver}
144-
onChange={() => setSaver(s => !s)}
145-
disabled={!deep?.id}
146-
/>
147-
</FormControl>
199+
<Syncing title={'Enable syncing with deep backend?'} value={saver} setValue={setSaver}/>
200+
<FormControl display='flex' alignItems='center'>
201+
<FormLabel htmlFor='syncing' mb='0'>
202+
ContainerId
203+
</FormLabel>
204+
<Input
205+
placeholder={`${deep?.linkId}`}
206+
value={containerId} onChange={(e) => setContainerId(e.target.value)}
207+
w={'10em'}
208+
/>
209+
</FormControl>
148210
<SaverProvider onSave={({ Type, id, object, mode, promise }) => {
149211
toast.promise(promise, {
150212
success: { title: `Saved ${mode} #${id || '?'} of type (#${Type}) to deep`, isClosable: true },
151-
error: { title: `Error with saving ${mode} #${id || '?'} of type (#${Type}) to deep`, isClosable: true },
213+
error: (e) => ({ title: `Error with saving ${mode} #${id || '?'} of type (#${Type}) to deep`, description: e.toString(), isClosable: true }),
152214
loading: { title: `Saving ${mode} #${id || '?'} of type (#${Type}) to deep`, isClosable: true },
153215
})
154216
}}>
155-
<DeviceProvider saver={saver} containerId={deep?.linkId} interval={deviceInterval}>
156-
<GeolocationProvider saver={saver} interval={geolocationInterval}>
157-
<Interval value={deviceInterval} onChange={setDeviceInterval}/>
158-
<DeviceView interval={deviceInterval}/>
159-
<Interval value={geolocationInterval} onChange={setGeolocationInterval}/>
160-
<GeolocationView interval={geolocationInterval}/>
217+
<DeviceProvider saver={saver && deviceSaver} containerId={containerId} interval={deviceInterval}>
218+
<GeolocationProvider saver={saver && geolocationSaver} interval={geolocationInterval}>
219+
<VoiceProvider saver={saver}>
220+
<VoiceView/>
221+
<Interval value={deviceInterval} onChange={setDeviceInterval}/>
222+
<Syncing title={'Enable voice syncing with deep backend?'} value={deviceSaver} setValue={setDeviceSaver}/>
223+
<DeviceView interval={deviceInterval}/>
224+
<Interval value={geolocationInterval} onChange={setGeolocationInterval}/>
225+
<Syncing title={'Enable geolocation syncing with deep backend?'} value={geolocationSaver} setValue={setGeolocationSaver}/>
226+
<GeolocationView interval={geolocationInterval}/>
227+
</VoiceProvider>
161228
</GeolocationProvider>
162229
</DeviceProvider>
163230
</SaverProvider>

0 commit comments

Comments
 (0)