@archilogic/extension-sdk 0.10.1 → 0.10.3
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 +16 -0
- package/dist/index.d.ts +7 -90
- package/package.json +3 -9
- package/dist/extension-sdk.cjs +0 -1
- package/dist/extension-sdk.js +0 -775
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @archilogic/extension-sdk
|
|
2
2
|
|
|
3
|
+
## 0.10.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8ee5ec0: chore(release): version packages (#716)
|
|
8
|
+
|
|
9
|
+
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
|
10
|
+
|
|
11
|
+
- 8ee5ec0: fix: use templates for npm create [snapshot]
|
|
12
|
+
|
|
13
|
+
## 0.10.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 84c8db2: fix: extension-sdk deployment fix
|
|
18
|
+
|
|
3
19
|
## 0.10.1
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { default as default_2 } from 'rbush';
|
|
2
|
-
import { Worker as Worker_2 } from 'node:worker_threads';
|
|
3
2
|
|
|
4
3
|
declare class AnnotationCreate extends OperationBase {
|
|
5
4
|
type: typeof AnnotationCreateTypeValue;
|
|
@@ -195,16 +194,6 @@ declare type BoundingBox3d = {
|
|
|
195
194
|
max: Vector3;
|
|
196
195
|
};
|
|
197
196
|
|
|
198
|
-
declare class CallOptions {
|
|
199
|
-
#private;
|
|
200
|
-
readonly transferables?: Transferable[];
|
|
201
|
-
readonly timeout?: number;
|
|
202
|
-
constructor(options?: {
|
|
203
|
-
transferables?: Transferable[];
|
|
204
|
-
timeout?: number;
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
197
|
declare interface CircleCurve extends CurveBase {
|
|
209
198
|
type: CircleCurveType;
|
|
210
199
|
radius: number;
|
|
@@ -302,47 +291,6 @@ export declare interface ConfirmArgs {
|
|
|
302
291
|
cancelLabel?: string;
|
|
303
292
|
}
|
|
304
293
|
|
|
305
|
-
/**
|
|
306
|
-
* An object representing the connection as a result of calling connect().
|
|
307
|
-
*/
|
|
308
|
-
export declare type Connection<TMethods extends Methods = Methods> = {
|
|
309
|
-
/**
|
|
310
|
-
* A promise which will be resolved once the connection has been established.
|
|
311
|
-
*/
|
|
312
|
-
promise: Promise<RemoteProxy<TMethods>>;
|
|
313
|
-
/**
|
|
314
|
-
* A method that, when called, will disconnect any communication.
|
|
315
|
-
* You may call this even before a connection has been established.
|
|
316
|
-
*/
|
|
317
|
-
destroy: () => void;
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
export declare type ConnectionOptions = {
|
|
321
|
-
useWorker?: 'node' | 'web';
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* @example
|
|
326
|
-
* const connection = createExtensionConnection(methods)
|
|
327
|
-
* const extension = await connection.promise
|
|
328
|
-
* // dispatch onConnect event
|
|
329
|
-
* await extension.onConnect({ floorMetaData })
|
|
330
|
-
* connection.destroy()
|
|
331
|
-
*/
|
|
332
|
-
export declare const createExtensionConnection: (methods: any, { iframe, worker, webWorker }: {
|
|
333
|
-
iframe?: HTMLIFrameElement;
|
|
334
|
-
worker?: Worker_2;
|
|
335
|
-
webWorker?: globalThis.Worker;
|
|
336
|
-
}) => Connection<ExtensionApi>;
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* @example
|
|
340
|
-
* const hostApi = createHostConnection()
|
|
341
|
-
* hostApi.on('layout-change', () => console.log('layout updated'))
|
|
342
|
-
* const spaces = await hostApi.getSpaces()
|
|
343
|
-
*/
|
|
344
|
-
export declare const createHostConnection: (extensionMethods?: Partial<ExtensionApi>, options?: ConnectionOptions) => HostApi;
|
|
345
|
-
|
|
346
294
|
declare class CuboidGeometry extends ParametricGeometryBase {
|
|
347
295
|
type: CuboidGeometryType;
|
|
348
296
|
dimensions: Vector3;
|
|
@@ -791,8 +739,6 @@ declare type ExtensionEventMap = {
|
|
|
791
739
|
'canvas-click': Parameters<ExtensionApi['onCanvasClick']>[0];
|
|
792
740
|
};
|
|
793
741
|
|
|
794
|
-
declare type ExtractValueFromReply<R> = R extends Reply ? Awaited<R['value']> : R;
|
|
795
|
-
|
|
796
742
|
declare class ExtrusionGeometry extends ParametricGeometryBase {
|
|
797
743
|
type: ExtrusionGeometryType;
|
|
798
744
|
profile: ClosedCurve;
|
|
@@ -1048,6 +994,11 @@ declare interface GroupShape extends BaseShape {
|
|
|
1048
994
|
children: Shape[];
|
|
1049
995
|
}
|
|
1050
996
|
|
|
997
|
+
/**
|
|
998
|
+
* Elements that can be hidden in the floor plan
|
|
999
|
+
*/
|
|
1000
|
+
export declare type HideableElement = LayoutElement['type'] | LayoutSpace['type'] | SpatialGraphEdge['type'] | LayoutAnnotation['type'] | 'roomStamp';
|
|
1001
|
+
|
|
1051
1002
|
declare type HingeSide = 'left' | 'right';
|
|
1052
1003
|
|
|
1053
1004
|
export declare type HostApi = {
|
|
@@ -1101,7 +1052,8 @@ export declare type HostApi = {
|
|
|
1101
1052
|
operations: OperationJson[];
|
|
1102
1053
|
}) => Promise<OperationsResult>;
|
|
1103
1054
|
setPlanConfig: (config: {
|
|
1104
|
-
theme
|
|
1055
|
+
theme?: FloorPlanTheme;
|
|
1056
|
+
hideElements?: HideableElement[];
|
|
1105
1057
|
}) => Promise<boolean>;
|
|
1106
1058
|
addPlanLayer: (args: {
|
|
1107
1059
|
id?: string;
|
|
@@ -1168,10 +1120,6 @@ export declare type HostApi = {
|
|
|
1168
1120
|
off: <K extends ExtensionEventKey>(event: K, listener?: ExtensionEventListener<K>) => void;
|
|
1169
1121
|
};
|
|
1170
1122
|
|
|
1171
|
-
export declare type HostApiSync = {
|
|
1172
|
-
[K in Exclude<keyof HostApi, OmitKeys>]: K extends KeepAsync ? HostApi[K] : Sync<HostApi[K]>;
|
|
1173
|
-
};
|
|
1174
|
-
|
|
1175
1123
|
declare type IndexedNodeReference = {
|
|
1176
1124
|
id: string;
|
|
1177
1125
|
type: LayoutBoundingBoxNode['type'];
|
|
@@ -1187,8 +1135,6 @@ declare type IndexRange = {
|
|
|
1187
1135
|
end: number;
|
|
1188
1136
|
};
|
|
1189
1137
|
|
|
1190
|
-
declare type KeepAsync = 'prompt' | 'confirm' | 'findClosest' | 'getPath';
|
|
1191
|
-
|
|
1192
1138
|
declare class Layout2dView extends LayoutViewBase {
|
|
1193
1139
|
type: Layout2dViewType;
|
|
1194
1140
|
parameters: Layout2dViewParameters;
|
|
@@ -2395,14 +2341,6 @@ declare type MeshGeometryType = typeof MeshGeometryTypeValue;
|
|
|
2395
2341
|
|
|
2396
2342
|
declare const MeshGeometryTypeValue = "geometry:mesh";
|
|
2397
2343
|
|
|
2398
|
-
/**
|
|
2399
|
-
* Methods to expose to the remote window. May contain nested objects
|
|
2400
|
-
* with methods as well.
|
|
2401
|
-
*/
|
|
2402
|
-
declare type Methods = {
|
|
2403
|
-
[index: string]: Methods | Function;
|
|
2404
|
-
};
|
|
2405
|
-
|
|
2406
2344
|
declare type NodeResult = {
|
|
2407
2345
|
id: string;
|
|
2408
2346
|
type: string;
|
|
@@ -2480,8 +2418,6 @@ declare interface NumberRange extends SpaceGraphTypedValueJson {
|
|
|
2480
2418
|
};
|
|
2481
2419
|
}
|
|
2482
2420
|
|
|
2483
|
-
declare type OmitKeys = 'on' | 'off' | 'once';
|
|
2484
|
-
|
|
2485
2421
|
declare type OpenCurve = LineCurve | PolylineCurve | ArcCurve;
|
|
2486
2422
|
|
|
2487
2423
|
declare type OpenCurves = LineCurve_2 | ArcCurve_2 | PolylineCurve_2 | BezierCurve;
|
|
@@ -2797,23 +2733,6 @@ declare const RelationUpdateTypeValue: "operation:relationUpdate";
|
|
|
2797
2733
|
|
|
2798
2734
|
declare type RelationUpdateValue = Omit<Partial<SpaceGraphRelationJson>, 'type'>;
|
|
2799
2735
|
|
|
2800
|
-
/**
|
|
2801
|
-
* An object representing methods exposed by the remote but that can be called
|
|
2802
|
-
* locally.
|
|
2803
|
-
*/
|
|
2804
|
-
export declare type RemoteProxy<TMethods extends Methods = Methods> = {
|
|
2805
|
-
[K in keyof TMethods]: TMethods[K] extends (...args: infer A) => infer R ? (...args: [...A, CallOptions?]) => Promise<ExtractValueFromReply<Awaited<R>>> : TMethods[K] extends Methods ? RemoteProxy<TMethods[K]> : never;
|
|
2806
|
-
};
|
|
2807
|
-
|
|
2808
|
-
declare class Reply<T = unknown> {
|
|
2809
|
-
#private;
|
|
2810
|
-
readonly value: T;
|
|
2811
|
-
readonly transferables?: Transferable[];
|
|
2812
|
-
constructor(value: T, options?: {
|
|
2813
|
-
transferables?: Transferable[];
|
|
2814
|
-
});
|
|
2815
|
-
}
|
|
2816
|
-
|
|
2817
2736
|
declare type Rgb = [number, number, number];
|
|
2818
2737
|
|
|
2819
2738
|
declare type RgbA = [number, number, number, number];
|
|
@@ -3784,8 +3703,6 @@ declare interface Surfaces {
|
|
|
3784
3703
|
[surface: string]: GeometryFaceIndices;
|
|
3785
3704
|
}
|
|
3786
3705
|
|
|
3787
|
-
declare type Sync<T> = T extends (...args: infer A) => Promise<infer R> ? (...args: A) => R : T;
|
|
3788
|
-
|
|
3789
3706
|
declare interface TextField extends BaseField {
|
|
3790
3707
|
type: 'text';
|
|
3791
3708
|
default?: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@archilogic/extension-sdk",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.3",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -21,19 +21,13 @@
|
|
|
21
21
|
"codecheck": "npm run typecheck && npm run lint && npm run format"
|
|
22
22
|
},
|
|
23
23
|
"type": "module",
|
|
24
|
-
"main": "./dist/extension-sdk.cjs",
|
|
25
24
|
"types": "./dist/index.d.ts",
|
|
26
25
|
"exports": {
|
|
27
26
|
".": {
|
|
28
|
-
"types": "./dist/index.d.ts"
|
|
29
|
-
"import": "./dist/extension-sdk.js",
|
|
30
|
-
"require": "./dist/extension-sdk.cjs"
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
31
28
|
}
|
|
32
29
|
},
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@archilogic/penpal": "^7.0.5",
|
|
35
|
-
"tiny-emitter": "^2.1.0"
|
|
36
|
-
},
|
|
30
|
+
"dependencies": {},
|
|
37
31
|
"devDependencies": {
|
|
38
32
|
"@archilogic/floor-plan-core": "^5.4.0",
|
|
39
33
|
"@archilogic/space-graph-sdk": "^0.8.0",
|
package/dist/extension-sdk.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var We=Object.defineProperty;var fe=e=>{throw TypeError(e)};var Fe=(e,t,r)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var h=(e,t,r)=>Fe(e,typeof t!="symbol"?t+"":t,r),ve=(e,t,r)=>t.has(e)||fe("Cannot "+r);var n=(e,t,r)=>(ve(e,t,"read from private field"),r?r.call(e):t.get(e)),o=(e,t,r)=>t.has(e)?fe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),p=(e,t,r,s)=>(ve(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Ue=class extends Error{constructor(t,r){super(r);h(this,"code");this.name="PenpalError",this.code=t}},w=Ue,Ve=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof w?e.code:void 0}),Ye=({name:e,message:t,stack:r,penpalCode:s})=>{const a=s?new w(s,t):new Error(t);return a.name=e,a.stack=r,a},$e=Symbol("Reply"),le,me,je=(me=class{constructor(e,t){h(this,"value");h(this,"transferables");o(this,le,$e);this.value=e,this.transferables=t==null?void 0:t.transferables}},le=new WeakMap,me),ze=je,P="penpal",ae=e=>typeof e=="object"&&e!==null,Ne=e=>typeof e=="function",Ke=e=>ae(e)&&e.namespace===P,W=e=>e.type==="SYN",ie=e=>e.type==="ACK1",z=e=>e.type==="ACK2",Re=e=>e.type==="CALL",_e=e=>e.type==="REPLY",Ge=e=>e.type==="DESTROY",ke=(e,t=[])=>{const r=[];for(const s of Object.keys(e)){const a=e[s];Ne(a)?r.push([...t,s]):ae(a)&&r.push(...ke(a,[...t,s]))}return r},qe=(e,t)=>{const r=e.reduce((s,a)=>ae(s)?s[a]:void 0,t);return Ne(r)?r:void 0},R=e=>e.join("."),pe=(e,t,r)=>({namespace:P,channel:e,type:"REPLY",callId:t,isError:!0,...r instanceof Error?{value:Ve(r),isSerializedErrorInstance:!0}:{value:r}}),Be=(e,t,r,s)=>{let a=!1;const i=async u=>{if(a||!Re(u))return;s==null||s(`Received ${R(u.methodPath)}() call`,u);const{methodPath:d,args:f,id:c}=u;let l,A;try{const M=qe(d,t);if(!M)throw new w("METHOD_NOT_FOUND",`Method \`${R(d)}\` is not found.`);let y=await M(...f);y instanceof ze&&(A=y.transferables,y=await y.value),l={namespace:P,channel:r,type:"REPLY",callId:c,value:y}}catch(M){l=pe(r,c,M)}if(!a)try{s==null||s(`Sending ${R(d)}() reply`,l),e.sendMessage(l,A)}catch(M){throw M.name==="DataCloneError"&&(l=pe(r,c,M),s==null||s(`Sending ${R(d)}() reply`,l),e.sendMessage(l)),M}};return e.addMessageHandler(i),()=>{a=!0,e.removeMessageHandler(i)}},Je=Be,Pe,Le=((Pe=crypto.randomUUID)==null?void 0:Pe.bind(crypto))??(()=>new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")),Xe=Symbol("CallOptions"),he,Ae,Qe=(Ae=class{constructor(e){h(this,"transferables");h(this,"timeout");o(this,he,Xe);this.transferables=e==null?void 0:e.transferables,this.timeout=e==null?void 0:e.timeout}},he=new WeakMap,Ae),Ze=Qe,et=new Set(["apply","call","bind"]),Te=(e,t,r=[])=>new Proxy(r.length?()=>{}:Object.create(null),{get(s,a){if(a!=="then")return r.length&&et.has(a)?Reflect.get(s,a):Te(e,t,[...r,a])},apply(s,a,i){return e(r,i)}}),Me=e=>new w("CONNECTION_DESTROYED",`Method call ${R(e)}() failed due to destroyed connection`),tt=(e,t,r)=>{let s=!1;const a=new Map,i=f=>{if(!_e(f))return;const{callId:c,value:l,isError:A,isSerializedErrorInstance:M}=f,y=a.get(c);y&&(a.delete(c),r==null||r(`Received ${R(y.methodPath)}() call`,f),A?y.reject(M?Ye(l):l):y.resolve(l))};return e.addMessageHandler(i),{remoteProxy:Te((f,c)=>{if(s)throw Me(f);const l=Le(),A=c[c.length-1],M=A instanceof Ze,{timeout:y,transferables:oe}=M?A:{},ee=M?c.slice(0,-1):c;return new Promise((te,j)=>{const de=y!==void 0?window.setTimeout(()=>{a.delete(l),j(new w("METHOD_CALL_TIMEOUT",`Method call ${R(f)}() timed out after ${y}ms`))},y):void 0;a.set(l,{methodPath:f,resolve:te,reject:j,timeoutId:de});try{const O={namespace:P,channel:t,type:"CALL",id:l,methodPath:f,args:ee};r==null||r(`Sending ${R(f)}() call`,O),e.sendMessage(O,oe)}catch(O){j(new w("TRANSMISSION_FAILED",O.message))}})},r),destroy:()=>{s=!0,e.removeMessageHandler(i);for(const{methodPath:f,reject:c,timeoutId:l}of a.values())clearTimeout(l),c(Me(f));a.clear()}}},rt=tt,nt=()=>{let e,t;return{promise:new Promise((s,a)=>{e=s,t=a}),resolve:e,reject:t}},st=nt,at=class extends Error{constructor(e){super(`You've hit a bug in Penpal. Please file an issue with the following information: ${e}`)}},F=at,ce="deprecated-penpal",it=e=>ae(e)&&"penpal"in e,ot=e=>e.split("."),ye=e=>e.join("."),be=e=>new F(`Unexpected message to translate: ${JSON.stringify(e)}`),dt=e=>{if(e.penpal==="syn")return{namespace:P,channel:void 0,type:"SYN",participantId:ce};if(e.penpal==="ack")return{namespace:P,channel:void 0,type:"ACK2"};if(e.penpal==="call")return{namespace:P,channel:void 0,type:"CALL",id:e.id,methodPath:ot(e.methodName),args:e.args};if(e.penpal==="reply")return e.resolution==="fulfilled"?{namespace:P,channel:void 0,type:"REPLY",callId:e.id,value:e.returnValue}:{namespace:P,channel:void 0,type:"REPLY",callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw be(e)},ct=e=>{if(ie(e))return{penpal:"synAck",methodNames:e.methodPaths.map(ye)};if(Re(e))return{penpal:"call",id:e.id,methodName:ye(e.methodPath),args:e.args};if(_e(e))return e.isError?{penpal:"reply",id:e.callId,resolution:"rejected",...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:"reply",id:e.callId,resolution:"fulfilled",returnValue:e.value};throw be(e)},lt=({messenger:e,methods:t,timeout:r,channel:s,log:a})=>{const i=Le();let u;const d=[];let f=!1;const c=ke(t),{promise:l,resolve:A,reject:M}=st(),y=r!==void 0?setTimeout(()=>{M(new w("CONNECTION_TIMEOUT",`Connection timed out after ${r}ms`))},r):void 0,oe=()=>{for(const v of d)v()},ee=()=>{if(f)return;d.push(Je(e,t,s,a));const{remoteProxy:v,destroy:_}=rt(e,s,a);d.push(_),clearTimeout(y),f=!0,A({remoteProxy:v,destroy:oe})},te=()=>{const v={namespace:P,type:"SYN",channel:s,participantId:i};a==null||a("Sending handshake SYN",v);try{e.sendMessage(v)}catch(_){M(new w("TRANSMISSION_FAILED",_.message))}},j=v=>{if(a==null||a("Received handshake SYN",v),v.participantId===u&&u!==ce||(u=v.participantId,te(),!(i>u||u===ce)))return;const re={namespace:P,channel:s,type:"ACK1",methodPaths:c};a==null||a("Sending handshake ACK1",re);try{e.sendMessage(re)}catch(Oe){M(new w("TRANSMISSION_FAILED",Oe.message));return}},de=v=>{a==null||a("Received handshake ACK1",v);const _={namespace:P,channel:s,type:"ACK2"};a==null||a("Sending handshake ACK2",_);try{e.sendMessage(_)}catch(re){M(new w("TRANSMISSION_FAILED",re.message));return}ee()},O=v=>{a==null||a("Received handshake ACK2",v),ee()},ue=v=>{W(v)&&j(v),ie(v)&&de(v),z(v)&&O(v)};return e.addMessageHandler(ue),d.push(()=>e.removeMessageHandler(ue)),te(),l},ht=lt,ut=e=>{let t=!1,r;return(...s)=>(t||(t=!0,r=e(...s)),r)},ft=ut,we=new WeakSet,vt=({messenger:e,methods:t={},timeout:r,channel:s,log:a})=>{if(!e)throw new w("INVALID_ARGUMENT","messenger must be defined");if(we.has(e))throw new w("INVALID_ARGUMENT","A messenger can only be used for a single connection");we.add(e);const i=[e.destroy],u=ft(c=>{if(c){const l={namespace:P,channel:s,type:"DESTROY"};try{e.sendMessage(l)}catch{}}for(const l of i)l();a==null||a("Connection destroyed")}),d=c=>Ke(c)&&c.channel===s;return{promise:(async()=>{try{e.initialize({log:a,validateReceivedMessage:d}),e.addMessageHandler(A=>{Ge(A)&&u(!1)});const{remoteProxy:c,destroy:l}=await ht({messenger:e,methods:t,timeout:r,channel:s,log:a});return i.push(l),c}catch(c){throw u(!0),c}})(),destroy:()=>{u(!0)}}},De=vt,g,k,U,V,L,C,E,T,se,Y,K,G,$,Ie,pt=(Ie=class{constructor({remoteWindow:e,allowedOrigins:t}){o(this,g);o(this,k);o(this,U);o(this,V);o(this,L);o(this,C,new Set);o(this,E);o(this,T,!1);h(this,"initialize",({log:e,validateReceivedMessage:t})=>{p(this,U,e),p(this,V,t),window.addEventListener("message",n(this,G))});h(this,"sendMessage",(e,t)=>{if(W(e)){const r=n(this,Y).call(this,e);n(this,g).postMessage(e,{targetOrigin:r,transfer:t});return}if(ie(e)||n(this,T)){const r=n(this,T)?ct(e):e,s=n(this,Y).call(this,e);n(this,g).postMessage(r,{targetOrigin:s,transfer:t});return}if(z(e)){const{port1:r,port2:s}=new MessageChannel;p(this,E,r),r.addEventListener("message",n(this,$)),r.start();const a=[s,...t||[]],i=n(this,Y).call(this,e);n(this,g).postMessage(e,{targetOrigin:i,transfer:a});return}if(n(this,E)){n(this,E).postMessage(e,{transfer:t});return}throw new F("Port is undefined")});h(this,"addMessageHandler",e=>{n(this,C).add(e)});h(this,"removeMessageHandler",e=>{n(this,C).delete(e)});h(this,"destroy",()=>{window.removeEventListener("message",n(this,G)),n(this,K).call(this),n(this,C).clear()});o(this,se,e=>n(this,k).some(t=>t instanceof RegExp?t.test(e):t===e||t==="*"));o(this,Y,e=>{if(W(e))return"*";if(!n(this,L))throw new F("Concrete remote origin not set");return n(this,L)==="null"&&n(this,k).includes("*")?"*":n(this,L)});o(this,K,()=>{var e,t;(e=n(this,E))==null||e.removeEventListener("message",n(this,$)),(t=n(this,E))==null||t.close(),p(this,E,void 0)});o(this,G,({source:e,origin:t,ports:r,data:s})=>{var a,i,u;if(e===n(this,g)&&(it(s)&&((a=n(this,U))==null||a.call(this,"Please upgrade the child window to the latest version of Penpal."),p(this,T,!0),s=dt(s)),!!((i=n(this,V))!=null&&i.call(this,s)))){if(!n(this,se).call(this,t)){(u=n(this,U))==null||u.call(this,`Received a message from origin \`${t}\` which did not match allowed origins \`[${n(this,k).join(", ")}]\``);return}if(W(s)&&(n(this,K).call(this),p(this,L,t)),z(s)&&!n(this,T)){if(p(this,E,r[0]),!n(this,E))throw new F("No port received on ACK2");n(this,E).addEventListener("message",n(this,$)),n(this,E).start()}for(const d of n(this,C))d(s)}});o(this,$,({data:e})=>{var t;if((t=n(this,V))!=null&&t.call(this,e))for(const r of n(this,C))r(e)});if(!e)throw new w("INVALID_ARGUMENT","remoteWindow must be defined");p(this,g,e),p(this,k,t!=null&&t.length?t:[window.origin])}},g=new WeakMap,k=new WeakMap,U=new WeakMap,V=new WeakMap,L=new WeakMap,C=new WeakMap,E=new WeakMap,T=new WeakMap,se=new WeakMap,Y=new WeakMap,K=new WeakMap,G=new WeakMap,$=new WeakMap,Ie),He=pt,S,q,b,m,B,N,ge,Mt=(ge=class{constructor({worker:e}){o(this,S);o(this,q);o(this,b,new Set);o(this,m);h(this,"initialize",({validateReceivedMessage:e})=>{p(this,q,e),n(this,S).addEventListener("message",n(this,N))});h(this,"sendMessage",(e,t)=>{if(W(e)||ie(e)){n(this,S).postMessage(e,{transfer:t});return}if(z(e)){const{port1:r,port2:s}=new MessageChannel;p(this,m,r),r.addEventListener("message",n(this,N)),r.start(),n(this,S).postMessage(e,{transfer:[s,...t||[]]});return}if(n(this,m)){n(this,m).postMessage(e,{transfer:t});return}throw new F("Port is undefined")});h(this,"addMessageHandler",e=>{n(this,b).add(e)});h(this,"removeMessageHandler",e=>{n(this,b).delete(e)});h(this,"destroy",()=>{n(this,S).removeEventListener("message",n(this,N)),n(this,B).call(this),n(this,b).clear()});o(this,B,()=>{var e,t;(e=n(this,m))==null||e.removeEventListener("message",n(this,N)),(t=n(this,m))==null||t.close(),p(this,m,void 0)});o(this,N,({ports:e,data:t})=>{var r;if((r=n(this,q))!=null&&r.call(this,t)){if(W(t)&&n(this,B).call(this),z(t)){if(p(this,m,e[0]),!n(this,m))throw new F("No port received on ACK2");n(this,m).addEventListener("message",n(this,N)),n(this,m).start()}for(const s of n(this,b))s(t)}});if(!e)throw new w("INVALID_ARGUMENT","worker must be defined");p(this,S,e)}},S=new WeakMap,q=new WeakMap,b=new WeakMap,m=new WeakMap,B=new WeakMap,N=new WeakMap,ge),xe=Mt,D,J,H,X,Ce,yt=(Ce=class{constructor({worker:e}){o(this,D);o(this,J);o(this,H,new Set);h(this,"initialize",({validateReceivedMessage:e})=>{p(this,J,e),n(this,D).addListener("message",n(this,X))});h(this,"sendMessage",(e,t)=>{n(this,D).postMessage(e,t)});h(this,"addMessageHandler",e=>{n(this,H).add(e)});h(this,"removeMessageHandler",e=>{n(this,H).delete(e)});h(this,"destroy",()=>{n(this,D).removeListener("message",n(this,X)),n(this,H).clear()});o(this,X,e=>{var t;if((t=n(this,J))!=null&&t.call(this,e))for(const r of n(this,H))r(e)});if(!e)throw new w("INVALID_ARGUMENT","worker must be defined");p(this,D,e)}},D=new WeakMap,J=new WeakMap,H=new WeakMap,X=new WeakMap,Ce),wt=yt,I,Q,x,Z,Se,Et=(Se=class{constructor({port:e}){o(this,I);o(this,Q);o(this,x,new Set);h(this,"initialize",({validateReceivedMessage:e})=>{p(this,Q,e),n(this,I).addEventListener("message",n(this,Z)),n(this,I).start()});h(this,"sendMessage",(e,t)=>{var r;(r=n(this,I))==null||r.postMessage(e,{transfer:t})});h(this,"addMessageHandler",e=>{n(this,x).add(e)});h(this,"removeMessageHandler",e=>{n(this,x).delete(e)});h(this,"destroy",()=>{n(this,I).removeEventListener("message",n(this,Z)),n(this,I).close(),n(this,x).clear()});o(this,Z,({data:e})=>{var t;if((t=n(this,Q))!=null&&t.call(this,e))for(const r of n(this,x))r(e)});if(!e)throw new w("INVALID_ARGUMENT","port must be defined");p(this,I,e)}},I=new WeakMap,Q=new WeakMap,x=new WeakMap,Z=new WeakMap,Se),mt=Et;const Pt=(e,{iframe:t,worker:r,webWorker:s})=>{let a;if(t)a=new He({remoteWindow:t.contentWindow,allowedOrigins:[/^http:\/\/localhost(:\d+)/,"https://extensions.archilogic.io","https://testing-extensions.archilogic.io"]});else if(r)a=new wt({worker:r});else if(s)a=new xe({worker:s});else throw new Error("No iframe or worker to connect to");return De({messenger:a,methods:e})};var ne={exports:{}},Ee;function At(){if(Ee)return ne.exports;Ee=1;function e(){}return e.prototype={on:function(t,r,s){var a=this.e||(this.e={});return(a[t]||(a[t]=[])).push({fn:r,ctx:s}),this},once:function(t,r,s){var a=this;function i(){a.off(t,i),r.apply(s,arguments)}return i._=r,this.on(t,i,s)},emit:function(t){var r=[].slice.call(arguments,1),s=((this.e||(this.e={}))[t]||[]).slice(),a=0,i=s.length;for(a;a<i;a++)s[a].fn.apply(s[a].ctx,r);return this},off:function(t,r){var s=this.e||(this.e={}),a=s[t],i=[];if(a&&r)for(var u=0,d=a.length;u<d;u++)a[u].fn!==r&&a[u].fn._!==r&&i.push(a[u]);return i.length?s[t]=i:delete s[t],this}},ne.exports=e,ne.exports.TinyEmitter=e,ne.exports}var It=At();const gt=(e={},t)=>{let r;const s=new It.TinyEmitter;if((t==null?void 0:t.useWorker)==="node"){const d=require("node:worker_threads").parentPort;if(!d)throw new Error("No parent port found for worker thread");r=new mt({port:d})}else(t==null?void 0:t.useWorker)==="web"?r=new xe({worker:self}):r=new He({remoteWindow:window.parent,allowedOrigins:[/^http:\/\/localhost(:\d+)/,/^https:\/\/(.*)app.archilogic.com/,/^https:\/\/(.*).archilogic-frontend.com/]});const a={onConnect:()=>{},onDestroy:()=>{},...e,onLayoutChange:d=>{s.emit("layout-change",d)},onSelectionChange:d=>{s.emit("selection-change",d)},onGraphicDrag:d=>{s.emit("graphic-crag",d)},onCanvasClick:d=>{s.emit("canvas-click",d)}},i=De({messenger:r,methods:a});return new Proxy({},{get(d,f){return f==="on"?s.on.bind(s):f==="once"?s.once.bind(s):f==="off"?s.off.bind(s):async(...c)=>(await i.promise)[f](...c)}})};exports.createExtensionConnection=Pt;exports.createHostConnection=gt;
|
package/dist/extension-sdk.js
DELETED
|
@@ -1,775 +0,0 @@
|
|
|
1
|
-
var We = Object.defineProperty;
|
|
2
|
-
var fe = (e) => {
|
|
3
|
-
throw TypeError(e);
|
|
4
|
-
};
|
|
5
|
-
var Fe = (e, t, r) => t in e ? We(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
6
|
-
var l = (e, t, r) => Fe(e, typeof t != "symbol" ? t + "" : t, r), ve = (e, t, r) => t.has(e) || fe("Cannot " + r);
|
|
7
|
-
var n = (e, t, r) => (ve(e, t, "read from private field"), r ? r.call(e) : t.get(e)), o = (e, t, r) => t.has(e) ? fe("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r), p = (e, t, r, s) => (ve(e, t, "write to private field"), s ? s.call(e, r) : t.set(e, r), r);
|
|
8
|
-
var Ue = class extends Error {
|
|
9
|
-
constructor(t, r) {
|
|
10
|
-
super(r);
|
|
11
|
-
l(this, "code");
|
|
12
|
-
this.name = "PenpalError", this.code = t;
|
|
13
|
-
}
|
|
14
|
-
}, w = Ue, Ve = (e) => ({
|
|
15
|
-
name: e.name,
|
|
16
|
-
message: e.message,
|
|
17
|
-
stack: e.stack,
|
|
18
|
-
penpalCode: e instanceof w ? e.code : void 0
|
|
19
|
-
}), Ye = ({
|
|
20
|
-
name: e,
|
|
21
|
-
message: t,
|
|
22
|
-
stack: r,
|
|
23
|
-
penpalCode: s
|
|
24
|
-
}) => {
|
|
25
|
-
const a = s ? new w(s, t) : new Error(t);
|
|
26
|
-
return a.name = e, a.stack = r, a;
|
|
27
|
-
}, $e = Symbol("Reply"), he, me, ze = (me = class {
|
|
28
|
-
constructor(e, t) {
|
|
29
|
-
l(this, "value");
|
|
30
|
-
l(this, "transferables");
|
|
31
|
-
// Allows TypeScript to distinguish between an actual instance of this
|
|
32
|
-
// class versus an object that looks structurally similar.
|
|
33
|
-
// eslint-disable-next-line no-unused-private-class-members
|
|
34
|
-
o(this, he, $e);
|
|
35
|
-
this.value = e, this.transferables = t == null ? void 0 : t.transferables;
|
|
36
|
-
}
|
|
37
|
-
}, he = new WeakMap(), me), je = ze, A = "penpal", ae = (e) => typeof e == "object" && e !== null, Ne = (e) => typeof e == "function", Ke = (e) => ae(e) && e.namespace === A, W = (e) => e.type === "SYN", ie = (e) => e.type === "ACK1", j = (e) => e.type === "ACK2", Re = (e) => e.type === "CALL", _e = (e) => e.type === "REPLY", Ge = (e) => e.type === "DESTROY", ke = (e, t = []) => {
|
|
38
|
-
const r = [];
|
|
39
|
-
for (const s of Object.keys(e)) {
|
|
40
|
-
const a = e[s];
|
|
41
|
-
Ne(a) ? r.push([...t, s]) : ae(a) && r.push(
|
|
42
|
-
...ke(a, [...t, s])
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
return r;
|
|
46
|
-
}, qe = (e, t) => {
|
|
47
|
-
const r = e.reduce(
|
|
48
|
-
(s, a) => ae(s) ? s[a] : void 0,
|
|
49
|
-
t
|
|
50
|
-
);
|
|
51
|
-
return Ne(r) ? r : void 0;
|
|
52
|
-
}, R = (e) => e.join("."), pe = (e, t, r) => ({
|
|
53
|
-
namespace: A,
|
|
54
|
-
channel: e,
|
|
55
|
-
type: "REPLY",
|
|
56
|
-
callId: t,
|
|
57
|
-
isError: !0,
|
|
58
|
-
...r instanceof Error ? { value: Ve(r), isSerializedErrorInstance: !0 } : { value: r }
|
|
59
|
-
}), Be = (e, t, r, s) => {
|
|
60
|
-
let a = !1;
|
|
61
|
-
const i = async (u) => {
|
|
62
|
-
if (a || !Re(u))
|
|
63
|
-
return;
|
|
64
|
-
s == null || s(`Received ${R(u.methodPath)}() call`, u);
|
|
65
|
-
const { methodPath: d, args: f, id: c } = u;
|
|
66
|
-
let h, I;
|
|
67
|
-
try {
|
|
68
|
-
const M = qe(d, t);
|
|
69
|
-
if (!M)
|
|
70
|
-
throw new w(
|
|
71
|
-
"METHOD_NOT_FOUND",
|
|
72
|
-
`Method \`${R(d)}\` is not found.`
|
|
73
|
-
);
|
|
74
|
-
let y = await M(...f);
|
|
75
|
-
y instanceof je && (I = y.transferables, y = await y.value), h = {
|
|
76
|
-
namespace: A,
|
|
77
|
-
channel: r,
|
|
78
|
-
type: "REPLY",
|
|
79
|
-
callId: c,
|
|
80
|
-
value: y
|
|
81
|
-
};
|
|
82
|
-
} catch (M) {
|
|
83
|
-
h = pe(r, c, M);
|
|
84
|
-
}
|
|
85
|
-
if (!a)
|
|
86
|
-
try {
|
|
87
|
-
s == null || s(`Sending ${R(d)}() reply`, h), e.sendMessage(h, I);
|
|
88
|
-
} catch (M) {
|
|
89
|
-
throw M.name === "DataCloneError" && (h = pe(r, c, M), s == null || s(`Sending ${R(d)}() reply`, h), e.sendMessage(h)), M;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
return e.addMessageHandler(i), () => {
|
|
93
|
-
a = !0, e.removeMessageHandler(i);
|
|
94
|
-
};
|
|
95
|
-
}, Je = Be, Ae, Le = ((Ae = crypto.randomUUID) == null ? void 0 : Ae.bind(crypto)) ?? (() => new Array(4).fill(0).map(
|
|
96
|
-
() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)
|
|
97
|
-
).join("-")), Xe = Symbol("CallOptions"), le, Ie, Qe = (Ie = class {
|
|
98
|
-
constructor(e) {
|
|
99
|
-
l(this, "transferables");
|
|
100
|
-
l(this, "timeout");
|
|
101
|
-
// Allows TypeScript to distinguish between an actual instance of this
|
|
102
|
-
// class versus an object that looks structurally similar.
|
|
103
|
-
// eslint-disable-next-line no-unused-private-class-members
|
|
104
|
-
o(this, le, Xe);
|
|
105
|
-
this.transferables = e == null ? void 0 : e.transferables, this.timeout = e == null ? void 0 : e.timeout;
|
|
106
|
-
}
|
|
107
|
-
}, le = new WeakMap(), Ie), Ze = Qe, et = /* @__PURE__ */ new Set(["apply", "call", "bind"]), Te = (e, t, r = []) => new Proxy(
|
|
108
|
-
r.length ? () => {
|
|
109
|
-
} : /* @__PURE__ */ Object.create(null),
|
|
110
|
-
{
|
|
111
|
-
get(s, a) {
|
|
112
|
-
if (a !== "then")
|
|
113
|
-
return r.length && et.has(a) ? Reflect.get(s, a) : Te(e, t, [...r, a]);
|
|
114
|
-
},
|
|
115
|
-
apply(s, a, i) {
|
|
116
|
-
return e(r, i);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
), Me = (e) => new w(
|
|
120
|
-
"CONNECTION_DESTROYED",
|
|
121
|
-
`Method call ${R(
|
|
122
|
-
e
|
|
123
|
-
)}() failed due to destroyed connection`
|
|
124
|
-
), tt = (e, t, r) => {
|
|
125
|
-
let s = !1;
|
|
126
|
-
const a = /* @__PURE__ */ new Map(), i = (f) => {
|
|
127
|
-
if (!_e(f))
|
|
128
|
-
return;
|
|
129
|
-
const { callId: c, value: h, isError: I, isSerializedErrorInstance: M } = f, y = a.get(c);
|
|
130
|
-
y && (a.delete(c), r == null || r(
|
|
131
|
-
`Received ${R(y.methodPath)}() call`,
|
|
132
|
-
f
|
|
133
|
-
), I ? y.reject(
|
|
134
|
-
M ? Ye(h) : h
|
|
135
|
-
) : y.resolve(h));
|
|
136
|
-
};
|
|
137
|
-
return e.addMessageHandler(i), {
|
|
138
|
-
remoteProxy: Te((f, c) => {
|
|
139
|
-
if (s)
|
|
140
|
-
throw Me(f);
|
|
141
|
-
const h = Le(), I = c[c.length - 1], M = I instanceof Ze, { timeout: y, transferables: oe } = M ? I : {}, ee = M ? c.slice(0, -1) : c;
|
|
142
|
-
return new Promise((te, z) => {
|
|
143
|
-
const de = y !== void 0 ? window.setTimeout(() => {
|
|
144
|
-
a.delete(h), z(
|
|
145
|
-
new w(
|
|
146
|
-
"METHOD_CALL_TIMEOUT",
|
|
147
|
-
`Method call ${R(
|
|
148
|
-
f
|
|
149
|
-
)}() timed out after ${y}ms`
|
|
150
|
-
)
|
|
151
|
-
);
|
|
152
|
-
}, y) : void 0;
|
|
153
|
-
a.set(h, { methodPath: f, resolve: te, reject: z, timeoutId: de });
|
|
154
|
-
try {
|
|
155
|
-
const O = {
|
|
156
|
-
namespace: A,
|
|
157
|
-
channel: t,
|
|
158
|
-
type: "CALL",
|
|
159
|
-
id: h,
|
|
160
|
-
methodPath: f,
|
|
161
|
-
args: ee
|
|
162
|
-
};
|
|
163
|
-
r == null || r(`Sending ${R(f)}() call`, O), e.sendMessage(O, oe);
|
|
164
|
-
} catch (O) {
|
|
165
|
-
z(
|
|
166
|
-
new w("TRANSMISSION_FAILED", O.message)
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}, r),
|
|
171
|
-
destroy: () => {
|
|
172
|
-
s = !0, e.removeMessageHandler(i);
|
|
173
|
-
for (const { methodPath: f, reject: c, timeoutId: h } of a.values())
|
|
174
|
-
clearTimeout(h), c(Me(f));
|
|
175
|
-
a.clear();
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
}, rt = tt, nt = () => {
|
|
179
|
-
let e, t;
|
|
180
|
-
return {
|
|
181
|
-
promise: new Promise((s, a) => {
|
|
182
|
-
e = s, t = a;
|
|
183
|
-
}),
|
|
184
|
-
resolve: e,
|
|
185
|
-
reject: t
|
|
186
|
-
};
|
|
187
|
-
}, st = nt, at = class extends Error {
|
|
188
|
-
constructor(e) {
|
|
189
|
-
super(
|
|
190
|
-
`You've hit a bug in Penpal. Please file an issue with the following information: ${e}`
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
}, F = at, ce = "deprecated-penpal", it = (e) => ae(e) && "penpal" in e, ot = (e) => e.split("."), ye = (e) => e.join("."), be = (e) => new F(
|
|
194
|
-
`Unexpected message to translate: ${JSON.stringify(e)}`
|
|
195
|
-
), dt = (e) => {
|
|
196
|
-
if (e.penpal === "syn")
|
|
197
|
-
return {
|
|
198
|
-
namespace: A,
|
|
199
|
-
channel: void 0,
|
|
200
|
-
type: "SYN",
|
|
201
|
-
participantId: ce
|
|
202
|
-
};
|
|
203
|
-
if (e.penpal === "ack")
|
|
204
|
-
return {
|
|
205
|
-
namespace: A,
|
|
206
|
-
channel: void 0,
|
|
207
|
-
type: "ACK2"
|
|
208
|
-
};
|
|
209
|
-
if (e.penpal === "call")
|
|
210
|
-
return {
|
|
211
|
-
namespace: A,
|
|
212
|
-
channel: void 0,
|
|
213
|
-
type: "CALL",
|
|
214
|
-
// Actually converting the ID to a string would break communication.
|
|
215
|
-
id: e.id,
|
|
216
|
-
methodPath: ot(e.methodName),
|
|
217
|
-
args: e.args
|
|
218
|
-
};
|
|
219
|
-
if (e.penpal === "reply")
|
|
220
|
-
return e.resolution === "fulfilled" ? {
|
|
221
|
-
namespace: A,
|
|
222
|
-
channel: void 0,
|
|
223
|
-
type: "REPLY",
|
|
224
|
-
// Actually converting the ID to a string would break communication.
|
|
225
|
-
callId: e.id,
|
|
226
|
-
value: e.returnValue
|
|
227
|
-
} : {
|
|
228
|
-
namespace: A,
|
|
229
|
-
channel: void 0,
|
|
230
|
-
type: "REPLY",
|
|
231
|
-
// Actually converting the ID to a string would break communication.
|
|
232
|
-
callId: e.id,
|
|
233
|
-
isError: !0,
|
|
234
|
-
...e.returnValueIsError ? {
|
|
235
|
-
value: e.returnValue,
|
|
236
|
-
isSerializedErrorInstance: !0
|
|
237
|
-
} : {
|
|
238
|
-
value: e.returnValue
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
throw be(e);
|
|
242
|
-
}, ct = (e) => {
|
|
243
|
-
if (ie(e))
|
|
244
|
-
return {
|
|
245
|
-
penpal: "synAck",
|
|
246
|
-
methodNames: e.methodPaths.map(ye)
|
|
247
|
-
};
|
|
248
|
-
if (Re(e))
|
|
249
|
-
return {
|
|
250
|
-
penpal: "call",
|
|
251
|
-
// Actually converting the ID to a number would break communication.
|
|
252
|
-
id: e.id,
|
|
253
|
-
methodName: ye(e.methodPath),
|
|
254
|
-
args: e.args
|
|
255
|
-
};
|
|
256
|
-
if (_e(e))
|
|
257
|
-
return e.isError ? {
|
|
258
|
-
penpal: "reply",
|
|
259
|
-
// Actually converting the ID to a number would break communication.
|
|
260
|
-
id: e.callId,
|
|
261
|
-
resolution: "rejected",
|
|
262
|
-
...e.isSerializedErrorInstance ? {
|
|
263
|
-
returnValue: e.value,
|
|
264
|
-
returnValueIsError: !0
|
|
265
|
-
} : { returnValue: e.value }
|
|
266
|
-
} : {
|
|
267
|
-
penpal: "reply",
|
|
268
|
-
// Actually converting the ID to a number would break communication.
|
|
269
|
-
id: e.callId,
|
|
270
|
-
resolution: "fulfilled",
|
|
271
|
-
returnValue: e.value
|
|
272
|
-
};
|
|
273
|
-
throw be(e);
|
|
274
|
-
}, ht = ({
|
|
275
|
-
messenger: e,
|
|
276
|
-
methods: t,
|
|
277
|
-
timeout: r,
|
|
278
|
-
channel: s,
|
|
279
|
-
log: a
|
|
280
|
-
}) => {
|
|
281
|
-
const i = Le();
|
|
282
|
-
let u;
|
|
283
|
-
const d = [];
|
|
284
|
-
let f = !1;
|
|
285
|
-
const c = ke(t), { promise: h, resolve: I, reject: M } = st(), y = r !== void 0 ? setTimeout(() => {
|
|
286
|
-
M(
|
|
287
|
-
new w(
|
|
288
|
-
"CONNECTION_TIMEOUT",
|
|
289
|
-
`Connection timed out after ${r}ms`
|
|
290
|
-
)
|
|
291
|
-
);
|
|
292
|
-
}, r) : void 0, oe = () => {
|
|
293
|
-
for (const v of d)
|
|
294
|
-
v();
|
|
295
|
-
}, ee = () => {
|
|
296
|
-
if (f)
|
|
297
|
-
return;
|
|
298
|
-
d.push(Je(e, t, s, a));
|
|
299
|
-
const { remoteProxy: v, destroy: _ } = rt(e, s, a);
|
|
300
|
-
d.push(_), clearTimeout(y), f = !0, I({
|
|
301
|
-
remoteProxy: v,
|
|
302
|
-
destroy: oe
|
|
303
|
-
});
|
|
304
|
-
}, te = () => {
|
|
305
|
-
const v = {
|
|
306
|
-
namespace: A,
|
|
307
|
-
type: "SYN",
|
|
308
|
-
channel: s,
|
|
309
|
-
participantId: i
|
|
310
|
-
};
|
|
311
|
-
a == null || a("Sending handshake SYN", v);
|
|
312
|
-
try {
|
|
313
|
-
e.sendMessage(v);
|
|
314
|
-
} catch (_) {
|
|
315
|
-
M(new w("TRANSMISSION_FAILED", _.message));
|
|
316
|
-
}
|
|
317
|
-
}, z = (v) => {
|
|
318
|
-
if (a == null || a("Received handshake SYN", v), v.participantId === u && // TODO: Used for backward-compatibility. Remove in next major version.
|
|
319
|
-
u !== ce || (u = v.participantId, te(), !(i > u || // TODO: Used for backward-compatibility. Remove in next major version.
|
|
320
|
-
u === ce)))
|
|
321
|
-
return;
|
|
322
|
-
const re = {
|
|
323
|
-
namespace: A,
|
|
324
|
-
channel: s,
|
|
325
|
-
type: "ACK1",
|
|
326
|
-
methodPaths: c
|
|
327
|
-
};
|
|
328
|
-
a == null || a("Sending handshake ACK1", re);
|
|
329
|
-
try {
|
|
330
|
-
e.sendMessage(re);
|
|
331
|
-
} catch (Oe) {
|
|
332
|
-
M(new w("TRANSMISSION_FAILED", Oe.message));
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
}, de = (v) => {
|
|
336
|
-
a == null || a("Received handshake ACK1", v);
|
|
337
|
-
const _ = {
|
|
338
|
-
namespace: A,
|
|
339
|
-
channel: s,
|
|
340
|
-
type: "ACK2"
|
|
341
|
-
};
|
|
342
|
-
a == null || a("Sending handshake ACK2", _);
|
|
343
|
-
try {
|
|
344
|
-
e.sendMessage(_);
|
|
345
|
-
} catch (re) {
|
|
346
|
-
M(new w("TRANSMISSION_FAILED", re.message));
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
ee();
|
|
350
|
-
}, O = (v) => {
|
|
351
|
-
a == null || a("Received handshake ACK2", v), ee();
|
|
352
|
-
}, ue = (v) => {
|
|
353
|
-
W(v) && z(v), ie(v) && de(v), j(v) && O(v);
|
|
354
|
-
};
|
|
355
|
-
return e.addMessageHandler(ue), d.push(() => e.removeMessageHandler(ue)), te(), h;
|
|
356
|
-
}, lt = ht, ut = (e) => {
|
|
357
|
-
let t = !1, r;
|
|
358
|
-
return (...s) => (t || (t = !0, r = e(...s)), r);
|
|
359
|
-
}, ft = ut, we = /* @__PURE__ */ new WeakSet(), vt = ({
|
|
360
|
-
messenger: e,
|
|
361
|
-
methods: t = {},
|
|
362
|
-
timeout: r,
|
|
363
|
-
channel: s,
|
|
364
|
-
log: a
|
|
365
|
-
}) => {
|
|
366
|
-
if (!e)
|
|
367
|
-
throw new w("INVALID_ARGUMENT", "messenger must be defined");
|
|
368
|
-
if (we.has(e))
|
|
369
|
-
throw new w(
|
|
370
|
-
"INVALID_ARGUMENT",
|
|
371
|
-
"A messenger can only be used for a single connection"
|
|
372
|
-
);
|
|
373
|
-
we.add(e);
|
|
374
|
-
const i = [e.destroy], u = ft((c) => {
|
|
375
|
-
if (c) {
|
|
376
|
-
const h = {
|
|
377
|
-
namespace: A,
|
|
378
|
-
channel: s,
|
|
379
|
-
type: "DESTROY"
|
|
380
|
-
};
|
|
381
|
-
try {
|
|
382
|
-
e.sendMessage(h);
|
|
383
|
-
} catch {
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
for (const h of i)
|
|
387
|
-
h();
|
|
388
|
-
a == null || a("Connection destroyed");
|
|
389
|
-
}), d = (c) => Ke(c) && c.channel === s;
|
|
390
|
-
return {
|
|
391
|
-
promise: (async () => {
|
|
392
|
-
try {
|
|
393
|
-
e.initialize({ log: a, validateReceivedMessage: d }), e.addMessageHandler((I) => {
|
|
394
|
-
Ge(I) && u(!1);
|
|
395
|
-
});
|
|
396
|
-
const { remoteProxy: c, destroy: h } = await lt({
|
|
397
|
-
messenger: e,
|
|
398
|
-
methods: t,
|
|
399
|
-
timeout: r,
|
|
400
|
-
channel: s,
|
|
401
|
-
log: a
|
|
402
|
-
});
|
|
403
|
-
return i.push(h), c;
|
|
404
|
-
} catch (c) {
|
|
405
|
-
throw u(!0), c;
|
|
406
|
-
}
|
|
407
|
-
})(),
|
|
408
|
-
// Why we don't reject the connection promise when consumer calls destroy():
|
|
409
|
-
// https://github.com/Aaronius/penpal/issues/51
|
|
410
|
-
destroy: () => {
|
|
411
|
-
u(!0);
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
}, De = vt, g, k, U, V, L, C, E, T, se, Y, K, G, $, Pe, pt = (Pe = class {
|
|
415
|
-
constructor({ remoteWindow: e, allowedOrigins: t }) {
|
|
416
|
-
o(this, g);
|
|
417
|
-
o(this, k);
|
|
418
|
-
o(this, U);
|
|
419
|
-
o(this, V);
|
|
420
|
-
o(this, L);
|
|
421
|
-
o(this, C, /* @__PURE__ */ new Set());
|
|
422
|
-
o(this, E);
|
|
423
|
-
// TODO: Used for backward-compatibility. Remove in next major version.
|
|
424
|
-
o(this, T, !1);
|
|
425
|
-
l(this, "initialize", ({
|
|
426
|
-
log: e,
|
|
427
|
-
validateReceivedMessage: t
|
|
428
|
-
}) => {
|
|
429
|
-
p(this, U, e), p(this, V, t), window.addEventListener("message", n(this, G));
|
|
430
|
-
});
|
|
431
|
-
l(this, "sendMessage", (e, t) => {
|
|
432
|
-
if (W(e)) {
|
|
433
|
-
const r = n(this, Y).call(this, e);
|
|
434
|
-
n(this, g).postMessage(e, {
|
|
435
|
-
targetOrigin: r,
|
|
436
|
-
transfer: t
|
|
437
|
-
});
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
if (ie(e) || // If the child is using a previous version of Penpal, we need to
|
|
441
|
-
// downgrade the message and send it through the window rather than
|
|
442
|
-
// the port because older versions of Penpal don't use MessagePorts.
|
|
443
|
-
n(this, T)) {
|
|
444
|
-
const r = n(this, T) ? ct(e) : e, s = n(this, Y).call(this, e);
|
|
445
|
-
n(this, g).postMessage(r, {
|
|
446
|
-
targetOrigin: s,
|
|
447
|
-
transfer: t
|
|
448
|
-
});
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
if (j(e)) {
|
|
452
|
-
const { port1: r, port2: s } = new MessageChannel();
|
|
453
|
-
p(this, E, r), r.addEventListener("message", n(this, $)), r.start();
|
|
454
|
-
const a = [s, ...t || []], i = n(this, Y).call(this, e);
|
|
455
|
-
n(this, g).postMessage(e, {
|
|
456
|
-
targetOrigin: i,
|
|
457
|
-
transfer: a
|
|
458
|
-
});
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
if (n(this, E)) {
|
|
462
|
-
n(this, E).postMessage(e, {
|
|
463
|
-
transfer: t
|
|
464
|
-
});
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
467
|
-
throw new F("Port is undefined");
|
|
468
|
-
});
|
|
469
|
-
l(this, "addMessageHandler", (e) => {
|
|
470
|
-
n(this, C).add(e);
|
|
471
|
-
});
|
|
472
|
-
l(this, "removeMessageHandler", (e) => {
|
|
473
|
-
n(this, C).delete(e);
|
|
474
|
-
});
|
|
475
|
-
l(this, "destroy", () => {
|
|
476
|
-
window.removeEventListener("message", n(this, G)), n(this, K).call(this), n(this, C).clear();
|
|
477
|
-
});
|
|
478
|
-
o(this, se, (e) => n(this, k).some(
|
|
479
|
-
(t) => t instanceof RegExp ? t.test(e) : t === e || t === "*"
|
|
480
|
-
));
|
|
481
|
-
o(this, Y, (e) => {
|
|
482
|
-
if (W(e))
|
|
483
|
-
return "*";
|
|
484
|
-
if (!n(this, L))
|
|
485
|
-
throw new F("Concrete remote origin not set");
|
|
486
|
-
return n(this, L) === "null" && n(this, k).includes("*") ? "*" : n(this, L);
|
|
487
|
-
});
|
|
488
|
-
o(this, K, () => {
|
|
489
|
-
var e, t;
|
|
490
|
-
(e = n(this, E)) == null || e.removeEventListener("message", n(this, $)), (t = n(this, E)) == null || t.close(), p(this, E, void 0);
|
|
491
|
-
});
|
|
492
|
-
o(this, G, ({
|
|
493
|
-
source: e,
|
|
494
|
-
origin: t,
|
|
495
|
-
ports: r,
|
|
496
|
-
data: s
|
|
497
|
-
}) => {
|
|
498
|
-
var a, i, u;
|
|
499
|
-
if (e === n(this, g) && (it(s) && ((a = n(this, U)) == null || a.call(
|
|
500
|
-
this,
|
|
501
|
-
"Please upgrade the child window to the latest version of Penpal."
|
|
502
|
-
), p(this, T, !0), s = dt(s)), !!((i = n(this, V)) != null && i.call(this, s)))) {
|
|
503
|
-
if (!n(this, se).call(this, t)) {
|
|
504
|
-
(u = n(this, U)) == null || u.call(
|
|
505
|
-
this,
|
|
506
|
-
`Received a message from origin \`${t}\` which did not match allowed origins \`[${n(this, k).join(", ")}]\``
|
|
507
|
-
);
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
if (W(s) && (n(this, K).call(this), p(this, L, t)), j(s) && // Previous versions of Penpal don't use MessagePorts and do all
|
|
511
|
-
// communication through the window.
|
|
512
|
-
!n(this, T)) {
|
|
513
|
-
if (p(this, E, r[0]), !n(this, E))
|
|
514
|
-
throw new F("No port received on ACK2");
|
|
515
|
-
n(this, E).addEventListener("message", n(this, $)), n(this, E).start();
|
|
516
|
-
}
|
|
517
|
-
for (const d of n(this, C))
|
|
518
|
-
d(s);
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
o(this, $, ({ data: e }) => {
|
|
522
|
-
var t;
|
|
523
|
-
if ((t = n(this, V)) != null && t.call(this, e))
|
|
524
|
-
for (const r of n(this, C))
|
|
525
|
-
r(e);
|
|
526
|
-
});
|
|
527
|
-
if (!e)
|
|
528
|
-
throw new w("INVALID_ARGUMENT", "remoteWindow must be defined");
|
|
529
|
-
p(this, g, e), p(this, k, t != null && t.length ? t : [window.origin]);
|
|
530
|
-
}
|
|
531
|
-
}, g = new WeakMap(), k = new WeakMap(), U = new WeakMap(), V = new WeakMap(), L = new WeakMap(), C = new WeakMap(), E = new WeakMap(), T = new WeakMap(), se = new WeakMap(), Y = new WeakMap(), K = new WeakMap(), G = new WeakMap(), $ = new WeakMap(), Pe), He = pt, S, q, b, m, B, N, ge, Mt = (ge = class {
|
|
532
|
-
constructor({ worker: e }) {
|
|
533
|
-
o(this, S);
|
|
534
|
-
o(this, q);
|
|
535
|
-
o(this, b, /* @__PURE__ */ new Set());
|
|
536
|
-
o(this, m);
|
|
537
|
-
l(this, "initialize", ({ validateReceivedMessage: e }) => {
|
|
538
|
-
p(this, q, e), n(this, S).addEventListener("message", n(this, N));
|
|
539
|
-
});
|
|
540
|
-
l(this, "sendMessage", (e, t) => {
|
|
541
|
-
if (W(e) || ie(e)) {
|
|
542
|
-
n(this, S).postMessage(e, { transfer: t });
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
if (j(e)) {
|
|
546
|
-
const { port1: r, port2: s } = new MessageChannel();
|
|
547
|
-
p(this, m, r), r.addEventListener("message", n(this, N)), r.start(), n(this, S).postMessage(e, {
|
|
548
|
-
transfer: [s, ...t || []]
|
|
549
|
-
});
|
|
550
|
-
return;
|
|
551
|
-
}
|
|
552
|
-
if (n(this, m)) {
|
|
553
|
-
n(this, m).postMessage(e, {
|
|
554
|
-
transfer: t
|
|
555
|
-
});
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
throw new F("Port is undefined");
|
|
559
|
-
});
|
|
560
|
-
l(this, "addMessageHandler", (e) => {
|
|
561
|
-
n(this, b).add(e);
|
|
562
|
-
});
|
|
563
|
-
l(this, "removeMessageHandler", (e) => {
|
|
564
|
-
n(this, b).delete(e);
|
|
565
|
-
});
|
|
566
|
-
l(this, "destroy", () => {
|
|
567
|
-
n(this, S).removeEventListener("message", n(this, N)), n(this, B).call(this), n(this, b).clear();
|
|
568
|
-
});
|
|
569
|
-
o(this, B, () => {
|
|
570
|
-
var e, t;
|
|
571
|
-
(e = n(this, m)) == null || e.removeEventListener("message", n(this, N)), (t = n(this, m)) == null || t.close(), p(this, m, void 0);
|
|
572
|
-
});
|
|
573
|
-
o(this, N, ({ ports: e, data: t }) => {
|
|
574
|
-
var r;
|
|
575
|
-
if ((r = n(this, q)) != null && r.call(this, t)) {
|
|
576
|
-
if (W(t) && n(this, B).call(this), j(t)) {
|
|
577
|
-
if (p(this, m, e[0]), !n(this, m))
|
|
578
|
-
throw new F("No port received on ACK2");
|
|
579
|
-
n(this, m).addEventListener("message", n(this, N)), n(this, m).start();
|
|
580
|
-
}
|
|
581
|
-
for (const s of n(this, b))
|
|
582
|
-
s(t);
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
if (!e)
|
|
586
|
-
throw new w("INVALID_ARGUMENT", "worker must be defined");
|
|
587
|
-
p(this, S, e);
|
|
588
|
-
}
|
|
589
|
-
}, S = new WeakMap(), q = new WeakMap(), b = new WeakMap(), m = new WeakMap(), B = new WeakMap(), N = new WeakMap(), ge), xe = Mt, D, J, H, X, Ce, yt = (Ce = class {
|
|
590
|
-
constructor({ worker: e }) {
|
|
591
|
-
o(this, D);
|
|
592
|
-
o(this, J);
|
|
593
|
-
o(this, H, /* @__PURE__ */ new Set());
|
|
594
|
-
l(this, "initialize", ({ validateReceivedMessage: e }) => {
|
|
595
|
-
p(this, J, e), n(this, D).addListener("message", n(this, X));
|
|
596
|
-
});
|
|
597
|
-
l(this, "sendMessage", (e, t) => {
|
|
598
|
-
n(this, D).postMessage(e, t);
|
|
599
|
-
});
|
|
600
|
-
l(this, "addMessageHandler", (e) => {
|
|
601
|
-
n(this, H).add(e);
|
|
602
|
-
});
|
|
603
|
-
l(this, "removeMessageHandler", (e) => {
|
|
604
|
-
n(this, H).delete(e);
|
|
605
|
-
});
|
|
606
|
-
l(this, "destroy", () => {
|
|
607
|
-
n(this, D).removeListener("message", n(this, X)), n(this, H).clear();
|
|
608
|
-
});
|
|
609
|
-
o(this, X, (e) => {
|
|
610
|
-
var t;
|
|
611
|
-
if ((t = n(this, J)) != null && t.call(this, e))
|
|
612
|
-
for (const r of n(this, H))
|
|
613
|
-
r(e);
|
|
614
|
-
});
|
|
615
|
-
if (!e)
|
|
616
|
-
throw new w("INVALID_ARGUMENT", "worker must be defined");
|
|
617
|
-
p(this, D, e);
|
|
618
|
-
}
|
|
619
|
-
}, D = new WeakMap(), J = new WeakMap(), H = new WeakMap(), X = new WeakMap(), Ce), wt = yt, P, Q, x, Z, Se, Et = (Se = class {
|
|
620
|
-
constructor({ port: e }) {
|
|
621
|
-
o(this, P);
|
|
622
|
-
o(this, Q);
|
|
623
|
-
o(this, x, /* @__PURE__ */ new Set());
|
|
624
|
-
l(this, "initialize", ({ validateReceivedMessage: e }) => {
|
|
625
|
-
p(this, Q, e), n(this, P).addEventListener("message", n(this, Z)), n(this, P).start();
|
|
626
|
-
});
|
|
627
|
-
l(this, "sendMessage", (e, t) => {
|
|
628
|
-
var r;
|
|
629
|
-
(r = n(this, P)) == null || r.postMessage(e, {
|
|
630
|
-
transfer: t
|
|
631
|
-
});
|
|
632
|
-
});
|
|
633
|
-
l(this, "addMessageHandler", (e) => {
|
|
634
|
-
n(this, x).add(e);
|
|
635
|
-
});
|
|
636
|
-
l(this, "removeMessageHandler", (e) => {
|
|
637
|
-
n(this, x).delete(e);
|
|
638
|
-
});
|
|
639
|
-
l(this, "destroy", () => {
|
|
640
|
-
n(this, P).removeEventListener("message", n(this, Z)), n(this, P).close(), n(this, x).clear();
|
|
641
|
-
});
|
|
642
|
-
o(this, Z, ({ data: e }) => {
|
|
643
|
-
var t;
|
|
644
|
-
if ((t = n(this, Q)) != null && t.call(this, e))
|
|
645
|
-
for (const r of n(this, x))
|
|
646
|
-
r(e);
|
|
647
|
-
});
|
|
648
|
-
if (!e)
|
|
649
|
-
throw new w("INVALID_ARGUMENT", "port must be defined");
|
|
650
|
-
p(this, P, e);
|
|
651
|
-
}
|
|
652
|
-
}, P = new WeakMap(), Q = new WeakMap(), x = new WeakMap(), Z = new WeakMap(), Se), mt = Et;
|
|
653
|
-
const gt = (e, {
|
|
654
|
-
iframe: t,
|
|
655
|
-
worker: r,
|
|
656
|
-
webWorker: s
|
|
657
|
-
}) => {
|
|
658
|
-
let a;
|
|
659
|
-
if (t)
|
|
660
|
-
a = new He({
|
|
661
|
-
remoteWindow: t.contentWindow,
|
|
662
|
-
// Defaults to the current origin.
|
|
663
|
-
allowedOrigins: [
|
|
664
|
-
/^http:\/\/localhost(:\d+)/,
|
|
665
|
-
"https://extensions.archilogic.io",
|
|
666
|
-
"https://testing-extensions.archilogic.io"
|
|
667
|
-
]
|
|
668
|
-
// Alternatively,
|
|
669
|
-
// allowedOrigins: [new Url(iframe.src).origin]
|
|
670
|
-
});
|
|
671
|
-
else if (r)
|
|
672
|
-
a = new wt({ worker: r });
|
|
673
|
-
else if (s)
|
|
674
|
-
a = new xe({ worker: s });
|
|
675
|
-
else
|
|
676
|
-
throw new Error("No iframe or worker to connect to");
|
|
677
|
-
return De({
|
|
678
|
-
messenger: a,
|
|
679
|
-
// Methods the parent window is exposing to the iframe window.
|
|
680
|
-
methods: e
|
|
681
|
-
});
|
|
682
|
-
};
|
|
683
|
-
var ne = { exports: {} }, Ee;
|
|
684
|
-
function At() {
|
|
685
|
-
if (Ee) return ne.exports;
|
|
686
|
-
Ee = 1;
|
|
687
|
-
function e() {
|
|
688
|
-
}
|
|
689
|
-
return e.prototype = {
|
|
690
|
-
on: function(t, r, s) {
|
|
691
|
-
var a = this.e || (this.e = {});
|
|
692
|
-
return (a[t] || (a[t] = [])).push({
|
|
693
|
-
fn: r,
|
|
694
|
-
ctx: s
|
|
695
|
-
}), this;
|
|
696
|
-
},
|
|
697
|
-
once: function(t, r, s) {
|
|
698
|
-
var a = this;
|
|
699
|
-
function i() {
|
|
700
|
-
a.off(t, i), r.apply(s, arguments);
|
|
701
|
-
}
|
|
702
|
-
return i._ = r, this.on(t, i, s);
|
|
703
|
-
},
|
|
704
|
-
emit: function(t) {
|
|
705
|
-
var r = [].slice.call(arguments, 1), s = ((this.e || (this.e = {}))[t] || []).slice(), a = 0, i = s.length;
|
|
706
|
-
for (a; a < i; a++)
|
|
707
|
-
s[a].fn.apply(s[a].ctx, r);
|
|
708
|
-
return this;
|
|
709
|
-
},
|
|
710
|
-
off: function(t, r) {
|
|
711
|
-
var s = this.e || (this.e = {}), a = s[t], i = [];
|
|
712
|
-
if (a && r)
|
|
713
|
-
for (var u = 0, d = a.length; u < d; u++)
|
|
714
|
-
a[u].fn !== r && a[u].fn._ !== r && i.push(a[u]);
|
|
715
|
-
return i.length ? s[t] = i : delete s[t], this;
|
|
716
|
-
}
|
|
717
|
-
}, ne.exports = e, ne.exports.TinyEmitter = e, ne.exports;
|
|
718
|
-
}
|
|
719
|
-
var It = At();
|
|
720
|
-
const Ct = (e = {}, t) => {
|
|
721
|
-
let r;
|
|
722
|
-
const s = new It.TinyEmitter();
|
|
723
|
-
if ((t == null ? void 0 : t.useWorker) === "node") {
|
|
724
|
-
const d = require("node:worker_threads").parentPort;
|
|
725
|
-
if (!d)
|
|
726
|
-
throw new Error("No parent port found for worker thread");
|
|
727
|
-
r = new mt({ port: d });
|
|
728
|
-
} else (t == null ? void 0 : t.useWorker) === "web" ? r = new xe({ worker: self }) : r = new He({
|
|
729
|
-
remoteWindow: window.parent,
|
|
730
|
-
// Defaults to the current origin.
|
|
731
|
-
allowedOrigins: [
|
|
732
|
-
/^http:\/\/localhost(:\d+)/,
|
|
733
|
-
/^https:\/\/(.*)app.archilogic.com/,
|
|
734
|
-
/^https:\/\/(.*).archilogic-frontend.com/
|
|
735
|
-
]
|
|
736
|
-
});
|
|
737
|
-
const a = {
|
|
738
|
-
/**
|
|
739
|
-
* event handler for initial connection of the extension
|
|
740
|
-
* for a headless extension ( without UI ) the host will await this method before it terminates the extension
|
|
741
|
-
*/
|
|
742
|
-
onConnect: () => {
|
|
743
|
-
},
|
|
744
|
-
onDestroy: () => {
|
|
745
|
-
},
|
|
746
|
-
...e,
|
|
747
|
-
onLayoutChange: (d) => {
|
|
748
|
-
s.emit("layout-change", d);
|
|
749
|
-
},
|
|
750
|
-
onSelectionChange: (d) => {
|
|
751
|
-
s.emit("selection-change", d);
|
|
752
|
-
},
|
|
753
|
-
onGraphicDrag: (d) => {
|
|
754
|
-
s.emit("graphic-crag", d);
|
|
755
|
-
},
|
|
756
|
-
onCanvasClick: (d) => {
|
|
757
|
-
s.emit("canvas-click", d);
|
|
758
|
-
}
|
|
759
|
-
}, i = De({
|
|
760
|
-
messenger: r,
|
|
761
|
-
methods: a
|
|
762
|
-
});
|
|
763
|
-
return new Proxy(
|
|
764
|
-
{},
|
|
765
|
-
{
|
|
766
|
-
get(d, f) {
|
|
767
|
-
return f === "on" ? s.on.bind(s) : f === "once" ? s.once.bind(s) : f === "off" ? s.off.bind(s) : async (...c) => (await i.promise)[f](...c);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
);
|
|
771
|
-
};
|
|
772
|
-
export {
|
|
773
|
-
gt as createExtensionConnection,
|
|
774
|
-
Ct as createHostConnection
|
|
775
|
-
};
|