@snaptrude/plugin-core 0.2.0 → 0.3.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.
@@ -9,13 +9,13 @@ import { PluginUnitsApi } from "./units";
9
9
  *
10
10
  * - {@linkcode PluginApi.core} — Math and geometry primitives
11
11
  * - {@linkcode PluginApi.entity} — CRUD operations on Snaptrude entities (spaces, stories)
12
- * - {@linkcode PluginApi.tools} — Copy, offset, selection, and transform tools
12
+ * - {@linkcode PluginApi.tools} — Copy, offset, selection, material and transform tools
13
13
  * - {@linkcode PluginApi.units} — Unit conversion utilities
14
14
  */
15
15
  export declare abstract class PluginApi {
16
16
  /** Core math and geometry primitives. See {@linkcode PluginCoreApi}. */
17
17
  abstract core: PluginCoreApi;
18
- /** Copy, offset, selection, and transform tools. See {@linkcode PluginToolsApi}. */
18
+ /** Copy, offset, selection, material and transform tools. See {@linkcode PluginToolsApi}. */
19
19
  abstract tools: PluginToolsApi;
20
20
  /** CRUD operations on Snaptrude entities. See {@linkcode PluginEntityApi}. */
21
21
  abstract entity: PluginEntityApi;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;;;;;GASG;AACH,8BAAsB,SAAS;IAC7B,wEAAwE;IACxE,SAAgB,IAAI,EAAE,aAAa,CAAA;IACnC,oFAAoF;IACpF,SAAgB,KAAK,EAAE,cAAc,CAAA;IACrC,8EAA8E;IAC9E,SAAgB,MAAM,EAAE,eAAe,CAAA;IACvC,iEAAiE;IACjE,SAAgB,KAAK,EAAE,cAAc,CAAA;;CAGtC;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExC;;;;;;;;;GASG;AACH,8BAAsB,SAAS;IAC7B,wEAAwE;IACxE,SAAgB,IAAI,EAAE,aAAa,CAAA;IACnC,6FAA6F;IAC7F,SAAgB,KAAK,EAAE,cAAc,CAAA;IACrC,8EAA8E;IAC9E,SAAgB,MAAM,EAAE,eAAe,CAAA;IACvC,iEAAiE;IACjE,SAAgB,KAAK,EAAE,cAAc,CAAA;;CAGtC;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { PluginMaterialApi } from "./material";
1
2
  import { PluginSelectionApi } from "./selection";
2
3
  import { PluginTransformApi } from "./transform";
3
4
  import type { PluginApiReturn } from "../../types";
@@ -16,6 +17,8 @@ export declare abstract class PluginToolsApi {
16
17
  abstract selection: PluginSelectionApi;
17
18
  /** Move and rotate components. See {@linkcode PluginTransformApi}. */
18
19
  abstract transform: PluginTransformApi;
20
+ /** Apply materials to the current user selection in the Snaptrude editor or passed component ids if any. See {@linkcode PluginMaterialApi}. */
21
+ abstract material: PluginMaterialApi;
19
22
  /** Copy components by ID. See {@linkcode PluginCopyArgs}. */
20
23
  abstract copy(args: PluginCopyArgs): PluginApiReturn<PluginCopyResult>;
21
24
  /** Offset or split a component profile. See {@linkcode PluginOffsetArgs}. */
@@ -26,4 +29,5 @@ export * from "./copy";
26
29
  export * from "./offset";
27
30
  export * from "./selection";
28
31
  export * from "./transform";
32
+ export * from "./material";
29
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAEpE;;;;;;;GAOG;AACH,8BAAsB,cAAc;IAClC,uEAAuE;IACvE,SAAgB,SAAS,EAAE,kBAAkB,CAAA;IAC7C,sEAAsE;IACtE,SAAgB,SAAS,EAAE,kBAAkB,CAAA;IAE7C,6DAA6D;aAC7C,IAAI,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,CAAC,gBAAgB,CAAC;IAE7E,6EAA6E;aAC7D,MAAM,CACpB,IAAI,EAAE,gBAAgB,GACrB,eAAe,CAAC,kBAAkB,CAAC;;CAGvC;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAEpE;;;;;;;GAOG;AACH,8BAAsB,cAAc;IAClC,uEAAuE;IACvE,SAAgB,SAAS,EAAE,kBAAkB,CAAA;IAC7C,sEAAsE;IACtE,SAAgB,SAAS,EAAE,kBAAkB,CAAA;IAC7C,+IAA+I;IAC/I,SAAgB,QAAQ,EAAE,iBAAiB,CAAA;IAE3C,6DAA6D;aAC7C,IAAI,CAAC,IAAI,EAAE,cAAc,GAAG,eAAe,CAAC,gBAAgB,CAAC;IAE7E,6EAA6E;aAC7D,MAAM,CACpB,IAAI,EAAE,gBAAgB,GACrB,eAAe,CAAC,kBAAkB,CAAC;;CAGvC;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,51 @@
1
+ import * as z from "zod";
2
+ import { PluginApiReturn } from "../../types";
3
+ /**
4
+ * Apply materials to the current user selection in the Snaptrude editor or passed component ids if any.
5
+ *
6
+ * Accessed via `snaptrude.tools.material`.
7
+ */
8
+ export declare abstract class PluginMaterialApi {
9
+ constructor();
10
+ /**
11
+ * Apply materials to the current user selection in the Snaptrude editor or passed component ids if any.
12
+ *
13
+ * @param args - An object containing:
14
+ * - {@linkcode PluginMaterialArgs.materialName args.materialName} — Material to apply
15
+ * - {@linkcode PluginMaterialArgs.componentIds args.componentIds} — Array of component
16
+ * ID strings to apply materials to if provided, if not provided, the current user selection will be used
17
+ */
18
+ abstract apply({ materialName, componentIds, }: PluginMaterialArgs): PluginApiReturn<void>;
19
+ }
20
+ declare enum DEFAULT_MATERIALS {
21
+ GLASS = "glass",
22
+ WOOD = "wood",
23
+ METAL = "metal",
24
+ STONE = "stone",
25
+ TILES = "tiles",
26
+ CONCRETE = "concrete",
27
+ BRICK = "brick"
28
+ }
29
+ /**
30
+ * Arguments for {@linkcode PluginMaterialApi.apply}.
31
+ *
32
+ * | Property | Type | Description |
33
+ * |---|---|---|
34
+ * | `materialName` | `DEFAULT_MATERIALS` | Material to apply |
35
+ * | `componentIds` | `string[]` | Component IDs to apply materials to if provided |
36
+ */
37
+ export declare const PluginMaterialArgs: z.ZodObject<{
38
+ materialName: z.ZodEnum<{
39
+ glass: DEFAULT_MATERIALS.GLASS;
40
+ wood: DEFAULT_MATERIALS.WOOD;
41
+ metal: DEFAULT_MATERIALS.METAL;
42
+ stone: DEFAULT_MATERIALS.STONE;
43
+ tiles: DEFAULT_MATERIALS.TILES;
44
+ concrete: DEFAULT_MATERIALS.CONCRETE;
45
+ brick: DEFAULT_MATERIALS.BRICK;
46
+ }>;
47
+ componentIds: z.ZodArray<z.ZodString>;
48
+ }, z.core.$strip>;
49
+ export type PluginMaterialArgs = z.infer<typeof PluginMaterialArgs>;
50
+ export {};
51
+ //# sourceMappingURL=material.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"material.d.ts","sourceRoot":"","sources":["../../../src/api/tools/material.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C;;;;GAIG;AACH,8BAAsB,iBAAiB;;IAGrC;;;;;;;OAOG;aACa,KAAK,CAAC,EACpB,YAAY,EACZ,YAAY,GACb,EAAE,kBAAkB,GAAG,eAAe,CAAC,IAAI,CAAC;CAC9C;AAED,aAAK,iBAAiB;IACpB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,KAAK,UAAU;IACf,KAAK,UAAU;IACf,KAAK,UAAU;IACf,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;iBAG7B,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
package/dist/index.cjs CHANGED
@@ -54,6 +54,8 @@ __export(index_exports, {
54
54
  PluginGeomApi: () => PluginGeomApi,
55
55
  PluginLineApi: () => PluginLineApi,
56
56
  PluginMassType: () => PluginMassType,
57
+ PluginMaterialApi: () => PluginMaterialApi,
58
+ PluginMaterialArgs: () => PluginMaterialArgs,
57
59
  PluginMathApi: () => PluginMathApi,
58
60
  PluginMoveArgs: () => PluginMoveArgs,
59
61
  PluginOffsetArgs: () => PluginOffsetArgs,
@@ -125,8 +127,8 @@ var PluginVec3Api = class {
125
127
  * // { x: 1, y: 2, z: 3 }
126
128
  * ```
127
129
  */
128
- new(x, y, z16) {
129
- return { x, y, z: z16 };
130
+ new(x, y, z17) {
131
+ return { x, y, z: z17 };
130
132
  }
131
133
  /**
132
134
  * Add two vectors component-wise.
@@ -304,8 +306,8 @@ var PluginQuatApi = class {
304
306
  * @param w - The W (scalar) component
305
307
  * @returns A new {@linkcode PQuat}
306
308
  */
307
- new(x, y, z16, w) {
308
- return { x, y, z: z16, w };
309
+ new(x, y, z17, w) {
310
+ return { x, y, z: z17, w };
309
311
  }
310
312
  /**
311
313
  * Create an identity quaternion representing no rotation.
@@ -349,13 +351,13 @@ var PluginQuatApi = class {
349
351
  * @param z - Rotation around Z axis in **radians**
350
352
  * @returns A new {@linkcode PQuat}
351
353
  */
352
- fromEuler(x, y, z16) {
354
+ fromEuler(x, y, z17) {
353
355
  const cx = Math.cos(x / 2);
354
356
  const sx = Math.sin(x / 2);
355
357
  const cy = Math.cos(y / 2);
356
358
  const sy = Math.sin(y / 2);
357
- const cz = Math.cos(z16 / 2);
358
- const sz = Math.sin(z16 / 2);
359
+ const cz = Math.cos(z17 / 2);
360
+ const sz = Math.sin(z17 / 2);
359
361
  return {
360
362
  x: sx * cy * cz + cx * sy * sz,
361
363
  y: cx * sy * cz - sx * cy * sz,
@@ -989,6 +991,27 @@ var PluginRotateArgs = z14.object({
989
991
  pivot: PVec3
990
992
  });
991
993
 
994
+ // src/api/tools/material.ts
995
+ var z15 = __toESM(require("zod"), 1);
996
+ var PluginMaterialApi = class {
997
+ constructor() {
998
+ }
999
+ };
1000
+ var DEFAULT_MATERIALS = /* @__PURE__ */ ((DEFAULT_MATERIALS2) => {
1001
+ DEFAULT_MATERIALS2["GLASS"] = "glass";
1002
+ DEFAULT_MATERIALS2["WOOD"] = "wood";
1003
+ DEFAULT_MATERIALS2["METAL"] = "metal";
1004
+ DEFAULT_MATERIALS2["STONE"] = "stone";
1005
+ DEFAULT_MATERIALS2["TILES"] = "tiles";
1006
+ DEFAULT_MATERIALS2["CONCRETE"] = "concrete";
1007
+ DEFAULT_MATERIALS2["BRICK"] = "brick";
1008
+ return DEFAULT_MATERIALS2;
1009
+ })(DEFAULT_MATERIALS || {});
1010
+ var PluginMaterialArgs = z15.object({
1011
+ materialName: z15.enum(Object.values(DEFAULT_MATERIALS)),
1012
+ componentIds: z15.array(z15.string())
1013
+ });
1014
+
992
1015
  // src/api/tools/index.ts
993
1016
  var PluginToolsApi = class {
994
1017
  constructor() {
@@ -996,12 +1019,12 @@ var PluginToolsApi = class {
996
1019
  };
997
1020
 
998
1021
  // src/api/units/index.ts
999
- var z15 = __toESM(require("zod"), 1);
1022
+ var z16 = __toESM(require("zod"), 1);
1000
1023
  var PluginUnitsApi = class {
1001
1024
  constructor() {
1002
1025
  }
1003
1026
  };
1004
- var PUnitType = z15.enum([
1027
+ var PUnitType = z16.enum([
1005
1028
  "meters",
1006
1029
  "feet-inches",
1007
1030
  "inches",
@@ -1010,21 +1033,21 @@ var PUnitType = z15.enum([
1010
1033
  "kilometers",
1011
1034
  "miles"
1012
1035
  ]);
1013
- var PluginUnitsConvertFromArgs = z15.object({
1036
+ var PluginUnitsConvertFromArgs = z16.object({
1014
1037
  unit: PUnitType,
1015
- value: z15.number(),
1016
- degree: z15.number().int().min(1).max(3).optional()
1038
+ value: z16.number(),
1039
+ degree: z16.number().int().min(1).max(3).optional()
1017
1040
  });
1018
- var PluginUnitsConvertFromResult = z15.object({
1019
- value: z15.number()
1041
+ var PluginUnitsConvertFromResult = z16.object({
1042
+ value: z16.number()
1020
1043
  });
1021
- var PluginUnitsConvertToArgs = z15.object({
1044
+ var PluginUnitsConvertToArgs = z16.object({
1022
1045
  unit: PUnitType,
1023
- value: z15.number(),
1024
- degree: z15.number().int().min(1).max(3).optional()
1046
+ value: z16.number(),
1047
+ degree: z16.number().int().min(1).max(3).optional()
1025
1048
  });
1026
- var PluginUnitsConvertToResult = z15.object({
1027
- value: z15.number()
1049
+ var PluginUnitsConvertToResult = z16.object({
1050
+ value: z16.number()
1028
1051
  });
1029
1052
 
1030
1053
  // src/api/index.ts
@@ -1058,6 +1081,8 @@ var PluginApi = class {
1058
1081
  PluginGeomApi,
1059
1082
  PluginLineApi,
1060
1083
  PluginMassType,
1084
+ PluginMaterialApi,
1085
+ PluginMaterialArgs,
1061
1086
  PluginMathApi,
1062
1087
  PluginMoveArgs,
1063
1088
  PluginOffsetArgs,