Skip to content

Commit bb00fe3

Browse files
committed
released v3.0.0-next.0 - testing import
1 parent 704a085 commit bb00fe3

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

examples/counter/Counter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IttyDurable } from '../../dist'
1+
import { IttyDurable } from '../../dist/index.mjs'
22

33
export class Counter extends IttyDurable {
44
value = 0

examples/counter/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { AutoRouter } from 'itty-router'
1+
import { AutoRouter } from './node_modules/itty-router'
22
export { Counter } from './Counter'
3-
import { withDO } from '../../dist'
3+
import { withDO } from '../../dist/index.mjs'
44

55
const router = AutoRouter({
66
before: [withDO],

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "itty-durable",
33
"description": "Easier to use Durable Objects.",
4-
"version": "2.4.1",
4+
"version": "3.0.0-next.0",
55
"main": "./index.js",
66
"module": "./index.mjs",
77
"types": "./index.d.ts",
@@ -17,8 +17,8 @@
1717
"lint": "yarn run eslint src",
1818
"test": "vitest run --coverage",
1919
"verify": "echo 'verifying module...' && yarn build && yarn test",
20-
"prerelease": "yarn verify",
21-
"prerelease:next": "yarn verify",
20+
"Xprerelease": "yarn verify",
21+
"Xprerelease:next": "yarn verify",
2222
"prebuild": "rimraf dist && mkdir dist",
2323
"build": "rollup -c",
2424
"release": "release --tag --push --patch --src=dist",

rollup.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export default async () => {
4141
// export base files
4242
return files.map(file => ({
4343
input: file.path,
44+
external: [
45+
'cloudflare:workers'
46+
],
4447
output: [
4548
{
4649
format: 'esm',

src/IttyDurable.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class IttyDurable extends DurableObject {
1313
#persistLoaded: undefined | true
1414

1515
// public attributes
16+
id?: any
1617
persisted: any
1718

1819
// default store
@@ -36,7 +37,14 @@ export class IttyDurable extends DurableObject {
3637
target = obj[prop],
3738
fn = target?.bind?.(obj),
3839
) => {
40+
// allow chainable id setting before calling other methods
41+
if (prop == '$id') return (id: any) => (this.id = this.id ?? id) && this
42+
43+
// return properties directly
3944
if (!fn) return target
45+
46+
// if method, start the persist debounce and call the function
47+
// CONSIDER: moving the persist to after fn is called
4048
this.persist()
4149
return async (...args: any) => this.#sync().then(() => fn(args))
4250
}

src/itty-router/withDO.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const withDO = (request: any, env: Record<string, any>) => {
44
request[k] = request[k] ?? (
55
(id: any) =>
66
typeof id == 'string'
7-
? v.get(v.idFromName(id))
7+
? v.get(v.idFromName(id))//.$id(id)
88
: v.get(id)
99
)
1010
}

0 commit comments

Comments
 (0)