shelving 1.86.1 → 1.86.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,3 +1,4 @@
1
+ import { getPrototype } from "../util/object.js";
1
2
  import { withArrayItems, omitArrayItems } from "../util/array.js";
2
3
  import { Constraint } from "./Constraint.js";
3
4
  /** Type of Rule that is powered by several sub-constraints (e.g. `Filters` and `Sorts` and `Query` itself extend this). */
@@ -21,12 +22,12 @@ export class Constraints extends Constraint {
21
22
  /** Clone this set of constraints but add additional constraints. */
22
23
  with(...constraints) {
23
24
  const _constraints = withArrayItems(this._constraints, ...constraints);
24
- return _constraints !== this._constraints ? { __proto__: Object.getPrototypeOf(this), ...this, _constraints: _constraints } : this;
25
+ return _constraints !== this._constraints ? { __proto__: getPrototype(this), ...this, _constraints: _constraints } : this;
25
26
  }
26
27
  /** Clone this set of constraints but remove specific constraints. */
27
28
  omit(...constraints) {
28
29
  const _constraints = omitArrayItems(this._constraints, ...constraints);
29
- return _constraints !== this._constraints ? { __proto__: Object.getPrototypeOf(this), ...this, _constraints: _constraints } : this;
30
+ return _constraints !== this._constraints ? { __proto__: getPrototype(this), ...this, _constraints: _constraints } : this;
30
31
  }
31
32
  /** Iterate over the constraints. */
32
33
  [Symbol.iterator]() {
@@ -31,7 +31,7 @@ export declare class QueryConstraints<T extends Data = Data> extends Constraint<
31
31
  readonly filters: FilterConstraints<T>;
32
32
  readonly sorts: SortConstraints<T>;
33
33
  readonly limit: number | null;
34
- constructor(filters?: FilterList<Partial<T>>, sorts?: SortList<Partial<T>>, limit?: number | null);
34
+ constructor(filters?: FilterList<Partial<T>> | FilterConstraints<T>, sorts?: SortList<Partial<T>> | SortConstraints<T>, limit?: number | null);
35
35
  filter(...filters: FilterList<Partial<T>>[]): this;
36
36
  get unfilter(): this;
37
37
  match(item: T): boolean;
@@ -1,4 +1,4 @@
1
- import { getProp } from "../util/object.js";
1
+ import { getProp, getPrototype } from "../util/object.js";
2
2
  import { assert } from "../util/assert.js";
3
3
  import { limitArray } from "../util/array.js";
4
4
  import { FilterConstraints } from "./FilterConstraints.js";
@@ -19,7 +19,7 @@ export class QueryConstraints extends Constraint {
19
19
  // Implement `Filterable`
20
20
  filter(...filters) {
21
21
  return {
22
- __proto__: Object.getPrototypeOf(this),
22
+ __proto__: getPrototype(this),
23
23
  ...this,
24
24
  filters: this.filters.filter(...filters),
25
25
  };
@@ -28,7 +28,7 @@ export class QueryConstraints extends Constraint {
28
28
  if (!this.filters.size)
29
29
  return this;
30
30
  return {
31
- __proto__: Object.getPrototypeOf(this),
31
+ __proto__: getPrototype(this),
32
32
  ...this,
33
33
  filters: EMPTY_FILTERS,
34
34
  };
@@ -39,7 +39,7 @@ export class QueryConstraints extends Constraint {
39
39
  // Implement `Sortable`
40
40
  sort(...sorts) {
41
41
  return {
42
- __proto__: Object.getPrototypeOf(this),
42
+ __proto__: getPrototype(this),
43
43
  ...this,
44
44
  sorts: this.sorts.sort(...sorts),
45
45
  };
@@ -48,7 +48,7 @@ export class QueryConstraints extends Constraint {
48
48
  if (!this.sorts.size)
49
49
  return this;
50
50
  return {
51
- __proto__: Object.getPrototypeOf(this),
51
+ __proto__: getPrototype(this),
52
52
  ...this,
53
53
  sorts: EMPTY_SORTS,
54
54
  };
@@ -59,14 +59,14 @@ export class QueryConstraints extends Constraint {
59
59
  // Implement `Queryable`
60
60
  after(item) {
61
61
  return {
62
- __proto__: Object.getPrototypeOf(this),
62
+ __proto__: getPrototype(this),
63
63
  ...this,
64
64
  filters: this.filters.with(..._getAfterFilters(this.sorts, item)),
65
65
  };
66
66
  }
67
67
  before(item) {
68
68
  return {
69
- __proto__: Object.getPrototypeOf(this),
69
+ __proto__: getPrototype(this),
70
70
  ...this,
71
71
  filters: this.filters.with(..._getBeforeFilters(this.sorts, item)),
72
72
  };
@@ -75,7 +75,7 @@ export class QueryConstraints extends Constraint {
75
75
  if (this.limit === limit)
76
76
  return this;
77
77
  return {
78
- __proto__: Object.getPrototypeOf(this),
78
+ __proto__: getPrototype(this),
79
79
  ...this,
80
80
  limit,
81
81
  };
@@ -7,7 +7,7 @@ export class ThroughError extends Error {
7
7
  constructor(message, cause) {
8
8
  super(message);
9
9
  this.cause = cause;
10
- this.stack = `${this.stack}\nCause: ${cause instanceof Error ? cause.stack : debug(cause)}`;
10
+ this.stack = `${this.stack || ""}\nCause: ${cause instanceof Error ? cause.stack || "" : debug(cause)}`;
11
11
  }
12
12
  }
13
13
  ThroughError.prototype.name = "ThroughError";
@@ -1,9 +1,8 @@
1
- import { orderBy as firestoreOrderBy, where as firestoreWhere, limit as firestoreLimit, increment as firestoreIncrement, arrayUnion as firestoreArrayUnion, arrayRemove as firestoreArrayRemove, deleteField as firestoreDeleteField, collection as firestoreCollection, doc as firestoreDocument, query as firestoreQuery, onSnapshot, addDoc, setDoc, updateDoc, deleteDoc, getDoc, getDocs, } from "firebase/firestore";
1
+ import { documentId as firestoreDocumentId, orderBy as firestoreOrderBy, where as firestoreWhere, limit as firestoreLimit, increment as firestoreIncrement, arrayUnion as firestoreArrayUnion, arrayRemove as firestoreArrayRemove, deleteField as firestoreDeleteField, collection as firestoreCollection, doc as firestoreDocument, query as firestoreQuery, onSnapshot, addDoc, setDoc, updateDoc, deleteDoc, getDoc, getDocs, } from "firebase/firestore";
2
2
  import { LazyDeferredSequence } from "../../sequence/LazyDeferredSequence.js";
3
3
  import { ArrayUpdate, DataUpdate, Increment, DictionaryUpdate, Delete, Update } from "../../update/index.js";
4
4
  // Constants.
5
- // const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
6
- const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
5
+ const ID = firestoreDocumentId();
7
6
  // Map `Filter.types` to `WhereFilterOp`
8
7
  const OPERATORS = {
9
8
  IS: "==",
@@ -1,9 +1,10 @@
1
- import { orderBy as firestoreOrderBy, where as firestoreWhere, limit as firestoreLimit, increment as firestoreIncrement, arrayUnion as firestoreArrayUnion, arrayRemove as firestoreArrayRemove, deleteField as firestoreDeleteField, collection as firestoreCollection, doc as firestoreDocument, query as firestoreQuery, setDoc, addDoc, updateDoc, deleteDoc, getDoc, getDocs, } from "firebase/firestore/lite";
1
+ import { documentId as firestoreDocumentId, orderBy as firestoreOrderBy, where as firestoreWhere, limit as firestoreLimit, increment as firestoreIncrement, arrayUnion as firestoreArrayUnion, arrayRemove as firestoreArrayRemove, deleteField as firestoreDeleteField, collection as firestoreCollection, doc as firestoreDocument, query as firestoreQuery, setDoc, addDoc, updateDoc, deleteDoc, getDoc, getDocs, } from "firebase/firestore/lite";
2
2
  import { UnsupportedError } from "../../error/UnsupportedError.js";
3
3
  import { ArrayUpdate, DataUpdate, Increment, DictionaryUpdate, Delete, Update } from "../../update/index.js";
4
4
  // Constants.
5
5
  // const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
6
- const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
6
+ // const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
7
+ const ID = firestoreDocumentId();
7
8
  // Map `Filter.types` to `WhereFilterOp`
8
9
  const OPERATORS = {
9
10
  IS: "==",
@@ -1,9 +1,8 @@
1
- import { Firestore, FieldValue as FirestoreFieldValue } from "@google-cloud/firestore";
1
+ import { Firestore, FieldValue, FieldPath } from "@google-cloud/firestore";
2
2
  import { LazyDeferredSequence } from "../../sequence/LazyDeferredSequence.js";
3
3
  import { ArrayUpdate, DataUpdate, Increment, DictionaryUpdate, Delete, Update } from "../../update/index.js";
4
4
  // Constants.
5
- // const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
6
- const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
5
+ const ID = FieldPath.documentId();
7
6
  // Map `Filter.types` to `WhereFilterOp`
8
7
  const OPERATORS = {
9
8
  IS: "==",
@@ -53,11 +52,11 @@ function* _getFieldValues(updates, prefix = "") {
53
52
  else if (update instanceof ArrayUpdate) {
54
53
  if (update.adds.length) {
55
54
  yield `${prefix}${key}`;
56
- yield FirestoreFieldValue.arrayUnion(...update.adds);
55
+ yield FieldValue.arrayUnion(...update.adds);
57
56
  }
58
57
  if (update.deletes.length) {
59
58
  yield `${prefix}${key}`;
60
- yield FirestoreFieldValue.arrayRemove(...update.deletes);
59
+ yield FieldValue.arrayRemove(...update.deletes);
61
60
  }
62
61
  }
63
62
  else {
@@ -65,9 +64,9 @@ function* _getFieldValues(updates, prefix = "") {
65
64
  if (!(update instanceof Update))
66
65
  yield update;
67
66
  else if (update instanceof Delete)
68
- yield FirestoreFieldValue.delete();
67
+ yield FieldValue.delete();
69
68
  else if (update instanceof Increment)
70
- yield FirestoreFieldValue.increment(update.amount);
69
+ yield FieldValue.increment(update.amount);
71
70
  else
72
71
  yield update.transform();
73
72
  }
package/markup/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./options.js";
2
+ export * from "./rule.js";
2
3
  export * from "./rules.js";
3
4
  export * from "./render.js";
4
5
  export * from "./regexp.js";
package/markup/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./options.js";
2
+ export * from "./rule.js";
2
3
  export * from "./rules.js";
3
4
  export * from "./render.js";
4
5
  export * from "./regexp.js";
@@ -1,4 +1,4 @@
1
- import { MarkupRules } from "./rules.js";
1
+ import type { MarkupRules } from "./rule.js";
2
2
  /** The current parsing options (represents the current state of the parsing). */
3
3
  export type MarkupOptions = {
4
4
  /** The active list of parsing rules. */
@@ -2,13 +2,13 @@ import type { Data } from "../util/data.js";
2
2
  import { NamedRegExp, NamedRegExpData, PossibleRegExp } from "../util/regexp.js";
3
3
  import type { MarkupOptions } from "./options.js";
4
4
  /** Subset of `NamedRegExpArray<T>` that are the only things we're required return from a `MarkupMatcher` function. */
5
- export type MarkupMatch<T extends Data | undefined = Data | undefined> = {
5
+ export type MarkupMatch<T extends Data | undefined> = {
6
6
  0: string;
7
7
  index: number;
8
8
  groups: T;
9
9
  };
10
10
  /** Function that matches a string and returns a `MarkupMatch` or `null` or `void` */
11
- export type MarkupMatcher<T extends Data | undefined = Data | undefined> = (input: string, options: MarkupOptions) => MarkupMatch<T> | null | void;
11
+ export type MarkupMatcher<T extends Data> = (input: string, options: MarkupOptions) => MarkupMatch<T> | null | void;
12
12
  export declare const LINE_REGEXP: RegExp;
13
13
  export declare const LINE_START_REGEXP: RegExp;
14
14
  export declare const LINE_END_REGEXP: RegExp;
package/markup/render.js CHANGED
@@ -77,49 +77,48 @@ function _renderElement(element, options, context) {
77
77
  */
78
78
  function* _parseString(input, options, context, offset = 0) {
79
79
  let matchedRule = undefined;
80
- let matchedPriority = Number.MIN_SAFE_INTEGER;
81
- let matchedIndex = Number.MIN_SAFE_INTEGER;
82
- let matchedLength = 0;
83
- let matchedGroups = undefined;
80
+ let matchedResult = undefined;
81
+ let highPriority = Number.MIN_SAFE_INTEGER;
82
+ let lowIndex = Number.MIN_SAFE_INTEGER;
84
83
  // Loop through all rules in the list and see if any match.
85
84
  for (const rule of options.rules) {
86
85
  // Only apply this rule if both:
87
86
  // 1. The priority is equal or higher to the current priority.
88
87
  // 2. The rule is allowed in the current context.
89
- const { priority = 0, match, contexts } = rule;
90
- if (priority >= matchedPriority && contexts.includes(context)) {
91
- const result = typeof match === "function" ? match(input, options) : match.exec(input);
88
+ const { priority } = rule;
89
+ if (rule.priority >= highPriority && rule.contexts.includes(context)) {
90
+ const result = rule.match(input, options);
92
91
  if (result) {
93
92
  // Use the match if it has length and is earlier in the string or is higher priority.
94
- const { 0: { length } = "", index, groups } = result;
95
- if (length && (index < matchedIndex || priority > matchedPriority)) {
93
+ const { 0: { length } = "", index } = result;
94
+ if (length && (index < lowIndex || rule.priority > highPriority)) {
96
95
  matchedRule = rule;
97
- matchedPriority = priority;
98
- matchedIndex = index;
99
- matchedLength = length;
100
- matchedGroups = groups;
96
+ matchedResult = result;
97
+ highPriority = priority;
98
+ lowIndex = index;
101
99
  }
102
100
  }
103
101
  }
104
102
  }
105
103
  // Did at least one rule match?
106
- if (matchedRule && matchedLength) {
104
+ if (matchedRule && matchedResult) {
107
105
  // If index is more than zero, then the string before the match may match another rule at lower priority.
108
- const prefix = input.slice(0, matchedIndex);
106
+ const prefix = input.slice(0, lowIndex);
109
107
  if (prefix.length)
110
108
  yield* _parseString(prefix, options, context, offset);
111
109
  // Call the rule's `render()` function to generate the node.
112
110
  // React gets annoyed if we don't set a `key:` property on lists of elements.
113
111
  // We use the string offset as the `.key` property in the element because it's cheap to calculate and guaranteed to be unique within the string.
114
112
  // Trying to generate an incrementing number would require tracking the number and passing it back and forth through `_parseString()`
115
- const { render, subcontext } = matchedRule;
116
- const element = render(matchedGroups, options);
117
- element.key = offset + matchedIndex;
113
+ const { 0: { length } = "", groups, index } = matchedResult;
114
+ const element = matchedRule.render(groups, options);
115
+ element.key = offset + index;
116
+ const { subcontext } = matchedRule;
118
117
  yield subcontext ? _renderElement(element, options, subcontext) : element;
119
118
  // Decrement the content.
120
- const suffix = input.slice(matchedIndex + matchedLength);
119
+ const suffix = input.slice(index + length);
121
120
  if (suffix.length)
122
- yield* _parseString(suffix, options, context, offset + matchedIndex + matchedLength);
121
+ yield* _parseString(suffix, options, context, offset + index + length);
123
122
  }
124
123
  else {
125
124
  // If nothing matched return the entire string..
@@ -0,0 +1,74 @@
1
+ import { NamedRegExp, NamedRegExpArray, NamedRegExpData } from "../util/regexp.js";
2
+ import { Data } from "../util/data.js";
3
+ import { JSXElement } from "../util/jsx.js";
4
+ import { ImmutableArray } from "../util/array.js";
5
+ import { MarkupOptions } from "./options.js";
6
+ export type MarkupRuleMatch<T extends Data = Data> = {
7
+ 0: string;
8
+ index: number;
9
+ groups?: T;
10
+ };
11
+ export declare abstract class MarkupRule {
12
+ /**
13
+ * Contexts this rule should be applied in,
14
+ *
15
+ * @example `["block", "inline", "list"]`
16
+ */
17
+ readonly contexts: ImmutableArray<string>;
18
+ /**
19
+ * Context that children should be rendered with.
20
+ *
21
+ * @example `"inline"` // Children of the element rendered by this rule will be parsed against markup rules applied in the "inline" context.
22
+ */
23
+ readonly subcontext: string | null;
24
+ /**
25
+ * Priority for this rule (defaults to zero).
26
+ *
27
+ * @example e.g. `<p>` rule is lower priority than other blocks so it matches last and paragraphs can be interrupted by e.g. `<ul>` and `<blockquote>`.
28
+ * @example e.g. `<code>` rule is higher priority than other inlines so e.g. `<strong>` or `<em>` don't match inside a code block.
29
+ */
30
+ readonly priority: number;
31
+ constructor(contexts: ImmutableArray<string>, //
32
+ subcontext?: string | null, priority?: number);
33
+ /** Match an input string against this */
34
+ abstract match(input: string, options: MarkupOptions): MarkupRuleMatch | null;
35
+ /** Render the JSX element for this rule using the props matched by `.match` */
36
+ abstract render(props: Data | undefined, options: MarkupOptions): JSXElement;
37
+ }
38
+ export declare class RegExpMarkupRule extends MarkupRule {
39
+ readonly regexp: RegExp;
40
+ readonly render: (props: Data, options: MarkupOptions) => JSXElement;
41
+ constructor(regexp: RegExp, //
42
+ render: (props: Data, options: MarkupOptions) => JSXElement, contexts: ImmutableArray<string>, subcontext?: string | null, priority?: number);
43
+ match(input: string): MarkupRuleMatch | null;
44
+ }
45
+ export declare class NamedRegExpMarkupRule<T extends NamedRegExpData> extends MarkupRule {
46
+ readonly regexp: NamedRegExp<T>;
47
+ readonly render: (props: T, options: MarkupOptions) => JSXElement;
48
+ constructor(regexp: NamedRegExp<T>, //
49
+ render: (props: T, options: MarkupOptions) => JSXElement, contexts: ImmutableArray<string>, subcontext?: string | null, priority?: number);
50
+ match(input: string): NamedRegExpArray<T> | null;
51
+ }
52
+ export declare class LinkRegExpMarkupRule extends MarkupRule {
53
+ readonly regexp: NamedRegExp<{
54
+ title?: string;
55
+ href: string;
56
+ }>;
57
+ readonly render: (props: {
58
+ title: string;
59
+ href: string;
60
+ }, options: MarkupOptions) => JSXElement;
61
+ constructor(regexp: NamedRegExp<{
62
+ title?: string;
63
+ href: string;
64
+ }>, //
65
+ render: (props: {
66
+ title: string;
67
+ href: string;
68
+ }, options: MarkupOptions) => JSXElement, contexts: ImmutableArray<string>, subcontext?: string | null, priority?: number);
69
+ match(input: string, { schemes, url: base }: MarkupOptions): MarkupRuleMatch<{
70
+ title: string;
71
+ href: string;
72
+ }> | null;
73
+ }
74
+ export type MarkupRules = MarkupRule[];
package/markup/rule.js ADDED
@@ -0,0 +1,54 @@
1
+ import { formatURL, getOptionalURL } from "../util/url.js";
2
+ export class MarkupRule {
3
+ constructor(contexts, //
4
+ subcontext = null, priority = 0) {
5
+ this.contexts = contexts;
6
+ this.subcontext = subcontext;
7
+ this.priority = priority;
8
+ }
9
+ }
10
+ export class RegExpMarkupRule extends MarkupRule {
11
+ constructor(regexp, //
12
+ render, contexts, subcontext, priority) {
13
+ super(contexts, subcontext, priority);
14
+ this.regexp = regexp;
15
+ this.render = render;
16
+ }
17
+ match(input) {
18
+ return this.regexp.exec(input);
19
+ }
20
+ }
21
+ export class NamedRegExpMarkupRule extends MarkupRule {
22
+ constructor(regexp, //
23
+ render, contexts, subcontext, priority) {
24
+ super(contexts, subcontext, priority);
25
+ this.regexp = regexp;
26
+ this.render = render;
27
+ }
28
+ match(input) {
29
+ return this.regexp.exec(input);
30
+ }
31
+ }
32
+ export class LinkRegExpMarkupRule extends MarkupRule {
33
+ constructor(regexp, //
34
+ render, contexts, subcontext, priority) {
35
+ super(contexts, subcontext, priority);
36
+ this.regexp = regexp;
37
+ this.render = render;
38
+ }
39
+ // Validates that the link is a valid URL (using `getOptionalURL()` to resolve relative links relative to `options.url`).
40
+ // Validates that the link's URL scheme is in the `options.schemes` whitelist (defaults to `http` and `https`).
41
+ // Generates a default title for the link using `formatURL()` (e.g. `shax.com/my/dir`).
42
+ match(input, { schemes, url: base }) {
43
+ const match = this.regexp.exec(input);
44
+ if (match) {
45
+ const { 0: first, index, groups } = match;
46
+ const { href, title } = groups;
47
+ const url = getOptionalURL(href, base);
48
+ if (url && schemes.includes(url.protocol)) {
49
+ return { 0: first, index, groups: { href: url.href, title: (title === null || title === void 0 ? void 0 : title.trim()) || formatURL(url) } };
50
+ }
51
+ }
52
+ return null;
53
+ }
54
+ }
package/markup/rules.d.ts CHANGED
@@ -1,49 +1,13 @@
1
- import type { Data } from "../util/data.js";
2
1
  import type { JSXElement } from "../util/jsx.js";
3
- import { NamedRegExp, NamedRegExpData } from "../util/regexp.js";
4
- import { MarkupMatcher } from "./regexp.js";
5
2
  import type { MarkupOptions } from "./options.js";
6
- /** Rule for parsing string markup into a JSX element. */
7
- export interface MarkupRule<T extends Data | undefined = Data | undefined> {
8
- /**
9
- * Regular expression or custom matching function.
10
- */
11
- readonly match: (T extends undefined ? RegExp : T extends NamedRegExpData ? NamedRegExp<T> : never) | MarkupMatcher<T>;
12
- /**
13
- * Render the JSX element for this rule using the props matched by
14
- */
15
- readonly render: (orops: T, options: MarkupOptions) => JSXElement;
16
- /**
17
- * Contexts this rule should be applied in,
18
- *
19
- * @example `["block", "inline", "list"]`
20
- */
21
- readonly contexts: string[];
22
- /**
23
- * Context that children should be rendered with.
24
- *
25
- * @example `"inline"` // Children of the element rendered by this rule will be parsed against markup rules applied in the "inline" context.
26
- */
27
- readonly subcontext?: string;
28
- /**
29
- * Priority for this rule (defaults to zero).
30
- *
31
- * @example e.g. `<p>` rule is lower priority than other blocks so it matches last and paragraphs can be interrupted by e.g. `<ul>` and `<blockquote>`.
32
- * @example e.g. `<code>` rule is higher priority than other inlines so e.g. `<strong>` or `<em>` don't match inside a code block.
33
- */
34
- readonly priority?: number;
35
- }
36
- /** Any markup rule. */
37
- export type AnyMarkupRule = MarkupRule<any>;
38
- /** A set of markup rules (as an object or array). */
39
- export type MarkupRules = AnyMarkupRule[];
3
+ import { LinkRegExpMarkupRule, MarkupRules, NamedRegExpMarkupRule, RegExpMarkupRule } from "./rule.js";
40
4
  /**
41
5
  * Headings are single line only (don't allow multiline).
42
6
  * - 1-6 hashes then 1+ spaces, then the title.
43
7
  * - Same as Markdown syntax.
44
8
  * - Markdown's underline syntax is not supported (for simplification).
45
9
  */
46
- export declare const HEADING_RULE: MarkupRule<{
10
+ export declare const HEADING_RULE: NamedRegExpMarkupRule<{
47
11
  prefix: string;
48
12
  heading: string;
49
13
  }>;
@@ -54,14 +18,14 @@ export declare const HEADING_RULE: MarkupRule<{
54
18
  * - Character must be the same every time (can't mix)
55
19
  * - Might have infinite number of spaces between the characters.
56
20
  */
57
- export declare const SEPARATOR_RULE: MarkupRule;
58
- export declare const UNORDERED_RULE: MarkupRule<{
21
+ export declare const SEPARATOR_RULE: RegExpMarkupRule;
22
+ export declare const UNORDERED_RULE: NamedRegExpMarkupRule<{
59
23
  list: string;
60
24
  }>;
61
- export declare const ORDERED_RULE: MarkupRule<{
25
+ export declare const ORDERED_RULE: NamedRegExpMarkupRule<{
62
26
  list: string;
63
27
  }>;
64
- export declare const BLOCKQUOTE_RULE: MarkupRule<{
28
+ export declare const BLOCKQUOTE_RULE: NamedRegExpMarkupRule<{
65
29
  quote: string;
66
30
  }>;
67
31
  /**
@@ -71,7 +35,7 @@ export declare const BLOCKQUOTE_RULE: MarkupRule<{
71
35
  * - If there's no closing fence the code block will run to the end of the current string.
72
36
  * - Markdown-style four-space indent syntax is not supported (only fenced code, since it's easier to use).
73
37
  */
74
- export declare const FENCED_CODE_RULE: MarkupRule<{
38
+ export declare const FENCED_CODE_RULE: NamedRegExpMarkupRule<{
75
39
  wrap: string;
76
40
  title?: string;
77
41
  code: string;
@@ -80,23 +44,14 @@ export declare const FENCED_CODE_RULE: MarkupRule<{
80
44
  * Paragraph.
81
45
  * - When ordering rules, paragraph should go after other "block" context elements (because it has a very generous capture).
82
46
  */
83
- export declare const PARAGRAPH_RULE: MarkupRule<{
47
+ export declare const PARAGRAPH_RULE: NamedRegExpMarkupRule<{
84
48
  paragraph: string;
85
49
  }>;
86
- /**
87
- * Function that checks a link against the schemas allowed by rendering.
88
- * - Used by `URL_RULE~ and `LINK_RULE`
89
- * - Validates that the link is a valid URL (using `getOptionalURL()` to resolve relative links relative to `options.url`).
90
- * - Validates that the link's URL scheme is in the `options.schemes` whitelist (defaults to `http` and `https`).
91
- * - Generates a default title for the link using `formatURL()` (e.g. `shax.com/my/dir`).
92
- */
93
- export declare function getLinkMatcher(regexp: NamedRegExp<{
94
- title?: string;
95
- href: string;
96
- }>): MarkupMatcher<{
50
+ /** Render function for URL and LINK rules. */
51
+ export declare function renderLinkRule({ href, title }: {
97
52
  title: string;
98
53
  href: string;
99
- }>;
54
+ }, { rel }: MarkupOptions): JSXElement;
100
55
  /**
101
56
  * Autolinked URL starts with `http:` or `https:` or `mailto:` (any scheme in `options.schemes`) and matches an unlimited number of non-space characters.
102
57
  * - If followed by space and then text in `()` round or `[]` square brackets that will be used as the title, e.g. `http://google.com/maps (Google Maps)` or `http://google.com/maps [Google Maps]` (this syntax is from Todoist and maybe other things too).
@@ -104,14 +59,7 @@ export declare function getLinkMatcher(regexp: NamedRegExp<{
104
59
  * - If link is not valid (using `new URL(url)` then unparsed text will be returned.
105
60
  * - For security only schemes that appear in `options.schemes` will match (defaults to `http:` and `https:`).
106
61
  */
107
- export declare const URL_REGEXP: NamedRegExp<{
108
- title?: string;
109
- href: string;
110
- }>;
111
- export declare const URL_RULE: MarkupRule<{
112
- title: string;
113
- href: string;
114
- }>;
62
+ export declare const URL_RULE: LinkRegExpMarkupRule;
115
63
  /**
116
64
  * Markdown-style link.
117
65
  * - Link in standard Markdown format, e.g. `[Google Maps](http://google.com/maps)`
@@ -120,14 +68,7 @@ export declare const URL_RULE: MarkupRule<{
120
68
  * - If link is not valid (using `new URL(url)` then unparsed text will be returned.
121
69
  * - For security only `http://` or `https://` links will work (if invalid the unparsed text will be returned).
122
70
  */
123
- export declare const LINK_REGEXP: NamedRegExp<{
124
- title: string;
125
- href: string;
126
- }>;
127
- export declare const LINK_RULE: MarkupRule<{
128
- title: string;
129
- href: string;
130
- }>;
71
+ export declare const LINK_RULE: LinkRegExpMarkupRule;
131
72
  /**
132
73
  * Inline code.
133
74
  * - Text surrounded by one or more "`" backtick tilde characters.
@@ -135,7 +76,7 @@ export declare const LINK_RULE: MarkupRule<{
135
76
  * - Closing characters must exactly match opening characters.
136
77
  * - Same as Markdown syntax.
137
78
  */
138
- export declare const CODE_RULE: MarkupRule<{
79
+ export declare const CODE_RULE: NamedRegExpMarkupRule<{
139
80
  code: string;
140
81
  }>;
141
82
  /**
@@ -160,7 +101,7 @@ declare const INLINE_CHARS: {
160
101
  "=": string;
161
102
  ":": string;
162
103
  };
163
- export declare const INLINE_RULE: MarkupRule<{
104
+ export declare const INLINE_RULE: NamedRegExpMarkupRule<{
164
105
  char: keyof typeof INLINE_CHARS;
165
106
  wrap: string;
166
107
  text: string;
@@ -173,7 +114,7 @@ export declare const INLINE_RULE: MarkupRule<{
173
114
  * - This is more intuitive (a linebreak becomes a linebreak is isn't silently ignored).
174
115
  * - This works better with textareas that wrap text (since manually breaking up long lines is no longer necessary).
175
116
  */
176
- export declare const LINEBREAK_RULE: MarkupRule;
117
+ export declare const LINEBREAK_RULE: RegExpMarkupRule;
177
118
  /**
178
119
  * All markup rules.
179
120
  * - Syntax parsed by `renderMarkup()` is defined entirely by the list of rules (i.e. not by code).