Git Product home page Git Product logo

sakana-widget's Introduction

Personal Blog (CN)

Support me on Ko-fi

Personal

Web/Cross-platform developer, amateur designer, PC enthusiastic, anime fan & console gamer.

Keywords

  • Tier 1 (Primary): JavaScript, TypeScript, HTML, CSS, React, Node.js
  • Tier 2 (Secondary): SolidJS, Svelte, Vue.js, Electron, Deno, Hugo

Stats

  • Huge fan of Kyoto Animation since Lucky Star (2007)
  • Prefer VS Code, always working with 2-space (in any language)
  • Using Windows 11, macOS Ventura and Ubuntu 22.04
  • JSX/TSX are the best syntax for mordern web development

Hardware

  • i9-13900KF, D5-7600C38, RTX4090, MBP16 M1P
  • LG 27GP95R UltraGear 4K Nano IPS
  • Varmilo VA87M Cherry MX Brown, Logitech G502X

Counter

Moe Counter CF

sakana-widget's People

Contributors

dsrkafuu avatar pinkchampagne17 avatar prosperbao avatar swingcosmic avatar yunjin77 avatar zhushenwudi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sakana-widget's Issues

SakanaWidget.getCharacter() 方法无法获取角色

你好,我想生成一个默认静止的chisato,但是无法获取,代码如下

function initSakanaWidget() {
  const characters = SakanaWidget.getCharacters()
  console.log(characters) // 这里打印是空角色池
  const chisato = SakanaWidget.getCharacter('chisato');
  chisato.initialState = {
    ...chisato.initialState,
    i: 0,
    d: 0
  }
  SakanaWidget.registerCharacter('chisato-silence', chisato);
  new SakanaWidget({
    character: 'chisato-silence',
    autoFit: true,
    controls: false
  }).mount('#sakana-widget')
}
Uncaught TypeError: Cannot read properties of null (reading 'chisato')
    at Q.getCharacter (index.ts:107:19)
    at initSakanaWidget (index.html:16:38)
    at HTMLScriptElement.onload (index.html:36:6)

can not use with vite-ssg

Not sure which is causing the problem, come here for help, thank you.

[vite-ssg] An internal error occurred.
[vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues
/home/hyoban/dev/ssg-sakana/node_modules/.pnpm/[email protected]/node_modules/sakana-widget/lib/index.js:10
})(self, () => {
   ^

ReferenceError: self is not defined
    at Object.<anonymous> (/home/hyoban/dev/ssg-sakana/node_modules/.pnpm/[email protected]/node_modules/sakana-widget/lib/index.js:10:4)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async build (file:///home/hyoban/dev/ssg-sakana/node_modules/.pnpm/[email protected]_thgl23324gg75myoeph36y4c5a/node_modules/vite-ssg/dist/chunks/build.mjs:171:87)
 ELIFECYCLE  Command failed with exit code 1.

minimal reproduction

https://github.com/hyoban/ssg-sakana

https://github.com/hyoban/ssg-sakana/commit/e99b063fb1630df60e064a9c6211c26ac12001a0

关于自定义组件

如果参考 README 的这一段使用说明:

const takina = SakanaWidget.getCharacter('takina');
takina.initialState = {
  ...takina.initialState,
  i: 0.001,
  d: 1,
};
SakanaWidget.registerCharacter('takina-slow', takina);
new SakanaWidget({ character: 'takina-slow' }).mount('#sakana-widget');

会发现切换角色后,原来的 takina 也跟着变慢了,应该不是很符合预期?

不太确定这里的 cloneDeep 用意是不是这个

// register default characters
const _characters: { [key: string]: SakanaWidgetCharacter } = {};
(Object.keys(characters) as Array<keyof typeof characters>).forEach((key) => {
const _char = characters[key];
_characters[key] = cloneDeep(_char);
});

如果是的话,考虑设置一下 proxy?

// register default characters 
const _characters: { [key: string]: SakanaWidgetCharacter } = {};
(Object.keys(characters) as Array<keyof typeof characters>).forEach((key) => {
  const _char = characters[key];
  _characters[key] = _char;
  Object.defineProperty(_characters, key, {
    get: () => cloneDeep(_char),
  });
});

TypeError: Object.defineProperty called on non-object

vue3中使用npm run serve时编译无异常,但该组件无法正常工作,控制台报错如下
屏幕截图 2022-09-11 155103
使用build打包后能正常工作,指定serve环境为production或test时亦能正常工作,serve环境为默认项development时出现问题
使用 import SakanaWidget from 'sakana-widget'; 直接导入

onMounted(() => {
  import('sakana-widget').then((pkg) => {
    const SakanaWidget = pkg.default
    new SakanaWidget().mount('#sakana-widget')
  });
});

导入均出现此错误
版本信息:
sakana-widget:2.3.0
vue:3.2.38

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.