Skip to content

Commit

Permalink
fixing bug where send() errors were swallowed, fixing build script bu…
Browse files Browse the repository at this point in the history
…g affecting 'bundlers/qrds-external-bundle.js', docs tweaks/fixes
  • Loading branch information
getify committed Mar 27, 2024
1 parent 908571b commit 776aef7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

----

[Demo/Tests](https://mylofi.github.io/qr-data-sync/)
[Library Tests (Demo)](https://mylofi.github.io/qr-data-sync/)

----

Expand All @@ -23,7 +23,7 @@ This is what **QR Data Sync** library supports.
npm install @lo-fi/qr-data-sync
```

The [**@lo-fi/qr-data-sync** npm package](https://npmjs.com/package/@lo-fi/webauthn-local-client) includes a `dist/` directory with all files you need to deploy **qr-data-sync** (and its dependencies) into your application/project.
The [**@lo-fi/qr-data-sync** npm package](https://npmjs.com/package/@lo-fi/qr-data-sync) includes a `dist/` directory with all files you need to deploy **qr-data-sync** (and its dependencies) into your application/project.

If you obtain this library via git instead of npm, you'll need to [build `dist/` manually](#re-building-dist) before deployment.

Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "qr-data-sync",
"name": "@lo-fi/qr-data-sync",
"description": "Browser-only utils for sharing/synchronizing data using 'animated' QR codes",
"version": "0.999.0",
"version": "0.999.1",
"exports": {
".": "./dist/bundlers/qrds.mjs",
"./bundlers/vite": "./bundler-plugins/vite.mjs",
Expand Down Expand Up @@ -34,7 +34,10 @@
"optional": true
}
},
"repository": "mylofi/qr-data-sync",
"repository": {
"type": "git",
"url": "git+https://github.com/mylofi/qr-data-sync.git"
},
"keywords": [
"qr",
"qr code",
Expand Down
8 changes: 4 additions & 4 deletions scripts/build-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function main() {
/*skipPatterns=*/[ "**/*.txt", "**/*.json", "**/external" ]
);

// build src/qrds.js to bundlers/qrds.js
// build src/qrds.js to bundlers/qrds.mjs
await buildFiles(
[ QRDS_SRC, ],
SRC_DIR,
Expand All @@ -96,7 +96,7 @@ async function main() {

// build qrds-external-bundle.js
var qrdsExternalBundleContents = [
`/*! ${path.basename(QRCODE_SRC)} */`, await minifyJS(qrCodeContents),
`/*! ${path.basename(QRCODE_SRC)} */`, await minifyJS(qrCodeContents,/*esModuleFormat=*/false),
].join("\n");

await Promise.all([
Expand Down Expand Up @@ -168,7 +168,7 @@ async function buildFiles(files,fromBasePath,toDir,processFileContents,skipPatte
}
}

async function minifyJS(contents) {
async function minifyJS(contents,esModuleFormat = true) {
let result = await terser.minify(contents,{
mangle: {
keep_fnames: true,
Expand All @@ -179,7 +179,7 @@ async function minifyJS(contents) {
output: {
comments: /^!/,
},
module: true,
module: esModuleFormat,
});
if (!(result && result.code)) {
if (result.error) throw result.error;
Expand Down
2 changes: 1 addition & 1 deletion src/qrds.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function send(
cancelSendSignal.throwIfAborted();
cancelSendSignal.addEventListener("abort",onAbort,false);
}
generateFrames(data).then(() => res(true),cleanup);
generateFrames(data).then(() => res(true),e => { rej(e); cleanup(); });
}));


Expand Down

0 comments on commit 776aef7

Please sign in to comment.