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

@matter/general

Package Overview
Dependencies
Maintainers
0
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@matter/general - npm Package Compare versions

Comparing version 0.11.0-alpha.0-20241008-64a416779 to 0.11.0-alpha.0-20241013-d38e934bb

11

dist/cjs/environment/Environment.d.ts

@@ -6,2 +6,3 @@ /**

*/
import { MaybePromise } from "#util/Promises.js";
import "../polyfills/disposable.js";

@@ -37,2 +38,6 @@ import { Observable } from "../util/Observable.js";

/**
* Access an environmental service that may not exist.
*/
maybeGet<T extends object>(type: abstract new (...args: any[]) => T): T | undefined;
/**
* Remove an environmental service.

@@ -45,2 +50,8 @@ *

/**
* Remove and close an environmental service.
*/
close<T extends object>(type: abstract new (...args: any[]) => T): T extends {
close: () => MaybePromise<void>;
} ? MaybePromise<void> : void;
/**
* Access an environmental service, waiting for any async initialization to complete.

@@ -47,0 +58,0 @@ */

20

dist/cjs/environment/Environment.js

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

get(type) {
let instance = this.#services?.get(type) ?? this.#parent?.get(type);
let instance = this.#services?.get(type) ?? this.#parent?.maybeGet(type);
if (instance) {

@@ -72,2 +72,10 @@ return instance;

/**
* Access an environmental service that may not exist.
*/
maybeGet(type) {
if (this.has(type)) {
return this.get(type);
}
}
/**
* Remove an environmental service.

@@ -91,2 +99,12 @@ *

/**
* Remove and close an environmental service.
*/
close(type) {
const instance = this.maybeGet(type);
if (instance !== void 0) {
this.delete(type, instance);
return instance.close?.();
}
}
/**
* Access an environmental service, waiting for any async initialization to complete.

@@ -93,0 +111,0 @@ */

9

dist/cjs/log/Diagnostic.js

@@ -222,5 +222,4 @@ "use strict";

if (error !== void 0 && error !== null) {
if (error instanceof Error) {
message = error.message;
rawStack = error.stack;
if ("message" in error) {
({ message, stack: rawStack } = error);
} else if (error.message) {

@@ -231,5 +230,5 @@ message = typeof error.message === "string" ? message : error.toString();

if (message === void 0 || message === null || message === "") {
if (error instanceof Error) {
if (error !== void 0 && error !== null) {
message = error.constructor.name;
if (message === "Error") {
if (!message || message === "Error") {
message = "(unknown error)";

@@ -236,0 +235,0 @@ }

@@ -22,4 +22,4 @@ /**

export declare class NetInterfaceSet extends TransportInterfaceSet<NetInterface> {
[Environmental.create](env: Environment): NetInterfaceSet;
static [Environmental.create](env: Environment): NetInterfaceSet;
}
//# sourceMappingURL=NetInterface.d.ts.map

@@ -36,5 +36,5 @@ "use strict";

class NetInterfaceSet extends import_TransportInterface.TransportInterfaceSet {
[import_Environmental.Environmental.create](env) {
static [import_Environmental.Environmental.create](env) {
const instance = new NetInterfaceSet();
env.set(NetInterfaceSet, this);
env.set(NetInterfaceSet, instance);
return instance;

@@ -41,0 +41,0 @@ }

@@ -6,2 +6,4 @@ /**

*/
import { Environment } from "#environment/Environment.js";
import { Environmental } from "#environment/Environmental.js";
import { BasicSet } from "#util/Set.js";

@@ -28,2 +30,3 @@ import { Channel, ChannelType } from "./Channel.js";

constructor(...initialInterfaces: T[]);
static [Environmental.create](env: Environment): TransportInterfaceSet<TransportInterface>;
/**

@@ -30,0 +33,0 @@ * Closes all interfaces.

@@ -24,2 +24,3 @@ "use strict";

module.exports = __toCommonJS(TransportInterface_exports);
var import_Environmental = require("#environment/Environmental.js");
var import_Set = require("#util/Set.js");

@@ -35,2 +36,7 @@ /**

}
static [import_Environmental.Environmental.create](env) {
const instance = new TransportInterfaceSet();
env.set(TransportInterfaceSet, instance);
return instance;
}
/**

@@ -37,0 +43,0 @@ * Closes all interfaces.

@@ -8,3 +8,6 @@ /**

import { SupportedStorageTypes } from "./StringifyTools.js";
export declare class StorageContext<S extends Storage = any> {
export interface StorageContextFactory<S extends Storage = any> {
createContext(context: string): StorageContext<S>;
}
export declare class StorageContext<S extends Storage = any> implements StorageContextFactory<S> {
private readonly storage;

@@ -11,0 +14,0 @@ readonly thisContexts: string[];

@@ -8,4 +8,4 @@ /**

import { Storage } from "./Storage.js";
import { StorageContext } from "./StorageContext.js";
export declare class StorageManager<S extends Storage = any> {
import { StorageContext, StorageContextFactory } from "./StorageContext.js";
export declare class StorageManager<S extends Storage = any> implements StorageContextFactory<S> {
private storage;

@@ -12,0 +12,0 @@ private initialized;

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

is(value) {
return typeof value === "object" && value !== null && typeof value.then === "function";
return typeof value === "object" && value !== null && typeof value.then === "function" && value !== this;
},

@@ -119,0 +119,0 @@ /**

@@ -6,2 +6,3 @@ /**

*/
import { MaybePromise } from "#util/Promises.js";
import "../polyfills/disposable.js";

@@ -37,2 +38,6 @@ import { Observable } from "../util/Observable.js";

/**
* Access an environmental service that may not exist.
*/
maybeGet<T extends object>(type: abstract new (...args: any[]) => T): T | undefined;
/**
* Remove an environmental service.

@@ -45,2 +50,8 @@ *

/**
* Remove and close an environmental service.
*/
close<T extends object>(type: abstract new (...args: any[]) => T): T extends {
close: () => MaybePromise<void>;
} ? MaybePromise<void> : void;
/**
* Access an environmental service, waiting for any async initialization to complete.

@@ -47,0 +58,0 @@ */

@@ -37,3 +37,3 @@ /**

get(type) {
let instance = this.#services?.get(type) ?? this.#parent?.get(type);
let instance = this.#services?.get(type) ?? this.#parent?.maybeGet(type);
if (instance) {

@@ -49,2 +49,10 @@ return instance;

/**
* Access an environmental service that may not exist.
*/
maybeGet(type) {
if (this.has(type)) {
return this.get(type);
}
}
/**
* Remove an environmental service.

@@ -68,2 +76,12 @@ *

/**
* Remove and close an environmental service.
*/
close(type) {
const instance = this.maybeGet(type);
if (instance !== void 0) {
this.delete(type, instance);
return instance.close?.();
}
}
/**
* Access an environmental service, waiting for any async initialization to complete.

@@ -70,0 +88,0 @@ */

@@ -199,5 +199,4 @@ /**

if (error !== void 0 && error !== null) {
if (error instanceof Error) {
message = error.message;
rawStack = error.stack;
if ("message" in error) {
({ message, stack: rawStack } = error);
} else if (error.message) {

@@ -208,5 +207,5 @@ message = typeof error.message === "string" ? message : error.toString();

if (message === void 0 || message === null || message === "") {
if (error instanceof Error) {
if (error !== void 0 && error !== null) {
message = error.constructor.name;
if (message === "Error") {
if (!message || message === "Error") {
message = "(unknown error)";

@@ -213,0 +212,0 @@ }

@@ -22,4 +22,4 @@ /**

export declare class NetInterfaceSet extends TransportInterfaceSet<NetInterface> {
[Environmental.create](env: Environment): NetInterfaceSet;
static [Environmental.create](env: Environment): NetInterfaceSet;
}
//# sourceMappingURL=NetInterface.d.ts.map

@@ -12,5 +12,5 @@ /**

class NetInterfaceSet extends TransportInterfaceSet {
[Environmental.create](env) {
static [Environmental.create](env) {
const instance = new NetInterfaceSet();
env.set(NetInterfaceSet, this);
env.set(NetInterfaceSet, instance);
return instance;

@@ -17,0 +17,0 @@ }

@@ -6,2 +6,4 @@ /**

*/
import { Environment } from "#environment/Environment.js";
import { Environmental } from "#environment/Environmental.js";
import { BasicSet } from "#util/Set.js";

@@ -28,2 +30,3 @@ import { Channel, ChannelType } from "./Channel.js";

constructor(...initialInterfaces: T[]);
static [Environmental.create](env: Environment): TransportInterfaceSet<TransportInterface>;
/**

@@ -30,0 +33,0 @@ * Closes all interfaces.

@@ -6,2 +6,3 @@ /**

*/
import { Environmental } from "#environment/Environmental.js";
import { BasicSet } from "#util/Set.js";

@@ -12,2 +13,7 @@ class TransportInterfaceSet extends BasicSet {

}
static [Environmental.create](env) {
const instance = new TransportInterfaceSet();
env.set(TransportInterfaceSet, instance);
return instance;
}
/**

@@ -14,0 +20,0 @@ * Closes all interfaces.

@@ -8,3 +8,6 @@ /**

import { SupportedStorageTypes } from "./StringifyTools.js";
export declare class StorageContext<S extends Storage = any> {
export interface StorageContextFactory<S extends Storage = any> {
createContext(context: string): StorageContext<S>;
}
export declare class StorageContext<S extends Storage = any> implements StorageContextFactory<S> {
private readonly storage;

@@ -11,0 +14,0 @@ readonly thisContexts: string[];

@@ -8,4 +8,4 @@ /**

import { Storage } from "./Storage.js";
import { StorageContext } from "./StorageContext.js";
export declare class StorageManager<S extends Storage = any> {
import { StorageContext, StorageContextFactory } from "./StorageContext.js";
export declare class StorageManager<S extends Storage = any> implements StorageContextFactory<S> {
private storage;

@@ -12,0 +12,0 @@ private initialized;

@@ -89,3 +89,3 @@ /**

is(value) {
return typeof value === "object" && value !== null && typeof value.then === "function";
return typeof value === "object" && value !== null && typeof value.then === "function" && value !== this;
},

@@ -92,0 +92,0 @@ /**

{
"name": "@matter/general",
"version": "0.11.0-alpha.0-20241008-64a416779",
"version": "0.11.0-alpha.0-20241013-d38e934bb",
"description": "Non-Matter support for Matter.js",

@@ -39,3 +39,3 @@ "keywords": [

"devDependencies": {
"@matter/tools": "0.11.0-alpha.0-20241008-64a416779"
"@matter/tools": "0.11.0-alpha.0-20241013-d38e934bb"
},

@@ -42,0 +42,0 @@ "files": [

@@ -7,2 +7,3 @@ /**

import { MaybePromise } from "#util/Promises.js";
import { DiagnosticSource } from "../log/DiagnosticSource.js";

@@ -12,3 +13,3 @@ import { Logger } from "../log/Logger.js";

import { Time } from "../time/Time.js";
import { UnsupportedDependencyError } from "../util/Lifecycle.js";
import { Destructable, UnsupportedDependencyError } from "../util/Lifecycle.js";
import { Observable } from "../util/Observable.js";

@@ -58,3 +59,3 @@ import { Environmental } from "./Environmental.js";

get<T extends object>(type: abstract new (...args: any[]) => T): T {
let instance = this.#services?.get(type) ?? this.#parent?.get(type);
let instance = this.#services?.get(type) ?? this.#parent?.maybeGet(type);

@@ -74,2 +75,11 @@ if (instance) {

/**
* Access an environmental service that may not exist.
*/
maybeGet<T extends object>(type: abstract new (...args: any[]) => T): T | undefined {
if (this.has(type)) {
return this.get(type);
}
}
/**
* Remove an environmental service.

@@ -96,2 +106,17 @@ *

/**
* Remove and close an environmental service.
*/
close<T extends object>(
type: abstract new (...args: any[]) => T,
): T extends { close: () => MaybePromise<void> } ? MaybePromise<void> : void {
const instance = this.maybeGet(type);
if (instance !== undefined) {
this.delete(type, instance);
return (instance as Partial<Destructable>).close?.() as T extends { close: () => MaybePromise<void> }
? MaybePromise<void>
: void;
}
}
/**
* Access an environmental service, waiting for any async initialization to complete.

@@ -98,0 +123,0 @@ */

@@ -342,5 +342,4 @@ /**

if (error !== undefined && error !== null) {
if (error instanceof Error) {
message = error.message;
rawStack = error.stack;
if ("message" in error) {
({ message, stack: rawStack } = error);
} else if (error.message) {

@@ -351,5 +350,5 @@ message = typeof error.message === "string" ? message : error.toString();

if (message === undefined || message === null || message === "") {
if (error instanceof Error) {
if (error !== undefined && error !== null) {
message = error.constructor.name;
if (message === "Error") {
if (!message || message === "Error") {
message = "(unknown error)";

@@ -356,0 +355,0 @@ }

@@ -357,4 +357,3 @@ /**

// Apply style codes. Maintains color state (via escapes) so values must
// be rendered sequentially as they appear
// Apply style codes. Maintains color state (via escapes) so values must be rendered sequentially as they appear
function style(style: StyleName, text: string) {

@@ -361,0 +360,0 @@ if (text === "") {

@@ -28,7 +28,7 @@ /**

export class NetInterfaceSet extends TransportInterfaceSet<NetInterface> {
[Environmental.create](env: Environment) {
static override [Environmental.create](env: Environment) {
const instance = new NetInterfaceSet();
env.set(NetInterfaceSet, this);
env.set(NetInterfaceSet, instance);
return instance;
}
}

@@ -7,2 +7,4 @@ /**

import { Environment } from "#environment/Environment.js";
import { Environmental } from "#environment/Environmental.js";
import { BasicSet } from "#util/Set.js";

@@ -35,2 +37,8 @@ import { Channel, ChannelType } from "./Channel.js";

static [Environmental.create](env: Environment) {
const instance = new TransportInterfaceSet();
env.set(TransportInterfaceSet, instance);
return instance;
}
/**

@@ -37,0 +45,0 @@ * Closes all interfaces.

@@ -11,3 +11,7 @@ /**

export class StorageContext<S extends Storage = any> {
export interface StorageContextFactory<S extends Storage = any> {
createContext(context: string): StorageContext<S>;
}
export class StorageContext<S extends Storage = any> implements StorageContextFactory<S> {
constructor(

@@ -14,0 +18,0 @@ private readonly storage: S,

@@ -9,5 +9,5 @@ /**

import { Storage, StorageError } from "./Storage.js";
import { StorageContext } from "./StorageContext.js";
import { StorageContext, StorageContextFactory } from "./StorageContext.js";
export class StorageManager<S extends Storage = any> {
export class StorageManager<S extends Storage = any> implements StorageContextFactory<S> {
private initialized = false;

@@ -14,0 +14,0 @@

@@ -59,3 +59,3 @@ /**

export module Constructable {
export namespace Constructable {
/**

@@ -62,0 +62,0 @@ * An {@link Constructable} that supports deferred construction.

@@ -151,3 +151,8 @@ /**

// We cannot use isObject because this could collide with valid values here
return typeof value === "object" && value !== null && typeof (value as { then?: unknown }).then === "function";
return (
typeof value === "object" &&
value !== null &&
typeof (value as { then?: unknown }).then === "function" &&
value !== this
);
},

@@ -154,0 +159,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

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

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

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