diff --git a/demo/package-lock.json b/demo/package-lock.json index 08ab5aa..33bfd78 100644 --- a/demo/package-lock.json +++ b/demo/package-lock.json @@ -3052,19 +3052,11 @@ }, "colour-chisel": { "version": "file:..", - "requires": { - "chroma-js": "^2.0.6", - "lodash.clonedeep": "^4.5.0" - }, "dependencies": { "@types/chai": { "version": "4.2.3", "bundled": true }, - "@types/chroma-js": { - "version": "1.4.3", - "bundled": true - }, "@types/expect": { "version": "1.20.4", "bundled": true @@ -3108,6 +3100,17 @@ "sprintf-js": "~1.0.2" } }, + "array-union": { + "version": "1.0.2", + "bundled": true, + "requires": { + "array-uniq": "^1.0.1" + } + }, + "array-uniq": { + "version": "1.0.3", + "bundled": true + }, "arrify": { "version": "1.0.1", "bundled": true @@ -3116,6 +3119,13 @@ "version": "1.1.0", "bundled": true }, + "async": { + "version": "2.6.3", + "bundled": true, + "requires": { + "lodash": "^4.17.14" + } + }, "balanced-match": { "version": "1.0.0", "bundled": true @@ -3174,10 +3184,6 @@ "version": "1.0.2", "bundled": true }, - "chroma-js": { - "version": "2.0.6", - "bundled": true - }, "cliui": { "version": "5.0.0", "bundled": true, @@ -3220,6 +3226,10 @@ "version": "1.1.3", "bundled": true }, + "commander": { + "version": "2.20.3", + "bundled": true + }, "concat-map": { "version": "0.0.1", "bundled": true @@ -3253,6 +3263,10 @@ "version": "3.5.0", "bundled": true }, + "email-addresses": { + "version": "3.1.0", + "bundled": true + }, "emoji-regex": { "version": "7.0.3", "bundled": true @@ -3290,6 +3304,27 @@ "version": "4.0.1", "bundled": true }, + "filename-reserved-regex": { + "version": "1.0.0", + "bundled": true + }, + "filenamify": { + "version": "1.2.1", + "bundled": true, + "requires": { + "filename-reserved-regex": "^1.0.0", + "strip-outer": "^1.0.0", + "trim-repeated": "^1.0.0" + } + }, + "filenamify-url": { + "version": "1.0.0", + "bundled": true, + "requires": { + "filenamify": "^1.0.0", + "humanize-url": "^1.0.0" + } + }, "find-up": { "version": "3.0.0", "bundled": true, @@ -3304,6 +3339,15 @@ "is-buffer": "~2.0.3" } }, + "fs-extra": { + "version": "7.0.1", + "bundled": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, "fs.realpath": { "version": "1.0.0", "bundled": true @@ -3320,6 +3364,20 @@ "version": "2.0.0", "bundled": true }, + "gh-pages": { + "version": "2.1.1", + "bundled": true, + "requires": { + "async": "^2.6.1", + "commander": "^2.18.0", + "email-addresses": "^3.0.1", + "filenamify-url": "^1.0.0", + "fs-extra": "^7.0.0", + "globby": "^6.1.0", + "graceful-fs": "^4.1.11", + "rimraf": "^2.6.2" + } + }, "glob": { "version": "7.1.3", "bundled": true, @@ -3332,6 +3390,21 @@ "path-is-absolute": "^1.0.0" } }, + "globby": { + "version": "6.1.0", + "bundled": true, + "requires": { + "array-union": "^1.0.1", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "graceful-fs": { + "version": "4.2.3", + "bundled": true + }, "growl": { "version": "1.10.5", "bundled": true @@ -3355,6 +3428,14 @@ "version": "1.2.0", "bundled": true }, + "humanize-url": { + "version": "1.0.1", + "bundled": true, + "requires": { + "normalize-url": "^1.0.0", + "strip-url-auth": "^1.0.0" + } + }, "inflight": { "version": "1.0.6", "bundled": true, @@ -3383,6 +3464,10 @@ "version": "2.0.0", "bundled": true }, + "is-plain-obj": { + "version": "1.1.0", + "bundled": true + }, "is-regex": { "version": "1.0.4", "bundled": true, @@ -3424,6 +3509,13 @@ } } }, + "jsonfile": { + "version": "4.0.0", + "bundled": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, "locate-path": { "version": "3.0.0", "bundled": true, @@ -3436,10 +3528,6 @@ "version": "4.17.15", "bundled": true }, - "lodash.clonedeep": { - "version": "4.5.0", - "bundled": true - }, "log-symbols": { "version": "2.2.0", "bundled": true, @@ -3510,6 +3598,20 @@ "semver": "^5.7.0" } }, + "normalize-url": { + "version": "1.9.1", + "bundled": true, + "requires": { + "object-assign": "^4.0.1", + "prepend-http": "^1.0.0", + "query-string": "^4.1.0", + "sort-keys": "^1.0.0" + } + }, + "object-assign": { + "version": "4.1.1", + "bundled": true + }, "object-inspect": { "version": "1.6.0", "bundled": true @@ -3573,6 +3675,33 @@ "version": "1.1.0", "bundled": true }, + "pify": { + "version": "2.3.0", + "bundled": true + }, + "pinkie": { + "version": "2.0.4", + "bundled": true + }, + "pinkie-promise": { + "version": "2.0.1", + "bundled": true, + "requires": { + "pinkie": "^2.0.0" + } + }, + "prepend-http": { + "version": "1.0.4", + "bundled": true + }, + "query-string": { + "version": "4.3.4", + "bundled": true, + "requires": { + "object-assign": "^4.1.0", + "strict-uri-encode": "^1.0.0" + } + }, "require-directory": { "version": "2.1.1", "bundled": true @@ -3581,6 +3710,13 @@ "version": "2.0.0", "bundled": true }, + "rimraf": { + "version": "2.7.1", + "bundled": true, + "requires": { + "glob": "^7.1.3" + } + }, "semver": { "version": "5.7.1", "bundled": true @@ -3589,6 +3725,13 @@ "version": "2.0.0", "bundled": true }, + "sort-keys": { + "version": "1.1.2", + "bundled": true, + "requires": { + "is-plain-obj": "^1.0.0" + } + }, "source-map": { "version": "0.6.1", "bundled": true @@ -3605,6 +3748,10 @@ "version": "1.0.3", "bundled": true }, + "strict-uri-encode": { + "version": "1.1.0", + "bundled": true + }, "string-width": { "version": "2.1.1", "bundled": true, @@ -3645,6 +3792,17 @@ "version": "2.0.1", "bundled": true }, + "strip-outer": { + "version": "1.0.1", + "bundled": true, + "requires": { + "escape-string-regexp": "^1.0.2" + } + }, + "strip-url-auth": { + "version": "1.0.1", + "bundled": true + }, "supports-color": { "version": "6.0.0", "bundled": true, @@ -3652,6 +3810,13 @@ "has-flag": "^3.0.0" } }, + "trim-repeated": { + "version": "1.0.0", + "bundled": true, + "requires": { + "escape-string-regexp": "^1.0.2" + } + }, "ts-mocha": { "version": "6.0.0", "bundled": true, @@ -3727,6 +3892,10 @@ "version": "3.6.3", "bundled": true }, + "universalify": { + "version": "0.1.2", + "bundled": true + }, "which": { "version": "1.3.1", "bundled": true, @@ -10791,6 +10960,11 @@ } } }, + "react-simple-code-editor": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/react-simple-code-editor/-/react-simple-code-editor-0.10.0.tgz", + "integrity": "sha512-bL5W5mAxSW6+cLwqqVWY47Silqgy2DKDTR4hDBrLrUqC5BXc29YVx17l2IZk5v36VcDEq1Bszu2oHm1qBwKqBA==" + }, "react-transition-group": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-2.9.0.tgz", diff --git a/demo/package.json b/demo/package.json index b13d9e0..802a3ed 100644 --- a/demo/package.json +++ b/demo/package.json @@ -13,14 +13,16 @@ "react": "^16.10.2", "react-dom": "^16.10.2", "react-scripts": "3.2.0", + "react-simple-code-editor": "^0.10.0", "reactstrap": "^8.0.1", "typescript": "3.6.4" }, "scripts": { "start": "react-scripts start", - "build": "react-scripts build", + "build": "npm run rebuild && react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject" + "eject": "react-scripts eject", + "rebuild": "npm remove colour-chisel && npm run build --prefix ../ && npm install ../" }, "eslintConfig": { "extends": "react-app" diff --git a/demo/public/colour_chisel_logo.png b/demo/public/colour_chisel_logo.png new file mode 100644 index 0000000..e66a4f9 Binary files /dev/null and b/demo/public/colour_chisel_logo.png differ diff --git a/demo/src/App.tsx b/demo/src/App.tsx index e33cb2b..7647832 100644 --- a/demo/src/App.tsx +++ b/demo/src/App.tsx @@ -1,34 +1,78 @@ -import {Card, CardBody, CardHeader, Container} from "reactstrap"; +import {Card, CardBody, CardText, Col, Container, Row} from "reactstrap"; import React from "react"; -import ColourWheel from "./ColourWheel"; +import Sandbox from "./Sandbox"; +import Editor from "react-simple-code-editor"; +import { + chaining, + compliments, + definingConstants, inlineRecursion, + paths, + rotationAndAnalogous, + sandBox, + scale, + variables +} from "./Sections/Sections"; -// Standard 'S' -// export const s0 = chroma("#c63939").hex(); -const radian = Math.PI/180; -const s0: [number, number, number] = [radian * 90, 0.5, 0.5]; -const [h, s, l]: [number, number, number] = s0; -const s1: [number, number, number] = [h + 30 * radian, s, l]; -const s2: [number, number, number] = [h - 30 * radian, s, l]; -const s3: [number, number, number] = [h + 145 * radian, s, l]; -const s4: [number, number, number] = [h + 180 * radian, s, l]; -const s5: [number, number, number] = [h + 215 * radian, s, l]; -const sPath: Array<[number, number, number]> = [s2, s0, s1, s5, s4, s3]; -const sPath2: Array<[number, number, number]> = sPath.map(([h, s, l]) => [h - radian * 90, s, l]); const App: React.FC = () => { + return ( - - - Colour-Chisel - - - - + + + + + + colour chisel logo + + Colour Chisel is a language and javascript library for creating shapes and + performing geometrical operations on a colour wheel. The library can be compiled + from the domain specific language or used as a recursive programmatic javascript language. + To install the library simply run... + + + {}} + highlight={code => code} + padding={10} + style={{ + fontFamily: 'monospace', + fontSize: 12, + }} + /> + + + To Compile the domain specific language, then simply run... + + + {}} + highlight={code => code} + padding={10} + style={{ + fontFamily: 'monospace', + fontSize: 12, + }} + /> + + + + + + + + + + + + + + ); }; diff --git a/demo/src/ColourWheel.tsx b/demo/src/ColourWheel.tsx index 85a4ff6..0c6b7a6 100644 --- a/demo/src/ColourWheel.tsx +++ b/demo/src/ColourWheel.tsx @@ -1,5 +1,4 @@ import React, {createRef, CSSProperties, useEffect} from "react"; -import chroma from "chroma-js" interface IProps { inputs: Array<[number, number, number]>[] @@ -22,8 +21,8 @@ const ColourWheel: React.FC = ({inputs, style}) => { const theta = (h) * Math.PI/180; const maxRadius = (current as any).offsetWidth / 2; const r = s * maxRadius; - const x = r * Math.cos(h) + maxRadius; - const y = -r * Math.sin(h) + maxRadius; + const x = r * Math.cos(theta) + maxRadius; + const y = -r * Math.sin(theta) + maxRadius; // drawing ctx.strokeStyle = 'rgb(255, 255, 255)'; @@ -43,7 +42,7 @@ const ColourWheel: React.FC = ({inputs, style}) => { ctx.strokeStyle = 'rgba(0, 0, 0, 0.5)'; ctx.stroke(); } - ctx.fillText(chroma.hsl(h, s, l).hex(), x, y - 12); + ctx.fillText([h, s, l].toString(), x, y - 12); lastCoord = [x, y] } @@ -95,8 +94,12 @@ const ColourWheel: React.FC = ({inputs, style}) => { } return ( - + ) }; -export default ColourWheel; \ No newline at end of file +function isEqual (prev: IProps, newProps: IProps): boolean { + return JSON.stringify(prev)==JSON.stringify(newProps); +} + +export default React.memo(ColourWheel, isEqual); \ No newline at end of file diff --git a/demo/src/Sandbox.tsx b/demo/src/Sandbox.tsx new file mode 100644 index 0000000..747ba58 --- /dev/null +++ b/demo/src/Sandbox.tsx @@ -0,0 +1,79 @@ +import {Alert, Card, CardBody, CardHeader, CardText, Col, Row} from "reactstrap"; +import React, {useEffect, useState} from "react"; +import Editor from 'react-simple-code-editor'; +import ColourChisel from "colour-chisel"; +import ColourWheel from "./ColourWheel"; + +export interface ISandboxProps { + title?: string, + child?: JSX.Element, + description?: string, + defaultCode?: string, +} + +const Sandbox: React.FC = ({title, description, defaultCode, child}) => { + const [code, updateCode] = useState(""); + const [hsls, updateHSLs] = useState[]>([]); + const [error, updateError] = useState(); + + useEffect(() => { + if (defaultCode) { + onChange(defaultCode) + } + }, [defaultCode]); + + function onChange(c: string): void { + updateCode(c); + try { + const ccs: ColourChisel[] = ColourChisel.compile(c); + updateError(undefined); + updateHSLs(ccs.map(cc => cc.hsl())); + console.log(hsls); + } catch (err) { + updateError(err.message); + updateHSLs([]); + } + } + + return ( + + {title &&

{title}

} + + {description && {description}} + {child && child} + + + + + + + + code} + padding={10} + style={{ + fontFamily: 'monospace', + fontSize: 12, + }} + /> + + + + {error && + + + {error} + + + } + + +
+ ) +}; + +export default Sandbox; \ No newline at end of file diff --git a/demo/src/Sections/Sections.tsx b/demo/src/Sections/Sections.tsx new file mode 100644 index 0000000..518872a --- /dev/null +++ b/demo/src/Sections/Sections.tsx @@ -0,0 +1,97 @@ +import {ISandboxProps} from "../Sandbox"; + +export const sandBox: ISandboxProps = { + title: "Sandbox", + description: "Feel free to experiment with the language in the editor." +}; + +export const definingConstants: ISandboxProps = { + title: "Defining Constants", + description: "In Colour Chisel there always needs to be a starting point. You cannot perform an operation or make a path without first giving a colour. In Colour Chisel there are three types of constants: RGB, HSL and Hex. These can be passed into 'expressions' to create points on the colour wheel. In Colour Chisel, you will not see an output unless you specify you want to export.", + defaultCode: "export (rgb(100, 50, 50));\n" + + "export (hsl(50, 0.5, 0.5));\n" + + "export (#FFFFFF);" +}; + +export const variables: ISandboxProps = { + title: "Variables", + description: "Variables can also be used to save any expression, constant or path. variables make it easier to use longer manipulations, or make a longer path more readable. Variables can also be exported.", + defaultCode: "var A = (rgb(100, 50, 50));\n" + + "export A;" +}; + +export const paths: ISandboxProps = { + title: "Paths", + description: "Paths are how shapes are formed and are a major building block of defining a colour scheme, paths can be used in any expression as with constants and variables. Paths can also be exported.", + defaultCode: + "export [\n" + + " (hsl(60, 0.5, 0.5)),\n" + + " (hsl(90, 0.5, 0.5)),\n" + + " (hsl(120, 0.5, 0.5)),\n" + + " (hsl(300, 0.5, 0.5)),\n" + + " (hsl(270, 0.5, 0.5)),\n" + + " (hsl(240, 0.5, 0.5))\n" + + "];" +}; + +export const rotationAndAnalogous: ISandboxProps = { + title: "Rotation & Analogous", + description: "Manipulations can be used to transform any point or path into another positions or shape, without losing the relation between the path. The most basic type of manipulation is a rotation, or simply finding the analogous colours to a point/path. You can specify a rotation command or an analogous command to perform an operation with a passed in range.", + defaultCode: + "var sPath = [\n" + + " (hsl(60, 0.5, 0.5)),\n" + + " (hsl(90, 0.5, 0.5)),\n" + + " (hsl(120, 0.5, 0.5)),\n" + + " (hsl(300, 0.5, 0.5)),\n" + + " (hsl(270, 0.5, 0.5)),\n" + + " (hsl(240, 0.5, 0.5))\n" + + "];\n" + + "export sPath > rotate 45;\n" + + "export sPath > analogous -45;" +}; + +export const compliments: ISandboxProps = { + title: "Compliment", + description: "A compliment is flipping the side of the colour wheel that you are on, this tends to create very favourable colours that look well and contrast with each other.", + defaultCode: + "export var primary = (hsl(50, 0.5, 0.5));\n" + + "export primary > compliment;" +}; + +export const scale: ISandboxProps = { + title: "Scale", + description: "Scale allows adjusting the saturation of a colour. This is equivalent to moving inward and outward from the center of the colour wheel.", + defaultCode: + "var diamond = [\n" + + " (hsl(0, 0.5, 0.5)),\n" + + " (hsl(90, 0.5, 0.5)),\n" + + " (hsl(180, 0.5, 0.5)),\n" + + " (hsl(270, 0.5, 0.5))\n" + + "];\n" + + "export diamond;\n" + + "export diamond > scale 0.5;\n" + + "export diamond > scale 1.5;" +}; + +export const chaining: ISandboxProps = { + title: "Chaining", + description: "Multiple manipulations can be chained in a single command.", + defaultCode: + "var sPath = [\n" + + " (hsl(60, 0.5, 0.5)),\n" + + " (hsl(90, 0.5, 0.5)),\n" + + " (hsl(120, 0.5, 0.5)),\n" + + " (hsl(300, 0.5, 0.5)),\n" + + " (hsl(270, 0.5, 0.5)),\n" + + " (hsl(240, 0.5, 0.5))\n" + + "];\n" + + "export sPath > rotate 45 > compliment > scale 1.5 > analogous -45;" +}; + +export const inlineRecursion: ISandboxProps = { + title: "Inline Recursion", + description: "At any point where a variable, constant or path can be inputed you can also create an expression and recurse down a series of commands.", + defaultCode: + "var a = (hsl(60, 0.5, 0.5));\n"+ + "export [a > compliment, a];" +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index bb7ffd8..8a25c94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,12 +10,6 @@ "integrity": "sha512-VRw2xEGbll3ZiTQ4J02/hUjNqZoue1bMhoo2dgM2LXjDdyaq4q80HgBDHwpI0/VKlo4Eg+BavyQMv/NYgTetzA==", "dev": true }, - "@types/chroma-js": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/@types/chroma-js/-/chroma-js-1.4.3.tgz", - "integrity": "sha512-m33zg9cRLtuaUSzlbMrr7iLIKNzrD4+M6Unt5+9mCu4BhR5NwnRjVKblINCwzcBXooukIgld8DtEncP8qpvbNg==", - "dev": true - }, "@types/expect": { "version": "1.20.4", "resolved": "https://registry.npmjs.org/@types/expect/-/expect-1.20.4.tgz", @@ -77,6 +71,21 @@ "sprintf-js": "~1.0.2" } }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, + "requires": { + "array-uniq": "^1.0.1" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, "arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", @@ -89,6 +98,15 @@ "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, + "async": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", + "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "dev": true, + "requires": { + "lodash": "^4.17.14" + } + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -165,11 +183,6 @@ "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", "dev": true }, - "chroma-js": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/chroma-js/-/chroma-js-2.0.6.tgz", - "integrity": "sha512-IiiClbBRkRwuXNl6impq5ssEhUGpmWvc5zzImZbDUWLWcFbj6ZbtsdZEx6sIXMKes7azgYaUpnmsY1T8BL6PqQ==" - }, "cliui": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", @@ -224,6 +237,12 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -269,6 +288,12 @@ "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, + "email-addresses": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/email-addresses/-/email-addresses-3.1.0.tgz", + "integrity": "sha512-k0/r7GrWVL32kZlGwfPNgB2Y/mMXVTq/decgLczm/j34whdaspNrZO8CnXPf1laaHxI6ptUlsnAxN+UAPw+fzg==", + "dev": true + }, "emoji-regex": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", @@ -316,6 +341,33 @@ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, + "filename-reserved-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-1.0.0.tgz", + "integrity": "sha1-5hz4BfDeHJhFZ9A4bcXfUO5a9+Q=", + "dev": true + }, + "filenamify": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/filenamify/-/filenamify-1.2.1.tgz", + "integrity": "sha1-qfL/0RxQO+0wABUCknI3jx8TZaU=", + "dev": true, + "requires": { + "filename-reserved-regex": "^1.0.0", + "strip-outer": "^1.0.0", + "trim-repeated": "^1.0.0" + } + }, + "filenamify-url": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/filenamify-url/-/filenamify-url-1.0.0.tgz", + "integrity": "sha1-syvYExnvWGO3MHi+1Q9GpPeXX1A=", + "dev": true, + "requires": { + "filenamify": "^1.0.0", + "humanize-url": "^1.0.0" + } + }, "find-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", @@ -334,6 +386,17 @@ "is-buffer": "~2.0.3" } }, + "fs-extra": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -358,6 +421,22 @@ "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", "dev": true }, + "gh-pages": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-2.1.1.tgz", + "integrity": "sha512-yNW2SFp9xGRP/8Sk2WXuLI/Gn92oOL4HBgudn6PsqAnuWT90Y1tozJoTfX1WdrDSW5Rb90kLVOf5mm9KJ/2fDw==", + "dev": true, + "requires": { + "async": "^2.6.1", + "commander": "^2.18.0", + "email-addresses": "^3.0.1", + "filenamify-url": "^1.0.0", + "fs-extra": "^7.0.0", + "globby": "^6.1.0", + "graceful-fs": "^4.1.11", + "rimraf": "^2.6.2" + } + }, "glob": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", @@ -372,6 +451,25 @@ "path-is-absolute": "^1.0.0" } }, + "globby": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", + "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", + "dev": true, + "requires": { + "array-union": "^1.0.1", + "glob": "^7.0.3", + "object-assign": "^4.0.1", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "graceful-fs": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", + "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", + "dev": true + }, "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -405,6 +503,16 @@ "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", "dev": true }, + "humanize-url": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/humanize-url/-/humanize-url-1.0.1.tgz", + "integrity": "sha1-9KuZ4NKIF0yk4eUEB8VfuuRk7/8=", + "dev": true, + "requires": { + "normalize-url": "^1.0.0", + "strip-url-auth": "^1.0.0" + } + }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -445,6 +553,12 @@ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, + "is-plain-obj": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", + "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", + "dev": true + }, "is-regex": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", @@ -498,6 +612,15 @@ } } }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, "locate-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", @@ -514,11 +637,6 @@ "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "dev": true }, - "lodash.clonedeep": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", - "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=" - }, "log-symbols": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", @@ -605,6 +723,24 @@ "semver": "^5.7.0" } }, + "normalize-url": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-1.9.1.tgz", + "integrity": "sha1-LMDWazHqIwNkWENuNiDYWVTGbDw=", + "dev": true, + "requires": { + "object-assign": "^4.0.1", + "prepend-http": "^1.0.0", + "query-string": "^4.1.0", + "sort-keys": "^1.0.0" + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, "object-inspect": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz", @@ -690,6 +826,43 @@ "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", "dev": true }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, + "requires": { + "pinkie": "^2.0.0" + } + }, + "prepend-http": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", + "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", + "dev": true + }, + "query-string": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz", + "integrity": "sha1-u7aTucqRXCMlFbIosaArYJBD2+s=", + "dev": true, + "requires": { + "object-assign": "^4.1.0", + "strict-uri-encode": "^1.0.0" + } + }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -702,6 +875,15 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "dev": true }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, "semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", @@ -714,6 +896,15 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", "dev": true }, + "sort-keys": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", + "integrity": "sha1-RBttTTRnmPG05J6JIK37oOVD+a0=", + "dev": true, + "requires": { + "is-plain-obj": "^1.0.0" + } + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -736,6 +927,12 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, + "strict-uri-encode": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", + "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=", + "dev": true + }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", @@ -788,6 +985,21 @@ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", "dev": true }, + "strip-outer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-outer/-/strip-outer-1.0.1.tgz", + "integrity": "sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.2" + } + }, + "strip-url-auth": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-url-auth/-/strip-url-auth-1.0.1.tgz", + "integrity": "sha1-IrD6OkE4WzO+PzMVUbu4N/oM164=", + "dev": true + }, "supports-color": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.0.0.tgz", @@ -797,6 +1009,15 @@ "has-flag": "^3.0.0" } }, + "trim-repeated": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/trim-repeated/-/trim-repeated-1.0.0.tgz", + "integrity": "sha1-42RqLqTokTEr9+rObPsFOAvAHCE=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.2" + } + }, "ts-mocha": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/ts-mocha/-/ts-mocha-6.0.0.tgz", @@ -892,6 +1113,12 @@ "integrity": "sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==", "dev": true }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", diff --git a/package.json b/package.json index 5a62146..e940b25 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "dist/index.js", "scripts": { "test": "ts-mocha ./test/**/* --timeout 10000", - "build": "rm -rf dist && tsc" + "build": "rm -rf dist && tsc", + "deploy-demo": "npm run build --prefix ./demo && gh-pages -d ./demo/build" }, "repository": { "type": "git", @@ -33,6 +34,7 @@ "mocha": "^6.2.1", "ts-mocha": "^6.0.0", "ts-node": "^8.4.1", - "typescript": "^3.6.3" + "typescript": "^3.6.3", + "gh-pages": "^2.0.1" } } diff --git a/src/compiler/index.ts b/src/compiler/index.ts index b954094..af0b79b 100644 --- a/src/compiler/index.ts +++ b/src/compiler/index.ts @@ -1,8 +1,8 @@ -import {IColourChisel} from "../interface"; import Tokenizer from "./Tokenizer"; import Program from "./ast/Program"; +import ColourChisel from "../ColourChisel"; -function compile(input: string): IColourChisel[] { +function compile(input: string): ColourChisel[] { const tokenizer = new Tokenizer(input); const program = new Program(tokenizer); program.parse();