applesauce-core 5.2.0 → 6.0.2

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.
Files changed (79) hide show
  1. package/dist/casts/cast.d.ts +31 -0
  2. package/dist/casts/cast.js +67 -0
  3. package/dist/casts/index.d.ts +3 -0
  4. package/dist/casts/index.js +3 -0
  5. package/dist/casts/pubkey.d.ts +27 -0
  6. package/dist/casts/pubkey.js +49 -0
  7. package/dist/casts/user.d.ts +19 -0
  8. package/dist/casts/user.js +25 -0
  9. package/dist/factories/delete.d.ts +18 -0
  10. package/dist/factories/delete.js +23 -0
  11. package/dist/factories/event.d.ts +61 -0
  12. package/dist/factories/event.js +164 -0
  13. package/dist/factories/index.d.ts +5 -0
  14. package/dist/factories/index.js +5 -0
  15. package/dist/factories/mailboxes.d.ts +33 -0
  16. package/dist/factories/mailboxes.js +57 -0
  17. package/dist/factories/profile.d.ts +46 -0
  18. package/dist/factories/profile.js +80 -0
  19. package/dist/factories/types.d.ts +56 -0
  20. package/dist/helpers/event.d.ts +11 -2
  21. package/dist/helpers/event.js +2 -1
  22. package/dist/helpers/mailboxes.d.ts +5 -1
  23. package/dist/helpers/mailboxes.js +5 -0
  24. package/dist/helpers/pipeline.d.ts +14 -1
  25. package/dist/helpers/pipeline.js +17 -2
  26. package/dist/helpers/pointers.js +2 -2
  27. package/dist/helpers/profile.d.ts +2 -2
  28. package/dist/helpers/regexp.d.ts +2 -0
  29. package/dist/helpers/regexp.js +8 -2
  30. package/dist/helpers/relays.d.ts +3 -1
  31. package/dist/helpers/relays.js +8 -10
  32. package/dist/helpers/url.d.ts +1 -4
  33. package/dist/helpers/url.js +1 -4
  34. package/dist/index.d.ts +3 -1
  35. package/dist/index.js +4 -1
  36. package/dist/observable/catch-error-inline.d.ts +3 -0
  37. package/dist/observable/catch-error-inline.js +5 -0
  38. package/dist/observable/chainable.d.ts +36 -0
  39. package/dist/observable/chainable.js +72 -0
  40. package/dist/observable/combine-latest-by-index.d.ts +10 -0
  41. package/dist/observable/combine-latest-by-index.js +121 -0
  42. package/dist/observable/combine-latest-by-key.d.ts +10 -0
  43. package/dist/observable/combine-latest-by-key.js +136 -0
  44. package/dist/observable/combine-latest-by-value.d.ts +10 -0
  45. package/dist/observable/combine-latest-by-value.js +117 -0
  46. package/dist/observable/combine-latest-by.d.ts +16 -0
  47. package/dist/observable/combine-latest-by.js +12 -0
  48. package/dist/observable/index.d.ts +10 -4
  49. package/dist/observable/index.js +10 -4
  50. package/dist/observable/timeout-with-ignore.d.ts +24 -0
  51. package/dist/observable/timeout-with-ignore.js +33 -0
  52. package/dist/operations/client.d.ts +1 -1
  53. package/dist/operations/client.js +2 -2
  54. package/dist/operations/content.d.ts +5 -2
  55. package/dist/operations/content.js +9 -7
  56. package/dist/operations/delete.d.ts +1 -1
  57. package/dist/operations/encrypted-content.d.ts +9 -3
  58. package/dist/operations/encrypted-content.js +9 -3
  59. package/dist/operations/event.d.ts +6 -4
  60. package/dist/operations/event.js +20 -12
  61. package/dist/operations/hidden-content.d.ts +8 -3
  62. package/dist/operations/hidden-content.js +11 -6
  63. package/dist/operations/mailboxes.d.ts +5 -1
  64. package/dist/operations/mailboxes.js +76 -0
  65. package/dist/operations/profile.d.ts +1 -1
  66. package/dist/operations/tag/common.d.ts +22 -7
  67. package/dist/operations/tag/common.js +33 -18
  68. package/dist/operations/tag/relay.d.ts +1 -1
  69. package/dist/operations/tags.d.ts +10 -4
  70. package/dist/operations/tags.js +19 -13
  71. package/package.json +20 -5
  72. package/dist/event-factory/event-factory.d.ts +0 -57
  73. package/dist/event-factory/event-factory.js +0 -94
  74. package/dist/event-factory/index.d.ts +0 -3
  75. package/dist/event-factory/index.js +0 -3
  76. package/dist/event-factory/methods.d.ts +0 -17
  77. package/dist/event-factory/methods.js +0 -44
  78. package/dist/event-factory/types.d.ts +0 -78
  79. /package/dist/{event-factory → factories}/types.js +0 -0
