Skip to content

Commit

Permalink
Fix issues #2103 and #2113 (#2119)
Browse files Browse the repository at this point in the history
* Fix issues #2103 and #2113

* Allow tagging released version as canary

---------

Co-authored-by: David Fahlander <[email protected]>
  • Loading branch information
dfahlander and David Fahlander authored Jan 15, 2025
1 parent 7e6b5e6 commit 3d238a4
Show file tree
Hide file tree
Showing 14 changed files with 304 additions and 240 deletions.
4 changes: 2 additions & 2 deletions addons/dexie-cloud/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dexie-cloud-addon",
"version": "4.0.8",
"version": "4.0.11",
"description": "Dexie addon that syncs with to Dexie Cloud",
"main": "dist/umd/dexie-cloud-addon.js",
"type": "module",
Expand Down Expand Up @@ -95,6 +95,6 @@
"rxjs": "^7.x"
},
"peerDependencies": {
"dexie": "^4.0.1"
"dexie": "workspace:^"
}
}
74 changes: 38 additions & 36 deletions addons/dexie-cloud/src/TSON.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TypesonSimplified } from 'dreambase-library/dist/typeson-simplified/TypesonSimplified';
import { Bison } from "dreambase-library/dist/typeson-simplified/Bison";
import { Bison } from 'dreambase-library/dist/typeson-simplified/Bison';
import undefinedDef from 'dreambase-library/dist/typeson-simplified/types/undefined.js';
import tsonBuiltinDefs from 'dreambase-library/dist/typeson-simplified/presets/builtin.js';
import { TypeDefSet } from 'dreambase-library/dist/typeson-simplified/TypeDefSet';
Expand All @@ -20,7 +20,8 @@ import { PropModSpec, PropModification } from 'dexie';
// serverRev.rev = bigIntDef.bigint.revive(server.rev)
// else
// serverRev.rev = new FakeBigInt(server.rev)
export const hasBigIntSupport = typeof BigInt === 'function' && typeof BigInt(0) === 'bigint';
export const hasBigIntSupport =
typeof BigInt === 'function' && typeof BigInt(0) === 'bigint';

function getValueOfBigInt(x: bigint | FakeBigInt | string) {
if (typeof x === 'bigint') {
Expand All @@ -33,7 +34,10 @@ function getValueOfBigInt(x: bigint | FakeBigInt | string) {
}
}

export function compareBigInts(a: bigint | FakeBigInt | string, b:bigint | FakeBigInt | string) {
export function compareBigInts(
a: bigint | FakeBigInt | string,
b: bigint | FakeBigInt | string
) {
const valA = getValueOfBigInt(a);
const valB = getValueOfBigInt(b);
return valA < valB ? -1 : valA > valB ? 1 : 0;
Expand All @@ -48,42 +52,40 @@ export class FakeBigInt {
}
}

const defs: TypeDefSet = {
...undefinedDef,
...(hasBigIntSupport
? {}
: {
bigint: {
test: (val: any) => val instanceof FakeBigInt,
replace: (fakeBigInt: any) => {
return {
$t: 'bigint',
...fakeBigInt
};
},
revive: ({
v,
}: {
$t: 'bigint';
v: string;
}) => new FakeBigInt(v) as any as bigint
}
}),
PropModification: {
test: (val: any) => val instanceof PropModification,
replace: (propModification: any) => {
const bigIntDef = hasBigIntSupport
? {}
: {
bigint: {
test: (val: any) => val instanceof FakeBigInt,
replace: (fakeBigInt: any) => {
return {
$t: 'PropModification',
...propModification
$t: 'bigint',
...fakeBigInt,
};
},
revive: ({
$t,
...propModification
}: {
$t: 'PropModification';
} & PropModSpec) => new PropModification(propModification)
}
revive: ({ v }: { $t: 'bigint'; v: string }) =>
new FakeBigInt(v) as any as bigint,
},
};

const defs: TypeDefSet = {
...undefinedDef,
...bigIntDef,
PropModification: {
test: (val: any) => val instanceof PropModification,
replace: (propModification: any) => {
return {
$t: 'PropModification',
...propModification['@@propmod'],
};
},
revive: ({
$t, // strip '$t'
...propModSpec // keep the rest
}: {
$t: 'PropModification';
} & PropModSpec) => new PropModification(propModSpec),
},
};

export const TSON = TypesonSimplified(tsonBuiltinDefs, defs);
Expand Down
4 changes: 2 additions & 2 deletions import-wrapper-prod.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (_Dexie.semVer !== Dexie.semVer) {
}
const {
liveQuery, mergeRanges, rangesOverlap, RangeSet, cmp, Entity,
PropModSymbol, PropModification, replacePrefix, add, remove } = Dexie;
PropModification, replacePrefix, add, remove } = Dexie;
export { liveQuery, mergeRanges, rangesOverlap, RangeSet, cmp, Dexie, Entity,
PropModSymbol, PropModification, replacePrefix, add, remove };
PropModification, replacePrefix, add, remove };
export default Dexie;
4 changes: 2 additions & 2 deletions import-wrapper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if (_Dexie.semVer !== Dexie.semVer) {
throw new Error(`Two different versions of Dexie loaded in the same app: ${_Dexie.semVer} and ${Dexie.semVer}`);
}
const { liveQuery, mergeRanges, rangesOverlap, RangeSet, cmp, Entity,
PropModSymbol, PropModification, replacePrefix, add, remove } = Dexie;
PropModification, replacePrefix, add, remove } = Dexie;
export { liveQuery, mergeRanges, rangesOverlap, RangeSet, cmp, Dexie, Entity,
PropModSymbol, PropModification, replacePrefix, add, remove };
PropModification, replacePrefix, add, remove };
export default Dexie;
4 changes: 2 additions & 2 deletions libs/dexie-react-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"homepage": "https://dexie.org",
"peerDependencies": {
"@types/react": ">=16",
"dexie": "^3.2 || ^4.0.1",
"dexie": "workspace:^",
"react": ">=16"
},
"devDependencies": {
Expand All @@ -65,7 +65,7 @@
"@types/qunit": "^2.9.6",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"dexie": "^3.2 || ^4.0.1",
"dexie": "workspace:^",
"just-build": "^0.9.24",
"qunit": "^2.12.0",
"react": "^17.0.1",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dexie",
"version": "4.0.10",
"version": "4.0.11",
"description": "A Minimalistic Wrapper for IndexedDB",
"main": "dist/dexie.js",
"module": "dist/dexie.mjs",
Expand Down
Loading

0 comments on commit 3d238a4

Please sign in to comment.