Skip to content

Commit

Permalink
feat(api/mime): introduce MIME database
Browse files Browse the repository at this point in the history
  • Loading branch information
jwerle committed Nov 8, 2023
1 parent 3be4edf commit ea36ab3
Show file tree
Hide file tree
Showing 13 changed files with 2,324 additions and 1 deletion.
75 changes: 75 additions & 0 deletions api/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4858,6 +4858,71 @@ declare module "socket:i18n" {
export default _default;
import Enumeration from "socket:enumeration";
}
declare module "socket:mime/index" {
/**
* Look up a MIME type in various MIME databases.
* @return {Promise<Array<{ name: string, mime: string }>>}
*/
export function lookup(query: any): Promise<Array<{
name: string;
mime: string;
}>>;
/**
* A container for MIME types by class (audio, video, text, etc)
* @see {@link https://www.iana.org/assignments/media-types/media-types.xhtml}
*/
export class Database {
/**
* `Database` class constructor.
* @param {string} name
*/
constructor(name: string);
/**
* @type {string}
*/
name: string;
/**
* @type {URL}
*/
url: URL;
/**
* @type {Map}
*/
map: Map<any, any>;
/**
* Loads database MIME entries into internal map.
* @return {Promise}
*/
load(): Promise<any>;
/**
* Lookup MIME type by name.
* @param {string} query
* @return {Promise<{ name: string, mime: string}>}
*/
lookup(query: string): Promise<{
name: string;
mime: string;
}>;
}
export const application: Database;
export const audio: Database;
export const font: Database;
export const image: Database;
export const model: Database;
export const multipart: Database;
export const text: Database;
export const video: Database;
namespace _default {
export { application };
export { Database };
}
export default _default;
}
declare module "socket:mime" {
export * from "socket:mime/index";
export default exports;
import * as exports from "socket:mime/index";
}
declare module "socket:test/fast-deep-equal" {
export default function equal(a: any, b: any): boolean;
}
Expand Down Expand Up @@ -7180,6 +7245,16 @@ declare module "socket:internal/globals" {
get(name: any): any;
};
}
declare module "socket:internal/pickers" {
/**
* TODO
*/
export function showOpenFilePicker(options?: any): Promise<void>;
namespace _default {
export { showOpenFilePicker };
}
export default _default;
}
declare module "socket:internal/monkeypatch" {
export function init(): void;
const _default: void;
Expand Down
9 changes: 8 additions & 1 deletion api/internal/monkeypatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import Notification from '../notification.js'
import geolocation from './geolocation.js'
import permissions from './permissions.js'

import {
showOpenFilePicker
} from './pickers.js'

import ipc from '../ipc.js'

let applied = false
Expand Down Expand Up @@ -79,7 +83,10 @@ export function init () {
Response,

// notifications
Notification
Notification,

// pickers
showOpenFilePicker
})

// navigator
Expand Down
8 changes: 8 additions & 0 deletions api/mime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @module mime
* @notice This is a rexports of `mime/index.js` so consumers will
* need to only `import mime from 'socket:mime'`
*/
import * as exports from './mime/index.js'
export * from './mime/index.js'
export default exports
Loading

0 comments on commit ea36ab3

Please sign in to comment.