@snaptrude/plugin-core 0.0.1
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/dist/api/entity/index.d.ts +7 -0
- package/dist/api/entity/index.d.ts.map +1 -0
- package/dist/api/entity/space.d.ts +25 -0
- package/dist/api/entity/space.d.ts.map +1 -0
- package/dist/api/index.d.ts +10 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/tools/index.d.ts +10 -0
- package/dist/api/tools/index.d.ts.map +1 -0
- package/dist/api/tools/selection.d.ts +9 -0
- package/dist/api/tools/selection.d.ts.map +1 -0
- package/dist/api/tools/transform.d.ts +17 -0
- package/dist/api/tools/transform.d.ts.map +1 -0
- package/dist/host-utils.d.ts +36 -0
- package/dist/host-utils.d.ts.map +1 -0
- package/dist/index.cjs +76 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +29 -0
- package/src/api/entity/index.ts +9 -0
- package/src/api/entity/space.ts +45 -0
- package/src/api/index.ts +12 -0
- package/src/api/tools/index.ts +12 -0
- package/src/api/tools/selection.ts +11 -0
- package/src/api/tools/transform.ts +29 -0
- package/src/host-utils.ts +54 -0
- package/src/index.ts +3 -0
- package/src/types.ts +9 -0
- package/tsconfig.json +16 -0
- package/tsup.config.ts +13 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/entity/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExC,8BAAsB,eAAe;IACnC,SAAgB,KAAK,EAAE,cAAc,CAAA;;CAGtC;AAED,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ComponentId, PluginApiReturn } from "../../types";
|
|
2
|
+
export declare abstract class PluginSpaceApi {
|
|
3
|
+
constructor();
|
|
4
|
+
abstract createRectangular({ position, dimensions, }: PluginSpaceCreateRectangularArgs): PluginApiReturn<PluginSpaceCreateRectangularResult>;
|
|
5
|
+
abstract getById({ spaceId, properties, }: PluginSpaceGetByIdArgs): PluginApiReturn<PluginSpaceGetByIdResult>;
|
|
6
|
+
abstract deleteById({ spaceId, }: PluginSpaceDeleteByIdArgs): PluginApiReturn<PluginSpaceDeleteByIdResult>;
|
|
7
|
+
}
|
|
8
|
+
export type PluginSpaceCreateRectangularArgs = {
|
|
9
|
+
position: [number, number, number];
|
|
10
|
+
dimensions: [number, number, number];
|
|
11
|
+
};
|
|
12
|
+
export type PluginSpaceCreateRectangularResult = {
|
|
13
|
+
spaceId: ComponentId;
|
|
14
|
+
};
|
|
15
|
+
export type PluginSpaceGetByIdArgs = {
|
|
16
|
+
spaceId: ComponentId;
|
|
17
|
+
properties: PluginSpaceGetByIdProperty[];
|
|
18
|
+
};
|
|
19
|
+
export type PluginSpaceGetByIdProperty = "id" | "type" | "room_type";
|
|
20
|
+
export type PluginSpaceGetByIdResult = Partial<Record<PluginSpaceGetByIdProperty, any>>;
|
|
21
|
+
export type PluginSpaceDeleteByIdArgs = {
|
|
22
|
+
spaceId: ComponentId;
|
|
23
|
+
};
|
|
24
|
+
export type PluginSpaceDeleteByIdResult = void;
|
|
25
|
+
//# sourceMappingURL=space.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../../src/api/entity/space.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE1D,8BAAsB,cAAc;;aAGlB,iBAAiB,CAAC,EAChC,QAAQ,EACR,UAAU,GACX,EAAE,gCAAgC,GAAG,eAAe,CAAC,kCAAkC,CAAC;aAEzE,OAAO,CAAC,EACtB,OAAO,EACP,UAAU,GACX,EAAE,sBAAsB,GAAG,eAAe,CAAC,wBAAwB,CAAC;aAErD,UAAU,CAAC,EACzB,OAAO,GACR,EAAE,yBAAyB,GAAG,eAAe,CAAC,2BAA2B,CAAC;CAC5E;AAED,MAAM,MAAM,gCAAgC,GAAG;IAC7C,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,kCAAkC,GAAG;IAC/C,OAAO,EAAE,WAAW,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,WAAW,CAAA;IACpB,UAAU,EAAE,0BAA0B,EAAE,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG,IAAI,GAAG,MAAM,GAAG,WAAW,CAAA;AAEpE,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAC5C,MAAM,CAAC,0BAA0B,EAAE,GAAG,CAAC,CACxC,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,WAAW,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PluginEntityApi } from "./entity";
|
|
2
|
+
import { PluginToolsApi } from "./tools";
|
|
3
|
+
export declare abstract class PluginApi {
|
|
4
|
+
abstract tools: PluginToolsApi;
|
|
5
|
+
abstract entity: PluginEntityApi;
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
export * from "./entity";
|
|
9
|
+
export * from "./tools";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExC,8BAAsB,SAAS;IAC7B,SAAgB,KAAK,EAAE,cAAc,CAAA;IACrC,SAAgB,MAAM,EAAE,eAAe,CAAA;;CAGxC;AAED,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PluginSelectionApi } from "./selection";
|
|
2
|
+
import { PluginTransformApi } from "./transform";
|
|
3
|
+
export declare abstract class PluginToolsApi {
|
|
4
|
+
abstract selection: PluginSelectionApi;
|
|
5
|
+
abstract transform: PluginTransformApi;
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
export * from "./selection";
|
|
9
|
+
export * from "./transform";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;AAEhD,8BAAsB,cAAc;IAClC,SAAgB,SAAS,EAAE,kBAAkB,CAAA;IAC7C,SAAgB,SAAS,EAAE,kBAAkB,CAAA;;CAG9C;AAED,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ComponentId, PluginApiReturn } from "../../types";
|
|
2
|
+
export declare abstract class PluginSelectionApi {
|
|
3
|
+
constructor();
|
|
4
|
+
abstract get(): PluginApiReturn<PluginSelectionGetResult>;
|
|
5
|
+
}
|
|
6
|
+
export type PluginSelectionGetResult = {
|
|
7
|
+
selected: ComponentId[];
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=selection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../src/api/tools/selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE1D,8BAAsB,kBAAkB;;aAGtB,GAAG,IAAI,eAAe,CAAC,wBAAwB,CAAC;CACjE;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,EAAE,WAAW,EAAE,CAAA;CACxB,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PluginApiReturn } from "../../types";
|
|
2
|
+
export declare abstract class PluginTransformApi {
|
|
3
|
+
constructor();
|
|
4
|
+
abstract move({ componentIds, displacement, }: PluginMoveArgs): PluginApiReturn<void>;
|
|
5
|
+
abstract rotate({ componentIds, angle, axis, pivot, }: PluginRotateArgs): PluginApiReturn<void>;
|
|
6
|
+
}
|
|
7
|
+
export type PluginMoveArgs = {
|
|
8
|
+
componentIds: string[];
|
|
9
|
+
displacement: [number, number, number];
|
|
10
|
+
};
|
|
11
|
+
export type PluginRotateArgs = {
|
|
12
|
+
componentIds: string[];
|
|
13
|
+
angle: number;
|
|
14
|
+
axis: [number, number, number];
|
|
15
|
+
pivot: [number, number, number];
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/api/tools/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,8BAAsB,kBAAkB;;aAGtB,IAAI,CAAC,EACnB,YAAY,EACZ,YAAY,GACb,EAAE,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC;aAEzB,MAAM,CAAC,EACrB,YAAY,EACZ,KAAK,EACL,IAAI,EACJ,KAAK,GACN,EAAE,gBAAgB,GAAG,eAAe,CAAC,IAAI,CAAC;CAC5C;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 {};
|
|
36
|
+
//# 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,GAAG,IAC/C,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;AAE5C,KAAK,YAAY,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;AAE7E;;;GAGG;AACH,KAAK,kBAAkB,CAAC,CAAC,EAAE,MAAM,SAAS,MAAM,GAAG,EAAE,IAAI;KACtD,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GACzD,MAAM,CACJ,GAAG,MAAM,GAAG,CAAC,EAAE,EACf;QAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,CACvD,GACD,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GACjB,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,GAC1C,KAAK;CACZ,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAA;AAInB;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,CACtC,mBAAmB,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,CACnD,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAA;AAEtD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe,IAC1E,kBAAkB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,IAAI,GACtC;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,IAAI,CAAA;CAAE,GAC1B;IAAE,MAAM,EAAE,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"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
PluginApi: () => PluginApi,
|
|
24
|
+
PluginEntityApi: () => PluginEntityApi,
|
|
25
|
+
PluginSelectionApi: () => PluginSelectionApi,
|
|
26
|
+
PluginSpaceApi: () => PluginSpaceApi,
|
|
27
|
+
PluginToolsApi: () => PluginToolsApi,
|
|
28
|
+
PluginTransformApi: () => PluginTransformApi
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(index_exports);
|
|
31
|
+
|
|
32
|
+
// src/api/entity/space.ts
|
|
33
|
+
var PluginSpaceApi = class {
|
|
34
|
+
constructor() {
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/api/entity/index.ts
|
|
39
|
+
var PluginEntityApi = class {
|
|
40
|
+
constructor() {
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// src/api/tools/selection.ts
|
|
45
|
+
var PluginSelectionApi = class {
|
|
46
|
+
constructor() {
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/api/tools/transform.ts
|
|
51
|
+
var PluginTransformApi = class {
|
|
52
|
+
constructor() {
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/api/tools/index.ts
|
|
57
|
+
var PluginToolsApi = class {
|
|
58
|
+
constructor() {
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// src/api/index.ts
|
|
63
|
+
var PluginApi = class {
|
|
64
|
+
constructor() {
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
PluginApi,
|
|
70
|
+
PluginEntityApi,
|
|
71
|
+
PluginSelectionApi,
|
|
72
|
+
PluginSpaceApi,
|
|
73
|
+
PluginToolsApi,
|
|
74
|
+
PluginTransformApi
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/api/entity/space.ts","../src/api/entity/index.ts","../src/api/tools/selection.ts","../src/api/tools/transform.ts","../src/api/tools/index.ts","../src/api/index.ts"],"sourcesContent":["export * from \"./api\"\nexport * from \"./types\"\nexport * from \"./host-utils\"\n","import { ComponentId, PluginApiReturn } from \"../../types\"\n\nexport abstract class PluginSpaceApi {\n constructor() {}\n\n public abstract createRectangular({\n position,\n dimensions,\n }: PluginSpaceCreateRectangularArgs): PluginApiReturn<PluginSpaceCreateRectangularResult>\n\n public abstract getById({\n spaceId,\n properties,\n }: PluginSpaceGetByIdArgs): PluginApiReturn<PluginSpaceGetByIdResult>\n\n public abstract deleteById({\n spaceId,\n }: PluginSpaceDeleteByIdArgs): PluginApiReturn<PluginSpaceDeleteByIdResult>\n}\n\nexport type PluginSpaceCreateRectangularArgs = {\n position: [number, number, number]\n dimensions: [number, number, number]\n}\n\nexport type PluginSpaceCreateRectangularResult = {\n spaceId: ComponentId\n}\n\nexport type PluginSpaceGetByIdArgs = {\n spaceId: ComponentId\n properties: PluginSpaceGetByIdProperty[]\n}\n\nexport type PluginSpaceGetByIdProperty = \"id\" | \"type\" | \"room_type\"\n\nexport type PluginSpaceGetByIdResult = Partial<\n Record<PluginSpaceGetByIdProperty, any>\n>\n\nexport type PluginSpaceDeleteByIdArgs = {\n spaceId: ComponentId\n}\n\nexport type PluginSpaceDeleteByIdResult = void\n","import { PluginSpaceApi } from \"./space\"\n\nexport abstract class PluginEntityApi {\n public abstract space: PluginSpaceApi\n\n constructor() {}\n}\n\nexport * from \"./space\"\n","import { ComponentId, PluginApiReturn } from \"../../types\"\n\nexport abstract class PluginSelectionApi {\n constructor() {}\n\n public abstract get(): PluginApiReturn<PluginSelectionGetResult>\n}\n\nexport type PluginSelectionGetResult = {\n selected: ComponentId[]\n}\n","import { PluginApiReturn } from \"../../types\"\n\nexport abstract class PluginTransformApi {\n constructor() {}\n\n public abstract move({\n componentIds,\n displacement,\n }: PluginMoveArgs): PluginApiReturn<void>\n\n public abstract rotate({\n componentIds,\n angle,\n axis,\n pivot,\n }: PluginRotateArgs): PluginApiReturn<void>\n}\n\nexport type PluginMoveArgs = {\n componentIds: string[]\n displacement: [number, number, number]\n}\n\nexport type PluginRotateArgs = {\n componentIds: string[]\n angle: number\n axis: [number, number, number]\n pivot: [number, number, number]\n}\n","import { PluginSelectionApi } from \"./selection\"\nimport { PluginTransformApi } from \"./transform\"\n\nexport abstract class PluginToolsApi {\n public abstract selection: PluginSelectionApi\n public abstract transform: PluginTransformApi\n\n constructor() {}\n}\n\nexport * from \"./selection\"\nexport * from \"./transform\"\n","import { PluginEntityApi } from \"./entity\"\nimport { PluginToolsApi } from \"./tools\"\n\nexport abstract class PluginApi {\n public abstract tools: PluginToolsApi\n public abstract entity: PluginEntityApi\n\n constructor() {}\n}\n\nexport * from \"./entity\"\nexport * from \"./tools\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAe,iBAAf,MAA8B;AAAA,EACnC,cAAc;AAAA,EAAC;AAejB;;;AChBO,IAAe,kBAAf,MAA+B;AAAA,EAGpC,cAAc;AAAA,EAAC;AACjB;;;ACJO,IAAe,qBAAf,MAAkC;AAAA,EACvC,cAAc;AAAA,EAAC;AAGjB;;;ACJO,IAAe,qBAAf,MAAkC;AAAA,EACvC,cAAc;AAAA,EAAC;AAajB;;;ACbO,IAAe,iBAAf,MAA8B;AAAA,EAInC,cAAc;AAAA,EAAC;AACjB;;;ACLO,IAAe,YAAf,MAAyB;AAAA,EAI9B,cAAc;AAAA,EAAC;AACjB;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// src/api/entity/space.ts
|
|
2
|
+
var PluginSpaceApi = class {
|
|
3
|
+
constructor() {
|
|
4
|
+
}
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/api/entity/index.ts
|
|
8
|
+
var PluginEntityApi = class {
|
|
9
|
+
constructor() {
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/api/tools/selection.ts
|
|
14
|
+
var PluginSelectionApi = class {
|
|
15
|
+
constructor() {
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// src/api/tools/transform.ts
|
|
20
|
+
var PluginTransformApi = class {
|
|
21
|
+
constructor() {
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/api/tools/index.ts
|
|
26
|
+
var PluginToolsApi = class {
|
|
27
|
+
constructor() {
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// src/api/index.ts
|
|
32
|
+
var PluginApi = class {
|
|
33
|
+
constructor() {
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
PluginApi,
|
|
38
|
+
PluginEntityApi,
|
|
39
|
+
PluginSelectionApi,
|
|
40
|
+
PluginSpaceApi,
|
|
41
|
+
PluginToolsApi,
|
|
42
|
+
PluginTransformApi
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/entity/space.ts","../src/api/entity/index.ts","../src/api/tools/selection.ts","../src/api/tools/transform.ts","../src/api/tools/index.ts","../src/api/index.ts"],"sourcesContent":["import { ComponentId, PluginApiReturn } from \"../../types\"\n\nexport abstract class PluginSpaceApi {\n constructor() {}\n\n public abstract createRectangular({\n position,\n dimensions,\n }: PluginSpaceCreateRectangularArgs): PluginApiReturn<PluginSpaceCreateRectangularResult>\n\n public abstract getById({\n spaceId,\n properties,\n }: PluginSpaceGetByIdArgs): PluginApiReturn<PluginSpaceGetByIdResult>\n\n public abstract deleteById({\n spaceId,\n }: PluginSpaceDeleteByIdArgs): PluginApiReturn<PluginSpaceDeleteByIdResult>\n}\n\nexport type PluginSpaceCreateRectangularArgs = {\n position: [number, number, number]\n dimensions: [number, number, number]\n}\n\nexport type PluginSpaceCreateRectangularResult = {\n spaceId: ComponentId\n}\n\nexport type PluginSpaceGetByIdArgs = {\n spaceId: ComponentId\n properties: PluginSpaceGetByIdProperty[]\n}\n\nexport type PluginSpaceGetByIdProperty = \"id\" | \"type\" | \"room_type\"\n\nexport type PluginSpaceGetByIdResult = Partial<\n Record<PluginSpaceGetByIdProperty, any>\n>\n\nexport type PluginSpaceDeleteByIdArgs = {\n spaceId: ComponentId\n}\n\nexport type PluginSpaceDeleteByIdResult = void\n","import { PluginSpaceApi } from \"./space\"\n\nexport abstract class PluginEntityApi {\n public abstract space: PluginSpaceApi\n\n constructor() {}\n}\n\nexport * from \"./space\"\n","import { ComponentId, PluginApiReturn } from \"../../types\"\n\nexport abstract class PluginSelectionApi {\n constructor() {}\n\n public abstract get(): PluginApiReturn<PluginSelectionGetResult>\n}\n\nexport type PluginSelectionGetResult = {\n selected: ComponentId[]\n}\n","import { PluginApiReturn } from \"../../types\"\n\nexport abstract class PluginTransformApi {\n constructor() {}\n\n public abstract move({\n componentIds,\n displacement,\n }: PluginMoveArgs): PluginApiReturn<void>\n\n public abstract rotate({\n componentIds,\n angle,\n axis,\n pivot,\n }: PluginRotateArgs): PluginApiReturn<void>\n}\n\nexport type PluginMoveArgs = {\n componentIds: string[]\n displacement: [number, number, number]\n}\n\nexport type PluginRotateArgs = {\n componentIds: string[]\n angle: number\n axis: [number, number, number]\n pivot: [number, number, number]\n}\n","import { PluginSelectionApi } from \"./selection\"\nimport { PluginTransformApi } from \"./transform\"\n\nexport abstract class PluginToolsApi {\n public abstract selection: PluginSelectionApi\n public abstract transform: PluginTransformApi\n\n constructor() {}\n}\n\nexport * from \"./selection\"\nexport * from \"./transform\"\n","import { PluginEntityApi } from \"./entity\"\nimport { PluginToolsApi } from \"./tools\"\n\nexport abstract class PluginApi {\n public abstract tools: PluginToolsApi\n public abstract entity: PluginEntityApi\n\n constructor() {}\n}\n\nexport * from \"./entity\"\nexport * from \"./tools\"\n"],"mappings":";AAEO,IAAe,iBAAf,MAA8B;AAAA,EACnC,cAAc;AAAA,EAAC;AAejB;;;AChBO,IAAe,kBAAf,MAA+B;AAAA,EAGpC,cAAc;AAAA,EAAC;AACjB;;;ACJO,IAAe,qBAAf,MAAkC;AAAA,EACvC,cAAc;AAAA,EAAC;AAGjB;;;ACJO,IAAe,qBAAf,MAAkC;AAAA,EACvC,cAAc;AAAA,EAAC;AAajB;;;ACbO,IAAe,iBAAf,MAA8B;AAAA,EAInC,cAAc;AAAA,EAAC;AACjB;;;ACLO,IAAe,YAAf,MAAyB;AAAA,EAI9B,cAAc;AAAA,EAAC;AACjB;","names":[]}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAA;AAEhC;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@snaptrude/plugin-core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"tsup": "^8.5.1",
|
|
21
|
+
"typescript": "^5.5.4"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"check-types": "tsc --noEmit",
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"dev": "tsup --watch",
|
|
27
|
+
"clean-dist": "rm -rf dist"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ComponentId, PluginApiReturn } from "../../types"
|
|
2
|
+
|
|
3
|
+
export abstract class PluginSpaceApi {
|
|
4
|
+
constructor() {}
|
|
5
|
+
|
|
6
|
+
public abstract createRectangular({
|
|
7
|
+
position,
|
|
8
|
+
dimensions,
|
|
9
|
+
}: PluginSpaceCreateRectangularArgs): PluginApiReturn<PluginSpaceCreateRectangularResult>
|
|
10
|
+
|
|
11
|
+
public abstract getById({
|
|
12
|
+
spaceId,
|
|
13
|
+
properties,
|
|
14
|
+
}: PluginSpaceGetByIdArgs): PluginApiReturn<PluginSpaceGetByIdResult>
|
|
15
|
+
|
|
16
|
+
public abstract deleteById({
|
|
17
|
+
spaceId,
|
|
18
|
+
}: PluginSpaceDeleteByIdArgs): PluginApiReturn<PluginSpaceDeleteByIdResult>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type PluginSpaceCreateRectangularArgs = {
|
|
22
|
+
position: [number, number, number]
|
|
23
|
+
dimensions: [number, number, number]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type PluginSpaceCreateRectangularResult = {
|
|
27
|
+
spaceId: ComponentId
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type PluginSpaceGetByIdArgs = {
|
|
31
|
+
spaceId: ComponentId
|
|
32
|
+
properties: PluginSpaceGetByIdProperty[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type PluginSpaceGetByIdProperty = "id" | "type" | "room_type"
|
|
36
|
+
|
|
37
|
+
export type PluginSpaceGetByIdResult = Partial<
|
|
38
|
+
Record<PluginSpaceGetByIdProperty, any>
|
|
39
|
+
>
|
|
40
|
+
|
|
41
|
+
export type PluginSpaceDeleteByIdArgs = {
|
|
42
|
+
spaceId: ComponentId
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type PluginSpaceDeleteByIdResult = void
|
package/src/api/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PluginEntityApi } from "./entity"
|
|
2
|
+
import { PluginToolsApi } from "./tools"
|
|
3
|
+
|
|
4
|
+
export abstract class PluginApi {
|
|
5
|
+
public abstract tools: PluginToolsApi
|
|
6
|
+
public abstract entity: PluginEntityApi
|
|
7
|
+
|
|
8
|
+
constructor() {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export * from "./entity"
|
|
12
|
+
export * from "./tools"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PluginSelectionApi } from "./selection"
|
|
2
|
+
import { PluginTransformApi } from "./transform"
|
|
3
|
+
|
|
4
|
+
export abstract class PluginToolsApi {
|
|
5
|
+
public abstract selection: PluginSelectionApi
|
|
6
|
+
public abstract transform: PluginTransformApi
|
|
7
|
+
|
|
8
|
+
constructor() {}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export * from "./selection"
|
|
12
|
+
export * from "./transform"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ComponentId, PluginApiReturn } from "../../types"
|
|
2
|
+
|
|
3
|
+
export abstract class PluginSelectionApi {
|
|
4
|
+
constructor() {}
|
|
5
|
+
|
|
6
|
+
public abstract get(): PluginApiReturn<PluginSelectionGetResult>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type PluginSelectionGetResult = {
|
|
10
|
+
selected: ComponentId[]
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PluginApiReturn } from "../../types"
|
|
2
|
+
|
|
3
|
+
export abstract class PluginTransformApi {
|
|
4
|
+
constructor() {}
|
|
5
|
+
|
|
6
|
+
public abstract move({
|
|
7
|
+
componentIds,
|
|
8
|
+
displacement,
|
|
9
|
+
}: PluginMoveArgs): PluginApiReturn<void>
|
|
10
|
+
|
|
11
|
+
public abstract rotate({
|
|
12
|
+
componentIds,
|
|
13
|
+
angle,
|
|
14
|
+
axis,
|
|
15
|
+
pivot,
|
|
16
|
+
}: PluginRotateArgs): PluginApiReturn<void>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type PluginMoveArgs = {
|
|
20
|
+
componentIds: string[]
|
|
21
|
+
displacement: [number, number, number]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type PluginRotateArgs = {
|
|
25
|
+
componentIds: string[]
|
|
26
|
+
angle: number
|
|
27
|
+
axis: [number, number, number]
|
|
28
|
+
pivot: [number, number, number]
|
|
29
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { PluginApi } from "./api"
|
|
2
|
+
|
|
3
|
+
// -- Type Utilities for inferring method paths from the class hierarchy ------
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* UnionToIntersection is a type utility that converts a union type to an intersection type.
|
|
7
|
+
*/
|
|
8
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
9
|
+
k: infer I,
|
|
10
|
+
) => void
|
|
11
|
+
? I
|
|
12
|
+
: never
|
|
13
|
+
|
|
14
|
+
type Flatten<T> = { [K in keyof T]: T[K] }
|
|
15
|
+
|
|
16
|
+
type MethodArgs<F extends (...args: any[]) => any> =
|
|
17
|
+
Parameters<F> extends [infer A] ? A : void
|
|
18
|
+
|
|
19
|
+
type MethodReturn<F extends (...args: any[]) => any> = Awaited<ReturnType<F>>
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Recursively walks a type tree and produces a union of single-key Records
|
|
23
|
+
* for every leaf method, using dot-separated paths as keys.
|
|
24
|
+
*/
|
|
25
|
+
type ExtractMethodPaths<T, Prefix extends string = ""> = {
|
|
26
|
+
[K in keyof T & string]: T[K] extends (...args: any[]) => any
|
|
27
|
+
? Record<
|
|
28
|
+
`${Prefix}${K}`,
|
|
29
|
+
{ args: MethodArgs<T[K]>; return: MethodReturn<T[K]> }
|
|
30
|
+
>
|
|
31
|
+
: T[K] extends object
|
|
32
|
+
? ExtractMethodPaths<T[K], `${Prefix}${K}.`>
|
|
33
|
+
: never
|
|
34
|
+
}[keyof T & string]
|
|
35
|
+
|
|
36
|
+
// -- Plugin API method map ---------------------------------------------------
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Maps every plugin API method path to its argument and return types.
|
|
40
|
+
* Automatically inferred from the PluginApi abstract class hierarchy.
|
|
41
|
+
*/
|
|
42
|
+
export type PluginApiMethodMap = Flatten<
|
|
43
|
+
UnionToIntersection<ExtractMethodPaths<PluginApi>>
|
|
44
|
+
>
|
|
45
|
+
|
|
46
|
+
export type PluginApiMethod = keyof PluginApiMethodMap
|
|
47
|
+
|
|
48
|
+
export type PluginApiCallPayload<M extends PluginApiMethod = PluginApiMethod> =
|
|
49
|
+
PluginApiMethodMap[M]["args"] extends void
|
|
50
|
+
? { method: M; args?: void }
|
|
51
|
+
: { method: M; args: PluginApiMethodMap[M]["args"] }
|
|
52
|
+
|
|
53
|
+
export type PluginApiCallResult<M extends PluginApiMethod> =
|
|
54
|
+
PluginApiMethodMap[M]["return"]
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "ES2020",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ES2020"],
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"emitDeclarationOnly": true,
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"declarationMap": true,
|
|
13
|
+
"outDir": "dist",
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*.ts"],
|
|
16
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig } from "tsup"
|
|
2
|
+
|
|
3
|
+
export default defineConfig( (options) => {
|
|
4
|
+
return {
|
|
5
|
+
entry: ["src/index.ts"],
|
|
6
|
+
format: ["cjs", "esm"],
|
|
7
|
+
dts: false,
|
|
8
|
+
sourcemap: true,
|
|
9
|
+
clean: true,
|
|
10
|
+
onSuccess: "tsc", // Run tsc to generate d.ts and d.ts.map
|
|
11
|
+
watch: options.watch,
|
|
12
|
+
}
|
|
13
|
+
})
|