bb-relay 0.0.32 → 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{FileContent-BWulmcoi.d.mts → FileContent-CXlulSZq.d.mts} +1 -0
- package/dist/{FileContent-BWulmcoi.d.ts → FileContent-CXlulSZq.d.ts} +1 -0
- package/dist/{Locale-DvFwr_9k.d.mts → Locale-DnNmuMZq.d.mts} +2 -0
- package/dist/{Locale-DvFwr_9k.d.ts → Locale-DnNmuMZq.d.ts} +2 -0
- package/dist/{EventReturn-CGAZ-l1W.d.mts → RequestReturn-Clb_WcNj.d.ts} +31 -13
- package/dist/{EventReturn-CXACStVQ.d.ts → RequestReturn-Dahl-hde.d.mts} +31 -13
- package/dist/api.d.mts +12 -6
- package/dist/api.d.ts +12 -6
- package/dist/editor.d.mts +3 -2
- package/dist/editor.d.ts +3 -2
- package/dist/index.d.mts +12 -16
- package/dist/index.d.ts +12 -16
- package/dist/index.js +59 -60
- package/dist/index.mjs +58 -59
- package/dist/locale.d.mts +2 -2
- package/dist/locale.d.ts +2 -2
- package/dist/locale.js +6 -2
- package/dist/locale.mjs +6 -2
- package/dist/plugin.d.mts +4 -3
- package/dist/plugin.d.ts +4 -3
- package/dist/plugin.js +3 -3
- package/dist/plugin.mjs +2 -2
- package/package.json +1 -1
- package/src/api.ts +11 -1
- package/src/index.ts +5 -5
- package/src/lib/plugin/ElementInstruction/InputInstruction.ts +1 -1
- package/src/lib/plugin/index.ts +8 -4
- package/src/lib/validate-manifest/index.ts +1 -5
- package/src/locales/en-GB.ts +168 -166
- package/src/locales/fr-FR.ts +171 -169
- package/src/relay/postEventResponse.ts +0 -2
- package/src/relay/postRequestResponse.ts +14 -0
- package/src/relay/registerEvent.ts +8 -3
- package/src/relay/registerRequest.ts +35 -0
- package/src/relay/request.ts +19 -0
- package/src/relay/subscribe.ts +20 -0
- package/src/types/api/EventParam.ts +1 -2
- package/src/types/api/EventReturn.ts +0 -2
- package/src/types/api/RelayEvent.ts +1 -7
- package/src/types/api/RequestParam.ts +10 -0
- package/src/types/api/RequestReturn.ts +9 -0
- package/src/types/editor/FileContent.ts +10 -6
- package/src/types/editor/Load.ts +1 -2
- package/src/types/editor/Manifest.ts +2 -4
- package/src/types/editor/Settings.ts +44 -43
- package/src/relay/index.ts +0 -61
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { F as FileContent } from './FileContent-
|
|
1
|
+
import { F as FileContent } from './FileContent-CXlulSZq.js';
|
|
2
2
|
|
|
3
3
|
type Load = {
|
|
4
|
-
|
|
5
|
-
theme: "light" | "dark";
|
|
4
|
+
theme: string;
|
|
6
5
|
languages: string[];
|
|
7
6
|
};
|
|
8
7
|
|
|
@@ -11,7 +10,7 @@ type RelayEvent = {
|
|
|
11
10
|
* Indicate change in theme
|
|
12
11
|
*/
|
|
13
12
|
theme: {
|
|
14
|
-
response:
|
|
13
|
+
response: string;
|
|
15
14
|
};
|
|
16
15
|
/**
|
|
17
16
|
* Indicate that the iframe is loaded and ready to receive instructions
|
|
@@ -22,12 +21,6 @@ type RelayEvent = {
|
|
|
22
21
|
load: {
|
|
23
22
|
response: Load;
|
|
24
23
|
};
|
|
25
|
-
/**
|
|
26
|
-
* The style of the editor
|
|
27
|
-
*/
|
|
28
|
-
style: {
|
|
29
|
-
response: string;
|
|
30
|
-
};
|
|
31
24
|
/**
|
|
32
25
|
* The language of the editor
|
|
33
26
|
*/
|
|
@@ -55,8 +48,33 @@ type RelayEvent = {
|
|
|
55
48
|
interface EventReturn<K extends keyof RelayEvent> {
|
|
56
49
|
type: K;
|
|
57
50
|
response: RelayEvent[K]["response"];
|
|
58
|
-
responseId: string;
|
|
59
|
-
source: "event";
|
|
60
51
|
}
|
|
61
52
|
|
|
62
|
-
|
|
53
|
+
type RelayRequest = {
|
|
54
|
+
/**
|
|
55
|
+
* Updates the content of the current file
|
|
56
|
+
* Note, type is not stated, it would use the one stated in manifest
|
|
57
|
+
*/
|
|
58
|
+
update: {
|
|
59
|
+
args: {
|
|
60
|
+
content: string;
|
|
61
|
+
};
|
|
62
|
+
response: {
|
|
63
|
+
error: string | null;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
ping: {
|
|
67
|
+
args: unknown;
|
|
68
|
+
response: {
|
|
69
|
+
data: unknown | null;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
interface RequestReturn<K extends keyof RelayRequest> {
|
|
75
|
+
type: K;
|
|
76
|
+
response: RelayRequest[K]["response"];
|
|
77
|
+
id: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type { EventReturn as E, RelayEvent as R, RelayRequest as a, RequestReturn as b };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { F as FileContent } from './FileContent-
|
|
1
|
+
import { F as FileContent } from './FileContent-CXlulSZq.mjs';
|
|
2
2
|
|
|
3
3
|
type Load = {
|
|
4
|
-
|
|
5
|
-
theme: "light" | "dark";
|
|
4
|
+
theme: string;
|
|
6
5
|
languages: string[];
|
|
7
6
|
};
|
|
8
7
|
|
|
@@ -11,7 +10,7 @@ type RelayEvent = {
|
|
|
11
10
|
* Indicate change in theme
|
|
12
11
|
*/
|
|
13
12
|
theme: {
|
|
14
|
-
response:
|
|
13
|
+
response: string;
|
|
15
14
|
};
|
|
16
15
|
/**
|
|
17
16
|
* Indicate that the iframe is loaded and ready to receive instructions
|
|
@@ -22,12 +21,6 @@ type RelayEvent = {
|
|
|
22
21
|
load: {
|
|
23
22
|
response: Load;
|
|
24
23
|
};
|
|
25
|
-
/**
|
|
26
|
-
* The style of the editor
|
|
27
|
-
*/
|
|
28
|
-
style: {
|
|
29
|
-
response: string;
|
|
30
|
-
};
|
|
31
24
|
/**
|
|
32
25
|
* The language of the editor
|
|
33
26
|
*/
|
|
@@ -55,8 +48,33 @@ type RelayEvent = {
|
|
|
55
48
|
interface EventReturn<K extends keyof RelayEvent> {
|
|
56
49
|
type: K;
|
|
57
50
|
response: RelayEvent[K]["response"];
|
|
58
|
-
responseId: string;
|
|
59
|
-
source: "event";
|
|
60
51
|
}
|
|
61
52
|
|
|
62
|
-
|
|
53
|
+
type RelayRequest = {
|
|
54
|
+
/**
|
|
55
|
+
* Updates the content of the current file
|
|
56
|
+
* Note, type is not stated, it would use the one stated in manifest
|
|
57
|
+
*/
|
|
58
|
+
update: {
|
|
59
|
+
args: {
|
|
60
|
+
content: string;
|
|
61
|
+
};
|
|
62
|
+
response: {
|
|
63
|
+
error: string | null;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
ping: {
|
|
67
|
+
args: unknown;
|
|
68
|
+
response: {
|
|
69
|
+
data: unknown | null;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
interface RequestReturn<K extends keyof RelayRequest> {
|
|
75
|
+
type: K;
|
|
76
|
+
response: RelayRequest[K]["response"];
|
|
77
|
+
id: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type { EventReturn as E, RelayEvent as R, RelayRequest as a, RequestReturn as b };
|
package/dist/api.d.mts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { R as RelayEvent } from './
|
|
2
|
-
export { E as EventReturn } from './
|
|
3
|
-
import './FileContent-
|
|
1
|
+
import { R as RelayEvent, a as RelayRequest } from './RequestReturn-Dahl-hde.mjs';
|
|
2
|
+
export { E as EventReturn, b as RequestReturn } from './RequestReturn-Dahl-hde.mjs';
|
|
3
|
+
import './FileContent-CXlulSZq.mjs';
|
|
4
4
|
|
|
5
5
|
type EventParam<K extends keyof RelayEvent> = {
|
|
6
|
-
id: string;
|
|
7
6
|
type: K;
|
|
8
|
-
source: "event";
|
|
7
|
+
source: "event" | "unsubscribe";
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type RequestParam<K extends keyof RelayRequest> = {
|
|
11
|
+
type: K;
|
|
12
|
+
source: "request";
|
|
13
|
+
id: string;
|
|
14
|
+
arg: RelayRequest[K]["args"];
|
|
9
15
|
};
|
|
10
16
|
|
|
11
|
-
export { type EventParam, RelayEvent };
|
|
17
|
+
export { type EventParam, RelayEvent, RelayRequest, type RequestParam };
|
package/dist/api.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { R as RelayEvent } from './
|
|
2
|
-
export { E as EventReturn } from './
|
|
3
|
-
import './FileContent-
|
|
1
|
+
import { R as RelayEvent, a as RelayRequest } from './RequestReturn-Clb_WcNj.js';
|
|
2
|
+
export { E as EventReturn, b as RequestReturn } from './RequestReturn-Clb_WcNj.js';
|
|
3
|
+
import './FileContent-CXlulSZq.js';
|
|
4
4
|
|
|
5
5
|
type EventParam<K extends keyof RelayEvent> = {
|
|
6
|
-
id: string;
|
|
7
6
|
type: K;
|
|
8
|
-
source: "event";
|
|
7
|
+
source: "event" | "unsubscribe";
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type RequestParam<K extends keyof RelayRequest> = {
|
|
11
|
+
type: K;
|
|
12
|
+
source: "request";
|
|
13
|
+
id: string;
|
|
14
|
+
arg: RelayRequest[K]["args"];
|
|
9
15
|
};
|
|
10
16
|
|
|
11
|
-
export { type EventParam, RelayEvent };
|
|
17
|
+
export { type EventParam, RelayEvent, RelayRequest, type RequestParam };
|
package/dist/editor.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { C as Commit } from './Commit-PdsjrKSG.mjs';
|
|
2
2
|
export { a as FileStat, F as FolderContent, b as FolderStat } from './FolderStat-Bhmwwc0t.mjs';
|
|
3
|
-
export { F as FileContent } from './FileContent-
|
|
4
|
-
import { L as Language, a as Locale } from './Locale-
|
|
3
|
+
export { F as FileContent } from './FileContent-CXlulSZq.mjs';
|
|
4
|
+
import { L as Language, a as Locale } from './Locale-DnNmuMZq.mjs';
|
|
5
5
|
export { R as Result } from './Result-BLbZLEgX.mjs';
|
|
6
6
|
|
|
7
7
|
type CopyArg = {
|
|
@@ -52,6 +52,7 @@ type Settings = {
|
|
|
52
52
|
trashBehaviour: "permanent" | "trash";
|
|
53
53
|
shortcuts: Shortcut[];
|
|
54
54
|
theme: string;
|
|
55
|
+
isDev: boolean;
|
|
55
56
|
/**
|
|
56
57
|
* { [fileExtension: string]: pluginId }
|
|
57
58
|
*/
|
package/dist/editor.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { C as Commit } from './Commit-PdsjrKSG.js';
|
|
2
2
|
export { a as FileStat, F as FolderContent, b as FolderStat } from './FolderStat-Bhmwwc0t.js';
|
|
3
|
-
export { F as FileContent } from './FileContent-
|
|
4
|
-
import { L as Language, a as Locale } from './Locale-
|
|
3
|
+
export { F as FileContent } from './FileContent-CXlulSZq.js';
|
|
4
|
+
import { L as Language, a as Locale } from './Locale-DnNmuMZq.js';
|
|
5
5
|
export { R as Result } from './Result-BLbZLEgX.js';
|
|
6
6
|
|
|
7
7
|
type CopyArg = {
|
|
@@ -52,6 +52,7 @@ type Settings = {
|
|
|
52
52
|
trashBehaviour: "permanent" | "trash";
|
|
53
53
|
shortcuts: Shortcut[];
|
|
54
54
|
theme: string;
|
|
55
|
+
isDev: boolean;
|
|
55
56
|
/**
|
|
56
57
|
* { [fileExtension: string]: pluginId }
|
|
57
58
|
*/
|
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { F as FileContent } from './FileContent-BWulmcoi.mjs';
|
|
1
|
+
import { F as FileContent } from './FileContent-CXlulSZq.mjs';
|
|
3
2
|
export { R as Result } from './Result-BLbZLEgX.mjs';
|
|
4
3
|
import { P as Plugin } from './Plugin-Db_XUKx0.mjs';
|
|
4
|
+
import { R as RelayEvent, E as EventReturn, a as RelayRequest, b as RequestReturn } from './RequestReturn-Dahl-hde.mjs';
|
|
5
5
|
import './Wrapper-DWhYVa7F.mjs';
|
|
6
6
|
|
|
7
|
-
declare class Relay {
|
|
8
|
-
private eventCallbacks;
|
|
9
|
-
handleEvent<K extends keyof RelayEvent>(data: EventReturn<K>): void;
|
|
10
|
-
init: () => void;
|
|
11
|
-
constructor();
|
|
12
|
-
subscribe<K extends keyof RelayEvent>(type: K, callback: (response: RelayEvent[K]["response"]) => void): () => void;
|
|
13
|
-
destroy(): void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
7
|
/**
|
|
17
8
|
* This is the function to inject styles to the iframe from the parent window
|
|
18
9
|
* @param css the css styles from parent window
|
|
@@ -35,6 +26,7 @@ type Manifest = {
|
|
|
35
26
|
path: string;
|
|
36
27
|
type: FileContent["type"];
|
|
37
28
|
extensions: string[];
|
|
29
|
+
icon?: string;
|
|
38
30
|
};
|
|
39
31
|
permissions: Permission[];
|
|
40
32
|
iconsPath?: string;
|
|
@@ -43,10 +35,7 @@ type Manifest = {
|
|
|
43
35
|
author?: string;
|
|
44
36
|
homepage?: string;
|
|
45
37
|
repository?: string;
|
|
46
|
-
theme?:
|
|
47
|
-
name: string;
|
|
48
|
-
path: string;
|
|
49
|
-
};
|
|
38
|
+
theme?: string;
|
|
50
39
|
[key: string]: unknown;
|
|
51
40
|
};
|
|
52
41
|
|
|
@@ -78,4 +67,11 @@ declare function validateUpload(manifest: Manifest, plugin: Plugin["doc"]): bool
|
|
|
78
67
|
type BBEventKey = keyof RelayEvent;
|
|
79
68
|
declare function postEventResponse<K extends BBEventKey>(window: Window, response: Omit<EventReturn<K>, "source" | "responseId">): void;
|
|
80
69
|
|
|
81
|
-
|
|
70
|
+
declare function subscribe<K extends keyof RelayEvent>(type: K, callback: (response: RelayEvent[K]["response"]) => void): () => void;
|
|
71
|
+
|
|
72
|
+
type BBRequestKey = keyof RelayRequest;
|
|
73
|
+
declare function postRequestResponse<K extends BBRequestKey>(window: Window, response: RequestReturn<K>): void;
|
|
74
|
+
|
|
75
|
+
declare function request<K extends keyof RelayRequest>(type: K, arg: RelayRequest[K]["args"], callback?: (response: RelayRequest[K]["response"]) => void): void;
|
|
76
|
+
|
|
77
|
+
export { type FileNode, type Manifest, type Zip, extractStyles, injectStyles, postEventResponse, postRequestResponse, request, subscribe, validateManifest, validateUpload };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { F as FileContent } from './FileContent-BWulmcoi.js';
|
|
1
|
+
import { F as FileContent } from './FileContent-CXlulSZq.js';
|
|
3
2
|
export { R as Result } from './Result-BLbZLEgX.js';
|
|
4
3
|
import { P as Plugin } from './Plugin-t8StCIag.js';
|
|
4
|
+
import { R as RelayEvent, E as EventReturn, a as RelayRequest, b as RequestReturn } from './RequestReturn-Clb_WcNj.js';
|
|
5
5
|
import './Wrapper-DWhYVa7F.js';
|
|
6
6
|
|
|
7
|
-
declare class Relay {
|
|
8
|
-
private eventCallbacks;
|
|
9
|
-
handleEvent<K extends keyof RelayEvent>(data: EventReturn<K>): void;
|
|
10
|
-
init: () => void;
|
|
11
|
-
constructor();
|
|
12
|
-
subscribe<K extends keyof RelayEvent>(type: K, callback: (response: RelayEvent[K]["response"]) => void): () => void;
|
|
13
|
-
destroy(): void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
7
|
/**
|
|
17
8
|
* This is the function to inject styles to the iframe from the parent window
|
|
18
9
|
* @param css the css styles from parent window
|
|
@@ -35,6 +26,7 @@ type Manifest = {
|
|
|
35
26
|
path: string;
|
|
36
27
|
type: FileContent["type"];
|
|
37
28
|
extensions: string[];
|
|
29
|
+
icon?: string;
|
|
38
30
|
};
|
|
39
31
|
permissions: Permission[];
|
|
40
32
|
iconsPath?: string;
|
|
@@ -43,10 +35,7 @@ type Manifest = {
|
|
|
43
35
|
author?: string;
|
|
44
36
|
homepage?: string;
|
|
45
37
|
repository?: string;
|
|
46
|
-
theme?:
|
|
47
|
-
name: string;
|
|
48
|
-
path: string;
|
|
49
|
-
};
|
|
38
|
+
theme?: string;
|
|
50
39
|
[key: string]: unknown;
|
|
51
40
|
};
|
|
52
41
|
|
|
@@ -78,4 +67,11 @@ declare function validateUpload(manifest: Manifest, plugin: Plugin["doc"]): bool
|
|
|
78
67
|
type BBEventKey = keyof RelayEvent;
|
|
79
68
|
declare function postEventResponse<K extends BBEventKey>(window: Window, response: Omit<EventReturn<K>, "source" | "responseId">): void;
|
|
80
69
|
|
|
81
|
-
|
|
70
|
+
declare function subscribe<K extends keyof RelayEvent>(type: K, callback: (response: RelayEvent[K]["response"]) => void): () => void;
|
|
71
|
+
|
|
72
|
+
type BBRequestKey = keyof RelayRequest;
|
|
73
|
+
declare function postRequestResponse<K extends BBRequestKey>(window: Window, response: RequestReturn<K>): void;
|
|
74
|
+
|
|
75
|
+
declare function request<K extends keyof RelayRequest>(type: K, arg: RelayRequest[K]["args"], callback?: (response: RelayRequest[K]["response"]) => void): void;
|
|
76
|
+
|
|
77
|
+
export { type FileNode, type Manifest, type Zip, extractStyles, injectStyles, postEventResponse, postRequestResponse, request, subscribe, validateManifest, validateUpload };
|
package/dist/index.js
CHANGED
|
@@ -1,52 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
2
|
-
function registerEvent(event) {
|
|
3
|
-
if (!window) throw new Error("Window not found");
|
|
4
|
-
if (window === window.parent) throw new Error("No parent window available");
|
|
5
|
-
window.parent.postMessage({ ...event, source: "event" }, "*");
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// src/relay/index.ts
|
|
9
|
-
var Relay = class {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.eventCallbacks = /* @__PURE__ */ new Map();
|
|
12
|
-
this.init = () => {
|
|
13
|
-
window.addEventListener("message", (event) => {
|
|
14
|
-
this.handleEvent(event.data);
|
|
15
|
-
});
|
|
16
|
-
window.addEventListener("unload", () => {
|
|
17
|
-
this.destroy();
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
this.init();
|
|
21
|
-
}
|
|
22
|
-
handleEvent(data) {
|
|
23
|
-
if (data.source !== "event") return;
|
|
24
|
-
for (const [, { type, callback }] of this.eventCallbacks) {
|
|
25
|
-
const { response } = data;
|
|
26
|
-
if (type === data.type) {
|
|
27
|
-
callback(response);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
subscribe(type, callback) {
|
|
33
|
-
const id = crypto.randomUUID();
|
|
34
|
-
this.eventCallbacks.set(id, {
|
|
35
|
-
type,
|
|
36
|
-
callback
|
|
37
|
-
});
|
|
38
|
-
registerEvent({ type, id, source: "event" });
|
|
39
|
-
return () => {
|
|
40
|
-
this.eventCallbacks.delete(id);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
destroy() {
|
|
44
|
-
this.eventCallbacks.clear();
|
|
45
|
-
window.removeEventListener("message", this.init);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// src/utils/inject-styles.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/utils/inject-styles.ts
|
|
50
2
|
function injectStyles(css) {
|
|
51
3
|
const style = document.createElement("style");
|
|
52
4
|
style.textContent = css;
|
|
@@ -80,8 +32,6 @@ var validateManifest = (manifestContent) => {
|
|
|
80
32
|
errors.push("Manifest permissions is missing");
|
|
81
33
|
} else if (!Array.isArray(content.permissions)) {
|
|
82
34
|
errors.push("Manifest permissions is not an array");
|
|
83
|
-
} else if (content.permissions.length === 0) {
|
|
84
|
-
errors.push("Manifest permissions is empty");
|
|
85
35
|
}
|
|
86
36
|
if (content.main) {
|
|
87
37
|
if (!content.main.path) {
|
|
@@ -116,9 +66,7 @@ var validateManifest = (manifestContent) => {
|
|
|
116
66
|
} else fileChecks.push(content.entry);
|
|
117
67
|
}
|
|
118
68
|
if (content.theme) {
|
|
119
|
-
|
|
120
|
-
if (!content.theme.path) errors.push("No css file path provided");
|
|
121
|
-
else fileChecks.push(content.theme.path);
|
|
69
|
+
fileChecks.push(content.theme);
|
|
122
70
|
}
|
|
123
71
|
return {
|
|
124
72
|
errors,
|
|
@@ -157,15 +105,66 @@ function validateUpload(manifest, plugin) {
|
|
|
157
105
|
// src/relay/postEventResponse.ts
|
|
158
106
|
function postEventResponse(window2, response) {
|
|
159
107
|
const res = {
|
|
160
|
-
...response
|
|
161
|
-
source: "event",
|
|
162
|
-
responseId: crypto.randomUUID()
|
|
108
|
+
...response
|
|
163
109
|
};
|
|
164
110
|
window2.postMessage(res, "*");
|
|
165
111
|
}
|
|
166
112
|
|
|
167
|
-
// src/
|
|
168
|
-
|
|
113
|
+
// src/relay/registerEvent.ts
|
|
114
|
+
function registerEvent(type, unsubscribe) {
|
|
115
|
+
if (!window) throw new Error("Window not found");
|
|
116
|
+
if (window === window.parent) throw new Error("No parent window available");
|
|
117
|
+
const message = {
|
|
118
|
+
type,
|
|
119
|
+
source: unsubscribe ? "unsubscribe" : "event"
|
|
120
|
+
};
|
|
121
|
+
window.parent.postMessage(message, "*");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/relay/subscribe.ts
|
|
125
|
+
function subscribe(type, callback) {
|
|
126
|
+
registerEvent(type);
|
|
127
|
+
window.addEventListener("message", (ev) => {
|
|
128
|
+
const data = ev.data;
|
|
129
|
+
const { response } = data;
|
|
130
|
+
if (type === data.type) {
|
|
131
|
+
callback(response);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
return () => {
|
|
135
|
+
registerEvent(type, true);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/relay/postRequestResponse.ts
|
|
140
|
+
function postRequestResponse(window2, response) {
|
|
141
|
+
const res = {
|
|
142
|
+
...response
|
|
143
|
+
};
|
|
144
|
+
window2.postMessage(res, "*");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/relay/registerRequest.ts
|
|
148
|
+
function registerRequest(request2) {
|
|
149
|
+
if (!window) throw new Error("Window not found");
|
|
150
|
+
if (window === window.parent) throw new Error("No parent window available");
|
|
151
|
+
window.parent.postMessage({ ...request2, source: "request" }, "*");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/relay/request.ts
|
|
155
|
+
function request(type, arg, callback) {
|
|
156
|
+
const id = crypto.randomUUID();
|
|
157
|
+
registerRequest({ type, id, arg, source: "request" });
|
|
158
|
+
window.addEventListener("message", (ev) => {
|
|
159
|
+
const data = ev.data;
|
|
160
|
+
const { response } = data;
|
|
161
|
+
if (type === data.type && id === data.id) {
|
|
162
|
+
_optionalChain([callback, 'optionalCall', _ => _(response)]);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
|
|
169
168
|
|
|
170
169
|
|
|
171
170
|
|
|
@@ -173,4 +172,4 @@ var index_default = Relay;
|
|
|
173
172
|
|
|
174
173
|
|
|
175
174
|
|
|
176
|
-
exports.
|
|
175
|
+
exports.extractStyles = extract_styles_default; exports.injectStyles = injectStyles; exports.postEventResponse = postEventResponse; exports.postRequestResponse = postRequestResponse; exports.request = request; exports.subscribe = subscribe; exports.validateManifest = validate_manifest_default; exports.validateUpload = validateUpload;
|
package/dist/index.mjs
CHANGED
|
@@ -1,51 +1,3 @@
|
|
|
1
|
-
// src/relay/registerEvent.ts
|
|
2
|
-
function registerEvent(event) {
|
|
3
|
-
if (!window) throw new Error("Window not found");
|
|
4
|
-
if (window === window.parent) throw new Error("No parent window available");
|
|
5
|
-
window.parent.postMessage({ ...event, source: "event" }, "*");
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// src/relay/index.ts
|
|
9
|
-
var Relay = class {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.eventCallbacks = /* @__PURE__ */ new Map();
|
|
12
|
-
this.init = () => {
|
|
13
|
-
window.addEventListener("message", (event) => {
|
|
14
|
-
this.handleEvent(event.data);
|
|
15
|
-
});
|
|
16
|
-
window.addEventListener("unload", () => {
|
|
17
|
-
this.destroy();
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
this.init();
|
|
21
|
-
}
|
|
22
|
-
handleEvent(data) {
|
|
23
|
-
if (data.source !== "event") return;
|
|
24
|
-
for (const [, { type, callback }] of this.eventCallbacks) {
|
|
25
|
-
const { response } = data;
|
|
26
|
-
if (type === data.type) {
|
|
27
|
-
callback(response);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
subscribe(type, callback) {
|
|
33
|
-
const id = crypto.randomUUID();
|
|
34
|
-
this.eventCallbacks.set(id, {
|
|
35
|
-
type,
|
|
36
|
-
callback
|
|
37
|
-
});
|
|
38
|
-
registerEvent({ type, id, source: "event" });
|
|
39
|
-
return () => {
|
|
40
|
-
this.eventCallbacks.delete(id);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
destroy() {
|
|
44
|
-
this.eventCallbacks.clear();
|
|
45
|
-
window.removeEventListener("message", this.init);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
1
|
// src/utils/inject-styles.ts
|
|
50
2
|
function injectStyles(css) {
|
|
51
3
|
const style = document.createElement("style");
|
|
@@ -80,8 +32,6 @@ var validateManifest = (manifestContent) => {
|
|
|
80
32
|
errors.push("Manifest permissions is missing");
|
|
81
33
|
} else if (!Array.isArray(content.permissions)) {
|
|
82
34
|
errors.push("Manifest permissions is not an array");
|
|
83
|
-
} else if (content.permissions.length === 0) {
|
|
84
|
-
errors.push("Manifest permissions is empty");
|
|
85
35
|
}
|
|
86
36
|
if (content.main) {
|
|
87
37
|
if (!content.main.path) {
|
|
@@ -116,9 +66,7 @@ var validateManifest = (manifestContent) => {
|
|
|
116
66
|
} else fileChecks.push(content.entry);
|
|
117
67
|
}
|
|
118
68
|
if (content.theme) {
|
|
119
|
-
|
|
120
|
-
if (!content.theme.path) errors.push("No css file path provided");
|
|
121
|
-
else fileChecks.push(content.theme.path);
|
|
69
|
+
fileChecks.push(content.theme);
|
|
122
70
|
}
|
|
123
71
|
return {
|
|
124
72
|
errors,
|
|
@@ -157,20 +105,71 @@ function validateUpload(manifest, plugin) {
|
|
|
157
105
|
// src/relay/postEventResponse.ts
|
|
158
106
|
function postEventResponse(window2, response) {
|
|
159
107
|
const res = {
|
|
160
|
-
...response
|
|
161
|
-
source: "event",
|
|
162
|
-
responseId: crypto.randomUUID()
|
|
108
|
+
...response
|
|
163
109
|
};
|
|
164
110
|
window2.postMessage(res, "*");
|
|
165
111
|
}
|
|
166
112
|
|
|
167
|
-
// src/
|
|
168
|
-
|
|
113
|
+
// src/relay/registerEvent.ts
|
|
114
|
+
function registerEvent(type, unsubscribe) {
|
|
115
|
+
if (!window) throw new Error("Window not found");
|
|
116
|
+
if (window === window.parent) throw new Error("No parent window available");
|
|
117
|
+
const message = {
|
|
118
|
+
type,
|
|
119
|
+
source: unsubscribe ? "unsubscribe" : "event"
|
|
120
|
+
};
|
|
121
|
+
window.parent.postMessage(message, "*");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/relay/subscribe.ts
|
|
125
|
+
function subscribe(type, callback) {
|
|
126
|
+
registerEvent(type);
|
|
127
|
+
window.addEventListener("message", (ev) => {
|
|
128
|
+
const data = ev.data;
|
|
129
|
+
const { response } = data;
|
|
130
|
+
if (type === data.type) {
|
|
131
|
+
callback(response);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
return () => {
|
|
135
|
+
registerEvent(type, true);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/relay/postRequestResponse.ts
|
|
140
|
+
function postRequestResponse(window2, response) {
|
|
141
|
+
const res = {
|
|
142
|
+
...response
|
|
143
|
+
};
|
|
144
|
+
window2.postMessage(res, "*");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/relay/registerRequest.ts
|
|
148
|
+
function registerRequest(request2) {
|
|
149
|
+
if (!window) throw new Error("Window not found");
|
|
150
|
+
if (window === window.parent) throw new Error("No parent window available");
|
|
151
|
+
window.parent.postMessage({ ...request2, source: "request" }, "*");
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/relay/request.ts
|
|
155
|
+
function request(type, arg, callback) {
|
|
156
|
+
const id = crypto.randomUUID();
|
|
157
|
+
registerRequest({ type, id, arg, source: "request" });
|
|
158
|
+
window.addEventListener("message", (ev) => {
|
|
159
|
+
const data = ev.data;
|
|
160
|
+
const { response } = data;
|
|
161
|
+
if (type === data.type && id === data.id) {
|
|
162
|
+
callback?.(response);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
}
|
|
169
166
|
export {
|
|
170
|
-
index_default as default,
|
|
171
167
|
extract_styles_default as extractStyles,
|
|
172
168
|
injectStyles,
|
|
173
169
|
postEventResponse,
|
|
170
|
+
postRequestResponse,
|
|
171
|
+
request,
|
|
172
|
+
subscribe,
|
|
174
173
|
validate_manifest_default as validateManifest,
|
|
175
174
|
validateUpload
|
|
176
175
|
};
|
package/dist/locale.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as Language } from './Locale-
|
|
2
|
-
export { a as Locale, e as enGB } from './Locale-
|
|
1
|
+
import { L as Language } from './Locale-DnNmuMZq.mjs';
|
|
2
|
+
export { a as Locale, e as enGB } from './Locale-DnNmuMZq.mjs';
|
|
3
3
|
|
|
4
4
|
declare const frFR: {
|
|
5
5
|
[key in Language]: string;
|