port tests to node 18 test module; remove zora dep

This commit is contained in:
Brandon Liu
2022-11-22 20:38:14 +08:00
parent f457724da1
commit 47d35484fc
9 changed files with 778 additions and 221 deletions

601
js/package-lock.json generated
View File

@@ -12,12 +12,50 @@
"fflate": "^0.7.3" "fflate": "^0.7.3"
}, },
"devDependencies": { "devDependencies": {
"esbuild": "^0.11.14", "@types/node": "^18.11.9",
"esbuild": "^0.15.11",
"esbuild-runner": "^2.2.1", "esbuild-runner": "^2.2.1",
"typescript": "^4.5.5", "typescript": "^4.5.5"
"zora": "^5.0.2"
} }
}, },
"node_modules/@esbuild/android-arm": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.15.15.tgz",
"integrity": "sha512-JJjZjJi2eBL01QJuWjfCdZxcIgot+VoK6Fq7eKF9w4YHm9hwl7nhBR1o2Wnt/WcANk5l9SkpvrldW1PLuXxcbw==",
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/linux-loong64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.15.tgz",
"integrity": "sha512-lhz6UNPMDXUhtXSulw8XlFAtSYO26WmHQnCi2Lg2p+/TMiJKNLtZCYUxV4wG6rZMzXmr8InGpNwk+DLT2Hm0PA==",
"cpu": [
"loong64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@types/node": {
"version": "18.11.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz",
"integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==",
"dev": true
},
"node_modules/buffer-from": { "node_modules/buffer-from": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
@@ -25,13 +63,296 @@
"dev": true "dev": true
}, },
"node_modules/esbuild": { "node_modules/esbuild": {
"version": "0.11.14", "version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.11.14.tgz", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.15.tgz",
"integrity": "sha512-ejheEPkqhq5y0LM9rG9e+3yDihPtqeeE4NZmG7VQiSGJ3CjO4HvPOHmhhttSksfSztjLAGo2+0/zSIvlqj4JOQ==", "integrity": "sha512-TEw/lwK4Zzld9x3FedV6jy8onOUHqcEX3ADFk4k+gzPUwrxn8nWV62tH0udo8jOtjFodlEfc4ypsqX3e+WWO6w==",
"dev": true, "dev": true,
"hasInstallScript": true, "hasInstallScript": true,
"bin": { "bin": {
"esbuild": "bin/esbuild" "esbuild": "bin/esbuild"
},
"engines": {
"node": ">=12"
},
"optionalDependencies": {
"@esbuild/android-arm": "0.15.15",
"@esbuild/linux-loong64": "0.15.15",
"esbuild-android-64": "0.15.15",
"esbuild-android-arm64": "0.15.15",
"esbuild-darwin-64": "0.15.15",
"esbuild-darwin-arm64": "0.15.15",
"esbuild-freebsd-64": "0.15.15",
"esbuild-freebsd-arm64": "0.15.15",
"esbuild-linux-32": "0.15.15",
"esbuild-linux-64": "0.15.15",
"esbuild-linux-arm": "0.15.15",
"esbuild-linux-arm64": "0.15.15",
"esbuild-linux-mips64le": "0.15.15",
"esbuild-linux-ppc64le": "0.15.15",
"esbuild-linux-riscv64": "0.15.15",
"esbuild-linux-s390x": "0.15.15",
"esbuild-netbsd-64": "0.15.15",
"esbuild-openbsd-64": "0.15.15",
"esbuild-sunos-64": "0.15.15",
"esbuild-windows-32": "0.15.15",
"esbuild-windows-64": "0.15.15",
"esbuild-windows-arm64": "0.15.15"
}
},
"node_modules/esbuild-android-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.15.tgz",
"integrity": "sha512-F+WjjQxO+JQOva3tJWNdVjouFMLK6R6i5gjDvgUthLYJnIZJsp1HlF523k73hELY20WPyEO8xcz7aaYBVkeg5Q==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-android-arm64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.15.tgz",
"integrity": "sha512-attlyhD6Y22jNyQ0fIIQ7mnPvDWKw7k6FKnsXlBvQE6s3z6s6cuEHcSgoirquQc7TmZgVCK5fD/2uxmRN+ZpcQ==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-darwin-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.15.tgz",
"integrity": "sha512-ohZtF8W1SHJ4JWldsPVdk8st0r9ExbAOSrBOh5L+Mq47i696GVwv1ab/KlmbUoikSTNoXEhDzVpxUR/WIO19FQ==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-darwin-arm64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.15.tgz",
"integrity": "sha512-P8jOZ5zshCNIuGn+9KehKs/cq5uIniC+BeCykvdVhx/rBXSxmtj3CUIKZz4sDCuESMbitK54drf/2QX9QHG5Ag==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-freebsd-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.15.tgz",
"integrity": "sha512-KkTg+AmDXz1IvA9S1gt8dE24C8Thx0X5oM0KGF322DuP+P3evwTL9YyusHAWNsh4qLsR80nvBr/EIYs29VSwuA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-freebsd-arm64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.15.tgz",
"integrity": "sha512-FUcML0DRsuyqCMfAC+HoeAqvWxMeq0qXvclZZ/lt2kLU6XBnDA5uKTLUd379WYEyVD4KKFctqWd9tTuk8C/96g==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-32": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.15.tgz",
"integrity": "sha512-q28Qn5pZgHNqug02aTkzw5sW9OklSo96b5nm17Mq0pDXrdTBcQ+M6Q9A1B+dalFeynunwh/pvfrNucjzwDXj+Q==",
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.15.tgz",
"integrity": "sha512-217KPmWMirkf8liO+fj2qrPwbIbhNTGNVtvqI1TnOWJgcMjUWvd677Gq3fTzXEjilkx2yWypVnTswM2KbXgoAg==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-arm": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.15.tgz",
"integrity": "sha512-RYVW9o2yN8yM7SB1yaWr378CwrjvGCyGybX3SdzPHpikUHkME2AP55Ma20uNwkNyY2eSYFX9D55kDrfQmQBR4w==",
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-arm64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.15.tgz",
"integrity": "sha512-/ltmNFs0FivZkYsTzAsXIfLQX38lFnwJTWCJts0IbCqWZQe+jjj0vYBNbI0kmXLb3y5NljiM5USVAO1NVkdh2g==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-mips64le": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.15.tgz",
"integrity": "sha512-PksEPb321/28GFFxtvL33yVPfnMZihxkEv5zME2zapXGp7fA1X2jYeiTUK+9tJ/EGgcNWuwvtawPxJG7Mmn86A==",
"cpu": [
"mips64el"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-ppc64le": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.15.tgz",
"integrity": "sha512-ek8gJBEIhcpGI327eAZigBOHl58QqrJrYYIZBWQCnH3UnXoeWMrMZLeeZL8BI2XMBhP+sQ6ERctD5X+ajL/AIA==",
"cpu": [
"ppc64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-riscv64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.15.tgz",
"integrity": "sha512-H5ilTZb33/GnUBrZMNJtBk7/OXzDHDXjIzoLXHSutwwsLxSNaLxzAaMoDGDd/keZoS+GDBqNVxdCkpuiRW4OSw==",
"cpu": [
"riscv64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-s390x": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.15.tgz",
"integrity": "sha512-jKaLUg78mua3rrtrkpv4Or2dNTJU7bgHN4bEjT4OX4GR7nLBSA9dfJezQouTxMmIW7opwEC5/iR9mpC18utnxQ==",
"cpu": [
"s390x"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-netbsd-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.15.tgz",
"integrity": "sha512-aOvmF/UkjFuW6F36HbIlImJTTx45KUCHJndtKo+KdP8Dhq3mgLRKW9+6Ircpm8bX/RcS3zZMMmaBLkvGY06Gvw==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-openbsd-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.15.tgz",
"integrity": "sha512-HFFX+WYedx1w2yJ1VyR1Dfo8zyYGQZf1cA69bLdrHzu9svj6KH6ZLK0k3A1/LFPhcEY9idSOhsB2UyU0tHPxgQ==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=12"
} }
}, },
"node_modules/esbuild-runner": { "node_modules/esbuild-runner": {
@@ -50,6 +371,70 @@
"esbuild": "*" "esbuild": "*"
} }
}, },
"node_modules/esbuild-sunos-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.15.tgz",
"integrity": "sha512-jOPBudffG4HN8yJXcK9rib/ZTFoTA5pvIKbRrt3IKAGMq1EpBi4xoVoSRrq/0d4OgZLaQbmkHp8RO9eZIn5atA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"sunos"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-windows-32": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.15.tgz",
"integrity": "sha512-MDkJ3QkjnCetKF0fKxCyYNBnOq6dmidcwstBVeMtXSgGYTy8XSwBeIE4+HuKiSsG6I/mXEb++px3IGSmTN0XiA==",
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-windows-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.15.tgz",
"integrity": "sha512-xaAUIB2qllE888SsMU3j9nrqyLbkqqkpQyWVkfwSil6BBPgcPk3zOFitTTncEKCLTQy3XV9RuH7PDj3aJDljWA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-windows-arm64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.15.tgz",
"integrity": "sha512-ttuoCYCIJAFx4UUKKWYnFdrVpoXa3+3WWkXVI6s09U+YjhnyM5h96ewTq/WgQj9LFSIlABQvadHSOQyAVjW5xQ==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/fflate": { "node_modules/fflate": {
"version": "0.7.3", "version": "0.7.3",
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.7.3.tgz", "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.7.3.tgz",
@@ -92,15 +477,29 @@
"engines": { "engines": {
"node": ">=4.2.0" "node": ">=4.2.0"
} }
},
"node_modules/zora": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/zora/-/zora-5.0.2.tgz",
"integrity": "sha512-HZtoEtYm9iJrym0nvel84NmmmOZyvS9I6q27kO1zAA5W4vY87LnRkokRGd5Qm6nrv0+YhGlr/i5VfVcS+VEK4g==",
"dev": true
} }
}, },
"dependencies": { "dependencies": {
"@esbuild/android-arm": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.15.15.tgz",
"integrity": "sha512-JJjZjJi2eBL01QJuWjfCdZxcIgot+VoK6Fq7eKF9w4YHm9hwl7nhBR1o2Wnt/WcANk5l9SkpvrldW1PLuXxcbw==",
"dev": true,
"optional": true
},
"@esbuild/linux-loong64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.15.tgz",
"integrity": "sha512-lhz6UNPMDXUhtXSulw8XlFAtSYO26WmHQnCi2Lg2p+/TMiJKNLtZCYUxV4wG6rZMzXmr8InGpNwk+DLT2Hm0PA==",
"dev": true,
"optional": true
},
"@types/node": {
"version": "18.11.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz",
"integrity": "sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg==",
"dev": true
},
"buffer-from": { "buffer-from": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
@@ -108,10 +507,146 @@
"dev": true "dev": true
}, },
"esbuild": { "esbuild": {
"version": "0.11.14", "version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.11.14.tgz", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.15.tgz",
"integrity": "sha512-ejheEPkqhq5y0LM9rG9e+3yDihPtqeeE4NZmG7VQiSGJ3CjO4HvPOHmhhttSksfSztjLAGo2+0/zSIvlqj4JOQ==", "integrity": "sha512-TEw/lwK4Zzld9x3FedV6jy8onOUHqcEX3ADFk4k+gzPUwrxn8nWV62tH0udo8jOtjFodlEfc4ypsqX3e+WWO6w==",
"dev": true "dev": true,
"requires": {
"@esbuild/android-arm": "0.15.15",
"@esbuild/linux-loong64": "0.15.15",
"esbuild-android-64": "0.15.15",
"esbuild-android-arm64": "0.15.15",
"esbuild-darwin-64": "0.15.15",
"esbuild-darwin-arm64": "0.15.15",
"esbuild-freebsd-64": "0.15.15",
"esbuild-freebsd-arm64": "0.15.15",
"esbuild-linux-32": "0.15.15",
"esbuild-linux-64": "0.15.15",
"esbuild-linux-arm": "0.15.15",
"esbuild-linux-arm64": "0.15.15",
"esbuild-linux-mips64le": "0.15.15",
"esbuild-linux-ppc64le": "0.15.15",
"esbuild-linux-riscv64": "0.15.15",
"esbuild-linux-s390x": "0.15.15",
"esbuild-netbsd-64": "0.15.15",
"esbuild-openbsd-64": "0.15.15",
"esbuild-sunos-64": "0.15.15",
"esbuild-windows-32": "0.15.15",
"esbuild-windows-64": "0.15.15",
"esbuild-windows-arm64": "0.15.15"
}
},
"esbuild-android-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.15.tgz",
"integrity": "sha512-F+WjjQxO+JQOva3tJWNdVjouFMLK6R6i5gjDvgUthLYJnIZJsp1HlF523k73hELY20WPyEO8xcz7aaYBVkeg5Q==",
"dev": true,
"optional": true
},
"esbuild-android-arm64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.15.tgz",
"integrity": "sha512-attlyhD6Y22jNyQ0fIIQ7mnPvDWKw7k6FKnsXlBvQE6s3z6s6cuEHcSgoirquQc7TmZgVCK5fD/2uxmRN+ZpcQ==",
"dev": true,
"optional": true
},
"esbuild-darwin-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.15.tgz",
"integrity": "sha512-ohZtF8W1SHJ4JWldsPVdk8st0r9ExbAOSrBOh5L+Mq47i696GVwv1ab/KlmbUoikSTNoXEhDzVpxUR/WIO19FQ==",
"dev": true,
"optional": true
},
"esbuild-darwin-arm64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.15.tgz",
"integrity": "sha512-P8jOZ5zshCNIuGn+9KehKs/cq5uIniC+BeCykvdVhx/rBXSxmtj3CUIKZz4sDCuESMbitK54drf/2QX9QHG5Ag==",
"dev": true,
"optional": true
},
"esbuild-freebsd-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.15.tgz",
"integrity": "sha512-KkTg+AmDXz1IvA9S1gt8dE24C8Thx0X5oM0KGF322DuP+P3evwTL9YyusHAWNsh4qLsR80nvBr/EIYs29VSwuA==",
"dev": true,
"optional": true
},
"esbuild-freebsd-arm64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.15.tgz",
"integrity": "sha512-FUcML0DRsuyqCMfAC+HoeAqvWxMeq0qXvclZZ/lt2kLU6XBnDA5uKTLUd379WYEyVD4KKFctqWd9tTuk8C/96g==",
"dev": true,
"optional": true
},
"esbuild-linux-32": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.15.tgz",
"integrity": "sha512-q28Qn5pZgHNqug02aTkzw5sW9OklSo96b5nm17Mq0pDXrdTBcQ+M6Q9A1B+dalFeynunwh/pvfrNucjzwDXj+Q==",
"dev": true,
"optional": true
},
"esbuild-linux-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.15.tgz",
"integrity": "sha512-217KPmWMirkf8liO+fj2qrPwbIbhNTGNVtvqI1TnOWJgcMjUWvd677Gq3fTzXEjilkx2yWypVnTswM2KbXgoAg==",
"dev": true,
"optional": true
},
"esbuild-linux-arm": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.15.tgz",
"integrity": "sha512-RYVW9o2yN8yM7SB1yaWr378CwrjvGCyGybX3SdzPHpikUHkME2AP55Ma20uNwkNyY2eSYFX9D55kDrfQmQBR4w==",
"dev": true,
"optional": true
},
"esbuild-linux-arm64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.15.tgz",
"integrity": "sha512-/ltmNFs0FivZkYsTzAsXIfLQX38lFnwJTWCJts0IbCqWZQe+jjj0vYBNbI0kmXLb3y5NljiM5USVAO1NVkdh2g==",
"dev": true,
"optional": true
},
"esbuild-linux-mips64le": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.15.tgz",
"integrity": "sha512-PksEPb321/28GFFxtvL33yVPfnMZihxkEv5zME2zapXGp7fA1X2jYeiTUK+9tJ/EGgcNWuwvtawPxJG7Mmn86A==",
"dev": true,
"optional": true
},
"esbuild-linux-ppc64le": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.15.tgz",
"integrity": "sha512-ek8gJBEIhcpGI327eAZigBOHl58QqrJrYYIZBWQCnH3UnXoeWMrMZLeeZL8BI2XMBhP+sQ6ERctD5X+ajL/AIA==",
"dev": true,
"optional": true
},
"esbuild-linux-riscv64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.15.tgz",
"integrity": "sha512-H5ilTZb33/GnUBrZMNJtBk7/OXzDHDXjIzoLXHSutwwsLxSNaLxzAaMoDGDd/keZoS+GDBqNVxdCkpuiRW4OSw==",
"dev": true,
"optional": true
},
"esbuild-linux-s390x": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.15.tgz",
"integrity": "sha512-jKaLUg78mua3rrtrkpv4Or2dNTJU7bgHN4bEjT4OX4GR7nLBSA9dfJezQouTxMmIW7opwEC5/iR9mpC18utnxQ==",
"dev": true,
"optional": true
},
"esbuild-netbsd-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.15.tgz",
"integrity": "sha512-aOvmF/UkjFuW6F36HbIlImJTTx45KUCHJndtKo+KdP8Dhq3mgLRKW9+6Ircpm8bX/RcS3zZMMmaBLkvGY06Gvw==",
"dev": true,
"optional": true
},
"esbuild-openbsd-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.15.tgz",
"integrity": "sha512-HFFX+WYedx1w2yJ1VyR1Dfo8zyYGQZf1cA69bLdrHzu9svj6KH6ZLK0k3A1/LFPhcEY9idSOhsB2UyU0tHPxgQ==",
"dev": true,
"optional": true
}, },
"esbuild-runner": { "esbuild-runner": {
"version": "2.2.1", "version": "2.2.1",
@@ -123,6 +658,34 @@
"tslib": "2.3.1" "tslib": "2.3.1"
} }
}, },
"esbuild-sunos-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.15.tgz",
"integrity": "sha512-jOPBudffG4HN8yJXcK9rib/ZTFoTA5pvIKbRrt3IKAGMq1EpBi4xoVoSRrq/0d4OgZLaQbmkHp8RO9eZIn5atA==",
"dev": true,
"optional": true
},
"esbuild-windows-32": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.15.tgz",
"integrity": "sha512-MDkJ3QkjnCetKF0fKxCyYNBnOq6dmidcwstBVeMtXSgGYTy8XSwBeIE4+HuKiSsG6I/mXEb++px3IGSmTN0XiA==",
"dev": true,
"optional": true
},
"esbuild-windows-64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.15.tgz",
"integrity": "sha512-xaAUIB2qllE888SsMU3j9nrqyLbkqqkpQyWVkfwSil6BBPgcPk3zOFitTTncEKCLTQy3XV9RuH7PDj3aJDljWA==",
"dev": true,
"optional": true
},
"esbuild-windows-arm64": {
"version": "0.15.15",
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.15.tgz",
"integrity": "sha512-ttuoCYCIJAFx4UUKKWYnFdrVpoXa3+3WWkXVI6s09U+YjhnyM5h96ewTq/WgQj9LFSIlABQvadHSOQyAVjW5xQ==",
"dev": true,
"optional": true
},
"fflate": { "fflate": {
"version": "0.7.3", "version": "0.7.3",
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.7.3.tgz", "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.7.3.tgz",
@@ -155,12 +718,6 @@
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz",
"integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==",
"dev": true "dev": true
},
"zora": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/zora/-/zora-5.0.2.tgz",
"integrity": "sha512-HZtoEtYm9iJrym0nvel84NmmmOZyvS9I6q27kO1zAA5W4vY87LnRkokRGd5Qm6nrv0+YhGlr/i5VfVcS+VEK4g==",
"dev": true
} }
} }
} }

