feat(js): expose typed browser environment and object-prop helpers - #10
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
glendix/js/environmentmodule:ColorScheme { Light, Dark, System }— the OS preference (Systemwhennone is expressed or
matchMediais unavailable).ResolvedColorScheme { ResolvedLight, ResolvedDark, ResolutionUnavailable }— what actually applies, distinguishing an unavailable environment from a
resolved light preference.
matchMediastays hidden behind the FFI; dynamic preference-changesubscriptions are intentionally documented as out of scope.
glendix/js/object.from_entriesto useObject.fromEntries, soordered typed entries preserve key order, keep the last value for duplicate
keys, and store special keys such as
__proto__as own data.object.from_entries→binding.element) in README and guide (EN/KO/JA).Acceptance mapping
matchMedia.duplicate/empty/
__proto__handled safely).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 exportcontracts for 318 externals, repository boundaries).
./scripts/family.sh widget-build— pass (glendix →.mpk).dependency-mode check-commit glendix) — valid;flexible
glendix→mendrawedge left unchanged (hex).Closes #9