@snaptrude/plugin-core 0.0.5 → 0.0.7

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 (63) hide show
  1. package/dist/api/core/geom/arc.d.ts +50 -1
  2. package/dist/api/core/geom/arc.d.ts.map +1 -1
  3. package/dist/api/core/geom/curve.d.ts +26 -1
  4. package/dist/api/core/geom/curve.d.ts.map +1 -1
  5. package/dist/api/core/geom/index.d.ts +16 -0
  6. package/dist/api/core/geom/index.d.ts.map +1 -1
  7. package/dist/api/core/geom/line.d.ts +35 -1
  8. package/dist/api/core/geom/line.d.ts.map +1 -1
  9. package/dist/api/core/geom/profile.d.ts +66 -2
  10. package/dist/api/core/geom/profile.d.ts.map +1 -1
  11. package/dist/api/core/index.d.ts +8 -0
  12. package/dist/api/core/index.d.ts.map +1 -1
  13. package/dist/api/core/math/index.d.ts +8 -0
  14. package/dist/api/core/math/index.d.ts.map +1 -1
  15. package/dist/api/core/math/quat.d.ts +156 -15
  16. package/dist/api/core/math/quat.d.ts.map +1 -1
  17. package/dist/api/core/math/vec3.d.ts +131 -14
  18. package/dist/api/core/math/vec3.d.ts.map +1 -1
  19. package/dist/api/entity/index.d.ts +13 -0
  20. package/dist/api/entity/index.d.ts.map +1 -1
  21. package/dist/api/entity/referenceLine.d.ts +259 -0
  22. package/dist/api/entity/referenceLine.d.ts.map +1 -0
  23. package/dist/api/entity/space.d.ts +467 -7
  24. package/dist/api/entity/space.d.ts.map +1 -1
  25. package/dist/api/entity/story.d.ts +166 -0
  26. package/dist/api/entity/story.d.ts.map +1 -1
  27. package/dist/api/index.d.ts +14 -0
  28. package/dist/api/index.d.ts.map +1 -1
  29. package/dist/api/tools/index.d.ts +8 -0
  30. package/dist/api/tools/index.d.ts.map +1 -1
  31. package/dist/api/tools/selection.d.ts +37 -0
  32. package/dist/api/tools/selection.d.ts.map +1 -1
  33. package/dist/api/tools/transform.d.ts +82 -0
  34. package/dist/api/tools/transform.d.ts.map +1 -1
  35. package/dist/api/units/index.d.ts +81 -13
  36. package/dist/api/units/index.d.ts.map +1 -1
  37. package/dist/index.cjs +547 -126
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.js +533 -126
  40. package/dist/index.js.map +1 -1
  41. package/dist/types.d.ts +8 -1
  42. package/dist/types.d.ts.map +1 -1
  43. package/package.json +2 -2
  44. package/src/api/core/geom/arc.ts +50 -1
  45. package/src/api/core/geom/curve.ts +26 -1
  46. package/src/api/core/geom/index.ts +16 -0
  47. package/src/api/core/geom/line.ts +35 -1
  48. package/src/api/core/geom/profile.ts +66 -2
  49. package/src/api/core/index.ts +8 -0
  50. package/src/api/core/math/index.ts +8 -0
  51. package/src/api/core/math/quat.ts +156 -15
  52. package/src/api/core/math/vec3.ts +131 -14
  53. package/src/api/entity/index.ts +13 -0
  54. package/src/api/entity/referenceLine.ts +215 -0
  55. package/src/api/entity/space.ts +447 -11
  56. package/src/api/entity/story.ts +166 -0
  57. package/src/api/index.ts +14 -0
  58. package/src/api/tools/index.ts +8 -0
  59. package/src/api/tools/selection.ts +37 -0
  60. package/src/api/tools/transform.ts +82 -0
  61. package/src/api/units/index.ts +81 -13
  62. package/src/types.ts +8 -1
  63. package/tsup.config.ts +0 -1
