Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@remote-ui/core

Package Overview
Dependencies
Maintainers
2
Versions
86
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.21 to 0.0.22

108

build/cjs/root.js

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

makeRemote(component, id, remoteRoot);
props.set(component, initialProps || {});
props.set(component, initialProps !== null && initialProps !== void 0 ? initialProps : {});
children.set(component, []);

@@ -272,14 +272,17 @@ return component;

function _appendChild(container, child) {
var normalizedChild = typeof child === 'string' ? remoteRoot.createText(child) : child;
return perform(container, {
remote: function remote(channel) {
return channel(_types.Action.InsertChild, container.id, container.children.length, serialize(child));
return channel(_types.Action.InsertChild, container.id, container.children.length, serialize(normalizedChild));
},
local: function local() {
var _children$get;
var newTop = container === remoteRoot ? remoteRoot : tops.get(container);
parents.set(child, container);
tops.set(child, newTop);
allDescendants(child, function (descendant) {
parents.set(normalizedChild, container);
tops.set(normalizedChild, newTop);
allDescendants(normalizedChild, function (descendant) {
return tops.set(descendant, newTop);
});
children.set(container, Object.freeze([].concat(_toConsumableArray(children.get(container) || []), [child])));
children.set(container, Object.freeze([].concat(_toConsumableArray((_children$get = children.get(container)) !== null && _children$get !== void 0 ? _children$get : []), [normalizedChild])));
}

@@ -304,3 +307,3 @@ });

local: function local() {
var _children$get;
var _children$get2;

@@ -312,3 +315,3 @@ parents["delete"](child);

var newChildren = _toConsumableArray((_children$get = children.get(container)) !== null && _children$get !== void 0 ? _children$get : []);
var newChildren = _toConsumableArray((_children$get2 = children.get(container)) !== null && _children$get2 !== void 0 ? _children$get2 : []);

@@ -347,3 +350,3 @@ newChildren.splice(newChildren.indexOf(child), 1);

},
configurable: false,
configurable: true,
enumerable: true

@@ -355,3 +358,3 @@ });

},
configurable: false,
configurable: true,
enumerable: true

@@ -379,87 +382,12 @@ });

value: id,
configurable: false,
writable: false
configurable: true,
writable: false,
enumerable: false
});
Reflect.defineProperty(value, 'root', {
value: root,
configurable: false,
configurable: true,
writable: false,
enumerable: false
});
} // type ValidationCollector<Validator extends (...args: any[]) => any> = (
// ...args: Arguments<Validator>
// ) => Exclude<ReturnType<Validator>, undefined>[];
// function createViolationCollector<Validator extends (...args: any[]) => any>(
// validators: Validator | Validator[] = [],
// ): ValidationCollector<Validator> {
// const normalizedValidators = Array.isArray(validators)
// ? validators
// : [validators];
// return (...args) => {
// return normalizedValidators.reduce<
// Exclude<ReturnType<Validator>, undefined>[]
// >((all, validator) => {
// const violation = validator(...args);
// return violation ? [...all, violation] : all;
// }, []);
// };
// }
// export interface RemoteRootValidatorOptions<RemoteComponents extends string> {
// insertRoot?: RemoteRootInsertRootValidator | RemoteRootInsertRootValidator[];
// components?: {
// [RemoteComponent in RemoteComponents]: {
// insert?:
// | RemoteRootInsertChildValidator
// | RemoteRootInsertChildValidator[];
// updateProps?:
// | RemoteRootUpdatePropsValidator<RemoteComponent>
// | RemoteRootUpdatePropsValidator<RemoteComponent>[];
// };
// };
// }
// export class RemoteRootValidator<RemoteComponents extends string> {
// readonly insertRoot: ValidationCollector<RemoteRootInsertRootValidator>;
// private readonly components?: Map<
// RemoteComponents,
// {
// insert: ValidationCollector<RemoteRootInsertChildValidator>;
// updateProps: ValidationCollector<
// RemoteRootUpdatePropsValidator<RemoteComponents>
// >;
// }
// >;
// constructor({
// insertRoot,
// components,
// }: RemoteRootValidatorOptions<RemoteComponents> = {}) {
// this.insertRoot = createViolationCollector(insertRoot);
// this.components =
// components &&
// new Map(
// (Object.entries(components) as [RemoteComponents, any][]).map(
// ([component, {insert, updateProps}]) => [
// component as any,
// {
// insert: createViolationCollector(insert),
// updateProps: createViolationCollector(updateProps),
// },
// ],
// ),
// );
// }
// supports(component: string): component is RemoteComponents {
// return this.components == null
// ? true
// : this.components.has(component as any);
// }
// component(component: string) {
// if (!this.supports(component)) {
// throw new Error(
// `Can’t access component config for unsupported ${component} component`,
// );
// }
// return this.components
// ? this.components.get(component)
// : {insert: () => [], updateProps: () => []};
// }
// }
}

