diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c976fd..56c1673 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Unreleased + +- Renamed ffi file to be scope with project name. + ## v0.10.0 - 2024-06-23 - The `Reference` type has been deprecated. diff --git a/src/gleam/javascript.gleam b/src/gleam/javascript.gleam index 9df0828..f75a2fd 100644 --- a/src/gleam/javascript.gleam +++ b/src/gleam/javascript.gleam @@ -33,7 +33,7 @@ pub type Symbol /// For further information view the MDN documentation: /// /// -@external(javascript, "../ffi.mjs", "type_of") +@external(javascript, "../gleam_javascript_ffi.mjs", "type_of") pub fn type_of(a: value) -> TypeOf /// Use the JavaScript `Symbol.for` method to look up a symbol with the given @@ -42,22 +42,22 @@ pub fn type_of(a: value) -> TypeOf /// For further information see the MDN documentation: /// /// -@external(javascript, "../ffi.mjs", "get_symbol") +@external(javascript, "../gleam_javascript_ffi.mjs", "get_symbol") pub fn get_symbol(a: String) -> Symbol @deprecated("The Reference type is being removed from this packge") pub type Reference(value) @deprecated("The Reference type is being removed from this packge") -@external(javascript, "../ffi.mjs", "dereference") +@external(javascript, "../gleam_javascript_ffi.mjs", "dereference") pub fn dereference(a: Reference(a)) -> a @deprecated("The Reference type is being removed from this packge") -@external(javascript, "../ffi.mjs", "set_reference") +@external(javascript, "../gleam_javascript_ffi.mjs", "set_reference") pub fn set_reference(a: Reference(a), b: a) -> a @deprecated("The Reference type is being removed from this packge") -@external(javascript, "../ffi.mjs", "make_reference") +@external(javascript, "../gleam_javascript_ffi.mjs", "make_reference") pub fn make_reference(a: a) -> Reference(a) @deprecated("The Reference type is being removed from this packge") @@ -68,5 +68,5 @@ pub fn update_reference(ref: Reference(a), f: fn(a) -> a) -> a { } @deprecated("The Reference type is being removed from this packge") -@external(javascript, "../ffi.mjs", "reference_equal") +@external(javascript, "../gleam_javascript_ffi.mjs", "reference_equal") pub fn reference_equal(a: Reference(a), b: Reference(a)) -> Bool diff --git a/src/gleam/javascript/array.gleam b/src/gleam/javascript/array.gleam index e644236..fc9d879 100644 --- a/src/gleam/javascript/array.gleam +++ b/src/gleam/javascript/array.gleam @@ -15,14 +15,14 @@ pub fn to_list(a: Array(element)) -> List(element) /// /// Runs in linear time. /// -@external(javascript, "../../ffi.mjs", "toArray") +@external(javascript, "../../gleam_javascript_ffi.mjs", "toArray") pub fn from_list(a: List(element)) -> Array(element) /// Get the number of elements in the array. /// /// Runs in constant time. /// -@external(javascript, "../../ffi.mjs", "length") +@external(javascript, "../../gleam_javascript_ffi.mjs", "length") pub fn size(a: Array(element)) -> Int /// Returns a new array containing only the elements of the first array after @@ -37,7 +37,7 @@ pub fn size(a: Array(element)) -> Int /// from_list([4, 8, 12]) /// ``` /// -@external(javascript, "../../ffi.mjs", "map") +@external(javascript, "../../gleam_javascript_ffi.mjs", "map") pub fn map(a: Array(a), with with: fn(a) -> b) -> Array(b) /// Reduces a list of elements into a single value by calling a given function @@ -48,7 +48,7 @@ pub fn map(a: Array(a), with with: fn(a) -> b) -> Array(b) /// /// Runs in linear time. /// -@external(javascript, "../../ffi.mjs", "reduce") +@external(javascript, "../../gleam_javascript_ffi.mjs", "reduce") pub fn fold(over over: Array(e), from from: a, with with: fn(a, e) -> a) -> a /// Reduces a list of elements into a single value by calling a given function @@ -59,7 +59,7 @@ pub fn fold(over over: Array(e), from from: a, with with: fn(a, e) -> a) -> a /// /// Runs in linear time. /// -@external(javascript, "../../ffi.mjs", "reduceRight") +@external(javascript, "../../gleam_javascript_ffi.mjs", "reduceRight") pub fn fold_right( over over: Array(e), from from: a, @@ -80,5 +80,5 @@ pub fn fold_right( /// Error(Nil) /// ``` /// -@external(javascript, "../../ffi.mjs", "index") +@external(javascript, "../../gleam_javascript_ffi.mjs", "index") pub fn get(a: Array(e), b: Int) -> Result(e, Nil) diff --git a/src/gleam/javascript/map.gleam b/src/gleam/javascript/map.gleam index a9dcf2e..6ae8f69 100644 --- a/src/gleam/javascript/map.gleam +++ b/src/gleam/javascript/map.gleam @@ -10,7 +10,7 @@ pub type Map(key, value) /// Create a new `Map` with no contained values. /// -@external(javascript, "../../ffi.mjs", "map_new") +@external(javascript, "../../gleam_javascript_ffi.mjs", "map_new") pub fn new() -> Map(key, value) /// Insert a new key and value into the `Map`. @@ -18,15 +18,15 @@ pub fn new() -> Map(key, value) /// **NOTE:** This function will mutate the `Map` rather than immutably /// updating it. /// -@external(javascript, "../../ffi.mjs", "map_set") +@external(javascript, "../../gleam_javascript_ffi.mjs", "map_set") pub fn set(a: Map(key, value), b: key, c: value) -> Map(key, value) /// Get the value for a given key in the `Map`. /// -@external(javascript, "../../ffi.mjs", "map_get") +@external(javascript, "../../gleam_javascript_ffi.mjs", "map_get") pub fn get(a: Map(key, value), b: key) -> Result(value, Nil) /// Get the number of key-value pairs in the `Map`. /// -@external(javascript, "../../ffi.mjs", "map_size") +@external(javascript, "../../gleam_javascript_ffi.mjs", "map_size") pub fn size(a: Map(key, value)) -> Int diff --git a/src/gleam/javascript/promise.gleam b/src/gleam/javascript/promise.gleam index 86bd983..1fa63f3 100644 --- a/src/gleam/javascript/promise.gleam +++ b/src/gleam/javascript/promise.gleam @@ -28,12 +28,12 @@ pub type Promise(value) /// This function is useful for converting code that uses callbacks into code /// that uses promises. /// -@external(javascript, "../../ffi.mjs", "newPromise") +@external(javascript, "../../gleam_javascript_ffi.mjs", "newPromise") pub fn new(a: fn(fn(value) -> Nil) -> Nil) -> Promise(value) /// Create a promise that resolves immediately. /// -@external(javascript, "../../ffi.mjs", "resolve") +@external(javascript, "../../gleam_javascript_ffi.mjs", "resolve") pub fn resolve(a: value) -> Promise(value) /// If the promise is in an error state then apply a function to convert the @@ -41,7 +41,7 @@ pub fn resolve(a: value) -> Promise(value) /// /// This is the equivilent of the `promise.catch` JavaScript method. /// -@external(javascript, "../../ffi.mjs", "rescue") +@external(javascript, "../../gleam_javascript_ffi.mjs", "rescue") pub fn rescue(a: Promise(value), b: fn(Dynamic) -> value) -> Promise(value) /// Chain a second asynchronous operation onto a promise, so it runs after the @@ -49,13 +49,13 @@ pub fn rescue(a: Promise(value), b: fn(Dynamic) -> value) -> Promise(value) /// /// This is the equivilent of the `promise.then` JavaScript method. /// -@external(javascript, "../../ffi.mjs", "then") +@external(javascript, "../../gleam_javascript_ffi.mjs", "then") pub fn await(a: Promise(a), b: fn(a) -> Promise(b)) -> Promise(b) /// Run a function on the value a promise resolves to, after it has resolved. /// The value returned becomes the new value contained by the promise. /// -@external(javascript, "../../ffi.mjs", "map_promise") +@external(javascript, "../../gleam_javascript_ffi.mjs", "map_promise") pub fn map(a: Promise(a), b: fn(a) -> b) -> Promise(b) /// Run a function on the value a promise resolves to, after it has resolved. @@ -116,7 +116,7 @@ pub fn try_await( /// /// This is the equivilent of the `Promise.all` JavaScript static method. /// -@external(javascript, "../../ffi.mjs", "all_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "all_promises") pub fn await2(a: Promise(a), b: Promise(b)) -> Promise(#(a, b)) /// Chain an asynchronous operation onto 3 promises, so it runs after the @@ -124,7 +124,7 @@ pub fn await2(a: Promise(a), b: Promise(b)) -> Promise(#(a, b)) /// /// This is the equivilent of the `Promise.all` JavaScript static method. /// -@external(javascript, "../../ffi.mjs", "all_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "all_promises") pub fn await3( a: Promise(a), b: Promise(b), @@ -136,7 +136,7 @@ pub fn await3( /// /// This is the equivilent of the `Promise.all` JavaScript static method. /// -@external(javascript, "../../ffi.mjs", "all_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "all_promises") pub fn await4( a: Promise(a), b: Promise(b), @@ -149,7 +149,7 @@ pub fn await4( /// /// This is the equivilent of the `Promise.all` JavaScript static method. /// -@external(javascript, "../../ffi.mjs", "all_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "all_promises") pub fn await5( a: Promise(a), b: Promise(b), @@ -163,7 +163,7 @@ pub fn await5( /// /// This is the equivilent of the `Promise.all` JavaScript static method. /// -@external(javascript, "../../ffi.mjs", "all_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "all_promises") pub fn await6( a: Promise(a), b: Promise(b), @@ -178,7 +178,7 @@ pub fn await6( /// /// This is the equivilent of the `Promise.all` JavaScript static method. /// -@external(javascript, "../../ffi.mjs", "all_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "all_promises") pub fn await_array(a: Array(Promise(a))) -> Promise(Array(a)) /// Chain an asynchronous operation onto an list of promises, so it runs after the @@ -192,16 +192,16 @@ pub fn await_list(xs: List(Promise(a))) -> Promise(List(a)) { |> map(array.to_list) } -@external(javascript, "../../ffi.mjs", "all_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "all_promises") fn do_await_list(a: List(Promise(a))) -> Promise(Array(a)) -@external(javascript, "../../ffi.mjs", "race_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "race_promises") pub fn race2(a: Promise(a), b: Promise(a)) -> Promise(a) -@external(javascript, "../../ffi.mjs", "race_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "race_promises") pub fn race3(a: Promise(a), b: Promise(a), c: Promise(a)) -> Promise(a) -@external(javascript, "../../ffi.mjs", "race_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "race_promises") pub fn race4( a: Promise(a), b: Promise(a), @@ -209,7 +209,7 @@ pub fn race4( d: Promise(a), ) -> Promise(a) -@external(javascript, "../../ffi.mjs", "race_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "race_promises") pub fn race5( a: Promise(a), b: Promise(a), @@ -218,7 +218,7 @@ pub fn race5( e: Promise(a), ) -> Promise(a) -@external(javascript, "../../ffi.mjs", "race_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "race_promises") pub fn race6( a: Promise(a), b: Promise(a), @@ -228,8 +228,8 @@ pub fn race6( f: Promise(a), ) -> Promise(a) -@external(javascript, "../../ffi.mjs", "race_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "race_promises") pub fn race_list(a: List(Promise(a))) -> Promise(a) -@external(javascript, "../../ffi.mjs", "race_promises") +@external(javascript, "../../gleam_javascript_ffi.mjs", "race_promises") pub fn race_array(a: Array(Promise(a))) -> Promise(a) diff --git a/src/ffi.mjs b/src/gleam_javascript_ffi.mjs similarity index 100% rename from src/ffi.mjs rename to src/gleam_javascript_ffi.mjs