@@ -0,0 +1,215 @@
1
+ import * as z from "zod"
2
+ import { PluginApiReturn } from "../../types"
3
+ import { PProfile } from "../core/geom/profile"
4
+ import { PCurve } from "../core/geom/curve"
5
+
6
+ /**
7
+ * Reference line management — create, query, and delete reference lines.
8
+ *
9
+ * A **reference line** is a 2D guide line (or arc) in the Snaptrude scene,
10
+ * typically used for grid lines and alignment guides. Reference lines
11
+ * carry properties such as grid tags, labels, and line styles.
12
+ *
13
+ * All methods are **host API calls** that return Promises and support
14
+ * undo/redo via Snaptrude's command system.
15
+ *
16
+ * Accessed via `snaptrude.entity.referenceLine`.
17
+ */
18
+ export abstract class PluginReferenceLineApi {
19
+ constructor() {}
20
+
21
+ /**
22
+ * Create multiple reference lines from a profile.
23
+ *
24
+ * Each {@linkcode PCurve} in the given {@linkcode PProfile} becomes
25
+ * a separate reference line. Uses `ReferenceLineConstructor.createFromProfile`
26
+ * internally.
27
+ *
28
+ * @param args - An object containing:
29
+ * - {@linkcode PluginReferenceLineCreateMultiArgs.profile args.profile} — A
30
+ * {@linkcode PProfile} whose curves define the reference lines to create
31
+ * @returns A {@linkcode PluginReferenceLineCreateMultiResult} with the
32
+ * `referenceLineIds` of the created reference lines
33
+ * @throws If reference line creation fails
34
+ *
35
+ * # Example
36
+ * ```ts
37
+ * const { vec3 } = snaptrude.core.math
38
+ *
39
+ * const l1 = snaptrude.core.geom.line.new(vec3.new(0, 0, 0), vec3.new(10, 0, 0))
40
+ * const l2 = snaptrude.core.geom.line.new(vec3.new(10, 0, 0), vec3.new(10, 0, 10))
41
+ * const profile = snaptrude.core.geom.profile.new([l1, l2])
42
+ *
43
+ * const { referenceLineIds } = await snaptrude.entity.referenceLine.createMulti({
44
+ * profile,
45
+ * })
46
+ * ```
47
+ */
48
+ public abstract createMulti(
49
+ args: PluginReferenceLineCreateMultiArgs
50
+ ): PluginApiReturn<PluginReferenceLineCreateMultiResult>
51
+
52
+ /**
53
+ * Get properties of a reference line by its ID.
54
+ *
55
+ * Only the properties listed in {@linkcode PluginReferenceLineGetArgs.properties
56
+ * args.properties} are returned — unlisted properties will be `undefined`
57
+ * in the result.
58
+ *
59
+ * @param args - An object containing:
60
+ * - {@linkcode PluginReferenceLineGetArgs.referenceLineId args.referenceLineId} —
61
+ * The unique reference line ID
62
+ * - {@linkcode PluginReferenceLineGetArgs.properties args.properties} — Array of
63
+ * property names to retrieve. See {@linkcode PluginReferenceLineGetProperty}.
64
+ * @returns A partial {@linkcode PluginReferenceLineGetResult} containing only the
65
+ * requested properties
66
+ * @throws If the reference line does not exist
67
+ *
68
+ * # Example
69
+ * ```ts
70
+ * const result = await snaptrude.entity.referenceLine.get({
71
+ * referenceLineId: "some-ref-line-id",
72
+ * properties: ["curve"],
73
+ * })
74
+ * console.log(result.curve) // PCurve
75
+ * ```
76
+ */
77
+ public abstract get(
78
+ args: PluginReferenceLineGetArgs
79
+ ): PluginApiReturn<PluginReferenceLineGetResult>
80
+
81
+ /**
82
+ * Get the IDs of all reference lines in the current project.
83
+ *
84
+ * Returns every reference line across all stories.
85
+ * Use the returned IDs with {@linkcode PluginReferenceLineApi.get} to query
86
+ * individual reference line properties.
87
+ *
88
+ * @returns A {@linkcode PluginReferenceLineGetAllResult} with a
89
+ * `referenceLineIds` array
90
+ *
91
+ * # Example
92
+ * ```ts
93
+ * const { referenceLineIds } = await snaptrude.entity.referenceLine.getAll()
94
+ * console.log(`Project has ${referenceLineIds.length} reference lines`)
95
+ * ```
96
+ */
97
+ public abstract getAll(): PluginApiReturn<PluginReferenceLineGetAllResult>
98
+
99
+ /**
100
+ * Delete a reference line by its ID.
101
+ *
102
+ * Permanently removes the reference line and its associated mesh from
103
+ * the scene. This operation is undoable via Snaptrude's command system.
104
+ *
105
+ * @param args - An object containing:
106
+ * - {@linkcode PluginReferenceLineDeleteArgs.referenceLineId args.referenceLineId} —
107
+ * The unique reference line ID to delete
108
+ * @throws If the reference line does not exist
109
+ *
110
+ * # Example
111
+ * ```ts
112
+ * await snaptrude.entity.referenceLine.delete({
113
+ * referenceLineId: "some-ref-line-id",
114
+ * })
115
+ * ```
116
+ */
117
+ public abstract delete(
118
+ args: PluginReferenceLineDeleteArgs
119
+ ): PluginApiReturn<PluginReferenceLineDeleteResult>
120
+ }
121
+
122
+ /**
123
+ * Arguments for {@linkcode PluginReferenceLineApi.createMulti}.
124
+ *
125
+ * | Property | Type | Description |
126
+ * |---|---|---|
127
+ * | `profile` | {@linkcode PProfile} | Profile whose curves define reference lines |
128
+ */
129
+ export const PluginReferenceLineCreateMultiArgs = z.object({
130
+ profile: PProfile,
131
+ })
132
+
133
+ export type PluginReferenceLineCreateMultiArgs = z.infer<typeof PluginReferenceLineCreateMultiArgs>
134
+
135
+ /**
136
+ * Result of {@linkcode PluginReferenceLineApi.createMulti}.
137
+ *
138
+ * | Property | Type | Description |
139
+ * |---|---|---|
140
+ * | `referenceLineIds` | `string[]` | IDs of the created reference lines |
141
+ */
142
+ export const PluginReferenceLineCreateMultiResult = z.object({
143
+ referenceLineIds: z.array(z.string()),
144
+ })
145
+
146
+ export type PluginReferenceLineCreateMultiResult = z.infer<typeof PluginReferenceLineCreateMultiResult>
147
+
148
+ /**
149
+ * Available properties that can be queried on a reference line.
150
+ *
151
+ * | Value | Return Type | Description |
152
+ * |---|---|---|
153
+ * | `"curve"` | {@linkcode PCurve} | The curve geometry of the reference line |
154
+ */
155
+ export const PluginReferenceLineGetProperty = z.enum([
156
+ "curve",
157
+ ])
158
+
159
+ /**
160
+ * Arguments for {@linkcode PluginReferenceLineApi.get}.
161
+ *
162
+ * | Property | Type | Description |
163
+ * |---|---|---|
164
+ * | `referenceLineId` | `string` | The reference line ID to query |
165
+ * | `properties` | {@linkcode PluginReferenceLineGetProperty}`[]` | Properties to retrieve |
166
+ */
167
+ export const PluginReferenceLineGetArgs = z.object({
168
+ referenceLineId: z.string(),
169
+ properties: z.array(PluginReferenceLineGetProperty),
170
+ })
171
+
172
+ export type PluginReferenceLineGetArgs = z.infer<typeof PluginReferenceLineGetArgs>
173
+
174
+ /**
175
+ * Result of {@linkcode PluginReferenceLineApi.get}.
176
+ *
177
+ * A partial object — only the properties that were requested in
178
+ * {@linkcode PluginReferenceLineGetArgs.properties} will be present.
179
+ */
180
+ export const PluginReferenceLineGetResult = z
181
+ .object({
182
+ curve: PCurve,
183
+ })
184
+ .partial()
185
+
186
+ export type PluginReferenceLineGetResult = z.infer<typeof PluginReferenceLineGetResult>
187
+
188
+ /**
189
+ * Result of {@linkcode PluginReferenceLineApi.getAll}.
190
+ *
191
+ * | Property | Type | Description |
192
+ * |---|---|---|
193
+ * | `referenceLineIds` | `string[]` | IDs of all reference lines in the project |
194
+ */
195
+ export const PluginReferenceLineGetAllResult = z.object({
196
+ referenceLineIds: z.array(z.string()),
197
+ })
198
+
199
+ export type PluginReferenceLineGetAllResult = z.infer<typeof PluginReferenceLineGetAllResult>
200
+
201
+ /**
202
+ * Arguments for {@linkcode PluginReferenceLineApi.delete}.
203
+ *
204
+ * | Property | Type | Description |
205
+ * |---|---|---|
206
+ * | `referenceLineId` | `string` | The reference line ID to delete |
207
+ */
208
+ export const PluginReferenceLineDeleteArgs = z.object({
209
+ referenceLineId: z.string(),
210
+ })
211
+
212
+ export type PluginReferenceLineDeleteArgs = z.infer<typeof PluginReferenceLineDeleteArgs>
213
+
214
+ /** Result type for {@linkcode PluginReferenceLineApi.delete} — returns nothing on success. */
215
+ export type PluginReferenceLineDeleteResult = void