Skip to content

Commit

Permalink
feat: no longer fully export plug-ins to provide better ts types
Browse files Browse the repository at this point in the history
  • Loading branch information
wzc520pyfm committed Mar 31, 2024
1 parent 4423680 commit f9a62a1
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 23 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export default (option, ohcolorClass, ohcolorFactory) => {
Support input w3cx11 color.

```ts
import { mycolor } from 'ohcolor'
import { inputNamed } from 'ohcolor/plugin'
import mycolor from 'ohcolor'
import inputNamed from 'ohcolor/plugin/inputNamed'

mycolor.extend(inputNamed)
mycolor("yellow").rgba() // [255, 255, 0, 1]
Expand All @@ -140,7 +140,7 @@ Returns a number (float) representing the luminance of a color.

```ts
import { mycolor } from 'ohcolor'
import { getLuminance } from 'ohcolor/plugin'
import { getLuminance } from 'ohcolor/plugin/getLuminance'

mycolor.extend(getLuminance)
mycolor("#ffff00").getLuminance() // 0.9278
Expand All @@ -152,7 +152,7 @@ Generate color shades for themes.

```ts
import { mycolor } from 'ohcolor'
import { themeColors } from 'ohcolor/plugin'
import { themeColors } from 'ohcolor/plugin/themeColors'

mycolor.extend(themeColors)
mycolor("#ffff00").themeColors()
Expand Down Expand Up @@ -182,7 +182,7 @@ Get black or white for best contrast depending on the luminosity.

```ts
import { mycolor } from 'ohcolor'
import { readableColor } from 'ohcolor/plugin'
import { readableColor } from 'ohcolor/plugin/readableColor'

mycolor.extend(readableColor)
mycolor("#ffff00").readableColor() // #000
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs"
},
"./plugin": {
"types": "./dist/plugin/index.d.ts",
"import": "./dist/plugin/index.mjs"
},
"./plugin/*": {
"types": "./dist/plugin/*/index.d.ts",
"import": "./dist/plugin/*/index.mjs"
Expand Down Expand Up @@ -59,4 +55,4 @@
"vitest": "^1.3.0"
},
"packageManager": "[email protected]"
}
}
6 changes: 0 additions & 6 deletions src/plugin/index.ts

This file was deleted.

7 changes: 4 additions & 3 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ describe("mycolor", () => {
expect(mycolor(255, 165, 0, 1).format("unknown")).toEqual([255, 165, 0, 1]);
});
it("allows multiple plugins to be installed", async () => {
const { inputHex, getLuminance, readableColor } = await import(
"../src/plugin"
);
const { inputHex } = await import("../src/plugin/inputHex");
const { getLuminance } = await import("../src/plugin/getLuminance");
const { readableColor } = await import("../src/plugin/readableColor");

mycolor.extend(inputHex);
mycolor.extend(getLuminance);
mycolor.extend(readableColor);
Expand Down
2 changes: 1 addition & 1 deletion test/plugin/get-luminance.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, it, describe } from "vitest";
import { mycolor } from "../../src";
import { getLuminance } from "../../src/plugin";
import { getLuminance } from "../../src/plugin/getLuminance";

describe("mycolor plugin: getLuminance", () => {
it("should get luminance", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/plugin/input-named.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, it, describe } from "vitest";
import { mycolor } from "../../src";
import { inputNamed } from "../../src/plugin";
import { inputNamed } from "../../src/plugin/inputNamed";

describe("mycolor plugin: inputNamed", () => {
mycolor.extend(inputNamed);
Expand Down
2 changes: 1 addition & 1 deletion test/plugin/readablecolor.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it, describe } from "vitest";
import { readableColor } from "../../src/plugin";
import { readableColor } from "../../src/plugin/readableColor";
import { mycolor } from "../../src/index";

describe("mycolor plugin: readableColor", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/plugin/theme-colors.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, it, describe } from "vitest";
import { mycolor } from "../../src";
import { themeColors } from "../../src/plugin";
import { themeColors } from "../../src/plugin/themeColors";

describe("mycolor plugin: themeColors", () => {
const fixture = {
Expand Down

0 comments on commit f9a62a1

Please sign in to comment.