Skip to content

Commit

Permalink
Docs, export utils from ESM package
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Feb 23, 2020
1 parent 5bc913d commit f63d853
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib"
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ hsv(244, 100%, 100%, 0.6)

[typedocs](https://kurkle.github.io/color/)

**note** The docs are for the ESM module. UMD module only exports the [default export](https://kurkle.github.io/color/globals.html#_default)

## Benchmarks

[benchmarks](https://kurkle.github.io/color/dev/bench/)
Expand Down
12 changes: 9 additions & 3 deletions color.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function hexParse(str: string): {
*/
export function hexString(v: RGBA): string | RGBA;
/**
* Rounds to decimal to nearest integer
* Rounds decimal to nearest integer
* @param {number} v - the number to round
*/
export function round(v: number): number;
Expand Down Expand Up @@ -137,9 +137,15 @@ export class Color {
* @param {Color|RGBA|string|number[]} input
*/
constructor(input: string | number[] | Color | RGBA);
/** @type {RGBA} */
/**
* @type {RGBA}
* @hidden
**/
_rgb: RGBA;
/** @type {boolean} */
/**
* @type {boolean}
* @hidden
**/
_valid: boolean;
/**
* `true` if this is a valid color
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kurkle/color",
"version": "0.1.6",
"version": "0.1.7",
"description": "css color parsing, manupulation and conversion",
"main": "dist/color.js",
"module": "dist/color.esm.js",
Expand Down
1 change: 1 addition & 0 deletions packed.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function unpack(obj) {
return unpacked;
}

/** @hidden */
export const names = unpack({
OiceXe: 'f0f8ff',
antiquewEte: 'faebd7',
Expand Down
5 changes: 3 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import visualizer from 'rollup-plugin-visualizer';
import {version, homepage} from './package.json';

const input = 'src/index.js';
const inputESM = 'src/index.esm.js';
const banner = `/*!
* @kurkle/color v${version}
* ${homepage}
Expand Down Expand Up @@ -53,7 +54,7 @@ export default [
}
},
{
input: input,
input: inputESM,
plugins: [
cleanup({
sourcemap: true
Expand All @@ -68,7 +69,7 @@ export default [
}
},
{
input: input,
input: inputESM,
plugins: [
terser({
output: {
Expand Down
4 changes: 2 additions & 2 deletions src/byte.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* @packageDocumentation
* @module helpers
* @module utils
*/

/**
* Rounds to decimal to nearest integer
* Rounds decimal to nearest integer
* @param {number} v - the number to round
*/
export function round(v) {
Expand Down
2 changes: 1 addition & 1 deletion src/hex.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module helpers
* @module utils
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion src/hue.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module helpers
* @module utils
*/

import {b2n, n2p, n2b, p2b} from './byte';
Expand Down
31 changes: 31 additions & 0 deletions src/index.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @packageDocumentation
* @module index
*/

import Color from './color';

export {Color};
export * from './byte';
export * from './hex';
export * from './hue';
export * from './names';
export * from './rgb';

/**
* @typedef {Object} RGBA
* @property {number} r - red [0..255]
* @property {number} g - green [0..255]
* @property {number} b - blue [0..255]
* @property {number} a - alpha [0..1]
* @internal
*/

/**
* Construct new Color instance
* @param {Color|RGBA|string|number[]} input
* @internal
*/
export default function(input) {
return new Color(input);
}
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* @packageDocumentation
* @module index
Expand All @@ -12,11 +11,13 @@ import Color from './color';
* @property {number} g - green [0..255]
* @property {number} b - blue [0..255]
* @property {number} a - alpha [0..1]
* @internal
*/

/**
* Construct new Color instance
* @param {Color|RGBA|string|number[]} input
* @internal
*/
export default function(input) {
return new Color(input);
Expand Down
2 changes: 1 addition & 1 deletion src/names.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module helpers
* @module utils
*/

import {names} from '../packed';
Expand Down
2 changes: 1 addition & 1 deletion src/rgb.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module helpers
* @module utils
*/

import {p2b, b2n} from './byte';
Expand Down
24 changes: 10 additions & 14 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es6",
"module": "es6",
"target": "ES6",
"module": "ES6",
"moduleResolution": "Node",
"allowJs": true,
"checkJs": true,
Expand All @@ -11,21 +11,17 @@
"esModuleInterop": true,
"noImplicitThis": true
},
"include": [
"./src/index.js"
"files": [
"./color.d.ts"
],
"typedocOptions": {
"name": "@kurkle/color",
"mode": "modules",
"excludeExternals": true,
"mode": "file",

"includeDeclarations": true,
"exclude": ["./node_modules/**/*"],

"target": "ES6",
"template": "minimal",
"includes": [
"./src"
],
"plugins": [
"typedoc-plugin-external-module-name",
],
"out": "./docs"
"out": "./docs",
},
}
2 changes: 1 addition & 1 deletion util/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,5 @@ function unpack(obj) {
}
`;
fs.writeFileSync('./packed.js', unpack + 'export const names = unpack(' + util.inspect(packed) + ');\n', 'utf-8');
fs.writeFileSync('./packed.js', unpack + '/** @hidden */\nexport const names = unpack(' + util.inspect(packed) + ');\n', 'utf-8');
};

0 comments on commit f63d853

Please sign in to comment.