feat(smart-app): implement complete mobile app MVP

- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
This commit is contained in:
Eric FELIXINE
2026-06-01 18:00:35 -04:00
parent 08ca495bde
commit e30ae8ed09
35578 changed files with 3703534 additions and 43 deletions

21
smart-app-city/frontend/node_modules/wonka/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Phil Plückthun
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

59
smart-app-city/frontend/node_modules/wonka/README.md generated vendored Normal file
View File

@@ -0,0 +1,59 @@
# Wonka
A fast push & pull stream library for Reason, loosely following the [callbag spec](https://github.com/callbag/callbag)
> **NOTE:** The `master` branch currently points to the v4 Release Candidate version!
> If you're looking for v3, [please check the `v3.2.2`](https://github.com/kitten/wonka/tree/v3.2.2)
<br>
<a href="https://npmjs.com/package/wonka">
<img alt="NPM Version" src="https://img.shields.io/npm/v/wonka.svg" />
</a>
<a href="https://npmjs.com/package/wonka">
<img alt="License" src="https://img.shields.io/npm/l/wonka.svg" />
</a>
<a href="https://coveralls.io/github/kitten/wonka?branch=master">
<img src="https://coveralls.io/repos/github/kitten/wonka/badge.svg?branch=master" alt="Test Coverage" />
</a>
<a href="https://bundlephobia.com/result?p=wonka">
<img alt="Minified gzip size" src="https://img.shields.io/bundlephobia/minzip/wonka.svg?label=gzip%20size" />
</a>
<br>
> “Theres no earthly way of knowing<br>
> Which direction we are going<br>
> Theres no knowing where were rowing<br>
> Or which way the rivers flowing” **Willy Wonka**
<br>
![Wonka](/docs/wonka.jpg?raw=true)
Wonka is a lightweight iterable and observable library loosely based on
the [callbag spec](https://github.com/callbag/callbag). It exposes a set of helpers to create streams,
which are sources of multiple values, which allow you to create, transform
and consume event streams or iterable sets of data.
Wonka is written in [Reason](https://reasonml.github.io/), a dialect of OCaml, and can hence be used
for native applications. It is also compiled using [BuckleScript](https://bucklescript.github.io) to plain
JavaScript and has typings for [TypeScript](https://www.typescriptlang.org/) and [Flow](https://flow.org/).
This means that out of the box Wonka is usable in any project that use the following:
- Plain JavaScript
- TypeScript
- Flow
- Reason/OCaml with BuckleScript
- Reason/OCaml with `bs-native`
- Reason/OCaml with Dune and Esy
## [Documentation](https://wonka.kitten.sh/)
**See the documentation at [wonka.kitten.sh](https://wonka.kitten.sh)** for more information about using `wonka`!
- [Introduction](https://wonka.kitten.sh/)
- [**Getting started**](https://wonka.kitten.sh/getting-started)
- [Basics](https://wonka.kitten.sh/basics/)
- [API Reference](https://wonka.kitten.sh/api/)
The raw markdown files can be found [in this repository in the `docs` folder](https://github.com/kitten/wonka/tree/master/docs).

View File

@@ -0,0 +1,52 @@
{
"name": "wonka",
"version": "3.1.0",
"namespace": false,
"bsc-flags": ["-bs-super-errors", "-bs-no-version-header"],
"refmt": 3,
"gentypeconfig": {
"language": "typescript",
"importPath": "relative",
"shims": {
"Js": "Js",
"Dom": "Dom",
"ReasonPervasives": "ReasonPervasives"
}
},
"suffix": ".bs.js",
"package-specs": {
"module": "es6",
"in-source": true
},
"sources": [
{
"dir": "src",
"subdirs": [
{
"dir": "shims"
},
{
"dir": "helpers"
},
{
"dir": "web",
"backend": ["js"]
},
{
"dir": "include",
"subdirs": [
{
"dir": "rebel_native"
},
{
"dir": "rebel_js",
"backend": ["js"]
}
]
}
]
}
],
"bs-dependencies": [],
"bs-dev-dependencies": []
}

View File

@@ -0,0 +1,6 @@
export * from './helpers/pipe';
export * from './Wonka_sources.gen';
export * from './Wonka_operators.gen';
export * from './Wonka_sinks.gen';
export * from './web/WonkaJs.gen';
export { sinkT as Sink, sourceT as Source, operatorT as Operator, subscriptionT as Subscription, observerT as Observer, subjectT as Subject } from './Wonka_types.gen';

View File

@@ -0,0 +1,15 @@
// @flow
declare export * from "./helpers/pipe"
declare export * from "./Wonka_sources.gen"
declare export * from "./Wonka_operators.gen"
declare export * from "./Wonka_sinks.gen"
declare export * from "./web/WonkaJs.gen"
declare export {
sinkT as Sink,
sourceT as Source,
operatorT as Operator,
subscriptionT as Subscription,
observerT as Observer,
subjectT as Subject
} from "./Wonka_types.gen";

View File

@@ -0,0 +1,29 @@
import { operatorT as Wonka_types_operatorT } from './Wonka_types.gen';
import { sourceT as Wonka_types_sourceT } from './Wonka_types.gen';
export declare const buffer: <a, b>(notifier: Wonka_types_sourceT<a>) => Wonka_types_operatorT<b, b[]>;
export declare const combine: <a, b>(sourceA: Wonka_types_sourceT<a>, sourceB: Wonka_types_sourceT<b>) => Wonka_types_sourceT<[a, b]>;
export declare const concatMap: <a, b>(f: ((_1: a) => Wonka_types_sourceT<b>)) => Wonka_types_operatorT<a, b>;
export declare const concatAll: <a>(source: Wonka_types_sourceT<Wonka_types_sourceT<a>>) => Wonka_types_sourceT<a>;
export declare const concat: <a>(sources: Wonka_types_sourceT<a>[]) => Wonka_types_sourceT<a>;
export declare const filter: <a>(f: ((_1: a) => boolean)) => Wonka_types_operatorT<a, a>;
export declare const map: <a, b>(f: ((_1: a) => b)) => Wonka_types_operatorT<a, b>;
export declare const mergeMap: <a, b>(f: ((_1: a) => Wonka_types_sourceT<b>)) => Wonka_types_operatorT<a, b>;
export declare const merge: <a>(sources: Wonka_types_sourceT<a>[]) => Wonka_types_sourceT<a>;
export declare const mergeAll: <a>(source: Wonka_types_sourceT<Wonka_types_sourceT<a>>) => Wonka_types_sourceT<a>;
export declare const flatten: <T1>(_1: Wonka_types_sourceT<Wonka_types_sourceT<T1>>) => Wonka_types_sourceT<T1>;
export declare const onEnd: <a>(f: (() => void)) => Wonka_types_operatorT<a, a>;
export declare const onPush: <a>(f: ((_1: a) => void)) => Wonka_types_operatorT<a, a>;
export declare const tap: <T1>(_1: ((_1: T1) => void)) => Wonka_types_operatorT<T1, T1>;
export declare const onStart: <a>(f: (() => void)) => Wonka_types_operatorT<a, a>;
export declare const sample: <a, b>(notifier: Wonka_types_sourceT<a>) => Wonka_types_operatorT<b, b>;
export declare const scan: <a, acc>(f: ((_1: acc, _2: a) => acc), seed: acc) => Wonka_types_operatorT<a, acc>;
export declare const share: <a>(source: Wonka_types_sourceT<a>) => Wonka_types_sourceT<a>;
export declare const skip: <a>(wait: number) => Wonka_types_operatorT<a, a>;
export declare const skipUntil: <a, b>(notifier: Wonka_types_sourceT<a>) => Wonka_types_operatorT<b, b>;
export declare const skipWhile: <a>(f: ((_1: a) => boolean)) => Wonka_types_operatorT<a, a>;
export declare const switchMap: <a, b>(f: ((_1: a) => Wonka_types_sourceT<b>)) => Wonka_types_operatorT<a, b>;
export declare const switchAll: <a>(source: Wonka_types_sourceT<Wonka_types_sourceT<a>>) => Wonka_types_sourceT<a>;
export declare const take: <a>(max: number) => Wonka_types_operatorT<a, a>;
export declare const takeLast: <a>(max: number) => Wonka_types_operatorT<a, a>;
export declare const takeUntil: <a, b>(notifier: Wonka_types_sourceT<a>) => Wonka_types_operatorT<b, b>;
export declare const takeWhile: <a>(f: ((_1: a) => boolean)) => Wonka_types_operatorT<a, a>;

View File

@@ -0,0 +1,75 @@
// @flow
import type { operatorT as Wonka_types_operatorT } from "./Wonka_types.gen";
import type { sourceT as Wonka_types_sourceT } from "./Wonka_types.gen";
declare export var buffer: <a, b>(
notifier: Wonka_types_sourceT<a>
) => Wonka_types_operatorT<b, b[]>;
declare export var combine: <a, b>(
sourceA: Wonka_types_sourceT<a>,
sourceB: Wonka_types_sourceT<b>
) => Wonka_types_sourceT<[a, b]>;
declare export var concatMap: <a, b>(
f: (_1: a) => Wonka_types_sourceT<b>
) => Wonka_types_operatorT<a, b>;
declare export var concatAll: <a>(
source: Wonka_types_sourceT<Wonka_types_sourceT<a>>
) => Wonka_types_sourceT<a>;
declare export var concat: <a>(
sources: Wonka_types_sourceT<a>[]
) => Wonka_types_sourceT<a>;
declare export var filter: <a>(
f: (_1: a) => boolean
) => Wonka_types_operatorT<a, a>;
declare export var map: <a, b>(f: (_1: a) => b) => Wonka_types_operatorT<a, b>;
declare export var mergeMap: <a, b>(
f: (_1: a) => Wonka_types_sourceT<b>
) => Wonka_types_operatorT<a, b>;
declare export var merge: <a>(
sources: Wonka_types_sourceT<a>[]
) => Wonka_types_sourceT<a>;
declare export var mergeAll: <a>(
source: Wonka_types_sourceT<Wonka_types_sourceT<a>>
) => Wonka_types_sourceT<a>;
declare export var flatten: <T1>(
_1: Wonka_types_sourceT<Wonka_types_sourceT<T1>>
) => Wonka_types_sourceT<T1>;
declare export var onEnd: <a>(f: () => void) => Wonka_types_operatorT<a, a>;
declare export var onPush: <a>(
f: (_1: a) => void
) => Wonka_types_operatorT<a, a>;
declare export var tap: <T1>(
_1: (_1: T1) => void
) => Wonka_types_operatorT<T1, T1>;
declare export var onStart: <a>(f: () => void) => Wonka_types_operatorT<a, a>;
declare export var sample: <a, b>(
notifier: Wonka_types_sourceT<a>
) => Wonka_types_operatorT<b, b>;
declare export var scan: <a, acc>(
f: (_1: acc, _2: a) => acc,
seed: acc
) => Wonka_types_operatorT<a, acc>;
declare export var share: <a>(
source: Wonka_types_sourceT<a>
) => Wonka_types_sourceT<a>;
declare export var skip: <a>(wait: number) => Wonka_types_operatorT<a, a>;
declare export var skipUntil: <a, b>(
notifier: Wonka_types_sourceT<a>
) => Wonka_types_operatorT<b, b>;
declare export var skipWhile: <a>(
f: (_1: a) => boolean
) => Wonka_types_operatorT<a, a>;
declare export var switchMap: <a, b>(
f: (_1: a) => Wonka_types_sourceT<b>
) => Wonka_types_operatorT<a, b>;
declare export var switchAll: <a>(
source: Wonka_types_sourceT<Wonka_types_sourceT<a>>
) => Wonka_types_sourceT<a>;
declare export var take: <a>(max: number) => Wonka_types_operatorT<a, a>;
declare export var takeLast: <a>(max: number) => Wonka_types_operatorT<a, a>;
declare export var takeUntil: <a, b>(
notifier: Wonka_types_sourceT<a>
) => Wonka_types_operatorT<b, b>;
declare export var takeWhile: <a>(
f: (_1: a) => boolean
) => Wonka_types_operatorT<a, a>;

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,3 @@
// @flow
declare export {};

View File

@@ -0,0 +1,8 @@
import { sourceT as Wonka_types_sourceT } from './Wonka_types.gen';
import { subscriptionT as Wonka_types_subscriptionT } from './Wonka_types.gen';
export declare type subscribeConsumerT<a> = (_1: Wonka_types_sourceT<a>) => Wonka_types_subscriptionT;
export declare type forEachConsumerT<a> = (_1: Wonka_types_sourceT<a>) => void;
export declare const subscribe: <a>(f: ((_1: a) => void)) => subscribeConsumerT<a>;
export declare const forEach: <a>(f: ((_1: a) => void)) => forEachConsumerT<a>;
export declare const publish: <a>(source: Wonka_types_sourceT<a>) => Wonka_types_subscriptionT;
export declare const toArray: <a>(source: Wonka_types_sourceT<a>) => a[];

View File

@@ -0,0 +1,14 @@
// @flow
import type { sourceT as Wonka_types_sourceT } from "./Wonka_types.gen";
import type { subscriptionT as Wonka_types_subscriptionT } from "./Wonka_types.gen";
export type subscribeConsumerT<a> = (
_1: Wonka_types_sourceT<a>
) => Wonka_types_subscriptionT;
export type forEachConsumerT<a> = (_1: Wonka_types_sourceT<a>) => void;
declare export var subscribe: <a>(f: (_1: a) => void) => subscribeConsumerT<a>;
declare export var forEach: <a>(f: (_1: a) => void) => forEachConsumerT<a>;
declare export var publish: <a>(
source: Wonka_types_sourceT<a>
) => Wonka_types_subscriptionT;
declare export var toArray: <a>(source: Wonka_types_sourceT<a>) => a[];

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,3 @@
// @flow
declare export {};

View File

@@ -0,0 +1,13 @@
import { list } from '../src/shims/ReasonPervasives.shim';
import { observerT as Wonka_types_observerT } from './Wonka_types.gen';
import { sinkT as Wonka_types_sinkT } from './Wonka_types.gen';
import { sourceT as Wonka_types_sourceT } from './Wonka_types.gen';
import { subjectT as Wonka_types_subjectT } from './Wonka_types.gen';
import { teardownT as Wonka_types_teardownT } from './Wonka_types.gen';
export declare const fromArray: <a>(arr: a[]) => Wonka_types_sourceT<a>;
export declare const fromList: <a>(ls: list<a>) => Wonka_types_sourceT<a>;
export declare const fromValue: <a>(x: a) => Wonka_types_sourceT<a>;
export declare const make: <a>(f: ((_1: Wonka_types_observerT<a>) => Wonka_types_teardownT)) => Wonka_types_sourceT<a>;
export declare const makeSubject: <a>() => Wonka_types_subjectT<a>;
export declare const empty: <a>(sink: Wonka_types_sinkT<a>) => void;
export declare const never: <a>(sink: Wonka_types_sinkT<a>) => void;

View File

@@ -0,0 +1,17 @@
// @flow
import type { list } from "../src/shims/ReasonPervasives.shim";
import type { observerT as Wonka_types_observerT } from "./Wonka_types.gen";
import type { sinkT as Wonka_types_sinkT } from "./Wonka_types.gen";
import type { sourceT as Wonka_types_sourceT } from "./Wonka_types.gen";
import type { subjectT as Wonka_types_subjectT } from "./Wonka_types.gen";
import type { teardownT as Wonka_types_teardownT } from "./Wonka_types.gen";
declare export var fromArray: <a>(arr: a[]) => Wonka_types_sourceT<a>;
declare export var fromList: <a>(ls: list<a>) => Wonka_types_sourceT<a>;
declare export var fromValue: <a>(x: a) => Wonka_types_sourceT<a>;
declare export var make: <a>(
f: (_1: Wonka_types_observerT<a>) => Wonka_types_teardownT
) => Wonka_types_sourceT<a>;
declare export var makeSubject: <a>() => Wonka_types_subjectT<a>;
declare export var empty: <a>(sink: Wonka_types_sinkT<a>) => void;
declare export var never: <a>(sink: Wonka_types_sinkT<a>) => void;

View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,3 @@
// @flow
declare export {};

View File

@@ -0,0 +1,20 @@
import { signalT as $$signalT } from './shims/Js.shim';
import { talkbackT as $$talkbackT } from './shims/Js.shim';
export declare type talkbackT = $$talkbackT;
export declare type signalT<a> = $$signalT<a>;
export declare type sinkT<a> = (_1: signalT<a>) => void;
export declare type sourceT<a> = (_1: sinkT<a>) => void;
export declare type operatorT<a, b> = (_1: sourceT<a>) => sourceT<b>;
export declare type teardownT = () => void;
export declare type subscriptionT = {
readonly unsubscribe: () => void;
};
export declare type observerT<a> = {
readonly next: (_1: a) => void;
readonly complete: () => void;
};
export declare type subjectT<a> = {
readonly source: sourceT<a>;
readonly next: (_1: a) => void;
readonly complete: () => void;
};

View File

@@ -0,0 +1,25 @@
// @flow
import type { signalT as $$signalT } from "./shims/Js.shim";
import type { talkbackT as $$talkbackT } from "./shims/Js.shim";
export type talkbackT = $$talkbackT;
export type signalT<a> = $$signalT<a>;
export type sinkT<a> = (_1: signalT<a>) => void;
export type sourceT<a> = (_1: sinkT<a>) => void;
export type operatorT<a, b> = (_1: sourceT<a>) => sourceT<b>;
export type teardownT = () => void;
export type subscriptionT = {
+unsubscribe: () => void,
...
};
export type observerT<a> = {
+next: (_1: a) => void,
+complete: () => void,
...
};
export type subjectT<a> = {
+source: sourceT<a>,
+next: (_1: a) => void,
+complete: () => void,
...
};

View File

@@ -0,0 +1,13 @@
import { talkbackT, signalT } from '../Wonka_types.gen';
declare type talkbackCb = (tb: talkbackT) => void;
export declare const pull: import("../shims/Js.shim").talkbackT;
export declare const close: import("../shims/Js.shim").talkbackT;
export declare const start: <a>(tb: talkbackCb) => import("../shims/Js.shim").signalT<a>;
export declare const push: <a>(x: a) => import("../shims/Js.shim").signalT<a>;
export declare const end: <a>() => import("../shims/Js.shim").signalT<a>;
export declare const isStart: <a>(s: import("../shims/Js.shim").signalT<a>) => boolean;
export declare const isPush: <a>(s: import("../shims/Js.shim").signalT<a>) => boolean;
export declare const isEnd: <a>(s: import("../shims/Js.shim").signalT<a>) => boolean;
export declare const unboxPush: <a>(s: import("../shims/Js.shim").signalT<a>) => a;
export declare const unboxStart: <a>(s: import("../shims/Js.shim").signalT<a>) => talkbackCb;
export {};

View File

@@ -0,0 +1,38 @@
// @flow
import type { talkbackT, signalT } from "../Wonka_types.gen";
declare type talkbackCb = (tb: talkbackT) => void;
declare export var pull: $PropertyType<
$Exports<"../shims/Js.shim">,
"talkbackT"
>;
declare export var close: $PropertyType<
$Exports<"../shims/Js.shim">,
"talkbackT"
>;
declare export var start: <a>(
tb: talkbackCb
) => $PropertyType<$Exports<"../shims/Js.shim">, "signalT">;
declare export var push: <a>(
x: a
) => $PropertyType<$Exports<"../shims/Js.shim">, "signalT">;
declare export var end: <a>() => $PropertyType<
$Exports<"../shims/Js.shim">,
"signalT"
>;
declare export var isStart: <a>(
s: $PropertyType<$Exports<"../shims/Js.shim">, "signalT">
) => boolean;
declare export var isPush: <a>(
s: $PropertyType<$Exports<"../shims/Js.shim">, "signalT">
) => boolean;
declare export var isEnd: <a>(
s: $PropertyType<$Exports<"../shims/Js.shim">, "signalT">
) => boolean;
declare export var unboxPush: <a>(
s: $PropertyType<$Exports<"../shims/Js.shim">, "signalT">
) => a;
declare export var unboxStart: <a>(
s: $PropertyType<$Exports<"../shims/Js.shim">, "signalT">
) => talkbackCb;
declare export {};

View File

@@ -0,0 +1,22 @@
import { sourceT as Source } from '../Wonka_types.gen';
interface UnaryFn<T, R> {
(source: T): R;
}
declare function pipe<T, A>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>): Source<A>;
declare function pipe<T, A, B>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>): Source<B>;
declare function pipe<T, A, B, C>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, op3: UnaryFn<Source<B>, Source<C>>): Source<C>;
declare function pipe<T, A, B, C, D>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, op3: UnaryFn<Source<B>, Source<C>>, op4: UnaryFn<Source<C>, Source<D>>): Source<D>;
declare function pipe<T, A, B, C, D, E>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, op3: UnaryFn<Source<B>, Source<C>>, op4: UnaryFn<Source<C>, Source<D>>, op5: UnaryFn<Source<D>, Source<E>>): Source<E>;
declare function pipe<T, A, B, C, D, E, F>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, op3: UnaryFn<Source<B>, Source<C>>, op4: UnaryFn<Source<C>, Source<D>>, op5: UnaryFn<Source<D>, Source<E>>, op6: UnaryFn<Source<E>, Source<F>>): Source<F>;
declare function pipe<T, A, B, C, D, E, F, G>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, op3: UnaryFn<Source<B>, Source<C>>, op4: UnaryFn<Source<C>, Source<D>>, op5: UnaryFn<Source<D>, Source<E>>, op6: UnaryFn<Source<E>, Source<F>>, op7: UnaryFn<Source<F>, Source<G>>): Source<G>;
declare function pipe<T, A, B, C, D, E, F, G, H>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, op3: UnaryFn<Source<B>, Source<C>>, op4: UnaryFn<Source<C>, Source<D>>, op5: UnaryFn<Source<D>, Source<E>>, op6: UnaryFn<Source<E>, Source<F>>, op7: UnaryFn<Source<F>, Source<G>>, op8: UnaryFn<Source<G>, Source<H>>): Source<H>;
declare function pipe<T, R>(source: Source<T>, consumer: UnaryFn<Source<T>, R>): R;
declare function pipe<T, A, R>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, consumer: UnaryFn<Source<A>, R>): R;
declare function pipe<T, A, B, R>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, consumer: UnaryFn<Source<B>, R>): R;
declare function pipe<T, A, B, C, R>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, op3: UnaryFn<Source<B>, Source<C>>, consumer: UnaryFn<Source<C>, R>): R;
declare function pipe<T, A, B, C, D, R>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, op3: UnaryFn<Source<B>, Source<C>>, op4: UnaryFn<Source<C>, Source<D>>, consumer: UnaryFn<Source<D>, R>): R;
declare function pipe<T, A, B, C, D, E, R>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, op3: UnaryFn<Source<B>, Source<C>>, op4: UnaryFn<Source<C>, Source<D>>, op5: UnaryFn<Source<D>, Source<E>>, consumer: UnaryFn<Source<E>, R>): R;
declare function pipe<T, A, B, C, D, E, F, R>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, op3: UnaryFn<Source<B>, Source<C>>, op4: UnaryFn<Source<C>, Source<D>>, op5: UnaryFn<Source<D>, Source<E>>, op6: UnaryFn<Source<E>, Source<F>>, consumer: UnaryFn<Source<F>, R>): R;
declare function pipe<T, A, B, C, D, E, F, G, R>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, op3: UnaryFn<Source<B>, Source<C>>, op4: UnaryFn<Source<C>, Source<D>>, op5: UnaryFn<Source<D>, Source<E>>, op6: UnaryFn<Source<E>, Source<F>>, op7: UnaryFn<Source<F>, Source<G>>, consumer: UnaryFn<Source<G>, R>): R;
declare function pipe<T, A, B, C, D, E, F, G, H, R>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>, op2: UnaryFn<Source<A>, Source<B>>, op3: UnaryFn<Source<B>, Source<C>>, op4: UnaryFn<Source<C>, Source<D>>, op5: UnaryFn<Source<D>, Source<E>>, op6: UnaryFn<Source<E>, Source<F>>, op7: UnaryFn<Source<F>, Source<G>>, op8: UnaryFn<Source<G>, Source<H>>, consumer: UnaryFn<Source<H>, R>): R;
export { pipe };

