diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf630370..ff7aabcd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,10 @@ on: jobs: maybe-release: name: release + permissions: + contents: write + pull-requests: write + id-token: write # The OIDC ID token is used for authentication with JSR. runs-on: ubuntu-latest if: github.event.workflow_run.conclusion == 'success' outputs: @@ -57,11 +61,16 @@ jobs: - name: Check npm config run: npm config list - - run: node_modules/.bin/lerna publish from-package --no-verify-access --yes + - name: Publish to npm + run: node_modules/.bin/lerna publish from-package --no-verify-access --yes if: ${{ steps.release.outputs.releases_created }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Publish to JSR + run: yarn jsr publish + if: ${{ steps.release.outputs.releases_created }} + - name: Publish to Cloudflare Pages if: ${{ steps.release.outputs.releases_created }} uses: cloudflare/pages-action@1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5ed44b54..153adc93 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,15 @@ jobs: run: yarn --immutable - name: Build run: yarn build + + # JSR requires all packages to have no slow types on public interfaces, + # Which requires explicit type annotations for complex types. + # i.e. `const a = 10;` is fine but `const a = new Map()` is complex. + # We can't enforce it with TSC or Biome so had to rely on this task + # https://jsr.io/docs/about-slow-types#explicit-types + - name: Dry run for JSR publish + run: yarn jsr publish --dry-run + - name: Generate run: yarn generate - name: Check types @@ -89,26 +98,3 @@ jobs: run: bun run --filter '*' generate - name: Unit Tests run: bun run --bun --filter '*' test:unit - - test-deno: - name: Tests Deno - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2-beta - with: - node-version: "22" - - uses: denoland/setup-deno@v2 - with: - deno-version: v2.x - - name: Install - run: yarn install --frozen-lockfile - - name: Build - run: yarn build - # Deno does not run task in workspaces if same task exists on root package.json - - name: Clean root scripts - run: cat package.json | jq 'del( .scripts )' > package.json.backup && mv package.json.backup package.json - - name: Generate - run: deno task --recursive generate - - name: Unit Tests - run: deno task --recursive test:unit diff --git a/deno.jsonc b/deno.jsonc deleted file mode 100644 index 28a9877e..00000000 --- a/deno.jsonc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nodeModulesDir": "auto" -} \ No newline at end of file diff --git a/package.json b/package.json index 138097e5..d8345640 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "@vitest/browser": "~3.0.7", "@vitest/coverage-v8": "~3.0.7", "babel-loader": "^8.2.2", + "jsr": "^0.13.4", "lerna": "^8.1.3", "ts-loader": "^9.5.1", "ts-node": "^10.9.2", diff --git a/packages/as-sha256/jsr.json b/packages/as-sha256/jsr.json new file mode 100644 index 00000000..170003a4 --- /dev/null +++ b/packages/as-sha256/jsr.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://jsr.io/schema/config-file.v1.json", + "name": "@chainsafe/as-sha256", + "version": "1.2.1", + "exports": { + ".": "./src/index.ts" + }, + "publish": { + "include": ["src", "package.json", ".npmrc", "README.md", "LICENSE", "CHANGELOG.md"] + } +} diff --git a/packages/persistent-merkle-tree/jsr.json b/packages/persistent-merkle-tree/jsr.json new file mode 100644 index 00000000..b25d9ec5 --- /dev/null +++ b/packages/persistent-merkle-tree/jsr.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://jsr.io/schema/config-file.v1.json", + "name": "@chainsafe/persistent-merkle-tree", + "version": "1.2.1", + "exports": { + ".": "./src/index.ts", + "./hasher/hashtree": "./src/hasher/hashtree.ts", + "./hasher/noble": "./src/hasher/noble.ts", + "./hasher/as-sha256": "./src/hasher/as-sha256.ts" + }, + "publish": { + "include": ["src", "package.json", ".npmrc", "README.md", "LICENSE", "CHANGELOG.md"] + } +} diff --git a/packages/persistent-ts/jsr.json b/packages/persistent-ts/jsr.json new file mode 100644 index 00000000..a1050dca --- /dev/null +++ b/packages/persistent-ts/jsr.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://jsr.io/schema/config-file.v1.json", + "name": "@chainsafe/persistent-ts", + "version": "1.0.1", + "exports": { + ".": "./src/index.ts" + }, + "publish": { + "include": [ + "src", + "package.json", + ".npmrc", + "README.md", + "LICENSE", + "CHANGELOG.md" + ] + } +} diff --git a/packages/ssz/jsr.json b/packages/ssz/jsr.json new file mode 100644 index 00000000..f4599af3 --- /dev/null +++ b/packages/ssz/jsr.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://jsr.io/schema/config-file.v1.json", + "name": "@chainsafe/ssz", + "version": "1.2.2", + "exports": { + ".": "./src/index.ts" + }, + "publish": { + "include": ["src", "package.json", ".npmrc", "README.md", "LICENSE", "CHANGELOG.md"] + } +} diff --git a/packages/ssz/src/type/bitList.ts b/packages/ssz/src/type/bitList.ts index 451f3694..30bb8ee4 100644 --- a/packages/ssz/src/type/bitList.ts +++ b/packages/ssz/src/type/bitList.ts @@ -34,8 +34,8 @@ export class BitListType extends BitArrayType { readonly maxSize: number; readonly maxChunkCount: number; readonly isList = true; - readonly mixInLengthBlockBytes = new Uint8Array(64); - readonly mixInLengthBuffer = Buffer.from( + readonly mixInLengthBlockBytes: Uint8Array = new Uint8Array(64); + readonly mixInLengthBuffer: Buffer = Buffer.from( this.mixInLengthBlockBytes.buffer, this.mixInLengthBlockBytes.byteOffset, this.mixInLengthBlockBytes.byteLength diff --git a/packages/ssz/src/type/byteList.ts b/packages/ssz/src/type/byteList.ts index 00149fa3..8e274f9d 100644 --- a/packages/ssz/src/type/byteList.ts +++ b/packages/ssz/src/type/byteList.ts @@ -42,8 +42,8 @@ export class ByteListType extends ByteArrayType { readonly isList = true; readonly blockArray: Uint8Array[] = []; private blockBytesLen = 0; - readonly mixInLengthBlockBytes = new Uint8Array(64); - readonly mixInLengthBuffer = Buffer.from( + readonly mixInLengthBlockBytes: Uint8Array = new Uint8Array(64); + readonly mixInLengthBuffer: Buffer = Buffer.from( this.mixInLengthBlockBytes.buffer, this.mixInLengthBlockBytes.byteOffset, this.mixInLengthBlockBytes.byteLength diff --git a/packages/ssz/src/type/composite.ts b/packages/ssz/src/type/composite.ts index ab2d1fb8..fae1621f 100644 --- a/packages/ssz/src/type/composite.ts +++ b/packages/ssz/src/type/composite.ts @@ -59,7 +59,7 @@ export abstract class CompositeType extends Type { * Required for ContainerNodeStruct to ensure no dangerous types are constructed. */ abstract readonly isViewMutable: boolean; - protected blocksBuffer = new Uint8Array(0); + protected blocksBuffer: Uint8Array = new Uint8Array(0); constructor( /** diff --git a/packages/ssz/src/type/listBasic.ts b/packages/ssz/src/type/listBasic.ts index 5cd1faf5..4cafadbf 100644 --- a/packages/ssz/src/type/listBasic.ts +++ b/packages/ssz/src/type/listBasic.ts @@ -50,8 +50,8 @@ export class ListBasicType> readonly maxSize: number; readonly isList = true; readonly isViewMutable = true; - readonly mixInLengthBlockBytes = new Uint8Array(64); - readonly mixInLengthBuffer = Buffer.from( + readonly mixInLengthBlockBytes: Uint8Array = new Uint8Array(64); + readonly mixInLengthBuffer: Buffer = Buffer.from( this.mixInLengthBlockBytes.buffer, this.mixInLengthBlockBytes.byteOffset, this.mixInLengthBlockBytes.byteLength diff --git a/packages/ssz/src/type/listComposite.ts b/packages/ssz/src/type/listComposite.ts index cb461154..27e0b2ff 100644 --- a/packages/ssz/src/type/listComposite.ts +++ b/packages/ssz/src/type/listComposite.ts @@ -61,8 +61,8 @@ export class ListCompositeType< readonly isList = true; readonly isViewMutable = true; readonly blockArray: Uint8Array[] = []; - readonly mixInLengthBlockBytes = new Uint8Array(64); - readonly mixInLengthBuffer = Buffer.from( + readonly mixInLengthBlockBytes: Uint8Array = new Uint8Array(64); + readonly mixInLengthBuffer: Buffer = Buffer.from( this.mixInLengthBlockBytes.buffer, this.mixInLengthBlockBytes.byteOffset, this.mixInLengthBlockBytes.byteLength diff --git a/packages/ssz/src/type/optional.ts b/packages/ssz/src/type/optional.ts index 81bf1a0b..7f323ca7 100644 --- a/packages/ssz/src/type/optional.ts +++ b/packages/ssz/src/type/optional.ts @@ -47,8 +47,8 @@ export class OptionalType> extends CompositeTy readonly maxSize: number; readonly isList = true; readonly isViewMutable = true; - readonly mixInLengthBlockBytes = new Uint8Array(64); - readonly mixInLengthBuffer = Buffer.from( + readonly mixInLengthBlockBytes: Uint8Array = new Uint8Array(64); + readonly mixInLengthBuffer: Buffer = Buffer.from( this.mixInLengthBlockBytes.buffer, this.mixInLengthBlockBytes.byteOffset, this.mixInLengthBlockBytes.byteLength diff --git a/packages/ssz/src/type/union.ts b/packages/ssz/src/type/union.ts index 9ab2f639..1c64f8f5 100644 --- a/packages/ssz/src/type/union.ts +++ b/packages/ssz/src/type/union.ts @@ -47,8 +47,8 @@ export class UnionType[]> extends CompositeType< readonly maxSize: number; readonly isList = true; readonly isViewMutable = true; - readonly mixInLengthBlockBytes = new Uint8Array(64); - readonly mixInLengthBuffer = Buffer.from( + readonly mixInLengthBlockBytes: Uint8Array = new Uint8Array(64); + readonly mixInLengthBuffer: Buffer = Buffer.from( this.mixInLengthBlockBytes.buffer, this.mixInLengthBlockBytes.byteOffset, this.mixInLengthBlockBytes.byteLength diff --git a/packages/ssz/src/viewDU/arrayBasic.ts b/packages/ssz/src/viewDU/arrayBasic.ts index 6bae7912..386b9b36 100644 --- a/packages/ssz/src/viewDU/arrayBasic.ts +++ b/packages/ssz/src/viewDU/arrayBasic.ts @@ -22,7 +22,7 @@ export class ArrayBasicTreeViewDU> extend ArrayBasicType > { protected nodes: LeafNode[]; - protected readonly nodesChanged = new Set(); + protected readonly nodesChanged: Set = new Set(); protected _length: number; protected dirtyLength = false; private nodesPopulated: boolean; diff --git a/packages/ssz/src/viewDU/arrayComposite.ts b/packages/ssz/src/viewDU/arrayComposite.ts index d38d160a..30d496d9 100644 --- a/packages/ssz/src/viewDU/arrayComposite.ts +++ b/packages/ssz/src/viewDU/arrayComposite.ts @@ -23,7 +23,10 @@ export class ArrayCompositeTreeViewDU< > extends TreeViewDU> { protected nodes: Node[]; protected caches: unknown[]; - protected readonly viewsChanged = new Map>(); + protected readonly viewsChanged: Map> = new Map< + number, + CompositeViewDU + >(); protected _length: number; // TODO: Consider these properties are not accessible in the cache object persisted in the parent's cache. // nodes, caches, _length, and nodesPopulated are mutated. Consider having them in a _cache object such that diff --git a/release-please-config.json b/release-please-config.json index 6401944b..551491e2 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -9,7 +9,10 @@ "bumpMinorPreMajor": true, "bumpPatchForMinorPreMajor": true, "changelogPath": "CHANGELOG.md", - "versioning": "default" + "versioning": "default", + "extra-files": [ + { "type": "json", "path": "jsr.json", "jsonpath": "$.version" } + ] }, "packages/persistent-merkle-tree": { "releaseType": "node", @@ -18,7 +21,10 @@ "bumpMinorPreMajor": true, "bumpPatchForMinorPreMajor": true, "changelogPath": "CHANGELOG.md", - "versioning": "default" + "versioning": "default", + "extra-files": [ + { "type": "json", "path": "jsr.json", "jsonpath": "$.version" } + ] }, "packages/persistent-ts": { "releaseType": "node", @@ -27,7 +33,10 @@ "bumpMinorPreMajor": true, "bumpPatchForMinorPreMajor": true, "changelogPath": "CHANGELOG.md", - "versioning": "default" + "versioning": "default", + "extra-files": [ + { "type": "json", "path": "jsr.json", "jsonpath": "$.version" } + ] }, "packages/ssz": { "releaseType": "node", @@ -36,7 +45,10 @@ "bumpMinorPreMajor": true, "bumpPatchForMinorPreMajor": true, "changelogPath": "CHANGELOG.md", - "versioning": "default" + "versioning": "default", + "extra-files": [ + { "type": "json", "path": "jsr.json", "jsonpath": "$.version" } + ] } } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index f27e7ee7..7b551d6b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8870,6 +8870,15 @@ jsonparse@^1.2.0, jsonparse@^1.3.1: resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg== +jsr@^0.13.4: + version "0.13.4" + resolved "https://registry.yarnpkg.com/jsr/-/jsr-0.13.4.tgz#49c3fdbce587ef4604304911011e242a3ed1d429" + integrity sha512-GJ9Ju8kf2SxH90C1AqANrMKBFlDjrZu1YoFm4SoMCOBOxix3Bvirdg5JB31gbF8FwPBo3196dAaqV0WUjeuq8Q== + dependencies: + kolorist "^1.8.0" + node-stream-zip "^1.15.0" + semiver "^1.1.0" + "jsx-ast-utils@^2.4.1 || ^3.0.0": version "3.3.5" resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz#4766bd05a8e2a11af222becd19e15575e52a853a" @@ -8909,6 +8918,11 @@ kind-of@^6.0.2, kind-of@^6.0.3: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== +kolorist@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/kolorist/-/kolorist-1.8.0.tgz#edddbbbc7894bc13302cdf740af6374d4a04743c" + integrity sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ== + launch-editor@^2.6.1: version "2.10.0" resolved "https://registry.yarnpkg.com/launch-editor/-/launch-editor-2.10.0.tgz#5ca3edfcb9667df1e8721310f3a40f1127d4bc42" @@ -9999,6 +10013,11 @@ node-stdlib-browser@^1.2.0: util "^0.12.4" vm-browserify "^1.0.1" +node-stream-zip@^1.15.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/node-stream-zip/-/node-stream-zip-1.15.0.tgz#158adb88ed8004c6c49a396b50a6a5de3bca33ea" + integrity sha512-LN4fydt9TqhZhThkZIVQnF9cwjU3qmUH9h78Mx/K7d3VvfRqqwthLwJEUOEL0QPZ0XQmNN7be5Ggit5+4dq3Bw== + nopt@^7.0.0: version "7.2.1" resolved "https://registry.yarnpkg.com/nopt/-/nopt-7.2.1.tgz#1cac0eab9b8e97c9093338446eddd40b2c8ca1e7" @@ -12014,6 +12033,11 @@ selfsigned@^2.4.1: "@types/node-forge" "^1.3.0" node-forge "^1" +semiver@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/semiver/-/semiver-1.1.0.tgz#9c97fb02c21c7ce4fcf1b73e2c7a24324bdddd5f" + integrity sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg== + "semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0: version "5.7.2" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8"