Skip to content

Commit 338b7f5

Browse files
spearwolfclaude
andcommitted
deps: bump @spearwolf/eventize to 4.3.1 and @spearwolf/signalize to 0.28.0
Eventize 4.1+ added typed-event overloads where polymorphic `this` no longer resolves through the new `NonTypedEmitter<T>` conditional. Cast `this` to its concrete class at eventize call sites, and replace `Parameters<typeof on>` in `ShadowObjectCreationAPI` with `[object, ...SubscribeArgs]` so the loose `(target, event, listener)` form keeps type-checking against the new overload set. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 89c59c2 commit 338b7f5

13 files changed

Lines changed: 318 additions & 59 deletions

File tree

packages/shadow-objects-e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"test": "pnpm playwright test"
2020
},
2121
"dependencies": {
22-
"@spearwolf/eventize": "^4.0.2",
22+
"@spearwolf/eventize": "^4.3.1",
2323
"@spearwolf/shadow-objects": "workspace:*"
2424
},
2525
"devDependencies": {

packages/shadow-objects-testing/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"watch": "web-test-runner \"test/**/*.test.js\" --node-resolve --watch"
1515
},
1616
"dependencies": {
17-
"@spearwolf/eventize": "^4.0.2",
17+
"@spearwolf/eventize": "^4.3.1",
1818
"@spearwolf/shadow-objects": "workspace:*"
1919
},
2020
"devDependencies": {

packages/shadow-objects/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"esbuild-plugin-inline-worker": "^0.1.1"
9797
},
9898
"dependencies": {
99-
"@spearwolf/eventize": "^4.0.2",
100-
"@spearwolf/signalize": "^0.27.2"
99+
"@spearwolf/eventize": "^4.3.1",
100+
"@spearwolf/signalize": "^0.28.0"
101101
}
102102
}

