@doki-land/live2d 0.0.8 → 0.0.9

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/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@doki-land/live2d",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "keywords": [
5
5
  "live2d",
6
6
  "pixi",
7
7
  "typescript"
8
8
  ],
9
- "description": "Live2D TypeScript runtime based on pixi-live2d-display",
9
+ "description": "Live2D TypeScript runtime based on pixi",
10
10
  "author": "Aster <192608617@qq.com>",
11
11
  "license": "LGPL-3.0-or-later",
12
12
  "type": "module",
@@ -16,13 +16,17 @@
16
16
  "require": "./dist/l2d.umd.js",
17
17
  "import": "./src/index.ts"
18
18
  },
19
- "./fs": {
20
- "types": "./src/fs/index.ts",
21
- "import": "./src/fs/index.ts"
22
- },
23
19
  "./types": {
24
20
  "types": "./src/types/index.ts",
25
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"
26
30
  }
27
31
  },
28
32
  "files": [
package/readme.md CHANGED
@@ -1,19 +1,60 @@
1
- ## Doki land live2d renderer
1
+ # Live2D Core Adapter (Unofficial)
2
2
 
3
+ ## Usage
3
4
 
5
+ This is the core library for rendering Live2D models in web applications.
4
6
 
5
- ## Using in html by module
7
+ It provides essential functionalities to load and display Live2D models with interactive capabilities.
8
+
9
+
10
+
11
+ ### In HTML via Module
6
12
 
7
13
  ```html
14
+ <script src="https://cdn.jsdelivr.net/npm/@doki-land/live2d@latest/dist/l2d.umd.js">
8
15
  <script type="module">
9
- const cdn = 'https://cdn.jsdelivr.net/npm/@doki-land/live2d@latest/dist/l2d.esm.js';
10
- const { createLive2dModel, initializeLive2D } = await import(cdn);
11
- initializeLive2D();
12
- await createLive2dModel({
16
+ l2d.initializeLive2D();
17
+ l2d.createLive2D({
13
18
  element_id: 'live2d-canvas',
14
19
  models: [
15
- {}
20
+ {}
16
21
  ]
17
- });
22
+ })
18
23
  </script>
19
- ```
24
+ ```
25
+
26
+
27
+ ### In Node via npm
28
+
29
+ - installation
30
+
31
+ ```bash
32
+ npm install @doki-land/live2d-core
33
+ ```
34
+
35
+ - usage
36
+
37
+ ```javascript
38
+
39
+
40
+
41
+
42
+
43
+ ```
44
+
45
+ ### In Other Frameworks
46
+
47
+ - [VitePress]()
48
+ - [VuePress]()
49
+ - [Hexo]()
50
+
51
+ ## Features
52
+
53
+ - Render Live2D Cubism™ v1, v2 (`*.model.json`).
54
+ - Render Live2D Cubism™ v3, v4, v5 (`*.model3.json`).
55
+
56
+
57
+
58
+ ### API Documentation
59
+ - `initializeLive2D()`: Initializes the Live2D environment
60
+ - `createLive2dModel(options)`: Creates and renders a Live2D model with specified options
@@ -0,0 +1,25 @@
1
+ import {findAllModels, mergeModels} from "@/fs/index.js";
2
+ import {ResolveCdn, ResolveElementId, ResolveModels} from "@/types/index.js";
3
+
4
+ export function generateModelList(options: ResolveModels) {
5
+ const models = mergeModels(options.domain || 'https://localhost:8080', findAllModels(options.models_folder || 'public/live2d'), options.models || []);
6
+ if (models.length == 0) {
7
+ throw new Error('At least one live2d model is required');
8
+ }
9
+ delete options.domain;
10
+ delete options.models;
11
+ delete options.models_folder;
12
+ return models;
13
+ }
14
+
15
+ export function generateElementId(options: ResolveElementId) {
16
+ const element_id = options.element_id || 'live2d-canvas';
17
+ delete options.element_id;
18
+ return element_id
19
+ }
20
+
21
+ export function generateCdn(options: ResolveCdn) {
22
+ const cdn = options.cdn || 'https://cdn.jsdelivr.net/npm/@doki-land/live2d@latest/dist/l2d.umd.js';
23
+ delete options.cdn;
24
+ return cdn
25
+ }
@@ -0,0 +1,16 @@
1
+ import {ModelOptions} from "@/types/ModelOptions.js";
2
+
3
+
4
+ export type ResolveModels = {
5
+ domain?: string,
6
+ models?: ModelOptions[]
7
+ models_folder?: string
8
+ }
9
+
10
+ export type ResolveElementId = {
11
+ element_id?: string
12
+ }
13
+
14
+ export type ResolveCdn = {
15
+ cdn?: string
16
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './Live2dOptions.js';
2
- export * from './ModelOptions.js';
2
+ export * from './ModelOptions.js';
3
+ export * from './Resolve.js';