duckhts 1.5.2-9002

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.
package/LICENSE ADDED
@@ -0,0 +1,338 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ <https://fsf.org/>
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, see <https://www.gnu.org/licenses/>.
308
+
309
+ Also add information on how to contact you by electronic and paper mail.
310
+
311
+ If the program is interactive, make it output a short notice like this
312
+ when it starts in an interactive mode:
313
+
314
+ Gnomovision version 69, Copyright (C) year name of author
315
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
316
+ This is free software, and you are welcome to redistribute it
317
+ under certain conditions; type `show c' for details.
318
+
319
+ The hypothetical commands `show w' and `show c' should show the appropriate
320
+ parts of the General Public License. Of course, the commands you use may
321
+ be called something other than `show w' and `show c'; they could even be
322
+ mouse-clicks or menu items--whatever suits your program.
323
+
324
+ You should also get your employer (if you work as a programmer) or your
325
+ school, if any, to sign a "copyright disclaimer" for the program, if
326
+ necessary. Here is a sample; alter the names:
327
+
328
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
329
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
330
+
331
+ <signature of Moe Ghoul>, 1 April 1989
332
+ Moe Ghoul, President of Vice
333
+
334
+ This General Public License does not permit incorporating your program into
335
+ proprietary programs. If your program is a subroutine library, you may
336
+ consider it more useful to permit linking proprietary applications with the
337
+ library. If this is what you want to do, use the GNU Lesser General
338
+ Public License instead of this License.
package/README.Rmd ADDED
@@ -0,0 +1,160 @@
1
+ # duckhts for duckdb-wasm
2
+
3
+ The [DuckHTS](https://github.com/RGenomicsETL/duckhts) DuckDB extension, packaged for
4
+ [`@duckdb/duckdb-wasm`](https://www.npmjs.com/package/@duckdb/duckdb-wasm), so a web
5
+ application can serve the extension from its own origin instead of fetching it from the
6
+ DuckDB community repository at runtime.
7
+
8
+ Each npm release contains one pinned set of `.wasm` files, verified byte for byte against
9
+ its channel's manifest before packaging. `SIGNED` reports which channel supplied them.
10
+
11
+ ## Channels
12
+
13
+ | npm dist-tag | Install | Binary source | DuckHTS version |
14
+ |---|---|---|---|
15
+ | `latest` | `npm install duckhts@latest` | signed community repository (`artifacts.json`) | released version |
16
+ | `dev` | `npm install duckhts@dev` | unsigned GitHub Actions run (`artifacts-dev.json`) | `1.5.2.9002` as npm `1.5.2-9002` |
17
+
18
+ The `dev` loader refuses to load unless DuckDB has `allow_unsigned_extensions=true`.
19
+ For duckdb-wasm, opt in explicitly when opening the database:
20
+
21
+ ```js
22
+ await db.open({ allowUnsignedExtensions: true });
23
+ ```
24
+
25
+ The loader checks `current_setting('allow_unsigned_extensions')`; it never enables it.
26
+ Unsigned extensions are not authenticated by DuckDB's community signature. Only opt in
27
+ when you trust the pinned commit and artifact checksums; enabling the setting applies
28
+ to the database, not just DuckHTS. The staging script verifies each download's sha256
29
+ against `artifacts-dev.json` before packaging. The pinned GitHub Actions run's artifacts
30
+ expire (90 days by default, subject to repository retention settings). The dev pin is
31
+ refreshed with each X.Y.Z.9NNN development version bump. A fresh staging run cannot
32
+ download an expired pin; already verified local `dist` files still work offline. Once
33
+ published to npm, the package tarball retains the verified binaries permanently.
34
+
35
+ ## Use
36
+
37
+ ```sh
38
+ npm install duckhts@latest @duckdb/duckdb-wasm@1.33.1-dev57.0
39
+ ```
40
+
41
+ Serve `node_modules/duckhts/dist/` with the rest of your static files (for example by
42
+ copying it to `vendor/duckhts/`), then:
43
+
44
+ ```js
45
+ import { loadDuckhts, SIGNED } from "duckhts";
46
+
47
+ const conn = await db.connect();
48
+ await loadDuckhts(conn, { baseUrl: "/vendor/duckhts/" });
49
+
50
+ const peaks = await conn.query(
51
+ `SELECT chrom, start, "end" FROM read_bed('${location.origin}/data/peaks.bed')`,
52
+ );
53
+ ```
54
+
55
+ `loadDuckhts` runs `PRAGMA platform` and loads
56
+ `<baseUrl>/<platform>/duckhts.duckdb_extension.wasm` for `wasm_mvp`, `wasm_eh` or
57
+ `wasm_threads`. The SQL functions are documented in the
58
+ [function catalog](https://github.com/RGenomicsETL/duckhts/blob/main/r/Rduckhts/inst/function_catalog/functions.md).
59
+
60
+ ## Runtime support
61
+
62
+ The peer range is `1.33.1-dev57.0 || >=1.33.1`: the one tested prerelease, or any stable
63
+ release from 1.33.1. npm compares prerelease tags as text (`dev6` sorts after `dev57`),
64
+ so a `>=` floor on a prerelease would admit older builds.
65
+
66
+ | duckdb-wasm | DuckDB | Status |
67
+ |---|---|---|
68
+ | `1.33.1-dev57.0` | v1.5.4 | Both channels: HTTP readers; `dev` also reads `blob:` files after unsigned opt-in |
69
+ | `1.32.0` | v1.4.3 | `dev` loads; signed DuckHTS 1.5.2 fails: https://github.com/RGenomicsETL/duckhts/issues/247 |
70
+
71
+ ## Browser file access
72
+
73
+ DuckHTS reads files through htslib using worker-synchronous XHR. Same-origin HTTP URLs
74
+ work, and cross-origin URLs need permissive CORS.
75
+
76
+ ### Local files
77
+
78
+ DuckHTS builds from https://github.com/RGenomicsETL/duckhts/pull/248 onward read
79
+ `blob:` object URLs, so a page can pass a dropped or picked `File` straight to a reader.
80
+ The URL is a capability, not a path: unguessable, read-only, scoped to the page that
81
+ created it, and revocable. Any `Blob` the page holds works the same way: a file from
82
+ `<input type="file">` or a drop event, an OPFS file (`handle.getFile()`), a Blob kept in
83
+ IndexedDB, or bytes the page fetched with its own credentials. SQL stays the same:
84
+ `read_bed(url)` does not care where the bytes came from, just as native builds read
85
+ paths, `data:` URLs and `/dev/fd/N`.
86
+
87
+ The `dev` binaries include the handler. `localFileUrl(file)` creates an object URL and
88
+ returns `{ url, revoke }`. Keep it live while queries use it, then revoke it:
89
+
90
+ ```js
91
+ import { localFileUrl, SIGNED } from "duckhts";
92
+
93
+ if (!SIGNED) {
94
+ const local = localFileUrl(fileInput.files[0]);
95
+ try {
96
+ const rows = await conn.query(`SELECT chrom, start, "end" FROM read_bed('${local.url}')`);
97
+ } finally {
98
+ local.revoke();
99
+ }
100
+ }
101
+ ```
102
+
103
+ On `latest` (DuckHTS 1.5.2), `localFileUrl` throws because the signed binaries predate
104
+ the handler. `SIGNED` lets applications select a supported input path.
105
+
106
+ Keep the URL live until every query or result stream using it finishes, including
107
+ queries against views that retain it. Object URLs have no sibling filenames: automatic
108
+ index discovery falls back to streaming, and a region query needs a second URL for the
109
+ index passed as `index_path := '<index blob URL>'`. If a transport ignores Range, the
110
+ backend caches the full response in JavaScript, which costs browser memory
111
+ proportional to the file size.
112
+
113
+ Files registered with duckdb-wasm (`registerFileBuffer`, `registerFileHandle`,
114
+ `registerFileText`) remain **invisible** to DuckHTS readers. The file-system integration
115
+ is a separate option in https://github.com/RGenomicsETL/duckhts/issues/246.
116
+
117
+ ## Development
118
+
119
+ ```sh
120
+ npm ci
121
+ npm test # loader, local-file helper and staging tests, offline (signed)
122
+ DUCKHTS_NPM_CHANNEL=dev npm test
123
+ DUCKHTS_NPM_CHANNEL=signed npm run test:browser
124
+ DUCKHTS_NPM_CHANNEL=dev npm run test:browser
125
+ DUCKHTS_NPM_CHANNEL=dev npm run check:version
126
+ ```
127
+
128
+ Render this README with `Rscript -e 'knitr::knit("js/README.Rmd", "js/README.md")'`
129
+ from the repository root. Local-extension blob tests run through `make wasm-playwright-test`.
130
+
131
+ Set `DUCKHTS_NPM_CHANNEL=signed|dev` for staging, browser tests and packaging.
132
+ `npm run stage` is the only network step; `npm pack` and `npm publish` run it through
133
+ `prepack`. To stage your own wasm binaries, build from source using the repository
134
+ [local duckdb-wasm setup](../README.md#browser-wasmduckdb-wasm-local-setup) or the
135
+ `wasm-playwright-test` target in the root Makefile (both describe a `wasm_eh` build).
136
+ Provide a checksum-pinned dev manifest with all three platform entries and an offline
137
+ download tree with each artifact name as a directory containing
138
+ `duckhts.duckdb_extension.wasm`:
139
+
140
+ ```sh
141
+ node js/scripts/stage.mjs dev /path/to/my-artifacts.json /path/to/output /path/to/gh-download
142
+ ```
143
+
144
+ The output directory is explicit for a custom manifest; staging verifies the sha256 of
145
+ every file before writing it. For the pinned manifest, use
146
+ `node js/scripts/stage.mjs dev js/artifacts-dev.json js/dist /path/to/gh-download`
147
+ from the repository root. `npm run check:version` requires a matching version in
148
+ `description.yml`, the selected manifest, `package.json` and `package-lock.json`.
149
+ It accepts `-- <channel> <pr|publish>`; without a mode it uses strict publish checks.
150
+ Pull requests check identity for the checkout's channel and skip the other channel's
151
+ identity check while testing both runtimes. The publish workflow dispatch takes
152
+ `channel=dev|signed` and `publish=true`; dispatch always requires the selected
153
+ channel to match the checkout's version form.
154
+
155
+ ## Licence
156
+
157
+ GPL-2.0-or-later: the GNU General Public License, version 2 or (at your option) any
158
+ later version. See [`LICENSE`](LICENSE). The wasm binaries also contain HTSlib,
159
+ htscodecs, libBigWig, cgranges, VariantKey, zlib, bzip2 and liblzma under their own
160
+ licences, reproduced in [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md).
package/README.md ADDED
@@ -0,0 +1,160 @@
1
+ # duckhts for duckdb-wasm
2
+
3
+ The [DuckHTS](https://github.com/RGenomicsETL/duckhts) DuckDB extension, packaged for
4
+ [`@duckdb/duckdb-wasm`](https://www.npmjs.com/package/@duckdb/duckdb-wasm), so a web
5
+ application can serve the extension from its own origin instead of fetching it from the
6
+ DuckDB community repository at runtime.
7
+
8
+ Each npm release contains one pinned set of `.wasm` files, verified byte for byte against
9
+ its channel's manifest before packaging. `SIGNED` reports which channel supplied them.
10
+
11
+ ## Channels
12
+
13
+ | npm dist-tag | Install | Binary source | DuckHTS version |
14
+ |---|---|---|---|
15
+ | `latest` | `npm install duckhts@latest` | signed community repository (`artifacts.json`) | released version |
16
+ | `dev` | `npm install duckhts@dev` | unsigned GitHub Actions run (`artifacts-dev.json`) | `1.5.2.9002` as npm `1.5.2-9002` |
17
+
18
+ The `dev` loader refuses to load unless DuckDB has `allow_unsigned_extensions=true`.
19
+ For duckdb-wasm, opt in explicitly when opening the database:
20
+
21
+ ```js
22
+ await db.open({ allowUnsignedExtensions: true });
23
+ ```
24
+
25
+ The loader checks `current_setting('allow_unsigned_extensions')`; it never enables it.
26
+ Unsigned extensions are not authenticated by DuckDB's community signature. Only opt in
27
+ when you trust the pinned commit and artifact checksums; enabling the setting applies
28
+ to the database, not just DuckHTS. The staging script verifies each download's sha256
29
+ against `artifacts-dev.json` before packaging. The pinned GitHub Actions run's artifacts
30
+ expire (90 days by default, subject to repository retention settings). The dev pin is
31
+ refreshed with each X.Y.Z.9NNN development version bump. A fresh staging run cannot
32
+ download an expired pin; already verified local `dist` files still work offline. Once
33
+ published to npm, the package tarball retains the verified binaries permanently.
34
+
35
+ ## Use
36
+
37
+ ```sh
38
+ npm install duckhts@latest @duckdb/duckdb-wasm@1.33.1-dev57.0
39
+ ```
40
+
41
+ Serve `node_modules/duckhts/dist/` with the rest of your static files (for example by
42
+ copying it to `vendor/duckhts/`), then:
43
+
44
+ ```js
45
+ import { loadDuckhts, SIGNED } from "duckhts";
46
+
47
+ const conn = await db.connect();
48
+ await loadDuckhts(conn, { baseUrl: "/vendor/duckhts/" });
49
+
50
+ const peaks = await conn.query(
51
+ `SELECT chrom, start, "end" FROM read_bed('${location.origin}/data/peaks.bed')`,
52
+ );
53
+ ```
54
+
55
+ `loadDuckhts` runs `PRAGMA platform` and loads
56
+ `<baseUrl>/<platform>/duckhts.duckdb_extension.wasm` for `wasm_mvp`, `wasm_eh` or
57
+ `wasm_threads`. The SQL functions are documented in the
58
+ [function catalog](https://github.com/RGenomicsETL/duckhts/blob/main/r/Rduckhts/inst/function_catalog/functions.md).
59
+
60
+ ## Runtime support
61
+
62
+ The peer range is `1.33.1-dev57.0 || >=1.33.1`: the one tested prerelease, or any stable
63
+ release from 1.33.1. npm compares prerelease tags as text (`dev6` sorts after `dev57`),
64
+ so a `>=` floor on a prerelease would admit older builds.
65
+
66
+ | duckdb-wasm | DuckDB | Status |
67
+ |---|---|---|
68
+ | `1.33.1-dev57.0` | v1.5.4 | Both channels: HTTP readers; `dev` also reads `blob:` files after unsigned opt-in |
69
+ | `1.32.0` | v1.4.3 | `dev` loads; signed DuckHTS 1.5.2 fails: https://github.com/RGenomicsETL/duckhts/issues/247 |
70
+
71
+ ## Browser file access
72
+
73
+ DuckHTS reads files through htslib using worker-synchronous XHR. Same-origin HTTP URLs
74
+ work, and cross-origin URLs need permissive CORS.
75
+
76
+ ### Local files
77
+
78
+ DuckHTS builds from https://github.com/RGenomicsETL/duckhts/pull/248 onward read
79
+ `blob:` object URLs, so a page can pass a dropped or picked `File` straight to a reader.
80
+ The URL is a capability, not a path: unguessable, read-only, scoped to the page that
81
+ created it, and revocable. Any `Blob` the page holds works the same way: a file from
82
+ `<input type="file">` or a drop event, an OPFS file (`handle.getFile()`), a Blob kept in
83
+ IndexedDB, or bytes the page fetched with its own credentials. SQL stays the same:
84
+ `read_bed(url)` does not care where the bytes came from, just as native builds read
85
+ paths, `data:` URLs and `/dev/fd/N`.
86
+
87
+ The `dev` binaries include the handler. `localFileUrl(file)` creates an object URL and
88
+ returns `{ url, revoke }`. Keep it live while queries use it, then revoke it:
89
+
90
+ ```js
91
+ import { localFileUrl, SIGNED } from "duckhts";
92
+
93
+ if (!SIGNED) {
94
+ const local = localFileUrl(fileInput.files[0]);
95
+ try {
96
+ const rows = await conn.query(`SELECT chrom, start, "end" FROM read_bed('${local.url}')`);
97
+ } finally {
98
+ local.revoke();
99
+ }
100
+ }
101
+ ```
102
+
103
+ On `latest` (DuckHTS 1.5.2), `localFileUrl` throws because the signed binaries predate
104
+ the handler. `SIGNED` lets applications select a supported input path.
105
+
106
+ Keep the URL live until every query or result stream using it finishes, including
107
+ queries against views that retain it. Object URLs have no sibling filenames: automatic
108
+ index discovery falls back to streaming, and a region query needs a second URL for the
109
+ index passed as `index_path := '<index blob URL>'`. If a transport ignores Range, the
110
+ backend caches the full response in JavaScript, which costs browser memory
111
+ proportional to the file size.
112
+
113
+ Files registered with duckdb-wasm (`registerFileBuffer`, `registerFileHandle`,
114
+ `registerFileText`) remain **invisible** to DuckHTS readers. The file-system integration
115
+ is a separate option in https://github.com/RGenomicsETL/duckhts/issues/246.
116
+
117
+ ## Development
118
+
119
+ ```sh
120
+ npm ci
121
+ npm test # loader, local-file helper and staging tests, offline (signed)
122
+ DUCKHTS_NPM_CHANNEL=dev npm test
123
+ DUCKHTS_NPM_CHANNEL=signed npm run test:browser
124
+ DUCKHTS_NPM_CHANNEL=dev npm run test:browser
125
+ DUCKHTS_NPM_CHANNEL=dev npm run check:version
126
+ ```
127
+
128
+ Render this README with `Rscript -e 'knitr::knit("js/README.Rmd", "js/README.md")'`
129
+ from the repository root. Local-extension blob tests run through `make wasm-playwright-test`.
130
+
131
+ Set `DUCKHTS_NPM_CHANNEL=signed|dev` for staging, browser tests and packaging.
132
+ `npm run stage` is the only network step; `npm pack` and `npm publish` run it through
133
+ `prepack`. To stage your own wasm binaries, build from source using the repository
134
+ [local duckdb-wasm setup](../README.md#browser-wasmduckdb-wasm-local-setup) or the
135
+ `wasm-playwright-test` target in the root Makefile (both describe a `wasm_eh` build).
136
+ Provide a checksum-pinned dev manifest with all three platform entries and an offline
137
+ download tree with each artifact name as a directory containing
138
+ `duckhts.duckdb_extension.wasm`:
139
+
140
+ ```sh
141
+ node js/scripts/stage.mjs dev /path/to/my-artifacts.json /path/to/output /path/to/gh-download
142
+ ```
143
+
144
+ The output directory is explicit for a custom manifest; staging verifies the sha256 of
145
+ every file before writing it. For the pinned manifest, use
146
+ `node js/scripts/stage.mjs dev js/artifacts-dev.json js/dist /path/to/gh-download`
147
+ from the repository root. `npm run check:version` requires a matching version in
148
+ `description.yml`, the selected manifest, `package.json` and `package-lock.json`.
149
+ It accepts `-- <channel> <pr|publish>`; without a mode it uses strict publish checks.
150
+ Pull requests check identity for the checkout's channel and skip the other channel's
151
+ identity check while testing both runtimes. The publish workflow dispatch takes
152
+ `channel=dev|signed` and `publish=true`; dispatch always requires the selected
153
+ channel to match the checkout's version form.
154
+
155
+ ## Licence
156
+
157
+ GPL-2.0-or-later: the GNU General Public License, version 2 or (at your option) any
158
+ later version. See [`LICENSE`](LICENSE). The wasm binaries also contain HTSlib,
159
+ htscodecs, libBigWig, cgranges, VariantKey, zlib, bzip2 and liblzma under their own
160
+ licences, reproduced in [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md).
@@ -0,0 +1,388 @@
1
+ # Third-party notices
2
+
3
+ The `duckhts.duckdb_extension.wasm` files in this package are the DuckHTS DuckDB extension compiled for duckdb-wasm. DuckHTS itself is distributed here under the GNU General Public License, version 2 or (at your option) any later version; see `LICENSE`. The binaries also contain the components below, each under its own licence, reproduced verbatim from the source named for it. The component list comes from the wasm build's link inputs (`libhts.a`, `libz.a`, `libbz2.a`, `liblzma.a`, and DuckHTS's own sources including the vendored cgranges, libBigWig and VariantKey code).
4
+
5
+ DuckHTS also contains a computational subset ported from Somalier v0.3.4 (Brent Pedersen and contributors, MIT), and is compiled against the DuckDB C API headers (DuckDB contributors, MIT); no Somalier or DuckDB source files are bundled.
6
+
7
+ ## HTSlib
8
+
9
+ - Copyright: Genome Research Ltd and contributors
10
+ - Licence: MIT/Expat outside `cram/`; Modified BSD 3-Clause for `cram/`
11
+ - Text from: third_party/htslib/LICENSE
12
+
13
+ ```text
14
+ [Files in this distribution outwith the cram/ subdirectory are distributed
15
+ according to the terms of the following MIT/Expat license.]
16
+
17
+ The MIT/Expat License
18
+
19
+ Copyright (C) 2012-2026 Genome Research Ltd.
20
+
21
+ Permission is hereby granted, free of charge, to any person obtaining a copy
22
+ of this software and associated documentation files (the "Software"), to deal
23
+ in the Software without restriction, including without limitation the rights
24
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25
+ copies of the Software, and to permit persons to whom the Software is
26
+ furnished to do so, subject to the following conditions:
27
+
28
+ The above copyright notice and this permission notice shall be included in
29
+ all copies or substantial portions of the Software.
30
+
31
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
34
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
36
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
37
+ DEALINGS IN THE SOFTWARE.
38
+
39
+
40
+ [Files within the cram/ subdirectory in this distribution are distributed
41
+ according to the terms of the following Modified 3-Clause BSD license.]
42
+
43
+ The Modified-BSD License
44
+
45
+ Copyright (C) 2012-2026 Genome Research Ltd.
46
+
47
+ Redistribution and use in source and binary forms, with or without
48
+ modification, are permitted provided that the following conditions are met:
49
+
50
+ 1. Redistributions of source code must retain the above copyright notice,
51
+ this list of conditions and the following disclaimer.
52
+
53
+ 2. Redistributions in binary form must reproduce the above copyright notice,
54
+ this list of conditions and the following disclaimer in the documentation
55
+ and/or other materials provided with the distribution.
56
+
57
+ 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger Institute
58
+ nor the names of its contributors may be used to endorse or promote products
59
+ derived from this software without specific prior written permission.
60
+
61
+ THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS IS"
62
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
63
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
64
+ DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH LTD OR ITS CONTRIBUTORS BE LIABLE
65
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
66
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
67
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
68
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
69
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
70
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
71
+
72
+
73
+ [The use of a range of years within a copyright notice in this distribution
74
+ should be interpreted as being equivalent to a list of years including the
75
+ first and last year specified and all consecutive years between them.
76
+
77
+ For example, a copyright notice that reads "Copyright (C) 2005, 2007-2009,
78
+ 2011-2012" should be interpreted as being identical to a notice that reads
79
+ "Copyright (C) 2005, 2007, 2008, 2009, 2011, 2012" and a copyright notice
80
+ that reads "Copyright (C) 2005-2012" should be interpreted as being identical
81
+ to a notice that reads "Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
82
+ 2011, 2012".]
83
+ ```
84
+
85
+ ## htscodecs (bundled with HTSlib)
86
+
87
+ - Copyright: Genome Research Ltd and contributors
88
+ - Licence: BSD 3-Clause (see text for exceptions)
89
+ - Text from: third_party/htslib/htscodecs/LICENSE.md
90
+
91
+ ```text
92
+ All files except those explicitly listed below are copyright Genome
93
+ Research Limited and are made available under the BSD license.
94
+
95
+ > Redistribution and use in source and binary forms, with or without
96
+ > modification, are permitted provided that the following conditions
97
+ > are met:
98
+ >
99
+ > (1) Redistributions of source code must retain the above copyright
100
+ > notice, this list of conditions and the following disclaimer.
101
+ >
102
+ > (2) Redistributions in binary form must reproduce the above copyright
103
+ > notice, this list of conditions and the following disclaimer in
104
+ > the documentation and/or other materials provided with the distribution.
105
+ >
106
+ > (3)The name of the author may not be used to endorse or promote
107
+ > products derived from this software without specific prior written
108
+ > permission.
109
+ >
110
+ > THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
111
+ > IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
112
+ > WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
113
+ > DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
114
+ > INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
115
+ > (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
116
+ > SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
117
+ > HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
118
+ > STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
119
+ > IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
120
+ > POSSIBILITY OF SUCH DAMAGE.
121
+
122
+ c_range_coder.h is Public Domain, derived from work by Eugene
123
+ Shelwien.
124
+
125
+ rANS_byte.h and rANS_word.h are derived from Fabien Giesen's work and
126
+ is Public Domain. https://github.com/rygorous/ryg_rans This work was
127
+ in turn based on the ANS family of entropy encoders as described by
128
+ Jarek Duda's paper: http://arxiv.org/abs/1311.2540
129
+
130
+ > To the extent possible under law, Fabian Giesen has waived all
131
+ > copyright and related or neighboring rights to ryg_rans, as
132
+ > per the terms of the CC0 license:
133
+ >
134
+ > https://creativecommons.org/publicdomain/zero/1.0
135
+ >
136
+ > This work is published from the United States.
137
+ ```
138
+
139
+ ## libBigWig
140
+
141
+ - Copyright: Devon Ryan
142
+ - Licence: MIT
143
+ - Text from: third_party/libBigWig/LICENSE
144
+
145
+ ```text
146
+ The MIT License (MIT)
147
+
148
+ Copyright (c) 2015 Devon Ryan
149
+
150
+ Permission is hereby granted, free of charge, to any person obtaining a copy
151
+ of this software and associated documentation files (the "Software"), to deal
152
+ in the Software without restriction, including without limitation the rights
153
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
154
+ copies of the Software, and to permit persons to whom the Software is
155
+ furnished to do so, subject to the following conditions:
156
+
157
+ The above copyright notice and this permission notice shall be included in all
158
+ copies or substantial portions of the Software.
159
+
160
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
161
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
162
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
163
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
164
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
165
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
166
+ SOFTWARE.
167
+ ```
168
+
169
+ ## cgranges
170
+
171
+ - Copyright: Dana-Farber Cancer Institute (Heng Li)
172
+ - Licence: MIT
173
+ - Text from: third_party/cgranges/cgranges.h (header)
174
+
175
+ ```text
176
+ The MIT License
177
+
178
+ Copyright (c) 2019 Dana-Farber Cancer Institute
179
+
180
+ Permission is hereby granted, free of charge, to any person obtaining
181
+ a copy of this software and associated documentation files (the
182
+ "Software"), to deal in the Software without restriction, including
183
+ without limitation the rights to use, copy, modify, merge, publish,
184
+ distribute, sublicense, and/or sell copies of the Software, and to
185
+ permit persons to whom the Software is furnished to do so, subject to
186
+ the following conditions:
187
+
188
+ The above copyright notice and this permission notice shall be
189
+ included in all copies or substantial portions of the Software.
190
+
191
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
192
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
193
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
194
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
195
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
196
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
197
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
198
+ SOFTWARE.
199
+ ```
200
+
201
+ ## VariantKey / RegionKey
202
+
203
+ - Copyright: Nicola Asuni and contributors
204
+ - Licence: MIT
205
+ - Text from: third_party/variantkey/LICENSE
206
+
207
+ ```text
208
+ MIT LICENSE
209
+
210
+ Copyright (c) 2017-2019, 2023 GENOMICS plc
211
+ Copyright (c) 2017-2018 Nicola Asuni - Tecnick.com (binsearch)
212
+
213
+ Permission is hereby granted, free of charge, to any person obtaining a copy
214
+ of this software and associated documentation files (the "Software"), to deal
215
+ in the Software without restriction, including without limitation the rights
216
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
217
+ copies of the Software, and to permit persons to whom the Software is
218
+ furnished to do so, subject to the following conditions:
219
+
220
+ The above copyright notice and this permission notice shall be included in
221
+ all copies or substantial portions of the Software.
222
+
223
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
224
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
225
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
226
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
227
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
228
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
229
+ THE SOFTWARE.
230
+ ```
231
+
232
+ ## zlib 1.3.1
233
+
234
+ - Copyright: Jean-loup Gailly and Mark Adler
235
+ - Licence: Zlib
236
+ - Text from: vcpkg zlib (wasm32-emscripten) copyright file
237
+
238
+ ```text
239
+ Copyright notice:
240
+
241
+ (C) 1995-2022 Jean-loup Gailly and Mark Adler
242
+
243
+ This software is provided 'as-is', without any express or implied
244
+ warranty. In no event will the authors be held liable for any damages
245
+ arising from the use of this software.
246
+
247
+ Permission is granted to anyone to use this software for any purpose,
248
+ including commercial applications, and to alter it and redistribute it
249
+ freely, subject to the following restrictions:
250
+
251
+ 1. The origin of this software must not be misrepresented; you must not
252
+ claim that you wrote the original software. If you use this software
253
+ in a product, an acknowledgment in the product documentation would be
254
+ appreciated but is not required.
255
+ 2. Altered source versions must be plainly marked as such, and must not be
256
+ misrepresented as being the original software.
257
+ 3. This notice may not be removed or altered from any source distribution.
258
+
259
+ Jean-loup Gailly Mark Adler
260
+ jloup@gzip.org madler@alumni.caltech.edu
261
+ ```
262
+
263
+ ## bzip2 1.0.8
264
+
265
+ - Copyright: Julian Seward
266
+ - Licence: bzip2-1.0.6
267
+ - Text from: vcpkg bzip2 (wasm32-emscripten) copyright file
268
+
269
+ ```text
270
+ --------------------------------------------------------------------------
271
+
272
+ This program, "bzip2", the associated library "libbzip2", and all
273
+ documentation, are copyright (C) 1996-2019 Julian R Seward. All
274
+ rights reserved.
275
+
276
+ Redistribution and use in source and binary forms, with or without
277
+ modification, are permitted provided that the following conditions
278
+ are met:
279
+
280
+ 1. Redistributions of source code must retain the above copyright
281
+ notice, this list of conditions and the following disclaimer.
282
+
283
+ 2. The origin of this software must not be misrepresented; you must
284
+ not claim that you wrote the original software. If you use this
285
+ software in a product, an acknowledgment in the product
286
+ documentation would be appreciated but is not required.
287
+
288
+ 3. Altered source versions must be plainly marked as such, and must
289
+ not be misrepresented as being the original software.
290
+
291
+ 4. The name of the author may not be used to endorse or promote
292
+ products derived from this software without specific prior written
293
+ permission.
294
+
295
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
296
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
297
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
298
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
299
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
300
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
301
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
302
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
303
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
304
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
305
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
306
+
307
+ Julian Seward, jseward@acm.org
308
+ bzip2/libbzip2 version 1.0.8 of 13 July 2019
309
+
310
+ --------------------------------------------------------------------------
311
+ ```
312
+
313
+ ## liblzma (XZ Utils) 5.8.1
314
+
315
+ - Copyright: Lasse Collin and contributors
316
+ - Licence: 0BSD for liblzma (see text)
317
+ - Text from: vcpkg liblzma (wasm32-emscripten) copyright file
318
+
319
+ ```text
320
+ XZ Utils Licensing
321
+ ==================
322
+
323
+ Different licenses apply to different files in this package. Here
324
+ is a summary of which licenses apply to which parts of this package:
325
+
326
+ - liblzma is under the BSD Zero Clause License (0BSD).
327
+
328
+ - The command line tools xz, xzdec, lzmadec, and lzmainfo are
329
+ under 0BSD except that, on systems that don't have a usable
330
+ getopt_long, GNU getopt_long is compiled and linked in from the
331
+ 'lib' directory. The getopt_long code is under GNU LGPLv2.1+.
332
+
333
+ - The scripts to grep, diff, and view compressed files have been
334
+ adapted from GNU gzip. These scripts (xzgrep, xzdiff, xzless,
335
+ and xzmore) are under GNU GPLv2+. The man pages of the scripts
336
+ are under 0BSD; they aren't based on the man pages of GNU gzip.
337
+
338
+ - Most of the XZ Utils specific documentation that is in
339
+ plain text files (like README, INSTALL, PACKAGERS, NEWS,
340
+ and ChangeLog) are under 0BSD unless stated otherwise in
341
+ the file itself. The files xz-file-format.txt and
342
+ lzma-file-format.xt are in the public domain but may
343
+ be distributed under the terms of 0BSD too.
344
+
345
+ - Translated messages and man pages are under 0BSD except that
346
+ some old translations are in the public domain.
347
+
348
+ - Test files and test code in the 'tests' directory, and
349
+ debugging utilities in the 'debug' directory are under
350
+ the BSD Zero Clause License (0BSD).
351
+
352
+ - The GNU Autotools based build system contains files that are
353
+ under GNU GPLv2+, GNU GPLv3+, and a few permissive licenses.
354
+ These files don't affect the licensing of the binaries being
355
+ built.
356
+
357
+ - The 'extra' directory contains files that are under various
358
+ free software licenses. These aren't built or installed as
359
+ part of XZ Utils.
360
+
361
+ The following command may be helpful in finding per-file license
362
+ information. It works on xz.git and on a clean file tree extracted
363
+ from a release tarball.
364
+
365
+ sh build-aux/license-check.sh -v
366
+
367
+ For the files under the BSD Zero Clause License (0BSD), if
368
+ a copyright notice is needed, the following is sufficient:
369
+
370
+ Copyright (C) The XZ Utils authors and contributors
371
+
372
+ If you copy significant amounts of 0BSD-licensed code from XZ Utils
373
+ into your project, acknowledging this somewhere in your software is
374
+ polite (especially if it is proprietary, non-free software), but
375
+ it is not legally required by the license terms. Here is an example
376
+ of a good notice to put into "about box" or into documentation:
377
+
378
+ This software includes code from XZ Utils <https://tukaani.org/xz/>.
379
+
380
+ The following license texts are included in the following files:
381
+ - COPYING.0BSD: BSD Zero Clause License
382
+ - COPYING.LGPLv2.1: GNU Lesser General Public License version 2.1
383
+ - COPYING.GPLv2: GNU General Public License version 2
384
+ - COPYING.GPLv3: GNU General Public License version 3
385
+
386
+ If you have questions, don't hesitate to ask for more information.
387
+ The contact information is in the README file.
388
+ ```
@@ -0,0 +1,24 @@
1
+ {
2
+ "duckhts": "1.5.2.9002",
3
+ "signed": false,
4
+ "source": {
5
+ "repository": "RGenomicsETL/duckhts",
6
+ "run": 36251218841,
7
+ "commit": "3e47da128d301dbf908d8052e778a9d8a8b5df48",
8
+ "url": "https://github.com/RGenomicsETL/duckhts/actions/runs/36251218841"
9
+ },
10
+ "platforms": {
11
+ "wasm_mvp": {
12
+ "artifact": "duckhts-v1.5.0-extension-wasm_mvp",
13
+ "sha256": "38a1f94963e911f17d3ea498cfbacf5f151e8ae487958f52a53328d5b9fd73b5"
14
+ },
15
+ "wasm_eh": {
16
+ "artifact": "duckhts-v1.5.0-extension-wasm_eh",
17
+ "sha256": "f9d5ece2f930717c48efe0b960f13817d37eb6389333a9d72a64c41c3fdc165f"
18
+ },
19
+ "wasm_threads": {
20
+ "artifact": "duckhts-v1.5.0-extension-wasm_threads",
21
+ "sha256": "f6e8234ad40cdd1cd948fc9fd2391fd3accc97f7830042024107072dafb2b0cd"
22
+ }
23
+ }
24
+ }
package/artifacts.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "duckhts": "1.5.2",
3
+ "source": "https://community-extensions.duckdb.org/v1.5.5",
4
+ "abi": "C_STRUCT",
5
+ "minimum_duckdb": "v1.2.0",
6
+ "platforms": {
7
+ "wasm_mvp": "b10b0e3aa9b4ed4a5301321578224a21f8528e45bd5b09a9141bc2b14a36b81c",
8
+ "wasm_eh": "2dc20d6cb8c85340c64a8cb3af728e343cca46c0bef356fe139ce9379e2ab7dd",
9
+ "wasm_threads": "74fd1176620bd4914123dbb16663cdca3d3559a516b1491403b9db5eef84a493"
10
+ }
11
+ }
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "duckhts",
3
+ "version": "1.5.2-9002",
4
+ "description": "DuckHTS DuckDB extension for duckdb-wasm: read HTS formats (BAM, CRAM, VCF, BCF, FASTA, FASTQ, GFF, GTF, BED, GenBank, bigWig, tabix) with SQL in the browser",
5
+ "type": "module",
6
+ "license": "GPL-2.0-or-later",
7
+ "author": "Sounkou Mahamane Toure",
8
+ "homepage": "https://github.com/RGenomicsETL/duckhts/tree/main/js#readme",
9
+ "bugs": "https://github.com/RGenomicsETL/duckhts/issues",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/RGenomicsETL/duckhts.git",
13
+ "directory": "js"
14
+ },
15
+ "keywords": [
16
+ "duckdb",
17
+ "duckdb-wasm",
18
+ "duckdb-extension",
19
+ "htslib",
20
+ "genomics",
21
+ "bioinformatics",
22
+ "bam",
23
+ "vcf",
24
+ "gff",
25
+ "genbank"
26
+ ],
27
+ "exports": {
28
+ ".": {
29
+ "types": "./src/index.d.ts",
30
+ "default": "./src/index.js"
31
+ },
32
+ "./dist/*": "./dist/*"
33
+ },
34
+ "files": [
35
+ "src",
36
+ "dist",
37
+ "artifacts.json",
38
+ "artifacts-dev.json",
39
+ "LICENSE",
40
+ "THIRD_PARTY_NOTICES.md"
41
+ ],
42
+ "scripts": {
43
+ "stage": "node scripts/stage.mjs",
44
+ "prepack": "node scripts/stage.mjs",
45
+ "pretest": "node scripts/channel.mjs",
46
+ "test": "node --test test/*.test.mjs",
47
+ "test:browser": "node scripts/stage.mjs && playwright test --config test/browser/playwright.config.mjs",
48
+ "check:version": "node scripts/check-version.mjs"
49
+ },
50
+ "peerDependencies": {
51
+ "@duckdb/duckdb-wasm": "1.33.1-dev57.0 || >=1.33.1"
52
+ },
53
+ "peerDependenciesMeta": {
54
+ "@duckdb/duckdb-wasm": {
55
+ "optional": true
56
+ }
57
+ },
58
+ "engines": {
59
+ "node": ">=20"
60
+ },
61
+ "devDependencies": {
62
+ "@playwright/test": "1.60.0",
63
+ "duckdb-wasm-next": "npm:@duckdb/duckdb-wasm@1.33.1-dev57.0",
64
+ "duckdb-wasm-stable": "npm:@duckdb/duckdb-wasm@1.32.0"
65
+ }
66
+ }
package/src/channel.js ADDED
@@ -0,0 +1,3 @@
1
+ // Generated by scripts/channel.mjs for the dev channel.
2
+ export const SIGNED = false;
3
+ export const BLOB_CAPABLE = true;
package/src/index.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ export type DuckhtsPlatform = "wasm_mvp" | "wasm_eh" | "wasm_threads";
2
+
3
+ export declare const SIGNED: boolean;
4
+
5
+ /** Create a revocable object URL for a blob-capable build; unavailable on the signed channel. */
6
+ export declare function localFileUrl(file: Blob): { url: string; revoke(): void };
7
+
8
+ export declare const EXTENSION_FILE: "duckhts.duckdb_extension.wasm";
9
+
10
+ export declare const PLATFORMS: readonly DuckhtsPlatform[];
11
+
12
+ /** URL of the DuckHTS binary for `platform` under `baseUrl`. */
13
+ export declare function extensionUrl(baseUrl: string | URL, platform: string): string;
14
+
15
+ /** The subset of an `AsyncDuckDBConnection` the loader uses. */
16
+ export interface QueryableConnection {
17
+ query(sql: string): Promise<{ toArray(): Array<Record<string, unknown>> }>;
18
+ }
19
+
20
+ /**
21
+ * Run `PRAGMA platform` on `conn` and `LOAD` the matching DuckHTS binary from
22
+ * `baseUrl`, the directory where the application serves this package's `dist/`.
23
+ * The dev channel requires `allow_unsigned_extensions=true` on the connection
24
+ * before loading; this function never changes that setting.
25
+ */
26
+ export declare function loadDuckhts(
27
+ conn: QueryableConnection,
28
+ options: { baseUrl: string | URL },
29
+ ): Promise<{ platform: DuckhtsPlatform }>;
package/src/index.js ADDED
@@ -0,0 +1,51 @@
1
+ // Load the DuckHTS extension into a duckdb-wasm connection from a URL the
2
+ // application controls, so no request leaves the application's own origin.
3
+ //
4
+ // `baseUrl` is the directory holding <platform>/duckhts.duckdb_extension.wasm,
5
+ // i.e. wherever the application serves this package's dist/ directory.
6
+
7
+ import { BLOB_CAPABLE, SIGNED } from "./channel.js";
8
+ import { localFileUrl as createLocalFileUrl } from "./local-file.js";
9
+
10
+ export { SIGNED };
11
+
12
+ export function localFileUrl(file) {
13
+ if (!BLOB_CAPABLE) throw new Error("duckhts: localFileUrl requires a blob-capable build; this signed build does not support blob: URLs");
14
+ return createLocalFileUrl(file);
15
+ }
16
+
17
+ export const EXTENSION_FILE = "duckhts.duckdb_extension.wasm";
18
+
19
+ export const PLATFORMS = Object.freeze(["wasm_mvp", "wasm_eh", "wasm_threads"]);
20
+
21
+ export function extensionUrl(baseUrl, platform) {
22
+ if (!PLATFORMS.includes(platform)) {
23
+ throw new Error(
24
+ `duckhts: no wasm build for DuckDB platform '${platform}'; ` +
25
+ `this package ships ${PLATFORMS.join(", ")}`,
26
+ );
27
+ }
28
+ const base = new URL(baseUrl, globalThis.location?.href);
29
+ if (!base.pathname.endsWith("/")) base.pathname += "/";
30
+ return new URL(`${platform}/${EXTENSION_FILE}`, base).href;
31
+ }
32
+
33
+ function sqlString(value) {
34
+ return `'${value.replaceAll("'", "''")}'`;
35
+ }
36
+
37
+ export async function loadDuckhts(conn, { baseUrl }) {
38
+ if (baseUrl === undefined) {
39
+ throw new Error("duckhts: loadDuckhts(conn, { baseUrl }) requires baseUrl");
40
+ }
41
+ if (!SIGNED) {
42
+ const setting = await conn.query("SELECT current_setting('allow_unsigned_extensions') AS enabled");
43
+ if (setting.toArray()[0]?.enabled !== true) {
44
+ throw new Error("duckhts: dev channel requires allow_unsigned_extensions=true before loadDuckhts; configure DuckDB to allow unsigned extensions explicitly");
45
+ }
46
+ }
47
+ const result = await conn.query("PRAGMA platform");
48
+ const platform = String(result.toArray()[0].platform);
49
+ await conn.query(`LOAD ${sqlString(extensionUrl(baseUrl, platform))}`);
50
+ return { platform };
51
+ }
@@ -0,0 +1,9 @@
1
+ // Object URLs for browser Files and Blobs, for DuckHTS readers built with the
2
+ // Emscripten blob: handler (https://github.com/RGenomicsETL/duckhts/pull/248).
3
+ //
4
+ // The caller owns the URL. Keep it live until every query or stream using it
5
+ // has finished, including queries against views that retain the URL.
6
+ export function localFileUrl(file) {
7
+ const url = URL.createObjectURL(file);
8
+ return { url, revoke: () => URL.revokeObjectURL(url) };
9
+ }