@woven-canvas/plugin-tapes 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 +21 -0
- package/README.md +28 -0
- package/build/_tsup-dts-rollup.d.cts +118 -0
- package/build/_tsup-dts-rollup.d.ts +118 -0
- package/build/index.cjs +379 -0
- package/build/index.cjs.map +1 -0
- package/build/index.d.cts +16 -0
- package/build/index.d.ts +16 -0
- package/build/index.js +368 -0
- package/build/index.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Will Holt
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @woven-canvas/plugin-tapes
|
|
2
|
+
|
|
3
|
+
Draw washi tape across the canvas with click-and-drag. Click to place a default-sized tape, or drag to stretch tape between two points.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @woven-canvas/core @woven-canvas/plugin-tapes
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Editor } from "@woven-canvas/core";
|
|
15
|
+
import { TapesPlugin } from "@woven-canvas/plugin-tapes";
|
|
16
|
+
|
|
17
|
+
const editor = new Editor(domElement, {
|
|
18
|
+
plugins: [TapesPlugin],
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Documentation
|
|
23
|
+
|
|
24
|
+
For full API documentation, see the [documentation site](https://woven-canvas.dev).
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
MIT
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { CanvasComponentDef } from '@woven-ecs/canvas-store';
|
|
2
|
+
import { CommandDef } from '@woven-canvas/core';
|
|
3
|
+
import { EditorPlugin } from '@woven-canvas/core';
|
|
4
|
+
import { EditorPluginFactory } from '@woven-canvas/core';
|
|
5
|
+
import { EditorStateDef } from '@woven-canvas/core';
|
|
6
|
+
import { EditorSystem } from '@woven-canvas/core';
|
|
7
|
+
import { EntityId } from '@woven-canvas/core';
|
|
8
|
+
import { NumberFieldBuilder } from '@woven-ecs/core';
|
|
9
|
+
import { RefFieldBuilder } from '@woven-ecs/core';
|
|
10
|
+
import { StringFieldBuilder } from '@woven-ecs/core';
|
|
11
|
+
import { TupleFieldBuilder } from '@woven-ecs/core';
|
|
12
|
+
import type { Vec2 } from '@woven-canvas/math';
|
|
13
|
+
|
|
14
|
+
declare const AddTape: CommandDef< {
|
|
15
|
+
entityId: EntityId;
|
|
16
|
+
position: Vec2;
|
|
17
|
+
}>;
|
|
18
|
+
export { AddTape }
|
|
19
|
+
export { AddTape as AddTape_alias_1 }
|
|
20
|
+
export { AddTape as AddTape_alias_2 }
|
|
21
|
+
|
|
22
|
+
declare const captureTapeDrawSystem: EditorSystem;
|
|
23
|
+
export { captureTapeDrawSystem }
|
|
24
|
+
export { captureTapeDrawSystem as captureTapeDrawSystem_alias_1 }
|
|
25
|
+
|
|
26
|
+
declare const CompleteTape: CommandDef< {
|
|
27
|
+
entityId: EntityId;
|
|
28
|
+
}>;
|
|
29
|
+
export { CompleteTape }
|
|
30
|
+
export { CompleteTape as CompleteTape_alias_1 }
|
|
31
|
+
export { CompleteTape as CompleteTape_alias_2 }
|
|
32
|
+
|
|
33
|
+
declare function createTapesPlugin(): EditorPlugin;
|
|
34
|
+
export { createTapesPlugin }
|
|
35
|
+
export { createTapesPlugin as createTapesPlugin_alias_1 }
|
|
36
|
+
|
|
37
|
+
declare const DEFAULT_TAPE_IMAGE = "https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7e3b7dde-927d-4b09-aeb4-d49eac36d4ea.png?generation=1715183194653465&alt=media";
|
|
38
|
+
export { DEFAULT_TAPE_IMAGE }
|
|
39
|
+
export { DEFAULT_TAPE_IMAGE as DEFAULT_TAPE_IMAGE_alias_1 }
|
|
40
|
+
|
|
41
|
+
declare const DEFAULT_TAPE_LENGTH = 200;
|
|
42
|
+
export { DEFAULT_TAPE_LENGTH }
|
|
43
|
+
export { DEFAULT_TAPE_LENGTH as DEFAULT_TAPE_LENGTH_alias_1 }
|
|
44
|
+
|
|
45
|
+
declare const DEFAULT_TAPE_THICKNESS = 30;
|
|
46
|
+
export { DEFAULT_TAPE_THICKNESS }
|
|
47
|
+
export { DEFAULT_TAPE_THICKNESS as DEFAULT_TAPE_THICKNESS_alias_1 }
|
|
48
|
+
|
|
49
|
+
declare const DrawTape: CommandDef< {
|
|
50
|
+
entityId: EntityId;
|
|
51
|
+
start: Vec2;
|
|
52
|
+
end: Vec2;
|
|
53
|
+
}>;
|
|
54
|
+
export { DrawTape }
|
|
55
|
+
export { DrawTape as DrawTape_alias_1 }
|
|
56
|
+
export { DrawTape as DrawTape_alias_2 }
|
|
57
|
+
|
|
58
|
+
declare const PlaceTape: CommandDef< {
|
|
59
|
+
entityId: EntityId;
|
|
60
|
+
position: Vec2;
|
|
61
|
+
}>;
|
|
62
|
+
export { PlaceTape }
|
|
63
|
+
export { PlaceTape as PlaceTape_alias_1 }
|
|
64
|
+
export { PlaceTape as PlaceTape_alias_2 }
|
|
65
|
+
|
|
66
|
+
declare const POINTING_THRESHOLD = 4;
|
|
67
|
+
export { POINTING_THRESHOLD }
|
|
68
|
+
export { POINTING_THRESHOLD as POINTING_THRESHOLD_alias_1 }
|
|
69
|
+
|
|
70
|
+
declare const RemoveTape: CommandDef< {
|
|
71
|
+
entityId: EntityId;
|
|
72
|
+
}>;
|
|
73
|
+
export { RemoveTape }
|
|
74
|
+
export { RemoveTape as RemoveTape_alias_1 }
|
|
75
|
+
export { RemoveTape as RemoveTape_alias_2 }
|
|
76
|
+
|
|
77
|
+
declare const Tape: CanvasComponentDef< {
|
|
78
|
+
thickness: NumberFieldBuilder<"float64">;
|
|
79
|
+
}, "tape">;
|
|
80
|
+
export { Tape }
|
|
81
|
+
export { Tape as Tape_alias_1 }
|
|
82
|
+
export { Tape as Tape_alias_2 }
|
|
83
|
+
|
|
84
|
+
declare const TapeDrawState: EditorStateDef< {
|
|
85
|
+
state: StringFieldBuilder;
|
|
86
|
+
activeTape: RefFieldBuilder;
|
|
87
|
+
pointingStartClient: TupleFieldBuilder<NumberFieldBuilder<"int32">, 2>;
|
|
88
|
+
pointingStartWorld: TupleFieldBuilder<NumberFieldBuilder<"float64">, 2>;
|
|
89
|
+
}>;
|
|
90
|
+
export { TapeDrawState }
|
|
91
|
+
export { TapeDrawState as TapeDrawState_alias_1 }
|
|
92
|
+
export { TapeDrawState as TapeDrawState_alias_2 }
|
|
93
|
+
|
|
94
|
+
declare const TapeDrawStateEnum: {
|
|
95
|
+
readonly Idle: "idle";
|
|
96
|
+
readonly Pointing: "pointing";
|
|
97
|
+
readonly Drawing: "drawing";
|
|
98
|
+
};
|
|
99
|
+
export { TapeDrawStateEnum }
|
|
100
|
+
export { TapeDrawStateEnum as TapeDrawStateEnum_alias_1 }
|
|
101
|
+
|
|
102
|
+
declare type TapeDrawStateValue = (typeof TapeDrawStateEnum)[keyof typeof TapeDrawStateEnum];
|
|
103
|
+
export { TapeDrawStateValue }
|
|
104
|
+
export { TapeDrawStateValue as TapeDrawStateValue_alias_1 }
|
|
105
|
+
|
|
106
|
+
declare const TAPES_PLUGIN_NAME = "tapes";
|
|
107
|
+
export { TAPES_PLUGIN_NAME }
|
|
108
|
+
export { TAPES_PLUGIN_NAME as TAPES_PLUGIN_NAME_alias_1 }
|
|
109
|
+
|
|
110
|
+
declare const TapesPlugin: EditorPluginFactory;
|
|
111
|
+
export { TapesPlugin }
|
|
112
|
+
export { TapesPlugin as TapesPlugin_alias_1 }
|
|
113
|
+
|
|
114
|
+
declare const updateTapeDrawSystem: EditorSystem;
|
|
115
|
+
export { updateTapeDrawSystem }
|
|
116
|
+
export { updateTapeDrawSystem as updateTapeDrawSystem_alias_1 }
|
|
117
|
+
|
|
118
|
+
export { }
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { CanvasComponentDef } from '@woven-ecs/canvas-store';
|
|
2
|
+
import { CommandDef } from '@woven-canvas/core';
|
|
3
|
+
import { EditorPlugin } from '@woven-canvas/core';
|
|
4
|
+
import { EditorPluginFactory } from '@woven-canvas/core';
|
|
5
|
+
import { EditorStateDef } from '@woven-canvas/core';
|
|
6
|
+
import { EditorSystem } from '@woven-canvas/core';
|
|
7
|
+
import { EntityId } from '@woven-canvas/core';
|
|
8
|
+
import { NumberFieldBuilder } from '@woven-ecs/core';
|
|
9
|
+
import { RefFieldBuilder } from '@woven-ecs/core';
|
|
10
|
+
import { StringFieldBuilder } from '@woven-ecs/core';
|
|
11
|
+
import { TupleFieldBuilder } from '@woven-ecs/core';
|
|
12
|
+
import type { Vec2 } from '@woven-canvas/math';
|
|
13
|
+
|
|
14
|
+
declare const AddTape: CommandDef< {
|
|
15
|
+
entityId: EntityId;
|
|
16
|
+
position: Vec2;
|
|
17
|
+
}>;
|
|
18
|
+
export { AddTape }
|
|
19
|
+
export { AddTape as AddTape_alias_1 }
|
|
20
|
+
export { AddTape as AddTape_alias_2 }
|
|
21
|
+
|
|
22
|
+
declare const captureTapeDrawSystem: EditorSystem;
|
|
23
|
+
export { captureTapeDrawSystem }
|
|
24
|
+
export { captureTapeDrawSystem as captureTapeDrawSystem_alias_1 }
|
|
25
|
+
|
|
26
|
+
declare const CompleteTape: CommandDef< {
|
|
27
|
+
entityId: EntityId;
|
|
28
|
+
}>;
|
|
29
|
+
export { CompleteTape }
|
|
30
|
+
export { CompleteTape as CompleteTape_alias_1 }
|
|
31
|
+
export { CompleteTape as CompleteTape_alias_2 }
|
|
32
|
+
|
|
33
|
+
declare function createTapesPlugin(): EditorPlugin;
|
|
34
|
+
export { createTapesPlugin }
|
|
35
|
+
export { createTapesPlugin as createTapesPlugin_alias_1 }
|
|
36
|
+
|
|
37
|
+
declare const DEFAULT_TAPE_IMAGE = "https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7e3b7dde-927d-4b09-aeb4-d49eac36d4ea.png?generation=1715183194653465&alt=media";
|
|
38
|
+
export { DEFAULT_TAPE_IMAGE }
|
|
39
|
+
export { DEFAULT_TAPE_IMAGE as DEFAULT_TAPE_IMAGE_alias_1 }
|
|
40
|
+
|
|
41
|
+
declare const DEFAULT_TAPE_LENGTH = 200;
|
|
42
|
+
export { DEFAULT_TAPE_LENGTH }
|
|
43
|
+
export { DEFAULT_TAPE_LENGTH as DEFAULT_TAPE_LENGTH_alias_1 }
|
|
44
|
+
|
|
45
|
+
declare const DEFAULT_TAPE_THICKNESS = 30;
|
|
46
|
+
export { DEFAULT_TAPE_THICKNESS }
|
|
47
|
+
export { DEFAULT_TAPE_THICKNESS as DEFAULT_TAPE_THICKNESS_alias_1 }
|
|
48
|
+
|
|
49
|
+
declare const DrawTape: CommandDef< {
|
|
50
|
+
entityId: EntityId;
|
|
51
|
+
start: Vec2;
|
|
52
|
+
end: Vec2;
|
|
53
|
+
}>;
|
|
54
|
+
export { DrawTape }
|
|
55
|
+
export { DrawTape as DrawTape_alias_1 }
|
|
56
|
+
export { DrawTape as DrawTape_alias_2 }
|
|
57
|
+
|
|
58
|
+
declare const PlaceTape: CommandDef< {
|
|
59
|
+
entityId: EntityId;
|
|
60
|
+
position: Vec2;
|
|
61
|
+
}>;
|
|
62
|
+
export { PlaceTape }
|
|
63
|
+
export { PlaceTape as PlaceTape_alias_1 }
|
|
64
|
+
export { PlaceTape as PlaceTape_alias_2 }
|
|
65
|
+
|
|
66
|
+
declare const POINTING_THRESHOLD = 4;
|
|
67
|
+
export { POINTING_THRESHOLD }
|
|
68
|
+
export { POINTING_THRESHOLD as POINTING_THRESHOLD_alias_1 }
|
|
69
|
+
|
|
70
|
+
declare const RemoveTape: CommandDef< {
|
|
71
|
+
entityId: EntityId;
|
|
72
|
+
}>;
|
|
73
|
+
export { RemoveTape }
|
|
74
|
+
export { RemoveTape as RemoveTape_alias_1 }
|
|
75
|
+
export { RemoveTape as RemoveTape_alias_2 }
|
|
76
|
+
|
|
77
|
+
declare const Tape: CanvasComponentDef< {
|
|
78
|
+
thickness: NumberFieldBuilder<"float64">;
|
|
79
|
+
}, "tape">;
|
|
80
|
+
export { Tape }
|
|
81
|
+
export { Tape as Tape_alias_1 }
|
|
82
|
+
export { Tape as Tape_alias_2 }
|
|
83
|
+
|
|
84
|
+
declare const TapeDrawState: EditorStateDef< {
|
|
85
|
+
state: StringFieldBuilder;
|
|
86
|
+
activeTape: RefFieldBuilder;
|
|
87
|
+
pointingStartClient: TupleFieldBuilder<NumberFieldBuilder<"int32">, 2>;
|
|
88
|
+
pointingStartWorld: TupleFieldBuilder<NumberFieldBuilder<"float64">, 2>;
|
|
89
|
+
}>;
|
|
90
|
+
export { TapeDrawState }
|
|
91
|
+
export { TapeDrawState as TapeDrawState_alias_1 }
|
|
92
|
+
export { TapeDrawState as TapeDrawState_alias_2 }
|
|
93
|
+
|
|
94
|
+
declare const TapeDrawStateEnum: {
|
|
95
|
+
readonly Idle: "idle";
|
|
96
|
+
readonly Pointing: "pointing";
|
|
97
|
+
readonly Drawing: "drawing";
|
|
98
|
+
};
|
|
99
|
+
export { TapeDrawStateEnum }
|
|
100
|
+
export { TapeDrawStateEnum as TapeDrawStateEnum_alias_1 }
|
|
101
|
+
|
|
102
|
+
declare type TapeDrawStateValue = (typeof TapeDrawStateEnum)[keyof typeof TapeDrawStateEnum];
|
|
103
|
+
export { TapeDrawStateValue }
|
|
104
|
+
export { TapeDrawStateValue as TapeDrawStateValue_alias_1 }
|
|
105
|
+
|
|
106
|
+
declare const TAPES_PLUGIN_NAME = "tapes";
|
|
107
|
+
export { TAPES_PLUGIN_NAME }
|
|
108
|
+
export { TAPES_PLUGIN_NAME as TAPES_PLUGIN_NAME_alias_1 }
|
|
109
|
+
|
|
110
|
+
declare const TapesPlugin: EditorPluginFactory;
|
|
111
|
+
export { TapesPlugin }
|
|
112
|
+
export { TapesPlugin as TapesPlugin_alias_1 }
|
|
113
|
+
|
|
114
|
+
declare const updateTapeDrawSystem: EditorSystem;
|
|
115
|
+
export { updateTapeDrawSystem }
|
|
116
|
+
export { updateTapeDrawSystem as updateTapeDrawSystem_alias_1 }
|
|
117
|
+
|
|
118
|
+
export { }
|
package/build/index.cjs
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AddTape: () => AddTape,
|
|
24
|
+
CompleteTape: () => CompleteTape,
|
|
25
|
+
DEFAULT_TAPE_IMAGE: () => DEFAULT_TAPE_IMAGE,
|
|
26
|
+
DEFAULT_TAPE_LENGTH: () => DEFAULT_TAPE_LENGTH,
|
|
27
|
+
DEFAULT_TAPE_THICKNESS: () => DEFAULT_TAPE_THICKNESS,
|
|
28
|
+
DrawTape: () => DrawTape,
|
|
29
|
+
POINTING_THRESHOLD: () => POINTING_THRESHOLD,
|
|
30
|
+
PlaceTape: () => PlaceTape,
|
|
31
|
+
RemoveTape: () => RemoveTape,
|
|
32
|
+
TAPES_PLUGIN_NAME: () => TAPES_PLUGIN_NAME,
|
|
33
|
+
Tape: () => Tape,
|
|
34
|
+
TapeDrawState: () => TapeDrawState,
|
|
35
|
+
TapeDrawStateEnum: () => TapeDrawStateEnum,
|
|
36
|
+
TapesPlugin: () => TapesPlugin,
|
|
37
|
+
createTapesPlugin: () => createTapesPlugin
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(index_exports);
|
|
40
|
+
|
|
41
|
+
// src/commands/tape.ts
|
|
42
|
+
var import_core = require("@woven-canvas/core");
|
|
43
|
+
var AddTape = (0, import_core.defineCommand)("tape-add");
|
|
44
|
+
var DrawTape = (0, import_core.defineCommand)("tape-draw");
|
|
45
|
+
var RemoveTape = (0, import_core.defineCommand)("tape-remove");
|
|
46
|
+
var CompleteTape = (0, import_core.defineCommand)("tape-complete");
|
|
47
|
+
var PlaceTape = (0, import_core.defineCommand)("tape-place");
|
|
48
|
+
|
|
49
|
+
// src/components/index.ts
|
|
50
|
+
var components_exports = {};
|
|
51
|
+
__export(components_exports, {
|
|
52
|
+
Tape: () => Tape
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// src/components/Tape.ts
|
|
56
|
+
var import_core2 = require("@woven-canvas/core");
|
|
57
|
+
var Tape = (0, import_core2.defineCanvasComponent)(
|
|
58
|
+
{ name: "tape", sync: "document" },
|
|
59
|
+
{
|
|
60
|
+
/** Tape thickness in world units (the height of the tape ribbon) */
|
|
61
|
+
thickness: import_core2.field.float64().default(30)
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// src/constants.ts
|
|
66
|
+
var TAPES_PLUGIN_NAME = "tapes";
|
|
67
|
+
var DEFAULT_TAPE_THICKNESS = 30;
|
|
68
|
+
var DEFAULT_TAPE_LENGTH = 200;
|
|
69
|
+
var POINTING_THRESHOLD = 4;
|
|
70
|
+
var DEFAULT_TAPE_IMAGE = "https://storage.googleapis.com/download/storage/v1/b/zine-maker-public/o/tapes%2F7e3b7dde-927d-4b09-aeb4-d49eac36d4ea.png?generation=1715183194653465&alt=media";
|
|
71
|
+
|
|
72
|
+
// src/singletons/index.ts
|
|
73
|
+
var singletons_exports = {};
|
|
74
|
+
__export(singletons_exports, {
|
|
75
|
+
TapeDrawState: () => TapeDrawState
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// src/singletons/TapeDrawState.ts
|
|
79
|
+
var import_core3 = require("@woven-canvas/core");
|
|
80
|
+
|
|
81
|
+
// src/types.ts
|
|
82
|
+
var TapeDrawStateEnum = {
|
|
83
|
+
/** Idle - waiting for user to start drawing */
|
|
84
|
+
Idle: "idle",
|
|
85
|
+
/** Pointing - pointer down, waiting for drag threshold */
|
|
86
|
+
Pointing: "pointing",
|
|
87
|
+
/** Drawing - tape created, stretching with pointer */
|
|
88
|
+
Drawing: "drawing"
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// src/singletons/TapeDrawState.ts
|
|
92
|
+
var TapeDrawState = (0, import_core3.defineEditorState)("tapeDrawState", {
|
|
93
|
+
/** Current state machine state */
|
|
94
|
+
state: import_core3.field.string().max(16).default(TapeDrawStateEnum.Idle),
|
|
95
|
+
/** Reference to the active tape entity (while drawing) */
|
|
96
|
+
activeTape: import_core3.field.ref(),
|
|
97
|
+
/** Pointing start position in client coordinates [x, y] */
|
|
98
|
+
pointingStartClient: import_core3.field.tuple(import_core3.field.int32(), 2).default([0, 0]),
|
|
99
|
+
/** Pointing start position in world coordinates [x, y] */
|
|
100
|
+
pointingStartWorld: import_core3.field.tuple(import_core3.field.float64(), 2).default([0, 0])
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// src/TapesPlugin.ts
|
|
104
|
+
var import_core6 = require("@woven-canvas/core");
|
|
105
|
+
|
|
106
|
+
// src/systems/index.ts
|
|
107
|
+
var systems_exports = {};
|
|
108
|
+
__export(systems_exports, {
|
|
109
|
+
captureTapeDrawSystem: () => captureTapeDrawSystem,
|
|
110
|
+
updateTapeDrawSystem: () => updateTapeDrawSystem
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// src/systems/captureTapeDrawSystem.ts
|
|
114
|
+
var import_core4 = require("@woven-canvas/core");
|
|
115
|
+
var import_math = require("@woven-canvas/math");
|
|
116
|
+
var import_plugin_selection = require("@woven-canvas/plugin-selection");
|
|
117
|
+
var import_xstate = require("xstate");
|
|
118
|
+
var tapeDrawMachine = (0, import_xstate.setup)({
|
|
119
|
+
types: {
|
|
120
|
+
context: {},
|
|
121
|
+
events: {}
|
|
122
|
+
},
|
|
123
|
+
guards: {
|
|
124
|
+
isThresholdReached: ({ context, event }) => {
|
|
125
|
+
const dist = import_math.Vec2.distance(context.pointingStartClient, event.screenPosition);
|
|
126
|
+
return dist >= POINTING_THRESHOLD;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
actions: {
|
|
130
|
+
setPointingStart: (0, import_xstate.assign)({
|
|
131
|
+
pointingStartClient: ({ event }) => [event.screenPosition[0], event.screenPosition[1]],
|
|
132
|
+
pointingStartWorld: ({ event }) => [event.worldPosition[0], event.worldPosition[1]]
|
|
133
|
+
}),
|
|
134
|
+
resetContext: (0, import_xstate.assign)({
|
|
135
|
+
pointingStartClient: () => [0, 0],
|
|
136
|
+
pointingStartWorld: () => [0, 0],
|
|
137
|
+
activeTape: () => null
|
|
138
|
+
}),
|
|
139
|
+
addTape: (0, import_xstate.assign)({
|
|
140
|
+
activeTape: ({ context, event }) => {
|
|
141
|
+
const startWorld = context.pointingStartWorld;
|
|
142
|
+
const entityId = (0, import_core4.createEntity)(event.ctx);
|
|
143
|
+
AddTape.spawn(event.ctx, {
|
|
144
|
+
entityId,
|
|
145
|
+
position: startWorld
|
|
146
|
+
});
|
|
147
|
+
return entityId;
|
|
148
|
+
}
|
|
149
|
+
}),
|
|
150
|
+
drawTape: ({ context, event }) => {
|
|
151
|
+
if (!context.activeTape) return;
|
|
152
|
+
const startWorld = context.pointingStartWorld;
|
|
153
|
+
DrawTape.spawn(event.ctx, {
|
|
154
|
+
entityId: context.activeTape,
|
|
155
|
+
start: startWorld,
|
|
156
|
+
end: event.worldPosition
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
completeTape: ({ context, event }) => {
|
|
160
|
+
if (!context.activeTape) return;
|
|
161
|
+
CompleteTape.spawn(event.ctx, { entityId: context.activeTape });
|
|
162
|
+
},
|
|
163
|
+
removeTape: (0, import_xstate.assign)({
|
|
164
|
+
activeTape: ({ context, event }) => {
|
|
165
|
+
if (!context.activeTape) return null;
|
|
166
|
+
RemoveTape.spawn(event.ctx, { entityId: context.activeTape });
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
}),
|
|
170
|
+
placeTape: ({ context, event }) => {
|
|
171
|
+
const startWorld = context.pointingStartWorld;
|
|
172
|
+
const entityId = (0, import_core4.createEntity)(event.ctx);
|
|
173
|
+
PlaceTape.spawn(event.ctx, {
|
|
174
|
+
entityId,
|
|
175
|
+
position: startWorld
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
exitTapeControl: ({ event }) => {
|
|
179
|
+
const controls = import_core4.Controls.write(event.ctx);
|
|
180
|
+
controls.leftMouseTool = "select";
|
|
181
|
+
const cursor = import_core4.Cursor.write(event.ctx);
|
|
182
|
+
cursor.cursorKind = "select";
|
|
183
|
+
},
|
|
184
|
+
deselectAll: ({ event }) => {
|
|
185
|
+
import_plugin_selection.DeselectAll.spawn(event.ctx);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}).createMachine({
|
|
189
|
+
id: "tapeDraw",
|
|
190
|
+
initial: TapeDrawStateEnum.Idle,
|
|
191
|
+
context: {
|
|
192
|
+
activeTape: null,
|
|
193
|
+
pointingStartClient: [0, 0],
|
|
194
|
+
pointingStartWorld: [0, 0]
|
|
195
|
+
},
|
|
196
|
+
states: {
|
|
197
|
+
[TapeDrawStateEnum.Idle]: {
|
|
198
|
+
entry: "resetContext",
|
|
199
|
+
on: {
|
|
200
|
+
pointerDown: [
|
|
201
|
+
{
|
|
202
|
+
actions: "deselectAll",
|
|
203
|
+
target: TapeDrawStateEnum.Pointing
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
[TapeDrawStateEnum.Pointing]: {
|
|
209
|
+
entry: "setPointingStart",
|
|
210
|
+
on: {
|
|
211
|
+
pointerMove: {
|
|
212
|
+
guard: "isThresholdReached",
|
|
213
|
+
target: TapeDrawStateEnum.Drawing
|
|
214
|
+
},
|
|
215
|
+
pointerUp: {
|
|
216
|
+
actions: ["placeTape", "exitTapeControl"],
|
|
217
|
+
target: TapeDrawStateEnum.Idle
|
|
218
|
+
},
|
|
219
|
+
cancel: {
|
|
220
|
+
target: TapeDrawStateEnum.Idle
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
[TapeDrawStateEnum.Drawing]: {
|
|
225
|
+
entry: "addTape",
|
|
226
|
+
exit: "exitTapeControl",
|
|
227
|
+
on: {
|
|
228
|
+
pointerMove: {
|
|
229
|
+
actions: "drawTape"
|
|
230
|
+
},
|
|
231
|
+
pointerUp: {
|
|
232
|
+
actions: "completeTape",
|
|
233
|
+
target: TapeDrawStateEnum.Idle
|
|
234
|
+
},
|
|
235
|
+
cancel: {
|
|
236
|
+
actions: "removeTape",
|
|
237
|
+
target: TapeDrawStateEnum.Idle
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
var captureTapeDrawSystem = (0, import_core4.defineEditorSystem)({ phase: "capture", priority: 100 }, (ctx) => {
|
|
244
|
+
const buttons = import_core4.Controls.getButtons(ctx, "tape");
|
|
245
|
+
if (buttons.length === 0) return;
|
|
246
|
+
const events = (0, import_core4.getPointerInput)(ctx, buttons);
|
|
247
|
+
if (events.length === 0) return;
|
|
248
|
+
TapeDrawState.run(ctx, tapeDrawMachine, events);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// src/systems/updateTapeDrawSystem.ts
|
|
252
|
+
var import_core5 = require("@woven-canvas/core");
|
|
253
|
+
var import_plugin_selection2 = require("@woven-canvas/plugin-selection");
|
|
254
|
+
var updateTapeDrawSystem = (0, import_core5.defineEditorSystem)({ phase: "update" }, (ctx) => {
|
|
255
|
+
(0, import_core5.on)(ctx, AddTape, (ctx2, { entityId, position }) => {
|
|
256
|
+
addTape(ctx2, entityId, position);
|
|
257
|
+
});
|
|
258
|
+
(0, import_core5.on)(ctx, DrawTape, (ctx2, { entityId, start, end }) => {
|
|
259
|
+
drawTape(ctx2, entityId, start, end);
|
|
260
|
+
});
|
|
261
|
+
(0, import_core5.on)(ctx, RemoveTape, (ctx2, { entityId }) => {
|
|
262
|
+
(0, import_core5.removeEntity)(ctx2, entityId);
|
|
263
|
+
});
|
|
264
|
+
(0, import_core5.on)(ctx, CompleteTape, (ctx2, { entityId }) => {
|
|
265
|
+
completeTape(ctx2, entityId);
|
|
266
|
+
});
|
|
267
|
+
(0, import_core5.on)(ctx, PlaceTape, (ctx2, { entityId, position }) => {
|
|
268
|
+
placeTape(ctx2, entityId, position);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
function addTape(ctx, entityId, position) {
|
|
272
|
+
const snappedPos = [position[0], position[1]];
|
|
273
|
+
import_core5.Grid.snapPosition(ctx, snappedPos);
|
|
274
|
+
(0, import_core5.addComponent)(ctx, entityId, import_core5.Block, {
|
|
275
|
+
tag: "tape",
|
|
276
|
+
rank: import_core5.RankBounds.genNext(ctx),
|
|
277
|
+
position: [snappedPos[0], snappedPos[1] - DEFAULT_TAPE_THICKNESS / 2],
|
|
278
|
+
size: [1, DEFAULT_TAPE_THICKNESS]
|
|
279
|
+
});
|
|
280
|
+
(0, import_core5.addComponent)(ctx, entityId, import_core5.Synced, {
|
|
281
|
+
id: crypto.randomUUID()
|
|
282
|
+
});
|
|
283
|
+
(0, import_core5.addComponent)(ctx, entityId, Tape);
|
|
284
|
+
(0, import_core5.addComponent)(ctx, entityId, import_core5.Image, {});
|
|
285
|
+
(0, import_core5.addComponent)(ctx, entityId, import_core5.Asset, {
|
|
286
|
+
identifier: DEFAULT_TAPE_IMAGE,
|
|
287
|
+
uploadState: import_core5.UploadState.Complete
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function drawTape(ctx, entityId, start, end) {
|
|
291
|
+
const s = [start[0], start[1]];
|
|
292
|
+
const e = [end[0], end[1]];
|
|
293
|
+
import_core5.Grid.snapPosition(ctx, s);
|
|
294
|
+
import_core5.Grid.snapPosition(ctx, e);
|
|
295
|
+
const dx = e[0] - s[0];
|
|
296
|
+
const dy = e[1] - s[1];
|
|
297
|
+
const length = Math.sqrt(dx * dx + dy * dy);
|
|
298
|
+
const angle = Math.atan2(dy, dx);
|
|
299
|
+
const midX = (s[0] + e[0]) / 2;
|
|
300
|
+
const midY = (s[1] + e[1]) / 2;
|
|
301
|
+
const block = import_core5.Block.write(ctx, entityId);
|
|
302
|
+
const tape = Tape.read(ctx, entityId);
|
|
303
|
+
const thickness = tape.thickness;
|
|
304
|
+
block.position = [midX - length / 2, midY - thickness / 2];
|
|
305
|
+
block.size = [Math.max(length, 1), thickness];
|
|
306
|
+
block.rotateZ = angle;
|
|
307
|
+
}
|
|
308
|
+
function placeTape(ctx, entityId, position) {
|
|
309
|
+
const snappedPos = [position[0], position[1]];
|
|
310
|
+
import_core5.Grid.snapPosition(ctx, snappedPos);
|
|
311
|
+
(0, import_core5.addComponent)(ctx, entityId, import_core5.Block, {
|
|
312
|
+
tag: "tape",
|
|
313
|
+
rank: import_core5.RankBounds.genNext(ctx),
|
|
314
|
+
position: [snappedPos[0] - DEFAULT_TAPE_LENGTH / 2, snappedPos[1] - DEFAULT_TAPE_THICKNESS / 2],
|
|
315
|
+
size: [DEFAULT_TAPE_LENGTH, DEFAULT_TAPE_THICKNESS]
|
|
316
|
+
});
|
|
317
|
+
(0, import_core5.addComponent)(ctx, entityId, import_core5.Synced, {
|
|
318
|
+
id: crypto.randomUUID()
|
|
319
|
+
});
|
|
320
|
+
(0, import_core5.addComponent)(ctx, entityId, Tape);
|
|
321
|
+
(0, import_core5.addComponent)(ctx, entityId, import_core5.Image, {});
|
|
322
|
+
(0, import_core5.addComponent)(ctx, entityId, import_core5.Asset, {
|
|
323
|
+
identifier: DEFAULT_TAPE_IMAGE,
|
|
324
|
+
uploadState: import_core5.UploadState.Complete
|
|
325
|
+
});
|
|
326
|
+
(0, import_plugin_selection2.selectBlock)(ctx, entityId);
|
|
327
|
+
}
|
|
328
|
+
function completeTape(ctx, entityId) {
|
|
329
|
+
const block = import_core5.Block.read(ctx, entityId);
|
|
330
|
+
if (block.size[0] <= 1) {
|
|
331
|
+
(0, import_core5.removeEntity)(ctx, entityId);
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
(0, import_plugin_selection2.selectBlock)(ctx, entityId);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// src/TapesPlugin.ts
|
|
338
|
+
var filterSystems = (ns) => Object.values(ns).filter(
|
|
339
|
+
(v) => typeof v === "object" && v !== null && "_system" in v && "phase" in v
|
|
340
|
+
);
|
|
341
|
+
function createTapesPlugin() {
|
|
342
|
+
return {
|
|
343
|
+
name: TAPES_PLUGIN_NAME,
|
|
344
|
+
dependencies: ["selection"],
|
|
345
|
+
components: Object.values(components_exports).filter((v) => v instanceof import_core6.CanvasComponentDef),
|
|
346
|
+
singletons: Object.values(singletons_exports).filter((v) => v instanceof import_core6.CanvasSingletonDef),
|
|
347
|
+
blockDefs: [
|
|
348
|
+
{
|
|
349
|
+
tag: "tape",
|
|
350
|
+
components: [Tape, import_core6.Image, import_core6.Asset],
|
|
351
|
+
resizeMode: import_core6.ResizeMode.Scale,
|
|
352
|
+
connectors: {
|
|
353
|
+
enabled: false
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
],
|
|
357
|
+
systems: filterSystems(systems_exports)
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
var TapesPlugin = () => createTapesPlugin();
|
|
361
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
362
|
+
0 && (module.exports = {
|
|
363
|
+
AddTape,
|
|
364
|
+
CompleteTape,
|
|
365
|
+
DEFAULT_TAPE_IMAGE,
|
|
366
|
+
DEFAULT_TAPE_LENGTH,
|
|
367
|
+
DEFAULT_TAPE_THICKNESS,
|
|
368
|
+
DrawTape,
|
|
369
|
+
POINTING_THRESHOLD,
|
|
370
|
+
PlaceTape,
|
|
371
|
+
RemoveTape,
|
|
372
|
+
TAPES_PLUGIN_NAME,
|
|
373
|
+
Tape,
|
|
374
|
+
TapeDrawState,
|
|
375
|
+
TapeDrawStateEnum,
|
|
376
|
+
TapesPlugin,
|
|
377
|
+
createTapesPlugin
|
|
378
|
+
});
|
|
379
|
+
//# sourceMappingURL=index.cjs.map
|