@archilogic/extension-sdk 0.15.0 → 0.16.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.
- package/CHANGELOG.md +7 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.ts +4430 -0
- package/dist/actions.js +74 -0
- package/dist/index.d.ts +38 -4
- package/package.json +7 -2
package/dist/actions.js
ADDED
|
@@ -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
|
@@ -1153,11 +1153,15 @@ declare type GroupRelationType = typeof GroupRelationTypeValue;
|
|
|
1153
1153
|
|
|
1154
1154
|
declare const GroupRelationTypeValue = "relation:group";
|
|
1155
1155
|
|
|
1156
|
-
declare
|
|
1156
|
+
declare type GroupShape = Omit<GroupShape_2, 'children'> & {
|
|
1157
|
+
children: Shape[];
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
declare interface GroupShape_2 {
|
|
1157
1161
|
type: 'group';
|
|
1158
1162
|
position?: Vector2;
|
|
1159
1163
|
rotation?: number;
|
|
1160
|
-
children:
|
|
1164
|
+
children: Shape_2[];
|
|
1161
1165
|
style?: ShapeStyle;
|
|
1162
1166
|
}
|
|
1163
1167
|
|
|
@@ -1218,8 +1222,10 @@ export declare type HostApi = {
|
|
|
1218
1222
|
getFloor: <S extends FloorSelect = FloorDefaultSelect>(args?: {
|
|
1219
1223
|
select?: S;
|
|
1220
1224
|
}) => Promise<QueryPick<FloorData, S>>;
|
|
1225
|
+
/** `label` names the undo step on hosts that support it; older hosts ignore it. */
|
|
1221
1226
|
runOperations: (args: {
|
|
1222
1227
|
operations: OperationJson[];
|
|
1228
|
+
label?: string;
|
|
1223
1229
|
}) => Promise<OperationsResult>;
|
|
1224
1230
|
setPlanConfig: (config: {
|
|
1225
1231
|
theme?: FloorPlanTheme;
|
|
@@ -1346,6 +1352,32 @@ export declare type HostApi = {
|
|
|
1346
1352
|
off: <K extends ExtensionEventKey>(event: K, listener?: ExtensionEventListener<K>) => void;
|
|
1347
1353
|
};
|
|
1348
1354
|
|
|
1355
|
+
/**
|
|
1356
|
+
* A resolved icon placed in the plan — first-class in fpe's render
|
|
1357
|
+
* vocabulary so every renderer consumes the icon svg natively instead of
|
|
1358
|
+
* decoding it from a data-uri fill.
|
|
1359
|
+
*/
|
|
1360
|
+
declare interface IconShape {
|
|
1361
|
+
type: 'icon';
|
|
1362
|
+
/** Center, world coordinates */
|
|
1363
|
+
position: Vector2;
|
|
1364
|
+
/** Width and height of the square icon, meters */
|
|
1365
|
+
size: number;
|
|
1366
|
+
/** Degrees, about the center — same convention as node transforms */
|
|
1367
|
+
rotation?: number;
|
|
1368
|
+
/** Raw icon svg using currentColor, resolved from a symbol library */
|
|
1369
|
+
svg?: string;
|
|
1370
|
+
/** Remote svg source for icons outside the symbol library */
|
|
1371
|
+
uri?: string;
|
|
1372
|
+
/** Symbol id the icon svg resolved from, e.g. 'hc:user-md' */
|
|
1373
|
+
symbol?: string;
|
|
1374
|
+
/**
|
|
1375
|
+
* `fill` completely overrides the icon color; without it, source colors
|
|
1376
|
+
* render as-is, with currentColor resolved from the surrounding context.
|
|
1377
|
+
*/
|
|
1378
|
+
style?: ShapeStyle;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1349
1381
|
declare type IndexedNodeReference = {
|
|
1350
1382
|
id: string;
|
|
1351
1383
|
type: LayoutBoundingBoxNode['type'];
|
|
@@ -2842,7 +2874,7 @@ declare class OperationBase {
|
|
|
2842
2874
|
*/
|
|
2843
2875
|
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
2876
|
|
|
2845
|
-
declare type OperationsResult = {
|
|
2877
|
+
export declare type OperationsResult = {
|
|
2846
2878
|
created: NodeResult[];
|
|
2847
2879
|
removed: NodeResult[];
|
|
2848
2880
|
updated: NodeResult[];
|
|
@@ -3120,7 +3152,9 @@ declare interface SelectOption {
|
|
|
3120
3152
|
label: string;
|
|
3121
3153
|
}
|
|
3122
3154
|
|
|
3123
|
-
export declare type Shape = CurveShape | TextShape | GroupShape;
|
|
3155
|
+
export declare type Shape = CurveShape | TextShape | GroupShape | IconShape;
|
|
3156
|
+
|
|
3157
|
+
declare type Shape_2 = CurveShape | TextShape | GroupShape_2;
|
|
3124
3158
|
|
|
3125
3159
|
declare interface ShapeStyle {
|
|
3126
3160
|
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.
|
|
4
|
+
"version": "0.16.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.
|
|
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
|
},
|