@yeti-cgi/aux-common
Advanced tools
Comparing version 0.3.7 to 0.3.9
@@ -53,3 +53,3 @@ import { precalculatedOp } from "../causal-trees"; | ||
// TODO: Work with all domains | ||
return sortBy(diff.addedFiles, f => !f.tags['aux.builder.context'], f => f.id); | ||
return sortBy(diff.addedFiles, f => !f.tags['aux.builder.context'], f => !f.tags['aux.player.context'], f => f.id); | ||
})); | ||
@@ -56,0 +56,0 @@ const fileRemoved = stateDiffs.pipe(flatMap(diff => diff.removedFiles)); |
@@ -540,5 +540,10 @@ import { DEFAULT_WORKSPACE_SCALE, DEFAULT_WORKSPACE_HEIGHT, DEFAULT_WORKSPACE_GRID_SCALE, DEFAULT_USER_MODE, DEFAULT_WORKSPACE_COLOR } from './File'; | ||
if (parsed.success && parsed.eventName === eventName) { | ||
const calculatedValue = calculateFileValue(context, file, parsed.filter.tag); | ||
return calculatedValue === parsed.filter.value || | ||
(Array.isArray(parsed.filter.value) && isEqual(file.tags[parsed.filter.tag], parsed.filter.value)); | ||
if (!!parsed.filter) { | ||
const calculatedValue = calculateFileValue(context, file, parsed.filter.tag); | ||
return calculatedValue === parsed.filter.value || | ||
(Array.isArray(parsed.filter.value) && isEqual(file.tags[parsed.filter.tag], parsed.filter.value)); | ||
} | ||
else { | ||
return true; | ||
} | ||
} | ||
@@ -777,2 +782,14 @@ return false; | ||
} | ||
let lastParen = tag.lastIndexOf(')'); | ||
if (lastParen > firstParenIndex) { | ||
let between = tag.slice(firstParenIndex + 1, lastParen); | ||
// Only whitespace is allowed | ||
if (/^\s*$/.test(between)) { | ||
return { | ||
success: true, | ||
eventName: eventName, | ||
filter: null | ||
}; | ||
} | ||
} | ||
return { | ||
@@ -779,0 +796,0 @@ success: false, |
@@ -71,11 +71,7 @@ import { Event } from "../channels-core"; | ||
/** | ||
* The file that is "sending" the event. | ||
* | ||
* The IDs of the files that the event is being sent to. | ||
* If null, then the action is sent to every file. | ||
*/ | ||
senderFileId: string; | ||
fileIds: string[] | null; | ||
/** | ||
* The file that is "receiving" the event. | ||
*/ | ||
receiverFileId: string; | ||
/** | ||
* The name of the event. | ||
@@ -89,3 +85,3 @@ */ | ||
export declare function transaction(events: FileEvent[]): FileTransactionEvent; | ||
export declare function action(senderFileId: string, receiverFileId: string, eventName: string): Action; | ||
export declare function action(eventName: string, fileIds?: string[]): Action; | ||
export declare function addState(state: FilesState): ApplyStateEvent; |
@@ -0,1 +1,2 @@ | ||
import { flatMap } from 'lodash'; | ||
import { tagsMatchingFilter, createCalculationContext, calculateFileValue, convertToFormulaObject, getActiveObjects } from './FileCalculations'; | ||
@@ -11,24 +12,16 @@ import { merge as mergeObj } from '../utils'; | ||
const objects = getActiveObjects(state); | ||
const sender = state[action.senderFileId]; | ||
const receiver = state[action.receiverFileId]; | ||
const files = !!action.fileIds ? action.fileIds.map(id => state[id]) : objects; | ||
const context = createCalculationContext(objects); | ||
const firstEvents = eventActions(state, objects, context, sender, receiver, action.eventName); | ||
const secondEvents = eventActions(state, objects, context, receiver, sender, action.eventName); | ||
const events = [ | ||
...firstEvents, | ||
...secondEvents, | ||
fileUpdated(sender.id, { | ||
const fileEvents = flatMap(files, (f, index) => eventActions(state, objects, context, f, (files.length > 1 && index === 0) ? files[1] : files[0], action.eventName)); | ||
const events = fileEvents; | ||
if (action.eventName === '+') { | ||
events.push(...files.map(f => fileUpdated(f.id, { | ||
tags: { | ||
_destroyed: true | ||
} | ||
}), | ||
fileUpdated(receiver.id, { | ||
tags: { | ||
_destroyed: true | ||
} | ||
}) | ||
]; | ||
}))); | ||
} | ||
return { | ||
events, | ||
hasUserDefinedEvents: firstEvents.length > 0 || secondEvents.length > 0 | ||
hasUserDefinedEvents: fileEvents.length > 0 | ||
}; | ||
@@ -101,7 +94,6 @@ } | ||
} | ||
export function action(senderFileId, receiverFileId, eventName) { | ||
export function action(eventName, fileIds = null) { | ||
return { | ||
type: 'action', | ||
senderFileId, | ||
receiverFileId, | ||
fileIds, | ||
eventName, | ||
@@ -108,0 +100,0 @@ }; |
@@ -65,3 +65,9 @@ import { File, FileEvent, FilesState } from "../Files"; | ||
export declare function combine(first: File | string, second: File | string): void; | ||
export declare function event(name: string, first: File | string, second: File | string): void; | ||
export declare function event(name: string, files: (File | string)[]): void; | ||
/** | ||
* Shouts the given event to every file. | ||
* @param name The event name. | ||
*/ | ||
export declare function shout(name: string): void; | ||
export declare function goToContext(simulationId: string, context: string): void; | ||
declare const _default: { | ||
@@ -82,3 +88,5 @@ sum: typeof sum; | ||
event: typeof event; | ||
shout: typeof shout; | ||
goToContext: typeof goToContext; | ||
}; | ||
export default _default; |
@@ -190,12 +190,21 @@ import { action, calculateActionEvents } from "../Files"; | ||
export function combine(first, second) { | ||
event('+', first, second); | ||
event('+', [first, second]); | ||
} | ||
export function event(name, first, second) { | ||
export function event(name, files) { | ||
if (!!state) { | ||
let firstId = typeof first === 'string' ? first : first.id; | ||
let secondId = typeof second === 'string' ? second : second.id; | ||
let results = calculateActionEvents(state, action(firstId, secondId, name)); | ||
let ids = !!files ? files.map(f => typeof f === 'string' ? f : f.id) : null; | ||
let results = calculateActionEvents(state, action(name, ids)); | ||
actions.push(...results.events); | ||
} | ||
} | ||
/** | ||
* Shouts the given event to every file. | ||
* @param name The event name. | ||
*/ | ||
export function shout(name) { | ||
event(name, null); | ||
} | ||
export function goToContext(simulationId, context) { | ||
window.location.pathname = `${simulationId}/${context}`; | ||
} | ||
export default { | ||
@@ -215,4 +224,6 @@ sum, | ||
combine, | ||
event | ||
event, | ||
shout, | ||
goToContext | ||
}; | ||
//# sourceMappingURL=formula-lib.js.map |
{ | ||
"name": "@yeti-cgi/aux-common", | ||
"version": "0.3.7", | ||
"version": "0.3.9", | ||
"description": "Common library for AUX projects", | ||
@@ -59,3 +59,3 @@ "main": "index.js", | ||
], | ||
"gitHead": "3274e3a668f900a82c8da6c08dc99cc7c5cba38f" | ||
"gitHead": "fbbdaed2794918a1a42faf0e44efd1faf39f43c5" | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
385763
7511