How to use logError method in differencify

Best JavaScript code snippet using differencify

package.js

Source:package.js Github

copy

Full Screen

...73}74function getStringFromWasm(ptr, len) {75 return cachedTextDecoder.decode(getUint8Memory().subarray(ptr, ptr + len));76}77function logError(e) {78 let error = (function () {79 try {80 return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString();81 } catch(_) {82 return "<failed to stringify thrown value>";83 }84 }());85 console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error);86 throw e;87}88let WASM_VECTOR_LEN = 0;89let cachedTextEncoder = new TextEncoder('utf-8');90const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'91 ? function (arg, view) {92 return cachedTextEncoder.encodeInto(arg, view);93}94 : function (arg, view) {95 const buf = cachedTextEncoder.encode(arg);96 view.set(buf);97 return {98 read: arg.length,99 written: buf.length100 };101});102function passStringToWasm(arg) {103 if (typeof(arg) !== 'string') throw new Error('expected a string argument');104 let len = arg.length;105 let ptr = wasm.__wbindgen_malloc(len);106 const mem = getUint8Memory();107 let offset = 0;108 for (; offset < len; offset++) {109 const code = arg.charCodeAt(offset);110 if (code > 0x7F) break;111 mem[ptr + offset] = code;112 }113 if (offset !== len) {114 if (offset !== 0) {115 arg = arg.slice(offset);116 }117 ptr = wasm.__wbindgen_realloc(ptr, len, len = offset + arg.length * 3);118 const view = getUint8Memory().subarray(ptr + offset, ptr + len);119 const ret = encodeString(arg, view);120 if (ret.read !== arg.length) throw new Error('failed to pass whole string');121 offset += ret.written;122 }123 WASM_VECTOR_LEN = offset;124 return ptr;125}126let cachegetInt32Memory = null;127function getInt32Memory() {128 if (cachegetInt32Memory === null || cachegetInt32Memory.buffer !== wasm.memory.buffer) {129 cachegetInt32Memory = new Int32Array(wasm.memory.buffer);130 }131 return cachegetInt32Memory;132}133function handleError(e) {134 wasm.__wbindgen_exn_store(addHeapObject(e));135}136function isLikeNone(x) {137 return x === undefined || x === null;138}139let cachegetUint32Memory = null;140function getUint32Memory() {141 if (cachegetUint32Memory === null || cachegetUint32Memory.buffer !== wasm.memory.buffer) {142 cachegetUint32Memory = new Uint32Array(wasm.memory.buffer);143 }144 return cachegetUint32Memory;145}146function debugString(val) {147 // primitive types148 const type = typeof val;149 if (type == 'number' || type == 'boolean' || val == null) {150 return `${val}`;151 }152 if (type == 'string') {153 return `"${val}"`;154 }155 if (type == 'symbol') {156 const description = val.description;157 if (description == null) {158 return 'Symbol';159 } else {160 return `Symbol(${description})`;161 }162 }163 if (type == 'function') {164 const name = val.name;165 if (typeof name == 'string' && name.length > 0) {166 return `Function(${name})`;167 } else {168 return 'Function';169 }170 }171 // objects172 if (Array.isArray(val)) {173 const length = val.length;174 let debug = '[';175 if (length > 0) {176 debug += debugString(val[0]);177 }178 for(let i = 1; i < length; i++) {179 debug += ', ' + debugString(val[i]);180 }181 debug += ']';182 return debug;183 }184 // Test for built-in185 const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));186 let className;187 if (builtInMatches.length > 1) {188 className = builtInMatches[1];189 } else {190 // Failed to match the standard '[object ClassName]'191 return toString.call(val);192 }193 if (className == 'Object') {194 // we're a user defined class or Object195 // JSON.stringify avoids problems with cycles, and is generally much196 // easier than looping through ownProperties of `val`.197 try {198 return 'Object(' + JSON.stringify(val) + ')';199 } catch (_) {200 return 'Object';201 }202 }203 // errors204 if (val instanceof Error) {205 return `${val.name}: ${val.message}\n${val.stack}`;206 }207 // TODO we could test for more things here, like `Set`s and `Map`s.208 return className;209}210function init(module) {211 if (typeof module === 'undefined') {212 module = import.meta.url.replace(/\.js$/, '_bg.wasm');213 }214 let result;215 const imports = {};216 imports.wbg = {};217 imports.wbg.__wbindgen_cb_forget = function(arg0) {218 takeObject(arg0);219 };220 imports.wbg.__wbindgen_cb_drop = function(arg0) {221 const obj = takeObject(arg0).original;222 if (obj.cnt-- == 1) {223 obj.a = 0;224 return true;225 }226 const ret = false;227 _assertBoolean(ret);228 return ret;229 };230 imports.wbg.__wbindgen_string_new = function(arg0, arg1) {231 const ret = getStringFromWasm(arg0, arg1);232 return addHeapObject(ret);233 };234 imports.wbg.__wbindgen_object_clone_ref = function(arg0) {235 const ret = getObject(arg0);236 return addHeapObject(ret);237 };238 imports.wbg.__wbindgen_object_drop_ref = function(arg0) {239 takeObject(arg0);240 };241 imports.wbg.__wbg_error_4bb6c2a97407129a = function(arg0, arg1) {242 const v0 = getStringFromWasm(arg0, arg1).slice();243 wasm.__wbindgen_free(arg0, arg1 * 1);244 try {245 console.error(v0);246 } catch (e) {247 logError(e)248 }249 };250 imports.wbg.__wbg_new_59cb74e423758ede = function() {251 try {252 const ret = new Error();253 return addHeapObject(ret);254 } catch (e) {255 logError(e)256 }257 };258 imports.wbg.__wbg_stack_558ba5917b466edd = function(arg0, arg1) {259 try {260 const ret = getObject(arg1).stack;261 const ret0 = passStringToWasm(ret);262 const ret1 = WASM_VECTOR_LEN;263 getInt32Memory()[arg0 / 4 + 0] = ret0;264 getInt32Memory()[arg0 / 4 + 1] = ret1;265 } catch (e) {266 logError(e)267 }268 };269 imports.wbg.__widl_f_create_element_Document = function(arg0, arg1, arg2) {270 try {271 try {272 const ret = getObject(arg0).createElement(getStringFromWasm(arg1, arg2));273 return addHeapObject(ret);274 } catch (e) {275 handleError(e)276 }277 } catch (e) {278 logError(e)279 }280 };281 imports.wbg.__widl_f_create_element_ns_Document = function(arg0, arg1, arg2, arg3, arg4) {282 try {283 try {284 const ret = getObject(arg0).createElementNS(arg1 === 0 ? undefined : getStringFromWasm(arg1, arg2), getStringFromWasm(arg3, arg4));285 return addHeapObject(ret);286 } catch (e) {287 handleError(e)288 }289 } catch (e) {290 logError(e)291 }292 };293 imports.wbg.__widl_f_create_text_node_Document = function(arg0, arg1, arg2) {294 try {295 const ret = getObject(arg0).createTextNode(getStringFromWasm(arg1, arg2));296 return addHeapObject(ret);297 } catch (e) {298 logError(e)299 }300 };301 imports.wbg.__widl_f_get_element_by_id_Document = function(arg0, arg1, arg2) {302 try {303 const ret = getObject(arg0).getElementById(getStringFromWasm(arg1, arg2));304 return isLikeNone(ret) ? 0 : addHeapObject(ret);305 } catch (e) {306 logError(e)307 }308 };309 imports.wbg.__widl_f_query_selector_Document = function(arg0, arg1, arg2) {310 try {311 try {312 const ret = getObject(arg0).querySelector(getStringFromWasm(arg1, arg2));313 return isLikeNone(ret) ? 0 : addHeapObject(ret);314 } catch (e) {315 handleError(e)316 }317 } catch (e) {318 logError(e)319 }320 };321 imports.wbg.__widl_f_active_element_Document = function(arg0) {322 try {323 const ret = getObject(arg0).activeElement;324 return isLikeNone(ret) ? 0 : addHeapObject(ret);325 } catch (e) {326 logError(e)327 }328 };329 imports.wbg.__widl_instanceof_Element = function(arg0) {330 try {331 const ret = getObject(arg0) instanceof Element;332 _assertBoolean(ret);333 return ret;334 } catch (e) {335 logError(e)336 }337 };338 imports.wbg.__widl_f_closest_Element = function(arg0, arg1, arg2) {339 try {340 try {341 const ret = getObject(arg0).closest(getStringFromWasm(arg1, arg2));342 return isLikeNone(ret) ? 0 : addHeapObject(ret);343 } catch (e) {344 handleError(e)345 }346 } catch (e) {347 logError(e)348 }349 };350 imports.wbg.__widl_f_get_attribute_Element = function(arg0, arg1, arg2, arg3) {351 try {352 const ret = getObject(arg1).getAttribute(getStringFromWasm(arg2, arg3));353 const ptr0 = isLikeNone(ret) ? 0 : passStringToWasm(ret);354 const len0 = WASM_VECTOR_LEN;355 const ret0 = ptr0;356 const ret1 = len0;357 getInt32Memory()[arg0 / 4 + 0] = ret0;358 getInt32Memory()[arg0 / 4 + 1] = ret1;359 } catch (e) {360 logError(e)361 }362 };363 imports.wbg.__widl_f_get_attribute_names_Element = function(arg0) {364 try {365 const ret = getObject(arg0).getAttributeNames();366 return addHeapObject(ret);367 } catch (e) {368 logError(e)369 }370 };371 imports.wbg.__widl_f_remove_attribute_Element = function(arg0, arg1, arg2) {372 try {373 try {374 getObject(arg0).removeAttribute(getStringFromWasm(arg1, arg2));375 } catch (e) {376 handleError(e)377 }378 } catch (e) {379 logError(e)380 }381 };382 imports.wbg.__widl_f_set_attribute_Element = function(arg0, arg1, arg2, arg3, arg4) {383 try {384 try {385 getObject(arg0).setAttribute(getStringFromWasm(arg1, arg2), getStringFromWasm(arg3, arg4));386 } catch (e) {387 handleError(e)388 }389 } catch (e) {390 logError(e)391 }392 };393 imports.wbg.__widl_f_namespace_uri_Element = function(arg0, arg1) {394 try {395 const ret = getObject(arg1).namespaceURI;396 const ptr0 = isLikeNone(ret) ? 0 : passStringToWasm(ret);397 const len0 = WASM_VECTOR_LEN;398 const ret0 = ptr0;399 const ret1 = len0;400 getInt32Memory()[arg0 / 4 + 0] = ret0;401 getInt32Memory()[arg0 / 4 + 1] = ret1;402 } catch (e) {403 logError(e)404 }405 };406 imports.wbg.__widl_f_tag_name_Element = function(arg0, arg1) {407 try {408 const ret = getObject(arg1).tagName;409 const ret0 = passStringToWasm(ret);410 const ret1 = WASM_VECTOR_LEN;411 getInt32Memory()[arg0 / 4 + 0] = ret0;412 getInt32Memory()[arg0 / 4 + 1] = ret1;413 } catch (e) {414 logError(e)415 }416 };417 imports.wbg.__widl_f_prevent_default_Event = function(arg0) {418 try {419 getObject(arg0).preventDefault();420 } catch (e) {421 logError(e)422 }423 };424 imports.wbg.__widl_f_target_Event = function(arg0) {425 try {426 const ret = getObject(arg0).target;427 return isLikeNone(ret) ? 0 : addHeapObject(ret);428 } catch (e) {429 logError(e)430 }431 };432 imports.wbg.__widl_f_add_event_listener_with_callback_EventTarget = function(arg0, arg1, arg2, arg3) {433 try {434 try {435 getObject(arg0).addEventListener(getStringFromWasm(arg1, arg2), getObject(arg3));436 } catch (e) {437 handleError(e)438 }439 } catch (e) {440 logError(e)441 }442 };443 imports.wbg.__widl_f_remove_event_listener_with_callback_EventTarget = function(arg0, arg1, arg2, arg3) {444 try {445 try {446 getObject(arg0).removeEventListener(getStringFromWasm(arg1, arg2), getObject(arg3));447 } catch (e) {448 handleError(e)449 }450 } catch (e) {451 logError(e)452 }453 };454 imports.wbg.__widl_instanceof_HTMLButtonElement = function(arg0) {455 try {456 const ret = getObject(arg0) instanceof HTMLButtonElement;457 _assertBoolean(ret);458 return ret;459 } catch (e) {460 logError(e)461 }462 };463 imports.wbg.__widl_f_value_HTMLButtonElement = function(arg0, arg1) {464 try {465 const ret = getObject(arg1).value;466 const ret0 = passStringToWasm(ret);467 const ret1 = WASM_VECTOR_LEN;468 getInt32Memory()[arg0 / 4 + 0] = ret0;469 getInt32Memory()[arg0 / 4 + 1] = ret1;470 } catch (e) {471 logError(e)472 }473 };474 imports.wbg.__widl_f_set_value_HTMLButtonElement = function(arg0, arg1, arg2) {475 try {476 getObject(arg0).value = getStringFromWasm(arg1, arg2);477 } catch (e) {478 logError(e)479 }480 };481 imports.wbg.__widl_instanceof_HTMLDataElement = function(arg0) {482 try {483 const ret = getObject(arg0) instanceof HTMLDataElement;484 _assertBoolean(ret);485 return ret;486 } catch (e) {487 logError(e)488 }489 };490 imports.wbg.__widl_f_value_HTMLDataElement = function(arg0, arg1) {491 try {492 const ret = getObject(arg1).value;493 const ret0 = passStringToWasm(ret);494 const ret1 = WASM_VECTOR_LEN;495 getInt32Memory()[arg0 / 4 + 0] = ret0;496 getInt32Memory()[arg0 / 4 + 1] = ret1;497 } catch (e) {498 logError(e)499 }500 };501 imports.wbg.__widl_f_set_value_HTMLDataElement = function(arg0, arg1, arg2) {502 try {503 getObject(arg0).value = getStringFromWasm(arg1, arg2);504 } catch (e) {505 logError(e)506 }507 };508 imports.wbg.__widl_instanceof_HTMLElement = function(arg0) {509 try {510 const ret = getObject(arg0) instanceof HTMLElement;511 _assertBoolean(ret);512 return ret;513 } catch (e) {514 logError(e)515 }516 };517 imports.wbg.__widl_f_focus_HTMLElement = function(arg0) {518 try {519 try {520 getObject(arg0).focus();521 } catch (e) {522 handleError(e)523 }524 } catch (e) {525 logError(e)526 }527 };528 imports.wbg.__widl_instanceof_HTMLInputElement = function(arg0) {529 try {530 const ret = getObject(arg0) instanceof HTMLInputElement;531 _assertBoolean(ret);532 return ret;533 } catch (e) {534 logError(e)535 }536 };537 imports.wbg.__widl_f_set_checked_HTMLInputElement = function(arg0, arg1) {538 try {539 getObject(arg0).checked = arg1 !== 0;540 } catch (e) {541 logError(e)542 }543 };544 imports.wbg.__widl_f_type_HTMLInputElement = function(arg0, arg1) {545 try {546 const ret = getObject(arg1).type;547 const ret0 = passStringToWasm(ret);548 const ret1 = WASM_VECTOR_LEN;549 getInt32Memory()[arg0 / 4 + 0] = ret0;550 getInt32Memory()[arg0 / 4 + 1] = ret1;551 } catch (e) {552 logError(e)553 }554 };555 imports.wbg.__widl_f_value_HTMLInputElement = function(arg0, arg1) {556 try {557 const ret = getObject(arg1).value;558 const ret0 = passStringToWasm(ret);559 const ret1 = WASM_VECTOR_LEN;560 getInt32Memory()[arg0 / 4 + 0] = ret0;561 getInt32Memory()[arg0 / 4 + 1] = ret1;562 } catch (e) {563 logError(e)564 }565 };566 imports.wbg.__widl_f_set_value_HTMLInputElement = function(arg0, arg1, arg2) {567 try {568 getObject(arg0).value = getStringFromWasm(arg1, arg2);569 } catch (e) {570 logError(e)571 }572 };573 imports.wbg.__widl_f_selection_start_HTMLInputElement = function(arg0, arg1) {574 try {575 try {576 const ret = getObject(arg1).selectionStart;577 if (!isLikeNone(ret)) {578 _assertNum(ret);579 }580 const ret0 = !isLikeNone(ret);581 const ret1 = isLikeNone(ret) ? 0 : ret;582 getInt32Memory()[arg0 / 4 + 0] = ret0;583 getInt32Memory()[arg0 / 4 + 1] = ret1;584 } catch (e) {585 handleError(e)586 }587 } catch (e) {588 logError(e)589 }590 };591 imports.wbg.__widl_f_set_selection_start_HTMLInputElement = function(arg0, arg1, arg2) {592 try {593 try {594 getObject(arg0).selectionStart = arg1 === 0 ? undefined : arg2 >>> 0;595 } catch (e) {596 handleError(e)597 }598 } catch (e) {599 logError(e)600 }601 };602 imports.wbg.__widl_f_selection_end_HTMLInputElement = function(arg0, arg1) {603 try {604 try {605 const ret = getObject(arg1).selectionEnd;606 if (!isLikeNone(ret)) {607 _assertNum(ret);608 }609 const ret0 = !isLikeNone(ret);610 const ret1 = isLikeNone(ret) ? 0 : ret;611 getInt32Memory()[arg0 / 4 + 0] = ret0;612 getInt32Memory()[arg0 / 4 + 1] = ret1;613 } catch (e) {614 handleError(e)615 }616 } catch (e) {617 logError(e)618 }619 };620 imports.wbg.__widl_f_set_selection_end_HTMLInputElement = function(arg0, arg1, arg2) {621 try {622 try {623 getObject(arg0).selectionEnd = arg1 === 0 ? undefined : arg2 >>> 0;624 } catch (e) {625 handleError(e)626 }627 } catch (e) {628 logError(e)629 }630 };631 imports.wbg.__widl_instanceof_HTMLLIElement = function(arg0) {632 try {633 const ret = getObject(arg0) instanceof HTMLLIElement;634 _assertBoolean(ret);635 return ret;636 } catch (e) {637 logError(e)638 }639 };640 imports.wbg.__widl_f_value_HTMLLIElement = function(arg0) {641 try {642 const ret = getObject(arg0).value;643 _assertNum(ret);644 return ret;645 } catch (e) {646 logError(e)647 }648 };649 imports.wbg.__widl_f_set_value_HTMLLIElement = function(arg0, arg1) {650 try {651 getObject(arg0).value = arg1;652 } catch (e) {653 logError(e)654 }655 };656 imports.wbg.__widl_instanceof_HTMLMenuItemElement = function(arg0) {657 try {658 const ret = getObject(arg0) instanceof HTMLMenuItemElement;659 _assertBoolean(ret);660 return ret;661 } catch (e) {662 logError(e)663 }664 };665 imports.wbg.__widl_f_set_checked_HTMLMenuItemElement = function(arg0, arg1) {666 try {667 getObject(arg0).checked = arg1 !== 0;668 } catch (e) {669 logError(e)670 }671 };672 imports.wbg.__widl_instanceof_HTMLMeterElement = function(arg0) {673 try {674 const ret = getObject(arg0) instanceof HTMLMeterElement;675 _assertBoolean(ret);676 return ret;677 } catch (e) {678 logError(e)679 }680 };681 imports.wbg.__widl_f_value_HTMLMeterElement = function(arg0) {682 try {683 const ret = getObject(arg0).value;684 _assertNum(ret);685 return ret;686 } catch (e) {687 logError(e)688 }689 };690 imports.wbg.__widl_f_set_value_HTMLMeterElement = function(arg0, arg1) {691 try {692 getObject(arg0).value = arg1;693 } catch (e) {694 logError(e)695 }696 };697 imports.wbg.__widl_instanceof_HTMLOptionElement = function(arg0) {698 try {699 const ret = getObject(arg0) instanceof HTMLOptionElement;700 _assertBoolean(ret);701 return ret;702 } catch (e) {703 logError(e)704 }705 };706 imports.wbg.__widl_f_value_HTMLOptionElement = function(arg0, arg1) {707 try {708 const ret = getObject(arg1).value;709 const ret0 = passStringToWasm(ret);710 const ret1 = WASM_VECTOR_LEN;711 getInt32Memory()[arg0 / 4 + 0] = ret0;712 getInt32Memory()[arg0 / 4 + 1] = ret1;713 } catch (e) {714 logError(e)715 }716 };717 imports.wbg.__widl_f_set_value_HTMLOptionElement = function(arg0, arg1, arg2) {718 try {719 getObject(arg0).value = getStringFromWasm(arg1, arg2);720 } catch (e) {721 logError(e)722 }723 };724 imports.wbg.__widl_instanceof_HTMLOutputElement = function(arg0) {725 try {726 const ret = getObject(arg0) instanceof HTMLOutputElement;727 _assertBoolean(ret);728 return ret;729 } catch (e) {730 logError(e)731 }732 };733 imports.wbg.__widl_f_value_HTMLOutputElement = function(arg0, arg1) {734 try {735 const ret = getObject(arg1).value;736 const ret0 = passStringToWasm(ret);737 const ret1 = WASM_VECTOR_LEN;738 getInt32Memory()[arg0 / 4 + 0] = ret0;739 getInt32Memory()[arg0 / 4 + 1] = ret1;740 } catch (e) {741 logError(e)742 }743 };744 imports.wbg.__widl_f_set_value_HTMLOutputElement = function(arg0, arg1, arg2) {745 try {746 getObject(arg0).value = getStringFromWasm(arg1, arg2);747 } catch (e) {748 logError(e)749 }750 };751 imports.wbg.__widl_instanceof_HTMLParamElement = function(arg0) {752 try {753 const ret = getObject(arg0) instanceof HTMLParamElement;754 _assertBoolean(ret);755 return ret;756 } catch (e) {757 logError(e)758 }759 };760 imports.wbg.__widl_f_value_HTMLParamElement = function(arg0, arg1) {761 try {762 const ret = getObject(arg1).value;763 const ret0 = passStringToWasm(ret);764 const ret1 = WASM_VECTOR_LEN;765 getInt32Memory()[arg0 / 4 + 0] = ret0;766 getInt32Memory()[arg0 / 4 + 1] = ret1;767 } catch (e) {768 logError(e)769 }770 };771 imports.wbg.__widl_f_set_value_HTMLParamElement = function(arg0, arg1, arg2) {772 try {773 getObject(arg0).value = getStringFromWasm(arg1, arg2);774 } catch (e) {775 logError(e)776 }777 };778 imports.wbg.__widl_instanceof_HTMLProgressElement = function(arg0) {779 try {780 const ret = getObject(arg0) instanceof HTMLProgressElement;781 _assertBoolean(ret);782 return ret;783 } catch (e) {784 logError(e)785 }786 };787 imports.wbg.__widl_f_value_HTMLProgressElement = function(arg0) {788 try {789 const ret = getObject(arg0).value;790 _assertNum(ret);791 return ret;792 } catch (e) {793 logError(e)794 }795 };796 imports.wbg.__widl_f_set_value_HTMLProgressElement = function(arg0, arg1) {797 try {798 getObject(arg0).value = arg1;799 } catch (e) {800 logError(e)801 }802 };803 imports.wbg.__widl_instanceof_HTMLSelectElement = function(arg0) {804 try {805 const ret = getObject(arg0) instanceof HTMLSelectElement;806 _assertBoolean(ret);807 return ret;808 } catch (e) {809 logError(e)810 }811 };812 imports.wbg.__widl_f_value_HTMLSelectElement = function(arg0, arg1) {813 try {814 const ret = getObject(arg1).value;815 const ret0 = passStringToWasm(ret);816 const ret1 = WASM_VECTOR_LEN;817 getInt32Memory()[arg0 / 4 + 0] = ret0;818 getInt32Memory()[arg0 / 4 + 1] = ret1;819 } catch (e) {820 logError(e)821 }822 };823 imports.wbg.__widl_f_set_value_HTMLSelectElement = function(arg0, arg1, arg2) {824 try {825 getObject(arg0).value = getStringFromWasm(arg1, arg2);826 } catch (e) {827 logError(e)828 }829 };830 imports.wbg.__widl_instanceof_HTMLTextAreaElement = function(arg0) {831 try {832 const ret = getObject(arg0) instanceof HTMLTextAreaElement;833 _assertBoolean(ret);834 return ret;835 } catch (e) {836 logError(e)837 }838 };839 imports.wbg.__widl_f_value_HTMLTextAreaElement = function(arg0, arg1) {840 try {841 const ret = getObject(arg1).value;842 const ret0 = passStringToWasm(ret);843 const ret1 = WASM_VECTOR_LEN;844 getInt32Memory()[arg0 / 4 + 0] = ret0;845 getInt32Memory()[arg0 / 4 + 1] = ret1;846 } catch (e) {847 logError(e)848 }849 };850 imports.wbg.__widl_f_set_value_HTMLTextAreaElement = function(arg0, arg1, arg2) {851 try {852 getObject(arg0).value = getStringFromWasm(arg1, arg2);853 } catch (e) {854 logError(e)855 }856 };857 imports.wbg.__widl_instanceof_HashChangeEvent = function(arg0) {858 try {859 const ret = getObject(arg0) instanceof HashChangeEvent;860 _assertBoolean(ret);861 return ret;862 } catch (e) {863 logError(e)864 }865 };866 imports.wbg.__widl_f_new_url_HashChangeEvent = function(arg0, arg1) {867 try {868 const ret = getObject(arg1).newURL;869 const ret0 = passStringToWasm(ret);870 const ret1 = WASM_VECTOR_LEN;871 getInt32Memory()[arg0 / 4 + 0] = ret0;872 getInt32Memory()[arg0 / 4 + 1] = ret1;873 } catch (e) {874 logError(e)875 }876 };877 imports.wbg.__widl_f_push_state_with_url_History = function(arg0, arg1, arg2, arg3, arg4, arg5) {878 try {879 try {880 getObject(arg0).pushState(getObject(arg1), getStringFromWasm(arg2, arg3), arg4 === 0 ? undefined : getStringFromWasm(arg4, arg5));881 } catch (e) {882 handleError(e)883 }884 } catch (e) {885 logError(e)886 }887 };888 imports.wbg.__widl_instanceof_KeyboardEvent = function(arg0) {889 try {890 const ret = getObject(arg0) instanceof KeyboardEvent;891 _assertBoolean(ret);892 return ret;893 } catch (e) {894 logError(e)895 }896 };897 imports.wbg.__widl_f_key_code_KeyboardEvent = function(arg0) {898 try {899 const ret = getObject(arg0).keyCode;900 _assertNum(ret);901 return ret;902 } catch (e) {903 logError(e)904 }905 };906 imports.wbg.__widl_f_href_Location = function(arg0, arg1) {907 try {908 try {909 const ret = getObject(arg1).href;910 const ret0 = passStringToWasm(ret);911 const ret1 = WASM_VECTOR_LEN;912 getInt32Memory()[arg0 / 4 + 0] = ret0;913 getInt32Memory()[arg0 / 4 + 1] = ret1;914 } catch (e) {915 handleError(e)916 }917 } catch (e) {918 logError(e)919 }920 };921 imports.wbg.__widl_instanceof_Node = function(arg0) {922 try {923 const ret = getObject(arg0) instanceof Node;924 _assertBoolean(ret);925 return ret;926 } catch (e) {927 logError(e)928 }929 };930 imports.wbg.__widl_f_append_child_Node = function(arg0, arg1) {931 try {932 try {933 const ret = getObject(arg0).appendChild(getObject(arg1));934 return addHeapObject(ret);935 } catch (e) {936 handleError(e)937 }938 } catch (e) {939 logError(e)940 }941 };942 imports.wbg.__widl_f_insert_before_Node = function(arg0, arg1, arg2) {943 try {944 try {945 const ret = getObject(arg0).insertBefore(getObject(arg1), getObject(arg2));946 return addHeapObject(ret);947 } catch (e) {948 handleError(e)949 }950 } catch (e) {951 logError(e)952 }953 };954 imports.wbg.__widl_f_remove_child_Node = function(arg0, arg1) {955 try {956 try {957 const ret = getObject(arg0).removeChild(getObject(arg1));958 return addHeapObject(ret);959 } catch (e) {960 handleError(e)961 }962 } catch (e) {963 logError(e)964 }965 };966 imports.wbg.__widl_f_replace_child_Node = function(arg0, arg1, arg2) {967 try {968 try {969 const ret = getObject(arg0).replaceChild(getObject(arg1), getObject(arg2));970 return addHeapObject(ret);971 } catch (e) {972 handleError(e)973 }974 } catch (e) {975 logError(e)976 }977 };978 imports.wbg.__widl_f_node_type_Node = function(arg0) {979 try {980 const ret = getObject(arg0).nodeType;981 _assertNum(ret);982 return ret;983 } catch (e) {984 logError(e)985 }986 };987 imports.wbg.__widl_f_child_nodes_Node = function(arg0) {988 try {989 const ret = getObject(arg0).childNodes;990 return addHeapObject(ret);991 } catch (e) {992 logError(e)993 }994 };995 imports.wbg.__widl_f_first_child_Node = function(arg0) {996 try {997 const ret = getObject(arg0).firstChild;998 return isLikeNone(ret) ? 0 : addHeapObject(ret);999 } catch (e) {1000 logError(e)1001 }1002 };1003 imports.wbg.__widl_f_next_sibling_Node = function(arg0) {1004 try {1005 const ret = getObject(arg0).nextSibling;1006 return isLikeNone(ret) ? 0 : addHeapObject(ret);1007 } catch (e) {1008 logError(e)1009 }1010 };1011 imports.wbg.__widl_f_text_content_Node = function(arg0, arg1) {1012 try {1013 const ret = getObject(arg1).textContent;1014 const ptr0 = isLikeNone(ret) ? 0 : passStringToWasm(ret);1015 const len0 = WASM_VECTOR_LEN;1016 const ret0 = ptr0;1017 const ret1 = len0;1018 getInt32Memory()[arg0 / 4 + 0] = ret0;1019 getInt32Memory()[arg0 / 4 + 1] = ret1;1020 } catch (e) {1021 logError(e)1022 }1023 };1024 imports.wbg.__widl_f_set_text_content_Node = function(arg0, arg1, arg2) {1025 try {1026 getObject(arg0).textContent = arg1 === 0 ? undefined : getStringFromWasm(arg1, arg2);1027 } catch (e) {1028 logError(e)1029 }1030 };1031 imports.wbg.__widl_f_get_NodeList = function(arg0, arg1) {1032 try {1033 const ret = getObject(arg0)[arg1 >>> 0];1034 return isLikeNone(ret) ? 0 : addHeapObject(ret);1035 } catch (e) {1036 logError(e)1037 }1038 };1039 imports.wbg.__widl_f_length_NodeList = function(arg0) {1040 try {1041 const ret = getObject(arg0).length;1042 _assertNum(ret);1043 return ret;1044 } catch (e) {1045 logError(e)1046 }1047 };1048 imports.wbg.__widl_f_now_Performance = function(arg0) {1049 try {1050 const ret = getObject(arg0).now();1051 _assertNum(ret);1052 return ret;1053 } catch (e) {1054 logError(e)1055 }1056 };1057 imports.wbg.__widl_instanceof_PopStateEvent = function(arg0) {1058 try {1059 const ret = getObject(arg0) instanceof PopStateEvent;1060 _assertBoolean(ret);1061 return ret;1062 } catch (e) {1063 logError(e)1064 }1065 };1066 imports.wbg.__widl_f_state_PopStateEvent = function(arg0) {1067 try {1068 const ret = getObject(arg0).state;1069 return addHeapObject(ret);1070 } catch (e) {1071 logError(e)1072 }1073 };1074 imports.wbg.__widl_f_set_item_Storage = function(arg0, arg1, arg2, arg3, arg4) {1075 try {1076 try {1077 getObject(arg0).setItem(getStringFromWasm(arg1, arg2), getStringFromWasm(arg3, arg4));1078 } catch (e) {1079 handleError(e)1080 }1081 } catch (e) {1082 logError(e)1083 }1084 };1085 imports.wbg.__widl_f_new_URL = function(arg0, arg1) {1086 try {1087 try {1088 const ret = new URL(getStringFromWasm(arg0, arg1));1089 return addHeapObject(ret);1090 } catch (e) {1091 handleError(e)1092 }1093 } catch (e) {1094 logError(e)1095 }1096 };1097 imports.wbg.__widl_f_new_with_base_URL = function(arg0, arg1, arg2, arg3) {1098 try {1099 try {1100 const ret = new URL(getStringFromWasm(arg0, arg1), getStringFromWasm(arg2, arg3));1101 return addHeapObject(ret);1102 } catch (e) {1103 handleError(e)1104 }1105 } catch (e) {1106 logError(e)1107 }1108 };1109 imports.wbg.__widl_f_pathname_URL = function(arg0, arg1) {1110 try {1111 const ret = getObject(arg1).pathname;1112 const ret0 = passStringToWasm(ret);1113 const ret1 = WASM_VECTOR_LEN;1114 getInt32Memory()[arg0 / 4 + 0] = ret0;1115 getInt32Memory()[arg0 / 4 + 1] = ret1;1116 } catch (e) {1117 logError(e)1118 }1119 };1120 imports.wbg.__widl_f_search_URL = function(arg0, arg1) {1121 try {1122 const ret = getObject(arg1).search;1123 const ret0 = passStringToWasm(ret);1124 const ret1 = WASM_VECTOR_LEN;1125 getInt32Memory()[arg0 / 4 + 0] = ret0;1126 getInt32Memory()[arg0 / 4 + 1] = ret1;1127 } catch (e) {1128 logError(e)1129 }1130 };1131 imports.wbg.__widl_f_hash_URL = function(arg0, arg1) {1132 try {1133 const ret = getObject(arg1).hash;1134 const ret0 = passStringToWasm(ret);1135 const ret1 = WASM_VECTOR_LEN;1136 getInt32Memory()[arg0 / 4 + 0] = ret0;1137 getInt32Memory()[arg0 / 4 + 1] = ret1;1138 } catch (e) {1139 logError(e)1140 }1141 };1142 imports.wbg.__widl_instanceof_Window = function(arg0) {1143 try {1144 const ret = getObject(arg0) instanceof Window;1145 _assertBoolean(ret);1146 return ret;1147 } catch (e) {1148 logError(e)1149 }1150 };1151 imports.wbg.__widl_f_cancel_animation_frame_Window = function(arg0, arg1) {1152 try {1153 try {1154 getObject(arg0).cancelAnimationFrame(arg1);1155 } catch (e) {1156 handleError(e)1157 }1158 } catch (e) {1159 logError(e)1160 }1161 };1162 imports.wbg.__widl_f_request_animation_frame_Window = function(arg0, arg1) {1163 try {1164 try {1165 const ret = getObject(arg0).requestAnimationFrame(getObject(arg1));1166 _assertNum(ret);1167 return ret;1168 } catch (e) {1169 handleError(e)1170 }1171 } catch (e) {1172 logError(e)1173 }1174 };1175 imports.wbg.__widl_f_document_Window = function(arg0) {1176 try {1177 const ret = getObject(arg0).document;1178 return isLikeNone(ret) ? 0 : addHeapObject(ret);1179 } catch (e) {1180 logError(e)1181 }1182 };1183 imports.wbg.__widl_f_location_Window = function(arg0) {1184 try {1185 const ret = getObject(arg0).location;1186 return addHeapObject(ret);1187 } catch (e) {1188 logError(e)1189 }1190 };1191 imports.wbg.__widl_f_history_Window = function(arg0) {1192 try {1193 try {1194 const ret = getObject(arg0).history;1195 return addHeapObject(ret);1196 } catch (e) {1197 handleError(e)1198 }1199 } catch (e) {1200 logError(e)1201 }1202 };1203 imports.wbg.__widl_f_performance_Window = function(arg0) {1204 try {1205 const ret = getObject(arg0).performance;1206 return isLikeNone(ret) ? 0 : addHeapObject(ret);1207 } catch (e) {1208 logError(e)1209 }1210 };1211 imports.wbg.__widl_f_local_storage_Window = function(arg0) {1212 try {1213 try {1214 const ret = getObject(arg0).localStorage;1215 return isLikeNone(ret) ? 0 : addHeapObject(ret);1216 } catch (e) {1217 handleError(e)1218 }1219 } catch (e) {1220 logError(e)1221 }1222 };1223 imports.wbg.__widl_f_error_1_ = function(arg0) {1224 try {1225 console.error(getObject(arg0));1226 } catch (e) {1227 logError(e)1228 }1229 };1230 imports.wbg.__wbg_forEach_233111cfe44b80fc = function(arg0, arg1, arg2) {1231 const state0 = {a: arg1, b: arg2};1232 const cb0 = (arg0, arg1, arg2) => {1233 const a = state0.a;1234 state0.a = 0;1235 try {1236 return __wbg_elem_binding3(a, state0.b, arg0, arg1, arg2);1237 } finally {1238 state0.a = a;1239 }1240 };1241 try {1242 try {1243 getObject(arg0).forEach(cb0);1244 } catch (e) {1245 logError(e)1246 }1247 } finally {1248 state0.a = state0.b = 0;1249 }1250 };1251 imports.wbg.__wbg_newnoargs_ccf8cbd1628a0c21 = function(arg0, arg1) {1252 try {1253 const ret = new Function(getStringFromWasm(arg0, arg1));1254 return addHeapObject(ret);1255 } catch (e) {1256 logError(e)1257 }1258 };1259 imports.wbg.__wbg_call_1c71dead4ddfc1a7 = function(arg0, arg1) {1260 try {1261 try {1262 const ret = getObject(arg0).call(getObject(arg1));1263 return addHeapObject(ret);1264 } catch (e) {1265 handleError(e)1266 }1267 } catch (e) {1268 logError(e)1269 }1270 };1271 imports.wbg.__wbg_call_9a450f735fcf1a81 = function(arg0, arg1, arg2) {1272 try {1273 try {1274 const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));1275 return addHeapObject(ret);1276 } catch (e) {1277 handleError(e)1278 }1279 } catch (e) {1280 logError(e)1281 }1282 };1283 imports.wbg.__wbg_is_6ea0f39f2d2d2335 = function(arg0, arg1) {1284 try {1285 const ret = Object.is(getObject(arg0), getObject(arg1));1286 _assertBoolean(ret);1287 return ret;1288 } catch (e) {1289 logError(e)1290 }1291 };1292 imports.wbg.__wbg_new_2d18bd51e2172a0d = function(arg0, arg1) {1293 const state0 = {a: arg0, b: arg1};1294 const cb0 = (arg0, arg1) => {1295 const a = state0.a;1296 state0.a = 0;1297 try {1298 return __wbg_elem_binding4(a, state0.b, arg0, arg1);1299 } finally {1300 state0.a = a;1301 }1302 };1303 try {1304 try {1305 const ret = new Promise(cb0);1306 return addHeapObject(ret);1307 } catch (e) {1308 logError(e)1309 }1310 } finally {1311 state0.a = state0.b = 0;1312 }1313 };1314 imports.wbg.__wbg_resolve_3457814e095bea39 = function(arg0) {1315 try {1316 const ret = Promise.resolve(getObject(arg0));1317 return addHeapObject(ret);1318 } catch (e) {1319 logError(e)1320 }1321 };1322 imports.wbg.__wbg_then_f8ceb6d7f2902004 = function(arg0, arg1) {1323 try {1324 const ret = getObject(arg0).then(getObject(arg1));1325 return addHeapObject(ret);1326 } catch (e) {1327 logError(e)1328 }1329 };1330 imports.wbg.__wbg_then_2b35dcc92370b6f9 = function(arg0, arg1, arg2) {1331 try {1332 const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));1333 return addHeapObject(ret);1334 } catch (e) {1335 logError(e)1336 }1337 };1338 imports.wbg.__wbg_globalThis_e18edfcaa69970d7 = function() {1339 try {1340 try {1341 const ret = globalThis.globalThis;1342 return addHeapObject(ret);1343 } catch (e) {1344 handleError(e)1345 }1346 } catch (e) {1347 logError(e)1348 }1349 };1350 imports.wbg.__wbg_self_c263ff272c9c2d42 = function() {1351 try {1352 try {1353 const ret = self.self;1354 return addHeapObject(ret);1355 } catch (e) {1356 handleError(e)1357 }1358 } catch (e) {1359 logError(e)1360 }1361 };1362 imports.wbg.__wbg_window_043622d0c8518027 = function() {1363 try {1364 try {1365 const ret = window.window;1366 return addHeapObject(ret);1367 } catch (e) {1368 handleError(e)1369 }1370 } catch (e) {1371 logError(e)1372 }1373 };1374 imports.wbg.__wbg_global_7e97ac1b8ea927d0 = function() {1375 try {1376 try {1377 const ret = global.global;1378 return addHeapObject(ret);1379 } catch (e) {1380 handleError(e)1381 }1382 } catch (e) {1383 logError(e)1384 }1385 };1386 imports.wbg.__wbindgen_is_undefined = function(arg0) {1387 const ret = getObject(arg0) === undefined;1388 _assertBoolean(ret);1389 return ret;1390 };1391 imports.wbg.__wbindgen_string_get = function(arg0, arg1) {1392 const obj = getObject(arg0);1393 if (typeof(obj) !== 'string') return 0;1394 const ptr = passStringToWasm(obj);1395 getUint32Memory()[arg1 / 4] = WASM_VECTOR_LEN;1396 const ret = ptr;1397 _assertNum(ret);1398 return ret;1399 };1400 imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {1401 const ret = debugString(getObject(arg1));1402 const ret0 = passStringToWasm(ret);1403 const ret1 = WASM_VECTOR_LEN;1404 getInt32Memory()[arg0 / 4 + 0] = ret0;1405 getInt32Memory()[arg0 / 4 + 1] = ret1;1406 };1407 imports.wbg.__wbindgen_throw = function(arg0, arg1) {1408 throw new Error(getStringFromWasm(arg0, arg1));1409 };1410 imports.wbg.__wbindgen_closure_wrapper455 = function(arg0, arg1, arg2) {1411 const state = { a: arg0, b: arg1, cnt: 1 };1412 const real = (arg0) => {1413 state.cnt++;1414 const a = state.a;1415 state.a = 0;1416 try {1417 return __wbg_elem_binding0(a, state.b, arg0);1418 } finally {1419 if (--state.cnt === 0) wasm.__wbg_function_table.get(8)(a, state.b);1420 else state.a = a;1421 }1422 }1423 ;1424 real.original = state;1425 try {1426 const ret = real;1427 return addHeapObject(ret);1428 } catch (e) {1429 logError(e)1430 }1431 };1432 imports.wbg.__wbindgen_closure_wrapper457 = function(arg0, arg1, arg2) {1433 const state = { a: arg0, b: arg1, cnt: 1 };1434 const real = (arg0) => {1435 state.cnt++;1436 const a = state.a;1437 state.a = 0;1438 try {1439 return __wbg_elem_binding1(a, state.b, arg0);1440 } finally {1441 if (--state.cnt === 0) wasm.__wbg_function_table.get(10)(a, state.b);1442 else state.a = a;1443 }1444 }1445 ;1446 real.original = state;1447 try {1448 const ret = real;1449 return addHeapObject(ret);1450 } catch (e) {1451 logError(e)1452 }1453 };1454 imports.wbg.__wbindgen_closure_wrapper6640 = function(arg0, arg1, arg2) {1455 const state = { a: arg0, b: arg1, cnt: 1 };1456 const real = (arg0) => {1457 state.cnt++;1458 const a = state.a;1459 state.a = 0;1460 try {1461 return __wbg_elem_binding2(a, state.b, arg0);1462 } finally {1463 if (--state.cnt === 0) wasm.__wbg_function_table.get(163)(a, state.b);1464 else state.a = a;1465 }1466 }1467 ;1468 real.original = state;1469 try {1470 const ret = real;1471 return addHeapObject(ret);1472 } catch (e) {1473 logError(e)1474 }1475 };1476 if ((typeof URL === 'function' && module instanceof URL) || typeof module === 'string' || (typeof Request === 'function' && module instanceof Request)) {1477 const response = fetch(module);1478 if (typeof WebAssembly.instantiateStreaming === 'function') {1479 result = WebAssembly.instantiateStreaming(response, imports)1480 .catch(e => {1481 return response1482 .then(r => {1483 if (r.headers.get('Content-Type') != 'application/wasm') {1484 console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);1485 return r.arrayBuffer();1486 } else {1487 throw e;...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...36 console[opts.logLevel](msg);37 opts.msg = msg;38 prependLogMessage(opts);39}40function logError(msg, error){41 if(typeof error === 'object'){42 msg += ': ' + JSON.stringify(error);43 }else if(typeof error === 'string'){44 msg += ': ' + error;45 }46 log(msg, {47 logLevel: "error"48 });49}50function clearLog(){51 $output.empty();52}53// Init54function onDeviceReady(){55 FirebasePlugin = window.FirebasePlugin;56 $output = $('#log-output');57 log("deviceready");58 document.getElementById("cameraTakePicture").addEventListener 59 ("click", cameraTakePicture); 60 document.getElementById("cameraGetPicture").addEventListener("click", cameraGetPicture); 61 // Set global error handler to catch uncaught JS exceptions62 var appRootURL = window.location.href.replace("index.html",'');63 window.onerror = function(errorMsg, url, line, col, error) {64 var logMessage = errorMsg;65 var stackTrace = null;66 var sendError = function(){67 FirebasePlugin.logError(logMessage, stackTrace, function(){68 log("Sent JS exception trace");69 },function(error){70 logError("Failed to send JS exception trace", error);71 });72 };73 logMessage += ': url='+url.replace(appRootURL, '')+'; line='+line+'; col='+col;74 if(typeof error === 'object'){75 StackTrace.fromError(error).then(function(trace){76 stackTrace = trace;77 sendError()78 });79 }else{80 sendError();81 }82 };83 //Register handlers84 FirebasePlugin.onMessageReceived(function(message) {85 try{86 console.log("onMessageReceived");87 console.dir(message);88 if(message.messageType === "notification"){89 handleNotificationMessage(message);90 }else{91 handleDataMessage(message);92 }93 }catch(e){94 logError("Exception in onMessageReceived callback: "+e.message);95 }96 }, function(error) {97 logError("Failed receiving FirebasePlugin message", error);98 });99 FirebasePlugin.onTokenRefresh(function(token){100 log("Token refreshed: " + token)101 }, function(error) {102 logError("Failed to refresh token", error);103 });104 checkNotificationPermission(false); // Check permission then get token105 checkAutoInit();106 // Platform-specific107 $('body').addClass(cordova.platformId);108 if(cordova.platformId === "android"){109 initAndroid();110 }else if(cordova.platformId === "ios"){111 initIos();112 }113}114$(document).on('deviceready', onDeviceReady);115var initIos = function(){116 FirebasePlugin.onApnsTokenReceived(function(token){117 log("APNS token received: " + token)118 }, function(error) {119 logError("Failed to receive APNS token", error);120 });121};122var initAndroid = function(){123 // Custom FCM receiver plugin124 cordova.plugin.customfcmreceiver.registerReceiver(function(message){125 log("Received custom message: "+message);126 });127 // Define custom channel - all keys are except 'id' are optional.128 var customChannel = {129 // channel ID - must be unique per app package130 id: "my_channel_id",131 // Channel name. Default: empty string132 name: "My channel name",133 //The sound to play once a push comes. Default value: 'default'134 //Values allowed:135 //'default' - plays the default notification sound136 //'ringtone' - plays the currently set ringtone137 //filename - the filename of the sound file located in '/res/raw' without file extension (mysound.mp3 -> mysound)138 sound: "blackberry",139 //Vibrate on new notification. Default value: true140 //Possible values:141 //Boolean - vibrate or not142 //Array - vibration pattern - e.g. [500, 200, 500] - milliseconds vibrate, milliseconds pause, vibrate, pause, etc.143 vibration: [300, 200, 300],144 // Whether to blink the LED145 light: true,146 //LED color in ARGB format - this example BLUE color. If set to -1, light color will be default. Default value: -1.147 lightColor: "0xFF0000FF",148 //Importance - integer from 0 to 4. Default value: 3149 //0 - none - no sound, does not show in the shade150 //1 - min - no sound, only shows in the shade, below the fold151 //2 - low - no sound, shows in the shade, and potentially in the status bar152 //3 - default - shows everywhere, makes noise, but does not visually intrude153 //4 - high - shows everywhere, makes noise and peeks154 importance: 4,155 //Show badge over app icon when non handled pushes are present. Default value: true156 badge: true,157 //Show message on locked screen. Default value: 1158 //Possible values (default 1):159 //-1 - secret - Do not reveal any part of the notification on a secure lockscreen.160 //0 - private - Show the notification on all lockscreens, but conceal sensitive or private information on secure lockscreens.161 //1 - public - Show the notification in its entirety on all lockscreens.162 visibility: 1163 };164 FirebasePlugin.createChannel(customChannel,165 function() {166 log("Created custom channel: "+customChannel.id);167 FirebasePlugin.listChannels(168 function(channels) {169 if(typeof channels == "undefined") return;170 for(var i=0;i<channels.length;i++) {171 log("Channel id=" + channels[i].id + "; name=" + channels[i].name);172 }173 },174 function(error) {175 logError('List channels error: ' + error);176 }177 );178 },179 function(error) {180 logError("Create channel error", error);181 }182 );183};184// Notifications185var checkNotificationPermission = function(requested){186 FirebasePlugin.hasPermission(function(hasPermission){187 if(hasPermission){188 log("Remote notifications permission granted");189 // Granted190 getToken();191 }else if(!requested){192 // Request permission193 log("Requesting remote notifications permission");194 FirebasePlugin.grantPermission(checkNotificationPermission.bind(this, true));195 }else{196 // Denied197 logError("Notifications won't be shown as permission is denied");198 }199 });200};201var checkAutoInit = function(){202 FirebasePlugin.isAutoInitEnabled(function(enabled){203 log("Auto init is " + (enabled ? "enabled" : "disabled"));204 $('body')205 .addClass('autoinit-' + (enabled ? 'enabled' : 'disabled'))206 .removeClass('autoinit-' + (enabled ? 'disabled' : 'enabled'));207 }, function(error) {208 logError("Failed to check auto init", error);209 });210};211var enableAutoInit = function(){212 FirebasePlugin.setAutoInitEnabled(true, function(){213 log("Enabled auto init");214 checkAutoInit();215 }, function(error) {216 logError("Failed to enable auto init", error);217 });218};219var disableAutoInit = function(){220 FirebasePlugin.setAutoInitEnabled(false, function(){221 log("Disabled auto init");222 checkAutoInit();223 }, function(error) {224 logError("Failed to disable auto init", error);225 });226};227var getID = function(){228 FirebasePlugin.getId(function(id){229 log("Got FCM ID: " + id)230 }, function(error) {231 logError("Failed to get FCM ID", error);232 });233};234var getToken = function(){235 FirebasePlugin.getToken(function(token){236 log("Got FCM token: " + token);237 localStorage.setItem('FCMToken', token);238 }, function(error) {239 logError("Failed to get FCM token", error);240 });241};242var getAPNSToken = function(){243 FirebasePlugin.getAPNSToken(function(token){244 log("Got APNS token: " + token)245 }, function(error) {246 logError("Failed to get APNS token", error);247 });248};249var handleNotificationMessage = function(message){250 var title;251 if(message.title){252 title = message.title;253 }else if(message.notification && message.notification.title){254 title = message.notification.title;255 }else if(message.aps && message.aps.alert && message.aps.alert.title){256 title = message.aps.alert.title;257 }258 var body;259 if(message.body){260 body = message.body;261 }else if(message.notification && message.notification.body){262 body = message.notification.body;263 }else if(message.aps && message.aps.alert && message.aps.alert.body){264 body = message.aps.alert.body;265 }266 var msg = "Notification message received";267 if(message.tap){268 msg += " (tapped in " + message.tap + ")";269 }270 if(title){271 msg += '; title='+title;272 }273 if(body){274 msg += '; body='+body;275 }276 msg += ": "+ JSON.stringify(message);277 log(msg);278};279var handleDataMessage = function(message){280 log("Data message received: " + JSON.stringify(message));281};282function clearNotifications(){283 FirebasePlugin.clearAllNotifications(function(){284 log("Cleared all notifications");285 },function(error){286 logError("Failed to clear notifications", error);287 });288}289function subscribe(){290 FirebasePlugin.subscribe("my_topic", function(){291 log("Subscribed to topic");292 },function(error){293 logError("Failed to subscribe to topic", error);294 });295}296function unsubscribe(){297 FirebasePlugin.unsubscribe("my_topic", function(){298 log("Unsubscribed from topic");299 },function(error){300 logError("Failed to unsubscribe from topic", error);301 });302}303function getBadgeNumber(){304 FirebasePlugin.getBadgeNumber(function(number){305 log("Current badge number: "+number);306 },function(error){307 logError("Failed to get badge number", error);308 });309}310function incrementBadgeNumber(){311 FirebasePlugin.getBadgeNumber(function(current){312 var number = current+1;313 FirebasePlugin.setBadgeNumber(number, function(){314 log("Set badge number to: "+number);315 },function(error){316 logError("Failed to set badge number", error);317 });318 },function(error){319 logError("Failed to get badge number", error);320 });321}322function clearBadgeNumber(){323 FirebasePlugin.setBadgeNumber(0, function(){324 log("Cleared badge number");325 },function(error){326 logError("Failed to clear badge number", error);327 });328}329function unregister(){330 FirebasePlugin.unregister(function(){331 log("Unregistered from Firebase");332 },function(error){333 logError("Failed to unregister from Firebase", error);334 });335}336// Crashlytics337function setCrashlyticsCollectionEnabled(){338 FirebasePlugin.setCrashlyticsCollectionEnabled( function(){339 log("Enabled crashlytics data collection");340 },function(error){341 logError("Failed to enable crashlytics data collection", error);342 });343}344function setCrashlyticsUserId(){345 FirebasePlugin.setCrashlyticsUserId("crashlytics_user_id", function(){346 log("Set crashlytics user ID");347 },function(error){348 logError("Failed to set crashlytics user ID", error);349 });350}351function sendNonFatal(){352 FirebasePlugin.logError("This is a non-fatal error", function(){353 log("Sent non-fatal error");354 },function(error){355 logError("Failed to send non-fatal error", error);356 });357}358function causeJsException(){359 // Cause an uncaught JS exception360 var foo = someUndefinedVariable.bar;361}362function logCrashMessage(){363 FirebasePlugin.logMessage("A custom message about this crash", function(){364 console.log("Logged crash message - it will be sent with the next crash");365 },function(error){366 logError("Failed to log crash message", error);367 });368}369function sendCrash(){370 FirebasePlugin.sendCrash();371}372// Analytics373function setAnalyticsCollectionEnabled(){374 FirebasePlugin.setAnalyticsCollectionEnabled(true, function(){375 log("Enabled analytics data collection");376 },function(error){377 logError("Failed to enable analytics data collection", error);378 });379}380function logEvent(){381 FirebasePlugin.logEvent("my_event", {382 string: "bar",383 integer: 10,384 float: 1.234385 }, function(){386 log("Logged event");387 },function(error){388 logError("Failed to log event", error);389 });390}391function setScreenName(){392 FirebasePlugin.setScreenName("my_screen", function(){393 log("Sent screen name");394 },function(error){395 logError("Failed to send screen name", error);396 });397}398function setUserID(){399 FirebasePlugin.setUserId("user_id", function(){400 log("Set user ID");401 },function(error){402 logError("Failed to set user ID", error);403 });404}405function setUserProperty(){406 FirebasePlugin.setUserProperty("some_key", "some_value", function(){407 log("Set user property");408 },function(error){409 logError("Failed to set user property", error);410 });411}412// Performance413function setPerformanceCollectionEnabled(){414 FirebasePlugin.setPerformanceCollectionEnabled(true, function(){415 log("Enabled performance data collection");416 },function(error){417 logError("Failed to enable performance data collection", error);418 });419}420var traceName = "my_trace";421function startTrace(){422 FirebasePlugin.startTrace(traceName, function(){423 log("Trace started");424 },function(error){425 logError("Failed to start trace", error);426 });427}428function incrementCounter(){429 FirebasePlugin.incrementCounter(traceName, "my_counter", function(){430 log("Incremented trace counter");431 },function(error){432 logError("Failed to increment trace counter", error);433 });434}435function stopTrace(){436 FirebasePlugin.stopTrace(traceName, function(){437 log("Trace stopped");438 },function(error){439 logError("Failed to stop trace", error);440 });441}442// Remote config443function fetch(){444 FirebasePlugin.fetch(function(){445 log("Remote config fetched");446 $('#remote_activate').removeAttr('disabled');447 },function(error){448 logError("Failed to fetch remote config", error);449 });450}451function activateFetched(){452 FirebasePlugin.activateFetched(function(activated){453 log("Remote config was activated: " + activated);454 if(activated){455 $('#remote_getValue').removeAttr('disabled');456 }457 },function(error){458 logError("Failed to activate remote config", error);459 });460}461function getValue(){462 FirebasePlugin.getValue("background_color", function(value){463 log("Get remote config activated: " + value);464 if(value){465 $('body').css('background-color', value);466 }467 },function(error){468 logError("Failed to activate remote config", error);469 });470}471// Authentication472var verificationId;473function verifyPhoneNumber(){474 var phoneNumber = $('#phoneNumberInput').val().trim();475 if(!phoneNumber) return logError("Valid phone number must be entered");476 var timeoutInSeconds = 60;477 var fakeVerificationCode = $('#mockInstantVerificationInput')[0].checked ? '123456' : null;478 FirebasePlugin.verifyPhoneNumber(function(credential) {479 log("Received phone number verification credential");480 console.dir(credential);481 verificationId = credential.verificationId;482 if(credential.instantVerification){483 log("Using instant verification code");484 $('#verificationCodeInput').val(credential.code);485 }486 $('#useVerificationCode').show();487 }, function(error) {488 logError("Failed to verify phone number", error);489 }, phoneNumber, timeoutInSeconds, fakeVerificationCode,);490}491function signInWithCredential(){492 var code = $('#verificationCodeInput').val().trim();493 if(!code) return logError("Verification code must be entered");494 FirebasePlugin.signInWithCredential(verificationId, code, function() {495 log("Successfully signed in");496 }, function(error) {497 logError("Failed to sign in", error);498 });499}500function linkUserWithCredential(){501 var code = $('#verificationCodeInput').val().trim();502 if(!code) return logError("Verification code must be entered");503 FirebasePlugin.linkUserWithCredential(verificationId, code, function() {504 log("Successfully linked user");505 }, function(error) {506 logError("Failed to link user", error);507 });508}509function cameraTakePicture() { 510 navigator.camera.getPicture(onSuccess, onFail, { 511 quality: 50, 512 destinationType: Camera.DestinationType.DATA_URL 513 }); 514 515 function onSuccess(imageData) { 516 var image = document.getElementById('myImage'); 517 image.src = "data:image/jpeg;base64," + imageData; 518 } 519 520 function onFail(message) { ...

