New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@remote-ui/core

Package Overview
Dependencies
Maintainers
2
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@remote-ui/core - npm Package Compare versions

Comparing version 0.0.30-alpha.0 to 0.0.30

LICENSE.md

4

build/cjs/receiver.js

@@ -86,3 +86,3 @@ "use strict";

function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }

@@ -217,3 +217,3 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

var props = _objectSpread({}, component.props, {}, newProps);
var props = _objectSpread(_objectSpread({}, component.props), newProps);

@@ -220,0 +220,0 @@ component.props = props; // eslint-disable-next-line promise/catch-or-return

@@ -66,4 +66,2 @@ "use strict";

require("regenerator-runtime/runtime");
var _types = require("./types");

@@ -79,3 +77,3 @@

function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }

@@ -86,6 +84,2 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

@@ -203,17 +197,3 @@

mount: function mount() {
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return channel(_types.ACTION_MOUNT, children.get(remoteRoot).map(serialize));
case 2:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
return Promise.resolve(channel(_types.ACTION_MOUNT, children.get(remoteRoot).map(serialize)));
}

@@ -292,3 +272,3 @@ };

local: function local() {
props.set(component, Object.freeze(_objectSpread({}, props.get(component), {}, newProps)));
props.set(component, Object.freeze(_objectSpread(_objectSpread({}, props.get(component)), newProps)));
}

@@ -295,0 +275,0 @@ });

@@ -101,4 +101,4 @@ "use strict";

