Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

1.1 KB
Raw Blame
/**
 * Implementation of the Storage interface
 * https://github.com/soulofmischief/proxy.js/blob/master/Storage.js
 */
 export function Storage() {

    if (localStorage){
        Object.keys(localStorage).map((key)=>{
            this.setItem(key, localStorage[key], false)
        })
    }

    Object.defineProperty( this, 'length', {
      get: function() {
        return Object.keys( this ).length
      },
      enumerable: false
    })
  }
  
  Storage.prototype.key = function( index ) {
    return Object.keys( this )[index]
  }
  
  Storage.prototype.getItem = function( key ) {
    try {
        return JSON.parse(this[key]);
    } catch {
        // not json
    }
    return this[key]
  }
  
  Storage.prototype.setItem = function( key, val, setLocal = true ) {
    const stVal = typeof val === 'string' ? val:JSON.stringify( val );
    if (setLocal)
        localStorage.setItem(key,stVal)
    return this[key] = stVal;
  }
  
  Storage.prototype.removeItem = function( key ) {
    delete this[key]
  }
  
  Storage.prototype.clear = function() {
    Object.keys( this ).forEach( key => delete this[key])
  }