@@ -0,0 +1,121 @@
1
+ import { Observable, Subject } from "rxjs";
2
+ /** Sentinel to distinguish "no value yet" from a real value */
3
+ const NOT_YET = Symbol("NOT_YET");
4
+ /**
5
+ * Dynamic counterpart to `switchMap(() => combineLatest(...))` for arrays,
6
+ * with stable branches by index.
7
+ *
8
+ * Each array index gets its own long-lived branch (`of(value).pipe(...)`
9
+ * equivalent), and branches are only created/removed when indices are
10
+ * added/removed.
11
+ */
12
+ export function combineLatestByIndex(project) {
13
+ return (source$) => new Observable((subscriber) => {
14
+ const slots = [];
15
+ let sourceCompleted = false;
16
+ let batchingSourceNext = false;
17
+ let emittedDuringBatch = false;
18
+ function checkComplete() {
19
+ if (!sourceCompleted)
20
+ return;
21
+ for (const slot of slots) {
22
+ if (!slot.completed)
23
+ return;
24
+ }
25
+ subscriber.complete();
26
+ }
27
+ function tryEmit() {
28
+ for (const slot of slots) {
29
+ if (slot.value === NOT_YET)
30
+ return;
31
+ }
32
+ subscriber.next(slots.map((slot) => slot.value));
33
+ }
34
+ function createSlot(index) {
35
+ const input = new Subject();
36
+ const slot = { input, value: NOT_YET, completed: false };
37
+ let projected$;
38
+ try {
39
+ projected$ = project(input, index);
40
+ }
41
+ catch (err) {
42
+ input.complete();
43
+ subscriber.error(err);
44
+ return undefined;
45
+ }
46
+ slot.sub = projected$.subscribe({
47
+ next(value) {
48
+ slot.value = value;
49
+ if (batchingSourceNext) {
50
+ emittedDuringBatch = true;
51
+ return;
52
+ }
53
+ tryEmit();
54
+ },
55
+ error(err) {
56
+ subscriber.error(err);
57
+ },
58
+ complete() {
59
+ slot.completed = true;
60
+ checkComplete();
61
+ },
62
+ });
63
+ return slot;
64
+ }
65
+ const sourceSub = source$.subscribe({
66
+ next(items) {
67
+ batchingSourceNext = true;
68
+ emittedDuringBatch = false;
69
+ while (slots.length > items.length) {
70
+ const slot = slots.pop();
71
+ if (!slot)
72
+ break;
73
+ slot.sub?.unsubscribe();
74
+ slot.input.complete();
75
+ }
76
+ while (slots.length < items.length) {
77
+ const slot = createSlot(slots.length);
78
+ if (!slot) {
79
+ batchingSourceNext = false;
80
+ return;
81
+ }
82
+ slots.push(slot);
83
+ }
84
+ for (let i = 0; i < items.length; i++) {
85
+ if (subscriber.closed) {
86
+ batchingSourceNext = false;
87
+ return;
88
+ }
89
+ const slot = slots[i];
90
+ if (!slot) {
91
+ batchingSourceNext = false;
92
+ return;
93
+ }
94
+ slot.input.next(items[i]);
95
+ }
96
+ // Emit once for this source update if possible.
97
+ if (emittedDuringBatch || items.length === 0)
98
+ tryEmit();
99
+ batchingSourceNext = false;
100
+ },
101
+ error(err) {
102
+ subscriber.error(err);
103
+ },
104
+ complete() {
105
+ sourceCompleted = true;
106
+ for (const slot of slots) {
107
+ slot.input.complete();
108
+ }
109
+ checkComplete();
110
+ },
111
+ });
112
+ return () => {
113
+ sourceSub.unsubscribe();
114
+ for (const slot of slots) {
115
+ slot.sub?.unsubscribe();
116
+ slot.input.complete();
117
+ }
118
+ slots.length = 0;
119
+ };
120
+ });
121
+ }
@@ -0,0 +1,10 @@
1
+ import { Observable, type OperatorFunction } from "rxjs";
2
+ /**
3
+ * Dynamic counterpart to `switchMap(() => combineLatest(...))` for records,
4
+ * with stable branches by key.
5
+ *
6
+ * Each record key gets its own long-lived branch. Branches are only
7
+ * created/removed when keys are added/removed; value updates are pushed through
8
+ * the existing key branch.
9
+ */
10
+ export declare function combineLatestByKey<Input extends Record<string, unknown>, R>(project: (source$: Observable<Input[Extract<keyof Input, string>]>, key: Extract<keyof Input, string>) => Observable<R>): OperatorFunction<Input, Record<Extract<keyof Input, string>, R>>;
@@ -0,0 +1,136 @@
1
+ import { Observable, Subject } from "rxjs";
2
+ /** Sentinel to distinguish "no value yet" from a real value */
3
+ const NOT_YET = Symbol("NOT_YET");
4
+ /**
5
+ * Dynamic counterpart to `switchMap(() => combineLatest(...))` for records,
6
+ * with stable branches by key.
7
+ *
8
+ * Each record key gets its own long-lived branch. Branches are only
9
+ * created/removed when keys are added/removed; value updates are pushed through
10
+ * the existing key branch.
11
+ */
12
+ export function combineLatestByKey(project) {
13
+ return (source$) => new Observable((subscriber) => {
14
+ const slots = new Map();
15
+ let sourceCompleted = false;
16
+ let currentKeys = [];
17
+ let batchingSourceNext = false;
18
+ let emittedDuringBatch = false;
19
+ function checkComplete() {
20
+ if (!sourceCompleted)
21
+ return;
22
+ for (const slot of slots.values()) {
23
+ if (!slot.completed)
24
+ return;
25
+ }
26
+ subscriber.complete();
27
+ }
28
+ function tryEmit() {
29
+ for (const key of currentKeys) {
30
+ const slot = slots.get(key);
31
+ if (!slot || slot.value === NOT_YET)
32
+ return;
33
+ }
34
+ const out = {};
35
+ for (const key of currentKeys) {
36
+ const slot = slots.get(key);
37
+ if (!slot)
38
+ return;
39
+ out[key] = slot.value;
40
+ }
41
+ subscriber.next(out);
42
+ if (batchingSourceNext)
43
+ emittedDuringBatch = true;
44
+ }
45
+ function createSlot(key) {
46
+ const input = new Subject();
47
+ const slot = { input, value: NOT_YET, completed: false };
48
+ let child$;
49
+ try {
50
+ child$ = project(input, key);
51
+ }
52
+ catch (err) {
53
+ input.complete();
54
+ subscriber.error(err);
55
+ return undefined;
56
+ }
57
+ slot.sub = child$.subscribe({
58
+ next(value) {
59
+ slot.value = value;
60
+ if (batchingSourceNext) {
61
+ emittedDuringBatch = true;
62
+ return;
63
+ }
64
+ tryEmit();
65
+ },
66
+ error(err) {
67
+ subscriber.error(err);
68
+ },
69
+ complete() {
70
+ slot.completed = true;
71
+ checkComplete();
72
+ },
73
+ });
74
+ return slot;
75
+ }
76
+ const sourceSub = source$.subscribe({
77
+ next(input) {
78
+ batchingSourceNext = true;
79
+ emittedDuringBatch = false;
80
+ const entries = Object.entries(input);
81
+ currentKeys = entries.map(([key]) => key);
82
+ const newKeysSet = new Set(currentKeys);
83
+ for (const [key, slot] of slots) {
84
+ if (!newKeysSet.has(key)) {
85
+ slot.sub?.unsubscribe();
86
+ slot.input.complete();
87
+ slots.delete(key);
88
+ }
89
+ }
90
+ for (const key of currentKeys) {
91
+ if (!slots.has(key)) {
92
+ const slot = createSlot(key);
93
+ if (!slot) {
94
+ batchingSourceNext = false;
95
+ return;
96
+ }
97
+ slots.set(key, slot);
98
+ }
99
+ }
100
+ for (const [key, value] of entries) {
101
+ if (subscriber.closed) {
102
+ batchingSourceNext = false;
103
+ return;
104
+ }
105
+ const slot = slots.get(key);
106
+ if (!slot) {
107
+ batchingSourceNext = false;
108
+ return;
109
+ }
110
+ slot.input.next(value);
111
+ }
112
+ if (emittedDuringBatch || entries.length === 0)
113
+ tryEmit();
114
+ batchingSourceNext = false;
115
+ },
116
+ error(err) {
117
+ subscriber.error(err);
118
+ },
119
+ complete() {
120
+ sourceCompleted = true;
121
+ for (const slot of slots.values()) {
122
+ slot.input.complete();
123
+ }
124
+ checkComplete();
125
+ },
126
+ });
127
+ return () => {
128
+ sourceSub.unsubscribe();
129
+ for (const slot of slots.values()) {
130
+ slot.sub?.unsubscribe();
131
+ slot.input.complete();
132
+ }
133
+ slots.clear();
134
+ };
135
+ });
136
+ }
@@ -0,0 +1,10 @@
1
+ import { Observable, type OperatorFunction } from "rxjs";
2
+ /**
3
+ * Dynamic counterpart to `switchMap((values) => combineLatest(values.map(...)))`
4
+ * for arrays, with stable branches by value.
5
+ *
6
+ * A single branch is created per unique array value (Map key semantics) and is
7
+ * only created/removed when values are added/removed across emissions. Duplicate
8
+ * values in the same array share the same branch.
9
+ */
10
+ export declare function combineLatestByValue<T, R>(project: (value: T) => Observable<R>): OperatorFunction<readonly T[], Map<T, R>>;
@@ -0,0 +1,117 @@
1
+ import { Observable } from "rxjs";
2
+ /** Sentinel to distinguish "no value yet" from a real value */
3
+ const NOT_YET = Symbol("NOT_YET");
4
+ /**
5
+ * Dynamic counterpart to `switchMap((values) => combineLatest(values.map(...)))`
6
+ * for arrays, with stable branches by value.
7
+ *
8
+ * A single branch is created per unique array value (Map key semantics) and is
9
+ * only created/removed when values are added/removed across emissions. Duplicate
10
+ * values in the same array share the same branch.
11
+ */
12
+ export function combineLatestByValue(project) {
13
+ return (source$) => new Observable((subscriber) => {
14
+ const slots = new Map();
15
+ let sourceCompleted = false;
16
+ let currentValues = [];
17
+ let batchingSourceNext = false;
18
+ function checkComplete() {
19
+ if (!sourceCompleted)
20
+ return;
21
+ for (const slot of slots.values()) {
22
+ if (!slot.completed)
23
+ return;
24
+ }
25
+ subscriber.complete();
26
+ }
27
+ function tryEmit() {
28
+ for (const value of currentValues) {
29
+ const slot = slots.get(value);
30
+ if (!slot || slot.value === NOT_YET)
31
+ return;
32
+ }
33
+ const out = new Map();
34
+ for (const value of currentValues) {
35
+ const slot = slots.get(value);
36
+ if (!slot)
37
+ return;
38
+ out.set(value, slot.value);
39
+ }
40
+ subscriber.next(out);
41
+ }
42
+ function createSlot(value) {
43
+ const slot = { value: NOT_YET, completed: false };
44
+ let child$;
45
+ try {
46
+ child$ = project(value);
47
+ }
48
+ catch (err) {
49
+ subscriber.error(err);
50
+ return undefined;
51
+ }
52
+ slot.sub = child$.subscribe({
53
+ next(nextValue) {
54
+ slot.value = nextValue;
55
+ if (batchingSourceNext) {
56
+ return;
57
+ }
58
+ tryEmit();
59
+ },
60
+ error(err) {
61
+ subscriber.error(err);
62
+ },
63
+ complete() {
64
+ slot.completed = true;
65
+ checkComplete();
66
+ },
67
+ });
68
+ return slot;
69
+ }
70
+ const sourceSub = source$.subscribe({
71
+ next(input) {
72
+ batchingSourceNext = true;
73
+ const uniqueValues = [];
74
+ const nextValueSet = new Set();
75
+ for (const value of input) {
76
+ if (nextValueSet.has(value))
77
+ continue;
78
+ nextValueSet.add(value);
79
+ uniqueValues.push(value);
80
+ }
81
+ currentValues = uniqueValues;
82
+ for (const [value, slot] of slots) {
83
+ if (!nextValueSet.has(value)) {
84
+ slot.sub?.unsubscribe();
85
+ slots.delete(value);
86
+ }
87
+ }
88
+ for (const value of currentValues) {
89
+ if (!slots.has(value)) {
90
+ const slot = createSlot(value);
91
+ if (!slot) {
92
+ batchingSourceNext = false;
93
+ return;
94
+ }
95
+ slots.set(value, slot);
96
+ }
97
+ }
98
+ tryEmit();
99
+ batchingSourceNext = false;
100
+ },
101
+ error(err) {
102
+ subscriber.error(err);
103
+ },
104
+ complete() {
105
+ sourceCompleted = true;
106
+ checkComplete();
107
+ },
108
+ });
109
+ return () => {
110
+ sourceSub.unsubscribe();
111
+ for (const slot of slots.values()) {
112
+ slot.sub?.unsubscribe();
113
+ }
114
+ slots.clear();
115
+ };
116
+ });
117
+ }
@@ -0,0 +1,16 @@
1
+ import { type OperatorFunction } from "rxjs";
2
+ /** Operator object type: one branch operator per output key. */
3
+ type CombineLatestByObjectOperators<Input, Output extends Record<string, unknown>> = {
4
+ [K in keyof Output]: OperatorFunction<Input, Output[K]>;
5
+ };
6
+ /** Operator tuple type: one branch operator per output index. */
7
+ type CombineLatestByArrayOperators<Input, Output extends readonly unknown[]> = {
8
+ [K in keyof Output]: OperatorFunction<Input, Output[K]>;
9
+ };
10
+ /**
11
+ * Branches a source through multiple operators and combines branch outputs with
12
+ * `combineLatest` semantics.
13
+ */
14
+ export declare function combineLatestBy<Input, Output extends Record<string, unknown>>(operators: CombineLatestByObjectOperators<Input, Output>): OperatorFunction<Input, Output>;
15
+ export declare function combineLatestBy<Input, Output extends readonly unknown[]>(operators: CombineLatestByArrayOperators<Input, Output>): OperatorFunction<Input, Output>;
16
+ export {};
@@ -0,0 +1,12 @@
1
+ import { combineLatest, connect } from "rxjs";
2
+ export function combineLatestBy(operators) {
3
+ return connect((shared$) => {
4
+ if (Array.isArray(operators)) {
5
+ const branches = operators.map((op) => shared$.pipe(op));
6
+ return combineLatest(branches);
7
+ }
8
+ const objectOperators = operators;
9
+ const branches = Object.fromEntries(Object.entries(objectOperators).map(([key, op]) => [key, shared$.pipe(op)]));
10
+ return combineLatest(branches);
11
+ });
12
+ }
@@ -1,10 +1,16 @@
1
- export { firstValueFrom, lastValueFrom, combineLatest, merge } from "rxjs";
2
- export { Observable, Subject, BehaviorSubject, ReplaySubject } from "rxjs";
1
+ export { BehaviorSubject, combineLatest, firstValueFrom, lastValueFrom, merge, Observable, ReplaySubject, Subject, } from "rxjs";
2
+ export * from "./catch-error-inline.js";
3
+ export * from "./chainable.js";
4
+ export * from "./combine-latest-by-index.js";
5
+ export * from "./combine-latest-by-key.js";
6
+ export * from "./combine-latest-by-value.js";
7
+ export * from "./combine-latest-by.js";
3
8
  export * from "./defined.js";
4
9
  export * from "./get-observable-value.js";
5
- export * from "./map-events-to-timeline.js";
6
10
  export * from "./map-events-to-store.js";
11
+ export * from "./map-events-to-timeline.js";
12
+ export * from "./relay-selection.js";
7
13
  export * from "./simple-timeout.js";
14
+ export * from "./timeout-with-ignore.js";
8
15
  export * from "./watch-event-updates.js";
9
16
  export * from "./with-immediate-value.js";
10
- export * from "./relay-selection.js";
@@ -1,11 +1,17 @@
1
1
  // Re-export some useful rxjs functions
2
- export { firstValueFrom, lastValueFrom, combineLatest, merge } from "rxjs";
3
- export { Observable, Subject, BehaviorSubject, ReplaySubject } from "rxjs";
2
+ export { BehaviorSubject, combineLatest, firstValueFrom, lastValueFrom, merge, Observable, ReplaySubject, Subject, } from "rxjs";
3
+ export * from "./catch-error-inline.js";
4
+ export * from "./chainable.js";
5
+ export * from "./combine-latest-by-index.js";
6
+ export * from "./combine-latest-by-key.js";
7
+ export * from "./combine-latest-by-value.js";
8
+ export * from "./combine-latest-by.js";
4
9
  export * from "./defined.js";
