Commit b3c6f5e
feat(core): add cloneable resource registry for structured clone support
Adds infrastructure for custom JS objects to support structured cloning
via `postMessage`/`MessageChannel`. This enables objects like
`CryptoKey` and `X509Certificate` to be cloned across message ports.
The mechanism works by:
1. Objects set `[core.hostObjectBrand]` to a serializer function that
returns `{ type: "<name>", ...data }`
2. Extensions register a deserializer via
`core.registerCloneableResource(name, deserializerFn)`
3. During deserialization, the registry is consulted to reconstruct
the original object
Changes:
- `libs/core/01_core.js`: Add `registerCloneableResource` /
`getCloneableDeserializers` registry, auto-pass deserializers
in `structuredClone`
- `libs/core/ops_builtin_v8.rs`: Mark `op_deserialize` as reentrant
so deserializer callbacks can invoke ops
- `ext/web/13_message_port.js`: Pass cloneable deserializers during
message deserialization
Ref: #12067
Ref: #12734
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent b31680f commit b3c6f5e
File tree
3 files changed
+18
-2
lines changed- ext/web
- libs/core
3 files changed
+18
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
412 | 418 | | |
413 | 419 | | |
414 | 420 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
683 | 683 | | |
684 | 684 | | |
685 | 685 | | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
686 | 694 | | |
687 | 695 | | |
688 | 696 | | |
| |||
1025 | 1033 | | |
1026 | 1034 | | |
1027 | 1035 | | |
| 1036 | + | |
| 1037 | + | |
1028 | 1038 | | |
1029 | 1039 | | |
1030 | 1040 | | |
1031 | 1041 | | |
1032 | | - | |
| 1042 | + | |
1033 | 1043 | | |
1034 | 1044 | | |
1035 | 1045 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
848 | 848 | | |
849 | 849 | | |
850 | 850 | | |
851 | | - | |
| 851 | + | |
852 | 852 | | |
853 | 853 | | |
854 | 854 | | |
| |||
0 commit comments