Skip to content

Commit

Permalink
add window scope with webdocker as default
Browse files Browse the repository at this point in the history
  • Loading branch information
Armin Jazi committed May 16, 2024
1 parent 310b0a9 commit b200500
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openreplyde/web-docker",
"version": "1.1.0",
"version": "1.2.0",
"type": "module",
"files": [
"dist"
Expand Down
5 changes: 5 additions & 0 deletions src/core/ScopeRegistry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default class Scope {
constructor(private readonly scope: string) {
window[this.scope] = {};
}
}
3 changes: 3 additions & 0 deletions src/core/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import ModuleRegistry from "~/core/ModuleRegistry";
import { Config } from "~/core/Config";
import { ModuleConfigService } from "~/core/ModuleConfig";
import { RegisterEventType } from "~/core/RegisterEvent";
import ScopeRegistry from "~/core/ScopeRegistry";

export type WebDockerOptions = {
configFilePath?: string;
logEvents?: boolean;
scope?: string;
};

const initialize = async (options: WebDockerOptions) => {
new ScopeRegistry(options.scope ?? "webdocker");
const moduleConfigService = new ModuleConfigService();
const registry = new ModuleRegistry(options.logEvents ?? false);
const remoteConfigurationService = new RemoteConfigurationService(options);
Expand Down
3 changes: 2 additions & 1 deletion src/core/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import initialize from "~/core/initialize";

initialize({
configFilePath: import.meta.env.VITE_CONFIG_FILE_PATH,
logEvents: import.meta.env.VITE_APP_LOG_EVENTS || false
logEvents: import.meta.env.VITE_APP_LOG_EVENTS || false,
scope: "webdocker"
})
.then(() => {
console.log("Web Docker initialized");
Expand Down
3 changes: 3 additions & 0 deletions src/core/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import RegisterEvent, { RegisterEventType } from "~/core/RegisterEvent";

declare global {
interface Window {
[key: string]: unknown;
}
interface WindowEventMap {
[RegisterEventType]: RegisterEvent;
}
Expand Down

0 comments on commit b200500

Please sign in to comment.