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

aurumjs

Package Overview
Dependencies
Maintainers
1
Versions
244
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aurumjs - npm Package Compare versions

Comparing version 0.9.27 to 0.9.28

2

package.json
{
"name": "aurumjs",
"version": "0.9.27",
"version": "0.9.28",
"main": "prebuilt/esnext/aurumjs.js",

@@ -5,0 +5,0 @@ "type": "module",

@@ -148,3 +148,3 @@ import { CancellationToken } from '../utilities/cancellation_token.js';

}));
}, CancellationToken.fromMultiple([cancellation, this.masterToken]));
}, cancellation.or(this.masterToken));
}

@@ -151,0 +151,0 @@ syncSource(cancellation, id, authenticationToken, source, syncedSources, listenMessage, cancelMessage) {

@@ -33,5 +33,4 @@ export * from './rendering/webcomponent.js';

export * from './decorators/attach_notifier.js';
export { debugMode, enableDebugMode } from './debug_mode.js';
export { AttributeValue, ClassType, StyleType, DataDrain, StringSource } from './utilities/common.js';
export { RemoteProtocol, getRemoteFunction } from './aurum_server/aurum_server_client.js';
//# sourceMappingURL=aurumjs.d.ts.map

@@ -29,4 +29,3 @@ export * from './rendering/webcomponent.js';

export * from './decorators/attach_notifier.js';
export { debugMode, enableDebugMode } from './debug_mode.js';
export { RemoteProtocol, getRemoteFunction } from './aurum_server/aurum_server_client.js';
//# sourceMappingURL=aurumjs.js.map
import { AurumComponentAPI, Renderable } from '../rendering/aurum_element.js';
import { DataSource } from '../stream/data_source.js';
export declare function AurumRouter(props: {}, children: Renderable[], api: AurumComponentAPI): DataSource<Renderable[]>;
export declare function AurumRouter(props: {
hashRouting?: boolean;
}, children: Renderable[], api: AurumComponentAPI): DataSource<Renderable[]>;
export interface RouteProps {

@@ -5,0 +7,0 @@ href: string;

@@ -27,3 +27,17 @@ import { DataSource } from '../stream/data_source.js';

if (typeof window !== 'undefined') {
urlHashEmitter(urlDataSource, true, api.cancellationToken);
if (props.hashRouting) {
urlHashEmitter(urlDataSource, true, api.cancellationToken);
}
else {
urlDataSource.update(window.location.pathname);
window.addEventListener('popstate', () => {
urlDataSource.update(window.location.pathname);
});
window.addEventListener('pushstate', () => {
urlDataSource.update(window.location.pathname);
});
window.addEventListener('replacestate', () => {
urlDataSource.update(window.location.pathname);
});
}
}

@@ -30,0 +44,0 @@ const activeRoute = new DataSource();

@@ -42,3 +42,3 @@ import { DomNodeCreator } from '../rendering/renderers/dom_adapter.js';

const input = node;
if (props.value) {
if (props?.value) {
if (props.value instanceof DataSource) {

@@ -64,3 +64,3 @@ props.value.listenAndRepeat((v) => {

}
if (props.checked) {
if (props?.checked) {
if (props.checked instanceof DataSource) {

@@ -67,0 +67,0 @@ props.checked.listenAndRepeat((v) => {

@@ -26,3 +26,3 @@ import { DataSource } from '../stream/data_source.js';

}
if (props.selectedIndex instanceof DataSource || props.selectedIndex instanceof DuplexDataSource) {
if (props?.selectedIndex instanceof DataSource || props?.selectedIndex instanceof DuplexDataSource) {
const mo = new MutationObserver(() => {

@@ -38,3 +38,3 @@ select.selectedIndex = props.selectedIndex.value;

}
if (props.value instanceof DataSource) {
if (props?.value instanceof DataSource) {
props.value.listenAndRepeat((v) => {

@@ -47,3 +47,3 @@ select.value = v;

}
else if (props.value instanceof DuplexDataSource) {
else if (props?.value instanceof DuplexDataSource) {
props.value.listenAndRepeat((v) => {

@@ -50,0 +50,0 @@ select.value = v;

@@ -34,3 +34,3 @@ import { DataSource } from '../stream/data_source.js';

const textArea = node;
if (props.value) {
if (props?.value) {
if (props.value instanceof DataSource) {

@@ -37,0 +37,0 @@ props.value.listenAndRepeat((v) => {

@@ -30,3 +30,2 @@ import { CancellationToken } from '../utilities/cancellation_token.js';

}
return v;
}

@@ -587,3 +586,2 @@ };

}
return v;
}

@@ -606,3 +604,2 @@ };

}
return v;
}

@@ -627,3 +624,2 @@ };

}
return v;
}

@@ -646,3 +642,2 @@ };

amount++;
return v;
}

@@ -660,3 +655,2 @@ };

cb(v);
return v;
}

@@ -684,3 +678,2 @@ };

}
return v;
}

@@ -698,3 +691,2 @@ };

console.log(`${prefix}${v}${suffix}`);
return v;
}

@@ -716,3 +708,2 @@ };

});
return v;
}

@@ -719,0 +710,0 @@ };

