@snaptrude/plugin-client 0.0.5 → 0.0.6

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.
@@ -1,10 +1,10 @@
1
- import { PluginSpaceApi, PluginSpaceCreateRectangularArgs, PluginSpaceCreateRectangularResult, PluginSpaceCreateFromProfileArgs, PluginSpaceCreateFromProfileResult, PluginSpaceDeleteByIdArgs, PluginSpaceDeleteByIdResult, PluginSpaceGetArgs, PluginSpaceGetResult, PluginSpaceGetAllResult } from "@snaptrude/plugin-core";
1
+ import { PluginSpaceApi, PluginSpaceCreateRectangularArgs, PluginSpaceCreateRectangularResult, PluginSpaceCreateFromProfileArgs, PluginSpaceCreateFromProfileResult, PluginSpaceDeleteArgs, PluginSpaceDeleteResult, PluginSpaceGetArgs, PluginSpaceGetResult, PluginSpaceGetAllResult } from "@snaptrude/plugin-core";
2
2
  export declare class ClientSpaceApi extends PluginSpaceApi {
3
3
  constructor();
4
4
  createRectangular({ position, dimensions, }: PluginSpaceCreateRectangularArgs): Promise<PluginSpaceCreateRectangularResult>;
5
5
  createFromProfile({ profile, extrudeHeight, position, }: PluginSpaceCreateFromProfileArgs): Promise<PluginSpaceCreateFromProfileResult>;
6
6
  get({ spaceId, properties, }: PluginSpaceGetArgs): Promise<PluginSpaceGetResult>;
7
7
  getAll(): Promise<PluginSpaceGetAllResult>;
8
- deleteById({ spaceId, }: PluginSpaceDeleteByIdArgs): Promise<PluginSpaceDeleteByIdResult>;
8
+ delete({ spaceId, }: PluginSpaceDeleteArgs): Promise<PluginSpaceDeleteResult>;
9
9
  }
10
10
  //# sourceMappingURL=space.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"space.d.ts","sourceRoot":"","sources":["../../../src/api/entity/space.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,gCAAgC,EAChC,kCAAkC,EAClC,gCAAgC,EAChC,kCAAkC,EAClC,yBAAyB,EACzB,2BAA2B,EAC3B,kBA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C,uBAAuB,CAAC;CAS5D"}
package/dist/index.cjs CHANGED
@@ -233,12 +233,12 @@ var ClientSpaceApi = class extends import_plugin_core10.PluginSpaceApi {
233
233
  method: "entity.space.getAll"
234
234
  });
235
235
  }
