@archilogic/extension-sdk 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,74 @@
1
+ //#region src/action-runner.ts
2
+ var e = (e) => {
3
+ if (!e || typeof e != "object") return !1;
4
+ let { code: t, message: n } = e;
5
+ return t === "METHOD_NOT_FOUND" || typeof n == "string" && n.includes("is not found");
6
+ }, t = (t) => {
7
+ let { hostApi: n } = t, r = t.onError ?? ((e) => console.warn("[extension-sdk] action start failed:", e)), i = null, a = !1, o = 0, s = null, c = () => {
8
+ i?.update(t.controls()).catch(() => {});
9
+ }, l = async (l) => {
10
+ if (a) return { status: "legacy-host" };
11
+ let u = ++o;
12
+ s = u;
13
+ let d = i;
14
+ i = null, d?.stop().catch(() => {});
15
+ try {
16
+ let e = await n.startActionRun({
17
+ name: l,
18
+ controls: t.controls(),
19
+ onControl: (e) => t.onControl?.(e),
20
+ onEnd: (e) => {
21
+ u === o && (i = null, t.onEnd?.(e));
22
+ }
23
+ });
24
+ return u === o ? e.status === "started" ? (i = e.run, c(), { status: "started" }) : {
25
+ status: "unavailable",
26
+ reason: e.reason
27
+ } : (e.status === "started" && e.run.stop().catch(() => {}), { status: "superseded" });
28
+ } catch (t) {
29
+ return u === o ? e(t) ? (a = !0, { status: "legacy-host" }) : (r(t), {
30
+ status: "error",
31
+ error: t
32
+ }) : { status: "superseded" };
33
+ } finally {
34
+ s === u && (s = null);
35
+ }
36
+ };
37
+ return {
38
+ start: l,
39
+ ensure: (e) => {
40
+ a || i || s !== null || l(e);
41
+ },
42
+ stop: () => {
43
+ o++, s = null;
44
+ let e = i;
45
+ i = null, e?.stop().catch(() => {});
46
+ },
47
+ sync: c,
48
+ commit: async (e) => {
49
+ let t = i;
50
+ if (t) {
51
+ let n = await t.commit(e);
52
+ if (n.status !== "ended") return {
53
+ via: "action",
54
+ result: n
55
+ };
56
+ }
57
+ return {
58
+ via: "operations",
59
+ result: await n.runOperations({
60
+ operations: e.operations,
61
+ label: e.label
62
+ })
63
+ };
64
+ },
65
+ get running() {
66
+ return i !== null;
67
+ },
68
+ get legacyHost() {
69
+ return a;
70
+ }
71
+ };
72
+ };
73
+ //#endregion
74
+ export { t as createActionRunner };
package/dist/index.d.ts CHANGED
@@ -799,6 +799,8 @@ export declare type ExtensionApi = {
799
799
  modifiers?: CanvasModifiers;
800
800
  }): void;
801
801
  onCanvasChange(change: CanvasChange): void;
802
+ /** The host's display settings changed — e.g. the user switched measurement units. Optional: extensions built before settings forwarding don't expose it, and hosts feature-check before calling. */
803
+ onSettingsChange?(settings: HostSettings): void;
802
804
  /** The user pressed a declared control of the running custom action. */
803
805
  onActionControl(args: {
804
806
  runId: string;
@@ -822,6 +824,7 @@ declare type ExtensionEventMap = {
822
824
  'canvas-click': Parameters<ExtensionApi['onCanvasClick']>[0];
823
825
  'canvas-mousemove': Parameters<ExtensionApi['onCanvasMouseMove']>[0];
824
826
  'canvas-change': Parameters<ExtensionApi['onCanvasChange']>[0];
827
+ 'settings-change': HostSettings;
825
828
  'action-control': Parameters<ExtensionApi['onActionControl']>[0];
826
829
  'action-end': Parameters<ExtensionApi['onActionEnd']>[0];
827
830
  };
@@ -1153,11 +1156,15 @@ declare type GroupRelationType = typeof GroupRelationTypeValue;
1153
1156
 
1154
1157
  declare const GroupRelationTypeValue = "relation:group";
1155
1158
 
1156
- declare interface GroupShape {
1159
+ declare type GroupShape = Omit<GroupShape_2, 'children'> & {
1160
+ children: Shape[];
1161
+ };
1162
+
1163
+ declare interface GroupShape_2 {
1157
1164
  type: 'group';
1158
1165
  position?: Vector2;
1159
1166
  rotation?: number;
1160
- children: Shape[];
1167
+ children: Shape_2[];
1161
1168
  style?: ShapeStyle;
1162
1169
  }
1163
1170
 
@@ -1218,8 +1225,10 @@ export declare type HostApi = {
1218
1225
  getFloor: <S extends FloorSelect = FloorDefaultSelect>(args?: {
1219
1226
  select?: S;
1220
1227
  }) => Promise<QueryPick<FloorData, S>>;
1228
+ /** `label` names the undo step on hosts that support it; older hosts ignore it. */
1221
1229
  runOperations: (args: {
1222
1230
  operations: OperationJson[];
1231
+ label?: string;
1223
1232
  }) => Promise<OperationsResult>;
1224
1233
  setPlanConfig: (config: {
1225
1234
  theme?: FloorPlanTheme;
@@ -1346,6 +1355,47 @@ export declare type HostApi = {
1346
1355
  off: <K extends ExtensionEventKey>(event: K, listener?: ExtensionEventListener<K>) => void;
1347
1356
  };
1348
1357
 
1358
+ /**
1359
+ * Display settings of the host, sent in the `onConnect` parameters (as `settings`) and again on
1360
+ * every change via `onSettingsChange` — so an extension can render measurements the way the
1361
+ * host does instead of hardcoding a unit system.
1362
+ */
1363
+ export declare type HostSettings = {
1364
+ units?: {
1365
+ system?: 'metric' | 'imperial';
1366
+ /** Decimal places the host displays area values with. */
1367
+ areaDecimals?: number;
1368
+ /** Decimal places the host displays length values with. */
1369
+ lengthDecimals?: number;
1370
+ };
1371
+ };
1372
+
1373
+ /**
1374
+ * A resolved icon placed in the plan — first-class in fpe's render
1375
+ * vocabulary so every renderer consumes the icon svg natively instead of
1376
+ * decoding it from a data-uri fill.
1377
+ */
1378
+ declare interface IconShape {
1379
+ type: 'icon';
1380
+ /** Center, world coordinates */
1381
+ position: Vector2;
1382
+ /** Width and height of the square icon, meters */
1383
+ size: number;
1384
+ /** Degrees, about the center — same convention as node transforms */
1385
+ rotation?: number;
1386
+ /** Raw icon svg using currentColor, resolved from a symbol library */
1387
+ svg?: string;
1388
+ /** Remote svg source for icons outside the symbol library */
1389
+ uri?: string;
1390
+ /** Symbol id the icon svg resolved from, e.g. 'hc:user-md' */
1391
+ symbol?: string;
1392
+ /**
1393
+ * `fill` completely overrides the icon color; without it, source colors
1394
+ * render as-is, with currentColor resolved from the surrounding context.
1395
+ */
1396
+ style?: ShapeStyle;
1397
+ }
1398
+
1349
1399
  declare type IndexedNodeReference = {
1350
1400
  id: string;
1351
1401
  type: LayoutBoundingBoxNode['type'];
@@ -2842,7 +2892,7 @@ declare class OperationBase {
2842
2892
  */
2843
2893
  declare type OperationJson = VertexCreateOperationJson | EdgeCreateOperationJson | SpaceCreateOperationJson | ElementCreateOperationJson | AnnotationCreateOperationJson | ViewCreateOperationJson | ProductCreateOperationJson | RelationCreateOperationJson | MaterialCreateOperationJson | CustomAttributeCreateOperationJson | VertexRemoveOperationJson | VertexUpdateOperationJson | VertexReplaceOperationJson | EdgeConnectOperationJson | EdgeRemoveOperationJson | EdgeReplaceOperationJson | EdgeMergeOperationJson | EdgeSplitOperationJson | EdgeUpdateOperationJson | SpaceUpdateOperationJson | SpaceRemoveOperationJson | ElementUpdateOperationJson | ElementRemoveOperationJson | AnnotationUpdateOperationJson | AnnotationRemoveOperationJson | ViewUpdateOperationJson | ViewRemoveOperationJson | ProductUpdateOperationJson | ProductRemoveOperationJson | RelationUpdateOperationJson | RelationRemoveOperationJson | RelationInsertNodesOperationJson | RelationRemoveNodesOperationJson | MaterialUpdateOperationJson | MaterialRemoveOperationJson | LayoutUpdateOperationJson | CustomAttributeUpdateOperationJson | CustomAttributeRemoveOperationJson;
2844
2894
 
2845
- declare type OperationsResult = {
2895
+ export declare type OperationsResult = {
2846
2896
  created: NodeResult[];
2847
2897
  removed: NodeResult[];
2848
2898
  updated: NodeResult[];
@@ -3120,7 +3170,9 @@ declare interface SelectOption {
3120
3170
  label: string;
3121
3171
  }
3122
3172
 
3123
- export declare type Shape = CurveShape | TextShape | GroupShape;
3173
+ export declare type Shape = CurveShape | TextShape | GroupShape | IconShape;
3174
+
3175
+ declare type Shape_2 = CurveShape | TextShape | GroupShape_2;
3124
3176
 
3125
3177
  declare interface ShapeStyle {
3126
3178
  stroke?: string | number | number[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@archilogic/extension-sdk",
3
3
  "description": "",
4
- "version": "0.15.0",
4
+ "version": "0.17.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -25,10 +25,15 @@
25
25
  "exports": {
26
26
  ".": {
27
27
  "types": "./dist/index.d.ts"
28
+ },
29
+ "./actions": {
30
+ "types": "./dist/actions.d.ts",
31
+ "import": "./dist/actions.js",
32
+ "require": "./dist/actions.cjs"
28
33
  }
29
34
  },
30
35
  "devDependencies": {
31
- "@archilogic/floor-plan-core": "^5.8.4",
36
+ "@archilogic/floor-plan-core": "^5.8.5",
32
37
  "@archilogic/space-graph-sdk": "^0.11.1",
33
38
  "vite-plugin-static-copy": "^4.1.1"
34
39
  },