@ignifx/editor-host 0.9.0 → 0.10.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.
@@ -0,0 +1,44 @@
1
+ //#region src/error-codes.d.ts
2
+ /**
3
+ * The diagnostic codes `@ignifx/editor-host` owns, and the origin rule both of its entries check.
4
+ *
5
+ * The package owns the `18xx` range (`docs/architecture/15-devtools-and-diagnostics.md` §1). This
6
+ * module is plain data with no imports, because the Vite plugin runs in Node without
7
+ * `@ignifx/core` and still reports the same codes.
8
+ */
9
+ /**
10
+ * Every diagnostic code `@ignifx/editor-host` can throw, keyed by an intention-revealing name.
11
+ *
12
+ * @beta
13
+ */
14
+ declare const EditorHostErrorCode: {
15
+ /** `editorOrigin` is not an origin such as `"ignifx://app"` or `"http://localhost:5173"`. */
16
+ readonly invalidEditorOrigin: "IGX-1801";
17
+ /** The host was started where there is no `window` to receive the editor's port, and was given no `messageTarget`. */
18
+ readonly noMessageTarget: "IGX-1802";
19
+ /** An option is outside its documented domain. */
20
+ readonly invalidOption: "IGX-1803";
21
+ };
22
+ /**
23
+ * The union of the codes in `EditorHostErrorCode`.
24
+ *
25
+ * @beta
26
+ */
27
+ type EditorHostErrorCode = (typeof EditorHostErrorCode)[keyof typeof EditorHostErrorCode];
28
+ /**
29
+ * Tells whether a string is an origin the editor can be served from.
30
+ *
31
+ * @remarks
32
+ * `new URL(value).origin` is not usable here: for a scheme Node does not know, such as the
33
+ * editor's `ignifx://app`, it answers `"null"`, while Chromium reports `ignifx://app` as
34
+ * `event.origin` because Electron registers the scheme as standard.
35
+ *
36
+ * @param value - The candidate, for example `"ignifx://app"` or `"http://localhost:5173"`.
37
+ * @returns `true` when the value is a scheme, `://`, and a host with an optional port.
38
+ *
39
+ * @beta
40
+ */
41
+ declare function isEditorOrigin(value: string): boolean;
42
+ //#endregion
43
+ export { isEditorOrigin as n, EditorHostErrorCode as t };
44
+ //# sourceMappingURL=error-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.d.ts","names":[],"sources":["../src/error-codes.ts"],"mappings":";;;;;;;;;;;;;cAaa;;WAEX;;WAEA;;WAEA;;;;;;;KAQU,8BAA8B,kCAAkC;;;;;;;;;;;;;;iBAqB5D,eAAe"}
@@ -0,0 +1,46 @@
1
+ //#region src/error-codes.ts
2
+ /**
3
+ * The diagnostic codes `@ignifx/editor-host` owns, and the origin rule both of its entries check.
4
+ *
5
+ * The package owns the `18xx` range (`docs/architecture/15-devtools-and-diagnostics.md` §1). This
6
+ * module is plain data with no imports, because the Vite plugin runs in Node without
7
+ * `@ignifx/core` and still reports the same codes.
8
+ */
9
+ /**
10
+ * Every diagnostic code `@ignifx/editor-host` can throw, keyed by an intention-revealing name.
11
+ *
12
+ * @beta
13
+ */
14
+ const EditorHostErrorCode = {
15
+ /** `editorOrigin` is not an origin such as `"ignifx://app"` or `"http://localhost:5173"`. */
16
+ invalidEditorOrigin: "IGX-1801",
17
+ /** The host was started where there is no `window` to receive the editor's port, and was given no `messageTarget`. */
18
+ noMessageTarget: "IGX-1802",
19
+ /** An option is outside its documented domain. */
20
+ invalidOption: "IGX-1803"
21
+ };
22
+ /**
23
+ * A scheme, `://`, and a host with an optional port: no path, no wildcard, and nothing that could
24
+ * end a `Content-Security-Policy` directive early.
25
+ */
26
+ const ORIGIN_SHAPE = /^[a-z][a-z\d+.-]*:\/\/[^\s/?#;,'"*]+$/iu;
27
+ /**
28
+ * Tells whether a string is an origin the editor can be served from.
29
+ *
30
+ * @remarks
31
+ * `new URL(value).origin` is not usable here: for a scheme Node does not know, such as the
32
+ * editor's `ignifx://app`, it answers `"null"`, while Chromium reports `ignifx://app` as
33
+ * `event.origin` because Electron registers the scheme as standard.
34
+ *
35
+ * @param value - The candidate, for example `"ignifx://app"` or `"http://localhost:5173"`.
36
+ * @returns `true` when the value is a scheme, `://`, and a host with an optional port.
37
+ *
38
+ * @beta
39
+ */
40
+ function isEditorOrigin(value) {
41
+ return ORIGIN_SHAPE.test(value);
42
+ }
43
+ //#endregion
44
+ export { isEditorOrigin as n, EditorHostErrorCode as t };
45
+
46
+ //# sourceMappingURL=error-codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.js","names":[],"sources":["../src/error-codes.ts"],"sourcesContent":["/**\n * The diagnostic codes `@ignifx/editor-host` owns, and the origin rule both of its entries check.\n *\n * The package owns the `18xx` range (`docs/architecture/15-devtools-and-diagnostics.md` §1). This\n * module is plain data with no imports, because the Vite plugin runs in Node without\n * `@ignifx/core` and still reports the same codes.\n */\n\n/**\n * Every diagnostic code `@ignifx/editor-host` can throw, keyed by an intention-revealing name.\n *\n * @beta\n */\nexport const EditorHostErrorCode = {\n /** `editorOrigin` is not an origin such as `\"ignifx://app\"` or `\"http://localhost:5173\"`. */\n invalidEditorOrigin: \"IGX-1801\",\n /** The host was started where there is no `window` to receive the editor's port, and was given no `messageTarget`. */\n noMessageTarget: \"IGX-1802\",\n /** An option is outside its documented domain. */\n invalidOption: \"IGX-1803\",\n} as const;\n\n/**\n * The union of the codes in `EditorHostErrorCode`.\n *\n * @beta\n */\nexport type EditorHostErrorCode = (typeof EditorHostErrorCode)[keyof typeof EditorHostErrorCode];\n\n/**\n * A scheme, `://`, and a host with an optional port: no path, no wildcard, and nothing that could\n * end a `Content-Security-Policy` directive early.\n */\nconst ORIGIN_SHAPE = /^[a-z][a-z\\d+.-]*:\\/\\/[^\\s/?#;,'\"*]+$/iu;\n\n/**\n * Tells whether a string is an origin the editor can be served from.\n *\n * @remarks\n * `new URL(value).origin` is not usable here: for a scheme Node does not know, such as the\n * editor's `ignifx://app`, it answers `\"null\"`, while Chromium reports `ignifx://app` as\n * `event.origin` because Electron registers the scheme as standard.\n *\n * @param value - The candidate, for example `\"ignifx://app\"` or `\"http://localhost:5173\"`.\n * @returns `true` when the value is a scheme, `://`, and a host with an optional port.\n *\n * @beta\n */\nexport function isEditorOrigin(value: string): boolean {\n return ORIGIN_SHAPE.test(value);\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAa,sBAAsB;;CAEjC,qBAAqB;;CAErB,iBAAiB;;CAEjB,eAAe;AACjB;;;;;AAaA,MAAM,eAAe;;;;;;;;;;;;;;AAerB,SAAgB,eAAe,OAAwB;CACrD,OAAO,aAAa,KAAK,KAAK;AAChC"}