miijs
Version:
The most complete and easy to use Mii library available.
37 lines (32 loc) • 9.35 kB
JavaScript
import{b as R,d as Se,e as Ne,f as I,g as pe,h as He,i as Ue,j as Re,k as _,l as ge,m as Ae,n as we,o as Ce,p as Le,q as Pe,r as Ge,s as m}from"./chunks/chunk-AD7HDZ5R.js";import{a as Z,d as y}from"./chunks/chunk-C7XDOTG6.js";import{b as O,d as U,f as l,g as a}from"./chunks/chunk-VMLSR5BU.js";var A=O((Be,g)=>{a();g.exports=function(e){return typeof e=="string"&&/[@?!+*]\(/.test(e)}});var C=O((Fe,w)=>{a();var z=A();w.exports=function(e){return typeof e=="string"&&(/[*!?{}(|)[\]]/.test(e)||z(e))}});var P=O((We,L)=>{"use strict";a();var X=C(),ee=/[‘“!#$%&+^<=>`]/;L.exports=function(t){return typeof t!="string"||X(t)||ee.test(t)}});var B=O((Ye,G)=>{"use strict";a();var te=P();G.exports=function(t){return te(t)===!1}});a();var W=U(Z(),1),K=U(B(),1);var{encodeMii:S,decodeMii:D,detectMiiFormat:ie}=_,{mappings:h,MiiFormats:s,ConsoleFormats:c}=m,{makeQR:re,scanQR:ne}=I,F={};function u(t,e){return F[t]??=e(),F[t]}var Y=()=>u("amiiboHandler",()=>import("./chunks/amiiboHandler-DJRKB37R.js")),E=()=>u("miiMeasureConversion",()=>import("./chunks/miiMeasureConversion-FX6GZ3HU.js")),oe=()=>u("miiRendering",()=>import("./chunks/miiRendering-DIBWLGPE.js")),p=()=>u("miiCrypto",()=>import("./chunks/miiCrypto-7URPNCBC.js")),H=()=>u("miiInstructions",()=>import("./chunks/miiInstructions-FJNU7F24.js")),b=()=>u("miiBabies",()=>import("./chunks/miiBabies-EVBBWW7R.js"));async function n(t,e,i){return(await t())[e](...i)}function x(t){return t&&typeof t.then=="function"}function se(t){return l.Buffer.isBuffer(t)||t instanceof Uint8Array||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}async function V(...t){return n(Y,"insertMiiIntoAmiibo",t)}async function ce(...t){return n(Y,"extractMiiFromAmiibo",t)}async function ae(...t){return n(E,"miiHeightToMeasurements",t)}async function fe(...t){return n(E,"inchesToMiiHeight",t)}async function le(...t){return n(E,"centimetersToMiiHeight",t)}async function ue(...t){return n(E,"miiWeightToMeasurements",t)}async function Ee(...t){return n(E,"imperialHeightWeightToMiiWeight",t)}async function de(...t){return n(E,"metricHeightWeightToMiiWeight",t)}async function $(...t){return n(oe,"renderMii",t)}async function Te(...t){return n(p,"decryptMii",t)}async function he(...t){return n(p,"encryptMii",t)}async function Me(...t){return n(p,"miiCrcCalc",t)}async function k(...t){return n(H,"makeInstructions",t)}async function j(...t){return n(H,"getAs",t)}async function J(...t){return n(H,"setAs",t)}async function Oe(...t){return n(b,"kidomatic",t)}async function ye(...t){return n(b,"makeMiiChild",t)}var Ie=Object.freeze({NORMAL:0,SMILE:1,ANGER:2,SORROW:3,PUZZLED:3,SURPRISE:4,SURPRISED:4,BLINK:5,OPEN_MOUTH:6,SMILE_OPEN_MOUTH:7,HAPPY:7,ANGER_OPEN_MOUTH:8,SORROW_OPEN_MOUTH:9,SURPRISE_OPEN_MOUTH:10,BLINK_OPEN_MOUTH:11,WINK_LEFT:12,WINK_RIGHT:13,WINK_LEFT_OPEN_MOUTH:14,WINK_RIGHT_OPEN_MOUTH:15,LIKE_WINK_LEFT:16,LIKE:16,LIKE_WINK_RIGHT:17,FRUSTRATED:18,BORED:19,BORED_OPEN_MOUTH:20,SIGH_MOUTH_STRAIGHT:21,SIGH:22,DISGUSTED_MOUTH_STRAIGHT:23,DISGUSTED:24,LOVE:25,LOVE_OPEN_MOUTH:26,DETERMINED_MOUTH_STRAIGHT:27,DETERMINED:28,CRY_MOUTH_STRAIGHT:29,CRY:30,BIG_SMILE_MOUTH_STRAIGHT:31,BIG_SMILE:32,CHEEKY:33,CHEEKY_DUPLICATE:34,JOJO_EYES_FUNNY_MOUTH:35,JOJO_EYES_FUNNY_MOUTH_OPEN:36,SMUG:37,SMUG_OPEN_MOUTH:38,RESOLVE:39,RESOLVE_OPEN_MOUTH:40,UNBELIEVABLE:41,UNBELIEVABLE_DUPLICATE:42,CUNNING:43,CUNNING_DUPLICATE:44,RASPBERRY:45,RASPBERRY_DUPLICATE:46,INNOCENT:47,INNOCENT_DUPLICATE:48,CAT:49,CAT_DUPLICATE:50,DOG:51,DOG_DUPLICATE:52,TASTY:53,TASTY_DUPLICATE:54,MONEY_MOUTH_STRAIGHT:55,MONEY:56,SPIRAL_MOUTH_STRAIGHT:57,CONFUSED:58,CHEERFUL_MOUTH_STRAIGHT:59,CHEERFUL:60,BLANK_61:61,BLANK_62:62,GRUMBLE_MOUTH_STRAIGHT:63,GRUMBLE:64,MOVED_MOUTH_STRAIGHT:65,MOVED:66,SINGING_MOUTH_SMALL:67,SINGING:68,STUNNED:69,MAX:70});function v(t,e){let i=e.split("."),r=t;for(let o=0;o<i.length-1;o++){if(r==null||!r.hasOwnProperty(i[o]))return;r=r[i[o]]}delete r[i[i.length-1]]}function Q(t,e){try{let i=e.split("."),r=t;for(let o of i){if(r==null)return;r=r[o]}return r}catch{return null}}function f(t,e){for(var i in t)if(t[i]===e)return i;return null}function q(t,e,i){try{let r=e.split("."),o=r.pop(),M=r.reduce((d,T)=>((!d[T]||typeof d[T]!="object"||Array.isArray(d[T]))&&(d[T]={}),d[T]),t);return M[o]=i,t}catch{throw new Error(`${e} was not usable.`)}}function _e(t){try{return new URL(t),!0}catch{return!1}}var N=class t{fields;constructor(e){if(typeof e=="object"&&e?.meta?.hasOwnProperty("favoriteColor"))this.fields=e;else{let i=D(e);if(x(i))throw new Error("This Mii format needs optional async decoding. Use await Mii.create(input) instead of new Mii(input).");this.fields=i}}static async create(e,i){typeof e=="string"&&((0,K.default)(e)&&y.existsSync(e)?e=await y.promises.readFile(e):_e(e)&&(e=await fetch(e),e=await e.buffer()));try{let o=ie(e);if(o.includes("png")||o.includes("jpg")||o.includes("webp")){let M=await ne(e);if(!M)throw new Error("Detected an image QR format (PNG/JPG/WEBP), but couldn't decode the QR code!");e=M}}catch{}let r=await D(e,i);return new t(r)}[Symbol.toPrimitive](e){return e==="string"?this.toString():this.toBuffer()}[W.default.inspect.custom](){return this.toString()}toString(e=s.MNMS){if(!s.hasOwnProperty(e)&&f(s,e)===null)throw new Error(`Unexpected format: ${e}. Expected one of: ${Object.keys(s).join(", ")}`);let i=S(this.fields,e);if(x(i))throw new Error("This format needs optional async encoding. Use await mii.encode(format) instead of mii.toString(format).");return i.toString("hex")}toBuffer(e=s.CHARINFO){return this.encode(e)}toJSON(){return structuredClone(this.fields)}set(e,i){if(e&&typeof e=="object")Object.assign(this.fields,e);else if(typeof e=="string"&&i!==void 0){if(h.hasOwnProperty(e))e=h[e];else if(f(h,e)===null)return this.fields;i===null?v(this.fields,e):this.fields=q(this.fields,e,i)}return this.fields}get(e){return h.hasOwnProperty(e)&&(e=h[e]),Q(this.fields,e)}async setAs(e=c.SWITCH,i,r){if(!c.hasOwnProperty(e)&&!f(c,e))throw new Error(`Invalid console type ${e}! Expected one of ${Object.keys(c).join(", ")}.`);return this.fields=await J(this.fields,e,i,r),this.fields}async getAs(e=c.SWITCH,i){if(!c.hasOwnProperty(e)&&!f(c,e))throw new Error(`Invalid console type ${e}! Expected one of ${Object.keys(c).join(", ")}.`);return j(this.fields,e,i)}encode(e=s.CHARINFO){if(!s.hasOwnProperty(e)&&f(s,e)===null)throw new Error(`Unexpected format: ${e}. Expected one of: ${Object.keys(s).join(", ")}`);return S(this.fields,e)}async toQR(e="3DS",i={}){let r=await S(this.fields,["3DS","CFED","CFSD","CFCD"].includes(e)?this.fields.hasOwnProperty("tl")?s.TLE:s.CFED:s.FFED);return re(r,i)}async render(e=!1,i={}){return await $(this.fields,Object.assign(i,{fullBody:e}))}async renderWithStudio(e=!1){return await renderMiiWithStudio(this.fields,e)}async insertIntoAmiibo(e){if(!e||!se(e)||e?.byteLength!==532&&e?.byteLength!==540&&e?.length!==532&&e?.length!==540)throw new Error(`Provided dump is not an Amiibo! Expected Buffer with a length that's one of: 532, 540. Received: ${typeof e}, ${e?.length}`);return V(e,this.fields)}async toInstructions(e=c.SWITCH){if(!c.hasOwnProperty(e)&&!f(c,e))throw new Error(`Invalid console type ${e}! Expected one of ${Object.keys(c).join(", ")}.`);return k(this.fields,e)}},me=R.favoriteColors;var ke={Mii:N,..._,...m,...I,insertMiiIntoAmiibo:V,extractMiiFromAmiibo:ce,miiHeightToMeasurements:ae,inchesToMiiHeight:fe,centimetersToMiiHeight:le,miiWeightToMeasurements:ue,imperialHeightWeightToMiiWeight:Ee,metricHeightWeightToMiiWeight:de,renderMii:$,FFLExpression:Ie,decryptMii:Te,encryptMii:he,miiCrcCalc:Me,makeInstructions:k,getAs:j,setAs:J,kidomatic:Oe,makeMiiChild:ye,FavoriteColors:me,getNestedValue:Q,setNestedValue:q,deleteNestedValue:v,getKeyByValue:f};export{Ce as ConsoleFormats,Ie as FFLExpression,me as FavoriteColors,N as Mii,we as MiiFormats,Ae as backPort,le as centimetersToMiiHeight,Ue as decodeMii,Te as decryptMii,ke as default,Ge as defaultMappings,v as deleteNestedValue,He as detectMiiFormat,Re as encodeMii,he as encryptMii,ce as extractMiiFromAmiibo,Le as formats,ge as forwardPort,j as getAs,f as getKeyByValue,Q as getNestedValue,Ee as imperialHeightWeightToMiiWeight,fe as inchesToMiiHeight,V as insertMiiIntoAmiibo,pe as isMiiInFormat,Oe as kidomatic,k as makeInstructions,ye as makeMiiChild,Ne as makeQR,Pe as mappings,de as metricHeightWeightToMiiWeight,Me as miiCrcCalc,ae as miiHeightToMeasurements,ue as miiWeightToMeasurements,$ as renderMii,Se as scanQR,J as setAs,q as setNestedValue};
/*! Bundled license information:
is-extglob/index.js:
(*!
* is-extglob <https://github.com/jonschlinkert/is-extglob>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*)
is-glob/index.js:
(*!
* is-glob <https://github.com/jonschlinkert/is-glob>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*)
is-invalid-path/index.js:
(*!
* is-invalid-path <https://github.com/jonschlinkert/is-invalid-path>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*)
is-valid-path/index.js:
(*!
* is-valid-path <https://github.com/jonschlinkert/is-valid-path>
*
* Copyright (c) 2015 Jon Schlinkert, contributors.
* Licensed under the MIT license.
*)
*/
//# sourceMappingURL=miijs.browser.js.map