View File

@@ -24,10 +24,10 @@
"author": "Brandon Liu", "author": "Brandon Liu",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"devDependencies": { "devDependencies": {
"esbuild": "^0.11.14", "@types/node": "^18.11.9",
"esbuild": "^0.15.11",
"esbuild-runner": "^2.2.1", "esbuild-runner": "^2.2.1",
"typescript": "^4.5.5", "typescript": "^4.5.5"
"zora": "^5.0.2"
}, },
"dependencies": { "dependencies": {
"fflate": "^0.7.3" "fflate": "^0.7.3"

View File

@@ -1,4 +1,5 @@
import { test } from "zora"; import { test } from "node:test";
import assert from "node:assert";
import { import {
unshift, unshift,
@@ -12,7 +13,7 @@ import {
createDirectory, createDirectory,
} from "../v2"; } from "../v2";
test("stub data", (assertion) => { test("stub data", () => {
let dataview = new DataView(createDirectory([ let dataview = new DataView(createDirectory([
{ z: 5, x: 1000, y: 2000, offset: 1000, length: 2000, is_dir: false }, { z: 5, x: 1000, y: 2000, offset: 1000, length: 2000, is_dir: false },
{ {
@@ -29,12 +30,12 @@ test("stub data", (assertion) => {
var y = getUint24(dataview, 17 + 4); var y = getUint24(dataview, 17 + 4);
var offset = getUint48(dataview, 17 + 7); var offset = getUint48(dataview, 17 + 7);
var length = dataview.getUint32(17 + 13, true); var length = dataview.getUint32(17 + 13, true);
assertion.ok(z_raw === 14); assert.strictEqual(z_raw,14);
assertion.ok(x === 16383); assert.strictEqual(x,16383);
assertion.ok(y === 16383); assert.strictEqual(y,16383);
}); });
test("get entry", (assertion) => { test("get entry", () => {
let view = new DataView(createDirectory([ let view = new DataView(createDirectory([
{ z: 5, x: 1000, y: 2000, offset: 1000, length: 2000, is_dir: false }, { z: 5, x: 1000, y: 2000, offset: 1000, length: 2000, is_dir: false },
{ {
@@ -47,16 +48,16 @@ test("get entry", (assertion) => {
}, },
])); ]));
let entry = queryTile(view, 14, 16383, 16383); let entry = queryTile(view, 14, 16383, 16383);
assertion.ok(entry!.z === 14); assert.strictEqual(entry!.z,14);
assertion.ok(entry!.x === 16383); assert.strictEqual(entry!.x,16383);
assertion.ok(entry!.y === 16383); assert.strictEqual(entry!.y,16383);
assertion.ok(entry!.offset === 999999); assert.strictEqual(entry!.offset,999999);
assertion.ok(entry!.length === 999); assert.strictEqual(entry!.length,999);
assertion.ok(entry!.is_dir === false); assert.strictEqual(entry!.is_dir,false);
assertion.ok(queryLeafdir(view, 14, 16383, 16383) === null); assert.strictEqual(queryLeafdir(view, 14, 16383, 16383),null);
}); });
test("get leafdir", (assertion) => { test("get leafdir", () => {
let view = new DataView(createDirectory([ let view = new DataView(createDirectory([
{ {
z: 14, z: 14,
@@ -68,16 +69,16 @@ test("get leafdir", (assertion) => {
}, },
])); ]));
let entry = queryLeafdir(view, 14, 16383, 16383); let entry = queryLeafdir(view, 14, 16383, 16383);
assertion.ok(entry!.z === 14); assert.strictEqual(entry!.z,14);
assertion.ok(entry!.x === 16383); assert.strictEqual(entry!.x,16383);
assertion.ok(entry!.y === 16383); assert.strictEqual(entry!.y,16383);
assertion.ok(entry!.offset === 999999); assert.strictEqual(entry!.offset,999999);
assertion.ok(entry!.length === 999); assert.strictEqual(entry!.length,999);
assertion.ok(entry!.is_dir === true); assert.strictEqual(entry!.is_dir,true);
assertion.ok(queryTile(view, 14, 16383, 16383) === null); assert.strictEqual(queryTile(view, 14, 16383, 16383),null);
}); });
test("derive the leaf level", (assertion) => { test("derive the leaf level", () => {
let view = new DataView(createDirectory([ let view = new DataView(createDirectory([
{ {
z: 6, z: 6,
@@ -89,9 +90,9 @@ test("derive the leaf level", (assertion) => {
}, },
])); ]));
let leaf = deriveLeaf(view,{z:7,x:6,y:6}); let leaf = deriveLeaf(view,{z:7,x:6,y:6});
assertion.ok(leaf!.z === 6); assert.strictEqual(leaf!.z,6);
assertion.ok(leaf!.x === 3); assert.strictEqual(leaf!.x,3);
assertion.ok(leaf!.y === 3); assert.strictEqual(leaf!.y,3);
view = new DataView(createDirectory([ view = new DataView(createDirectory([
{ {
z: 6, z: 6,
@@ -103,10 +104,10 @@ test("derive the leaf level", (assertion) => {
}, },
])); ]));
leaf = deriveLeaf(view,{z:7,x:6,y:6}); leaf = deriveLeaf(view,{z:7,x:6,y:6});
assertion.ok(leaf === null); assert.strictEqual(leaf,null);
}); });
test("convert spec v1 directory to spec v2 directory", (assertion) => { test("convert spec v1 directory to spec v2 directory", () => {
let view = new DataView(createDirectory([ let view = new DataView(createDirectory([
{ {
z: 7, z: 7,
@@ -134,16 +135,16 @@ test("convert spec v1 directory to spec v2 directory", (assertion) => {
}, },
])); ]));
let entry = queryLeafdir(view, 7, 3, 3); let entry = queryLeafdir(view, 7, 3, 3);
assertion.ok(entry!.offset === 3); assert.strictEqual(entry!.offset,3);
entry = queryTile(view, 6, 2, 2); entry = queryTile(view, 6, 2, 2);
assertion.ok(entry!.offset === 2); assert.strictEqual(entry!.offset,2);
entry = queryTile(view, 6, 2, 1); entry = queryTile(view, 6, 2, 1);
assertion.ok(entry!.offset === 1); assert.strictEqual(entry!.offset,1);
entry = parseEntry(view, 0); entry = parseEntry(view, 0);
assertion.ok(entry!.offset === 1); assert.strictEqual(entry!.offset,1);
entry = parseEntry(view, 1); entry = parseEntry(view, 1);
assertion.ok(entry!.offset === 2); assert.strictEqual(entry!.offset,2);
entry = parseEntry(view, 2); entry = parseEntry(view, 2);
assertion.ok(entry!.offset === 3); assert.strictEqual(entry!.offset,3);
}); });

View File

@@ -1,8 +1,5 @@
import { test } from "zora"; import { test } from "node:test";
import assert from "node:assert";
// tests run in node, for convenience
// we don't need to typecheck all of it
// @ts-ignore
import fs from "fs"; import fs from "fs";
import { import {
@@ -19,81 +16,81 @@ import {
PMTiles, PMTiles,
} from "../index"; } from "../index";
test("varint", (assertion) => { test("varint", () => {
let b: BufferPosition = { let b: BufferPosition = {
buf: new Uint8Array([0, 1, 127, 0xe5, 0x8e, 0x26]), buf: new Uint8Array([0, 1, 127, 0xe5, 0x8e, 0x26]),
pos: 0, pos: 0,
}; };
assertion.eq(readVarint(b), 0); assert.strictEqual(readVarint(b), 0);
assertion.eq(readVarint(b), 1); assert.strictEqual(readVarint(b), 1);
assertion.eq(readVarint(b), 127); assert.strictEqual(readVarint(b), 127);
assertion.eq(readVarint(b), 624485); assert.strictEqual(readVarint(b), 624485);
b = { b = {
buf: new Uint8Array([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f]), buf: new Uint8Array([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f]),
pos: 0, pos: 0,
}; };
assertion.eq(readVarint(b), 9007199254740991); assert.strictEqual(readVarint(b), 9007199254740991);
}); });
test("zxy to tile id", (assertion) => { test("zxy to tile id", () => {
assertion.eq(zxyToTileId(0, 0, 0), 0); assert.strictEqual(zxyToTileId(0, 0, 0), 0);
assertion.eq(zxyToTileId(1, 0, 0), 1); assert.strictEqual(zxyToTileId(1, 0, 0), 1);
assertion.eq(zxyToTileId(1, 0, 1), 2); assert.strictEqual(zxyToTileId(1, 0, 1), 2);
assertion.eq(zxyToTileId(1, 1, 1), 3); assert.strictEqual(zxyToTileId(1, 1, 1), 3);
assertion.eq(zxyToTileId(1, 1, 0), 4); assert.strictEqual(zxyToTileId(1, 1, 0), 4);
assertion.eq(zxyToTileId(2, 0, 0), 5); assert.strictEqual(zxyToTileId(2, 0, 0), 5);
}); });
test("tile id to zxy", (assertion) => { test("tile id to zxy", () => {
assertion.eq(tileIdToZxy(0), [0, 0, 0]); assert.deepEqual(tileIdToZxy(0), [0, 0, 0]);
assertion.eq(tileIdToZxy(1), [1, 0, 0]); assert.deepEqual(tileIdToZxy(1), [1, 0, 0]);
assertion.eq(tileIdToZxy(2), [1, 0, 1]); assert.deepEqual(tileIdToZxy(2), [1, 0, 1]);
assertion.eq(tileIdToZxy(3), [1, 1, 1]); assert.deepEqual(tileIdToZxy(3), [1, 1, 1]);
assertion.eq(tileIdToZxy(4), [1, 1, 0]); assert.deepEqual(tileIdToZxy(4), [1, 1, 0]);
assertion.eq(tileIdToZxy(5), [2, 0, 0]); assert.deepEqual(tileIdToZxy(5), [2, 0, 0]);
}); });
test("a lot of tiles", (assertion) => { test("a lot of tiles", () => {
for (let z = 0; z < 9; z++) { for (let z = 0; z < 9; z++) {
for (let x = 0; x < 1 << z; x++) { for (let x = 0; x < 1 << z; x++) {
for (let y = 0; y < 1 << z; y++) { for (let y = 0; y < 1 << z; y++) {
const result = tileIdToZxy(zxyToTileId(z, x, y)); const result = tileIdToZxy(zxyToTileId(z, x, y));
if (result[0] !== z || result[1] !== x || result[2] !== y) { if (result[0] !== z || result[1] !== x || result[2] !== y) {
assertion.fail("roundtrip failed"); assert.fail("roundtrip failed");
} }
} }
} }
} }
}); });
test("tile search for missing entry", (assertion) => { test("tile search for missing entry", () => {
const entries: Entry[] = []; const entries: Entry[] = [];
assertion.eq(findTile(entries, 101), null); assert.strictEqual(findTile(entries, 101), null);
}); });
test("tile search for first entry == id", (assertion) => { test("tile search for first entry == id", () => {
const entries: Entry[] = [ const entries: Entry[] = [
{ tileId: 100, offset: 1, length: 1, runLength: 1 }, { tileId: 100, offset: 1, length: 1, runLength: 1 },
]; ];
const entry = findTile(entries, 100)!; const entry = findTile(entries, 100)!;
assertion.eq(entry.offset, 1); assert.strictEqual(entry.offset, 1);
assertion.eq(entry.length, 1); assert.strictEqual(entry.length, 1);
assertion.eq(findTile(entries, 101), null); assert.strictEqual(findTile(entries, 101), null);
}); });
test("tile search with multiple tile entries", (assertion) => { test("tile search with multiple tile entries", () => {
let entries: Entry[] = [{ tileId: 100, offset: 1, length: 1, runLength: 2 }]; let entries: Entry[] = [{ tileId: 100, offset: 1, length: 1, runLength: 2 }];
let entry = findTile(entries, 101)!; let entry = findTile(entries, 101)!;
assertion.eq(entry.offset, 1); assert.strictEqual(entry.offset, 1);
assertion.eq(entry.length, 1); assert.strictEqual(entry.length, 1);
entries = [ entries = [
{ tileId: 100, offset: 1, length: 1, runLength: 1 }, { tileId: 100, offset: 1, length: 1, runLength: 1 },
{ tileId: 150, offset: 2, length: 2, runLength: 2 }, { tileId: 150, offset: 2, length: 2, runLength: 2 },
]; ];
entry = findTile(entries, 151)!; entry = findTile(entries, 151)!;
assertion.eq(entry.offset, 2); assert.strictEqual(entry.offset, 2);
assertion.eq(entry.length, 2); assert.strictEqual(entry.length, 2);
entries = [ entries = [
{ tileId: 50, offset: 1, length: 1, runLength: 2 }, { tileId: 50, offset: 1, length: 1, runLength: 2 },
@@ -101,17 +98,17 @@ test("tile search with multiple tile entries", (assertion) => {
{ tileId: 150, offset: 3, length: 3, runLength: 1 }, { tileId: 150, offset: 3, length: 3, runLength: 1 },
]; ];
entry = findTile(entries, 51)!; entry = findTile(entries, 51)!;
assertion.eq(entry.offset, 1); assert.strictEqual(entry.offset, 1);
assertion.eq(entry.length, 1); assert.strictEqual(entry.length, 1);
}); });
test("leaf search", (assertion) => { test("leaf search", () => {
const entries: Entry[] = [ const entries: Entry[] = [
{ tileId: 100, offset: 1, length: 1, runLength: 0 }, { tileId: 100, offset: 1, length: 1, runLength: 0 },
]; ];
const entry = findTile(entries, 150); const entry = findTile(entries, 150);
assertion.eq(entry!.offset, 1); assert.strictEqual(entry!.offset, 1);
assertion.eq(entry!.length, 1); assert.strictEqual(entry!.length, 1);
}); });
// inefficient method only for testing // inefficient method only for testing
@@ -144,70 +141,70 @@ class TestNodeFileSource implements Source {
} }
// echo '{"type":"Polygon","coordinates":[[[0,0],[0,1],[1,1],[1,0],[0,0]]]}' | ./tippecanoe -zg -o test_fixture_1.pmtiles // echo '{"type":"Polygon","coordinates":[[[0,0],[0,1],[1,1],[1,0],[0,0]]]}' | ./tippecanoe -zg -o test_fixture_1.pmtiles
test("cache getHeader", async (assertion) => { test("cache getHeader", async () => {
const source = new TestNodeFileSource( const source = new TestNodeFileSource(
"test/data/test_fixture_1.pmtiles", "test/data/test_fixture_1.pmtiles",
"1" "1"
); );
const cache = new SharedPromiseCache(); const cache = new SharedPromiseCache();
const header = await cache.getHeader(source); const header = await cache.getHeader(source);
assertion.eq(header.rootDirectoryOffset, 127); assert.strictEqual(header.rootDirectoryOffset, 127);
assertion.eq(header.rootDirectoryLength, 25); assert.strictEqual(header.rootDirectoryLength, 25);
assertion.eq(header.jsonMetadataOffset, 152); assert.strictEqual(header.jsonMetadataOffset, 152);
assertion.eq(header.jsonMetadataLength, 247); assert.strictEqual(header.jsonMetadataLength, 247);
assertion.eq(header.leafDirectoryOffset, 0); assert.strictEqual(header.leafDirectoryOffset, 0);
assertion.eq(header.leafDirectoryLength, 0); assert.strictEqual(header.leafDirectoryLength, 0);
assertion.eq(header.tileDataOffset, 399); assert.strictEqual(header.tileDataOffset, 399);
assertion.eq(header.tileDataLength, 69); assert.strictEqual(header.tileDataLength, 69);
assertion.eq(header.numAddressedTiles, 1); assert.strictEqual(header.numAddressedTiles, 1);
assertion.eq(header.numTileEntries, 1); assert.strictEqual(header.numTileEntries, 1);
assertion.eq(header.numTileContents, 1); assert.strictEqual(header.numTileContents, 1);
assertion.eq(header.clustered, false); assert.strictEqual(header.clustered, false);
assertion.eq(header.internalCompression, 2); assert.strictEqual(header.internalCompression, 2);
assertion.eq(header.tileCompression, 2); assert.strictEqual(header.tileCompression, 2);
assertion.eq(header.tileType, 1); assert.strictEqual(header.tileType, 1);
assertion.eq(header.minZoom, 0); assert.strictEqual(header.minZoom, 0);
assertion.eq(header.maxZoom, 0); assert.strictEqual(header.maxZoom, 0);
assertion.eq(header.minLon, 0); assert.strictEqual(header.minLon, 0);
assertion.eq(header.minLat, 0); assert.strictEqual(header.minLat, 0);
// assertion.eq(header.maxLon,1); // TODO fix me // assert.strictEqual(header.maxLon,1); // TODO fix me
assertion.eq(header.maxLat, 1); assert.strictEqual(header.maxLat, 1);
}); });
test("cache check against empty", async (assertion) => { test("cache check against empty", async () => {
const source = new TestNodeFileSource("test/data/empty.pmtiles", "1"); const source = new TestNodeFileSource("test/data/empty.pmtiles", "1");
const cache = new SharedPromiseCache(); const cache = new SharedPromiseCache();
try { try {
await cache.getHeader(source); await cache.getHeader(source);
assertion.fail("Should have thrown"); assert.fail("Should have thrown");
} catch (e) { } catch (e) {
assertion.ok(e instanceof Error); assert.ok(e instanceof Error);
} }
}); });
test("cache check magic number", async (assertion) => { test("cache check magic number", async () => {
const source = new TestNodeFileSource("test/data/invalid.pmtiles", "1"); const source = new TestNodeFileSource("test/data/invalid.pmtiles", "1");
const cache = new SharedPromiseCache(); const cache = new SharedPromiseCache();
try { try {
await cache.getHeader(source); await cache.getHeader(source);
assertion.fail("Should have thrown"); assert.fail("Should have thrown");
} catch (e) { } catch (e) {
assertion.ok(e instanceof Error); assert.ok(e instanceof Error);
} }
}); });
test("cache check future spec version", async (assertion) => { test("cache check future spec version", async () => {
const source = new TestNodeFileSource("test/data/invalid_v4.pmtiles", "1"); const source = new TestNodeFileSource("test/data/invalid_v4.pmtiles", "1");
const cache = new SharedPromiseCache(); const cache = new SharedPromiseCache();
try { try {
await cache.getHeader(source); await cache.getHeader(source);
assertion.fail("Should have thrown"); assert.fail("Should have thrown");
} catch (e) { } catch (e) {
assertion.ok(e instanceof Error); assert.ok(e instanceof Error);
} }
}); });
test("cache getDirectory", async (assertion) => { test("cache getDirectory", async () => {
const source = new TestNodeFileSource( const source = new TestNodeFileSource(
"test/data/test_fixture_1.pmtiles", "test/data/test_fixture_1.pmtiles",
"1" "1"
@@ -215,13 +212,13 @@ test("cache getDirectory", async (assertion) => {
let cache = new SharedPromiseCache(6400, false); let cache = new SharedPromiseCache(6400, false);
let header = await cache.getHeader(source); let header = await cache.getHeader(source);
assertion.eq(cache.cache.size, 1); assert.strictEqual(cache.cache.size, 1);
cache = new SharedPromiseCache(6400, true); cache = new SharedPromiseCache(6400, true);
header = await cache.getHeader(source); header = await cache.getHeader(source);
// prepopulates the root directory // prepopulates the root directory
assertion.eq(cache.cache.size, 2); assert.strictEqual(cache.cache.size, 2);
const directory = await cache.getDirectory( const directory = await cache.getDirectory(
source, source,
@@ -229,18 +226,18 @@ test("cache getDirectory", async (assertion) => {
header.rootDirectoryLength, header.rootDirectoryLength,
header header
); );
assertion.eq(directory.length, 1); assert.strictEqual(directory.length, 1);
assertion.eq(directory[0].tileId, 0); assert.strictEqual(directory[0].tileId, 0);
assertion.eq(directory[0].offset, 0); assert.strictEqual(directory[0].offset, 0);
assertion.eq(directory[0].length, 69); assert.strictEqual(directory[0].length, 69);
assertion.eq(directory[0].runLength, 1); assert.strictEqual(directory[0].runLength, 1);
for (const v of cache.cache.values()) { for (const v of cache.cache.values()) {
assertion.ok(v.lastUsed > 0); assert.ok(v.lastUsed > 0);
} }
}); });
test("multiple sources in a single cache", async (assertion) => { test("multiple sources in a single cache", async () => {
const cache = new SharedPromiseCache(); const cache = new SharedPromiseCache();
const source1 = new TestNodeFileSource( const source1 = new TestNodeFileSource(
"test/data/test_fixture_1.pmtiles", "test/data/test_fixture_1.pmtiles",
@@ -251,12 +248,12 @@ test("multiple sources in a single cache", async (assertion) => {
"2" "2"
); );
await cache.getHeader(source1); await cache.getHeader(source1);
assertion.eq(cache.cache.size, 2); assert.strictEqual(cache.cache.size, 2);
await cache.getHeader(source2); await cache.getHeader(source2);
assertion.eq(cache.cache.size, 4); assert.strictEqual(cache.cache.size, 4);
}); });
test("etags are part of key", async (assertion) => { test("etags are part of key", async () => {
const cache = new SharedPromiseCache(6400, false); const cache = new SharedPromiseCache(6400, false);
const source = new TestNodeFileSource( const source = new TestNodeFileSource(
"test/data/test_fixture_1.pmtiles", "test/data/test_fixture_1.pmtiles",
@@ -264,7 +261,7 @@ test("etags are part of key", async (assertion) => {
); );
source.etag = "etag_1"; source.etag = "etag_1";
let header = await cache.getHeader(source); let header = await cache.getHeader(source);
assertion.eq(header.etag, "etag_1"); assert.strictEqual(header.etag, "etag_1");
source.etag = "etag_2"; source.etag = "etag_2";
@@ -275,13 +272,13 @@ test("etags are part of key", async (assertion) => {
header.rootDirectoryLength, header.rootDirectoryLength,
header header
); );
assertion.fail("Should have thrown"); assert.fail("Should have thrown");
} catch (e) { } catch (e) {
assertion.ok(e instanceof EtagMismatch); assert.ok(e instanceof EtagMismatch);
} }
cache.invalidate(source, "etag_2"); cache.invalidate(source, "etag_2");
header = await cache.getHeader(source); header = await cache.getHeader(source);
assertion.ok( assert.ok(
await cache.getDirectory( await cache.getDirectory(
source, source,
header.rootDirectoryOffset, header.rootDirectoryOffset,
@@ -291,7 +288,7 @@ test("etags are part of key", async (assertion) => {
); );
}); });
test("soft failure on etag weirdness", async (assertion) => { test("soft failure on etag weirdness", async () => {
const cache = new SharedPromiseCache(6400, false); const cache = new SharedPromiseCache(6400, false);
const source = new TestNodeFileSource( const source = new TestNodeFileSource(
"test/data/test_fixture_1.pmtiles", "test/data/test_fixture_1.pmtiles",
@@ -299,7 +296,7 @@ test("soft failure on etag weirdness", async (assertion) => {
); );
source.etag = "etag_1"; source.etag = "etag_1";
let header = await cache.getHeader(source); let header = await cache.getHeader(source);
assertion.eq(header.etag, "etag_1"); assert.strictEqual(header.etag, "etag_1");
source.etag = "etag_2"; source.etag = "etag_2";
@@ -310,42 +307,42 @@ test("soft failure on etag weirdness", async (assertion) => {
header.rootDirectoryLength, header.rootDirectoryLength,
header header
); );
assertion.fail("Should have thrown"); assert.fail("Should have thrown");
} catch (e) { } catch (e) {
assertion.ok(e instanceof EtagMismatch); assert.ok(e instanceof EtagMismatch);
} }
source.etag = "etag_1"; source.etag = "etag_1";
cache.invalidate(source, "etag_2"); cache.invalidate(source, "etag_2");
header = await cache.getHeader(source); header = await cache.getHeader(source);
assertion.eq(header.etag, undefined); assert.strictEqual(header.etag, undefined);
}); });
test("cache pruning by byte size", async (assertion) => { test("cache pruning by byte size", async () => {
const cache = new SharedPromiseCache(2, false); const cache = new SharedPromiseCache(2, false);
cache.cache.set("0", { lastUsed: 0, data: Promise.resolve([]) }); cache.cache.set("0", { lastUsed: 0, data: Promise.resolve([]) });
cache.cache.set("1", { lastUsed: 1, data: Promise.resolve([]) }); cache.cache.set("1", { lastUsed: 1, data: Promise.resolve([]) });
cache.cache.set("2", { lastUsed: 2, data: Promise.resolve([]) }); cache.cache.set("2", { lastUsed: 2, data: Promise.resolve([]) });
cache.prune(); cache.prune();
assertion.eq(cache.cache.size, 2); assert.strictEqual(cache.cache.size, 2);
assertion.ok(cache.cache.get("2")); assert.ok(cache.cache.get("2"));
assertion.ok(cache.cache.get("1")); assert.ok(cache.cache.get("1"));
assertion.notOk(cache.cache.get("0")); assert.ok(!cache.cache.get("0"));
}); });
test("pmtiles get metadata", async (assertion) => { test("pmtiles get metadata", async () => {
const source = new TestNodeFileSource( const source = new TestNodeFileSource(
"test/data/test_fixture_1.pmtiles", "test/data/test_fixture_1.pmtiles",
"1" "1"
); );
const p = new PMTiles(source); const p = new PMTiles(source);
const metadata = await p.getMetadata(); const metadata = await p.getMetadata();
assertion.ok(metadata.name); assert.ok(metadata.name);
}); });
// echo '{"type":"Polygon","coordinates":[[[0,0],[0,1],[1,0],[0,0]]]}' | ./tippecanoe -zg -o test_fixture_2.pmtiles // echo '{"type":"Polygon","coordinates":[[[0,0],[0,1],[1,0],[0,0]]]}' | ./tippecanoe -zg -o test_fixture_2.pmtiles
test("pmtiles handle retries", async (assertion) => { test("pmtiles handle retries", async () => {
const source = new TestNodeFileSource( const source = new TestNodeFileSource(
"test/data/test_fixture_1.pmtiles", "test/data/test_fixture_1.pmtiles",
"1" "1"
@@ -353,8 +350,8 @@ test("pmtiles handle retries", async (assertion) => {
source.etag = "1"; source.etag = "1";
const p = new PMTiles(source); const p = new PMTiles(source);
const metadata = await p.getMetadata(); const metadata = await p.getMetadata();
assertion.ok(metadata.name); assert.ok(metadata.name);
source.etag = "2"; source.etag = "2";
source.replaceData("test/data/test_fixture_2.pmtiles"); source.replaceData("test/data/test_fixture_2.pmtiles");
assertion.ok(await p.getZxy(0, 0, 0)); assert.ok(await p.getZxy(0, 0, 0));
}); });

View File

@@ -6,7 +6,8 @@
"moduleResolution": "node", "moduleResolution": "node",
"paths": { "paths": {
}, },
"types": [] "types": ["node"],
"allowSyntheticDefaultImports": true
}, },
"include": ["*.ts","test/*.ts"] "include": ["*.ts","test/*.ts"]
} }

View File

@@ -11,8 +11,7 @@
"@cloudflare/workers-types": "^3.17.0", "@cloudflare/workers-types": "^3.17.0",
"esbuild-runner": "^2.2.2", "esbuild-runner": "^2.2.2",
"typescript": "^4.8.4", "typescript": "^4.8.4",
"wrangler": "2.1.12", "wrangler": "2.1.12"
"zora": "^5.1.0"
} }
}, },
"node_modules/@cloudflare/kv-asset-handler": { "node_modules/@cloudflare/kv-asset-handler": {
@@ -1571,12 +1570,6 @@
"mustache": "^4.2.0", "mustache": "^4.2.0",
"stack-trace": "0.0.10" "stack-trace": "0.0.10"
} }
},
"node_modules/zora": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/zora/-/zora-5.1.0.tgz",
"integrity": "sha512-ikV3raEYF44q4BWfWzalqceCelgQPFxCjK61Nt6NNLfogRIezZmY3A/oGzOuSqLV8iySsw4xcrrFTEaCf6LY+g==",
"dev": true
} }
}, },
"dependencies": { "dependencies": {
@@ -2637,12 +2630,6 @@
"mustache": "^4.2.0", "mustache": "^4.2.0",
"stack-trace": "0.0.10" "stack-trace": "0.0.10"
} }
},
"zora": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/zora/-/zora-5.1.0.tgz",
"integrity": "sha512-ikV3raEYF44q4BWfWzalqceCelgQPFxCjK61Nt6NNLfogRIezZmY3A/oGzOuSqLV8iySsw4xcrrFTEaCf6LY+g==",
"dev": true
} }
} }
} }

View File

@@ -5,8 +5,7 @@
"@cloudflare/workers-types": "^3.17.0", "@cloudflare/workers-types": "^3.17.0",
"esbuild-runner": "^2.2.2", "esbuild-runner": "^2.2.2",
"typescript": "^4.8.4", "typescript": "^4.8.4",
"wrangler": "2.1.12", "wrangler": "2.1.12"
"zora": "^5.1.0"
}, },
"private": true, "private": true,
"scripts": { "scripts": {

View File

@@ -1,58 +1,72 @@
import { test } from "zora"; import { test } from "node:test";
import assert from "node:assert";
import { pmtiles_path, tile_path } from "./index"; import { pmtiles_path, tile_path } from "./index";
test("pmtiles path", (assertion) => { test("pmtiles path", () => {
let result = pmtiles_path("foo", undefined); let result = pmtiles_path("foo", undefined);
assertion.equal(result, "foo.pmtiles"); assert.strictEqual(result, "foo.pmtiles");
}); });
test("pmtiles path", (assertion) => { test("pmtiles path", () => {
let result = pmtiles_path("foo","folder/{name}/file.pmtiles"); let result = pmtiles_path("foo", "folder/{name}/file.pmtiles");
assertion.equal(result, "folder/foo/file.pmtiles"); assert.strictEqual(result, "folder/foo/file.pmtiles");
}); });
test("pmtiles path with slash", (assertion) => { test("pmtiles path with slash", () => {
let result = pmtiles_path("foo/bar","folder/{name}/file.pmtiles"); let result = pmtiles_path("foo/bar", "folder/{name}/file.pmtiles");
assertion.equal(result, "folder/foo/bar/file.pmtiles"); assert.strictEqual(result, "folder/foo/bar/file.pmtiles");
}); });
test("pmtiles path with multiple names", (assertion) => { test("pmtiles path with multiple names", () => {
let result = pmtiles_path("slug","folder/{name}/{name}.pmtiles"); let result = pmtiles_path("slug", "folder/{name}/{name}.pmtiles");
assertion.equal(result, "folder/slug/slug.pmtiles"); assert.strictEqual(result, "folder/slug/slug.pmtiles");
result = pmtiles_path("foo/bar","folder/{name}/{name}.pmtiles"); result = pmtiles_path("foo/bar", "folder/{name}/{name}.pmtiles");
assertion.equal(result, "folder/foo/bar/foo/bar.pmtiles"); assert.strictEqual(result, "folder/foo/bar/foo/bar.pmtiles");
}); });
test("parse tile default", (assertion) => { test("parse tile default", () => {
let {ok, name, tile, ext} = tile_path("abcd"); let { ok, name, tile, ext } = tile_path("abcd");
assertion.equal(ok, false); assert.strictEqual(ok, false);
({name, tile} = tile_path("/foo/11/22/33.pbf")); ({ name, tile } = tile_path("/foo/11/22/33.pbf"));
assertion.equal(name,"foo"); assert.strictEqual(name, "foo");
assertion.equal(tile[0],11); assert.strictEqual(tile[0], 11);
assertion.equal(tile[1],22); assert.strictEqual(tile[1], 22);
assertion.equal(tile[2],33); assert.strictEqual(tile[2], 33);
}); });
test("parse tile path setting", (assertion) => { test("parse tile path setting", () => {
let {ok, name, tile, ext} = tile_path("/foo/11/22/33.pbf","/{name}/{z}/{y}/{x}.{ext}"); let { ok, name, tile, ext } = tile_path(
assertion.equal(tile[1],33); "/foo/11/22/33.pbf",
assertion.equal(tile[2],22); "/{name}/{z}/{y}/{x}.{ext}"
assertion.equal(ext,"pbf"); );
({ok, name, tile, ext} = tile_path("/tiles/foo/4/2/3.mvt","/tiles/{name}/{z}/{x}/{y}.{ext}")); assert.strictEqual(tile[1], 33);
assertion.equal(name,"foo"); assert.strictEqual(tile[2], 22);
assertion.equal(tile[0],4); assert.strictEqual(ext, "pbf");
assertion.equal(tile[1],2); ({ ok, name, tile, ext } = tile_path(
assertion.equal(tile[2],3); "/tiles/foo/4/2/3.mvt",
assertion.equal(ext,"mvt"); "/tiles/{name}/{z}/{x}/{y}.{ext}"
));
assert.strictEqual(name, "foo");
assert.strictEqual(tile[0], 4);
assert.strictEqual(tile[1], 2);
assert.strictEqual(tile[2], 3);
assert.strictEqual(ext, "mvt");
}); });
test("parse tile path setting special chars", (assertion) => { test("parse tile path setting special chars", () => {
let {ok, name, tile, ext} = tile_path("/folder(new/foo/11/22/33.pbf","/folder(new/{name}/{z}/{y}/{x}.{ext}"); let { ok, name, tile, ext } = tile_path(
assertion.equal(name,"foo"); "/folder(new/foo/11/22/33.pbf",
"/folder(new/{name}/{z}/{y}/{x}.{ext}"
);
assert.strictEqual(name, "foo");
}); });
test("parse tile path setting slash", (assertion) => { test("parse tile path setting slash", () => {
let {ok, name, tile, ext} = tile_path("/foo/bar/11/22/33.pbf","/{name}/{z}/{y}/{x}.{ext}"); let { ok, name, tile, ext } = tile_path(
assertion.equal(name,"foo/bar"); "/foo/bar/11/22/33.pbf",
"/{name}/{z}/{y}/{x}.{ext}"
);
assert.strictEqual(name, "foo/bar");
}); });

View File

@@ -8,7 +8,8 @@
"module": "es2022", "module": "es2022",
"moduleResolution": "node", "moduleResolution": "node",
"types": [ "types": [
"@cloudflare/workers-types" "@cloudflare/workers-types",
"node"
], ],
"resolveJsonModule": true, "resolveJsonModule": true,
"allowJs": true, "allowJs": true,