@@ -39,3 +39,5 @@ "use strict";

// Just satisfying the type definition, since we need to write
// some properties manually.
// some properties manually, which we do below. If we just `as any`
// the whole object, we lose the implicit argument types for the
// methods above.
...{}

@@ -51,3 +53,3 @@ };

makeRemote(component, id, remoteRoot);
props.set(component, initialProps || {});
props.set(component, initialProps !== null && initialProps !== void 0 ? initialProps : {});
children.set(component, []);

@@ -145,10 +147,13 @@ return component;

function appendChild(container, child) {
const normalizedChild = typeof child === 'string' ? remoteRoot.createText(child) : child;
return perform(container, {
remote: channel => channel(_types.Action.InsertChild, container.id, container.children.length, serialize(child)),
remote: channel => channel(_types.Action.InsertChild, container.id, container.children.length, serialize(normalizedChild)),
local: () => {
var _children$get;
const newTop = container === remoteRoot ? remoteRoot : tops.get(container);
parents.set(child, container);
tops.set(child, newTop);
allDescendants(child, descendant => tops.set(descendant, newTop));
children.set(container, Object.freeze([...(children.get(container) || []), child]));
parents.set(normalizedChild, container);
tops.set(normalizedChild, newTop);
allDescendants(normalizedChild, descendant => tops.set(descendant, newTop));
children.set(container, Object.freeze([...((_children$get = children.get(container)) !== null && _children$get !== void 0 ? _children$get : []), normalizedChild]));
}

@@ -171,7 +176,7 @@ });

local: () => {
var _children$get;
var _children$get2;
parents.delete(child);
allDescendants(child, descendant => tops.set(descendant, child));
const newChildren = [...((_children$get = children.get(container)) !== null && _children$get !== void 0 ? _children$get : [])];
const newChildren = [...((_children$get2 = children.get(container)) !== null && _children$get2 !== void 0 ? _children$get2 : [])];
newChildren.splice(newChildren.indexOf(child), 1);

@@ -204,3 +209,3 @@ children.set(container, Object.freeze(newChildren));

configurable: false,
configurable: true,
enumerable: true

@@ -213,3 +218,3 @@ });

configurable: false,
configurable: true,
enumerable: true

@@ -235,87 +240,12 @@ });