View File

@@ -0,0 +1,139 @@
// @flow
import type { sourceT as Source } from "../Wonka_types.gen";
declare interface UnaryFn<T, R> {
(source: T): R;
}
declare function pipe<T, A>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>
): Source<A>;
declare function pipe<T, A, B>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>
): Source<B>;
declare function pipe<T, A, B, C>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>
): Source<C>;
declare function pipe<T, A, B, C, D>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>
): Source<D>;
declare function pipe<T, A, B, C, D, E>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>
): Source<E>;
declare function pipe<T, A, B, C, D, E, F>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
op6: UnaryFn<Source<E>, Source<F>>
): Source<F>;
declare function pipe<T, A, B, C, D, E, F, G>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
op6: UnaryFn<Source<E>, Source<F>>,
op7: UnaryFn<Source<F>, Source<G>>
): Source<G>;
declare function pipe<T, A, B, C, D, E, F, G, H>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
op6: UnaryFn<Source<E>, Source<F>>,
op7: UnaryFn<Source<F>, Source<G>>,
op8: UnaryFn<Source<G>, Source<H>>
): Source<H>;
declare function pipe<T, R>(
source: Source<T>,
consumer: UnaryFn<Source<T>, R>
): R;
declare function pipe<T, A, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
consumer: UnaryFn<Source<A>, R>
): R;
declare function pipe<T, A, B, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
consumer: UnaryFn<Source<B>, R>
): R;
declare function pipe<T, A, B, C, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
consumer: UnaryFn<Source<C>, R>
): R;
declare function pipe<T, A, B, C, D, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
consumer: UnaryFn<Source<D>, R>
): R;
declare function pipe<T, A, B, C, D, E, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
consumer: UnaryFn<Source<E>, R>
): R;
declare function pipe<T, A, B, C, D, E, F, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
op6: UnaryFn<Source<E>, Source<F>>,
consumer: UnaryFn<Source<F>, R>
): R;
declare function pipe<T, A, B, C, D, E, F, G, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
op6: UnaryFn<Source<E>, Source<F>>,
op7: UnaryFn<Source<F>, Source<G>>,
consumer: UnaryFn<Source<G>, R>
): R;
declare function pipe<T, A, B, C, D, E, F, G, H, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
op6: UnaryFn<Source<E>, Source<F>>,
op7: UnaryFn<Source<F>, Source<G>>,
op8: UnaryFn<Source<G>, Source<H>>,
consumer: UnaryFn<Source<H>, R>
): R;
declare export { pipe };

View File

@@ -0,0 +1,2 @@
export declare type element = HTMLElement;
export declare type event = Event;

View File

@@ -0,0 +1,4 @@
// @flow
export type element = HTMLElement;
export type event = Event;

View File

@@ -0,0 +1,26 @@
export declare type Exn_t = Error;
export declare type Internal_meth<_T, R> = () => R;
export declare type talkbackT = 0 | 1;
export declare type signalT<a> = ({
tag: 0;
} & [(talkback: talkbackT) => void]) | ({
tag: 1;
} & [a]) | 0;
export interface observableSubscriptionT {
unsubscribe(): void;
}
export interface observableObserverT<a> {
next(value: a): void;
error(error: any): void;
complete(): void;
}
export interface observableT<a> {
subscribe(observer: observableObserverT<a>): observableSubscriptionT;
}
interface Callbag<I, O> {
(t: 0, d: Callbag<O, I>): void;
(t: 1, d: I): void;
(t: 2, d?: any): void;
}
export declare type callbagT<a> = Callbag<void, a>;
export {};

View File

@@ -0,0 +1,33 @@
// @flow
export type Exn_t = Error;
export type Internal_meth<_T, R> = () => R;
export type talkbackT = 0 | 1;
export type signalT<a> =
| ({
tag: 0,
...
} & [(talkback: talkbackT) => void])
| ({
tag: 1,
...
} & [a])
| 0;
export interface observableSubscriptionT {
unsubscribe(): void;
}
export interface observableObserverT<a> {
next(value: a): void;
error(error: any): void;
complete(): void;
}
export interface observableT<a> {
subscribe(observer: observableObserverT<a>): observableSubscriptionT;
}
declare interface Callbag<I, O> {
(t: 0, d: Callbag<O, I>): void;
(t: 1, d: I): void;
(t: 2, d?: any): void;
}
export type callbagT<a> = Callbag<void, a>;
declare export {};

View File

@@ -0,0 +1,7 @@
export declare abstract class EmptyList {
protected opaque: any;
}
export declare abstract class Cons<T> {
protected opaque: T;
}
export declare type list<T> = Cons<T> | EmptyList;

View File

@@ -0,0 +1,9 @@
// @flow
declare export class EmptyList {
opaque: any;
}
declare export class Cons<T> {
opaque: T;
}
export type list<T> = Cons<T> | EmptyList;

View File

@@ -0,0 +1,17 @@
import { callbagT as Wonka_callbag_callbagT } from './Wonka_callbag.gen';
import { element as Dom_element } from '../../src/shims/Dom.shim';
import { event as Dom_event } from '../../src/shims/Dom.shim';
import { observableT as Wonka_observable_observableT } from './Wonka_observable.gen';
import { operatorT as Wonka_types_operatorT } from '../../src/Wonka_types.gen';
import { sourceT as Wonka_types_sourceT } from '../../src/Wonka_types.gen';
export declare const fromObservable: <T1>(_1: Wonka_observable_observableT<T1>) => Wonka_types_sourceT<T1>;
export declare const toObservable: <T1>(_1: Wonka_types_sourceT<T1>) => Wonka_observable_observableT<T1>;
export declare const fromCallbag: <T1>(_1: Wonka_callbag_callbagT<T1>) => Wonka_types_sourceT<T1>;
export declare const toCallbag: <T1>(_1: Wonka_types_sourceT<T1>) => Wonka_callbag_callbagT<T1>;
export declare const debounce: <a>(f: ((_1: a) => number)) => Wonka_types_operatorT<a, a>;
export declare const delay: <a>(wait: number) => Wonka_types_operatorT<a, a>;
export declare const throttle: <a>(f: ((_1: a) => number)) => Wonka_types_operatorT<a, a>;
export declare const toPromise: <a>(source: Wonka_types_sourceT<a>) => Promise<a>;
export declare const interval: (p: number) => Wonka_types_sourceT<number>;
export declare const fromDomEvent: (element: Dom_element, event: string) => Wonka_types_sourceT<Dom_event>;
export declare const fromPromise: <a>(promise: Promise<a>) => Wonka_types_sourceT<a>;

View File

@@ -0,0 +1,36 @@
// @flow
import type { callbagT as Wonka_callbag_callbagT } from "./Wonka_callbag.gen";
import type { element as Dom_element } from "../../src/shims/Dom.shim";
import type { event as Dom_event } from "../../src/shims/Dom.shim";
import type { observableT as Wonka_observable_observableT } from "./Wonka_observable.gen";
import type { operatorT as Wonka_types_operatorT } from "../../src/Wonka_types.gen";
import type { sourceT as Wonka_types_sourceT } from "../../src/Wonka_types.gen";
declare export var fromObservable: <T1>(
_1: Wonka_observable_observableT<T1>
) => Wonka_types_sourceT<T1>;
declare export var toObservable: <T1>(
_1: Wonka_types_sourceT<T1>
) => Wonka_observable_observableT<T1>;
declare export var fromCallbag: <T1>(
_1: Wonka_callbag_callbagT<T1>
) => Wonka_types_sourceT<T1>;
declare export var toCallbag: <T1>(
_1: Wonka_types_sourceT<T1>
) => Wonka_callbag_callbagT<T1>;
declare export var debounce: <a>(
f: (_1: a) => number
) => Wonka_types_operatorT<a, a>;
declare export var delay: <a>(wait: number) => Wonka_types_operatorT<a, a>;
declare export var throttle: <a>(
f: (_1: a) => number
) => Wonka_types_operatorT<a, a>;
declare export var toPromise: <a>(source: Wonka_types_sourceT<a>) => Promise<a>;
declare export var interval: (p: number) => Wonka_types_sourceT<number>;
declare export var fromDomEvent: (
element: Dom_element,
event: string
) => Wonka_types_sourceT<Dom_event>;
declare export var fromPromise: <a>(
promise: Promise<a>
) => Wonka_types_sourceT<a>;

View File

@@ -0,0 +1,10 @@
import { callbagT as $$callbagT } from '../shims/Js.shim';
import { sourceT as Wonka_types_sourceT } from '../../src/Wonka_types.gen';
export declare type callbagSignal = 0 | 1 | 2;
export declare abstract class callbagData<a> {
protected opaque: a;
}
export declare type callbagTalkback = (_1: callbagSignal) => void;
export declare type callbagT<a> = $$callbagT<a>;
export declare const fromCallbag: <a>(callbag: callbagT<a>) => Wonka_types_sourceT<a>;
export declare const toCallbag: <a>(source: Wonka_types_sourceT<a>) => callbagT<a>;

View File

@@ -0,0 +1,16 @@
// @flow
import type { callbagT as $$callbagT } from "../shims/Js.shim";
import type { sourceT as Wonka_types_sourceT } from "../../src/Wonka_types.gen";
export type callbagSignal = 0 | 1 | 2;
declare export class callbagData<a> {
opaque: a;
}
export type callbagTalkback = (_1: callbagSignal) => void;
export type callbagT<a> = $$callbagT<a>;
declare export var fromCallbag: <a>(
callbag: callbagT<a>
) => Wonka_types_sourceT<a>;
declare export var toCallbag: <a>(
source: Wonka_types_sourceT<a>
) => callbagT<a>;

View File

@@ -0,0 +1,9 @@
import { observableObserverT as $$observableObserverT } from '../shims/Js.shim';
import { observableSubscriptionT as $$observableSubscriptionT } from '../shims/Js.shim';
import { observableT as $$observableT } from '../shims/Js.shim';
import { sourceT as Wonka_types_sourceT } from '../../src/Wonka_types.gen';
export declare type observableSubscriptionT = $$observableSubscriptionT;
export declare type observableObserverT<a> = $$observableObserverT<a>;
export declare type observableT<a> = $$observableT<a>;
export declare const fromObservable: <a>(input: observableT<a>) => Wonka_types_sourceT<a>;
export declare const toObservable: <a>(source: Wonka_types_sourceT<a>) => observableT<a>;

View File

@@ -0,0 +1,15 @@
// @flow
import type { observableObserverT as $$observableObserverT } from "../shims/Js.shim";
import type { observableSubscriptionT as $$observableSubscriptionT } from "../shims/Js.shim";
import type { observableT as $$observableT } from "../shims/Js.shim";
import type { sourceT as Wonka_types_sourceT } from "../../src/Wonka_types.gen";
export type observableSubscriptionT = $$observableSubscriptionT;
export type observableObserverT<a> = $$observableObserverT<a>;
export type observableT<a> = $$observableT<a>;
declare export var fromObservable: <a>(
input: observableT<a>
) => Wonka_types_sourceT<a>;
declare export var toObservable: <a>(
source: Wonka_types_sourceT<a>
) => observableT<a>;

1271
smart-app-city/frontend/node_modules/wonka/dist/wonka.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
// @flow
declare export * from "./types/src/Wonka.js.flow"

File diff suppressed because one or more lines are too long

1182
smart-app-city/frontend/node_modules/wonka/dist/wonka.mjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
// @flow
declare export * from "./types/src/Wonka.js.flow"

View File

