@dxos/context 0.8.4-main.bc674ce → 0.8.4-main.bd9b33e6c8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +4 -1
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +4 -1
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/context.d.ts.map +1 -1
- package/dist/types/src/resource.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/context.ts +1 -0
- package/src/resource.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/context",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.bd9b33e6c8",
|
|
4
4
|
"description": "Async utils.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@hazae41/symbol-dispose-polyfill": "^1.0.2",
|
|
35
|
-
"@dxos/debug": "0.8.4-main.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
35
|
+
"@dxos/debug": "0.8.4-main.bd9b33e6c8",
|
|
36
|
+
"@dxos/log": "0.8.4-main.bd9b33e6c8",
|
|
37
|
+
"@dxos/node-std": "0.8.4-main.bd9b33e6c8",
|
|
38
|
+
"@dxos/util": "0.8.4-main.bd9b33e6c8"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
package/src/context.ts
CHANGED
|
@@ -236,6 +236,7 @@ export class Context {
|
|
|
236
236
|
|
|
237
237
|
derive({ onError, attributes }: CreateContextProps = {}): Context {
|
|
238
238
|
const newCtx = new Context({
|
|
239
|
+
parent: this,
|
|
239
240
|
// TODO(dmaretskyi): Optimize to not require allocating a new closure for every context.
|
|
240
241
|
onError: async (error) => {
|
|
241
242
|
if (!onError) {
|
package/src/resource.ts
CHANGED
|
@@ -164,6 +164,7 @@ export abstract class Resource implements Lifecycle {
|
|
|
164
164
|
async #open(ctx?: Context): Promise<void> {
|
|
165
165
|
this.#closePromise = null;
|
|
166
166
|
this.#parentCtx = ctx?.derive({ name: this.#name }) ?? this.#createParentContext();
|
|
167
|
+
this.#internalCtx = this.#createContext(this.#parentCtx);
|
|
167
168
|
await this._open(this.#parentCtx);
|
|
168
169
|
this.#lifecycleState = LifecycleState.OPEN;
|
|
169
170
|
}
|
|
@@ -176,9 +177,10 @@ export abstract class Resource implements Lifecycle {
|
|
|
176
177
|
this.#lifecycleState = LifecycleState.CLOSED;
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
#createContext(): Context {
|
|
180
|
+
#createContext(attributeParent?: Context): Context {
|
|
180
181
|
return new Context({
|
|
181
182
|
name: this.#name,
|
|
183
|
+
parent: attributeParent,
|
|
182
184
|
onError: (error) =>
|
|
183
185
|
queueMicrotask(async () => {
|
|
184
186
|
try {
|