@snaptrude/plugin-core 0.2.4 → 0.2.5

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 (52) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/api/core/geom/arc.d.ts +81 -0
  3. package/dist/api/core/geom/arc.d.ts.map +1 -0
  4. package/dist/api/core/geom/curve.d.ts +70 -0
  5. package/dist/api/core/geom/curve.d.ts.map +1 -0
  6. package/dist/api/core/geom/index.d.ts +32 -0
  7. package/dist/api/core/geom/index.d.ts.map +1 -0
  8. package/dist/api/core/geom/line.d.ts +56 -0
  9. package/dist/api/core/geom/line.d.ts.map +1 -0
  10. package/dist/api/core/geom/profile.d.ts +121 -0
  11. package/dist/api/core/geom/profile.d.ts.map +1 -0
  12. package/dist/api/core/index.d.ts +18 -0
  13. package/dist/api/core/index.d.ts.map +1 -0
  14. package/dist/api/core/math/index.d.ts +18 -0
  15. package/dist/api/core/math/index.d.ts.map +1 -0
  16. package/dist/api/core/math/quat.d.ts +187 -0
  17. package/dist/api/core/math/quat.d.ts.map +1 -0
  18. package/dist/api/core/math/vec3.d.ts +156 -0
  19. package/dist/api/core/math/vec3.d.ts.map +1 -0
  20. package/dist/api/entity/buildableEnvelope.d.ts +233 -0
  21. package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
  22. package/dist/api/entity/department.d.ts +99 -0
  23. package/dist/api/entity/department.d.ts.map +1 -0
  24. package/dist/api/entity/index.d.ts +33 -0
  25. package/dist/api/entity/index.d.ts.map +1 -0
  26. package/dist/api/entity/referenceLine.d.ts +259 -0
  27. package/dist/api/entity/referenceLine.d.ts.map +1 -0
  28. package/dist/api/entity/space.d.ts +816 -0
  29. package/dist/api/entity/space.d.ts.map +1 -0
  30. package/dist/api/entity/story.d.ts +239 -0
  31. package/dist/api/entity/story.d.ts.map +1 -0
  32. package/dist/api/index.d.ts +30 -0
  33. package/dist/api/index.d.ts.map +1 -0
  34. package/dist/api/tools/copy.d.ts +59 -0
  35. package/dist/api/tools/copy.d.ts.map +1 -0
  36. package/dist/api/tools/index.d.ts +29 -0
  37. package/dist/api/tools/index.d.ts.map +1 -0
  38. package/dist/api/tools/offset.d.ts +43 -0
  39. package/dist/api/tools/offset.d.ts.map +1 -0
  40. package/dist/api/tools/selection.d.ts +48 -0
  41. package/dist/api/tools/selection.d.ts.map +1 -0
  42. package/dist/api/tools/transform.d.ts +114 -0
  43. package/dist/api/tools/transform.d.ts.map +1 -0
  44. package/dist/api/units/index.d.ts +163 -0
  45. package/dist/api/units/index.d.ts.map +1 -0
  46. package/dist/host-utils.d.ts +41 -0
  47. package/dist/host-utils.d.ts.map +1 -0
  48. package/dist/index.d.ts +4 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/types.d.ts +16 -0
  51. package/dist/types.d.ts.map +1 -0
  52. package/package.json +1 -1
