├── .gitmodules ├── LICENSE ├── README.md ├── examples ├── basic.js ├── create.js ├── htdocs │ ├── assets │ │ ├── fetch.umd.js │ │ ├── promise.min.js │ │ └── vue.min.js │ ├── calc.css │ ├── calc.html │ ├── calc.js │ ├── itworks.html │ ├── simple.html │ ├── todo.css │ ├── todo.html │ └── todo.js ├── launch.js └── simple.js └── webview.c /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "webview-c"] 2 | path = webview-c 3 | url = https://github.com/javalikescript/webview-c.git 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | "qjs-webview" contained in the file "webview.c" is licensed under the MIT License as follows: 2 | 3 | ==== 4 | 5 | Copyright (c) 2020 SPYL, javalikescript@free.fr 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | 25 | ==== 26 | 27 | The examples maintained within the "qjs-webview" project, 28 | excluding the folder "examples/htdocs/assets" and the files "examples/htdocs/todo.*", 29 | are licensed under the MIT License unless otherwise noticed. 30 | 31 | 32 | This repository also contains external software/libraries, the related license information is provided below for information only. 33 | 34 | The dependent libraries are licensed under the MIT License: 35 | - "webview-c" contained in the folder "webview-c" is licensed under the MIT License see https://github.com/javalikescript/webview-c 36 | "webview-c" is based on prior work by Serge Zaitsev, see https://github.com/zserge/webview 37 | "webview-c" embeds part of the Microsoft Edge WebView2 SDK, see https://aka.ms/webviewnuget 38 | 39 | The example dependent libraries are mainly licensed under the MIT License: 40 | - "fetch" is licensed under the MIT License see https://github.com/github/fetch/releases 41 | - "vuejs" is licensed under the MIT License see https://vuejs.org/ 42 | - "promise" is licensed under the MIT License see https://github.com/taylorhakes/promise-polyfill 43 | - "todo" is licensed under the MIT License see https://github.com/tastejs/todomvc/tree/gh-pages/examples/vue 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | The QuickJS webview module provides functions to open a web page in a dedicated window from QuickJS. 4 | 5 | ```js 6 | import * as webview from 'webview.so' 7 | webview.open("https://bellard.org/quickjs/", "QuickJS at bellard.org", 800, 600, true) 8 | ``` 9 | 10 | It uses *gtk-webkit2* on Linux and *MSHTML* (IE10/11) or *Edge* (Chromium) on Windows. 11 | 12 | QuickJS can evaluate JavaScript code in the browser and the browser can call a registered QuickJS function, see the `simple.js` file in the examples. 13 | 14 | This module is a binding of the tiny cross-platform [webview-c](https://github.com/javalikescript/webview-c) C library. 15 | 16 | This module is part of the [qjls-dist](https://github.com/javalikescript/qjls-dist) project, 17 | the binaries can be found on the [qjls](http://javalikescript.free.fr/quickjs/) page. 18 | 19 | QuickJS webview is covered by the MIT license. 20 | 21 | ## Examples 22 | 23 | Using the file system 24 | ```sh 25 | qjs examples/launch.js examples/htdocs/calc.html "Calc" 320 400 26 | ``` 27 | -------------------------------------------------------------------------------- /examples/basic.js: -------------------------------------------------------------------------------- 1 | import * as webview from '../webview.so' 2 | 3 | webview.open("https://bellard.org/quickjs/", "QuickJS at bellard.org", 800, 600, true) 4 | -------------------------------------------------------------------------------- /examples/create.js: -------------------------------------------------------------------------------- 1 | import * as webview from '../webview.so' 2 | 3 | let w = webview.create("https://bellard.org/quickjs/", "QuickJS at bellard.org", 800, 600, true) 4 | w.init() 5 | w.loop(); 6 | w = null; 7 | -------------------------------------------------------------------------------- /examples/htdocs/assets/fetch.umd.js: -------------------------------------------------------------------------------- 1 | (function (global, factory) { 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : 3 | typeof define === 'function' && define.amd ? define(['exports'], factory) : 4 | (factory((global.WHATWGFetch = {}))); 5 | }(this, (function (exports) { 'use strict'; 6 | 7 | var support = { 8 | searchParams: 'URLSearchParams' in self, 9 | iterable: 'Symbol' in self && 'iterator' in Symbol, 10 | blob: 11 | 'FileReader' in self && 12 | 'Blob' in self && 13 | (function() { 14 | try { 15 | new Blob(); 16 | return true 17 | } catch (e) { 18 | return false 19 | } 20 | })(), 21 | formData: 'FormData' in self, 22 | arrayBuffer: 'ArrayBuffer' in self 23 | }; 24 | 25 | function isDataView(obj) { 26 | return obj && DataView.prototype.isPrototypeOf(obj) 27 | } 28 | 29 | if (support.arrayBuffer) { 30 | var viewClasses = [ 31 | '[object Int8Array]', 32 | '[object Uint8Array]', 33 | '[object Uint8ClampedArray]', 34 | '[object Int16Array]', 35 | '[object Uint16Array]', 36 | '[object Int32Array]', 37 | '[object Uint32Array]', 38 | '[object Float32Array]', 39 | '[object Float64Array]' 40 | ]; 41 | 42 | var isArrayBufferView = 43 | ArrayBuffer.isView || 44 | function(obj) { 45 | return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 46 | }; 47 | } 48 | 49 | function normalizeName(name) { 50 | if (typeof name !== 'string') { 51 | name = String(name); 52 | } 53 | if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) { 54 | throw new TypeError('Invalid character in header field name') 55 | } 56 | return name.toLowerCase() 57 | } 58 | 59 | function normalizeValue(value) { 60 | if (typeof value !== 'string') { 61 | value = String(value); 62 | } 63 | return value 64 | } 65 | 66 | // Build a destructive iterator for the value list 67 | function iteratorFor(items) { 68 | var iterator = { 69 | next: function() { 70 | var value = items.shift(); 71 | return {done: value === undefined, value: value} 72 | } 73 | }; 74 | 75 | if (support.iterable) { 76 | iterator[Symbol.iterator] = function() { 77 | return iterator 78 | }; 79 | } 80 | 81 | return iterator 82 | } 83 | 84 | function Headers(headers) { 85 | this.map = {}; 86 | 87 | if (headers instanceof Headers) { 88 | headers.forEach(function(value, name) { 89 | this.append(name, value); 90 | }, this); 91 | } else if (Array.isArray(headers)) { 92 | headers.forEach(function(header) { 93 | this.append(header[0], header[1]); 94 | }, this); 95 | } else if (headers) { 96 | Object.getOwnPropertyNames(headers).forEach(function(name) { 97 | this.append(name, headers[name]); 98 | }, this); 99 | } 100 | } 101 | 102 | Headers.prototype.append = function(name, value) { 103 | name = normalizeName(name); 104 | value = normalizeValue(value); 105 | var oldValue = this.map[name]; 106 | this.map[name] = oldValue ? oldValue + ', ' + value : value; 107 | }; 108 | 109 | Headers.prototype['delete'] = function(name) { 110 | delete this.map[normalizeName(name)]; 111 | }; 112 | 113 | Headers.prototype.get = function(name) { 114 | name = normalizeName(name); 115 | return this.has(name) ? this.map[name] : null 116 | }; 117 | 118 | Headers.prototype.has = function(name) { 119 | return this.map.hasOwnProperty(normalizeName(name)) 120 | }; 121 | 122 | Headers.prototype.set = function(name, value) { 123 | this.map[normalizeName(name)] = normalizeValue(value); 124 | }; 125 | 126 | Headers.prototype.forEach = function(callback, thisArg) { 127 | for (var name in this.map) { 128 | if (this.map.hasOwnProperty(name)) { 129 | callback.call(thisArg, this.map[name], name, this); 130 | } 131 | } 132 | }; 133 | 134 | Headers.prototype.keys = function() { 135 | var items = []; 136 | this.forEach(function(value, name) { 137 | items.push(name); 138 | }); 139 | return iteratorFor(items) 140 | }; 141 | 142 | Headers.prototype.values = function() { 143 | var items = []; 144 | this.forEach(function(value) { 145 | items.push(value); 146 | }); 147 | return iteratorFor(items) 148 | }; 149 | 150 | Headers.prototype.entries = function() { 151 | var items = []; 152 | this.forEach(function(value, name) { 153 | items.push([name, value]); 154 | }); 155 | return iteratorFor(items) 156 | }; 157 | 158 | if (support.iterable) { 159 | Headers.prototype[Symbol.iterator] = Headers.prototype.entries; 160 | } 161 | 162 | function consumed(body) { 163 | if (body.bodyUsed) { 164 | return Promise.reject(new TypeError('Already read')) 165 | } 166 | body.bodyUsed = true; 167 | } 168 | 169 | function fileReaderReady(reader) { 170 | return new Promise(function(resolve, reject) { 171 | reader.onload = function() { 172 | resolve(reader.result); 173 | }; 174 | reader.onerror = function() { 175 | reject(reader.error); 176 | }; 177 | }) 178 | } 179 | 180 | function readBlobAsArrayBuffer(blob) { 181 | var reader = new FileReader(); 182 | var promise = fileReaderReady(reader); 183 | reader.readAsArrayBuffer(blob); 184 | return promise 185 | } 186 | 187 | function readBlobAsText(blob) { 188 | var reader = new FileReader(); 189 | var promise = fileReaderReady(reader); 190 | reader.readAsText(blob); 191 | return promise 192 | } 193 | 194 | function readArrayBufferAsText(buf) { 195 | var view = new Uint8Array(buf); 196 | var chars = new Array(view.length); 197 | 198 | for (var i = 0; i < view.length; i++) { 199 | chars[i] = String.fromCharCode(view[i]); 200 | } 201 | return chars.join('') 202 | } 203 | 204 | function bufferClone(buf) { 205 | if (buf.slice) { 206 | return buf.slice(0) 207 | } else { 208 | var view = new Uint8Array(buf.byteLength); 209 | view.set(new Uint8Array(buf)); 210 | return view.buffer 211 | } 212 | } 213 | 214 | function Body() { 215 | this.bodyUsed = false; 216 | 217 | this._initBody = function(body) { 218 | this._bodyInit = body; 219 | if (!body) { 220 | this._bodyText = ''; 221 | } else if (typeof body === 'string') { 222 | this._bodyText = body; 223 | } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { 224 | this._bodyBlob = body; 225 | } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { 226 | this._bodyFormData = body; 227 | } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { 228 | this._bodyText = body.toString(); 229 | } else if (support.arrayBuffer && support.blob && isDataView(body)) { 230 | this._bodyArrayBuffer = bufferClone(body.buffer); 231 | // IE 10-11 can't handle a DataView body. 232 | this._bodyInit = new Blob([this._bodyArrayBuffer]); 233 | } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { 234 | this._bodyArrayBuffer = bufferClone(body); 235 | } else { 236 | this._bodyText = body = Object.prototype.toString.call(body); 237 | } 238 | 239 | if (!this.headers.get('content-type')) { 240 | if (typeof body === 'string') { 241 | this.headers.set('content-type', 'text/plain;charset=UTF-8'); 242 | } else if (this._bodyBlob && this._bodyBlob.type) { 243 | this.headers.set('content-type', this._bodyBlob.type); 244 | } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { 245 | this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); 246 | } 247 | } 248 | }; 249 | 250 | if (support.blob) { 251 | this.blob = function() { 252 | var rejected = consumed(this); 253 | if (rejected) { 254 | return rejected 255 | } 256 | 257 | if (this._bodyBlob) { 258 | return Promise.resolve(this._bodyBlob) 259 | } else if (this._bodyArrayBuffer) { 260 | return Promise.resolve(new Blob([this._bodyArrayBuffer])) 261 | } else if (this._bodyFormData) { 262 | throw new Error('could not read FormData body as blob') 263 | } else { 264 | return Promise.resolve(new Blob([this._bodyText])) 265 | } 266 | }; 267 | 268 | this.arrayBuffer = function() { 269 | if (this._bodyArrayBuffer) { 270 | return consumed(this) || Promise.resolve(this._bodyArrayBuffer) 271 | } else { 272 | return this.blob().then(readBlobAsArrayBuffer) 273 | } 274 | }; 275 | } 276 | 277 | this.text = function() { 278 | var rejected = consumed(this); 279 | if (rejected) { 280 | return rejected 281 | } 282 | 283 | if (this._bodyBlob) { 284 | return readBlobAsText(this._bodyBlob) 285 | } else if (this._bodyArrayBuffer) { 286 | return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) 287 | } else if (this._bodyFormData) { 288 | throw new Error('could not read FormData body as text') 289 | } else { 290 | return Promise.resolve(this._bodyText) 291 | } 292 | }; 293 | 294 | if (support.formData) { 295 | this.formData = function() { 296 | return this.text().then(decode) 297 | }; 298 | } 299 | 300 | this.json = function() { 301 | return this.text().then(JSON.parse) 302 | }; 303 | 304 | return this 305 | } 306 | 307 | // HTTP methods whose capitalization should be normalized 308 | var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; 309 | 310 | function normalizeMethod(method) { 311 | var upcased = method.toUpperCase(); 312 | return methods.indexOf(upcased) > -1 ? upcased : method 313 | } 314 | 315 | function Request(input, options) { 316 | options = options || {}; 317 | var body = options.body; 318 | 319 | if (input instanceof Request) { 320 | if (input.bodyUsed) { 321 | throw new TypeError('Already read') 322 | } 323 | this.url = input.url; 324 | this.credentials = input.credentials; 325 | if (!options.headers) { 326 | this.headers = new Headers(input.headers); 327 | } 328 | this.method = input.method; 329 | this.mode = input.mode; 330 | this.signal = input.signal; 331 | if (!body && input._bodyInit != null) { 332 | body = input._bodyInit; 333 | input.bodyUsed = true; 334 | } 335 | } else { 336 | this.url = String(input); 337 | } 338 | 339 | this.credentials = options.credentials || this.credentials || 'same-origin'; 340 | if (options.headers || !this.headers) { 341 | this.headers = new Headers(options.headers); 342 | } 343 | this.method = normalizeMethod(options.method || this.method || 'GET'); 344 | this.mode = options.mode || this.mode || null; 345 | this.signal = options.signal || this.signal; 346 | this.referrer = null; 347 | 348 | if ((this.method === 'GET' || this.method === 'HEAD') && body) { 349 | throw new TypeError('Body not allowed for GET or HEAD requests') 350 | } 351 | this._initBody(body); 352 | } 353 | 354 | Request.prototype.clone = function() { 355 | return new Request(this, {body: this._bodyInit}) 356 | }; 357 | 358 | function decode(body) { 359 | var form = new FormData(); 360 | body 361 | .trim() 362 | .split('&') 363 | .forEach(function(bytes) { 364 | if (bytes) { 365 | var split = bytes.split('='); 366 | var name = split.shift().replace(/\+/g, ' '); 367 | var value = split.join('=').replace(/\+/g, ' '); 368 | form.append(decodeURIComponent(name), decodeURIComponent(value)); 369 | } 370 | }); 371 | return form 372 | } 373 | 374 | function parseHeaders(rawHeaders) { 375 | var headers = new Headers(); 376 | // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space 377 | // https://tools.ietf.org/html/rfc7230#section-3.2 378 | var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); 379 | preProcessedHeaders.split(/\r?\n/).forEach(function(line) { 380 | var parts = line.split(':'); 381 | var key = parts.shift().trim(); 382 | if (key) { 383 | var value = parts.join(':').trim(); 384 | headers.append(key, value); 385 | } 386 | }); 387 | return headers 388 | } 389 | 390 | Body.call(Request.prototype); 391 | 392 | function Response(bodyInit, options) { 393 | if (!options) { 394 | options = {}; 395 | } 396 | 397 | this.type = 'default'; 398 | this.status = options.status === undefined ? 200 : options.status; 399 | this.ok = this.status >= 200 && this.status < 300; 400 | this.statusText = 'statusText' in options ? options.statusText : 'OK'; 401 | this.headers = new Headers(options.headers); 402 | this.url = options.url || ''; 403 | this._initBody(bodyInit); 404 | } 405 | 406 | Body.call(Response.prototype); 407 | 408 | Response.prototype.clone = function() { 409 | return new Response(this._bodyInit, { 410 | status: this.status, 411 | statusText: this.statusText, 412 | headers: new Headers(this.headers), 413 | url: this.url 414 | }) 415 | }; 416 | 417 | Response.error = function() { 418 | var response = new Response(null, {status: 0, statusText: ''}); 419 | response.type = 'error'; 420 | return response 421 | }; 422 | 423 | var redirectStatuses = [301, 302, 303, 307, 308]; 424 | 425 | Response.redirect = function(url, status) { 426 | if (redirectStatuses.indexOf(status) === -1) { 427 | throw new RangeError('Invalid status code') 428 | } 429 | 430 | return new Response(null, {status: status, headers: {location: url}}) 431 | }; 432 | 433 | exports.DOMException = self.DOMException; 434 | try { 435 | new exports.DOMException(); 436 | } catch (err) { 437 | exports.DOMException = function(message, name) { 438 | this.message = message; 439 | this.name = name; 440 | var error = Error(message); 441 | this.stack = error.stack; 442 | }; 443 | exports.DOMException.prototype = Object.create(Error.prototype); 444 | exports.DOMException.prototype.constructor = exports.DOMException; 445 | } 446 | 447 | function fetch(input, init) { 448 | return new Promise(function(resolve, reject) { 449 | var request = new Request(input, init); 450 | 451 | if (request.signal && request.signal.aborted) { 452 | return reject(new exports.DOMException('Aborted', 'AbortError')) 453 | } 454 | 455 | var xhr = new XMLHttpRequest(); 456 | 457 | function abortXhr() { 458 | xhr.abort(); 459 | } 460 | 461 | xhr.onload = function() { 462 | var options = { 463 | status: xhr.status, 464 | statusText: xhr.statusText, 465 | headers: parseHeaders(xhr.getAllResponseHeaders() || '') 466 | }; 467 | options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); 468 | var body = 'response' in xhr ? xhr.response : xhr.responseText; 469 | resolve(new Response(body, options)); 470 | }; 471 | 472 | xhr.onerror = function() { 473 | reject(new TypeError('Network request failed')); 474 | }; 475 | 476 | xhr.ontimeout = function() { 477 | reject(new TypeError('Network request failed')); 478 | }; 479 | 480 | xhr.onabort = function() { 481 | reject(new exports.DOMException('Aborted', 'AbortError')); 482 | }; 483 | 484 | xhr.open(request.method, request.url, true); 485 | 486 | if (request.credentials === 'include') { 487 | xhr.withCredentials = true; 488 | } else if (request.credentials === 'omit') { 489 | xhr.withCredentials = false; 490 | } 491 | 492 | if ('responseType' in xhr && support.blob) { 493 | xhr.responseType = 'blob'; 494 | } 495 | 496 | request.headers.forEach(function(value, name) { 497 | xhr.setRequestHeader(name, value); 498 | }); 499 | 500 | if (request.signal) { 501 | request.signal.addEventListener('abort', abortXhr); 502 | 503 | xhr.onreadystatechange = function() { 504 | // DONE (success or failure) 505 | if (xhr.readyState === 4) { 506 | request.signal.removeEventListener('abort', abortXhr); 507 | } 508 | }; 509 | } 510 | 511 | xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); 512 | }) 513 | } 514 | 515 | fetch.polyfill = true; 516 | 517 | if (!self.fetch) { 518 | self.fetch = fetch; 519 | self.Headers = Headers; 520 | self.Request = Request; 521 | self.Response = Response; 522 | } 523 | 524 | exports.Headers = Headers; 525 | exports.Request = Request; 526 | exports.Response = Response; 527 | exports.fetch = fetch; 528 | 529 | Object.defineProperty(exports, '__esModule', { value: true }); 530 | 531 | }))); 532 | -------------------------------------------------------------------------------- /examples/htdocs/assets/promise.min.js: -------------------------------------------------------------------------------- 1 | !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";function e(e){var n=this.constructor;return this.then(function(t){return n.resolve(e()).then(function(){return t})},function(t){return n.resolve(e()).then(function(){return n.reject(t)})})}function n(e){return!(!e||"undefined"==typeof e.length)}function t(){}function o(e){if(!(this instanceof o))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=undefined,this._deferreds=[],c(e,this)}function r(e,n){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,o._immediateFn(function(){var t=1===e._state?n.onFulfilled:n.onRejected;if(null!==t){var o;try{o=t(e._value)}catch(r){return void f(n.promise,r)}i(n.promise,o)}else(1===e._state?i:f)(n.promise,e._value)})):e._deferreds.push(n)}function i(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var t=n.then;if(n instanceof o)return e._state=3,e._value=n,void u(e);if("function"==typeof t)return void c(function(e,n){return function(){e.apply(n,arguments)}}(t,n),e)}e._state=1,e._value=n,u(e)}catch(r){f(e,r)}}function f(e,n){e._state=2,e._value=n,u(e)}function u(e){2===e._state&&0===e._deferreds.length&&o._immediateFn(function(){e._handled||o._unhandledRejectionFn(e._value)});for(var n=0,t=e._deferreds.length;t>n;n++)r(e,e._deferreds[n]);e._deferreds=null}function c(e,n){var t=!1;try{e(function(e){t||(t=!0,i(n,e))},function(e){t||(t=!0,f(n,e))})}catch(o){if(t)return;t=!0,f(n,o)}}var a=setTimeout;o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,n){var o=new this.constructor(t);return r(this,new function(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}(e,n,o)),o},o.prototype["finally"]=e,o.all=function(e){return new o(function(t,o){function r(e,n){try{if(n&&("object"==typeof n||"function"==typeof n)){var u=n.then;if("function"==typeof u)return void u.call(n,function(n){r(e,n)},o)}i[e]=n,0==--f&&t(i)}catch(c){o(c)}}if(!n(e))return o(new TypeError("Promise.all accepts an array"));var i=Array.prototype.slice.call(e);if(0===i.length)return t([]);for(var f=i.length,u=0;i.length>u;u++)r(u,i[u])})},o.resolve=function(e){return e&&"object"==typeof e&&e.constructor===o?e:new o(function(n){n(e)})},o.reject=function(e){return new o(function(n,t){t(e)})},o.race=function(e){return new o(function(t,r){if(!n(e))return r(new TypeError("Promise.race accepts an array"));for(var i=0,f=e.length;f>i;i++)o.resolve(e[i]).then(t,r)})},o._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){a(e,0)},o._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var l=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw Error("unable to locate global object")}();"Promise"in l?l.Promise.prototype["finally"]||(l.Promise.prototype["finally"]=e):l.Promise=o}); 2 | -------------------------------------------------------------------------------- /examples/htdocs/assets/vue.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Vue.js v2.6.10 3 | * (c) 2014-2019 Evan You 4 | * Released under the MIT License. 5 | */ 6 | !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Vue=t()}(this,function(){"use strict";var e=Object.freeze({});function t(e){return null==e}function n(e){return null!=e}function r(e){return!0===e}function i(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}function o(e){return null!==e&&"object"==typeof e}var a=Object.prototype.toString;function s(e){return"[object Object]"===a.call(e)}function c(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}function u(e){return n(e)&&"function"==typeof e.then&&"function"==typeof e.catch}function l(e){return null==e?"":Array.isArray(e)||s(e)&&e.toString===a?JSON.stringify(e,null,2):String(e)}function f(e){var t=parseFloat(e);return isNaN(t)?e:t}function p(e,t){for(var n=Object.create(null),r=e.split(","),i=0;i-1)return e.splice(n,1)}}var m=Object.prototype.hasOwnProperty;function y(e,t){return m.call(e,t)}function g(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}var _=/-(\w)/g,b=g(function(e){return e.replace(_,function(e,t){return t?t.toUpperCase():""})}),$=g(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}),w=/\B([A-Z])/g,C=g(function(e){return e.replace(w,"-$1").toLowerCase()});var x=Function.prototype.bind?function(e,t){return e.bind(t)}:function(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n};function k(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function A(e,t){for(var n in t)e[n]=t[n];return e}function O(e){for(var t={},n=0;n0,Z=J&&J.indexOf("edge/")>0,G=(J&&J.indexOf("android"),J&&/iphone|ipad|ipod|ios/.test(J)||"ios"===K),X=(J&&/chrome\/\d+/.test(J),J&&/phantomjs/.test(J),J&&J.match(/firefox\/(\d+)/)),Y={}.watch,Q=!1;if(z)try{var ee={};Object.defineProperty(ee,"passive",{get:function(){Q=!0}}),window.addEventListener("test-passive",null,ee)}catch(e){}var te=function(){return void 0===B&&(B=!z&&!V&&"undefined"!=typeof global&&(global.process&&"server"===global.process.env.VUE_ENV)),B},ne=z&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__;function re(e){return"function"==typeof e&&/native code/.test(e.toString())}var ie,oe="undefined"!=typeof Symbol&&re(Symbol)&&"undefined"!=typeof Reflect&&re(Reflect.ownKeys);ie="undefined"!=typeof Set&&re(Set)?Set:function(){function e(){this.set=Object.create(null)}return e.prototype.has=function(e){return!0===this.set[e]},e.prototype.add=function(e){this.set[e]=!0},e.prototype.clear=function(){this.set=Object.create(null)},e}();var ae=S,se=0,ce=function(){this.id=se++,this.subs=[]};ce.prototype.addSub=function(e){this.subs.push(e)},ce.prototype.removeSub=function(e){h(this.subs,e)},ce.prototype.depend=function(){ce.target&&ce.target.addDep(this)},ce.prototype.notify=function(){for(var e=this.subs.slice(),t=0,n=e.length;t-1)if(o&&!y(i,"default"))a=!1;else if(""===a||a===C(e)){var c=Pe(String,i.type);(c<0||s0&&(st((u=e(u,(a||"")+"_"+c))[0])&&st(f)&&(s[l]=he(f.text+u[0].text),u.shift()),s.push.apply(s,u)):i(u)?st(f)?s[l]=he(f.text+u):""!==u&&s.push(he(u)):st(u)&&st(f)?s[l]=he(f.text+u.text):(r(o._isVList)&&n(u.tag)&&t(u.key)&&n(a)&&(u.key="__vlist"+a+"_"+c+"__"),s.push(u)));return s}(e):void 0}function st(e){return n(e)&&n(e.text)&&!1===e.isComment}function ct(e,t){if(e){for(var n=Object.create(null),r=oe?Reflect.ownKeys(e):Object.keys(e),i=0;i0,a=t?!!t.$stable:!o,s=t&&t.$key;if(t){if(t._normalized)return t._normalized;if(a&&r&&r!==e&&s===r.$key&&!o&&!r.$hasNormal)return r;for(var c in i={},t)t[c]&&"$"!==c[0]&&(i[c]=pt(n,c,t[c]))}else i={};for(var u in n)u in i||(i[u]=dt(n,u));return t&&Object.isExtensible(t)&&(t._normalized=i),R(i,"$stable",a),R(i,"$key",s),R(i,"$hasNormal",o),i}function pt(e,t,n){var r=function(){var e=arguments.length?n.apply(null,arguments):n({});return(e=e&&"object"==typeof e&&!Array.isArray(e)?[e]:at(e))&&(0===e.length||1===e.length&&e[0].isComment)?void 0:e};return n.proxy&&Object.defineProperty(e,t,{get:r,enumerable:!0,configurable:!0}),r}function dt(e,t){return function(){return e[t]}}function vt(e,t){var r,i,a,s,c;if(Array.isArray(e)||"string"==typeof e)for(r=new Array(e.length),i=0,a=e.length;idocument.createEvent("Event").timeStamp&&(sn=function(){return cn.now()})}function un(){var e,t;for(an=sn(),rn=!0,Qt.sort(function(e,t){return e.id-t.id}),on=0;onon&&Qt[n].id>e.id;)n--;Qt.splice(n+1,0,e)}else Qt.push(e);nn||(nn=!0,Ye(un))}}(this)},fn.prototype.run=function(){if(this.active){var e=this.get();if(e!==this.value||o(e)||this.deep){var t=this.value;if(this.value=e,this.user)try{this.cb.call(this.vm,e,t)}catch(e){Re(e,this.vm,'callback for watcher "'+this.expression+'"')}else this.cb.call(this.vm,e,t)}}},fn.prototype.evaluate=function(){this.value=this.get(),this.dirty=!1},fn.prototype.depend=function(){for(var e=this.deps.length;e--;)this.deps[e].depend()},fn.prototype.teardown=function(){if(this.active){this.vm._isBeingDestroyed||h(this.vm._watchers,this);for(var e=this.deps.length;e--;)this.deps[e].removeSub(this);this.active=!1}};var pn={enumerable:!0,configurable:!0,get:S,set:S};function dn(e,t,n){pn.get=function(){return this[t][n]},pn.set=function(e){this[t][n]=e},Object.defineProperty(e,n,pn)}function vn(e){e._watchers=[];var t=e.$options;t.props&&function(e,t){var n=e.$options.propsData||{},r=e._props={},i=e.$options._propKeys=[];e.$parent&&$e(!1);var o=function(o){i.push(o);var a=Me(o,t,n,e);xe(r,o,a),o in e||dn(e,"_props",o)};for(var a in t)o(a);$e(!0)}(e,t.props),t.methods&&function(e,t){e.$options.props;for(var n in t)e[n]="function"!=typeof t[n]?S:x(t[n],e)}(e,t.methods),t.data?function(e){var t=e.$options.data;s(t=e._data="function"==typeof t?function(e,t){le();try{return e.call(t,t)}catch(e){return Re(e,t,"data()"),{}}finally{fe()}}(t,e):t||{})||(t={});var n=Object.keys(t),r=e.$options.props,i=(e.$options.methods,n.length);for(;i--;){var o=n[i];r&&y(r,o)||(a=void 0,36!==(a=(o+"").charCodeAt(0))&&95!==a&&dn(e,"_data",o))}var a;Ce(t,!0)}(e):Ce(e._data={},!0),t.computed&&function(e,t){var n=e._computedWatchers=Object.create(null),r=te();for(var i in t){var o=t[i],a="function"==typeof o?o:o.get;r||(n[i]=new fn(e,a||S,S,hn)),i in e||mn(e,i,o)}}(e,t.computed),t.watch&&t.watch!==Y&&function(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var i=0;i-1:"string"==typeof e?e.split(",").indexOf(t)>-1:(n=e,"[object RegExp]"===a.call(n)&&e.test(t));var n}function An(e,t){var n=e.cache,r=e.keys,i=e._vnode;for(var o in n){var a=n[o];if(a){var s=xn(a.componentOptions);s&&!t(s)&&On(n,o,r,i)}}}function On(e,t,n,r){var i=e[t];!i||r&&i.tag===r.tag||i.componentInstance.$destroy(),e[t]=null,h(n,t)}!function(t){t.prototype._init=function(t){var n=this;n._uid=bn++,n._isVue=!0,t&&t._isComponent?function(e,t){var n=e.$options=Object.create(e.constructor.options),r=t._parentVnode;n.parent=t.parent,n._parentVnode=r;var i=r.componentOptions;n.propsData=i.propsData,n._parentListeners=i.listeners,n._renderChildren=i.children,n._componentTag=i.tag,t.render&&(n.render=t.render,n.staticRenderFns=t.staticRenderFns)}(n,t):n.$options=De($n(n.constructor),t||{},n),n._renderProxy=n,n._self=n,function(e){var t=e.$options,n=t.parent;if(n&&!t.abstract){for(;n.$options.abstract&&n.$parent;)n=n.$parent;n.$children.push(e)}e.$parent=n,e.$root=n?n.$root:e,e.$children=[],e.$refs={},e._watcher=null,e._inactive=null,e._directInactive=!1,e._isMounted=!1,e._isDestroyed=!1,e._isBeingDestroyed=!1}(n),function(e){e._events=Object.create(null),e._hasHookEvent=!1;var t=e.$options._parentListeners;t&&qt(e,t)}(n),function(t){t._vnode=null,t._staticTrees=null;var n=t.$options,r=t.$vnode=n._parentVnode,i=r&&r.context;t.$slots=ut(n._renderChildren,i),t.$scopedSlots=e,t._c=function(e,n,r,i){return Pt(t,e,n,r,i,!1)},t.$createElement=function(e,n,r,i){return Pt(t,e,n,r,i,!0)};var o=r&&r.data;xe(t,"$attrs",o&&o.attrs||e,null,!0),xe(t,"$listeners",n._parentListeners||e,null,!0)}(n),Yt(n,"beforeCreate"),function(e){var t=ct(e.$options.inject,e);t&&($e(!1),Object.keys(t).forEach(function(n){xe(e,n,t[n])}),$e(!0))}(n),vn(n),function(e){var t=e.$options.provide;t&&(e._provided="function"==typeof t?t.call(e):t)}(n),Yt(n,"created"),n.$options.el&&n.$mount(n.$options.el)}}(wn),function(e){var t={get:function(){return this._data}},n={get:function(){return this._props}};Object.defineProperty(e.prototype,"$data",t),Object.defineProperty(e.prototype,"$props",n),e.prototype.$set=ke,e.prototype.$delete=Ae,e.prototype.$watch=function(e,t,n){if(s(t))return _n(this,e,t,n);(n=n||{}).user=!0;var r=new fn(this,e,t,n);if(n.immediate)try{t.call(this,r.value)}catch(e){Re(e,this,'callback for immediate watcher "'+r.expression+'"')}return function(){r.teardown()}}}(wn),function(e){var t=/^hook:/;e.prototype.$on=function(e,n){var r=this;if(Array.isArray(e))for(var i=0,o=e.length;i1?k(t):t;for(var n=k(arguments,1),r='event handler for "'+e+'"',i=0,o=t.length;iparseInt(this.max)&&On(a,s[0],s,this._vnode)),t.data.keepAlive=!0}return t||e&&e[0]}}};!function(e){var t={get:function(){return F}};Object.defineProperty(e,"config",t),e.util={warn:ae,extend:A,mergeOptions:De,defineReactive:xe},e.set=ke,e.delete=Ae,e.nextTick=Ye,e.observable=function(e){return Ce(e),e},e.options=Object.create(null),M.forEach(function(t){e.options[t+"s"]=Object.create(null)}),e.options._base=e,A(e.options.components,Tn),function(e){e.use=function(e){var t=this._installedPlugins||(this._installedPlugins=[]);if(t.indexOf(e)>-1)return this;var n=k(arguments,1);return n.unshift(this),"function"==typeof e.install?e.install.apply(e,n):"function"==typeof e&&e.apply(null,n),t.push(e),this}}(e),function(e){e.mixin=function(e){return this.options=De(this.options,e),this}}(e),Cn(e),function(e){M.forEach(function(t){e[t]=function(e,n){return n?("component"===t&&s(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&"function"==typeof n&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}})}(e)}(wn),Object.defineProperty(wn.prototype,"$isServer",{get:te}),Object.defineProperty(wn.prototype,"$ssrContext",{get:function(){return this.$vnode&&this.$vnode.ssrContext}}),Object.defineProperty(wn,"FunctionalRenderContext",{value:Tt}),wn.version="2.6.10";var En=p("style,class"),Nn=p("input,textarea,option,select,progress"),jn=function(e,t,n){return"value"===n&&Nn(e)&&"button"!==t||"selected"===n&&"option"===e||"checked"===n&&"input"===e||"muted"===n&&"video"===e},Dn=p("contenteditable,draggable,spellcheck"),Ln=p("events,caret,typing,plaintext-only"),Mn=function(e,t){return Hn(t)||"false"===t?"false":"contenteditable"===e&&Ln(t)?t:"true"},In=p("allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,defaultchecked,defaultmuted,defaultselected,defer,disabled,enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,required,reversed,scoped,seamless,selected,sortable,translate,truespeed,typemustmatch,visible"),Fn="http://www.w3.org/1999/xlink",Pn=function(e){return":"===e.charAt(5)&&"xlink"===e.slice(0,5)},Rn=function(e){return Pn(e)?e.slice(6,e.length):""},Hn=function(e){return null==e||!1===e};function Bn(e){for(var t=e.data,r=e,i=e;n(i.componentInstance);)(i=i.componentInstance._vnode)&&i.data&&(t=Un(i.data,t));for(;n(r=r.parent);)r&&r.data&&(t=Un(t,r.data));return function(e,t){if(n(e)||n(t))return zn(e,Vn(t));return""}(t.staticClass,t.class)}function Un(e,t){return{staticClass:zn(e.staticClass,t.staticClass),class:n(e.class)?[e.class,t.class]:t.class}}function zn(e,t){return e?t?e+" "+t:e:t||""}function Vn(e){return Array.isArray(e)?function(e){for(var t,r="",i=0,o=e.length;i-1?hr(e,t,n):In(t)?Hn(n)?e.removeAttribute(t):(n="allowfullscreen"===t&&"EMBED"===e.tagName?"true":t,e.setAttribute(t,n)):Dn(t)?e.setAttribute(t,Mn(t,n)):Pn(t)?Hn(n)?e.removeAttributeNS(Fn,Rn(t)):e.setAttributeNS(Fn,t,n):hr(e,t,n)}function hr(e,t,n){if(Hn(n))e.removeAttribute(t);else{if(q&&!W&&"TEXTAREA"===e.tagName&&"placeholder"===t&&""!==n&&!e.__ieph){var r=function(t){t.stopImmediatePropagation(),e.removeEventListener("input",r)};e.addEventListener("input",r),e.__ieph=!0}e.setAttribute(t,n)}}var mr={create:dr,update:dr};function yr(e,r){var i=r.elm,o=r.data,a=e.data;if(!(t(o.staticClass)&&t(o.class)&&(t(a)||t(a.staticClass)&&t(a.class)))){var s=Bn(r),c=i._transitionClasses;n(c)&&(s=zn(s,Vn(c))),s!==i._prevClass&&(i.setAttribute("class",s),i._prevClass=s)}}var gr,_r,br,$r,wr,Cr,xr={create:yr,update:yr},kr=/[\w).+\-_$\]]/;function Ar(e){var t,n,r,i,o,a=!1,s=!1,c=!1,u=!1,l=0,f=0,p=0,d=0;for(r=0;r=0&&" "===(h=e.charAt(v));v--);h&&kr.test(h)||(u=!0)}}else void 0===i?(d=r+1,i=e.slice(0,r).trim()):m();function m(){(o||(o=[])).push(e.slice(d,r).trim()),d=r+1}if(void 0===i?i=e.slice(0,r).trim():0!==d&&m(),o)for(r=0;r-1?{exp:e.slice(0,$r),key:'"'+e.slice($r+1)+'"'}:{exp:e,key:null};_r=e,$r=wr=Cr=0;for(;!zr();)Vr(br=Ur())?Jr(br):91===br&&Kr(br);return{exp:e.slice(0,wr),key:e.slice(wr+1,Cr)}}(e);return null===n.key?e+"="+t:"$set("+n.exp+", "+n.key+", "+t+")"}function Ur(){return _r.charCodeAt(++$r)}function zr(){return $r>=gr}function Vr(e){return 34===e||39===e}function Kr(e){var t=1;for(wr=$r;!zr();)if(Vr(e=Ur()))Jr(e);else if(91===e&&t++,93===e&&t--,0===t){Cr=$r;break}}function Jr(e){for(var t=e;!zr()&&(e=Ur())!==t;);}var qr,Wr="__r",Zr="__c";function Gr(e,t,n){var r=qr;return function i(){null!==t.apply(null,arguments)&&Qr(e,i,n,r)}}var Xr=Ve&&!(X&&Number(X[1])<=53);function Yr(e,t,n,r){if(Xr){var i=an,o=t;t=o._wrapper=function(e){if(e.target===e.currentTarget||e.timeStamp>=i||e.timeStamp<=0||e.target.ownerDocument!==document)return o.apply(this,arguments)}}qr.addEventListener(e,t,Q?{capture:n,passive:r}:n)}function Qr(e,t,n,r){(r||qr).removeEventListener(e,t._wrapper||t,n)}function ei(e,r){if(!t(e.data.on)||!t(r.data.on)){var i=r.data.on||{},o=e.data.on||{};qr=r.elm,function(e){if(n(e[Wr])){var t=q?"change":"input";e[t]=[].concat(e[Wr],e[t]||[]),delete e[Wr]}n(e[Zr])&&(e.change=[].concat(e[Zr],e.change||[]),delete e[Zr])}(i),rt(i,o,Yr,Qr,Gr,r.context),qr=void 0}}var ti,ni={create:ei,update:ei};function ri(e,r){if(!t(e.data.domProps)||!t(r.data.domProps)){var i,o,a=r.elm,s=e.data.domProps||{},c=r.data.domProps||{};for(i in n(c.__ob__)&&(c=r.data.domProps=A({},c)),s)i in c||(a[i]="");for(i in c){if(o=c[i],"textContent"===i||"innerHTML"===i){if(r.children&&(r.children.length=0),o===s[i])continue;1===a.childNodes.length&&a.removeChild(a.childNodes[0])}if("value"===i&&"PROGRESS"!==a.tagName){a._value=o;var u=t(o)?"":String(o);ii(a,u)&&(a.value=u)}else if("innerHTML"===i&&qn(a.tagName)&&t(a.innerHTML)){(ti=ti||document.createElement("div")).innerHTML=""+o+"";for(var l=ti.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}else if(o!==s[i])try{a[i]=o}catch(e){}}}}function ii(e,t){return!e.composing&&("OPTION"===e.tagName||function(e,t){var n=!0;try{n=document.activeElement!==e}catch(e){}return n&&e.value!==t}(e,t)||function(e,t){var r=e.value,i=e._vModifiers;if(n(i)){if(i.number)return f(r)!==f(t);if(i.trim)return r.trim()!==t.trim()}return r!==t}(e,t))}var oi={create:ri,update:ri},ai=g(function(e){var t={},n=/:(.+)/;return e.split(/;(?![^(]*\))/g).forEach(function(e){if(e){var r=e.split(n);r.length>1&&(t[r[0].trim()]=r[1].trim())}}),t});function si(e){var t=ci(e.style);return e.staticStyle?A(e.staticStyle,t):t}function ci(e){return Array.isArray(e)?O(e):"string"==typeof e?ai(e):e}var ui,li=/^--/,fi=/\s*!important$/,pi=function(e,t,n){if(li.test(t))e.style.setProperty(t,n);else if(fi.test(n))e.style.setProperty(C(t),n.replace(fi,""),"important");else{var r=vi(t);if(Array.isArray(n))for(var i=0,o=n.length;i-1?t.split(yi).forEach(function(t){return e.classList.add(t)}):e.classList.add(t);else{var n=" "+(e.getAttribute("class")||"")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function _i(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(yi).forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t),e.classList.length||e.removeAttribute("class");else{for(var n=" "+(e.getAttribute("class")||"")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");(n=n.trim())?e.setAttribute("class",n):e.removeAttribute("class")}}function bi(e){if(e){if("object"==typeof e){var t={};return!1!==e.css&&A(t,$i(e.name||"v")),A(t,e),t}return"string"==typeof e?$i(e):void 0}}var $i=g(function(e){return{enterClass:e+"-enter",enterToClass:e+"-enter-to",enterActiveClass:e+"-enter-active",leaveClass:e+"-leave",leaveToClass:e+"-leave-to",leaveActiveClass:e+"-leave-active"}}),wi=z&&!W,Ci="transition",xi="animation",ki="transition",Ai="transitionend",Oi="animation",Si="animationend";wi&&(void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(ki="WebkitTransition",Ai="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(Oi="WebkitAnimation",Si="webkitAnimationEnd"));var Ti=z?window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout:function(e){return e()};function Ei(e){Ti(function(){Ti(e)})}function Ni(e,t){var n=e._transitionClasses||(e._transitionClasses=[]);n.indexOf(t)<0&&(n.push(t),gi(e,t))}function ji(e,t){e._transitionClasses&&h(e._transitionClasses,t),_i(e,t)}function Di(e,t,n){var r=Mi(e,t),i=r.type,o=r.timeout,a=r.propCount;if(!i)return n();var s=i===Ci?Ai:Si,c=0,u=function(){e.removeEventListener(s,l),n()},l=function(t){t.target===e&&++c>=a&&u()};setTimeout(function(){c0&&(n=Ci,l=a,f=o.length):t===xi?u>0&&(n=xi,l=u,f=c.length):f=(n=(l=Math.max(a,u))>0?a>u?Ci:xi:null)?n===Ci?o.length:c.length:0,{type:n,timeout:l,propCount:f,hasTransform:n===Ci&&Li.test(r[ki+"Property"])}}function Ii(e,t){for(;e.length1}function Ui(e,t){!0!==t.data.show&&Pi(t)}var zi=function(e){var o,a,s={},c=e.modules,u=e.nodeOps;for(o=0;ov?_(e,t(i[y+1])?null:i[y+1].elm,i,d,y,o):d>y&&$(0,r,p,v)}(p,h,y,o,l):n(y)?(n(e.text)&&u.setTextContent(p,""),_(p,null,y,0,y.length-1,o)):n(h)?$(0,h,0,h.length-1):n(e.text)&&u.setTextContent(p,""):e.text!==i.text&&u.setTextContent(p,i.text),n(v)&&n(d=v.hook)&&n(d=d.postpatch)&&d(e,i)}}}function k(e,t,i){if(r(i)&&n(e.parent))e.parent.data.pendingInsert=t;else for(var o=0;o-1,a.selected!==o&&(a.selected=o);else if(N(Wi(a),r))return void(e.selectedIndex!==s&&(e.selectedIndex=s));i||(e.selectedIndex=-1)}}function qi(e,t){return t.every(function(t){return!N(t,e)})}function Wi(e){return"_value"in e?e._value:e.value}function Zi(e){e.target.composing=!0}function Gi(e){e.target.composing&&(e.target.composing=!1,Xi(e.target,"input"))}function Xi(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}function Yi(e){return!e.componentInstance||e.data&&e.data.transition?e:Yi(e.componentInstance._vnode)}var Qi={model:Vi,show:{bind:function(e,t,n){var r=t.value,i=(n=Yi(n)).data&&n.data.transition,o=e.__vOriginalDisplay="none"===e.style.display?"":e.style.display;r&&i?(n.data.show=!0,Pi(n,function(){e.style.display=o})):e.style.display=r?o:"none"},update:function(e,t,n){var r=t.value;!r!=!t.oldValue&&((n=Yi(n)).data&&n.data.transition?(n.data.show=!0,r?Pi(n,function(){e.style.display=e.__vOriginalDisplay}):Ri(n,function(){e.style.display="none"})):e.style.display=r?e.__vOriginalDisplay:"none")},unbind:function(e,t,n,r,i){i||(e.style.display=e.__vOriginalDisplay)}}},eo={name:String,appear:Boolean,css:Boolean,mode:String,type:String,enterClass:String,leaveClass:String,enterToClass:String,leaveToClass:String,enterActiveClass:String,leaveActiveClass:String,appearClass:String,appearActiveClass:String,appearToClass:String,duration:[Number,String,Object]};function to(e){var t=e&&e.componentOptions;return t&&t.Ctor.options.abstract?to(zt(t.children)):e}function no(e){var t={},n=e.$options;for(var r in n.propsData)t[r]=e[r];var i=n._parentListeners;for(var o in i)t[b(o)]=i[o];return t}function ro(e,t){if(/\d-keep-alive$/.test(t.tag))return e("keep-alive",{props:t.componentOptions.propsData})}var io=function(e){return e.tag||Ut(e)},oo=function(e){return"show"===e.name},ao={name:"transition",props:eo,abstract:!0,render:function(e){var t=this,n=this.$slots.default;if(n&&(n=n.filter(io)).length){var r=this.mode,o=n[0];if(function(e){for(;e=e.parent;)if(e.data.transition)return!0}(this.$vnode))return o;var a=to(o);if(!a)return o;if(this._leaving)return ro(e,o);var s="__transition-"+this._uid+"-";a.key=null==a.key?a.isComment?s+"comment":s+a.tag:i(a.key)?0===String(a.key).indexOf(s)?a.key:s+a.key:a.key;var c=(a.data||(a.data={})).transition=no(this),u=this._vnode,l=to(u);if(a.data.directives&&a.data.directives.some(oo)&&(a.data.show=!0),l&&l.data&&!function(e,t){return t.key===e.key&&t.tag===e.tag}(a,l)&&!Ut(l)&&(!l.componentInstance||!l.componentInstance._vnode.isComment)){var f=l.data.transition=A({},c);if("out-in"===r)return this._leaving=!0,it(f,"afterLeave",function(){t._leaving=!1,t.$forceUpdate()}),ro(e,o);if("in-out"===r){if(Ut(a))return u;var p,d=function(){p()};it(c,"afterEnter",d),it(c,"enterCancelled",d),it(f,"delayLeave",function(e){p=e})}}return o}}},so=A({tag:String,moveClass:String},eo);function co(e){e.elm._moveCb&&e.elm._moveCb(),e.elm._enterCb&&e.elm._enterCb()}function uo(e){e.data.newPos=e.elm.getBoundingClientRect()}function lo(e){var t=e.data.pos,n=e.data.newPos,r=t.left-n.left,i=t.top-n.top;if(r||i){e.data.moved=!0;var o=e.elm.style;o.transform=o.WebkitTransform="translate("+r+"px,"+i+"px)",o.transitionDuration="0s"}}delete so.mode;var fo={Transition:ao,TransitionGroup:{props:so,beforeMount:function(){var e=this,t=this._update;this._update=function(n,r){var i=Zt(e);e.__patch__(e._vnode,e.kept,!1,!0),e._vnode=e.kept,i(),t.call(e,n,r)}},render:function(e){for(var t=this.tag||this.$vnode.data.tag||"span",n=Object.create(null),r=this.prevChildren=this.children,i=this.$slots.default||[],o=this.children=[],a=no(this),s=0;s-1?Gn[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:Gn[e]=/HTMLUnknownElement/.test(t.toString())},A(wn.options.directives,Qi),A(wn.options.components,fo),wn.prototype.__patch__=z?zi:S,wn.prototype.$mount=function(e,t){return function(e,t,n){var r;return e.$el=t,e.$options.render||(e.$options.render=ve),Yt(e,"beforeMount"),r=function(){e._update(e._render(),n)},new fn(e,r,S,{before:function(){e._isMounted&&!e._isDestroyed&&Yt(e,"beforeUpdate")}},!0),n=!1,null==e.$vnode&&(e._isMounted=!0,Yt(e,"mounted")),e}(this,e=e&&z?Yn(e):void 0,t)},z&&setTimeout(function(){F.devtools&&ne&&ne.emit("init",wn)},0);var po=/\{\{((?:.|\r?\n)+?)\}\}/g,vo=/[-.*+?^${}()|[\]\/\\]/g,ho=g(function(e){var t=e[0].replace(vo,"\\$&"),n=e[1].replace(vo,"\\$&");return new RegExp(t+"((?:.|\\n)+?)"+n,"g")});var mo={staticKeys:["staticClass"],transformNode:function(e,t){t.warn;var n=Fr(e,"class");n&&(e.staticClass=JSON.stringify(n));var r=Ir(e,"class",!1);r&&(e.classBinding=r)},genData:function(e){var t="";return e.staticClass&&(t+="staticClass:"+e.staticClass+","),e.classBinding&&(t+="class:"+e.classBinding+","),t}};var yo,go={staticKeys:["staticStyle"],transformNode:function(e,t){t.warn;var n=Fr(e,"style");n&&(e.staticStyle=JSON.stringify(ai(n)));var r=Ir(e,"style",!1);r&&(e.styleBinding=r)},genData:function(e){var t="";return e.staticStyle&&(t+="staticStyle:"+e.staticStyle+","),e.styleBinding&&(t+="style:("+e.styleBinding+"),"),t}},_o=function(e){return(yo=yo||document.createElement("div")).innerHTML=e,yo.textContent},bo=p("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),$o=p("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),wo=p("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),Co=/^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,xo=/^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,ko="[a-zA-Z_][\\-\\.0-9_a-zA-Z"+P.source+"]*",Ao="((?:"+ko+"\\:)?"+ko+")",Oo=new RegExp("^<"+Ao),So=/^\s*(\/?)>/,To=new RegExp("^<\\/"+Ao+"[^>]*>"),Eo=/^]+>/i,No=/^",""":'"',"&":"&"," ":"\n"," ":"\t","'":"'"},Io=/&(?:lt|gt|quot|amp|#39);/g,Fo=/&(?:lt|gt|quot|amp|#39|#10|#9);/g,Po=p("pre,textarea",!0),Ro=function(e,t){return e&&Po(e)&&"\n"===t[0]};function Ho(e,t){var n=t?Fo:Io;return e.replace(n,function(e){return Mo[e]})}var Bo,Uo,zo,Vo,Ko,Jo,qo,Wo,Zo=/^@|^v-on:/,Go=/^v-|^@|^:/,Xo=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,Yo=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Qo=/^\(|\)$/g,ea=/^\[.*\]$/,ta=/:(.*)$/,na=/^:|^\.|^v-bind:/,ra=/\.[^.\]]+(?=[^\]]*$)/g,ia=/^v-slot(:|$)|^#/,oa=/[\r\n]/,aa=/\s+/g,sa=g(_o),ca="_empty_";function ua(e,t,n){return{type:1,tag:e,attrsList:t,attrsMap:ma(t),rawAttrsMap:{},parent:n,children:[]}}function la(e,t){Bo=t.warn||Sr,Jo=t.isPreTag||T,qo=t.mustUseProp||T,Wo=t.getTagNamespace||T;t.isReservedTag;zo=Tr(t.modules,"transformNode"),Vo=Tr(t.modules,"preTransformNode"),Ko=Tr(t.modules,"postTransformNode"),Uo=t.delimiters;var n,r,i=[],o=!1!==t.preserveWhitespace,a=t.whitespace,s=!1,c=!1;function u(e){if(l(e),s||e.processed||(e=fa(e,t)),i.length||e===n||n.if&&(e.elseif||e.else)&&da(n,{exp:e.elseif,block:e}),r&&!e.forbidden)if(e.elseif||e.else)a=e,(u=function(e){var t=e.length;for(;t--;){if(1===e[t].type)return e[t];e.pop()}}(r.children))&&u.if&&da(u,{exp:a.elseif,block:a});else{if(e.slotScope){var o=e.slotTarget||'"default"';(r.scopedSlots||(r.scopedSlots={}))[o]=e}r.children.push(e),e.parent=r}var a,u;e.children=e.children.filter(function(e){return!e.slotScope}),l(e),e.pre&&(s=!1),Jo(e.tag)&&(c=!1);for(var f=0;f]*>)","i")),p=e.replace(f,function(e,n,r){return u=r.length,Do(l)||"noscript"===l||(n=n.replace(//g,"$1").replace(//g,"$1")),Ro(l,n)&&(n=n.slice(1)),t.chars&&t.chars(n),""});c+=e.length-p.length,e=p,A(l,c-u,c)}else{var d=e.indexOf("<");if(0===d){if(No.test(e)){var v=e.indexOf("--\x3e");if(v>=0){t.shouldKeepComment&&t.comment(e.substring(4,v),c,c+v+3),C(v+3);continue}}if(jo.test(e)){var h=e.indexOf("]>");if(h>=0){C(h+2);continue}}var m=e.match(Eo);if(m){C(m[0].length);continue}var y=e.match(To);if(y){var g=c;C(y[0].length),A(y[1],g,c);continue}var _=x();if(_){k(_),Ro(_.tagName,e)&&C(1);continue}}var b=void 0,$=void 0,w=void 0;if(d>=0){for($=e.slice(d);!(To.test($)||Oo.test($)||No.test($)||jo.test($)||(w=$.indexOf("<",1))<0);)d+=w,$=e.slice(d);b=e.substring(0,d)}d<0&&(b=e),b&&C(b.length),t.chars&&b&&t.chars(b,c-b.length,c)}if(e===n){t.chars&&t.chars(e);break}}function C(t){c+=t,e=e.substring(t)}function x(){var t=e.match(Oo);if(t){var n,r,i={tagName:t[1],attrs:[],start:c};for(C(t[0].length);!(n=e.match(So))&&(r=e.match(xo)||e.match(Co));)r.start=c,C(r[0].length),r.end=c,i.attrs.push(r);if(n)return i.unarySlash=n[1],C(n[0].length),i.end=c,i}}function k(e){var n=e.tagName,c=e.unarySlash;o&&("p"===r&&wo(n)&&A(r),s(n)&&r===n&&A(n));for(var u=a(n)||!!c,l=e.attrs.length,f=new Array(l),p=0;p=0&&i[a].lowerCasedTag!==s;a--);else a=0;if(a>=0){for(var u=i.length-1;u>=a;u--)t.end&&t.end(i[u].tag,n,o);i.length=a,r=a&&i[a-1].tag}else"br"===s?t.start&&t.start(e,[],!0,n,o):"p"===s&&(t.start&&t.start(e,[],!1,n,o),t.end&&t.end(e,n,o))}A()}(e,{warn:Bo,expectHTML:t.expectHTML,isUnaryTag:t.isUnaryTag,canBeLeftOpenTag:t.canBeLeftOpenTag,shouldDecodeNewlines:t.shouldDecodeNewlines,shouldDecodeNewlinesForHref:t.shouldDecodeNewlinesForHref,shouldKeepComment:t.comments,outputSourceRange:t.outputSourceRange,start:function(e,o,a,l,f){var p=r&&r.ns||Wo(e);q&&"svg"===p&&(o=function(e){for(var t=[],n=0;nc&&(s.push(o=e.slice(c,i)),a.push(JSON.stringify(o)));var u=Ar(r[1].trim());a.push("_s("+u+")"),s.push({"@binding":u}),c=i+r[0].length}return c-1"+("true"===o?":("+t+")":":_q("+t+","+o+")")),Mr(e,"change","var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+o+"):("+a+");if(Array.isArray($$a)){var $$v="+(r?"_n("+i+")":i)+",$$i=_i($$a,$$v);if($$el.checked){$$i<0&&("+Br(t,"$$a.concat([$$v])")+")}else{$$i>-1&&("+Br(t,"$$a.slice(0,$$i).concat($$a.slice($$i+1))")+")}}else{"+Br(t,"$$c")+"}",null,!0)}(e,r,i);else if("input"===o&&"radio"===a)!function(e,t,n){var r=n&&n.number,i=Ir(e,"value")||"null";Er(e,"checked","_q("+t+","+(i=r?"_n("+i+")":i)+")"),Mr(e,"change",Br(t,i),null,!0)}(e,r,i);else if("input"===o||"textarea"===o)!function(e,t,n){var r=e.attrsMap.type,i=n||{},o=i.lazy,a=i.number,s=i.trim,c=!o&&"range"!==r,u=o?"change":"range"===r?Wr:"input",l="$event.target.value";s&&(l="$event.target.value.trim()"),a&&(l="_n("+l+")");var f=Br(t,l);c&&(f="if($event.target.composing)return;"+f),Er(e,"value","("+t+")"),Mr(e,u,f,null,!0),(s||a)&&Mr(e,"blur","$forceUpdate()")}(e,r,i);else if(!F.isReservedTag(o))return Hr(e,r,i),!1;return!0},text:function(e,t){t.value&&Er(e,"textContent","_s("+t.value+")",t)},html:function(e,t){t.value&&Er(e,"innerHTML","_s("+t.value+")",t)}},isPreTag:function(e){return"pre"===e},isUnaryTag:bo,mustUseProp:jn,canBeLeftOpenTag:$o,isReservedTag:Wn,getTagNamespace:Zn,staticKeys:function(e){return e.reduce(function(e,t){return e.concat(t.staticKeys||[])},[]).join(",")}(ba)},xa=g(function(e){return p("type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap"+(e?","+e:""))});function ka(e,t){e&&($a=xa(t.staticKeys||""),wa=t.isReservedTag||T,function e(t){t.static=function(e){if(2===e.type)return!1;if(3===e.type)return!0;return!(!e.pre&&(e.hasBindings||e.if||e.for||d(e.tag)||!wa(e.tag)||function(e){for(;e.parent;){if("template"!==(e=e.parent).tag)return!1;if(e.for)return!0}return!1}(e)||!Object.keys(e).every($a)))}(t);if(1===t.type){if(!wa(t.tag)&&"slot"!==t.tag&&null==t.attrsMap["inline-template"])return;for(var n=0,r=t.children.length;n|^function\s*(?:[\w$]+)?\s*\(/,Oa=/\([^)]*?\);*$/,Sa=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/,Ta={esc:27,tab:9,enter:13,space:32,up:38,left:37,right:39,down:40,delete:[8,46]},Ea={esc:["Esc","Escape"],tab:"Tab",enter:"Enter",space:[" ","Spacebar"],up:["Up","ArrowUp"],left:["Left","ArrowLeft"],right:["Right","ArrowRight"],down:["Down","ArrowDown"],delete:["Backspace","Delete","Del"]},Na=function(e){return"if("+e+")return null;"},ja={stop:"$event.stopPropagation();",prevent:"$event.preventDefault();",self:Na("$event.target !== $event.currentTarget"),ctrl:Na("!$event.ctrlKey"),shift:Na("!$event.shiftKey"),alt:Na("!$event.altKey"),meta:Na("!$event.metaKey"),left:Na("'button' in $event && $event.button !== 0"),middle:Na("'button' in $event && $event.button !== 1"),right:Na("'button' in $event && $event.button !== 2")};function Da(e,t){var n=t?"nativeOn:":"on:",r="",i="";for(var o in e){var a=La(e[o]);e[o]&&e[o].dynamic?i+=o+","+a+",":r+='"'+o+'":'+a+","}return r="{"+r.slice(0,-1)+"}",i?n+"_d("+r+",["+i.slice(0,-1)+"])":n+r}function La(e){if(!e)return"function(){}";if(Array.isArray(e))return"["+e.map(function(e){return La(e)}).join(",")+"]";var t=Sa.test(e.value),n=Aa.test(e.value),r=Sa.test(e.value.replace(Oa,""));if(e.modifiers){var i="",o="",a=[];for(var s in e.modifiers)if(ja[s])o+=ja[s],Ta[s]&&a.push(s);else if("exact"===s){var c=e.modifiers;o+=Na(["ctrl","shift","alt","meta"].filter(function(e){return!c[e]}).map(function(e){return"$event."+e+"Key"}).join("||"))}else a.push(s);return a.length&&(i+=function(e){return"if(!$event.type.indexOf('key')&&"+e.map(Ma).join("&&")+")return null;"}(a)),o&&(i+=o),"function($event){"+i+(t?"return "+e.value+"($event)":n?"return ("+e.value+")($event)":r?"return "+e.value:e.value)+"}"}return t||n?e.value:"function($event){"+(r?"return "+e.value:e.value)+"}"}function Ma(e){var t=parseInt(e,10);if(t)return"$event.keyCode!=="+t;var n=Ta[e],r=Ea[e];return"_k($event.keyCode,"+JSON.stringify(e)+","+JSON.stringify(n)+",$event.key,"+JSON.stringify(r)+")"}var Ia={on:function(e,t){e.wrapListeners=function(e){return"_g("+e+","+t.value+")"}},bind:function(e,t){e.wrapData=function(n){return"_b("+n+",'"+e.tag+"',"+t.value+","+(t.modifiers&&t.modifiers.prop?"true":"false")+(t.modifiers&&t.modifiers.sync?",true":"")+")"}},cloak:S},Fa=function(e){this.options=e,this.warn=e.warn||Sr,this.transforms=Tr(e.modules,"transformCode"),this.dataGenFns=Tr(e.modules,"genData"),this.directives=A(A({},Ia),e.directives);var t=e.isReservedTag||T;this.maybeComponent=function(e){return!!e.component||!t(e.tag)},this.onceId=0,this.staticRenderFns=[],this.pre=!1};function Pa(e,t){var n=new Fa(t);return{render:"with(this){return "+(e?Ra(e,n):'_c("div")')+"}",staticRenderFns:n.staticRenderFns}}function Ra(e,t){if(e.parent&&(e.pre=e.pre||e.parent.pre),e.staticRoot&&!e.staticProcessed)return Ha(e,t);if(e.once&&!e.onceProcessed)return Ba(e,t);if(e.for&&!e.forProcessed)return za(e,t);if(e.if&&!e.ifProcessed)return Ua(e,t);if("template"!==e.tag||e.slotTarget||t.pre){if("slot"===e.tag)return function(e,t){var n=e.slotName||'"default"',r=qa(e,t),i="_t("+n+(r?","+r:""),o=e.attrs||e.dynamicAttrs?Ga((e.attrs||[]).concat(e.dynamicAttrs||[]).map(function(e){return{name:b(e.name),value:e.value,dynamic:e.dynamic}})):null,a=e.attrsMap["v-bind"];!o&&!a||r||(i+=",null");o&&(i+=","+o);a&&(i+=(o?"":",null")+","+a);return i+")"}(e,t);var n;if(e.component)n=function(e,t,n){var r=t.inlineTemplate?null:qa(t,n,!0);return"_c("+e+","+Va(t,n)+(r?","+r:"")+")"}(e.component,e,t);else{var r;(!e.plain||e.pre&&t.maybeComponent(e))&&(r=Va(e,t));var i=e.inlineTemplate?null:qa(e,t,!0);n="_c('"+e.tag+"'"+(r?","+r:"")+(i?","+i:"")+")"}for(var o=0;o>>0}(a):"")+")"}(e,e.scopedSlots,t)+","),e.model&&(n+="model:{value:"+e.model.value+",callback:"+e.model.callback+",expression:"+e.model.expression+"},"),e.inlineTemplate){var o=function(e,t){var n=e.children[0];if(n&&1===n.type){var r=Pa(n,t.options);return"inlineTemplate:{render:function(){"+r.render+"},staticRenderFns:["+r.staticRenderFns.map(function(e){return"function(){"+e+"}"}).join(",")+"]}"}}(e,t);o&&(n+=o+",")}return n=n.replace(/,$/,"")+"}",e.dynamicAttrs&&(n="_b("+n+',"'+e.tag+'",'+Ga(e.dynamicAttrs)+")"),e.wrapData&&(n=e.wrapData(n)),e.wrapListeners&&(n=e.wrapListeners(n)),n}function Ka(e){return 1===e.type&&("slot"===e.tag||e.children.some(Ka))}function Ja(e,t){var n=e.attrsMap["slot-scope"];if(e.if&&!e.ifProcessed&&!n)return Ua(e,t,Ja,"null");if(e.for&&!e.forProcessed)return za(e,t,Ja);var r=e.slotScope===ca?"":String(e.slotScope),i="function("+r+"){return "+("template"===e.tag?e.if&&n?"("+e.if+")?"+(qa(e,t)||"undefined")+":undefined":qa(e,t)||"undefined":Ra(e,t))+"}",o=r?"":",proxy:true";return"{key:"+(e.slotTarget||'"default"')+",fn:"+i+o+"}"}function qa(e,t,n,r,i){var o=e.children;if(o.length){var a=o[0];if(1===o.length&&a.for&&"template"!==a.tag&&"slot"!==a.tag){var s=n?t.maybeComponent(a)?",1":",0":"";return""+(r||Ra)(a,t)+s}var c=n?function(e,t){for(var n=0,r=0;r':'
',ts.innerHTML.indexOf(" ")>0}var os=!!z&&is(!1),as=!!z&&is(!0),ss=g(function(e){var t=Yn(e);return t&&t.innerHTML}),cs=wn.prototype.$mount;return wn.prototype.$mount=function(e,t){if((e=e&&Yn(e))===document.body||e===document.documentElement)return this;var n=this.$options;if(!n.render){var r=n.template;if(r)if("string"==typeof r)"#"===r.charAt(0)&&(r=ss(r));else{if(!r.nodeType)return this;r=r.innerHTML}else e&&(r=function(e){if(e.outerHTML)return e.outerHTML;var t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}(e));if(r){var i=rs(r,{outputSourceRange:!1,shouldDecodeNewlines:os,shouldDecodeNewlinesForHref:as,delimiters:n.delimiters,comments:n.comments},this),o=i.render,a=i.staticRenderFns;n.render=o,n.staticRenderFns=a}}return cs.call(this,e,t)},wn.compile=rs,wn}); -------------------------------------------------------------------------------- /examples/htdocs/calc.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: sans-serif; 3 | background: #ededed; 4 | } 5 | .line { 6 | width: 90%; 7 | height: 4rem; 8 | font-size: 3rem; 9 | text-align: right; 10 | text-overflow: ellipsis; 11 | } 12 | table { 13 | width: 100%; 14 | } 15 | button { 16 | background: none; 17 | border: none; 18 | overflow: hidden; 19 | margin: 1px; 20 | height: 3rem; 21 | font-size: 1.5rem; 22 | } 23 | table button { 24 | background: #fbfbfb; 25 | width: 100%; 26 | } 27 | table button.input { 28 | background: #f3f3f3; 29 | } 30 | table button:hover, button:hover { 31 | background: #c0c0c0; 32 | } 33 | button:active { 34 | transform: scale(0.9); 35 | } 36 | -------------------------------------------------------------------------------- /examples/htdocs/calc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Calc 6 | 7 | 8 | 9 |
10 |
11 | {{ value }} 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
53 |
54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /examples/htdocs/calc.js: -------------------------------------------------------------------------------- 1 | var calc = new Vue({ 2 | el: '#calc', 3 | data: { 4 | value: '0' 5 | }, 6 | methods: { 7 | clearLine: function() { 8 | this.value = '0'; 9 | }, 10 | append: function(value) { 11 | if (this.value == '0') { 12 | this.value = value; 13 | } else { 14 | this.value += value; 15 | } 16 | }, 17 | backspace: function() { 18 | if (this.value.length > 1) { 19 | this.value = this.value.substring(0, this.value.length - 1); 20 | } else { 21 | this.value = '0'; 22 | } 23 | }, 24 | calculate: function() { 25 | var calc = this; 26 | window.external.invoke("eval:print('calculate', '" + calc.value + "'); callBrowser('result', " + calc.value + ")") 27 | } 28 | } 29 | }); 30 | 31 | function result(value) { 32 | calc.value = '' + value; 33 | }; 34 | -------------------------------------------------------------------------------- /examples/htdocs/itworks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

