Skip to content

Commit 3d068fc

Browse files
authored
refactor: finish package split cleanup (#156)
## Summary Follow-up to #149. The package split was done mostly automatically, leaving behind a few cases of code duplication. This PR finishes the cleanup. - **Delete `packages/ios/src/renderer/` shims** — 7 one-liner re-export files (`context-registry`, `dispatcher`, `element-registry`, `flatten-styles`, `render-cache`, `stylesheet-registry`, `types`) were left over from the split, making `@use-voltra/ios` look like it had its own renderer. Removed them and cleaned up the barrel `index.ts`. - **Re-export `createVoltraComponent` from core** — the implementation was duplicated verbatim in `@use-voltra/ios` and `@use-voltra/android`. Core already owns and exports it — both platform packages now re-export from there. Internal consumers within each package continue to import from the local path, transparently resolving through the re-export. ### What was considered but left alone - `chart-types.ts` (`ChartDataPoint`, `SectorDataPoint`) — identical 2-line type file in both platform packages. Moving to core would give a platform-agnostic renderer package chart-domain knowledge. Duplication is acceptable at this size. - `useUpdateOnHMR.ts` — identical 20-line RN hook in both client packages. Uses `__DEV__` and Metro's `global.__accept`, so it can't go to core. No appropriate shared home without a new package for 20 lines. - `widgets/server-credentials.ts` — near-identical in `@use-voltra/ios-client` and `@use-voltra/android-client`, differing only in the native module import, error message platform label, and caller. The differences are genuine platform facts; there is no valid shared home (clients cannot depend on each other, and both are restricted from importing `@use-voltra/core` directly). - `VoltraRNNativeComponent.ts` — present in both client `native/` dirs, differing only in the registered native view name (`'VoltraView'` vs `'AndroidVoltraView'`). Intentional — different native components for each platform. - `fonts.ts` across expo-plugins — not actually duplicated. `packages/expo-plugin/src/utils/fonts.ts` is a shared utility; the platform-specific plugin files (`ios-client/expo-plugin` and `android-client/expo-plugin`) import `resolveFontPaths` from it. Structure is correct. - Lint rules for RN/expo in `@use-voltra/ios` and `@use-voltra/android` — already in place in #149. - Dependency audit — all packages clean; RN and expo only appear in `peerDependencies`. ## Test plan - [x] `tsc --noEmit` passes on `@use-voltra/ios` and `@use-voltra/android` - [x] `@use-voltra/ios` test suite passes (5/5) - [x] `@use-voltra/android` test suite passes (6/6) - [x] `oxlint` passes on all changed packages
1 parent 7b6b387 commit 3d068fc

10 files changed

Lines changed: 12 additions & 80 deletions

File tree

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,6 @@
1-
import type { ComponentType } from 'react'
2-
import { createElement } from 'react'
3-
4-
export const VOLTRA_COMPONENT_TAG = Symbol.for('VOLTRA_COMPONENT_TAG')
5-
6-
export type VoltraComponent<TProps extends Record<string, unknown>> = ComponentType<TProps> & {
7-
displayName: string
8-
[VOLTRA_COMPONENT_TAG]: true
9-
}
10-
11-
export type VoltraComponentOptions<TProps extends Record<string, unknown>> = {
12-
toJSON?: (props: TProps) => Record<string, unknown>
13-
}
14-
15-
export const createVoltraComponent = <TProps extends Record<string, unknown>>(
16-
componentName: string,
17-
options?: VoltraComponentOptions<TProps>
18-
): VoltraComponent<TProps> => {
19-
const Component = (props: TProps) => {
20-
const toJSON = options?.toJSON ? options.toJSON : (value: TProps) => value
21-
const normalizedProps = toJSON(props)
22-
23-
return createElement(componentName, normalizedProps)
24-
}
25-
26-
Component[VOLTRA_COMPONENT_TAG] = true
27-
Component.displayName = componentName
28-
29-
return Component as VoltraComponent<TProps>
30-
}
31-
32-
export const isVoltraComponent = <TProps extends Record<string, unknown>>(
33-
component: ComponentType<TProps>
34-
): component is VoltraComponent<TProps> => {
35-
return typeof component === 'function' && VOLTRA_COMPONENT_TAG in component
36-
}
1+
export {
2+
createVoltraComponent,
3+
isVoltraComponent,
4+
VOLTRA_COMPONENT_TAG,
5+
} from '@use-voltra/core'
6+
export type { VoltraComponent, VoltraComponentOptions } from '@use-voltra/core'
Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,6 @@
1-
import type { ComponentType } from 'react'
2-
import { createElement } from 'react'
3-
4-
export const VOLTRA_COMPONENT_TAG = Symbol.for('VOLTRA_COMPONENT_TAG')
5-
6-
export type VoltraComponent<TProps extends Record<string, unknown>> = ComponentType<TProps> & {
7-
displayName: string
8-
[VOLTRA_COMPONENT_TAG]: true
9-
}
10-
11-
export type VoltraComponentOptions<TProps extends Record<string, unknown>> = {
12-
toJSON?: (props: TProps) => Record<string, unknown>
13-
}
14-
15-
export const createVoltraComponent = <TProps extends Record<string, unknown>>(
16-
componentName: string,
17-
options?: VoltraComponentOptions<TProps>
18-
): VoltraComponent<TProps> => {
19-
const Component = (props: TProps) => {
20-
const toJSON = options?.toJSON ? options.toJSON : (value: TProps) => value
21-
const normalizedProps = toJSON(props)
22-
23-
return createElement(componentName, normalizedProps)
24-
}
25-
26-
Component[VOLTRA_COMPONENT_TAG] = true
27-
Component.displayName = componentName
28-
29-
return Component as VoltraComponent<TProps>
30-
}
31-
32-
export const isVoltraComponent = <TProps extends Record<string, unknown>>(
33-
component: ComponentType<TProps>
34-
): component is VoltraComponent<TProps> => {
35-
return typeof component === 'function' && VOLTRA_COMPONENT_TAG in component
36-
}
1+
export {
2+
createVoltraComponent,
3+
isVoltraComponent,
4+
VOLTRA_COMPONENT_TAG,
5+
} from '@use-voltra/core'
6+
export type { VoltraComponent, VoltraComponentOptions } from '@use-voltra/core'

packages/ios/src/renderer/context-registry.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ios/src/renderer/dispatcher.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ios/src/renderer/element-registry.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ios/src/renderer/flatten-styles.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ios/src/renderer/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export { flattenStyle } from './flatten-styles.js'
21
export {
32
type ComponentRegistry,
43
createVoltraRenderer,

packages/ios/src/renderer/render-cache.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ios/src/renderer/stylesheet-registry.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ios/src/renderer/types.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)