value: id,
configurable: false,
writable: false
configurable: true,
writable: false,
enumerable: false
});
Reflect.defineProperty(value, 'root', {
value: root,
configurable: false,
configurable: true,
writable: false,
enumerable: false
});
} // type ValidationCollector<Validator extends (...args: any[]) => any> = (
// ...args: Arguments<Validator>
// ) => Exclude<ReturnType<Validator>, undefined>[];
// function createViolationCollector<Validator extends (...args: any[]) => any>(
// validators: Validator | Validator[] = [],
// ): ValidationCollector<Validator> {
// const normalizedValidators = Array.isArray(validators)
// ? validators
// : [validators];
// return (...args) => {
// return normalizedValidators.reduce<
// Exclude<ReturnType<Validator>, undefined>[]
// >((all, validator) => {
// const violation = validator(...args);
// return violation ? [...all, violation] : all;
// }, []);
// };
// }
// export interface RemoteRootValidatorOptions<RemoteComponents extends string> {
// insertRoot?: RemoteRootInsertRootValidator | RemoteRootInsertRootValidator[];
// components?: {
// [RemoteComponent in RemoteComponents]: {
// insert?:
// | RemoteRootInsertChildValidator
// | RemoteRootInsertChildValidator[];
// updateProps?:
// | RemoteRootUpdatePropsValidator<RemoteComponent>
// | RemoteRootUpdatePropsValidator<RemoteComponent>[];
// };
// };
// }
// export class RemoteRootValidator<RemoteComponents extends string> {
// readonly insertRoot: ValidationCollector<RemoteRootInsertRootValidator>;
// private readonly components?: Map<
// RemoteComponents,
// {
// insert: ValidationCollector<RemoteRootInsertChildValidator>;
// updateProps: ValidationCollector<
// RemoteRootUpdatePropsValidator<RemoteComponents>
// >;
// }
// >;
// constructor({
// insertRoot,
// components,
// }: RemoteRootValidatorOptions<RemoteComponents> = {}) {
// this.insertRoot = createViolationCollector(insertRoot);
// this.components =
// components &&
// new Map(
// (Object.entries(components) as [RemoteComponents, any][]).map(
// ([component, {insert, updateProps}]) => [
// component as any,
// {
// insert: createViolationCollector(insert),
// updateProps: createViolationCollector(updateProps),
// },
// ],
// ),
// );
// }
// supports(component: string): component is RemoteComponents {
// return this.components == null
// ? true
// : this.components.has(component as any);
// }
// component(component: string) {
// if (!this.supports(component)) {
// throw new Error(
// `Can’t access component config for unsupported ${component} component`,
// );
// }
// return this.components
// ? this.components.get(component)
// : {insert: () => [], updateProps: () => []};
// }
// }
}

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

makeRemote(component, id, remoteRoot);
props.set(component, initialProps || {});
props.set(component, initialProps !== null && initialProps !== void 0 ? initialProps : {});
children.set(component, []);

@@ -103,10 +103,12 @@ return component;

function appendChild(container, child) {
const normalizedChild = typeof child === 'string' ? remoteRoot.createText(child) : child;
return perform(container, {
remote: (channel) => channel(types_1.Action.InsertChild, container.id, container.children.length, serialize(child)),
remote: (channel) => channel(types_1.Action.InsertChild, container.id, container.children.length, serialize(normalizedChild)),
local: () => {
var _a;
const newTop = container === remoteRoot ? remoteRoot : tops.get(container);
parents.set(child, container);
tops.set(child, newTop);
allDescendants(child, (descendant) => tops.set(descendant, newTop));
children.set(container, Object.freeze([...(children.get(container) || []), child]));
parents.set(normalizedChild, container);
tops.set(normalizedChild, newTop);
allDescendants(normalizedChild, (descendant) => tops.set(descendant, newTop));
children.set(container, Object.freeze([...((_a = children.get(container)) !== null && _a !== void 0 ? _a : []), normalizedChild]));
},

@@ -156,3 +158,3 @@ });

},
configurable: false,
configurable: true,
enumerable: true,

@@ -164,3 +166,3 @@ });

},
configurable: false,
configurable: true,
enumerable: true,

@@ -184,8 +186,9 @@ });

