Skip to content

Add guard-clause style to CLAUDE.md (#2135) - #2135

Open
tmikov wants to merge 10 commits into
facebook:static_hfrom
tmikov:export-D114548566
Open

tmikov wants to merge 10 commits into
facebook:static_hfrom
tmikov:export-D114548566

Conversation

@tmikov

@tmikov tmikov commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Add a Code Style convention recommending condition-scoped variable
declarations with an early return (if (auto *x = expr()) ...) over
intermediate nullable locals and ternary chains, matching the
LLVM/Hermes idiom already used in the codebase.

Reviewed By: avp

Differential Revision: D114548566

tmikov added 9 commits August 2, 2026 17:56
Summary:
Add the design spec and the task-by-task implementation plan for
extending the Worker constructor to accept a URL, loaded via an
integrator-provided IWorkerSetup (jsi::ICast-based for
ABI-stable extension) that resolves a URL to a jsi::Buffer of script
bytes (bytecode or source), enabling zero-copy / memory-mapped native
loading, plus hooks to configure the worker RuntimeConfig and run
one-time JS setup in the worker runtime. Also covers string-vs-URL
classification with {inline} and opt-in {allowData} data: URL
decoding, URL-object ToString coercion, and the relationship to the
standard Blob/createObjectURL web idiom (host-level, composed on top of
the resolver). Documentation only.

Differential Revision: D114087763
Summary:
Add IWorkerSetup and ISetWorkerSetup to
hermes-interfaces.h (an ICast-based setter with a
getWorkerSetup accessor), and wire HermesRuntimeImpl to store
the integrator's opaque provider pointer and expose it via that getter.
Give the APITest provider harness a virtual destructor and mark a
not-yet-used helper [[maybe_unused]] so the build is warning-free.

Differential Revision: D114374137
Summary:
Classify a Worker string argument as a URL when a provider is
registered (unless {inline:true}); resolve it to a jsi::Buffer on the
worker thread, run the init hook, then evaluate. Propagate the provider
to nested worker runtimes. Drop a misleading zero-copy assertion from
the bytecode test.

Differential Revision: D114374130
Summary:
Seed a default RuntimeConfig and let the provider adjust it in
place before creating the worker runtime.

Differential Revision: D114374132
Summary:
Match the web USVString coercion: a non-buffer object argument (e.g.
an RN URL) is stringified via ToString and classified as a string.
Non-string, non-object primitives still throw TypeError.

Differential Revision: D114374133
Summary:
With {allowData:true}, natively decode a data: URL (percent or base64)
into worker script bytes on the constructor thread, taking precedence
over the resolver and source. Malformed data: URLs throw TypeError.
Unify string classification via a sourceFromString helper.

Differential Revision: D114374134
Summary:
new Worker({}) now coerces to string source instead of throwing, per
the object ToString coercion change. Drop the stale object-throws
assertion from worker-from-buffer.js.

Differential Revision: D114374136
Summary:
Catch non-JSI C++ exceptions from resolveScript/initWorkerRuntime so a
throwing integrator resolver terminates the worker instead of aborting
the process. Make WorkerFromUrlBytecode assert the resolver buffer is
retained then released. Document that a blocking resolver blocks worker
teardown (both hermes-interfaces.h copies).

Differential Revision: D114374131
Summary:
hermes::base64Decode now strips ASCII whitespace (WHATWG forgiving
base64) and returns empty output for empty input instead of indexing
out of bounds. This makes data: URL decoding (worker scripts and source
maps via parseJSONBase64DataURL) spec-compliant and fixes a crash on an
empty base64 payload such as data:application/json;base64,.

Differential Revision: D114374135
@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Aug 15, 2026
@meta-codesync

meta-codesync Bot commented Aug 15, 2026

Copy link
Copy Markdown

@tmikov has exported this pull request. If you are a Meta employee, you can view the originating Diff in D114548566.

Summary:
Pull Request resolved: facebook#2135

Add a Code Style convention recommending condition-scoped variable
declarations with an early return (if (auto *x = expr()) ...) over
intermediate nullable locals and ternary chains, matching the
LLVM/Hermes idiom already used in the codebase.

Reviewed By: avp

Differential Revision: D114548566
@tmikov
tmikov force-pushed the export-D114548566 branch from 9416aee to 7a830c6 Compare August 15, 2026 19:06
@meta-codesync meta-codesync Bot changed the title Add guard-clause style to CLAUDE.md Add guard-clause style to CLAUDE.md (#2135) Aug 15, 2026

This branch was previously deployed

1 inactive deployment
npm-publish — 7a830c6d Deployed Aug 15, 2026 by tmikov via publish #1379
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants