Skip to content

feat(js): expose typed browser environment and object-prop helpers - #10

Merged
GG-O-BP merged 1 commit into
mainfrom
feat/js-typed-environment-object-prop-issue-9
Sep 7, 2026
Merged

feat(js): expose typed browser environment and object-prop helpers#10
GG-O-BP merged 1 commit into
mainfrom
feat/js-typed-environment-object-prop-issue-9

Conversation

@GG-O-BP

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

Copy link
Copy Markdown
Collaborator

Summary

Implements #9. Adds a typed public capability so Mendix widgets can read the
browser color-scheme preference and pass a single plain-object React prop
without any application-local FFI.

  • New glendix/js/environment module:
    • ColorScheme { Light, Dark, System } — the OS preference (System when
      none is expressed or matchMedia is unavailable).
    • ResolvedColorScheme { ResolvedLight, ResolvedDark, ResolutionUnavailable }
      — what actually applies, distinguishing an unavailable environment from a
      resolved light preference.
    • matchMedia stays hidden behind the FFI; dynamic preference-change
      subscriptions are intentionally documented as out of scope.
  • Hardened glendix/js/object.from_entries to use Object.fromEntries, so
    ordered typed entries preserve key order, keep the last value for duplicate
    keys, and store special keys such as __proto__ as own data.
  • Documented the browser-environment + single-object-prop pattern (via
    object.from_entriesbinding.element) in README and guide (EN/KO/JA).

Acceptance mapping

  • ✅ Query color-scheme preference without exposing matchMedia.
  • ✅ Represent light/dark/system explicitly.
  • ✅ Build a plain object from ordered typed entries (order preserved,
    duplicate/empty/__proto__ handled safely).
  • ✅ Pass the object as one external-component prop through Glendix bindings.
  • ✅ Existing DOM/object APIs remain compatible.

Tests

Contract tests cover light, dark, system-resolved, and unavailable
preferences; entry order, empty, duplicate-key, and prototype-key object
construction; and object-prop pass-through via binding.element.

Verification

  • ./scripts/verify.sh inner glendix — pass (28 tests).
  • check-all — pass (format, compile, warnings-as-errors, docs, FFI export
    contracts for 318 externals, repository boundaries).
  • ./scripts/family.sh widget-build — pass (glendix → .mpk).
  • Family unit suites — pass (glendix 28, mendraw 41, mxpak 121, glendam 61).
  • Dependency-source gate (dependency-mode check-commit glendix) — valid;
    flexible glendix→mendraw edge left unchanged (hex).

Note: the mandatory verify.sh final push gate could not complete in the
current environment — test-all is blocked by a transient Hex API rate limit
(mxpak standalone-consumer download, an untouched package), and the Mendix
full E2E / Lustre E2E require Mendix DB/runtime, the secret token, and a live
browser session that are not runnable here. Mendix/Lustre compatibility is
therefore not claimed and should be confirmed by CI or a maintainer before
release.

Closes #9

Add a typed `glendix/js/environment` module that reads the browser
color-scheme preference behind an FFI boundary, so widgets no longer call
`window.matchMedia` from application-local FFI.

- `ColorScheme { Light, Dark, System }` reports the OS preference, using
  `System` when no preference is expressed or `matchMedia` is unavailable.
- `ResolvedColorScheme { ResolvedLight, ResolvedDark, ResolutionUnavailable }`
  resolves what actually applies, distinguishing an unavailable environment
  from a resolved light preference.
- Dynamic preference-change subscriptions (`MediaQueryList` change events) are
  intentionally documented as out of scope.

Harden `glendix/js/object.from_entries` to build objects with
`Object.fromEntries`, so ordered typed entries preserve key order, keep the
last value for duplicate keys, and store special keys such as `__proto__` as
own data instead of invoking the legacy prototype setter.

Document the browser-environment and single-object-prop pattern (built with
`object.from_entries` and passed through `binding.element`) in the README and
guide across English, Korean, and Japanese.

Add contract tests covering light, dark, system-resolved, and unavailable
preferences; entry order, empty, duplicate-key, and prototype-key object
construction; and end-to-end object-prop passing through Glendix bindings.

Closes #9
@GG-O-BP
GG-O-BP merged commit e52ccc0 into main Sep 7, 2026
1 check passed
@GG-O-BP
GG-O-BP deleted the feat/js-typed-environment-object-prop-issue-9 branch September 7, 2026 01:40
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.

[js] Expose typed browser environment and object-prop helpers

1 participant