Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@casual-simulation/aux-vm

Package Overview
Dependencies
Maintainers
2
Versions
476
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@casual-simulation/aux-vm - npm Package Compare versions

Comparing version 0.9.25 to 0.9.26

6

package.json
{
"name": "@casual-simulation/aux-vm",
"version": "0.9.25",
"version": "0.9.26",
"description": "A set of abstractions required to securely run an AUX.",

@@ -43,3 +43,3 @@ "keywords": [

"dependencies": {
"@casual-simulation/aux-common": "^0.9.25",
"@casual-simulation/aux-common": "^0.9.26",
"@casual-simulation/causal-tree-client-socketio": "^0.9.21",

@@ -53,3 +53,3 @@ "@casual-simulation/causal-tree-store-browser": "^0.9.21",

},
"gitHead": "73a4f29e2d375629fd9b297419f852ef0d47068f"
"gitHead": "ebae83bcf708102964d9c12755fb98f430268224"
}

@@ -69,3 +69,5 @@ import { AuxCausalTree, SandboxLibrary, LocalEvents, AuxFile, FileEvent, File, PartialFile, FileSandboxContext, Sandbox, AuxOp, FormulaLibraryOptions } from '@casual-simulation/aux-common';

private _pasteState;
private _pasteExistingWorksurface;
private _pasteNewWorksurface;
}
//# sourceMappingURL=AuxHelper.d.ts.map

@@ -9,6 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
import { createCalculationContext, createFile, updateFile, merge, AUX_FILE_VERSION, calculateFormulaEvents, calculateActionEvents, DEFAULT_USER_MODE, getFileConfigContexts, createWorkspace, createContextId, duplicateFile, cleanFile, addState, searchFileState, createFormulaLibrary, } from '@casual-simulation/aux-common';
import { createCalculationContext, createFile, updateFile, merge, AUX_FILE_VERSION, calculateFormulaEvents, calculateActionEvents, DEFAULT_USER_MODE, getFileConfigContexts, createWorkspace, createContextId, duplicateFile, cleanFile, searchFileState, createFormulaLibrary, addToContextDiff, fileAdded, filterWellKnownAndContextTags, tagsOnFile, } from '@casual-simulation/aux-common';
import { storedTree, } from '@casual-simulation/causal-trees';
import { Subject } from 'rxjs';
import { flatMap } from 'lodash';
import { flatMap, fromPairs } from 'lodash';
import { BaseHelper } from '../managers/BaseHelper';

