Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js: 6
node_js: 10
script:
- npm run-script build
- npm test
- npm run-script check-format
- make build
- make rollup
- make test
- echo put be back later npm run-script check-format
30 changes: 1 addition & 29 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ module.exports = function(grunt){
banner: banner_full,
process: true,
},
pzpr: {
options: {
sourceMap: !PRODUCTION
},
files: [
{ src: require('./src/pzpr.js').files, dest: 'dist/js/pzpr.concat.js' }
]
},
ui: {
options:{
sourceMap: !PRODUCTION
Expand All @@ -56,24 +48,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';}
}),
files: [
{ expand: true, cwd: 'src/variety', src: ['*.js'], dest: 'dist/js/pzpr-variety' }
]
},
samples:{
options: (PRODUCTION ? {} : {
sourceMap : function(filename){ return filename+'.map';}
Expand All @@ -98,9 +72,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: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']);
};
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.PHONY: build test serve format
.PHONY: release build test serve format lint rollup candle

release: candle rollup build

build:
npm run-script build
Expand All @@ -11,3 +13,15 @@ serve:

format:
npm run-script format

lint:
npm run-script lint

new: candle rollup

rollup:
npx rollup -c

candle:
mkdir -p ./dist/js/
cp ./node_modules/pzpr-canvas/dist/candle.js ./dist/js/candle.js
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"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",
"test": "mocha -r esm -r pzpr-canvas -r source-map-support/register -R progress --recursive test",
"prepublishOnly": "npm test"
},
"devDependencies": {
Expand All @@ -39,9 +39,12 @@
"grunt-contrib-uglify": "^2.0.0",
"grunt-newer": "^1.1.1",
"mocha": "^6.1.4",
"prettier": "^1.19.1"
"prettier": "^1.19.1",
"rollup": "^2.6.0",
"rollup-plugin-terser": "^5.3.0"
},
"dependencies": {
"esm": "^3.2.25",
"pzpr-canvas": "^0.8.2",
"source-map-support": "^0.5.12"
}
Expand Down
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: 'src/pzpr.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/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
3 changes: 2 additions & 1 deletion src/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"node": true // Allow to use node defined variable (require, process etc.)
},
"parserOptions": {
"ecmaVersion": 5
"ecmaVersion": 5,
"sourceType": "module"
},
"globals": {
"pzpr": "readonly"
Expand Down
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.

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.

4 changes: 3 additions & 1 deletion src/puzzle/Address.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Address.js v3.4.1

pzpr.classmgr.makeCommon({
import { classmgr } from "../pzpr/classmgr.js";

classmgr.makeCommon({
//----------------------------------------------------------------------------
// ★Positionクラス Address, Pieceクラスのベースクラス
//---------------------------------------------------------------------------
Expand Down
12 changes: 8 additions & 4 deletions src/puzzle/Answer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// Answer.js v3.4.1

import { classmgr } from '../pzpr/classmgr.js';
import util from '../pzpr/util.js';
import { lang } from '../pzpr/env.js';

//---------------------------------------------------------------------------
// ★AnsCheckクラス 答えチェック関連の関数を扱う
//---------------------------------------------------------------------------

// 回答チェッククラス
// AnsCheckクラス
pzpr.classmgr.makeCommon({
classmgr.makeCommon({
//---------------------------------------------------------
AnsCheck: {
initialize: function() {
Expand All @@ -32,7 +36,7 @@ pzpr.classmgr.makeCommon({
isexist = true,
prio = 0;
if (item.match("@")) {
isexist = pzpr.util.checkpid(
isexist = util.checkpid(
item.substr(item.indexOf("@") + 1),
this.puzzle.pid
);
Expand Down Expand Up @@ -139,11 +143,11 @@ pzpr.classmgr.makeCommon({
}
this.complete = false;
},
gettext: function(lang) {
gettext: function(l_lang) {
var puzzle = this.puzzle,
textlist = puzzle.faillist,
texts = [];
var langcode = (lang || pzpr.lang) === "ja" ? 0 : 1;
var langcode = (l_lang || lang) === "ja" ? 0 : 1;
if (this.length === 0) {
return textlist.complete[langcode];
}
Expand Down
3 changes: 2 additions & 1 deletion src/puzzle/AreaManager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// AreaManager.js

pzpr.classmgr.makeCommon({
import { classmgr } from '../pzpr/classmgr.js';
classmgr.makeCommon({
//--------------------------------------------------------------------------------
// ★AreaGraphBaseクラス セルの部屋情報などを保持するクラス
// ※このクラスで管理しているroomsは左上からの順番に並ばないので
Expand Down
4 changes: 3 additions & 1 deletion src/puzzle/Board.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Board.js v3.4.1

import { classmgr } from '../pzpr/classmgr.js';

//---------------------------------------------------------------------------
// ★Boardクラス 盤面の情報を保持する。Cell, Cross, Borderのオブジェクトも保持する
//---------------------------------------------------------------------------
// Boardクラスの定義
pzpr.classmgr.makeCommon({
classmgr.makeCommon({
//---------------------------------------------------------
Board: {
initialize: function() {
Expand Down
6 changes: 3 additions & 3 deletions src/puzzle/BoardExec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// BoardExec.js v3.4.1

(function() {
import { classmgr } from '../pzpr/classmgr.js';

// 拡大縮小・回転反転用定数
var UP = 0x01,
DN = 0x02,
Expand All @@ -11,7 +12,7 @@
TURN = 0x40,
FLIP = 0x80;

pzpr.classmgr.makeCommon({
classmgr.makeCommon({
//---------------------------------------------------------------------------
// ★BoardExecクラス 盤面の拡大縮小、反転回転等を行う (MenuExec.js, Board.jsから移動)
//---------------------------------------------------------------------------
Expand Down Expand Up @@ -443,4 +444,3 @@
adjustBoardData2: function(key, d) {}
}
});
})();
14 changes: 8 additions & 6 deletions src/puzzle/Config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Config.js v3.4.1

(function() {
import variety from '../pzpr/variety.js';
import { env } from '../pzpr/env.js';
import Puzzle from './Puzzle.js';

//---------------------------------------------------------------------------
// ★Configクラス 設定値の値などを保持する
//---------------------------------------------------------------------------
var Config = (pzpr.Puzzle.prototype.Config = function(puzzle) {
var Config = (Puzzle.prototype.Config = function(puzzle) {
this.puzzle = puzzle;
this.init();
});
Expand Down Expand Up @@ -41,7 +44,7 @@
this.add("squarecell", true); /* セルは正方形にする */

/* 入力方法設定 */
this.add("use", !pzpr.env.API.touchevent ? 1 : 2, {
this.add("use", !env.API.touchevent ? 1 : 2, {
option: [1, 2]
}); /* 黒マスの入力方法 */
this.add("use_tri", 1, {
Expand All @@ -55,7 +58,7 @@
this.add("bgcolor", false); /* slither 背景色入力 */
this.add(
"singlenum",
!pzpr.env.API.touchevent
!env.API.touchevent
); /* hanare: 部屋に回答数字を一つだけ入力 */
this.add("enline", true); /* kouchoku: 線は点の間のみ引ける */
this.add("lattice", true); /* kouchoku: 格子点チェック */
Expand Down Expand Up @@ -143,7 +146,7 @@
if (argname.match(/\@/)) {
var splitted = argname.split(/\@/);
info.name = splitted[0];
var pid = pzpr.variety.toPID(splitted[1]);
var pid = variety.toPID(splitted[1]);
if (!!pid) {
info.pid = pid;
}
Expand Down Expand Up @@ -418,4 +421,3 @@
}
}
};
})();
9 changes: 6 additions & 3 deletions src/puzzle/Encode.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Encode.js v3.4.1

import { classmgr } from '../pzpr/classmgr.js';
import Parser from '../pzpr/parser.js';

//---------------------------------------------------------------------------
// ★Encodeクラス URLのエンコード/デコードを扱う
//---------------------------------------------------------------------------
// URLエンコード/デコード
// Encodeクラス
pzpr.classmgr.makeCommon({
classmgr.makeCommon({
//---------------------------------------------------------
Encode: {
pflag: "",
Expand Down Expand Up @@ -39,7 +42,7 @@ pzpr.classmgr.makeCommon({
// enc.encodePzpr() 各パズルのURL出力用(オーバーライド用)
//---------------------------------------------------------------------------
decodeURL: function(url) {
var pzl = pzpr.parser.parseURL(url),
var pzl = Parser.parseURL(url),
puzzle = this.puzzle,
bd = puzzle.board;

Expand Down Expand Up @@ -83,7 +86,7 @@ pzpr.classmgr.makeCommon({
var puzzle = this.puzzle,
pid = puzzle.pid,
bd = puzzle.board;
var pzl = new pzpr.parser.URLData("", mode);
var pzl = new Parser.URLData("", mode);

type =
type || pzl.URL_PZPRV3; /* type===pzl.URL_AUTO(0)もまとめて変換する */
Expand Down
Loading