shelving 1.124.2 → 1.124.3

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.
@@ -1,5 +1,5 @@
1
1
  import type { MarkupRules } from "./rule.js";
2
- import type { Link, LinkHosts, LinkSchemes } from "../util/link.js";
2
+ import type { AbsoluteLink, LinkHosts, LinkSchemes } from "../util/link.js";
3
3
  /** The current parsing options (represents the current state of the parsing). */
4
4
  export type MarkupOptions = {
5
5
  /** The active list of parsing rules. */
@@ -9,7 +9,7 @@ export type MarkupOptions = {
9
9
  /** Set the `rel=""` property used for any links (e.g. `rel="nofollow ugc"`). */
10
10
  readonly rel: string | undefined;
11
11
  /** Set the base URL that any relative links will be relative to (defaults to `window.location.href`, if undefined then relative links won't work). */
12
- readonly base: Link | undefined;
12
+ readonly base: AbsoluteLink | undefined;
13
13
  /** Valid URL schemes/protocols for links (including trailing commas), defaults to `[`http:`, `https:`]` */
14
14
  readonly schemes: LinkSchemes | undefined;
15
15
  /** Valid URL hosts for links (including trailing commas) */
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.124.2",
14
+ "version": "1.124.3",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -1,10 +1,10 @@
1
1
  import type { StringSchemaOptions } from "./StringSchema.js";
2
2
  import type { ImmutableArray } from "../util/array.js";
3
- import { type Link } from "../util/link.js";
3
+ import { type AbsoluteLink } from "../util/link.js";
4
4
  import { StringSchema } from "./StringSchema.js";
5
5
  /** Allowed options for `LinkSchema` */
6
6
  export interface LinkSchemaOptions extends Omit<StringSchemaOptions, "type" | "min" | "max" | "multiline"> {
7
- readonly base?: Link | undefined;
7
+ readonly base?: AbsoluteLink | undefined;
8
8
  readonly schemes?: ImmutableArray<string> | undefined;
9
9
  readonly hosts?: ImmutableArray<string> | undefined;
10
10
  }
@@ -15,11 +15,11 @@ export interface LinkSchemaOptions extends Omit<StringSchemaOptions, "type" | "m
15
15
  * - Falsy values are converted to `""` empty string.
16
16
  */
17
17
  export declare class LinkSchema extends StringSchema {
18
- readonly base: Link | undefined;
18
+ readonly base: AbsoluteLink | undefined;
19
19
  readonly schemes: ImmutableArray<string> | undefined;
20
20
  readonly hosts: ImmutableArray<string> | undefined;
21
21
  constructor({ base, schemes, hosts, title, ...options }: LinkSchemaOptions);
22
- validate(unsafeValue: unknown): Link;
22
+ validate(unsafeValue: unknown): AbsoluteLink;
23
23
  }
24
24
  /** Valid link, e.g. `https://www.google.com` */
25
25
  export declare const LINK: LinkSchema;
package/util/link.d.ts CHANGED
@@ -1,35 +1,38 @@
1
1
  import type { ImmutableArray } from "./array.js";
2
2
  import type { Optional } from "./optional.js";
3
- import { type AbsolutePath } from "./path.js";
3
+ import { type Path } from "./path.js";
4
4
  import { type PossibleURL } from "./url.js";
5
- /** List of allowed schemes for a link. */
6
- export type LinkSchemes = ImmutableArray<string>;
7
- /** List of allowed hosts for a link. */
8
- export type LinkHosts = ImmutableArray<string>;
9
5
  /**
10
6
  * URL string with a `scheme:` at the start and a path component, e.g. `https://` or `file://`
11
7
  * - The `//` in a URI indicates that type of URI has a path heirarchy indicated by the first `/` after the `://`
12
8
  * - If the URI has no explicit `/path` component it will always be assumed to be `/`
13
9
  * - Some URIs are non-heirarchical, e.g. `mailto:me@gmail.com`
14
10
  */
15
- export type Link = `${string}:${string}`;
11
+ export type AbsoluteLink = `${string}:${string}`;
12
+ /** Relative link starts with `./` or `../` or `/` */
13
+ export type RelativeLink = Path;
14
+ /** Either an absolute URL string or a relative URL string. */
15
+ export type Link = AbsoluteLink | RelativeLink;
16
+ /** List of allowed schemes for a link. */
17
+ export type LinkSchemes = ImmutableArray<string>;
18
+ /** List of allowed hosts for a link. */
19
+ export type LinkHosts = ImmutableArray<string>;
16
20
  /**
17
- * Link URL is a URL that has an `href` that is a `Link` element and a `pathname` that is an `AbsolutePath` property.
21
+ * Absolute URL is a URL that has an `href` that is a `Link` element and a `pathname` that is an `AbsolutePath` property.
18
22
  * - e.g. `http://x.com/a/b` is a link URL because `.pathname` will be `/a/b`
19
23
  * - e.g. `http://x.com` is a link URL because `.pathname` will be `/`
20
24
  * - e.g. `mailto:me@gmail.com` is _not_ an absolute URL because `.pathname` will be `"me@gmail.com"` which does not start with `/` slash.
21
25
  */
22
- export type LinkURL = URL & {
23
- href: Link;
24
- pathname: AbsolutePath;
26
+ export type AbsoluteLinkURL = URL & {
27
+ href: AbsoluteLink;
25
28
  };
26
29
  /** Is an unknown value a URL object with an absolute path component? */
27
- export declare function isLinkURL(value: unknown): value is LinkURL;
30
+ export declare function isLinkURL(value: unknown): value is AbsoluteLinkURL;
28
31
  /** Convert a possible URL to a URL or return `undefined` if conversion fails. */
29
- export declare function getOptionalLinkURL(possible: Optional<PossibleURL>, base?: LinkURL | Link, schemes?: LinkSchemes, hosts?: LinkHosts): LinkURL | undefined;
32
+ export declare function getOptionalLinkURL(possible: Optional<PossibleURL>, base?: AbsoluteLinkURL | AbsoluteLink, schemes?: LinkSchemes, hosts?: LinkHosts): AbsoluteLinkURL | undefined;
30
33
  /** Convert a possible URL to a URL or return `undefined` if conversion fails. */
31
- export declare function getLinkURL(possible: PossibleURL, base?: LinkURL | Link, schemes?: LinkSchemes, hosts?: LinkHosts): LinkURL;
34
+ export declare function getLinkURL(possible: PossibleURL, base?: AbsoluteLinkURL | AbsoluteLink, schemes?: LinkSchemes, hosts?: LinkHosts): AbsoluteLinkURL;
32
35
  /** Convert a possible URL to a absolute URL string or return `undefined` if conversion fails. */
33
- export declare function getOptionalLink(possible: Optional<PossibleURL>, base?: LinkURL | Link, schemes?: LinkSchemes, hosts?: LinkHosts): Link | undefined;
36
+ export declare function getOptionalLink(possible: Optional<PossibleURL>, base?: AbsoluteLinkURL | AbsoluteLink, schemes?: LinkSchemes, hosts?: LinkHosts): AbsoluteLink | undefined;
34
37
  /** Convert a possible URL to an absolute URL string. */
35
- export declare function getLink(possible: PossibleURL, base?: LinkURL | Link, schemes?: LinkSchemes, hosts?: LinkHosts): Link;
38
+ export declare function getLink(possible: PossibleURL, base?: AbsoluteLinkURL | AbsoluteLink, schemes?: LinkSchemes, hosts?: LinkHosts): AbsoluteLink;