Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/deprecate-dom-receiver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@remote-dom/core': patch
---

Deprecate `DOMRemoteReceiver` and `RemoteReceiverElement`. Use `RemoteReceiver` or a framework-specific receiver instead.
4 changes: 3 additions & 1 deletion packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,8 @@ receiver.get(receiver.root) === receiver.root; // true

#### `DOMRemoteReceiver`

> **Deprecated:** `DOMRemoteReceiver` is no longer recommended for new code. Use `RemoteReceiver` or a framework-specific receiver instead.

`DOMRemoteReceiver` takes care of mapping remote elements to matching HTML elements on the host page. If you implement your UI with [custom elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements), `DOMRemoteReceiver` is a simple option that avoids much of the manual work required when using the basic `RemoteReceiver`.

An empty remote receiver can be created using the `DOMRemoteReceiver` constructor. You’ll then call the `connect()` method with the HTML element that will serve as your “root” element, to which all the synchronized remote elements will be attached:
Expand Down Expand Up @@ -738,7 +740,7 @@ This list is copied at construction, applies case-insensitively to every element

By default, calls on the root are denied. An explicit `call(element, method, ...args)` callback overrides method policy, including for the root. It must enforce its own allowlist and validate arguments; do not forward arbitrary method names to the DOM.

For the `<remote-receiver>` custom element, configure a host-side subclass before registering it:
For the `<remote-receiver>` custom element, configure a host-side subclass before registering it. This API is deprecated; use `RemoteReceiver` or a framework-specific receiver instead for new code.

```ts
import {RemoteReceiverElement} from '@remote-dom/core/elements';
Expand Down
3 changes: 3 additions & 0 deletions packages/core/source/elements/RemoteReceiverElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {
* a `RemoteReceiverElement` and use its `connection` property to connect
* it to a remote environment
*
* @deprecated `RemoteReceiverElement` is no longer recommended. Use `RemoteReceiver`
* or a framework-specific receiver instead.
*
* @example
* ```ts
* import {RemoteReceiverElement} from '@remote-dom/core/elements';
Expand Down
19 changes: 17 additions & 2 deletions packages/core/source/receivers/DOMRemoteReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import type {RemoteReceiverOptions} from './shared.ts';
const REMOTE_PROPERTIES = new WeakMap<Node, Record<string, any>>();
const REMOTE_EVENT_LISTENERS = new WeakMap<Node, Record<string, any>>();

/** Host-owned configuration for a property and its corresponding attribute. */
/**
* Host-owned configuration for a property and its corresponding attribute.
*
* @deprecated `DOMRemoteReceiver` is no longer recommended.
*/
export interface DOMRemotePropertyPolicy {
/** Checks non-nullish property values without coercion. */
readonly type?:
Expand All @@ -29,7 +33,11 @@ export interface DOMRemotePropertyPolicy {
readonly attribute?: string | boolean;
}

/** Host-owned capabilities exposed to the remote for one element name. */
/**
* Host-owned capabilities exposed to the remote for one element name.
*
* @deprecated `DOMRemoteReceiver` is no longer recommended.
*/
export interface DOMRemoteElementPolicy {
readonly properties?: Readonly<Record<string, DOMRemotePropertyPolicy>>;
/** Additional attribute-only names, independent of property definitions. */
Expand All @@ -39,6 +47,10 @@ export interface DOMRemoteElementPolicy {
readonly methods?: readonly string[];
}

/**
* @deprecated `DOMRemoteReceiver` is no longer recommended. Use `RemoteReceiver`
* or a framework-specific receiver instead.
*/
export interface DOMRemoteReceiverOptions extends RemoteReceiverOptions {
/**
* The root element for this receiver. This acts as a shortcut for calling
Expand Down Expand Up @@ -132,6 +144,9 @@ const SCRIPT_URL =
* on the host page. If you implement your UI with [custom elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements),
* `DOMRemoteReceiver` is a simple option that avoids much of the
* manual work required when using the basic `RemoteReceiver`.
*
* @deprecated `DOMRemoteReceiver` is no longer recommended. Use `RemoteReceiver`
* or a framework-specific receiver instead.
*/
export class DOMRemoteReceiver {
/**
Expand Down
Loading