wrangler 0.0.0-e6733a3 → 0.0.0-e6ada079
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of wrangler might be problematic. Click here for more details.
- package/README.md +47 -16
- package/bin/wrangler.js +94 -31
- package/config-schema.json +3100 -0
- package/kv-asset-handler.js +1 -0
- package/package.json +154 -82
- package/templates/__tests__/pages-dev-util.test.ts +128 -0
- package/templates/__tests__/tsconfig-sanity.ts +12 -0
- package/templates/__tests__/tsconfig.json +8 -0
- package/templates/checked-fetch.js +30 -0
- package/templates/facade.d.ts +19 -0
- package/templates/gitignore +170 -0
- package/templates/init-tests/test-jest-new-worker.js +23 -0
- package/templates/init-tests/test-vitest-new-worker.js +24 -0
- package/templates/init-tests/test-vitest-new-worker.ts +25 -0
- package/templates/middleware/common.ts +67 -0
- package/templates/middleware/loader-modules.ts +134 -0
- package/templates/middleware/loader-sw.ts +229 -0
- package/templates/middleware/middleware-ensure-req-body-drained.ts +18 -0
- package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
- package/templates/middleware/middleware-pretty-error.ts +40 -0
- package/templates/middleware/middleware-scheduled.ts +15 -0
- package/templates/middleware/middleware-serve-static-assets.d.ts +6 -0
- package/templates/middleware/middleware-serve-static-assets.ts +56 -0
- package/templates/modules-watch-stub.js +4 -0
- package/templates/new-worker-scheduled.js +17 -0
- package/templates/new-worker-scheduled.ts +32 -0
- package/templates/new-worker.js +15 -0
- package/templates/new-worker.ts +33 -0
- package/templates/no-op-worker.js +10 -0
- package/templates/pages-dev-pipeline.ts +32 -0
- package/templates/pages-dev-util.ts +55 -0
- package/templates/pages-shim.ts +9 -0
- package/templates/pages-template-plugin.ts +190 -0
- package/templates/pages-template-worker.ts +198 -0
- package/templates/startDevWorker/InspectorProxyWorker.ts +664 -0
- package/templates/startDevWorker/ProxyWorker.ts +334 -0
- package/templates/tsconfig-sanity.ts +11 -0
- package/templates/tsconfig.init.json +22 -0
- package/templates/tsconfig.json +8 -0
- package/wrangler-dist/InspectorProxyWorker.js +464 -0
- package/wrangler-dist/InspectorProxyWorker.js.map +6 -0
- package/wrangler-dist/ProxyWorker.js +240 -0
- package/wrangler-dist/ProxyWorker.js.map +6 -0
- package/wrangler-dist/cli.d.ts +26391 -0
- package/wrangler-dist/cli.js +204293 -116652
- package/wrangler-dist/wasm-sync.wasm +0 -0
- package/import_meta_url.js +0 -3
- package/miniflare-config-stubs/.env.empty +0 -0
- package/miniflare-config-stubs/package.empty.json +0 -1
- package/miniflare-config-stubs/wrangler.empty.toml +0 -0
- package/pages/functions/buildWorker.ts +0 -62
- package/pages/functions/filepath-routing.test.ts +0 -39
- package/pages/functions/filepath-routing.ts +0 -221
- package/pages/functions/identifiers.ts +0 -78
- package/pages/functions/routes.ts +0 -158
- package/pages/functions/template-worker.ts +0 -144
- package/src/__tests__/clipboardy-mock.js +0 -4
- package/src/__tests__/dev.test.tsx +0 -66
- package/src/__tests__/index.test.ts +0 -287
- package/src/__tests__/jest.setup.ts +0 -22
- package/src/__tests__/kv.test.ts +0 -1098
- package/src/__tests__/mock-cfetch.ts +0 -171
- package/src/__tests__/mock-dialogs.ts +0 -65
- package/src/__tests__/run-in-tmp.ts +0 -19
- package/src/__tests__/run-wrangler.ts +0 -32
- package/src/api/form_data.ts +0 -131
- package/src/api/preview.ts +0 -128
- package/src/api/worker.ts +0 -155
- package/src/cfetch/index.ts +0 -102
- package/src/cfetch/internal.ts +0 -69
- package/src/cli.ts +0 -9
- package/src/config.ts +0 -487
- package/src/dev.tsx +0 -771
- package/src/dialogs.tsx +0 -77
- package/src/index.tsx +0 -1974
- package/src/inspect.ts +0 -524
- package/src/kv.tsx +0 -267
- package/src/module-collection.ts +0 -64
- package/src/pages.tsx +0 -1031
- package/src/proxy.ts +0 -294
- package/src/publish.ts +0 -358
- package/src/sites.tsx +0 -114
- package/src/tail.tsx +0 -73
- package/src/user.tsx +0 -1025
- package/static-asset-facade.js +0 -47
- package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
- package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
- package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
- package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
- package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
- package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
- package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
- package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
- package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
- package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
- package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
- package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
- package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
- package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
- package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
- package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
- package/vendor/wrangler-mime/CHANGELOG.md +0 -289
- package/vendor/wrangler-mime/LICENSE +0 -21
- package/vendor/wrangler-mime/Mime.js +0 -97
- package/vendor/wrangler-mime/README.md +0 -187
- package/vendor/wrangler-mime/cli.js +0 -46
- package/vendor/wrangler-mime/index.js +0 -4
- package/vendor/wrangler-mime/lite.js +0 -4
- package/vendor/wrangler-mime/package.json +0 -52
- package/vendor/wrangler-mime/types/other.js +0 -1
- package/vendor/wrangler-mime/types/standard.js +0 -1
- package/wrangler-dist/cli.js.map +0 -7
@@ -1,289 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
4
|
-
|
5
|
-
### [2.5.2](https://github.com/broofa/mime/compare/v2.5.0...v2.5.2) (2021-02-17)
|
6
|
-
|
7
|
-
|
8
|
-
### Bug Fixes
|
9
|
-
|
10
|
-
* update to mime-db@1.46.0, fixes [#253](https://github.com/broofa/mime/issues/253) ([f10e6aa](https://github.com/broofa/mime/commit/f10e6aa62e1356de7e2491d7fb4374c8dac65800))
|
11
|
-
|
12
|
-
## [2.5.0](https://github.com/broofa/mime/compare/v2.4.7...v2.5.0) (2021-01-16)
|
13
|
-
|
14
|
-
|
15
|
-
### Features
|
16
|
-
|
17
|
-
* improved CLI ([#244](https://github.com/broofa/mime/issues/244)) ([c8a8356](https://github.com/broofa/mime/commit/c8a8356e3b27f3ef46b64b89b428fdb547b14d5f))
|
18
|
-
|
19
|
-
### [2.4.7](https://github.com/broofa/mime/compare/v2.4.6...v2.4.7) (2020-12-16)
|
20
|
-
|
21
|
-
|
22
|
-
### Bug Fixes
|
23
|
-
|
24
|
-
* update to latest mime-db ([43b09ef](https://github.com/broofa/mime/commit/43b09eff0233eacc449af2b1f99a19ba9e104a44))
|
25
|
-
|
26
|
-
### [2.4.6](https://github.com/broofa/mime/compare/v2.4.5...v2.4.6) (2020-05-27)
|
27
|
-
|
28
|
-
|
29
|
-
### Bug Fixes
|
30
|
-
|
31
|
-
* add cli.js to package.json files ([#237](https://github.com/broofa/mime/issues/237)) ([6c070bc](https://github.com/broofa/mime/commit/6c070bc298fa12a48e2ed126fbb9de641a1e7ebc))
|
32
|
-
|
33
|
-
### [2.4.5](https://github.com/broofa/mime/compare/v2.4.4...v2.4.5) (2020-05-01)
|
34
|
-
|
35
|
-
|
36
|
-
### Bug Fixes
|
37
|
-
|
38
|
-
* fix [#236](https://github.com/broofa/mime/issues/236) ([7f4ecd0](https://github.com/broofa/mime/commit/7f4ecd0d850ed22c9e3bfda2c11fc74e4dde12a7))
|
39
|
-
* update to latest mime-db ([c5cb3f2](https://github.com/broofa/mime/commit/c5cb3f2ab8b07642a066efbde1142af1b90c927b))
|
40
|
-
|
41
|
-
### [2.4.4](https://github.com/broofa/mime/compare/v2.4.3...v2.4.4) (2019-06-07)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
### [2.4.3](https://github.com/broofa/mime/compare/v2.4.2...v2.4.3) (2019-05-15)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
### [2.4.2](https://github.com/broofa/mime/compare/v2.4.1...v2.4.2) (2019-04-07)
|
50
|
-
|
51
|
-
|
52
|
-
### Bug Fixes
|
53
|
-
|
54
|
-
* don't use arrow function introduced in 2.4.1 ([2e00b5c](https://github.com/broofa/mime/commit/2e00b5c))
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
### [2.4.1](https://github.com/broofa/mime/compare/v2.4.0...v2.4.1) (2019-04-03)
|
59
|
-
|
60
|
-
|
61
|
-
### Bug Fixes
|
62
|
-
|
63
|
-
* update MDN and mime-db types ([3e567a9](https://github.com/broofa/mime/commit/3e567a9))
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
# [2.4.0](https://github.com/broofa/mime/compare/v2.3.1...v2.4.0) (2018-11-26)
|
68
|
-
|
69
|
-
|
70
|
-
### Features
|
71
|
-
|
72
|
-
* Bind exported methods ([9d2a7b8](https://github.com/broofa/mime/commit/9d2a7b8))
|
73
|
-
* update to mime-db@1.37.0 ([49e6e41](https://github.com/broofa/mime/commit/49e6e41))
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
### [2.3.1](https://github.com/broofa/mime/compare/v2.3.0...v2.3.1) (2018-04-11)
|
78
|
-
|
79
|
-
|
80
|
-
### Bug Fixes
|
81
|
-
|
82
|
-
* fix [#198](https://github.com/broofa/mime/issues/198) ([25ca180](https://github.com/broofa/mime/commit/25ca180))
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
# [2.3.0](https://github.com/broofa/mime/compare/v2.2.2...v2.3.0) (2018-04-11)
|
87
|
-
|
88
|
-
|
89
|
-
### Bug Fixes
|
90
|
-
|
91
|
-
* fix [#192](https://github.com/broofa/mime/issues/192) ([5c35df6](https://github.com/broofa/mime/commit/5c35df6))
|
92
|
-
|
93
|
-
|
94
|
-
### Features
|
95
|
-
|
96
|
-
* add travis-ci testing ([d64160f](https://github.com/broofa/mime/commit/d64160f))
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
### [2.2.2](https://github.com/broofa/mime/compare/v2.2.1...v2.2.2) (2018-03-30)
|
101
|
-
|
102
|
-
|
103
|
-
### Bug Fixes
|
104
|
-
|
105
|
-
* update types files to mime-db@1.32.0 ([85aac16](https://github.com/broofa/mime/commit/85aac16))
|
106
|
-
|
107
|
-
|
108
|
-
### [2.2.1](https://github.com/broofa/mime/compare/v2.2.0...v2.2.1) (2018-03-30)
|
109
|
-
|
110
|
-
|
111
|
-
### Bug Fixes
|
112
|
-
|
113
|
-
* Retain type->extension mappings for non-default types. Fixes [#180](https://github.com/broofa/mime/issues/180) ([b5c83fb](https://github.com/broofa/mime/commit/b5c83fb))
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
# [2.2.0](https://github.com/broofa/mime/compare/v2.1.0...v2.2.0) (2018-01-04)
|
118
|
-
|
119
|
-
|
120
|
-
### Features
|
121
|
-
|
122
|
-
* Retain type->extension mappings for non-default types. Fixes [#180](https://github.com/broofa/mime/issues/180) ([10f82ac](https://github.com/broofa/mime/commit/10f82ac))
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
# [2.1.0](https://github.com/broofa/mime/compare/v2.0.5...v2.1.0) (2017-12-22)
|
127
|
-
|
128
|
-
|
129
|
-
### Features
|
130
|
-
|
131
|
-
* Upgrade to mime-db@1.32.0. Fixes [#185](https://github.com/broofa/mime/issues/185) ([3f775ba](https://github.com/broofa/mime/commit/3f775ba))
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
### [2.0.5](https://github.com/broofa/mime/compare/v2.0.1...v2.0.5) (2017-12-22)
|
136
|
-
|
137
|
-
|
138
|
-
### Bug Fixes
|
139
|
-
|
140
|
-
* ES5 support (back to node v0.4) ([f14ccb6](https://github.com/broofa/mime/commit/f14ccb6))
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
# Changelog
|
145
|
-
|
146
|
-
### v2.0.4 (24/11/2017)
|
147
|
-
- [**closed**] Switch to mime-score module for resolving extension contention issues. [#182](https://github.com/broofa/mime/issues/182)
|
148
|
-
- [**closed**] Update mime-db to 1.31.0 in v1.x branch [#181](https://github.com/broofa/mime/issues/181)
|
149
|
-
|
150
|
-
---
|
151
|
-
|
152
|
-
## v1.5.0 (22/11/2017)
|
153
|
-
- [**closed**] need ES5 version ready in npm package [#179](https://github.com/broofa/mime/issues/179)
|
154
|
-
- [**closed**] mime-db no trace of iWork - pages / numbers / etc. [#178](https://github.com/broofa/mime/issues/178)
|
155
|
-
- [**closed**] How it works in brownser ? [#176](https://github.com/broofa/mime/issues/176)
|
156
|
-
- [**closed**] Missing `./Mime` [#175](https://github.com/broofa/mime/issues/175)
|
157
|
-
- [**closed**] Vulnerable Regular Expression [#167](https://github.com/broofa/mime/issues/167)
|
158
|
-
|
159
|
-
---
|
160
|
-
|
161
|
-
### v2.0.3 (25/09/2017)
|
162
|
-
*No changelog for this release.*
|
163
|
-
|
164
|
-
---
|
165
|
-
|
166
|
-
### v1.4.1 (25/09/2017)
|
167
|
-
- [**closed**] Issue when bundling with webpack [#172](https://github.com/broofa/mime/issues/172)
|
168
|
-
|
169
|
-
---
|
170
|
-
|
171
|
-
### v2.0.2 (15/09/2017)
|
172
|
-
- [**V2**] fs.readFileSync is not a function [#165](https://github.com/broofa/mime/issues/165)
|
173
|
-
- [**closed**] The extension for video/quicktime should map to .mov, not .qt [#164](https://github.com/broofa/mime/issues/164)
|
174
|
-
- [**V2**] [v2 Feedback request] Mime class API [#163](https://github.com/broofa/mime/issues/163)
|
175
|
-
- [**V2**] [v2 Feedback request] Resolving conflicts over extensions [#162](https://github.com/broofa/mime/issues/162)
|
176
|
-
- [**V2**] Allow callers to load module with official, full, or no defined types. [#161](https://github.com/broofa/mime/issues/161)
|
177
|
-
- [**V2**] Use "facets" to resolve extension conflicts [#160](https://github.com/broofa/mime/issues/160)
|
178
|
-
- [**V2**] Remove fs and path dependencies [#152](https://github.com/broofa/mime/issues/152)
|
179
|
-
- [**V2**] Default content-type should not be application/octet-stream [#139](https://github.com/broofa/mime/issues/139)
|
180
|
-
- [**V2**] reset mime-types [#124](https://github.com/broofa/mime/issues/124)
|
181
|
-
- [**V2**] Extensionless paths should return null or false [#113](https://github.com/broofa/mime/issues/113)
|
182
|
-
|
183
|
-
---
|
184
|
-
|
185
|
-
### v2.0.1 (14/09/2017)
|
186
|
-
- [**closed**] Changelog for v2.0 does not mention breaking changes [#171](https://github.com/broofa/mime/issues/171)
|
187
|
-
- [**closed**] MIME breaking with 'class' declaration as it is without 'use strict mode' [#170](https://github.com/broofa/mime/issues/170)
|
188
|
-
|
189
|
-
---
|
190
|
-
|
191
|
-
## v2.0.0 (12/09/2017)
|
192
|
-
- [**closed**] woff and woff2 [#168](https://github.com/broofa/mime/issues/168)
|
193
|
-
|
194
|
-
---
|
195
|
-
|
196
|
-
## v1.4.0 (28/08/2017)
|
197
|
-
- [**closed**] support for ac3 voc files [#159](https://github.com/broofa/mime/issues/159)
|
198
|
-
- [**closed**] Help understanding change from application/xml to text/xml [#158](https://github.com/broofa/mime/issues/158)
|
199
|
-
- [**closed**] no longer able to override mimetype [#157](https://github.com/broofa/mime/issues/157)
|
200
|
-
- [**closed**] application/vnd.adobe.photoshop [#147](https://github.com/broofa/mime/issues/147)
|
201
|
-
- [**closed**] Directories should appear as something other than application/octet-stream [#135](https://github.com/broofa/mime/issues/135)
|
202
|
-
- [**closed**] requested features [#131](https://github.com/broofa/mime/issues/131)
|
203
|
-
- [**closed**] Make types.json loading optional? [#129](https://github.com/broofa/mime/issues/129)
|
204
|
-
- [**closed**] Cannot find module './types.json' [#120](https://github.com/broofa/mime/issues/120)
|
205
|
-
- [**V2**] .wav files show up as "audio/x-wav" instead of "audio/x-wave" [#118](https://github.com/broofa/mime/issues/118)
|
206
|
-
- [**closed**] Don't be a pain in the ass for node community [#108](https://github.com/broofa/mime/issues/108)
|
207
|
-
- [**closed**] don't make default_type global [#78](https://github.com/broofa/mime/issues/78)
|
208
|
-
- [**closed**] mime.extension() fails if the content-type is parameterized [#74](https://github.com/broofa/mime/issues/74)
|
209
|
-
|
210
|
-
---
|
211
|
-
|
212
|
-
### v1.3.6 (11/05/2017)
|
213
|
-
- [**closed**] .md should be text/markdown as of March 2016 [#154](https://github.com/broofa/mime/issues/154)
|
214
|
-
- [**closed**] Error while installing mime [#153](https://github.com/broofa/mime/issues/153)
|
215
|
-
- [**closed**] application/manifest+json [#149](https://github.com/broofa/mime/issues/149)
|
216
|
-
- [**closed**] Dynamic adaptive streaming over HTTP (DASH) file extension typo [#141](https://github.com/broofa/mime/issues/141)
|
217
|
-
- [**closed**] charsets image/png undefined [#140](https://github.com/broofa/mime/issues/140)
|
218
|
-
- [**closed**] Mime-db dependency out of date [#130](https://github.com/broofa/mime/issues/130)
|
219
|
-
- [**closed**] how to support plist? [#126](https://github.com/broofa/mime/issues/126)
|
220
|
-
- [**closed**] how does .types file format look like? [#123](https://github.com/broofa/mime/issues/123)
|
221
|
-
- [**closed**] Feature: support for expanding MIME patterns [#121](https://github.com/broofa/mime/issues/121)
|
222
|
-
- [**closed**] DEBUG_MIME doesn't work [#117](https://github.com/broofa/mime/issues/117)
|
223
|
-
|
224
|
-
---
|
225
|
-
|
226
|
-
### v1.3.4 (06/02/2015)
|
227
|
-
*No changelog for this release.*
|
228
|
-
|
229
|
-
---
|
230
|
-
|
231
|
-
### v1.3.3 (06/02/2015)
|
232
|
-
*No changelog for this release.*
|
233
|
-
|
234
|
-
---
|
235
|
-
|
236
|
-
### v1.3.1 (05/02/2015)
|
237
|
-
- [**closed**] Consider adding support for Handlebars .hbs file ending [#111](https://github.com/broofa/mime/issues/111)
|
238
|
-
- [**closed**] Consider adding support for hjson. [#110](https://github.com/broofa/mime/issues/110)
|
239
|
-
- [**closed**] Add mime type for Opus audio files [#94](https://github.com/broofa/mime/issues/94)
|
240
|
-
- [**closed**] Consider making the `Requesting New Types` information more visible [#77](https://github.com/broofa/mime/issues/77)
|
241
|
-
|
242
|
-
---
|
243
|
-
|
244
|
-
## v1.3.0 (05/02/2015)
|
245
|
-
- [**closed**] Add common name? [#114](https://github.com/broofa/mime/issues/114)
|
246
|
-
- [**closed**] application/x-yaml [#104](https://github.com/broofa/mime/issues/104)
|
247
|
-
- [**closed**] Add mime type for WOFF file format 2.0 [#102](https://github.com/broofa/mime/issues/102)
|
248
|
-
- [**closed**] application/x-msi for .msi [#99](https://github.com/broofa/mime/issues/99)
|
249
|
-
- [**closed**] Add mimetype for gettext translation files [#98](https://github.com/broofa/mime/issues/98)
|
250
|
-
- [**closed**] collaborators [#88](https://github.com/broofa/mime/issues/88)
|
251
|
-
- [**closed**] getting errot in installation of mime module...any1 can help? [#87](https://github.com/broofa/mime/issues/87)
|
252
|
-
- [**closed**] should application/json's charset be utf8? [#86](https://github.com/broofa/mime/issues/86)
|
253
|
-
- [**closed**] Add "license" and "licenses" to package.json [#81](https://github.com/broofa/mime/issues/81)
|
254
|
-
- [**closed**] lookup with extension-less file on Windows returns wrong type [#68](https://github.com/broofa/mime/issues/68)
|
255
|
-
|
256
|
-
---
|
257
|
-
|
258
|
-
### v1.2.11 (15/08/2013)
|
259
|
-
- [**closed**] Update mime.types [#65](https://github.com/broofa/mime/issues/65)
|
260
|
-
- [**closed**] Publish a new version [#63](https://github.com/broofa/mime/issues/63)
|
261
|
-
- [**closed**] README should state upfront that "application/octet-stream" is default for unknown extension [#55](https://github.com/broofa/mime/issues/55)
|
262
|
-
- [**closed**] Suggested improvement to the charset API [#52](https://github.com/broofa/mime/issues/52)
|
263
|
-
|
264
|
-
---
|
265
|
-
|
266
|
-
### v1.2.10 (25/07/2013)
|
267
|
-
- [**closed**] Mime type for woff files should be application/font-woff and not application/x-font-woff [#62](https://github.com/broofa/mime/issues/62)
|
268
|
-
- [**closed**] node.types in conflict with mime.types [#51](https://github.com/broofa/mime/issues/51)
|
269
|
-
|
270
|
-
---
|
271
|
-
|
272
|
-
### v1.2.9 (17/01/2013)
|
273
|
-
- [**closed**] Please update "mime" NPM [#49](https://github.com/broofa/mime/issues/49)
|
274
|
-
- [**closed**] Please add semicolon [#46](https://github.com/broofa/mime/issues/46)
|
275
|
-
- [**closed**] parse full mime types [#43](https://github.com/broofa/mime/issues/43)
|
276
|
-
|
277
|
-
---
|
278
|
-
|
279
|
-
### v1.2.8 (10/01/2013)
|
280
|
-
- [**closed**] /js directory mime is application/javascript. Is it correct? [#47](https://github.com/broofa/mime/issues/47)
|
281
|
-
- [**closed**] Add mime types for lua code. [#45](https://github.com/broofa/mime/issues/45)
|
282
|
-
|
283
|
-
---
|
284
|
-
|
285
|
-
### v1.2.7 (19/10/2012)
|
286
|
-
- [**closed**] cannot install 1.2.7 via npm [#41](https://github.com/broofa/mime/issues/41)
|
287
|
-
- [**closed**] Transfer ownership to @broofa [#36](https://github.com/broofa/mime/issues/36)
|
288
|
-
- [**closed**] it's wrong to set charset to UTF-8 for text [#30](https://github.com/broofa/mime/issues/30)
|
289
|
-
- [**closed**] Allow multiple instances of MIME types container [#27](https://github.com/broofa/mime/issues/27)
|
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2010 Benjamin Thomas, Robert Kieffer
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
@@ -1,97 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* @param typeMap [Object] Map of MIME type -> Array[extensions]
|
5
|
-
* @param ...
|
6
|
-
*/
|
7
|
-
function Mime() {
|
8
|
-
this._types = Object.create(null);
|
9
|
-
this._extensions = Object.create(null);
|
10
|
-
|
11
|
-
for (let i = 0; i < arguments.length; i++) {
|
12
|
-
this.define(arguments[i]);
|
13
|
-
}
|
14
|
-
|
15
|
-
this.define = this.define.bind(this);
|
16
|
-
this.getType = this.getType.bind(this);
|
17
|
-
this.getExtension = this.getExtension.bind(this);
|
18
|
-
}
|
19
|
-
|
20
|
-
/**
|
21
|
-
* Define mimetype -> extension mappings. Each key is a mime-type that maps
|
22
|
-
* to an array of extensions associated with the type. The first extension is
|
23
|
-
* used as the default extension for the type.
|
24
|
-
*
|
25
|
-
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
|
26
|
-
*
|
27
|
-
* If a type declares an extension that has already been defined, an error will
|
28
|
-
* be thrown. To suppress this error and force the extension to be associated
|
29
|
-
* with the new type, pass `force`=true. Alternatively, you may prefix the
|
30
|
-
* extension with "*" to map the type to extension, without mapping the
|
31
|
-
* extension to the type.
|
32
|
-
*
|
33
|
-
* e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']});
|
34
|
-
*
|
35
|
-
*
|
36
|
-
* @param map (Object) type definitions
|
37
|
-
* @param force (Boolean) if true, force overriding of existing definitions
|
38
|
-
*/
|
39
|
-
Mime.prototype.define = function(typeMap, force) {
|
40
|
-
for (let type in typeMap) {
|
41
|
-
let extensions = typeMap[type].map(function(t) {
|
42
|
-
return t.toLowerCase();
|
43
|
-
});
|
44
|
-
type = type.toLowerCase();
|
45
|
-
|
46
|
-
for (let i = 0; i < extensions.length; i++) {
|
47
|
-
const ext = extensions[i];
|
48
|
-
|
49
|
-
// '*' prefix = not the preferred type for this extension. So fixup the
|
50
|
-
// extension, and skip it.
|
51
|
-
if (ext[0] === '*') {
|
52
|
-
continue;
|
53
|
-
}
|
54
|
-
|
55
|
-
if (!force && (ext in this._types)) {
|
56
|
-
throw new Error(
|
57
|
-
'Attempt to change mapping for "' + ext +
|
58
|
-
'" extension from "' + this._types[ext] + '" to "' + type +
|
59
|
-
'". Pass `force=true` to allow this, otherwise remove "' + ext +
|
60
|
-
'" from the list of extensions for "' + type + '".'
|
61
|
-
);
|
62
|
-
}
|
63
|
-
|
64
|
-
this._types[ext] = type;
|
65
|
-
}
|
66
|
-
|
67
|
-
// Use first extension as default
|
68
|
-
if (force || !this._extensions[type]) {
|
69
|
-
const ext = extensions[0];
|
70
|
-
this._extensions[type] = (ext[0] !== '*') ? ext : ext.substr(1);
|
71
|
-
}
|
72
|
-
}
|
73
|
-
};
|
74
|
-
|
75
|
-
/**
|
76
|
-
* Lookup a mime type based on extension
|
77
|
-
*/
|
78
|
-
Mime.prototype.getType = function(path) {
|
79
|
-
path = String(path);
|
80
|
-
let last = path.replace(/^.*[/\\]/, '').toLowerCase();
|
81
|
-
let ext = last.replace(/^.*\./, '').toLowerCase();
|
82
|
-
|
83
|
-
let hasPath = last.length < path.length;
|
84
|
-
let hasDot = ext.length < last.length - 1;
|
85
|
-
|
86
|
-
return (hasDot || !hasPath) && this._types[ext] || null;
|
87
|
-
};
|
88
|
-
|
89
|
-
/**
|
90
|
-
* Return file extension associated with a mime type
|
91
|
-
*/
|
92
|
-
Mime.prototype.getExtension = function(type) {
|
93
|
-
type = /^\s*([^;\s]*)/.test(type) && RegExp.$1;
|
94
|
-
return type && this._extensions[type.toLowerCase()] || null;
|
95
|
-
};
|
96
|
-
|
97
|
-
module.exports = Mime;
|
@@ -1,187 +0,0 @@
|
|
1
|
-
<!--
|
2
|
-
-- This file is auto-generated from src/README_js.md. Changes should be made there.
|
3
|
-
-->
|
4
|
-
# Mime
|
5
|
-
|
6
|
-
A comprehensive, compact MIME type module.
|
7
|
-
|
8
|
-
[](https://travis-ci.org/broofa/mime)
|
9
|
-
|
10
|
-
## Version 2 Notes
|
11
|
-
|
12
|
-
Version 2 is a breaking change from 1.x as the semver implies. Specifically:
|
13
|
-
|
14
|
-
* `lookup()` renamed to `getType()`
|
15
|
-
* `extension()` renamed to `getExtension()`
|
16
|
-
* `charset()` and `load()` methods have been removed
|
17
|
-
|
18
|
-
If you prefer the legacy version of this module please `npm install mime@^1`. Version 1 docs may be found [here](https://github.com/broofa/mime/tree/v1.4.0).
|
19
|
-
|
20
|
-
## Install
|
21
|
-
|
22
|
-
### NPM
|
23
|
-
```
|
24
|
-
npm install mime
|
25
|
-
```
|
26
|
-
|
27
|
-
### Browser
|
28
|
-
|
29
|
-
It is recommended that you use a bundler such as
|
30
|
-
[webpack](https://webpack.github.io/) or [browserify](http://browserify.org/) to
|
31
|
-
package your code. However, browser-ready versions are available via wzrd.in.
|
32
|
-
E.g. For the full version:
|
33
|
-
|
34
|
-
<script src="https://wzrd.in/standalone/mime@latest"></script>
|
35
|
-
<script>
|
36
|
-
mime.getType(...); // etc.
|
37
|
-
</script>
|
38
|
-
|
39
|
-
Or, for the `mime/lite` version:
|
40
|
-
|
41
|
-
<script src="https://wzrd.in/standalone/mime%2flite@latest"></script>
|
42
|
-
<script>
|
43
|
-
mimelite.getType(...); // (Note `mimelite` here)
|
44
|
-
</script>
|
45
|
-
|
46
|
-
## Quick Start
|
47
|
-
|
48
|
-
For the full version (800+ MIME types, 1,000+ extensions):
|
49
|
-
|
50
|
-
```javascript
|
51
|
-
const mime = require('mime');
|
52
|
-
|
53
|
-
mime.getType('txt'); // ⇨ 'text/plain'
|
54
|
-
mime.getExtension('text/plain'); // ⇨ 'txt'
|
55
|
-
```
|
56
|
-
|
57
|
-
See [Mime API](#mime-api) below for API details.
|
58
|
-
|
59
|
-
## Lite Version
|
60
|
-
|
61
|
-
There is also a "lite" version of this module that omits vendor-specific
|
62
|
-
(`*/vnd.*`) and experimental (`*/x-*`) types. It weighs in at ~2.5KB, compared
|
63
|
-
to 8KB for the full version. To load the lite version:
|
64
|
-
|
65
|
-
```javascript
|
66
|
-
const mime = require('mime/lite');
|
67
|
-
```
|
68
|
-
|
69
|
-
## Mime .vs. mime-types .vs. mime-db modules
|
70
|
-
|
71
|
-
For those of you wondering about the difference between these [popular] NPM modules,
|
72
|
-
here's a brief rundown ...
|
73
|
-
|
74
|
-
[`mime-db`](https://github.com/jshttp/mime-db) is "the source of
|
75
|
-
truth" for MIME type information. It is not an API. Rather, it is a canonical
|
76
|
-
dataset of mime type definitions pulled from IANA, Apache, NGINX, and custom mappings
|
77
|
-
submitted by the Node.js community.
|
78
|
-
|
79
|
-
[`mime-types`](https://github.com/jshttp/mime-types) is a thin
|
80
|
-
wrapper around mime-db that provides an API drop-in compatible(ish) with `mime @ < v1.3.6` API.
|
81
|
-
|
82
|
-
`mime` is, as of v2, a self-contained module bundled with a pre-optimized version
|
83
|
-
of the `mime-db` dataset. It provides a simplified API with the following characteristics:
|
84
|
-
|
85
|
-
* Intelligently resolved type conflicts (See [mime-score](https://github.com/broofa/mime-score) for details)
|
86
|
-
* Method naming consistent with industry best-practices
|
87
|
-
* Compact footprint. E.g. The minified+compressed sizes of the various modules:
|
88
|
-
|
89
|
-
Module | Size
|
90
|
-
--- | ---
|
91
|
-
`mime-db` | 18 KB
|
92
|
-
`mime-types` | same as mime-db
|
93
|
-
`mime` | 8 KB
|
94
|
-
`mime/lite` | 2 KB
|
95
|
-
|
96
|
-
## Mime API
|
97
|
-
|
98
|
-
Both `require('mime')` and `require('mime/lite')` return instances of the MIME
|
99
|
-
class, documented below.
|
100
|
-
|
101
|
-
Note: Inputs to this API are case-insensitive. Outputs (returned values) will
|
102
|
-
be lowercase.
|
103
|
-
|
104
|
-
### new Mime(typeMap, ... more maps)
|
105
|
-
|
106
|
-
Most users of this module will not need to create Mime instances directly.
|
107
|
-
However if you would like to create custom mappings, you may do so as follows
|
108
|
-
...
|
109
|
-
|
110
|
-
```javascript
|
111
|
-
// Require Mime class
|
112
|
-
const Mime = require('mime/Mime');
|
113
|
-
|
114
|
-
// Define mime type -> extensions map
|
115
|
-
const typeMap = {
|
116
|
-
'text/abc': ['abc', 'alpha', 'bet'],
|
117
|
-
'text/def': ['leppard']
|
118
|
-
};
|
119
|
-
|
120
|
-
// Create and use Mime instance
|
121
|
-
const myMime = new Mime(typeMap);
|
122
|
-
myMime.getType('abc'); // ⇨ 'text/abc'
|
123
|
-
myMime.getExtension('text/def'); // ⇨ 'leppard'
|
124
|
-
```
|
125
|
-
|
126
|
-
If more than one map argument is provided, each map is `define()`ed (see below), in order.
|
127
|
-
|
128
|
-
### mime.getType(pathOrExtension)
|
129
|
-
|
130
|
-
Get mime type for the given path or extension. E.g.
|
131
|
-
|
132
|
-
```javascript
|
133
|
-
mime.getType('js'); // ⇨ 'application/javascript'
|
134
|
-
mime.getType('json'); // ⇨ 'application/json'
|
135
|
-
|
136
|
-
mime.getType('txt'); // ⇨ 'text/plain'
|
137
|
-
mime.getType('dir/text.txt'); // ⇨ 'text/plain'
|
138
|
-
mime.getType('dir\\text.txt'); // ⇨ 'text/plain'
|
139
|
-
mime.getType('.text.txt'); // ⇨ 'text/plain'
|
140
|
-
mime.getType('.txt'); // ⇨ 'text/plain'
|
141
|
-
```
|
142
|
-
|
143
|
-
`null` is returned in cases where an extension is not detected or recognized
|
144
|
-
|
145
|
-
```javascript
|
146
|
-
mime.getType('foo/txt'); // ⇨ null
|
147
|
-
mime.getType('bogus_type'); // ⇨ null
|
148
|
-
```
|
149
|
-
|
150
|
-
### mime.getExtension(type)
|
151
|
-
Get extension for the given mime type. Charset options (often included in
|
152
|
-
Content-Type headers) are ignored.
|
153
|
-
|
154
|
-
```javascript
|
155
|
-
mime.getExtension('text/plain'); // ⇨ 'txt'
|
156
|
-
mime.getExtension('application/json'); // ⇨ 'json'
|
157
|
-
mime.getExtension('text/html; charset=utf8'); // ⇨ 'html'
|
158
|
-
```
|
159
|
-
|
160
|
-
### mime.define(typeMap[, force = false])
|
161
|
-
|
162
|
-
Define [more] type mappings.
|
163
|
-
|
164
|
-
`typeMap` is a map of type -> extensions, as documented in `new Mime`, above.
|
165
|
-
|
166
|
-
By default this method will throw an error if you try to map a type to an
|
167
|
-
extension that is already assigned to another type. Passing `true` for the
|
168
|
-
`force` argument will suppress this behavior (overriding any previous mapping).
|
169
|
-
|
170
|
-
```javascript
|
171
|
-
mime.define({'text/x-abc': ['abc', 'abcd']});
|
172
|
-
|
173
|
-
mime.getType('abcd'); // ⇨ 'text/x-abc'
|
174
|
-
mime.getExtension('text/x-abc') // ⇨ 'abc'
|
175
|
-
```
|
176
|
-
|
177
|
-
## Command Line
|
178
|
-
|
179
|
-
mime [path_or_extension]
|
180
|
-
|
181
|
-
E.g.
|
182
|
-
|
183
|
-
> mime scripts/jquery.js
|
184
|
-
application/javascript
|
185
|
-
|
186
|
-
----
|
187
|
-
Markdown generated from [src/README_js.md](src/README_js.md) by [](https://github.com/broofa/runmd)
|
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
'use strict';
|
4
|
-
|
5
|
-
process.title = 'mime';
|
6
|
-
let mime = require('.');
|
7
|
-
let pkg = require('./package.json');
|
8
|
-
let args = process.argv.splice(2);
|
9
|
-
|
10
|
-
if (args.includes('--version') || args.includes('-v') || args.includes('--v')) {
|
11
|
-
console.log(pkg.version);
|
12
|
-
process.exit(0);
|
13
|
-
} else if (args.includes('--name') || args.includes('-n') || args.includes('--n')) {
|
14
|
-
console.log(pkg.name);
|
15
|
-
process.exit(0);
|
16
|
-
} else if (args.includes('--help') || args.includes('-h') || args.includes('--h')) {
|
17
|
-
console.log(pkg.name + ' - ' + pkg.description + '\n');
|
18
|
-
console.log(`Usage:
|
19
|
-
|
20
|
-
mime [flags] [path_or_extension]
|
21
|
-
|
22
|
-
Flags:
|
23
|
-
--help, -h Show this message
|
24
|
-
--version, -v Display the version
|
25
|
-
--name, -n Print the name of the program
|
26
|
-
|
27
|
-
Note: the command will exit after it executes if a command is specified
|
28
|
-
The path_or_extension is the path to the file or the extension of the file.
|
29
|
-
|
30
|
-
Examples:
|
31
|
-
mime --help
|
32
|
-
mime --version
|
33
|
-
mime --name
|
34
|
-
mime -v
|
35
|
-
mime src/log.js
|
36
|
-
mime new.py
|
37
|
-
mime foo.sh
|
38
|
-
`);
|
39
|
-
process.exit(0);
|
40
|
-
}
|
41
|
-
|
42
|
-
let file = args[0];
|
43
|
-
let type = mime.getType(file);
|
44
|
-
|
45
|
-
process.stdout.write(type + '\n');
|
46
|
-
|