@moloodev/editor-sdk 0.5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moloodev/editor-sdk",
3
- "version": "0.5.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.5.0",
33
- "@moloodev/ui": "0.5.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.5.0"
51
+ "@moloodev/typescript-config": "0.7.0"
52
52
  },
53
53
  "publishConfig": {
54
54
  "access": "public"
package/src/editor-id.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { z } from "zod";
2
+ import { parseQualifiedName } from "@moloodev/platform";
2
3
 
3
4
  /**
4
- * DNS label used for both halves of `publisher.editor`.
5
+ * DNS label used for the editor half of `publisher.editor`.
5
6
  * 1–63 characters, lowercase letters, digits, and hyphens.
6
7
  * No leading or trailing hyphen. Positions 3–4 must not be `--` (punycode).
7
8
  */
@@ -10,21 +11,6 @@ const editorLabelSchema = z
10
11
  .regex(/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/)
11
12
  .refine((label) => label.length < 4 || label[2] !== "-" || label[3] !== "-");
12
13
 
13
- export const reservedPublishers: readonly string[] = [
14
- "www",
15
- "api",
16
- "app",
17
- "admin",
18
- "static",
19
- "cdn",
20
- "preview",
21
- "dev",
22
- "localhost",
23
- "local",
24
- "mail",
25
- "moloo",
26
- ];
27
-
28
14
  export type EditorId = {
29
15
  publisher: string;
30
16
  editor: string;
@@ -34,23 +20,8 @@ export function isEditorLabel(label: string): boolean {
34
20
  return editorLabelSchema.safeParse(label).success;
35
21
  }
36
22
 
37
- /** `firstParty` is the only caller that may use the `moloo` publisher. */
38
- export function isPublisherName(publisher: string, firstParty: boolean): boolean {
39
- if (!isEditorLabel(publisher)) return false;
40
- if (publisher === "moloo") return firstParty;
41
- return !reservedPublishers.includes(publisher);
42
- }
43
-
44
- export function parseEditorId(
45
- id: string,
46
- firstParty: boolean,
47
- ): EditorId | undefined {
48
- const dot = id.indexOf(".");
49
- if (dot < 1 || dot !== id.lastIndexOf(".")) return undefined;
50
- const publisher = id.slice(0, dot);
51
- const editor = id.slice(dot + 1);
52
- if (!isPublisherName(publisher, firstParty) || !isEditorLabel(editor)) {
53
- return undefined;
54
- }
55
- 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 };
56
27
  }
package/src/protocol.ts CHANGED
@@ -464,8 +464,6 @@ export function parseChromeManifest(
464
464
 
465
465
  export {
466
466
  isEditorLabel,
467
- isPublisherName,
468
467
  parseEditorId,
469
- reservedPublishers,
470
468
  } from "./editor-id";
471
469
  export type { EditorId } from "./editor-id";
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, true);
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" })