@dxos/context 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/context",
3
- "version": "0.8.4-main.bc674ce",
3
+ "version": "0.8.4-main.bcb3aa67d6",
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.bc674ce",
36
- "@dxos/node-std": "0.8.4-main.bc674ce",
37
- "@dxos/util": "0.8.4-main.bc674ce",
38
- "@dxos/log": "0.8.4-main.bc674ce"
35
+ "@dxos/log": "0.8.4-main.bcb3aa67d6",
36
+ "@dxos/node-std": "0.8.4-main.bcb3aa67d6",
37
+ "@dxos/debug": "0.8.4-main.bcb3aa67d6",
38
+ "@dxos/util": "0.8.4-main.bcb3aa67d6"
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 {