a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto bluesky typescript npm
101
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(cbor): quickly bail out to slow path on server runtimes

Mary a891529d 6ba553fd

+24 -1
+5
.changeset/bright-snails-hide.md
··· 1 + --- 2 + '@atcute/cbor': patch 3 + --- 4 + 5 + quickly bail out to slow path on server runtimes
+3 -1
packages/utilities/cbor/lib/encode.ts
··· 1 1 import { type CidLink, CidLinkWrapper, fromString } from '@atcute/cid'; 2 2 import { allocUnsafe, concat, encodeUtf8Into } from '@atcute/uint8array'; 3 3 4 + import { IS_NODE_RUNTIME } from '#runtime'; 5 + 4 6 import { type Bytes, BytesWrapper, fromBytes } from './bytes.ts'; 5 7 6 8 const MAX_TYPE_ARG_LEN = 9; ··· 166 168 resizeIfNeeded(state, strLength * 3 + MAX_TYPE_ARG_LEN); 167 169 168 170 // Optimistic fast encode 169 - ascii: { 171 + ascii: if (!IS_NODE_RUNTIME || strLength < 24) { 170 172 const ptr = state.p + getTypeInfoLength(strLength); 171 173 const first = val.charCodeAt(0); 172 174 if (first > 0x7f) {
+1
packages/utilities/cbor/lib/runtime.node.ts
··· 1 + export const IS_NODE_RUNTIME = true;
+1
packages/utilities/cbor/lib/runtime.ts
··· 1 + export const IS_NODE_RUNTIME = false;
+14
packages/utilities/cbor/package.json
··· 20 20 ], 21 21 "type": "module", 22 22 "sideEffects": false, 23 + "imports": { 24 + "#runtime": { 25 + "workerd": "./lib/runtime.ts", 26 + "node": "./lib/runtime.node.ts", 27 + "default": "./lib/runtime.ts" 28 + } 29 + }, 23 30 "exports": { 24 31 ".": "./lib/index.ts", 25 32 "./bytes": "./lib/bytes.ts" ··· 29 36 "exports": { 30 37 ".": "./dist/index.js", 31 38 "./bytes": "./dist/bytes.js" 39 + }, 40 + "imports": { 41 + "#runtime": { 42 + "workerd": "./dist/runtime.js", 43 + "node": "./dist/runtime.node.js", 44 + "default": "./dist/runtime.js" 45 + } 32 46 } 33 47 }, 34 48 "scripts": {