5
10
  export * from "./get-observable-value.js";
6
- export * from "./map-events-to-timeline.js";
7
11
  export * from "./map-events-to-store.js";
12
+ export * from "./map-events-to-timeline.js";
13
+ export * from "./relay-selection.js";
8
14
  export * from "./simple-timeout.js";
15
+ export * from "./timeout-with-ignore.js";
9
16
  export * from "./watch-event-updates.js";
10
17
  export * from "./with-immediate-value.js";
11
- export * from "./relay-selection.js";
@@ -0,0 +1,24 @@
1
+ import { type ObservableInput, type ObservedValueOf, type OperatorFunction, type TimeoutConfig } from "rxjs";
2
+ /**
3
+ * Like RxJS `timeout`, but only for emissions that are not ignored.
4
+ *
5
+ * Values that match `config.ignore` are forwarded immediately and do not affect
6
+ * timeout state (`first`/`each`). Timeout timing only observes non-ignored values.
7
+ *
8
+ * Example usage:
9
+ *
10
+ * source$.pipe(
11
+ * timeoutWithIgnore({
12
+ * first: 1500,
13
+ * each: 1000,
14
+ * with: () => of(null),
15
+ * ignore: value => value === undefined,
16
+ * })
17
+ * )
18
+ *
19
+ * @param config RxJS timeout config with an additional `ignore` matcher
20
+ * (`(value) => boolean` or array of values) used to bypass timeout checks.
21
+ */
22
+ export declare function timeoutWithIgnore<T, O extends ObservableInput<unknown> = ObservableInput<T>, M = unknown>(config: TimeoutConfig<T, O, M> & {
23
+ ignore: readonly T[] | ((value: T) => boolean);
24
+ }): OperatorFunction<T, T | ObservedValueOf<O>>;
@@ -0,0 +1,33 @@
1
+ import { endWith, filter, ignoreElements, merge, share, takeUntil, timeout, } from "rxjs";
2
+ /**
3
+ * Like RxJS `timeout`, but only for emissions that are not ignored.
4
+ *
5
+ * Values that match `config.ignore` are forwarded immediately and do not affect
6
+ * timeout state (`first`/`each`). Timeout timing only observes non-ignored values.
7
+ *
8
+ * Example usage:
9
+ *
10
+ * source$.pipe(
11
+ * timeoutWithIgnore({
12
+ * first: 1500,
13
+ * each: 1000,
14
+ * with: () => of(null),
15
+ * ignore: value => value === undefined,
16
+ * })
17
+ * )
18
+ *
19
+ * @param config RxJS timeout config with an additional `ignore` matcher
20
+ * (`(value) => boolean` or array of values) used to bypass timeout checks.
21
+ */
22
+ export function timeoutWithIgnore(config) {
23
+ return (source) => {
24
+ const { ignore, ...timeoutConfig } = config;
25
+ const isIgnored = (value) => (typeof ignore === "function" ? ignore(value) : ignore.includes(value));
26
+ const shared$ = source.pipe(share());
27
+ const watched$ = shared$.pipe(filter((value) => !isIgnored(value)));
28
+ const ignored$ = shared$.pipe(filter(isIgnored));
29
+ const timed$ = watched$.pipe(timeout(timeoutConfig), share());
30
+ // Stop forwarding ignored values as soon as the timed branch completes/errors.
31
+ return merge(timed$, ignored$).pipe(takeUntil(timed$.pipe(ignoreElements(), endWith(true))));
32
+ };
33
+ }
@@ -1,4 +1,4 @@
1
- import { EventOperation } from "../event-factory/types.js";
1
+ import type { EventOperation } from "../factories/types.js";
2
2
  import { AddressPointer } from "../helpers/pointers.js";
