Skip to content

Commit

Permalink
fix: storage plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
wqcstrong committed Mar 14, 2023
1 parent 6c7dcef commit 1b9eb23
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.config.?[jt]s
*.config.[jt]s
*.config.mjs
.eslintrc.js
dist/
tests/
Expand Down
4 changes: 0 additions & 4 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ export default {
format: 'iife',
name: 'PageSpy',
},
{
file: pkg.module,
format: 'es',
},
],
plugins,
};
12 changes: 11 additions & 1 deletion src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions src/index.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@primary-color: #9a62e4;
@gradient: linear-gradient(45deg, #efdfff, #4e00b1 52%, #3d0c7c);
@size: 80em;
@fontSize: 14px;

Expand All @@ -15,7 +17,7 @@
font-size: (14em / @fontSize);
border-radius: (@size / @fontSize);
background-color: #fff;
box-shadow: 0px 3px 10px 3px rgba(0, 0, 0, 0.2);
box-shadow: 0px 4px 8px 2px rgba(0, 0, 0, 0.2);
cursor: pointer;
z-index: 13000;
}
Expand Down Expand Up @@ -66,8 +68,10 @@
padding: (8em / @fontSize) 0;
border-top: 1px solid #eee;
font-size: (16em / @fontSize);
color: rgb(5, 145, 245);
line-height: 1.5;
color: transparent;
background-clip: text;
background-image: @gradient;
}
}
}
21 changes: 13 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ import { mergeConfig } from './utils/config';
const Identifier = '__pageSpy';

export default class PageSpy {
private root: HTMLElement | null = null;
root: HTMLElement | null = null;

private version = pkg.version;
version = pkg.version;

private plugins: Record<string, PageSpyPlugin> = {};
plugins: Record<string, PageSpyPlugin> = {};

config: Required<InitConfig> = {
api: '',
clientOrigin: '',
};

// System info: <os>-<browser>:<browserVersion>
private name = '';
Expand All @@ -49,9 +54,9 @@ export default class PageSpy {

private socketStore = socketStore;

constructor(init: InitConfig) {
const config = mergeConfig(init);
const { api, clientOrigin } = config;
constructor(init: InitConfig = {}) {
this.config = mergeConfig(init);
const { api, clientOrigin } = this.config;

this.request = new Request(api);
this.clientOrigin = clientOrigin;
Expand Down Expand Up @@ -151,10 +156,10 @@ export default class PageSpy {
}
this.render();
} else {
timer = setTimeout(pollingDocument, 1);
timer = window.setTimeout(pollingDocument, 1);
}
};
timer = setTimeout(pollingDocument, 1);
timer = window.setTimeout(pollingDocument, 1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class StoragePlugin implements PageSpyPlugin {

const session = { ...sessionStorage };
Object.keys(session).forEach((key) => {
const value = local[key];
const value = session[key];
sendStorageItem({ type: 'session', action: 'get', key, value });
});

Expand Down
7 changes: 4 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
export interface InitConfig {
/**
* The server base url. For example, "example.com".
* - Create room: `${api}/room/create`
* - Filter romm: `${api}/room/list`
* - Create room: `https://${api}/room/create`
* - Filter room: `https://${api}/room/list`
* - Join WebSocket room: `wss://${api}/ws/room/join`
*/
api?: string;

/**
* Client host. Form example, "https://example.com".
*
*/
clientOrigin?: string;
}
Expand Down
Loading

0 comments on commit 1b9eb23

Please sign in to comment.