@casual-simulation/aux-common
Advanced tools
Comparing version 0.9.11 to 0.9.12
@@ -62,2 +62,3 @@ export declare type PartialFile = Partial<File>; | ||
['aux.label.anchor']?: FileLabelAnchor | null | string; | ||
['aux.listening']?: unknown; | ||
['aux.input']?: string; | ||
@@ -81,3 +82,3 @@ ['aux.input.target']?: string; | ||
['aux.mod']?: unknown; | ||
['aux.mod.tags']?: unknown; | ||
['aux.mod.mergeTags']?: unknown; | ||
['aux.creator']?: string; | ||
@@ -84,0 +85,0 @@ ['aux._selection']?: string; |
@@ -119,2 +119,3 @@ /** | ||
'aux.label.anchor', | ||
'aux.listening', | ||
'aux.scale', | ||
@@ -121,0 +122,0 @@ 'aux.scale.x', |
@@ -613,2 +613,8 @@ import { Object, File, Workspace, AuxDomain, UserMode, SelectionMode, FileShape, FileTags, FileLabelAnchor, FileDragMode, ContextVisualizeMode, PrecalculatedFile, PrecalculatedTags, FilesState } from './File'; | ||
/** | ||
* Gets whether the given file is listening for shouts or whispers. | ||
* @param calc The calculation context. | ||
* @param file The file to check. | ||
*/ | ||
export declare function isFileListening(calc: FileCalculationContext, file: File): boolean; | ||
/** | ||
* Gets whether the given file's context is movable. | ||
@@ -762,3 +768,3 @@ * @param calc The calculation context. | ||
* Gets a partial file that can be used to apply the diff that the given file represents. | ||
* A diff file is any file that has `aux.mod` set to `true` and `aux.mod.tags` set to a list of tag names. | ||
* A diff file is any file that has `aux.mod` set to `true` and `aux.mod.mergeTags` set to a list of tag names. | ||
* @param calc The file calculation context. | ||
@@ -765,0 +771,0 @@ * @param file The file that represents the diff. |
@@ -598,3 +598,3 @@ import { DEFAULT_WORKSPACE_SCALE, DEFAULT_WORKSPACE_HEIGHT, DEFAULT_WORKSPACE_GRID_SCALE, DEFAULT_USER_MODE, DEFAULT_BUILDER_USER_COLOR, DEFAULT_PLAYER_USER_COLOR, DEFAULT_SELECTION_MODE, DEFAULT_FILE_SHAPE, DEFAULT_WORKSPACE_SIZE, DEFAULT_LABEL_ANCHOR, DEFAULT_USER_INACTIVE_TIME, DEFAULT_USER_DELETION_TIME, } from './File'; | ||
export function createContextId() { | ||
return `context_${shortUuid()}`; | ||
return `${shortUuid()}`; | ||
} | ||
@@ -1024,3 +1024,3 @@ /** | ||
val === 'drag' || | ||
val === 'mod') { | ||
val === 'cloneMod') { | ||
return val; | ||
@@ -1050,2 +1050,11 @@ } | ||
/** | ||
* Gets whether the given file is listening for shouts or whispers. | ||
* @param calc The calculation context. | ||
* @param file The file to check. | ||
*/ | ||
export function isFileListening(calc, file) { | ||
// checks if file is movable, but we should also allow it if it is pickupable so we can drag it into inventory if movable is false | ||
return calculateBooleanTagValue(calc, file, 'aux.listening', true); | ||
} | ||
/** | ||
* Gets whether the given file's context is movable. | ||
@@ -1266,8 +1275,6 @@ * @param calc The calculation context. | ||
if (calc) { | ||
return (!!file && | ||
calculateBooleanTagValue(calc, file, 'aux.mod', false) && | ||
!!file.tags['aux.mod.tags']); | ||
return !!file && calculateBooleanTagValue(calc, file, 'aux.mod', false); | ||
} | ||
else { | ||
return !!file && !!file.tags['aux.mod'] && !!file.tags['aux.mod.tags']; | ||
return !!file && !!file.tags['aux.mod']; | ||
} | ||
@@ -1295,3 +1302,3 @@ } | ||
* Gets a partial file that can be used to apply the diff that the given file represents. | ||
* A diff file is any file that has `aux.mod` set to `true` and `aux.mod.tags` set to a list of tag names. | ||
* A diff file is any file that has `aux.mod` set to `true` and `aux.mod.mergeTags` set to a list of tag names. | ||
* @param calc The file calculation context. | ||
@@ -1310,3 +1317,3 @@ * @param file The file that represents the diff. | ||
if (tag === 'aux.mod' || | ||
tag === 'aux.mod.tags' || | ||
tag === 'aux.mod.mergeTags' || | ||
tag === 'aux.movable.mod.tags' || | ||
@@ -1327,3 +1334,3 @@ diffTags.indexOf(tag) < 0) { | ||
let diffTags = calculateFileValue(calc, file, 'aux.movable.mod.tags') || | ||
calculateFileValue(calc, file, 'aux.mod.tags'); | ||
calculateFileValue(calc, file, 'aux.mod.mergeTags'); | ||
if (!diffTags) { | ||
@@ -1330,0 +1337,0 @@ return []; |
import { PartialFile, FilesState, File } from './File'; | ||
import { Vector2 } from 'three'; | ||
/** | ||
@@ -104,2 +105,3 @@ * Defines a union type for all the possible events that can be emitted from a files channel. | ||
zoomValue: number; | ||
rotationValue: Vector2; | ||
} | ||
@@ -347,3 +349,3 @@ /** | ||
*/ | ||
export declare function tweenTo(fileId: string, zoomValue?: number): TweenToEvent; | ||
export declare function tweenTo(fileId: string, zoomValue?: number, rotX?: number, rotY?: number): TweenToEvent; | ||
/** | ||
@@ -350,0 +352,0 @@ * Creates a new OpenQRCodeScannerEvent. |
@@ -0,1 +1,2 @@ | ||
import { Vector2 } from 'three'; | ||
/** | ||
@@ -102,9 +103,24 @@ * Creates a new FileAddedEvent. | ||
*/ | ||
export function tweenTo(fileId, zoomValue = -1) { | ||
return { | ||
type: 'local', | ||
name: 'tween_to', | ||
fileId: fileId, | ||
zoomValue: zoomValue, | ||
}; | ||
export function tweenTo(fileId, zoomValue = -1, rotX = null, rotY = null) { | ||
if (rotY != null && rotX != null && rotY > 0 && rotX === 0) { | ||
rotX = 1; | ||
} | ||
if (rotX === null || rotY === null) { | ||
return { | ||
type: 'local', | ||
name: 'tween_to', | ||
fileId: fileId, | ||
zoomValue: zoomValue, | ||
rotationValue: null, | ||
}; | ||
} | ||
else { | ||
return { | ||
type: 'local', | ||
name: 'tween_to', | ||
fileId: fileId, | ||
zoomValue: zoomValue, | ||
rotationValue: new Vector2(rotX / 180, rotY / 180), | ||
}; | ||
} | ||
} | ||
@@ -111,0 +127,0 @@ /** |
@@ -1,4 +0,5 @@ | ||
import { getActiveObjects, filtersMatchingArguments, calculateFileValue, } from './FileCalculations'; | ||
import { getActiveObjects, filtersMatchingArguments, calculateFileValue, isFileListening, } from './FileCalculations'; | ||
import { getActions, getCalculationContext, getFileState, getUserId, setActions, setFileState, setCalculationContext, } from '../Formulas/formula-lib-globals'; | ||
import { flatMap, sortBy } from 'lodash'; | ||
import { createCalculationContext } from './FileCalculationContextFactories'; | ||
/** | ||
@@ -13,2 +14,3 @@ * Calculates the set of events that should be run as the result of the given action using the given context. | ||
export function getFilesForAction(state, action) { | ||
//here | ||
const objects = getActiveObjects(state); | ||
@@ -18,2 +20,8 @@ const files = !!action.fileIds | ||
: objects; | ||
let calc = createCalculationContext(objects, action.userId); | ||
for (let i = files.length - 1; i >= 0; i--) { | ||
if (isFileListening(calc, files[i]) == false) { | ||
files.splice(i, 1); | ||
} | ||
} | ||
return { files, objects }; | ||
@@ -20,0 +28,0 @@ } |
@@ -276,3 +276,3 @@ import { File, FileTags } from '../Files/File'; | ||
*/ | ||
declare function tweenTo(file: File | string, zoomValue?: number): void; | ||
declare function tweenTo(file: File | string, zoomValue?: number, rotX?: number, rotY?: number): void; | ||
/** | ||
@@ -279,0 +279,0 @@ * Opens the QR Code Scanner. |
@@ -808,5 +808,5 @@ import { GLOBALS_FILE_ID } from '../Files/File'; | ||
*/ | ||
function tweenTo(file, zoomValue) { | ||
function tweenTo(file, zoomValue, rotX, rotY) { | ||
let actions = getActions(); | ||
actions.push(calcTweenTo(getFileId(file), zoomValue)); | ||
actions.push(calcTweenTo(getFileId(file), zoomValue, rotX, rotY)); | ||
} | ||
@@ -813,0 +813,0 @@ /** |
{ | ||
"name": "@casual-simulation/aux-common", | ||
"version": "0.9.11", | ||
"version": "0.9.12", | ||
"description": "Common library for AUX projects", | ||
@@ -36,3 +36,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@casual-simulation/causal-trees": "^0.9.7", | ||
"@casual-simulation/causal-trees": "^0.9.12", | ||
"@casual-simulation/crypto": "^0.9.7", | ||
@@ -57,3 +57,3 @@ "@types/acorn": "^4.0.5", | ||
], | ||
"gitHead": "4a5c09546ff57d6e14c085fdc9379bc208ddccc4" | ||
"gitHead": "b15b3789cda9dcd00a4c7137387d84d9b949ab12" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
443666
8879