3
3
  /** Includes a NIP-89 client tag in an event*/
4
4
  export declare function setClient(name: string, pointer?: Omit<AddressPointer, "kind" | "relays">, replace?: boolean): EventOperation;
@@ -6,7 +6,7 @@ import { includeSingletonTag } from "./tags.js";
6
6
  const NEVER_ATTACH_CLIENT_TAG = [kinds.EncryptedDirectMessage, kinds.GiftWrap, kinds.Seal, kinds.PrivateDirectMessage];
7
7
  /** Includes a NIP-89 client tag in an event*/
8
8
  export function setClient(name, pointer, replace = true) {
9
- return (draft, ctx) => {
9
+ return (draft) => {
10
10
  if (NEVER_ATTACH_CLIENT_TAG.includes(draft.kind))
11
11
  return draft;
12
12
  else {
@@ -17,7 +17,7 @@ export function setClient(name, pointer, replace = true) {
17
17
  kind: kinds.Handlerinformation,
18
18
  })
19
19
  : undefined;
20
- return includeSingletonTag(fillAndTrimTag(["client", name, coordinate]), replace)(draft, ctx);
20
+ return includeSingletonTag(fillAndTrimTag(["client", name, coordinate]), replace)(draft);
21
21
  }
22
22
  };
23
23
  }
