Skip to content

Commit

Permalink
Merge pull request #137 from Phuire-Research/UI
Browse files Browse the repository at this point in the history
UI
  • Loading branch information
REllEK-IO authored Oct 31, 2023
2 parents e85d95d + dc7f19c commit 7640d39
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 18 deletions.
10 changes: 7 additions & 3 deletions Axium.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The design decision here allows us to forgo the need for dependency injection. A
export type AxiumState {
name: string;
open: boolean;
exit: boolean;
logging: boolean;
dialog: string;
storeDialog: boolean;
Expand All @@ -37,13 +38,15 @@ export type AxiumState {
generalSubscribers: NamedSubscribers[];
action$: Subject<Action>;
concepts$: UnifiedSubject;
innerConcepts$: UnifiedSubject;
subConcepts$: UnifiedSubject;
addConceptQue: Concept[],
removeConceptQue: Concept[],
subConcepts$: UnifiedSubject;
}
```
* name - This should be set to a unique network identifier, and/or the concept of your system.
* open - This is utilized by principles and external subscribers to denote when they should initialize their functionality.
* exit - Controls whether close will have the process exit.
* logging - controls whether the Stratimux dialog paragraphs are emitted upon strategy completion. In addition to other debugging procedures.
* dialog - Is the internal representation of the strategies that the axium has ran.
* storeDialog - This is set to false by default to save on memory, but if true will store each dialog, and allows such to be subscribed to.
Expand All @@ -57,10 +60,11 @@ export type AxiumState {
* methodSubscribers - Accumulates all method subscriptions for their manipulation at run time.
* generalSubscribers - Same as method subscribers, but a catch all including that of principles and their internal subscriptions that would ordinarily leave principles as hot and active in memory if not concluded upon removal or close.
* action$ - Is the internal action stream.
* concepts$ - Is the internal Concepts stream that methods and principles have access to.
* concepts$ - Is the internal Concepts stream that methods and principles have access to, will not be notified in blocking mode.
* innerConcepts$ - Internal Concepts stream that only the Axium principles have access to.
* subConcepts$ - This is the outer subscription that other axiums or applications may have access to. While in blocking mode, these subscriptions are not updated.
* addConceptQue - The current pattern to allow for principles to effect the concepts within the application. Rather than a direct subscription to the action$, they listen to state properties to control what actions they emit into the stream. In this case a set of concepts to be loaded into the axium.
* removeConceptQue - The inverse of the above to remove concepts.
* subConcepts - This is the outer subscription that other axiums or applications may Have access to. While in blocking mode, these subscriptions are not updated.

## The Anatomy of an Axium
* Action - Is a dumb object that is supplied some data as payload or performs some transformation of state based on its semaphore which is inferred via its type. Is the messaging protocol of an axium.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* Hot Loading
* No Dependency Injection

Getting Started: [STRATIMUX PROJECT TEMPLATE](https://github.com/Phuire-Research/STRATIMUX-TEMPLATE)

*Note if you notice a strange any capitalization, this is a new format that is being formalized as conceptual logic. Where we capitalize not just people, places, and things, but concepts as well. In addition, there was no generative intelligence used in the creation of this framework or documentation. This is **100% hand written.***

----
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@phuire/stratimux",
"version": "0.0.58",
"name": "stratimux",
"license": "GPL-3.0",
"version": "0.0.60",
"description": "Unified Turing Machine",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
6 changes: 4 additions & 2 deletions src/concepts/axium/axium.concept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ export type AxiumState = {
stagePlanners: NamedStagePlanner[];
action$: Subject<Action>;
concepts$: UnifiedSubject;
innerConcepts$: UnifiedSubject;
subConcepts$: UnifiedSubject;
addConceptQue: Concept[],
removeConceptQue: Concept[],
subConcepts$: UnifiedSubject;
badPlans: Plan[];
badActions: Action[];
}
Expand Down Expand Up @@ -91,9 +92,10 @@ const createAxiumState = (name: string, storeDialog?: boolean, logging?: boolean
stagePlanners: [] as NamedStagePlanner[],
action$: new Subject<Action>(),
concepts$: new UnifiedSubject(),
innerConcepts$: new UnifiedSubject(),
subConcepts$: new UnifiedSubject(),
addConceptQue: [] as Concept[],
removeConceptQue: [] as Concept[],
subConcepts$: new UnifiedSubject(),
badPlans: [],
badActions: []
};
Expand Down
2 changes: 1 addition & 1 deletion src/concepts/axium/axium.mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const blockingMode: Mode = (
const reduce = concepts[action.semaphore[0]].qualities[action.semaphore[1]].reducer;
const state = concepts[action.semaphore[0]].state;
concepts[action.semaphore[0]].state = reduce(state, action);
concepts$.next(concepts);
axiumState.innerConcepts$.next(concepts);
let subject: Subject<Action>;
if (concepts[action.semaphore[0]].qualities[action.semaphore[1]].method) {
subject = concepts[action.semaphore[0]].qualities[action.semaphore[1]].subject as Subject<Action>;
Expand Down
1 change: 1 addition & 0 deletions src/concepts/axium/qualities/close.quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function closeReducer(state: AxiumState, _action: Action): AxiumState {
state.stagePlanners.forEach(named => named.conclude());
state.action$.complete();
state.concepts$.complete();
state.innerConcepts$.complete();
state.subConcepts$.complete();
if (exit) {
process.exit();
Expand Down
13 changes: 11 additions & 2 deletions src/concepts/axium/qualities/initializePrinciples.quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Subject, Subscriber } from 'rxjs';
import { Concept, Concepts, defaultMethodCreator, forEachConcept } from '../../../model/concept';
import { createPrinciple$ } from '../../../model/principle';
import { Action, ActionType, prepareActionWithPayloadCreator } from '../../../model/action';
import { AxiumState } from '../axium.concept';
import { AxiumState, axiumName } from '../axium.concept';
import { createQuality } from '../../../model/concept';
import { UnifiedSubject } from '../../../model/stagePlanner';
import { selectPayload } from '../../../model/selector';
Expand All @@ -22,7 +22,16 @@ export function initializePrinciplesReducer(state: AxiumState, _action: Action):
const concepts$ = state.concepts$ as UnifiedSubject;
const principleSubscribers = state.generalSubscribers;
forEachConcept(concepts ,((concept: Concept, semaphore) => {
if (concept.principles) {
if (concept.name === axiumName && concept.principles) {
concept.principles.forEach(principle => {
const observable = createPrinciple$(principle, concepts, state.innerConcepts$, semaphore as number);
principleSubscribers.push({
name: concept.name,
subscription: observable.subscribe((action: Action) => action$.next(action)) as Subscriber<Action>,
});
});
conceptCounter += 1;
} else if (concept.principles) {
concept.principles.forEach(principle => {
const observable = createPrinciple$(principle, concepts, concepts$, semaphore as number);
principleSubscribers.push({
Expand Down
2 changes: 1 addition & 1 deletion src/concepts/axium/qualities/open.quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type OpenPayload = boolean;
export const axiumOpenType: ActionType = 'Open Axium';
export const axiumOpen = prepareActionWithPayloadCreator<OpenPayload>(axiumOpenType);

export function openReducer(state: AxiumState, action: Action) {
export function openReducer(state: AxiumState, action: Action): AxiumState {
const payload = selectPayload<OpenPayload>(action);
return {
...state,
Expand Down
4 changes: 2 additions & 2 deletions src/concepts/axium/qualities/setBlockingMode.quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type SetBlockingModePayload = {
export const axiumSetBlockingModeType: ActionType = 'set Axium to Blocking Mode';
export const axiumSetBlockingMode = prepareActionWithPayloadCreator<SetBlockingModePayload>(axiumSetBlockingModeType);

export function setBlockingModeReducer(state: AxiumState, _action: Action) {
export function setBlockingModeReducer(state: AxiumState, _action: Action): AxiumState {
let methodSubscribers = state.methodSubscribers;
methodSubscribers.forEach(named => named.subscription.unsubscribe());
methodSubscribers = [];
Expand All @@ -36,7 +36,7 @@ export function setBlockingModeReducer(state: AxiumState, _action: Action) {

return {
...state,
modeIndex: [0],
modeIndex: 0,
methodSubscribers,
open: false,
};
Expand Down
4 changes: 2 additions & 2 deletions src/concepts/axium/qualities/setDefaultMode.quality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type SetDefaultModePayload = {
export const axiumSetDefaultModeType: ActionType = 'set Axium to its current Default Mode Index';
export const axiumSetDefaultMode = prepareActionWithPayloadCreator<SetDefaultModePayload>(axiumSetDefaultModeType);

export function setDefaultModeReducer(state: AxiumState, _action: Action) {
export function setDefaultModeReducer(state: AxiumState, _action: Action): AxiumState {
let methodSubscribers = state.methodSubscribers;
methodSubscribers.forEach(named => named.subscription.unsubscribe());
methodSubscribers = [];
Expand All @@ -37,7 +37,7 @@ export function setDefaultModeReducer(state: AxiumState, _action: Action) {
...state,
modeIndex: state.defaultModeIndex,
methodSubscribers,
} as AxiumState;
};
}

export const setDefaultModeQuality = createQuality(
Expand Down
2 changes: 0 additions & 2 deletions src/concepts/axium/qualities/setMode.quality.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { AxiumState } from '../axium.concept';
import { Action, createAction, prepareActionWithPayloadCreator} from '../../../model/action';
import { createQuality, MethodCreator, Method } from '../../../model/concept';
import { Subject, map } from 'rxjs';
import { axiumConclude, axiumConcludeType } from './conclude.quality';
import { strategySuccess } from '../../../model/actionStrategy';
import { selectPayload } from '../../../model/selector';
import { createMethod } from '../../../model/method';
Expand Down
10 changes: 9 additions & 1 deletion src/model/axium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
createAxiumConcept,
AxiumState,
initializationStrategy,
axiumName,
} from '../concepts/axium/axium.concept';
import { axiumClose } from '../concepts/axium/qualities/close.quality';
import {
Expand Down Expand Up @@ -113,7 +114,7 @@ export function createAxium(name: string, initialConcepts: Concept[], logging?:
}));
axiumState.action$
.pipe(
withLatestFrom(axiumState.concepts$),
withLatestFrom(axiumState.innerConcepts$),
// This will be where the Ownership Principle will be Loaded
// As Such is a Unique Principle in the Scope of State Management
// This will also allow for Actions to be added to the Stream to Update to most Recent Values
Expand All @@ -137,6 +138,13 @@ export function createAxium(name: string, initialConcepts: Concept[], logging?:
axiumState = concepts[0].state as AxiumState;
const action$ = axiumState.action$;
const subConcepts$ = axiumState.subConcepts$;
const concepts$Sub = axiumState.concepts$.subscribe(_concepts => {
axiumState.innerConcepts$.next(_concepts);
});
axiumState.generalSubscribers.push({
name: axiumName,
subscription: concepts$Sub
});
axiumState.concepts$.next(concepts);
axiumState.action$.next(
strategyBegin(initializationStrategy(concepts)),
Expand Down

0 comments on commit 7640d39

Please sign in to comment.