Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async _pasteClipboard() {
if (navigator.clipboard) {
try {
const calc = appManager.simulationManager.primary.helper.createContext();
// TODO: Cleanup this function
const json = await navigator.clipboard.readText();
const stored: StoredCausalTree = JSON.parse(json);
let tree = new AuxCausalTree(stored);
await tree.import(stored);
const fileIds = keys(tree.value);
const interaction = this._game.getInteraction() as BuilderInteractionManager;
const mouseDir = Physics.screenPosToRay(
this._game.getInput().getMouseScreenPos(),
this._game.mainCameraRig.mainCamera
);
const point = Physics.pointOnPlane(
mouseDir,
new Plane(new Vector3(0, 1, 0))
);
let options: PasteStateOptions = {
x: point.x,
y: point.z,
z: point.y,
private async _pasteClipboard() {
if (navigator.clipboard) {
try {
const calc = appManager.simulationManager.primary.helper.createContext();
// TODO: Cleanup this function
const json = await navigator.clipboard.readText();
const stored: StoredCausalTree = JSON.parse(json);
let tree = new AuxCausalTree(stored);
await tree.import(stored);
const fileIds = keys(tree.value);
const interaction = this._game.getInteraction() as BuilderInteractionManager;
const mouseDir = Physics.screenPosToRay(
this._game.getInput().getMouseScreenPos(),
this._game.mainCameraRig.mainCamera
);
const point = Physics.pointOnPlane(
mouseDir,
new Plane(new Vector3(0, 1, 0))
);
let options: PasteStateOptions = {
x: point.x,
y: point.z,
z: point.y,
id: 'testUserId',
isGuest: false,
name: 'Test User Name',
username: 'testUserId',
token: 'token',
};
let testConfig = {
host: 'host',
config: {
isBuilder: false,
isPlayer: false,
},
id: 'id',
treeName: 'treeName',
};
let testTree = new AuxCausalTree(storedTree(site(1)));
await testTree.root();
let testChannel = new NodeAuxChannel(
testTree,
testUser,
testConfig
);
await testChannel.initAndWait();
await channel.sendEvents([
fileAdded(
createFile('channelFileId', {
'aux.channels': true,
'aux.channel': 'test',
})
),
user = {
id: 'user',
isGuest: false,
name: 'name',
token: 'token',
username: 'username',
};
device = {
claims: {
[USERNAME_CLAIM]: 'server',
[DEVICE_ID_CLAIM]: 'serverDeviceId',
[SESSION_ID_CLAIM]: 'serverSessionId',
},
roles: [SERVER_ROLE],
};
tree = new AuxCausalTree(storedTree(site(1)));
const config = { isBuilder: false, isPlayer: false };
const nodeChannel = new NodeAuxChannel(tree, user, device, {
config: config,
partitions: {
'*': {
type: 'causal_tree',
tree: tree,
id: 'test',
},
},
});
await tree.root();
const simulation = new NodeSimulation(
'test',
},
roles: [SERVER_ROLE],
};
store = new TestCausalTreeStore();
factory = auxCausalTreeFactory();
crypto = new TestCryptoImpl('ECDSA-SHA256-NISTP256');
crypto.valid = true;
manager = new AuxChannelManagerImpl(
user,
device,
store,
factory,
crypto,
[]
);
stored = new AuxCausalTree(storedTree(site(1)));
await stored.root();
store.put('test', stored.export());
});
beforeEach(async () => {
tree = new AuxCausalTree(storedTree(site(1)));
await tree.root();
});
beforeEach(async () => {
tree = new AuxCausalTree(storedTree(site(1)));
precalc = new PrecalculationManager(
() => tree.value,
() => createCalculationContext(values(tree.value), 'user')
);
await tree.root();
await tree.addFile(createFile('user'));
});
async downloadState(): Promise {
const stored = await this.simulationManager.primary.exportTree();
let tree = new AuxCausalTree(stored);
const channelId = this._simulationManager.primary.id;
await tree.import(stored);
downloadAuxState(tree, `${this.user.name}-${channelId || 'default'}`);
}
user = {
id: 'userId',
username: 'username',
isGuest: false,
name: 'name',
token: 'token',
};
device = {
claims: {
[USERNAME_CLAIM]: 'username',
[DEVICE_ID_CLAIM]: 'deviceId',
[SESSION_ID_CLAIM]: 'sessionId',
},
roles: [],
};
tree = new AuxCausalTree(storedTree(site(1)));
await tree.root();
channel = new AuxChannelImpl(tree, user, device, config);
});