@etherealengine/hyperflux
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -34,3 +34,3 @@ | ||
'tests/mocha.env', // init env here | ||
'ts-node/register' | ||
'jsdom-global/register' | ||
], | ||
@@ -37,0 +37,0 @@ extension: [ |
@@ -48,2 +48,10 @@ # Change Log | ||
**Note:** Version bump only for package @etherealengine/hyperflux | ||
**Note:** Version bump only for package @xrengine/hyperflux | ||
@@ -50,0 +58,0 @@ |
@@ -31,6 +31,7 @@ /* | ||
import { PeerID } from '@etherealengine/common/src/interfaces/PeerID' | ||
import { UserId } from '@etherealengine/common/src/interfaces/UserId' | ||
import multiLogger from '@etherealengine/common/src/logger' | ||
import { deepEqual } from '@etherealengine/engine/src/common/functions/deepEqual' | ||
import multiLogger from '@etherealengine/engine/src/common/functions/logger' | ||
import { UserID } from '@etherealengine/engine/src/schemas/user/user.schema' | ||
import { InstanceID } from '@etherealengine/engine/src/schemas/networking/instance.schema' | ||
import { HyperFlux } from './StoreFunctions' | ||
@@ -51,3 +52,3 @@ | ||
export type ActionRecipients = UserId | UserId[] | 'all' | 'others' | ||
export type ActionRecipients = PeerID | PeerID[] | 'all' | 'others' | ||
@@ -82,4 +83,5 @@ export type ActionCacheOptions = | ||
* The id of the sender | ||
* @deprecated see getDispatchId | ||
*/ | ||
$from?: UserId | ||
$from?: UserID | ||
@@ -98,5 +100,14 @@ /** | ||
/** | ||
* The network type for which to send this action to | ||
*/ | ||
$topic?: Topic | ||
/** | ||
* Optionally specify the network to send this action to. | ||
* Specifying this will not send the action to other networks, even as a cached action. | ||
*/ | ||
$network?: InstanceID | undefined // TODO make a type for NetworkID | ||
/** | ||
* Specifies how this action should be cached for newly joining clients. | ||
@@ -218,2 +229,4 @@ */ | ||
*/ | ||
export const ActionDefinitions = {} as Record<string, any> | ||
function defineAction<Shape extends ActionShape<Action>>(actionShape: Shape) { | ||
@@ -285,2 +298,3 @@ type ResolvedAction = ResolvedActionType<Shape> | ||
ActionDefinitions[actionCreator.type as string] = actionCreator | ||
return actionCreator | ||
@@ -299,3 +313,3 @@ } | ||
action.$from = action.$from ?? (storeId as UserId) | ||
action.$from = action.$from ?? (storeId as UserID) | ||
action.$peer = action.$peer ?? (agentId as PeerID) | ||
@@ -379,2 +393,3 @@ action.$to = action.$to ?? 'all' | ||
for (const a of [...cachedActions]) { | ||
// TODO - is it safe to change $from to $peer here? | ||
if (a.$from === incomingAction.$from && a.type === incomingAction.type) { | ||
@@ -381,0 +396,0 @@ if (remove === true) { |
@@ -30,5 +30,5 @@ /* | ||
import { DeepReadonly } from '@etherealengine/common/src/DeepReadonly' | ||
import multiLogger from '@etherealengine/common/src/logger' | ||
import { resolveObject } from '@etherealengine/common/src/utils/resolveObject' | ||
import { isClient } from '@etherealengine/engine/src/common/functions/getEnvironment' | ||
import multiLogger from '@etherealengine/engine/src/common/functions/logger' | ||
@@ -41,4 +41,3 @@ import { | ||
defineActionQueue, | ||
removeActionQueue, | ||
ResolvedActionType | ||
removeActionQueue | ||
} from './ActionFunctions' | ||
@@ -68,6 +67,6 @@ import { HyperFlux, HyperStore } from './StoreFunctions' | ||
export function defineState<S>(definition: StateDefinition<S>) { | ||
export function defineState<S, StateExtras = unknown>(definition: StateDefinition<S> & StateExtras) { | ||
if (StateDefinitions.has(definition.name)) throw new Error(`State ${definition.name} already defined`) | ||
StateDefinitions.add(definition.name) | ||
return definition as StateDefinition<S> & { _TYPE: S } | ||
return definition as StateDefinition<S> & { _TYPE: S } & StateExtras | ||
} | ||
@@ -80,3 +79,3 @@ | ||
typeof StateDefinition.initial === 'function' | ||
? (StateDefinition.initial as Function)() | ||
? (StateDefinition.initial as any)() | ||
: JSON.parse(JSON.stringify(StateDefinition.initial)) | ||
@@ -83,0 +82,0 @@ HyperFlux.store.valueMap[StateDefinition.name] = initial |
@@ -28,3 +28,2 @@ /* | ||
import { merge } from 'lodash' | ||
import { Validator } from 'ts-matches' | ||
@@ -31,0 +30,0 @@ import { |
@@ -27,4 +27,4 @@ /* | ||
export * from './functions/ActionFunctions' | ||
export * from './functions/ReactorFunctions' | ||
export * from './functions/StateFunctions' | ||
export * from './functions/StoreFunctions' | ||
export * from './functions/ReactorFunctions' |
{ | ||
"name": "@etherealengine/hyperflux", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"main": "index.ts", | ||
@@ -30,3 +30,3 @@ "description": "State Management for Ethereal Engine", | ||
}, | ||
"gitHead": "7971db41683055b7f5182c902cdb45884280000b" | ||
"gitHead": "0feb543315062e51548b551ce6d50f7c14e2eb38" | ||
} |
@@ -28,4 +28,4 @@ /* | ||
import { UserId } from '@etherealengine/common/src/interfaces/UserId' | ||
import { matches, matchesWithDefault } from '@etherealengine/engine/src/common/functions/MatchesUtils' | ||
import { UserID } from '@etherealengine/engine/src/schemas/user/user.schema' | ||
@@ -41,3 +41,2 @@ import { | ||
getMutableState, | ||
getState, | ||
registerState, | ||
@@ -316,3 +315,3 @@ removeActionReceptor | ||
dispatchAction(greet({ $from: 'differentUser' as UserId, $cache: { removePrevious: true } })) | ||
dispatchAction(greet({ $from: 'differentUser' as UserID, $cache: { removePrevious: true } })) | ||
applyIncomingActions() | ||
@@ -327,3 +326,3 @@ assert.equal(receivedCount, 12) | ||
dispatchAction(greet({ $from: 'differentUser' as UserId, $cache: { removePrevious: true, disable: true } })) | ||
dispatchAction(greet({ $from: 'differentUser' as UserID, $cache: { removePrevious: true, disable: true } })) | ||
applyIncomingActions() | ||
@@ -330,0 +329,0 @@ assert.equal(receivedCount, 14) |
@@ -27,6 +27,12 @@ | ||
process.env.APP_ENV = 'test' | ||
process.env.NODE_ENV = 'test' | ||
process.env.NODE_TLS_REJECT_UNAUTHORIZED='0' | ||
process.env.APP_ENV = 'test' | ||
process.env.TS_NODE_FILES = true | ||
process.env.TS_NODE_PROJECT = 'tsconfig.json' | ||
process.env.TS_NODE_COMPILER_OPTIONS = '{\"module\": \"commonjs\" }' | ||
require("ts-node").register({ | ||
project: './tsconfig.json', | ||
files: true, | ||
swc: true | ||
}) | ||
require("fix-esm").register() |
@@ -39,2 +39,3 @@ { | ||
"include": [ | ||
"../../__global.d.ts", | ||
"../server-core/src/", | ||
@@ -41,0 +42,0 @@ "./**/*.ts", |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances 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
94107
12
1566
3