Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Add Js namespace #2

Merged
merged 2 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/src/Core__Array.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ external getUnsafe: (array<'a>, int) => 'a = "%array_unsafe_get"
external setUnsafe: (array<'a>, int, 'a) => unit = "%array_unsafe_set"

@val external fromIterator: Core__Iterator.t<'a> => array<'a> = "Array.from"
@val external fromArrayLike: Js_types.arrayLike<'a> => array<'a> = "Array.from"
@val external fromArrayLike: Runtime_types.arrayLike<'a> => array<'a> = "Array.from"
@val
external fromArrayLikeWithMap: (Js_types.arrayLike<'a>, 'a => 'b) => array<'b> = "Array.from"
external fromArrayLikeWithMap: (Runtime_types.arrayLike<'a>, 'a => 'b) => array<'b> = "Array.from"

@send external fillAll: (array<'a>, 'a) => unit = "fill"

Expand Down
4 changes: 2 additions & 2 deletions core/src/Core__Array.resi
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
external fromIterator: Core__Iterator.t<'a> => array<'a> = "Array.from"

// TODO: Docs
@val external fromArrayLike: Js_types.arrayLike<'a> => array<'a> = "Array.from"
@val external fromArrayLike: Runtime_types.arrayLike<'a> => array<'a> = "Array.from"

// TODO: Docs
@val
external fromArrayLikeWithMap: (Js_types.arrayLike<'a>, 'a => 'b) => array<'b> = "Array.from"
external fromArrayLikeWithMap: (Runtime_types.arrayLike<'a>, 'a => 'b) => array<'b> = "Array.from"

/**
`make(~length, init)`
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__ArrayBuffer.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t = Js_types.arrayBuffer
type t = Runtime_types.arrayBuffer

@new external make: int => t = "ArrayBuffer"
@get external byteLength: t => int = "byteLength"
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Date.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t = Js_types.date
type t = Runtime_types.date

type msSinceEpoch = float

Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Date.resi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
A type representing a JavaScript date.
*/
type t = Js_types.date
type t = Runtime_types.date

/**
Time, in milliseconds, since / until the UNIX epoch (January 1, 1970 00:00:00 UTC).
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Error.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t = Js_types.jsExn
type t = Runtime_types.jsExn

external fromException: exn => option<t> = "?as_js_exn"
external toException: t => exn = "%identity"
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Error.resi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ See [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/
*/

/** Represents a JavaScript exception. */
type t = Js_types.jsExn
type t = Runtime_types.jsExn

external fromException: exn => option<t> = "?as_js_exn"

Expand Down
4 changes: 2 additions & 2 deletions core/src/Core__Global.res
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
type timeoutId = Js_types.timeoutId
type timeoutId = Runtime_types.timeoutId

@val external setTimeout: (unit => unit, int) => timeoutId = "setTimeout"
@val external setTimeoutFloat: (unit => unit, float) => timeoutId = "setTimeout"
@val external clearTimeout: timeoutId => unit = "clearTimeout"

type intervalId = Js_types.intervalId
type intervalId = Runtime_types.intervalId

@val external setInterval: (unit => unit, int) => intervalId = "setInterval"
@val external setIntervalFloat: (unit => unit, float) => intervalId = "setInterval"
Expand Down
4 changes: 2 additions & 2 deletions core/src/Core__Global.resi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ An `id` representing a timeout started via `setTimeout`.

See [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout) on MDN.
*/
type timeoutId = Js_types.timeoutId
type timeoutId = Runtime_types.timeoutId

/**
`setTimeout(callback, durationInMilliseconds)` starts a timer that will execute `callback` after `durationInMilliseconds`.
Expand Down Expand Up @@ -66,7 +66,7 @@ An `id` representing an interval started via `setInterval`.

See [`setInterval`](https://developer.mozilla.org/en-US/docs/Web/API/setInterval) on MDN.
*/
type intervalId = Js_types.intervalId
type intervalId = Runtime_types.intervalId

/**
`setInterval(callback, intervalInMilliseconds)` starts an interval that will execute `callback` every `durationInMilliseconds` milliseconds.
Expand Down
6 changes: 3 additions & 3 deletions core/src/Core__JSON.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@unboxed
type rec t = Js_types.json =
type rec t = Runtime_types.json =
| Boolean(bool)
| @as(null) Null
| String(string)
Expand Down Expand Up @@ -54,8 +54,8 @@ module Classify = {
external _asBool: 'a => bool = "%identity"
external _asString: 'a => string = "%identity"
external _asFloat: 'a => float = "%identity"
external _asArray: 'a => array<Js_types.json> = "%identity"
external _asDict: 'a => Core__Dict.t<Js_types.json> = "%identity"
external _asArray: 'a => array<Runtime_types.json> = "%identity"
external _asDict: 'a => Core__Dict.t<Runtime_types.json> = "%identity"

let classify = value => {
switch _internalClass(value) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__JSON.resi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Functions for interacting with JSON.
A type representing a JSON object.
*/
@unboxed
type rec t = Js_types.json =
type rec t = Runtime_types.json =
| Boolean(bool)
| @as(null) Null
| String(string)
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Map.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t<'k, 'v> = Js_types.map<'k, 'v>
type t<'k, 'v> = Runtime_types.map<'k, 'v>

@new external make: unit => t<'k, 'v> = "Map"
@new external fromArray: array<('k, 'v)> => t<'k, 'v> = "Map"
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Map.resi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ See [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Gl
/**
Type representing an instance of `Map`.
*/
type t<'k, 'v> = Js_types.map<'k, 'v>
type t<'k, 'v> = Runtime_types.map<'k, 'v>

/**
Creates a new, mutable JavaScript `Map`. A `Map` can have any values as both keys and values.
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Null.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@unboxed
type t<'a> = Js_types.null<'a> =
type t<'a> = Runtime_types.null<'a> =
| Value('a)
| @as(null) Null

Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Null.resi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ If you also need to cover `undefined`, check out `Nullable` instead.
A type representing a value that can be either `'a` or `null`.
*/
@unboxed
type t<'a> = Js_types.null<'a> =
type t<'a> = Runtime_types.null<'a> =
| Value('a)
| @as(null) Null

Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Nullable.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@unboxed
type t<'a> = Js_types.nullable<'a> =
type t<'a> = Runtime_types.nullable<'a> =
| Value('a)
| @as(null) Null
| @as(undefined) Undefined
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Nullable.resi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Type representing a nullable value.
A nullable value can be the value `'a`, `null` or `undefined`.
*/
@unboxed
type t<'a> = Js_types.nullable<'a> =
type t<'a> = Runtime_types.nullable<'a> =
| Value('a)
| @as(null) Null
| @as(undefined) Undefined
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__RegExp.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t = Js_types.regExp
type t = Runtime_types.regExp

module Result = {
type t = array<option<string>>
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__RegExp.resi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ See [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
/**
Type representing an instantiated `RegExp`.
*/
type t = Js_types.regExp
type t = Runtime_types.regExp

module Result: {
/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Set.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t<'a> = Js_types.set<'a>
type t<'a> = Runtime_types.set<'a>

@new external make: unit => t<'a> = "Set"
@new external fromArray: array<'a> => t<'a> = "Set"
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Set.resi
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ See [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Gl
/**
Type representing an instance of `Set`.
*/
type t<'a> = Js_types.set<'a>
type t<'a> = Runtime_types.set<'a>

/**
Creates a new, mutable JavaScript `Set`. A `Set` is a collection of unique values.
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__Symbol.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t = Js_types.symbol
type t = Runtime_types.symbol

@val external make: string => t = "Symbol"
@val external getFor: string => t = "Symbol.for"
Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__WeakMap.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t<'k, 'v> = Js_types.weakMap<'k, 'v>
type t<'k, 'v> = Runtime_types.weakMap<'k, 'v>

@new external make: unit => t<'k, 'v> = "WeakMap"

Expand Down
2 changes: 1 addition & 1 deletion core/src/Core__WeakSet.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type t<'a> = Js_types.weakSet<'a>
type t<'a> = Runtime_types.weakSet<'a>

@new external make: unit => t<'a> = "WeakSet"

Expand Down
10 changes: 5 additions & 5 deletions core/src/RescriptCore.res
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ module BigUint64Array = Core__BigUint64Array

module Intl = Core__Intl

@val external window: Js_types.window = "window"
@val external document: Js_types.document = "document"
@val external window: Runtime_types.window = "window"
@val external document: Runtime_types.document = "document"
@val external globalThis: {..} = "globalThis"

external null: Core__Nullable.t<'a> = "#null"
Expand Down Expand Up @@ -105,10 +105,10 @@ module Option = Core__Option
module List = Core__List
module Result = Core__Result

type null<+'a> = Js_types.null<'a>
type null<+'a> = Runtime_types.null<'a>

type undefined<+'a> = Js_types.undefined<'a>
type undefined<+'a> = Runtime_types.undefined<'a>

type nullable<+'a> = Js_types.nullable<'a>
type nullable<+'a> = Runtime_types.nullable<'a>

let panic = Core__Error.panic
4 changes: 4 additions & 0 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "js",
"version": "0.0.0"
}
9 changes: 9 additions & 0 deletions js/rescript.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "js",
"sources": {
"dir": "src",
"subdirs": true
},
"bs-dependencies": ["stdlib-mini"],
"bsc-flags": ["-nostdlib", "-nopervasives", "-open Stdlib_mini"]
}
114 changes: 114 additions & 0 deletions js/src/js.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading