-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 05528a8
Showing
31 changed files
with
5,844 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Including this file prevents `npm`/`yarn` from excluding everything in | ||
# `.gitignore, and only ignores files specified here. | ||
/node_modules | ||
/dev-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
language: node_js | ||
node_js: | ||
- "node" | ||
- "lts/*" | ||
script: | ||
- yarn install | ||
# - make test |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# `cubing.js` | ||
|
||
A meta-library that makes it easy to use multiple | ||
[js.cubing.net](https://js.cubing.net) libraries. | ||
|
||
## Usage | ||
|
||
### Browser | ||
|
||
<script src="cubing.js"></script> | ||
<script> | ||
const sune = alg.parse("R U R' U R U2 R'"); | ||
const antiSune = alg.invert(sune); | ||
console.log(alg.algToString(antiSune)); | ||
|
||
const {KPuzzle, Puzzles} = kpuzzle; | ||
|
||
const puzzle = new KPuzzle(Puzzles["333"]); | ||
puzzle.applyMove("R"); | ||
console.log(puzzle.state); | ||
</script> | ||
|
||
### Node / TypeScript | ||
|
||
import {parse, invert, algToString} from "cubing/alg" | ||
import {KPuzzle, Puzzles} from "cubing/kpuzzle" | ||
|
||
const sune = parse("R U R' U R U2 R'"); | ||
const antiSune = invert(sune); | ||
console.log(algToString(antiSune)); | ||
|
||
const puzzle = new KPuzzle(Puzzles["333"]); | ||
puzzle.applyMove("R"); | ||
console.log(puzzle.state); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "alg" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require("alg"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"main": "./index.js", | ||
"types": "./index.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/dist | ||
/yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
NODE_BIN = ../node_modules/.bin | ||
|
||
.PHONY: dist | ||
dist: clean-dist | ||
env PROD=true ${NODE_BIN}/webpack-cli | ||
|
||
.PHONY: dev | ||
dev: | ||
${NODE_BIN}/webpack-cli --watch | ||
|
||
.PHONY: test | ||
test: | ||
npm test | ||
|
||
.PHONY: clean | ||
clean: clean-dist | ||
rm -f yarn-error.log | ||
|
||
.PHONY: clean-dist | ||
clean-dist: | ||
rm -rf ./dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../index.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports.alg = require("expose-loader?alg!../alg"); | ||
module.exports.kpuzzle = require("expose-loader?kpuzzle!../kpuzzle"); | ||
module.exports.twisty = require("expose-loader?twisty!../twisty"); | ||
module.exports.cuble = require("expose-loader?cuble!../cuble"); | ||
module.exports["puzzle-geometry"] = require("expose-loader?puzzle-geometry!../puzzle-geometry"); | ||
module.exports.puzzleGeometry = require("expose-loader?puzzleGeometry!../puzzle-geometry"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<html> | ||
<title>cubing.js Test</title> | ||
<script src="../../dist/cubing.js"></script> | ||
</style> | ||
<body> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "node", | ||
"target": "es6", | ||
|
||
"rootDir": "src", | ||
"outDir": "", | ||
"declaration": true, | ||
"sourceMap": true, | ||
|
||
"alwaysStrict": true, | ||
"noImplicitAny": true, | ||
"noImplicitReturns": true, | ||
"strictNullChecks": true, | ||
"noUnusedLocals": true | ||
}, | ||
"include": [ | ||
"src", | ||
"alg", | ||
"kpuzzle" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const path = require("path"); | ||
const webpack = require('webpack'); | ||
const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); | ||
const WebpackNotifierPlugin = require("webpack-notifier"); | ||
|
||
const umdName = "cubing"; | ||
const externals = []; | ||
const targetFileName = "cubing.js"; | ||
const targetDirName = "./dist"; | ||
var PROD = JSON.parse(process.env.PROD || false); | ||
|
||
module.exports = { | ||
entry: "./index.dist.js", | ||
mode: "none", | ||
devtool: "source-map", | ||
plugins: [ | ||
new WebpackNotifierPlugin({ | ||
title: targetFileName, | ||
alwaysNotify: true | ||
}) | ||
], | ||
module: { | ||
rules: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: {"presets": ["env"]} | ||
}, | ||
{ | ||
test: /\.ts$/, | ||
use: "ts-loader", | ||
exclude: /node_modules/ | ||
} | ||
] | ||
}, | ||
resolve: { | ||
extensions: [ ".ts" ] | ||
}, | ||
output: { | ||
filename: targetFileName, | ||
path: path.resolve(__dirname, targetDirName), | ||
library: umdName, | ||
libraryTarget: "umd", | ||
// Workaround for Webpack 4. See https://github.com/webpack/webpack/issues/6522#issuecomment-371120689 | ||
globalObject: "typeof self !== \"undefined\" ? self : this" | ||
}, | ||
externals: externals | ||
}; | ||
|
||
if (PROD) { | ||
// https://webpack.js.org/concepts/mode/#mode-production | ||
module.exports.plugins.push( | ||
new UglifyJSPlugin({ | ||
sourceMap: true, | ||
uglifyOptions: { | ||
mangle: false | ||
} | ||
}) | ||
); | ||
module.exports.plugins.push( | ||
new webpack.DefinePlugin({"process.env.NODE_ENV": JSON.stringify("production")}) | ||
); | ||
module.exports.plugins.push( | ||
new webpack.optimize.ModuleConcatenationPlugin() | ||
); | ||
module.exports.plugins.push( | ||
new webpack.NoEmitOnErrorsPlugin() | ||
); | ||
} | ||
|
Oops, something went wrong.