@doki-land/live2d-widget 0.0.14 โ†’ 0.0.16

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.
Files changed (2) hide show
  1. package/README.md +165 -1
  2. package/package.json +12 -10
package/README.md CHANGED
@@ -1,3 +1,167 @@
1
1
  # @doki-land/live2d-widget
2
2
 
3
- live2d.ts package 0.0.14.
3
+ An optional webpage character shell built on `@doki-land/live2d`.
4
+
5
+ The widget package is intended for blogs, documentation sites, personal sites, and other pages that want a floating or
6
+ embedded character with messages and controls. It is not a second model runtime and it is not required by game-engine
7
+ integrations.
8
+
9
+ ## โœจ Features
10
+
11
+ - Mount a character into an existing element.
12
+ - Optional browser-driven animation loop.
13
+ - Pointer tracking and click feedback.
14
+ - Speech bubble with priority and timeout handling.
15
+ - Welcome messages and page-event messages.
16
+ - Hitokoto toolbar action.
17
+ - Canvas screenshot download.
18
+ - Hide/quit action.
19
+ - Renderer fallback configuration passed to the runtime.
20
+
21
+ ## ๐Ÿงญ Package Role
22
+
23
+ ```text
24
+ Webpage behavior and controls
25
+ -> @doki-land/live2d-widget
26
+ -> @doki-land/live2d
27
+ -> model runtime and renderer
28
+ ```
29
+
30
+ The widget owns webpage presentation such as tips and toolbar actions. Model parsing, parameter evaluation, graphics
31
+ backends, and resource semantics belong to `@doki-land/live2d` and its implementation packages.
32
+
33
+ ## ๐Ÿ“ฆ Installation
34
+
35
+ ```bash
36
+ pnpm add @doki-land/live2d-widget
37
+ ```
38
+
39
+ ## ๐Ÿš€ Quick Start
40
+
41
+ ```html
42
+
43
+ <div id="live2d-widget"></div>
44
+ ```
45
+
46
+ ```ts
47
+ import {mountWidget} from "@doki-land/live2d-widget";
48
+
49
+ const widget = await mountWidget({
50
+ target: "#live2d-widget",
51
+ model: "/models/character.model3.json",
52
+ width: 280,
53
+ height: 400,
54
+ prefer: ["webgpu", "webgl2", "canvas2d"],
55
+ autoSway: true,
56
+ chrome: true,
57
+ });
58
+ ```
59
+
60
+ Destroy the widget when its host is permanently removed:
61
+
62
+ ```ts
63
+ widget.destroy();
64
+ ```
65
+
66
+ ## ๐Ÿ’ฌ Messages
67
+
68
+ ```ts
69
+ widget.showMessage("Welcome back.");
70
+
71
+ widget.showMessage(
72
+ ["Hello.", "Nice to see you again."],
73
+ 5000,
74
+ 4,
75
+ );
76
+ ```
77
+
78
+ Higher-priority messages can temporarily prevent lower-priority page events from replacing important feedback.
79
+
80
+ ## ๐Ÿงฐ Toolbar
81
+
82
+ Enable default controls:
83
+
84
+ ```ts
85
+ const widget = await mountWidget({
86
+ target: host,
87
+ model,
88
+ chrome: true,
89
+ });
90
+ ```
91
+
92
+ Or configure them explicitly:
93
+
94
+ ```ts
95
+ const widget = await mountWidget({
96
+ target: host,
97
+ model,
98
+ chrome: {
99
+ tips: true,
100
+ welcome: ["Welcome to the site."],
101
+ tools: ["hitokoto", "photo", "quit"],
102
+ hitokotoApi: "https://v1.hitokoto.cn",
103
+ },
104
+ });
105
+ ```
106
+
107
+ The Hitokoto action performs a network request. Sites with strict privacy or content-security requirements should
108
+ disable it or provide an approved endpoint.
109
+
110
+ ## ๐Ÿ–ฑ๏ธ Interaction
111
+
112
+ ```ts
113
+ await mountWidget({
114
+ target: host,
115
+ model,
116
+ onHit({area, x, y}) {
117
+ console.log(area, x, y);
118
+ },
119
+ });
120
+ ```
121
+
122
+ Pointer tracking drives supported focus parameters. Exact visible behavior depends on the parameter definitions and
123
+ deformation data in the loaded model.
124
+
125
+ ## ๐Ÿ“ Blog Engines
126
+
127
+ The package is suitable as the shared browser layer for blog-engine adapters. An adapter should only:
128
+
129
+ - read host configuration;
130
+ - emit or copy browser assets;
131
+ - create the target element;
132
+ - pass options to the widget;
133
+ - integrate with the host's navigation lifecycle.
134
+
135
+ It should not copy model decoding, rendering, pointer math, or message behavior into the adapter.
136
+
137
+ ## ๐ŸŽฎ Game Engines
138
+
139
+ Game engines should normally use `@doki-land/live2d` directly. The widget creates webpage chrome and may own a browser
140
+ animation loop, which is usually inappropriate when an engine already controls its canvas, scheduler, input system, and
141
+ scene lifecycle.
142
+
143
+ ## ๐Ÿ”’ Privacy and Security
144
+
145
+ - Remote models and Hitokoto endpoints are network dependencies.
146
+ - Screenshot export may fail when textures make the canvas origin-unclean.
147
+ - Apply a content-security policy appropriate for model, texture, and API origins.
148
+ - Do not forward authentication credentials to arbitrary user-provided URLs.
149
+ - Provide a network-free configuration for privacy-sensitive sites.
150
+
151
+ ## ๐Ÿงช Development
152
+
153
+ ```bash
154
+ pnpm --filter @doki-land/live2d-widget typecheck
155
+ pnpm --filter @doki-land/live2d-widget test
156
+ ```
157
+
158
+ Widget changes should test listener cleanup, repeated mount/destroy behavior, message priority, toolbar actions, and
159
+ hosts without optional browser capabilities.
160
+
161
+ ## ๐Ÿค Contributing
162
+
163
+ Keep this package focused on webpage character behavior. Runtime and renderer changes belong in their owning packages.
164
+
165
+ ## ๐Ÿ“„ License
166
+
167
+ See the repository license. Character models and message-service content may have separate terms.
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@doki-land/live2d-widget",
3
- "version": "0.0.14",
4
- "description": "Browser canvas widget for @doki-land/live2d",
3
+ "version": "0.0.16",
4
+ "description": "Live2D page widget โ€” canvas shell, autoplay, optional tips chrome; built on @doki-land/live2d.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "author": "Doki Land",
7
+ "homepage": "https://github.com/doki-land/live2d.ts",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/doki-land/live2d.ts.git",
11
+ "directory": "projects/live2d-widget"
12
+ },
8
13
  "keywords": [
9
14
  "live2d",
10
15
  "widget",
@@ -17,7 +22,8 @@
17
22
  },
18
23
  "files": [
19
24
  "dist",
20
- "src"
25
+ "src",
26
+ "README.md"
21
27
  ],
22
28
  "publishConfig": {
23
29
  "access": "public",
@@ -36,11 +42,7 @@
36
42
  "test": "vitest run --passWithNoTests"
37
43
  },
38
44
  "dependencies": {
39
- "@doki-land/live2d": "0.0.14"
45
+ "@doki-land/live2d": "0.0.16"
40
46
  },
41
- "sideEffects": false,
42
- "repository": {
43
- "type": "git",
44
- "url": "git+https://github.com/doki-land/live2d.ts.git"
45
- }
47
+ "sideEffects": false
46
48
  }