Skip to content

Commit

Permalink
engine package setup
Browse files Browse the repository at this point in the history
  • Loading branch information
funwithtriangles committed Nov 10, 2024
1 parent 0f54618 commit adb6121
Show file tree
Hide file tree
Showing 40 changed files with 328 additions and 36 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.DS_Store
node_modules/
lerna-debug.log
*.log*
*.tsbuildinfo
dist
out
6 changes: 0 additions & 6 deletions packages/desktop/.gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
node_modules
dist
out
.DS_Store
*.log*
.sketches-server
dev-settings.json
chrome-extensions

*storybook.log
2 changes: 1 addition & 1 deletion packages/desktop/src/renderer/appStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { create, StoreApi } from 'zustand'
import { devtools, persist, subscribeWithSelector } from 'zustand/middleware'
import { immer } from 'zustand/middleware/immer'
import type {} from '@redux-devtools/extension' // required for devtools typing
import { DialogId } from '@hedron/engine/store/types'
import { DialogId } from '@hedron/engine'

export interface SaveItem {
title: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DialogId } from '@hedron/engine/store/types'
import { DialogId } from '@hedron/engine'
import { useGlobalDialog } from '@components/GlobalDialogs/useGlobalDialog'
import { SketchModulesDialog } from '@components/GlobalDialogs/SketchModulesDialog'
import { GlobalDialogProps } from '@components/GlobalDialogs/types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback } from 'react'
import { SketchModuleItem } from '@hedron/engine/store/types'
import { SketchModuleItem } from '@hedron/engine'
import { GlobalDialogProps } from '@components/GlobalDialogs/types'
import { useEngineStore } from '@renderer/engine'
import { useSketchModuleList } from '@components/hooks/useSketchModuleList'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback } from 'react'
import { DialogId } from '@hedron/engine/store/types'
import { DialogId } from '@hedron/engine'
import { useAppStore } from '@renderer/appStore'

export const useGlobalDialog = (id?: DialogId) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodeTypes } from '@hedron/engine/store/types'
import { NodeTypes } from '@hedron/engine'
import { useOnSelectNode } from '@components/hooks/useOnSelectNode'
import { ParamWithInfo, useActiveSketchParams } from '@components/hooks/useActiveSketchParams'
import { ParamNumber } from '@components/ParamNumber/ParamNumber'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { forwardRef, useCallback, useImperativeHandle, useRef } from 'react'
import { EnumOption } from '@hedron/engine/store/types'
import { EnumOption } from '@hedron/engine'

export type EnumDropdownHandle = {
setValue: (value: string) => void
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMemo } from 'react'
import { Param } from '@hedron/engine/index'
import { Param } from '@hedron/engine'
import { useActiveSketch } from '@components/hooks/useActiveSketch'
import { useEngineStore } from '@renderer/engine'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback } from 'react'
import { NodeValue } from '@hedron/engine/store/types'
import { NodeValue } from '@hedron/engine'
import { useUpdateNodeValue } from '@components/hooks/useUpdateNodeValue'

export const useOnNodeValueChange = (id: string) => {
Expand Down
4 changes: 1 addition & 3 deletions packages/desktop/src/renderer/engine.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { useStore } from 'zustand'
import { HedronEngine } from '@hedron/engine/index'
import { EngineStateWithActions } from '@hedron/engine/store/types'
import { HedronEngine, EngineStateWithActions } from '@hedron/engine'

export const engine = new HedronEngine()

export const engineStore = engine.getStore()

export const useEngineStore = <T>(selector?: (state: EngineStateWithActions) => T) => {
// @ts-expect-error -- might be an issue with zustand...
return useStore(engineStore, selector!)
}
2 changes: 1 addition & 1 deletion packages/desktop/src/shared/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EngineData } from '@hedron/engine/store/types'
import { EngineData } from '@hedron/engine'

export interface ProjectData {
version: number
Expand Down
6 changes: 0 additions & 6 deletions packages/engine/index.ts

This file was deleted.

9 changes: 8 additions & 1 deletion packages/engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"version": "0.0.0",
"description": "Core functionality for Hedron",
"keywords": [],
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"typecheck": "tsc --noEmit -p tsconfig.json",
"dev": "tsup --watch",
"build": "tsup",
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix"
},
"repository": {
Expand All @@ -14,5 +18,8 @@
"bugs": {
"url": "https://github.com/nudibranchrecords/hedron/issues"
},
"homepage": "https://github.com/nudibranchrecords/hedron#readme"
"homepage": "https://github.com/nudibranchrecords/hedron#readme",
"devDependencies": {
"tsup": "^8.3.5"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { importSketchModule } from './importSketchModule'
import { listenToStore } from './storeListener'
import { importSketchModule } from './importSketchModule'
import { stripForSave } from '@utils/stripForSave'
import { Renderer } from '@world/Renderer'
import { SketchManager } from '@world/SketchManager'
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions packages/engine/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './HedronEngine'
export * from '@store/types'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions packages/engine/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"extends": ["../../tsconfig.json"],
"include": ["src/**/*"],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@store/*": ["store/*"],
"@utils/*": ["utils/*"],
"@world/*": ["world/*"]
"@store/*": ["src/store/*"],
"@utils/*": ["src/utils/*"],
"@world/*": ["src/world/*"]
}
}
}
8 changes: 8 additions & 0 deletions packages/engine/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'tsup'

export default defineConfig({
entry: ['src/index.ts'],
sourcemap: true,
clean: true,
dts: true,
})
Loading

0 comments on commit adb6121

Please sign in to comment.