It works !

8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/htdocs/simple.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

It works !

8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 37 | 38 | -------------------------------------------------------------------------------- /examples/htdocs/todo.css: -------------------------------------------------------------------------------- 1 | /* See https://github.com/tastejs/todomvc/tree/gh-pages/examples/vue */ 2 | 3 | html, 4 | body { 5 | margin: 0; 6 | padding: 0; 7 | } 8 | 9 | button { 10 | margin: 0; 11 | padding: 0; 12 | border: 0; 13 | background: none; 14 | font-size: 100%; 15 | vertical-align: baseline; 16 | font-family: inherit; 17 | font-weight: inherit; 18 | color: inherit; 19 | -webkit-appearance: none; 20 | appearance: none; 21 | -webkit-font-smoothing: antialiased; 22 | -moz-osx-font-smoothing: grayscale; 23 | } 24 | 25 | body { 26 | font: 14px 'Helvetica Neue', Helvetica, Arial, sans-serif; 27 | line-height: 1.4em; 28 | background: #f5f5f5; 29 | color: #4d4d4d; 30 | min-width: 230px; 31 | max-width: 550px; 32 | margin: 0 auto; 33 | -webkit-font-smoothing: antialiased; 34 | -moz-osx-font-smoothing: grayscale; 35 | font-weight: 300; 36 | } 37 | 38 | :focus { 39 | outline: 0; 40 | } 41 | 42 | .hidden { 43 | display: none; 44 | } 45 | 46 | .todoapp { 47 | background: #fff; 48 | margin: 130px 0 40px 0; 49 | position: relative; 50 | box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 51 | 0 25px 50px 0 rgba(0, 0, 0, 0.1); 52 | } 53 | 54 | .todoapp input::-webkit-input-placeholder { 55 | font-style: italic; 56 | font-weight: 300; 57 | color: #e6e6e6; 58 | } 59 | 60 | .todoapp input::-moz-placeholder { 61 | font-style: italic; 62 | font-weight: 300; 63 | color: #e6e6e6; 64 | } 65 | 66 | .todoapp input::input-placeholder { 67 | font-style: italic; 68 | font-weight: 300; 69 | color: #e6e6e6; 70 | } 71 | 72 | .todoapp h1 { 73 | position: absolute; 74 | top: -155px; 75 | width: 100%; 76 | font-size: 100px; 77 | font-weight: 100; 78 | text-align: center; 79 | color: rgba(175, 47, 47, 0.15); 80 | -webkit-text-rendering: optimizeLegibility; 81 | -moz-text-rendering: optimizeLegibility; 82 | text-rendering: optimizeLegibility; 83 | } 84 | 85 | .new-todo, 86 | .edit { 87 | position: relative; 88 | margin: 0; 89 | width: 100%; 90 | font-size: 24px; 91 | font-family: inherit; 92 | font-weight: inherit; 93 | line-height: 1.4em; 94 | border: 0; 95 | color: inherit; 96 | padding: 6px; 97 | border: 1px solid #999; 98 | box-shadow: inset 0 -1px 5px 0 rgba(0, 0, 0, 0.2); 99 | box-sizing: border-box; 100 | -webkit-font-smoothing: antialiased; 101 | -moz-osx-font-smoothing: grayscale; 102 | } 103 | 104 | .new-todo { 105 | padding: 16px 16px 16px 60px; 106 | border: none; 107 | background: rgba(0, 0, 0, 0.003); 108 | box-shadow: inset 0 -2px 1px rgba(0,0,0,0.03); 109 | } 110 | 111 | .main { 112 | position: relative; 113 | z-index: 2; 114 | border-top: 1px solid #e6e6e6; 115 | } 116 | 117 | .toggle-all { 118 | width: 1px; 119 | height: 1px; 120 | border: none; /* Mobile Safari */ 121 | opacity: 0; 122 | position: absolute; 123 | right: 100%; 124 | bottom: 100%; 125 | } 126 | 127 | .toggle-all + label { 128 | width: 60px; 129 | height: 34px; 130 | font-size: 0; 131 | position: absolute; 132 | top: -52px; 133 | left: -13px; 134 | -webkit-transform: rotate(90deg); 135 | transform: rotate(90deg); 136 | } 137 | 138 | .toggle-all + label:before { 139 | content: '❯'; 140 | font-size: 22px; 141 | color: #e6e6e6; 142 | padding: 10px 27px 10px 27px; 143 | } 144 | 145 | .toggle-all:checked + label:before { 146 | color: #737373; 147 | } 148 | 149 | .todo-list { 150 | margin: 0; 151 | padding: 0; 152 | list-style: none; 153 | } 154 | 155 | .todo-list li { 156 | position: relative; 157 | font-size: 24px; 158 | border-bottom: 1px solid #ededed; 159 | } 160 | 161 | .todo-list li:last-child { 162 | border-bottom: none; 163 | } 164 | 165 | .todo-list li.editing { 166 | border-bottom: none; 167 | padding: 0; 168 | } 169 | 170 | .todo-list li.editing .edit { 171 | display: block; 172 | width: calc(100% - 43px); 173 | padding: 12px 16px; 174 | margin: 0 0 0 43px; 175 | } 176 | 177 | .todo-list li.editing .view { 178 | display: none; 179 | } 180 | 181 | .todo-list li .toggle { 182 | text-align: center; 183 | width: 40px; 184 | /* auto, since non-WebKit browsers doesn't support input styling */ 185 | height: auto; 186 | position: absolute; 187 | top: 0; 188 | bottom: 0; 189 | margin: auto 0; 190 | border: none; /* Mobile Safari */ 191 | -webkit-appearance: none; 192 | appearance: none; 193 | } 194 | 195 | .todo-list li .toggle { 196 | opacity: 0; 197 | } 198 | 199 | .todo-list li .toggle + label { 200 | /* 201 | Firefox requires `#` to be escaped - https://bugzilla.mozilla.org/show_bug.cgi?id=922433 202 | IE and Edge requires *everything* to be escaped to render, so we do that instead of just the `#` - https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7157459/ 203 | */ 204 | background-image: url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23ededed%22%20stroke-width%3D%223%22/%3E%3C/svg%3E'); 205 | background-repeat: no-repeat; 206 | background-position: center left; 207 | } 208 | 209 | .todo-list li .toggle:checked + label { 210 | background-image: url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23bddad5%22%20stroke-width%3D%223%22/%3E%3Cpath%20fill%3D%22%235dc2af%22%20d%3D%22M72%2025L42%2071%2027%2056l-4%204%2020%2020%2034-52z%22/%3E%3C/svg%3E'); 211 | } 212 | 213 | .todo-list li label { 214 | word-break: break-all; 215 | padding: 15px 15px 15px 60px; 216 | display: block; 217 | line-height: 1.2; 218 | transition: color 0.4s; 219 | } 220 | 221 | .todo-list li.completed label { 222 | color: #d9d9d9; 223 | text-decoration: line-through; 224 | } 225 | 226 | .todo-list li .destroy { 227 | display: none; 228 | position: absolute; 229 | top: 0; 230 | right: 10px; 231 | bottom: 0; 232 | width: 40px; 233 | height: 40px; 234 | margin: auto 0; 235 | font-size: 30px; 236 | color: #cc9a9a; 237 | margin-bottom: 11px; 238 | transition: color 0.2s ease-out; 239 | } 240 | 241 | .todo-list li .destroy:hover { 242 | color: #af5b5e; 243 | } 244 | 245 | .todo-list li .destroy:after { 246 | content: '×'; 247 | } 248 | 249 | .todo-list li:hover .destroy { 250 | display: block; 251 | } 252 | 253 | .todo-list li .edit { 254 | display: none; 255 | } 256 | 257 | .todo-list li.editing:last-child { 258 | margin-bottom: -1px; 259 | } 260 | 261 | .footer { 262 | color: #777; 263 | padding: 10px 15px; 264 | height: 20px; 265 | text-align: center; 266 | border-top: 1px solid #e6e6e6; 267 | } 268 | 269 | .footer:before { 270 | content: ''; 271 | position: absolute; 272 | right: 0; 273 | bottom: 0; 274 | left: 0; 275 | height: 50px; 276 | overflow: hidden; 277 | box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 278 | 0 8px 0 -3px #f6f6f6, 279 | 0 9px 1px -3px rgba(0, 0, 0, 0.2), 280 | 0 16px 0 -6px #f6f6f6, 281 | 0 17px 2px -6px rgba(0, 0, 0, 0.2); 282 | } 283 | 284 | .todo-count { 285 | float: left; 286 | text-align: left; 287 | } 288 | 289 | .todo-count strong { 290 | font-weight: 300; 291 | } 292 | 293 | .filters { 294 | margin: 0; 295 | padding: 0; 296 | list-style: none; 297 | position: absolute; 298 | right: 0; 299 | left: 0; 300 | } 301 | 302 | .filters li { 303 | display: inline; 304 | } 305 | 306 | .filters li a { 307 | color: inherit; 308 | margin: 3px; 309 | padding: 3px 7px; 310 | text-decoration: none; 311 | border: 1px solid transparent; 312 | border-radius: 3px; 313 | } 314 | 315 | .filters li a:hover { 316 | border-color: rgba(175, 47, 47, 0.1); 317 | } 318 | 319 | .filters li a.selected { 320 | border-color: rgba(175, 47, 47, 0.2); 321 | } 322 | 323 | .clear-completed, 324 | html .clear-completed:active { 325 | float: right; 326 | position: relative; 327 | line-height: 20px; 328 | text-decoration: none; 329 | cursor: pointer; 330 | } 331 | 332 | .clear-completed:hover { 333 | text-decoration: underline; 334 | } 335 | 336 | .info { 337 | margin: 65px auto 0; 338 | color: #bfbfbf; 339 | font-size: 10px; 340 | text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); 341 | text-align: center; 342 | } 343 | 344 | .info p { 345 | line-height: 1; 346 | } 347 | 348 | .info a { 349 | color: inherit; 350 | text-decoration: none; 351 | font-weight: 400; 352 | } 353 | 354 | .info a:hover { 355 | text-decoration: underline; 356 | } 357 | 358 | /* 359 | Hack to remove background from Mobile Safari. 360 | Can't use it globally since it destroys checkboxes in Firefox 361 | */ 362 | @media screen and (-webkit-min-device-pixel-ratio:0) { 363 | .toggle-all, 364 | .todo-list li .toggle { 365 | background: none; 366 | } 367 | 368 | .todo-list li .toggle { 369 | height: 40px; 370 | } 371 | } 372 | 373 | @media (max-width: 430px) { 374 | .footer { 375 | height: 50px; 376 | } 377 | 378 | .filters { 379 | bottom: 10px; 380 | } 381 | } 382 | -------------------------------------------------------------------------------- /examples/htdocs/todo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Vue.js - TodoMVC 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 |

todos

14 | 19 |
20 |
21 | 22 | 23 |
    24 |
  • 28 |
    29 | 30 | 31 | 32 |
    33 | 39 |
  • 40 |
41 |
42 |
43 | 44 | {{ remaining }} {{ remaining | pluralize }} left 45 | 46 | 51 | 54 |
55 |
56 |
57 |

Double-click to edit a todo

58 |

Written by Evan You

59 |

Part of TodoMVC

60 |
61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /examples/htdocs/todo.js: -------------------------------------------------------------------------------- 1 | // See https://github.com/tastejs/todomvc/tree/gh-pages/examples/vue 2 | 3 | // IE on file does not provide localStorage 4 | var windowLocalStorage = window.localStorage; 5 | if (!windowLocalStorage) { 6 | windowLocalStorage = { 7 | _data : {}, 8 | setItem : function(id, val) { return this._data[id] = String(val); }, 9 | getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; }, 10 | removeItem : function(id) { return delete this._data[id]; }, 11 | clear : function() { return this._data = {}; } 12 | }; 13 | } 14 | 15 | // Full spec-compliant TodoMVC with localStorage persistence 16 | // and hash-based routing in ~120 effective lines of JavaScript. 17 | 18 | // localStorage persistence 19 | var STORAGE_KEY = 'todos-vuejs-2.0' 20 | var todoStorage = { 21 | fetch: function () { 22 | var todos = JSON.parse(windowLocalStorage.getItem(STORAGE_KEY) || '[]') 23 | todos.forEach(function (todo, index) { 24 | todo.id = index 25 | }) 26 | todoStorage.uid = todos.length 27 | return todos 28 | }, 29 | save: function (todos) { 30 | windowLocalStorage.setItem(STORAGE_KEY, JSON.stringify(todos)) 31 | } 32 | } 33 | 34 | // visibility filters 35 | var filters = { 36 | all: function (todos) { 37 | return todos 38 | }, 39 | active: function (todos) { 40 | return todos.filter(function (todo) { 41 | return !todo.completed 42 | }) 43 | }, 44 | completed: function (todos) { 45 | return todos.filter(function (todo) { 46 | return todo.completed 47 | }) 48 | } 49 | } 50 | 51 | // app Vue instance 52 | var app = new Vue({ 53 | // app initial state 54 | data: { 55 | todos: todoStorage.fetch(), 56 | newTodo: '', 57 | editedTodo: null, 58 | visibility: 'all' 59 | }, 60 | 61 | // watch todos change for localStorage persistence 62 | watch: { 63 | todos: { 64 | handler: function (todos) { 65 | todoStorage.save(todos) 66 | }, 67 | deep: true 68 | } 69 | }, 70 | 71 | // computed properties 72 | // http://vuejs.org/guide/computed.html 73 | computed: { 74 | filteredTodos: function () { 75 | return filters[this.visibility](this.todos) 76 | }, 77 | remaining: function () { 78 | return filters.active(this.todos).length 79 | }, 80 | allDone: { 81 | get: function () { 82 | return this.remaining === 0 83 | }, 84 | set: function (value) { 85 | this.todos.forEach(function (todo) { 86 | todo.completed = value 87 | }) 88 | } 89 | } 90 | }, 91 | 92 | filters: { 93 | pluralize: function (n) { 94 | return n === 1 ? 'item' : 'items' 95 | } 96 | }, 97 | 98 | // methods that implement data logic. 99 | // note there's no DOM manipulation here at all. 100 | methods: { 101 | addTodo: function () { 102 | var value = this.newTodo && this.newTodo.trim() 103 | if (!value) { 104 | return 105 | } 106 | this.todos.push({ 107 | id: todoStorage.uid++, 108 | title: value, 109 | completed: false 110 | }) 111 | this.newTodo = '' 112 | }, 113 | 114 | removeTodo: function (todo) { 115 | this.todos.splice(this.todos.indexOf(todo), 1) 116 | }, 117 | 118 | editTodo: function (todo) { 119 | this.beforeEditCache = todo.title 120 | this.editedTodo = todo 121 | }, 122 | 123 | doneEdit: function (todo) { 124 | if (!this.editedTodo) { 125 | return 126 | } 127 | this.editedTodo = null 128 | todo.title = todo.title.trim() 129 | if (!todo.title) { 130 | this.removeTodo(todo) 131 | } 132 | }, 133 | 134 | cancelEdit: function (todo) { 135 | this.editedTodo = null 136 | todo.title = this.beforeEditCache 137 | }, 138 | 139 | removeCompleted: function () { 140 | this.todos = filters.active(this.todos) 141 | } 142 | }, 143 | 144 | // a custom directive to wait for the DOM to be updated 145 | // before focusing on the input field. 146 | // http://vuejs.org/guide/custom-directive.html 147 | directives: { 148 | 'todo-focus': function (el, binding) { 149 | if (binding.value) { 150 | el.focus() 151 | } 152 | } 153 | } 154 | }) 155 | 156 | // handle routing 157 | function onHashChange () { 158 | var visibility = window.location.hash.replace(/#\/?/, '') 159 | if (filters[visibility]) { 160 | app.visibility = visibility 161 | } else { 162 | window.location.hash = '' 163 | app.visibility = 'all' 164 | } 165 | } 166 | 167 | window.addEventListener('hashchange', onHashChange) 168 | onHashChange() 169 | 170 | // mount 171 | app.$mount('.todoapp') 172 | -------------------------------------------------------------------------------- /examples/launch.js: -------------------------------------------------------------------------------- 1 | 2 | // This script allows to launch a web page that could executes custom code on QuickJS. 3 | 4 | import * as webview from '../webview.so' 5 | import * as os from 'os' 6 | import * as std from 'std' 7 | 8 | let url = `data:text/html, 9 | 10 | 11 |

Welcome !

12 |

You could specify an URL to launch as a command line argument.

13 | 14 | 15 | 16 | ` 17 | 18 | //print('path', os.realpath('.'), 'args', scriptArgs) 19 | 20 | const target = scriptArgs[1]; 21 | const title = scriptArgs[2] || 'WebView'; 22 | const width = parseInt(scriptArgs[3] || '800', 10); 23 | const height = parseInt(scriptArgs[4] || '600', 10); 24 | const resizable = scriptArgs[5] === 'true'; 25 | 26 | if (target) { 27 | if (target === '-h') { 28 | print('Try', scriptArgs[0], 'url title width height resizable'); 29 | std.exit(0); 30 | } else if (target.startsWith('/') || (target.substring(1, 3) == ':\\')) { 31 | url = 'file://' + target; 32 | } else if (target.startsWith('http') || target.startsWith('https') || target.startsWith('file') || target.startsWith('data')) { 33 | url = target; 34 | } else if (typeof os.realpath === 'function') { 35 | let path, err; 36 | [path, err] = os.realpath(target); 37 | if (err === 0) { 38 | url = 'file://' + path; 39 | } else { 40 | print('File not found (' + target + ')'); 41 | std.exit(std.Error.ENOENT); 42 | } 43 | } else { 44 | print('Please specify an absolute filename or a valid URL'); 45 | std.exit(std.Error.EINVAL); 46 | } 47 | } 48 | 49 | // Named requests callable from JS using window.external.invoke('name:value') 50 | // Custom request can be registered using window.external.invoke('+name:JS code') 51 | // The JS code has access to the string value 52 | const requestFunctionMap = { 53 | // Toggles the web view full screen on/off 54 | fullscreen: function(value, requestContext, evalBrowser, callBrowser, webview) { 55 | webview.fullscreen(value === 'true'); 56 | }, 57 | // Terminates the web view 58 | terminate: function(value, requestContext, evalBrowser, callBrowser, webview) { 59 | webview.terminate(true); 60 | }, 61 | // Sets the web view title 62 | title: function(value, requestContext, evalBrowser, callBrowser, webview) { 63 | webview.title(value); 64 | }, 65 | // Evaluates the specified JS code in the browser 66 | evalBrowser: function(value, requestContext, evalBrowser, callBrowser, webview) { 67 | webview.eval(value, true); 68 | }, 69 | // Executes the specified JS code in QuickJS 70 | eval: function(value, requestContext, evalBrowser, callBrowser, webview) { 71 | const fn = new Function('requestContext', 'evalBrowser', 'callBrowser', 'webview', value); 72 | fn(requestContext, evalBrowser, callBrowser, webview); 73 | }, 74 | } 75 | 76 | // Defines a context that will be shared across requests 77 | const requestContext = {} 78 | 79 | // Setup a function to evaluates JS code in the browser 80 | const evalBrowser = function(value) { 81 | w.eval(value, true); 82 | } 83 | 84 | // Setup a function to call a function in the browser 85 | const callBrowser = function(functionName) { 86 | const jsArgs = []; 87 | for (let i = 1; i < arguments.length; i++) { 88 | jsArgs.push(JSON.stringify(arguments[i])); 89 | } 90 | const js = functionName + '(' + jsArgs.join(',') + ')'; 91 | w.eval(js, true); 92 | } 93 | 94 | let w = webview.create(url, title, width, height, resizable) 95 | w.init() 96 | w.callback(function(request) { 97 | const colonIndex = request.indexOf(':'); 98 | if (colonIndex <= 0) { 99 | print('invalid request', request); 100 | return; 101 | } 102 | const flag = request.charAt(0); 103 | const hasFlag = flag < 'A'; 104 | const name = request.substring(hasFlag ? 1 : 0, colonIndex); 105 | const value = request.substring(colonIndex + 1); 106 | if (hasFlag) { 107 | switch(flag) { 108 | case '+': 109 | requestFunctionMap[name] = new Function('value', 'requestContext', 'evalBrowser', 'callBrowser', 'webview', value); 110 | print('added request function', name); 111 | break; 112 | case '-': 113 | delete requestFunctionMap[name]; 114 | print('deleted request function', name); 115 | break; 116 | case '*': 117 | requestFunctionMap[name] = new Function('jsonValue', 'requestContext', 'evalBrowser', 'callBrowser', 'webview', 'const value = JSON.parse(jsonValue);' + value); 118 | print('added request function', name); 119 | break; 120 | default: 121 | print('unknown request flag', flag); 122 | break; 123 | } 124 | } else { 125 | const fn = requestFunctionMap[name]; 126 | if (fn) { 127 | fn(value, requestContext, evalBrowser, callBrowser, w); 128 | } else { 129 | print('unknown request function', name); 130 | } 131 | } 132 | }) 133 | w.loop(); 134 | //w = null; 135 | -------------------------------------------------------------------------------- /examples/simple.js: -------------------------------------------------------------------------------- 1 | import * as webview from '../webview.so' 2 | 3 | const content = ` 4 | 5 | 6 | 7 | 8 | 9 |

It works !

10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 |
18 | 19 | 22 | 23 | `; 24 | 25 | let w = webview.create('data:text/html,' + encodeURIComponent(content), "QuickJS WebView Example", 640, 480, true) 26 | 27 | w.init() 28 | 29 | w.callback(function(value) { 30 | if (value == 'print_date') { 31 | print(new Date()); 32 | } else if (value == 'show_date') { 33 | w.eval('document.getElementById("sentence").innerHTML = "QuickJS date is ' + (new Date()) + '"', true); 34 | } else if (value == 'fullscreen') { 35 | w.fullscreen(true); 36 | } else if (value == 'exit_fullscreen') { 37 | w.fullscreen(false); 38 | } else if (value == 'terminate') { 39 | w.terminate(true); 40 | } else if (value.startsWith('title=')) { 41 | w.title(value.substring(6)); 42 | } else { 43 | print('callback received', value); 44 | } 45 | }) 46 | 47 | w.loop(); 48 | //w = null; 49 | -------------------------------------------------------------------------------- /webview.c: -------------------------------------------------------------------------------- 1 | #include "quickjs-libc.h" 2 | #include "cutils.h" 3 | 4 | #define WEBVIEW_IMPLEMENTATION 5 | #include "webview.h" 6 | 7 | //#define QJLS_MOD_TRACE 1 8 | #ifdef QJLS_MOD_TRACE 9 | #include 10 | #define trace(...) printf(__VA_ARGS__) 11 | #else 12 | #define trace(...) ((void)0) 13 | #endif 14 | 15 | static void *memdup(const void* mem, size_t size) { 16 | void *dup = malloc(size); 17 | if (dup != NULL) { 18 | memcpy(dup, mem, size); 19 | } 20 | return dup; 21 | } 22 | 23 | #define QJS_ARG_IS_DEFINED(_argc, _argv, _index) ((_argc > _index) && (!JS_IsUndefined(_argv[_index]))) 24 | 25 | #define QJS_ARG_AS_BOOL(_ctx, _argc, _argv, _index) (QJS_ARG_IS_DEFINED(_argc, _argv, _index) && (JS_ToBool(_ctx, _argv[_index]) > 0)) 26 | 27 | static const char *qjs_newCString(JSContext *ctx, JSValueConst value) { 28 | size_t len; 29 | const char *p = NULL; 30 | const char *cStr = JS_ToCStringLen(ctx, &len, value); 31 | if (cStr != NULL) { 32 | p = memdup(cStr, len + 1); 33 | JS_FreeCString(ctx, cStr); 34 | } 35 | return p; 36 | } 37 | 38 | typedef struct { 39 | JSContext *ctx; 40 | JSValue fn; 41 | struct webview wv; 42 | } QJSWebView; 43 | 44 | #define QJS_WEBVIEW_PTR(_cp) ((QJSWebView *) ((char *) (_cp) - offsetof(QJSWebView, wv))) 45 | 46 | static void qjs_webview_free_rt(struct webview *pwv, JSRuntime *rt) { 47 | trace("qjs_webview_free(%p)\n", rt); 48 | trace("qjs_webview_free() url: %p, title: %p\n", pwv->url, pwv->title); 49 | free((void *)pwv->url); 50 | pwv->url = NULL; 51 | free((void *)pwv->title); 52 | pwv->title = NULL; 53 | trace("qjs_webview_free() completed\n"); 54 | } 55 | 56 | #define qjs_webview_free(_pwv, _ctx) qjs_webview_free_rt(_pwv, JS_GetRuntime(_ctx)) 57 | 58 | static int qjs_webview_fillDefault(struct webview *pwv) { 59 | trace("qjs_webview_fillDefault(%p)\n", pwv); 60 | if (pwv->url == NULL) { 61 | pwv->url = strdup("about:blank"); 62 | if (pwv->url == NULL) { 63 | return 1; 64 | } 65 | } 66 | if (pwv->title == NULL) { 67 | pwv->title = strdup("QuickJS Web View"); 68 | if (pwv->title == NULL) { 69 | return 1; 70 | } 71 | } 72 | if (pwv->width <= 0) { 73 | pwv->width = 800; 74 | } 75 | if (pwv->height <= 0) { 76 | pwv->height = 600; 77 | } 78 | return 0; 79 | } 80 | 81 | static int qjs_webview_fill(struct webview *pwv, JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { 82 | trace("qjs_webview_fill(%p, %p, ?, %d, ?)\n", pwv, ctx, argc); 83 | if (QJS_ARG_IS_DEFINED(argc, argv, 0)) { 84 | free((void *)pwv->url); 85 | pwv->url = qjs_newCString(ctx, argv[0]); 86 | if (pwv->url == NULL) { 87 | return 1; 88 | } 89 | } 90 | if (QJS_ARG_IS_DEFINED(argc, argv, 1)) { 91 | free((void *)pwv->title); 92 | pwv->title = qjs_newCString(ctx, argv[1]); 93 | if (pwv->title == NULL) { 94 | return 1; 95 | } 96 | } 97 | if (QJS_ARG_IS_DEFINED(argc, argv, 2) && JS_ToInt32(ctx, &pwv->width, argv[2])) { 98 | return 1; 99 | } 100 | if (QJS_ARG_IS_DEFINED(argc, argv, 3) && JS_ToInt32(ctx, &pwv->height, argv[3])) { 101 | return 1; 102 | } 103 | if (QJS_ARG_IS_DEFINED(argc, argv, 4) && ((pwv->resizable = JS_ToBool(ctx, argv[3])) < 0)) { 104 | return 1; 105 | } 106 | return 0; 107 | } 108 | 109 | static JSValue qjs_webview_open(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { 110 | trace("qjs_webview_open(%p, ?, %d, ?)\n", ctx, argc); 111 | struct webview webview; 112 | memset(&webview, 0, sizeof(webview)); 113 | if (qjs_webview_fill(&webview, ctx, this_val, argc, argv)) { 114 | qjs_webview_free(&webview, ctx); 115 | return JS_EXCEPTION; 116 | } 117 | if (qjs_webview_fillDefault(&webview)) { 118 | qjs_webview_free(&webview, ctx); 119 | return JS_EXCEPTION; 120 | } 121 | int r = webview_init(&webview); 122 | if (r != 0) { 123 | qjs_webview_free(&webview, ctx); 124 | return JS_UNDEFINED; 125 | } 126 | while (webview_loop(&webview, 1) == 0) {} 127 | webview_exit(&webview); 128 | 129 | qjs_webview_free(&webview, ctx); 130 | return JS_UNDEFINED; 131 | } 132 | 133 | static JSClassID qjs_webview_class_id; 134 | 135 | static void qjs_webview_finalizer(JSRuntime *rt, JSValue val) { 136 | trace("qjs_webview_finalizer(%p)\n", rt); 137 | QJSWebView *p = JS_GetOpaque(val, qjs_webview_class_id); 138 | if (p) { 139 | trace("qjs_webview_finalizer() free webview\n"); 140 | qjs_webview_free_rt(&p->wv, rt); 141 | if (!JS_IsUndefined(p->fn)) { 142 | trace("qjs_webview_finalizer() free fn\n"); 143 | JS_FreeValueRT(rt, p->fn); 144 | } 145 | p->fn = JS_UNDEFINED; 146 | trace("qjs_webview_finalizer() free QJSWebView\n"); 147 | free(p); 148 | } 149 | trace("qjs_webview_finalizer() completed\n"); 150 | } 151 | 152 | static void qjs_webview_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func) { 153 | trace("qjs_webview_mark(%p)\n", rt); 154 | QJSWebView *p = JS_GetOpaque(val, qjs_webview_class_id); 155 | if (p) { 156 | JS_MarkValue(rt, p->fn, mark_func); 157 | } 158 | } 159 | 160 | static JSClassDef qjs_webview_class = { 161 | "WebView", 162 | .finalizer = qjs_webview_finalizer, 163 | .gc_mark = qjs_webview_mark, 164 | }; 165 | 166 | static JSValue qjs_webview_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { 167 | trace("qjs_webview_create(%p, ?, %d, ?)\n", ctx, argc); 168 | JSValue obj = JS_NewObjectClass(ctx, qjs_webview_class_id); 169 | if (JS_IsException(obj)) 170 | return obj; 171 | 172 | QJSWebView *p = calloc(1, sizeof(QJSWebView)); // The memory is set to zero 173 | if (!p) { 174 | JS_FreeValue(ctx, obj); 175 | return JS_EXCEPTION; 176 | } 177 | p->fn = JS_UNDEFINED; 178 | if (qjs_webview_fill(&p->wv, ctx, this_val, argc, argv)) { 179 | qjs_webview_free(&p->wv, ctx); 180 | JS_FreeValue(ctx, obj); 181 | free(p); 182 | return JS_EXCEPTION; 183 | } 184 | JS_SetOpaque(obj, p); 185 | return obj; 186 | } 187 | 188 | static JSValue qjs_webview_init(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { 189 | trace("qjs_webview_init(%p)\n", ctx); 190 | QJSWebView *p = JS_GetOpaque2(ctx, this_val, qjs_webview_class_id); 191 | if (!p) { 192 | return JS_EXCEPTION; 193 | } 194 | if (qjs_webview_fill(&p->wv, ctx, this_val, argc, argv)) { 195 | return JS_EXCEPTION; 196 | } 197 | if (qjs_webview_fillDefault(&p->wv)) { 198 | return JS_EXCEPTION; 199 | } 200 | int r = webview_init(&p->wv); 201 | if (r != 0) { 202 | return JS_EXCEPTION; 203 | } 204 | return JS_UNDEFINED; 205 | } 206 | 207 | static JSValue qjs_webview_loop(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { 208 | trace("qjs_webview_loop(%p)\n", ctx); 209 | QJSWebView *p = JS_GetOpaque2(ctx, this_val, qjs_webview_class_id); 210 | if (!p) { 211 | return JS_EXCEPTION; 212 | } 213 | trace("qjs_webview_loop() ctx: %p, %p %p\n", ctx, p->wv.url, p->wv.title); 214 | while (webview_loop(&p->wv, 1) == 0) {} 215 | webview_exit(&p->wv); 216 | return JS_UNDEFINED; 217 | } 218 | 219 | static void qjs_webview_invoke_cb(struct webview *pwv, const char *arg) { 220 | if ((pwv != NULL) && (arg != NULL)) { 221 | QJSWebView *p = QJS_WEBVIEW_PTR(pwv); 222 | JSContext *ctx = p->ctx; 223 | JSValue ret, fn, s; 224 | JSValueConst argv[1]; 225 | s = JS_NewString(ctx, arg); 226 | fn = JS_DupValue(ctx, p->fn); 227 | argv[0] = (JSValueConst) s; 228 | ret = JS_Call(ctx, fn, JS_UNDEFINED, 1, argv); 229 | JS_FreeValue(ctx, fn); 230 | JS_FreeValue(ctx, s); 231 | if (JS_IsException(ret)) { 232 | trace("qjs_webview_invoke_cb() raise an exception\n"); 233 | } 234 | JS_FreeValue(ctx, ret); 235 | } 236 | } 237 | 238 | static JSValue qjs_webview_callback(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { 239 | trace("qjs_webview_callback(%p)\n", ctx); 240 | QJSWebView *p = JS_GetOpaque2(ctx, this_val, qjs_webview_class_id); 241 | if (!p) { 242 | return JS_EXCEPTION; 243 | } 244 | if (JS_IsFunction(ctx, argv[0])) { 245 | p->fn = JS_DupValue(ctx, argv[0]); 246 | p->ctx = ctx; 247 | p->wv.external_invoke_cb = qjs_webview_invoke_cb; 248 | } else { 249 | //JS_IsObject 250 | if (!JS_IsUndefined(p->fn)) { 251 | JS_FreeValue(p->ctx, p->fn); 252 | } 253 | p->fn = JS_UNDEFINED; 254 | p->ctx = NULL; 255 | p->wv.external_invoke_cb = NULL; 256 | } 257 | return JS_UNDEFINED; 258 | } 259 | 260 | static void dispatched_eval(struct webview *pwv, void *arg) { 261 | if ((pwv != NULL) && (arg != NULL)) { 262 | webview_eval(pwv, (const char *) arg); 263 | free(arg); 264 | } 265 | } 266 | 267 | static JSValue qjs_webview_eval(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { 268 | QJSWebView *p = JS_GetOpaque2(ctx, this_val, qjs_webview_class_id); 269 | char *js; 270 | const char *cStr; 271 | size_t len; 272 | if (!p) { 273 | return JS_EXCEPTION; 274 | } 275 | if ((argc == 0) || ((cStr = JS_ToCStringLen(ctx, &len, argv[0])) == NULL)) { 276 | return JS_EXCEPTION; 277 | } 278 | int dispatch = QJS_ARG_AS_BOOL(ctx, argc, argv, 1); 279 | trace("qjs_webview_eval(%p, '%s', %d)\n", ctx, cStr, dispatch); 280 | if (dispatch) { 281 | js = memdup(cStr, len + 1); 282 | JS_FreeCString(ctx, cStr); 283 | webview_dispatch(&p->wv, dispatched_eval, (void *)js); 284 | return JS_UNDEFINED; 285 | } 286 | int r = webview_eval(&p->wv, cStr); 287 | JS_FreeCString(ctx, cStr); 288 | if (r) { 289 | return JS_UNDEFINED; 290 | } 291 | return JS_UNDEFINED; 292 | } 293 | 294 | static void dispatched_terminate(struct webview *w, void *arg) { 295 | webview_terminate(w); 296 | } 297 | 298 | static JSValue qjs_webview_terminate(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { 299 | trace("qjs_webview_terminate(%p)\n", ctx); 300 | QJSWebView *p = JS_GetOpaque2(ctx, this_val, qjs_webview_class_id); 301 | if (!p) { 302 | return JS_EXCEPTION; 303 | } 304 | int dispatch = QJS_ARG_AS_BOOL(ctx, argc, argv, 0); 305 | if (dispatch) { 306 | webview_dispatch(&p->wv, dispatched_terminate, NULL); 307 | return JS_UNDEFINED; 308 | } 309 | webview_terminate(&p->wv); 310 | return JS_UNDEFINED; 311 | } 312 | 313 | static JSValue qjs_webview_title(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { 314 | trace("qjs_webview_title(%p)\n", ctx); 315 | const char *title; 316 | QJSWebView *p = JS_GetOpaque2(ctx, this_val, qjs_webview_class_id); 317 | if (!p) { 318 | return JS_EXCEPTION; 319 | } 320 | if ((argc == 0) || ((title = JS_ToCString(ctx, argv[0])) == NULL)) { 321 | return JS_EXCEPTION; 322 | } 323 | webview_set_title(&p->wv, title); 324 | JS_FreeCString(ctx, title); 325 | return JS_UNDEFINED; 326 | } 327 | 328 | static JSValue qjs_webview_fullscreen(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { 329 | trace("qjs_webview_fullscreen(%p)\n", ctx); 330 | QJSWebView *p = JS_GetOpaque2(ctx, this_val, qjs_webview_class_id); 331 | if (!p) { 332 | return JS_EXCEPTION; 333 | } 334 | int fullscreen = QJS_ARG_AS_BOOL(ctx, argc, argv, 0); 335 | webview_set_fullscreen(&p->wv, fullscreen); 336 | return JS_UNDEFINED; 337 | } 338 | 339 | static const JSCFunctionListEntry qjs_webview_proto_funcs[] = { 340 | JS_CFUNC_DEF("init", 0, qjs_webview_init), 341 | JS_CFUNC_DEF("loop", 0, qjs_webview_loop), 342 | JS_CFUNC_DEF("callback", 0, qjs_webview_callback), 343 | JS_CFUNC_DEF("eval", 0, qjs_webview_eval), 344 | JS_CFUNC_DEF("fullscreen", 0, qjs_webview_fullscreen), 345 | JS_CFUNC_DEF("title", 0, qjs_webview_title), 346 | JS_CFUNC_DEF("terminate", 0, qjs_webview_terminate), 347 | }; 348 | 349 | static const JSCFunctionListEntry qjs_webview_funcs[] = { 350 | JS_CFUNC_DEF("open", 1, qjs_webview_open), 351 | JS_CFUNC_DEF("create", 0, qjs_webview_create), 352 | }; 353 | 354 | static int qjs_webview_init_module(JSContext *ctx, JSModuleDef *m) { 355 | JS_NewClassID(&qjs_webview_class_id); 356 | JS_NewClass(JS_GetRuntime(ctx), qjs_webview_class_id, &qjs_webview_class); 357 | JSValue proto = JS_NewObject(ctx); 358 | JS_SetPropertyFunctionList(ctx, proto, qjs_webview_proto_funcs, countof(qjs_webview_proto_funcs)); 359 | JS_SetClassProto(ctx, qjs_webview_class_id, proto); 360 | return JS_SetModuleExportList(ctx, m, qjs_webview_funcs, countof(qjs_webview_funcs)); 361 | } 362 | 363 | #ifdef JS_SHARED_LIBRARY 364 | #define JS_INIT_MODULE js_init_module 365 | #else 366 | #define JS_INIT_MODULE js_init_module_webview 367 | #endif 368 | 369 | JSModuleDef *JS_INIT_MODULE(JSContext *ctx, const char *module_name) { 370 | JSModuleDef *m; 371 | m = JS_NewCModule(ctx, module_name, qjs_webview_init_module); 372 | if (!m) { 373 | return NULL; 374 | } 375 | JS_AddModuleExportList(ctx, m, qjs_webview_funcs, countof(qjs_webview_funcs)); 376 | return m; 377 | } --------------------------------------------------------------------------------