@@ -0,0 +1,136 @@
---
title: Getting Started
order: 1
---
This page will explain how to install the Wonka package and
its basic usage and helper functions.
## Installation
The `wonka` package from `npm` is all you need to install to use
Wonka. The process is the same with `yarn` and `esy`.
```bash
yarn add wonka
# or with npm:
npm install --save wonka
# or with esy:
esy add wonka
```
For **JavaScript projects**, the package contains both CommonJS and
ES Modules bundles. For Flow and TypeScript the package also contains
typings files already, so if you're using either you're already done and
ready to go.
If you're using **BuckleScript** or `bs-native` you will need to add `"wonka"`
to your `bs-dependencies` in your `bsconfig.json` configuration file:
```diff
{
"name": "<some_name>",
"version": "0.1.0",
"sources": ["src"],
"bsc-flags": ["-bs-super-errors"],
"bs-dependencies": [
+ "wonka"
]
}
```
If you're using **Dune** and **Esy** you will need to add `wonka` to
your `libraries` entry in the respective `dune` configuration file:
```diff
(library
(name some_name)
(public_name some_name)
+ (libraries wonka)
)
```
## Usage with JavaScript
In most cases you'll simply import or require `wonka` and use its exposed
methods and utilities. In both CommonJS and ES Modules the Wonka package
simply exposes all its utilities.
```js
// With CommonJS
const { fromArray } = require('wonka');
// With ES Modules
import { fromArray } from 'wonka';
```
There are also some special operators in Wonka that will only be exposed in
Web/JavaScript environments, like `fromPromise`, `toPromise`,
or `fromEvent`, or even `debounce` and `throttle`.
In TypeScript and Flow the typings also expose all types.
There's also a special utility in JavaScript environments to replace the pipeline
operator. This function is called `pipe` and simply calls functions that it's
being passed in order with the previous return value.
```js
import { pipe } from 'wonka';
const output = pipe(
'test',
x => x + ' this',
x => x.toUpperCase()
);
output; // "TEST THIS"
```
As shown above, the `pipe` function takes the first argument and passes it
in order to the other function arguments. The return value of one function will
be passed on to the next function.
In TypeScript and Flow the `pipe` function is also typed to handle all generics
in Wonka utilities correctly. Using it will ensure that most of the time you won't
have to specify the types of any generics manually.
If you're using Babel and the [pipeline proposal plugin](https://babeljs.io/docs/en/babel-plugin-proposal-pipeline-operator), you can just use
the pipeline operator to do the same and not use the `pipe` helper.
## Usage with Reason
Everything in the Wonka package is exposed under a single module called `Wonka`.
This module also contains `Wonka.Types`, which contains all internal types of the Wonka
library, but you will typically not need it.
In `BuckleScript` when you're compiling to JavaScript you will also have access to
more utilities like `fromPromise`, `toPromise`, `fromEvent`, or even `debounce` and `throttle`.
These utilities are missing in native compilation, like Dune or `bsb-native`, since they're
relying on JavaScript APIs like Promises, `window.addEventListener`, and `setTimeout`.
When using Wonka you'd simply either open the module and use its utilities or just
access them from the `Wonka` module:
```reason
Wonka.fromValue("test")
|> Wonka.map((.x) => x ++ " this")
|> Wonka.forEach((.x) => print_endline(x));
```
It's worth noting that most callbacks in Wonka need to be explicitly uncurried, since
this will help them compile cleanly to JavaScript.
## Interoperability
In JavaScript environments, Wonka comes with several utilities that make it easier
to interoperate with JavaScript primitives and other libraries:
- [`fromPromise`](./api/sources.md#frompromise) & [`toPromise`](./api/sinks.md#topromise) can be used to interoperate with Promises
- [`fromObservable`](./api/sources.md#fromobservable) & [`toObservable`](./api/sinks.md#toobservable) can be used to interoperate with spec-compliant Observables
- [`fromCallbag`](./api/sources.md#fromcallbag) & [`toCallbag`](./api/sinks.md#tocallbag) can be used to interoperate with spec-compliant Callbags
Furthermore there are a couple of operators that only work in JavaScript environments
since they need timing primitives, like `setTimeout` and `setInterval`:
- [`delay`](./api/operators.md#delay)
- [`debounce`](./api/operators.md#debounce)
- [`throttle`](./api/operators.md#throttle)
- [`interval`](./api/sources.md#interval)

View File

@@ -0,0 +1,51 @@
---
title: Introduction
order: 0
---
Wonka is a lightweight iterable and observable library loosely based on
the [callbag spec](https://github.com/callbag/callbag). It exposes a set of helpers to create streams,
which are sources of multiple values, which allow you to create, transform
and consume event streams or iterable sets of data.
## What it is
Wonka is a library for streams _and_ iterables that behaves predictably
and can be used for many problems where you're dealing with streams of
values, asynchronous or not.
It's similar to [RxJS](https://github.com/ReactiveX/rxjs) in that it enables asynchronous programming with
observable streams, with an API that looks like functional programming on
iterables, but it's also similar to [IxJS](https://github.com/ReactiveX/IxJS) since Wonka streams will run
synchronously if an iterable source runs synchronously.
It also comes with many operators that users from [RxJS](https://github.com/ReactiveX/rxjs) will be used to.
## Compatibility
Wonka is written in [Reason](https://reasonml.github.io/), a dialect of OCaml, and can hence be used
for native applications. It is also compiled using [BuckleScript](https://bucklescript.github.io) to plain
JavaScript and has typings for [TypeScript](https://www.typescriptlang.org/) and [Flow](https://flow.org/).
This means that out of the box Wonka is usable in any project that use the following:
- Plain JavaScript
- TypeScript
- Flow
- Reason/OCaml with BuckleScript
- Reason/OCaml with `bs-native`
- Reason/OCaml with Dune and Esy
In summary, Wonka provides a consistent interface in and works across
TypeScript/Flow/Reason/OCaml environments with full type safety.
## About the docs
As mentioned in the prior section, Wonka supports not one but a couple of
environments and languages. To accommodate for this, most of the docs
are written with examples and sections for TypeScript and Reason.
We don't provide examples in most parts of the docs for Flow and OCaml because
their respective usage is almost identical to TypeScript and Reason, so for
the most part the examples mostly deal with the differences between a
TypeScript and a Reason project.

View File

@@ -0,0 +1,110 @@
---
title: Migration
order: 2
---
This page lists breaking changes and migration guides for
various major releases of Wonka.
## v4.0.0
In `v4.0.0` of Wonka, we've migrated to BuckleScript v7 and
`genType` for automatic type generation for TypeScript. The
Flow types are derived from the automatic types and are generated
by `flowgen`.
This may mean that `bsb-native` and Dune/Esy builds are temporarily
broken, as they haven't been tested yet. If so, they will be fixed
in a future minor release. Please stick with `v3.2.2` if you're having
trouble.
This release has no breaking changes for Reason/OCaml in terms of
API changes. You can use the library exactly as you have before.
**For TypeScript and Flow some APIs have changed**.
### New TypeScript and Flow typings
The type for `Subscription`, `Observer`, and `Subject` have changed.
These used to be exposed as tuples (fixed-size arrays) in the past,
but are now compiled to objects, due to the upgrade to BuckleScript v7.
If you're using `subscribe`, `makeSubject`, or `make` you will have
to change some of your types. If you don't, you won't have to update
any of your code and can even mix Wonka `v4.0.0` with `v3.2.2` in the
same bundle.
The `Subscription` type has changed from `[() => void]` to
`{ unsubscribe: (_: void) => void }`:
```ts
import { subscribe } from 'wonka';
// Before:
const [unsubscribe] = subscribe(source);
// After:
const { unsubscribe } = subscribe(source);
```
The `Observer` type has changed similarly, so you'll have to
update your code if you're using `make`:
```ts
import { make } from 'wonka';
// Before:
const source = make(([next, complete]) => /* ... */);
// After:
const source = make(({ next, complete }) => /* ... */);
```
And lastly the `Subject` type has changed as well, so update
your usage of `makeSubject`:
```ts
import { makeSubject } from 'wonka';
// Before:
const [source, next, complete] = makeSubject();
// After:
const { source, next, complete } = makeSubject();
```
### Improvements
The test suite has been rewritten from scratch to improve our
testing of some tricky edge cases. In most cases operators have
been updated to behave more nicely and closer to the spec and
as expected. This is especially true if you're using synchronous
sources or iterables a lot.
Wonka has reached a much higher test coverage and operators like
`merge` and `switchMap` will now behave as expected with synchronous
sources.
This is the list of operators that have changed. If your code has
been working before, you _shouldn't see any different behaviour_.
The changed operators will simply have received bugfixes and will
behave more predictably (and hopefully correctly) in certain edge cases!
- [`buffer`](./api/operators.md#buffer)
- [`combine`](./api/operators.md#combine)
- [`debounce`](./api/operators.md#debounce)
- [`delay`](./api/operators.md#delay)
- [`sample`](./api/operators.md#sample)
- [`skipUntil`](./api/operators.md#skipuntil)
- [`take`](./api/operators.md#take)
- [`takeLast`](./api/operators.md#takelast)
- [`takeWhile`](./api/operators.md#takewhile)
- [`switchMap`](./api/operators.md#switchmap)
- [`mergeMap`](./api/operators.md#mergemap)
- [`concatMap`](./api/operators.md#concatmap)
- [`switchAll`](./api/operators.md#switchall)
- [`mergeAll`](./api/operators.md#mergeall)
- [`concatAll`](./api/operators.md#concatall)
- [`merge`](./api/operators.md#merge)
- [`concat`](./api/operators.md#concat)
The `take` operator is the only one that has been changed to fix
a notable new usage case. It can now accept a maximum of `0` or below,
to close the source immediately.

View File

@@ -0,0 +1 @@
(lang dune 1.6)

20
smart-app-city/frontend/node_modules/wonka/esy.json generated vendored Normal file
View File

@@ -0,0 +1,20 @@
{
"name": "wonka",
"version": "4.0.3",
"esy": {
"build": "dune build -p #{self.name}"
},
"peerDependencies": {
"ocaml": ">= 4.6.0"
},
"dependencies": {
"@opam/dune": "^1.7.3",
"@esy-ocaml/reason": ">= 3.4.0 < 3.6.0",
"refmterr": "*",
"belt": "jaredly/belt"
},
"devDependencies": {
"@opam/merlin": "*",
"ocaml": "4.8.1000"
}
}

View File

@@ -0,0 +1,3 @@
# Set eol to LF so files aren't converted to CRLF-eol on Windows.
* text eol=lf

View File

@@ -0,0 +1,3 @@
# Reset any possible .gitignore, we want all esy.lock to be un-ignored.
!*

View File

@@ -0,0 +1,725 @@
{
"checksum": "f65f3554d6e408990d52199c5e9747c9",
"root": "wonka@link-dev:./esy.json",
"node": {
"wonka@link-dev:./esy.json": {
"id": "wonka@link-dev:./esy.json",
"name": "wonka",
"version": "link-dev:./esy.json",
"source": { "type": "link-dev", "path": ".", "manifest": "esy.json" },
"overrides": [],
"dependencies": [
"refmterr@3.3.0@d41d8cd9", "ocaml@4.8.1000@d41d8cd9",
"belt@github:jaredly/belt#4d07f859403fdbd3fbfc5a9547c6066d657a2131@d41d8cd9",
"@opam/dune@opam:2.1.2@94bd8c1b", "@esy-ocaml/reason@3.5.2@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/merlin@opam:3.3.3@d653b06a"
]
},
"refmterr@3.3.0@d41d8cd9": {
"id": "refmterr@3.3.0@d41d8cd9",
"name": "refmterr",
"version": "3.3.0",
"source": {
"type": "install",
"source": [
"archive:https://registry.npmjs.org/refmterr/-/refmterr-3.3.0.tgz#sha1:45adde80205093c201b491b3c37dd7740c9b036b"
]
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@reason-native/pastel@0.2.3@d41d8cd9",
"@reason-native/console@0.1.0@d41d8cd9",
"@opam/re@opam:1.9.0@d4d5e13d", "@opam/dune@opam:2.1.2@94bd8c1b",
"@opam/atdgen@opam:2.0.0@46af0360",
"@esy-ocaml/reason@3.5.2@d41d8cd9"
],
"devDependencies": []
},
"ocaml@4.8.1000@d41d8cd9": {
"id": "ocaml@4.8.1000@d41d8cd9",
"name": "ocaml",
"version": "4.8.1000",
"source": {
"type": "install",
"source": [
"archive:https://registry.npmjs.org/ocaml/-/ocaml-4.8.1000.tgz#sha1:abc435b5d4ddea2acba8b2df7efb81e2d1690db1"
]
},
"overrides": [],
"dependencies": [],
"devDependencies": []
},
"belt@github:jaredly/belt#4d07f859403fdbd3fbfc5a9547c6066d657a2131@d41d8cd9": {
"id":
"belt@github:jaredly/belt#4d07f859403fdbd3fbfc5a9547c6066d657a2131@d41d8cd9",
"name": "belt",
"version":
"github:jaredly/belt#4d07f859403fdbd3fbfc5a9547c6066d657a2131",
"source": {
"type": "install",
"source": [
"github:jaredly/belt#4d07f859403fdbd3fbfc5a9547c6066d657a2131"
]
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9",
"@opam/ppx_tools_versioned@opam:5.2.3@4994ec80",
"@opam/ocaml-migrate-parsetree@opam:1.5.0@3e319dbc",
"@opam/dune@opam:2.1.2@94bd8c1b", "@esy-ocaml/reason@3.5.2@d41d8cd9"
],
"devDependencies": []
},
"@reason-native/pastel@0.2.3@d41d8cd9": {
"id": "@reason-native/pastel@0.2.3@d41d8cd9",
"name": "@reason-native/pastel",
"version": "0.2.3",
"source": {
"type": "install",
"source": [
"archive:https://registry.npmjs.org/@reason-native/pastel/-/pastel-0.2.3.tgz#sha1:5c5d420c09874584ce15a38695c5dfd0f0ff5dfa"
]
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/re@opam:1.9.0@d4d5e13d",
"@opam/dune@opam:2.1.2@94bd8c1b", "@esy-ocaml/reason@3.5.2@d41d8cd9"
],
"devDependencies": []
},
"@reason-native/console@0.1.0@d41d8cd9": {
"id": "@reason-native/console@0.1.0@d41d8cd9",
"name": "@reason-native/console",
"version": "0.1.0",
"source": {
"type": "install",
"source": [
"archive:https://registry.npmjs.org/@reason-native/console/-/console-0.1.0.tgz#sha1:3b56f0e9e1be8464329793df29020aa90e71c22c"
]
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:2.1.2@94bd8c1b",
"@esy-ocaml/reason@3.5.2@d41d8cd9"
],
"devDependencies": []
},
"@opam/yojson@opam:1.7.0@7056d985": {
"id": "@opam/yojson@opam:1.7.0@7056d985",
"name": "@opam/yojson",
"version": "opam:1.7.0",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/md5/b8/b89d39ca3f8c532abe5f547ad3b8f84d#md5:b89d39ca3f8c532abe5f547ad3b8f84d",
"archive:https://github.com/ocaml-community/yojson/releases/download/1.7.0/yojson-1.7.0.tbz#md5:b89d39ca3f8c532abe5f547ad3b8f84d"
],
"opam": {
"name": "yojson",
"version": "1.7.0",
"path": "esy.lock/opam/yojson.1.7.0"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@0484b3c4",
"@opam/dune@opam:2.1.2@94bd8c1b", "@opam/cppo@opam:1.6.6@f4f83858",
"@opam/biniou@opam:1.2.1@d7570399",
"@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@0484b3c4",
"@opam/dune@opam:2.1.2@94bd8c1b", "@opam/biniou@opam:1.2.1@d7570399"
]
},
"@opam/seq@opam:base@d8d7de1d": {
"id": "@opam/seq@opam:base@d8d7de1d",
"name": "@opam/seq",
"version": "opam:base",
"source": {
"type": "install",
"source": [ "no-source:" ],
"opam": {
"name": "seq",
"version": "base",
"path": "esy.lock/opam/seq.base"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [ "ocaml@4.8.1000@d41d8cd9" ]
},
"@opam/result@opam:1.4@dc720aef": {
"id": "@opam/result@opam:1.4@dc720aef",
"name": "@opam/result",
"version": "opam:1.4",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/md5/d3/d3162dbc501a2af65c8c71e0866541da#md5:d3162dbc501a2af65c8c71e0866541da",
"archive:https://github.com/janestreet/result/archive/1.4.tar.gz#md5:d3162dbc501a2af65c8c71e0866541da"
],
"opam": {
"name": "result",
"version": "1.4",
"path": "esy.lock/opam/result.1.4"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:2.1.2@94bd8c1b",
"@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:2.1.2@94bd8c1b"
]
},
"@opam/re@opam:1.9.0@d4d5e13d": {
"id": "@opam/re@opam:1.9.0@d4d5e13d",
"name": "@opam/re",
"version": "opam:1.9.0",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/md5/bd/bddaed4f386a22cace7850c9c7dac296#md5:bddaed4f386a22cace7850c9c7dac296",
"archive:https://github.com/ocaml/ocaml-re/releases/download/1.9.0/re-1.9.0.tbz#md5:bddaed4f386a22cace7850c9c7dac296"
],
"opam": {
"name": "re",
"version": "1.9.0",
"path": "esy.lock/opam/re.1.9.0"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/seq@opam:base@d8d7de1d",
"@opam/dune@opam:2.1.2@94bd8c1b", "@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/seq@opam:base@d8d7de1d",
"@opam/dune@opam:2.1.2@94bd8c1b"
]
},
"@opam/ppx_tools_versioned@opam:5.2.3@4994ec80": {
"id": "@opam/ppx_tools_versioned@opam:5.2.3@4994ec80",
"name": "@opam/ppx_tools_versioned",
"version": "opam:5.2.3",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/md5/b1/b1455e5a4a1bcd9ddbfcf712ccbd4262#md5:b1455e5a4a1bcd9ddbfcf712ccbd4262",
"archive:https://github.com/ocaml-ppx/ppx_tools_versioned/archive/5.2.3.tar.gz#md5:b1455e5a4a1bcd9ddbfcf712ccbd4262"
],
"opam": {
"name": "ppx_tools_versioned",
"version": "5.2.3",
"path": "esy.lock/opam/ppx_tools_versioned.5.2.3"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9",
"@opam/ocaml-migrate-parsetree@opam:1.5.0@3e319dbc",
"@opam/dune@opam:2.1.2@94bd8c1b", "@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9",
"@opam/ocaml-migrate-parsetree@opam:1.5.0@3e319dbc",
"@opam/dune@opam:2.1.2@94bd8c1b"
]
},
"@opam/ppx_derivers@opam:1.2.1@ecf0aa45": {
"id": "@opam/ppx_derivers@opam:1.2.1@ecf0aa45",
"name": "@opam/ppx_derivers",
"version": "opam:1.2.1",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/md5/5d/5dc2bf130c1db3c731fe0fffc5648b41#md5:5dc2bf130c1db3c731fe0fffc5648b41",
"archive:https://github.com/ocaml-ppx/ppx_derivers/archive/1.2.1.tar.gz#md5:5dc2bf130c1db3c731fe0fffc5648b41"
],
"opam": {
"name": "ppx_derivers",
"version": "1.2.1",
"path": "esy.lock/opam/ppx_derivers.1.2.1"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:2.1.2@94bd8c1b",
"@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:2.1.2@94bd8c1b"
]
},
"@opam/ocamlfind@opam:1.8.1@ff07b0f9": {
"id": "@opam/ocamlfind@opam:1.8.1@ff07b0f9",
"name": "@opam/ocamlfind",
"version": "opam:1.8.1",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/md5/18/18ca650982c15536616dea0e422cbd8c#md5:18ca650982c15536616dea0e422cbd8c",
"archive:http://download2.camlcity.org/download/findlib-1.8.1.tar.gz#md5:18ca650982c15536616dea0e422cbd8c",
"archive:http://download.camlcity.org/download/findlib-1.8.1.tar.gz#md5:18ca650982c15536616dea0e422cbd8c"
],
"opam": {
"name": "ocamlfind",
"version": "1.8.1",
"path": "esy.lock/opam/ocamlfind.1.8.1"
}
},
"overrides": [
{
"opamoverride":
"esy.lock/overrides/opam__s__ocamlfind_opam__c__1.8.1_opam_override"
}
],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/conf-m4@opam:1@3b2b148a",
"@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [ "ocaml@4.8.1000@d41d8cd9" ]
},
"@opam/ocamlbuild@opam:0.14.0@6ac75d03": {
"id": "@opam/ocamlbuild@opam:0.14.0@6ac75d03",
"name": "@opam/ocamlbuild",
"version": "opam:0.14.0",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/sha256/87/87b29ce96958096c0a1a8eeafeb6268077b2d11e1bf2b3de0f5ebc9cf8d42e78#sha256:87b29ce96958096c0a1a8eeafeb6268077b2d11e1bf2b3de0f5ebc9cf8d42e78",
"archive:https://github.com/ocaml/ocamlbuild/archive/0.14.0.tar.gz#sha256:87b29ce96958096c0a1a8eeafeb6268077b2d11e1bf2b3de0f5ebc9cf8d42e78"
],
"opam": {
"name": "ocamlbuild",
"version": "0.14.0",
"path": "esy.lock/opam/ocamlbuild.0.14.0"
}
},
"overrides": [
{
"opamoverride":
"esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override"
}
],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [ "ocaml@4.8.1000@d41d8cd9" ]
},
"@opam/ocaml-migrate-parsetree@opam:1.5.0@3e319dbc": {
"id": "@opam/ocaml-migrate-parsetree@opam:1.5.0@3e319dbc",
"name": "@opam/ocaml-migrate-parsetree",
"version": "opam:1.5.0",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/sha256/7f/7f56679c9561552762666de5b6b81c8e4cc2e9fd92272e2269878a2eb534e3c0#sha256:7f56679c9561552762666de5b6b81c8e4cc2e9fd92272e2269878a2eb534e3c0",
"archive:https://github.com/ocaml-ppx/ocaml-migrate-parsetree/releases/download/v1.5.0/ocaml-migrate-parsetree-v1.5.0.tbz#sha256:7f56679c9561552762666de5b6b81c8e4cc2e9fd92272e2269878a2eb534e3c0"
],
"opam": {
"name": "ocaml-migrate-parsetree",
"version": "1.5.0",
"path": "esy.lock/opam/ocaml-migrate-parsetree.1.5.0"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/result@opam:1.4@dc720aef",
"@opam/ppx_derivers@opam:1.2.1@ecf0aa45",
"@opam/dune@opam:2.1.2@94bd8c1b", "@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/result@opam:1.4@dc720aef",
"@opam/ppx_derivers@opam:1.2.1@ecf0aa45",
"@opam/dune@opam:2.1.2@94bd8c1b"
]
},
"@opam/merlin-extend@opam:0.5@a5dd7d4b": {
"id": "@opam/merlin-extend@opam:0.5@a5dd7d4b",
"name": "@opam/merlin-extend",
"version": "opam:0.5",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/sha256/ca/ca3a38c360c7d4827eb4789abf7a6aa4b6e3b4e3c3ef69a5be64dce4601ec227#sha256:ca3a38c360c7d4827eb4789abf7a6aa4b6e3b4e3c3ef69a5be64dce4601ec227",
"archive:https://github.com/let-def/merlin-extend/releases/download/v0.5/merlin-extend-v0.5.tbz#sha256:ca3a38c360c7d4827eb4789abf7a6aa4b6e3b4e3c3ef69a5be64dce4601ec227"
],
"opam": {
"name": "merlin-extend",
"version": "0.5",
"path": "esy.lock/opam/merlin-extend.0.5"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:2.1.2@94bd8c1b",
"@opam/cppo@opam:1.6.6@f4f83858", "@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:2.1.2@94bd8c1b"
]
},
"@opam/merlin@opam:3.3.3@d653b06a": {
"id": "@opam/merlin@opam:3.3.3@d653b06a",
"name": "@opam/merlin",
"version": "opam:3.3.3",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/sha256/72/72909ef47eea1f6fca13b4109a34dccf8fe3923a3c026f1ed1db9eb5ee9aae15#sha256:72909ef47eea1f6fca13b4109a34dccf8fe3923a3c026f1ed1db9eb5ee9aae15",
"archive:https://github.com/ocaml/merlin/releases/download/v3.3.3/merlin-v3.3.3.tbz#sha256:72909ef47eea1f6fca13b4109a34dccf8fe3923a3c026f1ed1db9eb5ee9aae15"
],
"opam": {
"name": "merlin",
"version": "3.3.3",
"path": "esy.lock/opam/merlin.3.3.3"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/yojson@opam:1.7.0@7056d985",
"@opam/ocamlfind@opam:1.8.1@ff07b0f9",
"@opam/dune@opam:2.1.2@94bd8c1b", "@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/yojson@opam:1.7.0@7056d985",
"@opam/ocamlfind@opam:1.8.1@ff07b0f9",
"@opam/dune@opam:2.1.2@94bd8c1b"
]
},
"@opam/menhir@opam:20190924@004407ff": {
"id": "@opam/menhir@opam:20190924@004407ff",
"name": "@opam/menhir",
"version": "opam:20190924",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/md5/67/677f1997fb73177d5a00fa1b8d61c3ef#md5:677f1997fb73177d5a00fa1b8d61c3ef",
"archive:https://gitlab.inria.fr/fpottier/menhir/repository/20190924/archive.tar.gz#md5:677f1997fb73177d5a00fa1b8d61c3ef"
],
"opam": {
"name": "menhir",
"version": "20190924",
"path": "esy.lock/opam/menhir.20190924"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/ocamlfind@opam:1.8.1@ff07b0f9",
"@opam/ocamlbuild@opam:0.14.0@6ac75d03",
"@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [ "ocaml@4.8.1000@d41d8cd9" ]
},
"@opam/jbuilder@opam:1.0+beta20.2@053ddcf2": {
"id": "@opam/jbuilder@opam:1.0+beta20.2@053ddcf2",
"name": "@opam/jbuilder",
"version": "opam:1.0+beta20.2",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/md5/fb/fbe8c3b1facb206cac3fb8932b5dd5d9#md5:fbe8c3b1facb206cac3fb8932b5dd5d9",
"archive:https://github.com/ocaml/dune/releases/download/1.0%2Bbeta20.2/jbuilder-1.0+beta20.2.tbz#md5:fbe8c3b1facb206cac3fb8932b5dd5d9"
],
"opam": {
"name": "jbuilder",
"version": "1.0+beta20.2",
"path": "esy.lock/opam/jbuilder.1.0+beta20.2"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [ "ocaml@4.8.1000@d41d8cd9" ]
},
"@opam/easy-format@opam:1.3.2@0484b3c4": {
"id": "@opam/easy-format@opam:1.3.2@0484b3c4",
"name": "@opam/easy-format",
"version": "opam:1.3.2",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/sha256/34/3440c2b882d537ae5e9011eb06abb53f5667e651ea4bb3b460ea8230fa8c1926#sha256:3440c2b882d537ae5e9011eb06abb53f5667e651ea4bb3b460ea8230fa8c1926",
"archive:https://github.com/mjambon/easy-format/releases/download/1.3.2/easy-format-1.3.2.tbz#sha256:3440c2b882d537ae5e9011eb06abb53f5667e651ea4bb3b460ea8230fa8c1926"
],
"opam": {
"name": "easy-format",
"version": "1.3.2",
"path": "esy.lock/opam/easy-format.1.3.2"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:2.1.2@94bd8c1b",
"@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:2.1.2@94bd8c1b"
]
},
"@opam/dune@opam:2.1.2@94bd8c1b": {
"id": "@opam/dune@opam:2.1.2@94bd8c1b",
"name": "@opam/dune",
"version": "opam:2.1.2",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/sha256/9c/9c3278ebb3ec14dc4b1880671371985edcd6cbb979260dd403f28acabbcc5faf#sha256:9c3278ebb3ec14dc4b1880671371985edcd6cbb979260dd403f28acabbcc5faf",
"archive:https://github.com/ocaml/dune/releases/download/2.1.2/dune-2.1.2.tbz#sha256:9c3278ebb3ec14dc4b1880671371985edcd6cbb979260dd403f28acabbcc5faf"
],
"opam": {
"name": "dune",
"version": "2.1.2",
"path": "esy.lock/opam/dune.2.1.2"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/base-unix@opam:base@87d0b2eb",
"@opam/base-threads@opam:base@36803084",
"@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/base-unix@opam:base@87d0b2eb",
"@opam/base-threads@opam:base@36803084"
]
},
"@opam/cppo@opam:1.6.6@f4f83858": {
"id": "@opam/cppo@opam:1.6.6@f4f83858",
"name": "@opam/cppo",
"version": "opam:1.6.6",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/sha256/e7/e7272996a7789175b87bb998efd079794a8db6625aae990d73f7b4484a07b8a0#sha256:e7272996a7789175b87bb998efd079794a8db6625aae990d73f7b4484a07b8a0",
"archive:https://github.com/ocaml-community/cppo/releases/download/v1.6.6/cppo-v1.6.6.tbz#sha256:e7272996a7789175b87bb998efd079794a8db6625aae990d73f7b4484a07b8a0"
],
"opam": {
"name": "cppo",
"version": "1.6.6",
"path": "esy.lock/opam/cppo.1.6.6"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:2.1.2@94bd8c1b",
"@opam/base-unix@opam:base@87d0b2eb",
"@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/dune@opam:2.1.2@94bd8c1b",
"@opam/base-unix@opam:base@87d0b2eb"
]
},
"@opam/conf-m4@opam:1@3b2b148a": {
"id": "@opam/conf-m4@opam:1@3b2b148a",
"name": "@opam/conf-m4",
"version": "opam:1",
"source": {
"type": "install",
"source": [ "no-source:" ],
"opam": {
"name": "conf-m4",
"version": "1",
"path": "esy.lock/opam/conf-m4.1"
}
},
"overrides": [],
"dependencies": [ "@esy-ocaml/substs@0.0.1@d41d8cd9" ],
"devDependencies": []
},
"@opam/biniou@opam:1.2.1@d7570399": {
"id": "@opam/biniou@opam:1.2.1@d7570399",
"name": "@opam/biniou",
"version": "opam:1.2.1",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/sha256/35/35546c68b1929a8e6d27a3b39ecd17b38303a0d47e65eb9d1480c2061ea84335#sha256:35546c68b1929a8e6d27a3b39ecd17b38303a0d47e65eb9d1480c2061ea84335",
"archive:https://github.com/mjambon/biniou/releases/download/1.2.1/biniou-1.2.1.tbz#sha256:35546c68b1929a8e6d27a3b39ecd17b38303a0d47e65eb9d1480c2061ea84335"
],
"opam": {
"name": "biniou",
"version": "1.2.1",
"path": "esy.lock/opam/biniou.1.2.1"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@0484b3c4",
"@opam/dune@opam:2.1.2@94bd8c1b", "@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/easy-format@opam:1.3.2@0484b3c4",
"@opam/dune@opam:2.1.2@94bd8c1b"
]
},
"@opam/base-unix@opam:base@87d0b2eb": {
"id": "@opam/base-unix@opam:base@87d0b2eb",
"name": "@opam/base-unix",
"version": "opam:base",
"source": {
"type": "install",
"source": [ "no-source:" ],
"opam": {
"name": "base-unix",
"version": "base",
"path": "esy.lock/opam/base-unix.base"
}
},
"overrides": [],
"dependencies": [ "@esy-ocaml/substs@0.0.1@d41d8cd9" ],
"devDependencies": []
},
"@opam/base-threads@opam:base@36803084": {
"id": "@opam/base-threads@opam:base@36803084",
"name": "@opam/base-threads",
"version": "opam:base",
"source": {
"type": "install",
"source": [ "no-source:" ],
"opam": {
"name": "base-threads",
"version": "base",
"path": "esy.lock/opam/base-threads.base"
}
},
"overrides": [],
"dependencies": [ "@esy-ocaml/substs@0.0.1@d41d8cd9" ],
"devDependencies": []
},
"@opam/atdgen-runtime@opam:2.0.0@60f6faab": {
"id": "@opam/atdgen-runtime@opam:2.0.0@60f6faab",
"name": "@opam/atdgen-runtime",
"version": "opam:2.0.0",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/md5/14/14e47609397c524ea0eae7c3f14f7ccf#md5:14e47609397c524ea0eae7c3f14f7ccf",
"archive:https://github.com/mjambon/atd/releases/download/2.0.0/atd-2.0.0.tbz#md5:14e47609397c524ea0eae7c3f14f7ccf"
],
"opam": {
"name": "atdgen-runtime",
"version": "2.0.0",
"path": "esy.lock/opam/atdgen-runtime.2.0.0"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/yojson@opam:1.7.0@7056d985",
"@opam/jbuilder@opam:1.0+beta20.2@053ddcf2",
"@opam/biniou@opam:1.2.1@d7570399",
"@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/yojson@opam:1.7.0@7056d985",
"@opam/jbuilder@opam:1.0+beta20.2@053ddcf2",
"@opam/biniou@opam:1.2.1@d7570399"
]
},
"@opam/atdgen@opam:2.0.0@46af0360": {
"id": "@opam/atdgen@opam:2.0.0@46af0360",
"name": "@opam/atdgen",
"version": "opam:2.0.0",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/md5/14/14e47609397c524ea0eae7c3f14f7ccf#md5:14e47609397c524ea0eae7c3f14f7ccf",
"archive:https://github.com/mjambon/atd/releases/download/2.0.0/atd-2.0.0.tbz#md5:14e47609397c524ea0eae7c3f14f7ccf"
],
"opam": {
"name": "atdgen",
"version": "2.0.0",
"path": "esy.lock/opam/atdgen.2.0.0"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/yojson@opam:1.7.0@7056d985",
"@opam/jbuilder@opam:1.0+beta20.2@053ddcf2",
"@opam/biniou@opam:1.2.1@d7570399",
"@opam/atdgen-runtime@opam:2.0.0@60f6faab",
"@opam/atd@opam:2.0.0@e0ddd12f", "@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/yojson@opam:1.7.0@7056d985",
"@opam/jbuilder@opam:1.0+beta20.2@053ddcf2",
"@opam/biniou@opam:1.2.1@d7570399",
"@opam/atdgen-runtime@opam:2.0.0@60f6faab",
"@opam/atd@opam:2.0.0@e0ddd12f"
]
},
"@opam/atd@opam:2.0.0@e0ddd12f": {
"id": "@opam/atd@opam:2.0.0@e0ddd12f",
"name": "@opam/atd",
"version": "opam:2.0.0",
"source": {
"type": "install",
"source": [
"archive:https://opam.ocaml.org/cache/md5/14/14e47609397c524ea0eae7c3f14f7ccf#md5:14e47609397c524ea0eae7c3f14f7ccf",
"archive:https://github.com/mjambon/atd/releases/download/2.0.0/atd-2.0.0.tbz#md5:14e47609397c524ea0eae7c3f14f7ccf"
],
"opam": {
"name": "atd",
"version": "2.0.0",
"path": "esy.lock/opam/atd.2.0.0"
}
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/menhir@opam:20190924@004407ff",
"@opam/jbuilder@opam:1.0+beta20.2@053ddcf2",
"@opam/easy-format@opam:1.3.2@0484b3c4",
"@esy-ocaml/substs@0.0.1@d41d8cd9"
],
"devDependencies": [
"ocaml@4.8.1000@d41d8cd9",
"@opam/jbuilder@opam:1.0+beta20.2@053ddcf2",
"@opam/easy-format@opam:1.3.2@0484b3c4"
]
},
"@esy-ocaml/substs@0.0.1@d41d8cd9": {
"id": "@esy-ocaml/substs@0.0.1@d41d8cd9",
"name": "@esy-ocaml/substs",
"version": "0.0.1",
"source": {
"type": "install",
"source": [
"archive:https://registry.npmjs.org/@esy-ocaml/substs/-/substs-0.0.1.tgz#sha1:59ebdbbaedcda123fc7ed8fb2b302b7d819e9a46"
]
},
"overrides": [],
"dependencies": [],
"devDependencies": []
},
"@esy-ocaml/reason@3.5.2@d41d8cd9": {
"id": "@esy-ocaml/reason@3.5.2@d41d8cd9",
"name": "@esy-ocaml/reason",
"version": "3.5.2",
"source": {
"type": "install",
"source": [
"archive:https://registry.npmjs.org/@esy-ocaml/reason/-/reason-3.5.2.tgz#sha1:ac48b63fd66fbbc1d77ab6a2b7e3a1ba21a8f40b"
]
},
"overrides": [],
"dependencies": [
"ocaml@4.8.1000@d41d8cd9", "@opam/result@opam:1.4@dc720aef",
"@opam/ocamlfind@opam:1.8.1@ff07b0f9",
"@opam/ocaml-migrate-parsetree@opam:1.5.0@3e319dbc",
"@opam/merlin-extend@opam:0.5@a5dd7d4b",
"@opam/menhir@opam:20190924@004407ff",
"@opam/dune@opam:2.1.2@94bd8c1b"
],
"devDependencies": []
}
}
}

View File

@@ -0,0 +1,3 @@
// @flow
declare export * from "./dist/types/src/Wonka.js.flow"

149
smart-app-city/frontend/node_modules/wonka/package.json generated vendored Normal file
View File

@@ -0,0 +1,149 @@
{
"name": "wonka",
"description": "A fast push & pull stream library for Reason/OCaml, Flow, and TypeScript",
"version": "4.0.15",
"author": "Phil Pluckthun <phil@kitten.sh>",
"source": "./src/Wonka.ts",
"main": "./dist/wonka",
"module": "./dist/wonka.mjs",
"types": "./dist/types/src/Wonka.d.ts",
"exports": {
".": {
"import": "./dist/wonka.mjs",
"require": "./dist/wonka.js",
"types": "./dist/types/src/Wonka.d.ts",
"source": "./src/Wonka.ts"
},
"./package.json": "./package.json",
"./": "./"
},
"sideEffects": false,
"files": [
"src",
"dist",
"docs/*.md",
"*.md",
"index.js.flow",
"dune-project",
"wonka.opam",
"esy.json",
"bsconfig.json"
],
"scripts": {
"docs:dev": "gatsby develop",
"docs:build": "gatsby build",
"check:ts": "tsc --noEmit",
"check:flow": "flow focus-check ./src/helpers/Wonka_flow_test.js",
"check": "run-s check:ts check:flow",
"bs:clean": "bsb -clean-world",
"bs:build": "bsb -make-world",
"bs:watch": "bsb -make-world -w",
"test": "jest",
"refmt": "bsrefmt --in-place **/**/*.{re,rei}",
"flowgen": "./scripts/generate-flow-files.js",
"bundle:clean": "rimraf dist node_modules/.cache",
"bundle": "rollup -c rollup.config.js",
"clean": "run-s bs:clean bundle:clean",
"build": "run-s bs:build bundle flowgen",
"prepublishOnly": "run-s clean build check test"
},
"keywords": [
"wonka",
"reason",
"bucklescript",
"callbag",
"callback",
"observable",
"iterable",
"stream"
],
"repository": "https://github.com/kitten/wonka",
"homepage": "https://wonka.kitten.sh",
"bugs": {
"url": "https://github.com/kitten/wonka/issues"
},
"license": "MIT",
"dependencies": {},
"devDependencies": {
"@ampproject/rollup-plugin-closure-compiler": "^0.25.2",
"@babel/core": "^7.10.2",
"@babel/plugin-syntax-typescript": "^7.10.1",
"@babel/plugin-transform-modules-commonjs": "^7.10.1",
"@babel/preset-env": "^7.10.2",
"@glennsl/bs-jest": "^0.5.1",
"@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-commonjs": "^12.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@types/jest": "^25.2.3",
"@types/zen-observable": "^0.8.0",
"babel-plugin-closure-elimination": "^1.3.1",
"bs-platform": "^7.3.2",
"callbag-from-iter": "^1.2.0",
"callbag-iterate": "^1.0.0",
"callbag-take": "^1.5.0",
"coveralls": "^3.1.0",
"flow-bin": "^0.125.1",
"flowgen": "^1.10.0",
"gatsby": "^2.18.17",
"gatsby-plugin-netlify": "^2.1.30",
"gatsby-theme-docs-system": "^0.2.2",
"gentype": "^3.23.0",
"globby": "^11.0.0",
"husky": "^4.2.5",
"lint-staged": "^10.2.7",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.5",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"rimraf": "^3.0.2",
"rollup": "^2.12.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-prettier": "^2.1.0",
"rollup-plugin-terser": "^6.1.0",
"rollup-plugin-typescript2": "^0.27.1",
"ts-jest": "^26.1.0",
"typescript": "^3.9.2",
"zen-observable": "^0.8.15"
},
"lint-staged": {
"*.{d.ts,js}": [
"prettier --write"
],
"*.{re,rei}": [
"bsrefmt --in-place"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"prettier": {
"singleQuote": true,
"printWidth": 100
},
"jest": {
"testEnvironment": "node",
"testRegex": "(src/.*(\\.|/)(test|spec))\\.(t|j)sx?$",
"moduleFileExtensions": [
"js",
"ts",
"tsx"
],
"transform": {
"\\.jsx?$": "<rootDir>/scripts/jest-transform-esm.js",
"\\.tsx?$": "ts-jest"
},
"transformIgnorePatterns": [
"/node_modules/(?!bs-platform)"
],
"collectCoverageFrom": [
"!<rootDir>/src/wonka.{ts,bs.js}",
"!<rootDir>/src/wonka_types.{ts,bs.js}",
"!<rootDir>/src/include/**",
"!<rootDir>/src/helpers/**",
"!<rootDir>/src/**/*.{shim,gen}.{ts,tsx}",
"<rootDir>/src/**/*.{js,ts,tsx}"
]
}
}

View File

@@ -0,0 +1,161 @@
import * as WonkaJs from "./web/WonkaJs.bs.js";
import * as Wonka_sinks from "./Wonka_sinks.bs.js";
import * as Wonka_sources from "./Wonka_sources.bs.js";
import * as Wonka_operators from "./Wonka_operators.bs.js";
var Types;
var fromArray = Wonka_sources.fromArray;
var fromList = Wonka_sources.fromList;
var fromValue = Wonka_sources.fromValue;
var make = Wonka_sources.make;
var makeSubject = Wonka_sources.makeSubject;
var empty = Wonka_sources.empty;
var never = Wonka_sources.never;
var buffer = Wonka_operators.buffer;
var combine = Wonka_operators.combine;
var concatMap = Wonka_operators.concatMap;
var concatAll = Wonka_operators.concatAll;
var concat = Wonka_operators.concat;
var filter = Wonka_operators.filter;
var map = Wonka_operators.map;
var mergeMap = Wonka_operators.mergeMap;
var merge = Wonka_operators.merge;
var mergeAll = Wonka_operators.mergeAll;
var flatten = Wonka_operators.flatten;
var onEnd = Wonka_operators.onEnd;
var onPush = Wonka_operators.onPush;
var tap = Wonka_operators.tap;
var onStart = Wonka_operators.onStart;
var sample = Wonka_operators.sample;
var scan = Wonka_operators.scan;
var share = Wonka_operators.share;
var skip = Wonka_operators.skip;
var skipUntil = Wonka_operators.skipUntil;
var skipWhile = Wonka_operators.skipWhile;
var switchMap = Wonka_operators.switchMap;
var switchAll = Wonka_operators.switchAll;
var take = Wonka_operators.take;
var takeLast = Wonka_operators.takeLast;
var takeUntil = Wonka_operators.takeUntil;
var takeWhile = Wonka_operators.takeWhile;
var subscribe = Wonka_sinks.subscribe;
var forEach = Wonka_sinks.forEach;
var publish = Wonka_sinks.publish;
var toArray = Wonka_sinks.toArray;
var fromObservable = WonkaJs.fromObservable;
var toObservable = WonkaJs.toObservable;
var fromCallbag = WonkaJs.fromCallbag;
var toCallbag = WonkaJs.toCallbag;
var debounce = WonkaJs.debounce;
var delay = WonkaJs.delay;
var throttle = WonkaJs.throttle;
var toPromise = WonkaJs.toPromise;
var interval = WonkaJs.interval;
var fromDomEvent = WonkaJs.fromDomEvent;
var fromPromise = WonkaJs.fromPromise;
export {
Types ,
fromArray ,
fromList ,
fromValue ,
make ,
makeSubject ,
empty ,
never ,
buffer ,
combine ,
concatMap ,
concatAll ,
concat ,
filter ,
map ,
mergeMap ,
merge ,
mergeAll ,
flatten ,
onEnd ,
onPush ,
tap ,
onStart ,
sample ,
scan ,
share ,
skip ,
skipUntil ,
skipWhile ,
switchMap ,
switchAll ,
take ,
takeLast ,
takeUntil ,
takeWhile ,
subscribe ,
forEach ,
publish ,
toArray ,
fromObservable ,
toObservable ,
fromCallbag ,
toCallbag ,
debounce ,
delay ,
throttle ,
toPromise ,
interval ,
fromDomEvent ,
fromPromise ,
}
/* WonkaJs Not a pure module */

View File

@@ -0,0 +1,13 @@
module Types = Wonka_types
include Wonka_sources
include Wonka_operators
include Wonka_sinks
#if BS_NATIVE then
#if BSB_BACKEND = "js" then
include WonkaJs
#end
#else
include WonkaJs
#end

View File

@@ -0,0 +1,15 @@
export * from './helpers/pipe';
export * from './Wonka_sources.gen';
export * from './Wonka_operators.gen';
export * from './Wonka_sinks.gen';
export * from './web/WonkaJs.gen';
export {
sinkT as Sink,
sourceT as Source,
operatorT as Operator,
subscriptionT as Subscription,
observerT as Observer,
subjectT as Subject
} from './Wonka_types.gen';

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,73 @@
/* TypeScript file generated from Wonka_operators.re by genType. */
/* eslint-disable import/first */
// tslint:disable-next-line:no-var-requires
const Curry = require('bs-platform/lib/es6/curry.js');
// tslint:disable-next-line:no-var-requires
const Wonka_operatorsBS = require('./Wonka_operators.bs');
import {operatorT as Wonka_types_operatorT} from './Wonka_types.gen';
import {sourceT as Wonka_types_sourceT} from './Wonka_types.gen';
export const buffer: <a,b>(notifier:Wonka_types_sourceT<a>) => Wonka_types_operatorT<b,b[]> = Wonka_operatorsBS.buffer;
export const combine: <a,b>(sourceA:Wonka_types_sourceT<a>, sourceB:Wonka_types_sourceT<b>) => Wonka_types_sourceT<[a, b]> = function <a,b>(Arg1: any, Arg2: any) {
const result = Curry._2(Wonka_operatorsBS.combine, Arg1, Arg2);
return result
};
export const concatMap: <a,b>(f:((_1:a) => Wonka_types_sourceT<b>)) => Wonka_types_operatorT<a,b> = Wonka_operatorsBS.concatMap;
export const concatAll: <a>(source:Wonka_types_sourceT<Wonka_types_sourceT<a>>) => Wonka_types_sourceT<a> = Wonka_operatorsBS.concatAll;
export const concat: <a>(sources:Wonka_types_sourceT<a>[]) => Wonka_types_sourceT<a> = Wonka_operatorsBS.concat;
export const filter: <a>(f:((_1:a) => boolean)) => Wonka_types_operatorT<a,a> = Wonka_operatorsBS.filter;
export const map: <a,b>(f:((_1:a) => b)) => Wonka_types_operatorT<a,b> = Wonka_operatorsBS.map;
export const mergeMap: <a,b>(f:((_1:a) => Wonka_types_sourceT<b>)) => Wonka_types_operatorT<a,b> = Wonka_operatorsBS.mergeMap;
export const merge: <a>(sources:Wonka_types_sourceT<a>[]) => Wonka_types_sourceT<a> = Wonka_operatorsBS.merge;
export const mergeAll: <a>(source:Wonka_types_sourceT<Wonka_types_sourceT<a>>) => Wonka_types_sourceT<a> = Wonka_operatorsBS.mergeAll;
export const flatten: <T1>(_1:Wonka_types_sourceT<Wonka_types_sourceT<T1>>) => Wonka_types_sourceT<T1> = Wonka_operatorsBS.flatten;
export const onEnd: <a>(f:(() => void)) => Wonka_types_operatorT<a,a> = Wonka_operatorsBS.onEnd;
export const onPush: <a>(f:((_1:a) => void)) => Wonka_types_operatorT<a,a> = Wonka_operatorsBS.onPush;
export const tap: <T1>(_1:((_1:T1) => void)) => Wonka_types_operatorT<T1,T1> = Wonka_operatorsBS.tap;
export const onStart: <a>(f:(() => void)) => Wonka_types_operatorT<a,a> = Wonka_operatorsBS.onStart;
export const sample: <a,b>(notifier:Wonka_types_sourceT<a>) => Wonka_types_operatorT<b,b> = Wonka_operatorsBS.sample;
export const scan: <a,acc>(f:((_1:acc, _2:a) => acc), seed:acc) => Wonka_types_operatorT<a,acc> = function <a,acc>(Arg1: any, Arg2: any) {
const result = Curry._2(Wonka_operatorsBS.scan, Arg1, Arg2);
return result
};
export const share: <a>(source:Wonka_types_sourceT<a>) => Wonka_types_sourceT<a> = Wonka_operatorsBS.share;
export const skip: <a>(wait:number) => Wonka_types_operatorT<a,a> = Wonka_operatorsBS.skip;
export const skipUntil: <a,b>(notifier:Wonka_types_sourceT<a>) => Wonka_types_operatorT<b,b> = Wonka_operatorsBS.skipUntil;
export const skipWhile: <a>(f:((_1:a) => boolean)) => Wonka_types_operatorT<a,a> = Wonka_operatorsBS.skipWhile;
export const switchMap: <a,b>(f:((_1:a) => Wonka_types_sourceT<b>)) => Wonka_types_operatorT<a,b> = Wonka_operatorsBS.switchMap;
export const switchAll: <a>(source:Wonka_types_sourceT<Wonka_types_sourceT<a>>) => Wonka_types_sourceT<a> = Wonka_operatorsBS.switchAll;
export const take: <a>(max:number) => Wonka_types_operatorT<a,a> = Wonka_operatorsBS.take;
export const takeLast: <a>(max:number) => Wonka_types_operatorT<a,a> = Wonka_operatorsBS.takeLast;
export const takeUntil: <a,b>(notifier:Wonka_types_sourceT<a>) => Wonka_types_operatorT<b,b> = Wonka_operatorsBS.takeUntil;
export const takeWhile: <a>(f:((_1:a) => boolean)) => Wonka_types_operatorT<a,a> = Wonka_operatorsBS.takeWhile;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,87 @@
import * as Curry from "bs-platform/lib/es6/curry.js";
import * as Wonka_helpers from "./helpers/Wonka_helpers.bs.js";
function subscribe(f) {
return (function (source) {
var state = {
talkback: Wonka_helpers.talkbackPlaceholder,
ended: false
};
Curry._1(source, (function (signal) {
if (typeof signal === "number") {
state.ended = true;
return ;
}
if (signal.tag) {
if (!state.ended) {
f(signal[0]);
return state.talkback(/* Pull */0);
} else {
return ;
}
}
var x = signal[0];
state.talkback = x;
return x(/* Pull */0);
}));
return {
unsubscribe: (function (param) {
if (!state.ended) {
state.ended = true;
return state.talkback(/* Close */1);
}
})
};
});
}
function forEach(f) {
return (function (source) {
subscribe(f)(source);
});
}
function publish(source) {
return subscribe((function (param) {
}))(source);
}
function toArray(source) {
var state = {
values: new Array(),
talkback: Wonka_helpers.talkbackPlaceholder,
value: undefined,
ended: false
};
Curry._1(source, (function (signal) {
if (typeof signal === "number") {
state.ended = true;
return ;
}
if (signal.tag) {
state.values.push(signal[0]);
return state.talkback(/* Pull */0);
}
var x = signal[0];
state.talkback = x;
return x(/* Pull */0);
}));
if (!state.ended) {
state.talkback(/* Close */1);
}
return state.values;
}
export {
subscribe ,
forEach ,
publish ,
toArray ,
}
/* No side effect */

View File

@@ -0,0 +1,24 @@
/* TypeScript file generated from Wonka_sinks.re by genType. */
/* eslint-disable import/first */
// tslint:disable-next-line:no-var-requires
const Wonka_sinksBS = require('./Wonka_sinks.bs');
import {sourceT as Wonka_types_sourceT} from './Wonka_types.gen';
import {subscriptionT as Wonka_types_subscriptionT} from './Wonka_types.gen';
// tslint:disable-next-line:interface-over-type-literal
export type subscribeConsumerT<a> = (_1:Wonka_types_sourceT<a>) => Wonka_types_subscriptionT;
// tslint:disable-next-line:interface-over-type-literal
export type forEachConsumerT<a> = (_1:Wonka_types_sourceT<a>) => void;
export const subscribe: <a>(f:((_1:a) => void)) => subscribeConsumerT<a> = Wonka_sinksBS.subscribe;
export const forEach: <a>(f:((_1:a) => void)) => forEachConsumerT<a> = Wonka_sinksBS.forEach;
export const publish: <a>(source:Wonka_types_sourceT<a>) => Wonka_types_subscriptionT = Wonka_sinksBS.publish;
export const toArray: <a>(source:Wonka_types_sourceT<a>) => a[] = Wonka_sinksBS.toArray;

View File

@@ -0,0 +1,86 @@
open Wonka_types;
open Wonka_helpers;
type subscribeStateT = {
mutable talkback: (. talkbackT) => unit,
mutable ended: bool,
};
[@genType]
type subscribeConsumerT('a) = sourceT('a) => subscriptionT;
[@genType]
let subscribe = (f: (. 'a) => unit): subscribeConsumerT('a) =>
curry(source => {
let state: subscribeStateT = {
talkback: talkbackPlaceholder,
ended: false,
};
source((. signal) =>
switch (signal) {
| Start(x) =>
state.talkback = x;
x(. Pull);
| Push(x) when !state.ended =>
f(. x);
state.talkback(. Pull);
| Push(_) => ()
| End => state.ended = true
}
);
{
unsubscribe: () =>
if (!state.ended) {
state.ended = true;
state.talkback(. Close);
},
};
});
[@genType]
type forEachConsumerT('a) = sourceT('a) => unit;
[@genType]
let forEach = (f: (. 'a) => unit): forEachConsumerT('a) =>
curry(source => ignore(subscribe(f, source)));
[@genType]
let publish = (source: sourceT('a)): subscriptionT =>
subscribe((. _) => (), source);
type toArrayStateT('a) = {
values: Rebel.MutableQueue.t('a),
mutable talkback: (. talkbackT) => unit,
mutable value: option('a),
mutable ended: bool,
};
[@genType]
let toArray = (source: sourceT('a)): array('a) => {
let state: toArrayStateT('a) = {
values: Rebel.MutableQueue.make(),
talkback: talkbackPlaceholder,
value: None,
ended: false,
};
source((. signal) =>
switch (signal) {
| Start(x) =>
state.talkback = x;
x(. Pull);
| Push(value) =>
Rebel.MutableQueue.add(state.values, value);
state.talkback(. Pull);
| End => state.ended = true
}
);
if (!state.ended) {
state.talkback(. Close);
};
Rebel.MutableQueue.toArray(state.values);
};

View File

@@ -0,0 +1,297 @@
import * as deriving from './helpers/Wonka_deriving';
import * as sinks from './Wonka_sinks.gen';
import * as sources from './Wonka_sources.gen';
import * as web from './web/WonkaJs.gen';
import * as types from './Wonka_types.gen';
import Observable from 'zen-observable';
import callbagIterate from 'callbag-iterate';
import callbagTake from 'callbag-take';
describe('subscribe', () => {
it('sends Pull talkback signals every Push signal', () => {
let pulls = 0;
const fn = jest.fn();
const source: types.sourceT<any> = sink => {
sink(deriving.start(tb => {
if (tb === deriving.pull) {
if (pulls < 3) {
pulls++;
sink(deriving.push(0));
} else {
sink(deriving.end());
expect(pulls).toBe(3);
}
}
}));
};
sinks.subscribe(fn)(source);
expect(fn).toHaveBeenCalledTimes(3);
expect(pulls).toBe(3);
});
it('cancels when unsubscribe is called', () => {
let pulls = 0;
let closing = 0;
const source: types.sourceT<any> = sink => {
sink(deriving.start(tb => {
if (tb === deriving.pull) {
if (!pulls) {
pulls++;
sink(deriving.push(0));
}
} else if (tb === deriving.close) {
closing++;
}
}));
};
const sub = sinks.subscribe(() => {})(source);
expect(pulls).toBe(1);
sub.unsubscribe();
expect(closing).toBe(1);
});
it('ignores cancellation when the source has already ended', () => {
let pulls = 0;
let closing = 0;
const source: types.sourceT<any> = sink => {
sink(deriving.start(tb => {
if (tb === deriving.pull) {
pulls++;
sink(deriving.end());
} else if (tb === deriving.close) {
closing++;
}
}));
};
const sub = sinks.subscribe(() => {})(source);
expect(pulls).toBe(1);
sub.unsubscribe();
expect(closing).toBe(0);
});
it('ignores Push signals after the source has ended', () => {
const fn = jest.fn();
const source: types.sourceT<any> = sink => {
sink(deriving.start(tb => {
if (tb === deriving.pull) {
sink(deriving.end());
sink(deriving.push(0));
}
}));
};
sinks.subscribe(fn)(source);
expect(fn).not.toHaveBeenCalled();
});
it('ignores Push signals after cancellation', () => {
const fn = jest.fn();
const source: types.sourceT<any> = sink => {
sink(deriving.start(tb => {
if (tb === deriving.close) {
sink(deriving.push(0));
}
}));
};
sinks.subscribe(fn)(source).unsubscribe();
expect(fn).not.toHaveBeenCalled();
});
});
describe('publish', () => {
it('sends Pull talkback signals every Push signal', () => {
let pulls = 0;
const source: types.sourceT<any> = sink => {
sink(deriving.start(tb => {
if (tb === deriving.pull) {
if (pulls < 3) {
pulls++;
sink(deriving.push(0));
} else {
sink(deriving.end());
expect(pulls).toBe(3);
}
}
}));
};
sinks.publish(source);
expect(pulls).toBe(3);
});
});
describe('toArray', () => {
it('sends Pull talkback signals every Push signal', () => {
let pulls = 0;
const source: types.sourceT<any> = sink => {
sink(deriving.start(tb => {
if (tb === deriving.pull) {
if (pulls < 3) {
pulls++;
sink(deriving.push(0));
} else {
sink(deriving.end());
expect(pulls).toBe(3);
}
}
}));
};
const array = sinks.toArray(source);
expect(array).toEqual([0, 0, 0]);
expect(pulls).toBe(3);
});
it('sends a Close talkback signal after all synchronous values have been pulled', () => {
let pulls = 0;
let ending = 0;
const source: types.sourceT<any> = sink => {
sink(deriving.start(tb => {
if (tb === deriving.pull) {
if (!pulls) {
pulls++;
sink(deriving.push(0));
}
} else if (tb === deriving.close) {
ending++;
}
}));
};
const array = sinks.toArray(source);
expect(array).toEqual([0]);
expect(ending).toBe(1);
});
});
describe('toPromise', () => {
it('creates a Promise that resolves on the last value', async () => {
let pulls = 0;
let sink = null;
const source: types.sourceT<any> = _sink => {
sink = _sink;
sink(deriving.start(tb => {
if (tb === deriving.pull)
pulls++;
}));
};
const fn = jest.fn();
const promise = web.toPromise(source).then(fn);
expect(pulls).toBe(1);
sink(deriving.push(0));
expect(pulls).toBe(2);
sink(deriving.push(1));
sink(deriving.end());
expect(fn).not.toHaveBeenCalled();
await promise;
expect(fn).toHaveBeenCalledWith(1);
});
it('creates a Promise for synchronous sources', async () => {
const fn = jest.fn();
await web.toPromise(sources.fromArray([1, 2, 3])).then(fn);
expect(fn).toHaveBeenCalledWith(3);
});
});
describe('toObservable', () => {
it('creates an Observable mirroring the Wonka source', () => {
const next = jest.fn();
const complete = jest.fn();
let pulls = 0;
let sink = null;
const source: types.sourceT<any> = _sink => {
sink = _sink;
sink(deriving.start(tb => {
if (tb === deriving.pull)
pulls++;
}));
};
Observable.from(web.toObservable(source) as any).subscribe({
next,
complete,
});
expect(pulls).toBe(1);
sink(deriving.push(0));
expect(next).toHaveBeenCalledWith(0);
sink(deriving.push(1));
expect(next).toHaveBeenCalledWith(1);
sink(deriving.end());
expect(complete).toHaveBeenCalled();
});
it('forwards cancellations from the Observable as a talkback', () => {
let ending = 0;
const source: types.sourceT<any> = sink =>
sink(deriving.start(tb => {
if (tb === deriving.close)
ending++;
}));
const sub = Observable.from(web.toObservable(source) as any).subscribe({});
expect(ending).toBe(0);
sub.unsubscribe();
expect(ending).toBe(1);
});
});
describe('toCallbag', () => {
it('creates a Callbag mirroring the Wonka source', () => {
const fn = jest.fn();
let pulls = 0;
let sink = null;
const source: types.sourceT<any> = _sink => {
sink = _sink;
sink(deriving.start(tb => {
if (tb === deriving.pull)
pulls++;
}));
};
callbagIterate(fn)(web.toCallbag(source));
expect(pulls).toBe(1);
sink(deriving.push(0));
expect(fn).toHaveBeenCalledWith(0);
sink(deriving.push(1));
expect(fn).toHaveBeenCalledWith(1);
sink(deriving.end());
});
it('forwards cancellations from the Callbag as a talkback', () => {
let ending = 0;
const fn = jest.fn();
const source: types.sourceT<any> = sink =>
sink(deriving.start(tb => {
if (tb === deriving.pull)
sink(deriving.push(0));
if (tb === deriving.close)
ending++;
}));
callbagIterate(fn)(callbagTake(1)(web.toCallbag(source) as any));
expect(fn.mock.calls).toEqual([[0]]);
expect(ending).toBe(1);
});
});

View File

@@ -0,0 +1,207 @@
import * as Block from "bs-platform/lib/es6/block.js";
import * as Wonka_helpers from "./helpers/Wonka_helpers.bs.js";
function fromArray(arr) {
return (function (sink) {
var size = arr.length;
var state = {
ended: false,
looping: false,
pulled: false,
current: 0
};
return sink(/* Start */Block.__(0, [(function (signal) {
var match = state.looping;
if (signal) {
state.ended = true;
return ;
}
if (match) {
state.pulled = true;
return ;
}
state.pulled = true;
state.looping = true;
while(state.pulled && !state.ended) {
if (state.current < size) {
var x = arr[state.current];
state.current = state.current + 1 | 0;
state.pulled = false;
sink(/* Push */Block.__(1, [x]));
} else {
state.ended = true;
sink(/* End */0);
}
};
state.looping = false;
})]));
});
}
function fromList(ls) {
return (function (sink) {
var state = {
ended: false,
looping: false,
pulled: false,
current: ls
};
return sink(/* Start */Block.__(0, [(function (signal) {
var match = state.looping;
if (signal) {
state.ended = true;
return ;
}
if (match) {
state.pulled = true;
return ;
}
state.pulled = true;
state.looping = true;
while(state.pulled && !state.ended) {
var match$1 = state.current;
if (match$1) {
state.current = match$1[1];
state.pulled = false;
sink(/* Push */Block.__(1, [match$1[0]]));
} else {
state.ended = true;
sink(/* End */0);
}
};
state.looping = false;
})]));
});
}
function fromValue(x) {
return (function (sink) {
var ended = {
contents: false
};
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
ended.contents = true;
return ;
} else if (!ended.contents) {
ended.contents = true;
sink(/* Push */Block.__(1, [x]));
return sink(/* End */0);
} else {
return ;
}
})]));
});
}
function make(f) {
return (function (sink) {
var state = {
teardown: (function () {
}),
ended: false
};
state.teardown = f({
next: (function (value) {
if (!state.ended) {
return sink(/* Push */Block.__(1, [value]));
}
}),
complete: (function (param) {
if (!state.ended) {
state.ended = true;
return sink(/* End */0);
}
})
});
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal && !state.ended) {
state.ended = true;
return state.teardown();
}
})]));
});
}
function makeSubject(param) {
var state = {
sinks: new Array(),
ended: false
};
var source = function (sink) {
state.sinks = state.sinks.concat(sink);
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
state.sinks = state.sinks.filter((function (x) {
return x !== sink;
}));
return ;
}
})]));
};
var next = function (value) {
if (!state.ended) {
state.sinks.forEach((function (sink) {
return sink(/* Push */Block.__(1, [value]));
}));
return ;
}
};
var complete = function (param) {
if (!state.ended) {
state.ended = true;
state.sinks.forEach((function (sink) {
return sink(/* End */0);
}));
return ;
}
};
return {
source: source,
next: next,
complete: complete
};
}
function empty(sink) {
var ended = {
contents: false
};
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
ended.contents = true;
return ;
} else if (!ended.contents) {
return sink(/* End */0);
} else {
return ;
}
})]));
}
function never(sink) {
return sink(/* Start */Block.__(0, [Wonka_helpers.talkbackPlaceholder]));
}
export {
fromArray ,
fromList ,
fromValue ,
make ,
makeSubject ,
empty ,
never ,
}
/* No side effect */

