Skip to content

Commit

Permalink
Merge branch 'layer5io:master' into 496-meshery-ui-app
Browse files Browse the repository at this point in the history
  • Loading branch information
nebula-aac authored Aug 8, 2024
2 parents fb88132 + 68a1ff7 commit 93673c9
Show file tree
Hide file tree
Showing 84 changed files with 25,802 additions and 12,598 deletions.
35,491 changes: 23,244 additions & 12,247 deletions package-lock.json

Large diffs are not rendered by default.

198 changes: 102 additions & 96 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,104 +1,110 @@
{
"name": "@layer5/sistent",
"version": "0.14.11",
"description": "Reusable React Components and SVG Icons library",
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/layer5io/sistent.git"
},
"main": "./dist/index.js",
"module": "./dist/index..js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "NODE_ENV=production tsup",
"build:watch": "NODE_ENV=production tsup --watch",
"commitlint": "commitlint --edit",
"coverage": "jest --coverage",
"dev": "NODE_ENV=development tsup",
"format:check": "prettier --check \"**/*.{ts,tsx,md}\" --config ./.prettierrc",
"format:write": "prettier --write \"**/*.{ts,tsx,md}\" --config ./.prettierrc",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:fix": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix",
"prepare": "husky install",
"test": "jest",
"versionup:major": "npm version major",
"versionup:minor": "npm version minor",
"versionup:patch": "npm version patch"
},
"lint-staged": {
"*.{ts,tsx,md}": [
"prettier --write",
"eslint --fix"
]
"name": "@layer5/sistent",
"version": "0.14.11",
"description": "Reusable React Components and SVG Icons library",
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/layer5io/sistent.git"
},
"main": "./dist/index.js",
"module": "./dist/index..js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "NODE_ENV=production tsup",
"build:watch": "NODE_ENV=production tsup --watch",
"commitlint": "commitlint --edit",
"coverage": "jest --coverage",
"dev": "NODE_ENV=development tsup",
"format:check": "prettier --check \"**/*.{ts,tsx,md}\" --config ./.prettierrc",
"format:write": "prettier --write \"**/*.{ts,tsx,md}\" --config ./.prettierrc",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:fix": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix",
"prepare": "husky install",
"test": "jest",
"versionup:major": "npm version major",
"versionup:minor": "npm version minor",
"versionup:patch": "npm version patch"
},
"lint-staged": {
"*.{ts,tsx,md}": [
"prettier --write",
"eslint --fix"
]
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"devDependencies": {
"@commitlint/cli": "^17.7.2",
"@commitlint/config-conventional": "^17.7.0",
"@mui/icons-material": "^5.15.11",
"@reduxjs/toolkit": "^2.2.5",
"@testing-library/react": "^14.1.2",
"@types/jest": "^29.5.11",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.49.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.4",
"eslint-plugin-storybook": "^0.6.15",
"husky": "^8.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^14.0.1",
"mui-datatables": "^4.3.0",
"notistack": "^3.0.1",
"prettier": "^3.0.3",
"prettier-plugin-organize-imports": "^3.2.3",
"react-error-boundary": "^4.0.12",
"react-markdown": "^8.0.7",
"rehype-raw": "^6.1.1",
"remark-gfm": "^3.0.1",
"ts-jest": "^29.1.1",
"tsup": "^8.0.1",
"typescript": "^5.3.3"
},
"peerDependencies": {
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@mui/material": "^5.15.11",
"@types/mui-datatables": "*",
"@xstate/react": "^4.1.1",
"mui-datatables": "*",
"react": ">=17",
"react-dom": ">=17",
"xstate": "^5.13.0"
},
"peerDependenciesMeta": {
"@emotion/react": {
"optional": true
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
"@emotion/styled": {
"optional": true
},
"devDependencies": {
"@commitlint/cli": "^17.7.2",
"@commitlint/config-conventional": "^17.7.0",
"@mui/icons-material": "^5.15.11",
"@testing-library/react": "^14.1.2",
"@types/jest": "^29.5.11",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.12.0",
"@typescript-eslint/parser": "^6.12.0",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.49.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.4",
"eslint-plugin-storybook": "^0.6.15",
"husky": "^8.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^14.0.1",
"mui-datatables": "^4.3.0",
"notistack": "^3.0.1",
"prettier": "^3.0.3",
"prettier-plugin-organize-imports": "^3.2.3",
"react-error-boundary": "^4.0.12",
"ts-jest": "^29.1.1",
"tsup": "^8.0.1",
"typescript": "^5.3.3"
"@mui/material": {
"optional": true
},
"peerDependencies": {
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@mui/material": "^5.15.11",
"@types/mui-datatables": "*",
"mui-datatables": "*",
"react": ">=17",
"react-dom": ">=17"
"mui-datatables": {
"optional": true
},
"peerDependenciesMeta": {
"@emotion/react": {
"optional": true
},
"@emotion/styled": {
"optional": true
},
"@mui/material": {
"optional": true
},
"mui-datatables": {
"optional": true
},
"react": {
"optional": true
},
"react-dom": {
"optional": true
}
"react": {
"optional": true
},
"publishConfig": {
"access": "public"
"react-dom": {
"optional": true
}
},
"publishConfig": {
"access": "public"
}
}
14 changes: 7 additions & 7 deletions site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions src/actors/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export {
DATA_VALIDATOR_COMMANDS,
DATA_VALIDATOR_EVENTS,
dataValidatorCommands,
dataValidatorEvents,
dataValidatorMachine,
selectIsValidating,
selectValidationResults
} from './validators/dataValidator';

export * from './worker';

export {
REDUX_COMMANDS,
REDUX_EVENTS,
reduxActor,
reduxCommands,
reduxEvents,
type REXUX_ACTOR_EVENTS
} from './reduxActor';

export {
RTK_EVENTS,
rtkQueryActor,
rtkQueryActorCommands,
rtkQueryActorEvents
} from './rtkQueryActor';

export const REEE = 'xxx';

export {
DeferEvents,
XSTATE_DEBUG_EVENT,
deadLetter,
forwardToActors,
reply,
sendToActor,
sendToActors
} from './utils';
94 changes: 94 additions & 0 deletions src/actors/reduxActor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { assertEvent, sendTo, setup } from 'xstate';

import { Selector, Store, UnknownAction } from '@reduxjs/toolkit';

interface ReduxActorContext {
store: Store;
selectors: {
[key: string]: Selector;
};
}

/* eslint-disable @typescript-eslint/no-explicit-any */
type extraArgs = any[];

export const REDUX_COMMANDS = {
DISPATCH: 'DISPATCH',
GET_STATE: 'GET_STATE',
GET_STATE_FROM_SELECTOR: 'GET_STATE_FROM_SELECTOR',
SUBSCRIBE: 'SUBSCRIBE',
UNSUBSCRIBE: 'UNSUBSCRIBE'
};

export const REDUX_EVENTS = {
REDUX_STATE_SNAPSHOT: 'REDUX_STATE_SNAPSHOT'
};

export type REXUX_ACTOR_EVENTS =
| { type: 'DISPATCH'; data: { action: UnknownAction } }
| { type: 'SUBSCRIBE' }
| { type: 'UNSUBSCRIBE' }
| { type: 'REDUX_STATE_SNAPSHOT'; data: { snapshot: unknown } }
| { type: 'GET_STATE'; returnAddress: string; data: { key: string } }
| {
type: 'GET_STATE_FROM_SELECTOR';
returnAddress: string;
data: { selector: string; extraArgs?: extraArgs };
};

export const reduxEvents = {
stateSnapshot: (snapshot: unknown) => ({
type: 'STATE_SNAPSHOT',
data: { snapshot }
})
};

export const reduxCommands = {
dispatch: (action: UnknownAction) => ({
type: 'DISPATCH',
data: { action }
}),

getState: (key: string, returnAddress: string) => ({
type: 'GET_STATE',
returnAddress,
data: { key }
}),

getStateFromSelector: (selector: string, returnAddress: string, extraArgs?: extraArgs) => ({
type: 'GET_STATE_FROM_SELECTOR',
returnAddress,
data: { selector, extraArgs }
})
};

export const reduxActor = setup({
types: {
context: {} as ReduxActorContext,
input: {} as ReduxActorContext,
events: {} as REXUX_ACTOR_EVENTS
}
}).createMachine({
initial: 'idle',
context: ({ input }) => input,
states: {
idle: {
on: {
DISPATCH: {
actions: [({ event, context }) => context.store.dispatch(event.data.action)]
},
GET_STATE_FROM_SELECTOR: {
actions: sendTo(
({ event }) => event.returnAddress,
({ context, event }) => {
assertEvent(event, 'GET_STATE_FROM_SELECTOR');
const selector = context.selectors[event.data.selector];
const snapshot = selector(context.store.getState(), ...(event.data.extraArgs || []));
return reduxEvents.stateSnapshot(snapshot);
}
)
}
}
}
}
});
Loading

0 comments on commit 93673c9

Please sign in to comment.