diff --git a/.changeset/solid-snakes-poke.md b/.changeset/solid-snakes-poke.md new file mode 100644 index 0000000..6ee06ea --- /dev/null +++ b/.changeset/solid-snakes-poke.md @@ -0,0 +1,16 @@ +--- +"@plextv/vite-plugin-react-reanimated-lightning": patch +"@plextv/vite-plugin-react-native-lightning": patch +"@plextv/react-native-lightning-components": patch +"@plextv/react-lightning-components": patch +"@plextv/vite-plugin-msdf-fontgen": patch +"@plextv/react-native-lightning": patch +"@plextv/react-lightning-plugin-css-transform": patch +"@plextv/react-lightning-plugin-flexbox-lite": patch +"@plextv/react-lightning-plugin-reanimated": patch +"@plextv/react-lightning": patch +"@plextv/react-lightning-plugin-flexbox": patch +"@repo/configs": patch +--- + +fix: Fix builds and enable isolated declarations diff --git a/.npmrc b/.npmrc index 3e775ef..7a5cba3 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,4 @@ auto-install-peers=true + +# Prefer exact dependency versions. +save-prefix="" diff --git a/package.json b/package.json index 7a49133..b766513 100644 --- a/package.json +++ b/package.json @@ -41,13 +41,13 @@ "glob": "11.0.3", "husky": "9.1.7", "listr2": "9.0.4", - "tsdown": "^0.15.7", + "tsdown": "0.16.6", "tsx": "4.20.6", "turbo": "2.5.8", "type-fest": "5.1.0", "typescript": "5.9.3", "vite": "7.1.10", - "vite-plugin-externalize-deps": "^0.10.0", + "vite-plugin-externalize-deps": "0.10.0", "vitest": "3.2.4", "yaml": "2.8.1" }, diff --git a/packages/configs/tsconfig.json b/packages/configs/tsconfig.json index 231462e..9b0699f 100644 --- a/packages/configs/tsconfig.json +++ b/packages/configs/tsconfig.json @@ -7,6 +7,7 @@ "esModuleInterop": true, "incremental": false, "isolatedModules": true, + "isolatedDeclarations": true, "lib": ["es2022", "DOM", "DOM.Iterable"], "module": "ESNext", "moduleDetection": "force", diff --git a/packages/configs/tsdown.config.ts b/packages/configs/tsdown.config.ts index 8822618..f9114c4 100644 --- a/packages/configs/tsdown.config.ts +++ b/packages/configs/tsdown.config.ts @@ -1,16 +1,17 @@ -import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; -export default defineConfig({ +const config: UserConfig = defineConfig({ entry: ['src/index.ts'], format: ['cjs', 'esm'], target: 'chrome56', platform: 'browser', sourcemap: true, - dts: true, + dts: { + oxc: true, + }, loader: { '.png': 'asset', }, - // minify: false, exports: { devExports: true, }, @@ -20,3 +21,5 @@ export default defineConfig({ }, }, }); + +export default config; diff --git a/packages/plugin-css-transform/src/utils/convertCSSTransformToLightning.ts b/packages/plugin-css-transform/src/utils/convertCSSTransformToLightning.ts index ab1499c..6f7b526 100644 --- a/packages/plugin-css-transform/src/utils/convertCSSTransformToLightning.ts +++ b/packages/plugin-css-transform/src/utils/convertCSSTransformToLightning.ts @@ -47,7 +47,7 @@ export function convertCSSTransformToLightning( | number | number[] | Record, -) { +): Transform { const transformResult: Transform = {}; if (typeof transformValue === 'object') { diff --git a/packages/plugin-css-transform/src/utils/convertRotationValue.ts b/packages/plugin-css-transform/src/utils/convertRotationValue.ts index 6394c36..e5ab660 100644 --- a/packages/plugin-css-transform/src/utils/convertRotationValue.ts +++ b/packages/plugin-css-transform/src/utils/convertRotationValue.ts @@ -1,4 +1,4 @@ -export function convertRotationValue(value: string) { +export function convertRotationValue(value: string): number { if (value.endsWith('deg')) { return (Number.parseFloat(value) * Math.PI) / 180; } diff --git a/packages/plugin-css-transform/tsconfig.json b/packages/plugin-css-transform/tsconfig.json index b86cf74..38c714b 100644 --- a/packages/plugin-css-transform/tsconfig.json +++ b/packages/plugin-css-transform/tsconfig.json @@ -1,10 +1,5 @@ { "extends": "@repo/configs/tsconfig.react-library.json", - "compilerOptions": { - "rootDir": "src", - "declaration": false, - "declarationMap": false - }, "include": ["src"], "exclude": ["node_modules", "dist"] } diff --git a/packages/plugin-css-transform/tsdown.config.ts b/packages/plugin-css-transform/tsdown.config.ts index b9c965a..d67c1c7 100644 --- a/packages/plugin-css-transform/tsdown.config.ts +++ b/packages/plugin-css-transform/tsdown.config.ts @@ -1,7 +1,7 @@ -import baseConfig from '@repo/configs/tsdown.config'; -import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; +import baseConfig from '../configs/tsdown.config'; -export default defineConfig({ +const config: UserConfig = defineConfig({ ...baseConfig, entry: ['src/index.ts', 'src/types/jsx.d.ts'], exports: { @@ -17,3 +17,5 @@ export default defineConfig({ }, }, }); + +export default config; diff --git a/packages/plugin-flexbox-lite/tsconfig.json b/packages/plugin-flexbox-lite/tsconfig.json index b166c95..57bcdb0 100644 --- a/packages/plugin-flexbox-lite/tsconfig.json +++ b/packages/plugin-flexbox-lite/tsconfig.json @@ -1,10 +1,5 @@ { "extends": "@repo/configs/tsconfig.react-library.json", - "compilerOptions": { - "rootDir": "src", - "declaration": false, - "declarationMap": false - }, "include": ["src", "../../types/*.d.ts"], "exclude": ["node_modules", "dist"] } diff --git a/packages/plugin-flexbox-lite/tsdown.config.ts b/packages/plugin-flexbox-lite/tsdown.config.ts index 004f057..f9b2474 100644 --- a/packages/plugin-flexbox-lite/tsdown.config.ts +++ b/packages/plugin-flexbox-lite/tsdown.config.ts @@ -1,7 +1,7 @@ -import baseConfig from '@repo/configs/tsdown.config'; -import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; +import baseConfig from '../configs/tsdown.config'; -export default defineConfig({ +const config: UserConfig = defineConfig({ ...baseConfig, entry: ['./src/index.ts', './src/types/jsx.d.ts'], exports: { @@ -17,3 +17,5 @@ export default defineConfig({ }, }, }); + +export default config; diff --git a/packages/plugin-flexbox/src/LightningManager.ts b/packages/plugin-flexbox/src/LightningManager.ts index 02ed346..6936ce5 100644 --- a/packages/plugin-flexbox/src/LightningManager.ts +++ b/packages/plugin-flexbox/src/LightningManager.ts @@ -19,7 +19,7 @@ export class LightningManager { private _elements = new Map(); private _yogaManager: YogaManager | Workerized | undefined; - public async init(yogaOptions?: YogaOptions) { + public async init(yogaOptions?: YogaOptions): Promise { this._yogaManager = await loadYoga(yogaOptions); this._yogaManager.on('render', this._applyUpdates); } @@ -105,7 +105,7 @@ export class LightningManager { elementId: number, style?: Partial | null, skipRender = false, - ) { + ): void { if (!this._elements.has(elementId)) { return; } diff --git a/packages/plugin-flexbox/src/YogaManager.ts b/packages/plugin-flexbox/src/YogaManager.ts index b53e3c4..27ae55f 100644 --- a/packages/plugin-flexbox/src/YogaManager.ts +++ b/packages/plugin-flexbox/src/YogaManager.ts @@ -54,10 +54,13 @@ export class YogaManager { private _eventEmitter: EventEmitter = new EventEmitter(); private _dataView: SimpleDataView; - public on = this._eventEmitter.on.bind(this._eventEmitter); - public off = this._eventEmitter.off.bind(this._eventEmitter); + public on: EventEmitter['on'] = this._eventEmitter.on.bind( + this._eventEmitter, + ); + public off: EventEmitter['off'] = + this._eventEmitter.off.bind(this._eventEmitter); - public get initialized() { + public get initialized(): boolean { return this._initialized; } @@ -69,7 +72,7 @@ export class YogaManager { ); } - public async init(yogaOptions?: YogaOptions) { + public async init(yogaOptions?: YogaOptions): Promise { Object.assign(this._yogaOptions, yogaOptions); this._yoga = await loadYoga(); @@ -104,7 +107,7 @@ export class YogaManager { this._initialized = true; } - public addNode(elementId: number) { + public addNode(elementId: number): ManagerNode { if (this._elementMap.has(elementId)) { // biome-ignore lint/style/noNonNullAssertion: Already checked return this._elementMap.get(elementId)!; @@ -117,7 +120,7 @@ export class YogaManager { return node; } - public removeNode(elementId: number) { + public removeNode(elementId: number): void { const yogaNode = this._elementMap.get(elementId); if (yogaNode) { @@ -136,7 +139,7 @@ export class YogaManager { } } - public addChildNode(parentId: number, childId: number, index?: number) { + public addChildNode(parentId: number, childId: number, index?: number): void { const parentYogaNode = this._elementMap.get(parentId); const childYogaNode = this._elementMap.get(childId); @@ -153,7 +156,7 @@ export class YogaManager { childYogaNode.parent = parentYogaNode; } - public queueRender(elementId: number, force = false) { + public queueRender(elementId: number, force = false): void { if (!this._initialized || !this._yoga) { throw new Error('Yoga is not initialized! Did you call `init()`?'); } @@ -199,7 +202,7 @@ export class YogaManager { public applyStyles( styles: Record>, skipRender = false, - ) { + ): void { if (!this._initialized) { throw new Error('Yoga was not initialized! Did you call `init()`?'); } @@ -215,7 +218,7 @@ export class YogaManager { elementId: number, style: Partial | null, skipRender = false, - ) { + ): void { if (!style) { return; } diff --git a/packages/plugin-flexbox/src/YogaManagerWorker.ts b/packages/plugin-flexbox/src/YogaManagerWorker.ts index 251c052..83793e5 100644 --- a/packages/plugin-flexbox/src/YogaManagerWorker.ts +++ b/packages/plugin-flexbox/src/YogaManagerWorker.ts @@ -341,4 +341,5 @@ function getId(): number { return ++count; } -export default () => wrapWorker(new Worker()); +export default (): Workerized => + wrapWorker(new Worker()); diff --git a/packages/plugin-flexbox/src/util/SimpleDataView.ts b/packages/plugin-flexbox/src/util/SimpleDataView.ts index 3f60535..ee7795d 100644 --- a/packages/plugin-flexbox/src/util/SimpleDataView.ts +++ b/packages/plugin-flexbox/src/util/SimpleDataView.ts @@ -37,23 +37,23 @@ export class SimpleDataView { this._overflowHandler = overflowHandler; } - get buffer() { + get buffer(): ArrayBuffer { return this._buffer.slice(0, this._offset); } - get fullBuffer() { + get fullBuffer(): ArrayBuffer { return this._buffer; } - get dataView() { + get dataView(): DataView { return this._view; } - get offset() { + get offset(): number { return this._offset; } - public reset() { + public reset(): void { this._buffer = new ArrayBuffer(this._maxSize); this._view = new DataView(this._buffer); this._offset = 0; @@ -66,7 +66,7 @@ export class SimpleDataView { } // Shifts the offset back by the specified size. - public shift(size: number) { + public shift(size: number): void { if (this._offset < size) { throw new Error('Cannot shift more than current offset'); } @@ -74,7 +74,7 @@ export class SimpleDataView { this._offset -= size; } - public moveTo(offset: number) { + public moveTo(offset: number): void { if (offset < 0 || offset >= this._maxSize) { throw new Error('Offset out of bounds'); } @@ -82,7 +82,7 @@ export class SimpleDataView { this._offset = offset; } - public moveBy(delta: number) { + public moveBy(delta: number): void { if (!this.hasSpace(delta)) { throw new Error('Offset out of bounds'); } @@ -90,59 +90,71 @@ export class SimpleDataView { this._offset += delta; } - public readUint8 = () => this._readInt(1, true); - public readUint8At = (offset: number) => this._readIntAt(offset, 1, true); - public readInt8 = () => this._readInt(1, false); - public readInt8At = (offset: number) => this._readIntAt(offset, 1, false); - public writeUint8 = (value: number) => this._writeInt(1, value, true); - public writeUint8At = (offset: number, value: number) => + public readUint8 = (): number => this._readInt(1, true); + public readUint8At = (offset: number): number => + this._readIntAt(offset, 1, true); + public readInt8 = (): number => this._readInt(1, false); + public readInt8At = (offset: number): number => + this._readIntAt(offset, 1, false); + public writeUint8 = (value: number): void => this._writeInt(1, value, true); + public writeUint8At = (offset: number, value: number): void => this._writeIntAt(offset, value, 1, true); - public writeInt8 = (value: number) => this._writeInt(1, value, false); - public writeInt8At = (offset: number, value: number) => + public writeInt8 = (value: number): void => this._writeInt(1, value, false); + public writeInt8At = (offset: number, value: number): void => this._writeIntAt(offset, value, 1, false); - public readUint16 = () => this._readInt(2, true); - public readUint16At = (offset: number) => this._readIntAt(offset, 2, true); - public readInt16 = () => this._readInt(2, false); - public readInt16At = (offset: number) => this._readIntAt(offset, 2, false); - public writeUint16 = (value: number) => this._writeInt(2, value, true); - public writeUint16At = (offset: number, value: number) => + public readUint16 = (): number => this._readInt(2, true); + public readUint16At = (offset: number): number => + this._readIntAt(offset, 2, true); + public readInt16 = (): number => this._readInt(2, false); + public readInt16At = (offset: number): number => + this._readIntAt(offset, 2, false); + public writeUint16 = (value: number): void => this._writeInt(2, value, true); + public writeUint16At = (offset: number, value: number): void => this._writeIntAt(offset, value, 2, true); - public writeInt16 = (value: number) => this._writeInt(2, value, false); - public writeInt16At = (offset: number, value: number) => + public writeInt16 = (value: number): void => this._writeInt(2, value, false); + public writeInt16At = (offset: number, value: number): void => this._writeIntAt(offset, value, 2, false); - public readUint32 = () => this._readInt(4, true); - public readUint32At = (offset: number) => this._readIntAt(offset, 4, true); - public readInt32 = () => this._readInt(4, false); - public readInt32At = (offset: number) => this._readIntAt(offset, 4, false); - public writeUint32 = (value: number) => this._writeInt(4, value, true); - public writeUint32At = (offset: number, value: number) => + public readUint32 = (): number => this._readInt(4, true); + public readUint32At = (offset: number): number => + this._readIntAt(offset, 4, true); + public readInt32 = (): number => this._readInt(4, false); + public readInt32At = (offset: number): number => + this._readIntAt(offset, 4, false); + public writeUint32 = (value: number): void => this._writeInt(4, value, true); + public writeUint32At = (offset: number, value: number): void => this._writeIntAt(offset, value, 4, true); - public writeInt32 = (value: number) => this._writeInt(4, value, false); - public writeInt32At = (offset: number, value: number) => + public writeInt32 = (value: number): void => this._writeInt(4, value, false); + public writeInt32At = (offset: number, value: number): void => this._writeIntAt(offset, value, 4, false); - public readBigUint64 = () => this._readInt(8, true); - public readBigUint64At = (offset: number) => this._readIntAt(offset, 8, true); - public readBigInt64 = () => this._readInt(8, false); - public readBigInt64At = (offset: number) => this._readIntAt(offset, 8, false); - public writeBigUint64 = (value: bigint) => this._writeInt(8, value, true); - public writeBigUint64At = (offset: number, value: bigint) => + public readBigUint64 = (): bigint => this._readInt(8, true); + public readBigUint64At = (offset: number): bigint => + this._readIntAt(offset, 8, true); + public readBigInt64 = (): bigint => this._readInt(8, false); + public readBigInt64At = (offset: number): bigint => + this._readIntAt(offset, 8, false); + public writeBigUint64 = (value: bigint): void => + this._writeInt(8, value, true); + public writeBigUint64At = (offset: number, value: bigint): void => this._writeIntAt(offset, value, 8, true); - public writeBigInt64 = (value: bigint) => this._writeInt(8, value, false); - public writeBigInt64At = (offset: number, value: bigint) => + public writeBigInt64 = (value: bigint): void => + this._writeInt(8, value, false); + public writeBigInt64At = (offset: number, value: bigint): void => this._writeIntAt(offset, value, 8, false); - public readFloat32 = () => this._readFloat(4); - public readFloat32At = (offset: number) => this._readFloatAt(offset, 4); - public readFloat64 = () => this._readFloat(8); - public readFloat64At = (offset: number) => this._readFloatAt(offset, 8); - public writeFloat32 = (value: number) => this._writeFloat(4, value); - public writeFloat32At = (offset: number, value: number) => + public readFloat32 = (): number => this._readFloat(4); + public readFloat32At = (offset: number): number => + this._readFloatAt(offset, 4); + public readFloat64 = (): number => this._readFloat(8); + public readFloat64At = (offset: number): number => + this._readFloatAt(offset, 8); + public writeFloat32 = (value: number): void => this._writeFloat(4, value); + public writeFloat32At = (offset: number, value: number): void => this._writeFloatAt(offset, value, 4); - public writeFloat64 = (value: number) => this._writeFloat(8, value); - public writeFloat64At = (offset: number, value: number) => + public writeFloat64 = (value: number): void => this._writeFloat(8, value); + public writeFloat64At = (offset: number, value: number): void => this._writeFloatAt(offset, value, 8); private _checkOverflow(size: number) { diff --git a/packages/plugin-flexbox/src/util/applyReactPropsToYoga.ts b/packages/plugin-flexbox/src/util/applyReactPropsToYoga.ts index 83a776e..1f61137 100644 --- a/packages/plugin-flexbox/src/util/applyReactPropsToYoga.ts +++ b/packages/plugin-flexbox/src/util/applyReactPropsToYoga.ts @@ -161,7 +161,7 @@ export default function applyReactPropsToYoga( config: YogaOptions, node: Node, style: Partial, -) { +): void { for (const [prop, value] of Object.entries(style)) { if (isFlexStyleProp(prop)) { applyFlexPropToYoga( diff --git a/packages/plugin-flexbox/src/util/getYogaStyle.ts b/packages/plugin-flexbox/src/util/getYogaStyle.ts index c54cd33..784216e 100644 --- a/packages/plugin-flexbox/src/util/getYogaStyle.ts +++ b/packages/plugin-flexbox/src/util/getYogaStyle.ts @@ -3,7 +3,7 @@ import { isFlexStyleProp } from './isFlexStyleProp'; export function getYogaStyle( style: Partial | null = {}, -) { +): Partial { const yogaStyles: typeof style = {}; for (const key in style) { diff --git a/packages/plugin-flexbox/src/util/isFlexStyleProp.ts b/packages/plugin-flexbox/src/util/isFlexStyleProp.ts index 9a6ea84..49f3801 100644 --- a/packages/plugin-flexbox/src/util/isFlexStyleProp.ts +++ b/packages/plugin-flexbox/src/util/isFlexStyleProp.ts @@ -53,7 +53,9 @@ export const flexProps = { left: true, right: true, bottom: true, -} as const satisfies Partial>; +} as const; + +flexProps satisfies Partial>; export type FlexProps = keyof typeof flexProps; diff --git a/packages/plugin-flexbox/src/yoga.ts b/packages/plugin-flexbox/src/yoga.ts index 23ee9e9..11c1860 100644 --- a/packages/plugin-flexbox/src/yoga.ts +++ b/packages/plugin-flexbox/src/yoga.ts @@ -1,6 +1,10 @@ import type { YogaOptions } from './types/YogaOptions'; +import type { YogaManager } from './YogaManager'; +import type { Workerized } from './YogaManagerWorker'; -async function load(yogaOptions: YogaOptions = {}) { +async function load( + yogaOptions: YogaOptions = {}, +): Promise> { if (yogaOptions.useWebWorker) { const { default: createWorkerManager } = await import( './YogaManagerWorker' diff --git a/packages/plugin-flexbox/tsconfig.json b/packages/plugin-flexbox/tsconfig.json index d8f78e2..9315187 100644 --- a/packages/plugin-flexbox/tsconfig.json +++ b/packages/plugin-flexbox/tsconfig.json @@ -1,9 +1,6 @@ { "extends": "@repo/configs/tsconfig.react-library.json", "compilerOptions": { - "rootDir": "src", - "declaration": false, - "declarationMap": false, "lib": ["es2022", "DOM", "DOM.Iterable", "WebWorker"] }, "include": ["src", "../../types/*.d.ts"], diff --git a/packages/plugin-flexbox/tsdown.lib.ts b/packages/plugin-flexbox/tsdown.lib.ts index b9c965a..d67c1c7 100644 --- a/packages/plugin-flexbox/tsdown.lib.ts +++ b/packages/plugin-flexbox/tsdown.lib.ts @@ -1,7 +1,7 @@ -import baseConfig from '@repo/configs/tsdown.config'; -import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; +import baseConfig from '../configs/tsdown.config'; -export default defineConfig({ +const config: UserConfig = defineConfig({ ...baseConfig, entry: ['src/index.ts', 'src/types/jsx.d.ts'], exports: { @@ -17,3 +17,5 @@ export default defineConfig({ }, }, }); + +export default config; diff --git a/packages/plugin-flexbox/tsdown.worker.ts b/packages/plugin-flexbox/tsdown.worker.ts index af8f4bc..245bc6c 100644 --- a/packages/plugin-flexbox/tsdown.worker.ts +++ b/packages/plugin-flexbox/tsdown.worker.ts @@ -1,6 +1,6 @@ -import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; -export default defineConfig([ +const config: UserConfig[] = defineConfig([ { entry: './src/worker.ts', format: 'cjs', @@ -12,3 +12,5 @@ export default defineConfig([ }, }, ]); + +export default config; diff --git a/packages/plugin-reanimated/src/animation/springUtils.ts b/packages/plugin-reanimated/src/animation/springUtils.ts index 321a36c..39cc9e1 100644 --- a/packages/plugin-reanimated/src/animation/springUtils.ts +++ b/packages/plugin-reanimated/src/animation/springUtils.ts @@ -109,7 +109,7 @@ export function getEnergy( velocity: number, stiffness: number, mass: number, -) { +): number { const potentialEnergy = 0.5 * stiffness * displacement ** 2; const kineticEnergy = 0.5 * mass * velocity ** 2; @@ -119,7 +119,7 @@ export function getEnergy( export function calculateNewStiffnessToMatchDuration( x0: number, config: DefaultSpringConfig, -) { +): number { /** * Use this formula: * https://phys.libretexts.org/Bookshelves/University_Physics/Book%3A_University_Physics_(OpenStax)/Book%3A_University_Physics_I_-_Mechanics_Sound_Oscillations_and_Waves_(OpenStax)/15%3A_Oscillations/15.06%3A_Damped_Oscillations diff --git a/packages/plugin-reanimated/src/builders/Fade.ts b/packages/plugin-reanimated/src/builders/Fade.ts index de571d2..8af543d 100644 --- a/packages/plugin-reanimated/src/builders/Fade.ts +++ b/packages/plugin-reanimated/src/builders/Fade.ts @@ -12,10 +12,11 @@ import { FadeOutRight as ReanimatedFadeOutRight, FadeOutUp as ReanimatedFadeOutUp, } from 'react-native-reanimated-original'; +import type { Class } from 'type-fest'; import { withTiming } from '../exports/withTiming'; import { createBuilderWrapper } from './createBuilderWrapper'; -export const FadeIn = createBuilderWrapper( +export const FadeIn: Class = createBuilderWrapper( ReanimatedFadeIn, function (this: ReanimatedFadeIn) { return () => ({ @@ -33,7 +34,7 @@ export const FadeIn = createBuilderWrapper( }, ); -export const FadeInRight = createBuilderWrapper( +export const FadeInRight: Class = createBuilderWrapper( ReanimatedFadeInRight, function (this: ReanimatedFadeInRight) { return (values: EntryAnimationsValues) => ({ @@ -56,7 +57,7 @@ export const FadeInRight = createBuilderWrapper( }, ); -export const FadeInLeft = createBuilderWrapper( +export const FadeInLeft: Class = createBuilderWrapper( ReanimatedFadeInLeft, function (this: ReanimatedFadeInLeft) { return (values: EntryAnimationsValues) => ({ @@ -79,7 +80,7 @@ export const FadeInLeft = createBuilderWrapper( }, ); -export const FadeInUp = createBuilderWrapper( +export const FadeInUp: Class = createBuilderWrapper( ReanimatedFadeInUp, function (this: ReanimatedFadeInUp) { return (values: EntryAnimationsValues) => ({ @@ -102,7 +103,7 @@ export const FadeInUp = createBuilderWrapper( }, ); -export const FadeInDown = createBuilderWrapper( +export const FadeInDown: Class = createBuilderWrapper( ReanimatedFadeInDown, function (this: ReanimatedFadeInDown) { return (values: EntryAnimationsValues) => ({ @@ -125,7 +126,7 @@ export const FadeInDown = createBuilderWrapper( }, ); -export const FadeOut = createBuilderWrapper( +export const FadeOut: Class = createBuilderWrapper( ReanimatedFadeOut, function (this: ReanimatedFadeOut) { return () => ({ @@ -143,7 +144,7 @@ export const FadeOut = createBuilderWrapper( }, ); -export const FadeOutRight = createBuilderWrapper( +export const FadeOutRight: Class = createBuilderWrapper( ReanimatedFadeOutRight, function (this: ReanimatedFadeOutRight) { return (values: ExitAnimationsValues) => ({ @@ -166,7 +167,7 @@ export const FadeOutRight = createBuilderWrapper( }, ); -export const FadeOutLeft = createBuilderWrapper( +export const FadeOutLeft: Class = createBuilderWrapper( ReanimatedFadeOutLeft, function (this: ReanimatedFadeOutLeft) { return (values: ExitAnimationsValues) => ({ @@ -189,7 +190,7 @@ export const FadeOutLeft = createBuilderWrapper( }, ); -export const FadeOutUp = createBuilderWrapper( +export const FadeOutUp: Class = createBuilderWrapper( ReanimatedFadeOutUp, function (this: ReanimatedFadeOutUp) { return (values: ExitAnimationsValues) => ({ @@ -212,7 +213,7 @@ export const FadeOutUp = createBuilderWrapper( }, ); -export const FadeOutDown = createBuilderWrapper( +export const FadeOutDown: Class = createBuilderWrapper( ReanimatedFadeOutDown, function (this: ReanimatedFadeOutDown) { return (values: ExitAnimationsValues) => ({ diff --git a/packages/plugin-reanimated/src/builders/Slide.ts b/packages/plugin-reanimated/src/builders/Slide.ts index 040dde3..d0123be 100644 --- a/packages/plugin-reanimated/src/builders/Slide.ts +++ b/packages/plugin-reanimated/src/builders/Slide.ts @@ -10,10 +10,11 @@ import { SlideOutRight as ReanimatedSlideOutRight, SlideOutUp as ReanimatedSlideOutUp, } from 'react-native-reanimated-original'; +import type { Class } from 'type-fest'; import { withTiming } from '../exports/withTiming'; import { createBuilderWrapper } from './createBuilderWrapper'; -export const SlideInRight = createBuilderWrapper( +export const SlideInRight: Class = createBuilderWrapper( ReanimatedSlideInRight, function (this: ReanimatedSlideInRight) { return (values: EntryAnimationsValues) => ({ @@ -31,7 +32,7 @@ export const SlideInRight = createBuilderWrapper( }, ); -export const SlideInLeft = createBuilderWrapper( +export const SlideInLeft: Class = createBuilderWrapper( ReanimatedSlideInLeft, function (this: ReanimatedSlideInLeft) { return (values: EntryAnimationsValues) => ({ @@ -49,7 +50,7 @@ export const SlideInLeft = createBuilderWrapper( }, ); -export const SlideInUp = createBuilderWrapper( +export const SlideInUp: Class = createBuilderWrapper( ReanimatedSlideInUp, function (this: ReanimatedSlideInUp) { return (values: EntryAnimationsValues) => ({ @@ -67,7 +68,7 @@ export const SlideInUp = createBuilderWrapper( }, ); -export const SlideInDown = createBuilderWrapper( +export const SlideInDown: Class = createBuilderWrapper( ReanimatedSlideInDown, function (this: ReanimatedSlideInDown) { return (values: EntryAnimationsValues) => ({ @@ -85,31 +86,32 @@ export const SlideInDown = createBuilderWrapper( }, ); -export const SlideOutRight = createBuilderWrapper( - ReanimatedSlideOutRight, - function (this: ReanimatedSlideOutRight) { - return (values: ExitAnimationsValues) => ({ - animations: { - x: withTiming( - Math.max( - values.currentOriginX + values.windowWidth, - values.windowWidth, +export const SlideOutRight: Class = + createBuilderWrapper( + ReanimatedSlideOutRight, + function (this: ReanimatedSlideOutRight) { + return (values: ExitAnimationsValues) => ({ + animations: { + x: withTiming( + Math.max( + values.currentOriginX + values.windowWidth, + values.windowWidth, + ), + { + duration: this.durationV, + easing: this.easingV, + }, ), - { - duration: this.durationV, - easing: this.easingV, - }, - ), - }, - initialValues: { - x: values.currentOriginX, - }, - callback: this.callbackV, - }); - }, -); + }, + initialValues: { + x: values.currentOriginX, + }, + callback: this.callbackV, + }); + }, + ); -export const SlideOutLeft = createBuilderWrapper( +export const SlideOutLeft: Class = createBuilderWrapper( ReanimatedSlideOutLeft, function (this: ReanimatedSlideOutLeft) { return (values: ExitAnimationsValues) => ({ @@ -133,7 +135,7 @@ export const SlideOutLeft = createBuilderWrapper( }, ); -export const SlideOutUp = createBuilderWrapper( +export const SlideOutUp: Class = createBuilderWrapper( ReanimatedSlideOutUp, function (this: ReanimatedSlideOutUp) { return (values: ExitAnimationsValues) => ({ @@ -157,7 +159,7 @@ export const SlideOutUp = createBuilderWrapper( }, ); -export const SlideOutDown = createBuilderWrapper( +export const SlideOutDown: Class = createBuilderWrapper( ReanimatedSlideOutDown, function (this: ReanimatedSlideOutDown) { return (values: ExitAnimationsValues) => ({ diff --git a/packages/plugin-reanimated/src/builders/createBuilderWrapper.ts b/packages/plugin-reanimated/src/builders/createBuilderWrapper.ts index daee5b5..d4b1f55 100644 --- a/packages/plugin-reanimated/src/builders/createBuilderWrapper.ts +++ b/packages/plugin-reanimated/src/builders/createBuilderWrapper.ts @@ -13,7 +13,7 @@ export function createBuilderWrapper< >( OriginalClass: TClass, buildFn: (this: T, originalBuildFn: T['build']) => ReturnType, -) { +): TClass { class LightningAnimationBuilder extends (OriginalClass as Constructor) { private _buildFn: T['build']; diff --git a/packages/plugin-reanimated/src/exports/FlatList.tsx b/packages/plugin-reanimated/src/exports/FlatList.tsx index 6dced75..ab6cef2 100644 --- a/packages/plugin-reanimated/src/exports/FlatList.tsx +++ b/packages/plugin-reanimated/src/exports/FlatList.tsx @@ -1,4 +1,8 @@ -import { FlatList as RNFlatList } from 'react-native'; -import { createAnimatedComponent } from './createAnimatedComponent'; +import { type FlatListProps, FlatList as RNFlatList } from 'react-native'; +import { + type AnimatedComponent, + createAnimatedComponent, +} from './createAnimatedComponent'; -export const FlatList = createAnimatedComponent(RNFlatList); +export const FlatList: AnimatedComponent> = + createAnimatedComponent(RNFlatList); diff --git a/packages/plugin-reanimated/src/exports/Image.tsx b/packages/plugin-reanimated/src/exports/Image.tsx index 596284d..5a0769a 100644 --- a/packages/plugin-reanimated/src/exports/Image.tsx +++ b/packages/plugin-reanimated/src/exports/Image.tsx @@ -1,4 +1,8 @@ -import { Image as RNImage } from 'react-native'; -import { createAnimatedComponent } from './createAnimatedComponent'; +import { type ImageProps, Image as RNImage } from 'react-native'; +import { + type AnimatedComponent, + createAnimatedComponent, +} from './createAnimatedComponent'; -export const Image = createAnimatedComponent(RNImage); +export const Image: AnimatedComponent = + createAnimatedComponent(RNImage); diff --git a/packages/plugin-reanimated/src/exports/ScrollView.tsx b/packages/plugin-reanimated/src/exports/ScrollView.tsx index 0819cd7..9cd3a5a 100644 --- a/packages/plugin-reanimated/src/exports/ScrollView.tsx +++ b/packages/plugin-reanimated/src/exports/ScrollView.tsx @@ -1,4 +1,8 @@ -import { ScrollView as RNScrollView } from 'react-native'; -import { createAnimatedComponent } from './createAnimatedComponent'; +import { ScrollView as RNScrollView, type ScrollViewProps } from 'react-native'; +import { + type AnimatedComponent, + createAnimatedComponent, +} from './createAnimatedComponent'; -export const ScrollView = createAnimatedComponent(RNScrollView); +export const ScrollView: AnimatedComponent = + createAnimatedComponent(RNScrollView); diff --git a/packages/plugin-reanimated/src/exports/Text.tsx b/packages/plugin-reanimated/src/exports/Text.tsx index 451ed6f..99ed6f0 100644 --- a/packages/plugin-reanimated/src/exports/Text.tsx +++ b/packages/plugin-reanimated/src/exports/Text.tsx @@ -1,4 +1,8 @@ -import { Text as RNText } from 'react-native'; -import { createAnimatedComponent } from './createAnimatedComponent'; +import { Text as RNText, type TextProps } from 'react-native'; +import { + type AnimatedComponent, + createAnimatedComponent, +} from './createAnimatedComponent'; -export const Text = createAnimatedComponent(RNText); +export const Text: AnimatedComponent = + createAnimatedComponent(RNText); diff --git a/packages/plugin-reanimated/src/exports/View.tsx b/packages/plugin-reanimated/src/exports/View.tsx index 3ae4a80..667d487 100644 --- a/packages/plugin-reanimated/src/exports/View.tsx +++ b/packages/plugin-reanimated/src/exports/View.tsx @@ -1,4 +1,8 @@ -import { View as RNView } from 'react-native'; -import { createAnimatedComponent } from './createAnimatedComponent'; +import { View as RNView, type ViewProps } from 'react-native'; +import { + type AnimatedComponent, + createAnimatedComponent, +} from './createAnimatedComponent'; -export const View = createAnimatedComponent(RNView); +export const View: AnimatedComponent = + createAnimatedComponent(RNView); diff --git a/packages/plugin-reanimated/src/exports/createAnimatedComponent.tsx b/packages/plugin-reanimated/src/exports/createAnimatedComponent.tsx index 835abf4..5eb15c3 100644 --- a/packages/plugin-reanimated/src/exports/createAnimatedComponent.tsx +++ b/packages/plugin-reanimated/src/exports/createAnimatedComponent.tsx @@ -9,7 +9,10 @@ import { Component, type ComponentType, type ForwardedRef, + type ForwardRefExoticComponent, forwardRef, + type PropsWithoutRef, + type RefAttributes, } from 'react'; import type { NativeMethods, StyleProp, ViewStyle } from 'react-native'; import type { @@ -139,10 +142,14 @@ function buildTransitions( return animation; } +export type AnimatedComponent = ForwardRefExoticComponent< + PropsWithoutRef> & RefAttributes +>; + export function createAnimatedComponent( ComponentToAnimate: ComponentType>, -) { - class AnimatedComponent extends Component> { +): AnimatedComponent { + class AnimatedComponentInternal extends Component> { static displayName = `LightningAnimated(${ComponentToAnimate.displayName || ComponentToAnimate.name || 'Component'})`; @@ -331,7 +338,7 @@ export function createAnimatedComponent( return forwardRef>( (props, forwardedRef) => { return ( - )} forwardedRef={forwardedRef} /> diff --git a/packages/plugin-reanimated/src/exports/useComposedEventHandler.ts b/packages/plugin-reanimated/src/exports/useComposedEventHandler.ts index f2af2ec..c8cbdfb 100644 --- a/packages/plugin-reanimated/src/exports/useComposedEventHandler.ts +++ b/packages/plugin-reanimated/src/exports/useComposedEventHandler.ts @@ -2,7 +2,7 @@ type EventHandler = (...args: any[]) => void; export function useComposedEventHandler(...handlers: EventHandler[]) { - return (...args: any[]) => { + return (...args: any[]): void => { for (const handler of handlers) { handler(...args); } diff --git a/packages/plugin-reanimated/src/exports/withRepeat.ts b/packages/plugin-reanimated/src/exports/withRepeat.ts index cc87f37..db2bb84 100644 --- a/packages/plugin-reanimated/src/exports/withRepeat.ts +++ b/packages/plugin-reanimated/src/exports/withRepeat.ts @@ -1,20 +1,30 @@ import type { AnimatedValue } from '../animation/AnimatedValue'; +import type { AnimationType } from '../types/AnimationType'; export function withRepeat( animation: AnimatedValue, repeatCount = 2, reverse = false, -) { +): { + isHigherOrder: boolean; + onFrame: () => void; + onStart: () => void; + reps: number; + current: AnimatedValue; + callback: () => void; + startValue: number; + reduceMotion: boolean; +} { animation.lngAnimation.repeat = repeatCount; animation.lngAnimation.stopMethod = reverse ? 'reverse' : false; return { isHigherOrder: true, - onFrame: () => {}, - onStart: () => {}, + onFrame: (): void => {}, + onStart: (): void => {}, reps: 0, current: animation, - callback: () => {}, + callback: (): void => {}, startValue: 0, reduceMotion: false, }; diff --git a/packages/plugin-reanimated/src/index.ts b/packages/plugin-reanimated/src/index.ts index 13d75be..3a8f3d6 100644 --- a/packages/plugin-reanimated/src/index.ts +++ b/packages/plugin-reanimated/src/index.ts @@ -12,14 +12,15 @@ export * from 'react-native-reanimated-original'; // Overrides export default { - createAnimatedComponent, - addWhitelistedUIProps: Noop, - addWhitelistedNativeProps: Noop, - Image, - FlatList, - ScrollView, - Text, - View, + createAnimatedComponent: + createAnimatedComponent as typeof createAnimatedComponent, + addWhitelistedUIProps: Noop as () => null, + addWhitelistedNativeProps: Noop as () => null, + Image: Image as typeof Image, + FlatList: FlatList as typeof FlatList, + ScrollView: ScrollView as typeof ScrollView, + Text: Text as typeof Text, + View: View as typeof View, }; export { diff --git a/packages/plugin-reanimated/src/mergeRefs.ts b/packages/plugin-reanimated/src/mergeRefs.ts index e15f601..9849597 100644 --- a/packages/plugin-reanimated/src/mergeRefs.ts +++ b/packages/plugin-reanimated/src/mergeRefs.ts @@ -18,7 +18,7 @@ export default function mergeRefs(...refs: any[]) { args[_key] = refs[_key]; } - return function forwardRef(node: any) { + return function forwardRef(node: any): void { for (const ref of args) { if (ref == null) { continue; @@ -38,7 +38,7 @@ export default function mergeRefs(...refs: any[]) { }; } -export function useMergeRefs(...refs: any[]) { +export function useMergeRefs(...refs: any[]): (node: any) => void { const _len = refs.length; const args = Array.from({ length: _len }); for (let _key = 0; _key < _len; _key++) { diff --git a/packages/plugin-reanimated/tsconfig.json b/packages/plugin-reanimated/tsconfig.json index 5d87499..641eec8 100644 --- a/packages/plugin-reanimated/tsconfig.json +++ b/packages/plugin-reanimated/tsconfig.json @@ -1,10 +1,5 @@ { "extends": "@repo/configs/tsconfig.react-library.json", - "compilerOptions": { - "rootDir": "src", - "declaration": false, - "declarationMap": false - }, "include": ["src", "./src/types/*.d.ts"], "exclude": ["node_modules", "dist"] } diff --git a/packages/plugin-reanimated/tsdown.config.ts b/packages/plugin-reanimated/tsdown.config.ts index 14a63f8..5caeff0 100644 --- a/packages/plugin-reanimated/tsdown.config.ts +++ b/packages/plugin-reanimated/tsdown.config.ts @@ -1,7 +1,9 @@ -import baseConfig from '@repo/configs/tsdown.config'; -import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; +import baseConfig from '../configs/tsdown.config'; -export default defineConfig({ +const config: UserConfig = defineConfig({ ...baseConfig, external: ['react-native-reanimated-original'], }); + +export default config; diff --git a/packages/react-lightning-components/src/exports/layout/Column.tsx b/packages/react-lightning-components/src/exports/layout/Column.tsx index 6d96ce1..33c0e86 100644 --- a/packages/react-lightning-components/src/exports/layout/Column.tsx +++ b/packages/react-lightning-components/src/exports/layout/Column.tsx @@ -4,7 +4,7 @@ import { type LightningViewElementProps, type LightningViewElementStyle, } from '@plextv/react-lightning'; -import { forwardRef } from 'react'; +import { type ForwardRefExoticComponent, forwardRef } from 'react'; export interface ColumnProps extends LightningViewElementProps { focusable?: boolean; @@ -16,7 +16,10 @@ export interface ColumnProps extends LightningViewElementProps { trapFocusLeft?: boolean; } -const Column = forwardRef( +const Column: ForwardRefExoticComponent = forwardRef< + LightningViewElement, + ColumnProps +>( ( { style, diff --git a/packages/react-lightning-components/src/exports/layout/Row.tsx b/packages/react-lightning-components/src/exports/layout/Row.tsx index f33ee82..d22b04f 100644 --- a/packages/react-lightning-components/src/exports/layout/Row.tsx +++ b/packages/react-lightning-components/src/exports/layout/Row.tsx @@ -4,7 +4,7 @@ import { type LightningViewElementProps, type LightningViewElementStyle, } from '@plextv/react-lightning'; -import { forwardRef } from 'react'; +import { type ForwardRefExoticComponent, forwardRef } from 'react'; export interface RowProps extends LightningViewElementProps { focusable?: boolean; @@ -16,7 +16,10 @@ export interface RowProps extends LightningViewElementProps { trapFocusLeft?: boolean; } -const Row = forwardRef( +const Row: ForwardRefExoticComponent = forwardRef< + LightningViewElement, + RowProps +>( ( { style, diff --git a/packages/react-lightning-components/src/exports/util/FPSMonitor.tsx b/packages/react-lightning-components/src/exports/util/FPSMonitor.tsx index d8b628b..fa3bdb3 100644 --- a/packages/react-lightning-components/src/exports/util/FPSMonitor.tsx +++ b/packages/react-lightning-components/src/exports/util/FPSMonitor.tsx @@ -2,7 +2,7 @@ import { LightningRootContext, type LightningTextElementStyle, } from '@plextv/react-lightning'; -import { useCallback, useContext, useEffect, useState } from 'react'; +import { type FC, useCallback, useContext, useEffect, useState } from 'react'; export interface FPSMonitorProps { prefix?: string; @@ -14,7 +14,7 @@ export interface FPSMonitorProps { lowCutoff?: number; } -const FPSMonitor = ({ +const FPSMonitor: FC = ({ style, prefix = 'FPS:', highColor = 0x00ff00ff, @@ -22,7 +22,7 @@ const FPSMonitor = ({ mediumCutoff = 30, lowColor = 0xff0000ff, lowCutoff = 15, -}: FPSMonitorProps) => { +}) => { const lngContext = useContext(LightningRootContext); const [fps, setFps] = useState(0); const [color, setColor] = useState(0); diff --git a/packages/react-lightning-components/tsconfig.json b/packages/react-lightning-components/tsconfig.json index 50d8fdf..9e82ff4 100644 --- a/packages/react-lightning-components/tsconfig.json +++ b/packages/react-lightning-components/tsconfig.json @@ -1,9 +1,6 @@ { "extends": "@repo/configs/tsconfig.react-library.json", "compilerOptions": { - "rootDir": "src", - "declaration": false, - "declarationMap": false, "types": [ "node", "@plextv/react-lightning-plugin-flexbox/jsx", diff --git a/packages/react-lightning-components/tsdown.config.ts b/packages/react-lightning-components/tsdown.config.ts index 89c8b86..b4b2925 100644 --- a/packages/react-lightning-components/tsdown.config.ts +++ b/packages/react-lightning-components/tsdown.config.ts @@ -1,3 +1,3 @@ -import baseConfig from '@repo/configs/tsdown.withExports.config'; +import baseConfig from '../configs/tsdown.withExports.config'; export default baseConfig; diff --git a/packages/react-lightning/src/components/Canvas/CanvasBridge.tsx b/packages/react-lightning/src/components/Canvas/CanvasBridge.tsx index 932302e..a102560 100644 --- a/packages/react-lightning/src/components/Canvas/CanvasBridge.tsx +++ b/packages/react-lightning/src/components/Canvas/CanvasBridge.tsx @@ -1,11 +1,11 @@ -import { useEffect, useRef, useState } from 'react'; +import { type FC, useEffect, useRef, useState } from 'react'; import { createRoot, type LightningRoot } from '../../render'; import type { CanvasProps } from './CanvasProps'; -export const CanvasBridge = ({ +export const CanvasBridge: FC> = ({ options, children, -}: Pick) => { +}) => { const [root, setRoot] = useState(); const [initReady, setInitReady] = useState(false); const containerRef = useRef(null); diff --git a/packages/react-lightning/src/components/Canvas/CanvasRoot.tsx b/packages/react-lightning/src/components/Canvas/CanvasRoot.tsx index f2ddddb..6b15d34 100644 --- a/packages/react-lightning/src/components/Canvas/CanvasRoot.tsx +++ b/packages/react-lightning/src/components/Canvas/CanvasRoot.tsx @@ -1,4 +1,4 @@ -import { useRef } from 'react'; +import { type FC, useRef } from 'react'; import { FocusGroup } from '../../focus/FocusGroup'; import { FocusKeyManager } from '../../focus/FocusKeyManager'; import { FocusManager } from '../../focus/FocusManager'; @@ -11,7 +11,7 @@ import type { CanvasProps } from './CanvasProps'; type Props = Omit & { width?: number; height?: number }; -export const CanvasRoot = ({ width, height, children, keyMap }: Props) => { +export const CanvasRoot: FC = ({ width, height, children, keyMap }) => { const ref = useRef(null); const focusManager = useRef>( new FocusManager(), diff --git a/packages/react-lightning/src/components/Canvas/index.tsx b/packages/react-lightning/src/components/Canvas/index.tsx index 07321b8..9aa092f 100644 --- a/packages/react-lightning/src/components/Canvas/index.tsx +++ b/packages/react-lightning/src/components/Canvas/index.tsx @@ -1,8 +1,9 @@ +import type { FC } from 'react'; import { CanvasBridge } from './CanvasBridge'; import type { CanvasProps } from './CanvasProps'; import { CanvasRoot } from './CanvasRoot'; -export const Canvas = ({ options, ...props }: CanvasProps) => { +export const Canvas: FC = ({ options, ...props }) => { return ( = LightningImageElementProps, > extends LightningViewElement { - public override get type() { + public override get type(): LightningElementType { return LightningElementType.Image; } @@ -98,7 +98,7 @@ export class LightningImageElement< return finalProps; } - protected override _doUpdate() { + protected override _doUpdate(): boolean { const payload = this._stagedUpdates; let changed = super._doUpdate(); diff --git a/packages/react-lightning/src/element/LightningTextElement.ts b/packages/react-lightning/src/element/LightningTextElement.ts index 188f1ec..426ef34 100644 --- a/packages/react-lightning/src/element/LightningTextElement.ts +++ b/packages/react-lightning/src/element/LightningTextElement.ts @@ -12,7 +12,7 @@ export class LightningTextElement extends LightningViewElement< LightningTextElementStyle, LightningTextElementProps > { - public override get type() { + public override get type(): LightningElementType { return LightningElementType.Text; } @@ -46,7 +46,7 @@ export class LightningTextElement extends LightningViewElement< return finalProps; } - protected override _doUpdate() { + protected override _doUpdate(): boolean { const payload = this._stagedUpdates; let changed = super._doUpdate(); diff --git a/packages/react-lightning/src/element/LightningViewElement.ts b/packages/react-lightning/src/element/LightningViewElement.ts index ad0f8c5..1de6b78 100644 --- a/packages/react-lightning/src/element/LightningViewElement.ts +++ b/packages/react-lightning/src/element/LightningViewElement.ts @@ -1,6 +1,7 @@ import type { AnimationSettings, CoreShaderNode, + IAnimationController, INode, INodeAnimateProps, INodeProps, @@ -126,11 +127,11 @@ export class LightningViewElement< this._eventEmitter.emit('focusableChanged', this, this._focusable); } - public get focused() { + public get focused(): boolean { return this._focused; } - public get type() { + public get type(): LightningElementType { return LightningElementType.View; } @@ -146,7 +147,7 @@ export class LightningViewElement< } } - public get parent() { + public get parent(): LightningElement | null { return this._parent; } @@ -219,7 +220,7 @@ export class LightningViewElement< return false; } - public get hasChildren() { + public get hasChildren(): boolean { return this.children.length > 0; } @@ -233,7 +234,7 @@ export class LightningViewElement< return root; } - public get isRoot() { + public get isRoot(): boolean { return this.node.id === 1; } @@ -290,7 +291,7 @@ export class LightningViewElement< this._eventEmitter.emit('initialized'); } - public destroy() { + public destroy(): void { this.node.off('inViewport', this._onInViewport); this.node.off('loaded', this._onTextureLoaded); this.node.off('failed', this._onTextureFailed); @@ -333,7 +334,7 @@ export class LightningViewElement< public emit: IEventEmitter['emit'] = (...args) => this._eventEmitter.emit(...args); - public setLightningNode(node: RendererNode) { + public setLightningNode(node: RendererNode): void { const oldNode = this.node; oldNode.off('inViewport', this._onInViewport); @@ -361,7 +362,7 @@ export class LightningViewElement< public insertChild( child: LightningElement, beforeChild?: LightningElement | null, - ) { + ): void { if (child.parent === this && child.parent.node === this.node) { return; } @@ -385,7 +386,7 @@ export class LightningViewElement< this._eventEmitter.emit('childAdded', child, index); } - public removeChild(child: LightningElement) { + public removeChild(child: LightningElement): void { const index = this.children.indexOf(child); if (index >= 0) { @@ -420,7 +421,10 @@ export class LightningViewElement< this._scheduleUpdate(); } - public getRelativePosition(ancestor?: LightningElement | null) { + public getRelativePosition(ancestor?: LightningElement | null): { + x: number; + y: number; + } { let totalX = 0; let totalY = 0; @@ -439,7 +443,17 @@ export class LightningViewElement< }; } - public getBoundingClientRect(ancestor?: LightningElement | null) { + public getBoundingClientRect(ancestor?: LightningElement | null): { + x: number; + y: number; + left: number; + top: number; + right: number; + bottom: number; + // TODO: Include padding + border in size + w: number; + h: number; + } { const { x, y } = this.getRelativePosition(ancestor); return { @@ -459,7 +473,7 @@ export class LightningViewElement< * Updates existing props with the payload, keeping other unspecified props * unchanged. */ - public setProps(payload: Partial) { + public setProps(payload: Partial): void { const { style, transition, ...otherProps } = payload; Object.assign(this._stagedUpdates, otherProps); @@ -524,7 +538,7 @@ export class LightningViewElement< return true; } - public emitLayoutEvent() { + public emitLayoutEvent(): void { const dimensions = { x: this.node.x, y: this.node.y, @@ -536,7 +550,7 @@ export class LightningViewElement< this._onLayout(dimensions); } - public recalculateVisibility = () => { + public recalculateVisibility = (): void => { const prevFocusable = this.focusable; const prevVisible = this._visible; @@ -562,7 +576,7 @@ export class LightningViewElement< public animateStyle( key: K, value: TStyleProps[K], - ) { + ): IAnimationController { return this._createAnimation( { [key]: value, @@ -571,7 +585,9 @@ export class LightningViewElement< ).start(); } - public animateShader(props: Partial) { + public animateShader( + props: Partial, + ): IAnimationController { return this._createAnimation( { shaderProps: props, @@ -618,7 +634,7 @@ export class LightningViewElement< }); } - protected _doUpdate() { + protected _doUpdate(): boolean { const payload = this._stagedUpdates; this._stagedUpdates = {}; diff --git a/packages/react-lightning/src/focus/FocusGroup.tsx b/packages/react-lightning/src/focus/FocusGroup.tsx index 0b1573e..57dce40 100644 --- a/packages/react-lightning/src/focus/FocusGroup.tsx +++ b/packages/react-lightning/src/focus/FocusGroup.tsx @@ -1,4 +1,5 @@ import { + type ForwardRefExoticComponent, forwardRef, useCallback, useEffect, @@ -33,100 +34,101 @@ export interface FocusGroupProps onChildFocused?: (child: LightningElement) => void; } -export const FocusGroup = forwardRef( - ( - { - autoFocus = false, - disable, - focusRedirect, - destinations, - trapFocusUp, - trapFocusRight, - trapFocusDown, - trapFocusLeft, - style, - onKeyDown, - onChildFocused, - ...otherProps - }, - ref, - ) => { - const focusManager = useFocusManager(); - const focusKeyManager = useFocusKeyManager(); - const { ref: focusRef, focused } = useFocus({ - autoFocus, - active: !disable, - focusRedirect, - destinations, - }); - const [viewElement, setViewElement] = useState( - null, - ); - const viewRef = useRef(null); - const combinedRef = useCombinedRef(ref, focusRef, viewRef); - - const traps = useMemo( - () => ({ - up: trapFocusUp ?? false, - right: trapFocusRight ?? false, - down: trapFocusDown ?? false, - left: trapFocusLeft ?? false, - }), - [trapFocusUp, trapFocusRight, trapFocusDown, trapFocusLeft], - ); +export const FocusGroup: ForwardRefExoticComponent = + forwardRef( + ( + { + autoFocus = false, + disable, + focusRedirect, + destinations, + trapFocusUp, + trapFocusRight, + trapFocusDown, + trapFocusLeft, + style, + onKeyDown, + onChildFocused, + ...otherProps + }, + ref, + ) => { + const focusManager = useFocusManager(); + const focusKeyManager = useFocusKeyManager(); + const { ref: focusRef, focused } = useFocus({ + autoFocus, + active: !disable, + focusRedirect, + destinations, + }); + const [viewElement, setViewElement] = useState( + null, + ); + const viewRef = useRef(null); + const combinedRef = useCombinedRef(ref, focusRef, viewRef); - const handleFocusKeyDown = useCallback( - (event: KeyEvent) => { - if (!viewRef.current) { - return onKeyDown?.(event); - } + const traps = useMemo( + () => ({ + up: trapFocusUp ?? false, + right: trapFocusRight ?? false, + down: trapFocusDown ?? false, + left: trapFocusLeft ?? false, + }), + [trapFocusUp, trapFocusRight, trapFocusDown, trapFocusLeft], + ); - const result = focusKeyManager.handleKeyDown( - viewRef.current, - event.remoteKey, - ); + const handleFocusKeyDown = useCallback( + (event: KeyEvent) => { + if (!viewRef.current) { + return onKeyDown?.(event); + } - return result === false ? false : onKeyDown?.(event); - }, - [focusKeyManager, onKeyDown], - ); + const result = focusKeyManager.handleKeyDown( + viewRef.current, + event.remoteKey, + ); - const finalStyle = useMemo( - () => (typeof style === 'function' ? style(focused) : style), - [style, focused], - ); + return result === false ? false : onKeyDown?.(event); + }, + [focusKeyManager, onKeyDown], + ); - useEffect(() => { - if (viewElement) { - focusManager.setTraps(viewElement, traps); - } - }, [focusManager, viewElement, traps]); + const finalStyle = useMemo( + () => (typeof style === 'function' ? style(focused) : style), + [style, focused], + ); - useEffect(() => { - if (viewRef.current) { - viewRef.current.isFocusGroup = true; - setViewElement(viewRef.current); - } + useEffect(() => { + if (viewElement) { + focusManager.setTraps(viewElement, traps); + } + }, [focusManager, viewElement, traps]); - return () => { + useEffect(() => { if (viewRef.current) { - viewRef.current.isFocusGroup = false; - setViewElement(null); + viewRef.current.isFocusGroup = true; + setViewElement(viewRef.current); } - }; - }, []); - return ( - - - - ); - }, -); + return () => { + if (viewRef.current) { + viewRef.current.isFocusGroup = false; + setViewElement(null); + } + }; + }, []); + + return ( + + + + ); + }, + ); FocusGroup.displayName = 'FocusGroup'; diff --git a/packages/react-lightning/src/focus/FocusGroupContext.tsx b/packages/react-lightning/src/focus/FocusGroupContext.tsx index 52046f4..6d3f798 100644 --- a/packages/react-lightning/src/focus/FocusGroupContext.tsx +++ b/packages/react-lightning/src/focus/FocusGroupContext.tsx @@ -1,6 +1,7 @@ -import { createContext } from 'react'; +import { type Context, createContext } from 'react'; import type { LightningElement } from '../types'; -export const FocusGroupContext = createContext(null); +export const FocusGroupContext: Context = + createContext(null); FocusGroupContext.displayName = 'FocusGroupContext'; diff --git a/packages/react-lightning/src/focus/FocusKeyManager.ts b/packages/react-lightning/src/focus/FocusKeyManager.ts index 3d79040..e5bccb1 100644 --- a/packages/react-lightning/src/focus/FocusKeyManager.ts +++ b/packages/react-lightning/src/focus/FocusKeyManager.ts @@ -11,7 +11,7 @@ export class FocusKeyManager { this._focusManager = focusManager; } - public handleKeyDown = (element: T, key: Keys | Keys[]) => { + public handleKeyDown = (element: T, key: Keys | Keys[]): boolean => { const direction = Array.isArray(key) ? key.map((k) => this._getKeyDirection(k)).find((dir) => dir != null) : this._getKeyDirection(key); diff --git a/packages/react-lightning/src/focus/FocusManager.ts b/packages/react-lightning/src/focus/FocusManager.ts index 46c54b9..8f68029 100644 --- a/packages/react-lightning/src/focus/FocusManager.ts +++ b/packages/react-lightning/src/focus/FocusManager.ts @@ -107,8 +107,11 @@ export class FocusManager< return () => this._eventEmitter.off(...args); }; - public off = this._eventEmitter.off.bind(this._eventEmitter); - public emit = this._eventEmitter.emit.bind(this._eventEmitter); + public off: EventEmitter>['off'] = this._eventEmitter.off.bind( + this._eventEmitter, + ); + public emit: EventEmitter>['emit'] = + this._eventEmitter.emit.bind(this._eventEmitter); public getFocusNode(element: T): FocusNode | null { const node = this.activeLayer.elements.get(element); @@ -129,7 +132,7 @@ export class FocusManager< destinations?: (T | null)[] | null; traps?: Traps; }, - ) { + ): void { const autoFocus = options?.autoFocus ?? false; const focusRedirect = options?.focusRedirect ?? false; const destinations = options?.destinations ?? null; @@ -234,7 +237,7 @@ export class FocusManager< this._recalculateFocusPath(); } - public removeElement(element: T) { + public removeElement(element: T): void { const node = this.activeLayer.elements.get(element); if (!node) { @@ -244,7 +247,7 @@ export class FocusManager< this._removeNode(node, true); } - public setTraps(element: T, traps: Traps) { + public setTraps(element: T, traps: Traps): void { const node = this.activeLayer.elements.get(element); if (node) { @@ -252,7 +255,7 @@ export class FocusManager< } } - public setAutoFocus(element: T, autoFocus?: boolean) { + public setAutoFocus(element: T, autoFocus?: boolean): void { const node = this.activeLayer.elements.get(element); if (node) { @@ -260,7 +263,7 @@ export class FocusManager< } } - public setFocusRedirect(element: T, focusRedirect?: boolean) { + public setFocusRedirect(element: T, focusRedirect?: boolean): void { const node = this.activeLayer.elements.get(element); if (node) { diff --git a/packages/react-lightning/src/focus/FocusManagerContext.tsx b/packages/react-lightning/src/focus/FocusManagerContext.tsx index e741409..5ae2237 100644 --- a/packages/react-lightning/src/focus/FocusManagerContext.tsx +++ b/packages/react-lightning/src/focus/FocusManagerContext.tsx @@ -1,9 +1,12 @@ -import { createContext } from 'react'; +import { type Context, createContext } from 'react'; import type { LightningElement } from '../types'; import type { FocusKeyManager } from './FocusKeyManager'; import type { FocusManager } from './FocusManager'; -export const FocusManagerContext = createContext<{ +type ContextType = { focusManager: FocusManager; focusKeyManager: FocusKeyManager; -} | null>(null); +} | null; + +export const FocusManagerContext: Context = + createContext(null); diff --git a/packages/react-lightning/src/focus/useFocus.tsx b/packages/react-lightning/src/focus/useFocus.tsx index 9c19b7e..5e0e533 100644 --- a/packages/react-lightning/src/focus/useFocus.tsx +++ b/packages/react-lightning/src/focus/useFocus.tsx @@ -1,4 +1,10 @@ -import { useContext, useEffect, useRef, useSyncExternalStore } from 'react'; +import { + type RefObject, + useContext, + useEffect, + useRef, + useSyncExternalStore, +} from 'react'; import type { LightningElement } from '../types'; import { FocusGroupContext } from './FocusGroupContext'; import { useFocusManager } from './useFocusManager'; @@ -16,7 +22,10 @@ export function useFocus( autoFocus: false, focusRedirect: false, }, -) { +): { + ref: RefObject; + focused: boolean; +} { const ref = useRef(null); const focusManager = useFocusManager(); const parentFocusable = useContext(FocusGroupContext); diff --git a/packages/react-lightning/src/focus/useFocusKeyManager.ts b/packages/react-lightning/src/focus/useFocusKeyManager.ts index 5386d0e..2670edf 100644 --- a/packages/react-lightning/src/focus/useFocusKeyManager.ts +++ b/packages/react-lightning/src/focus/useFocusKeyManager.ts @@ -1,7 +1,9 @@ import { useContext } from 'react'; +import type { LightningElement } from '../types'; +import type { FocusKeyManager } from './FocusKeyManager'; import { FocusManagerContext } from './FocusManagerContext'; -export const useFocusKeyManager = () => { +export const useFocusKeyManager = (): FocusKeyManager => { const focusContext = useContext(FocusManagerContext); if (!focusContext) { diff --git a/packages/react-lightning/src/focus/useFocusManager.ts b/packages/react-lightning/src/focus/useFocusManager.ts index 4f21e91..a31adbb 100644 --- a/packages/react-lightning/src/focus/useFocusManager.ts +++ b/packages/react-lightning/src/focus/useFocusManager.ts @@ -1,7 +1,9 @@ import { useContext } from 'react'; +import type { LightningElement } from '../types'; +import type { FocusManager } from './FocusManager'; import { FocusManagerContext } from './FocusManagerContext'; -export const useFocusManager = () => { +export const useFocusManager = (): FocusManager => { const focusContext = useContext(FocusManagerContext); if (!focusContext) { diff --git a/packages/react-lightning/src/hooks/useDebugHooks.ts b/packages/react-lightning/src/hooks/useDebugHooks.ts index 6903d39..e24ed8c 100644 --- a/packages/react-lightning/src/hooks/useDebugHooks.ts +++ b/packages/react-lightning/src/hooks/useDebugHooks.ts @@ -37,6 +37,12 @@ function wrapHook(hook: T, name: string): T { }) as T; } -export const useEffectDebug = wrapHook(useEffect, 'useEffectDebug'); -export const useCallbackDebug = wrapHook(useCallback, 'useCallbackDebug'); -export const useMemoDebug = wrapHook(useMemo, 'useMemoDebug'); +export const useEffectDebug: typeof useEffect = wrapHook( + useEffect, + 'useEffectDebug', +); +export const useCallbackDebug: typeof useCallback = wrapHook( + useCallback, + 'useCallbackDebug', +); +export const useMemoDebug: typeof useMemo = wrapHook(useMemo, 'useMemoDebug'); diff --git a/packages/react-lightning/src/input/KeyEventProvider.tsx b/packages/react-lightning/src/input/KeyEventProvider.tsx index dcb5a00..e915ab1 100644 --- a/packages/react-lightning/src/input/KeyEventProvider.tsx +++ b/packages/react-lightning/src/input/KeyEventProvider.tsx @@ -1,4 +1,4 @@ -import type { ReactNode } from 'react'; +import type { Context, FC, ReactNode } from 'react'; import { createContext, useCallback } from 'react'; import { useFocusManager } from '../focus/useFocusManager'; import type { KeyEvent, LightningElement } from '../types'; @@ -8,11 +8,12 @@ type BubbleEventFn = ( event: Omit, ) => void; -export const KeyEventContext = createContext<{ bubbleEvent: BubbleEventFn }>({ - bubbleEvent: () => {}, -}); +export const KeyEventContext: Context<{ bubbleEvent: BubbleEventFn }> = + createContext<{ bubbleEvent: BubbleEventFn }>({ + bubbleEvent: () => {}, + }); -export const KeyEventProvider = ({ children }: { children: ReactNode }) => { +export const KeyEventProvider: FC<{ children: ReactNode }> = ({ children }) => { const focusManager = useFocusManager(); const bubbleEvent = useCallback( diff --git a/packages/react-lightning/src/input/KeyMapContext.ts b/packages/react-lightning/src/input/KeyMapContext.ts index 861d186..52a3d81 100644 --- a/packages/react-lightning/src/input/KeyMapContext.ts +++ b/packages/react-lightning/src/input/KeyMapContext.ts @@ -1,8 +1,8 @@ -import { createContext } from 'react'; +import { type Context, createContext } from 'react'; import type { Keys } from './Keys'; export type KeyMap = Record; -const KeyMapContext = createContext({}); +const KeyMapContext: Context = createContext({}); export { KeyMapContext }; diff --git a/packages/react-lightning/src/input/KeyPressHandler.tsx b/packages/react-lightning/src/input/KeyPressHandler.tsx index 74a0c7b..cfe57d8 100644 --- a/packages/react-lightning/src/input/KeyPressHandler.tsx +++ b/packages/react-lightning/src/input/KeyPressHandler.tsx @@ -1,4 +1,4 @@ -import type { ReactNode } from 'react'; +import type { FC, ReactNode } from 'react'; import { useCallback, useContext, useEffect, useRef } from 'react'; import { KeyEventContext } from './KeyEventProvider'; import type { KeyMap } from './KeyMapContext'; @@ -7,7 +7,7 @@ import { Keys } from './Keys'; const LONG_PRESS_THRESHOLD = 500; -export const KeyPressHandler = ({ children }: { children: ReactNode }) => { +export const KeyPressHandler: FC<{ children: ReactNode }> = ({ children }) => { const keyMap = useContext(KeyMapContext); const keyEvents = useContext(KeyEventContext); const keyDownTime = useRef(0); diff --git a/packages/react-lightning/src/mocks/createMockElement.ts b/packages/react-lightning/src/mocks/createMockElement.ts index dfa616d..c280c2c 100644 --- a/packages/react-lightning/src/mocks/createMockElement.ts +++ b/packages/react-lightning/src/mocks/createMockElement.ts @@ -31,13 +31,13 @@ export class MockElement implements Focusable, EventNotifier { this._focusable = value; } - public get focused() { + public get focused(): boolean { return this._focused; } - public focus() { + public focus(): void { this._focused = true; } - public blur() { + public blur(): void { this._focused = false; } @@ -46,6 +46,10 @@ export class MockElement implements Focusable, EventNotifier { } } -export function createMockElement(id: number, name: string, visible = true) { +export function createMockElement( + id: number, + name: string, + visible = true, +): MockElement { return new MockElement(id, name, visible); } diff --git a/packages/react-lightning/src/render/index.tsx b/packages/react-lightning/src/render/index.tsx index 189b8a4..9699214 100644 --- a/packages/react-lightning/src/render/index.tsx +++ b/packages/react-lightning/src/render/index.tsx @@ -13,7 +13,7 @@ import { SdfTextRenderer, WebGlCoreRenderer, } from '@lightningjs/renderer/webgl'; -import type { ComponentType, ReactNode } from 'react'; +import type { ComponentType, Context, ReactNode } from 'react'; import { createContext, createElement } from 'react'; import createReconciler, { type Reconciler } from 'react-reconciler'; import type { LightningTextElement } from '../element/LightningTextElement'; @@ -65,7 +65,8 @@ export type LightningRoot = { const TRACE_ENABLED = false; const SKIP_STACK_TRACE = true; -export const LightningRootContext = createContext(null); +export const LightningRootContext: Context = + createContext(null); let reconciler: Reconciler< ReconcilerContainer, diff --git a/packages/react-lightning/src/utils/isEmptyObject.ts b/packages/react-lightning/src/utils/isEmptyObject.ts index b6449c6..ea0c28a 100644 --- a/packages/react-lightning/src/utils/isEmptyObject.ts +++ b/packages/react-lightning/src/utils/isEmptyObject.ts @@ -1,4 +1,4 @@ -export function isEmptyObject(obj: object) { +export function isEmptyObject(obj: object): boolean { for (const _ in obj) { return false; } diff --git a/packages/react-lightning/src/utils/isTextStyleProp.ts b/packages/react-lightning/src/utils/isTextStyleProp.ts index aa28826..fd13661 100644 --- a/packages/react-lightning/src/utils/isTextStyleProp.ts +++ b/packages/react-lightning/src/utils/isTextStyleProp.ts @@ -23,7 +23,9 @@ const textProps = { fontStyle: true, fontStretch: true, fontSize: true, -} as const satisfies Partial>; +} as const; + +textProps satisfies Partial>; export type TextProps = keyof typeof textProps; diff --git a/packages/react-lightning/src/utils/keyExists.ts b/packages/react-lightning/src/utils/keyExists.ts index c758e0a..c414ea3 100644 --- a/packages/react-lightning/src/utils/keyExists.ts +++ b/packages/react-lightning/src/utils/keyExists.ts @@ -1,7 +1,7 @@ export function keyExists( obj: Record, keys: (number | string | symbol)[], -) { +): boolean { for (const key of keys) { if (key in obj) { return true; diff --git a/packages/react-lightning/src/utils/traceWrap.ts b/packages/react-lightning/src/utils/traceWrap.ts index 63bf109..908a568 100644 --- a/packages/react-lightning/src/utils/traceWrap.ts +++ b/packages/react-lightning/src/utils/traceWrap.ts @@ -1,4 +1,4 @@ -export function traceWrap(obj: T, skipTrace = false) { +export function traceWrap(obj: T, skipTrace = false): T { const copy = { ...obj }; for (const key in copy) { diff --git a/packages/react-lightning/tsconfig.json b/packages/react-lightning/tsconfig.json index b166c95..57bcdb0 100644 --- a/packages/react-lightning/tsconfig.json +++ b/packages/react-lightning/tsconfig.json @@ -1,10 +1,5 @@ { "extends": "@repo/configs/tsconfig.react-library.json", - "compilerOptions": { - "rootDir": "src", - "declaration": false, - "declarationMap": false - }, "include": ["src", "../../types/*.d.ts"], "exclude": ["node_modules", "dist"] } diff --git a/packages/react-lightning/tsdown.config.ts b/packages/react-lightning/tsdown.config.ts index b9c965a..d67c1c7 100644 --- a/packages/react-lightning/tsdown.config.ts +++ b/packages/react-lightning/tsdown.config.ts @@ -1,7 +1,7 @@ -import baseConfig from '@repo/configs/tsdown.config'; -import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; +import baseConfig from '../configs/tsdown.config'; -export default defineConfig({ +const config: UserConfig = defineConfig({ ...baseConfig, entry: ['src/index.ts', 'src/types/jsx.d.ts'], exports: { @@ -17,3 +17,5 @@ export default defineConfig({ }, }, }); + +export default config; diff --git a/packages/react-native-lightning-components/src/exports/layout/Column.tsx b/packages/react-native-lightning-components/src/exports/layout/Column.tsx index 55b2026..bfc3822 100644 --- a/packages/react-native-lightning-components/src/exports/layout/Column.tsx +++ b/packages/react-native-lightning-components/src/exports/layout/Column.tsx @@ -3,25 +3,26 @@ import RLColumn, { type ColumnProps as RLColumnProps, } from '@plextv/react-lightning-components/layout/Column'; import { createLayoutEvent } from '@plextv/react-native-lightning'; -import { forwardRef, useCallback } from 'react'; +import { type ForwardRefExoticComponent, forwardRef, useCallback } from 'react'; import type { ViewProps } from 'react-native'; export interface ColumnProps extends Omit { onLayout?: ViewProps['onLayout']; } -const Column = forwardRef( - ({ onLayout, ...props }, ref) => { - const handleLayout = useCallback( - (rect: Rect) => { - onLayout?.(createLayoutEvent(rect)); - }, - [onLayout], - ); +const Column: ForwardRefExoticComponent = forwardRef< + LightningViewElement, + ColumnProps +>(({ onLayout, ...props }, ref) => { + const handleLayout = useCallback( + (rect: Rect) => { + onLayout?.(createLayoutEvent(rect)); + }, + [onLayout], + ); - return ; - }, -); + return ; +}); Column.displayName = 'Column'; diff --git a/packages/react-native-lightning-components/src/exports/layout/Row.tsx b/packages/react-native-lightning-components/src/exports/layout/Row.tsx index c206ebe..7b87a36 100644 --- a/packages/react-native-lightning-components/src/exports/layout/Row.tsx +++ b/packages/react-native-lightning-components/src/exports/layout/Row.tsx @@ -3,25 +3,26 @@ import RLRow, { type RowProps as RLRowProps, } from '@plextv/react-lightning-components/layout/Row'; import { createLayoutEvent } from '@plextv/react-native-lightning'; -import { forwardRef, useCallback } from 'react'; +import { type ForwardRefExoticComponent, forwardRef, useCallback } from 'react'; import type { ViewProps } from 'react-native'; export interface RowProps extends Omit { onLayout?: ViewProps['onLayout']; } -const Row = forwardRef( - ({ onLayout, ...props }, ref) => { - const handleLayout = useCallback( - (rect: Rect) => { - onLayout?.(createLayoutEvent(rect)); - }, - [onLayout], - ); +const Row: ForwardRefExoticComponent = forwardRef< + LightningViewElement, + RowProps +>(({ onLayout, ...props }, ref) => { + const handleLayout = useCallback( + (rect: Rect) => { + onLayout?.(createLayoutEvent(rect)); + }, + [onLayout], + ); - return ; - }, -); + return ; +}); Row.displayName = 'Row'; diff --git a/packages/react-native-lightning-components/src/exports/lists/CellContainer.tsx b/packages/react-native-lightning-components/src/exports/lists/CellContainer.tsx index 3171160..0985b6c 100644 --- a/packages/react-native-lightning-components/src/exports/lists/CellContainer.tsx +++ b/packages/react-native-lightning-components/src/exports/lists/CellContainer.tsx @@ -4,51 +4,57 @@ import { createLayoutEvent, type ViewProps, } from '@plextv/react-native-lightning'; -import { forwardRef, useCallback, useMemo } from 'react'; +import { + type ForwardRefExoticComponent, + forwardRef, + useCallback, + useMemo, +} from 'react'; type CellContainerProps = ViewProps & { estimatedSize?: number; }; -const CellContainer = forwardRef( - ({ style, estimatedSize, onLayout, ...props }, forwardedRef) => { - const lngStyle = useMemo(() => convertCSSStyleToLightning(style), [style]); +const CellContainer: ForwardRefExoticComponent = forwardRef< + LightningElement, + CellContainerProps +>(({ style, estimatedSize, onLayout, ...props }, forwardedRef) => { + const lngStyle = useMemo(() => convertCSSStyleToLightning(style), [style]); - const handleOnLayout = useCallback( - (rect: Rect) => { - onLayout?.(createLayoutEvent(rect)); - }, - [onLayout], + const handleOnLayout = useCallback( + (rect: Rect) => { + onLayout?.(createLayoutEvent(rect)); + }, + [onLayout], + ); + if (!estimatedSize && import.meta.env.DEV) { + console.error( + 'FlashList: estimatedItemSize is required when using CellRendererComponent. Defaulting to 2.', ); - if (!estimatedSize && import.meta.env.DEV) { - console.error( - 'FlashList: estimatedItemSize is required when using CellRendererComponent. Defaulting to 2.', - ); - } + } - // We need to not set overflow: 'hidden' on the cell view, otherwise the - // FlashList will not render the items correctly. - return ( - - ); - }, -); + }, + ]} + /> + ); +}); CellContainer.displayName = 'LightningCellContainer'; diff --git a/packages/react-native-lightning-components/tsconfig.json b/packages/react-native-lightning-components/tsconfig.json index 50d8fdf..9e82ff4 100644 --- a/packages/react-native-lightning-components/tsconfig.json +++ b/packages/react-native-lightning-components/tsconfig.json @@ -1,9 +1,6 @@ { "extends": "@repo/configs/tsconfig.react-library.json", "compilerOptions": { - "rootDir": "src", - "declaration": false, - "declarationMap": false, "types": [ "node", "@plextv/react-lightning-plugin-flexbox/jsx", diff --git a/packages/react-native-lightning-components/tsdown.config.ts b/packages/react-native-lightning-components/tsdown.config.ts index 89c8b86..b4b2925 100644 --- a/packages/react-native-lightning-components/tsdown.config.ts +++ b/packages/react-native-lightning-components/tsdown.config.ts @@ -1,3 +1,3 @@ -import baseConfig from '@repo/configs/tsdown.withExports.config'; +import baseConfig from '../configs/tsdown.withExports.config'; export default baseConfig; diff --git a/packages/react-native-lightning/package.json b/packages/react-native-lightning/package.json index e381799..3159e2f 100644 --- a/packages/react-native-lightning/package.json +++ b/packages/react-native-lightning/package.json @@ -14,7 +14,7 @@ "type": "module", "main": "./dist/index.cjs", "module": "./dist/index.js", - "types": "./dist/index.d.ts", + "types": "./dist/index.d.cts", "exports": { ".": "./src/index.ts", "./package.json": "./package.json" @@ -31,9 +31,8 @@ } }, "scripts": { - "build": "tsdown && pnpm run build:types", - "build:watch": "tsdown -w", - "build:types": "tsc --outDir dist/lib --declarationDir dist --declaration true --emitDeclarationOnly true", + "build": "tsdown", + "watch": "tsdown -w", "clean": "del ./dist", "check:types": "tsc --noEmit", "test:unit": "vitest run --passWithNoTests" @@ -44,7 +43,7 @@ "dependencies": { "@plextv/react-lightning-plugin-css-transform": "workspace:*", "@plextv/react-lightning-plugin-flexbox": "workspace:*", - "its-fine": "^2.0.0", + "its-fine": "2.0.0", "react-native-web": "0.21.1" }, "devDependencies": { diff --git a/packages/react-native-lightning/src/exports/Button.tsx b/packages/react-native-lightning/src/exports/Button.tsx index ecb8b63..c44297e 100644 --- a/packages/react-native-lightning/src/exports/Button.tsx +++ b/packages/react-native-lightning/src/exports/Button.tsx @@ -3,7 +3,11 @@ import { useCombinedRef, useFocus, } from '@plextv/react-lightning'; -import { forwardRef, type RefAttributes } from 'react'; +import { + type ForwardRefExoticComponent, + forwardRef, + type RefAttributes, +} from 'react'; import type { ButtonProps as RNButtonProps, StyleProp, @@ -19,42 +23,43 @@ export type ButtonProps = RNButtonProps & | ((props: { pressed: boolean }) => StyleProp); }; -export const Button = forwardRef( - ({ title, color, style, ...props }, forwardedRef) => { - // TODO: height should come from text size - // TODO: Move to a stylesheet object (not doing this yet because vite caches things outside of the component function) - const baseStyles: ViewStyle = { - height: 40, - display: 'flex' as const, - justifyContent: 'center' as const, - alignItems: 'center' as const, - borderRadius: 4, - }; +export const Button: ForwardRefExoticComponent = forwardRef< + LightningViewElement, + ButtonProps +>(({ title, color, style, ...props }, forwardedRef) => { + // TODO: height should come from text size + // TODO: Move to a stylesheet object (not doing this yet because vite caches things outside of the component function) + const baseStyles: ViewStyle = { + height: 40, + display: 'flex' as const, + justifyContent: 'center' as const, + alignItems: 'center' as const, + borderRadius: 4, + }; - const { ref, focused } = useFocus(); - const combinedRef = useCombinedRef(forwardedRef, ref); + const { ref, focused } = useFocus(); + const combinedRef = useCombinedRef(forwardedRef, ref); - if (color && focused) { - baseStyles.backgroundColor = color; - } else { - baseStyles.backgroundColor = 'transparent'; - } + if (color && focused) { + baseStyles.backgroundColor = color; + } else { + baseStyles.backgroundColor = 'transparent'; + } - return ( - [ - baseStyles, - typeof style === 'function' ? style({ pressed }) : style, - { borderWidth: focused ? 4 : 0 }, - { opacity: pressed ? 0.6 : 1 }, - ]} - > - {title} - - ); - }, -); + return ( + [ + baseStyles, + typeof style === 'function' ? style({ pressed }) : style, + { borderWidth: focused ? 4 : 0 }, + { opacity: pressed ? 0.6 : 1 }, + ]} + > + {title} + + ); +}); Button.displayName = 'Button'; diff --git a/packages/react-native-lightning/src/exports/FocusGroup.tsx b/packages/react-native-lightning/src/exports/FocusGroup.tsx index 93cd6b2..3b1e3c2 100644 --- a/packages/react-native-lightning/src/exports/FocusGroup.tsx +++ b/packages/react-native-lightning/src/exports/FocusGroup.tsx @@ -4,29 +4,30 @@ import type { FocusGroupProps as RLFocusGroupProps, } from '@plextv/react-lightning'; import { FocusGroup as RLFocusGroup } from '@plextv/react-lightning'; -import { forwardRef, useCallback } from 'react'; +import { type ForwardRefExoticComponent, forwardRef, useCallback } from 'react'; import { createLayoutEvent } from '../utils/createLayoutEvent'; import type { ViewProps } from './View'; export type FocusGroupProps = AddMissingProps; -const FocusGroup = forwardRef( - ({ onLayout, ...props }, ref) => { - const handleFocusGroupLayout = useCallback( - (event: Rect) => { - onLayout?.(createLayoutEvent(event)); - }, - [onLayout], - ); +const FocusGroup: ForwardRefExoticComponent = forwardRef< + LightningElement, + FocusGroupProps +>(({ onLayout, ...props }, ref) => { + const handleFocusGroupLayout = useCallback( + (event: Rect) => { + onLayout?.(createLayoutEvent(event)); + }, + [onLayout], + ); - return ( - - ); - }, -); + return ( + + ); +}); export { FocusGroup }; diff --git a/packages/react-native-lightning/src/exports/FocusableView.tsx b/packages/react-native-lightning/src/exports/FocusableView.tsx index 325768d..b70095b 100644 --- a/packages/react-native-lightning/src/exports/FocusableView.tsx +++ b/packages/react-native-lightning/src/exports/FocusableView.tsx @@ -1,13 +1,11 @@ import { focusable } from '@plextv/react-lightning'; +import type { ForwardRefExoticComponent } from 'react'; import { View, type ViewProps } from './View'; -const FocusableView = focusable( - View, - undefined, - ({ active, autoFocus }) => ({ +const FocusableView: ForwardRefExoticComponent = + focusable(View, undefined, ({ active, autoFocus }) => ({ active, autoFocus, - }), -); + })); export { FocusableView }; diff --git a/packages/react-native-lightning/src/exports/Image.tsx b/packages/react-native-lightning/src/exports/Image.tsx index 1b9e63f..64944a4 100644 --- a/packages/react-native-lightning/src/exports/Image.tsx +++ b/packages/react-native-lightning/src/exports/Image.tsx @@ -3,7 +3,7 @@ import type { LightningElementStyle, LightningImageElement, } from '@plextv/react-lightning'; -import { forwardRef, useCallback } from 'react'; +import { type ForwardRefExoticComponent, forwardRef, useCallback } from 'react'; import type { ImageLoadEventData, ImageSourcePropType, @@ -28,7 +28,10 @@ function isImageURISource( export type Image = RNImage & LightningImageElement; -export const Image = forwardRef( +export const Image: ForwardRefExoticComponent = forwardRef< + LightningImageElement, + ImageProps +>( ( { onLoad, diff --git a/packages/react-native-lightning/src/exports/Platform.ts b/packages/react-native-lightning/src/exports/Platform.ts index f83e0ad..dc04159 100644 --- a/packages/react-native-lightning/src/exports/Platform.ts +++ b/packages/react-native-lightning/src/exports/Platform.ts @@ -7,7 +7,7 @@ export const isLightning = true; export const isTesting = true; export const Version = '0.1.0'; export const constants = { - isTesting, + isTesting: isTesting as boolean, reactNativeVersion: { major: 0, minor: 73, diff --git a/packages/react-native-lightning/src/exports/Pressable.tsx b/packages/react-native-lightning/src/exports/Pressable.tsx index 6dd7097..a1e04b0 100644 --- a/packages/react-native-lightning/src/exports/Pressable.tsx +++ b/packages/react-native-lightning/src/exports/Pressable.tsx @@ -1,6 +1,10 @@ import type { KeyEvent, LightningElement, Rect } from '@plextv/react-lightning'; import { focusable, Keys, LightningViewElement } from '@plextv/react-lightning'; -import type { DependencyList, RefAttributes } from 'react'; +import type { + DependencyList, + ForwardRefExoticComponent, + RefAttributes, +} from 'react'; import { useCallback, useState } from 'react'; import type { BlurEvent, @@ -33,7 +37,10 @@ function useEnterKeyHandler( ); } -export const Pressable = focusable( +export const Pressable: ForwardRefExoticComponent = focusable< + PressableProps, + LightningViewElement +>( function Pressable( { style, diff --git a/packages/react-native-lightning/src/exports/ScrollView.tsx b/packages/react-native-lightning/src/exports/ScrollView.tsx index 47fa52b..0ef936b 100644 --- a/packages/react-native-lightning/src/exports/ScrollView.tsx +++ b/packages/react-native-lightning/src/exports/ScrollView.tsx @@ -1,15 +1,18 @@ import { type LightningElement, LightningViewElement, + type LightningViewElementProps, simpleDiff, } from '@plextv/react-lightning'; import { Component, createRef } from 'react'; +import type { JSX } from 'react/jsx-runtime'; import type { NativeScrollEvent, ScrollView as RNScrollView, ScrollViewProps as RNScrollViewProps, } from 'react-native'; import { View } from 'react-native'; +import type { LightningViewElementStyle } from '../../../react-lightning/src/types'; import { createNativeSyntheticEvent } from '../utils/createNativeSyntheticEvent'; import { FocusGroup } from './FocusGroup'; import { defaultViewStyle } from './View'; @@ -143,7 +146,7 @@ export class ScrollView extends Component { } }; - public scrollToElement = (el: LightningElement) => { + public scrollToElement = (el: LightningElement): void => { const offset = this._getChildOffset(el); if (offset) { @@ -171,25 +174,31 @@ export class ScrollView extends Component { }); }; - public getScrollableNode() { + public getScrollableNode(): LightningViewElement< + LightningViewElementStyle, + LightningViewElementProps + > | null { return this._viewportRef.current; } // Undocumented - public getInnerViewNode() { + public getInnerViewNode(): LightningViewElement< + LightningViewElementStyle, + LightningViewElementProps + > | null { return this._containerRef.current; } public shouldComponentUpdate( nextProps: ScrollViewProps, nextState: ScrollViewState, - ) { + ): boolean { return ( !!simpleDiff(this.props, nextProps) || !!simpleDiff(this.state, nextState) ); } - public render() { + public render(): JSX.Element { const { children, style, diff --git a/packages/react-native-lightning/src/exports/StyleSheet.ts b/packages/react-native-lightning/src/exports/StyleSheet.ts index 49812ce..519aae4 100644 --- a/packages/react-native-lightning/src/exports/StyleSheet.ts +++ b/packages/react-native-lightning/src/exports/StyleSheet.ts @@ -1,6 +1,6 @@ export function create( stylesObject: Record>, -) { +): Record> { return stylesObject; } @@ -13,14 +13,14 @@ export function flatten(...args: T[]): Exclude { ); } -export function compose(style1: T, style2: T) { +export function compose(style1: T, style2: T): T | NonNullable[] { if (style1 && style2) { return [style1, style2]; } return style1 || style2; } -export function setStyleAttributePreprocessor(...args: unknown[]) { +export function setStyleAttributePreprocessor(...args: unknown[]): void { console.log('>> setStyleAttributePreprocessor', args); } diff --git a/packages/react-native-lightning/src/exports/Text.tsx b/packages/react-native-lightning/src/exports/Text.tsx index 39d8b82..dc5b00e 100644 --- a/packages/react-native-lightning/src/exports/Text.tsx +++ b/packages/react-native-lightning/src/exports/Text.tsx @@ -4,14 +4,21 @@ import type { LightningTextElementStyle, Rect, } from '@plextv/react-lightning'; -import { forwardRef, useCallback, useMemo } from 'react'; +import { + type ForwardRefExoticComponent, + forwardRef, + type RefAttributes, + useCallback, + useMemo, +} from 'react'; import type { Text as RNText, TextProps as RNTextProps } from 'react-native'; import { createLayoutEvent } from '../utils/createLayoutEvent'; import type { ViewProps } from './View'; -export type TextProps = AddMissingProps & { - onLoaded?: (dimensions: Rect) => void; -}; +export type TextProps = Omit, 'ref'> & + RefAttributes & { + onLoaded?: (dimensions: Rect) => void; + }; const defaultTextStyle: Partial = { fontWeight: 'normal', @@ -19,7 +26,10 @@ const defaultTextStyle: Partial = { export type Text = RNText & LightningTextElement; -export const Text = forwardRef( +export const Text: ForwardRefExoticComponent = forwardRef< + LightningTextElement, + TextProps +>( ( { onLoaded, diff --git a/packages/react-native-lightning/src/exports/TouchableHighlight.tsx b/packages/react-native-lightning/src/exports/TouchableHighlight.tsx index ca62284..d87205f 100644 --- a/packages/react-native-lightning/src/exports/TouchableHighlight.tsx +++ b/packages/react-native-lightning/src/exports/TouchableHighlight.tsx @@ -1,30 +1,31 @@ import type { LightningElement } from '@plextv/react-lightning'; import { useCombinedRef, useFocus } from '@plextv/react-lightning'; -import { forwardRef } from 'react'; +import { type ForwardRefExoticComponent, forwardRef } from 'react'; import type { TouchableHighlightProps } from 'react-native'; import { Pressable } from './Pressable'; -export const TouchableHighlight = forwardRef< - LightningElement, - TouchableHighlightProps ->(({ onLayout, activeOpacity, style, ...props }, ref) => { - const { ref: focusRef, focused } = useFocus(); - const combinedRef = useCombinedRef(ref, focusRef); +export const TouchableHighlight: ForwardRefExoticComponent = + forwardRef( + ({ onLayout, activeOpacity, style, ...props }, ref) => { + const { ref: focusRef, focused } = useFocus(); + const combinedRef = useCombinedRef(ref, focusRef); - const baseOpacity = focused ? 1 : 0.8; + const baseOpacity = focused ? 1 : 0.8; - return ( - [ - style, - { opacity: pressed ? (activeOpacity ?? 0.2) : baseOpacity }, - ]} - {...props} - onLayout={onLayout} - /> + return ( + [ + style, + { opacity: pressed ? (activeOpacity ?? 0.2) : baseOpacity }, + ]} + {...props} + onLayout={onLayout} + /> + ); + }, ); -}); + TouchableHighlight.displayName = 'TouchableHighlight'; export type { TouchableHighlightProps }; diff --git a/packages/react-native-lightning/src/exports/TouchableOpacity.tsx b/packages/react-native-lightning/src/exports/TouchableOpacity.tsx index c10326e..8ce35b6 100644 --- a/packages/react-native-lightning/src/exports/TouchableOpacity.tsx +++ b/packages/react-native-lightning/src/exports/TouchableOpacity.tsx @@ -1,30 +1,31 @@ import type { LightningElement } from '@plextv/react-lightning'; import { useCombinedRef, useFocus } from '@plextv/react-lightning'; -import { forwardRef } from 'react'; +import { type ForwardRefExoticComponent, forwardRef } from 'react'; import type { TouchableOpacityProps } from 'react-native'; import { Pressable } from './Pressable'; -export const TouchableOpacity = forwardRef< - LightningElement, - TouchableOpacityProps ->(({ onLayout, activeOpacity, style, ...props }, ref) => { - const { ref: focusRef, focused } = useFocus(); - const combinedRef = useCombinedRef(ref, focusRef); +export const TouchableOpacity: ForwardRefExoticComponent = + forwardRef( + ({ onLayout, activeOpacity, style, ...props }, ref) => { + const { ref: focusRef, focused } = useFocus(); + const combinedRef = useCombinedRef(ref, focusRef); - const baseOpacity = focused ? 1 : 0.8; + const baseOpacity = focused ? 1 : 0.8; - return ( - [ - style, - { opacity: pressed ? (activeOpacity ?? 0.2) : baseOpacity }, - ]} - {...props} - onLayout={onLayout} - /> + return ( + [ + style, + { opacity: pressed ? (activeOpacity ?? 0.2) : baseOpacity }, + ]} + {...props} + onLayout={onLayout} + /> + ); + }, ); -}); + TouchableOpacity.displayName = 'TouchableOpacity'; export type { TouchableOpacityProps }; diff --git a/packages/react-native-lightning/src/exports/TouchableWithoutFeedback.tsx b/packages/react-native-lightning/src/exports/TouchableWithoutFeedback.tsx index 7bbcf73..b9b2374 100644 --- a/packages/react-native-lightning/src/exports/TouchableWithoutFeedback.tsx +++ b/packages/react-native-lightning/src/exports/TouchableWithoutFeedback.tsx @@ -3,19 +3,20 @@ import { useCombinedRef, useFocus, } from '@plextv/react-lightning'; -import { forwardRef } from 'react'; +import { type ForwardRefExoticComponent, forwardRef } from 'react'; import type { TouchableWithoutFeedbackProps } from 'react-native'; import { Pressable } from './Pressable'; -export const TouchableWithoutFeedback = forwardRef< - LightningViewElement, - TouchableWithoutFeedbackProps ->(({ onLayout, ...props }, ref) => { - const { ref: focusRef } = useFocus(); - const combinedRef = useCombinedRef(ref, focusRef); +export const TouchableWithoutFeedback: ForwardRefExoticComponent = + forwardRef( + ({ onLayout, ...props }, ref) => { + const { ref: focusRef } = useFocus(); + const combinedRef = useCombinedRef(ref, focusRef); + + return ; + }, + ); - return ; -}); TouchableWithoutFeedback.displayName = 'TouchableWithoutFeedback'; export type { TouchableWithoutFeedbackProps }; diff --git a/packages/react-native-lightning/src/plugins/cssClassNameTransformPlugin.ts b/packages/react-native-lightning/src/plugins/cssClassNameTransformPlugin.ts index 3960031..729aba9 100644 --- a/packages/react-native-lightning/src/plugins/cssClassNameTransformPlugin.ts +++ b/packages/react-native-lightning/src/plugins/cssClassNameTransformPlugin.ts @@ -1,7 +1,8 @@ import type { Plugin } from '@plextv/react-lightning'; + // Necessary for the declaration merging to work below, since we don't import // the `react-native-web` typings. -import '../types/react-native-web.d.ts'; +// import '../types/react-native-web.d.ts'; declare module 'react-native-web' { namespace StyleSheet { diff --git a/packages/react-native-lightning/src/utils/createSyntheticEvent.ts b/packages/react-native-lightning/src/utils/createSyntheticEvent.ts index f6da162..51353fd 100644 --- a/packages/react-native-lightning/src/utils/createSyntheticEvent.ts +++ b/packages/react-native-lightning/src/utils/createSyntheticEvent.ts @@ -6,14 +6,16 @@ const defaultEventProps = { cancelable: false, defaultPrevented: false, eventPhase: 0, - isDefaultPrevented: () => false, - isPropagationStopped: () => false, + isDefaultPrevented: (): false => false, + isPropagationStopped: (): false => false, isTrusted: false, - persist: () => {}, - preventDefault: () => {}, - stopPropagation: () => {}, - timeStamp: Date.now(), -} satisfies Partial< + persist: (): void => {}, + preventDefault: (): void => {}, + stopPropagation: (): void => {}, + timeStamp: Date.now() as number, +} as const; + +defaultEventProps satisfies Partial< BaseSyntheticEvent >; diff --git a/packages/react-native-lightning/tsconfig.json b/packages/react-native-lightning/tsconfig.json index 553133a..8f8ca2b 100644 --- a/packages/react-native-lightning/tsconfig.json +++ b/packages/react-native-lightning/tsconfig.json @@ -1,10 +1,6 @@ { "extends": "@repo/configs/tsconfig.react-library.json", "compilerOptions": { - "rootDir": "src", - "outDir": "dist", - "declaration": false, - "declarationMap": false, "types": [ "node", "@plextv/react-lightning-plugin-css-transform/jsx", diff --git a/packages/react-native-lightning/tsdown.config.ts b/packages/react-native-lightning/tsdown.config.ts index 3616e37..646fd6d 100644 --- a/packages/react-native-lightning/tsdown.config.ts +++ b/packages/react-native-lightning/tsdown.config.ts @@ -1,9 +1,11 @@ -import baseConfig from '@repo/configs/tsdown.config'; -import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; +import baseConfig from '../configs/tsdown.config'; -export default defineConfig({ +const config: UserConfig = defineConfig({ ...baseConfig, // Todo: Figure out why tsdown wants to import the react-native-web types // in the final bundle. - dts: false, + // dts: false, }); + +export default config; diff --git a/packages/vite-plugin-msdf-fontgen/package.json b/packages/vite-plugin-msdf-fontgen/package.json index 655b8ed..d41d110 100644 --- a/packages/vite-plugin-msdf-fontgen/package.json +++ b/packages/vite-plugin-msdf-fontgen/package.json @@ -17,7 +17,7 @@ "type": "module", "main": "./dist/index.js", "module": "./dist/index.js", - "types": "./dist/index-BZeJgyNV.d.ts", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js", "./package.json": "./package.json" @@ -39,7 +39,7 @@ ], "dependencies": { "@lightningjs/msdf-generator": "1.1.1", - "crc-32": "^1.2.2", + "crc-32": "1.2.2", "glob": "11.0.3" }, "devDependencies": { diff --git a/packages/vite-plugin-msdf-fontgen/src/checksum.ts b/packages/vite-plugin-msdf-fontgen/src/checksum.ts index 0829c67..3abd9a1 100644 --- a/packages/vite-plugin-msdf-fontgen/src/checksum.ts +++ b/packages/vite-plugin-msdf-fontgen/src/checksum.ts @@ -5,7 +5,9 @@ import crc32 from 'crc-32'; const CHECKSUM_FILENAME = 'hash.json'; -export async function readFileChecksum(filePath: string) { +export async function readFileChecksum( + filePath: string, +): Promise { try { const fileData = await readFile(filePath); @@ -41,7 +43,7 @@ export async function readChecksumCache( export async function writeChecksumCache( checksums: Record, checksumFolder: string, -) { +): Promise { try { if (!existsSync(checksumFolder)) { console.info( diff --git a/packages/vite-plugin-msdf-fontgen/src/configs.ts b/packages/vite-plugin-msdf-fontgen/src/configs.ts index febd797..2f69bb8 100644 --- a/packages/vite-plugin-msdf-fontgen/src/configs.ts +++ b/packages/vite-plugin-msdf-fontgen/src/configs.ts @@ -7,7 +7,7 @@ export async function ensureConfigsExist({ charsetFile, overrides, overridesFile, -}: OptionsInput) { +}: OptionsInput): Promise<() => Promise> { const cleanupFiles: string[] = []; console.info(`Looking for charset file at ${charsetFile}`); @@ -42,7 +42,6 @@ export async function ensureConfigsExist({ return () => { console.log('Cleaning up...'); - return Promise.all( cleanupFiles.map((file) => { console.info(` Removing ${file}`); diff --git a/packages/vite-plugin-msdf-fontgen/src/generateFonts.ts b/packages/vite-plugin-msdf-fontgen/src/generateFonts.ts index f02353a..b6a0dc7 100644 --- a/packages/vite-plugin-msdf-fontgen/src/generateFonts.ts +++ b/packages/vite-plugin-msdf-fontgen/src/generateFonts.ts @@ -13,7 +13,7 @@ export default async function generateFonts( checksums: Record, cacheFolder: string, copyOriginalToDestDir: boolean, -) { +): Promise { const cleanup = await ensureConfigsExist(options); const { charsetFile, types } = options; diff --git a/packages/vite-plugin-msdf-fontgen/src/getFiles.ts b/packages/vite-plugin-msdf-fontgen/src/getFiles.ts index c9eb924..172576b 100644 --- a/packages/vite-plugin-msdf-fontgen/src/getFiles.ts +++ b/packages/vite-plugin-msdf-fontgen/src/getFiles.ts @@ -24,7 +24,7 @@ export default async function getFiles( { src, dest, charsetFile, types, extensions }: OptionsInput, force: boolean, checksums: Record, -) { +): Promise { const fontFiles: Record = {}; const extensionGlob = extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0]; diff --git a/packages/vite-plugin-msdf-fontgen/src/sortByExtension.ts b/packages/vite-plugin-msdf-fontgen/src/sortByExtension.ts index 24de796..cc316c2 100644 --- a/packages/vite-plugin-msdf-fontgen/src/sortByExtension.ts +++ b/packages/vite-plugin-msdf-fontgen/src/sortByExtension.ts @@ -1,5 +1,7 @@ -export function sortByExtension(extensions: string[]) { - return (a: string, b: string) => { +export function sortByExtension( + extensions: string[], +): (a: string, b: string) => number { + return (a: string, b: string): number => { const extA = a.split('.').pop() as string; const extB = b.split('.').pop() as string; return extensions.indexOf(extA) - extensions.indexOf(extB); diff --git a/packages/vite-plugin-msdf-fontgen/tsconfig.json b/packages/vite-plugin-msdf-fontgen/tsconfig.json index 56ee006..c57cff2 100644 --- a/packages/vite-plugin-msdf-fontgen/tsconfig.json +++ b/packages/vite-plugin-msdf-fontgen/tsconfig.json @@ -1,11 +1,5 @@ { "extends": "@repo/configs/tsconfig.json", - "compilerOptions": { - "rootDir": "src", - "outDir": "dist", - "declaration": false, - "declarationMap": false - }, "include": ["src", "../../types/*.d.ts"], "exclude": ["node_modules", "dist"] } diff --git a/packages/vite-plugin-msdf-fontgen/tsdown.config.ts b/packages/vite-plugin-msdf-fontgen/tsdown.config.ts index 2664f18..fe94ca6 100644 --- a/packages/vite-plugin-msdf-fontgen/tsdown.config.ts +++ b/packages/vite-plugin-msdf-fontgen/tsdown.config.ts @@ -1,7 +1,7 @@ -import baseConfig from '@repo/configs/tsdown.config'; -import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; +import baseConfig from '../configs/tsdown.config'; -export default defineConfig({ +const config: UserConfig = defineConfig({ ...baseConfig, format: 'esm', target: 'node22', @@ -10,3 +10,5 @@ export default defineConfig({ devExports: false, }, }); + +export default config; diff --git a/packages/vite-plugin-react-native-lightning/package.json b/packages/vite-plugin-react-native-lightning/package.json index e964369..6fbca92 100644 --- a/packages/vite-plugin-react-native-lightning/package.json +++ b/packages/vite-plugin-react-native-lightning/package.json @@ -19,7 +19,7 @@ "type": "module", "main": "./dist/index.js", "module": "./dist/index.js", - "types": "./dist/index-DnMelX_-.d.ts", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js", "./package.json": "./package.json" diff --git a/packages/vite-plugin-react-native-lightning/tsconfig.json b/packages/vite-plugin-react-native-lightning/tsconfig.json index a06d639..c57cff2 100644 --- a/packages/vite-plugin-react-native-lightning/tsconfig.json +++ b/packages/vite-plugin-react-native-lightning/tsconfig.json @@ -1,9 +1,5 @@ { "extends": "@repo/configs/tsconfig.json", - "compilerOptions": { - "rootDir": "src", - "outDir": "dist" - }, "include": ["src", "../../types/*.d.ts"], "exclude": ["node_modules", "dist"] } diff --git a/packages/vite-plugin-react-native-lightning/tsdown.config.ts b/packages/vite-plugin-react-native-lightning/tsdown.config.ts index 622f715..0b451ba 100644 --- a/packages/vite-plugin-react-native-lightning/tsdown.config.ts +++ b/packages/vite-plugin-react-native-lightning/tsdown.config.ts @@ -1,7 +1,7 @@ -import baseConfig from '@repo/configs/tsdown.config'; -import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; +import baseConfig from '../configs/tsdown.config'; -export default defineConfig({ +const config: UserConfig = defineConfig({ ...baseConfig, format: 'esm', target: 'node22', @@ -9,3 +9,5 @@ export default defineConfig({ devExports: false, }, }); + +export default config; diff --git a/packages/vite-plugin-react-reanimated-lightning/package.json b/packages/vite-plugin-react-reanimated-lightning/package.json index b164880..67c5d00 100644 --- a/packages/vite-plugin-react-reanimated-lightning/package.json +++ b/packages/vite-plugin-react-reanimated-lightning/package.json @@ -20,7 +20,7 @@ "type": "module", "main": "./dist/index.js", "module": "./dist/index.js", - "types": "./dist/index-DZReoLB_.d.ts", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js", "./package.json": "./package.json" diff --git a/packages/vite-plugin-react-reanimated-lightning/tsconfig.json b/packages/vite-plugin-react-reanimated-lightning/tsconfig.json index a06d639..c57cff2 100644 --- a/packages/vite-plugin-react-reanimated-lightning/tsconfig.json +++ b/packages/vite-plugin-react-reanimated-lightning/tsconfig.json @@ -1,9 +1,5 @@ { "extends": "@repo/configs/tsconfig.json", - "compilerOptions": { - "rootDir": "src", - "outDir": "dist" - }, "include": ["src", "../../types/*.d.ts"], "exclude": ["node_modules", "dist"] } diff --git a/packages/vite-plugin-react-reanimated-lightning/tsdown.config.ts b/packages/vite-plugin-react-reanimated-lightning/tsdown.config.ts index 2664f18..fe94ca6 100644 --- a/packages/vite-plugin-react-reanimated-lightning/tsdown.config.ts +++ b/packages/vite-plugin-react-reanimated-lightning/tsdown.config.ts @@ -1,7 +1,7 @@ -import baseConfig from '@repo/configs/tsdown.config'; -import { defineConfig } from 'tsdown'; +import { defineConfig, type UserConfig } from 'tsdown'; +import baseConfig from '../configs/tsdown.config'; -export default defineConfig({ +const config: UserConfig = defineConfig({ ...baseConfig, format: 'esm', target: 'node22', @@ -10,3 +10,5 @@ export default defineConfig({ devExports: false, }, }); + +export default config; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cc84ea2..6084922 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,8 +36,8 @@ importers: specifier: 9.0.4 version: 9.0.4 tsdown: - specifier: ^0.15.7 - version: 0.15.7(typescript@5.9.3) + specifier: 0.16.6 + version: 0.16.6(typescript@5.9.3) tsx: specifier: 4.20.6 version: 4.20.6 @@ -54,7 +54,7 @@ importers: specifier: 7.1.10 version: 7.1.10(@types/node@24.7.2)(jiti@2.6.1)(terser@5.44.0)(tsx@4.20.6)(yaml@2.8.1) vite-plugin-externalize-deps: - specifier: ^0.10.0 + specifier: 0.10.0 version: 0.10.0(vite@7.1.10(@types/node@24.7.2)(jiti@2.6.1)(terser@5.44.0)(tsx@4.20.6)(yaml@2.8.1)) vitest: specifier: 3.2.4 @@ -404,7 +404,7 @@ importers: specifier: workspace:* version: link:../plugin-flexbox its-fine: - specifier: ^2.0.0 + specifier: 2.0.0 version: 2.0.0(@types/react@19.2.2)(react@19.2.0) react: specifier: ^19.2.0 @@ -469,7 +469,7 @@ importers: specifier: 1.1.1 version: 1.1.1 crc-32: - specifier: ^1.2.2 + specifier: 1.2.2 version: 1.2.2 glob: specifier: 11.0.3 @@ -526,6 +526,10 @@ packages: resolution: {integrity: sha512-3lSpxGgvnmZznmBkCRnVREPUFJv2wrv9iAoFDvADJc0ypmdOxdUtcLeBgBJ6zE0PMeTKnxeQzyk0xTBq4Ep7zw==} engines: {node: '>=6.9.0'} + '@babel/generator@7.28.5': + resolution: {integrity: sha512-3EwLFhZ38J4VyIP6WNtt2kUdW9dokXA9Cr4IVIFHuCpZ3H8/YFOl5JjZHisrn1fATPBmKKqXzDFvh9fUwHz6CQ==} + engines: {node: '>=6.9.0'} + '@babel/helper-annotate-as-pure@7.27.3': resolution: {integrity: sha512-fXSwMQqitTGeHLBC08Eq5yXz2m37E4pJX1qAU1+2cNedz/ifv/bVXft90VeSav5nFO61EcNgwr0aJxbyPaWBPg==} engines: {node: '>=6.9.0'} @@ -601,6 +605,10 @@ packages: resolution: {integrity: sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==} engines: {node: '>=6.9.0'} + '@babel/helper-validator-identifier@7.28.5': + resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==} + engines: {node: '>=6.9.0'} + '@babel/helper-validator-option@7.27.1': resolution: {integrity: sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==} engines: {node: '>=6.9.0'} @@ -618,6 +626,11 @@ packages: engines: {node: '>=6.0.0'} hasBin: true + '@babel/parser@7.28.5': + resolution: {integrity: sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==} + engines: {node: '>=6.0.0'} + hasBin: true + '@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.27.1': resolution: {integrity: sha512-QPG3C9cCVRQLxAVwmefEmwdTanECuUBMQZ/ym5kiw3XKCGA7qkuQLcjWWHcrD/GKbn/WmJwaezfuuAOcyKlRPA==} engines: {node: '>=6.9.0'} @@ -1118,6 +1131,10 @@ packages: resolution: {integrity: sha512-bkFqkLhh3pMBUQQkpVgWDWq/lqzc2678eUyDlTBhRqhCHFguYYGM0Efga7tYk4TogG/3x0EEl66/OQ+WGbWB/Q==} engines: {node: '>=6.9.0'} + '@babel/types@7.28.5': + resolution: {integrity: sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA==} + engines: {node: '>=6.9.0'} + '@biomejs/biome@2.2.6': resolution: {integrity: sha512-yKTCNGhek0rL5OEW1jbLeZX8LHaM8yk7+3JRGv08my+gkpmtb5dDE+54r2ZjZx0ediFEn1pYBOJSmOdDP9xtFw==} engines: {node: '>=14.21.3'} @@ -1650,6 +1667,10 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} + '@oxc-project/runtime@0.96.0': + resolution: {integrity: sha512-34lh4o9CcSw09Hx6fKihPu85+m+4pmDlkXwJrLvN5nMq5JrcGhhihVM415zDqT8j8IixO1PYYdQZRN4SwQCncg==} + engines: {node: ^20.19.0 || >=22.12.0} + '@oxc-project/types@0.98.0': resolution: {integrity: sha512-Vzmd6FsqVuz5HQVcRC/hrx7Ujo3WEVeQP7C2UNP5uy1hUY4SQvMB+93jxkI1KRHz9a/6cni3glPOtvteN+zpsw==} @@ -2295,8 +2316,8 @@ packages: resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} engines: {node: '>=12'} - ast-kit@2.1.3: - resolution: {integrity: sha512-TH+b3Lv6pUjy/Nu0m6A2JULtdzLpmqF9x1Dhj00ZoEiML8qvVA9j1flkzTKNYgdEhWrjDwtWNpyyCUbfQe514g==} + ast-kit@2.2.0: + resolution: {integrity: sha512-m1Q/RaVOnTp9JxPX+F+Zn7IcLYMzM8kZofDImfsKZd8MbR+ikdOzTeztStWqfrqIxZnYWryyI9ePm3NGjnZgGw==} engines: {node: '>=20.19.0'} ast-types@0.16.1: @@ -2367,8 +2388,8 @@ packages: resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} engines: {node: '>=4'} - birpc@2.6.1: - resolution: {integrity: sha512-LPnFhlDpdSH6FJhJyn4M0kFO7vtQ5iPw24FnG0y21q09xC7e8+1LeR31S1MAIrDAHp4m7aas4bEkTDTvMAtebQ==} + birpc@2.8.0: + resolution: {integrity: sha512-Bz2a4qD/5GRhiHSwj30c/8kC8QGj12nNDwz3D4ErQ4Xhy35dsSDvF+RA/tWpjyU0pdGtSDiEk6B5fBGE1qNVhw==} bmp-js@0.1.0: resolution: {integrity: sha512-vHdS19CnY3hwiNdkaqk93DvjVLfbEcI8mys4UjuWrlX1haDmroo8o4xCzh4wD6DGV6HxRCyauwhHRqMTfERtjw==} @@ -2626,9 +2647,6 @@ packages: resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==} engines: {node: '>=8'} - defu@6.1.4: - resolution: {integrity: sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==} - del-cli@7.0.0: resolution: {integrity: sha512-fRl4pWJYu9WFQH8jXdQUYvcD0IMtij9WEc7qmB7xOyJEweNJNuE7iKmqNeoOT1DbBUjtRjxlw8Y63qKBI/NQ1g==} engines: {node: '>=18'} @@ -2691,9 +2709,9 @@ packages: resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==} engines: {node: '>=8'} - dts-resolver@2.1.2: - resolution: {integrity: sha512-xeXHBQkn2ISSXxbJWD828PFjtyg+/UrMDo7W4Ffcs7+YWCquxU8YjV1KoxuiL+eJ5pg3ll+bC6flVv61L3LKZg==} - engines: {node: '>=20.18.0'} + dts-resolver@2.1.3: + resolution: {integrity: sha512-bihc7jPC90VrosXNzK0LTE2cuLP6jr0Ro8jk+kMugHReJVLIpHz/xadeq3MhuwyO4TD4OA3L1Q8pBBFRc08Tsw==} + engines: {node: '>=20.19.0'} peerDependencies: oxc-resolver: '>=11.0.0' peerDependenciesMeta: @@ -2963,6 +2981,9 @@ packages: get-tsconfig@4.12.0: resolution: {integrity: sha512-LScr2aNr2FbjAjZh2C6X6BxRx1/x+aTDExct/xyq2XKbYOiG5c0aK7pMsSuyc0brz3ibr/lbQiHD9jzt4lccJw==} + get-tsconfig@4.13.0: + resolution: {integrity: sha512-1VKTZJCwBrvbd+Wn3AOgQP/2Av+TfTCOlE4AcRJE72W1ksZXbAx8PPBR9RzgTeSPzlPMHrbANMH3LbltH73wxQ==} + glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -3403,6 +3424,9 @@ packages: magic-string@0.30.19: resolution: {integrity: sha512-2N21sPY9Ws53PZvsEpVtNuSW+ScYbQdp4b9qUaL+9QkHUrGFKo56Lg9Emg5s9V/qrtNBmiR01sYhUOwu3H+VOw==} + magic-string@0.30.21: + resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} + make-dir@3.1.0: resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} engines: {node: '>=8'} @@ -3633,6 +3657,9 @@ packages: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} + obug@2.1.0: + resolution: {integrity: sha512-uu/tgLPoa75CFA7UDkmqspKbefvZh1WMPwkU3bNr0PY746a/+xwXVgbw5co5C3GvJj3h5u8g/pbxXzI0gd1QFg==} + omggif@1.0.10: resolution: {integrity: sha512-LMJTtvgc/nugXj0Vcrrs68Mn2D1r0zf630VNtqtpI1FEO7e+O9FP4gqs9AcnBaSEeoHIPm28u6qgPR0oyEpGSw==} @@ -4116,13 +4143,13 @@ packages: deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true - rolldown-plugin-dts@0.16.11: - resolution: {integrity: sha512-9IQDaPvPqTx3RjG2eQCK5GYZITo203BxKunGI80AGYicu1ySFTUyugicAaTZWRzFWh9DSnzkgNeMNbDWBbSs0w==} - engines: {node: '>=20.18.0'} + rolldown-plugin-dts@0.18.0: + resolution: {integrity: sha512-2CJtKYa9WPClZxkJeCt4bGUegQvQKQ1VJp9jFJzG0h8I/80XI6qDgoWfVJUOEhT2swbsRQh/42N1RIWvbXT4rA==} + engines: {node: '>=20.19.0'} peerDependencies: '@ts-macro/tsc': ^0.3.6 '@typescript/native-preview': '>=7.0.0-dev.20250601.1' - rolldown: ^1.0.0-beta.9 + rolldown: ^1.0.0-beta.51 typescript: ^5.0.0 vue-tsc: ~3.1.0 peerDependenciesMeta: @@ -4418,8 +4445,9 @@ packages: tinyexec@0.3.2: resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==} - tinyexec@1.0.1: - resolution: {integrity: sha512-5uC6DDlmeqiOwCPmK9jMSdOuZTh8bU39Ys6yidB+UTt5hfZUPGAypSgFRiEp+jbi9qH40BLDvy85jIU88wKSqw==} + tinyexec@1.0.2: + resolution: {integrity: sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==} + engines: {node: '>=18'} tinyglobby@0.2.15: resolution: {integrity: sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==} @@ -4480,12 +4508,13 @@ packages: resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==} engines: {node: '>=6'} - tsdown@0.15.7: - resolution: {integrity: sha512-uFaVgWAogjOMqjY+CQwrUt3C6wzy6ynt82CIoXymnbS17ipUZ8WDXUceJjkislUahF/BZc5+W44Ue3p2oWtqUg==} + tsdown@0.16.6: + resolution: {integrity: sha512-g3xHEnGdfwJTlXhEkqww3Q/KlCfyNFw4rnzuQ9Gqw8T2xjDYrw94qmSw5wYYTAW5zV1sEfWDlfgxZo5mmtu0NQ==} engines: {node: '>=20.19.0'} hasBin: true peerDependencies: '@arethetypeswrong/core': ^0.18.1 + '@vitejs/devtools': ^0.0.0-alpha.17 publint: ^0.3.0 typescript: ^5.0.0 unplugin-lightningcss: ^0.4.0 @@ -4493,6 +4522,8 @@ packages: peerDependenciesMeta: '@arethetypeswrong/core': optional: true + '@vitejs/devtools': + optional: true publint: optional: true typescript: @@ -4580,8 +4611,8 @@ packages: engines: {node: '>=0.8.0'} hasBin: true - unconfig@7.3.3: - resolution: {integrity: sha512-QCkQoOnJF8L107gxfHL0uavn7WD9b3dpBcFX6HtfQYmjw2YzWxGuFQ0N0J6tE9oguCBJn9KOvfqYDCMPHIZrBA==} + unconfig-core@7.4.1: + resolution: {integrity: sha512-Bp/bPZjV2Vl/fofoA2OYLSnw1Z0MOhCX7zHnVCYrazpfZvseBbGhwcNQMxsg185Mqh7VZQqK3C8hFG/Dyng+yA==} undici-types@7.14.0: resolution: {integrity: sha512-QQiYxHuyZ9gQUIrmPo3IA+hUl4KYk8uSA7cHrcKd/l3p1OTpZcM0Tbp9x7FAtXdAYhlasd60ncPpgu6ihG6TOA==} @@ -4630,6 +4661,16 @@ packages: resolution: {integrity: sha512-4/u/j4FrCKdi17jaxuJA0jClGxB1AvU2hw/IuayPc4ay1XGaJs/rbb4v5WKwAjNifjmXK9PIFyuPiaK8azyR9w==} engines: {node: '>=14.0.0'} + unrun@0.2.11: + resolution: {integrity: sha512-HjUuNLRGfRxMvxkwOuO/CpkSzdizTPPApbarLplsTzUm8Kex+nS9eomKU1qgVus6WGWkDYhtf/mgNxGEpyTR6A==} + engines: {node: '>=20.19.0'} + hasBin: true + peerDependencies: + synckit: ^0.11.11 + peerDependenciesMeta: + synckit: + optional: true + untildify@4.0.0: resolution: {integrity: sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==} engines: {node: '>=8'} @@ -4954,6 +4995,14 @@ snapshots: '@jridgewell/trace-mapping': 0.3.31 jsesc: 3.1.0 + '@babel/generator@7.28.5': + dependencies: + '@babel/parser': 7.28.5 + '@babel/types': 7.28.5 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 + jsesc: 3.1.0 + '@babel/helper-annotate-as-pure@7.27.3': dependencies: '@babel/types': 7.28.4 @@ -5057,6 +5106,8 @@ snapshots: '@babel/helper-validator-identifier@7.27.1': {} + '@babel/helper-validator-identifier@7.28.5': {} + '@babel/helper-validator-option@7.27.1': {} '@babel/helper-wrap-function@7.28.3': @@ -5076,6 +5127,10 @@ snapshots: dependencies: '@babel/types': 7.28.4 + '@babel/parser@7.28.5': + dependencies: + '@babel/types': 7.28.5 + '@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.27.1(@babel/core@7.28.4)': dependencies: '@babel/core': 7.28.4 @@ -5689,6 +5744,11 @@ snapshots: '@babel/helper-string-parser': 7.27.1 '@babel/helper-validator-identifier': 7.27.1 + '@babel/types@7.28.5': + dependencies: + '@babel/helper-string-parser': 7.27.1 + '@babel/helper-validator-identifier': 7.28.5 + '@biomejs/biome@2.2.6': optionalDependencies: '@biomejs/cli-darwin-arm64': 2.2.6 @@ -6347,6 +6407,8 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.19.1 + '@oxc-project/runtime@0.96.0': {} + '@oxc-project/types@0.98.0': {} '@pkgjs/parseargs@0.11.0': @@ -6972,9 +7034,9 @@ snapshots: assertion-error@2.0.1: {} - ast-kit@2.1.3: + ast-kit@2.2.0: dependencies: - '@babel/parser': 7.28.4 + '@babel/parser': 7.28.5 pathe: 2.0.3 ast-types@0.16.1: @@ -7080,7 +7142,7 @@ snapshots: dependencies: is-windows: 1.0.2 - birpc@2.6.1: {} + birpc@2.8.0: {} bmp-js@0.1.0: {} @@ -7350,8 +7412,6 @@ snapshots: define-lazy-prop@2.0.0: {} - defu@6.1.4: {} - del-cli@7.0.0: dependencies: del: 8.0.1 @@ -7428,7 +7488,7 @@ snapshots: dependencies: is-obj: 2.0.0 - dts-resolver@2.1.2: {} + dts-resolver@2.1.3: {} duplexer3@0.1.5: {} @@ -7681,6 +7741,10 @@ snapshots: dependencies: resolve-pkg-maps: 1.0.0 + get-tsconfig@4.13.0: + dependencies: + resolve-pkg-maps: 1.0.0 + glob-parent@5.1.2: dependencies: is-glob: 4.0.3 @@ -8047,7 +8111,8 @@ snapshots: transitivePeerDependencies: - debug - jiti@2.6.1: {} + jiti@2.6.1: + optional: true jpeg-js@0.3.7: {} @@ -8173,6 +8238,10 @@ snapshots: dependencies: '@jridgewell/sourcemap-codec': 1.5.5 + magic-string@0.30.21: + dependencies: + '@jridgewell/sourcemap-codec': 1.5.5 + make-dir@3.1.0: dependencies: semver: 6.3.1 @@ -8488,6 +8557,8 @@ snapshots: object-assign@4.1.1: {} + obug@2.1.0: {} + omggif@1.0.10: {} on-finished@2.3.0: @@ -9018,23 +9089,22 @@ snapshots: dependencies: glob: 7.2.3 - rolldown-plugin-dts@0.16.11(rolldown@1.0.0-beta.51)(typescript@5.9.3): - dependencies: - '@babel/generator': 7.28.3 - '@babel/parser': 7.28.4 - '@babel/types': 7.28.4 - ast-kit: 2.1.3 - birpc: 2.6.1 - debug: 4.4.3 - dts-resolver: 2.1.2 - get-tsconfig: 4.12.0 - magic-string: 0.30.19 + rolldown-plugin-dts@0.18.0(rolldown@1.0.0-beta.51)(typescript@5.9.3): + dependencies: + '@babel/generator': 7.28.5 + '@babel/parser': 7.28.5 + '@babel/types': 7.28.5 + ast-kit: 2.2.0 + birpc: 2.8.0 + dts-resolver: 2.1.3 + get-tsconfig: 4.13.0 + magic-string: 0.30.21 + obug: 2.1.0 rolldown: 1.0.0-beta.51 optionalDependencies: typescript: 5.9.3 transitivePeerDependencies: - oxc-resolver - - supports-color rolldown@1.0.0-beta.51: dependencies: @@ -9341,7 +9411,7 @@ snapshots: tinyexec@0.3.2: {} - tinyexec@1.0.1: {} + tinyexec@1.0.2: {} tinyglobby@0.2.15: dependencies: @@ -9382,29 +9452,30 @@ snapshots: minimist: 1.2.8 strip-bom: 3.0.0 - tsdown@0.15.7(typescript@5.9.3): + tsdown@0.16.6(typescript@5.9.3): dependencies: ansis: 4.2.0 cac: 6.7.14 chokidar: 4.0.3 - debug: 4.4.3 diff: 8.0.2 empathic: 2.0.0 hookable: 5.5.3 + obug: 2.1.0 rolldown: 1.0.0-beta.51 - rolldown-plugin-dts: 0.16.11(rolldown@1.0.0-beta.51)(typescript@5.9.3) + rolldown-plugin-dts: 0.18.0(rolldown@1.0.0-beta.51)(typescript@5.9.3) semver: 7.7.3 - tinyexec: 1.0.1 + tinyexec: 1.0.2 tinyglobby: 0.2.15 tree-kill: 1.2.2 - unconfig: 7.3.3 + unconfig-core: 7.4.1 + unrun: 0.2.11 optionalDependencies: typescript: 5.9.3 transitivePeerDependencies: - '@ts-macro/tsc' - '@typescript/native-preview' - oxc-resolver - - supports-color + - synckit - vue-tsc tseep@1.3.1: {} @@ -9466,11 +9537,9 @@ snapshots: uglify-js@3.19.3: optional: true - unconfig@7.3.3: + unconfig-core@7.4.1: dependencies: '@quansync/fs': 0.1.5 - defu: 6.1.4 - jiti: 2.6.1 quansync: 0.2.11 undici-types@7.14.0: {} @@ -9505,6 +9574,11 @@ snapshots: acorn: 8.15.0 webpack-virtual-modules: 0.6.2 + unrun@0.2.11: + dependencies: + '@oxc-project/runtime': 0.96.0 + rolldown: 1.0.0-beta.51 + untildify@4.0.0: {} update-browserslist-db@1.1.3(browserslist@4.26.3): diff --git a/tsconfig.json b/tsconfig.json index 623fda7..bacc439 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,3 +1,6 @@ { - "extends": "@repo/configs/tsconfig.json" + "extends": "@repo/configs/tsconfig.json", + "compilerOptions": { + "rootDir": "." + } }