View File

@@ -0,0 +1,32 @@
/* TypeScript file generated from Wonka_sources.re by genType. */
/* eslint-disable import/first */
// tslint:disable-next-line:no-var-requires
const Wonka_sourcesBS = require('./Wonka_sources.bs');
import {list} from '../src/shims/ReasonPervasives.shim';
import {observerT as Wonka_types_observerT} from './Wonka_types.gen';
import {sinkT as Wonka_types_sinkT} from './Wonka_types.gen';
import {sourceT as Wonka_types_sourceT} from './Wonka_types.gen';
import {subjectT as Wonka_types_subjectT} from './Wonka_types.gen';
import {teardownT as Wonka_types_teardownT} from './Wonka_types.gen';
export const fromArray: <a>(arr:a[]) => Wonka_types_sourceT<a> = Wonka_sourcesBS.fromArray;
export const fromList: <a>(ls:list<a>) => Wonka_types_sourceT<a> = Wonka_sourcesBS.fromList;
export const fromValue: <a>(x:a) => Wonka_types_sourceT<a> = Wonka_sourcesBS.fromValue;
export const make: <a>(f:((_1:Wonka_types_observerT<a>) => Wonka_types_teardownT)) => Wonka_types_sourceT<a> = Wonka_sourcesBS.make;
export const makeSubject: <a>() => Wonka_types_subjectT<a> = Wonka_sourcesBS.makeSubject;
export const empty: <a>(sink:Wonka_types_sinkT<a>) => void = Wonka_sourcesBS.empty;
export const never: <a>(sink:Wonka_types_sinkT<a>) => void = Wonka_sourcesBS.never;

