New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@makemogic/runtime

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@makemogic/runtime

Mogic Runtime Libra

latest
npmnpm
Version
0.9.4
Version published
Maintainers
2
Created
Source

@makemogic/runtime

用于构建 Mogic 平台交互式应用的运行时库。

使用

import { mogicRuntime } from '@makemogic/runtime'

Tweaks (调整参数)

创建可在父应用中实时调整的可配置参数。

import remixConfig from './remix.json'
const tweaks = mogicRuntime.tweaks(remixConfig)

// 在 React 组件中使用
function App() {
  const bgColor = tweaks.bg.useState()
  const speed = tweaks.speed.useState()
  return <div style={{ backgroundColor: bgColor }}>Speed: {speed}</div>
}

// 编程式更新
mogicRuntime.updateTweaks({ bg: '#00FF00', speed: 5 })

支持类型: text, slider, toggle, color, select, theme, image/video/audio

注意: 每个应用仅调用一次 tweaks()

文本生成

const response = await mogicRuntime.generateText({
  prompt: 'Write a short story'
})
console.log(response.text)

选项: prompt (必填)

图片生成

const response = await mogicRuntime.generateImage({
  prompt: 'A beautiful sunset',
  aspectRatio: '16:9',
  referenceImages: ['https://example.com/image1.jpg']
})

const img = document.createElement('img')
img.src = response.img?.url ?? ''
document.body.appendChild(img)

选项: prompt (必填), aspectRatio, referenceImages

文件上传

const file = fileInput.files[0]
const response = await mogicRuntime.uploadFile(file)
console.log(response.url)

触觉反馈

mogicRuntime.performHaptic('medium')

震动强度: 'light', 'medium', 'heavy', 'rigid', 'soft'

运动与摇动检测

const unsubscribe = mogicRuntime.addMotionListener((motion) => {
  console.log(motion)
})

const removeShake = mogicRuntime.addShakeListener(() => {
  console.log('Shaken!')
})

// 清理监听
unsubscribe()
removeShake()

销毁实例

mogicRuntime.destroy()

Keywords

moly

FAQs

Package last updated on 23 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts