Skip to content

Commit

Permalink
v2.7.10
Browse files Browse the repository at this point in the history
- Migrate "mime" package to a local source to avoid issues with the CDN being offline/having a build error.
  • Loading branch information
sneat authored Dec 18, 2023
1 parent f4e3793 commit 7a2e188
Show file tree
Hide file tree
Showing 24 changed files with 388 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v2.7.10

- Migrate "mime" package to a local source to avoid issues with the CDN being offline/having a build error.

## v2.7.9

- Updated the "Relink compendium Entries" macro:
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "scene-packer",
"title": "Library: Scene Packer",
"description": "A module to assist with Scene and Adventure packing and unpacking.",
"version": "2.7.9",
"version": "2.7.10",
"library": "true",
"manifestPlusVersion": "1.2.0",
"minimumCoreVersion": "0.8.6",
Expand Down
2 changes: 1 addition & 1 deletion scripts/export-import/zip-importer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mime from 'https://cdn.skypack.dev/mime/lite';
import mime from '../lib/mime/dist/src/index.js';
import * as fflate from '../lib/fflate/fflate.js';
import { CONSTANTS } from '../constants.js';
import MoulinetteImporter from './moulinette-importer.js';
Expand Down
21 changes: 21 additions & 0 deletions scripts/lib/mime/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Robert Kieffer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
143 changes: 143 additions & 0 deletions scripts/lib/mime/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<!--
-- This file is auto-generated from src/README_js.md. Changes should be made there.
-->
# Mime

[![NPM downloads](https://img.shields.io/npm/dm/mime)](https://www.npmjs.com/package/mime)
[![Mime CI](https://github.com/broofa/mime/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/broofa/mime/actions/workflows/ci.yml?query=branch%3Amain)

An API for MIME type information.

- All `mime-db` types
- Compact and dependency-free [![mime's badge](https://deno.bundlejs.com/?q=mime&badge)](https://bundlejs.com/?q=mime)
- Full TS support


> [!Note]
> `mime@4` is now `latest`. If you're upgrading from `mime@3`, note the following:
> * `mime@4` is API-compatible with `mime@3`, with ~~one~~ two exceptions:
> * Direct imports of `mime` properties [no longer supported](https://github.com/broofa/mime/issues/295)
> * `mime.define()` cannot be called on the default `mime` object
> * ESM module support is required. [ESM Module FAQ](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
> * Requires an [ES2020](https://caniuse.com/?search=es2020) or newer runtime
> * Built-in Typescript types (`@types/mime` no longer needed)
## Installation

```bash
npm install mime
```

## Quick Start

For the full version (800+ MIME types, 1,000+ extensions):

```javascript
import mime from 'mime';

mime.getType('txt'); // ⇨ 'text/plain'
mime.getExtension('text/plain'); // ⇨ 'txt'
```

### Lite Version [![mime/lite's badge](https://deno.bundlejs.com/?q=mime/lite&badge)](https://bundlejs.com/?q=mime/lite)

`mime/lite` is a drop-in `mime` replacement, stripped of unofficial ("`prs.*`", "`x-*`", "`vnd.*`") types:

```javascript
import mime from 'mime/lite';
```

## API

### `mime.getType(pathOrExtension)`

Get mime type for the given file path or extension. E.g.

```javascript
mime.getType('js'); // ⇨ 'application/javascript'
mime.getType('json'); // ⇨ 'application/json'

mime.getType('txt'); // ⇨ 'text/plain'
mime.getType('dir/text.txt'); // ⇨ 'text/plain'
mime.getType('dir\\text.txt'); // ⇨ 'text/plain'
mime.getType('.text.txt'); // ⇨ 'text/plain'
mime.getType('.txt'); // ⇨ 'text/plain'
```

`null` is returned in cases where an extension is not detected or recognized

```javascript
mime.getType('foo/txt'); // ⇨ null
mime.getType('bogus_type'); // ⇨ null
```

### `mime.getExtension(type)`

Get file extension for the given mime type. Charset options (often included in Content-Type headers) are ignored.

```javascript
mime.getExtension('text/plain'); // ⇨ 'txt'
mime.getExtension('application/json'); // ⇨ 'json'
mime.getExtension('text/html; charset=utf8'); // ⇨ 'html'
```

### `mime.getAllExtensions(type)`

> [!Note]
> New in `mime@4`
Get all file extensions for the given mime type.

```javascript --run default
mime.getAllExtensions('image/jpeg'); // ⇨ Set(3) { 'jpeg', 'jpg', 'jpe' }
```

## Custom `Mime` instances

The default `mime` objects are immutable. Custom, mutable versions can be created as follows...
### new Mime(type map [, type map, ...])

Create a new, custom mime instance. For example, to create a mutable version of the default `mime` instance:

```javascript
import { Mime } from 'mime/lite';

import standardTypes from 'mime/types/standard.js';
import otherTypes from 'mime/types/other.js';

const mime = new Mime(standardTypes, otherTypes);
```

Each argument is passed to the `define()` method, below. For example `new Mime(standardTypes, otherTypes)` is synonomous with `new Mime().define(standardTypes).define(otherTypes)`

### `mime.define(type map [, force = false])`

> [!Note]
> Only available on custom `Mime` instances
Define MIME type -> extensions.

Attempting to map a type to an already-defined extension will `throw` unless the `force` argument is set to `true`.

```javascript
mime.define({'text/x-abc': ['abc', 'abcd']});

mime.getType('abcd'); // ⇨ 'text/x-abc'
mime.getExtension('text/x-abc') // ⇨ 'abc'
```

## Command Line

### Extension -> type

```bash
$ mime scripts/jquery.js
application/javascript
```

### Type -> extension

```bash
$ mime -r image/jpeg
jpeg
```
6 changes: 6 additions & 0 deletions scripts/lib/mime/bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node

// Thin wrapper around mime
import mime_cli from '../dist/src/mime_cli.js';

await mime_cli();
17 changes: 17 additions & 0 deletions scripts/lib/mime/dist/src/Mime.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
type TypeMap = {
[key: string]: string[];
};
export default class Mime {
#private;
constructor(...args: TypeMap[]);
define(typeMap: TypeMap, force?: boolean): this;
getType(path: string): string | null;
getExtension(type: string): string | null;
getAllExtensions(type: string): Set<string> | null;
_freeze(): this;
_getTestState(): {
types: Map<string, string>;
extensions: Map<string, string>;
};
}
export {};
85 changes: 85 additions & 0 deletions scripts/lib/mime/dist/src/Mime.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/lib/mime/dist/src/Mime.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions scripts/lib/mime/dist/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Mime from './Mime.js';
export { default as Mime } from './Mime.js';
declare const _default: Mime;
export default _default;
6 changes: 6 additions & 0 deletions scripts/lib/mime/dist/src/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/lib/mime/dist/src/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions scripts/lib/mime/dist/src/index_lite.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Mime from './Mime.js';
export { default as Mime } from './Mime.js';
declare const _default: Mime;
export default _default;
5 changes: 5 additions & 0 deletions scripts/lib/mime/dist/src/index_lite.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/lib/mime/dist/src/index_lite.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions scripts/lib/mime/dist/src/mime_cli.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
export default function (): Promise<void>;
Loading

0 comments on commit 7a2e188

Please sign in to comment.