value: id,
configurable: false,
configurable: true,
writable: false,
enumerable: false,
});
Reflect.defineProperty(value, 'root', {
value: root,
configurable: false,
configurable: true,
writable: false,

@@ -195,78 +198,1 @@ enumerable: false,

}
// type ValidationCollector<Validator extends (...args: any[]) => any> = (
// ...args: Arguments<Validator>
// ) => Exclude<ReturnType<Validator>, undefined>[];
// function createViolationCollector<Validator extends (...args: any[]) => any>(
// validators: Validator | Validator[] = [],
// ): ValidationCollector<Validator> {
// const normalizedValidators = Array.isArray(validators)
// ? validators
// : [validators];
// return (...args) => {
// return normalizedValidators.reduce<
// Exclude<ReturnType<Validator>, undefined>[]
// >((all, validator) => {
// const violation = validator(...args);
// return violation ? [...all, violation] : all;
// }, []);
// };
// }
// export interface RemoteRootValidatorOptions<RemoteComponents extends string> {
// insertRoot?: RemoteRootInsertRootValidator | RemoteRootInsertRootValidator[];
// components?: {
// [RemoteComponent in RemoteComponents]: {
// insert?:
// | RemoteRootInsertChildValidator
// | RemoteRootInsertChildValidator[];
// updateProps?:
// | RemoteRootUpdatePropsValidator<RemoteComponent>
// | RemoteRootUpdatePropsValidator<RemoteComponent>[];
// };
// };
// }
// export class RemoteRootValidator<RemoteComponents extends string> {
// readonly insertRoot: ValidationCollector<RemoteRootInsertRootValidator>;
// private readonly components?: Map<
// RemoteComponents,
// {
// insert: ValidationCollector<RemoteRootInsertChildValidator>;
// updateProps: ValidationCollector<
// RemoteRootUpdatePropsValidator<RemoteComponents>
// >;
// }
// >;
// constructor({
// insertRoot,
// components,
// }: RemoteRootValidatorOptions<RemoteComponents> = {}) {
// this.insertRoot = createViolationCollector(insertRoot);
// this.components =
// components &&
// new Map(
// (Object.entries(components) as [RemoteComponents, any][]).map(
// ([component, {insert, updateProps}]) => [
// component as any,
// {
// insert: createViolationCollector(insert),
// updateProps: createViolationCollector(updateProps),
// },
// ],
// ),
// );
// }
// supports(component: string): component is RemoteComponents {
// return this.components == null
// ? true
// : this.components.has(component as any);
// }
// component(component: string) {
// if (!this.supports(component)) {
// throw new Error(
// `Can’t access component config for unsupported ${component} component`,
// );
// }
// return this.components
// ? this.components.get(component)
// : {insert: () => [], updateProps: () => []};
// }
// }

7

build/ts/types.d.ts

@@ -36,6 +36,7 @@ import { RemoteComponentType, PropsForRemoteComponent } from '@remote-ui/types';

declare type ExtractChildren<Type> = Type extends RemoteComponentType<infer Children, any> ? Children : never;
declare type AllowedChildren<Children extends RemoteComponentType<any, any> | boolean, Root extends RemoteRoot<any, any>> = Children extends true ? RemoteComponent<any, Root> | RemoteText<Root> : Children extends false ? never : AllowedRemoteChildren<Children, Root> | RemoteText<Root>;
declare type AllowedChildren<Children extends RemoteComponentType<any, any> | boolean, Root extends RemoteRoot<any, any>, AllowString extends boolean = false> = Children extends true ? RemoteComponent<any, Root> | AllowedTextChildren<Root, AllowString> : Children extends false ? never : AllowedRemoteChildren<Children, Root> | AllowedTextChildren<Root, AllowString>;
declare type AllowedTextChildren<Root extends RemoteRoot<any, any>, AllowString extends boolean = false> = AllowString extends true ? RemoteText<Root> | string : RemoteText<Root>;
export interface RemoteRoot<AllowedComponents extends RemoteComponentType<any, any> = RemoteComponentType<any, any>, AllowedChildrenTypes extends RemoteComponentType<any, any> | boolean = true> {
readonly children: readonly AllowedChildren<AllowedChildrenTypes, RemoteRoot<AllowedComponents, AllowedChildrenTypes>>[];
appendChild(child: AllowedChildren<AllowedChildrenTypes, RemoteRoot<AllowedComponents, AllowedChildrenTypes>>): void | Promise<void>;
appendChild(child: AllowedChildren<AllowedChildrenTypes, RemoteRoot<AllowedComponents, AllowedChildrenTypes>, true>): void | Promise<void>;
removeChild(child: AllowedChildren<AllowedChildrenTypes, RemoteRoot<AllowedComponents, AllowedChildrenTypes>>): void | Promise<void>;

@@ -56,3 +57,3 @@ insertChildBefore(child: AllowedChildren<AllowedChildrenTypes, RemoteRoot<AllowedComponents, AllowedChildrenTypes>>, before: AllowedChildren<AllowedChildrenTypes, RemoteRoot<AllowedComponents, AllowedChildrenTypes>>): void | Promise<void>;

updateProps(props: Partial<PropsForRemoteComponent<Type>>): void | Promise<void>;
appendChild(child: AllowedChildren<ExtractChildren<Type>, Root>): void | Promise<void>;
appendChild(child: AllowedChildren<ExtractChildren<Type>, Root, true>): void | Promise<void>;
removeChild(child: AllowedChildren<ExtractChildren<Type>, Root>): void | Promise<void>;

@@ -59,0 +60,0 @@ insertChildBefore(child: AllowedChildren<ExtractChildren<Type>, Root>, before: AllowedChildren<ExtractChildren<Type>, Root>): void | Promise<void>;

{
"name": "@remote-ui/core",
"version": "0.0.21",
"version": "0.0.22",
"publishConfig": {

@@ -13,3 +13,3 @@ "access": "public",

},
"gitHead": "95211c6df63af9f4b3aa59b2773e5284ea77e277"
"gitHead": "ffa1d7735432c06b09d61e74813d3ca8faa0720c"
}

@@ -9,5 +9,2 @@ import {RemoteComponentType} from '@remote-ui/types';

RemoteComponent,
// RemoteComponentInsertChildViolation,
// RemoteComponentInsertRootViolation,
// RemoteComponentUpdatePropsViolation,
} from './types';

@@ -55,3 +52,3 @@

get children() {
return children.get(component as any) as any;
return children.get(component);
},

@@ -62,8 +59,10 @@ get props() {

updateProps: (newProps) => updateProps(component, newProps),
appendChild: (child) => appendChild(component, child as any),
removeChild: (child) => removeChild(component, child as any),
appendChild: (child) => appendChild(component, child),
removeChild: (child) => removeChild(component, child),
insertChildBefore: (child, before) =>
insertChildBefore(component, child as any, before as any),
insertChildBefore(component, child, before),
// Just satisfying the type definition, since we need to write
// some properties manually.
// some properties manually, which we do below. If we just `as any`
// the whole object, we lose the implicit argument types for the
// methods above.
...({} as any),

@@ -81,3 +80,3 @@ };

makeRemote(component, id, remoteRoot);
props.set(component, initialProps || ({} as any));
props.set(component, initialProps ?? ({} as any));
children.set(component, []);

@@ -130,4 +129,4 @@

for (const child of element.children) {
withEach(child as any);
recurse(child as any);
withEach(child);
recurse(child);
}

@@ -189,3 +188,6 @@ }

function appendChild(container: HasChildren, child: CanBeChild) {
function appendChild(container: HasChildren, child: CanBeChild | string) {
const normalizedChild =
typeof child === 'string' ? remoteRoot.createText(child) : child;
return perform(container, {

@@ -197,3 +199,3 @@ remote: (channel) =>

container.children.length,
serialize(child),
serialize(normalizedChild),
),

@@ -204,9 +206,11 @@ local: () => {

parents.set(child, container);
tops.set(child, newTop);
allDescendants(child, (descendant) => tops.set(descendant, newTop));
parents.set(normalizedChild, container);
tops.set(normalizedChild, newTop);
allDescendants(normalizedChild, (descendant) =>
tops.set(descendant, newTop),
);
children.set(
container,
Object.freeze([...(children.get(container) || []), child]),
Object.freeze([...(children.get(container) ?? []), normalizedChild]),
);

@@ -280,3 +284,3 @@ },

},
configurable: false,
configurable: true,
enumerable: true,

@@ -289,3 +293,3 @@ });

},
configurable: false,
configurable: true,
enumerable: true,

@@ -314,4 +318,5 @@ });

value: id,
configurable: false,
configurable: true,
writable: false,
enumerable: false,
});

@@ -321,3 +326,3 @@

value: root,
configurable: false,
configurable: true,
writable: false,