View File

@@ -0,0 +1,193 @@
open Wonka_types;
open Wonka_helpers;
type trampolineT('a) = {
mutable ended: bool,
mutable looping: bool,
mutable pulled: bool,
mutable current: 'a,
};
[@genType]
let fromArray = (arr: array('a)): sourceT('a) =>
curry(sink => {
let size = Rebel.Array.size(arr);
let state = {ended: false, looping: false, pulled: false, current: 0};
sink(.
Start(
(. signal) =>
switch (signal, state.looping) {
| (Pull, false) =>
state.pulled = true;
state.looping = true;
while (state.pulled && !state.ended) {
if (state.current < size) {
let x = Rebel.Array.getUnsafe(arr, state.current);
state.current = state.current + 1;
state.pulled = false;
sink(. Push(x));
} else {
state.ended = true;
sink(. End);
};
};
state.looping = false;
| (Pull, true) => state.pulled = true
| (Close, _) => state.ended = true
},
),
);
});
[@genType]
let fromList = (ls: list('a)): sourceT('a) =>
curry(sink => {
let state = {ended: false, looping: false, pulled: false, current: ls};
sink(.
Start(
(. signal) =>
switch (signal, state.looping) {
| (Pull, false) =>
state.pulled = true;
state.looping = true;
while (state.pulled && !state.ended) {
switch (state.current) {
| [x, ...rest] =>
state.current = rest;
state.pulled = false;
sink(. Push(x));
| [] =>
state.ended = true;
sink(. End);
};
};
state.looping = false;
| (Pull, true) => state.pulled = true
| (Close, _) => state.ended = true
},
),
);
});
[@genType]
let fromValue = (x: 'a): sourceT('a) =>
curry(sink => {
let ended = ref(false);
sink(.
Start(
(. signal) =>
switch (signal) {
| Pull when ! ended^ =>
ended := true;
sink(. Push(x));
sink(. End);
| Pull => ()
| Close => ended := true
},
),
);
});
type makeStateT = {
mutable teardown: (. unit) => unit,
mutable ended: bool,
};
[@genType]
let make = (f: (. observerT('a)) => teardownT): sourceT('a) =>
curry(sink => {
let state: makeStateT = {teardown: (.) => (), ended: false};
state.teardown =
f(. {
next: value =>
if (!state.ended) {
sink(. Push(value));
},
complete: () =>
if (!state.ended) {
state.ended = true;
sink(. End);
},
});
sink(.
Start(
(. signal) =>
switch (signal) {
| Close when !state.ended =>
state.ended = true;
state.teardown(.);
| _ => ()
},
),
);
});
type subjectState('a) = {
mutable sinks: Rebel.Array.t(sinkT('a)),
mutable ended: bool,
};
[@genType]
let makeSubject = (): subjectT('a) => {
let state: subjectState('a) = {
sinks: Rebel.Array.makeEmpty(),
ended: false,
};
let source = sink => {
state.sinks = Rebel.Array.append(state.sinks, sink);
sink(.
Start(
(. signal) =>
switch (signal) {
| Close =>
state.sinks = Rebel.Array.filter(state.sinks, x => x !== sink)
| _ => ()
},
),
);
};
let next = value =>
if (!state.ended) {
Rebel.Array.forEach(state.sinks, sink => sink(. Push(value)));
};
let complete = () =>
if (!state.ended) {
state.ended = true;
Rebel.Array.forEach(state.sinks, sink => sink(. End));
};
{source, next, complete};
};
[@genType]
let empty = (sink: sinkT('a)): unit => {
let ended = ref(false);
sink(.
Start(
(. signal) => {
switch (signal) {
| Close => ended := true
| Pull when ! ended^ => sink(. End)
| _ => ()
}
},
),
);
};
[@genType]
let never = (sink: sinkT('a)): unit => {
sink(. Start(talkbackPlaceholder));
};

View File

@@ -0,0 +1,457 @@
import * as deriving from './helpers/Wonka_deriving';
import * as sources from './Wonka_sources.gen';
import * as operators from './Wonka_operators.gen';
import * as types from './Wonka_types.gen';
import * as web from './web/WonkaJs.gen';
import callbagFromArray from 'callbag-from-iter';
import Observable from 'zen-observable';
const collectSignals = (
source: types.sourceT<any>,
onStart?: (talkbackCb: (tb: types.talkbackT) => void) => void
) => {
let talkback = null;
const signals = [];
source(signal => {
signals.push(signal);
if (deriving.isStart(signal)) {
talkback = deriving.unboxStart(signal);
if (onStart) onStart(talkback);
talkback(deriving.pull);
} else if (deriving.isPush(signal)) {
talkback(deriving.pull);
}
})
return signals;
};
/* When a Close talkback signal is sent the source should immediately end */
const passesActiveClose = (source: types.sourceT<any>) =>
it('stops emitting when a Close talkback signal is received (spec)', () => {
let talkback = null;
const sink: types.sinkT<any> = signal => {
expect(deriving.isPush(signal)).toBeFalsy();
expect(deriving.isEnd(signal)).toBeFalsy();
if (deriving.isStart(signal)) {
talkback = deriving.unboxStart(signal);
talkback(deriving.close);
}
};
source(sink);
expect(talkback).not.toBe(null);
});
/* All synchronous, cold sources won't send anything unless a Pull signal
has been received. */
const passesColdPull = (source: types.sourceT<any>) =>
it('sends nothing when no Pull talkback signal has been sent (spec)', () => {
let pushes = 0;
let talkback = null;
const sink: types.sinkT<any> = signal => {
if (deriving.isPush(signal)) {
pushes++;
} else if (deriving.isStart(signal)) {
talkback = deriving.unboxStart(signal);
}
};
source(sink);
expect(talkback).not.toBe(null);
expect(pushes).toBe(0);
setTimeout(() => {
expect(pushes).toBe(0);
talkback(deriving.pull);
}, 10);
jest.runAllTimers();
expect(pushes).toBe(1);
});
/* All synchronous, cold sources need to use trampoline scheduling to avoid
recursively sending more and more Push signals which would eventually lead
to a call stack overflow when too many values are emitted. */
const passesTrampoline = (source: types.sourceT<any>) =>
it('uses trampoline scheduling instead of recursive push signals (spec)', () => {
let talkback = null;
let pushes = 0;
const signals = [];
const sink: types.sinkT<any> = signal => {
if (deriving.isPush(signal)) {
const lastPushes = ++pushes;
signals.push(signal);
talkback(deriving.pull);
expect(lastPushes).toBe(pushes);
} else if (deriving.isStart(signal)) {
talkback = deriving.unboxStart(signal);
talkback(deriving.pull);
expect(pushes).toBe(2);
} else if (deriving.isEnd(signal)) {
signals.push(signal);
expect(pushes).toBe(2);
}
};
source(sink);
expect(signals).toEqual([
deriving.push(1),
deriving.push(2),
deriving.end(),
]);
});
beforeEach(() => {
jest.useFakeTimers();
});
describe('fromArray', () => {
passesTrampoline(sources.fromArray([1, 2]));
passesColdPull(sources.fromArray([0]));
passesActiveClose(sources.fromArray([0]));
});
describe('fromList', () => {
passesTrampoline(sources.fromList([1, [2]] as any));
passesColdPull(sources.fromList([0] as any));
passesActiveClose(sources.fromList([0] as any));
});
describe('fromValue', () => {
passesColdPull(sources.fromValue(0));
passesActiveClose(sources.fromValue(0));
it('sends a single value and ends', () => {
expect(collectSignals(sources.fromValue(1))).toEqual([
deriving.start(expect.any(Function)),
deriving.push(1),
deriving.end()
]);
});
});
describe('merge', () => {
const source = operators.merge<any>([
sources.fromValue(0),
sources.empty
]);
passesColdPull(source);
passesActiveClose(source);
it('correctly merges two sources where the second is empty', () => {
const source = operators.merge<any>([
sources.fromValue(0),
sources.empty
]);
expect(collectSignals(source)).toEqual([
deriving.start(expect.any(Function)),
deriving.push(0),
deriving.end(),
]);
});
it('correctly merges hot sources', () => {
const onStart = jest.fn();
const source = operators.merge<any>([
operators.onStart(onStart)(sources.never),
operators.onStart(onStart)(sources.fromArray([1, 2])),
]);
const signals = collectSignals(source);
expect(onStart).toHaveBeenCalledTimes(2);
expect(signals).toEqual([
deriving.start(expect.any(Function)),
deriving.push(1),
deriving.push(2),
]);
});
it('correctly merges asynchronous sources', () => {
jest.useFakeTimers();
const onStart = jest.fn();
const source = operators.merge<any>([
operators.onStart(onStart)(sources.fromValue(-1)),
operators.onStart(onStart)(
operators.take(2)(web.interval(50))
),
]);
const signals = collectSignals(source);
jest.advanceTimersByTime(100);
expect(onStart).toHaveBeenCalledTimes(2);
expect(signals).toEqual([
deriving.start(expect.any(Function)),
deriving.push(-1),
deriving.push(0),
deriving.push(1),
deriving.end(),
]);
});
});
describe('concat', () => {
const source = operators.concat<any>([
sources.fromValue(0),
sources.empty
]);
passesColdPull(source);
passesActiveClose(source);
it('correctly concats two sources where the second is empty', () => {
const source = operators.concat<any>([
sources.fromValue(0),
sources.empty
]);
expect(collectSignals(source)).toEqual([
deriving.start(expect.any(Function)),
deriving.push(0),
deriving.end(),
]);
});
});
describe('make', () => {
it('may be used to create async sources', () => {
const teardown = jest.fn();
const source = sources.make(observer => {
setTimeout(() => observer.next(1), 10);
setTimeout(() => observer.complete(), 20);
return teardown;
});
const signals = collectSignals(source);
expect(signals).toEqual([deriving.start(expect.any(Function))]);
jest.runAllTimers();
expect(signals).toEqual([
deriving.start(expect.any(Function)),
deriving.push(1),
deriving.end(),
]);
});
it('supports active cancellation', () => {
const teardown = jest.fn();
const source = sources.make(() => teardown);
const sink: types.sinkT<any> = signal => {
expect(deriving.isPush(signal)).toBeFalsy();
expect(deriving.isEnd(signal)).toBeFalsy();
if (deriving.isStart(signal))
setTimeout(() => deriving.unboxStart(signal)(deriving.close));
};
source(sink);
expect(teardown).not.toHaveBeenCalled();
jest.runAllTimers();
expect(teardown).toHaveBeenCalled();
});
});
describe('makeSubject', () => {
it('may be used to emit signals programmatically', () => {
const { source, next, complete } = sources.makeSubject();
const signals = collectSignals(source);
expect(signals).toEqual([
deriving.start(expect.any(Function)),
]);
next(1);
expect(signals).toEqual([
deriving.start(expect.any(Function)),
deriving.push(1),
]);
complete();
expect(signals).toEqual([
deriving.start(expect.any(Function)),
deriving.push(1),
deriving.end(),
]);
});
it('ignores signals after complete has been called', () => {
const { source, next, complete } = sources.makeSubject();
const signals = collectSignals(source);
complete();
expect(signals).toEqual([
deriving.start(expect.any(Function)),
deriving.end(),
]);
next(1);
complete();
expect(signals.length).toBe(2);
});
});
describe('never', () => {
it('emits nothing and ends immediately', () => {
const signals = collectSignals(sources.never);
expect(signals).toEqual([deriving.start(expect.any(Function)) ]);
});
});
describe('empty', () => {
it('emits nothing and ends immediately', () => {
const signals = collectSignals(sources.empty);
expect(signals).toEqual([
deriving.start(expect.any(Function)),
deriving.end(),
]);
});
});
describe('fromPromise', () => {
passesActiveClose(web.fromPromise(Promise.resolve(null)));
it('emits a value when the promise resolves', async () => {
const promise = Promise.resolve(1);
const signals = collectSignals(web.fromPromise(promise));
expect(signals).toEqual([
deriving.start(expect.any(Function)),
]);
await promise;
expect(signals).toEqual([
deriving.start(expect.any(Function)),
deriving.push(1),
deriving.end(),
]);
});
});
describe('fromObservable', () => {
beforeEach(() => {
jest.useRealTimers();
});
it('converts an Observable to a Wonka source', async () => {
const source = web.fromObservable(Observable.from([1, 2]));
const signals = collectSignals(source);
await new Promise(resolve => setTimeout(resolve));
expect(signals).toEqual([
deriving.start(expect.any(Function)),
deriving.push(1),
deriving.push(2),
deriving.end(),
]);
});
it('supports cancellation on converted Observables', async () => {
const source = web.fromObservable(Observable.from([1, 2]));
const signals = collectSignals(source, talkback => {
talkback(deriving.close);
});
await new Promise(resolve => setTimeout(resolve));
expect(signals).toEqual([
deriving.start(expect.any(Function)),
]);
});
});
describe('fromCallbag', () => {
it('converts a Callbag to a Wonka source', () => {
const source = web.fromCallbag(callbagFromArray([1, 2]));
const signals = collectSignals(source);
expect(signals).toEqual([
deriving.start(expect.any(Function)),
deriving.push(1),
deriving.push(2),
deriving.end(),
]);
});
it('supports cancellation on converted Observables', () => {
const source = web.fromCallbag(callbagFromArray([1, 2]));
const signals = collectSignals(source, talkback => {
talkback(deriving.close);
});
expect(signals).toEqual([
deriving.start(expect.any(Function)),
]);
});
});
describe('interval', () => {
it('emits Push signals until Cancel is sent', () => {
let pushes = 0;
let talkback = null;
const sink: types.sinkT<any> = signal => {
if (deriving.isPush(signal)) {
pushes++;
} else if (deriving.isStart(signal)) {
talkback = deriving.unboxStart(signal);
}
};
web.interval(100)(sink);
expect(talkback).not.toBe(null);
expect(pushes).toBe(0);
jest.advanceTimersByTime(100);
expect(pushes).toBe(1);
jest.advanceTimersByTime(100);
expect(pushes).toBe(2);
talkback(deriving.close);
jest.advanceTimersByTime(100);
expect(pushes).toBe(2);
});
});
describe('fromDomEvent', () => {
it('emits Push signals for events on a DOM element', () => {
let talkback = null;
const element = {
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
};
const sink: types.sinkT<any> = signal => {
expect(deriving.isEnd(signal)).toBeFalsy();
if (deriving.isStart(signal))
talkback = deriving.unboxStart(signal);
};
web.fromDomEvent(element as any, 'click')(sink);
expect(element.addEventListener).toHaveBeenCalledWith('click', expect.any(Function));
expect(element.removeEventListener).not.toHaveBeenCalled();
const listener = element.addEventListener.mock.calls[0][1];
listener(1);
listener(2);
talkback(deriving.close);
expect(element.removeEventListener).toHaveBeenCalledWith('click', listener);
});
});

View File

@@ -0,0 +1 @@
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */

View File

@@ -0,0 +1,38 @@
/* TypeScript file generated from Wonka_types.re by genType. */
/* eslint-disable import/first */
import {signalT as $$signalT} from './shims/Js.shim';
import {talkbackT as $$talkbackT} from './shims/Js.shim';
// tslint:disable-next-line:interface-over-type-literal
export type talkbackT = $$talkbackT;
// tslint:disable-next-line:interface-over-type-literal
export type signalT<a> = $$signalT<a>;
// tslint:disable-next-line:interface-over-type-literal
export type sinkT<a> = (_1:signalT<a>) => void;
// tslint:disable-next-line:interface-over-type-literal
export type sourceT<a> = (_1:sinkT<a>) => void;
// tslint:disable-next-line:interface-over-type-literal
export type operatorT<a,b> = (_1:sourceT<a>) => sourceT<b>;
// tslint:disable-next-line:interface-over-type-literal
export type teardownT = () => void;
// tslint:disable-next-line:interface-over-type-literal
export type subscriptionT = { readonly unsubscribe: () => void };
// tslint:disable-next-line:interface-over-type-literal
export type observerT<a> = { readonly next: (_1:a) => void; readonly complete: () => void };
// tslint:disable-next-line:interface-over-type-literal
export type subjectT<a> = {
readonly source: sourceT<a>;
readonly next: (_1:a) => void;
readonly complete: () => void
};

View File

@@ -0,0 +1,72 @@
/* A sink has the signature: `signalT('a) => unit`
* A source thus has the signature: `sink => unit`, or `(signalT('a) => unit) => unit`
*
* Effectively a sink is a callback receiving signals as its first argument.
* - Start(talkback) will be carrying a talkback using which the sink can attempt
* to pull values (Pull) or request the source to end its stream (End)
* - Push(payload) carries a value that the source sends to the sink.
* This can happen at any time, since a source can be both pullable or
* merely listenable.
* - End signifies the end of the source stream, be it because of a talkback (End)
* or because the source is exhausted.
*
* In detail, a talkback is simply a callback that receives a talkback signal as
* its first argument. It's thus typically anonymously created by the source.
*
* A source is a factory that accepts a sink. Calling a source with a sink will
* instantiate and initiate the source's stream, after which the source sends the sink
* a talkback (Start(talkback)). This is called the "handshake".
*
* Typically an operator factory won't call the source with a sink it receives
* immediately—because this would cause the operator to simply be a noop—but instead
* it will create an intermediate sink with the same signature to perform its own
* logic.
*
* At that point the operator can for instance intercept the talkback for its own
* purposes, or call the actual sink as it sees fit.
*/
[@genType.import "./shims/Js.shim"]
type talkbackT =
| Pull
| Close;
[@genType.import "./shims/Js.shim"]
type signalT('a) =
| Start((. talkbackT) => unit)
| Push('a)
| End;
[@genType]
type sinkT('a) = (. signalT('a)) => unit;
[@genType]
type sourceT('a) = sinkT('a) => unit;
[@genType]
type operatorT('a, 'b) = sourceT('a) => sourceT('b);
[@genType]
type teardownT = (. unit) => unit;
[@genType]
type subscriptionT = {unsubscribe: unit => unit};
[@genType]
type observerT('a) = {
next: 'a => unit,
complete: unit => unit,
};
[@genType]
type subjectT('a) = {
source: sourceT('a),
next: 'a => unit,
complete: unit => unit,
};
/* Sinks and sources need to explicitly be their own callbacks;
* This means that currying needs to be forced for Bucklescript
* not to optimise them away
*/
external curry: 'a => 'a = "%identity";

View File

@@ -0,0 +1,10 @@
EXCLUDE_QUERY_DIR
B /Users/phil/.esy/3____________________________________________________________________/i/belt-d295eda5/lib/belt
B /Users/phil/Development/wonka/_esy/default/store/b/wonka-3b561974/default/src/dune/.wonka.objs/byte
S /Users/phil/.esy/3____________________________________________________________________/i/belt-d295eda5/lib/belt
S ..
S .
S ../helpers
S ../include/rebel_native
FLG -ppx '/Users/phil/Development/wonka/_esy/default/store/b/wonka-3b561974/default/.ppx/1532bed008d8875f00cab31e45a595e2/ppx.exe --as-ppx --cookie '\''library-name="wonka"'\'''
FLG -open Wonka__ -w -40

View File

@@ -0,0 +1 @@
include Rebel_native;

View File

@@ -0,0 +1,4 @@
module Types = Wonka_types;
include Wonka_sources;
include Wonka_operators;
include Wonka_sinks;

View File

@@ -0,0 +1,9 @@
(library
(name wonka)
(public_name wonka)
(libraries belt)
(preprocess (pps belt.ppx)))
(copy_files ../include/rebel_native/*.{re,rei})
(copy_files ../Wonka_*.{re,rei})
(copy_files ../helpers/Wonka_*.{re,rei})

View File

@@ -0,0 +1,28 @@
import { __ as block } from 'bs-platform/lib/es6/block';
import { talkbackPlaceholder } from './Wonka_helpers.bs';
import {
talkbackT,
signalT
} from '../Wonka_types.gen';
type talkbackCb = (tb: talkbackT) => void;
export const pull = (0 as any as talkbackT);
export const close = (1 as any as talkbackT);
export const start = <a>(tb: talkbackCb): signalT<a> => block(0, [tb]) as any;
export const push = <a>(x: a): signalT<a> => block(1, [x]) as any;
export const end = <a>(): signalT<a> => 0 as any;
export const isStart = <a>(s: signalT<a>) =>
typeof s !== 'number' && (s as any).tag === 0;
export const isPush = <a>(s: signalT<a>) =>
typeof s !== 'number' && (s as any).tag === 1;
export const isEnd = <a>(s: signalT<a>) =>
typeof s === 'number' && (s as any) === 0;
export const unboxPush = <a>(s: signalT<a>): a | null =>
isPush(s) ? (s as any)[0] : null;
export const unboxStart = <a>(s: signalT<a>): talkbackCb =>
isStart(s) ? (s as any)[0] : (talkbackPlaceholder as any);

View File

@@ -0,0 +1,9 @@
// @flow
import * as Wonka from '../../';
Wonka.pipe(
Wonka.fromArray([1, 2, 3]),
Wonka.map(x => x * 2),
Wonka.publish
);

View File

@@ -0,0 +1,12 @@
function talkbackPlaceholder(param) {
}
export {
talkbackPlaceholder ,
}
/* No side effect */

View File

@@ -0,0 +1,3 @@
open Wonka_types;
let talkbackPlaceholder = (. _: talkbackT) => ();

View File

@@ -0,0 +1,161 @@
import { sourceT as Source } from '../Wonka_types.gen';
interface UnaryFn<T, R> {
(source: T): R;
}
/* pipe definitions for source + operators composition */
function pipe<T, A>(source: Source<T>, op1: UnaryFn<Source<T>, Source<A>>): Source<A>;
function pipe<T, A, B>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>
): Source<B>;
function pipe<T, A, B, C>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>
): Source<C>;
function pipe<T, A, B, C, D>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>
): Source<D>;
function pipe<T, A, B, C, D, E>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>
): Source<E>;
function pipe<T, A, B, C, D, E, F>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
op6: UnaryFn<Source<E>, Source<F>>
): Source<F>;
function pipe<T, A, B, C, D, E, F, G>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
op6: UnaryFn<Source<E>, Source<F>>,
op7: UnaryFn<Source<F>, Source<G>>
): Source<G>;
function pipe<T, A, B, C, D, E, F, G, H>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
op6: UnaryFn<Source<E>, Source<F>>,
op7: UnaryFn<Source<F>, Source<G>>,
op8: UnaryFn<Source<G>, Source<H>>
): Source<H>;
/* pipe definitions for source + operators + consumer composition */
function pipe<T, R>(source: Source<T>, consumer: UnaryFn<Source<T>, R>): R;
function pipe<T, A, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
consumer: UnaryFn<Source<A>, R>
): R;
function pipe<T, A, B, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
consumer: UnaryFn<Source<B>, R>
): R;
function pipe<T, A, B, C, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
consumer: UnaryFn<Source<C>, R>
): R;
function pipe<T, A, B, C, D, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
consumer: UnaryFn<Source<D>, R>
): R;
function pipe<T, A, B, C, D, E, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
consumer: UnaryFn<Source<E>, R>
): R;
function pipe<T, A, B, C, D, E, F, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
op6: UnaryFn<Source<E>, Source<F>>,
consumer: UnaryFn<Source<F>, R>
): R;
function pipe<T, A, B, C, D, E, F, G, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
op6: UnaryFn<Source<E>, Source<F>>,
op7: UnaryFn<Source<F>, Source<G>>,
consumer: UnaryFn<Source<G>, R>
): R;
function pipe<T, A, B, C, D, E, F, G, H, R>(
source: Source<T>,
op1: UnaryFn<Source<T>, Source<A>>,
op2: UnaryFn<Source<A>, Source<B>>,
op3: UnaryFn<Source<B>, Source<C>>,
op4: UnaryFn<Source<C>, Source<D>>,
op5: UnaryFn<Source<D>, Source<E>>,
op6: UnaryFn<Source<E>, Source<F>>,
op7: UnaryFn<Source<F>, Source<G>>,
op8: UnaryFn<Source<G>, Source<H>>,
consumer: UnaryFn<Source<H>, R>
): R;
function pipe() {
let x = arguments[0];
for (let i = 1, l = arguments.length; i < l; i++)
x = arguments[i](x);
return x;
}
export { pipe };