@@ -1,4 +1,4 @@
1
- import { Emoji, EventOperation } from "../event-factory/types.js";
1
+ import type { EventOperation, Emoji } from "../factories/types.js";
2
2
  /** Override the event content */
3
3
  export declare function setContent(content: string): EventOperation;
4
4
  /** Replaces any `@npub` or bare npub mentions with nostr: prefix */
@@ -11,7 +11,10 @@ export declare function setContentWarning(warning: boolean | string): EventOpera
11
11
  export declare function includeQuoteTags(): EventOperation;
12
12
  /** Adds "t" tags for every #hashtag in the content */
13
13
  export declare function includeContentHashtags(): EventOperation;
14
- /** Adds "emoji" tags for NIP-30 emojis used in the content */
14
+ /**
15
+ * Adds "emoji" tags for NIP-30 emojis used in the content
16
+ * @param emojis - Array of custom emojis to check for in content
17
+ */
15
18
  export declare function includeEmojis(emojis?: Emoji[]): EventOperation;
16
19
  export type TextContentOptions = {
17
20
  emojis?: Emoji[];
@@ -16,7 +16,7 @@ export function setContent(content) {
16
16
  export function repairNostrLinks() {
17
17
  return (draft) => ({
18
18
  ...draft,
19
- content: draft.content.replaceAll(/(?<=^|\s)(?:@)?((?:npub|note|nprofile|nevent|naddr)1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58})/gi, "nostr:$1"),
19
+ content: draft.content.replaceAll(/(?<=^|\s)(?:@)?((?:npub|note|nprofile|nevent|naddr)1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{58,})/gi, "nostr:$1"),
20
20
  });
21
21
  }
22
22
  /** "p" tag any pubkey mentioned in the content using nostr: links */
@@ -76,15 +76,17 @@ export function includeContentHashtags() {
76
76
  return { ...draft, tags };
77
77
  };
78
78
  }
