@armniko/assets
Advanced tools
| import { Loader } from './loader'; | ||
| import { LoadableAsset } from '../core/loadable-asset'; | ||
| import { AssetType } from '../enums/asset-type'; | ||
| export declare class AudioLoader extends Loader<AssetType.Audio> { | ||
| load(loadableAsset: LoadableAsset, onSuccess: (audio: HTMLAudioElement) => void, onError: (error: Error) => void): void; | ||
| } |
| import { AssetsBatch } from './assets-batch'; | ||
| export declare class Assets { | ||
| private _store; | ||
| font(name: string): string | undefined; | ||
| image(name: string): HTMLImageElement | undefined; | ||
| font(name: string): string | undefined; | ||
| audio(name: string): HTMLAudioElement | undefined; | ||
| fetch(batch: AssetsBatch): void; | ||
| } |
| export declare enum AssetType { | ||
| Image = "image", | ||
| Font = "font" | ||
| Image = 0, | ||
| Font = 1, | ||
| Audio = 2 | ||
| } |
+231
-1
@@ -1,1 +0,231 @@ | ||
| var t,s={d:(t,e)=>{for(var o in e)s.o(e,o)&&!s.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},o:(t,s)=>Object.prototype.hasOwnProperty.call(t,s)},e={};s.d(e,{sP:()=>c,Gq:()=>d,ke:()=>r});class o{}class a extends o{load(t,s,e){const o=new Image;o.crossOrigin="Anonymous",o.onload=()=>{s(o)},o.onerror=t=>{"string"==typeof t&&e(new Error(t))},o.src=t.url()}}class r{_total;_loaded;_failed;constructor(t,s,e){this._total=t,this._loaded=s,this._failed=e}total(){return this._total}loaded(){return this._loaded}failed(){return this._failed}isCompleted(){return this.loaded()+this.failed()>=this.total()}percents(){return Math.floor(100/this.total()*(this.loaded()+this.failed()))}}!function(t){t.Image="image",t.Font="font"}(t||(t={}));class n{_batchAsset;constructor(t){this._batchAsset=t}url(){return"string"==typeof this._batchAsset?this._batchAsset:Object.values(this._batchAsset)[0]}name(){return"string"==typeof this._batchAsset?this.urlLastSegment().split(".")[0]:Object.keys(this._batchAsset)[0]}type(){let s;switch(this.urlLastSegment().split(".").pop()){case"jpg":case"jpeg":case"png":case"gif":case"svg":s=t.Image;break;case"woff2":case"woff":case"ttf":case"otf":s=t.Font;break;default:s=void 0}return s}urlLastSegment(){return this.url().split("?")[0].split("/").filter((t=>""!==t)).pop()||""}}class i extends o{load(t,s,e){const o=new FontFace(t.name(),"url("+t.url()+")");document.fonts.add(o),o.load().then((()=>{s(t.name())})).catch((t=>{e(t)}))}}class l{_total=0;_loaded=0;_failed=0;_batchAssets=[];_onLoad;_onComplete;_onError;constructor(t,s,e,o){this._batchAssets=t,this._total=this._batchAssets.length,this._onLoad=s,this._onComplete=e,this._onError=o}loadAsset(t,s,e){const o=new n(t),a=this.loader(o);a?a.load(o,(t=>{s({name:o.name(),url:o.url(),asset:t,type:o.type()})}),(t=>e(o.url(),t))):e(o.url(),new Error("Cant find loader for `"+o.url()+"`"))}progress(){return new r(this._total,this._loaded,this._failed)}loader(s){let e;switch(s.type()){case t.Image:e=new a;break;case t.Font:e=new i}return e}}class h extends l{fetch(){this._batchAssets.forEach((t=>{this.loadAsset(t,this.onLoadAssetSuccessCallback.bind(this),this.onLoadAssetErrorCallback.bind(this))}))}onLoadAssetSuccessCallback(t){this._loaded++;const s=this.progress();this._onLoad(t,s),this.checkAndCompleteBatch(s)}onLoadAssetErrorCallback(t,s){this._failed++;const e=this.progress();this._onError(t,s),this.checkAndCompleteBatch(e)}checkAndCompleteBatch(t){t.isCompleted()&&this._onComplete(t)}}class c{_store={[t.Image]:{},[t.Font]:{}};image(s){return this._store[t.Image][s]?.asset}font(s){return this._store[t.Font][s]?.asset}fetch(t){new h(t.assets(),((s,e)=>{this._store[s.type][s.name]=s,t.loaded(s.name,e)}),(s=>{t.completed(s)}),((s,e)=>{t.error(s,e)})).fetch()}}class d{options;constructor(t){this.options=t,t.assets=this.uniqueAssets(t.assets)}assets(){return this.options.assets}loaded(t,s){this.options.onLoad&&this.options.onLoad(t,s)}completed(t){this.options.onComplete&&this.options.onComplete(t)}error(t,s){this.options.onError&&this.options.onError(t,s)}uniqueAssets(t){return t.filter(((t,s,e)=>s===e.indexOf(t)))}}var p=e.sP,u=e.Gq,_=e.ke;export{p as Assets,u as AssetsBatch,_ as Progress}; | ||
| class l { | ||
| } | ||
| class c extends l { | ||
| load(t, s, o) { | ||
| const e = new Image(); | ||
| e.crossOrigin = "Anonymous", e.onload = () => { | ||
| s(e); | ||
| }, e.onerror = (n) => { | ||
| typeof n == "string" && o(new Error(n)); | ||
| }, e.src = t.url(); | ||
| } | ||
| } | ||
| class d { | ||
| _total; | ||
| _loaded; | ||
| _failed; | ||
| constructor(t, s, o) { | ||
| this._total = t, this._loaded = s, this._failed = o; | ||
| } | ||
| total() { | ||
| return this._total; | ||
| } | ||
| loaded() { | ||
| return this._loaded; | ||
| } | ||
| failed() { | ||
| return this._failed; | ||
| } | ||
| isCompleted() { | ||
| return this.loaded() + this.failed() >= this.total(); | ||
| } | ||
| percents() { | ||
| return Math.floor(100 / this.total() * (this.loaded() + this.failed())); | ||
| } | ||
| } | ||
| var r = /* @__PURE__ */ ((a) => (a[a.Image = 0] = "Image", a[a.Font = 1] = "Font", a[a.Audio = 2] = "Audio", a))(r || {}); | ||
| class h { | ||
| _batchAsset; | ||
| constructor(t) { | ||
| this._batchAsset = t; | ||
| } | ||
| url() { | ||
| return typeof this._batchAsset == "string" ? this._batchAsset : Object.values(this._batchAsset)[0]; | ||
| } | ||
| name() { | ||
| return typeof this._batchAsset == "string" ? this.urlLastSegment().split(".")[0] : Object.keys(this._batchAsset)[0]; | ||
| } | ||
| type() { | ||
| const t = this.urlLastSegment().split(".").pop(); | ||
| let s; | ||
| switch (t) { | ||
| case "woff2": | ||
| case "woff": | ||
| case "ttf": | ||
| case "otf": | ||
| s = r.Font; | ||
| break; | ||
| case "png": | ||
| case "webp": | ||
| case "jpg": | ||
| case "jpeg": | ||
| case "svg": | ||
| case "gif": | ||
| s = r.Image; | ||
| break; | ||
| case "webm": | ||
| case "mp3": | ||
| case "ogg": | ||
| case "m4a": | ||
| case "aac": | ||
| case "wav": | ||
| s = r.Audio; | ||
| break; | ||
| default: | ||
| s = void 0; | ||
| break; | ||
| } | ||
| return s; | ||
| } | ||
| urlLastSegment() { | ||
| return this.url().split("?")[0].split("/").filter((t) => t !== "").pop() || ""; | ||
| } | ||
| } | ||
| class u extends l { | ||
| load(t, s, o) { | ||
| const e = new FontFace(t.name(), "url(" + t.url() + ")"); | ||
| document.fonts.add(e), e.load().then(() => { | ||
| s(t.name()); | ||
| }).catch((n) => { | ||
| o(n); | ||
| }); | ||
| } | ||
| } | ||
| class _ extends l { | ||
| load(t, s, o) { | ||
| const e = new Audio(t.url()); | ||
| e.oncanplaythrough = () => { | ||
| s(e); | ||
| }, e.onerror = () => { | ||
| const n = e.error ? e.error.message : "Failed to load audio!"; | ||
| o(new Error(n)); | ||
| }, e.load(); | ||
| } | ||
| } | ||
| class p { | ||
| _total = 0; | ||
| _loaded = 0; | ||
| _failed = 0; | ||
| _batchAssets = []; | ||
| _onLoad; | ||
| _onComplete; | ||
| _onError; | ||
| constructor(t, s, o, e) { | ||
| this._batchAssets = t, this._total = this._batchAssets.length, this._onLoad = s, this._onComplete = o, this._onError = e; | ||
| } | ||
| loadAsset(t, s, o) { | ||
| const e = new h(t), n = this.loader(e); | ||
| n ? n.load( | ||
| e, | ||
| (i) => { | ||
| s({ | ||
| name: e.name(), | ||
| url: e.url(), | ||
| asset: i, | ||
| type: e.type() | ||
| }); | ||
| }, | ||
| (i) => o(e.url(), i) | ||
| ) : o(e.url(), new Error("Cant find loader for `" + e.url() + "`")); | ||
| } | ||
| progress() { | ||
| return new d(this._total, this._loaded, this._failed); | ||
| } | ||
| loader(t) { | ||
| let s; | ||
| switch (t.type()) { | ||
| case r.Font: | ||
| s = new u(); | ||
| break; | ||
| case r.Image: | ||
| s = new c(); | ||
| break; | ||
| case r.Audio: | ||
| s = new _(); | ||
| break; | ||
| } | ||
| return s; | ||
| } | ||
| } | ||
| class f extends p { | ||
| fetch() { | ||
| this._batchAssets.forEach((t) => { | ||
| this.loadAsset( | ||
| t, | ||
| this.onLoadAssetSuccessCallback.bind(this), | ||
| this.onLoadAssetErrorCallback.bind(this) | ||
| ); | ||
| }); | ||
| } | ||
| onLoadAssetSuccessCallback(t) { | ||
| this._loaded++; | ||
| const s = this.progress(); | ||
| this._onLoad(t, s), this.checkAndCompleteBatch(s); | ||
| } | ||
| onLoadAssetErrorCallback(t, s) { | ||
| this._failed++; | ||
| const o = this.progress(); | ||
| this._onError(t, s), this.checkAndCompleteBatch(o); | ||
| } | ||
| checkAndCompleteBatch(t) { | ||
| t.isCompleted() && this._onComplete(t); | ||
| } | ||
| } | ||
| class m { | ||
| _store = { | ||
| [r.Font]: {}, | ||
| [r.Image]: {}, | ||
| [r.Audio]: {} | ||
| }; | ||
| font(t) { | ||
| return this._store[r.Font][t]?.asset; | ||
| } | ||
| image(t) { | ||
| return this._store[r.Image][t]?.asset; | ||
| } | ||
| audio(t) { | ||
| return this._store[r.Audio][t]?.asset; | ||
| } | ||
| fetch(t) { | ||
| new f( | ||
| t.assets(), | ||
| (s, o) => { | ||
| const e = this._store[s.type]; | ||
| e[s.name] = s, t.loaded(s.name, o); | ||
| }, | ||
| (s) => { | ||
| t.completed(s); | ||
| }, | ||
| (s, o) => { | ||
| t.error(s, o); | ||
| } | ||
| ).fetch(); | ||
| } | ||
| } | ||
| class g { | ||
| constructor(t) { | ||
| this.options = t, t.assets = this.uniqueAssets(t.assets); | ||
| } | ||
| assets() { | ||
| return this.options.assets; | ||
| } | ||
| loaded(t, s) { | ||
| this.options.onLoad && this.options.onLoad(t, s); | ||
| } | ||
| completed(t) { | ||
| this.options.onComplete && this.options.onComplete(t); | ||
| } | ||
| error(t, s) { | ||
| this.options.onError && this.options.onError(t, s); | ||
| } | ||
| uniqueAssets(t) { | ||
| return t.filter( | ||
| (s, o, e) => o === e.indexOf(s) | ||
| ); | ||
| } | ||
| } | ||
| export { | ||
| m as Assets, | ||
| g as AssetsBatch, | ||
| d as Progress | ||
| }; |
@@ -1,1 +0,1 @@ | ||
| !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("Assets",[],e):"object"==typeof exports?exports.Assets=e():t.Assets=e()}(self,(()=>(()=>{"use strict";var t,e={d:(t,s)=>{for(var o in s)e.o(s,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:s[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},s={};e.r(s),e.d(s,{Assets:()=>h,AssetsBatch:()=>d,Progress:()=>a});class o{}class r extends o{load(t,e,s){const o=new Image;o.crossOrigin="Anonymous",o.onload=()=>{e(o)},o.onerror=t=>{"string"==typeof t&&s(new Error(t))},o.src=t.url()}}class a{_total;_loaded;_failed;constructor(t,e,s){this._total=t,this._loaded=e,this._failed=s}total(){return this._total}loaded(){return this._loaded}failed(){return this._failed}isCompleted(){return this.loaded()+this.failed()>=this.total()}percents(){return Math.floor(100/this.total()*(this.loaded()+this.failed()))}}!function(t){t.Image="image",t.Font="font"}(t||(t={}));class n{_batchAsset;constructor(t){this._batchAsset=t}url(){return"string"==typeof this._batchAsset?this._batchAsset:Object.values(this._batchAsset)[0]}name(){return"string"==typeof this._batchAsset?this.urlLastSegment().split(".")[0]:Object.keys(this._batchAsset)[0]}type(){let e;switch(this.urlLastSegment().split(".").pop()){case"jpg":case"jpeg":case"png":case"gif":case"svg":e=t.Image;break;case"woff2":case"woff":case"ttf":case"otf":e=t.Font;break;default:e=void 0}return e}urlLastSegment(){return this.url().split("?")[0].split("/").filter((t=>""!==t)).pop()||""}}class i extends o{load(t,e,s){const o=new FontFace(t.name(),"url("+t.url()+")");document.fonts.add(o),o.load().then((()=>{e(t.name())})).catch((t=>{s(t)}))}}class l{_total=0;_loaded=0;_failed=0;_batchAssets=[];_onLoad;_onComplete;_onError;constructor(t,e,s,o){this._batchAssets=t,this._total=this._batchAssets.length,this._onLoad=e,this._onComplete=s,this._onError=o}loadAsset(t,e,s){const o=new n(t),r=this.loader(o);r?r.load(o,(t=>{e({name:o.name(),url:o.url(),asset:t,type:o.type()})}),(t=>s(o.url(),t))):s(o.url(),new Error("Cant find loader for `"+o.url()+"`"))}progress(){return new a(this._total,this._loaded,this._failed)}loader(e){let s;switch(e.type()){case t.Image:s=new r;break;case t.Font:s=new i}return s}}class c extends l{fetch(){this._batchAssets.forEach((t=>{this.loadAsset(t,this.onLoadAssetSuccessCallback.bind(this),this.onLoadAssetErrorCallback.bind(this))}))}onLoadAssetSuccessCallback(t){this._loaded++;const e=this.progress();this._onLoad(t,e),this.checkAndCompleteBatch(e)}onLoadAssetErrorCallback(t,e){this._failed++;const s=this.progress();this._onError(t,e),this.checkAndCompleteBatch(s)}checkAndCompleteBatch(t){t.isCompleted()&&this._onComplete(t)}}class h{_store={[t.Image]:{},[t.Font]:{}};image(e){return this._store[t.Image][e]?.asset}font(e){return this._store[t.Font][e]?.asset}fetch(t){new c(t.assets(),((e,s)=>{this._store[e.type][e.name]=e,t.loaded(e.name,s)}),(e=>{t.completed(e)}),((e,s)=>{t.error(e,s)})).fetch()}}class d{options;constructor(t){this.options=t,t.assets=this.uniqueAssets(t.assets)}assets(){return this.options.assets}loaded(t,e){this.options.onLoad&&this.options.onLoad(t,e)}completed(t){this.options.onComplete&&this.options.onComplete(t)}error(t,e){this.options.onError&&this.options.onError(t,e)}uniqueAssets(t){return t.filter(((t,e,s)=>e===s.indexOf(t)))}}return s})())); | ||
| (function(i,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(i=typeof globalThis<"u"?globalThis:i||self,l(i.Assets={}))})(this,(function(i){"use strict";class l{}class h extends l{load(t,e,o){const s=new Image;s.crossOrigin="Anonymous",s.onload=()=>{e(s)},s.onerror=n=>{typeof n=="string"&&o(new Error(n))},s.src=t.url()}}class c{_total;_loaded;_failed;constructor(t,e,o){this._total=t,this._loaded=e,this._failed=o}total(){return this._total}loaded(){return this._loaded}failed(){return this._failed}isCompleted(){return this.loaded()+this.failed()>=this.total()}percents(){return Math.floor(100/this.total()*(this.loaded()+this.failed()))}}var r=(a=>(a[a.Image=0]="Image",a[a.Font=1]="Font",a[a.Audio=2]="Audio",a))(r||{});class u{_batchAsset;constructor(t){this._batchAsset=t}url(){return typeof this._batchAsset=="string"?this._batchAsset:Object.values(this._batchAsset)[0]}name(){return typeof this._batchAsset=="string"?this.urlLastSegment().split(".")[0]:Object.keys(this._batchAsset)[0]}type(){const t=this.urlLastSegment().split(".").pop();let e;switch(t){case"woff2":case"woff":case"ttf":case"otf":e=r.Font;break;case"png":case"webp":case"jpg":case"jpeg":case"svg":case"gif":e=r.Image;break;case"webm":case"mp3":case"ogg":case"m4a":case"aac":case"wav":e=r.Audio;break;default:e=void 0;break}return e}urlLastSegment(){return this.url().split("?")[0].split("/").filter(t=>t!=="").pop()||""}}class f extends l{load(t,e,o){const s=new FontFace(t.name(),"url("+t.url()+")");document.fonts.add(s),s.load().then(()=>{e(t.name())}).catch(n=>{o(n)})}}class p extends l{load(t,e,o){const s=new Audio(t.url());s.oncanplaythrough=()=>{e(s)},s.onerror=()=>{const n=s.error?s.error.message:"Failed to load audio!";o(new Error(n))},s.load()}}class _{_total=0;_loaded=0;_failed=0;_batchAssets=[];_onLoad;_onComplete;_onError;constructor(t,e,o,s){this._batchAssets=t,this._total=this._batchAssets.length,this._onLoad=e,this._onComplete=o,this._onError=s}loadAsset(t,e,o){const s=new u(t),n=this.loader(s);n?n.load(s,d=>{e({name:s.name(),url:s.url(),asset:d,type:s.type()})},d=>o(s.url(),d)):o(s.url(),new Error("Cant find loader for `"+s.url()+"`"))}progress(){return new c(this._total,this._loaded,this._failed)}loader(t){let e;switch(t.type()){case r.Font:e=new f;break;case r.Image:e=new h;break;case r.Audio:e=new p;break}return e}}class m extends _{fetch(){this._batchAssets.forEach(t=>{this.loadAsset(t,this.onLoadAssetSuccessCallback.bind(this),this.onLoadAssetErrorCallback.bind(this))})}onLoadAssetSuccessCallback(t){this._loaded++;const e=this.progress();this._onLoad(t,e),this.checkAndCompleteBatch(e)}onLoadAssetErrorCallback(t,e){this._failed++;const o=this.progress();this._onError(t,e),this.checkAndCompleteBatch(o)}checkAndCompleteBatch(t){t.isCompleted()&&this._onComplete(t)}}class g{_store={[r.Font]:{},[r.Image]:{},[r.Audio]:{}};font(t){return this._store[r.Font][t]?.asset}image(t){return this._store[r.Image][t]?.asset}audio(t){return this._store[r.Audio][t]?.asset}fetch(t){new m(t.assets(),(e,o)=>{const s=this._store[e.type];s[e.name]=e,t.loaded(e.name,o)},e=>{t.completed(e)},(e,o)=>{t.error(e,o)}).fetch()}}class A{constructor(t){this.options=t,t.assets=this.uniqueAssets(t.assets)}assets(){return this.options.assets}loaded(t,e){this.options.onLoad&&this.options.onLoad(t,e)}completed(t){this.options.onComplete&&this.options.onComplete(t)}error(t,e){this.options.onError&&this.options.onError(t,e)}uniqueAssets(t){return t.filter((e,o,s)=>o===s.indexOf(e))}}i.Assets=g,i.AssetsBatch=A,i.Progress=c,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})})); |
@@ -1,2 +0,2 @@ | ||
| import type { AssetType } from '../enums/asset-type'; | ||
| import { AssetType } from '../enums/asset-type'; | ||
| import { AssetResources } from './asset-resources.interface'; | ||
@@ -3,0 +3,0 @@ export interface AssetRecord<T extends AssetType = AssetType> { |
@@ -1,5 +0,6 @@ | ||
| import type { AssetType } from '../enums/asset-type'; | ||
| import { AssetType } from '../enums/asset-type'; | ||
| export interface AssetResources { | ||
| [AssetType.Font]: string; | ||
| [AssetType.Image]: HTMLImageElement; | ||
| [AssetType.Font]: string; | ||
| [AssetType.Audio]: HTMLAudioElement; | ||
| } |
@@ -1,2 +0,2 @@ | ||
| import type { Progress } from '../core/progress'; | ||
| import { Progress } from '../core/progress'; | ||
| import { BatchAsset } from '../types'; | ||
@@ -3,0 +3,0 @@ export interface AssetsBatchOptions { |
+48
-49
| { | ||
| "name": "@armniko/assets", | ||
| "version": "1.2.0", | ||
| "description": "Javascript/typescript library for fetching, storing and retrieving assets!", | ||
| "author": "Armīns Nikolajevs <armins.nikolajevs@gmail.com>", | ||
| "license": "MIT", | ||
| "bugs": { | ||
| "email": "armins.nikolajevs@gmail.com" | ||
| }, | ||
| "keywords": [ | ||
| "assets", | ||
| "loader", | ||
| "fetcher", | ||
| "concurrent", | ||
| "batching", | ||
| "async" | ||
| ], | ||
| "main": "./dist/index.umd.js", | ||
| "module": "./dist/index.esm.js", | ||
| "typings": "./dist/index.d.ts", | ||
| "type": "module", | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "build": "rimraf dist && webpack", | ||
| "dev": "node test/server/main.js & webpack --watch", | ||
| "lint": "tsc --noEmit && eslint src --max-warnings=0", | ||
| "lint:fix": "npm run lint -- --fix", | ||
| "test": "npm run build && jest", | ||
| "test:coverage": "npm run test -- --collect-coverage" | ||
| }, | ||
| "devDependencies": { | ||
| "@armniko/canvas": "^1.2.0", | ||
| "@armniko/ticker": "^2.0.0", | ||
| "@types/jest": "^29.5.12", | ||
| "@typescript-eslint/eslint-plugin": "^7.15.0", | ||
| "@typescript-eslint/parser": "^7.15.0", | ||
| "eslint": "^8.57.0", | ||
| "eslint-config-prettier": "^9.1.0", | ||
| "eslint-plugin-prettier": "^5.1.3", | ||
| "jest": "^29.7.0", | ||
| "jest-environment-jsdom": "^29.7.0", | ||
| "prettier": "^3.3.2", | ||
| "ts-jest": "^29.1.5", | ||
| "ts-loader": "^9.5.1", | ||
| "typescript": "^5.5.3", | ||
| "webpack": "^5.92.1", | ||
| "webpack-cli": "^5.1.4" | ||
| } | ||
| "name": "@armniko/assets", | ||
| "version": "1.3.0", | ||
| "description": "Javascript/typescript library for fetching, storing and retrieving assets!", | ||
| "author": "Armīns Nikolajevs <armins.nikolajevs@gmail.com>", | ||
| "license": "MIT", | ||
| "bugs": { | ||
| "email": "armins.nikolajevs@gmail.com" | ||
| }, | ||
| "keywords": [ | ||
| "assets", | ||
| "loader", | ||
| "fetcher", | ||
| "concurrent", | ||
| "batching", | ||
| "async", | ||
| "fonts", | ||
| "images", | ||
| "audio" | ||
| ], | ||
| "main": "./dist/index.umd.js", | ||
| "module": "./dist/index.esm.js", | ||
| "typings": "./dist/index.d.ts", | ||
| "type": "module", | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "build": "vite build", | ||
| "dev": "vite build --watch", | ||
| "lint": "tsc --noEmit && eslint ./src --max-warnings=0 && npm run lint --prefix=demo", | ||
| "lint:fix": "npm run lint -- --fix && npm run lint:fix --prefix=demo", | ||
| "test": "vitest", | ||
| "test:coverage": "vitest run --coverage" | ||
| }, | ||
| "devDependencies": { | ||
| "@eslint/js": "^9.39.2", | ||
| "@vitest/coverage-v8": "^4.0.16", | ||
| "eslint": "^9.39.2", | ||
| "eslint-config-prettier": "^10.1.8", | ||
| "eslint-plugin-prettier": "^5.5.4", | ||
| "happy-dom": "^20.0.11", | ||
| "prettier": "^3.7.4", | ||
| "typescript": "^5.9.3", | ||
| "typescript-eslint": "^8.50.1", | ||
| "vite": "^7.3.0", | ||
| "vite-plugin-dts": "^4.5.4", | ||
| "vitest": "^4.0.16" | ||
| } | ||
| } |
+12
-2
@@ -9,3 +9,5 @@ <h1 align="center">Assets</h1> | ||
| Javascript/typescript library for fetching, storing and retrieving assets!<br> | ||
| Supported formats: jpg, jpeg, png, gif, svg, woff, woff2, ttf, otf | ||
| Supported font formats: woff, woff2, ttf, otf<br> | ||
| Supported image formats: png, webp, jpg, jpeg, svg, gif<br> | ||
| Supported audio formats: webm, mp3, ogg, m4a, aac, wav<br> | ||
| </p> | ||
@@ -23,3 +25,3 @@ <hr> | ||
| ```typescript | ||
| import {Assets, AssetsBatch, Progress} from '@armniko/assets'; | ||
| import {Assets, AssetsBatch, type Progress} from '@armniko/assets'; | ||
@@ -50,2 +52,10 @@ const assetsBatch: AssetsBatch = new AssetsBatch({ | ||
| <tr> | ||
| <td>v1.3.0</td> | ||
| <td> | ||
| Added audio loader.<br> | ||
| Added webp format.<br> | ||
| Migrated from webpack to vite. | ||
| </td> | ||
| </tr> | ||
| <tr> | ||
| <td>v1.2.0</td> | ||
@@ -52,0 +62,0 @@ <td> |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
18174
15.74%12
-25%21
5%369
220.87%2
-33.33%77
14.93%