-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdeep.json
256 lines (256 loc) · 16.8 KB
/
deep.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
{
"package": {
"name": "@deep-foundation/deepcase",
"version": "0.0.135"
},
"data": [
{
"package": {
"dependencyId": 0,
"containValue": "TSX"
},
"id": 1
},
{
"package": {
"dependencyId": 1,
"containValue": "Handler"
},
"id": 2
},
{
"package": {
"dependencyId": 1,
"containValue": "clientSupportsJs"
},
"id": 3
},
{
"package": {
"dependencyId": 1,
"containValue": "HandleClient"
},
"id": 4
},
{
"package": {
"dependencyId": 1,
"containValue": "AsyncFile"
},
"id": 5
},
{
"package": {
"dependencyId": 1,
"containValue": "Type"
},
"id": 6
},
{
"package": {
"dependencyId": 1,
"containValue": "Any"
},
"id": 7
},
{
"package": {
"dependencyId": 1,
"containValue": "Query"
},
"id": 8
},
{
"package": {
"dependencyId": 1,
"containValue": "Symbol"
},
"id": 9
},
{
"package": {
"dependencyId": 1,
"containValue": "Join"
},
"id": 10
},
{
"package": {
"dependencyId": 1,
"containValue": "PackageQuery"
},
"id": 11
},
{
"package": {
"dependencyId": 1,
"containValue": "Contain"
},
"id": 12
},
{
"package": {
"dependencyId": 1,
"containValue": "SyncTextFile"
},
"id": 13
},
{
"id": "asyncFileClientHandler",
"type": 1,
"value": {
"value": "({ deep, require }) => {\n const React = require('react');\n const { useState } = require('react');\n const axiosHooks = require(\"axios-hooks\");\n const axios = require(\"axios\");\n const useAxios = axiosHooks.makeUseAxios({ axios: axios.create() });\n\n return ({ fillSize, style, link }) => {\n\n const ssl = deep.apolloClient.ssl;\n const path = deep.apolloClient.path.slice(0, -4);\n const url = `${ssl ? \"https://\" : \"http://\"}${path}/file?linkId=${link.id}`;\n\n const [{ data, loading, error }, refetch] = useAxios({ \n method: 'get',\n url,\n headers: {\n 'Authorization': `Bearer ${deep.token}`\n },\n \n responseType: \"blob\",\n });\n\n const [src, setSrc] = useState(\"test\");\n if (!loading && data) {\n const reader = new window.FileReader();\n reader.onload = () => {\n setSrc(reader.result);\n }\n reader.readAsDataURL(data);\n }\n\n const renderMedia = () => {\n if (src.startsWith('data:image')) {\n return <img src={src} alt=\"An image from Deep file storage.\" style={style}></img>;\n } else if (src.startsWith('data:audio')) {\n return <audio src={src} controls style={style}>Your browser does not support the audio element.</audio>;\n } else {\n return <div>Unsupported file type.</div>;\n }\n } \n\n return renderMedia();\n }\n}\n"
}
},
{
"id": "asyncFileHandler",
"type": 2,
"from": 3,
"to": "asyncFileClientHandler"
},
{
"id": "asyncFileHandleClient",
"type": 4,
"from": 5,
"to": "asyncFileHandler"
},
{
"id": "Traveler",
"type": 6,
"from": 7,
"to": 8
},
{
"id": "travelerSymbol",
"type": 9,
"from": "Traveler",
"to": "Traveler",
"value": {
"value": "🧳"
}
},
{
"id": "ContextToken",
"type": 6
},
{
"id": "Context",
"type": 6,
"from": "ContextToken",
"to": 2
},
{
"id": "stringClientHandler",
"type": 1,
"value": {
"value": "({ deep, require }) => {\n const React = require('react');\n const { useState, useEffect } = React;\n const json5 = require('json5');\n const { Input, useColorModeValue } = require('@chakra-ui/react');\n const { useHotkeys } = require('react-hotkeys-hook');\n const { useDebounceCallback } = require('@react-hook/debounce');\n const { useContainer } = require('@deep-foundation/deepcase');\n // Only string editor.\n return ({ fillSize, style, link, onClose }) => {\n \n \n const currentValue = deep.stringify(link?.value?.value) || '';\n const [value, setValue] = useState(currentValue);\n const save = async (value) => {\n if (!link.value) await deep.insert({\n link_id: link.id, value: value,\n }, { table: 'strings' });\n deep.update({ link_id: link.id }, { value: value }, { table: 'strings' });\n \n };\n const ref = useHotkeys('enter', async () => {\n await save(value);\n onClose && onClose();\n }, { enableOnTags: [\"INPUT\"] });\n \n const setValuesDebounced = useDebounceCallback(async(value) => {await save(value)}, 500);\n\n useEffect(() => {\n setValuesDebounced(value);\n }, [value])\n\n const bg = useColorModeValue('#eeeeee', '#434343');\n const hover = useColorModeValue('white', '#1e1e1e');\n const borderColor = useColorModeValue('#434343', '#eeeeee');\n const color = useColorModeValue('#1e1e1e', 'white');\n\n return <div\n style={{\n width: 300,\n ...style,\n position: 'relative', \n // background: 'red'\n }}\n >\n <Input\n ref={ref}\n autoFocus\n type=\"text\"\n variant='filled'\n variant='filled'\n bg={bg}\n color={color}\n borderWidth='thin'\n borderColor={borderColor}\n _hover={{bg: hover}}\n _focus={{bg: bg}}\n sx={{\n width: '100%',\n }}\n onChange={(e) => setValue(e.target.value)}\n value={value}\n />\n </div>;\n }\n }"
}
},
{
"id": "stringHandler",
"type": 2,
"from": 3,
"to": "stringClientHandler",
"value": {
"value": ""
}
},
{
"id": "stringJoinHandleClient",
"type": 4,
"from": 10,
"to": "stringHandler",
"value": {
"value": ""
}
},
{
"id": "stringPackageQueryHandleClient",
"type": 4,
"from": 11,
"to": "stringHandler",
"value": {
"value": ""
}
},
{
"id": "stringContainHandleClient",
"type": 4,
"from": 12,
"to": "stringHandler",
"value": {
"value": ""
}
},
{
"id": "queryClientHandler",
"type": 1,
"value": {
"value": "({ deep, require }) => {\n const React = require('react');\n const { useState, useEffect } = React;\n const json5 = require('json5');\n const { useContainer, Resize, CustomizableIcon } = require('@deep-foundation/deepcase');\n const MonacoEditor = require('@monaco-editor/react');\n const { Box, IconButton, useColorModeValue, useColorMode } = require('@chakra-ui/react');\n const { BsCheck2, BsLightbulbFill, BsLightbulbOff } = require('react-icons/bs');\n const { motion, useAnimation } = require('framer-motion');\n\n const variants = {\n view: {\n opacity: 1,\n scale: 1,\n transition: {\n duration: 1,\n delay: 0.3,\n scale: { delay: 0.5, } \n }\n },\n hide: {\n opacity: 0, \n scale: 0,\n transition: {\n type: 'spring'\n }\n },\n initial: {\n originX: 1,\n opacity: 1,\n scale: 1,\n }\n };\n \n const stackVariants = {\n outside: {\n x: '0%',\n opacity: 1,\n scale: 1,\n originX: 0,\n transition: {\n type: 'spring',\n\n duration: 0.5,\n delay: 0.2,\n scale: { delay: 0.3, }\n }\n },\n nested: {\n x: '-100%',\n opacity: 1,\n scale: 1,\n originX: 1,\n transition: {\n type: 'spring',\n duration: 0.5,\n delay: 0.2,\n scale: { delay: 0.3, }\n }\n },\n initial: {\n x: '0%',\n opacity: 0,\n scale: 0,\n }\n };\n \n // Only objects editor.\n return ({ fillSize, style, link }) => {\n const currentValue = deep.stringify(link?.value?.value) || '';\n const [value, setValue] = useState(currentValue);\n const isSaved = value == currentValue;\n const [container] = useContainer();\n const { data } = deep.useDeepSubscription({\n type_id: { _in: [\n deep.idLocal('@deep-foundation/core', 'Active'),\n deep.idLocal('@deep-foundation/core', 'Contain'),\n ] },\n to_id: { _eq: link.id },\n });\n const contain = data?.find(l => l.type_id === deep.idLocal('@deep-foundation/core', 'Contain'))\n const active = data?.find(l => l.type_id === deep.idLocal('@deep-foundation/core', 'Active'))\n\n const [viewSize, setViewSize] = useState({width: 300, height: 300});\n const terminalBorderWidth = viewSize.width - 1;\n const terminalBorderHeight = viewSize.height - 1;\n\n const control = useAnimation();\n const controlStack = useAnimation();\n\n useEffect(() => {\n if (value) {\n control.start('view')\n } else {\n control.start('hide')\n };\n if (fillSize === true) {\n controlStack.start('nested')\n } else {\n // controlStack.start('initial')\n controlStack.start('outside')\n };\n\n }, [control, controlStack, value, fillSize])\n\n const { colorMode } = useColorMode();\n\n const body = <div\n style={{\n width: viewSize.width,\n height: viewSize.height,\n ...style,\n position: 'relative',\n }}\n >\n <Box \n position='relative'\n display='grid' \n gridTemplateColumns='1fr max-content' \n height='inherit'\n >\n <Box\n position='relative'\n overflow='hidden' sx={{ borderRadius: 5 }}\n border='1px dashed #605c60'\n > \n <MonacoEditor\n options={{\n minimap: {\n enabled: false\n },\n lineNumbers: 'off',\n wordWrap: true,\n }}\n height=\"100%\"\n width=\"100%\"\n theme={colorMode === 'light' ? 'light' : \"vs-dark\"}\n defaultLanguage=\"json\"\n defaultValue={value || ''}\n onChange={(value) => setValue(value)}\n // onMount={handleEditorDidMount}\n />\n </Box>\n <Box\n as={motion.div}\n animate={controlStack}\n variants={stackVariants}\n initial='initial'\n // height={stackHeight}\n height={fillSize ? '100%' : viewSize.height}\n display='flex'\n justifyContent='space-between'\n flexDirection='column'\n ml={fillSize ? 0 : '0.2rem'}\n >\n <IconButton \n as={motion.div}\n variants={variants}\n initial='initial'\n // whileInView='view'\n animate='view'\n aria-label='activate/inactivate button' \n bg={active && colorMode === 'dark' ? 'gray.700' : 'blue.50'}\n _hover={{\n bg: 'blue.100'\n }}\n isRound\n variant='outline'\n sx={{ borderColor: active ? '#111' : 'rgb(0, 128, 255)' }}\n mr={fillSize ? '0.2rem' : 0}\n mt={fillSize ? '0.2rem' : 0}\n size='xs'\n onClick={async () => {\n if (active) {\n await deep.delete({\n _or: [{\n id: { _eq: active?.id },\n }, {\n type_id: deep.idLocal('@deep-foundation/core', 'Contain'),\n from_id: link.id,\n to_id: active.id,\n }],\n });\n } else {\n await deep.insert({\n type_id: deep.idLocal('@deep-foundation/core', 'Active'),\n from_id: contain.from_id,\n to_id: contain.to_id,\n in: { data: {\n type_id: deep.idLocal('@deep-foundation/core', 'Contain'),\n from_id: link.id,\n } },\n });\n }\n }}\n icon={active ? <BsLightbulbOff /> : <CustomizableIcon Component={BsLightbulbFill} value={{ color: 'rgb(0, 128, 255)' }} />}\n />\n <IconButton \n as={motion.div}\n variants={variants}\n initial='initial'\n animate={control}\n whileInView='view'\n // isDisabled={isSaved}\n aria-label='save button' \n isRound\n bg='blue.50'\n _hover={{\n bg: 'blue.100'\n }}\n variant='outline'\n sx={{ borderColor: 'rgb(0, 128, 255)' }}\n mr={fillSize ? '0.2rem' : 0}\n mb={fillSize ? '0.2rem' : 0}\n // isLoading={!isSaved}\n size='xs'\n icon={<CustomizableIcon Component={BsCheck2} value={{ color: 'rgb(0, 128, 255)' }} />}\n onClick={() => {\n try {\n const _value = json5.parse(value);\n if (!link.value) deep.insert({\n link_id: link.id, value: _value,\n }, { table: 'objects' });\n deep.update({ link_id: link.id }, { value: _value }, { table: 'objects' });\n } catch(error) {}\n }}\n />\n </Box>\n </Box>\n </div>;\n\n return <>\n {fillSize \n ? body \n : <Resize\n onChangeSize={(viewSize) => setViewSize(viewSize)} \n style={{\n // position: 'relative',\n // overflow: nested ? 'hidden' : 'inherit',\n borderRadius: 5,\n border: 'none',\n }}\n >{body}</Resize>}\n </>;\n }\n }\n"
}
},
{
"id": "queryHandler",
"type": 2,
"from": 3,
"to": "queryClientHandler",
"value": {
"value": ""
}
},
{
"id": "queryHandleClient",
"type": 4,
"from": 8,
"to": "queryHandler",
"value": {
"value": ""
}
},
{
"id": "editorClientHandler",
"type": 1,
"value": {
"value": "({ deep, require }) => {\n const React = require('react');\n const { useState } = React;\n const json5 = require('json5');\n const { useContainer, CytoEditorPreview } = require('@deep-foundation/deepcase');\n const { Box, SimpleGrid } = require('@chakra-ui/react');\n // Only objects editor.\n return ({ fillSize, style, link }) => {\n const currentValue = deep.stringify(link?.value?.value) || '';\n const [value, setValue] = useState(currentValue);\n const isSaved = value == currentValue;\n const [container] = useContainer();\n const { data } = deep.useDeepSubscription({\n type_id: { _in: [\n deep.idLocal('@deep-foundation/core', 'Active'),\n deep.idLocal('@deep-foundation/core', 'Contain'),\n ] },\n to_id: { _eq: link.id },\n });\n const contain = data?.find(l => l.type_id === deep.idLocal('@deep-foundation/core', 'Contain'))\n const active = data?.find(l => l.type_id === deep.idLocal('@deep-foundation/core', 'Active'))\n return <div\n style={{\n width: 600,\n height: 600,\n ...style,\n position: 'relative',\n }}\n >\n <CytoEditorPreview link={link} compact/>\n </div>;\n }\n}"
}
},
{
"id": "editorHandler",
"type": 2,
"from": 3,
"to": "editorClientHandler",
"value": {
"value": ""
}
},
{
"id": "editorHandleClientTSX",
"type": 4,
"from": 13,
"to": "editorHandler",
"value": {
"value": ""
}
},
{
"id": "editorHandleClientSyncTextFile",
"type": 4,
"from": 1,
"to": "editorHandler",
"value": {
"value": ""
}
}
],
"errors": [],
"dependencies": [
{
"name": "@deep-foundation/tsx",
"version": "0.0.5"
},
{
"name": "@deep-foundation/core",
"version": "0.0.2"
}
]
}