@@ -0,0 +1,163 @@
1
+ import * as z from "zod";
2
+ import { PluginApiReturn } from "../../types";
3
+ /**
4
+ * Unit conversion between real-world units and Snaptrude's internal
5
+ * (Babylon) coordinate system.
6
+ *
7
+ * Snaptrude uses an internal unit system (Babylon units) for all
8
+ * coordinates and dimensions. Use these methods to convert between
9
+ * real-world measurements and Babylon units.
10
+ *
11
+ * Accessed via `snaptrude.units`.
12
+ */
13
+ export declare abstract class PluginUnitsApi {
14
+ constructor();
15
+ /**
16
+ * Convert a value from a real-world unit to Snaptrude's internal (Babylon) units.
17
+ *
18
+ * Use this when you have a measurement in real-world units (e.g. meters, feet)
19
+ * and need to convert it to the coordinate system used by Snaptrude internally.
20
+ *
21
+ * @param args - An object containing:
22
+ * - {@linkcode PluginUnitsConvertFromArgs.unit args.unit} — The source unit
23
+ * to convert from. See {@linkcode PUnitType} for supported values.
24
+ * - {@linkcode PluginUnitsConvertFromArgs.value args.value} — The numeric
25
+ * value in the source unit
26
+ * - {@linkcode PluginUnitsConvertFromArgs.degree args.degree} — (Optional)
27
+ * Degree of the unit: 1 for length, 2 for area, 3 for volume. Defaults to 1
28
+ * @returns A {@linkcode PluginUnitsConvertFromResult} containing the converted
29
+ * `value` in Babylon units
30
+ *
31
+ * # Example
32
+ * ```ts
33
+ * // Convert 5 meters to Babylon units for use in API calls
34
+ * const result = await snaptrude.units.convertFrom({ unit: "meters", value: 5 })
35
+ * const { spaceId } = await snaptrude.entity.space.createRectangular({
36
+ * position: snaptrude.core.math.vec3.new(0, 0, 0),
37
+ * dimensions: { width: result.value, height: result.value, depth: result.value },
38
+ * })
39
+ * ```
40
+ */
41
+ abstract convertFrom(args: PluginUnitsConvertFromArgs): PluginApiReturn<PluginUnitsConvertFromResult>;
42
+ /**
43
+ * Convert a value from Snaptrude's internal (Babylon) units to a real-world unit.
44
+ *
45
+ * Use this when you have a value in Snaptrude's internal coordinate system
46
+ * and need to express it in real-world units (e.g. meters, feet).
47
+ *
48
+ * @param args - An object containing:
49
+ * - {@linkcode PluginUnitsConvertToArgs.unit args.unit} — The target unit
50
+ * to convert to. See {@linkcode PUnitType} for supported values.
51
+ * - {@linkcode PluginUnitsConvertToArgs.value args.value} — The numeric
52
+ * value in Babylon units
53
+ * - {@linkcode PluginUnitsConvertToArgs.degree args.degree} — (Optional)
54
+ * Degree of the unit: 1 for length, 2 for area, 3 for volume. Defaults to 1
55
+ * @returns A {@linkcode PluginUnitsConvertToResult} containing the converted
56
+ * `value` in the target unit
57
+ *
58
+ * # Example
59
+ * ```ts
60
+ * // Get a space's area in square meters
61
+ * const info = await snaptrude.entity.space.get({
62
+ * spaceId: "some-id",
63
+ * properties: ["area"],
64
+ * })
65
+ * const areaInMeters = await snaptrude.units.convertTo({
66
+ * unit: "meters",
67
+ * value: info.area!,
68
+ * degree: 2,
69
+ * })
70
+ * ```
71
+ */
72
+ abstract convertTo(args: PluginUnitsConvertToArgs): PluginApiReturn<PluginUnitsConvertToResult>;
73
+ }
74
+ /**
75
+ * Supported unit types for conversion.
76
+ *
77
+ * - `meters` — Metric meters
78
+ * - `feet-inches` — Imperial feet (1 foot = 12 inches)
79
+ * - `inches` — Imperial inches
80
+ * - `centimeters` — Metric centimeters
81
+ * - `millimeters` — Metric millimeters
82
+ * - `kilometers` — Metric kilometers
83
+ * - `miles` — Imperial miles
84
+ */
85
+ export declare const PUnitType: z.ZodEnum<{
86
+ meters: "meters";
87
+ "feet-inches": "feet-inches";
88
+ inches: "inches";
89
+ centimeters: "centimeters";
90
+ millimeters: "millimeters";
91
+ kilometers: "kilometers";
92
+ miles: "miles";
93
+ }>;
94
+ export type PUnitType = z.infer<typeof PUnitType>;
95
+ /**
96
+ * Arguments for {@linkcode PluginUnitsApi.convertFrom}.
97
+ *
98
+ * | Property | Type | Description |
99
+ * |---|---|---|
100
+ * | `unit` | {@linkcode PUnitType} | Source real-world unit |
101
+ * | `value` | `number` | Numeric value in the source unit |
102
+ * | `degree` | `1 \| 2 \| 3` | (Optional) Degree of the unit (e.g. 1 for length, 2 for area, 3 for volume). Defaults to 1 |
103
+ */
104
+ export declare const PluginUnitsConvertFromArgs: z.ZodObject<{
105
+ unit: z.ZodEnum<{
106
+ meters: "meters";
107
+ "feet-inches": "feet-inches";
108
+ inches: "inches";
109
+ centimeters: "centimeters";
110
+ millimeters: "millimeters";
111
+ kilometers: "kilometers";
112
+ miles: "miles";
113
+ }>;
114
+ value: z.ZodNumber;
115
+ degree: z.ZodOptional<z.ZodNumber>;
116
+ }, z.core.$strip>;
117
+ export type PluginUnitsConvertFromArgs = z.infer<typeof PluginUnitsConvertFromArgs>;
118
+ /**
119
+ * Result of {@linkcode PluginUnitsApi.convertFrom}.
120
+ *
121
+ * | Property | Type | Description |
122
+ * |---|---|---|
123
+ * | `value` | `number` | The converted value in Babylon units |
124
+ */
125
+ export declare const PluginUnitsConvertFromResult: z.ZodObject<{
126
+ value: z.ZodNumber;
127
+ }, z.core.$strip>;
128
+ export type PluginUnitsConvertFromResult = z.infer<typeof PluginUnitsConvertFromResult>;
129
+ /**
130
+ * Arguments for {@linkcode PluginUnitsApi.convertTo}.
131
+ *
132
+ * | Property | Type | Description |
133
+ * |---|---|---|
134
+ * | `unit` | {@linkcode PUnitType} | Target real-world unit |
135
+ * | `value` | `number` | Numeric value in Babylon units |
136
+ * | `degree` | `1 \| 2 \| 3` | (Optional) Degree of the unit (e.g. 1 for length, 2 for area, 3 for volume). Defaults to 1 |
137
+ */
138
+ export declare const PluginUnitsConvertToArgs: z.ZodObject<{
139
+ unit: z.ZodEnum<{
140
+ meters: "meters";
141
+ "feet-inches": "feet-inches";
142
+ inches: "inches";
143
+ centimeters: "centimeters";
144
+ millimeters: "millimeters";
145
+ kilometers: "kilometers";
146
+ miles: "miles";
147
+ }>;
148
+ value: z.ZodNumber;
149
+ degree: z.ZodOptional<z.ZodNumber>;
150
+ }, z.core.$strip>;
151
+ export type PluginUnitsConvertToArgs = z.infer<typeof PluginUnitsConvertToArgs>;
152
+ /**
153
+ * Result of {@linkcode PluginUnitsApi.convertTo}.
154
+ *
155
+ * | Property | Type | Description |
156
+ * |---|---|---|
157
+ * | `value` | `number` | The converted value in the target unit |
158
+ */
159
+ export declare const PluginUnitsConvertToResult: z.ZodObject<{
160
+ value: z.ZodNumber;
161
+ }, z.core.$strip>;
162
+ export type PluginUnitsConvertToResult = z.infer<typeof PluginUnitsConvertToResult>;
163
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/units/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;;;;;;GASG;AACH,8BAAsB,cAAc;;IAGlC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;aACa,WAAW,CACzB,IAAI,EAAE,0BAA0B,GAC/B,eAAe,CAAC,4BAA4B,CAAC;IAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;aACa,SAAS,CACvB,IAAI,EAAE,wBAAwB,GAC7B,eAAe,CAAC,0BAA0B,CAAC;CAC/C;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS;;;;;;;;EAQpB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAEjD;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;iBAIrC,CAAA;AAEF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAEnF;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B;;iBAEvC,CAAA;AAEF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAEvF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;iBAInC,CAAA;AAEF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAE/E;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B;;iBAErC,CAAA;AAEF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA"}
@@ -0,0 +1,41 @@
1
+ import type { PluginApi } from "./api";
2
+ /**
3
+ * UnionToIntersection is a type utility that converts a union type to an intersection type.
4
+ */
5
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
6
+ type Flatten<T> = {
7
+ [K in keyof T]: T[K];
8
+ };
9
+ type MethodArgs<F extends (...args: any[]) => any> = Parameters<F> extends [infer A] ? A : void;
10
+ type MethodReturn<F extends (...args: any[]) => any> = Awaited<ReturnType<F>>;
11
+ /**
12
+ * Recursively walks a type tree and produces a union of single-key Records
13
+ * for every leaf method, using dot-separated paths as keys.
14
+ */
15
+ type ExtractMethodPaths<T, Prefix extends string = ""> = {
16
+ [K in keyof T & string]: T[K] extends (...args: any[]) => any ? Record<`${Prefix}${K}`, {
17
+ args: MethodArgs<T[K]>;
18
+ return: MethodReturn<T[K]>;
19
+ }> : T[K] extends object ? ExtractMethodPaths<T[K], `${Prefix}${K}.`> : never;
20
+ }[keyof T & string];
21
+ /**
22
+ * Maps every plugin API method path to its argument and return types.
23
+ * Automatically inferred from the PluginApi abstract class hierarchy.
24
+ */
25
+ export type PluginApiMethodMap = Flatten<UnionToIntersection<ExtractMethodPaths<PluginApi>>>;
26
+ export type PluginApiMethod = keyof PluginApiMethodMap;
27
+ export type PluginApiCallPayload<M extends PluginApiMethod = PluginApiMethod> = PluginApiMethodMap[M]["args"] extends void ? {
28
+ method: M;
29
+ args?: void;
30
+ } : {
31
+ method: M;
32
+ args: PluginApiMethodMap[M]["args"];
33
+ };
34
+ export type PluginApiCallResult<M extends PluginApiMethod> = PluginApiMethodMap[M]["return"];
35
+ export type PluginApiCallWrappedResult<M extends PluginApiMethod> = {
36
+ success: boolean;
37
+ data?: PluginApiCallResult<M>;
38
+ error?: string;
39
+ };
40
+ export {};
41
+ //# sourceMappingURL=host-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-utils.d.ts","sourceRoot":"","sources":["../src/host-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC;;GAEG;AACH,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,SAAS,CAC7E,CAAC,EAAE,MAAM,CAAC,KACP,IAAI,GACL,CAAC,GACD,KAAK,CAAA;AAET,KAAK,OAAO,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAA;AAE1C,KAAK,UAAU,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GA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,CAAC,CAAC;IAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;CAAE,CAAA;AAExD,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,eAAe,IACvD,kBAAkB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;AAEjC,MAAM,MAAM,0BAA0B,CAAC,CAAC,SAAS,eAAe,IAAI;IAClE,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA"}
@@ -0,0 +1,4 @@
1
+ export * from "./api";
2
+ export * from "./types";
3
+ export * from "./host-utils";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,SAAS,CAAA;AACvB,cAAc,cAAc,CAAA"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A unique identifier for a component in the Snaptrude scene.
3
+ *
4
+ * Component IDs are returned by entity creation methods (e.g.
5
+ * {@linkcode PluginSpaceApi.createRectangular}) and can be used with
6
+ * query and transform methods throughout the API.
7
+ */
8
+ export type ComponentId = string;
9
+ /**
10
+ * Return type for a plugin API method.
11
+ *
12
+ * Methods that require a host round-trip return `Promise<T>`,
13
+ * while pure local computations may return `T` directly.
14
+ */
15
+ export type PluginApiReturn<T> = Promise<T> | T;
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAA;AAEhC;;;;;GAKG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snaptrude/plugin-core",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",