Skip to content
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
11 changes: 10 additions & 1 deletion README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Glendix は Marketplace やブラウザ自動化を実装しません。

```toml
[dependencies]
glendix = ">= 5.1.0 and < 6.0.0"
glendix = ">= 6.0.0 and < 7.0.0"
```

Mendix クライアント値または MPK コンポーネントが必要な場合だけ `mendraw`、
Expand Down Expand Up @@ -219,6 +219,15 @@ JavaScript 設定、最終 MPK ビルドを担当します。
| `gleam run -m glendix/lint_fix` | lint 修正 |
| `gleam run -m glendix/release` | release ビルド |

## 6.0.0 の破壊的変更

`glendix/js/array` は変換を `gleam/javascript/array` に委譲するようになり、手書き
の JavaScript アダプターを同梱しなくなりました。`from_list` と `to_list` は関数
名・ラベル・要素順序の挙動を維持するため、一般的な
`list |> array.from_list |> array.to_list` の利用方法は変わりません。従来の
opaque 型 `glendix/js/array.JsArray(element)` は削除されたので、値の型は
`gleam/javascript/array.Array(element)` で注釈してください。

## 開発

```sh
Expand Down
11 changes: 10 additions & 1 deletion README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Glendix는 Marketplace나 브라우저 자동화를 구현하지 않는다.

```toml
[dependencies]
glendix = ">= 5.1.0 and < 6.0.0"
glendix = ">= 6.0.0 and < 7.0.0"
```

Mendix 클라이언트 값이나 MPK 컴포넌트가 필요할 때만 `mendraw`를 추가하고,
Expand Down Expand Up @@ -215,6 +215,15 @@ JavaScript 설정, 최종 MPK 빌드를 담당한다. Marketplace 위젯을 쓰
| `gleam run -m glendix/lint_fix` | lint 수정 |
| `gleam run -m glendix/release` | release 빌드 |

## 6.0.0 호환성 변경

`glendix/js/array`는 이제 변환을 `gleam/javascript/array`에 위임하며 수기
JavaScript 어댑터를 더 이상 포함하지 않는다. `from_list`와 `to_list`는 함수
이름·label·원소 순서 동작을 그대로 유지하므로 일반적인
`list |> array.from_list |> array.to_list` 사용은 변경되지 않는다. 기존 opaque
타입 `glendix/js/array.JsArray(element)`는 제거되었으므로 값의 타입은
`gleam/javascript/array.Array(element)`로 표기한다.

## 개발

```sh
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Glendix does not implement Marketplace access or browser automation.

```toml
[dependencies]
glendix = ">= 5.1.0 and < 6.0.0"
glendix = ">= 6.0.0 and < 7.0.0"
```

Add `mendraw` only when the project uses Mendix client values or installed MPK
Expand Down Expand Up @@ -282,6 +282,15 @@ Projects that do not use Marketplace widgets omit the first two steps.
| `gleam run -m glendix/lint_fix` | Apply lint fixes |
| `gleam run -m glendix/release` | Run the release build |

## Breaking changes in 6.0.0

`glendix/js/array` now delegates its conversions to `gleam/javascript/array`
and no longer ships a handwritten JavaScript adapter. The `from_list` and
`to_list` functions keep their names, labels, and element-order behavior, so the
common `list |> array.from_list |> array.to_list` usage is unchanged. The former
opaque `glendix/js/array.JsArray(element)` type is removed; annotate values with
`gleam/javascript/array.Array(element)` instead.

## Development