View File

@@ -0,0 +1,17 @@
import * as Rebel_js from "./rebel_js/Rebel_js.bs.js";
var $$Array = Rebel_js.$$Array;
var MutableStack = Rebel_js.MutableStack;
var MutableQueue = Rebel_js.MutableQueue;
export {
$$Array ,
MutableStack ,
MutableQueue ,
}
/* No side effect */

View File

@@ -0,0 +1,9 @@
#if BS_NATIVE then
#if BSB_BACKEND = "js" then
include Rebel_js
#else
include Rebel_native
#end
#else
include Rebel_js
#end

View File

@@ -0,0 +1,62 @@
import * as Belt_Array from "bs-platform/lib/es6/belt_Array.js";
function make(len, vals) {
var res = new Array(len);
res.fill(vals);
return res;
}
function set(arr, index, x) {
if (index < arr.length && index >= 0) {
arr[index] = x;
return true;
} else {
return false;
}
}
function reverse(arr) {
var res = arr.slice();
arr.reverse();
return res;
}
function includes(arr, x) {
return arr.indexOf(x) > -1;
}
function remove(arr, pos) {
return arr.slice().splice(pos);
}
function removeCount(arr, pos, count) {
return arr.slice().splice(pos, count);
}
function splice(arr, pos, remove, add) {
return arr.slice().splice(pos, remove, add);
}
var Js = {
splice: splice
};
var shuffle = Belt_Array.shuffle;
var shuffleInPlace = Belt_Array.shuffleInPlace;
export {
shuffle ,
shuffleInPlace ,
make ,
set ,
reverse ,
includes ,
remove ,
removeCount ,
Js ,
}
/* No side effect */

View File

@@ -0,0 +1,94 @@
type t('a) = array('a);
[@bs.new] external makeEmpty: unit => t('a) = "Array";
[@bs.new] external makeUninitialized: int => t('a) = "Array";
[@bs.get] external size: t('a) => int = "length";
[@bs.get_index] external get: (t('a), int) => option('a) = "";
[@bs.get_index] external getUnsafe: (t('a), int) => 'a = "";
[@bs.set_index] external setUnsafe: (t('a), int, 'a) => unit = "";
[@bs.send] external fill: (t('a), 'a) => unit = "fill";
[@bs.send] external reverseInPlace: t('a) => unit = "reverse";
[@bs.send] external copy: t('a) => t('a) = "slice";
[@bs.send]
external slice: (t('a), ~start: int, ~end_: int) => t('a) = "slice";
[@bs.send] external append: (t('a), 'a) => t('a) = "concat";
[@bs.send] external concat: (t('a), t('a)) => t('a) = "concat";
[@bs.send] external map: (t('a), 'a => 'b) => t('b) = "map";
[@bs.send] external mapi: (t('a), ('a, int) => 'b) => t('b) = "map";
[@bs.send] external some: (t('a), 'a => bool) => bool = "some";
[@bs.send] external somei: (t('a), ('a, int) => bool) => bool = "some";
[@bs.send] external every: (t('a), 'a => bool) => bool = "every";
[@bs.send] external everyi: (t('a), ('a, int) => bool) => bool = "every";
[@bs.send] external filter: (t('a), 'a => bool) => t('a) = "filter";
[@bs.send] external filteri: (t('a), ('a, int) => bool) => t('a) = "filter";
[@bs.send] external find: (t('a), 'a => bool) => option('a) = "find";
[@bs.send] external findi: (t('a), ('a, int) => bool) => option('a) = "find";
[@bs.send] external findIndex: (t('a), 'a => bool) => int = "findIndex";
[@bs.send] external forEach: (t('a), 'a => unit) => unit = "forEach";
[@bs.send] external forEachi: (t('a), ('a, int) => unit) => unit = "forEach";
[@bs.send] external reduce: (t('a), ('b, 'a) => 'b, 'b) => 'b = "reduce";
[@bs.send]
external reduceRight: (t('a), ('b, 'a) => 'b, 'b) => 'b = "reduceRight";
[@bs.send] external indexOf: (t('a), 'a) => int = "indexOf";
[@bs.send] external lastIndexOf: (t('a), 'a) => int = "lastIndexOf";
/* No need to replicate what Belt already has */
let shuffle = Belt.Array.shuffle;
let shuffleInPlace = Belt.Array.shuffleInPlace;
let make = (len: int, vals: 'a): t('a) => {
let res = makeUninitialized(len);
fill(res, vals);
res;
};
let set = (arr: t('a), index: int, x: 'a) =>
if (index < size(arr) && index >= 0) {
setUnsafe(arr, index, x);
true;
} else {
false;
};
let reverse = (arr: t('a)): t('a) => {
let res = copy(arr);
reverseInPlace(arr);
res;
};
let includes = (arr: t('a), x: 'a): bool => indexOf(arr, x) > (-1);
[@bs.send] external removeInPlace: (t('a), int) => t('a) = "splice";
[@bs.send]
external removeCountInPlace: (t('a), ~pos: int, ~count: int) => t('a) =
"splice";
let remove = (arr: t('a), pos: int) => removeInPlace(copy(arr), pos);
let removeCount = (arr: t('a), ~pos: int, ~count: int) =>
removeCountInPlace(copy(arr), ~pos, ~count);
module Js = {
[@bs.send] external push: (t('a), 'a) => unit = "push";
[@bs.send] external pop: t('a) => option('a) = "pop";
[@bs.send] external unshift: (t('a), 'a) => unit = "unshift";
[@bs.send] external shift: t('a) => option('a) = "shift";
[@bs.scope ("Array", "prototype", "push")] [@bs.val]
external pushMany: (t('a), t('a)) => unit = "apply";
[@bs.scope ("Array", "prototype", "unshift")] [@bs.val]
external unshiftMany: (t('a), t('a)) => unit = "apply";
[@bs.send]
external spliceInPlace:
(t('a), ~pos: int, ~remove: int, ~add: t('a)) => t('a) =
"splice";
let splice = (arr: t('a), ~pos: int, ~remove: int, ~add: t('a)) =>
spliceInPlace(copy(arr), ~pos, ~remove, ~add);
};

View File

@@ -0,0 +1,32 @@
import * as Curry from "bs-platform/lib/es6/curry.js";
function isEmpty(q) {
return q.length === 0;
}
function reduceU(q, accu, f) {
return q.reduce((function (acc, x) {
return f(acc, x);
}), accu);
}
function reduce(q, accu, f) {
return q.reduce(Curry.__2(f), accu);
}
function transfer(q1, q2) {
Array.prototype.push.apply(q1, q2);
q1.length = 0;
}
export {
isEmpty ,
reduceU ,
reduce ,
transfer ,
}
/* No side effect */

View File

@@ -0,0 +1,31 @@
type t('a) = array('a);
external fromArray: array('a) => t('a) = "%identity";
external toArray: t('a) => array('a) = "%identity";
[@bs.new] external make: unit => t('a) = "Array";
[@bs.set] external clear: (t('a), [@bs.as 0] _) => unit = "length";
[@bs.send] external add: (t('a), 'a) => unit = "push";
[@bs.get] external peek: t('a) => option('a) = "0";
[@bs.send] external pop: t('a) => option('a) = "shift";
[@bs.send] external copy: t('a) => t('a) = "slice";
[@bs.get] external size: t('a) => int = "length";
[@bs.send] external mapU: (t('a), (. 'a) => 'b) => t('b) = "map";
[@bs.send] external map: (t('a), 'a => 'b) => t('b) = "map";
[@bs.send] external forEachU: (t('a), (. 'a) => unit) => unit = "forEach";
[@bs.send] external forEach: (t('a), 'a => unit) => unit = "forEach";
let isEmpty = (q: t('a)): bool => size(q) === 0;
let reduceU = (q: t('a), accu: 'b, f: (. 'b, 'a) => 'b): 'b =>
Js.Array.reduce((acc, x) => f(. acc, x), accu, q);
let reduce = (q: t('a), accu: 'b, f: ('b, 'a) => 'b): 'b =>
Js.Array.reduce(f, accu, q);
[@bs.scope ("Array", "prototype", "push")] [@bs.val]
external addMany: (t('a), t('a)) => unit = "apply";
let transfer = (q1: t('a), q2: t('a)) => {
addMany(q1, q2);
clear(q1);
};

View File

@@ -0,0 +1,20 @@
var Helpers = { };
function isEmpty(stack) {
return stack.length === 0;
}
function top(stack) {
return stack[stack.length - 1 | 0];
}
export {
Helpers ,
isEmpty ,
top ,
}
/* No side effect */

View File

@@ -0,0 +1,19 @@
type t('a) = array('a);
module Helpers = {
[@bs.get_index] external get: (t('a), int) => option('a) = "";
};
[@bs.new] external make: unit => t('a) = "Array";
[@bs.set] external clear: (t('a), [@bs.as 0] _) => unit = "length";
[@bs.send] external push: (t('a), 'a) => unit = "push";
[@bs.send] external pop: t('a) => option('a) = "pop";
[@bs.send] external copy: t('a) => t('a) = "slice";
[@bs.get] external size: t('a) => int = "length";
[@bs.send] external forEachU: (t('a), (. 'a) => unit) => unit = "forEach";
[@bs.send] external forEach: (t('a), 'a => unit) => unit = "forEach";
let isEmpty = (stack: t('a)): bool => size(stack) === 0;
let top = (stack: t('a)): option('a) =>
Helpers.get(stack, size(stack) - 1);

View File

@@ -0,0 +1,16 @@
var $$Array;
var MutableStack;
var MutableQueue;
export {
$$Array ,
MutableStack ,
MutableQueue ,
}
/* No side effect */

View File

@@ -0,0 +1,3 @@
module Array = Array_js;
module MutableStack = MutableStack_js;
module MutableQueue = MutableQueue_js;

View File

@@ -0,0 +1,282 @@
import * as $$Array from "bs-platform/lib/es6/array.js";
import * as Curry from "bs-platform/lib/es6/curry.js";
import * as Belt_Array from "bs-platform/lib/es6/belt_Array.js";
import * as Caml_option from "bs-platform/lib/es6/caml_option.js";
function makeEmpty(param) {
return [];
}
function makeUninitialized(prim) {
return new Array(prim);
}
function size(prim) {
return prim.length;
}
function getUnsafe(prim, prim$1) {
return prim[prim$1];
}
function setUnsafe(prim, prim$1, prim$2) {
prim[prim$1] = prim$2;
}
function fill(arr, x) {
return Belt_Array.fill(arr, 0, arr.length, x);
}
function copy(prim) {
return prim.slice(0);
}
function slice(arr, start, end_) {
var len = end_ - start | 0;
return Belt_Array.slice(arr, start, len);
}
function append(arr, x) {
return Belt_Array.concat(arr, [x]);
}
function somei(arr, f) {
var len = arr.length;
var _i = 0;
while(true) {
var i = _i;
if (i >= len) {
return false;
}
if (Curry._2(f, arr[i], i)) {
return true;
}
_i = i + 1 | 0;
continue ;
};
}
function everyi(arr, f) {
var len = arr.length;
var _i = 0;
while(true) {
var i = _i;
if (i >= len) {
return true;
}
if (!Curry._2(f, arr[i], i)) {
return false;
}
_i = i + 1 | 0;
continue ;
};
}
function findi(arr, f) {
var len = arr.length;
var _i = 0;
while(true) {
var i = _i;
if (i >= len) {
return ;
}
var x = arr[i];
if (Curry._2(f, x, i)) {
return Caml_option.some(x);
}
_i = i + 1 | 0;
continue ;
};
}
function findIndex(arr, f) {
var len = arr.length;
var _i = 0;
while(true) {
var i = _i;
if (i >= len) {
return -1;
}
if (Curry._1(f, arr[i])) {
return i;
}
_i = i + 1 | 0;
continue ;
};
}
function lastIndexOf(arr, x) {
var len = arr.length;
var _i = len - 1 | 0;
while(true) {
var i = _i;
if (i < 0) {
return -1;
}
if (x === arr[i]) {
return i;
}
_i = i - 1 | 0;
continue ;
};
}
function filteri(arr, f) {
var len = arr.length;
var res = arr.slice(0);
var j = {
contents: -1
};
var _i = 0;
while(true) {
var i = _i;
if (i >= len) {
return $$Array.sub(res, 0, j.contents + 1 | 0);
}
var x = arr[i];
if (Curry._2(f, x, i)) {
j.contents = j.contents + 1 | 0;
arr[j.contents] = x;
}
_i = i + 1 | 0;
continue ;
};
}
function removeCount(arr, pos, count) {
var len = arr.length;
var pos2 = (pos + count | 0) - 1 | 0;
var res = $$Array.sub(arr, 0, len - count | 0);
var _i = 0;
while(true) {
var i = _i;
if (i >= len) {
return res;
}
if (i >= pos && i <= pos2) {
_i = i + 1 | 0;
continue ;
}
var j = i > pos2 ? i - count | 0 : i;
arr[j] = arr[i];
_i = i + 1 | 0;
continue ;
};
}
function find(arr, f) {
return findi(arr, (function (x, _i) {
return Curry._1(f, x);
}));
}
function indexOf(arr, x) {
return findIndex(arr, (function (item) {
return item === x;
}));
}
function includes(arr, x) {
return findIndex(arr, (function (item) {
return item === x;
})) > -1;
}
function filter(arr, f) {
return filteri(arr, (function (x, _i) {
return Curry._1(f, x);
}));
}
function remove(arr, index) {
return removeCount(arr, index, 1);
}
function mapi(arr, f) {
return Belt_Array.mapWithIndexU(arr, (function (i, x) {
return Curry._2(f, x, i);
}));
}
function forEachi(arr, f) {
return Belt_Array.forEachWithIndexU(arr, (function (i, x) {
return Curry._2(f, x, i);
}));
}
function reduce(arr, reducer, acc) {
return Belt_Array.reduce(arr, acc, reducer);
}
function reduceRight(arr, reducer, acc) {
return Belt_Array.reduceReverse(arr, acc, reducer);
}
var make = Belt_Array.make;
var get = Belt_Array.get;
var set = Belt_Array.set;
var reverseInPlace = Belt_Array.reverseInPlace;
var reverse = Belt_Array.reverse;
var shuffle = Belt_Array.shuffle;
var shuffleInPlace = Belt_Array.shuffleInPlace;
var concat = Belt_Array.concat;
var some = Belt_Array.some;
var every = Belt_Array.every;
var map = Belt_Array.map;
var forEach = Belt_Array.forEach;
export {
makeEmpty ,
makeUninitialized ,
make ,
size ,
get ,
getUnsafe ,
set ,
setUnsafe ,
fill ,
reverseInPlace ,
reverse ,
shuffle ,
shuffleInPlace ,
copy ,
slice ,
concat ,
append ,
somei ,
everyi ,
findi ,
findIndex ,
lastIndexOf ,
filteri ,
removeCount ,
find ,
indexOf ,
includes ,
filter ,
remove ,
some ,
every ,
map ,
mapi ,
forEach ,
forEachi ,
reduce ,
reduceRight ,
}
/* No side effect */

View File

@@ -0,0 +1,166 @@
type t('a) = array('a);
let makeEmpty = (): t('a) => [||];
let makeUninitialized = Belt.Array.makeUninitializedUnsafe;
let make = Belt.Array.make;
let size = Belt.Array.size;
let get = Belt.Array.get;
let getUnsafe = Belt.Array.getUnsafe;
let set = Belt.Array.set;
let setUnsafe = Belt.Array.setUnsafe;
let fill = (arr: t('a), x: 'a) =>
Belt.Array.fill(arr, ~offset=0, ~len=size(arr), x);
let reverseInPlace = Belt.Array.reverseInPlace;
let reverse = Belt.Array.reverse;
let shuffle = Belt.Array.shuffle;
let shuffleInPlace = Belt.Array.shuffleInPlace;
let copy = Belt.Array.copy;
let slice = (arr: t('a), ~start: int, ~end_: int): t('a) => {
let len = end_ - start;
Belt.Array.slice(arr, ~offset=start, ~len);
};
let concat = Belt.Array.concat;
let append = (arr: t('a), x: 'a) => Belt.Array.concat(arr, [|x|]);
let somei = (arr: t('a), f: ('a, int) => bool): bool => {
let len = size(arr);
let rec search = (i: int) =>
if (i >= len) {
false;
} else if (f(getUnsafe(arr, i), i)) {
true;
} else {
search(i + 1);
};
search(0);
};
let everyi = (arr: t('a), f: ('a, int) => bool): bool => {
let len = size(arr);
let rec search = (i: int) =>
if (i >= len) {
true;
} else if (!f(getUnsafe(arr, i), i)) {
false;
} else {
search(i + 1);
};
search(0);
};
let findi = (arr: t('a), f: ('a, int) => bool): option('a) => {
let len = size(arr);
let rec search = (i: int) =>
if (i >= len) {
None;
} else {
let x = getUnsafe(arr, i);
if (f(x, i)) {
Some(x);
} else {
search(i + 1);
};
};
search(0);
};
let findIndex = (arr: t('a), f: 'a => bool): int => {
let len = size(arr);
let rec search = (i: int) =>
if (i >= len) {
(-1);
} else if (f(getUnsafe(arr, i))) {
i;
} else {
search(i + 1);
};
search(0);
};
let lastIndexOf = (arr: t('a), x: 'a): int => {
let len = size(arr);
let rec search = (i: int) =>
if (i < 0) {
(-1);
} else if (x === getUnsafe(arr, i)) {
i;
} else {
search(i - 1);
};
search(len - 1);
};
let filteri = (arr: t('a), f: ('a, int) => bool): t('a) => {
let len = size(arr);
let res: t('a) = copy(arr);
let j = ref(-1);
let rec filter = (i: int) =>
if (i >= len) {
Array.sub(res, 0, j^ + 1);
} else {
let x = getUnsafe(arr, i);
if (f(x, i)) {
j := j^ + 1;
Belt.Array.setUnsafe(arr, j^, x);
};
filter(i + 1);
};
filter(0);
};
let removeCount = (arr: t('a), ~pos: int, ~count: int): t('a) => {
let len = size(arr);
let pos2 = pos + count - 1;
let res = Array.sub(arr, 0, len - count);
let rec copy = (i: int) =>
if (i >= len) {
res;
} else if (i >= pos && i <= pos2) {
copy(i + 1);
} else {
let j = i > pos2 ? i - count : i;
Belt.Array.setUnsafe(arr, j, Belt.Array.getUnsafe(arr, i));
copy(i + 1);
};
copy(0);
};
let find = (arr: t('a), f: 'a => bool): option('a) =>
findi(arr, (x, _i) => f(x));
let indexOf = (arr: t('a), x: 'a): int => findIndex(arr, item => item === x);
let includes = (arr: t('a), x: 'a): bool =>
findIndex(arr, item => item === x) > (-1);
let filter = (arr: t('a), f: 'a => bool): t('a) =>
filteri(arr, (x, _i) => f(x));
let remove = (arr: t('a), index: int): t('a) =>
removeCount(arr, ~pos=index, ~count=1);
let some = Belt.Array.some;
let every = Belt.Array.every;
let map = Belt.Array.map;
let mapi = (arr: t('a), f: ('a, int) => 'b): t('b) =>
Belt.Array.mapWithIndexU(arr, (. i, x) => f(x, i));
let forEach = Belt.Array.forEach;
let forEachi = (arr: t('a), f: ('a, int) => unit): unit =>
Belt.Array.forEachWithIndexU(arr, (. i, x) => f(x, i));
let reduce = (arr: t('a), reducer: ('b, 'a) => 'b, acc: 'b): 'b =>
Belt.Array.reduce(arr, acc, reducer);
let reduceRight = (arr: t('a), reducer: ('b, 'a) => 'b, acc: 'b): 'b =>
Belt.Array.reduceReverse(arr, acc, reducer);

View File

@@ -0,0 +1,64 @@
import * as Belt_MutableQueue from "bs-platform/lib/es6/belt_MutableQueue.js";
function addMany(q1, q2) {
return Belt_MutableQueue.transfer(Belt_MutableQueue.copy(q1), q2);
}
var fromArray = Belt_MutableQueue.fromArray;
var toArray = Belt_MutableQueue.toArray;
var make = Belt_MutableQueue.make;
var clear = Belt_MutableQueue.clear;
var add = Belt_MutableQueue.add;
var peek = Belt_MutableQueue.peek;
var pop = Belt_MutableQueue.pop;
var copy = Belt_MutableQueue.copy;
var size = Belt_MutableQueue.size;
var mapU = Belt_MutableQueue.mapU;
var map = Belt_MutableQueue.map;
var forEachU = Belt_MutableQueue.forEachU;
var forEach = Belt_MutableQueue.forEach;
var isEmpty = Belt_MutableQueue.isEmpty;
var reduceU = Belt_MutableQueue.reduceU;
var reduce = Belt_MutableQueue.reduce;
var transfer = Belt_MutableQueue.transfer;
export {
fromArray ,
toArray ,
make ,
clear ,
add ,
peek ,
pop ,
copy ,
size ,
mapU ,
map ,
forEachU ,
forEach ,
isEmpty ,
reduceU ,
reduce ,
addMany ,
transfer ,
}
/* No side effect */

View File

@@ -0,0 +1,24 @@
type t('a) = Belt.MutableQueue.t('a);
let fromArray = Belt.MutableQueue.fromArray;
let toArray = Belt.MutableQueue.toArray;
let make = Belt.MutableQueue.make;
let clear = Belt.MutableQueue.clear;
let add = Belt.MutableQueue.add;
let peek = Belt.MutableQueue.peek;
let pop = Belt.MutableQueue.pop;
let copy = Belt.MutableQueue.copy;
let size = Belt.MutableQueue.size;
let mapU = Belt.MutableQueue.mapU;
let map = Belt.MutableQueue.map;
let forEachU = Belt.MutableQueue.forEachU;
let forEach = Belt.MutableQueue.forEach;
let isEmpty = Belt.MutableQueue.isEmpty;
let reduceU = Belt.MutableQueue.reduceU;
let reduce = Belt.MutableQueue.reduce;
let addMany = (q1: t('a), q2: t('a)) =>
Belt.MutableQueue.transfer(copy(q1), q2);
let transfer = Belt.MutableQueue.transfer;

View File

@@ -0,0 +1,38 @@
import * as Belt_MutableStack from "bs-platform/lib/es6/belt_MutableStack.js";
var make = Belt_MutableStack.make;
var clear = Belt_MutableStack.clear;
var push = Belt_MutableStack.push;
var pop = Belt_MutableStack.pop;
var copy = Belt_MutableStack.copy;
var size = Belt_MutableStack.size;
var forEachU = Belt_MutableStack.forEachU;
var forEach = Belt_MutableStack.forEach;
var isEmpty = Belt_MutableStack.isEmpty;
var top = Belt_MutableStack.top;
export {
make ,
clear ,
push ,
pop ,
copy ,
size ,
forEachU ,
forEach ,
isEmpty ,
top ,
}
/* No side effect */

View File

@@ -0,0 +1,13 @@
type t('a) = Belt.MutableStack.t('a);
let make = Belt.MutableStack.make;
let clear = Belt.MutableStack.clear;
let push = Belt.MutableStack.push;
let pop = Belt.MutableStack.pop;
let copy = Belt.MutableStack.copy;
let size = Belt.MutableStack.size;
let forEachU = Belt.MutableStack.forEachU;
let forEach = Belt.MutableStack.forEach;
let isEmpty = Belt.MutableStack.isEmpty;
let top = Belt.MutableStack.top;

View File

@@ -0,0 +1,16 @@
var $$Array;
var MutableStack;
var MutableQueue;
export {
$$Array ,
MutableStack ,
MutableQueue ,
}
/* No side effect */

View File

@@ -0,0 +1,3 @@
module Array = Array_native;
module MutableStack = MutableStack_native;
module MutableQueue = MutableQueue_native;

View File

@@ -0,0 +1,2 @@
export type element = HTMLElement;
export type event = Event;

View File

@@ -0,0 +1,31 @@
export type Exn_t = Error;
export type Internal_meth<_T, R> = () => R;
export type talkbackT = 0 | 1;
export type signalT<a> =
| ({ tag: 0 } & [(talkback: talkbackT) => void])
| ({ tag: 1 } & [a])
| 0;
export interface observableSubscriptionT {
unsubscribe(): void;
}
export interface observableObserverT<a> {
next(value: a): void;
error(error: any): void;
complete(): void;
}
export interface observableT<a> {
subscribe(observer: observableObserverT<a>): observableSubscriptionT;
}
interface Callbag<I, O> {
(t: 0, d: Callbag<O, I>): void;
(t: 1, d: I): void;
(t: 2, d?: any): void;
}
export type callbagT<a> = Callbag<void, a>;

View File

@@ -0,0 +1,11 @@
// tslint:disable-next-line:max-classes-per-file
export abstract class EmptyList {
protected opaque: any;
}
// tslint:disable-next-line:max-classes-per-file
export abstract class Cons<T> {
protected opaque!: T;
}
export type list<T> = Cons<T> | EmptyList;

View File

@@ -0,0 +1,250 @@
import * as Block from "bs-platform/lib/es6/block.js";
import * as Curry from "bs-platform/lib/es6/curry.js";
import * as Caml_option from "bs-platform/lib/es6/caml_option.js";
import * as Wonka_callbag from "./Wonka_callbag.bs.js";
import * as Wonka_operators from "../Wonka_operators.bs.js";
import * as Wonka_observable from "./Wonka_observable.bs.js";
function debounce(f) {
return (function (source) {
return (function (sink) {
var state = {
id: undefined,
deferredEnded: false,
ended: false
};
var $$clearTimeout$1 = function (param) {
var timeoutId = state.id;
if (timeoutId !== undefined) {
state.id = undefined;
clearTimeout(Caml_option.valFromOption(timeoutId));
return ;
}
};
return Curry._1(source, (function (signal) {
if (typeof signal === "number") {
if (state.ended) {
return ;
}
state.ended = true;
var match = state.id;
if (match !== undefined) {
state.deferredEnded = true;
return ;
} else {
return sink(/* End */0);
}
}
if (signal.tag) {
if (!state.ended) {
$$clearTimeout$1(undefined);
state.id = Caml_option.some(setTimeout((function (param) {
state.id = undefined;
sink(signal);
if (state.deferredEnded) {
return sink(/* End */0);
}
}), f(signal[0])));
return ;
} else {
return ;
}
}
var tb = signal[0];
return sink(/* Start */Block.__(0, [(function (signal) {
if (!state.ended) {
if (signal) {
state.ended = true;
state.deferredEnded = false;
$$clearTimeout$1(undefined);
return tb(/* Close */1);
} else {
return tb(/* Pull */0);
}
}
})]));
}));
});
});
}
function delay(wait) {
return (function (source) {
return (function (sink) {
var active = {
contents: 0
};
return Curry._1(source, (function (signal) {
if (typeof signal !== "number" && !signal.tag) {
return sink(signal);
}
active.contents = active.contents + 1 | 0;
setTimeout((function (param) {
if (active.contents !== 0) {
active.contents = active.contents - 1 | 0;
return sink(signal);
}
}), wait);
}));
});
});
}
function throttle(f) {
return (function (source) {
return (function (sink) {
var skip = {
contents: false
};
var id = {
contents: undefined
};
var $$clearTimeout$1 = function (param) {
var timeoutId = id.contents;
if (timeoutId !== undefined) {
clearTimeout(Caml_option.valFromOption(timeoutId));
return ;
}
};
return Curry._1(source, (function (signal) {
if (typeof signal === "number") {
$$clearTimeout$1(undefined);
return sink(/* End */0);
}
if (signal.tag) {
if (!skip.contents) {
skip.contents = true;
$$clearTimeout$1(undefined);
id.contents = Caml_option.some(setTimeout((function (param) {
id.contents = undefined;
skip.contents = false;
}), f(signal[0])));
return sink(signal);
} else {
return ;
}
}
var tb = signal[0];
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
$$clearTimeout$1(undefined);
return tb(/* Close */1);
} else {
return tb(signal);
}
})]));
}));
});
});
}
function toPromise(source) {
return new Promise((function (resolve, param) {
Curry._1(Wonka_operators.takeLast(1)(source), (function (signal) {
if (typeof signal === "number") {
return ;
} else if (signal.tag) {
return resolve(signal[0]);
} else {
return signal[0](/* Pull */0);
}
}));
}));
}
function interval(p) {
return (function (sink) {
var i = {
contents: 0
};
var id = setInterval((function (param) {
var num = i.contents;
i.contents = i.contents + 1 | 0;
return sink(/* Push */Block.__(1, [num]));
}), p);
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
clearInterval(id);
return ;
}
})]));
});
}
function fromDomEvent(element, $$event) {
return (function (sink) {
var addEventListener = (function (element, event, handler) {
element.addEventListener(event, handler);
});
var removeEventListener = (function (element, event, handler) {
element.removeEventListener(event, handler);
});
var handler = function ($$event) {
return sink(/* Push */Block.__(1, [$$event]));
};
sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
return removeEventListener(element, $$event, handler);
}
})]));
return addEventListener(element, $$event, handler);
});
}
function fromPromise(promise) {
return (function (sink) {
var ended = {
contents: false
};
promise.then((function (value) {
if (!ended.contents) {
sink(/* Push */Block.__(1, [value]));
sink(/* End */0);
}
return Promise.resolve(undefined);
}));
return sink(/* Start */Block.__(0, [(function (signal) {
if (signal) {
ended.contents = true;
return ;
}
})]));
});
}
var fromObservable = Wonka_observable.fromObservable;
var toObservable = Wonka_observable.toObservable;
var fromCallbag = Wonka_callbag.fromCallbag;
var toCallbag = Wonka_callbag.toCallbag;
export {
fromObservable ,
toObservable ,
fromCallbag ,
toCallbag ,
debounce ,
delay ,
throttle ,
toPromise ,
interval ,
fromDomEvent ,
fromPromise ,
}
/* Wonka_observable Not a pure module */

View File

@@ -0,0 +1,46 @@
/* TypeScript file generated from WonkaJs.re by genType. */
/* eslint-disable import/first */
// tslint:disable-next-line:no-var-requires
const Curry = require('bs-platform/lib/es6/curry.js');
// tslint:disable-next-line:no-var-requires
const WonkaJsBS = require('./WonkaJs.bs');
import {callbagT as Wonka_callbag_callbagT} from './Wonka_callbag.gen';
import {element as Dom_element} from '../../src/shims/Dom.shim';
import {event as Dom_event} from '../../src/shims/Dom.shim';
import {observableT as Wonka_observable_observableT} from './Wonka_observable.gen';
import {operatorT as Wonka_types_operatorT} from '../../src/Wonka_types.gen';
import {sourceT as Wonka_types_sourceT} from '../../src/Wonka_types.gen';
export const fromObservable: <T1>(_1:Wonka_observable_observableT<T1>) => Wonka_types_sourceT<T1> = WonkaJsBS.fromObservable;
export const toObservable: <T1>(_1:Wonka_types_sourceT<T1>) => Wonka_observable_observableT<T1> = WonkaJsBS.toObservable;
export const fromCallbag: <T1>(_1:Wonka_callbag_callbagT<T1>) => Wonka_types_sourceT<T1> = WonkaJsBS.fromCallbag;
export const toCallbag: <T1>(_1:Wonka_types_sourceT<T1>) => Wonka_callbag_callbagT<T1> = WonkaJsBS.toCallbag;
export const debounce: <a>(f:((_1:a) => number)) => Wonka_types_operatorT<a,a> = WonkaJsBS.debounce;
export const delay: <a>(wait:number) => Wonka_types_operatorT<a,a> = WonkaJsBS.delay;
export const throttle: <a>(f:((_1:a) => number)) => Wonka_types_operatorT<a,a> = WonkaJsBS.throttle;
export const toPromise: <a>(source:Wonka_types_sourceT<a>) => Promise<a> = WonkaJsBS.toPromise;
export const interval: (p:number) => Wonka_types_sourceT<number> = WonkaJsBS.interval;
export const fromDomEvent: (element:Dom_element, event:string) => Wonka_types_sourceT<Dom_event> = function (Arg1: any, Arg2: any) {
const result = Curry._2(WonkaJsBS.fromDomEvent, Arg1, Arg2);
return result
};
export const fromPromise: <a>(promise:Promise<a>) => Wonka_types_sourceT<a> = WonkaJsBS.fromPromise;

Some files were not shown because too many files have changed in this diff Show More