Skip to content

refactor(js)!: replace glendix/js/array with gleam_javascript array (#11) - #25

Merged
GG-O-BP merged 1 commit into
mainfrom
refactor/array-gleam-javascript-issue-11
Sep 7, 2026
Merged

refactor(js)!: replace glendix/js/array with gleam_javascript array (#11)#25
GG-O-BP merged 1 commit into
mainfrom
refactor/array-gleam-javascript-issue-11

Conversation

@GG-O-BP

@GG-O-BP GG-O-BP commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #11. Delegates glendix/js/array conversions to gleam/javascript/array
and removes the handwritten JavaScript adapter, so Glendix no longer owns
duplicate array runtime code.

Changes

  • src/glendix/js/array.gleamfrom_list and to_list now delegate to
    gleam/javascript/array.from_list/to_list. Their names, labels, and
    element-order behavior are unchanged, so list |> array.from_list |> array.to_list
    keeps working. The former opaque JsArray(element) type is removed and its
    two private @external declarations are gone.
  • src/glendix/js/array_ffi.mjs — deleted; nothing references it.
  • test/glendix_test.gleam — round-trip tests now cover empty, singleton,
    and ordered Int lists plus a String list for generic-element typing.
  • gleam.toml + READMEs/guides — version bumped to 6.0.0 and install
    ranges updated; a migration note documents the JsArray removal.

Why JsArray was removed (not kept as a facade)

The issue prefers preserving JsArray as a compatibility facade "if Gleam's
type-alias/export rules permit it." A transparent re-export would require a
pub type JsArray(element) = gleam/javascript/array.Array(element) alias, but
the family's mechanical style gate (check-style.py, run by
./scripts/verify.sh shared) forbids all type X = aliases. Since this is a
public/shared boundary change, that gate must pass, so the alias cannot merge.

Per the issue's fallback ("document the required migration and treat the change
according to semantic-versioning policy"), the opaque type is removed and this
is treated as a breaking change:

  • Normal usage through from_list/to_list is source-compatible (the type was
    opaque, so callers never constructed or matched it).
  • Only callers that explicitly annotated array.JsArray(T) must switch to
    gleam/javascript/array.Array(T).
  • Package bumped 5.1.0 -> 6.0.0; migration documented in README*.md.

Acceptance criteria

  • from_list/to_list delegate to gleam/javascript/array; no handwritten JS remains
  • src/glendix/js/array_ffi.mjs removed
  • Unavoidable source incompatibility (removal of opaque JsArray) documented and versioned
  • Round-trip tests cover empty, singleton, and ordered multi-element arrays (plus a second element type)
  • FFI contract checks report no stale external declarations or exports
  • glendix -> mendraw retains its declared Hex dependency source form

Verification (isolated worktree pinned to the pushed commit)

  • ./scripts/verify.sh inner glendix — pass (52 tests, --runtime bun)
  • scripts/check-style.py, scripts/check-ffi-contracts.py, scripts/check-boundaries.py — pass
  • scripts/family.sh deps-statusSummary: valid (mendraw stays hex)
  • dependency-mode.sh check-commit glendix <tip> — valid

Note: ./scripts/verify.sh final (Lustre + full Mendix runtime E2E) was not
run — the managed Mendix toolchain (mx/mxbuild) is unavailable in this
environment. This change is a pure JavaScript-target FFI refactor with no
Mendix/Lustre runtime behavior change, so no Mendix/Lustre compatibility is
claimed beyond the source gates above.

Delegate glendix/js/array conversions to gleam/javascript/array and remove the handwritten JavaScript adapter and its externals. from_list and to_list keep their names, labels, and element-order behavior, so list |> array.from_list |> array.to_list is unchanged.

The project's style gate forbids type aliases, so the former opaque JsArray(element) type cannot be preserved as a re-export and is removed; annotate values with gleam/javascript/array.Array(element) instead. This is a source-breaking change for callers that named JsArray explicitly, so bump the package to 6.0.0 and document the migration in the READMEs.

Tests cover empty, singleton, and ordered Int round trips plus a String round trip for generic-element typing. glendix -> mendraw keeps its declared Hex source form.

Closes #11.
@GG-O-BP
GG-O-BP merged commit fe1acd3 into main Sep 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ffi] Replace glendix/js/array with gleam_javascript array

1 participant