@doki-land/live2d 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/live2d.css CHANGED
@@ -1 +1 @@
1
- .live2d-icon-panel{position:fixed;right:10px;bottom:150px;z-index:10000;display:flex;flex-direction:column;gap:10px;opacity:0;transition:opacity .3s ease}.live2d-icon-panel.visible{opacity:1}.live2d-icon{width:40px;height:40px;background-color:#fffc;border-radius:50%;display:flex;justify-content:center;align-items:center;cursor:pointer;box-shadow:0 2px 5px #0003;transition:transform .2s ease}.live2d-icon:hover{transform:scale(1.1)}.live2d-icon svg{width:24px;height:24px;fill:#666}
1
+ .live2d-icon-panel{position:fixed;right:10px;bottom:150px;z-index:10000;display:flex;flex-direction:column;gap:10px;opacity:0;transition:opacity .3s ease}.live2d-icon-panel.visible{opacity:1}.live2d-icon{width:40px;height:40px;background-color:#fffc;border-radius:50%;display:flex;justify-content:center;align-items:center;cursor:pointer;box-shadow:0 2px 5px #0003;transition:transform .2s ease}.live2d-icon:hover{transform:scale(1.1)}.live2d-icon svg{width:24px;height:24px;fill:#666}.live2d-canvas{position:absolute;z-index:9999;display:block}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doki-land/live2d",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "keywords": [
5
5
  "live2d",
6
6
  "pixi",
@@ -13,20 +13,12 @@
13
13
  "exports": {
14
14
  ".": {
15
15
  "types": "./src/index.ts",
16
- "require": "./dist/l2d.umd.js",
17
- "import": "./src/index.ts"
16
+ "import": "./src/index.ts",
17
+ "require": "./dist/l2d.umd.js"
18
18
  },
19
- "./types": {
20
- "types": "./src/types/index.ts",
21
- "import": "./src/types/index.ts"
22
- },
23
- "./helper": {
24
- "types": "./src/helper/index.ts",
25
- "import": "./src/helper/index.ts"
26
- },
27
- "./fs": {
28
- "types": "./src/fs/index.ts",
29
- "import": "./src/fs/index.ts"
19
+ "./*": {
20
+ "types": "./src/*/index.ts",
21
+ "import": "./src/*/index.ts"
30
22
  }
31
23
  },
32
24
  "files": [
package/src/fs/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { minimatch } from 'minimatch';
2
- import { ModelOptions } from '@/types/index.js';
2
+ import { ModelOptions } from '@doki-land/live2d/types';
3
3
  import path from 'node:path';
4
4
  import fs from 'node:fs';
5
5
 
@@ -1,5 +1,5 @@
1
- import {findAllModels, mergeModels} from "@/fs/index.js";
2
- import {ResolveCdn, ResolveElementId, ResolveModels} from "@/types/index.js";
1
+ import {findAllModels, mergeModels} from "@doki-land/live2d/fs";
2
+ import {ResolveCdn, ResolveElementId, ResolveModels} from "@doki-land/live2d/types";
3
3
 
4
4
  export function generateModelList(options: ResolveModels) {
5
5
  const models = mergeModels(options.domain || 'https://localhost:8080', findAllModels(options.models_folder || 'public/live2d'), options.models || []);
@@ -35,4 +35,10 @@
35
35
  width: 24px;
36
36
  height: 24px;
37
37
  fill: #666;
38
+ }
39
+
40
+ .live2d-canvas {
41
+ position: absolute;
42
+ z-index: 9999;
43
+ display: block;
38
44
  }
package/src/index.ts CHANGED
@@ -1,16 +1,11 @@
1
1
  import '../lib/cubism2.min.js';
2
2
  import '../lib/cubism5.min.js';
3
3
  import * as PIXI from 'pixi.js';
4
-
5
- import { Ticker, TickerPlugin } from '@pixi/ticker';
6
- import {
7
- Live2DModel,
8
- MotionManager,
9
- SoundManager
10
- } from 'pixi-live2d-display-lipsyncpatch';
11
- import { Application, } from 'pixi.js';
4
+ import {Application} from 'pixi.js';
5
+ import {Ticker} from '@pixi/ticker';
6
+ import {Live2DModel, MotionManager, SoundManager} from 'pixi-live2d-display-lipsyncpatch';
12
7
  import './icons/style.css';
13
- import { Live2dOptions } from '@/types/index.js';
8
+ import {Live2dOptions} from '@doki-land/live2d/types';
14
9
 
15
10
  export {MotionManager, SoundManager, Live2DModel, PIXI};
16
11
 
@@ -50,7 +45,7 @@ export async function createLive2D(options: Live2dOptions): Promise<Live2DModel>
50
45
  });
51
46
 
52
47
  // 加载模型
53
- const model = await Live2DModel.from(models[0].model_url, {
48
+ const model = await Live2DModel.from(models[0].model_url, {
54
49
  ticker: Ticker.system,
55
50
  });
56
51
  // 添加模型到舞台
@@ -76,7 +71,7 @@ export async function createLive2D(options: Live2dOptions): Promise<Live2DModel>
76
71
  if (auto_motion) {
77
72
  await startIdleAnimation(model);
78
73
  }
79
-
74
+
80
75
  // 创建右侧图标栏
81
76
  // createIconPanel(model, element);
82
77
 
@@ -88,15 +83,10 @@ function findOrCreateCanvas(id: string, options: Live2dOptions): HTMLCanvasEleme
88
83
  if (!canvas) {
89
84
  canvas = document.createElement('canvas');
90
85
  canvas.id = id;
91
- document.body.appendChild(canvas);
92
- canvas.style.display = 'none';
93
- canvas.style.position = 'fixed';
94
- // 设置画布样式
95
- canvas.style.display = 'block';
96
- canvas.style.position = 'absolute';
86
+ canvas.classList.add('live2d-canvas')
97
87
  canvas.style.bottom = `${options.spacing_y || 0}px`;
98
88
  canvas.style[options.position === 'left' ? 'left' : 'right'] = `${options.spacing_x || 0}px`;
99
- canvas.style.zIndex = '9999';
89
+ document.body.appendChild(canvas);
100
90
  }
101
91
  return canvas;
102
92
  }
@@ -124,7 +114,7 @@ function enableMouseTracking(model: Live2DModel, canvas: any) {
124
114
  model.internalModel.focusController?.focus(mouseX, mouseY);
125
115
  }
126
116
  });
127
-
117
+
128
118
  // 添加点击模型触发动作的交互
129
119
  canvas.addEventListener('click', () => {
130
120
  // 尝试播放tap_body动作,如果没有则尝试其他可用动作
@@ -1,4 +1,4 @@
1
- import { ModelOptions } from './ModelOptions.js';
1
+ import { ModelOptions } from './ModelOptions.ts';
2
2
 
3
3
  /**
4
4
  * Live2D模型配置选项
@@ -1,4 +1,4 @@
1
- import {ModelOptions} from "@/types/ModelOptions.js";
1
+ import {ModelOptions} from "./ModelOptions.ts";
2
2
 
3
3
 
4
4
  export type ResolveModels = {
@@ -1,3 +1,3 @@
1
- export * from './Live2dOptions.js';
2
- export * from './ModelOptions.js';
3
- export * from './Resolve.js';
1
+ export * from './Live2dOptions.ts';
2
+ export * from './ModelOptions.ts';
3
+ export * from './Resolve.ts';