silentium 0.0.168 → 0.0.170
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/CHANGELOG.md +15 -0
- package/dist/silentium.cjs +9 -3
- package/dist/silentium.cjs.map +1 -1
- package/dist/silentium.d.ts +25 -23
- package/dist/silentium.js +8 -3
- package/dist/silentium.js.map +1 -1
- package/dist/silentium.min.js +1 -1
- package/dist/silentium.min.mjs +1 -1
- package/dist/silentium.min.mjs.map +1 -1
- package/dist/silentium.mjs +8 -3
- package/dist/silentium.mjs.map +1 -1
- package/package.json +1 -1
- package/src/base/Message.ts +2 -2
- package/src/base/MessageSource.ts +2 -2
- package/src/base/Silence.test.ts +13 -1
- package/src/base/Silence.ts +8 -2
- package/src/components/Applied.test.ts +9 -0
- package/src/components/Race.test.ts +131 -0
- package/src/components/Race.ts +21 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.0.170](https://github.com/silentium-lab/silentium/compare/v0.0.169...v0.0.170) (2025-12-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **main:** builded ([7e7399e](https://github.com/silentium-lab/silentium/commit/7e7399e2a077c65a2d90b051aac5538118af817f))
|
|
11
|
+
* **main:** race component ([aa0e52e](https://github.com/silentium-lab/silentium/commit/aa0e52e7c2abac263e65d60008fb28d157507af4))
|
|
12
|
+
|
|
13
|
+
### [0.0.169](https://github.com/silentium-lab/silentium/compare/v0.0.168...v0.0.169) (2025-12-05)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **main:** ability to reset cache inside silence ([0de79ac](https://github.com/silentium-lab/silentium/commit/0de79ac9a99ddddacde791fef19042ea9f0b4939))
|
|
19
|
+
|
|
5
20
|
### [0.0.168](https://github.com/silentium-lab/silentium/compare/v0.0.167...v0.0.168) (2025-12-04)
|
|
6
21
|
|
|
7
22
|
|
package/dist/silentium.cjs
CHANGED
|
@@ -82,9 +82,14 @@ class Rejections {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
const ResetSilenceCache = Symbol("reset-silence-cache");
|
|
85
86
|
function Silence(resolve) {
|
|
86
87
|
let lastValue;
|
|
87
88
|
return (v) => {
|
|
89
|
+
if (v === ResetSilenceCache) {
|
|
90
|
+
lastValue = void 0;
|
|
91
|
+
v = void 0;
|
|
92
|
+
}
|
|
88
93
|
if (isFilled(v) && v !== lastValue) {
|
|
89
94
|
lastValue = v;
|
|
90
95
|
resolve(v);
|
|
@@ -107,9 +112,9 @@ var __defProp$5 = Object.defineProperty;
|
|
|
107
112
|
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
108
113
|
var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
109
114
|
function Message(executor) {
|
|
110
|
-
return new
|
|
115
|
+
return new MessageImpl(executor);
|
|
111
116
|
}
|
|
112
|
-
class
|
|
117
|
+
class MessageImpl {
|
|
113
118
|
constructor(executor) {
|
|
114
119
|
this.executor = executor;
|
|
115
120
|
__publicField$5(this, "rejections", new Rejections());
|
|
@@ -691,7 +696,7 @@ exports.LateImpl = LateImpl;
|
|
|
691
696
|
exports.Local = Local;
|
|
692
697
|
exports.Map = Map$1;
|
|
693
698
|
exports.Message = Message;
|
|
694
|
-
exports.
|
|
699
|
+
exports.MessageImpl = MessageImpl;
|
|
695
700
|
exports.MessageSource = MessageSource;
|
|
696
701
|
exports.MessageSourceImpl = MessageSourceImpl;
|
|
697
702
|
exports.New = New;
|
|
@@ -702,6 +707,7 @@ exports.Primitive = Primitive;
|
|
|
702
707
|
exports.PrimitiveImpl = PrimitiveImpl;
|
|
703
708
|
exports.Process = Process;
|
|
704
709
|
exports.Rejections = Rejections;
|
|
710
|
+
exports.ResetSilenceCache = ResetSilenceCache;
|
|
705
711
|
exports.Sequence = Sequence;
|
|
706
712
|
exports.Shared = Shared;
|
|
707
713
|
exports.SharedImpl = SharedImpl;
|
package/dist/silentium.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"silentium.cjs","sources":["../src/helpers/guards.ts","../src/base/Destroyable.ts","../src/base/DestroyContainer.ts","../src/base/Rejections.ts","../src/base/Silence.ts","../src/helpers/ensures.ts","../src/base/Message.ts","../src/base/Of.ts","../src/base/ActualMessage.ts","../src/base/Chainable.ts","../src/base/Local.ts","../src/base/MessageSource.ts","../src/base/New.ts","../src/base/Void.ts","../src/components/All.ts","../src/components/Any.ts","../src/components/Applied.ts","../src/components/AppliedDestructured.ts","../src/components/Primitive.ts","../src/components/Shared.ts","../src/components/Late.ts","../src/components/Catch.ts","../src/components/Chain.ts","../src/components/Computed.ts","../src/components/Context.ts","../src/components/ContextChain.ts","../src/components/ContextOf.ts","../src/components/Filtered.ts","../src/components/Empty.ts","../src/components/ExecutorApplied.ts","../src/components/Freeze.ts","../src/components/FromEvent.ts","../src/components/Map.ts","../src/components/Once.ts","../src/components/Process.ts","../src/components/Sequence.ts","../src/components/Stream.ts"],"sourcesContent":["import { DestroyableType, DestroyedType } from \"types/DestroyableType\";\nimport { MessageType } from \"types/MessageType\";\nimport { SourceType } from \"types/SourceType\";\n\n/**\n * Checks that the value is neither undefined nor null\n */\nexport const isFilled = <T>(\n value?: T,\n): value is Exclude<T, null | undefined> => {\n return value !== undefined && value !== null;\n};\n\n/**\n * Checks that the object is an message\n */\nexport function isMessage(o: unknown): o is MessageType {\n return (\n o !== null &&\n typeof o === \"object\" &&\n \"then\" in o &&\n typeof (o as any).then === \"function\"\n );\n}\n\n/**\n * Checks that the object is an message\n */\nexport function isSource(o: unknown): o is SourceType {\n return (\n o !== null &&\n typeof o === \"object\" &&\n \"use\" in o &&\n typeof (o as any).use === \"function\"\n );\n}\n\n/**\n * Checks that the object is destroyable\n */\nexport function isDestroyable(o: unknown): o is DestroyableType {\n return (\n o !== null &&\n typeof o === \"object\" &&\n \"destroy\" in o &&\n typeof (o as any).destroy === \"function\"\n );\n}\n\n/**\n * Checks that the object can indicate whether it has been destroyed or not\n */\nexport function isDestroyed(o: unknown): o is DestroyedType {\n return (\n o !== null &&\n typeof o === \"object\" &&\n \"destroyed\" in o &&\n typeof (o as any).destroyed === \"function\"\n );\n}\n","import { isDestroyable } from \"helpers/guards\";\nimport { DestroyableType } from \"types/DestroyableType\";\n\n/**\n * Allows creating an object that definitely has a destructor,\n * useful to avoid creating unnecessary conditions\n */\nexport function Destroyable<T>(base: T) {\n return new DestroyableImpl(base);\n}\n\nexport class DestroyableImpl<T> implements DestroyableType {\n public constructor(private base: T) {}\n\n public destroy(): this {\n if (isDestroyable(this.base)) {\n this.base.destroy();\n }\n\n if (typeof this.base === \"function\") {\n this.base();\n }\n\n return this;\n }\n}\n","import { Destroyable } from \"base/Destroyable\";\nimport { DestroyableType } from \"types/DestroyableType\";\n\n/**\n * An object that allows collecting all disposable objects and\n * disposing them later all together\n */\nexport function DestroyContainer() {\n return new DestroyContainerImpl();\n}\n\nexport class DestroyContainerImpl implements DestroyableType {\n private destructors: DestroyableType[] = [];\n\n public add<R>(e: R): R {\n this.destructors.push(Destroyable(e));\n return e;\n }\n\n public destroy() {\n this.destructors.forEach((d) => d.destroy());\n this.destructors.length = 0;\n return this;\n }\n}\n","import { ConstructorType } from \"types/ConstructorType\";\n\n/**\n * Handles rejections collection\n */\nexport class Rejections {\n private catchers: ConstructorType<[unknown]>[] = [];\n private lastRejectReason: unknown = null;\n\n public reject = (reason: unknown) => {\n this.lastRejectReason = reason;\n this.catchers.forEach((catcher) => {\n catcher(reason);\n });\n };\n\n public catch(rejected: ConstructorType<[unknown]>) {\n if (this.lastRejectReason !== null) {\n rejected(this.lastRejectReason);\n }\n this.catchers.push(rejected);\n return this;\n }\n\n public destroy() {\n this.catchers.length = 0;\n return this;\n }\n}\n","import { isFilled } from \"helpers/guards\";\nimport { ConstructorType } from \"types/ConstructorType\";\n\n/**\n * Silence is null or undefined or duplicated values\n * Everything else is not silence\n */\nexport function Silence<T>(resolve: ConstructorType<[T]>) {\n let lastValue: T;\n return (v: T) => {\n if (isFilled(v) && v !== lastValue) {\n lastValue = v;\n resolve(v);\n }\n };\n}\n","import { isMessage } from \"helpers/guards\";\n\nexport function ensureFunction(v: unknown, label: string) {\n if (typeof v !== \"function\") {\n throw new Error(`${label}: is not function`);\n }\n}\n\nexport function ensureMessage(v: unknown, label: string) {\n if (!isMessage(v)) {\n throw new Error(`${label}: is not message`);\n }\n}\n","import { DestroyContainer } from \"base/DestroyContainer\";\nimport { Rejections } from \"base/Rejections\";\nimport { Silence } from \"base/Silence\";\nimport { ensureFunction } from \"helpers/ensures\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { DestroyableType } from \"types/DestroyableType\";\nimport { MessageType } from \"types/MessageType\";\n\nexport type MessageExecutorType<T> = (\n resolve: ConstructorType<[T]>,\n reject: ConstructorType<[unknown]>,\n) => MessageType | (() => void) | void;\n\n/**\n * A message created from an executor function.\n * The executor function can return a message destruction function.\n */\nexport function Message<T>(executor: MessageExecutorType<T>) {\n return new MessageRx<T>(executor);\n}\n\n/**\n * Reactive message implementation\n */\nexport class MessageRx<T> implements MessageType<T>, DestroyableType {\n private rejections = new Rejections();\n private dc = DestroyContainer();\n\n public constructor(private executor: MessageExecutorType<T>) {\n ensureFunction(executor, \"Message: executor\");\n }\n\n public then(resolve: ConstructorType<[T]>) {\n try {\n this.dc.add(this.executor(Silence(resolve), this.rejections.reject));\n } catch (e: any) {\n this.rejections.reject(e);\n }\n return this;\n }\n\n public catch(rejected: ConstructorType<[unknown]>) {\n this.rejections.catch(rejected);\n return this;\n }\n\n public destroy() {\n this.dc.destroy();\n this.rejections.destroy();\n return this;\n }\n}\n","import { Message } from \"base/Message\";\n\n/**\n * Helps convert a value into a message\n */\nexport function Of<T>(value: T) {\n return Message<T>(function OfImpl(r) {\n r(value);\n });\n}\n","import { Of } from \"base/Of\";\nimport { isMessage } from \"helpers/guards\";\nimport { MaybeMessage, MessageType } from \"types/MessageType\";\n\n/**\n * A function that helps to ensure that\n * the message is indeed a message object\n * and not just a value\n */\nexport function ActualMessage<T>(message: MaybeMessage<T>): MessageType<T> {\n return isMessage(message) ? message : Of(message);\n}\n","import { ChainableType } from \"types/ChainableType\";\nimport { MessageType } from \"types/MessageType\";\nimport { SourceType } from \"types/SourceType\";\n\n/**\n * Helps to connect Different\n * message and source\n */\nexport function Chainable<T>(src: SourceType<T>) {\n return new ChainableImpl(src);\n}\n\nexport class ChainableImpl<T> implements ChainableType<T> {\n public constructor(private src: SourceType<T>) {}\n\n public chain($m: MessageType<T>) {\n $m.then(this.src.use.bind(this.src));\n return this;\n }\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { MaybeMessage } from \"types/MessageType\";\n\n/**\n * Create local copy of source what can be destroyed\n */\nexport function Local<T>(_base: MaybeMessage<T>) {\n const $base = ActualMessage(_base);\n return Message<T>(function LocalImpl(resolve, reject) {\n let destroyed = false;\n $base.then((v) => {\n if (!destroyed) {\n resolve(v);\n }\n });\n $base.catch(reject);\n return () => {\n destroyed = true;\n };\n });\n}\n","import { Message, MessageExecutorType, MessageRx } from \"base/Message\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MessageSourceType } from \"types/SourceType\";\n\n/**\n * Base message source object\n */\nexport function MessageSource<T>(\n messageExecutor: MessageExecutorType<T>,\n sourceExecutor: ConstructorType<[T]>,\n) {\n return new MessageSourceImpl(messageExecutor, sourceExecutor);\n}\n\nexport class MessageSourceImpl<T> implements MessageSourceType<T> {\n private message: MessageRx<T>;\n\n public constructor(\n messageExecutor: MessageExecutorType<T>,\n private sourceExecutor: ConstructorType<[T]>,\n ) {\n this.message = Message(messageExecutor);\n }\n\n public use(value: T): this {\n this.sourceExecutor(value);\n return this;\n }\n\n public then(resolved: ConstructorType<[T]>): this {\n this.message.then(resolved);\n return this;\n }\n\n public catch(rejected: ConstructorType<[unknown]>): this {\n this.message.catch(rejected);\n return this;\n }\n}\n","import { Message } from \"base/Message\";\nimport { ConstructorType } from \"types/ConstructorType\";\n\n/**\n * A component that, on each access, returns a new instance\n * of a reference type based on the constructor function\n */\nexport function New<T>(construct: ConstructorType<[], T>) {\n return Message<T>(function NewImpl(resolve) {\n resolve(construct());\n });\n}\n","/**\n * Resolver that does nothing with the passed value,\n * needed for silent message triggering\n */\nexport function Void() {\n return () => {};\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { MaybeMessage } from \"types/MessageType\";\n\ntype ExtractTypeS<T> = T extends MaybeMessage<infer U> ? U : never;\n\ntype ExtractTypesFromArrayS<T extends MaybeMessage<any>[]> = {\n [K in keyof T]: ExtractTypeS<T[K]>;\n};\n\nconst isAllFilled = (keysFilled: Set<string>, keysKnown: Set<string>) => {\n return keysFilled.size > 0 && keysFilled.size === keysKnown.size;\n};\n\n/**\n * A message that represents values from\n * all provided messages as an array.\n * When all messages emit their values,\n * the combined value will be returned.\n * If at least one message later emits a new\n * value, the updated array with the new value\n * will be emitted by All.\n */\nexport function All<const T extends MaybeMessage[]>(...messages: T) {\n const $messages = messages.map(ActualMessage);\n return Message<ExtractTypesFromArrayS<T>>(function AllImpl(resolve, reject) {\n const known = new Set<string>(Object.keys(messages));\n const filled = new Set<string>();\n const result: unknown[] = [];\n if (known.size === 0) {\n resolve([] as ExtractTypesFromArrayS<T>);\n return;\n }\n $messages.map((m, key) => {\n m.catch(reject);\n m.then((v) => {\n filled.add(key.toString());\n result[key] = v;\n if (isAllFilled(filled, known)) {\n resolve(result.slice() as ExtractTypesFromArrayS<T>);\n }\n });\n });\n });\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { MaybeMessage } from \"types/MessageType\";\n\n/**\n * A message that emits values received from\n * any of its bound messages\n */\nexport function Any<const T>(...messages: MaybeMessage<T>[]) {\n const $messages = messages.map(ActualMessage);\n return Message<T>(function AnyImpl(resolve, reject) {\n $messages.forEach((message) => {\n message.catch(reject);\n message.then(resolve);\n });\n });\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MaybeMessage } from \"types/MessageType\";\n\n/**\n * An message that applies a function\n * to the value of the base message\n */\nexport function Applied<const T, R>(\n base: MaybeMessage<T>,\n applier: ConstructorType<[T], R>,\n) {\n const $base = ActualMessage(base);\n return Message<R>(function AppliedImpl(resolve, reject) {\n $base.catch(reject);\n $base.then((v) => {\n resolve(applier(v));\n });\n });\n}\n","import { Applied } from \"components/Applied\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MaybeMessage } from \"types/MessageType\";\n\n/**\n * Allows applying variables from an message that passes an array to a function,\n * where each element of the array will be passed as a separate argument\n */\nexport function AppliedDestructured<const T extends any[], R>(\n $base: MaybeMessage<T>,\n applier: ConstructorType<any[], R>,\n) {\n return Applied($base, function AppliedDestructuredImpl(args) {\n return applier(...args);\n });\n}\n","import { MessageType } from \"types/MessageType\";\n\n/**\n * Helps represent an message as a primitive type, which can be useful\n * for cases when you need to always have a reference to the current value\n * without updating the shared value when the current one changes.\n * For example, this could be used when passing an authorization token.\n * It can also be useful for testing or logging purposes.\n */\nexport function Primitive<T>($base: MessageType<T>, theValue: T | null = null) {\n return new PrimitiveImpl<T>($base, theValue);\n}\n\nexport class PrimitiveImpl<T> {\n private touched = false;\n\n public constructor(\n private $base: MessageType<T>,\n private theValue: T | null = null,\n ) {}\n\n private ensureTouched() {\n if (!this.touched) {\n this.$base.then((v) => {\n this.theValue = v;\n });\n }\n this.touched = true;\n }\n\n public [Symbol.toPrimitive]() {\n this.ensureTouched();\n return this.theValue;\n }\n\n public primitive() {\n this.ensureTouched();\n return this.theValue;\n }\n\n public primitiveWithException() {\n this.ensureTouched();\n if (this.theValue === null) {\n throw new Error(\"Primitive value is null\");\n }\n return this.theValue;\n }\n}\n","import { MessageType } from \"types/MessageType\";\nimport { MessageSourceType, SourceType } from \"types/SourceType\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { isFilled, isSource } from \"helpers/guards\";\nimport { Primitive } from \"components/Primitive\";\nimport { ChainableType } from \"types/ChainableType\";\n\n/**\n * An information object that helps multiple owners access\n * a single another information object\n */\nexport function Shared<T>($base: MessageType<T> | MessageSourceType<T>) {\n return new SharedImpl<T>($base);\n}\n\nexport class SharedImpl<T> implements MessageSourceType<T>, ChainableType<T> {\n private resolver = (v: T) => {\n this.lastV = v;\n this.resolvers.forEach((r) => {\n r(v);\n });\n };\n private lastV: T | undefined;\n private resolvers = new Set<ConstructorType<[T]>>();\n private source?: SourceType<T>;\n\n public constructor(private $base: MessageType<T> | MessageSourceType<T>) {\n if (isSource($base)) {\n this.source = $base;\n }\n }\n\n public then(resolved: ConstructorType<[T]>) {\n this.resolvers.add(resolved);\n if (this.resolvers.size === 1) {\n this.$base.then(this.resolver);\n } else if (isFilled(this.lastV)) {\n resolved(this.lastV);\n }\n return this;\n }\n\n public use(value: T) {\n if (this.source) {\n this.source.use(value);\n } else {\n this.resolver(value);\n }\n return this;\n }\n\n public catch(rejected: ConstructorType<[unknown]>) {\n this.$base.catch(rejected);\n return this;\n }\n\n public destroy() {\n this.resolvers.clear();\n return this;\n }\n\n public value() {\n return Primitive(this);\n }\n\n public chain(m: MessageType<T>) {\n m.then(this.use.bind(this));\n return this;\n }\n}\n","import { Rejections } from \"base/Rejections\";\nimport { Silence } from \"base/Silence\";\nimport { Shared } from \"components/Shared\";\nimport { isFilled } from \"helpers/guards\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MessageSourceType } from \"types/SourceType\";\n\n/**\n * A component that allows creating linked objects of information and its owner\n * in such a way that if a new value is assigned to the owner, this value\n * will become the value of the linked information source\n * https://silentium-lab.github.io/silentium/#/en/information/of\n */\nexport function Late<T>(v?: T) {\n return Shared(new LateImpl<T>(v));\n}\n\nexport class LateImpl<T> implements MessageSourceType<T> {\n private rejections = new Rejections();\n private lateR: ConstructorType<[T]> | null = null;\n private notify = () => {\n if (isFilled(this.v) && this.lateR) {\n try {\n this.lateR(this.v);\n } catch (e: any) {\n this.rejections.reject(e);\n }\n }\n };\n\n public constructor(private v?: T) {}\n\n public then(r: ConstructorType<[T]>): this {\n if (this.lateR) {\n throw new Error(\n \"Late component gets new resolver, when another was already connected!\",\n );\n }\n this.lateR = Silence(r);\n this.notify();\n return this;\n }\n\n public use(value: T): this {\n this.v = value;\n this.notify();\n return this;\n }\n\n public catch(rejected: ConstructorType<[unknown]>) {\n this.rejections.catch(rejected);\n return this;\n }\n}\n","import { Rejections } from \"base/Rejections\";\nimport { Late } from \"components/Late\";\nimport { MessageType } from \"types/MessageType\";\n\n/**\n * Message with error catched\n * inside another message\n */\nexport function Catch<T>($base: MessageType) {\n const rejections = new Rejections();\n $base.catch(rejections.reject);\n const $error = Late<T>();\n rejections.catch((e) => {\n $error.use(e as T);\n });\n\n return $error;\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { MessageType, MessageTypeValue } from \"types/MessageType\";\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype Last<T extends readonly any[]> = T extends readonly [...infer _, infer L]\n ? L\n : never;\n\n/**\n * Chains messages together and triggers\n * the last message only when all previous messages\n * have emitted their values. The value of Chain will be the value\n * of the last message. If any messages\n * emit a value again after the overall Chain response was already returned,\n * then Chain emits again with the value of the last message.\n */\nexport function Chain<T extends readonly MessageType[]>(...messages: T) {\n const $messages = messages.map(ActualMessage);\n return Message<MessageTypeValue<Last<T>>>(\n function ChainImpl(resolve, reject) {\n let $latest: MessageTypeValue<Last<T>> | undefined;\n const handleMessage = (index: number) => {\n const message = $messages[index] as Last<T>;\n message.catch(reject);\n const next = $messages[index + 1] as Last<T> | undefined;\n message.then((v) => {\n oneMessage(v as MessageTypeValue<Last<T>>, next, index);\n });\n };\n function oneMessage(\n v: MessageTypeValue<Last<T>>,\n next: Last<T> | undefined,\n index: number,\n ) {\n if (!next) {\n $latest = v as MessageTypeValue<Last<T>>;\n }\n if ($latest) {\n resolve($latest);\n }\n if (next && !$latest) {\n handleMessage(index + 1);\n }\n }\n handleMessage(0);\n },\n );\n}\n","import { All } from \"components/All\";\nimport { AppliedDestructured } from \"components/AppliedDestructured\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MaybeMessage } from \"types/MessageType\";\n\n/**\n * Component what helps to compute\n * poor functions, and represent result\n * as message\n */\nexport function Computed<const T extends MaybeMessage<any>[], R>(\n applier: ConstructorType<any[], R>,\n ...messages: T\n) {\n return AppliedDestructured(All(...messages), applier);\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { ContextType } from \"types/ContextType\";\nimport { MaybeMessage } from \"types/MessageType\";\n\nContext.transport = new Map<any, ConstructorType<[ContextType]>>();\n\n/**\n * The ability to call an external system through\n * sending a message in a standardized format\n * ContextType, the list of transport should be defined via\n * the Context.transport map object\n */\nexport function Context<T>(msg: MaybeMessage<ContextType>) {\n const $msg = ActualMessage(msg);\n return Message<T>((resolve, reject) => {\n $msg.then((message) => {\n const transport = Context.transport.get(message.transport);\n if (transport === undefined) {\n throw new Error(`Context: unknown transport ${message.transport}`);\n }\n if (!message.result) {\n message.result = resolve;\n }\n if (!message.error) {\n message.error = reject;\n }\n try {\n transport(message);\n } catch (error) {\n reject(error);\n }\n });\n });\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { MaybeMessage } from \"types/MessageType\";\nimport { ContextType } from \"types/ContextType\";\n\n/**\n * Connects an external message to an RPC message chain\n */\nexport function ContextChain(base: MaybeMessage) {\n const $base = ActualMessage(base);\n return (context: ContextType) => {\n if (!context.result) {\n throw new Error(\"ContextChain did not find result in rpc message\");\n }\n $base.then(context.result);\n };\n}\n","import { Message } from \"base/Message\";\nimport { Context } from \"components/Context\";\nimport { Late } from \"components/Late\";\nimport { ContextType } from \"types/ContextType\";\n\n/**\n * Message for the arrival of a specific RPC message\n * for specific transport\n */\nexport function ContextOf(transport: string) {\n const $msg = Late<ContextType>();\n Context.transport.set(transport, $msg.use.bind($msg));\n return Message<ContextType>((resolve, reject) => {\n $msg.catch(reject);\n $msg.then(resolve);\n });\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MaybeMessage, MessageType } from \"types/MessageType\";\n\n/**\n * Filters values from the source message based on a predicate function,\n * optionally providing a default value when the predicate fails.\n */\nexport function Filtered<T>(\n base: MaybeMessage<T>,\n predicate: ConstructorType<[T], boolean>,\n defaultValue?: T,\n): MessageType<T> {\n const $base = ActualMessage(base);\n return Message<T>(function FilteredImpl(resolve, reject) {\n $base.catch(reject);\n $base.then((v) => {\n if (predicate(v)) {\n resolve(v);\n } else if (defaultValue !== undefined) {\n resolve(defaultValue);\n }\n });\n });\n}\n","import { Filtered } from \"components/Filtered\";\nimport { Late } from \"components/Late\";\nimport { Shared } from \"components/Shared\";\nimport { EmptyType } from \"types/EmptyType\";\nimport { MessageType } from \"types/MessageType\";\n\nexport const Nothing = Symbol(\"nothing\");\n\n/**\n * Helps to split message and empty\n * response\n */\nexport function Empty<T>($base: MessageType<T>) {\n return new EmptyImpl<T>($base);\n}\n\nexport class EmptyImpl<T> implements EmptyType {\n private $empty = Late<boolean>();\n\n public constructor(private $base: MessageType<T>) {}\n\n public message() {\n Shared(this.$base).then((v) => {\n if (v === Nothing) {\n this.$empty.use(true);\n }\n });\n return Filtered(this.$base, (v) => v !== Nothing);\n }\n\n public empty(): MessageType<boolean> {\n return this.$empty;\n }\n}\n","import { Message } from \"base/Message\";\nimport { MessageType } from \"types/MessageType\";\n\ntype ExecutorApplier<T> = (executor: (v: T) => void) => (v: T) => void;\n\n/**\n * Applies a value transfer function to the resolver\n * and returns the same value transfer function for the resolver\n * Useful for applying functions like debounced or throttle\n */\nexport function ExecutorApplied<T>(\n $base: MessageType<T>,\n applier: ExecutorApplier<T>,\n) {\n return Message<T>(function ExecutorAppliedImpl(resolve, reject) {\n $base.catch(reject);\n $base.then(applier(resolve));\n });\n}\n","import { Message } from \"base/Message\";\nimport { MessageType } from \"types/MessageType\";\n\n/**\n * Message what freezes first known value\n */\nexport function Freeze<T>($base: MessageType<T>, $invalidate?: MessageType<T>) {\n let freezedValue: T | null = null;\n return Message<T>(function FreezeImpl(resolve, reject) {\n $base.catch(reject);\n $base.then((v) => {\n if (freezedValue === null) {\n freezedValue = v;\n }\n resolve(freezedValue as T);\n });\n\n $invalidate?.then(() => {\n freezedValue = null;\n });\n });\n}\n","import { MaybeMessage } from \"types/MessageType\";\nimport { All } from \"components/All\";\nimport { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { ConstructorType } from \"types/ConstructorType\";\n\n/**\n * A message derived from event with a different\n * method call interface, based on callbacks.\n * Allows attaching a custom handler to an existing event source\n * and presenting it as a silentium message\n */\nexport function FromEvent<T>(\n emitter: MaybeMessage<any>,\n eventName: MaybeMessage<string>,\n subscribeMethod: MaybeMessage<string>,\n unsubscribeMethod?: MaybeMessage<string>,\n) {\n const $emitter = ActualMessage(emitter);\n const $eventName = ActualMessage(eventName);\n const $subscribeMethod = ActualMessage(subscribeMethod);\n const $unsubscribeMethod = ActualMessage(unsubscribeMethod);\n return Message<T>((resolve, reject) => {\n $emitter.catch(reject);\n $eventName.catch(reject);\n $subscribeMethod.catch(reject);\n $unsubscribeMethod.catch(reject);\n let lastR: ConstructorType<[T]> | null = null;\n const handler = (v: T) => {\n if (lastR) {\n lastR(v);\n }\n };\n All($emitter, $eventName, $subscribeMethod).then(\n ([emitter, eventName, subscribe]) => {\n lastR = resolve;\n if (!emitter?.[subscribe]) {\n return;\n }\n emitter[subscribe](eventName, handler);\n },\n );\n return () => {\n lastR = null;\n if (!$unsubscribeMethod) {\n return;\n }\n All($emitter, $eventName, $unsubscribeMethod).then(\n ([emitter, eventName, unsubscribe]) => {\n emitter?.[unsubscribe as string]?.(eventName, handler);\n },\n );\n };\n });\n}\n","import { MaybeMessage, MessageType } from \"types/MessageType\";\nimport { All } from \"components/All\";\nimport { isMessage } from \"helpers/guards\";\nimport { Of } from \"base/Of\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { Message } from \"base/Message\";\nimport { ActualMessage } from \"base/ActualMessage\";\nimport { DestroyContainer } from \"base/DestroyContainer\";\n\n/**\n * Component that applies an info object constructor to each data item,\n * producing an information source with new values\n */\nexport function Map<T, TG>(\n base: MaybeMessage<T[]>,\n target: ConstructorType<[any], MessageType<TG>>,\n) {\n const $base = ActualMessage(base);\n return Message<TG[]>((resolve, reject) => {\n $base.catch(reject);\n const infos: MessageType<TG>[] = [];\n const dc = DestroyContainer();\n $base.then((v) => {\n infos.length = 0;\n dc.destroy();\n v.forEach((val) => {\n let $val: MessageType<T> | T = val;\n if (!isMessage($val as object)) {\n $val = Of($val);\n }\n const info = target($val);\n dc.add(info);\n infos.push(info);\n });\n All(...infos).then(resolve);\n });\n });\n}\n","import { Message } from \"base/Message\";\nimport { MessageType } from \"types/MessageType\";\n\n/**\n * Limits the number of values from the information source\n * to a single value - once the first value is emitted, no more\n * values are delivered from the source\n */\nexport function Once<T>($base: MessageType<T>) {\n return Message<T>((resolve, reject) => {\n let isFilled = false;\n $base.catch(reject);\n $base.then((v) => {\n if (!isFilled) {\n isFilled = true;\n resolve(v);\n }\n });\n });\n}\n","import { DestroyContainer } from \"base/DestroyContainer\";\nimport { Message } from \"base/Message\";\nimport { Late } from \"components/Late\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MessageType } from \"types/MessageType\";\n\nexport function Process<T, R = unknown>(\n $base: MessageType<T>,\n builder: ConstructorType<[T], MessageType<R>>,\n) {\n return Message<R>((resolve, reject) => {\n const $res = Late<R>();\n const dc = DestroyContainer();\n\n $base.then((v) => {\n dc.destroy();\n const $msg = builder(v);\n dc.add($msg);\n $res.chain($msg);\n $msg.catch(reject);\n });\n $base.catch(reject);\n $res.then(resolve);\n\n return () => {\n dc.destroy();\n };\n });\n}\n","import { Message } from \"base/Message\";\nimport { MessageType } from \"types/MessageType\";\n\n/**\n * Creates a sequence that accumulates all values from the source into an array,\n * emitting the growing array with each new value.\n */\nexport function Sequence<T>($base: MessageType<T>) {\n return Message<T[]>((resolve, reject) => {\n const result: T[] = [];\n $base.catch(reject);\n $base.then((v) => {\n result.push(v);\n resolve(result.slice());\n });\n });\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { MaybeMessage } from \"types/MessageType\";\n\n/**\n * Component that receives a data array and yields values one by one\n */\nexport function Stream<T>(base: MaybeMessage<T[]>) {\n const $base = ActualMessage(base);\n return Message<T>((resolve, reject) => {\n $base.catch(reject);\n $base.then((v) => {\n v.forEach((cv) => {\n resolve(cv);\n });\n });\n });\n}\n"],"names":["__publicField","emitter","eventName","Map"],"mappings":";;AAOa,MAAA,QAAA,GAAW,CACtB,KAC0C,KAAA;AAC1C,EAAO,OAAA,KAAA,KAAU,UAAa,KAAU,KAAA,IAAA;AAC1C;AAKO,SAAS,UAAU,CAA8B,EAAA;AACtD,EACE,OAAA,CAAA,KAAM,QACN,OAAO,CAAA,KAAM,YACb,MAAU,IAAA,CAAA,IACV,OAAQ,CAAA,CAAU,IAAS,KAAA,UAAA;AAE/B;AAKO,SAAS,SAAS,CAA6B,EAAA;AACpD,EACE,OAAA,CAAA,KAAM,QACN,OAAO,CAAA,KAAM,YACb,KAAS,IAAA,CAAA,IACT,OAAQ,CAAA,CAAU,GAAQ,KAAA,UAAA;AAE9B;AAKO,SAAS,cAAc,CAAkC,EAAA;AAC9D,EACE,OAAA,CAAA,KAAM,QACN,OAAO,CAAA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CAAO,KAAK,CAAC,CAAA;AACb,MAAQ,OAAA,CAAA,MAAA,CAAO,OAAO,CAAA;AAAA,KACvB,CAAA;AAAA,GACF,CAAA;AACH;;ACTO,SAAS,OAAU,IAAyB,EAAA;AACjD,EAAM,MAAA,KAAA,GAAQ,cAAc,IAAI,CAAA;AAChC,EAAO,OAAA,OAAA,CAAW,CAAC,OAAA,EAAS,MAAW,KAAA;AACrC,IAAA,KAAA,CAAM,MAAM,MAAM,CAAA;AAClB,IAAM,KAAA,CAAA,IAAA,CAAK,CAAC,CAAM,KAAA;AAChB,MAAE,CAAA,CAAA,OAAA,CAAQ,CAAC,EAAO,KAAA;AAChB,QAAA,OAAA,CAAQ,EAAE,CAAA;AAAA,OACX,CAAA;AAAA,KACF,CAAA;AAAA,GACF,CAAA;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"silentium.cjs","sources":["../src/helpers/guards.ts","../src/base/Destroyable.ts","../src/base/DestroyContainer.ts","../src/base/Rejections.ts","../src/base/Silence.ts","../src/helpers/ensures.ts","../src/base/Message.ts","../src/base/Of.ts","../src/base/ActualMessage.ts","../src/base/Chainable.ts","../src/base/Local.ts","../src/base/MessageSource.ts","../src/base/New.ts","../src/base/Void.ts","../src/components/All.ts","../src/components/Any.ts","../src/components/Applied.ts","../src/components/AppliedDestructured.ts","../src/components/Primitive.ts","../src/components/Shared.ts","../src/components/Late.ts","../src/components/Catch.ts","../src/components/Chain.ts","../src/components/Computed.ts","../src/components/Context.ts","../src/components/ContextChain.ts","../src/components/ContextOf.ts","../src/components/Filtered.ts","../src/components/Empty.ts","../src/components/ExecutorApplied.ts","../src/components/Freeze.ts","../src/components/FromEvent.ts","../src/components/Map.ts","../src/components/Once.ts","../src/components/Process.ts","../src/components/Sequence.ts","../src/components/Stream.ts"],"sourcesContent":["import { DestroyableType, DestroyedType } from \"types/DestroyableType\";\nimport { MessageType } from \"types/MessageType\";\nimport { SourceType } from \"types/SourceType\";\n\n/**\n * Checks that the value is neither undefined nor null\n */\nexport const isFilled = <T>(\n value?: T,\n): value is Exclude<T, null | undefined> => {\n return value !== undefined && value !== null;\n};\n\n/**\n * Checks that the object is an message\n */\nexport function isMessage(o: unknown): o is MessageType {\n return (\n o !== null &&\n typeof o === \"object\" &&\n \"then\" in o &&\n typeof (o as any).then === \"function\"\n );\n}\n\n/**\n * Checks that the object is an message\n */\nexport function isSource(o: unknown): o is SourceType {\n return (\n o !== null &&\n typeof o === \"object\" &&\n \"use\" in o &&\n typeof (o as any).use === \"function\"\n );\n}\n\n/**\n * Checks that the object is destroyable\n */\nexport function isDestroyable(o: unknown): o is DestroyableType {\n return (\n o !== null &&\n typeof o === \"object\" &&\n \"destroy\" in o &&\n typeof (o as any).destroy === \"function\"\n );\n}\n\n/**\n * Checks that the object can indicate whether it has been destroyed or not\n */\nexport function isDestroyed(o: unknown): o is DestroyedType {\n return (\n o !== null &&\n typeof o === \"object\" &&\n \"destroyed\" in o &&\n typeof (o as any).destroyed === \"function\"\n );\n}\n","import { isDestroyable } from \"helpers/guards\";\nimport { DestroyableType } from \"types/DestroyableType\";\n\n/**\n * Allows creating an object that definitely has a destructor,\n * useful to avoid creating unnecessary conditions\n */\nexport function Destroyable<T>(base: T) {\n return new DestroyableImpl(base);\n}\n\nexport class DestroyableImpl<T> implements DestroyableType {\n public constructor(private base: T) {}\n\n public destroy(): this {\n if (isDestroyable(this.base)) {\n this.base.destroy();\n }\n\n if (typeof this.base === \"function\") {\n this.base();\n }\n\n return this;\n }\n}\n","import { Destroyable } from \"base/Destroyable\";\nimport { DestroyableType } from \"types/DestroyableType\";\n\n/**\n * An object that allows collecting all disposable objects and\n * disposing them later all together\n */\nexport function DestroyContainer() {\n return new DestroyContainerImpl();\n}\n\nexport class DestroyContainerImpl implements DestroyableType {\n private destructors: DestroyableType[] = [];\n\n public add<R>(e: R): R {\n this.destructors.push(Destroyable(e));\n return e;\n }\n\n public destroy() {\n this.destructors.forEach((d) => d.destroy());\n this.destructors.length = 0;\n return this;\n }\n}\n","import { ConstructorType } from \"types/ConstructorType\";\n\n/**\n * Handles rejections collection\n */\nexport class Rejections {\n private catchers: ConstructorType<[unknown]>[] = [];\n private lastRejectReason: unknown = null;\n\n public reject = (reason: unknown) => {\n this.lastRejectReason = reason;\n this.catchers.forEach((catcher) => {\n catcher(reason);\n });\n };\n\n public catch(rejected: ConstructorType<[unknown]>) {\n if (this.lastRejectReason !== null) {\n rejected(this.lastRejectReason);\n }\n this.catchers.push(rejected);\n return this;\n }\n\n public destroy() {\n this.catchers.length = 0;\n return this;\n }\n}\n","import { isFilled } from \"helpers/guards\";\nimport { ConstructorType } from \"types/ConstructorType\";\n\nexport const ResetSilenceCache = Symbol(\"reset-silence-cache\");\n\n/**\n * Silence is null or undefined or duplicated values\n * Everything else is not silence\n */\nexport function Silence<T>(resolve: ConstructorType<[T]>) {\n let lastValue: T | undefined;\n return (v: T | undefined) => {\n if (v === ResetSilenceCache) {\n lastValue = undefined;\n v = undefined;\n }\n if (isFilled(v) && v !== lastValue) {\n lastValue = v;\n resolve(v);\n }\n };\n}\n","import { isMessage } from \"helpers/guards\";\n\nexport function ensureFunction(v: unknown, label: string) {\n if (typeof v !== \"function\") {\n throw new Error(`${label}: is not function`);\n }\n}\n\nexport function ensureMessage(v: unknown, label: string) {\n if (!isMessage(v)) {\n throw new Error(`${label}: is not message`);\n }\n}\n","import { DestroyContainer } from \"base/DestroyContainer\";\nimport { Rejections } from \"base/Rejections\";\nimport { Silence } from \"base/Silence\";\nimport { ensureFunction } from \"helpers/ensures\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { DestroyableType } from \"types/DestroyableType\";\nimport { MessageType } from \"types/MessageType\";\n\nexport type MessageExecutorType<T> = (\n resolve: ConstructorType<[T]>,\n reject: ConstructorType<[unknown]>,\n) => MessageType | (() => void) | void;\n\n/**\n * A message created from an executor function.\n * The executor function can return a message destruction function.\n */\nexport function Message<T>(executor: MessageExecutorType<T>) {\n return new MessageImpl<T>(executor);\n}\n\n/**\n * Reactive message implementation\n */\nexport class MessageImpl<T> implements MessageType<T>, DestroyableType {\n private rejections = new Rejections();\n private dc = DestroyContainer();\n\n public constructor(private executor: MessageExecutorType<T>) {\n ensureFunction(executor, \"Message: executor\");\n }\n\n public then(resolve: ConstructorType<[T]>) {\n try {\n this.dc.add(this.executor(Silence(resolve), this.rejections.reject));\n } catch (e: any) {\n this.rejections.reject(e);\n }\n return this;\n }\n\n public catch(rejected: ConstructorType<[unknown]>) {\n this.rejections.catch(rejected);\n return this;\n }\n\n public destroy() {\n this.dc.destroy();\n this.rejections.destroy();\n return this;\n }\n}\n","import { Message } from \"base/Message\";\n\n/**\n * Helps convert a value into a message\n */\nexport function Of<T>(value: T) {\n return Message<T>(function OfImpl(r) {\n r(value);\n });\n}\n","import { Of } from \"base/Of\";\nimport { isMessage } from \"helpers/guards\";\nimport { MaybeMessage, MessageType } from \"types/MessageType\";\n\n/**\n * A function that helps to ensure that\n * the message is indeed a message object\n * and not just a value\n */\nexport function ActualMessage<T>(message: MaybeMessage<T>): MessageType<T> {\n return isMessage(message) ? message : Of(message);\n}\n","import { ChainableType } from \"types/ChainableType\";\nimport { MessageType } from \"types/MessageType\";\nimport { SourceType } from \"types/SourceType\";\n\n/**\n * Helps to connect Different\n * message and source\n */\nexport function Chainable<T>(src: SourceType<T>) {\n return new ChainableImpl(src);\n}\n\nexport class ChainableImpl<T> implements ChainableType<T> {\n public constructor(private src: SourceType<T>) {}\n\n public chain($m: MessageType<T>) {\n $m.then(this.src.use.bind(this.src));\n return this;\n }\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { MaybeMessage } from \"types/MessageType\";\n\n/**\n * Create local copy of source what can be destroyed\n */\nexport function Local<T>(_base: MaybeMessage<T>) {\n const $base = ActualMessage(_base);\n return Message<T>(function LocalImpl(resolve, reject) {\n let destroyed = false;\n $base.then((v) => {\n if (!destroyed) {\n resolve(v);\n }\n });\n $base.catch(reject);\n return () => {\n destroyed = true;\n };\n });\n}\n","import { Message, MessageExecutorType, MessageImpl } from \"base/Message\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MessageSourceType } from \"types/SourceType\";\n\n/**\n * Base message source object\n */\nexport function MessageSource<T>(\n messageExecutor: MessageExecutorType<T>,\n sourceExecutor: ConstructorType<[T]>,\n) {\n return new MessageSourceImpl(messageExecutor, sourceExecutor);\n}\n\nexport class MessageSourceImpl<T> implements MessageSourceType<T> {\n private message: MessageImpl<T>;\n\n public constructor(\n messageExecutor: MessageExecutorType<T>,\n private sourceExecutor: ConstructorType<[T]>,\n ) {\n this.message = Message(messageExecutor);\n }\n\n public use(value: T): this {\n this.sourceExecutor(value);\n return this;\n }\n\n public then(resolved: ConstructorType<[T]>): this {\n this.message.then(resolved);\n return this;\n }\n\n public catch(rejected: ConstructorType<[unknown]>): this {\n this.message.catch(rejected);\n return this;\n }\n}\n","import { Message } from \"base/Message\";\nimport { ConstructorType } from \"types/ConstructorType\";\n\n/**\n * A component that, on each access, returns a new instance\n * of a reference type based on the constructor function\n */\nexport function New<T>(construct: ConstructorType<[], T>) {\n return Message<T>(function NewImpl(resolve) {\n resolve(construct());\n });\n}\n","/**\n * Resolver that does nothing with the passed value,\n * needed for silent message triggering\n */\nexport function Void() {\n return () => {};\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { MaybeMessage } from \"types/MessageType\";\n\ntype ExtractTypeS<T> = T extends MaybeMessage<infer U> ? U : never;\n\ntype ExtractTypesFromArrayS<T extends MaybeMessage<any>[]> = {\n [K in keyof T]: ExtractTypeS<T[K]>;\n};\n\nconst isAllFilled = (keysFilled: Set<string>, keysKnown: Set<string>) => {\n return keysFilled.size > 0 && keysFilled.size === keysKnown.size;\n};\n\n/**\n * A message that represents values from\n * all provided messages as an array.\n * When all messages emit their values,\n * the combined value will be returned.\n * If at least one message later emits a new\n * value, the updated array with the new value\n * will be emitted by All.\n */\nexport function All<const T extends MaybeMessage[]>(...messages: T) {\n const $messages = messages.map(ActualMessage);\n return Message<ExtractTypesFromArrayS<T>>(function AllImpl(resolve, reject) {\n const known = new Set<string>(Object.keys(messages));\n const filled = new Set<string>();\n const result: unknown[] = [];\n if (known.size === 0) {\n resolve([] as ExtractTypesFromArrayS<T>);\n return;\n }\n $messages.map((m, key) => {\n m.catch(reject);\n m.then((v) => {\n filled.add(key.toString());\n result[key] = v;\n if (isAllFilled(filled, known)) {\n resolve(result.slice() as ExtractTypesFromArrayS<T>);\n }\n });\n });\n });\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { MaybeMessage } from \"types/MessageType\";\n\n/**\n * A message that emits values received from\n * any of its bound messages\n */\nexport function Any<const T>(...messages: MaybeMessage<T>[]) {\n const $messages = messages.map(ActualMessage);\n return Message<T>(function AnyImpl(resolve, reject) {\n $messages.forEach((message) => {\n message.catch(reject);\n message.then(resolve);\n });\n });\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MaybeMessage } from \"types/MessageType\";\n\n/**\n * An message that applies a function\n * to the value of the base message\n */\nexport function Applied<const T, R>(\n base: MaybeMessage<T>,\n applier: ConstructorType<[T], R>,\n) {\n const $base = ActualMessage(base);\n return Message<R>(function AppliedImpl(resolve, reject) {\n $base.catch(reject);\n $base.then((v) => {\n resolve(applier(v));\n });\n });\n}\n","import { Applied } from \"components/Applied\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MaybeMessage } from \"types/MessageType\";\n\n/**\n * Allows applying variables from an message that passes an array to a function,\n * where each element of the array will be passed as a separate argument\n */\nexport function AppliedDestructured<const T extends any[], R>(\n $base: MaybeMessage<T>,\n applier: ConstructorType<any[], R>,\n) {\n return Applied($base, function AppliedDestructuredImpl(args) {\n return applier(...args);\n });\n}\n","import { MessageType } from \"types/MessageType\";\n\n/**\n * Helps represent an message as a primitive type, which can be useful\n * for cases when you need to always have a reference to the current value\n * without updating the shared value when the current one changes.\n * For example, this could be used when passing an authorization token.\n * It can also be useful for testing or logging purposes.\n */\nexport function Primitive<T>($base: MessageType<T>, theValue: T | null = null) {\n return new PrimitiveImpl<T>($base, theValue);\n}\n\nexport class PrimitiveImpl<T> {\n private touched = false;\n\n public constructor(\n private $base: MessageType<T>,\n private theValue: T | null = null,\n ) {}\n\n private ensureTouched() {\n if (!this.touched) {\n this.$base.then((v) => {\n this.theValue = v;\n });\n }\n this.touched = true;\n }\n\n public [Symbol.toPrimitive]() {\n this.ensureTouched();\n return this.theValue;\n }\n\n public primitive() {\n this.ensureTouched();\n return this.theValue;\n }\n\n public primitiveWithException() {\n this.ensureTouched();\n if (this.theValue === null) {\n throw new Error(\"Primitive value is null\");\n }\n return this.theValue;\n }\n}\n","import { MessageType } from \"types/MessageType\";\nimport { MessageSourceType, SourceType } from \"types/SourceType\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { isFilled, isSource } from \"helpers/guards\";\nimport { Primitive } from \"components/Primitive\";\nimport { ChainableType } from \"types/ChainableType\";\n\n/**\n * An information object that helps multiple owners access\n * a single another information object\n */\nexport function Shared<T>($base: MessageType<T> | MessageSourceType<T>) {\n return new SharedImpl<T>($base);\n}\n\nexport class SharedImpl<T> implements MessageSourceType<T>, ChainableType<T> {\n private resolver = (v: T) => {\n this.lastV = v;\n this.resolvers.forEach((r) => {\n r(v);\n });\n };\n private lastV: T | undefined;\n private resolvers = new Set<ConstructorType<[T]>>();\n private source?: SourceType<T>;\n\n public constructor(private $base: MessageType<T> | MessageSourceType<T>) {\n if (isSource($base)) {\n this.source = $base;\n }\n }\n\n public then(resolved: ConstructorType<[T]>) {\n this.resolvers.add(resolved);\n if (this.resolvers.size === 1) {\n this.$base.then(this.resolver);\n } else if (isFilled(this.lastV)) {\n resolved(this.lastV);\n }\n return this;\n }\n\n public use(value: T) {\n if (this.source) {\n this.source.use(value);\n } else {\n this.resolver(value);\n }\n return this;\n }\n\n public catch(rejected: ConstructorType<[unknown]>) {\n this.$base.catch(rejected);\n return this;\n }\n\n public destroy() {\n this.resolvers.clear();\n return this;\n }\n\n public value() {\n return Primitive(this);\n }\n\n public chain(m: MessageType<T>) {\n m.then(this.use.bind(this));\n return this;\n }\n}\n","import { Rejections } from \"base/Rejections\";\nimport { Silence } from \"base/Silence\";\nimport { Shared } from \"components/Shared\";\nimport { isFilled } from \"helpers/guards\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MessageSourceType } from \"types/SourceType\";\n\n/**\n * A component that allows creating linked objects of information and its owner\n * in such a way that if a new value is assigned to the owner, this value\n * will become the value of the linked information source\n * https://silentium-lab.github.io/silentium/#/en/information/of\n */\nexport function Late<T>(v?: T) {\n return Shared(new LateImpl<T>(v));\n}\n\nexport class LateImpl<T> implements MessageSourceType<T> {\n private rejections = new Rejections();\n private lateR: ConstructorType<[T]> | null = null;\n private notify = () => {\n if (isFilled(this.v) && this.lateR) {\n try {\n this.lateR(this.v);\n } catch (e: any) {\n this.rejections.reject(e);\n }\n }\n };\n\n public constructor(private v?: T) {}\n\n public then(r: ConstructorType<[T]>): this {\n if (this.lateR) {\n throw new Error(\n \"Late component gets new resolver, when another was already connected!\",\n );\n }\n this.lateR = Silence(r);\n this.notify();\n return this;\n }\n\n public use(value: T): this {\n this.v = value;\n this.notify();\n return this;\n }\n\n public catch(rejected: ConstructorType<[unknown]>) {\n this.rejections.catch(rejected);\n return this;\n }\n}\n","import { Rejections } from \"base/Rejections\";\nimport { Late } from \"components/Late\";\nimport { MessageType } from \"types/MessageType\";\n\n/**\n * Message with error catched\n * inside another message\n */\nexport function Catch<T>($base: MessageType) {\n const rejections = new Rejections();\n $base.catch(rejections.reject);\n const $error = Late<T>();\n rejections.catch((e) => {\n $error.use(e as T);\n });\n\n return $error;\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { MessageType, MessageTypeValue } from \"types/MessageType\";\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\ntype Last<T extends readonly any[]> = T extends readonly [...infer _, infer L]\n ? L\n : never;\n\n/**\n * Chains messages together and triggers\n * the last message only when all previous messages\n * have emitted their values. The value of Chain will be the value\n * of the last message. If any messages\n * emit a value again after the overall Chain response was already returned,\n * then Chain emits again with the value of the last message.\n */\nexport function Chain<T extends readonly MessageType[]>(...messages: T) {\n const $messages = messages.map(ActualMessage);\n return Message<MessageTypeValue<Last<T>>>(\n function ChainImpl(resolve, reject) {\n let $latest: MessageTypeValue<Last<T>> | undefined;\n const handleMessage = (index: number) => {\n const message = $messages[index] as Last<T>;\n message.catch(reject);\n const next = $messages[index + 1] as Last<T> | undefined;\n message.then((v) => {\n oneMessage(v as MessageTypeValue<Last<T>>, next, index);\n });\n };\n function oneMessage(\n v: MessageTypeValue<Last<T>>,\n next: Last<T> | undefined,\n index: number,\n ) {\n if (!next) {\n $latest = v as MessageTypeValue<Last<T>>;\n }\n if ($latest) {\n resolve($latest);\n }\n if (next && !$latest) {\n handleMessage(index + 1);\n }\n }\n handleMessage(0);\n },\n );\n}\n","import { All } from \"components/All\";\nimport { AppliedDestructured } from \"components/AppliedDestructured\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MaybeMessage } from \"types/MessageType\";\n\n/**\n * Component what helps to compute\n * poor functions, and represent result\n * as message\n */\nexport function Computed<const T extends MaybeMessage<any>[], R>(\n applier: ConstructorType<any[], R>,\n ...messages: T\n) {\n return AppliedDestructured(All(...messages), applier);\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { ContextType } from \"types/ContextType\";\nimport { MaybeMessage } from \"types/MessageType\";\n\nContext.transport = new Map<any, ConstructorType<[ContextType]>>();\n\n/**\n * The ability to call an external system through\n * sending a message in a standardized format\n * ContextType, the list of transport should be defined via\n * the Context.transport map object\n */\nexport function Context<T>(msg: MaybeMessage<ContextType>) {\n const $msg = ActualMessage(msg);\n return Message<T>((resolve, reject) => {\n $msg.then((message) => {\n const transport = Context.transport.get(message.transport);\n if (transport === undefined) {\n throw new Error(`Context: unknown transport ${message.transport}`);\n }\n if (!message.result) {\n message.result = resolve;\n }\n if (!message.error) {\n message.error = reject;\n }\n try {\n transport(message);\n } catch (error) {\n reject(error);\n }\n });\n });\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { MaybeMessage } from \"types/MessageType\";\nimport { ContextType } from \"types/ContextType\";\n\n/**\n * Connects an external message to an RPC message chain\n */\nexport function ContextChain(base: MaybeMessage) {\n const $base = ActualMessage(base);\n return (context: ContextType) => {\n if (!context.result) {\n throw new Error(\"ContextChain did not find result in rpc message\");\n }\n $base.then(context.result);\n };\n}\n","import { Message } from \"base/Message\";\nimport { Context } from \"components/Context\";\nimport { Late } from \"components/Late\";\nimport { ContextType } from \"types/ContextType\";\n\n/**\n * Message for the arrival of a specific RPC message\n * for specific transport\n */\nexport function ContextOf(transport: string) {\n const $msg = Late<ContextType>();\n Context.transport.set(transport, $msg.use.bind($msg));\n return Message<ContextType>((resolve, reject) => {\n $msg.catch(reject);\n $msg.then(resolve);\n });\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MaybeMessage, MessageType } from \"types/MessageType\";\n\n/**\n * Filters values from the source message based on a predicate function,\n * optionally providing a default value when the predicate fails.\n */\nexport function Filtered<T>(\n base: MaybeMessage<T>,\n predicate: ConstructorType<[T], boolean>,\n defaultValue?: T,\n): MessageType<T> {\n const $base = ActualMessage(base);\n return Message<T>(function FilteredImpl(resolve, reject) {\n $base.catch(reject);\n $base.then((v) => {\n if (predicate(v)) {\n resolve(v);\n } else if (defaultValue !== undefined) {\n resolve(defaultValue);\n }\n });\n });\n}\n","import { Filtered } from \"components/Filtered\";\nimport { Late } from \"components/Late\";\nimport { Shared } from \"components/Shared\";\nimport { EmptyType } from \"types/EmptyType\";\nimport { MessageType } from \"types/MessageType\";\n\nexport const Nothing = Symbol(\"nothing\");\n\n/**\n * Helps to split message and empty\n * response\n */\nexport function Empty<T>($base: MessageType<T>) {\n return new EmptyImpl<T>($base);\n}\n\nexport class EmptyImpl<T> implements EmptyType {\n private $empty = Late<boolean>();\n\n public constructor(private $base: MessageType<T>) {}\n\n public message() {\n Shared(this.$base).then((v) => {\n if (v === Nothing) {\n this.$empty.use(true);\n }\n });\n return Filtered(this.$base, (v) => v !== Nothing);\n }\n\n public empty(): MessageType<boolean> {\n return this.$empty;\n }\n}\n","import { Message } from \"base/Message\";\nimport { MessageType } from \"types/MessageType\";\n\ntype ExecutorApplier<T> = (executor: (v: T) => void) => (v: T) => void;\n\n/**\n * Applies a value transfer function to the resolver\n * and returns the same value transfer function for the resolver\n * Useful for applying functions like debounced or throttle\n */\nexport function ExecutorApplied<T>(\n $base: MessageType<T>,\n applier: ExecutorApplier<T>,\n) {\n return Message<T>(function ExecutorAppliedImpl(resolve, reject) {\n $base.catch(reject);\n $base.then(applier(resolve));\n });\n}\n","import { Message } from \"base/Message\";\nimport { MessageType } from \"types/MessageType\";\n\n/**\n * Message what freezes first known value\n */\nexport function Freeze<T>($base: MessageType<T>, $invalidate?: MessageType<T>) {\n let freezedValue: T | null = null;\n return Message<T>(function FreezeImpl(resolve, reject) {\n $base.catch(reject);\n $base.then((v) => {\n if (freezedValue === null) {\n freezedValue = v;\n }\n resolve(freezedValue as T);\n });\n\n $invalidate?.then(() => {\n freezedValue = null;\n });\n });\n}\n","import { MaybeMessage } from \"types/MessageType\";\nimport { All } from \"components/All\";\nimport { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { ConstructorType } from \"types/ConstructorType\";\n\n/**\n * A message derived from event with a different\n * method call interface, based on callbacks.\n * Allows attaching a custom handler to an existing event source\n * and presenting it as a silentium message\n */\nexport function FromEvent<T>(\n emitter: MaybeMessage<any>,\n eventName: MaybeMessage<string>,\n subscribeMethod: MaybeMessage<string>,\n unsubscribeMethod?: MaybeMessage<string>,\n) {\n const $emitter = ActualMessage(emitter);\n const $eventName = ActualMessage(eventName);\n const $subscribeMethod = ActualMessage(subscribeMethod);\n const $unsubscribeMethod = ActualMessage(unsubscribeMethod);\n return Message<T>((resolve, reject) => {\n $emitter.catch(reject);\n $eventName.catch(reject);\n $subscribeMethod.catch(reject);\n $unsubscribeMethod.catch(reject);\n let lastR: ConstructorType<[T]> | null = null;\n const handler = (v: T) => {\n if (lastR) {\n lastR(v);\n }\n };\n All($emitter, $eventName, $subscribeMethod).then(\n ([emitter, eventName, subscribe]) => {\n lastR = resolve;\n if (!emitter?.[subscribe]) {\n return;\n }\n emitter[subscribe](eventName, handler);\n },\n );\n return () => {\n lastR = null;\n if (!$unsubscribeMethod) {\n return;\n }\n All($emitter, $eventName, $unsubscribeMethod).then(\n ([emitter, eventName, unsubscribe]) => {\n emitter?.[unsubscribe as string]?.(eventName, handler);\n },\n );\n };\n });\n}\n","import { MaybeMessage, MessageType } from \"types/MessageType\";\nimport { All } from \"components/All\";\nimport { isMessage } from \"helpers/guards\";\nimport { Of } from \"base/Of\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { Message } from \"base/Message\";\nimport { ActualMessage } from \"base/ActualMessage\";\nimport { DestroyContainer } from \"base/DestroyContainer\";\n\n/**\n * Component that applies an info object constructor to each data item,\n * producing an information source with new values\n */\nexport function Map<T, TG>(\n base: MaybeMessage<T[]>,\n target: ConstructorType<[any], MessageType<TG>>,\n) {\n const $base = ActualMessage(base);\n return Message<TG[]>((resolve, reject) => {\n $base.catch(reject);\n const infos: MessageType<TG>[] = [];\n const dc = DestroyContainer();\n $base.then((v) => {\n infos.length = 0;\n dc.destroy();\n v.forEach((val) => {\n let $val: MessageType<T> | T = val;\n if (!isMessage($val as object)) {\n $val = Of($val);\n }\n const info = target($val);\n dc.add(info);\n infos.push(info);\n });\n All(...infos).then(resolve);\n });\n });\n}\n","import { Message } from \"base/Message\";\nimport { MessageType } from \"types/MessageType\";\n\n/**\n * Limits the number of values from the information source\n * to a single value - once the first value is emitted, no more\n * values are delivered from the source\n */\nexport function Once<T>($base: MessageType<T>) {\n return Message<T>((resolve, reject) => {\n let isFilled = false;\n $base.catch(reject);\n $base.then((v) => {\n if (!isFilled) {\n isFilled = true;\n resolve(v);\n }\n });\n });\n}\n","import { DestroyContainer } from \"base/DestroyContainer\";\nimport { Message } from \"base/Message\";\nimport { Late } from \"components/Late\";\nimport { ConstructorType } from \"types/ConstructorType\";\nimport { MessageType } from \"types/MessageType\";\n\nexport function Process<T, R = unknown>(\n $base: MessageType<T>,\n builder: ConstructorType<[T], MessageType<R>>,\n) {\n return Message<R>((resolve, reject) => {\n const $res = Late<R>();\n const dc = DestroyContainer();\n\n $base.then((v) => {\n dc.destroy();\n const $msg = builder(v);\n dc.add($msg);\n $res.chain($msg);\n $msg.catch(reject);\n });\n $base.catch(reject);\n $res.then(resolve);\n\n return () => {\n dc.destroy();\n };\n });\n}\n","import { Message } from \"base/Message\";\nimport { MessageType } from \"types/MessageType\";\n\n/**\n * Creates a sequence that accumulates all values from the source into an array,\n * emitting the growing array with each new value.\n */\nexport function Sequence<T>($base: MessageType<T>) {\n return Message<T[]>((resolve, reject) => {\n const result: T[] = [];\n $base.catch(reject);\n $base.then((v) => {\n result.push(v);\n resolve(result.slice());\n });\n });\n}\n","import { ActualMessage } from \"base/ActualMessage\";\nimport { Message } from \"base/Message\";\nimport { MaybeMessage } from \"types/MessageType\";\n\n/**\n * Component that receives a data array and yields values one by one\n */\nexport function Stream<T>(base: MaybeMessage<T[]>) {\n const $base = ActualMessage(base);\n return Message<T>((resolve, reject) => {\n $base.catch(reject);\n $base.then((v) => {\n v.forEach((cv) => {\n resolve(cv);\n });\n });\n });\n}\n"],"names":["__publicField","emitter","eventName","Map"],"mappings":";;AAOO,MAAM,QAAA,GAAW,CACtB,KAAA,KAC0C;AAC1C,EAAA,OAAO,KAAA,KAAU,UAAa,KAAA,KA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AAChB,MAAA,MAAA,CAAO,KAAK,CAAC,CAAA;AACb,MAAA,OAAA,CAAQ,MAAA,CAAO,OAAO,CAAA;AAAA,IACxB,CAAC,CAAA;AAAA,EACH,CAAC,CAAA;AACH;;ACTO,SAAS,OAAU,IAAA,EAAyB;AACjD,EAAA,MAAM,KAAA,GAAQ,cAAc,IAAI,CAAA;AAChC,EAAA,OAAO,OAAA,CAAW,CAAC,OAAA,EAAS,MAAA,KAAW;AACrC,IAAA,KAAA,CAAM,MAAM,MAAM,CAAA;AAClB,IAAA,KAAA,CAAM,IAAA,CAAK,CAAC,CAAA,KAAM;AAChB,MAAA,CAAA,CAAE,OAAA,CAAQ,CAAC,EAAA,KAAO;AAChB,QAAA,OAAA,CAAQ,EAAE,CAAA;AAAA,MACZ,CAAC,CAAA;AAAA,IACH,CAAC,CAAA;AAAA,EACH,CAAC,CAAA;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/silentium.d.ts
CHANGED
|
@@ -96,11 +96,11 @@ type MessageExecutorType<T> = (resolve: ConstructorType<[T]>, reject: Constructo
|
|
|
96
96
|
* A message created from an executor function.
|
|
97
97
|
* The executor function can return a message destruction function.
|
|
98
98
|
*/
|
|
99
|
-
declare function Message<T>(executor: MessageExecutorType<T>):
|
|
99
|
+
declare function Message<T>(executor: MessageExecutorType<T>): MessageImpl<T>;
|
|
100
100
|
/**
|
|
101
101
|
* Reactive message implementation
|
|
102
102
|
*/
|
|
103
|
-
declare class
|
|
103
|
+
declare class MessageImpl<T> implements MessageType<T>, DestroyableType {
|
|
104
104
|
private executor;
|
|
105
105
|
private rejections;
|
|
106
106
|
private dc;
|
|
@@ -113,7 +113,7 @@ declare class MessageRx<T> implements MessageType<T>, DestroyableType {
|
|
|
113
113
|
/**
|
|
114
114
|
* Create local copy of source what can be destroyed
|
|
115
115
|
*/
|
|
116
|
-
declare function Local<T>(_base: MaybeMessage<T>):
|
|
116
|
+
declare function Local<T>(_base: MaybeMessage<T>): MessageImpl<T>;
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* Base message source object
|
|
@@ -132,12 +132,12 @@ declare class MessageSourceImpl<T> implements MessageSourceType<T> {
|
|
|
132
132
|
* A component that, on each access, returns a new instance
|
|
133
133
|
* of a reference type based on the constructor function
|
|
134
134
|
*/
|
|
135
|
-
declare function New<T>(construct: ConstructorType<[], T>):
|
|
135
|
+
declare function New<T>(construct: ConstructorType<[], T>): MessageImpl<T>;
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
138
|
* Helps convert a value into a message
|
|
139
139
|
*/
|
|
140
|
-
declare function Of<T>(value: T):
|
|
140
|
+
declare function Of<T>(value: T): MessageImpl<T>;
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
143
|
* Handles rejections collection
|
|
@@ -150,11 +150,12 @@ declare class Rejections {
|
|
|
150
150
|
destroy(): this;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
declare const ResetSilenceCache: unique symbol;
|
|
153
154
|
/**
|
|
154
155
|
* Silence is null or undefined or duplicated values
|
|
155
156
|
* Everything else is not silence
|
|
156
157
|
*/
|
|
157
|
-
declare function Silence<T>(resolve: ConstructorType<[T]>): (v: T) => void;
|
|
158
|
+
declare function Silence<T>(resolve: ConstructorType<[T]>): (v: T | undefined) => void;
|
|
158
159
|
|
|
159
160
|
/**
|
|
160
161
|
* Resolver that does nothing with the passed value,
|
|
@@ -175,25 +176,25 @@ type ExtractTypesFromArrayS<T extends MaybeMessage<any>[]> = {
|
|
|
175
176
|
* value, the updated array with the new value
|
|
176
177
|
* will be emitted by All.
|
|
177
178
|
*/
|
|
178
|
-
declare function All<const T extends MaybeMessage[]>(...messages: T):
|
|
179
|
+
declare function All<const T extends MaybeMessage[]>(...messages: T): MessageImpl<ExtractTypesFromArrayS<T>>;
|
|
179
180
|
|
|
180
181
|
/**
|
|
181
182
|
* A message that emits values received from
|
|
182
183
|
* any of its bound messages
|
|
183
184
|
*/
|
|
184
|
-
declare function Any<const T>(...messages: MaybeMessage<T>[]):
|
|
185
|
+
declare function Any<const T>(...messages: MaybeMessage<T>[]): MessageImpl<T>;
|
|
185
186
|
|
|
186
187
|
/**
|
|
187
188
|
* An message that applies a function
|
|
188
189
|
* to the value of the base message
|
|
189
190
|
*/
|
|
190
|
-
declare function Applied<const T, R>(base: MaybeMessage<T>, applier: ConstructorType<[T], R>):
|
|
191
|
+
declare function Applied<const T, R>(base: MaybeMessage<T>, applier: ConstructorType<[T], R>): MessageImpl<R>;
|
|
191
192
|
|
|
192
193
|
/**
|
|
193
194
|
* Allows applying variables from an message that passes an array to a function,
|
|
194
195
|
* where each element of the array will be passed as a separate argument
|
|
195
196
|
*/
|
|
196
|
-
declare function AppliedDestructured<const T extends any[], R>($base: MaybeMessage<T>, applier: ConstructorType<any[], R>):
|
|
197
|
+
declare function AppliedDestructured<const T extends any[], R>($base: MaybeMessage<T>, applier: ConstructorType<any[], R>): MessageImpl<R>;
|
|
197
198
|
|
|
198
199
|
/**
|
|
199
200
|
* Helps represent an message as a primitive type, which can be useful
|
|
@@ -249,14 +250,14 @@ type Last<T extends readonly any[]> = T extends readonly [...infer _, infer L] ?
|
|
|
249
250
|
* emit a value again after the overall Chain response was already returned,
|
|
250
251
|
* then Chain emits again with the value of the last message.
|
|
251
252
|
*/
|
|
252
|
-
declare function Chain<T extends readonly MessageType[]>(...messages: T):
|
|
253
|
+
declare function Chain<T extends readonly MessageType[]>(...messages: T): MessageImpl<MessageTypeValue<Last<T>>>;
|
|
253
254
|
|
|
254
255
|
/**
|
|
255
256
|
* Component what helps to compute
|
|
256
257
|
* poor functions, and represent result
|
|
257
258
|
* as message
|
|
258
259
|
*/
|
|
259
|
-
declare function Computed<const T extends MaybeMessage<any>[], R>(applier: ConstructorType<any[], R>, ...messages: T):
|
|
260
|
+
declare function Computed<const T extends MaybeMessage<any>[], R>(applier: ConstructorType<any[], R>, ...messages: T): MessageImpl<R>;
|
|
260
261
|
|
|
261
262
|
/**
|
|
262
263
|
* Type for passing action requirements
|
|
@@ -275,7 +276,7 @@ interface ContextType extends Record<string, any> {
|
|
|
275
276
|
* ContextType, the list of transport should be defined via
|
|
276
277
|
* the Context.transport map object
|
|
277
278
|
*/
|
|
278
|
-
declare function Context<T>(msg: MaybeMessage<ContextType>):
|
|
279
|
+
declare function Context<T>(msg: MaybeMessage<ContextType>): MessageImpl<T>;
|
|
279
280
|
declare namespace Context {
|
|
280
281
|
var transport: Map<any, ConstructorType<[ContextType]>>;
|
|
281
282
|
}
|
|
@@ -289,7 +290,7 @@ declare function ContextChain(base: MaybeMessage): (context: ContextType) => voi
|
|
|
289
290
|
* Message for the arrival of a specific RPC message
|
|
290
291
|
* for specific transport
|
|
291
292
|
*/
|
|
292
|
-
declare function ContextOf(transport: string):
|
|
293
|
+
declare function ContextOf(transport: string): MessageImpl<ContextType>;
|
|
293
294
|
|
|
294
295
|
interface EmptyType {
|
|
295
296
|
empty(): MessageType<boolean>;
|
|
@@ -315,7 +316,7 @@ type ExecutorApplier<T> = (executor: (v: T) => void) => (v: T) => void;
|
|
|
315
316
|
* and returns the same value transfer function for the resolver
|
|
316
317
|
* Useful for applying functions like debounced or throttle
|
|
317
318
|
*/
|
|
318
|
-
declare function ExecutorApplied<T>($base: MessageType<T>, applier: ExecutorApplier<T>):
|
|
319
|
+
declare function ExecutorApplied<T>($base: MessageType<T>, applier: ExecutorApplier<T>): MessageImpl<T>;
|
|
319
320
|
|
|
320
321
|
/**
|
|
321
322
|
* Filters values from the source message based on a predicate function,
|
|
@@ -326,7 +327,7 @@ declare function Filtered<T>(base: MaybeMessage<T>, predicate: ConstructorType<[
|
|
|
326
327
|
/**
|
|
327
328
|
* Message what freezes first known value
|
|
328
329
|
*/
|
|
329
|
-
declare function Freeze<T>($base: MessageType<T>, $invalidate?: MessageType<T>):
|
|
330
|
+
declare function Freeze<T>($base: MessageType<T>, $invalidate?: MessageType<T>): MessageImpl<T>;
|
|
330
331
|
|
|
331
332
|
/**
|
|
332
333
|
* A message derived from event with a different
|
|
@@ -334,7 +335,7 @@ declare function Freeze<T>($base: MessageType<T>, $invalidate?: MessageType<T>):
|
|
|
334
335
|
* Allows attaching a custom handler to an existing event source
|
|
335
336
|
* and presenting it as a silentium message
|
|
336
337
|
*/
|
|
337
|
-
declare function FromEvent<T>(emitter: MaybeMessage<any>, eventName: MaybeMessage<string>, subscribeMethod: MaybeMessage<string>, unsubscribeMethod?: MaybeMessage<string>):
|
|
338
|
+
declare function FromEvent<T>(emitter: MaybeMessage<any>, eventName: MaybeMessage<string>, subscribeMethod: MaybeMessage<string>, unsubscribeMethod?: MaybeMessage<string>): MessageImpl<T>;
|
|
338
339
|
|
|
339
340
|
/**
|
|
340
341
|
* A component that allows creating linked objects of information and its owner
|
|
@@ -358,27 +359,27 @@ declare class LateImpl<T> implements MessageSourceType<T> {
|
|
|
358
359
|
* Component that applies an info object constructor to each data item,
|
|
359
360
|
* producing an information source with new values
|
|
360
361
|
*/
|
|
361
|
-
declare function Map$1<T, TG>(base: MaybeMessage<T[]>, target: ConstructorType<[any], MessageType<TG>>):
|
|
362
|
+
declare function Map$1<T, TG>(base: MaybeMessage<T[]>, target: ConstructorType<[any], MessageType<TG>>): MessageImpl<TG[]>;
|
|
362
363
|
|
|
363
364
|
/**
|
|
364
365
|
* Limits the number of values from the information source
|
|
365
366
|
* to a single value - once the first value is emitted, no more
|
|
366
367
|
* values are delivered from the source
|
|
367
368
|
*/
|
|
368
|
-
declare function Once<T>($base: MessageType<T>):
|
|
369
|
+
declare function Once<T>($base: MessageType<T>): MessageImpl<T>;
|
|
369
370
|
|
|
370
|
-
declare function Process<T, R = unknown>($base: MessageType<T>, builder: ConstructorType<[T], MessageType<R>>):
|
|
371
|
+
declare function Process<T, R = unknown>($base: MessageType<T>, builder: ConstructorType<[T], MessageType<R>>): MessageImpl<R>;
|
|
371
372
|
|
|
372
373
|
/**
|
|
373
374
|
* Creates a sequence that accumulates all values from the source into an array,
|
|
374
375
|
* emitting the growing array with each new value.
|
|
375
376
|
*/
|
|
376
|
-
declare function Sequence<T>($base: MessageType<T>):
|
|
377
|
+
declare function Sequence<T>($base: MessageType<T>): MessageImpl<T[]>;
|
|
377
378
|
|
|
378
379
|
/**
|
|
379
380
|
* Component that receives a data array and yields values one by one
|
|
380
381
|
*/
|
|
381
|
-
declare function Stream<T>(base: MaybeMessage<T[]>):
|
|
382
|
+
declare function Stream<T>(base: MaybeMessage<T[]>): MessageImpl<T>;
|
|
382
383
|
|
|
383
384
|
declare function ensureFunction(v: unknown, label: string): void;
|
|
384
385
|
declare function ensureMessage(v: unknown, label: string): void;
|
|
@@ -404,4 +405,5 @@ declare function isDestroyable(o: unknown): o is DestroyableType;
|
|
|
404
405
|
*/
|
|
405
406
|
declare function isDestroyed(o: unknown): o is DestroyedType;
|
|
406
407
|
|
|
407
|
-
export { ActualMessage, All, Any, Applied, AppliedDestructured, Catch, Chain, Chainable, ChainableImpl, Computed,
|
|
408
|
+
export { ActualMessage, All, Any, Applied, AppliedDestructured, Catch, Chain, Chainable, ChainableImpl, Computed, Context, ContextChain, ContextOf, DestroyContainer, DestroyContainerImpl, Destroyable, DestroyableImpl, Empty, EmptyImpl, ExecutorApplied, Filtered, Freeze, FromEvent, Late, LateImpl, Local, Map$1 as Map, Message, MessageImpl, MessageSource, MessageSourceImpl, New, Nothing, Of, Once, Primitive, PrimitiveImpl, Process, Rejections, ResetSilenceCache, Sequence, Shared, SharedImpl, Silence, Stream, Void, ensureFunction, ensureMessage, isDestroyable, isDestroyed, isFilled, isMessage, isSource };
|
|
409
|
+
export type { ConstructorType, ContextType, DestroyableType, DestroyedType, MaybeMessage, MessageExecutorType, MessageSourceType, MessageType, MessageTypeValue, SourceType };
|
package/dist/silentium.js
CHANGED
|
@@ -80,9 +80,14 @@ class Rejections {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
const ResetSilenceCache = Symbol("reset-silence-cache");
|
|
83
84
|
function Silence(resolve) {
|
|
84
85
|
let lastValue;
|
|
85
86
|
return (v) => {
|
|
87
|
+
if (v === ResetSilenceCache) {
|
|
88
|
+
lastValue = void 0;
|
|
89
|
+
v = void 0;
|
|
90
|
+
}
|
|
86
91
|
if (isFilled(v) && v !== lastValue) {
|
|
87
92
|
lastValue = v;
|
|
88
93
|
resolve(v);
|
|
@@ -105,9 +110,9 @@ var __defProp$5 = Object.defineProperty;
|
|
|
105
110
|
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
106
111
|
var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
107
112
|
function Message(executor) {
|
|
108
|
-
return new
|
|
113
|
+
return new MessageImpl(executor);
|
|
109
114
|
}
|
|
110
|
-
class
|
|
115
|
+
class MessageImpl {
|
|
111
116
|
constructor(executor) {
|
|
112
117
|
this.executor = executor;
|
|
113
118
|
__publicField$5(this, "rejections", new Rejections());
|
|
@@ -661,5 +666,5 @@ function Stream(base) {
|
|
|
661
666
|
});
|
|
662
667
|
}
|
|
663
668
|
|
|
664
|
-
export { ActualMessage, All, Any, Applied, AppliedDestructured, Catch, Chain, Chainable, ChainableImpl, Computed, Context, ContextChain, ContextOf, DestroyContainer, DestroyContainerImpl, Destroyable, DestroyableImpl, Empty, EmptyImpl, ExecutorApplied, Filtered, Freeze, FromEvent, Late, LateImpl, Local, Map$1 as Map, Message,
|
|
669
|
+
export { ActualMessage, All, Any, Applied, AppliedDestructured, Catch, Chain, Chainable, ChainableImpl, Computed, Context, ContextChain, ContextOf, DestroyContainer, DestroyContainerImpl, Destroyable, DestroyableImpl, Empty, EmptyImpl, ExecutorApplied, Filtered, Freeze, FromEvent, Late, LateImpl, Local, Map$1 as Map, Message, MessageImpl, MessageSource, MessageSourceImpl, New, Nothing, Of, Once, Primitive, PrimitiveImpl, Process, Rejections, ResetSilenceCache, Sequence, Shared, SharedImpl, Silence, Stream, Void, ensureFunction, ensureMessage, isDestroyable, isDestroyed, isFilled, isMessage, isSource };
|
|
665
670
|
//# sourceMappingURL=silentium.js.map
|