236
- async deleteById({
236
+ async delete({
237
237
  spaceId
238
238
  }) {
239
239
  const hostApi = getHostApi();
240
240
  return hostApi.call({
241
- method: "entity.space.deleteById",
241
+ method: "entity.space.delete",
242
242
  args: {
243
243
  spaceId
244
244
  }
@@ -424,6 +424,15 @@ var PluginWorker = class {
424
424
  ;
425
425
  this.hostAPI.ui.sendToUI({ action, payload });
426
426
  }
427
+ /**
428
+ * Signal the host that this plugin has finished its work and should be
429
+ * stopped. Use this in headless (UI-less) plugins that run a task and
430
+ * self-terminate.
431
+ */
432
+ complete() {
433
+ ;
434
+ this.hostAPI.lifecycle.complete();
435
+ }
427
436
  async init() {
428
437
  console.log(this.pluginId, "init() called");
429
438
  console.log(this.pluginId, "Initialization complete");
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/api/core/index.ts","../src/api/core/math/index.ts","../src/api/core/math/vec3.ts","../src/api/core/math/quat.ts","../src/api/core/geom/index.ts","../src/api/core/geom/line.ts","../src/api/core/geom/arc.ts","../src/api/core/geom/curve.ts","../src/api/core/geom/profile.ts","../src/host-api.ts","../src/api/entity/index.ts","../src/api/entity/space.ts","../src/api/entity/story.ts","../src/api/tools/index.ts","../src/api/tools/selection.ts","../src/api/tools/transform.ts","../src/api/units/index.ts","../src/api/index.ts","../src/plugin-worker.ts"],"sourcesContent":["import { ClientPluginApi } from \"./api\"\n\nexport * from \"./api\"\nexport * from \"./host-api\"\nexport * from \"./plugin-worker\"\n\n/**\n * The Snaptrude plugin client API.\n *\n * The main entry point for plugins to interact with the Snaptrude platform.\n */\nexport const snaptrude = ClientPluginApi.getInstance()\n","import { PluginCoreApi } from \"@snaptrude/plugin-core\"\nimport { ClientMathApi } from \"./math\"\nimport { ClientGeomApi } from \"./geom\"\n\nexport class ClientCoreApi extends PluginCoreApi {\n public math: ClientMathApi\n public geom: ClientGeomApi\n\n constructor() {\n super()\n this.math = new ClientMathApi()\n this.geom = new ClientGeomApi()\n }\n}\n\nexport * from \"./math\"\nexport * from \"./geom\"\n","import { PluginMathApi } from \"@snaptrude/plugin-core\"\nimport { ClientVec3Api } from \"./vec3\"\nimport { ClientQuatApi } from \"./quat\"\n\nexport class ClientMathApi extends PluginMathApi {\n public vec3: ClientVec3Api\n public quat: ClientQuatApi\n\n constructor() {\n super()\n this.vec3 = new ClientVec3Api()\n this.quat = new ClientQuatApi()\n }\n}\n\nexport * from \"./vec3\"\nexport * from \"./quat\"\n","import { PluginVec3Api } from \"@snaptrude/plugin-core\"\n\nexport class ClientVec3Api extends PluginVec3Api {\n constructor() {\n super()\n }\n}\n","import { PluginQuatApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientQuatApi extends PluginQuatApi {\n constructor() {\n super()\n }\n}\n","import { PluginGeomApi } from \"@snaptrude/plugin-core\"\nimport { ClientLineApi } from \"./line\"\nimport { ClientArcApi } from \"./arc\"\nimport { ClientCurveApi } from \"./curve\"\nimport { ClientProfileApi } from \"./profile\"\n\nexport class ClientGeomApi extends PluginGeomApi {\n public line: ClientLineApi\n public arc: ClientArcApi\n public curve: ClientCurveApi\n public profile: ClientProfileApi\n\n constructor() {\n super()\n this.line = new ClientLineApi()\n this.arc = new ClientArcApi()\n this.curve = new ClientCurveApi()\n this.profile = new ClientProfileApi()\n }\n}\n\nexport * from \"./line\"\nexport * from \"./arc\"\nexport * from \"./curve\"\nexport * from \"./profile\"\n","import { PluginLineApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientLineApi extends PluginLineApi {\n constructor() {\n super()\n }\n}\n","import { PluginArcApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientArcApi extends PluginArcApi {\n constructor() {\n super()\n }\n}\n","import { PluginCurveApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientCurveApi extends PluginCurveApi {\n constructor() {\n super()\n }\n}\n","import { PluginProfileApi } from \"@snaptrude/plugin-core\"\nimport type { PProfile, PluginProfileFromLinePointsArgs } from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../../host-api\"\n\nexport class ClientProfileApi extends PluginProfileApi {\n constructor() {\n super()\n }\n\n public async fromLinePoints(args: PluginProfileFromLinePointsArgs): Promise<PProfile> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"core.geom.profile.fromLinePoints\",\n args,\n })\n }\n}\n","import * as Comlink from \"comlink\"\nimport type {\n PluginApiMethod,\n PluginApiCallPayload,\n PluginApiCallWrappedResult,\n PluginApiCallResult,\n} from \"@snaptrude/plugin-core\"\n\nexport interface HostApi {\n call<M extends PluginApiMethod>(\n payload: PluginApiCallPayload<M>\n ): Promise<PluginApiCallWrappedResult<M>>\n}\n\nexport interface HostApiWrapped {\n call<M extends PluginApiMethod>(\n payload: PluginApiCallPayload<M>\n ): Promise<PluginApiCallResult<M>>\n}\n\nexport function createHostApi(endpoint?: Comlink.Endpoint): HostApi {\n return Comlink.wrap<HostApi>(\n endpoint ?? (globalThis as unknown as Comlink.Endpoint)\n ) as unknown as HostApi\n}\n\nlet _instance: HostApi | null = null\n\nexport function getHostApi(): HostApiWrapped {\n if (!_instance) {\n _instance = createHostApi()\n }\n return {\n call: async <M extends PluginApiMethod>(payload: PluginApiCallPayload<M>): Promise<PluginApiCallResult<M>> => {\n if (!_instance) {\n throw new Error(\"Host API not initialized\")\n }\n return _instance.call(payload).then(result => {\n if (result.success) {\n return result.data\n } else {\n throw new Error(result.error)\n }\n })\n }\n }\n}\n","import { PluginEntityApi } from \"@snaptrude/plugin-core\"\nimport { ClientSpaceApi } from \"./space\"\nimport { ClientStoryApi } from \"./story\"\n\nexport class ClientEntityApi extends PluginEntityApi {\n public space: ClientSpaceApi\n public story: ClientStoryApi\n\n constructor() {\n super()\n this.space = new ClientSpaceApi()\n this.story = new ClientStoryApi()\n }\n}\n\nexport * from \"./space\"\nexport * from \"./story\"\n","import {\n PluginSpaceApi,\n PluginSpaceCreateRectangularArgs,\n PluginSpaceCreateRectangularResult,\n PluginSpaceCreateFromProfileArgs,\n PluginSpaceCreateFromProfileResult,\n PluginSpaceDeleteByIdArgs,\n PluginSpaceDeleteByIdResult,\n PluginSpaceGetArgs,\n PluginSpaceGetResult,\n PluginSpaceGetAllResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientSpaceApi extends PluginSpaceApi {\n constructor() {\n super()\n }\n\n public async createRectangular({\n position,\n dimensions,\n }: PluginSpaceCreateRectangularArgs): Promise<PluginSpaceCreateRectangularResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.createRectangular\",\n args: {\n position,\n dimensions,\n },\n })\n }\n\n public async createFromProfile({\n profile,\n extrudeHeight,\n position,\n }: PluginSpaceCreateFromProfileArgs): Promise<PluginSpaceCreateFromProfileResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.createFromProfile\",\n args: {\n profile,\n extrudeHeight,\n position,\n },\n })\n }\n\n public async get({\n spaceId,\n properties,\n }: PluginSpaceGetArgs): Promise<PluginSpaceGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.get\",\n args: {\n spaceId,\n properties,\n },\n })\n }\n\n public async getAll(): Promise<PluginSpaceGetAllResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.getAll\",\n })\n }\n\n public async deleteById({\n spaceId,\n }: PluginSpaceDeleteByIdArgs): Promise<PluginSpaceDeleteByIdResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.deleteById\",\n args: {\n spaceId,\n },\n })\n }\n}\n","import {\n PluginStoryApi,\n PluginStoryGetArgs,\n PluginStoryGetResult,\n PluginStoryGetAllResult,\n PluginStoryCreateArgs,\n PluginStoryCreateResult,\n PluginStoryUpdateArgs,\n PluginStoryUpdateResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientStoryApi extends PluginStoryApi {\n constructor() {\n super()\n }\n\n public async get({\n storyValue,\n properties,\n }: PluginStoryGetArgs): Promise<PluginStoryGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.get\",\n args: {\n storyValue,\n properties,\n },\n })\n }\n\n public async getAll(): Promise<PluginStoryGetAllResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.getAll\",\n })\n }\n\n public async create({\n storyValue,\n height,\n }: PluginStoryCreateArgs): Promise<PluginStoryCreateResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.create\",\n args: {\n storyValue,\n height,\n },\n })\n }\n\n public async update({\n storyValue,\n height,\n }: PluginStoryUpdateArgs): Promise<PluginStoryUpdateResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.update\",\n args: {\n storyValue,\n height,\n },\n })\n }\n}\n","import { PluginToolsApi } from \"@snaptrude/plugin-core\"\nimport { ClientSelectionApi } from \"./selection\"\nimport { ClientTransformApi } from \"./transform\"\n\nexport class ClientToolsApi extends PluginToolsApi {\n public selection: ClientSelectionApi\n public transform: ClientTransformApi\n\n constructor() {\n super()\n this.selection = new ClientSelectionApi()\n this.transform = new ClientTransformApi()\n }\n}\n\nexport * from \"./selection\"\nexport * from \"./transform\"\n","import { PluginSelectionApi, PluginSelectionGetResult } from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientSelectionApi extends PluginSelectionApi {\n constructor() {\n super()\n }\n\n public async get(): Promise<PluginSelectionGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.selection.get\",\n })\n }\n}\n","import {\n PluginTransformApi,\n PluginMoveArgs,\n PluginRotateArgs,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientTransformApi extends PluginTransformApi {\n constructor() {\n super()\n }\n\n public async move({\n componentIds,\n displacement,\n }: PluginMoveArgs): Promise<void> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.transform.move\",\n args: {\n componentIds,\n displacement,\n },\n })\n }\n\n public async rotate({\n componentIds,\n angle,\n axis,\n pivot,\n }: PluginRotateArgs): Promise<void> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.transform.rotate\",\n args: {\n componentIds,\n angle,\n axis,\n pivot,\n },\n })\n }\n}\n","import {\n PluginUnitsApi,\n PluginUnitsConvertFromArgs,\n PluginUnitsConvertFromResult,\n PluginUnitsConvertToArgs,\n PluginUnitsConvertToResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientUnitsApi extends PluginUnitsApi {\n constructor() {\n super()\n }\n\n public async convertFrom(\n args: PluginUnitsConvertFromArgs,\n ): Promise<PluginUnitsConvertFromResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"units.convertFrom\",\n args,\n })\n }\n\n public async convertTo(\n args: PluginUnitsConvertToArgs,\n ): Promise<PluginUnitsConvertToResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"units.convertTo\",\n args,\n })\n }\n}\n","import { ClientCoreApi } from \"./core\"\nimport { ClientEntityApi } from \"./entity\"\nimport { ClientToolsApi } from \"./tools\"\nimport { ClientUnitsApi } from \"./units\"\nimport { PluginApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientPluginApi extends PluginApi {\n private static instance: ClientPluginApi\n\n public core: ClientCoreApi\n public tools: ClientToolsApi\n public entity: ClientEntityApi\n public units: ClientUnitsApi\n\n private constructor() {\n super()\n this.core = new ClientCoreApi()\n this.tools = new ClientToolsApi()\n this.entity = new ClientEntityApi()\n this.units = new ClientUnitsApi()\n }\n\n static getInstance(): ClientPluginApi {\n if (!ClientPluginApi.instance) {\n ClientPluginApi.instance = new ClientPluginApi()\n }\n return ClientPluginApi.instance\n }\n}\n\nexport * from \"./core\"\nexport * from \"./entity\"\nexport * from \"./tools\"\nexport * from \"./units\"\n","import * as Comlink from \"comlink\"\n\nexport interface UIMessage {\n action: string\n payload: unknown\n}\n\ninterface PluginConfig {\n pluginId: string\n permissions: string[]\n}\n\n/**\n * Base class for Snaptrude plugin workers.\n *\n * Handles Comlink wiring, host communication, and the standard lifecycle\n * methods (`init`, `destroy`, `ping`, `onUIMessage`). Subclass this and\n * override only the methods you need — then call `start()` to expose the\n * worker API.\n *\n * The plugin ID is received automatically from the host during\n * initialization — no need to pass it manually.\n *\n * @example\n * ```ts\n * import { PluginWorker } from \"@snaptrude/plugin-client\";\n *\n * class MyPlugin extends PluginWorker {\n * async onUIMessage(message: UIMessage) {\n * // handle messages from the UI panel\n * }\n * }\n *\n * new MyPlugin().start();\n * ```\n */\nexport abstract class PluginWorker {\n protected pluginId!: string\n private hostAPI: Comlink.Remote<Record<string, unknown>>\n\n constructor() {\n this.hostAPI = Comlink.wrap<Record<string, unknown>>(\n self as unknown as Comlink.Endpoint\n )\n }\n\n protected sendToUI(action: string, payload: unknown): void {\n ;(this.hostAPI as Record<string, any>).ui.sendToUI({ action, payload })\n }\n\n async init(): Promise<void> {\n console.log(this.pluginId, \"init() called\")\n console.log(this.pluginId, \"Initialization complete\")\n }\n\n async destroy(): Promise<void> {\n console.log(this.pluginId, \"destroy() called — cleaning up\")\n }\n\n async ping(): Promise<string> {\n return \"pong\"\n }\n\n async onUIMessage(_message: UIMessage): Promise<void> {\n // Override in subclass to handle UI messages\n }\n\n /**\n * Expose the worker API via Comlink and start listening.\n * Call this once after constructing the plugin instance.\n *\n * The host calls `init(config)` with `{ pluginId, permissions }`,\n * which is captured here to set `this.pluginId` before the\n * subclass's `init()` runs.\n */\n start(): void {\n Comlink.expose(\n {\n init: (config: PluginConfig) => {\n this.pluginId = config.pluginId\n return this.init()\n },\n destroy: () => this.destroy(),\n ping: () => this.ping(),\n onUIMessage: (message: UIMessage) => this.onUIMessage(message),\n },\n self as unknown as Comlink.Endpoint\n )\n console.log(\"Worker loaded, API exposed via Comlink\")\n }\n}\n"],"mappings":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KAAK,UAAU,eAAe;AAC1C,YAAQ,IAAI,KAAK,UAAU,yBAAyB;AAAA,EACtD;AAAA,EAEA,MAAM,UAAyB;AAC7B,YAAQ,IAAI,KAAK,UAAU,qCAAgC;AAAA,EAC7D;AAAA,EAEA,MAAM,OAAwB;AAC5B,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,YAAY,UAAoC;AAAA,EAEtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,QAAc;AACZ,IAAQ;AAAA,MACN;AAAA,QACE,MAAM,CAAC,WAAyB;AAC9B,eAAK,WAAW,OAAO;AACvB,iBAAO,KAAK,KAAK;AAAA,QACnB;AAAA,QACA,SAAS,MAAM,KAAK,QAAQ;AAAA,QAC5B,MAAM,MAAM,KAAK,KAAK;AAAA,QACtB,aAAa,CAAC,YAAuB,KAAK,YAAY,OAAO;AAAA,MAC/D;AAAA,MACA;AAAA,IACF;AACA,YAAQ,IAAI,wCAAwC;AAAA,EACtD;AACF;;;AnB/EO,IAAM,YAAY,gBAAgB,YAAY;","names":["import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","Comlink"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/api/core/index.ts","../src/api/core/math/index.ts","../src/api/core/math/vec3.ts","../src/api/core/math/quat.ts","../src/api/core/geom/index.ts","../src/api/core/geom/line.ts","../src/api/core/geom/arc.ts","../src/api/core/geom/curve.ts","../src/api/core/geom/profile.ts","../src/host-api.ts","../src/api/entity/index.ts","../src/api/entity/space.ts","../src/api/entity/story.ts","../src/api/tools/index.ts","../src/api/tools/selection.ts","../src/api/tools/transform.ts","../src/api/units/index.ts","../src/api/index.ts","../src/plugin-worker.ts"],"sourcesContent":["import { ClientPluginApi } from \"./api\"\n\nexport * from \"./api\"\nexport * from \"./host-api\"\nexport * from \"./plugin-worker\"\n\n/**\n * The Snaptrude plugin client API.\n *\n * The main entry point for plugins to interact with the Snaptrude platform.\n */\nexport const snaptrude = ClientPluginApi.getInstance()\n","import { PluginCoreApi } from \"@snaptrude/plugin-core\"\nimport { ClientMathApi } from \"./math\"\nimport { ClientGeomApi } from \"./geom\"\n\nexport class ClientCoreApi extends PluginCoreApi {\n public math: ClientMathApi\n public geom: ClientGeomApi\n\n constructor() {\n super()\n this.math = new ClientMathApi()\n this.geom = new ClientGeomApi()\n }\n}\n\nexport * from \"./math\"\nexport * from \"./geom\"\n","import { PluginMathApi } from \"@snaptrude/plugin-core\"\nimport { ClientVec3Api } from \"./vec3\"\nimport { ClientQuatApi } from \"./quat\"\n\nexport class ClientMathApi extends PluginMathApi {\n public vec3: ClientVec3Api\n public quat: ClientQuatApi\n\n constructor() {\n super()\n this.vec3 = new ClientVec3Api()\n this.quat = new ClientQuatApi()\n }\n}\n\nexport * from \"./vec3\"\nexport * from \"./quat\"\n","import { PluginVec3Api } from \"@snaptrude/plugin-core\"\n\nexport class ClientVec3Api extends PluginVec3Api {\n constructor() {\n super()\n }\n}\n","import { PluginQuatApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientQuatApi extends PluginQuatApi {\n constructor() {\n super()\n }\n}\n","import { PluginGeomApi } from \"@snaptrude/plugin-core\"\nimport { ClientLineApi } from \"./line\"\nimport { ClientArcApi } from \"./arc\"\nimport { ClientCurveApi } from \"./curve\"\nimport { ClientProfileApi } from \"./profile\"\n\nexport class ClientGeomApi extends PluginGeomApi {\n public line: ClientLineApi\n public arc: ClientArcApi\n public curve: ClientCurveApi\n public profile: ClientProfileApi\n\n constructor() {\n super()\n this.line = new ClientLineApi()\n this.arc = new ClientArcApi()\n this.curve = new ClientCurveApi()\n this.profile = new ClientProfileApi()\n }\n}\n\nexport * from \"./line\"\nexport * from \"./arc\"\nexport * from \"./curve\"\nexport * from \"./profile\"\n","import { PluginLineApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientLineApi extends PluginLineApi {\n constructor() {\n super()\n }\n}\n","import { PluginArcApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientArcApi extends PluginArcApi {\n constructor() {\n super()\n }\n}\n","import { PluginCurveApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientCurveApi extends PluginCurveApi {\n constructor() {\n super()\n }\n}\n","import { PluginProfileApi } from \"@snaptrude/plugin-core\"\nimport type { PProfile, PluginProfileFromLinePointsArgs } from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../../host-api\"\n\nexport class ClientProfileApi extends PluginProfileApi {\n constructor() {\n super()\n }\n\n public async fromLinePoints(args: PluginProfileFromLinePointsArgs): Promise<PProfile> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"core.geom.profile.fromLinePoints\",\n args,\n })\n }\n}\n","import * as Comlink from \"comlink\"\nimport type {\n PluginApiMethod,\n PluginApiCallPayload,\n PluginApiCallWrappedResult,\n PluginApiCallResult,\n} from \"@snaptrude/plugin-core\"\n\nexport interface HostApi {\n call<M extends PluginApiMethod>(\n payload: PluginApiCallPayload<M>\n ): Promise<PluginApiCallWrappedResult<M>>\n}\n\nexport interface HostApiWrapped {\n call<M extends PluginApiMethod>(\n payload: PluginApiCallPayload<M>\n ): Promise<PluginApiCallResult<M>>\n}\n\nexport function createHostApi(endpoint?: Comlink.Endpoint): HostApi {\n return Comlink.wrap<HostApi>(\n endpoint ?? (globalThis as unknown as Comlink.Endpoint)\n ) as unknown as HostApi\n}\n\nlet _instance: HostApi | null = null\n\nexport function getHostApi(): HostApiWrapped {\n if (!_instance) {\n _instance = createHostApi()\n }\n return {\n call: async <M extends PluginApiMethod>(payload: PluginApiCallPayload<M>): Promise<PluginApiCallResult<M>> => {\n if (!_instance) {\n throw new Error(\"Host API not initialized\")\n }\n return _instance.call(payload).then(result => {\n if (result.success) {\n return result.data\n } else {\n throw new Error(result.error)\n }\n })\n }\n }\n}\n","import { PluginEntityApi } from \"@snaptrude/plugin-core\"\nimport { ClientSpaceApi } from \"./space\"\nimport { ClientStoryApi } from \"./story\"\n\nexport class ClientEntityApi extends PluginEntityApi {\n public space: ClientSpaceApi\n public story: ClientStoryApi\n\n constructor() {\n super()\n this.space = new ClientSpaceApi()\n this.story = new ClientStoryApi()\n }\n}\n\nexport * from \"./space\"\nexport * from \"./story\"\n","import {\n PluginSpaceApi,\n PluginSpaceCreateRectangularArgs,\n PluginSpaceCreateRectangularResult,\n PluginSpaceCreateFromProfileArgs,\n PluginSpaceCreateFromProfileResult,\n PluginSpaceDeleteArgs,\n PluginSpaceDeleteResult,\n PluginSpaceGetArgs,\n PluginSpaceGetResult,\n PluginSpaceGetAllResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientSpaceApi extends PluginSpaceApi {\n constructor() {\n super()\n }\n\n public async createRectangular({\n position,\n dimensions,\n }: PluginSpaceCreateRectangularArgs): Promise<PluginSpaceCreateRectangularResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.createRectangular\",\n args: {\n position,\n dimensions,\n },\n })\n }\n\n public async createFromProfile({\n profile,\n extrudeHeight,\n position,\n }: PluginSpaceCreateFromProfileArgs): Promise<PluginSpaceCreateFromProfileResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.createFromProfile\",\n args: {\n profile,\n extrudeHeight,\n position,\n },\n })\n }\n\n public async get({\n spaceId,\n properties,\n }: PluginSpaceGetArgs): Promise<PluginSpaceGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.get\",\n args: {\n spaceId,\n properties,\n },\n })\n }\n\n public async getAll(): Promise<PluginSpaceGetAllResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.getAll\",\n })\n }\n\n public async delete({\n spaceId,\n }: PluginSpaceDeleteArgs): Promise<PluginSpaceDeleteResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.delete\",\n args: {\n spaceId,\n },\n })\n }\n}\n","import {\n PluginStoryApi,\n PluginStoryGetArgs,\n PluginStoryGetResult,\n PluginStoryGetAllResult,\n PluginStoryCreateArgs,\n PluginStoryCreateResult,\n PluginStoryUpdateArgs,\n PluginStoryUpdateResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientStoryApi extends PluginStoryApi {\n constructor() {\n super()\n }\n\n public async get({\n storyValue,\n properties,\n }: PluginStoryGetArgs): Promise<PluginStoryGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.get\",\n args: {\n storyValue,\n properties,\n },\n })\n }\n\n public async getAll(): Promise<PluginStoryGetAllResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.getAll\",\n })\n }\n\n public async create({\n storyValue,\n height,\n }: PluginStoryCreateArgs): Promise<PluginStoryCreateResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.create\",\n args: {\n storyValue,\n height,\n },\n })\n }\n\n public async update({\n storyValue,\n height,\n }: PluginStoryUpdateArgs): Promise<PluginStoryUpdateResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.update\",\n args: {\n storyValue,\n height,\n },\n })\n }\n}\n","import { PluginToolsApi } from \"@snaptrude/plugin-core\"\nimport { ClientSelectionApi } from \"./selection\"\nimport { ClientTransformApi } from \"./transform\"\n\nexport class ClientToolsApi extends PluginToolsApi {\n public selection: ClientSelectionApi\n public transform: ClientTransformApi\n\n constructor() {\n super()\n this.selection = new ClientSelectionApi()\n this.transform = new ClientTransformApi()\n }\n}\n\nexport * from \"./selection\"\nexport * from \"./transform\"\n","import { PluginSelectionApi, PluginSelectionGetResult } from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientSelectionApi extends PluginSelectionApi {\n constructor() {\n super()\n }\n\n public async get(): Promise<PluginSelectionGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.selection.get\",\n })\n }\n}\n","import {\n PluginTransformApi,\n PluginMoveArgs,\n PluginRotateArgs,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientTransformApi extends PluginTransformApi {\n constructor() {\n super()\n }\n\n public async move({\n componentIds,\n displacement,\n }: PluginMoveArgs): Promise<void> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.transform.move\",\n args: {\n componentIds,\n displacement,\n },\n })\n }\n\n public async rotate({\n componentIds,\n angle,\n axis,\n pivot,\n }: PluginRotateArgs): Promise<void> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.transform.rotate\",\n args: {\n componentIds,\n angle,\n axis,\n pivot,\n },\n })\n }\n}\n","import {\n PluginUnitsApi,\n PluginUnitsConvertFromArgs,\n PluginUnitsConvertFromResult,\n PluginUnitsConvertToArgs,\n PluginUnitsConvertToResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientUnitsApi extends PluginUnitsApi {\n constructor() {\n super()\n }\n\n public async convertFrom(\n args: PluginUnitsConvertFromArgs,\n ): Promise<PluginUnitsConvertFromResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"units.convertFrom\",\n args,\n })\n }\n\n public async convertTo(\n args: PluginUnitsConvertToArgs,\n ): Promise<PluginUnitsConvertToResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"units.convertTo\",\n args,\n })\n }\n}\n","import { ClientCoreApi } from \"./core\"\nimport { ClientEntityApi } from \"./entity\"\nimport { ClientToolsApi } from \"./tools\"\nimport { ClientUnitsApi } from \"./units\"\nimport { PluginApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientPluginApi extends PluginApi {\n private static instance: ClientPluginApi\n\n public core: ClientCoreApi\n public tools: ClientToolsApi\n public entity: ClientEntityApi\n public units: ClientUnitsApi\n\n private constructor() {\n super()\n this.core = new ClientCoreApi()\n this.tools = new ClientToolsApi()\n this.entity = new ClientEntityApi()\n this.units = new ClientUnitsApi()\n }\n\n static getInstance(): ClientPluginApi {\n if (!ClientPluginApi.instance) {\n ClientPluginApi.instance = new ClientPluginApi()\n }\n return ClientPluginApi.instance\n }\n}\n\nexport * from \"./core\"\nexport * from \"./entity\"\nexport * from \"./tools\"\nexport * from \"./units\"\n","import * as Comlink from \"comlink\"\n\nexport interface UIMessage {\n action: string\n payload: unknown\n}\n\ninterface PluginConfig {\n pluginId: string\n permissions: string[]\n}\n\n/**\n * Base class for Snaptrude plugin workers.\n *\n * Handles Comlink wiring, host communication, and the standard lifecycle\n * methods (`init`, `destroy`, `ping`, `onUIMessage`). Subclass this and\n * override only the methods you need — then call `start()` to expose the\n * worker API.\n *\n * The plugin ID is received automatically from the host during\n * initialization — no need to pass it manually.\n *\n * @example\n * ```ts\n * import { PluginWorker } from \"@snaptrude/plugin-client\";\n *\n * class MyPlugin extends PluginWorker {\n * async onUIMessage(message: UIMessage) {\n * // handle messages from the UI panel\n * }\n * }\n *\n * new MyPlugin().start();\n * ```\n */\nexport abstract class PluginWorker {\n protected pluginId!: string\n private hostAPI: Comlink.Remote<Record<string, unknown>>\n\n constructor() {\n this.hostAPI = Comlink.wrap<Record<string, unknown>>(\n self as unknown as Comlink.Endpoint\n )\n }\n\n protected sendToUI(action: string, payload: unknown): void {\n ;(this.hostAPI as Record<string, any>).ui.sendToUI({ action, payload })\n }\n\n /**\n * Signal the host that this plugin has finished its work and should be\n * stopped. Use this in headless (UI-less) plugins that run a task and\n * self-terminate.\n */\n protected complete(): void {\n ;(this.hostAPI as Record<string, any>).lifecycle.complete()\n }\n\n async init(): Promise<void> {\n console.log(this.pluginId, \"init() called\")\n console.log(this.pluginId, \"Initialization complete\")\n }\n\n async destroy(): Promise<void> {\n console.log(this.pluginId, \"destroy() called — cleaning up\")\n }\n\n async ping(): Promise<string> {\n return \"pong\"\n }\n\n async onUIMessage(_message: UIMessage): Promise<void> {\n // Override in subclass to handle UI messages\n }\n\n /**\n * Expose the worker API via Comlink and start listening.\n * Call this once after constructing the plugin instance.\n *\n * The host calls `init(config)` with `{ pluginId, permissions }`,\n * which is captured here to set `this.pluginId` before the\n * subclass's `init()` runs.\n */\n start(): void {\n Comlink.expose(\n {\n init: (config: PluginConfig) => {\n this.pluginId = config.pluginId\n return this.init()\n },\n destroy: () => this.destroy(),\n ping: () => this.ping(),\n onUIMessage: (message: UIMessage) => this.onUIMessage(message),\n },\n self as unknown as Comlink.Endpoint\n )\n console.log(\"Worker loaded, API exposed via Comlink\")\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,sBAA8B;;;ACA9B,IAAAC,sBAA8B;;;ACA9B,yBAA8B;AAEvB,IAAM,gBAAN,cAA4B,iCAAc;AAAA,EAC/C,cAAc;AACZ,UAAM;AAAA,EACR;AACF;;;ACNA,IAAAC,sBAA8B;AAEvB,IAAM,gBAAN,cAA4B,kCAAc;AAAA,EAC/C,cAAc;AACZ,UAAM;AAAA,EACR;AACF;;;AFFO,IAAM,gBAAN,cAA4B,kCAAc;AAAA,EAI/C,cAAc;AACZ,UAAM;AACN,SAAK,OAAO,IAAI,cAAc;AAC9B,SAAK,OAAO,IAAI,cAAc;AAAA,EAChC;AACF;;;AGbA,IAAAC,sBAA8B;;;ACA9B,IAAAC,sBAA8B;AAEvB,IAAM,gBAAN,cAA4B,kCAAc;AAAA,EAC/C,cAAc;AACZ,UAAM;AAAA,EACR;AACF;;;ACNA,IAAAC,sBAA6B;AAEtB,IAAM,eAAN,cAA2B,iCAAa;AAAA,EAC7C,cAAc;AACZ,UAAM;AAAA,EACR;AACF;;;ACNA,IAAAC,sBAA+B;AAExB,IAAM,iBAAN,cAA6B,mCAAe;AAAA,EACjD,cAAc;AACZ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;AAAA,IACjD;AACA,WAAO,iBAAgB;AAAA,EACzB;AACF;;;AC5BA,IAAAC,WAAyB;AAoClB,IAAe,eAAf,MAA4B;AAAA,EAIjC,cAAc;AACZ,SAAK,UAAkB;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAAA,EAEU,SAAS,QAAgB,SAAwB;AACzD;AAAC,IAAC,KAAK,QAAgC,GAAG,SAAS,EAAE,QAAQ,QAAQ,CAAC;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,WAAiB;AACzB;AAAC,IAAC,KAAK,QAAgC,UAAU,SAAS;AAAA,EAC5D;AAAA,EAEA,MAAM,OAAsB;AAC1B,YAAQ,IAAI,KAAK,UAAU,eAAe;AAC1C,YAAQ,IAAI,KAAK,UAAU,yBAAyB;AAAA,EACtD;AAAA,EAEA,MAAM,UAAyB;AAC7B,YAAQ,IAAI,KAAK,UAAU,qCAAgC;AAAA,EAC7D;AAAA,EAEA,MAAM,OAAwB;AAC5B,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,YAAY,UAAoC;AAAA,EAEtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,QAAc;AACZ,IAAQ;AAAA,MACN;AAAA,QACE,MAAM,CAAC,WAAyB;AAC9B,eAAK,WAAW,OAAO;AACvB,iBAAO,KAAK,KAAK;AAAA,QACnB;AAAA,QACA,SAAS,MAAM,KAAK,QAAQ;AAAA,QAC5B,MAAM,MAAM,KAAK,KAAK;AAAA,QACtB,aAAa,CAAC,YAAuB,KAAK,YAAY,OAAO;AAAA,MAC/D;AAAA,MACA;AAAA,IACF;AACA,YAAQ,IAAI,wCAAwC;AAAA,EACtD;AACF;;;AnBxFO,IAAM,YAAY,gBAAgB,YAAY;","names":["import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","import_plugin_core","Comlink"]}
package/dist/index.js CHANGED
@@ -179,12 +179,12 @@ var ClientSpaceApi = class extends PluginSpaceApi {
179
179
  method: "entity.space.getAll"
180
180
  });
181
181
  }
182
- async deleteById({
182
+ async delete({
183
183
  spaceId
184
184
  }) {
185
185
  const hostApi = getHostApi();
186
186
  return hostApi.call({
187
- method: "entity.space.deleteById",
187
+ method: "entity.space.delete",
188
188
  args: {
189
189
  spaceId
190
190
  }
@@ -376,6 +376,15 @@ var PluginWorker = class {
376
376
  ;
377
377
  this.hostAPI.ui.sendToUI({ action, payload });
378
378
  }
379
+ /**
380
+ * Signal the host that this plugin has finished its work and should be
381
+ * stopped. Use this in headless (UI-less) plugins that run a task and
382
+ * self-terminate.
383
+ */
384
+ complete() {
385
+ ;
386
+ this.hostAPI.lifecycle.complete();
387
+ }
379
388
  async init() {
380
389
  console.log(this.pluginId, "init() called");
381
390
  console.log(this.pluginId, "Initialization complete");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/api/core/index.ts","../src/api/core/math/index.ts","../src/api/core/math/vec3.ts","../src/api/core/math/quat.ts","../src/api/core/geom/index.ts","../src/api/core/geom/line.ts","../src/api/core/geom/arc.ts","../src/api/core/geom/curve.ts","../src/api/core/geom/profile.ts","../src/host-api.ts","../src/api/entity/index.ts","../src/api/entity/space.ts","../src/api/entity/story.ts","../src/api/tools/index.ts","../src/api/tools/selection.ts","../src/api/tools/transform.ts","../src/api/units/index.ts","../src/api/index.ts","../src/plugin-worker.ts","../src/index.ts"],"sourcesContent":["import { PluginCoreApi } from \"@snaptrude/plugin-core\"\nimport { ClientMathApi } from \"./math\"\nimport { ClientGeomApi } from \"./geom\"\n\nexport class ClientCoreApi extends PluginCoreApi {\n public math: ClientMathApi\n public geom: ClientGeomApi\n\n constructor() {\n super()\n this.math = new ClientMathApi()\n this.geom = new ClientGeomApi()\n }\n}\n\nexport * from \"./math\"\nexport * from \"./geom\"\n","import { PluginMathApi } from \"@snaptrude/plugin-core\"\nimport { ClientVec3Api } from \"./vec3\"\nimport { ClientQuatApi } from \"./quat\"\n\nexport class ClientMathApi extends PluginMathApi {\n public vec3: ClientVec3Api\n public quat: ClientQuatApi\n\n constructor() {\n super()\n this.vec3 = new ClientVec3Api()\n this.quat = new ClientQuatApi()\n }\n}\n\nexport * from \"./vec3\"\nexport * from \"./quat\"\n","import { PluginVec3Api } from \"@snaptrude/plugin-core\"\n\nexport class ClientVec3Api extends PluginVec3Api {\n constructor() {\n super()\n }\n}\n","import { PluginQuatApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientQuatApi extends PluginQuatApi {\n constructor() {\n super()\n }\n}\n","import { PluginGeomApi } from \"@snaptrude/plugin-core\"\nimport { ClientLineApi } from \"./line\"\nimport { ClientArcApi } from \"./arc\"\nimport { ClientCurveApi } from \"./curve\"\nimport { ClientProfileApi } from \"./profile\"\n\nexport class ClientGeomApi extends PluginGeomApi {\n public line: ClientLineApi\n public arc: ClientArcApi\n public curve: ClientCurveApi\n public profile: ClientProfileApi\n\n constructor() {\n super()\n this.line = new ClientLineApi()\n this.arc = new ClientArcApi()\n this.curve = new ClientCurveApi()\n this.profile = new ClientProfileApi()\n }\n}\n\nexport * from \"./line\"\nexport * from \"./arc\"\nexport * from \"./curve\"\nexport * from \"./profile\"\n","import { PluginLineApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientLineApi extends PluginLineApi {\n constructor() {\n super()\n }\n}\n","import { PluginArcApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientArcApi extends PluginArcApi {\n constructor() {\n super()\n }\n}\n","import { PluginCurveApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientCurveApi extends PluginCurveApi {\n constructor() {\n super()\n }\n}\n","import { PluginProfileApi } from \"@snaptrude/plugin-core\"\nimport type { PProfile, PluginProfileFromLinePointsArgs } from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../../host-api\"\n\nexport class ClientProfileApi extends PluginProfileApi {\n constructor() {\n super()\n }\n\n public async fromLinePoints(args: PluginProfileFromLinePointsArgs): Promise<PProfile> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"core.geom.profile.fromLinePoints\",\n args,\n })\n }\n}\n","import * as Comlink from \"comlink\"\nimport type {\n PluginApiMethod,\n PluginApiCallPayload,\n PluginApiCallWrappedResult,\n PluginApiCallResult,\n} from \"@snaptrude/plugin-core\"\n\nexport interface HostApi {\n call<M extends PluginApiMethod>(\n payload: PluginApiCallPayload<M>\n ): Promise<PluginApiCallWrappedResult<M>>\n}\n\nexport interface HostApiWrapped {\n call<M extends PluginApiMethod>(\n payload: PluginApiCallPayload<M>\n ): Promise<PluginApiCallResult<M>>\n}\n\nexport function createHostApi(endpoint?: Comlink.Endpoint): HostApi {\n return Comlink.wrap<HostApi>(\n endpoint ?? (globalThis as unknown as Comlink.Endpoint)\n ) as unknown as HostApi\n}\n\nlet _instance: HostApi | null = null\n\nexport function getHostApi(): HostApiWrapped {\n if (!_instance) {\n _instance = createHostApi()\n }\n return {\n call: async <M extends PluginApiMethod>(payload: PluginApiCallPayload<M>): Promise<PluginApiCallResult<M>> => {\n if (!_instance) {\n throw new Error(\"Host API not initialized\")\n }\n return _instance.call(payload).then(result => {\n if (result.success) {\n return result.data\n } else {\n throw new Error(result.error)\n }\n })\n }\n }\n}\n","import { PluginEntityApi } from \"@snaptrude/plugin-core\"\nimport { ClientSpaceApi } from \"./space\"\nimport { ClientStoryApi } from \"./story\"\n\nexport class ClientEntityApi extends PluginEntityApi {\n public space: ClientSpaceApi\n public story: ClientStoryApi\n\n constructor() {\n super()\n this.space = new ClientSpaceApi()\n this.story = new ClientStoryApi()\n }\n}\n\nexport * from \"./space\"\nexport * from \"./story\"\n","import {\n PluginSpaceApi,\n PluginSpaceCreateRectangularArgs,\n PluginSpaceCreateRectangularResult,\n PluginSpaceCreateFromProfileArgs,\n PluginSpaceCreateFromProfileResult,\n PluginSpaceDeleteByIdArgs,\n PluginSpaceDeleteByIdResult,\n PluginSpaceGetArgs,\n PluginSpaceGetResult,\n PluginSpaceGetAllResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientSpaceApi extends PluginSpaceApi {\n constructor() {\n super()\n }\n\n public async createRectangular({\n position,\n dimensions,\n }: PluginSpaceCreateRectangularArgs): Promise<PluginSpaceCreateRectangularResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.createRectangular\",\n args: {\n position,\n dimensions,\n },\n })\n }\n\n public async createFromProfile({\n profile,\n extrudeHeight,\n position,\n }: PluginSpaceCreateFromProfileArgs): Promise<PluginSpaceCreateFromProfileResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.createFromProfile\",\n args: {\n profile,\n extrudeHeight,\n position,\n },\n })\n }\n\n public async get({\n spaceId,\n properties,\n }: PluginSpaceGetArgs): Promise<PluginSpaceGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.get\",\n args: {\n spaceId,\n properties,\n },\n })\n }\n\n public async getAll(): Promise<PluginSpaceGetAllResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.getAll\",\n })\n }\n\n public async deleteById({\n spaceId,\n }: PluginSpaceDeleteByIdArgs): Promise<PluginSpaceDeleteByIdResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.deleteById\",\n args: {\n spaceId,\n },\n })\n }\n}\n","import {\n PluginStoryApi,\n PluginStoryGetArgs,\n PluginStoryGetResult,\n PluginStoryGetAllResult,\n PluginStoryCreateArgs,\n PluginStoryCreateResult,\n PluginStoryUpdateArgs,\n PluginStoryUpdateResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientStoryApi extends PluginStoryApi {\n constructor() {\n super()\n }\n\n public async get({\n storyValue,\n properties,\n }: PluginStoryGetArgs): Promise<PluginStoryGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.get\",\n args: {\n storyValue,\n properties,\n },\n })\n }\n\n public async getAll(): Promise<PluginStoryGetAllResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.getAll\",\n })\n }\n\n public async create({\n storyValue,\n height,\n }: PluginStoryCreateArgs): Promise<PluginStoryCreateResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.create\",\n args: {\n storyValue,\n height,\n },\n })\n }\n\n public async update({\n storyValue,\n height,\n }: PluginStoryUpdateArgs): Promise<PluginStoryUpdateResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.update\",\n args: {\n storyValue,\n height,\n },\n })\n }\n}\n","import { PluginToolsApi } from \"@snaptrude/plugin-core\"\nimport { ClientSelectionApi } from \"./selection\"\nimport { ClientTransformApi } from \"./transform\"\n\nexport class ClientToolsApi extends PluginToolsApi {\n public selection: ClientSelectionApi\n public transform: ClientTransformApi\n\n constructor() {\n super()\n this.selection = new ClientSelectionApi()\n this.transform = new ClientTransformApi()\n }\n}\n\nexport * from \"./selection\"\nexport * from \"./transform\"\n","import { PluginSelectionApi, PluginSelectionGetResult } from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientSelectionApi extends PluginSelectionApi {\n constructor() {\n super()\n }\n\n public async get(): Promise<PluginSelectionGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.selection.get\",\n })\n }\n}\n","import {\n PluginTransformApi,\n PluginMoveArgs,\n PluginRotateArgs,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientTransformApi extends PluginTransformApi {\n constructor() {\n super()\n }\n\n public async move({\n componentIds,\n displacement,\n }: PluginMoveArgs): Promise<void> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.transform.move\",\n args: {\n componentIds,\n displacement,\n },\n })\n }\n\n public async rotate({\n componentIds,\n angle,\n axis,\n pivot,\n }: PluginRotateArgs): Promise<void> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.transform.rotate\",\n args: {\n componentIds,\n angle,\n axis,\n pivot,\n },\n })\n }\n}\n","import {\n PluginUnitsApi,\n PluginUnitsConvertFromArgs,\n PluginUnitsConvertFromResult,\n PluginUnitsConvertToArgs,\n PluginUnitsConvertToResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientUnitsApi extends PluginUnitsApi {\n constructor() {\n super()\n }\n\n public async convertFrom(\n args: PluginUnitsConvertFromArgs,\n ): Promise<PluginUnitsConvertFromResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"units.convertFrom\",\n args,\n })\n }\n\n public async convertTo(\n args: PluginUnitsConvertToArgs,\n ): Promise<PluginUnitsConvertToResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"units.convertTo\",\n args,\n })\n }\n}\n","import { ClientCoreApi } from \"./core\"\nimport { ClientEntityApi } from \"./entity\"\nimport { ClientToolsApi } from \"./tools\"\nimport { ClientUnitsApi } from \"./units\"\nimport { PluginApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientPluginApi extends PluginApi {\n private static instance: ClientPluginApi\n\n public core: ClientCoreApi\n public tools: ClientToolsApi\n public entity: ClientEntityApi\n public units: ClientUnitsApi\n\n private constructor() {\n super()\n this.core = new ClientCoreApi()\n this.tools = new ClientToolsApi()\n this.entity = new ClientEntityApi()\n this.units = new ClientUnitsApi()\n }\n\n static getInstance(): ClientPluginApi {\n if (!ClientPluginApi.instance) {\n ClientPluginApi.instance = new ClientPluginApi()\n }\n return ClientPluginApi.instance\n }\n}\n\nexport * from \"./core\"\nexport * from \"./entity\"\nexport * from \"./tools\"\nexport * from \"./units\"\n","import * as Comlink from \"comlink\"\n\nexport interface UIMessage {\n action: string\n payload: unknown\n}\n\ninterface PluginConfig {\n pluginId: string\n permissions: string[]\n}\n\n/**\n * Base class for Snaptrude plugin workers.\n *\n * Handles Comlink wiring, host communication, and the standard lifecycle\n * methods (`init`, `destroy`, `ping`, `onUIMessage`). Subclass this and\n * override only the methods you need — then call `start()` to expose the\n * worker API.\n *\n * The plugin ID is received automatically from the host during\n * initialization — no need to pass it manually.\n *\n * @example\n * ```ts\n * import { PluginWorker } from \"@snaptrude/plugin-client\";\n *\n * class MyPlugin extends PluginWorker {\n * async onUIMessage(message: UIMessage) {\n * // handle messages from the UI panel\n * }\n * }\n *\n * new MyPlugin().start();\n * ```\n */\nexport abstract class PluginWorker {\n protected pluginId!: string\n private hostAPI: Comlink.Remote<Record<string, unknown>>\n\n constructor() {\n this.hostAPI = Comlink.wrap<Record<string, unknown>>(\n self as unknown as Comlink.Endpoint\n )\n }\n\n protected sendToUI(action: string, payload: unknown): void {\n ;(this.hostAPI as Record<string, any>).ui.sendToUI({ action, payload })\n }\n\n async init(): Promise<void> {\n console.log(this.pluginId, \"init() called\")\n console.log(this.pluginId, \"Initialization complete\")\n }\n\n async destroy(): Promise<void> {\n console.log(this.pluginId, \"destroy() called — cleaning up\")\n }\n\n async ping(): Promise<string> {\n return \"pong\"\n }\n\n async onUIMessage(_message: UIMessage): Promise<void> {\n // Override in subclass to handle UI messages\n }\n\n /**\n * Expose the worker API via Comlink and start listening.\n * Call this once after constructing the plugin instance.\n *\n * The host calls `init(config)` with `{ pluginId, permissions }`,\n * which is captured here to set `this.pluginId` before the\n * subclass's `init()` runs.\n */\n start(): void {\n Comlink.expose(\n {\n init: (config: PluginConfig) => {\n this.pluginId = config.pluginId\n return this.init()\n },\n destroy: () => this.destroy(),\n ping: () => this.ping(),\n onUIMessage: (message: UIMessage) => this.onUIMessage(message),\n },\n self as unknown as Comlink.Endpoint\n )\n console.log(\"Worker loaded, API exposed via Comlink\")\n }\n}\n","import { ClientPluginApi } from \"./api\"\n\nexport * from \"./api\"\nexport * from \"./host-api\"\nexport * from \"./plugin-worker\"\n\n/**\n * The Snaptrude plugin client API.\n *\n * The main entry point for plugins to interact with the Snaptrude platform.\n */\nexport const snaptrude = ClientPluginAp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A,EAEA,MAAM,OAAwB;AAC5B,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,YAAY,UAAoC;AAAA,EAEtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,QAAc;AACZ,IAAQ;AAAA,MACN;AAAA,QACE,MAAM,CAAC,WAAyB;AAC9B,eAAK,WAAW,OAAO;AACvB,iBAAO,KAAK,KAAK;AAAA,QACnB;AAAA,QACA,SAAS,MAAM,KAAK,QAAQ;AAAA,QAC5B,MAAM,MAAM,KAAK,KAAK;AAAA,QACtB,aAAa,CAAC,YAAuB,KAAK,YAAY,OAAO;AAAA,MAC/D;AAAA,MACA;AAAA,IACF;AACA,YAAQ,IAAI,wCAAwC;AAAA,EACtD;AACF;;;AC/EO,IAAM,YAAY,gBAAgB,YAAY;","names":["Comlink"]}
1
+ {"version":3,"sources":["../src/api/core/index.ts","../src/api/core/math/index.ts","../src/api/core/math/vec3.ts","../src/api/core/math/quat.ts","../src/api/core/geom/index.ts","../src/api/core/geom/line.ts","../src/api/core/geom/arc.ts","../src/api/core/geom/curve.ts","../src/api/core/geom/profile.ts","../src/host-api.ts","../src/api/entity/index.ts","../src/api/entity/space.ts","../src/api/entity/story.ts","../src/api/tools/index.ts","../src/api/tools/selection.ts","../src/api/tools/transform.ts","../src/api/units/index.ts","../src/api/index.ts","../src/plugin-worker.ts","../src/index.ts"],"sourcesContent":["import { PluginCoreApi } from \"@snaptrude/plugin-core\"\nimport { ClientMathApi } from \"./math\"\nimport { ClientGeomApi } from \"./geom\"\n\nexport class ClientCoreApi extends PluginCoreApi {\n public math: ClientMathApi\n public geom: ClientGeomApi\n\n constructor() {\n super()\n this.math = new ClientMathApi()\n this.geom = new ClientGeomApi()\n }\n}\n\nexport * from \"./math\"\nexport * from \"./geom\"\n","import { PluginMathApi } from \"@snaptrude/plugin-core\"\nimport { ClientVec3Api } from \"./vec3\"\nimport { ClientQuatApi } from \"./quat\"\n\nexport class ClientMathApi extends PluginMathApi {\n public vec3: ClientVec3Api\n public quat: ClientQuatApi\n\n constructor() {\n super()\n this.vec3 = new ClientVec3Api()\n this.quat = new ClientQuatApi()\n }\n}\n\nexport * from \"./vec3\"\nexport * from \"./quat\"\n","import { PluginVec3Api } from \"@snaptrude/plugin-core\"\n\nexport class ClientVec3Api extends PluginVec3Api {\n constructor() {\n super()\n }\n}\n","import { PluginQuatApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientQuatApi extends PluginQuatApi {\n constructor() {\n super()\n }\n}\n","import { PluginGeomApi } from \"@snaptrude/plugin-core\"\nimport { ClientLineApi } from \"./line\"\nimport { ClientArcApi } from \"./arc\"\nimport { ClientCurveApi } from \"./curve\"\nimport { ClientProfileApi } from \"./profile\"\n\nexport class ClientGeomApi extends PluginGeomApi {\n public line: ClientLineApi\n public arc: ClientArcApi\n public curve: ClientCurveApi\n public profile: ClientProfileApi\n\n constructor() {\n super()\n this.line = new ClientLineApi()\n this.arc = new ClientArcApi()\n this.curve = new ClientCurveApi()\n this.profile = new ClientProfileApi()\n }\n}\n\nexport * from \"./line\"\nexport * from \"./arc\"\nexport * from \"./curve\"\nexport * from \"./profile\"\n","import { PluginLineApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientLineApi extends PluginLineApi {\n constructor() {\n super()\n }\n}\n","import { PluginArcApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientArcApi extends PluginArcApi {\n constructor() {\n super()\n }\n}\n","import { PluginCurveApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientCurveApi extends PluginCurveApi {\n constructor() {\n super()\n }\n}\n","import { PluginProfileApi } from \"@snaptrude/plugin-core\"\nimport type { PProfile, PluginProfileFromLinePointsArgs } from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../../host-api\"\n\nexport class ClientProfileApi extends PluginProfileApi {\n constructor() {\n super()\n }\n\n public async fromLinePoints(args: PluginProfileFromLinePointsArgs): Promise<PProfile> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"core.geom.profile.fromLinePoints\",\n args,\n })\n }\n}\n","import * as Comlink from \"comlink\"\nimport type {\n PluginApiMethod,\n PluginApiCallPayload,\n PluginApiCallWrappedResult,\n PluginApiCallResult,\n} from \"@snaptrude/plugin-core\"\n\nexport interface HostApi {\n call<M extends PluginApiMethod>(\n payload: PluginApiCallPayload<M>\n ): Promise<PluginApiCallWrappedResult<M>>\n}\n\nexport interface HostApiWrapped {\n call<M extends PluginApiMethod>(\n payload: PluginApiCallPayload<M>\n ): Promise<PluginApiCallResult<M>>\n}\n\nexport function createHostApi(endpoint?: Comlink.Endpoint): HostApi {\n return Comlink.wrap<HostApi>(\n endpoint ?? (globalThis as unknown as Comlink.Endpoint)\n ) as unknown as HostApi\n}\n\nlet _instance: HostApi | null = null\n\nexport function getHostApi(): HostApiWrapped {\n if (!_instance) {\n _instance = createHostApi()\n }\n return {\n call: async <M extends PluginApiMethod>(payload: PluginApiCallPayload<M>): Promise<PluginApiCallResult<M>> => {\n if (!_instance) {\n throw new Error(\"Host API not initialized\")\n }\n return _instance.call(payload).then(result => {\n if (result.success) {\n return result.data\n } else {\n throw new Error(result.error)\n }\n })\n }\n }\n}\n","import { PluginEntityApi } from \"@snaptrude/plugin-core\"\nimport { ClientSpaceApi } from \"./space\"\nimport { ClientStoryApi } from \"./story\"\n\nexport class ClientEntityApi extends PluginEntityApi {\n public space: ClientSpaceApi\n public story: ClientStoryApi\n\n constructor() {\n super()\n this.space = new ClientSpaceApi()\n this.story = new ClientStoryApi()\n }\n}\n\nexport * from \"./space\"\nexport * from \"./story\"\n","import {\n PluginSpaceApi,\n PluginSpaceCreateRectangularArgs,\n PluginSpaceCreateRectangularResult,\n PluginSpaceCreateFromProfileArgs,\n PluginSpaceCreateFromProfileResult,\n PluginSpaceDeleteArgs,\n PluginSpaceDeleteResult,\n PluginSpaceGetArgs,\n PluginSpaceGetResult,\n PluginSpaceGetAllResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientSpaceApi extends PluginSpaceApi {\n constructor() {\n super()\n }\n\n public async createRectangular({\n position,\n dimensions,\n }: PluginSpaceCreateRectangularArgs): Promise<PluginSpaceCreateRectangularResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.createRectangular\",\n args: {\n position,\n dimensions,\n },\n })\n }\n\n public async createFromProfile({\n profile,\n extrudeHeight,\n position,\n }: PluginSpaceCreateFromProfileArgs): Promise<PluginSpaceCreateFromProfileResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.createFromProfile\",\n args: {\n profile,\n extrudeHeight,\n position,\n },\n })\n }\n\n public async get({\n spaceId,\n properties,\n }: PluginSpaceGetArgs): Promise<PluginSpaceGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.get\",\n args: {\n spaceId,\n properties,\n },\n })\n }\n\n public async getAll(): Promise<PluginSpaceGetAllResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.getAll\",\n })\n }\n\n public async delete({\n spaceId,\n }: PluginSpaceDeleteArgs): Promise<PluginSpaceDeleteResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.delete\",\n args: {\n spaceId,\n },\n })\n }\n}\n","import {\n PluginStoryApi,\n PluginStoryGetArgs,\n PluginStoryGetResult,\n PluginStoryGetAllResult,\n PluginStoryCreateArgs,\n PluginStoryCreateResult,\n PluginStoryUpdateArgs,\n PluginStoryUpdateResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientStoryApi extends PluginStoryApi {\n constructor() {\n super()\n }\n\n public async get({\n storyValue,\n properties,\n }: PluginStoryGetArgs): Promise<PluginStoryGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.get\",\n args: {\n storyValue,\n properties,\n },\n })\n }\n\n public async getAll(): Promise<PluginStoryGetAllResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.getAll\",\n })\n }\n\n public async create({\n storyValue,\n height,\n }: PluginStoryCreateArgs): Promise<PluginStoryCreateResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.create\",\n args: {\n storyValue,\n height,\n },\n })\n }\n\n public async update({\n storyValue,\n height,\n }: PluginStoryUpdateArgs): Promise<PluginStoryUpdateResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.update\",\n args: {\n storyValue,\n height,\n },\n })\n }\n}\n","import { PluginToolsApi } from \"@snaptrude/plugin-core\"\nimport { ClientSelectionApi } from \"./selection\"\nimport { ClientTransformApi } from \"./transform\"\n\nexport class ClientToolsApi extends PluginToolsApi {\n public selection: ClientSelectionApi\n public transform: ClientTransformApi\n\n constructor() {\n super()\n this.selection = new ClientSelectionApi()\n this.transform = new ClientTransformApi()\n }\n}\n\nexport * from \"./selection\"\nexport * from \"./transform\"\n","import { PluginSelectionApi, PluginSelectionGetResult } from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientSelectionApi extends PluginSelectionApi {\n constructor() {\n super()\n }\n\n public async get(): Promise<PluginSelectionGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.selection.get\",\n })\n }\n}\n","import {\n PluginTransformApi,\n PluginMoveArgs,\n PluginRotateArgs,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientTransformApi extends PluginTransformApi {\n constructor() {\n super()\n }\n\n public async move({\n componentIds,\n displacement,\n }: PluginMoveArgs): Promise<void> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.transform.move\",\n args: {\n componentIds,\n displacement,\n },\n })\n }\n\n public async rotate({\n componentIds,\n angle,\n axis,\n pivot,\n }: PluginRotateArgs): Promise<void> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.transform.rotate\",\n args: {\n componentIds,\n angle,\n axis,\n pivot,\n },\n })\n }\n}\n","import {\n PluginUnitsApi,\n PluginUnitsConvertFromArgs,\n PluginUnitsConvertFromResult,\n PluginUnitsConvertToArgs,\n PluginUnitsConvertToResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientUnitsApi extends PluginUnitsApi {\n constructor() {\n super()\n }\n\n public async convertFrom(\n args: PluginUnitsConvertFromArgs,\n ): Promise<PluginUnitsConvertFromResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"units.convertFrom\",\n args,\n })\n }\n\n public async convertTo(\n args: PluginUnitsConvertToArgs,\n ): Promise<PluginUnitsConvertToResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"units.convertTo\",\n args,\n })\n }\n}\n","import { ClientCoreApi } from \"./core\"\nimport { ClientEntityApi } from \"./entity\"\nimport { ClientToolsApi } from \"./tools\"\nimport { ClientUnitsApi } from \"./units\"\nimport { PluginApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientPluginApi extends PluginApi {\n private static instance: ClientPluginApi\n\n public core: ClientCoreApi\n public tools: ClientToolsApi\n public entity: ClientEntityApi\n public units: ClientUnitsApi\n\n private constructor() {\n super()\n this.core = new ClientCoreApi()\n this.tools = new ClientToolsApi()\n this.entity = new ClientEntityApi()\n this.units = new ClientUnitsApi()\n }\n\n static getInstance(): ClientPluginApi {\n if (!ClientPluginApi.instance) {\n ClientPluginApi.instance = new ClientPluginApi()\n }\n return ClientPluginApi.instance\n }\n}\n\nexport * from \"./core\"\nexport * from \"./entity\"\nexport * from \"./tools\"\nexport * from \"./units\"\n","import * as Comlink from \"comlink\"\n\nexport interface UIMessage {\n action: string\n payload: unknown\n}\n\ninterface PluginConfig {\n pluginId: string\n permissions: string[]\n}\n\n/**\n * Base class for Snaptrude plugin workers.\n *\n * Handles Comlink wiring, host communication, and the standard lifecycle\n * methods (`init`, `destroy`, `ping`, `onUIMessage`). Subclass this and\n * override only the methods you need — then call `start()` to expose the\n * worker API.\n *\n * The plugin ID is received automatically from the host during\n * initialization — no need to pass it manually.\n *\n * @example\n * ```ts\n * import { PluginWorker } from \"@snaptrude/plugin-client\";\n *\n * class MyPlugin extends PluginWorker {\n * async onUIMessage(message: UIMessage) {\n * // handle messages from the UI panel\n * }\n * }\n *\n * new MyPlugin().start();\n * ```\n */\nexport abstract class PluginWorker {\n protected pluginId!: string\n private hostAPI: Comlink.Remote<Record<string, unknown>>\n\n constructor() {\n this.hostAPI = Comlink.wrap<Record<string, unknown>>(\n self as unknown as Comlink.Endpoint\n )\n }\n\n protected sendToUI(action: string, payload: unknown): void {\n ;(this.hostAPI as Record<string, any>).ui.sendToUI({ action, payload })\n }\n\n /**\n * Signal the host that this plugin has finished its work and should be\n * stopped. Use this in headless (UI-less) plugins that run a task and\n * self-terminate.\n */\n protected complete(): void {\n ;(this.hostAPI as Record<string, any>).lifecycle.complete()\n }\n\n async init(): Promise<void> {\n console.log(this.pluginId, \"init() called\")\n console.log(this.pluginId, \"Initialization complete\")\n }\n\n async destroy(): Promise<void> {\n console.log(this.pluginId, \"destroy() called — cleaning up\")\n }\n\n async ping(): Promise<string> {\n return \"pong\"\n }\n\n async onUIMessage(_message: UIMessage): Promise<void> {\n // Override in subclass to handle UI messages\n }\n\n /**\n * Expose the worker API via Comlink and start listening.\n * Call this once after constructing the plugin instance.\n *\n * The host calls `init(config)` with `{ pluginId, permissions }`,\n * which is captured here to set `this.pluginId` before the\n * subclass's `init()` runs.\n */\n start(): void {\n Comlink.expose(\n {\n init: (config: PluginConfig) => {\n this.pluginId = config.pluginId\n return this.init()\n },\n destroy: () => this.destroy(),\n ping: () => this.ping(),\n onUIMessage: (message: UIMessage) => this.onUIMessage(message),\n },\n self as unknown as Comlink.Endpoint\n )\n console.log(\"Worker loaded, API exposed via Comlink\")\n }\n}\n","import { ClientPluginApi } from \"./api\"\n\nexport * from \"./api\"\nexport * from \"./host-api\"\nexport * from \"./plugin-worker\"\n\n/**\n * The Snaptrude plugin client API.\n *\n * The main entry point for plugins to interact with the Snaptrude platform.\n */\nexport const snaptrude = ClientPlu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UAAU,yBAAyB;AAAA,EACtD;AAAA,EAEA,MAAM,UAAyB;AAC7B,YAAQ,IAAI,KAAK,UAAU,qCAAgC;AAAA,EAC7D;AAAA,EAEA,MAAM,OAAwB;AAC5B,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,YAAY,UAAoC;AAAA,EAEtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,QAAc;AACZ,IAAQ;AAAA,MACN;AAAA,QACE,MAAM,CAAC,WAAyB;AAC9B,eAAK,WAAW,OAAO;AACvB,iBAAO,KAAK,KAAK;AAAA,QACnB;AAAA,QACA,SAAS,MAAM,KAAK,QAAQ;AAAA,QAC5B,MAAM,MAAM,KAAK,KAAK;AAAA,QACtB,aAAa,CAAC,YAAuB,KAAK,YAAY,OAAO;AAAA,MAC/D;AAAA,MACA;AAAA,IACF;AACA,YAAQ,IAAI,wCAAwC;AAAA,EACtD;AACF;;;ACxFO,IAAM,YAAY,gBAAgB,YAAY;","names":["Comlink"]}
@@ -31,6 +31,12 @@ export declare abstract class PluginWorker {
31
31
  private hostAPI;
32
32
  constructor();
33
33
  protected sendToUI(action: string, payload: unknown): void;
34
+ /**
35
+ * Signal the host that this plugin has finished its work and should be
36
+ * stopped. Use this in headless (UI-less) plugins that run a task and
37
+ * self-terminate.
38
+ */
39
+ protected complete(): void;
34
40
  init(): Promise<void>;
35
41
  destroy(): Promise<void>;
36
42
  ping(): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-worker.d.ts","sourceRoot":"","sources":["../src/plugin-worker.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;CACjB;AAOD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,8BAAsB,YAAY;IAChC,SAAS,CAAC,QAAQ,EAAG,MAAM,CAAA;IAC3B,OAAO,CAAC,OAAO,CAAyC;;IAQxD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAIpD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAKrB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAIvB,WAAW,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD;;;;;;;OAOG;IACH,KAAK,IAAI,IAAI;CAed"}
1
+ {"version":3,"file":"plugin-worker.d.ts","sourceRoot":"","sources":["../src/plugin-worker.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;CACjB;AAOD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,8BAAsB,YAAY;IAChC,SAAS,CAAC,QAAQ,EAAG,MAAM,CAAA;IAC3B,OAAO,CAAC,OAAO,CAAyC;;IAQxD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAI1D;;;;OAIG;IACH,SAAS,CAAC,QAAQ,IAAI,IAAI;IAIpB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAKrB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAIvB,WAAW,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD;;;;;;;OAOG;IACH,KAAK,IAAI,IAAI;CAed"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snaptrude/plugin-client",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "comlink": "^4.4.2",
21
- "@snaptrude/plugin-core": "0.0.5"
21
+ "@snaptrude/plugin-core": "0.0.6"
22
22
  },
23
23
  "devDependencies": {
24
24
  "tsup": "^8.5.1",
@@ -4,8 +4,8 @@ import {
4
4
  PluginSpaceCreateRectangularResult,
5
5
  PluginSpaceCreateFromProfileArgs,
6
6
  PluginSpaceCreateFromProfileResult,
7
- PluginSpaceDeleteByIdArgs,
8
- PluginSpaceDeleteByIdResult,
7
+ PluginSpaceDeleteArgs,
8
+ PluginSpaceDeleteResult,
9
9
  PluginSpaceGetArgs,
10
10
  PluginSpaceGetResult,
11
11
  PluginSpaceGetAllResult,
@@ -68,12 +68,12 @@ export class ClientSpaceApi extends PluginSpaceApi {
68
68
  })
69
69
  }
70
70
 
71
- public async deleteById({
71
+ public async delete({
72
72
  spaceId,
73
- }: PluginSpaceDeleteByIdArgs): Promise<PluginSpaceDeleteByIdResult> {
73
+ }: PluginSpaceDeleteArgs): Promise<PluginSpaceDeleteResult> {
74
74
  const hostApi = getHostApi()
75
75
  return hostApi.call({
76
- method: "entity.space.deleteById",
76
+ method: "entity.space.delete",
77
77
  args: {
78
78
  spaceId,
79
79
  },
@@ -48,6 +48,15 @@ export abstract class PluginWorker {
48
48
  ;(this.hostAPI as Record<string, any>).ui.sendToUI({ action, payload })
49
49
  }
50
50
 
51
+ /**
52
+ * Signal the host that this plugin has finished its work and should be
53
+ * stopped. Use this in headless (UI-less) plugins that run a task and
54
+ * self-terminate.
55
+ */
56
+ protected complete(): void {
57
+ ;(this.hostAPI as Record<string, any>).lifecycle.complete()
58
+ }
59
+
51
60
  async init(): Promise<void> {
52
61
  console.log(this.pluginId, "init() called")
53
62
  console.log(this.pluginId, "Initialization complete")