Skip to content

PAM Native 1.40.0

Choose a tag to compare

@DavidWilliamBalbino DavidWilliamBalbino released this 14 Oct 23:49
· 637 commits to main since this release

PAM Native 1.40.0 moves the app plumbing that every production app ends up hand-writing into the SDK: event buses, timers that stop with their screen, rate limiters, bounded caches, optimistic overlays, display formatting, progressive list windows and a durable offline queue. It is a pure PHP release. The Android and iOS hosts, the protocol and the native engines are unchanged from 1.39.4, whose delta hot reload this release includes; only the version moves. Guide: docs/app-infrastructure.md. Example: examples/showcase/src/InfrastructureDemo.php.

Ownership. Disposable, Component::own() and the owner: arguments release subscriptions, timers and rate limiters when a component unmounts. Subscription::from() adapts id-based APIs such as App::onStateChange().

Events. Events\EventBus supports named and typed events, once(), shared buses (emptied on hot reload), a listener bound and error isolation. Events\Observable is a Signal-backed value with change listeners.

Component timers. Component::timers() provides timeout, every, ensure, debounce and throttle.

  • Timers are cancelled on unmount and follow TimerBackgroundPolicy (Suspend, Cancel or Continue).
  • Suspended timers re-arm with the wall-clock time left.
  • Each timer has restart(), onCancel and onFinish hooks and failure handlers.
  • Delays may be longer than a day.

Rate limiting.

  • Scheduling\Debouncer has maxWait, flush, setDelay and markSent.
  • Scheduling\Throttler has leading/trailing calls, rearm: false batching windows, setInterval and markSent.
  • Both accept an injectable scheduler and clock plus failure handlers.
  • Scheduling\SingleFlight joins concurrent callers, supports an again refresh and bounds its keys.

Caches.

  • Cache\BoundedStore is an LRU cache with max items, TTL, a byte budget and account scope. It provides get/peek/put/replace/forget/remember/trim/persist/hydrate.
  • Cache\IdLedger is a bounded id set with TTL.
  • Persistence goes through CachePersistence: StoragePersistence, CallbackPersistence (for Nitro or other stores) or MemoryPersistence. Snapshots are trimmed to the backend's maxValueBytes().
  • Storage\StorageBudget together with Storage::MAX_VALUE_BYTES, KEY_PATTERN and safeKey() handles the native limits: 256 KiB per value and keys matching [A-Za-z0-9_.-]{1,128}.

Optimistic UI. Store\OptimisticOverlay provides begin/settle/rollback/set/apply/applyAll.

  • dropSettled() can drop entries by revision or by age.
  • Listeners fire only when something changes.
  • The LRU never evicts entries that are still in flight.

Formatting. Support\Format provides count, countLabel, compact, relative (Short/Long/Narrow/Tiny), date/dateTime with DateStyle, bytes, duration and time. It covers pt-BR and English without ext-intl. Support\Text provides fold, foldWithMap, contains and length; folding is NFD-equivalent for Latin, Greek and Cyrillic.

Lists. Support\ProgressiveListWindow builds viewport-first windows using row or cost/height budgets. admitLeading handles rows inserted at the top. Deferred rows join on the next frame through a component timer.

Offline queue. Sync\OfflineMutationQueue adds:

  • BackoffPolicy, with base, cap, factor, jitter and maxAttempts.
  • dedupeKey coalescing of unsent intents.
  • stored/failed write callbacks, batch(), clear(), createdAtMs and all($operation).
  • Persistence with hydrate()/persist(). Interrupted sends are restored as Retry.
  • drainOn() triggers: Enqueue, Connectivity, Foreground and RetryDue. They run only while mutations are pending and the app is in the foreground.

Existing calls keep their behaviour.

Validation on candidate 7c5f3502 (rebased on v1.39.4):

  • Full PHP SDK suite, including 148 new 1.40 assertion groups. The performance, visual DOM, navigation and fuzz benchmarks pass, as do the release-workflow contracts and protocol parity.
  • PHPStan level 9 is clean on every new source.
  • 235 Rust tests (80 CLI, 142 engine, 13 protocol); fmt and clippy are clean. The Rust engine and the Android/iOS sources are unchanged from 1.39.4.
  • Exact-candidate native and native-ui community first-run gates on the API 36 emulator (isolated dev port 39102): pam init, pam dev, launch, clean logcat and a PNG capture.
  • The Linux CLI, the Android renderer, the PHP SDK archives and the plugin AAR pass deterministic rebuilds and package budgets.
  • Zé Chat was ported onto these APIs: 23 event buses, 69 timer fields, 9 caches plus the ledger, PostInteractions, about 30 formatters, the offline queue and 14 list windows. All 291 app validators pass.

Known limits:

  • The first community gate attempt for native timed out because the launcher held the foreground (no crash in logcat). A clean rerun passed both surfaces; the evidence is from that run.
  • Only the PHP SDK changes, so Android instrumented and iOS XCTest suites were not rerun.
  • tests/mbstring_polyfill.php differs from the local PHP 8.4.24 ext-mbstring on mb_strrpos with negative offsets. It behaves identically at 1.39.3 and 1.39.4, so this is a host difference, not a 1.40 change.