UNPKG

skynovel

Version:
1,338 lines (1,285 loc) 7.01 MB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else { var a = factory(); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(window, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) /************************************************************************/ /******/ ({ /***/ "./core/src/app.ts": /*!*************************!*\ !*** ./core/src/app.ts ***! \*************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.argChk_Boolean = exports.argChk_Num = exports.Layer = exports.CmnLib = exports.SysApp = void 0; const SysApp_1 = __webpack_require__(/*! ./sn/SysApp */ "./core/src/sn/SysApp.ts"); Object.defineProperty(exports, "SysApp", { enumerable: true, get: function () { return SysApp_1.SysApp; } }); const CmnLib_1 = __webpack_require__(/*! ./sn/CmnLib */ "./core/src/sn/CmnLib.ts"); Object.defineProperty(exports, "CmnLib", { enumerable: true, get: function () { return CmnLib_1.CmnLib; } }); Object.defineProperty(exports, "argChk_Num", { enumerable: true, get: function () { return CmnLib_1.argChk_Num; } }); Object.defineProperty(exports, "argChk_Boolean", { enumerable: true, get: function () { return CmnLib_1.argChk_Boolean; } }); const Layer_1 = __webpack_require__(/*! ./sn/Layer */ "./core/src/sn/Layer.ts"); Object.defineProperty(exports, "Layer", { enumerable: true, get: function () { return Layer_1.Layer; } }); /***/ }), /***/ "./core/src/sn/AnalyzeTagArg.ts": /*!**************************************!*\ !*** ./core/src/sn/AnalyzeTagArg.ts ***! \**************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AnalyzeTagArg = void 0; class AnalyzeTagArg { constructor() { this.REG_TAGARG = /;.*\n|(?<key>\w+)(?:\s+|;[^\n]*\n)*=(?:\s+|;.*\n)*(?:(?<val>[^\s"'#|;]+)|(["'#])(?<val2>.*?)\3)(?:\|(?:(?<def>[^\s"'#;]+)|(["'#])(?<def2>.*?)\6))?|(?<literal>[^\s;]+)/g; this.$hPrm = {}; this.$isKomeParam = false; } go(args) { var _a, _b; this.$hPrm = {}; this.$isKomeParam = false; if (!args) return; let e = null; while (e = this.REG_TAGARG.exec(args)) { const g = e === null || e === void 0 ? void 0 : e.groups; if (!g) continue; if (g.key) this.$hPrm[g.key] = { val: (_a = g.val) !== null && _a !== void 0 ? _a : g.val2, def: (_b = g.def) !== null && _b !== void 0 ? _b : g.def2 }; else if (g.literal) { if (g.literal === '*') this.$isKomeParam = true; else this.$hPrm[g.literal] = { val: '1' }; } } } get hPrm() { return this.$hPrm; } get isKomeParam() { return this.$isKomeParam; } } exports.AnalyzeTagArg = AnalyzeTagArg; /***/ }), /***/ "./core/src/sn/Areas.ts": /*!******************************!*\ !*** ./core/src/sn/Areas.ts ***! \******************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Areas = void 0; class Areas { constructor() { this.hAreas = {}; } search(idx) { for (const begin in this.hAreas) { if (idx < parseInt(begin)) continue; if (idx <= this.hAreas[begin]) return true; } return false; } record(idx) { if (this.search(idx)) return; for (const begin in this.hAreas) { if (this.hAreas[begin] + 1 === idx) { if ((idx + 1) in this.hAreas) { this.hAreas[begin] = this.hAreas[idx + 1]; delete this.hAreas[idx + 1]; } else { this.hAreas[begin] = idx; } return; } } if ((idx + 1) in this.hAreas) { this.hAreas[idx] = this.hAreas[idx + 1]; delete this.hAreas[idx + 1]; return; } this.hAreas[idx] = idx; } erase(idx) { if (!this.search(idx)) return; if (idx in this.hAreas) { if (this.hAreas[idx] > idx) this.hAreas[idx + 1] = this.hAreas[idx]; delete this.hAreas[idx]; return; } for (const begin in this.hAreas) { if (idx < parseInt(begin)) continue; if (this.hAreas[begin] < idx) continue; if (this.hAreas[begin] === idx) { this.hAreas[begin] = idx - 1; return; } this.hAreas[idx + 1] = this.hAreas[begin]; this.hAreas[begin] = idx - 1; return; } } get count() { return Object.keys(this.hAreas).length; } toString() { let ret = ''; const aBegin = []; for (const begin in this.hAreas) aBegin.push(parseInt(begin)); aBegin.sort(function (x, y) { return x - y; }); for (const v of aBegin) { ret += true ? '' : undefined; } if (ret !== '') ret = ret.slice(1); return ret; } } exports.Areas = Areas; /***/ }), /***/ "./core/src/sn/Button.ts": /*!*******************************!*\ !*** ./core/src/sn/Button.ts ***! \*******************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Button = void 0; const pixi_js_1 = __webpack_require__(/*! pixi.js */ "./node_modules/pixi.js/lib/pixi.es.js"); const CmnLib_1 = __webpack_require__(/*! ./CmnLib */ "./core/src/sn/CmnLib.ts"); const GrpLayer_1 = __webpack_require__(/*! ./GrpLayer */ "./core/src/sn/GrpLayer.ts"); const Layer_1 = __webpack_require__(/*! ./Layer */ "./core/src/sn/Layer.ts"); class Button extends pixi_js_1.Container { constructor(main, evtMng, hArg) { var _a; super(); this.main = main; this.evtMng = evtMng; this.isStop = false; const enabled = CmnLib_1.argChk_Boolean(hArg, 'enabled', true); if (enabled) this.evtMng.button(hArg, this); if ('text' in hArg) { const fontSize = CmnLib_1.uint(hArg.height || 30); const style = { fill: 'black', align: 'center', fontFamily: Button.fontFamily, fontSize: fontSize, padding: 5, dropShadow: true, dropShadowAlpha: 0.7, dropShadowColor: '#ffffff', dropShadowBlur: 7, dropShadowDistance: 0, }; if (hArg.style) Button.s2hStyle(style, hArg.style); const txt = new pixi_js_1.Text((_a = hArg.text) !== null && _a !== void 0 ? _a : '', style); txt.alpha = CmnLib_1.argChk_Num(hArg, 'alpha', txt.alpha); txt.pivot.set(CmnLib_1.argChk_Num(hArg, 'pivot_x', txt.pivot.x), CmnLib_1.argChk_Num(hArg, 'pivot_y', txt.pivot.y)); txt.rotation = CmnLib_1.argChk_Num(hArg, 'rotation', txt.rotation); txt.scale.set(CmnLib_1.argChk_Num(hArg, 'scale_x', txt.scale.x), CmnLib_1.argChk_Num(hArg, 'scale_y', txt.scale.y)); txt.width = CmnLib_1.uint(hArg.width || 100); txt.height = fontSize; txt.x = CmnLib_1.uint(hArg.left || 0); txt.y = CmnLib_1.uint(hArg.top || 0); if (hArg.b_pic) { const cnt = new pixi_js_1.Container(); this.addChild(cnt); this.isStop = GrpLayer_1.GrpLayer.csv2Sprites(hArg.b_pic, cnt, sp => { sp.alpha = txt.alpha; sp.rotation = txt.rotation; sp.x = txt.x; sp.y = txt.y; sp.pivot.set((sp.width - txt.width) / 2, (sp.height - txt.height) / 2); }, isStop => { Layer_1.Layer.setBlendmode(this, hArg); if (isStop) this.main.resume(); }); } this.addChild(txt); if (!hArg.b_pic) Layer_1.Layer.setBlendmode(this, hArg); if (!enabled) return; const normal = () => txt.style = { ...txt.style, ...style }; const style_hover = { ...style }; if (hArg.style_hover) Button.s2hStyle(style_hover, hArg.style_hover); else style_hover.fill = 'white'; const hover = () => txt.style = { ...txt.style, ...style_hover }; const style_clicked = { ...style_hover }; if (hArg.style_clicked) Button.s2hStyle(style_clicked, hArg.style_clicked); else style_clicked.dropShadow = false; const clicked = () => txt.style = { ...txt.style, ...style_clicked }; this.on('pointerover', hover); this.on('pointerout', normal); this.on('pointerdown', clicked); this.on('pointerup', CmnLib_1.CmnLib.isMobile ? normal : hover); return; } if (!hArg.pic) throw 'textまたはpic属性は必須です'; this.isStop = GrpLayer_1.GrpLayer.csv2Sprites(hArg.pic, this, sp => { sp.alpha = CmnLib_1.argChk_Num(hArg, 'alpha', sp.alpha); sp.pivot.set(CmnLib_1.argChk_Num(hArg, 'pivot_x', sp.pivot.x), CmnLib_1.argChk_Num(hArg, 'pivot_y', sp.pivot.y)); sp.rotation = CmnLib_1.argChk_Num(hArg, 'rotation', sp.rotation); sp.scale.set(CmnLib_1.argChk_Num(hArg, 'scale_x', sp.scale.x), CmnLib_1.argChk_Num(hArg, 'scale_y', sp.scale.y)); sp.x = CmnLib_1.uint(hArg.left || 0); sp.y = CmnLib_1.uint(hArg.top || 0); const w3 = sp.width / 3; const h = sp.height; const tx = sp.texture.baseTexture; const txNormal = new pixi_js_1.Texture(tx, new pixi_js_1.Rectangle(0, 0, w3, h)); const txClicked = new pixi_js_1.Texture(tx, new pixi_js_1.Rectangle(w3, 0, w3, h)); const txHover = new pixi_js_1.Texture(tx, new pixi_js_1.Rectangle(w3 * 2, 0, w3, h)); const normal = () => sp.texture = txNormal; const hover = () => sp.texture = txHover; const clicked = () => sp.texture = txClicked; this.on('pointerover', hover); this.on('pointerout', normal); this.on('pointerdown', clicked); this.on('pointerup', CmnLib_1.CmnLib.isMobile ? normal : hover); normal(); }, isStop => { if (isStop) this.main.resume(); }); } static s2hStyle(hStyle, style) { Button.cln = document.createElement('span'); const s = Button.cln.style; s.cssText = style; const len = s.length; for (let i = 0; i < len; ++i) { const nm = s[i]; hStyle[nm] = s[nm]; } } } exports.Button = Button; Button.fontFamily = "'Hiragino Sans', 'Hiragino Kaku Gothic ProN', '游ゴシック Medium', meiryo, sans-serif"; /***/ }), /***/ "./core/src/sn/CallStack.ts": /*!**********************************!*\ !*** ./core/src/sn/CallStack.ts ***! \**********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CallStack = void 0; class CallStack { constructor($fn = '', $idx = 0, $hArg = null) { this.$fn = $fn; this.$idx = $idx; this.$hArg = $hArg; this.toString = () => `[fn:${this.$fn}, idx:${this.$idx}, hArg:${this.$hArg}]`; } get fn() { return this.$fn; } get idx() { return this.$idx; } get csArg() { return this.$hArg; } } exports.CallStack = CallStack; /***/ }), /***/ "./core/src/sn/CmnLib.ts": /*!*******************************!*\ !*** ./core/src/sn/CmnLib.ts ***! \*******************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CmnLib = exports.getExt = exports.getFn = exports.argChk_Boolean = exports.argChk_Num = exports.cnvTweenArg = exports.hMemberCnt = exports.getDateStr = exports.uint = exports.int = void 0; function int(o) { return parseInt(String(o), 10); } exports.int = int; function uint(o) { const v = parseInt(String(o), 10); return v < 0 ? -v : v; } exports.uint = uint; if (!('toInt' in String.prototype)) { String.prototype.toInt = function () { return int(this); }; } if (!('toUint' in String.prototype)) { String.prototype.toUint = function () { const v = int(this); return v < 0 ? -v : v; }; } function getDateStr(spl_dd = '/', spl_dt = ' ', spl_tt = ':', spl_ms = '') { const now = new Date(); return now.getFullYear() + spl_dd + String(100 + now.getMonth() + 1).slice(1, 3) + spl_dd + String(100 + now.getDate()).slice(1, 3) + spl_dt + String(100 + now.getHours()).slice(1, 3) + spl_tt + String(100 + now.getMinutes()).slice(1, 3) + (spl_ms === '' ? '' : spl_ms + String(now.getMilliseconds())); } exports.getDateStr = getDateStr; exports.hMemberCnt = { alpha: 0, height: 0, rotation: 0, scale_x: 0, scale_y: 0, width: 0, x: 0, y: 0, }; function cnvTweenArg(hArg, lay) { const hTo = {}; for (const nm in exports.hMemberCnt) { if (!(nm in hArg)) continue; const v = String(hArg[nm]); const a = ((v.charAt(0) === '=') ? v.slice(1) : v).split(','); const a0 = hTo[nm] = parseFloat(a[0]); if (a.length > 1) hTo[nm] += Math.round(Math.random() * (parseFloat(a[1]) - a0 + 1)); if (v.charAt(0) === '=') hTo[nm] += parseFloat(lay[nm]); } return hTo; } exports.cnvTweenArg = cnvTweenArg; function argChk_Num(hash, name, def) { const v = hash[name]; if (!(name in hash)) { if (isNaN(def)) throw `[${hash.タグ名}]属性 ${name} は必須です`; hash[name] = def; return def; } const n = (String(v).slice(0, 2) === '0x') ? parseInt(v) : parseFloat(v); if (isNaN(n)) throw `[${hash.タグ名}]属性 ${name} の値【${v}】が数値ではありません`; return hash[name] = n; } exports.argChk_Num = argChk_Num; function argChk_Boolean(hash, name, def) { if (!(name in hash)) return hash[name] = def; const v = hash[name]; if (v === null) return false; const v2 = String(v); return hash[name] = (v2 === 'false') ? false : Boolean(v2); } exports.argChk_Boolean = argChk_Boolean; const m_path = __webpack_require__(/*! path */ "path"); function getFn(path) { return m_path.basename(path, m_path.extname(path)); } exports.getFn = getFn; function getExt(path) { return m_path.extname(path).slice(1); } exports.getExt = getExt; const platform = __webpack_require__(/*! platform */ "./node_modules/platform/platform.js"); class CmnLib { static cvsResize(cvs) { var _a; const bk_cw = CmnLib.cvsWidth; const bk_ch = CmnLib.cvsHeight; let wiw = window.innerWidth; let wih = window.innerHeight; const wi = window; const lp = screen.orientation ? screen.orientation.type.charAt(0) : (((_a = wi.orientation) !== null && _a !== void 0 ? _a : 90) % 180 === 0) ? 'p' : 'l'; if (CmnLib.isMobile && ((lp === 'p' && wiw > wih) || (lp === 'l' && wiw < wih))) [wiw, wih] = [wih, wiw]; if (argChk_Boolean(CmnLib.hDip, 'expanding', true) || CmnLib.stageW > wiw || CmnLib.stageH > wih) { if (CmnLib.stageW / CmnLib.stageH <= wiw / wih) { CmnLib.cvsHeight = wih; CmnLib.cvsWidth = CmnLib.stageW / CmnLib.stageH * wih; } else { CmnLib.cvsWidth = wiw; CmnLib.cvsHeight = CmnLib.stageH / CmnLib.stageW * wiw; } CmnLib.cvsScale = CmnLib.cvsWidth / CmnLib.stageW; const cr = cvs.getBoundingClientRect(); CmnLib.ofsPadLeft_Dom2PIXI = (CmnLib.isMobile ? (window.innerWidth - CmnLib.cvsWidth) / 2 : cr.left) * (1 - CmnLib.cvsScale); CmnLib.ofsPadTop_Dom2PIXI = (CmnLib.isMobile ? (window.innerHeight - CmnLib.cvsHeight) / 2 : cr.top) * (1 - CmnLib.cvsScale); } else { CmnLib.cvsWidth = CmnLib.stageW; CmnLib.cvsHeight = CmnLib.stageH; CmnLib.cvsScale = 1; CmnLib.ofsPadLeft_Dom2PIXI = 0; CmnLib.ofsPadTop_Dom2PIXI = 0; } if (cvs.parentElement) { const ps = cvs.parentElement.style; ps.position = 'relative'; const s = cvs.style; ps.width = s.width = `${CmnLib.cvsWidth}px`; ps.height = s.height = `${CmnLib.cvsHeight}px`; } return bk_cw !== CmnLib.cvsWidth || bk_ch !== CmnLib.cvsHeight; } } exports.CmnLib = CmnLib; CmnLib.stageW = 0; CmnLib.stageH = 0; CmnLib.ofsPadLeft_Dom2PIXI = 0; CmnLib.ofsPadTop_Dom2PIXI = 0; CmnLib.cvsWidth = 0; CmnLib.cvsHeight = 0; CmnLib.cvsScale = 1; CmnLib.debugLog = false; CmnLib.platform = { ...platform }; CmnLib.isSafari = platform.name === 'Safari'; CmnLib.isFirefox = platform.name === 'Firefox'; CmnLib.isMac = new RegExp('OS X').test(CmnLib.platform.os.family); CmnLib.isMobile = !new RegExp('(Windows|OS X)').test(CmnLib.platform.os.family); CmnLib.hDip = {}; CmnLib.isRetina = false; CmnLib.isDarkMode = false; CmnLib.retinaRate = 1; CmnLib.SN_ID = 'skynovel'; /***/ }), /***/ "./core/src/sn/CmnTween.ts": /*!*********************************!*\ !*** ./core/src/sn/CmnTween.ts ***! \*********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CmnTween = void 0; const Tween = __webpack_require__(/*! @tweenjs/tween.js */ "./node_modules/@tweenjs/tween.js/dist/tween.esm.js").default; class CmnTween { static ease(nm) { if (!nm) return k => Tween.Easing.Linear.None(k); if (!(nm in CmnTween.hEase)) throw '異常なease指定です'; return CmnTween.hEase[nm]; } } exports.CmnTween = CmnTween; CmnTween.hEase = { 'Back.In': k => Tween.Easing.Back.In(k), 'Back.InOut': k => Tween.Easing.Back.InOut(k), 'Back.Out': k => Tween.Easing.Back.Out(k), 'Bounce.In': k => Tween.Easing.Bounce.In(k), 'Bounce.InOut': k => Tween.Easing.Bounce.InOut(k), 'Bounce.Out': k => Tween.Easing.Bounce.Out(k), 'Circular.In': k => Tween.Easing.Circular.In(k), 'Circular.InOut': k => Tween.Easing.Circular.InOut(k), 'Circular.Out': k => Tween.Easing.Circular.Out(k), 'Cubic.In': k => Tween.Easing.Cubic.In(k), 'Cubic.InOut': k => Tween.Easing.Cubic.InOut(k), 'Cubic.Out': k => Tween.Easing.Cubic.Out(k), 'Elastic.In': k => Tween.Easing.Elastic.In(k), 'Elastic.InOut': k => Tween.Easing.Elastic.InOut(k), 'Elastic.Out': k => Tween.Easing.Elastic.Out(k), 'Exponential.In': k => Tween.Easing.Exponential.In(k), 'Exponential.InOut': k => Tween.Easing.Exponential.InOut(k), 'Exponential.Out': k => Tween.Easing.Exponential.Out(k), 'Linear.None': k => Tween.Easing.Linear.None(k), 'Quadratic.In': k => Tween.Easing.Quadratic.In(k), 'Quadratic.InOut': k => Tween.Easing.Quadratic.InOut(k), 'Quadratic.Out': k => Tween.Easing.Quadratic.Out(k), 'Quartic.In': k => Tween.Easing.Quartic.In(k), 'Quartic.InOut': k => Tween.Easing.Quartic.InOut(k), 'Quartic.Out': k => Tween.Easing.Quartic.Out(k), 'Quintic.In': k => Tween.Easing.Quintic.In(k), 'Quintic.InOut': k => Tween.Easing.Quintic.InOut(k), 'Quintic.Out': k => Tween.Easing.Quintic.Out(k), 'Sinusoidal.In': k => Tween.Easing.Sinusoidal.In(k), 'Sinusoidal.InOut': k => Tween.Easing.Sinusoidal.InOut(k), 'Sinusoidal.Out': k => Tween.Easing.Sinusoidal.Out(k), }; /***/ }), /***/ "./core/src/sn/Config.ts": /*!*******************************!*\ !*** ./core/src/sn/Config.ts ***! \*******************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Config = void 0; const CmnLib_1 = __webpack_require__(/*! ./CmnLib */ "./core/src/sn/CmnLib.ts"); class Config { constructor(sys, fncLoaded, oCfg4tst) { this.sys = sys; this.oCfg = { save_ns: '', coder: { len: 0x360 }, window: { width: 300, height: 300, }, book: { title: '', creator: '', cre_url: '', publisher: '', pub_url: '', detail: '', version: '1.0', }, log: { max_len: 1024 }, init: { bg_color: 0x000000, tagch_msecwait: 10, auto_msecpagewait: 3500, escape: '', }, debug: { devtool: false, token: false, tag: false, putCh: false, debugLog: false, baseTx: false, masume: false, variable: false, }, }; this.userFnTail = ''; this.hPathFn2Exts = {}; this.getJsonSearchPath = () => JSON.stringify(this.hPathFn2Exts); this.$existsBreakline = false; this.$existsBreakpage = false; this.regPath = /([^\/\s]+)\.([^\d]\w+)/; const load = (oCfg) => { var _a, _b, _c, _d, _e, _f, _g, _h, _j; this.oCfg.save_ns = (_a = oCfg === null || oCfg === void 0 ? void 0 : oCfg.save_ns) !== null && _a !== void 0 ? _a : this.oCfg.save_ns; this.oCfg.coder = (_b = oCfg === null || oCfg === void 0 ? void 0 : oCfg.coder) !== null && _b !== void 0 ? _b : this.oCfg.coder; CmnLib_1.CmnLib.stageW = this.oCfg.window.width = Number((_d = (_c = oCfg === null || oCfg === void 0 ? void 0 : oCfg.window) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : this.oCfg.window.width); CmnLib_1.CmnLib.stageH = this.oCfg.window.height = Number((_f = (_e = oCfg === null || oCfg === void 0 ? void 0 : oCfg.window) === null || _e === void 0 ? void 0 : _e.height) !== null && _f !== void 0 ? _f : this.oCfg.window.height); this.oCfg.book = { ...this.oCfg.book, ...oCfg.book }; this.oCfg.log.max_len = (_j = (_h = (_g = oCfg.log) === null || _g === void 0 ? void 0 : _g.max_len) === null || _h === void 0 ? void 0 : _h.max_len) !== null && _j !== void 0 ? _j : this.oCfg.log.max_len; this.oCfg.init = { ...this.oCfg.init, ...oCfg.init }; if ('init' in oCfg) { for (const n in this.oCfg.init) { const v = String(this.oCfg.init[n]); if (v.charAt(0) === '#') this.oCfg.init[n] = parseInt(v.slice(1), 16); } } this.oCfg.debug = { ...this.oCfg.debug, ...oCfg.debug }; CmnLib_1.CmnLib.debugLog = this.oCfg.debug.debugLog; sys.loadPathAndVal(this.hPathFn2Exts, async () => { this.$existsBreakline = this.matchPath('^breakline$', Config.EXT_SPRITE).length > 0; this.$existsBreakpage = this.matchPath('^breakpage$', Config.EXT_SPRITE).length > 0; if (this.sys.crypto) for (const nm in this.hPathFn2Exts) { const o = this.hPathFn2Exts[nm]; for (const ext in o) { if (ext.slice(-10) !== ':RIPEMD160') continue; const hp = o[ext].slice(o[ext].lastIndexOf('/') + 1); const fn = o[ext.slice(0, -10)]; const res = await sys.fetch(fn); const s = await res.text(); const hf = sys.hash(s); if (hp !== hf) throw `ファイル改竄エラーです fn:${fn}`; } } fncLoaded(); }, this); }; if (oCfg4tst) { load(oCfg4tst); return; } const fn = sys.cur + 'prj.json'; sys.fetch(fn) .then(res => res.text()) .then(d => sys.pre('json', d)) .then(s => JSON.parse(s)) .then(load) .catch(e => console.error(`load err fn:prj.json e:%o`, e)); } get existsBreakline() { return this.$existsBreakline; } get existsBreakpage() { return this.$existsBreakpage; } getNs() { return `skynovel.${this.oCfg.save_ns} - `; } searchPath(path, extptn = '') { if (!path) throw '[searchPath] fnが空です'; if (path.slice(0, 7) === 'http://') return path; if (path.slice(0, 11) === 'downloads:/') { return this.sys.path_downloads + path.slice(11); } if (path.slice(0, 10) === 'userdata:/') { return this.sys.path_userdata + path.slice(10); } const a = path.match(this.regPath); let fn = a ? a[1] : path; const ext = a ? a[2] : ''; if (this.userFnTail) { const utn = fn + '@@' + this.userFnTail; if (utn in this.hPathFn2Exts) { if (extptn === '') fn = utn; else for (let e3 in this.hPathFn2Exts[utn]) { if (`|${extptn}|`.indexOf(`|${e3}|`) === -1) continue; fn = utn; break; } } } const h_exts = this.hPathFn2Exts[fn]; if (!h_exts) throw `サーチパスに存在しないファイル【${path}】です`; let ret = ''; if (!ext) { const hcnt = CmnLib_1.int(h_exts[':cnt']); if (extptn === '') { if (hcnt > 1) throw `指定ファイル【${path}】が複数マッチします。サーチ対象拡張子群【${extptn}】で絞り込むか、ファイル名を個別にして下さい。`; return path; } const search_exts = `|${extptn}|`; if (hcnt > 1) { let cnt = 0; for (const e2 in h_exts) { if (search_exts.indexOf(`|${e2}|`) === -1) continue; if (++cnt > 1) throw `指定ファイル【${path}】が複数マッチします。サーチ対象拡張子群【${extptn}】で絞り込むか、ファイル名を個別にして下さい。`; } } for (let e in h_exts) { if (search_exts.indexOf(`|${e}|`) === -1) continue; return h_exts[e]; } throw `サーチ対象拡張子群【${extptn}】にマッチするファイルがサーチパスに存在しません。探索ファイル名=【${path}】`; } if (extptn !== '') { const search_exts2 = `|${extptn}|`; if (search_exts2.indexOf(`|${ext}|`) === -1) { throw `指定ファイルの拡張子【${ext}】は、サーチ対象拡張子群【${extptn}】にマッチしません。探索ファイル名=【${path}】`; } } ret = h_exts[ext]; if (!ret) throw `サーチパスに存在しない拡張子【${ext}】です。探索ファイル名=【${path}】、サーチ対象拡張子群【${extptn}】`; return ret; } matchPath(fnptn, extptn = '') { const aRet = []; const regPtn = new RegExp(fnptn); const regExt = new RegExp(extptn); for (let fn in this.hPathFn2Exts) { if (fn.search(regPtn) === -1) continue; const h_exts = this.hPathFn2Exts[fn]; if (extptn === '') { aRet.push(h_exts); continue; } const o = {}; let isa = false; for (const ext in h_exts) { if (ext.search(regExt) === -1) continue; o[ext] = h_exts[ext]; isa = true; } if (isa) aRet.push(o); } return aRet; } } exports.Config = Config; Config.EXT_SPRITE = 'png|jpg|jpeg|json|svg|webp|mp4|webm'; Config.EXT_SCRIPT = 'sn'; Config.EXT_FONT = 'woff2|otf|ttf'; Config.EXT_SOUND = 'mp3|m4a|ogg|aac|flac|wav'; Config.EXT_HTML = 'htm|html'; /***/ }), /***/ "./core/src/sn/DebugMng.ts": /*!*********************************!*\ !*** ./core/src/sn/DebugMng.ts ***! \*********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DebugMng = void 0; const CmnLib_1 = __webpack_require__(/*! ./CmnLib */ "./core/src/sn/CmnLib.ts"); class DebugMng { constructor(sys, hTag, scrItr) { this.sys = sys; this.first = true; DebugMng.scrItr = scrItr; DebugMng.hTag = hTag; DebugMng.title = hTag.title; DebugMng.myTrace = DebugMng.fncMyTrace; hTag.log = o => this.log(o); hTag.trace = o => this.trace(o); DebugMng.spnDbg = document.createElement('span'); DebugMng.spnDbg.hidden = true; DebugMng.spnDbg.textContent = ''; DebugMng.spnDbg.style.cssText = ` z-index: ${Number.MAX_SAFE_INTEGER}; position: absolute; left: 0; top: 0; color: black; background-color: rgba(255, 255, 255, 0.7);`; document.body.appendChild(DebugMng.spnDbg); } destroy() { DebugMng.title = () => false; document.body.removeChild(DebugMng.spnDbg); } log(hArg) { let dat = ''; if (this.first) { this.first = false; dat = `== ${CmnLib_1.CmnLib.platform.description} ==\n`; } this.sys.appendFile(this.sys.path_downloads + 'log.txt', `${dat}--- ${CmnLib_1.getDateStr('-', '_', '')} [fn:${DebugMng.scrItr.scriptFn} line:${DebugMng.scrItr.lineNum}] prj:${this.sys.cur}\n${hArg.text || `(text is ${hArg.text})`}\n`, err => { if (err) console.log(err); }); return false; } trace(hArg) { DebugMng.myTrace(hArg.text || `(text is ${hArg.text})`, 'I'); return false; } static fncMyTrace(txt, lvl = 'E') { let mes = `{${lvl}} `; if (DebugMng.scrItr && DebugMng.scrItr.lineNum > 0) mes += `(fn:${DebugMng.scrItr.scriptFn} line:${DebugMng.scrItr.lineNum}) `; mes += txt; DebugMng.dspDbg(mes, lvl); let sty = ''; switch (lvl) { case 'D': sty = `color:#${CmnLib_1.CmnLib.isDarkMode ? '49F' : '05A'};`; break; case 'W': sty = 'color:#F80;'; break; case 'F': sty = 'color:#B00;'; break; case 'ET': case 'E': DebugMng.title({ text: txt }); this.hTag.dump_lay({}); this.hTag.dump_val({}); DebugMng.scrItr.dumpErrForeLine(); this.hTag.dump_stack({}); if (lvl === 'ET') throw mes; console.error('%c' + mes, 'color:#F30;'); return; default: sty = ''; mes = ' ' + mes; } console.info('%c' + mes, sty); } static dspDbg(mes, lvl) { let sty = ''; switch (lvl) { case 'D': sty = 'color:#05A;'; break; case 'W': sty = 'color:#F80;'; break; case 'F': sty = 'color:#B00;'; break; case 'ET': case 'E': sty = 'color:#F30;'; break; default: sty = ''; } DebugMng.spnDbg.innerHTML += `<span style='${sty}'>${mes}</span><br/>`; DebugMng.spnDbg.hidden = false; } ; } exports.DebugMng = DebugMng; DebugMng.myTrace = (txt, lvl = 'E') => { let mes = `{${lvl}} ` + txt; let sty = ''; switch (lvl) { case 'D': sty = `color:#${CmnLib_1.CmnLib.isDarkMode ? '49F' : '05A'};`; break; case 'W': sty = 'color:#FF8800;'; break; case 'F': sty = 'color:#BB0000;'; break; case 'ET': throw mes; case 'E': console.error('%c' + mes, 'color:#FF3300;'); return; default: sty = 'color:black;'; mes = ' ' + mes; } console.info('%c' + mes, sty); }; /***/ }), /***/ "./core/src/sn/EventListenerCtn.ts": /*!*****************************************!*\ !*** ./core/src/sn/EventListenerCtn.ts ***! \*****************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EventListenerCtn = void 0; const pixi_js_1 = __webpack_require__(/*! pixi.js */ "./node_modules/pixi.js/lib/pixi.es.js"); class EventListenerCtn { constructor() { this.vctEvt = []; } add(ed, type, fnc, ctx = {}) { if (ed instanceof pixi_js_1.BaseTexture) { switch (type) { case 'loaded': case 'update': case 'error': case 'dispose': ed.on(type, fnc, ctx); this.vctEvt.push(() => ed.off(type, fnc, ctx)); break; } return; } if (ed instanceof pixi_js_1.utils.EventEmitter) { ed.on(type, fnc, ctx); this.vctEvt.push(() => ed.off(type, fnc, ctx)); return; } ed.addEventListener(type, fnc, ctx); this.vctEvt.push(() => { var _a; return ed.removeEventListener(type, fnc, { capture: (_a = ctx.capture) !== null && _a !== void 0 ? _a : false }); }); } clear() { for (const fnc of this.vctEvt) fnc(); this.vctEvt = []; } } exports.EventListenerCtn = EventListenerCtn; /***/ }), /***/ "./core/src/sn/EventMng.ts": /*!*********************************!*\ !*** ./core/src/sn/EventMng.ts ***! \*********************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EventMng = void 0; const CmnLib_1 = __webpack_require__(/*! ./CmnLib */ "./core/src/sn/CmnLib.ts"); const TxtLayer_1 = __webpack_require__(/*! ./TxtLayer */ "./core/src/sn/TxtLayer.ts"); const EventListenerCtn_1 = __webpack_require__(/*! ./EventListenerCtn */ "./core/src/sn/EventListenerCtn.ts"); const Tween = __webpack_require__(/*! @tweenjs/tween.js */ "./node_modules/@tweenjs/tween.js/dist/tween.esm.js").default; const Config_1 = __webpack_require__(/*! ./Config */ "./core/src/sn/Config.ts"); const Hammer = __webpack_require__(/*! hammerjs */ "./node_modules/hammerjs/hammer.js"); class EventMng { constructor(cfg, hTag, appPixi, main, layMng, val, sndMng, scrItr, sys) { this.cfg = cfg; this.hTag = hTag; this.appPixi = appPixi; this.main = main; this.layMng = layMng; this.val = val; this.sndMng = sndMng; this.scrItr = scrItr; this.sys = sys; this.elc = new EventListenerCtn_1.EventListenerCtn; this.hHamEv = { tap2: null, press: null, swipeleft: null, swiperight: null, swipeup: null, swipedown: null, }; this.resvFlameEvent4Wheel = (_win) => { }; this.wheeling = false; this.extend_wheel = false; this.hLocalEvt2Fnc = {}; this.hGlobalEvt2Fnc = {}; this.isWait = false; this.isBreak = false; this.waitCustomEvent4Wheel = (_elc, _fnc) => { }; this.goTxt = () => this.layMng.goTxt(); this.fncCancelSkip = () => { }; this.hDownKeys = { 'Alt': 0, 'Meta': 0, 'Control': 0, 'ArrowDown': 0, 'End': 0, 'Enter': 0, 'Escape': 0, ' ': 0, 'GoBack': 0, }; hTag.clear_event = o => this.clear_event(o); hTag.event = o => this.event(o); hTag.l = o => this.l(o); hTag.p = o => this.p(o); hTag.s = () => { this.stdWait(() => { }, false); return true; }; hTag.set_cancel_skip = () => this.set_cancel_skip(); hTag.wait = o => this.wait(o); hTag.waitclick = () => { this.stdWait(() => main.resume()); return true; }; sndMng.setEvtMng(this); scrItr.setOtherObj(this, layMng); TxtLayer_1.TxtLayer.setEvtMng(main, this); layMng.setEvtMng(this); sys.setFire((KEY, e) => this.fire(KEY, e)); sys.addHook((type, o) => this.procHook(type, o)); this.ham = new Hammer(appPixi.view, { recognizers: [ [Hammer.Press], [Hammer.Swipe, { direction: Hammer.DIRECTION_ALL }], ] }); this.hHamEv.tap2 = null; for (const key in this.hHamEv) { const fnc = this.hHamEv[key] = (e) => { val.defTmp('sn.eventArg.type', e.type); val.defTmp('sn.eventArg.pointers', e.pointers); this.fire(e.type, e); }; this.ham.on(key, fnc); } appPixi.stage.interactive = true; if (CmnLib_1.CmnLib.isMobile) appPixi.stage.on('pointerdown', (e) => this.fire('click', e)); else this.elc.add(appPixi.stage, 'pointerdown', e => { switch (e.data.button) { case 0: this.fire('click', e); break; case 1: this.fire('middleclick', e); break; } }); this.elc.add(window, 'keydown', e => this.ev_keydown(e)); this.elc.add(appPixi.view, 'contextmenu', e => this.ev_contextmenu(e)); if ('WheelEvent' in window) { this.elc.add(appPixi.view, 'wheel', e => this.ev_wheel(e), { passive: true }); this.resvFlameEvent4Wheel = (win) => win.addEventListener('wheel', e => this.ev_wheel(e), { passive: true }); this.waitCustomEvent4Wheel = (elc, fnc) => elc.add(this.appPixi.view, 'wheel', (e) => { if (e['isComposing']) return; if (e.deltaY <= 0) return; e.stopPropagation(); fnc(); }); } this.elc.add(window, 'gamepadconnected', (e) => { if (CmnLib_1.CmnLib.debugLog) console.log('👺 Gamepad connected at index %d: %s. %d buttons, %d axes.', e['gamepad'].index, e['gamepad'].id, e['gamepad'].buttons.length, e['gamepad'].axes.length); const key = e.type; this.fire(key, e); }); this.elc.add(window, 'gamepaddisconnected', (e) => { if (CmnLib_1.CmnLib.debugLog) console.log('👺 Gamepad disconnected from index %d: %s', e['gamepad'].index, e['gamepad'].id); const key = e.type; this.fire(key, e); }); this.elc.add(window, 'keyup', (e) => { if (e['isComposing']) return; if (e.key in this.hDownKeys) this.hDownKeys[e.key] = 0; }); val.defTmp('const.sn.key.alternate', () => (this.hDownKeys['Alt'] > 0)); val.defTmp('const.sn.key.command', () => (this.hDownKeys['Meta'] > 0)); val.defTmp('const.sn.key.control', () => (this.hDownKeys['Control'] > 0)); val.defTmp('const.sn.key.end', () => (this.hDownKeys['End'] > 0)); val.defTmp('const.sn.key.escape', () => (this.hDownKeys['Escape'] > 0)); val.defTmp('const.sn.key.back', () => (this.hDownKeys['GoBack'] > 0)); } resvFlameEvent(win) { win.addEventListener('keydown', e => this.ev_keydown(e)); win.addEventListener('contextmenu', e => this.ev_contextmenu(e)); this.resvFlameEvent4Wheel(win); } ev_keydown(e) { if (e['isComposing']) return; if (e.key in this.hDownKeys) this.hDownKeys[e.key] = e.repeat ? 2 : 1; const key = (e.altKey ? (e.key === 'Alt' ? '' : 'alt+') : '') + (e.ctrlKey ? (e.key === 'Control' ? '' : 'ctrl+') : '') + (e.shiftKey ? (e.key === 'Shift' ? '' : 'shift+') : '') + e.key; this.fire(key, e); } ev_contextmenu(e) { const key = (e.altKey ? (e.key === 'Alt' ? '' : 'alt+') : '') + (e.ctrlKey ? (e.key === 'Control' ? '' : 'ctrl+') : '') + (e.shiftKey ? (e.key === 'Shift' ? '' : 'shift+') : '') + 'rightclick'; this.fire(key, e); e.preventDefault(); } ev_wheel(e) { if (e['isComposing']) return; if (this.wheeling) { this.extend_wheel = true; return; } this.wheeling = true; this.ev_wheel_waitstop(); const key = (e.altKey ? 'alt+' : '') + (e.ctrlKey ? 'ctrl+' : '') + (e.shiftKey ? 'shift+' : '') + (e.deltaY > 0 ? 'downwheel' : 'upwheel'); this.fire(key, e); } ev_wheel_waitstop() { setTimeout(() => { if (this.extend_wheel) { this.extend_wheel = false; this.ev_wheel_waitstop(); return; } this.wheeling = false; }, 250); } destroy() { this.elc.clear(); for (const key in this.hHamEv) { this.ham.off(key); } this.ham.destroy(); } fire(KEY, e) { var _a, _b; if (this.isBreak) return; const key = KEY.toLowerCase(); const ke = this.hLocalEvt2Fnc[key] || this.hGlobalEvt2Fnc[key]; if (!ke) { if (key.slice(0, 5) === 'swipe') { const esw = e; window.scrollBy(-((_a = esw.deltaX) !== null && _a !== void 0 ? _a : 0), -((_b = esw.deltaY) !== null && _b !== void 0 ? _b : 0)); } return; } if ((key.slice(-5) !== 'wheel') && ('preventDefault' in e)) e.preventDefault(); e.stopPropagation(); if (key.slice(0, 4) !== 'dom=' && this.layMng.clickTxtLay()) return; if (!this.isWait) return; this.isWait = false; ke(e); } popLocalEvts() { if (this.isWait) return {}; const ret = this.hLocalEvt2Fnc; this.hLocalEvt2Fnc = {}; return ret; } pushLocalEvts(h) { this.hLocalEvt2Fnc = h; } stdWait(fnc, canskip = true) { this.goTxt(); if (canskip) { const fncKey = () => fnc(); this.hLocalEvt2Fnc['click'] = fncKey; this.hLocalEvt2Fnc['enter'] = fncKey; this.hLocalEvt2Fnc['arrowdown'] = fncKey; this.hLocalEvt2Fnc['wheel.y>0'] = fncKey; } else { delete this.hLocalEvt2Fnc['click']; delete this.hLocalEvt2Fnc['enter']; delete this.hLocalEvt2Fnc['arrowdown']; delete this.hLocalEvt2Fnc['wheel.y>0']; } this.val.saveKidoku(); this.fncCancelSkip(); this.isWait = true; } procHook(type, _o) { switch (type) { case 'continue': case 'disconnect': this.isBreak = false; break; default: this.isBreak = true; } } button(hArg, em) { var _a; if (!hArg.fn && !hArg.label) this.main.errScript('fnまたはlabelは必須です'); em.interactive = em.buttonMode = true; const key = ((_a = hArg.key) !== null && _a !== void 0 ? _a : ' ').toLowerCase(); if (!hArg.fn) hArg.fn = this.scrItr.scriptFn; const glb = CmnLib_1.argChk_Boolean(hArg, 'global', false); if (glb) this.hGlobalEvt2Fnc[key] = () => this.main.resumeByJumpOrCall(hArg); else this.hLocalEvt2Fnc[key] = () => this.main.resumeByJumpOrCall(hArg); em.on('pointerdown', (e) => this.fire(key, e)); if (hArg.clickse) { this.cfg.searchPath(hArg.clickse, Config_1.Config.EXT_SOUND); em.on('pointerdown', () => { const o = { fn: hArg.clickse, join: false }; if (hArg.clicksebuf) o.buf = hArg.clicksebuf; this.hTag.playse(o); }); } if (hArg.enterse) { this.cfg.searchPath(hArg.enterse, Config_1.Config.EXT_SOUND); em.on('pointerover', () => { const o = { fn: hArg.enterse, join: false }; if (hArg.entersebuf) o.buf = hArg.entersebuf; this.hTag.playse(o); }); } if (hArg.leavese) { this.cfg.searchPath(hArg.leavese, Config_1.Config.EXT_SOUND); em.on('pointerout', () => { const o = { fn: hArg.leavese, join: false }; if (