packages/shadow-objects/src/in-the-dark/Entity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class Entity {
129129
constructor(kernel: Kernel, uuid: string) {
130130
this.#kernel = kernel;
131131
this.#uuid = uuid;
132-
once(this, onDestroy, Priority.Min, this);
132+
once(this as Entity, onDestroy, Priority.Min, this);
133133
}
134134

135135
traverse(callback: (entity: Entity) => void) {
@@ -257,7 +257,7 @@ export class Entity {
257257

258258
dispatchViewEvents(events: IComponentEvent[]) {
259259
for (const {type, data} of events) {
260-
emit(this, onViewEvent, type, data);
260+
emit(this as Entity, onViewEvent, type, data);
261261
}
262262
}
263263

packages/shadow-objects/src/in-the-dark/Kernel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export class Kernel {
315315

316316
dispatchMessageToView(message: MessageToViewEvent): void {
317317
queueMicrotask(() => {
318-
emit(this, MessageToView, message);
318+
emit(this as Kernel, MessageToView, message);
319319
});
320320
}
321321

packages/shadow-objects/src/in-the-dark/SignalsPath.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ export class SignalsPath {
2323
readonly value$: Signal<any>;
2424

2525
constructor(signals?: SignalLike<any>[]) {
26-
retain(this, VALUE);
26+
retain(this as SignalsPath, VALUE);
2727

2828
this.value$ = findObjectSignalByName(this, VALUE);
29-
this.value$.onChange((val) => emit(this, VALUE, val));
29+
this.value$.onChange((val) => emit(this as SignalsPath, VALUE, val));
3030

3131
if (signals) {
3232
this.add(...signals);
@@ -60,7 +60,7 @@ export class SignalsPath {
6060
this.#effect?.destroy();
6161
this.#effect = undefined;
6262

63-
retainClear(this, VALUE);
63+
retainClear(this as SignalsPath, VALUE);
6464
off(this);
6565

6666
this.value$.destroy();

packages/shadow-objects/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ export interface ShadowObjectCreationAPI {
143143
createMemo<T = unknown>(...args: Parameters<typeof createMemo<T>>): SignalReader<T>;
144144

145145
on(...args: SubscribeArgs): ReturnType<typeof on>;
146-
on(...args: Parameters<typeof on>): ReturnType<typeof on>;
146+
on(...args: [object, ...SubscribeArgs]): ReturnType<typeof on>;
147147

148148
once(...args: SubscribeArgs): ReturnType<typeof once>;
149-
once(...args: Parameters<typeof once>): ReturnType<typeof once>;
149+
once(...args: [object, ...SubscribeArgs]): ReturnType<typeof once>;
150150

151151
onViewEvent(callback: (type: string, data: unknown) => any): void;
152152

packages/shadow-objects/src/utils/FrameLoop.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class FrameLoop {
2121
this.#requestAnimationFrame();
2222
}
2323

24-
on(this, FrameLoop.OnFrame, target);
24+
on(this as FrameLoop, FrameLoop.OnFrame, target);
2525

2626
this.#subscriptionCount++;
2727

@@ -39,7 +39,7 @@ export class FrameLoop {
3939
}
4040

4141
#onFrame = (now: number) => {
42-
emit(this, FrameLoop.OnFrame, now);
42+
emit(this as FrameLoop, FrameLoop.OnFrame, now);
4343
this.#requestAnimationFrame();
4444
};
4545

packages/shadow-objects/src/view/RemoteWorkerEnv.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ export class RemoteWorkerEnv implements IShadowObjectEnvProxy {
5353
}
5454

5555
get workerLoaded(): Promise<RemoteWorkerEnv> {
56-
return onceAsync<RemoteWorkerEnv>(this, RemoteWorkerEnv.WorkerLoaded);
56+
return onceAsync<RemoteWorkerEnv>(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerLoaded);
5757
}
5858

5959
constructor() {
60-
retain(this, RemoteWorkerEnv.WorkerLoaded);
60+
retain(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerLoaded);
6161
}
6262

6363
async start(): Promise<void> {
@@ -88,7 +88,7 @@ export class RemoteWorkerEnv implements IShadowObjectEnvProxy {
8888
worker.addEventListener('message', this.onMessageFromWorker.bind(this));
8989

9090
queueMicrotask(() => {
91-
emit(this, RemoteWorkerEnv.WorkerLoaded, this);
91+
emit(this as RemoteWorkerEnv, RemoteWorkerEnv.WorkerLoaded, this);
9292
});
9393
} catch (error) {
9494
this.logger.error('failed to start', error);

packages/shadow-objects/src/view/ShadowEnv.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,23 @@ export class ShadowEnv {
4343
}
4444

4545
constructor() {
46-
retain(this, ShadowEnv.ContextCreated);
46+
const self = this as ShadowEnv;
47+
retain(self, ShadowEnv.ContextCreated);
4748

48-
on(this, ShadowEnv.ContextLost, Priority.AAA, () => {
49-
retainClear(this, ShadowEnv.ContextCreated);
49+
on(self, ShadowEnv.ContextLost, Priority.AAA, () => {
50+
retainClear(self, ShadowEnv.ContextCreated);
5051
});
5152

5253
createEffect(() => {
5354
if (this.viewReady && this.proxyReady) {
5455
this.view!.reCreateChanges();
55-
emit(this, ShadowEnv.ContextCreated, this);
56+
emit(self, ShadowEnv.ContextCreated, self);
5657
if (this.#syncAfterContextCreated) {
5758
this.#syncAfterContextCreated = false;
5859
this.#syncNow();
5960
}
6061
return () => {
61-
emit(this, ShadowEnv.ContextLost, this);
62+
emit(self, ShadowEnv.ContextLost, self);
6263
};
6364
}
6465
}, [findObjectSignalByName(this, 'viewReady'), findObjectSignalByName(this, 'proxyReady')]);
@@ -130,7 +131,7 @@ export class ShadowEnv {
130131
}
131132

132133
readonly ready = async (): Promise<ShadowEnv> => {
133-
return this.isReady ? this : onceAsync(this, ShadowEnv.ContextCreated);
134+
return this.isReady ? this : onceAsync(this as ShadowEnv, ShadowEnv.ContextCreated);
134135
};
135136

136137
sync(): void {
@@ -147,7 +148,7 @@ export class ShadowEnv {
147148
this.#syncWaitForConfirmation = true;
148149
this.sync();
149150
if (this.#afterNextSync) return this.#afterNextSync;
150-
this.#afterNextSync = onceAsync<ChangeTrailType>(this, ShadowEnv.AfterSync).then((changeTrail) => {
151+
this.#afterNextSync = onceAsync<ChangeTrailType>(this as ShadowEnv, ShadowEnv.AfterSync).then((changeTrail) => {
151152
this.#afterNextSync = undefined;
152153
return changeTrail;
153154
});
@@ -194,7 +195,7 @@ export class ShadowEnv {
194195
} catch (error) {
195196
this.logger.error('failed to apply change trail', error);
196197
} finally {
197-
emit(this, ShadowEnv.AfterSync, data);
198+
emit(this as ShadowEnv, ShadowEnv.AfterSync, data);
198199
}
199200
}
200201
}

0 commit comments

Comments
 (0)