@edv4h/usketch-plugin-effect-ripple 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 EdV4H
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ export { createRippleEffectPlugin, rippleEffectPlugin } from "./plugin.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { createRippleEffectPlugin, rippleEffectPlugin } from "./plugin.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type UsketchPlugin } from "@edv4h/usketch-shared";
2
+ import type { WsProviderHandle } from "@edv4h/usketch-sync";
3
+ /** WsProvider付きファクトリ(リアルタイム同期対応) */
4
+ export declare function createRippleEffectPlugin(wsProvider: WsProviderHandle): UsketchPlugin;
5
+ /** ローカル専用(後方互換) */
6
+ export declare const rippleEffectPlugin: UsketchPlugin;
7
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.tsx"],"names":[],"mappings":"AAAA,OAAO,EAMN,KAAK,aAAa,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAuJ5D,oCAAoC;AACpC,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,gBAAgB,GAAG,aAAa,CAEpF;AAED,mBAAmB;AACnB,eAAO,MAAM,kBAAkB,EAAE,aAA8B,CAAC"}
package/dist/plugin.js ADDED
@@ -0,0 +1,113 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { generateId, } from "@edv4h/usketch-shared";
3
+ const RIPPLE_TTL = 600;
4
+ const RIPPLE_SIZE = 80;
5
+ function RippleEffect({ obj }) {
6
+ const color = obj.data.color ?? "rgba(59, 130, 246, 0.5)";
7
+ return (_jsx("div", { style: {
8
+ position: "absolute",
9
+ left: -RIPPLE_SIZE / 2,
10
+ top: -RIPPLE_SIZE / 2,
11
+ width: RIPPLE_SIZE,
12
+ height: RIPPLE_SIZE,
13
+ borderRadius: "50%",
14
+ border: `2px solid ${color}`,
15
+ animation: `usketch-ripple ${RIPPLE_TTL}ms ease-out forwards`,
16
+ } }));
17
+ }
18
+ function RippleIcon() {
19
+ return (_jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", children: [_jsx("title", { children: "Ripple" }), _jsx("circle", { cx: "10", cy: "10", r: "3", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }), _jsx("circle", { cx: "10", cy: "10", r: "6", fill: "none", stroke: "currentColor", strokeWidth: "1", opacity: "0.6" }), _jsx("circle", { cx: "10", cy: "10", r: "9", fill: "none", stroke: "currentColor", strokeWidth: "0.5", opacity: "0.3" })] }));
20
+ }
21
+ let styleInjected = false;
22
+ function injectStyle() {
23
+ if (styleInjected)
24
+ return;
25
+ styleInjected = true;
26
+ const style = document.createElement("style");
27
+ style.textContent = `
28
+ @keyframes usketch-ripple {
29
+ 0% { transform: scale(0); opacity: 1; }
30
+ 100% { transform: scale(2); opacity: 0; }
31
+ }
32
+ `;
33
+ document.head.appendChild(style);
34
+ }
35
+ function createPlugin(wsProvider) {
36
+ let cleanup;
37
+ return {
38
+ id: "usketch-plugin-effect-ripple",
39
+ name: "リップルエフェクト",
40
+ setup(ctx) {
41
+ injectStyle();
42
+ ctx.transient.registerType("ripple", {
43
+ render: (obj) => _jsx(RippleEffect, { obj: obj }),
44
+ });
45
+ let unsubBroadcast;
46
+ if (wsProvider) {
47
+ unsubBroadcast = wsProvider.onBroadcast((msg) => {
48
+ if (msg.kind !== "ripple")
49
+ return;
50
+ // バリデーション
51
+ const id = msg.id;
52
+ const position = msg.position;
53
+ if (typeof id !== "string" ||
54
+ !position ||
55
+ typeof position.x !== "number" ||
56
+ typeof position.y !== "number") {
57
+ return;
58
+ }
59
+ ctx.transient.emit({
60
+ id,
61
+ type: "ripple",
62
+ sourceUserId: typeof msg.sourceUserId === "string" ? msg.sourceUserId : "remote",
63
+ position: { x: position.x, y: position.y },
64
+ data: { color: typeof msg.color === "string" ? msg.color : "rgba(59, 130, 246, 0.5)" },
65
+ ttl: typeof msg.ttl === "number" ? msg.ttl : RIPPLE_TTL,
66
+ createdAt: Date.now(),
67
+ });
68
+ });
69
+ }
70
+ function onPointerDown(_toolCtx, event) {
71
+ const id = generateId();
72
+ const color = "rgba(59, 130, 246, 0.5)";
73
+ ctx.transient.emit({
74
+ id,
75
+ type: "ripple",
76
+ sourceUserId: "local",
77
+ position: event.worldPoint,
78
+ data: { color },
79
+ ttl: RIPPLE_TTL,
80
+ createdAt: Date.now(),
81
+ });
82
+ wsProvider?.broadcast({
83
+ kind: "ripple",
84
+ id,
85
+ sourceUserId: "local",
86
+ position: event.worldPoint,
87
+ color,
88
+ ttl: RIPPLE_TTL,
89
+ });
90
+ }
91
+ ctx.tools.register("effect-ripple", {
92
+ icon: RippleIcon,
93
+ cursor: "crosshair",
94
+ shortcut: "r",
95
+ order: 50,
96
+ onPointerDown,
97
+ });
98
+ cleanup = () => {
99
+ unsubBroadcast?.();
100
+ };
101
+ },
102
+ teardown() {
103
+ cleanup?.();
104
+ },
105
+ };
106
+ }
107
+ /** WsProvider付きファクトリ(リアルタイム同期対応) */
108
+ export function createRippleEffectPlugin(wsProvider) {
109
+ return createPlugin(wsProvider);
110
+ }
111
+ /** ローカル専用(後方互換) */
112
+ export const rippleEffectPlugin = createPlugin();
113
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEN,UAAU,GAKV,MAAM,uBAAuB,CAAC;AAG/B,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB,SAAS,YAAY,CAAC,EAAE,GAAG,EAA4B;IACtD,MAAM,KAAK,GAAI,GAAG,CAAC,IAAI,CAAC,KAAgB,IAAI,yBAAyB,CAAC;IAEtE,OAAO,CACN,cACC,KAAK,EAAE;YACN,QAAQ,EAAE,UAAU;YACpB,IAAI,EAAE,CAAC,WAAW,GAAG,CAAC;YACtB,GAAG,EAAE,CAAC,WAAW,GAAG,CAAC;YACrB,KAAK,E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AAkB,GAAkB,YAAY,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@edv4h/usketch-plugin-effect-ripple",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.ts",
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "dependencies": {
15
+ "@edv4h/usketch-sync": "1.0.0",
16
+ "@edv4h/usketch-shared": "1.0.0"
17
+ },
18
+ "peerDependencies": {
19
+ "react": ">=19"
20
+ },
21
+ "devDependencies": {
22
+ "@types/react": "19.2.14",
23
+ "typescript": "5.9.3",
24
+ "vitest": "3.2.4"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "README.md"
32
+ ],
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/EdV4H/usketch.git",
37
+ "directory": "plugins/usketch-plugin-effect-ripple"
38
+ },
39
+ "homepage": "https://github.com/EdV4H/usketch#readme",
40
+ "bugs": {
41
+ "url": "https://github.com/EdV4H/usketch/issues"
42
+ },
43
+ "scripts": {
44
+ "build": "tsc -p tsconfig.json",
45
+ "typecheck": "tsc --noEmit",
46
+ "test": "vitest run --passWithNoTests",
47
+ "clean": "rm -rf dist"
48
+ }
49
+ }