79
- /** Adds "emoji" tags for NIP-30 emojis used in the content */
80
- export function includeEmojis(emojis) {
81
- return (draft, ctx) => {
82
- const all = [...(ctx.emojis ?? []), ...(emojis ?? [])];
79
+ /**
80
+ * Adds "emoji" tags for NIP-30 emojis used in the content
81
+ * @param emojis - Array of custom emojis to check for in content
82
+ */
83
+ export function includeEmojis(emojis = []) {
84
+ return (draft) => {
83
85
  const tags = Array.from(draft.tags);
84
- // create tags for all occurrences of #hashtag
86
+ // create tags for all occurrences of :emoji:
85
87
  const matches = draft.content.matchAll(Expressions.emoji);
86
88
  for (const [_, name] of matches) {
87
- const emoji = all.find((e) => e.shortcode === name);
89
+ const emoji = emojis.find((e) => e.shortcode === name);
88
90
  if (emoji?.url) {
89
91
  tags.push(emoji.address
90
92
  ? ["emoji", emoji.shortcode, emoji.url, getReplaceableAddressFromPointer(emoji.address)]
@@ -1,4 +1,4 @@
1
- import { EventOperation } from "../event-factory/types.js";
1
+ import type { EventOperation } from "../factories/types.js";
2
2
  import { NostrEvent } from "../helpers/event.js";
3
3
  /** Sets the necessary tags for a NIP-09 delete event to point to a the events being deleted */
4
4
  export declare function setDeleteEvents(events: (string | NostrEvent)[]): EventOperation;
@@ -1,4 +1,10 @@
1
- import { EventOperation } from "../event-factory/types.js";
1
+ import type { EventOperation } from "../factories/types.js";
2
2
  import { EncryptionMethod } from "../helpers/encrypted-content.js";
3
- /** Sets the content to be encrypted to the pubkey with optional override method */
4
- export declare function setEncryptedContent(pubkey: string, content: string, override?: EncryptionMethod): EventOperation;
3
+ /**
4
+ * Sets the content to be encrypted to the pubkey with optional override method
5
+ * @param pubkey - Pubkey to encrypt the content for
6
+ * @param content - Plaintext content to encrypt
7
+ * @param signer - EventSigner for encryption
8
+ * @param override - Optional encryption method override
9
+ */
10
+ export declare function setEncryptedContent(pubkey: string, content: string, signer?: import("../factories/types.js").EventSigner, override?: EncryptionMethod): EventOperation;
@@ -1,7 +1,13 @@
1
1
  import { EncryptedContentSymbol, getEncryptedContentEncryptionMethods, } from "../helpers/encrypted-content.js";
2
- /** Sets the content to be encrypted to the pubkey with optional override method */
3
- export function setEncryptedContent(pubkey, content, override) {
4
- return async (draft, { signer }) => {
2
+ /**
3
+ * Sets the content to be encrypted to the pubkey with optional override method
4
+ * @param pubkey - Pubkey to encrypt the content for
5
+ * @param content - Plaintext content to encrypt
6
+ * @param signer - EventSigner for encryption
7
+ * @param override - Optional encryption method override
8
+ */
9
+ export function setEncryptedContent(pubkey, content, signer, override) {
10
+ return async (draft) => {
5
11
  if (!signer)
6
12
  throw new Error("Signer required for encrypted content");
7
13
  // Set method based on kind if not provided