Skip to content

Fix fragment, patch, cache, and chrome conformance - #5

Open
prateekbhujel wants to merge 1 commit into
NativePHP:mainfrom
prateekbhujel:fix/fragment-patch-cache-chrome-conformance
Open

prateekbhujel wants to merge 1 commit into
NativePHP:mainfrom
prateekbhujel:fix/fragment-patch-cache-chrome-conformance

Conversation

@prateekbhujel

Copy link
Copy Markdown

Fixes Draft 4 Asgard protocol conformance issues across fragment validation, patches, caching, chrome, callbacks, and stream subscriptions. Separate from #3 and #4.

Changes

  • Fragment validation and prop sanitization (src/Asgard/ServerRegion.php):
    • Reject associative roots without a string type, non-list children, duplicate sibling keys (including numeric/string collisions like 7 and "7"), and non-text children inside text nodes.
    • Strip compiler-internal props and non-conforming core props/types, including empty image.src, leadingAvatar, and leadingImage.
  • Patches and deferred replay (src/Asgard/ServerRegion.php):
    • Require non-empty keys (remove) and nodes (prepend / append), and reject explicit keep: null.
    • Enforce text-only children when patching into a text container.
    • Trigger a push fetch and repaint when replayDeferred() fails on a landed fragment, clear deferred patches on timeout in expire(), and replay deferred patches on inline redraws in paintInline().
  • Cache, chrome, callbacks, and subscriptions (FragmentCallbacks.php, ServerChrome.php, ServerMethods.php, ServerRegion.php):
    • Refuse undeclared cached: true answers and Asgard-Cache: invalidate paired with cached: true as invalid across renders, batches, and inline calls (ServerMethods + ServerRegion).
    • Avoid caching rejected chrome under app.debug = false (applyChrome() returns null when rejected).
    • Add /D to FragmentCallbacks::CALL_PATTERN and reject explicit null on optional callback/navigation keys (args, target, transition, replace).
    • Reject non-bool divider, explicit null on logo.height and tab_bar.presentation.configuration, and lift chrome media string limit from 1024 to MediaUrl (2048 bytes).
    • Compare subscription version tokens strictly as strings ("01" vs "1") and guard hints() in deliverAction() when $owner is null.
  • Tests:
    • Updated 3 pre-Draft-4 cache tests in RegionCacheTest.php and StateEverywhereTest.php so requests declare cached regions before simulating lost device cache.
    • Added regression tests across RegionCacheTest.php, RegionPatchTest.php, ServerRegionTest.php, FragmentActionsTest.php, ServerScreenTest.php, and ServerChromeTest.php.

Verification

  • ./vendor/bin/pint --test passed.
  • ./vendor/bin/pest --compact passed: 964 passed, 1 skipped (4425 assertions).

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.

1 participant