Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
f015620
fix: change cytoscape layout
L4legenda Aug 25, 2023
9d8260b
update: rename deep.react-cytoscapejs
L4legenda Aug 25, 2023
85e000b
deeplinks is updated to 0.0.286
konard Aug 25, 2023
83d29b5
Better resolution mechanism globally for all deep clients.
konard Aug 25, 2023
2773e1c
0.0.74
konard Aug 25, 2023
f58a37b
eval and react client handler errors
ivansglazunov Aug 27, 2023
2214215
aframe components update
Romanxz Aug 29, 2023
2fd18a2
0.0.75
Romanxz Aug 29, 2023
387d453
node-sound update
Romanxz Aug 30, 2023
19f6620
0.0.76
Romanxz Aug 31, 2023
1ea4f04
recharts
ivansglazunov Sep 2, 2023
f83b542
0.0.77
ivansglazunov Sep 2, 2023
d78afa2
node version is updated to 18
konard Sep 2, 2023
02fcc67
node-sound update
Romanxz Sep 3, 2023
80c68b5
0.0.78
Romanxz Sep 3, 2023
0cf717a
+aframe-extras
Romanxz Sep 3, 2023
3e55777
0.0.79
Romanxz Sep 3, 2023
a78c031
Better support for Codespaces
konard Sep 4, 2023
023ffca
0.0.80
konard Sep 4, 2023
130fbf9
Update provider.tsx
konard Sep 4, 2023
704ab7e
Update provider.tsx
konard Sep 4, 2023
38c183f
0.0.81
flakeed Sep 4, 2023
9f4e27d
parseUrl is exported, more console output
konard Sep 6, 2023
4813453
0.0.82
konard Sep 6, 2023
1848af0
rm rh
konard Sep 6, 2023
5472691
dl295
konard Sep 6, 2023
381163c
0.0.83
konard Sep 6, 2023
26b8a12
checkSystemStatus now always uses deepcase proxy (that goes through e…
konard Sep 9, 2023
2ac8310
0.0.84
konard Sep 9, 2023
b4725e7
dl 0.0.302
ivansglazunov Sep 14, 2023
5e288e7
0.0.85
ivansglazunov Sep 14, 2023
534ce32
fetchPolicy no-cache
ivansglazunov Sep 14, 2023
b8c0f03
0.0.86
ivansglazunov Sep 14, 2023
55b7f42
package:watch
konard Sep 16, 2023
a331d63
GitPod badge
konard Sep 18, 2023
5dc1f28
Discord badge
konard Sep 18, 2023
17a2c21
aframe import + @aframe/types
Romanxz Sep 19, 2023
6f81acc
0.0.87
Romanxz Sep 19, 2023
84f43ff
0.0.88
ivansglazunov Sep 19, 2023
c2c839d
deep-foundation/deepcase
ivansglazunov Sep 19, 2023
e1763ec
fix
ivansglazunov Sep 19, 2023
efde84d
0.0.90
ivansglazunov Sep 19, 2023
061a639
fix
ivansglazunov Sep 19, 2023
30da967
0.0.91
ivansglazunov Sep 19, 2023
13dda86
"@deep-foundation/npm-automation": "^18.1.10"
FreePhoenix888 Sep 20, 2023
af7679b
"@deep-foundation/npm-automation": "^18.1.10"
FreePhoenix888 Sep 20, 2023
776f328
@chakra-ui/theme-tools
ivansglazunov Oct 1, 2023
60b713c
0.0.92
ivansglazunov Oct 1, 2023
952fb03
client-handler deps
ivansglazunov Oct 1, 2023
d8b4b9e
0.0.94
ivansglazunov Oct 1, 2023
dd1cdc0
import * as
ivansglazunov Oct 1, 2023
f159da5
0.0.95
ivansglazunov Oct 1, 2023
f930e44
Merge branch 'main' of github.com:L4legenda/deepcase
L4legenda Oct 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This configuration file was automatically generated by Gitpod.
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
# and commit this file to your remote git repository to share the goodness with others.

# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart

tasks:
- init: npm install


2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.16.1
18
2 changes: 1 addition & 1 deletion deep.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"package": {
"name": "@deep-foundation/deepcase",
"version": "0.0.73"
"version": "0.0.95"
},
"data": [
{
Expand Down
2 changes: 1 addition & 1 deletion imports/aframe/components/dragger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as THREE from "three";

AFRAME.registerComponent("dragger", {
init: function () {
const graph = document.querySelector("[forcegraph]");
const graph = document.getElementById("deepgraph");
const rightController = document.getElementById("right");
const leftController = document.getElementById("left");
this.dragDisabled = false; // Set true when both grips are pressed or both pinches are started
Expand Down
146 changes: 146 additions & 0 deletions imports/aframe/components/node-sound.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// @ts-nocheck
import AFRAME from "aframe";

AFRAME.registerComponent('node-sound', {
schema: {
id: { type: 'number', default: 1 },
wave: { type: 'string', default: 'sine' },
minFreq: { type: 'number', default: 200 },
maxFreq: { type: 'number', default: 3000 },
volume: { type: 'number', default: 0.5 },
panningModel: { type: "string", default: 'HRTF' },
distanceModel: { type: "string", default: 'inverse' },
refDistance: { type: 'number', default: 1 },
maxDistance: { type: 'number', default: 10000 },
rolloffFactor: { type: 'number', default: 1 },
coneInnerAngle: { type: 'number', default: 360 },
coneOuterAngle: { type: 'number', default: 360 },
coneOuterGain: { type: 'number', default: 1 },
throttle: { type: 'number', default: 0 },
timeout: { type: 'number', default: 1000 },
attack: { type: "number", default: 3.0 },
bufferSize: { type: 'number', default: 1024 },
sampleRate: { type: 'number', default: 44100 }
},

init: function () {
this.audioContext = new (window.AudioContext || window.webkitAudioContext)();
const self = this;
this.isSoundInitialized = false; // Flag to track if sound is initialized

if (self.data.id) {
// Set timeout before sound starts playing
setTimeout(function () {
const hash = function (id) {
let hashValue = 0;
const str = id.toString();
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i);
hashValue = ((hashValue << 5) - hashValue) + char;
hashValue |= 0; // Convert to 32bit integer
}
return Math.abs(hashValue) % 1000000; // Ensure positive value and limit the range
};

// Map the hashed value to the desired frequency range
const hashedValue = hash(self.data.id);
const normalizedHash = hashedValue / 1000000; // Since we limited the hash range to 1,000,000
const frequencyFloat = self.data.minFreq + normalizedHash * (self.data.maxFreq - self.data.minFreq);

// Round and clamp the frequency
const frequency = Math.round(frequencyFloat);
const clampedFrequency = Math.min(Math.max(frequency, self.data.minFreq), self.data.maxFreq);

// Set the oscillator options
self.oscillator = self.audioContext.createOscillator({
type: self.data.wave,
frequency: clampedFrequency,
bufferSize: self.data.bufferSize,
sampleRate: self.data.sampleRate
});

self.oscillator.frequency.setValueAtTime(clampedFrequency, self.audioContext.currentTime);

// Check if volume is finite, set to 0 if it's not
if (!isFinite(self.data.volume)) {
self.data.volume = 0;
}

self.panner = self.audioContext.createPanner();
self.panner.panningModel = self.data.panningModel;
self.panner.distanceModel = self.data.distanceModel;
self.panner.refDistance = self.data.refDistance;
self.panner.maxDistance = self.data.maxDistance;
self.panner.rolloffFactor = self.data.rolloffFactor;
self.panner.coneInnerAngle = self.data.coneInnerAngle;
self.panner.coneOuterAngle = self.data.coneOuterAngle;
self.panner.coneOuterGain = self.data.coneOuterGain;

// Create a gain node and ramp up the volume gradually
self.gainNode = self.audioContext.createGain();
self.gainNode.gain.setValueAtTime(0.0000001, self.audioContext.currentTime); // set to very low value to avoid clicks
self.gainNode.gain.exponentialRampToValueAtTime(self.data.volume, self.audioContext.currentTime + self.data.attack); // 3 second attack time

self.oscillator.connect(self.gainNode); // Connect to gain node instead of Panner
self.gainNode.connect(self.panner); // Then connect to Panner
self.panner.connect(self.audioContext.destination);

self.oscillator.start();

self.camera = document.getElementById('camera');
self.isSoundInitialized = true; // Flag that sound is initialized

if (self.data.throttle > 0) {
self.tick = AFRAME.utils.throttleTick(self.tick, self.data.throttle, self);
}
}, self.data.timeout); // Timeout value from component schema
}

},

tick: function () {
if (!this.isSoundInitialized) return; // Return if sound is not initialized

const { x, y, z } = this.el.getAttribute('position');

if (!this.lastPosition ||
(x !== this.lastPosition.x || y !== this.lastPosition.y || z !== this.lastPosition.z)) {
this.panner.setPosition(x, y, z);
this.lastPosition = { x, y, z };
}

if (this.camera && this.camera.object3D) {
const { x: cameraX, y: cameraY, z: cameraZ } = this.camera.getAttribute('position');
const cameraPosition = { x: cameraX, y: cameraY, z: cameraZ };

if (!this.lastCameraPosition ||
(cameraX !== this.lastCameraPosition.x || cameraY !== this.lastCameraPosition.y || cameraZ !== this.lastCameraPosition.z)) {
this.audioContext.listener.setPosition(cameraX, cameraY, cameraZ);
this.lastCameraPosition = cameraPosition;
}

const { x: rotationX, y: rotationY, z: rotationZ } = this.camera.getAttribute('rotation');
const rotation = { x: rotationX, y: rotationY, z: rotationZ };

if (!this.lastRotation ||
(rotationX !== this.lastRotation.x || rotationY !== this.lastRotation.y || rotationZ !== this.lastRotation.z)) {
const forwardVector = new THREE.Vector3().setFromEuler(new THREE.Euler(-this.degToRad(rotation.x), -this.degToRad(rotation.y), -this.degToRad(rotation.z), "YXZ"));
const upVector = new THREE.Vector3(0, 1, 0);
if (this.camera.object3D.quaternion) {
upVector.applyQuaternion(this.camera.object3D.quaternion);
this.audioContext.listener.setOrientation(forwardVector.x, forwardVector.y, forwardVector.z, upVector.x, upVector.y, upVector.z);
}
this.lastRotation = rotation;
}
}
},

degToRad: function (degrees) {
return degrees * Math.PI / 180;
},

remove: function () {
if (!this.isSoundInitialized) return;
this.oscillator.stop();
}
});
2 changes: 1 addition & 1 deletion imports/aframe/components/rotator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as THREE from "three";

AFRAME.registerComponent("rotator", {
init: function () {
const graph = document.querySelector("[forcegraph]");
const graph = document.getElementById("deepgraph");
const rightController = document.getElementById("right");
const leftController = document.getElementById("left");
this.rotationDisabled = false; // Set true when both grips are pressed
Expand Down
2 changes: 1 addition & 1 deletion imports/aframe/components/scaler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as THREE from "three";

AFRAME.registerComponent("scaler", {
init: function () {
this.graph = document.querySelector("[forcegraph]");
this.graph = document.getElementById("deepgraph");
const rightController = document.getElementById("right");
const leftController = document.getElementById("left");
this.resizeStarted = false; // Resizing starts with both hands or controllers are active.
Expand Down
103 changes: 83 additions & 20 deletions imports/client-handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,36 @@ import WordCloud from 'react-d3-cloud';
import ReactResizeDetector from 'react-resize-detector';
import queryStore from '@deep-foundation/store/query';
import localStore from '@deep-foundation/store/local';
import * as themeTools from '@chakra-ui/theme-tools';
import * as recharts from 'recharts';
import * as i18n from "i18next";
import * as LanguageDetector from 'i18next-browser-languagedetector';
import * as reacti18next from "react-i18next";
const MonacoEditor = dynamic(() => import('@monaco-editor/react').then(m => m.default), { ssr: false });


DeepClient.resolveDependency = async (path: string) : Promise<any> => {
if (path == 'peerjs') {
return await import('peerjs');
} else if (path == 'node-sound') {
return await import('./aframe/components/node-sound');
} else if (path == 'dragger') {
return await import('./aframe/components/dragger');
} else if (path == 'rotator') {
return await import('./aframe/components/rotator');
} else if (path == 'scaler') {
return await import('./aframe/components/scaler');
} else if (path == 'use-engine-tick') {
return await import('./aframe/components/tick');
} else if (path == 'el-movement') {
return await import('./aframe/components/el-movement');
} else if (path == 'aframe-extras') {
return await import('aframe-extras');
} else if (path == 'aframe') {
return await import('aframe');
} else {
return r(path);
}
};

export const r: any = (path) => {
if (r.list[path]) return r.list[path];
Expand Down Expand Up @@ -133,6 +160,11 @@ r.list = {
'react-resize-detector': ReactResizeDetector,
'@deep-foundation/store/query': queryStore,
'@deep-foundation/store/local': localStore,
'recharts': recharts,
'@chakra-ui/theme-tools': themeTools,
"i18next": i18n,
'i18next-browser-languagedetector': LanguageDetector,
"react-i18next": reacti18next,
};

export async function evalClientHandler({
Expand All @@ -147,17 +179,6 @@ export async function evalClientHandler({
error?: any;
data?: any;
}> {
(deep as any).import = async (path: string) : Promise<any> => {
if (path == 'peerjs') {
return await import('peerjs');
} else {
try {
return r(path);
} catch(e) {
return await import(path);
}
}
};
return await deepclientEvalClientHandler({
value, deep, input: {
require: r,
Expand Down Expand Up @@ -195,6 +216,7 @@ export interface ClientHandlerProps extends Partial<ClientHandlerRendererProps>
handlerId?: number;
context?: number[];
ml?: any;
error?: any;
onClose?: () => any,
}

Expand Down Expand Up @@ -243,6 +265,7 @@ export function ClientHandler(_props: ClientHandlerProps) {
ml,
onClose,
fillSize,
error: outerError,
...props
} = _props;
const deep = useDeep();
Expand All @@ -253,7 +276,7 @@ export function ClientHandler(_props: ClientHandlerProps) {
});
const file = files?.[0];

const [Component, setComponent] = React.useState<any>(null);
const [{ Component, errored } = {} as any, setState] = React.useState<any>({ Component: undefined, errored: undefined });

// console.log('ClientHandler root', { linkId, handlerId, context, file, hid, files, Component });
const lastEvalRef = useRef(0);
Expand All @@ -267,20 +290,60 @@ export function ClientHandler(_props: ClientHandlerProps) {
const evalId = ++lastEvalRef.current;
evalClientHandler({ value, deep }).then(({ data, error }) => {
if (evalId === lastEvalRef.current) {
console.log('ClientHandler evalClientHandler setComponent', { file, data, error });
if (!error) setComponent(() => data);
else setComponent(undefined);
console.log('ClientHandler evalClientHandler setState', { file, data, error });
if (!error) {
setState(() => ({ Component: data }));
erroredResetRef?.current && (erroredResetRef?.current(), erroredResetRef.current = undefined);
}
else {
setErrorRef.current && setErrorRef.current(error);
setState({ Component: undefined, errored: error });
}
} else {
console.log('ClientHandler evalClientHandler outdated', { file, data, error, evalId, 'lastEvalRef.current': lastEvalRef.current });
}
});
}, [file?.value?.value, hid]);

const erroredResetRef = useRef<any>();
const setErrorRef = useRef<any>();

return (<>
{(typeof (Component) === 'function')
? <><CatchErrors errorRenderer={() => <div></div>}>
<CatchErrors
error={errored || outerError}
errorRenderer={(error, reset) => {
erroredResetRef.current = reset;
return <div
style={{
...(fillSize ? { width: '100%', height: '100%' } : {
width: 500, maxHeight: 500
}),
overflow: 'scroll',
}}
><chakra.Alert
style={{
width: 'max-content',
}}
status='error'
variant='subtle'
flexDirection='column'
alignItems='left'
justifyContent='left'
textAlign='left'
>
<chakra.Button disabled={!Component} width="100%" onClick={reset}>reset</chakra.Button>
<chakra.AlertIcon />
<chakra.AlertTitle>{error?.message || (error || '')?.toString()}</chakra.AlertTitle>
{!!error?.stack && <chakra.AlertDescription>
<pre>{error?.stack}</pre>
</chakra.AlertDescription>}
</chakra.Alert></div>
}}
onMounted={(setError) => setErrorRef.current = setError}
>
{(typeof (Component) === 'function') ? <>
{[<ClientHandlerRenderer key={Component.toString()} Component={Component} {...props} fillSize={fillSize} link={_ml.byId[linkId]} ml={_ml} onClose={onClose} />]}
</CatchErrors></>
: <div></div>}
</> : <></>}
</CatchErrors>
</>);
}
Loading