Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deck Usage Consistency #242

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ When in doubt simplify.
* [Muxified Turing Machine](https://github.com/Phuire-Research/Stratimux/blob/main/The-Muxified-Turing-Machine.md) - The governing concept for this entire framework.:|

## Change Log ![Tests](https://github.com/Phuire-Research/Stratimux/actions/workflows/node.js.yml/badge
### QoL
### QoL 0.2.42
* Broke up complex files into distinguishable parts
* Hooked in deck functionality into method creators properly
* muxium_createStitchNode now requires a deck load
* Renamed muxificationConcept to muxiumConcept
### Stratimux 0.2.0-1 Stealth Roll Out
* Introduces type safety throughout your muxiums via a new DECK Interface System
* e: Entry Action
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stratimux",
"license": "GPL-3.0",
"version": "0.2.2",
"version": "0.2.42",
"description": "Muxified Turing Machine",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
10 changes: 6 additions & 4 deletions src/concepts/muxium/model/gather.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { ActionNode, ActionNodeOptions } from '../../../model/action/strategy/ac
import { Action, AnyAction } from '../../../model/action/action.type';
import { createActionNode, createStrategy } from '../../../model/action/strategy/actionStrategy';
import { createAction } from '../../../model/action/action';
import { Deck } from '../../../model/deck';
import { MuxiumDeck } from '../muxium.concept';

export type MuxiumGatherNode = {
actions: Action[],
Expand All @@ -23,7 +25,7 @@ export type MuxiumGatherNode = {
* You may use this to continue a strategy after the gathered actions have concluded.
* @returns ActionNode of muxiumStitch
*/
export const muxium_createGatherNode = (props: MuxiumGatherNode, options?: ActionNodeOptions[]) => {
export const muxium_createGatherNode = (deck: Deck<MuxiumDeck>, props: MuxiumGatherNode, options?: ActionNodeOptions[]) => {
const {
actions,
last,
Expand Down Expand Up @@ -51,7 +53,7 @@ export const muxium_createGatherNode = (props: MuxiumGatherNode, options?: Actio
if (first) {
return first;
} else {
const log = createAction('logged a message passed to Muxium') as AnyAction;
const log = deck.muxium.e.muxiumLog() as AnyAction;
log.payload = {message: 'NO ACTIONS WERE GATHERED VIA AXIUM_CREATE_GATHER_NODE'};
return createActionNode(log, {
successNode: null,
Expand All @@ -76,8 +78,8 @@ export type MuxiumGatherStrategy = {

* @returns ActionStrategy of the provided actions to be executed in a sequence.
*/
export const muxium_createGatherStrategy = (props: MuxiumGatherStrategy, options?: ActionNodeOptions[]) => {
const stepFirst = muxium_createGatherNode(props, options);
export const muxium_createGatherStrategy = (deck: Deck<MuxiumDeck>, props: MuxiumGatherStrategy, options?: ActionNodeOptions[]) => {
const stepFirst = muxium_createGatherNode(deck, props, options);
return createStrategy({
topic: props.topic ? props.topic : 'Muxium Gather Strategy for: ' + props.actions.map(act => act.type).join(', '),
initialNode: stepFirst
Expand Down
7 changes: 4 additions & 3 deletions src/concepts/muxium/model/stitch.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ This function allows for Strategy Stitches to be composed of only one action nod
While calling the muxium's stitch quality to silently move to the next node assigned to the end of that stitch.
$>*/
/*<#*/
import { createAction } from '../../../model/action/action';
import { createActionNode } from '../../../model/action/strategy/actionStrategy';
import { ActionNodeOptions } from '../../../model/action/strategy/actionStrategy.type';
import { Deck } from '../../../model/deck';
import { MuxiumDeck } from '../muxium.concept';

/**
* Must be used within an ActionStrategyStitch with only one ActionNode provided.
* @param options `optional` will set return ActionNode's options if provided.
* @returns ActionNode of muxiumStitch
*/
export const muxium_createStitchNode = (options?: ActionNodeOptions) =>
(createActionNode(createAction('Muxium Stitch'), options ? options : {
export const muxium_createStitchNode = (deck: Deck<MuxiumDeck>, options?: ActionNodeOptions) =>
(createActionNode(deck.muxium.e.muxiumStitch(), options ? options : {
successNode: null,
failureNode: null,
}));
Expand Down
2 changes: 1 addition & 1 deletion src/concepts/muxium/muxium.concept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const muxificationState = <Q, C extends LoadConcepts>(
const muxiumStaticPrinciple = [muxiumClosePrinciple];
export type MuxiumPrinciple = PrincipleFunction<MuxiumQualities, MuxiumDeck, MuxiumState<MuxiumQualities, LoadConcepts>>;

export const muxificationConcept = <Q, C extends LoadConcepts>(
export const muxiumConcept = <Q, C extends LoadConcepts>(
name: string,
storeDialog?: boolean,
logging?: boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export { muxiumTimeOut } from './model/time';

//** Concept Exports */
// Muxium
export { MuxiumState, muxiumName, muxificationConcept, MuxiumDeck } from './concepts/muxium/muxium.concept';
export { MuxiumState, muxiumName, muxiumConcept, MuxiumDeck } from './concepts/muxium/muxium.concept';
export { blockingMode, permissiveMode } from './concepts/muxium/muxium.mode';
export {
muxiumSelectOpen,
Expand Down
1 change: 1 addition & 0 deletions src/model/action/strategy/actionStrategy.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ $>*/
import { Action, ActionType } from '../action.type';
import { OwnershipTicketStub } from '../../ownership';
import { KeyedSelector } from '../../selector/selector.type';
import { Deck } from '../../deck';

/**
* ActionNode - Control Structure used by ActionStrategy
Expand Down
3 changes: 1 addition & 2 deletions src/model/concept/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*<$
For the asynchronous graph programming framework Stratimux, define the Concept Index model file.
This file defines a bundled concept object, that enables ease of access to the handling of concepts within
a Muxium.
This file defines a bundled concept object, that enables ease of access to the handling of concepts.
$>*/
/*<#*/
import { createConcept } from './concept';
Expand Down
2 changes: 1 addition & 1 deletion src/model/deck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ For the asynchronous graph programming framework Stratimux, define the Deck Mode
$>*/
/*<#*/
import { getMuxiumState } from './muxium/muxiumHelpers';
import { AnyConcept, Concept, Concepts } from './concept/concept.type';
import { AnyConcept, Concept, Concepts, LoadConcepts } from './concept/concept.type';
import { Comparators } from './interface';
import { Qualities } from './quality';
import { BundledSelectors, KeyedSelectors, Selectors } from './selector/selector.type';
Expand Down
28 changes: 14 additions & 14 deletions src/model/method/method.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,42 +86,42 @@ export type MethodAsyncWithStateParams<S extends Record<string, unknown>, T = vo

export type MethodCreatorAsyncWithState = <S extends Record<string, unknown>, T = void, C = void>(
asyncMethodWithState: (params: MethodAsyncWithStateParams<S, T, C>) => void,
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodCreatorAsyncDebounce = <S extends Record<string, unknown>, T = void, C = void>(
asyncMethod: (params: MethodAsyncParams<T,C>) => void,
duration: number
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodCreatorAsyncDebounceWithConcepts= <S extends Record<string, unknown>, T = void, C = void>(
asyncMethodWithConcepts: (params: MethodAsyncWithConceptsParams<T,C>) => void,
duration: number,
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodCreatorAsyncDebounceWithState = <S extends Record<string, unknown>, T = void, C = void>(
asyncMethodWithState: (params: MethodAsyncWithStateParams<S,T,C>) => void,
duration: number
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodCreatorBaseThrottle = <S extends Record<string, unknown>, T = void, C = void>(
method: (params: MethodParams<T,C>) => Action<any>,
duration: number
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodCreatorBaseThrottleWithState = <S extends Record<string, unknown>, T = void, C = void>(
methodWithState: (params: MethodWithStateParams<S,T,C>) => Action<any>,
duration: number
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodCreatorAsyncThrottle = <S extends Record<string, unknown>, T = void, C = void>(
asyncMethod: (params: MethodAsyncParams<T,C>) => void,
duration: number
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodCreatorAsyncThrottleWithState = <S extends Record<string, unknown>, T = void, C = void>(
asyncMethodWithState: (params: MethodAsyncWithStateParams<S,T,C>) => void,
duration: number
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodAsyncWithConceptsParams<T = void, C = void> = {
action: Action<T>,
Expand All @@ -137,31 +137,31 @@ export type MethodAsyncWithConceptsParams<T = void, C = void> = {
export type MethodCreatorAsyncWithConcepts= <S extends Record<string, unknown>, T = void, C = void>(
asyncMethodWithConcepts: (params: MethodAsyncWithConceptsParams<T,C>) => void,
duration: number
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodCreatorBaseThrottleWithConcepts= <S extends Record<string, unknown>, T = void, C = void>(
methodWithConcepts: (params: MethodWithConceptsParams<T,C>) => Action,
duration: number
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodCreatorAsyncThrottleWithConcepts= <S extends Record<string, unknown>, T = void, C = void>(
asyncMethodWithConcepts: (params: MethodAsyncWithConceptsParams<T,C>) => void,
duration: number
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodCreatorBaseDebounce = <S extends Record<string, unknown>, T = void, C = void>(
method: (params: MethodParams<T,C>) => Action<any>,
duration: number
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodCreatorBaseDebounceWithState = <S extends Record<string, unknown>, T = void, C = void>(
methodWithState: (params: MethodWithStateParams<S, T, C>) => Action<any>,
duration: number
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

export type MethodCreatorBaseDebounceWithConcepts= <S extends Record<string, unknown>, T = void, C = void>(
methodWithConcepts: (params: MethodWithConceptsParams<T,C>) => Action<any>,
duration: number
) => MethodCreator<S, T, any>;
) => MethodCreator<S, T, C>;

/*#>*/
24 changes: 12 additions & 12 deletions src/model/muxium/muxium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
forEachConcept,
qualityToString
} from '../concept/conceptHelpers';
import { muxificationConcept, MuxiumState, initializationStrategy, MuxiumDeck } from '../../concepts/muxium/muxium.concept';
import { muxiumConcept, MuxiumState, initializationStrategy, MuxiumDeck } from '../../concepts/muxium/muxium.concept';
import { Planner } from '../stagePlanner/stagePlanner.type';
import { handlePriority, isPriorityValid } from '../priority';
import { MuxiumQualities } from '../../concepts/muxium/qualities';
Expand All @@ -40,35 +40,35 @@ export function muxification<C extends LoadConcepts>(
dynamic?: boolean,
}
): Muxium<MuxiumQualities, C & MuxiumDeck, MuxiumState<MuxiumQualities, C>> {
const muxiumConcept = muxificationConcept<MuxiumQualities, C>(
const muxium = muxiumConcept<MuxiumQualities, C>(
name,
options?.storeDialog,
options?.logging,
options?.logActionStream,
options?.dynamic
) as Concept<MuxiumState<MuxiumQualities, C>, MuxiumQualities>;
const concepts: Concepts = {
0: muxiumConcept
0: muxium
};
// as Concept<MuxiumState<MuxiumQualities, MuxiumDeck & C>, MuxiumQualities>;
updateKeyedSelectors(concepts, muxiumConcept.keyedSelectors, 0);
muxiumConcept.selectors = createSelectors(0);
updateKeyedSelectors(concepts, muxium.keyedSelectors, 0);
muxium.selectors = createSelectors(0);
const bundledSelectors = {
...muxiumConcept.keyedSelectors,
...muxiumConcept.selectors
...muxium.keyedSelectors,
...muxium.selectors
} as BundledSelectors<MuxiumState<MuxiumQualities, C>>;
const baseDeck: Decks<MuxiumQualities, MuxiumState<MuxiumQualities, C>, MuxiumLoad<MuxiumDeck>> = {
d: { muxium: {
e: muxiumConcept.actions,
c: muxiumConcept.comparators,
e: muxium.actions,
c: muxium.comparators,
k: bundledSelectors,
},
} as Deck<MuxiumLoad<MuxiumDeck>>,
e: muxiumConcept.actions,
c: muxiumConcept.comparators,
e: muxium.actions,
c: muxium.comparators,
k: bundledSelectors,
};
muxiumConcept.semaphore = 0;
muxium.semaphore = 0;
Object.keys(deckLoad).forEach((key, i) => {
const semaphore = i + 1;
concepts[semaphore] = deckLoad[key];
Expand Down
Loading
Loading