```sh
Expand Down
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "glendix"
version = "5.1.0"
version = "6.0.0"
gleam = ">= 1.17.0"
target = "javascript"
description = "Mendix widget build tooling with external React bindings and a Lustre bridge"
Expand Down
2 changes: 1 addition & 1 deletion glendix_guide.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Glendix は Marketplace やブラウザ自動化を実装しません。

```toml
[dependencies]
glendix = ">= 5.1.0 and < 6.0.0"
glendix = ">= 6.0.0 and < 7.0.0"
```

Mendix クライアント値または MPK コンポーネントが必要な場合だけ `mendraw`、
Expand Down
2 changes: 1 addition & 1 deletion glendix_guide.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Glendix는 Marketplace나 브라우저 자동화를 구현하지 않는다.

```toml
[dependencies]
glendix = ">= 5.1.0 and < 6.0.0"
glendix = ">= 6.0.0 and < 7.0.0"
```

Mendix 클라이언트 값이나 MPK 컴포넌트가 필요할 때만 `mendraw`를 추가하고,
Expand Down
2 changes: 1 addition & 1 deletion glendix_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Glendix does not implement Marketplace access or browser automation.

```toml
[dependencies]
glendix = ">= 5.1.0 and < 6.0.0"
glendix = ">= 6.0.0 and < 7.0.0"
```

Add `mendraw` only when the project uses Mendix client values or installed MPK
Expand Down
30 changes: 14 additions & 16 deletions src/glendix/js/array.gleam
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
//// Converts between Gleam lists and JavaScript arrays at the FFI boundary.
//// Converts between Gleam lists and JavaScript arrays.
////
//// The conversions delegate to `gleam/javascript/array`, so the standard
//// `Array(element)` type is the JavaScript array representation and Glendix no
//// longer owns equivalent runtime code. The former opaque `JsArray(element)`
//// type is removed; annotate values with `gleam/javascript/array.Array`
//// instead. See the repository README for the migration note.
////

/// Represents a JavaScript array whose elements have a known Gleam type.
pub type JsArray(element)
import gleam/javascript/array as javascript_array

/// Converts a Gleam list into a JavaScript array.
pub fn from_list(list list: List(element)) -> JsArray(element) {
list_to_array(list)
/// Converts a Gleam list into a JavaScript array, preserving element order.
pub fn from_list(list list: List(element)) -> javascript_array.Array(element) {
javascript_array.from_list(list)
}

/// Converts a JavaScript array into a Gleam list.
pub fn to_list(array array: JsArray(element)) -> List(element) {
array_to_list(array)
/// Converts a JavaScript array into a Gleam list, preserving element order.
pub fn to_list(array array: javascript_array.Array(element)) -> List(element) {
javascript_array.to_list(array)
}

// -- FFI --
@external(javascript, "./array_ffi.mjs", "list_to_array")
fn list_to_array(list: List(element)) -> JsArray(element)

@external(javascript, "./array_ffi.mjs", "array_to_list")
fn array_to_list(array: JsArray(element)) -> List(element)
7 changes: 0 additions & 7 deletions src/glendix/js/array_ffi.mjs

This file was deleted.

20 changes: 16 additions & 4 deletions test/glendix_test.gleam
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//// Exercises Glendix pure domain logic and JavaScript FFI contracts.
////

import gleam/javascript/array as javascript_array
import gleam/javascript/promise
import gleam/json
import gleam/list
Expand Down Expand Up @@ -217,12 +218,23 @@ pub fn define_failed_file_write_contract_test() -> Nil {
}
}

/// Verifies the JavaScript array FFI preserves element order.
pub fn javascript_array_round_trip_test() -> Nil {
[1, 2, 3]
/// Verifies Int list round trips preserve empty, singleton, and ordered values.
pub fn javascript_array_int_round_trip_test() -> Nil {
let examples = [[], [1], [1, 2, 3]]
list.each(examples, fn(example) {
let standard_array: javascript_array.Array(Int) = array.from_list(example)
standard_array
|> array.to_list
|> should.equal(example)
})
}

/// Verifies the conversion is generic over the element type.
pub fn javascript_array_string_round_trip_test() -> Nil {
["glendix", "js", "array"]
|> array.from_list
|> array.to_list
|> should.equal([1, 2, 3])
|> should.equal(["glendix", "js", "array"])
}

/// Verifies the JavaScript JSON FFI parses and serializes typed JSON values.
Expand Down
Loading