Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
02bca34
update travis npm to something more recent
alicebob Apr 18, 2020
5a51d4a
restructure build process to use `rollup`
alicebob Apr 18, 2020
a91ebd2
fix lint and remove unused files
alicebob Apr 18, 2020
1a183a3
fix read-only-object errors
alicebob Apr 18, 2020
da17a11
update all tests to use `import`s
alicebob Apr 18, 2020
5ab22fd
load stand-alone candle.js file
alicebob Apr 18, 2020
38c2637
fix githash variable in the final .js file
alicebob Apr 18, 2020
2428e8c
travis: build before test
alicebob Apr 18, 2020
d3f688a
run prettier
alicebob Apr 18, 2020
1e68e0e
Merge remote-tracking branch 'origin/master' into reimport
alicebob Apr 25, 2020
b8d87b4
more clear install target
alicebob Apr 25, 2020
3a5601f
use variable for files we bundle
alicebob Apr 25, 2020
e68fe02
move format checks to the Makefile
alicebob Apr 25, 2020
96df19d
add .json files to the format checks, and prettify them
alicebob Apr 25, 2020
e15d00c
restore Grunt bundling target
robx Apr 28, 2020
3c68511
skip frozen checks
robx Apr 28, 2020
4d9ea3a
checkLineShape: test whether cell isnull, not is null
robx Apr 28, 2020
8189d2f
kinkonkan: corner excells are "isnull", they don't have coordinates
robx Apr 28, 2020
da65ab1
fix sed
robx May 6, 2020
a893dc5
dependency bump
robx May 6, 2020
b790892
use grunt concat target
robx May 6, 2020
f4a992e
change default target
robx May 6, 2020
6f61769
move more logic from Gruntfile to Makefile
robx May 6, 2020
64b5740
remove some stale package.json fields
robx May 6, 2020
f296cba
remove index.js
robx May 6, 2020
de8b52b
Merge branch 'master' into reimport
robx May 6, 2020
2d040e8
tawa: don't set error on out-of-board neighbours
robx May 6, 2020
8e2a468
remove another frozen check
robx May 6, 2020
5f9d9a9
fmt
robx May 6, 2020
a01fadf
remove npm-install makefile target
robx May 6, 2020
88b5026
Revert "remove index.js"
robx May 6, 2020
3bd5a16
or maybe try exporting the concat version (this is for pzprnode)
robx May 6, 2020
93ba59f
fancy module
alicebob May 6, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
language: node_js
node_js: 10
script:
- npm run-script build
- npm test
- npm run-script check-format
- make lint build test check-format
19 changes: 3 additions & 16 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ module.exports = function(grunt){
options: {
banner: banner_full,
process: true,
},
},
pzpr: {
options: {
options:{
sourceMap: !PRODUCTION
},
files: [
Expand All @@ -56,16 +56,6 @@ module.exports = function(grunt){
banner: banner_min,
report: 'min'
},
pzpr:{
options: (PRODUCTION ? {} : {
sourceMap : 'dist/js/pzpr.js.map',
sourceMapIn : 'dist/js/pzpr.concat.js.map',
sourceMapIncludeSources : true
}),
files: [
{ src: 'dist/js/pzpr.concat.js', dest: 'dist/js/pzpr.js'}
]
},
variety:{
options: (PRODUCTION ? {} : {
sourceMap : function(filename){ return filename+'.map';}
Expand Down Expand Up @@ -96,10 +86,7 @@ module.exports = function(grunt){
}
});

grunt.registerTask('default', ['build']);
grunt.registerTask('release', ['build']);
grunt.registerTask('build', ['build:pzpr', 'build:variety', 'build:samples', 'build:ui']);
grunt.registerTask('build:pzpr', ['newer:concat:pzpr', 'newer:uglify:pzpr']);
grunt.registerTask('build', ['build:variety', 'build:samples', 'build:ui']);
grunt.registerTask('build:ui', ['newer:copy:ui', 'newer:concat:ui', 'newer:uglify:ui']);
grunt.registerTask('build:variety',['newer:uglify:variety']);
grunt.registerTask('build:samples',['newer:uglify:samples']);
Expand Down
36 changes: 30 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
.PHONY: build test serve format
.PHONY: default build test serve serve-all format check-format lint bundle rollup git-hash clean

build:
npm run-script build
default: build

test:
npm test
clean:
rm -rf ./dist/
rm -f git.json

build: rollup git-hash
npx grunt build

git-hash:
./git-hash.sh

bundle: git-hash
npx grunt concat:pzpr

rollup: bundle
mkdir -p ./dist/js/
cp ./node_modules/pzpr-canvas/dist/candle.js ./dist/js/candle.js
npx rollup -c ./rollup.config.js

test: bundle
npx grunt build:variety
npx mocha -r esm -r pzpr-canvas -r source-map-support/register -R progress --recursive test

lint:
npx eslint --quiet src src-ui test sample

serve:
cd dist && python3 -m http.server -b localhost
Expand All @@ -13,4 +34,7 @@ serve-all:
cd dist && python3 -m http.server

format:
npm run-script format
npx prettier --write "{src,src-ui,test}/**/*.{js,json,css}"

check-format:
npx prettier --check "{src,src-ui,test}/**/*.{js,json,css}"
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

module.exports = require('./dist/js/pzpr.js');
import pzpr from './dist/js/pzpr.concat.js';
export default pzpr;
28 changes: 7 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"version": "0.12.0",
"description": "Scripts for handling puzzle objects",
"main": "./index.js",
"directories": {
"test": "test"
},
"keywords": [
"puzzle",
"HTML5"
Expand All @@ -14,35 +11,24 @@
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/sabo2/pzprjs"
},
"homepage": "https://github.com/sabo2/pzprjs",
"engines": {
"node": ">= 5.6.0"
},
"scripts": {
"build": "eslint --cache --quiet src src-ui && \"./git-hash.sh\" && grunt default",
"release": "npm run clean && eslint --cache --quiet src && grunt release",
"clean": "del dist/* pzpr-*.{zip,tar.gz,tar.bz2,tgz}",
"format": "prettier --write \"{src,src-ui,test}/**/*.{js,css}\"",
"check-format": "prettier --check \"{src,src-ui,test}/**/*.{js,css}\"",
"lint": "eslint src src-ui test sample",
"test": "eslint --quiet src src-ui test sample && mocha -r source-map-support/register -R progress --recursive test",
"prepublishOnly": "npm test"
"url": "https://github.com/robx/pzprjs"
},
"homepage": "https://puzz.link",
"devDependencies": {
"del-cli": "^2.0.0",
"eslint": "^5.16.0",
"esm": "^3.2.25",
"grunt": "^1.1.0",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-uglify": "^2.0.0",
"grunt-newer": "^1.1.1",
"mocha": "^6.2.3",
"prettier": "^1.19.1"
"prettier": "^1.19.1",
"rollup": "^2.8.0",
"rollup-plugin-terser": "^5.3.0"
},
"dependencies": {
"pzpr-canvas": "^0.8.2",
"source-map-support": "^0.5.17"
"source-map-support": "^0.5.19"
}
}
22 changes: 22 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { terser } from 'rollup-plugin-terser';

// `npm run build` -> `production` is true
// `npm run dev` -> `production` is false
const production = !process.env.ROLLUP_WATCH;

export default {
input: 'dist/js/pzpr.concat.js',
output: {
file: 'dist/js/pzpr.js',
name: 'pzpr',
format: 'iife',
sourcemap: true,
globals: {
"pzpr-canvas": "Candle"
}
},
context: "window",
plugins: [
production && terser() // minify, but only in production
]
};
1 change: 1 addition & 0 deletions src-ui/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta http-equiv="Content-Type" content="text/html">
<TITLE>puzz.link list of puzzle types</TITLE>
<link rel="stylesheet" href="./css/list.css?<%= git.hash %>">
<script src="./js/candle.js?<%= git.hash %>"></script>
<script src="./js/pzpr.js?<%= git.hash %>"></script>
<script src="./js/list.js?<%= git.hash %>"></script>
</HEAD>
Expand Down
1 change: 1 addition & 0 deletions src-ui/p.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<link rel="mask-icon" href="./safari-pinned-tab.svg" color="#5bbad5">

<link rel="stylesheet" href="./css/ui.css?<%= git.hash %>" type="text/css">
<script type="text/javascript" src="./js/candle.js?<%= git.hash %>"></script>
<script type="text/javascript" src="./js/pzpr.js?<%= git.hash %>"></script>
<script type="text/javascript" src="./js/pzpr-ui.js?<%= git.hash %>"></script>
<title>puzz.link player</title>
Expand Down
1 change: 1 addition & 0 deletions src-ui/rules.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
}
</style>

<script type="text/javascript" src="./js/candle.js?<%= git.hash %>"></script>
<script type="text/javascript" src="./js/pzpr.js?<%= git.hash %>"></script>
<script>

Expand Down
43 changes: 22 additions & 21 deletions src/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
{
"env": {
"browser": true, // Allow to use browser defined variable (not console, alert etc.)
"node": true // Allow to use node defined variable (require, process etc.)
"browser": true, // Allow to use browser defined variable (not console, alert etc.)
"node": true // Allow to use node defined variable (require, process etc.)
},
"parserOptions": {
"ecmaVersion": 5
"ecmaVersion": 5,
"sourceType": "module"
},
"globals": {
"pzpr": "readonly"
},
"extends": "eslint:recommended", // Implement recommended rules
"extends": "eslint:recommended", // Implement recommended rules
"rules": {
"curly": ["error", "all"], // Error for no curly brancket in loop or conditions
"no-unused-vars": // Error for unused variables, not detect arguments
["error", {"args": "none"}],
"no-undef": "error", // Error for unused variable (that will become global variable)
"new-cap": "error", // Error for lowercase first letter or constructor call as function
"eqeqeq": ["error", "always"], // Error for ==, != to compare
"no-use-before-define": // Error for using variable before definition
["error", {"functions":false, "classes":false}],
"curly": ["error", "all"], // Error for no curly brancket in loop or conditions
// Error for unused variables, not detect arguments
"no-unused-vars": ["error", { "args": "none" }],
"no-undef": "error", // Error for unused variable (that will become global variable)
"new-cap": "error", // Error for lowercase first letter or constructor call as function
"eqeqeq": ["error", "always"], // Error for ==, != to compare
// Error for using variable before definition
"no-use-before-define": ["error", { "functions": false, "classes": false }],
"comma-dangle": ["error", "never"], // Error for trailing comma
"no-redeclare": "warn", // Warn redefine variable (TODO: make this rule error)
"no-redeclare": "warn", // Warn redefine variable (TODO: make this rule error)
//"block-scoped-var": "warn", // Warn var declaration inside block scope
"no-empty": "off", // Allow empty block statements
"no-constant-condition": // Allow constant condition in conditions
["error", {"checkLoops": false}],
"no-useless-escape": "off", // Allow unnessesary escape charactors
"no-extra-boolean-cast": "off", // Allow to use boolean cast for boolean value
"no-mixed-spaces-and-tabs": "off", // Allow to use spaces and tabs for indent
"dot-notation": "off", // Allow object access via obj["name"]
"no-loop-func": "off" // Allow function definition in loop
"no-empty": "off", // Allow empty block statements
// Allow constant condition in conditions
"no-constant-condition": ["error", { "checkLoops": false }],
"no-useless-escape": "off", // Allow unnessesary escape charactors
"no-extra-boolean-cast": "off", // Allow to use boolean cast for boolean value
"no-mixed-spaces-and-tabs": "off", // Allow to use spaces and tabs for indent
"dot-notation": "off", // Allow object access via obj["name"]
"no-loop-func": "off" // Allow function definition in loop
}
}
3 changes: 0 additions & 3 deletions src/common/intro.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/common/outro.js

This file was deleted.

14 changes: 14 additions & 0 deletions src/header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var pzpr = {
version: "<%= git.hash %>"
};
export default pzpr;

import Candle from "pzpr-canvas";
pzpr.Candle = Candle;

//eslint-disable-next-line no-unused-vars
var document = this.document || pzpr.Candle.document;
//eslint-disable-next-line no-unused-vars
var DOMParser = this.DOMParser || pzpr.Candle.DOMParser;
//eslint-disable-next-line no-unused-vars
var XMLSerializer = this.XMLSerializer || pzpr.Candle.XMLSerializer;
13 changes: 0 additions & 13 deletions src/lib/candle-intro.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/lib/candle-outro.js

This file was deleted.

9 changes: 2 additions & 7 deletions src/pzpr.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
exports.files = [
"common/intro",
"pzpr/core",
"lib/candle-intro",
"../node_modules/pzpr-canvas/dist/candle",
"lib/candle-outro",
"header",
"pzpr/env",
"pzpr/event",
"pzpr/classmgr",
Expand Down Expand Up @@ -34,8 +30,7 @@ exports.files = [
"variety-common/Answer",
"variety-common/BoardExec",
"variety-common/Encode",
"variety-common/FileData",
"common/outro"
"variety-common/FileData"
].map(function(mod) {
return "src/" + mod + ".js";
});
15 changes: 0 additions & 15 deletions src/pzpr/core.js

This file was deleted.

6 changes: 1 addition & 5 deletions src/pzpr/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@
}
}
} else {
return (
require("path").dirname(__filename) +
"/" +
(__filename.match("pzpr.js") ? "" : "../")
);
return require("path").dirname(__filename) + "/";
}
return "";
},
Expand Down
23 changes: 15 additions & 8 deletions src/variety/tawa.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,20 @@
numberRemainsUnshaded: true,

maxnum: 6,
minnum: 0
minnum: 0,

adjCells: function() {
var clist = new this.klass.CellList();
clist.add(this.relcell(-1, -2));
clist.add(this.relcell(1, -2));
clist.add(this.relcell(-2, 0));
clist.add(this.relcell(2, 0));
clist.add(this.relcell(-1, 2));
clist.add(this.relcell(1, 2));
return clist.filter(function(c) {
return !c.isnull;
});
}
},
Board: {
cols: 6, // ※本スクリプトでは一番上の段のマスの数を表すこととする.
Expand Down Expand Up @@ -541,13 +554,7 @@
if (!cell.isValidNum()) {
continue;
}
var clist = new this.klass.CellList();
clist.add(cell.relcell(-1, -2));
clist.add(cell.relcell(1, -2));
clist.add(cell.relcell(-2, 0));
clist.add(cell.relcell(2, 0));
clist.add(cell.relcell(-1, 2));
clist.add(cell.relcell(1, 2));
var clist = cell.adjCells();
if (
cell.qnum ===
clist.filter(function(cell) {
Expand Down
Loading