Full Screen

Full Screen

Compiler.js

Source:Compiler.js Github

copy

Full Screen

1var Greytyphoon = { Characters: [] };2function logError(val) {3 let p = document.createElement("p");4 p.className = "error";5 p.innerHTML = val;6 document.querySelector("body > .container").appendChild(p);7}8/* Main */9function main() {10 for (let character of Greytyphoon.Characters) {11 // Check the name first12 let name = character.name;13 if (!name || name == "" || typeof name != "string") {14 logError("Found a character with no name: " + character);15 continue;16 }17 checkOverProperties(character);18 checkMeta(character);19 checkAlignment(character);20 checkAncestry(character);21 checkLevels(character);22 checkStat(character.str);23 checkStat(character.dex);24 checkStat(character.con);25 checkStat(character.int);26 checkStat(character.wis);27 checkStat(character.cha);28 checkTraits(character);29 checkStartingFeats(character);30 checkProgressFeats(character);31 checkTargetFeats(character);32 checkSpells(character);33 checkEquipment(character);34 checkLoot(character);35 if (character.flair) OptionalChecks.checkFlair(character);36 if (character.deity) OptionalChecks.checkDeity(character);37 if (character.languages) OptionalChecks.checkLanguages(character);38 // closing message39 let p = document.createElement("p");40 p.innerHTML = "Finished inspecting " + name;41 document.querySelector("body > .container").appendChild(p);42 }43}44function checkMeta(character) {45 // Self-check46 if (!character.meta || typeof character.meta != "object") {47 logError(character.name + "'s meta property is wrong");48 return;49 }50 // Accepted properties51 var metaAccepts = ["quest", "owner", "companion", "source"];52 for (let metaProp in character.meta)53 if (!metaAccepts.includes(metaProp))54 logError(character.name + "'s meta's " + prop + " property is not supported");55 // Simple properties56 if (!character.meta.quest || typeof character.meta.quest != "string")57 logError(character.name + "'s meta.quest property is wrong");58 if (!character.meta.owner || typeof character.meta.owner != "string")59 logError(character.name + "'s meta.owner property is wrong");60 // Complex/children properties61 if (character.meta.companion) OptionalChecks.checkCompanion(character);62 if (character.meta.source) OptionalChecks.checkSource(character);63}64function checkAlignment(character) {65 // Alignment is mandatory. Must be a valid, two-letters alignment.66 if (!character.alignment) {67 logError(character.name + " has no alignment");68 return;69 }70 var alignmentAccepts = ["LG", "NG", "CG", "LN", "N", "CN", "LE", "NE", "CE"];71 if (!alignmentAccepts.includes(character.alignment))72 logError(character.name + "'s alignment was not recognized");73}74function checkAncestry(character) {75 // Self-check76 if (!character.ancestry) {77 logError(character.name + " has no ancestry");78 return;79 }80 // Accepted properties81 var ancestryAccepts= ["name", "url", "archetypes"];82 for (let ancestryProp in character.ancestry)83 if (!ancestryAccepts.includes(ancestryProp))84 logError(character.name + "'s ancestry's " + ancestryProp + " property is not supported");85 // Simple properties86 if (!character.ancestry.name || typeof character.ancestry.name != "string")87 logError(character.name + "'s ancestry has no name.");88 if (!character.ancestry.url || typeof character.ancestry.url != "string")89 logError(character.name + "'s ancestry has no url.");90 // Complex/children properties91 if (character.ancestry.archetypes) {92 if (typeof character.ancestry.archetypes != "object" || character.ancestry.archetypes.constructor !== Array)93 logError(character.name + "'s ancestry's archetype is not formatted correctly");94 else95 for (let ancestryArch of character.ancestry.archetypes)96 checkAncestryArchetype(ancestryArch);97 }98}99function checkAncestryArchetype(archetype) {100 // Self-check101 if (!archetype || typeof archetype != "string") {102 logError("Bad Ancestry Archetype");103 }104}105function checkLevels(character) {106 if (typeof character.level != "object" || character.level.constructor !== Array) {107 logError(character.name + "'s level is not formatted correctly");108 return;109 }110 if (character.level.length < 1)111 logError(character.name + " has no levels");112 for (let level of character.level)113 checkSingleLevel(level);114}115function checkSingleLevel(level) {116 // Self-check117 if (!level || typeof level != "object") {118 logError("Bad level");119 return;120 }121 // Accepted properties122 var levelAccepts = ["name", "url", "quantity", "archetypes"];123 for (let levelProp in level)124 if (!levelAccepts.includes(levelProp))125 logError("Invalid level property: " + levelProp);126 // Simple properties127 if (!level.name || typeof level.name != "string")128 logError("Bad level name");129 if (!level.url || typeof level.url != "string")130 logError("Bad level url");131 if (!level.quantity || typeof level.quantity != "number" || level.quantity < 1 || level.quantity > 20)132 logError("Bad level quantity");133 // Complex/children properties134 if (level.archetypes)135 {136 if (typeof level.archetypes != "object" || level.archetypes.constructor !== Array)137 logError("Level Archetype is not an array");138 else139 for (let archetype of level.archetypes)140 checkLevelArchetype(archetype);141 }142}143function checkLevelArchetype(archetype) {144 // Self-check145 if (!archetype || typeof archetype != "object") {146 logError("Archetype has bad format");147 return;148 }149 // Accepted properties150 var lvlArchetypeAccepts = ["title", "name", "url"];151 for (let archProp in archetype)152 if (!lvlArchetypeAccepts.includes(archProp))153 logError("Unknown property: " + archProp);154 // Simple properties155 if (!archetype.name || typeof archetype.name != "string")156 logError("Bad Archetype Name");157 if (!archetype.url || typeof archetype.url != "string")158 logError("Bad Archetype url");159 if (archetype.title && typeof archetype.title != "string")160 logError("Bad Archetype Title");161}162function checkStat(stat) {163 // Stat is either an int (no mods) or an array [base, {mod}, {mod}]164 if (typeof stat == "number") {165 if (stat < 7 || stat > 17)166 logError("Impossible unmodded stat");167 return;168 }169 if (typeof stat != "object" || stat.constructor !== Array) {170 logError("Invalid stat format:" + stat);171 return172 }173 if (typeof stat[0] != "number" || stat[0] < 7 || stat[0] > 18)174 logError("Invalid first stat");175 for (let statMod of stat.splice(1, stat.length))176 checkStatModifier(statMod);177}178function checkStatModifier(mod) {179 // Self-check180 if (!mod || typeof mod != "object") {181 logError("Bad stat mod");182 return;183 }184 // Accepted properties185 var statModAccepts = ["points", "reason"];186 for (let modProp in mod)187 if (!statModAccepts.includes(modProp))188 logError("Unsupported stat modifier property: " + modProp);189 // Simple Properties190 if (!mod.points || typeof mod.points != "number" || mod.points > 6 || mod.points < -6)191 logError("Invalid stat modifier points");192 if (!mod.reason || typeof mod.reason != "string")193 logError("Invalid stat modifier reason");194}195function checkTraits(character) {196 if (!character.traits || typeof character.traits != "object" || character.traits.constructor !== Array)197 logError("Bad Traits");198 else199 for (let trait of character.traits)200 checkSingleTrait(trait);201}202function checkSingleTrait(trait) {203 // Self-check204 if (!trait || typeof trait != "object") {205 logError("Bad Trait");206 return;207 }208 // Accepted properties209 var traitAccepts = ["name", "url", "drawback"];210 for (let traitProp in trait)211 if (!traitAccepts.includes(traitProp))212 logError("Unexpected property in trait");213 // Simple properties214 if (!trait.name || typeof trait.name != "string")215 logError("Bad trait name");216 if (!trait.url || typeof trait.url != "string")217 logError("Bad trait url");218 if (trait.drawback && typeof trait.drawback != "boolean")219 logError("Bad trait drawback");220}221function checkStartingFeats(character) {222 if (!character.startingFeats || typeof character.startingFeats != "object" || character.startingFeats.constructor !== Array)223 logError("Bad Starting Feats");224 else225 for (let sf of character.startingFeats)226 checkSingleFeat(sf);227}228function checkProgressFeats(character) {229 if (!character.progressFeats || typeof character.progressFeats != "object" || character.progressFeats.constructor !== Array)230 logError("Bad Progress Feats");231 else232 for (let sf of character.progressFeats)233 checkSingleFeat(sf);234}235function checkTargetFeats(character) {236 if (!character.targetFeats || typeof character.targetFeats != "object" || character.targetFeats.constructor !== Array)237 logError("Bad Target Feats");238 else239 for (let sf of character.targetFeats)240 checkSingleFeat(sf, true);241}242function checkSingleFeat(feat, isReasonOptional) {243 // Self-check244 if (!feat || typeof feat != "object") {245 logError("Bad Feat: " + feat);246 return;247 }248 // Accepted properties249 var featAccepts = ["name", "url", "title", "reason"];250 for (let featProp in feat)251 if (!featAccepts.includes(featProp))252 logError("Unsupported feat property: " + featProp);253 // Simple properties254 if (!feat.name || typeof feat.name != "string")255 logError("Bad feat name");256 if (feat.url && typeof feat.url != "string")257 logError("Bad feat url");258 if (feat.title && typeof feat.title != "string")259 logError("Bad feat title");260 if (feat.reason && typeof feat.reason != "string") // reason is present but the type is wrong261 logError("Bad feat reason");262 if (!feat.reason && !isReasonOptional) // reason is absent but it shouldn't263 logError("Feat reason is not optional in this case");264 if (feat.name == "Skill Focus" || feat.name == "Spell Focus" || feat.name == "Weapon Focus")265 logError("Untyped " + feat.name);266}267function checkSpells(character) {268 if (!character.spells || typeof character.spells != "object" || character.spells.constructor !== Array)269 logError("Bad Spells");270 else271 for (let spell of character.spells)272 checkSingleSpell(spell);273}274function checkSingleSpell(spell) {275 // Self-check276 if (!spell || typeof spell != "object") {277 logError("Bad spell: " + spell);278 return;279 }280 // Accepted properties281 var spellAccepts = ["level", "name", "url", "tag"];282 for (let spellProp in spell)283 if (!spellAccepts.includes(spellProp))284 logError("Unsupported spell property: " + spellProp);285 // Simple properties286 if (spell.level === null || spell.level === undefined || typeof spell.level != "number" || spell.level < 0 || spell.level > 9)287 logError("Bad spell level");288 if (!spell.name || typeof spell.name != "string")289 logError("Bad spell name");290 if (!spell.url || typeof spell.url != "string")291 logError("Bad spell url");292 if (spell.tag && typeof spell.tag != "string")293 logError("Bad spell tag");294}295function checkEquipment(character) {296 if (!character.equips || typeof character.equips != "object" || character.equips.constructor !== Array)297 logError("Bad Equipment");298 else299 for (let equip of character.equips)300 checkSingleEquip(equip);301}302function checkSingleEquip(weapon) {303 // Self-check304 if (!weapon || typeof weapon != "object") {305 logError("Bad weapon: " + weapon);306 return;307 }308 // Accepted properties309 var equipAccepts = ["slot", "value", "name", "url", "material", "bonus", "enchants", "quantity"];310 for (let equipProp in weapon)311 if (!equipAccepts.includes(equipProp))312 logError("Unsupported equipment property: " + equipProp);313 // Simple properties314 var slotAccepts = ["weapon-m", "weapon-r", "armor", "shield"];315 if (!weapon.slot || !slotAccepts.includes(weapon.slot))316 logError("Bad equipment slot");317 if (!weapon.name || typeof weapon.name != "string")318 logError("Bad equipment name");319 else if (weapon.name.includes("masterwork"))320 logError("Masterwork equipments are assumed");321 if (weapon.url && typeof weapon.url != "string") // Optional: always https://d20pfsrd.com/equipment/weapons if omitted322 logError("Bad equipment url");323 if (weapon.value && (typeof weapon.value != "number" || weapon.value < 1)) // Optional: always 300 (mwk) if omitted324 logError("Bad equipment value");325 if (weapon.bonus && (typeof weapon.bonus != "number" || weapon.bonus < 0 || weapon.bonus > 5))326 logError("Bad equipment bonus");327 if (weapon.quantity && (typeof weapon.quantity != "number" || weapon.quantity < 0))328 logError("Bad equipment quantity");329 // Complex/children properties330 if (weapon.material)331 checkEquipMaterial(weapon.material);332 if (weapon.enchants) {333 if (!weapon.bonus)334 logError("Can't add enchantments to a weapon without a bonus");335 if (typeof weapon.enchants != "object" || weapon.enchants.constructor !== Array)336 logError("Bad equipment enchants: not an array");337 else338 for (let enchant of weapon.enchants)339 checkEquipEnchant(enchant);340 }341}342function checkEquipMaterial(material) {343 // Self-check344 if (typeof material != "object") {345 logError("Bad weapon material");346 return;347 }348 // Accepted properties349 var equipAccepts = ["value", "name", "url"];350 for (let equipProp in material)351 if (!equipAccepts.includes(equipProp))352 logError("Unsupported material property: " + equipProp);353 // Simple properties354 if (!material.name || typeof material.name != "string")355 logError("Bad material name");356 if (!material.url || typeof material.url != "string")357 logError("Bad material url");358 if (!material.value || typeof material.value != "number" || material.value < 1)359 logError("Bad material value");360}361function checkEquipEnchant(enchant) {362 // Self-check363 if (!enchant || typeof enchant != "object") {364 logError("Bad weapon enchant");365 return;366 }367 // Accepted properties368 var equipAccepts = ["valueB", "valueF", "name", "url"];369 for (let equipProp in enchant)370 if (!equipAccepts.includes(equipProp))371 logError("Unsupported enchant property: " + equipProp);372 // Simple properties373 if (!enchant.name || typeof enchant.name != "string")374 logError("Bad enchant name");375 if (!enchant.url || typeof enchant.url != "string")376 logError("Bad enchant url");377 if (enchant.valueF && (typeof enchant.valueF != "number" || enchant.valueF < 1))378 logError("Bad enchant value(F)");379 if (enchant.valueB && (typeof enchant.valueB != "number" || enchant.valueB < 1 || enchant.valueB > 5))380 logError("Bad enchant value(B)");381 if (enchant.valueF && enchant.valueB)382 logError("Enchantment cannot have two values");383 if (!enchant.valueF && !enchant.valueB)384 logError("Enchantment must have one value");385}386function checkLoot(character) {387 if (!character.loot || typeof character.loot != "object" || character.loot.constructor !== Array)388 logError("Bad Loot");389 else390 for (let item of character.loot)391 checkSingleItem(item);392}393function checkSingleItem(item) {394 // Self-check395 if (!item || typeof item != "object") {396 logError("Bad item: " + item);397 return;398 }399 // Accepted properties400 var itemAccepts = ["slot", "value", "name", "url"];401 for (let itemProp in item)402 if (!itemAccepts.includes(itemProp))403 logError("Unsupported item property: " + itemProp);404 // Simple properties405 var slotAccepts = ["none", "head", "headband", "eyes",406 "neck", "shoulders", "chest",407 "body", "belt", "wrists",408 "hands", "ring", "feet"];409 if (!item.slot || !slotAccepts.includes(item.slot))410 logError("Bad item slot");411 if (!item.value || typeof item.value != "number" || item.value < 0)412 logError("Bad item value");413 if (!item.name || typeof item.name != "string")414 logError("Bad item name");415 if (!item.url || typeof item.url != "string")416 logError("Bad item url");417}418var OptionalChecks = {419 checkCompanion: function (character) {420 // Self-check421 if (typeof character.meta.companion != "object") {422 logError(character.name + "'s companion is not defined properly");423 return;424 }425 // Accepted properties426 var companionAccepts = ["name", "flair", "url"];427 for (let companionProp in character.meta.companion)428 if (!companionAccepts.includes(companionProp))429 logError(character.name + "'s companion's " + companionProp + " property is not supported");430 // Simple properties431 if (!character.meta.companion.name || typeof character.meta.companion.name != "string")432 logError(character.name + "'s companion has no name.");433 if (!character.meta.companion.url || typeof character.meta.companion.url != "string")434 logError(character.name + "'s companion has no url.");435 if (character.meta.companion.flair && typeof character.meta.companion.flair != "string")436 logError(character.name + "'s companion has an invalid flair");437 },438 checkSource: function (character) {439 // Self-check440 if (typeof character.meta.source != "object") {441 logError(character.name + "'s source is not defined properly");442 return;443 }444 // Accepted properties445 var sourceAccepts = ["name", "url"];446 for (let sourceProp in character.meta.source)447 if (!sourceAccepts.includes(sourceProp))448 logError(character.name + "'s source's " + sourceProp + " property is not supported");449 // Simple properties450 if (!character.meta.source.name || typeof character.meta.source.name != "string")451 logError(character.name + "'s source has no name.");452 if (!character.meta.source.url || typeof character.meta.source.url != "string")453 logError(character.name + "'s source has no url.");454 },455 checkFlair: function (character) {456 // If Flair is present, it must be a string.457 if (typeof character.flair != "string")458 logError(character.name + "'s flair is not a string");459 },460 checkDeity: function (character) {461 // Deity is either a string (god's name) or an object {name, url}462 if (typeof character.deity == "string")463 return;464 if (typeof character.deity != "object") {465 logError(character.name + "'s deity is invalid");466 return;467 }468 // Accepted properties469 var deityAccepts = ["name", "url"];470 for (let deityProp in character.deity)471 if (!deityAccepts.includes(deityProp))472 logError(character.name + "'s deity's " + deityProp + " property is not supported");473 // Simple properties474 if (!character.deity.name || typeof character.deity.name != "string")475 logError(character.name + "'s deity has no name.");476 if (!character.deity.url || typeof character.deity.url != "string")477 logError(character.name + "'s deity has no url.");478 },479 checkLanguages: function (character) {480 // If Languages is present, it must be a string.481 if (typeof character.languages != "string")482 logError(character.name + "'s language is not a string");483 },484}485function checkOverProperties(character) {486 var allAccepted = [487 "name", "flair", "meta",488 "alignment", "deity", "languages",489 "ancestry", "level",490 "str", "dex", "con", "int", "wis", "cha",491 "traits", "startingFeats", "progressFeats", "targetFeats",492 "spells", "equips", "loot"493 ];494 for (let prop in character)495 if (!allAccepted.includes(prop))496 logError(character.name + "'s " + prop + " property is not supported");...

Full Screen

Full Screen

actions.js

Source:actions.js Github

copy

Full Screen

...6 res => {7 if (res.response.status === 200) {8 commit(types.REFRESH_STAFF, res.result.data)9 } else {10 logError('获取员工列表失败', res.response.status)11 }12 },13 err => {14 logError('获取员工列表失败', err)15 }16 )17 },18 synchronizeOlist ({commit}) {19 let arr = []20 $fetch('notice/list?is_read=1').then(21 res => {22 if (res.response.status === 200) {23 res.result.data.forEach(v => {24 if (arr.length < 5) {25 arr.push(v)26 }27 })28 commit(types.MESSAGE_OLIST, arr)29 } else {30 logError('获取消息列表失败', res.response.status)31 }32 },33 err => {34 logError('获取消息列表失败', err)35 }36 )37 },38 synchronizeClearMsg ({commit}) {39 let arr = []40 commit(types.MESSAGE_OLIST, arr)41 // $fetch('notice/list?is_read=1').then(42 // res => {43 // if (res.response.status === 200) {44 // res.result.data.forEach(v => {45 // if (arr.length < 5) {46 // arr.push(v)47 // }48 // })49 // commit(types.MESSAGE_OLIST, arr)50 // } else {51 // logError('获取消息列表失败', res.response.status)52 // }53 // },54 // err => {55 // logError('获取消息列表失败', err)56 // }57 // )58 },59 synchronizeMsgCount ({commit}) {60 $fetch('notice/unread-count').then(61 res => {62 if (res.response.status === 200) {63 commit(types.MESSAGE_COUNT, res.result.data)64 } else {65 logError('获取未读消息失败', res.response.status)66 }67 },68 err => {69 logError('获取未读消息失败', err)70 }71 )72 },73 synchronizeStores ({commit}) {74 $fetch('store/list').then(75 res => {76 if (res.response.status === 200) {77 commit(types.REFRESH_STORES, res.result.data)78 } else {79 logError('获取门店列表失败', res.response.status)80 }81 },82 err => {83 logError('获取门店列表失败', err)84 }85 )86 },87 synchronizeInsurances ({commit}) {88 $fetch('insurance_companies').then(89 res => {90 if (res.response.status === 200) {91 commit(types.REFRESH_INSURANCES, res.result.data)92 } else {93 logError('获取保险公司列表失败', res.response.status)94 }95 },96 err => {97 logError('获取保险公司列表失败', err)98 }99 )100 },101 synchronizeBrands ({commit}) {102 $fetch('vehicles/brands').then(103 res => {104 if (res.response.status === 200) {105 commit(types.REFRESH_BRANDS, res.result.data)106 } else {107 logError('获取汽车品牌列表失败', res.response.status)108 }109 },110 err => {111 logError('获取汽车品牌列表失败', err)112 }113 )114 },115 synchronizeSalesAssistant ({commit}) {116 $fetch('sa/index_no_page', {query: {117 is_sa: true,118 }}).then(119 res => {120 if (res.response.status === 200) {121 commit(types.REFRESH_SALES_ASSISTANT, res.result.data)122 } else {123 logError('获取销售经理列表失败', res.response.status)124 }125 },126 err => {127 logError('获取销售经理列表失败', err)128 }129 )130 },131 synchronizeMechanic ({commit}) {132 $fetch('sa/index_no_page', {query: {133 is_mechanic: true,134 }}).then(135 res => {136 if (res.response.status === 200) {137 commit(types.REFRESH_MECHANIC, res.result.data)138 } else {139 logError('获取技工列表失败', res.response.status)140 }141 },142 err => {143 logError('获取技工列表失败', err)144 }145 )146 },147 synchronizeShopCategories ({commit}) {148 $fetch('shop/categories', {query: {149 with_items_count: true,150 }}).then(151 res => {152 if (res.response.status === 200) {153 commit(types.REFRESH_SHOP_CATEGORIES, res.result.data)154 } else {155 logError('获取分类列表失败', res.response.status)156 }157 },158 err => {159 logError('获取分类列表失败', err)160 }161 )162 },163 clearStores ({commit}) {164 commit(types.CLEAR__STORES)165 },166 // 获取企业微信是否授权167 syncAuthorizeStatus ({commit}) {168 $fetch('quick/work/register_info').then(169 res => {170 if (res.response.status === 200) {171 commit(types.WX_STATUS, res.result.data)172 } else {173 logError('获取企业微信授权信息失败', res.response.status)174 }175 },176 err => {177 logError('获取企业微信授权信息失败', err)178 }179 )180 },181 // 更新是否开启语音播报状态182 updateAudio ({commit}, message) {183 commit(types.JUDGE_AUDIO, message)184 },185 // 获取小程序申请二审核状态186 syncMiniStatus ({commit}) {187 $fetch('mini_program/get_update_mini_status', {188 method: 'POST',189 }).then(190 res => {191 if (res.response.status === 200) {192 commit(types.MINI_STATUS, res)193 } else {194 logError('获取小程序审核信息失败', res.response.status)195 }196 },197 err => {198 logError('获取小程序审核信息失败', err)199 }200 )201 },202}203function logError (title, error) {204 console.error(`[error] ${title}: ${(error && error.message) || '服务异常'}(${error && error.msgcode})`, error)...

Full Screen

Full Screen

ScouterDataService.js

Source:ScouterDataService.js Github

copy

Full Screen

...38 data: data,39 dataType: 'json'40 }).fail(function (errdata)41 {42 ds.logError("save", errdata);43 });44 },45 saveHuman: function (data)46 {47 var48 type = httpVerbs.POST,49 url = '/api/HumanEventsApi';50 return $.ajax(51 {52 type: type,53 url: url,54 data: data,55 dataType: 'json'56 }).fail(function (errdata)57 {58 ds.logError("save", errdata);59 });60 },61 saveStack: function (data) {62 var63 type = httpVerbs.POST,64 url = '/api/ScouterApi';65 return $.ajax(66 {67 type: type,68 url: url,69 data: data,70 dataType: 'json'71 }).fail(function (errdata) {72 ds.logError("saveStack", errdata);73 });74 },75 getScoutData: function ()76 {77 return $.ajax(78 {79 type: httpVerbs.GET,80 url: '/api/ScouterApi'81 }).fail(function (errdata)82 {83 ds.logError("getScoutData", errdata);84 });85 },86 updateScoutData: function (data)87 {88 return $.ajax(89 {90 type: httpVerbs.PATCH,91 url: '/api/ScoutDataApi/',92 data: data,93 dataType: 'JSON'94 }).fail(function (errdata)95 {96 ds.logError("updateScoutData", errdata);97 });98 },99 getMatchData: function(num)100 {101 return $.ajax(102 {103 type: httpVerbs.GET,104 url: '/api/ScoutManagerApi/' + num,105 }).fail(function (errdata)106 {107 ds.logError("getMatchData", errdata);108 });109 },110 setMatch: function(data)111 {112 return $.ajax(113 {114 type: httpVerbs.PUT,115 url: '/api/ScoutManagerApi/',116 data: data,117 dataType: 'JSON'118 }).fail(function (errdata)119 {120 ds.logError("setMatch", errdata);121 });122 },123 addNotes: function(data)124 {125 return $.ajax(126 {127 type: httpVerbs.POST,128 url: '/api/NotesApi/',129 data: data,130 dataType: 'JSON'131 }).fail(function (errdata)132 {133 ds.logError("addNotes", errdata);134 });135 },136 undo: function(num)137 {138 return $.ajax(139 {140 type: httpVerbs.DEL,141 url: '/api/ScoutDataApi/' + num142 }).fail(function (errdata)143 {144 ds.logError("undo", errdata);145 });146 },147 undoHuman: function (num)148 {149 return $.ajax(150 {151 type: httpVerbs.DEL,152 url: '/api/HumanEventsApi/' + num153 }).fail(function (errdata)154 {155 ds.logError("undo", errdata);156 });157 },158 undoStack: function (num) {159 return $.ajax(160 {161 type: httpVerbs.DEL,162 url: '/api/ScouterApi/' + num163 }).fail(function (errdata) {164 ds.logError("undoStack", errdata);165 });166 },167 updateCounter: function(num)168 {169 return $.ajax(170 {171 type: httpVerbs.GET,172 url: '/api/ScoutDataApi/' + num173 }).fail(function (errdata)174 {175 ds.logError("updateCounter", errdata);176 });177 },178 updateHumanCounter: function (num)179 {180 return $.ajax(181 {182 type: httpVerbs.GET,183 url: '/api/HumanEventsApi/' + num184 }).fail(function (errdata)185 {186 ds.logError("updateHumanCounter", errdata);187 });188 }189 };190 _.bindAll(ds, 'save', 'saveHuman', 'saveStack', 'getScoutData', 'updateScoutData', 'getMatchData', 'setMatch', 'addNotes', 'undo', 'undo', 'undoStack', 'updateCounter', 'updateHumanCounter');191 return {192 logError: ds.logError,193 save: ds.save,194 saveHuman: ds.saveHuman,195 saveStack: ds.saveStack,196 getScoutData: ds.getScoutData,197 updateScoutData: ds.updateScoutData,198 getMatchData: ds.getMatchData,199 setMatch: ds.setMatch,200 addNotes: ds.addNotes,...

Full Screen

Full Screen

index.test.js

Source:index.test.js Github

copy

Full Screen

...27 "Pellentesque gravida orci in tellus tristique, ac commodo nibh congue.";28 var error = new Error();29 error.name = name;30 error.message = message;31 logError("a label", error);32 assert(spy.called);33 assert(spy.calledWithMatch(name));34 assert(spy.calledWithMatch(message));35 });36 it("calls config.logger function with a stack", function() {37 var spy = this.sandbox.spy();38 var logError = configureLogError({39 logger: spy,40 setTimeout: this.timeOutStub,41 useImmediateExceptions: false42 });43 var stack =44 "Integer rutrum dictum elit, posuere accumsan nisi pretium vel. Phasellus adipiscing.";45 var error = new Error();46 error.stack = stack;47 logError("another label", error);48 assert(spy.called);49 assert(spy.calledWithMatch(stack));50 });51 it("should call config.setTimeout", function() {52 var logError = configureLogError({53 setTimeout: this.timeOutStub,54 useImmediateExceptions: false55 });56 var error = new Error();57 logError("some wonky label", error);58 assert(this.timeOutStub.calledOnce);59 });60 it("should pass a throwing function to config.setTimeout", function() {61 var logError = configureLogError({62 setTimeout: this.timeOutStub,63 useImmediateExceptions: false64 });65 var error = new Error();66 logError("async error", error);67 var func = this.timeOutStub.args[0][0];68 assert.exception(func);69 });70 describe("config.useImmediateExceptions", function() {71 beforeEach(function() {72 this.sandbox = sinon.createSandbox();73 this.timeOutStub = this.sandbox.stub();74 });75 afterEach(function() {76 this.sandbox.restore();77 });78 it("throws the logged error immediately, does not call logError.setTimeout when flag is true", function() {79 var error = new Error();80 var logError = configureLogError({81 setTimeout: this.timeOutStub,82 useImmediateExceptions: true83 });84 assert.exception(function() {85 logError("an error", error);86 });87 assert(this.timeOutStub.notCalled);88 });89 it("does not throw logged error immediately and calls logError.setTimeout when flag is false", function() {90 var error = new Error();91 var logError = configureLogError({92 setTimeout: this.timeOutStub,93 useImmediateExceptions: false94 });95 refute.exception(function() {96 logError("an error", error);97 });98 assert(this.timeOutStub.called);99 });100 });101 describe("#835", function() {102 it("logError() throws an exception if the passed err is read-only", function() {103 var logError = configureLogError({ useImmediateExceptions: true });104 // passes105 var err = {106 name: "TestError",107 message: "this is a proper exception"108 };109 assert.exception(110 function() {111 logError("#835 test", err);112 },113 {114 name: err.name115 }116 );117 // fails until this issue is fixed118 assert.exception(119 function() {120 logError(121 "#835 test",122 "this literal string is not a proper exception"123 );124 },125 {126 name: "#835 test"127 }128 );129 });130 });...

Full Screen

Full Screen

api.js

Source:api.js Github

copy

Full Screen

...27 setToken = (token)=> {28 this.token = token29 this.isLoggedIn=true30 }31 logError(error){32 errorHandler(error)33 }34 35 getBanners(bid,success,error){36 this.http.get('getbanner',{params:{bid:bid}}).then(success,error)37 }38 getNewsBanner(){39 return this.http.get('getnewsbanner')40 }41 getNewsNav(success,error=this.logError){42 this.http.get('getNewsNav').then(success,error)43 }44 getNewsList(success,error=this.logError){45 this.http.get('getNewsList').then(success,error)...

Full Screen

Full Screen

make-transaction.js

Source:make-transaction.js Github

copy

Full Screen

1const randomIntegerFromInterval = (min, max) => {2 return Math.floor(Math.random() * (max - min + 1) + min);3};4const makeTransaction = ({ id }) => {5 const delay = randomIntegerFromInterval(200, 500);6 return new Promise((resolve, reject) => {7 setTimeout(() => {8 const canProcess = Math.random() > 0.3;9 if (canProcess) {10 resolve({ id, time: delay });11 }12 reject(id);13 }, delay);14 });15};16const logSuccess = ({ id, time }) => {17 console.log(`Transaction ${id} processed in ${time}ms`);18};19const logError = (id) => {20 console.warn(`Error processing transaction ${id}. Please try again later.`);21};22/*23 * Работает так24 */25// makeTransaction({ id: 70, amount: 150 }, logSuccess, logError);26// makeTransaction({ id: 71, amount: 230 }, logSuccess, logError);27// makeTransaction({ id: 72, amount: 75 }, logSuccess, logError);28// makeTransaction({ id: 73, amount: 100 }, logSuccess, logError);29/*30 * Должно работать так31 */32makeTransaction({ id: 70, amount: 150 }).then(logSuccess).catch(logError);33makeTransaction({ id: 71, amount: 230 }).then(logSuccess).catch(logError);34makeTransaction({ id: 72, amount: 75 }).then(logSuccess).catch(logError);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const differencifyLogger = require('differencify-logger');2differencifyLogger.logError('This is an error message');3const differencifyLogger = require('differencify-logger');4differencifyLogger.logInfo('This is an info message');5const differencifyLogger = require('differencify-logger');6differencifyLogger.logWarning('This is an warning message');7const differencifyLogger = require('differencify-logger');8differencifyLogger.logSuccess('This is an success message');9const differencifyLogger = require('differencify-logger');10differencifyLogger.logDebug('This is an debug message');11const differencifyLogger = require('differencify-logger');12differencifyLogger.logTrace('This is an trace message');13const differencifyLogger = require('differencify-logger');14differencifyLogger.log('This is an log message');15const differencifyLogger = require('differencify-logger');16differencifyLogger.logWithTimestamp('This is an log message with timestamp');17const differencifyLogger = require('differencify-logger');18differencifyLogger.logErrorWithTimestamp('This is an error message with timestamp');19const differencifyLogger = require('differencify-logger');20differencifyLogger.logInfoWithTimestamp('This is an info message with timestamp');

Full Screen

Using AI Code Generation

copy

Full Screen

1const differencify = require("differencify");2differencify.init(browser, {3 {4 }5 {6 }7 {8 }9});10differencify.init(browser, options);11differencify.setViewportSize(width, height);12differencify.setScreenshotConfig(options);13differencify.setBlockOut(options);14differencify.setHideElements(options);15differencify.setIgnoreRectangles(options);16differencify.setIgnoreAntialiasing(options);17differencify.setIgnoreColors(options);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { logError } = require('differencify');2try {3 await page.waitForSelector('input[title="Search"]');4 await page.type('input[title="Search"]', 'hello');5 await page.click('input[value="Google Search"]');6 await page.waitForSelector('h3');7 await page.screenshot({ path: 'google.png' });8} catch (error) {9 logError(error);10}11If you run into any issues, please report them [here](

Full Screen

Using AI Code Generation

copy

Full Screen

1const differencify = require("differencify");2const { logError } = differencify;3describe("Differencify", () => {4 it("should log error", async () => {5 try {6 await page.screenshot({ path: "google.png" });7 } catch (error) {8 logError(error);9 }10 });11});12### `differencify.init(config: object)`13- `blockOut: Array<{ x: number, y: number, width: number, height: number }>` (default: `[]`) - An array of objects with the following properties:

Full Screen

Using AI Code Generation

copy

Full Screen

1import differencify from 'differencify';2import { logError } from 'differencify/src/utils/logger';3import { expect } from 'chai';4describe('Test differencify', () => {5 it('should throw error', async () => {6 const differencifyInstance = differencify.init();7 try {8 await differencifyInstance.checkElement('body', 'test');9 } catch (error) {10 logError(error);11 expect(error).to.be.instanceOf(Error);12 }13 });14});15{16 "scripts": {17 },18 "devDependencies": {19 }20}

Full Screen

Using AI Code Generation

copy

Full Screen

1var differencify = require('differencify');2var differencifyUtils = differencify.utils;3var differencifyInstance = differencify.init({4});5differencifyInstance.logError(new Error('Some error'));6differencifyUtils.logError(new Error('Some error'));7### init(options)8### setViewportSize(options)9### setScreenshotOptions(options)10### setDefaultOptions(options)11### setOptions(options)

Full Screen

Using AI Code Generation

copy

Full Screen

1const differencify = require('differencify');2const { logError } = differencify;3logError(new Error('test error'));4#### `logError(error, options)`5- `options.baseDir` - Base directory to save the error image. Default value is `process.cwd()`6### `setConfig(options)`7- `options.baseDir` - Base directory to save the error image. Default value is `process.cwd()`8### `getConfig()`9### `setDiffConfig(options)`10### `getDiffConfig()`11### `setDiffImageName(imageName)`12### `getDiffImageName()`13### `setReferenceImageName(imageName)`

Full Screen

Using AI Code Generation

copy

Full Screen

1const differencify = require('differencify');2differencify.init(browser, { logError: true });3const differencify = require('differencify');4differencify.init(browser, { logInfo: true });5const differencify = require('differencify');6differencify.init(browser, { logLevel: 'debug' });7const differencify = require('differencify');8differencify.init(browser, { logScreenshot: true });9const differencify = require('differencify');10differencify.init(browser, { logSuccess: true });11const differencify = require('differencify');12differencify.init(browser, { logTrace: true });13const differencify = require('differencify');14differencify.init(browser, { logWarn: true });

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run differencify automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful