euv-cli 0.51.0

Cross-platform CLI tool for the euv native UI framework supporting run, build, check, fmt, doctor, new, and Hyperlane SSE dynamic updates across all supported platforms.
Documentation
<template>
  <div class="euv-root">
    <canvas
      id="euv-canvas"
      class="euv-canvas"
      ontouchstart="onTouchStart"
      ontouchmove="onTouchMove"
      ontouchend="onTouchEnd"
      ontouchcancel="onTouchCancel"
    ></canvas>
    <input
      id="euv-ime-proxy"
      class="euv-ime-proxy"
      type="text"
      value="{{imeValue}}"
      onchange="onImeChange"
      onenterkeyclick="onImeConfirm"
    />
  </div>
</template>

<style>
  .euv-root {
    width: 100%;
    height: 100%;
    flex-direction: column;
    background-color: #09090b;
  }
  .euv-canvas {
    width: 100%;
    height: 100%;
  }
  .euv-ime-proxy {
    position: fixed;
    left: -9999px;
    top: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
  }
</style>

<script>
import router from '@system.router';
import storage from '@system.storage';
import clipboard from '@system.clipboard';
import device from '@system.device';
import network from '@system.network';
import vibrator from '@system.vibrator';
import prompt from '@system.prompt';
import sensor from '@system.sensor';
import euvWasmGlue from '../Common/euv_wasm_glue.js';
import createQuickAppBridge from '../Common/euv-bridge.js';

export default {
  private: {
    imeValue: '',
    bridge: null
  },
  onReady() {
    const canvas = this.$element('euv-canvas');
    this.bridge = createQuickAppBridge(
      { router, storage, clipboard, device, network, vibrator, prompt, sensor },
      euvWasmGlue
    );
    const boot = (info) => {
      this.bridge.mount(this, canvas, info || { screenWidth: 1080, screenHeight: 2400, screenDensity: 3.0 });
    };
    if (device && typeof device.getInfo === 'function') {
      device.getInfo({ success: boot, fail: () => boot(null) });
    } else {
      boot(null);
    }
    if (network && typeof network.subscribe === 'function') {
      network.subscribe({
        callback: (status) => {
          if (this.bridge) this.bridge.dispatchNetwork((status && status.type) || 'wifi');
        }
      });
    }
    if (sensor && typeof sensor.subscribeAccelerometer === 'function') {
      sensor.subscribeAccelerometer({
        interval: 'game',
        callback: (ev) => {
          if (this.bridge && ev) {
            this.bridge.dispatchSensor([Number(ev.x || 0), Number(ev.y || 0), Number(ev.z || 0)], null);
          }
        }
      });
    }
  },
  onShow() {
    if (this.bridge) this.bridge.dispatchLifecycle(2, '');
  },
  onHide() {
    if (this.bridge) this.bridge.dispatchLifecycle(3, '');
  },
  onDestroy() {
    if (sensor && typeof sensor.unsubscribeAccelerometer === 'function') {
      sensor.unsubscribeAccelerometer();
    }
    if (this.bridge) {
      this.bridge.dispatchLifecycle(4, '');
      this.bridge.destroy();
      this.bridge = null;
    }
  },
  onBackPress() {
    return this.bridge ? this.bridge.dispatchLifecycle(5, '') : false;
  },
  onConfigurationChanged(params) {
    if (this.bridge && params && typeof params.themeMode !== 'undefined') {
      this.bridge.dispatchTheme(params.themeMode === 1 || params.themeMode === 'dark');
    }
  },
  setImeFocus(enabled) {
    const el = this.$element('euv-ime-proxy');
    if (el && typeof el.focus === 'function') {
      el.focus({ focus: Boolean(enabled) });
    }
  },
  onTouchStart(e) {
    if (this.bridge) this.bridge.dispatchDesignTouch('down', e);
  },
  onTouchMove(e) {
    if (this.bridge) this.bridge.dispatchDesignTouch('move', e);
  },
  onTouchEnd(e) {
    if (this.bridge) this.bridge.dispatchDesignTouch('up', e);
  },
  onTouchCancel(e) {
    if (this.bridge) this.bridge.dispatchDesignTouch('cancel', e);
  },
  onImeChange(e) {
    const val = (e && e.value) || '';
    if (this.bridge && val) this.bridge.dispatchIme(val, false);
    this.imeValue = '';
  },
  onImeConfirm(e) {
    const val = (e && e.value) || this.imeValue || '';
    if (this.bridge) this.bridge.dispatchIme(val, true);
    this.imeValue = '';
  }
};
</script>