@@ -327,87 +332,1 @@ enumerable: false,

}
// type ValidationCollector<Validator extends (...args: any[]) => any> = (
// ...args: Arguments<Validator>
// ) => Exclude<ReturnType<Validator>, undefined>[];
// function createViolationCollector<Validator extends (...args: any[]) => any>(
// validators: Validator | Validator[] = [],
// ): ValidationCollector<Validator> {
// const normalizedValidators = Array.isArray(validators)
// ? validators
// : [validators];
// return (...args) => {
// return normalizedValidators.reduce<
// Exclude<ReturnType<Validator>, undefined>[]
// >((all, validator) => {
// const violation = validator(...args);
// return violation ? [...all, violation] : all;
// }, []);
// };
// }
// export interface RemoteRootValidatorOptions<RemoteComponents extends string> {
// insertRoot?: RemoteRootInsertRootValidator | RemoteRootInsertRootValidator[];
// components?: {
// [RemoteComponent in RemoteComponents]: {
// insert?:
// | RemoteRootInsertChildValidator
// | RemoteRootInsertChildValidator[];
// updateProps?:
// | RemoteRootUpdatePropsValidator<RemoteComponent>
// | RemoteRootUpdatePropsValidator<RemoteComponent>[];
// };
// };
// }
// export class RemoteRootValidator<RemoteComponents extends string> {
// readonly insertRoot: ValidationCollector<RemoteRootInsertRootValidator>;
// private readonly components?: Map<
// RemoteComponents,
// {
// insert: ValidationCollector<RemoteRootInsertChildValidator>;
// updateProps: ValidationCollector<
// RemoteRootUpdatePropsValidator<RemoteComponents>
// >;
// }
// >;
// constructor({
// insertRoot,
// components,
// }: RemoteRootValidatorOptions<RemoteComponents> = {}) {
// this.insertRoot = createViolationCollector(insertRoot);
// this.components =
// components &&
// new Map(
// (Object.entries(components) as [RemoteComponents, any][]).map(
// ([component, {insert, updateProps}]) => [
// component as any,
// {
// insert: createViolationCollector(insert),
// updateProps: createViolationCollector(updateProps),
// },
// ],
// ),
// );
// }
// supports(component: string): component is RemoteComponents {
// return this.components == null
// ? true
// : this.components.has(component as any);
// }
// component(component: string) {
// if (!this.supports(component)) {
// throw new Error(
// `Can’t access component config for unsupported ${component} component`,
// );
// }
// return this.components
// ? this.components.get(component)
// : {insert: () => [], updateProps: () => []};
// }
// }

@@ -65,9 +65,17 @@ import {RemoteComponentType, PropsForRemoteComponent} from '@remote-ui/types';

Children extends RemoteComponentType<any, any> | boolean,
Root extends RemoteRoot<any, any>
Root extends RemoteRoot<any, any>,
AllowString extends boolean = false
> = Children extends true
? RemoteComponent<any, Root> | RemoteText<Root>
? RemoteComponent<any, Root> | AllowedTextChildren<Root, AllowString>
: Children extends false
? never
: AllowedRemoteChildren<Children, Root> | RemoteText<Root>;
:
| AllowedRemoteChildren<Children, Root>
| AllowedTextChildren<Root, AllowString>;
type AllowedTextChildren<
Root extends RemoteRoot<any, any>,
AllowString extends boolean = false
> = AllowString extends true ? RemoteText<Root> | string : RemoteText<Root>;
export interface RemoteRoot<

@@ -87,3 +95,4 @@ AllowedComponents extends RemoteComponentType<any, any> = RemoteComponentType<

AllowedChildrenTypes,
RemoteRoot<AllowedComponents, AllowedChildrenTypes>
RemoteRoot<AllowedComponents, AllowedChildrenTypes>,
true
>,

@@ -136,3 +145,3 @@ ): void | Promise<void>;

appendChild(
child: AllowedChildren<ExtractChildren<Type>, Root>,
child: AllowedChildren<ExtractChildren<Type>, Root, true>,
): void | Promise<void>;

@@ -139,0 +148,0 @@ removeChild(

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

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