@@ -135,2 +135,27 @@ import { AurumServerInfo } from '../aurum_server/aurum_server_client.js';

/**
* Creates a new `DataSource` from a callback function.
* The callback function is expected to take an `update` function as a parameter,
* which can be used to update the value of the `DataSource`.
* This is useful to create a `DataSource` that is updated with an event such as a button click.
* @example ```typescript
* const buttonClicks = DataSource.fromCallback((update) => {
* button.addEventListener('click', update);
* });
* ```
*
* @template T - The type of the value emitted by the `DataSource`.
* @param callback - The callback function that provides the `update` function.
* @param cancellation - The cancellation token used to cancel the `DataSource`.
* @returns A new `DataSource` instance.
*/
static fromCallback<T>(callback: (update: (value: T) => void, token: CancellationToken) => void, cancellation: CancellationToken): DataSource<T>;
static fromDomEvent<T extends Event>(element: {
addEventListener: (event: string, cb: (e: T) => void) => void;
removeEventListener: (event: string, cb: (e: T) => void) => void;
}, event: string, cancellation: CancellationToken): DataSource<T>;
static fromNodeJsEvent<T>(emitter: {
on(event: string, listener: (value: T) => void): void;
off(event: string, listener: (value: T) => void): void;
}, event: string, cancellation: CancellationToken): DataSource<T>;
/**
* Connects to an aurum-server exposed datasource. View https://github.com/CyberPhoenix90/aurum-server for more information

@@ -303,2 +328,3 @@ * Note that type safety is not guaranteed. Whatever the server sends as an update will be propagated

awaitNextUpdate(cancellationToken?: CancellationToken): Promise<T>;
take(amount: number, cancellationToken?: CancellationToken): AsyncIterableIterator<T>;
/**

@@ -305,0 +331,0 @@ * Remove all listeners

@@ -69,3 +69,3 @@ import { DataSource, ArrayDataSource } from './data_source.js';

if (cancellationToken) {
cancellationToken.chain(animationToken);
cancellationToken.addCancellable(animationToken);
}

@@ -72,0 +72,0 @@ animationToken.addCancellable(resolve);

export declare enum OperationType {
FILTER = 0,
NOOP = 1,
MAP = 2,
DELAY = 3,
MAP_DELAY = 4,
DELAY_FILTER = 5,
MAP_DELAY_FILTER = 6
CLOSE = 1,
NOOP = 2,
MAP = 3,
DELAY = 4,
MAP_DELAY = 5,
DELAY_FILTER = 6,
MAP_DELAY_FILTER = 7
}

@@ -40,3 +41,3 @@ interface SourceOperator {

operationType: OperationType.NOOP;
operation: (value: T) => T;
operation: (value: T) => void;
}

@@ -43,0 +44,0 @@ export interface DataSourceDelayOperator<T> extends DataSourceOperator<T, T> {

export var OperationType;
(function (OperationType) {
OperationType[OperationType["FILTER"] = 0] = "FILTER";
OperationType[OperationType["NOOP"] = 1] = "NOOP";
OperationType[OperationType["MAP"] = 2] = "MAP";
OperationType[OperationType["DELAY"] = 3] = "DELAY";
OperationType[OperationType["MAP_DELAY"] = 4] = "MAP_DELAY";
OperationType[OperationType["DELAY_FILTER"] = 5] = "DELAY_FILTER";
OperationType[OperationType["MAP_DELAY_FILTER"] = 6] = "MAP_DELAY_FILTER";
OperationType[OperationType["CLOSE"] = 1] = "CLOSE";
OperationType[OperationType["NOOP"] = 2] = "NOOP";
OperationType[OperationType["MAP"] = 3] = "MAP";
OperationType[OperationType["DELAY"] = 4] = "DELAY";
OperationType[OperationType["MAP_DELAY"] = 5] = "MAP_DELAY";
OperationType[OperationType["DELAY_FILTER"] = 6] = "DELAY_FILTER";
OperationType[OperationType["MAP_DELAY_FILTER"] = 7] = "MAP_DELAY_FILTER";
})(OperationType || (OperationType = {}));
//# sourceMappingURL=operator_model.js.map

@@ -37,3 +37,3 @@ import { CancellationToken } from '../utilities/cancellation_token.js';

watchMap.set(node, new CancellationToken());
this.watchToken.chain(watchMap.get(node));
this.watchToken.addCancellable(watchMap.get(node));
node[this.childrenKey].listenAndRepeat((change) => {

@@ -60,3 +60,3 @@ this.watchHandleChange(change, node, watchMap);

watchMap.set(item, new CancellationToken());
this.watchToken.chain(watchMap.get(item));
this.watchToken.addCancellable(watchMap.get(item));
item[this.childrenKey].listenAndRepeat((change) => {

@@ -166,3 +166,3 @@ this.watchHandleChange(change, item, watchMap);

adaptMap.set(item, new CancellationToken());
parentToken.chain(adaptMap.get(item));
parentToken.addCancellable(adaptMap.get(item));
const list = ArrayDataSource.toArrayDataSource(item[this.childrenKey]);

@@ -169,0 +169,0 @@ this.adaptNodeList(list, adaptMap.get(item), nodeList);

@@ -13,2 +13,8 @@ import { HTMLNodeProps } from '../rendering/renderers/dom_adapter.js';

static rehydrate(aurumRenderable: Renderable, dom: HTMLElement): CancellationToken;
/**
* Creates a new Aurum rendering root attached to a dom element
* @param aurumRenderable the renderable to attach
* @param dom the dom element to attach to
* @returns a token that can be used to unmount the renderable
*/
static attach(aurumRenderable: Renderable, dom: HTMLElement): CancellationToken;