@@ -186,3 +186,3 @@ /**

else if (event.type === 'paste_state') {
resultEvents.push(this._pasteState(event));
resultEvents.push(...this._pasteState(event));
}

@@ -226,55 +226,66 @@ else {

const oldFiles = fileIds.map(id => value[id]);
const calc = createCalculationContext(oldFiles, this.userId, this._lib, this._sandboxFactory);
// Grab the old worksurface
// and map everything into a new context
// where they keep their relative positions
const oldWorksurface = oldFiles.find(f => getFileConfigContexts(calc, f).length > 0) ||
createWorkspace();
const oldContexts = getFileConfigContexts(calc, oldWorksurface);
const contextMap = new Map();
let newContexts = [];
oldContexts.forEach(c => {
const context = createContextId();
newContexts.push(context);
contextMap.set(c, context);
});
let worksurface = duplicateFile(calc, oldWorksurface);
oldContexts.forEach(c => {
let newContext = contextMap.get(c);
worksurface.tags[c] = null;
worksurface.tags['aux.context'] = newContext;
worksurface.tags['aux.context.visualize'] = 'surface';
worksurface.tags[newContext] = true;
});
worksurface = cleanFile(worksurface);
worksurface.tags['aux.context.x'] = event.x;
worksurface.tags['aux.context.y'] = event.z;
worksurface.tags['aux.context.z'] = event.y;
state[worksurface.id] = worksurface;
for (let i = 0; i < fileIds.length; i++) {
const file = value[fileIds[i]];
if (file.id === oldWorksurface.id) {
const oldCalc = createCalculationContext(oldFiles, this.userId, this._lib, this._sandboxFactory);
const newCalc = this.createContext();
if (event.options.context) {
return this._pasteExistingWorksurface(oldFiles, oldCalc, event, newCalc);
}
else {
return this._pasteNewWorksurface(oldFiles, oldCalc, event, newCalc);
}
}
_pasteExistingWorksurface(oldFiles, oldCalc, event, newCalc) {
let events = [];
// Preserve positions from old context
for (let oldFile of oldFiles) {
const tags = tagsOnFile(oldFile);
const tagsToRemove = filterWellKnownAndContextTags(newCalc, tags);
const removedValues = tagsToRemove.map(t => [t, null]);
let newFile = duplicateFile(oldCalc, oldFile, {
tags: Object.assign({}, fromPairs(removedValues), addToContextDiff(newCalc, event.options.context, event.options.x, event.options.y), { [`${event.options.context}.z`]: event.options.z }),
});
events.push(fileAdded(cleanFile(newFile)));
}
return events;
}
_pasteNewWorksurface(oldFiles, oldCalc, event, newCalc) {
const oldContextFiles = oldFiles.filter(f => getFileConfigContexts(oldCalc, f).length > 0);
const oldContextFile = oldContextFiles.length > 0 ? oldContextFiles[0] : null;
const oldContexts = oldContextFile
? getFileConfigContexts(oldCalc, oldContextFile)
: [];
let oldContext = oldContexts.length > 0 ? oldContexts[0] : null;
let events = [];
const context = createContextId();
let workspace;
if (oldContextFile) {
workspace = duplicateFile(oldCalc, oldContextFile, {
tags: {
'aux.context': context,
},
});
}
else {
workspace = createWorkspace(undefined, context);
}
workspace.tags['aux.context.x'] = event.options.x;
workspace.tags['aux.context.y'] = event.options.y;
workspace.tags['aux.context.z'] = event.options.z;
events.push(fileAdded(workspace));
if (!oldContext) {
oldContext = context;
}
// Preserve positions from old context
for (let oldFile of oldFiles) {
if (oldContextFile && oldFile.id === oldContextFile.id) {
continue;
}
let newFile = duplicateFile(calc, file);
oldContexts.forEach(c => {
let newContext = contextMap.get(c);
newFile.tags[c] = null;
let x = file.tags[`${c}.x`];
let y = file.tags[`${c}.y`];
let z = file.tags[`${c}.z`];
let index = file.tags[`${c}.sortOrder`];
newFile.tags[`${c}.x`] = null;
newFile.tags[`${c}.y`] = null;
newFile.tags[`${c}.z`] = null;
newFile.tags[`${c}.sortOrder`] = null;
newFile.tags[newContext] = true;
newFile.tags[`${newContext}.x`] = x;
newFile.tags[`${newContext}.y`] = y;
newFile.tags[`${newContext}.z`] = z;
newFile.tags[`${newContext}.sortOrder`] = index;
const tags = tagsOnFile(oldFile);
const tagsToRemove = filterWellKnownAndContextTags(newCalc, tags);
const removedValues = tagsToRemove.map(t => [t, null]);
let newFile = duplicateFile(oldCalc, oldFile, {
tags: Object.assign({}, fromPairs(removedValues), addToContextDiff(newCalc, context, oldFile.tags[`${oldContext}.x`], oldFile.tags[`${oldContext}.y`], oldFile.tags[`${oldContext}.sortOrder`]), { [`${context}.z`]: oldFile.tags[`${oldContext}.z`] }),
});
state[newFile.id] = cleanFile(newFile);
events.push(fileAdded(cleanFile(newFile)));
}
return addState(state);
return events;
}

@@ -281,0 +292,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc