@moloodev/editor-sdk 0.6.0 → 0.7.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/package.json +4 -4
- package/src/editor-id.ts +5 -21
- package/src/protocol.ts +0 -2
- package/src/view.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moloodev/editor-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/view.ts",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"y-protocols": "^1.0.7",
|
|
30
30
|
"yjs": "^13.6.32",
|
|
31
31
|
"zod": "^4.5.4",
|
|
32
|
-
"@moloodev/platform": "0.
|
|
33
|
-
"@moloodev/ui": "0.
|
|
32
|
+
"@moloodev/platform": "0.7.0",
|
|
33
|
+
"@moloodev/ui": "0.7.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": "^19.0.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"react-dom": "^19.2.8",
|
|
49
49
|
"tsx": "^4.23.13",
|
|
50
50
|
"typescript": "^7.0.2",
|
|
51
|
-
"@moloodev/typescript-config": "0.
|
|
51
|
+
"@moloodev/typescript-config": "0.7.0"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
package/src/editor-id.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
export { reservedPublishers } from "@moloodev/platform";
|
|
2
|
+
import { parseQualifiedName } from "@moloodev/platform";
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* DNS label used for the editor half of `publisher.editor`.
|
|
@@ -21,23 +20,8 @@ export function isEditorLabel(label: string): boolean {
|
|
|
21
20
|
return editorLabelSchema.safeParse(label).success;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!
|
|
27
|
-
|
|
28
|
-
return !isReservedPublisherHandle(publisher);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function parseEditorId(
|
|
32
|
-
id: string,
|
|
33
|
-
firstParty: boolean,
|
|
34
|
-
): EditorId | undefined {
|
|
35
|
-
const dot = id.indexOf(".");
|
|
36
|
-
if (dot < 1 || dot !== id.lastIndexOf(".")) return undefined;
|
|
37
|
-
const publisher = id.slice(0, dot);
|
|
38
|
-
const editor = id.slice(dot + 1);
|
|
39
|
-
if (!isPublisherName(publisher, firstParty) || !isEditorLabel(editor)) {
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
return { publisher, editor };
|
|
23
|
+
export function parseEditorId(id: string): EditorId | undefined {
|
|
24
|
+
const name = parseQualifiedName(id);
|
|
25
|
+
if (!name || !isEditorLabel(name.name)) return undefined;
|
|
26
|
+
return { publisher: name.publisher, editor: name.name };
|
|
43
27
|
}
|
package/src/protocol.ts
CHANGED
package/src/view.ts
CHANGED
|
@@ -236,7 +236,7 @@ export function connectEditorView(deps: EditorViewDeps): EditorView {
|
|
|
236
236
|
} satisfies EditorViewCall;
|
|
237
237
|
|
|
238
238
|
const origin = absoluteHttpOrigin(deps.parent);
|
|
239
|
-
const editor = parseEditorId(deps.editorId
|
|
239
|
+
const editor = parseEditorId(deps.editorId);
|
|
240
240
|
const handshake: Promise<HandshakeResult> =
|
|
241
241
|
origin === undefined || editor === undefined
|
|
242
242
|
? Promise.resolve({ ok: false, code: "rejected" })
|