Skip to content

Commit

Permalink
refactor messaging and schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
garredow committed Apr 16, 2024
1 parent 5c5b7e1 commit 89d81f7
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 170 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# kaiware-lib

![build](https://github.com/nothingspecialdev/kaiware-lib/actions/workflows/build.yml/badge.svg)
![build](https://github.com/nothingspecialdev/kaiware-lib/actions/workflows/build.yml/badge.svg)
![NPM Version](https://img.shields.io/npm/v/%40nothing-special%2Fkaiware-lib)
34 changes: 26 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nothing-special/kaiware-lib",
"version": "0.3.0",
"version": "0.4.0",
"type": "module",
"author": {
"name": "Garrett Downs",
Expand All @@ -26,16 +26,34 @@
"index.d.ts"
],
"types": "./build/src/index.d.ts",
"module": "./build/src/index.mjs",
"main": "./build/src/index.cjs",
"exports": {
".": {
"types": "./build/esm/src/index.d.ts",
"import": "./build/esm/src/index.js",
"require": "./build/cjs/src/index.js"
"types": "./build/src/index.d.ts",
"import": "./build/src/index.mjs",
"require": "./build/src/index.cjs"
},
"./lib": "./build/esm/src/lib/index.js",
"./types": "./build/esm/src/types/index.js",
"./enums": "./build/esm/src/enums/index.js",
"./utils": "./build/esm/src/utils/index.js"
"./lib": {
"types": "./build/src/lib/index.d.ts",
"import": "./build/src/lib/index.mjs",
"require": "./build/src/lib/index.cjs"
},
"./types": {
"types": "./build/src/types/index.d.ts",
"import": "./build/src/types/index.mjs",
"require": "./build/src/types/index.cjs"
},
"./enums": {
"types": "./build/src/enums/index.d.ts",
"import": "./build/src/enums/index.mjs",
"require": "./build/src/enums/index.cjs"
},
"./utils": {
"types": "./build/src/utils/index.d.ts",
"import": "./build/src/utils/index.mjs",
"require": "./build/src/utils/index.cjs"
}
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.24.3",
Expand Down
149 changes: 51 additions & 98 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,108 +1,61 @@
import alias from '@rollup/plugin-alias';
import babel from '@rollup/plugin-babel';
import nodeResolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import path from 'node:path';

/** @type {import('rollup').RollupOptions[]} */
export default [
{
input: [
'src/index.ts',
'src/enums/index.ts',
'src/lib/index.ts',
'src/types/index.ts',
'src/utils/index.ts'
],
output: {
dir: 'build/esm',
/** @type {import('rollup').RollupOptions} */
export default {
input: [
'src/index.ts',
'src/enums/index.ts',
'src/lib/index.ts',
'src/types/index.ts',
'src/utils/index.ts'
],
output: [
{
dir: 'build',
format: 'esm',
preserveModules: true,
exports: 'named'
exports: 'named',
entryFileNames: '[name].mjs'
},
preserveEntrySignatures: 'strict',
plugins: [
typescript({
outDir: 'build/esm/src'
}),
alias({
customResolver: nodeResolve({ extensions: ['.ts', '.js', '.d.ts'] }),
entries: [{ find: 'src', replacement: path.resolve(__dirname, 'build/esm/src') }]
}),
babel({
extensions: ['.js', '.ts', '.mjs', '.cjs', '.html'],
babelHelpers: 'runtime',
exclude: ['node_modules/@babel/**'],
presets: [
[
'@babel/preset-env',
{
targets: { firefox: '48' },
exclude: ['@babel/plugin-transform-regenerator']
}
]
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
[
'@babel/plugin-transform-runtime',
{
useESModules: true,
regenerator: false
}
]
]
}),
nodeResolve()
]
},
{
input: [
'src/index.ts',
'src/enums/index.ts',
'src/lib/index.ts',
'src/types/index.ts',
'src/utils/index.ts'
],
output: {
dir: 'build/cjs',
{
dir: 'build',
format: 'cjs',
preserveModules: true,
exports: 'named'
},
preserveEntrySignatures: 'strict',
plugins: [
alias({
entries: [{ find: '$', replacement: path.resolve(__dirname, 'src') }]
}),
typescript({
outDir: 'build/cjs/src'
}),
babel({
extensions: ['.js', '.ts', '.mjs', '.cjs', '.html'],
babelHelpers: 'runtime',
exclude: ['node_modules/@babel/**'],
presets: [
[
'@babel/preset-env',
{
targets: { firefox: '48' },
exclude: ['@babel/plugin-transform-regenerator']
}
]
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
[
'@babel/plugin-transform-runtime',
{
useESModules: true,
regenerator: false
}
]
exports: 'named',
entryFileNames: '[name].cjs'
}
],
preserveEntrySignatures: 'strict',
plugins: [
nodeResolve({}),
typescript({
outDir: 'build/src'
}),
babel({
extensions: ['.js', '.ts', '.mjs', '.cjs', '.html'],
babelHelpers: 'runtime',
exclude: ['node_modules/@babel/**'],
presets: [
[
'@babel/preset-env',
{
targets: { firefox: '48' },
exclude: ['@babel/plugin-transform-regenerator']
}
]
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
[
'@babel/plugin-transform-runtime',
{
useESModules: true,
regenerator: false
}
]
}),
nodeResolve()
]
}
];
]
})
]
};
29 changes: 22 additions & 7 deletions src/enums/MessageType.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
export enum MessageType {
RefreshElements = 'refresh-elements',
RefreshDeviceInfo = 'refresh-device-info',
RefreshStorage = 'refresh-storage',
GetDeviceInfo = 'get-device-info',
GetDeviceInfoRes = 'get-device-info-res',

GetElements = 'get-elements',
GetElementsRes = 'get-elements-res',

GetElementStyles = 'get-element-styles',
GetElementStylesRes = 'get-element-styles-res',
SetElementStyles = 'set-element-styles',
SetElementStylesRes = 'set-element-styles-res',

GetElementData = 'get-element-data',
GetElementDataRes = 'get-element-data-res',
SetElementData = 'set-element-data',
SetElementDataRes = 'set-element-data-res',

GetStorage = 'get-storage',
GetStorageRes = 'get-storage-res',
SetStorage = 'set-storage',
SetStorageRes = 'set-storage-res',

// Misc

DeviceInfoUpdate = 'device-info-update',
NewLog = 'new-log',
ClearLogs = 'clear-logs',
ElementsUpdate = 'elements-update',
StorageUpdate = 'storage-update',

Error = 'error'
}
Loading

0 comments on commit 89d81f7

Please sign in to comment.