@moloodev/editor-sdk 0.5.0 → 0.6.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 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moloodev/editor-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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.6.0",
|
|
33
|
+
"@moloodev/ui": "0.6.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.6.0"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
package/src/editor-id.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { isPublisherHandle, isReservedPublisherHandle } from "@moloodev/platform";
|
|
3
|
+
export { reservedPublishers } from "@moloodev/platform";
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
|
-
* DNS label used for
|
|
6
|
+
* DNS label used for the editor half of `publisher.editor`.
|
|
5
7
|
* 1–63 characters, lowercase letters, digits, and hyphens.
|
|
6
8
|
* No leading or trailing hyphen. Positions 3–4 must not be `--` (punycode).
|
|
7
9
|
*/
|
|
@@ -10,21 +12,6 @@ const editorLabelSchema = z
|
|
|
10
12
|
.regex(/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/)
|
|
11
13
|
.refine((label) => label.length < 4 || label[2] !== "-" || label[3] !== "-");
|
|
12
14
|
|
|
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
15
|
export type EditorId = {
|
|
29
16
|
publisher: string;
|
|
30
17
|
editor: string;
|
|
@@ -36,9 +23,9 @@ export function isEditorLabel(label: string): boolean {
|
|
|
36
23
|
|
|
37
24
|
/** `firstParty` is the only caller that may use the `moloo` publisher. */
|
|
38
25
|
export function isPublisherName(publisher: string, firstParty: boolean): boolean {
|
|
39
|
-
if (!
|
|
26
|
+
if (!isPublisherHandle(publisher)) return false;
|
|
40
27
|
if (publisher === "moloo") return firstParty;
|
|
41
|
-
return !
|
|
28
|
+
return !isReservedPublisherHandle(publisher);
|
|
42
29
|
}
|
|
43
30
|
|
|
44
31
|
export function parseEditorId(
|