Skip to content

Commit

Permalink
refactor: make unprefixed elements opt-in
Browse files Browse the repository at this point in the history
BREAKING CHANGE: unprefixed elements must be explicitly added

Signed-off-by: Trezy <tre@trezy.com>
  • Loading branch information
trezy committed Dec 31, 2024
1 parent 2f18915 commit b820aba
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 21 deletions.
8 changes: 7 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ export default [
{
rules: {
'max-len': 0,
'@typescript-eslint/no-empty-object-type': [
0,
{
allowInterfaces: 'with-single-extends',
},
],
},
},
{
Expand All @@ -20,7 +26,6 @@ export default [
'*.test.tsx',
],
rules: {
'@typescript-eslint/no-unused-expressions': 0,
'@typescript-eslint/dot-notation': [
0,
{
Expand All @@ -29,6 +34,7 @@ export default [
allowIndexSignaturePropertyAccess: true,
},
],
'@typescript-eslint/no-unused-expressions': 0,
'dot-notation': 0,
},
},
Expand Down
7 changes: 3 additions & 4 deletions src/global.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type NamespacedPixiElements } from './typedefs/NamespacedPixiElements';
import { type PixiElements } from './typedefs/PixiElements';

import type {} from 'react';
Expand All @@ -10,7 +9,7 @@ declare module 'react'
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX
{
interface IntrinsicElements extends PixiElements, NamespacedPixiElements {}
interface IntrinsicElements extends PixiElements {}
}
}

Expand All @@ -19,7 +18,7 @@ declare module 'react/jsx-runtime'
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX
{
interface IntrinsicElements extends PixiElements, NamespacedPixiElements {}
interface IntrinsicElements extends PixiElements {}
}
}

Expand All @@ -28,6 +27,6 @@ declare module 'react/jsx-dev-runtime'
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX
{
interface IntrinsicElements extends PixiElements, NamespacedPixiElements {}
interface IntrinsicElements extends PixiElements {}
}
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ export { useExtend } from './hooks/useExtend';
export { useSuspenseAssets } from './hooks/useSuspenseAssets';
export { useTick } from './hooks/useTick';
export { type ApplicationRef } from './typedefs/ApplicationRef';
export { type PixiElements } from './typedefs/PixiElements';
export { type PixiReactElementProps } from './typedefs/PixiReactNode';
export { type UnprefixedPixiElements } from './typedefs/UnprefixedPixiElements';
3 changes: 1 addition & 2 deletions src/typedefs/HostConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
type Container,
type Filter,
} from 'pixi.js';
import { type NamespacedPixiElements } from './NamespacedPixiElements';
import { type PixiElements } from './PixiElements';
import { type PixiReactNode } from './PixiReactNode';

Expand All @@ -21,7 +20,7 @@ export interface HostConfig
suspenseInstance: PixiReactNode;
textInstance: PixiReactNode;
timeoutHandle: number;
type: keyof PixiElements | keyof NamespacedPixiElements;
type: keyof PixiElements;
updatePayload: object;
transitionStatus: null,
}
5 changes: 0 additions & 5 deletions src/typedefs/NamespacedPixiElements.ts

This file was deleted.

11 changes: 2 additions & 9 deletions src/typedefs/PixiElements.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
import { type NameOverrides } from '../constants/NameOverrides';
import { type PixiComponents } from './PixiComponents';
import { type PixiReactElementProps } from './PixiReactNode';
import { type PrefixedPixiElements } from './PrefixedPixiElements';

import type * as PIXI from 'pixi.js';

export type PixiElements = {
[K in PixiComponents as K extends keyof typeof NameOverrides ? typeof NameOverrides[K] : Uncapitalize<K>]:
PixiReactElementProps<typeof PIXI[K]>;
};
export interface PixiElements extends PrefixedPixiElements {}
5 changes: 5 additions & 0 deletions src/typedefs/PrefixedPixiElements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { type UnprefixedPixiElements } from './UnprefixedPixiElements';

export type PrefixedPixiElements = {
[K in keyof UnprefixedPixiElements as `pixi${Capitalize<string & K>}`]: UnprefixedPixiElements[K];
};
10 changes: 10 additions & 0 deletions src/typedefs/UnprefixedPixiElements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { type NameOverrides } from '../constants/NameOverrides';
import { type PixiComponents } from './PixiComponents';
import { type PixiReactElementProps } from './PixiReactNode';

import type * as PIXI from 'pixi.js';

export type UnprefixedPixiElements = {
[K in PixiComponents as K extends keyof typeof NameOverrides ? typeof NameOverrides[K] : Uncapitalize<K>]:
PixiReactElementProps<typeof PIXI[K]>;
};

0 comments on commit b820aba

Please sign in to comment.