@matter/general
Advanced tools
Comparing version 0.12.0-alpha.0-20241213-fcd71a96d to 0.12.0-alpha.0-20241216-01bff7bc4
@@ -86,3 +86,3 @@ "use strict"; | ||
} | ||
return new TextDecoder("iso-8859-1").decode(out); | ||
return new TextDecoder().decode(out); | ||
} | ||
@@ -89,0 +89,0 @@ Base642.encode = encode; |
@@ -14,3 +14,3 @@ /** | ||
* | ||
* Any object may be an environmental service. This methods in this interface are optional. | ||
* Any object may be an environmental service. The methods in this interface are optional. | ||
*/ | ||
@@ -23,6 +23,2 @@ interface Service { | ||
/** | ||
* Asynchronous destruction. Invoked by the environment when it is destroyed. | ||
*/ | ||
[Symbol.asyncDispose]?: () => Promise<any>; | ||
/** | ||
* Standard diagnostic presentation. | ||
@@ -29,0 +25,0 @@ */ |
@@ -37,2 +37,3 @@ "use strict"; | ||
class RuntimeService { | ||
#env; | ||
#workers = /* @__PURE__ */ new Set(); | ||
@@ -46,2 +47,3 @@ #cancelled = /* @__PURE__ */ new Set(); | ||
constructor(environment) { | ||
this.#env = environment; | ||
environment.set(RuntimeService, this); | ||
@@ -87,6 +89,2 @@ import_DiagnosticSource.DiagnosticSource.add(this); | ||
}); | ||
} else if (worker.then) { | ||
if (worker.then) { | ||
Promise.resolve(worker).catch((error) => this.#crash(error)).finally(() => this.delete(worker)); | ||
} | ||
} | ||
@@ -180,2 +178,3 @@ } | ||
await this.inactive; | ||
this.#env.delete(RuntimeService, this); | ||
import_DiagnosticSource.DiagnosticSource.delete(this); | ||
@@ -182,0 +181,0 @@ } |
@@ -27,2 +27,12 @@ /** | ||
} | ||
/** | ||
* Extended interface for storage that supports snapshotting. | ||
*/ | ||
export interface CloneableStorage { | ||
clone(): MaybePromise<Storage>; | ||
} | ||
export declare namespace CloneableStorage { | ||
function is<T extends {}>(storage: T): storage is T & CloneableStorage; | ||
function assert<T extends {}>(storage: T): asserts storage is T & CloneableStorage; | ||
} | ||
export declare abstract class MaybeAsyncStorage implements Storage { | ||
@@ -29,0 +39,0 @@ abstract initialized: boolean; |
@@ -21,2 +21,3 @@ "use strict"; | ||
__export(Storage_exports, { | ||
CloneableStorage: () => CloneableStorage, | ||
MaybeAsyncStorage: () => MaybeAsyncStorage, | ||
@@ -35,2 +36,15 @@ StorageError: () => StorageError, | ||
} | ||
var CloneableStorage; | ||
((CloneableStorage2) => { | ||
function is(storage) { | ||
return "clone" in storage && typeof storage.clone === "function"; | ||
} | ||
CloneableStorage2.is = is; | ||
function assert(storage) { | ||
if (!is(storage)) { | ||
throw new import_MatterError.ImplementationError("Storage does not support required snapshotting function"); | ||
} | ||
} | ||
CloneableStorage2.assert = assert; | ||
})(CloneableStorage || (CloneableStorage = {})); | ||
class MaybeAsyncStorage { | ||
@@ -37,0 +51,0 @@ } |
@@ -6,5 +6,5 @@ /** | ||
*/ | ||
import { SyncStorage } from "./Storage.js"; | ||
import { CloneableStorage, SyncStorage } from "./Storage.js"; | ||
import { SupportedStorageTypes } from "./StringifyTools.js"; | ||
export declare class StorageBackendMemory extends SyncStorage { | ||
export declare class StorageBackendMemory extends SyncStorage implements CloneableStorage { | ||
#private; | ||
@@ -18,2 +18,3 @@ protected store: any; | ||
initialize(): void; | ||
clone(): StorageBackendMemory; | ||
close(): void; | ||
@@ -20,0 +21,0 @@ clear(): void; |
@@ -24,2 +24,3 @@ "use strict"; | ||
module.exports = __toCommonJS(StorageBackendMemory_exports); | ||
var import_DeepCopy = require("#util/DeepCopy.js"); | ||
var import_Storage = require("./Storage.js"); | ||
@@ -55,2 +56,7 @@ /** | ||
} | ||
clone() { | ||
const clone = new StorageBackendMemory((0, import_DeepCopy.deepCopy)(this.store)); | ||
clone.initialize(); | ||
return clone; | ||
} | ||
close() { | ||
@@ -57,0 +63,0 @@ this.isInitialized = false; |
@@ -227,3 +227,3 @@ "use strict"; | ||
if (newStatus !== import_Lifecycle.Lifecycle.Status.Destroyed) { | ||
throw new import_MatterError.ImplementationError("Cannog change status because destruction is ongoing"); | ||
throw new import_MatterError.ImplementationError("Cannot change status because destruction is ongoing"); | ||
} | ||
@@ -395,3 +395,3 @@ break; | ||
const crashed = Object.values(subjectArray).filter( | ||
(backing) => backing.construction.status === import_Lifecycle.Lifecycle.Status.Crashed | ||
(subject) => subject.construction.status === import_Lifecycle.Lifecycle.Status.Crashed | ||
); | ||
@@ -398,0 +398,0 @@ if (crashed.length) { |
@@ -81,3 +81,3 @@ "use strict"; | ||
}).join(""); | ||
result = result.replace(/(\d+)Ths/i, "$1ths"); | ||
result = result.replace(/(\d)Ths/i, "$1ths"); | ||
return result; | ||
@@ -84,0 +84,0 @@ } |
@@ -63,3 +63,3 @@ /** | ||
} | ||
return new TextDecoder("iso-8859-1").decode(out); | ||
return new TextDecoder().decode(out); | ||
} | ||
@@ -66,0 +66,0 @@ Base642.encode = encode; |
@@ -14,3 +14,3 @@ /** | ||
* | ||
* Any object may be an environmental service. This methods in this interface are optional. | ||
* Any object may be an environmental service. The methods in this interface are optional. | ||
*/ | ||
@@ -23,6 +23,2 @@ interface Service { | ||
/** | ||
* Asynchronous destruction. Invoked by the environment when it is destroyed. | ||
*/ | ||
[Symbol.asyncDispose]?: () => Promise<any>; | ||
/** | ||
* Standard diagnostic presentation. | ||
@@ -29,0 +25,0 @@ */ |
@@ -14,2 +14,3 @@ /** | ||
class RuntimeService { | ||
#env; | ||
#workers = /* @__PURE__ */ new Set(); | ||
@@ -23,2 +24,3 @@ #cancelled = /* @__PURE__ */ new Set(); | ||
constructor(environment) { | ||
this.#env = environment; | ||
environment.set(RuntimeService, this); | ||
@@ -64,6 +66,2 @@ DiagnosticSource.add(this); | ||
}); | ||
} else if (worker.then) { | ||
if (worker.then) { | ||
Promise.resolve(worker).catch((error) => this.#crash(error)).finally(() => this.delete(worker)); | ||
} | ||
} | ||
@@ -157,2 +155,3 @@ } | ||
await this.inactive; | ||
this.#env.delete(RuntimeService, this); | ||
DiagnosticSource.delete(this); | ||
@@ -159,0 +158,0 @@ } |
@@ -27,2 +27,12 @@ /** | ||
} | ||
/** | ||
* Extended interface for storage that supports snapshotting. | ||
*/ | ||
export interface CloneableStorage { | ||
clone(): MaybePromise<Storage>; | ||
} | ||
export declare namespace CloneableStorage { | ||
function is<T extends {}>(storage: T): storage is T & CloneableStorage; | ||
function assert<T extends {}>(storage: T): asserts storage is T & CloneableStorage; | ||
} | ||
export declare abstract class MaybeAsyncStorage implements Storage { | ||
@@ -29,0 +39,0 @@ abstract initialized: boolean; |
@@ -6,5 +6,18 @@ /** | ||
*/ | ||
import { MatterError } from "../MatterError.js"; | ||
import { ImplementationError, MatterError } from "../MatterError.js"; | ||
class StorageError extends MatterError { | ||
} | ||
var CloneableStorage; | ||
((CloneableStorage2) => { | ||
function is(storage) { | ||
return "clone" in storage && typeof storage.clone === "function"; | ||
} | ||
CloneableStorage2.is = is; | ||
function assert(storage) { | ||
if (!is(storage)) { | ||
throw new ImplementationError("Storage does not support required snapshotting function"); | ||
} | ||
} | ||
CloneableStorage2.assert = assert; | ||
})(CloneableStorage || (CloneableStorage = {})); | ||
class MaybeAsyncStorage { | ||
@@ -15,2 +28,3 @@ } | ||
export { | ||
CloneableStorage, | ||
MaybeAsyncStorage, | ||
@@ -17,0 +31,0 @@ StorageError, |
@@ -6,5 +6,5 @@ /** | ||
*/ | ||
import { SyncStorage } from "./Storage.js"; | ||
import { CloneableStorage, SyncStorage } from "./Storage.js"; | ||
import { SupportedStorageTypes } from "./StringifyTools.js"; | ||
export declare class StorageBackendMemory extends SyncStorage { | ||
export declare class StorageBackendMemory extends SyncStorage implements CloneableStorage { | ||
#private; | ||
@@ -18,2 +18,3 @@ protected store: any; | ||
initialize(): void; | ||
clone(): StorageBackendMemory; | ||
close(): void; | ||
@@ -20,0 +21,0 @@ clear(): void; |
@@ -6,2 +6,3 @@ /** | ||
*/ | ||
import { deepCopy } from "#util/DeepCopy.js"; | ||
import { StorageError, SyncStorage } from "./Storage.js"; | ||
@@ -32,2 +33,7 @@ class StorageBackendMemory extends SyncStorage { | ||
} | ||
clone() { | ||
const clone = new StorageBackendMemory(deepCopy(this.store)); | ||
clone.initialize(); | ||
return clone; | ||
} | ||
close() { | ||
@@ -34,0 +40,0 @@ this.isInitialized = false; |
@@ -203,3 +203,3 @@ /** | ||
if (newStatus !== Lifecycle.Status.Destroyed) { | ||
throw new ImplementationError("Cannog change status because destruction is ongoing"); | ||
throw new ImplementationError("Cannot change status because destruction is ongoing"); | ||
} | ||
@@ -371,3 +371,3 @@ break; | ||
const crashed = Object.values(subjectArray).filter( | ||
(backing) => backing.construction.status === Lifecycle.Status.Crashed | ||
(subject) => subject.construction.status === Lifecycle.Status.Crashed | ||
); | ||
@@ -374,0 +374,0 @@ if (crashed.length) { |
@@ -54,3 +54,3 @@ /** | ||
}).join(""); | ||
result = result.replace(/(\d+)Ths/i, "$1ths"); | ||
result = result.replace(/(\d)Ths/i, "$1ths"); | ||
return result; | ||
@@ -57,0 +57,0 @@ } |
{ | ||
"name": "@matter/general", | ||
"version": "0.12.0-alpha.0-20241213-fcd71a96d", | ||
"version": "0.12.0-alpha.0-20241216-01bff7bc4", | ||
"description": "Non-Matter support for Matter.js", | ||
@@ -39,3 +39,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@matter/testing": "0.12.0-alpha.0-20241213-fcd71a96d" | ||
"@matter/testing": "0.12.0-alpha.0-20241216-01bff7bc4" | ||
}, | ||
@@ -42,0 +42,0 @@ "files": [ |
@@ -80,3 +80,3 @@ /** | ||
return new TextDecoder("iso-8859-1").decode(out); | ||
return new TextDecoder().decode(out); | ||
} | ||
@@ -83,0 +83,0 @@ |
@@ -17,3 +17,3 @@ /** | ||
* | ||
* Any object may be an environmental service. This methods in this interface are optional. | ||
* Any object may be an environmental service. The methods in this interface are optional. | ||
*/ | ||
@@ -27,7 +27,2 @@ export interface Service { | ||
/** | ||
* Asynchronous destruction. Invoked by the environment when it is destroyed. | ||
*/ | ||
[Symbol.asyncDispose]?: () => Promise<any>; | ||
/** | ||
* Standard diagnostic presentation. | ||
@@ -34,0 +29,0 @@ */ |
@@ -23,2 +23,3 @@ /** | ||
export class RuntimeService implements Multiplex { | ||
#env: Environment; | ||
#workers = new Set<RuntimeService.Worker>(); | ||
@@ -33,2 +34,3 @@ #cancelled = new Set<RuntimeService.Worker>(); | ||
constructor(environment: Environment) { | ||
this.#env = environment; | ||
environment.set(RuntimeService, this); | ||
@@ -84,8 +86,2 @@ DiagnosticSource.add(this); | ||
}); | ||
} else if (worker.then) { | ||
if (worker.then) { | ||
Promise.resolve(worker) | ||
.catch(error => this.#crash(error)) | ||
.finally(() => this.delete(worker)); | ||
} | ||
} | ||
@@ -199,2 +195,3 @@ } | ||
await this.inactive; | ||
this.#env.delete(RuntimeService, this); | ||
DiagnosticSource.delete(this); | ||
@@ -201,0 +198,0 @@ } |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
import { MatterError } from "../MatterError.js"; | ||
import { ImplementationError, MatterError } from "../MatterError.js"; | ||
import { MaybePromise } from "../util/Promises.js"; | ||
@@ -30,2 +30,21 @@ import { SupportedStorageTypes } from "./StringifyTools.js"; | ||
/** | ||
* Extended interface for storage that supports snapshotting. | ||
*/ | ||
export interface CloneableStorage { | ||
clone(): MaybePromise<Storage>; | ||
} | ||
export namespace CloneableStorage { | ||
export function is<T extends {}>(storage: T): storage is T & CloneableStorage { | ||
return "clone" in storage && typeof storage.clone === "function"; | ||
} | ||
export function assert<T extends {}>(storage: T): asserts storage is T & CloneableStorage { | ||
if (!is(storage)) { | ||
throw new ImplementationError("Storage does not support required snapshotting function"); | ||
} | ||
} | ||
} | ||
// This extra class is needed because of https://github.com/microsoft/TypeScript/issues/57905 in order | ||
@@ -32,0 +51,0 @@ // to have the generics typing support on the "get" method and can be removed when the TS issue is fixed |
@@ -7,6 +7,7 @@ /** | ||
import { StorageError, SyncStorage } from "./Storage.js"; | ||
import { deepCopy } from "#util/DeepCopy.js"; | ||
import { CloneableStorage, StorageError, SyncStorage } from "./Storage.js"; | ||
import { SupportedStorageTypes } from "./StringifyTools.js"; | ||
export class StorageBackendMemory extends SyncStorage { | ||
export class StorageBackendMemory extends SyncStorage implements CloneableStorage { | ||
protected isInitialized = false; | ||
@@ -41,2 +42,8 @@ | ||
clone() { | ||
const clone = new StorageBackendMemory(deepCopy(this.store)); | ||
clone.initialize(); | ||
return clone; | ||
} | ||
close() { | ||
@@ -43,0 +50,0 @@ this.isInitialized = false; |
@@ -461,3 +461,3 @@ /** | ||
if (newStatus !== Lifecycle.Status.Destroyed) { | ||
throw new ImplementationError("Cannog change status because destruction is ongoing"); | ||
throw new ImplementationError("Cannot change status because destruction is ongoing"); | ||
} | ||
@@ -695,3 +695,3 @@ break; | ||
const crashed = Object.values(subjectArray).filter( | ||
backing => backing.construction.status === Lifecycle.Status.Crashed, | ||
subject => subject.construction.status === Lifecycle.Status.Crashed, | ||
); | ||
@@ -698,0 +698,0 @@ if (crashed.length) { |
@@ -74,3 +74,3 @@ /** | ||
// Special case so "100ths" doesn't become "100Ths" which is formally correct but goofy | ||
result = result.replace(/(\d+)Ths/i, "$1ths"); | ||
result = result.replace(/(\d)Ths/i, "$1ths"); | ||
@@ -77,0 +77,0 @@ return result; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1594861
32219