Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Sep 19, 2018
0 parents commit 05528a8
Show file tree
Hide file tree
Showing 31 changed files with 5,844 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
4 changes: 4 additions & 0 deletions .npmignore
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
7 changes: 7 additions & 0 deletions .travis.yml
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
675 changes: 675 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions README.md
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);
1 change: 1 addition & 0 deletions alg/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "alg"
1 change: 1 addition & 0 deletions alg/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require("alg");
4 changes: 4 additions & 0 deletions alg/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"main": "./index.js",
"types": "./index.d.ts"
}
2 changes: 2 additions & 0 deletions browser-build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/dist
/yarn-error.log
21 changes: 21 additions & 0 deletions browser-build/Makefile
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
1 change: 1 addition & 0 deletions browser-build/index.dist.d.ts
6 changes: 6 additions & 0 deletions browser-build/index.dist.js
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");
7 changes: 7 additions & 0 deletions browser-build/test/html/index.html
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>
22 changes: 22 additions & 0 deletions browser-build/tsconfig.json
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"
]
}
69 changes: 69 additions & 0 deletions browser-build/webpack.config.js
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()
);
}

Loading

0 comments on commit 05528a8

Please sign in to comment.