Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/Browser/Content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import browser from 'webextension-polyfill'

const messageHandler = (event: MessageEvent) => {
// Only accept messages from same frame
if (event.source !== globalThis) return
if (event.source !== (globalThis as unknown as Window)) return

// Only accept messages that we know are ours
if (event.data.source !== 'meteor-devtools-evolved') return

browser.runtime.sendMessage(event.data).catch(() => {
// Cleans up and prevent "context invalidated" errors.
window.removeEventListener('message', messageHandler)
globalThis.removeEventListener('message', messageHandler)
})
}

window.addEventListener('message', messageHandler)
globalThis.addEventListener('message', messageHandler)

const url = browser.runtime.getURL('/dist/inject.js')
const script = document.createElement('script')
Expand Down
12 changes: 6 additions & 6 deletions src/Injectors/MinimongoInjector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@ const cleanup = (object: any) => {

for (const key of Object.keys(clonedObject)) {
if (!clonedObject[key]) {
return
// Falsy primitive value (null, 0, false, '') — leave as-is and keep going.
continue
}

if (typeof clonedObject[key] === 'object') {
if (isArray(clonedObject[key])) {
clonedObject[key] = clonedObject[key].map((item: any) => cleanup(item))
return
continue
}

if (clonedObject[key] instanceof Date) {
clonedObject[key] = `[Object::${
clonedObject[key].constructor.name
}] ${clonedObject[key].toISOString()}`
return
continue
}

if (clonedObject[key].constructor.name !== 'Object') {
if (typeof clonedObject[key].toString === 'function') {
clonedObject[key] = `[Object::${
clonedObject[key].constructor.name
}] ${clonedObject[key].toString()}`
return
} else {
clonedObject[key] = `[Object::${clonedObject[key].constructor.name}]`
return
}
continue
}

clonedObject[key] = cleanup(clonedObject[key])
Expand Down Expand Up @@ -73,7 +73,7 @@ const getCollections = () => {
const data = Object.fromEntries(
Object.values(collections).map((collection: any) => [
collection.name,
[...getDocs(collection)].map(item => cleanup(item)),
[...getDocs(collection)].map(item => cleanup(item)).filter(Boolean),
]),
)

Expand Down
2 changes: 1 addition & 1 deletion src/Pages/Panel/DDP/FilterConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const FilterCriteriaMap: {
Object.entries(FilterCriteria).flatMap(([key, matchers]) =>
matchers.map(matcher => [matcher, key]),
),
)
) as { [key: string]: FilterType }

export const detectType = (content?: DDPLogContent) => {
if (content && content.msg && content.msg in FilterCriteriaMap) {
Expand Down
4 changes: 4 additions & 0 deletions src/Pages/Panel/Minimongo/MinimongoContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export const MinimongoContainer: FunctionComponent<Props> = observer(
({ data, index, style }: IRow) => {
const item = data.items![index]

if (!item?.document) {
return null
}

return (
<MinimongoRow
style={style}
Expand Down
4 changes: 2 additions & 2 deletions src/Pages/Panel/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const Navigation: FunctionComponent = observer(() => {
icon: 'issue',
content: <strong>Issues</strong>,
handler: () => {
openTab([...repositoryData.html_url, '/issues'])
openTab(repositoryData.html_url + '/issues')
analytics?.event('navigation', 'click', { label: 'feedback' })
},
shine: true,
Expand All @@ -106,7 +106,7 @@ export const Navigation: FunctionComponent = observer(() => {
),
shine: true,
handler: () => {
openTab([...repositoryData.html_url, '/stargazers'])
openTab(repositoryData.html_url + '/stargazers')

analytics?.event('navigation', 'click', { label: 'star' })
},
Expand Down
8 changes: 3 additions & 5 deletions src/Stores/Panel/MinimongoStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ export class MinimongoStore {
@action
setCollections(collections: RawCollections) {
this.collections = mapValues(collections, (collection, collectionName) => {
return collection.map(document =>
MinimongoStore.wrapDocument(document, collectionName),
)
return collection
.filter(doc => doc != null)
.map(document => MinimongoStore.wrapDocument(document, collectionName))
})

this.computeCollectionSizes()
Expand Down Expand Up @@ -122,8 +122,6 @@ export class MinimongoStore {
): IDocumentWrapper {
const _string = JSONUtils.stringify(document)

console.log({ collectionName })

return {
collectionName,
document,
Expand Down
4 changes: 1 addition & 3 deletions src/Utils/StringUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ export namespace StringUtils {
export const classPrefix = 'mde'

export const truncate = (str: string, max: number = 40) => {
return isString(str) && str.length > max
? [...str.slice(0, max), '...']
: str
return isString(str) && str.length > max ? str.slice(0, max) + '...' : str
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
declare module '*.gif'
declare module '*.png'

// structuredClone is available in page context at runtime but not typed until TS 4.7.
declare function structuredClone<T>(
value: T,
options?: { transfer?: Transferable[] },
): T

type MeteorID = string

interface Window {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"strict": false,
"noImplicitAny": false,
"target": "ES6",
"lib": ["esnext", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"experimentalDecorators": true,
Expand Down