@@ -15,0 +21,0 @@ /**

@@ -120,3 +120,12 @@ import { Input } from '../nodes/input.js';

}
/**
* Creates a new Aurum rendering root attached to a dom element
* @param aurumRenderable the renderable to attach
* @param dom the dom element to attach to
* @returns a token that can be used to unmount the renderable
*/
static attach(aurumRenderable, dom) {
if (aurumRenderable == undefined) {
throw new Error('Cannot attach undefined renderable');
}
const session = createRenderSession();

@@ -133,2 +142,4 @@ const content = renderInternal(aurumRenderable, session);

}
else if (content == undefined) {
}
else {

@@ -135,0 +146,0 @@ dom.appendChild(content);

import { Delegate, Callback } from './common.js';
export interface ReadonlyCancellationToken {
readonly isCancelled: boolean;
hasCancellables(): boolean;
}
export declare class CancellationToken {

@@ -7,4 +11,4 @@ private cancelables;

constructor(...cancellables: Delegate[]);
static expired: CancellationToken;
static forever: CancellationToken;
static fromMultiple(tokens: CancellationToken[]): CancellationToken;
hasCancellables(): boolean;

@@ -15,3 +19,3 @@ /**

*/
addCancellable(delegate: Delegate): this;
addCancellable(delegate: Delegate | CancellationToken): this;
removeCancellable(delegate: Delegate): this;

@@ -23,7 +27,17 @@ setTimeout(cb: Delegate, time?: number): void;

throwIfCancelled(msg: string): void;
chain(target: CancellationToken, twoWays?: boolean): CancellationToken;
/**
* Combines multiple tokens into one. If any of the tokens are cancelled the returned token will be cancelled as well
*/
or(...token: CancellationToken[]): CancellationToken;
/**
* Combines multiple tokens into one. If all of the tokens are cancelled the returned token will be cancelled as well
*/
and(...token: CancellationToken[]): CancellationToken;
/**
* Registers an event using addEventListener and if you cancel the token the event will be canceled as well
*/
registerDomEvent(eventEmitter: HTMLElement | Document | Window, event: string, callback: (e: Event) => void): this;
registerDomEvent<T extends Event>(eventEmitter: {
addEventListener: (event: string, cb: (e: T) => void) => void;
removeEventListener: (event: string, cb: (e: T) => void) => void;
}, event: string, callback: (e: T) => void): this;
/**

@@ -30,0 +44,0 @@ * Registers an event using on and if you cancel the token the event will be canceled using off as well

@@ -11,10 +11,4 @@ export class CancellationToken {

}
static expired = new CancellationToken();
static forever = new CancellationToken();
static fromMultiple(tokens) {
const result = new CancellationToken();
for (const token of tokens) {
token.chain(result);
}
return result;
}
hasCancellables() {

@@ -29,2 +23,6 @@ return this.cancelables.length > 0;

this.throwIfCancelled('attempting to add cancellable to token that is already cancelled');
if (delegate instanceof CancellationToken) {
this.addCancellable(() => delegate.cancel());
return this;
}
this.cancelables.push(delegate);

@@ -72,18 +70,46 @@ if (this.cancelables.length === 200) {

}
chain(target, twoWays = false) {
const cancelable = () => target.cancel();
if (twoWays) {
target.chain(this, false);
/**
* Combines multiple tokens into one. If any of the tokens are cancelled the returned token will be cancelled as well
*/
or(...token) {
if (token.every((t) => t === CancellationToken.forever || t == undefined)) {
return this;
}
else {
target.addCancellable(() => {
if (!this.isCancelled) {
this.removeCancellable(cancelable);
}
});
if (token.some((t) => t.isCancelled)) {
return CancellationToken.expired;
}
this.addCancellable(cancelable);
return this;
token = token.filter(Boolean);
const orToken = new CancellationToken();
this.addCancellable(() => orToken.cancel());
for (const t of token) {
t.addCancellable(() => orToken.cancel());
}
return orToken;
}
/**
* Combines multiple tokens into one. If all of the tokens are cancelled the returned token will be cancelled as well
*/
and(...token) {
if (token.every((t) => t.isCancelled || t == undefined)) {
return this;
}
if (token.some((t) => t === CancellationToken.forever)) {
return CancellationToken.forever;
}
token = token.filter(Boolean);
let cancelCount = 0;
const andToken = new CancellationToken();
const cancel = () => {
cancelCount++;
if (cancelCount === token.length + 1) {
andToken.cancel();
}
};
this.addCancellable(cancel);
for (const t of token) {
t.addCancellable(cancel);
}
return andToken;
}
/**
* Registers an event using addEventListener and if you cancel the token the event will be canceled as well

@@ -144,2 +170,5 @@ */

}
// Token that is pre-cancelled. Signals that the operation should be cancelled immediately
CancellationToken.expired.cancel();
// Token that is never cancelled. Signals that the operation should never be cancelled or lasts for the whole process lifetime
CancellationToken.forever.addCancellable = () => void 0;

@@ -146,0 +175,0 @@ CancellationToken.forever.cancel = () => {

@@ -11,6 +11,2 @@ import { DataSource, ArrayDataSource, MapDataSource } from '../stream/data_source.js';

export declare function getValueOf<T>(sourceOrPrimitive: Data<T> | DuplexDataSource<T> | Stream<T>): T;
export type UnwrapObjectRecursive<T> = T extends ArrayDataSource<infer U> ? UnwrapObjectRecursive<U[]> : T extends DataSource<infer U> ? UnwrapObjectRecursive<U> : T extends DuplexDataSource<infer U> ? UnwrapObjectRecursive<U> : T extends ObjectDataSource<infer U> ? UnwrapObjectRecursive<U> : T extends Stream<infer U> ? UnwrapObjectRecursive<U> : {
[K in keyof T]: T[K] extends DataSource<infer U> ? UnwrapObjectRecursive<U> : T[K] extends DuplexDataSource<infer U> ? UnwrapObjectRecursive<U> : T[K] extends Stream<infer U> ? UnwrapObjectRecursive<U> : T[K] extends ObjectDataSource<infer U> ? UnwrapObjectRecursive<U> : T[K] extends object ? UnwrapObjectRecursive<T[K]> : T[K];
};
export declare function unwrapObjectRecursive<T>(object: T): UnwrapObjectRecursive<T>;
//# sourceMappingURL=sources.d.ts.map
import { DataSource, ArrayDataSource } from '../stream/data_source.js';
import { DuplexDataSource } from '../stream/duplex_data_source.js';
import { ObjectDataSource } from '../stream/object_data_source.js';
import { Stream } from '../stream/stream.js';

@@ -14,37 +13,2 @@ export function getValueOf(sourceOrPrimitive) {

}
export function unwrapObjectRecursive(object) {
if (object instanceof DataSource || object instanceof DuplexDataSource || object instanceof Stream) {
//@ts-ignore
return unwrapObjectRecursive(object.value);
}
if (object instanceof ArrayDataSource) {
//@ts-ignore
return unwrapObjectRecursive(object.toArray());
}
if (object instanceof ObjectDataSource) {
//@ts-ignore
return unwrapObjectRecursive(object.getData());
}
if (object instanceof DuplexDataSource) {
//@ts-ignore
return unwrapObjectRecursive(object.value);
}
if (object instanceof Stream) {
//@ts-ignore
return unwrapObjectRecursive(object.value);
}
if (Array.isArray(object)) {
//@ts-ignore
return object.map(unwrapObjectRecursive);
}
if (object instanceof Object) {
const result = {};
for (const key in object) {
result[key] = unwrapObjectRecursive(object[key]);
}
return result;
}
//@ts-ignore
return object;
}
//# sourceMappingURL=sources.js.map
import { Renderable } from '../rendering/aurum_element.js';
import { ReadOnlyArrayDataSource } from '../stream/data_source.js';
import { CancellationToken } from './cancellation_token.js';
/**
* Simplifies the children of a component by resolving the different types of children into an array data source
*/
export declare function resolveChildren<T>(children: Renderable[], cancellationToken: CancellationToken, validation?: (child: Renderable) => void): ReadOnlyArrayDataSource<T>;
//# sourceMappingURL=transclusion.d.ts.map
import { ArrayDataSource, DataSource } from '../stream/data_source.js';
/**
* Simplifies the children of a component by resolving the different types of children into an array data source
*/
export function resolveChildren(children, cancellationToken, validation) {

@@ -3,0 +6,0 @@ const chunks = process(children);

@@ -27,6 +27,4 @@ {

"src/**/*.ts",
"src/**/*.tsx",
"test/**/*.ts",
"test/**/*.tsx"
"src/**/*.tsx"
]
}

@@ -27,6 +27,4 @@ {

"src/**/*.ts",
"src/**/*.tsx",
"test/**/*.ts",
"test/**/*.tsx"
"src/**/*.tsx"
]
}

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

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

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 too big to display

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

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

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

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