async mount() {
await channel(_types.ACTION_MOUNT, children.get(remoteRoot).map(serialize));
mount() {
return Promise.resolve(channel(_types.ACTION_MOUNT, children.get(remoteRoot).map(serialize)));
}

@@ -105,0 +105,0 @@

@@ -67,4 +67,4 @@ "use strict";

insertChildBefore: (child, before) => insertChildBefore(remoteRoot, child, before),
async mount() {
await channel(types_1.ACTION_MOUNT, children.get(remoteRoot).map(serialize));
mount() {
return Promise.resolve(channel(types_1.ACTION_MOUNT, children.get(remoteRoot).map(serialize)));
},

@@ -71,0 +71,0 @@ };

{
"name": "@remote-ui/core",
"version": "0.0.30-alpha.0",
"version": "0.0.30",
"publishConfig": {

@@ -9,7 +9,8 @@ "access": "public",

"license": "MIT",
"sideEffects": false,
"dependencies": {
"@remote-ui/rpc": "^0.0.11-alpha.0",
"@remote-ui/types": "^0.0.8"
"@remote-ui/rpc": "^0.0.11",
"@remote-ui/types": "^0.0.9"
},
"gitHead": "b5226d46807aa50774447d3d9d710739b377f5b1"
"gitHead": "38ab5544914dc588ea275bcaa54ed9f2d9de61d8"
}
# `@remote-ui/core`
This library provides the core model for implementing a remote representation of a UI, and for signalling operations on that representation to another context via a small message channel. For a full overview of how `@remote-ui/core` fits in to the different pieces of Remote UI, you can refer to our [comprehensive example](../../README.md#example).
This library provides the core model for implementing a remote representation of a UI, and for signalling operations on that representation to another context via a message channel. For a full overview of how `@remote-ui/core` fits in to the different pieces of remote-ui, you can refer to our [comprehensive example](../../documentation/comprehensive-example.md).

@@ -19,5 +19,9 @@ ## Installation

## Prerequisites
`@remote-ui/core` uses JavaScript’s native `Map`, `Set`, and `WeakSet`. It also uses numerous language constructs that require the `Symbol` global. Polyfills for these features (via [`core-js`](https://github.com/zloirock/core-js)) are imported automatically with the “default” version of this package. If you have a build system that is smart about adding polyfills, you can configure it to [prefer (and process) a special build meant to minimize polyfills](../documentation/guides/polyfills.md).
## Usage
`@remote-ui/core` provides two main exports. You’ll use [`RemoteRoot`](#createremoteroot) in the remote environment to construct a tree for attaching UI components, and [`RemoteReceiver`](#remotereceiver) on the host to react to changes in the remote root.
`@remote-ui/core` provides two main exports. You’ll use [`createRemoteRoot`](#createremoteroot) in the remote environment to construct a tree for attaching UI components, and [`RemoteReceiver`](#remotereceiver) on the host to react to changes in the remote root.

@@ -30,3 +34,3 @@ ### `createRemoteRoot()`

- `channel` is a `RemoteChannel`, which is just a function that will be called with serialized representation of UI updates. [`RemoteReceiver#receive`](#remotereceiverreceive) is one such function, and most uses of Remote UI will just pass that function here.
- `channel` is a `RemoteChannel`, which is just a function that will be called with serialized representation of UI updates. [`RemoteReceiver#receive`](#remotereceiverreceive) is one such function, and most uses of remote-ui will just pass that function here.
- `options` is an optional options object. There is currently one supported option: `components`. This value is the list of components that can be constructed and attached to this root. This is necessary because, by default, this library does not supply any components to render; you are responsible for implementing a component API that makes sense for your use case.

@@ -37,5 +41,5 @@

const {receive} = new RemoteReceiver();
const receiver = new RemoteReceiver();
const root = createRemoteRoot(receive, {
const root = createRemoteRoot(receiver.receive, {
components: ['Button', 'TextField', 'Card'],

@@ -198,3 +202,3 @@ });

if (LOCALE === 'fr') {
text.setText('Bonjour');
text.updateText('Bonjour');
}

@@ -304,30 +308,2 @@ ```

This package exports a variety of helper types for easy access in more complex use cases, including some types representing the wire format Remote UI uses to communicate component tree updates. It also re-exports the `retain` and `release` methods from `@remote-ui/rpc` for easy access. Finally, it provides some types that may be useful for you to describe the different objects in Remote UI in your application:
- `RemoteComponentType` represents the components created by `createRemoteComponent`. This type has the prop types and allowed children embedded in its type.
- `PropsForRemoteComponent` accepts a `RemoteComponentType` as a type argument, and returns the type of the props for that component.
```ts
import {
createRemoteComponent,
PropsForRemoteComponent,
} from '@remote-ui/core';
const Button = createRemoteComponent<'Button', {onPress?(): void}>('Button');
type ButtonProps = PropsForRemoteComponent<typeof Button>; // {onPress?(): void}
```
- `AllowedChildrenForRemoteComponent` accepts a `RemoteComponentType` as a type argument, and returns the types of the components allowed to be direct children of that component.
```ts
import {
createRemoteComponent,
AllowedChildrenForRemoteComponent,
} from '@remote-ui/core';
const Button = createRemoteComponent<'Button', {onPress?(): void}>('Button');
const ButtonGroup = createRemoteComponent<'ButtonGroup', {}, typeof Button>(
'ButtonGroup',
);
type ButtonChildren = AllowedChildrenForRemoteComponent<typeof ButtonGroup>; // Button
```
This package exports a variety of helper types for easy access in more complex use cases, including some types representing the wire format remote-ui uses to communicate component tree updates. It also re-exports the [`retain` and `release` methods from `@remote-ui/rpc`](../rpc), and the [helper TypeScript types from `@remote-ui/types`](../types), for easy access.

@@ -133,4 +133,6 @@ import {RemoteComponentType} from '@remote-ui/types';

insertChildBefore(remoteRoot, child, before),
async mount() {
await channel(ACTION_MOUNT, children.get(remoteRoot)!.map(serialize));
mount() {
return Promise.resolve(
channel(ACTION_MOUNT, children.get(remoteRoot)!.map(serialize)),
);
},

@@ -137,0 +139,0 @@ };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc