How to use the @casual-simulation/aux-common.AuxCausalTree function in @casual-simulation/aux-common

To help you get started, we’ve selected a few @casual-simulation/aux-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github casual-simulation / aux / src / aux-server / aux-web / aux-projector / BuilderGameView / BuilderGameView.ts View on Github external
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,
github casual-simulation / aux / src / aux-server / aux-web / aux-projector / BuilderGameView / BuilderGameView.ts View on Github external
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,
github casual-simulation / aux / src / aux-vm-node / modules / AdminModule.spec.ts View on Github external
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',
                    })
                ),
github casual-simulation / aux / src / aux-vm-node / managers / AuxUserAuthorizer.spec.ts View on Github external
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',
github casual-simulation / aux / src / aux-vm-node / managers / AuxChannelManagerImpl.spec.ts View on Github external
},
            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());
    });
github casual-simulation / aux / src / aux-vm-node / vm / NodeAuxChannel.spec.ts View on Github external
beforeEach(async () => {
        tree = new AuxCausalTree(storedTree(site(1)));
        await tree.root();
    });
github casual-simulation / aux / src / aux-vm / managers / PrecalculationManager.spec.ts View on Github external
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'));
    });
github casual-simulation / aux / src / aux-server / aux-web / shared / AppManager.ts View on Github external
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'}`);
    }
github casual-simulation / aux / src / aux-vm / vm / BaseAuxChannel.spec.ts View on Github external
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);
    });