Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sandboxing issue #11

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import type { BunyanLikeLogger } from './decorator';
import { Bunyamin } from './decorator';
import { noopLogger } from './noopLogger';
import realm from './realm';

export * from './noopLogger';
export * from './traceEventStream';
export * from './uniteTraceEvents';
export * from './wrapLogger';
export * from './is-debug';

const threadGroups: any[] = [];
export const bunyamin = new Bunyamin<BunyanLikeLogger>({ logger: noopLogger(), threadGroups });
export const nobunyamin = new Bunyamin<BunyanLikeLogger>({
logger: noopLogger(),
threadGroups,
immutable: true,
});
export const bunyamin = realm.bunyamin;
export const nobunyamin = realm.nobunyamin;

export default bunyamin;
31 changes: 31 additions & 0 deletions src/realm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { BunyanLikeLogger } from './decorator';
import { Bunyamin } from './decorator';
import { noopLogger } from './noopLogger';

type Realm = {
bunyamin: Bunyamin<BunyanLikeLogger>;
nobunyamin: Bunyamin<BunyanLikeLogger>;
};

function create() {
const threadGroups: any[] = [];

Check warning on line 11 in src/realm.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const bunyamin = new Bunyamin<BunyanLikeLogger>({ logger: noopLogger(), threadGroups });
const nobunyamin = new Bunyamin<BunyanLikeLogger>({
logger: noopLogger(),
threadGroups,
immutable: true,
});

return { bunyamin, nobunyamin };
}

function getCached(): Realm | undefined {
return (globalThis as any).__BUNYAMIN__;

Check warning on line 23 in src/realm.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
}

function setCached(realm: Realm) {
(globalThis as any).__BUNYAMIN__ = realm;

Check warning on line 27 in src/realm.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
return realm;
}

export default setCached(getCached() ?? create());
Loading