Skip to content

refactor(js)!: split js/object reflection into glendix/js/reflect (#19) - #29

Merged
GG-O-BP merged 2 commits into
mainfrom
refactor/js-object-reflection-split-issue-19
Sep 7, 2026
Merged

refactor(js)!: split js/object reflection into glendix/js/reflect (#19)#29
GG-O-BP merged 2 commits into
mainfrom
refactor/js-object-reflection-split-issue-19

Conversation

@GG-O-BP

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

Copy link
Copy Markdown
Collaborator

Summary

Closes #19.

glendix/js/object previously bundled two distinct concerns behind one FFI file:
plain data-object construction and arbitrary JavaScript reflection. This
splits them so the data boundary no longer depends on interop.

  • glendix/js/object is now data-only: JsValue, JsObject, JsBoolean,
    the scalar coercions (string/int/float/bool/from_object),
    from_entries, and empty. object_ffi.mjs is trimmed to
    create_object/empty_object/identity.
  • New glendix/js/reflect (+ reflect_ffi.mjs) owns the minimized, explicitly
    named reflection surface: get, set, delete, has, call_method,
    call_method_without_arguments, new_instance, and the JsConstructor type.
    Function names, labels, and behavior are preserved; only the owning module
    changes.

Ecosystem evaluation (data-object construction)

No safe ecosystem equivalent exists for building a live, prototype-pollution-safe
plain object: the public gleam/javascript API only covers arrays/promises/
symbols, Plinth has no general plain-object builder, and a gleam/json
round-trip is indirect and lossy for live handles. The minimal
Object.fromEntries FFI is therefore retained with a documented justification,
and its __proto__-as-own-data guarantee is preserved.

Tests

Source-matched test modules cover object creation (all value coercions, empty
construction, duplicate-key last-wins, ordering, and __proto__ remaining own
data without changing the prototype) and reflection (get present/missing,
set overwrite + same-handle identity, delete present/missing, has
prototype-chain semantics, method calls with/without arguments and receiver
binding, and constructor argument forwarding).

Compatibility / migration

Documented as a versioned migration in the English, Korean, and Japanese READMEs.
The glendix -> mendraw dependency source form is unchanged.

Verification

  • gleam format --check, gleam check, gleam build --warnings-as-errors,
    gleam docs build — passed
  • gleam test --runtime bun85 passed, 0 failures
  • Family static gates: mechanical style, FFI export contracts (98 externals,
    no stale declarations/exports), and repository boundaries — passed

This is a pure FFI module-split refactor with identical runtime behavior; no
Mendix/Lustre end-to-end path is exercised or claimed.

`glendix/js/object` bundled two concerns behind one FFI file: plain
data-object construction and arbitrary JavaScript reflection. This
separates them so the data boundary no longer depends on interop.

- `glendix/js/object` is now data-only: `JsValue`/`JsObject`/`JsBoolean`,
  the scalar coercions, `from_entries`, and `empty`. `object_ffi.mjs`
  is trimmed to `create_object`/`empty_object`/`identity`.
- New `glendix/js/reflect` (+ `reflect_ffi.mjs`) owns the minimized,
  explicitly named reflection surface: `get`/`set`/`delete`/`has`,
  `call_method`, `call_method_without_arguments`, `new_instance`, and
  the `JsConstructor` type. Function names, labels, and behavior are
  preserved; only the module changes.

Data construction keeps its bespoke `Object.fromEntries` FFI on purpose:
no ecosystem package builds a live, prototype-pollution-safe plain
object (`gleam/javascript` only covers arrays/promises/symbols, and a
`gleam/json` round-trip is indirect and lossy for live handles). The
`__proto__`-as-own-data guarantee is retained and documented.

Tests cover creation (including a `__proto__` key), property
get/set/delete/has, method calls with and without arguments, and
construction. Module docs and the README document the split, the
migration, and the unsafe/dynamic reflection boundary. The
`glendix -> mendraw` dependency source form is unchanged.

Closes #19
Move the object and reflection contracts into source-matched test modules,
cover all value coercions, empty construction, missing and inherited
properties, handle identity, receiver binding, and constructor arguments,
and assert that __proto__ remains own data without changing the prototype.

Clarify the reflection setter risk and has-property semantics, document the
ecosystem retention rationale, and keep the English, Korean, and Japanese
migration guidance synchronized.
@GG-O-BP
GG-O-BP merged commit 872e517 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] Separate data-only JavaScript objects from reflection operations

1 participant