@livestore/sync-cf 0.3.0-dev.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/cf-worker/durable-object.d.ts +45 -28
  3. package/dist/cf-worker/durable-object.d.ts.map +1 -1
  4. package/dist/cf-worker/durable-object.js +224 -121
  5. package/dist/cf-worker/durable-object.js.map +1 -1
  6. package/dist/cf-worker/worker.d.ts +44 -1
  7. package/dist/cf-worker/worker.d.ts.map +1 -1
  8. package/dist/cf-worker/worker.js +83 -15
  9. package/dist/cf-worker/worker.js.map +1 -1
  10. package/dist/common/mod.d.ts +5 -0
  11. package/dist/common/mod.d.ts.map +1 -1
  12. package/dist/common/mod.js +5 -0
  13. package/dist/common/mod.js.map +1 -1
  14. package/dist/common/ws-message-types.d.ts +148 -98
  15. package/dist/common/ws-message-types.d.ts.map +1 -1
  16. package/dist/common/ws-message-types.js +19 -24
  17. package/dist/common/ws-message-types.js.map +1 -1
  18. package/dist/sync-impl/ws-impl.d.ts +2 -5
  19. package/dist/sync-impl/ws-impl.d.ts.map +1 -1
  20. package/dist/sync-impl/ws-impl.js +89 -36
  21. package/dist/sync-impl/ws-impl.js.map +1 -1
  22. package/package.json +4 -4
  23. package/src/cf-worker/durable-object.ts +273 -126
  24. package/src/cf-worker/worker.ts +125 -16
  25. package/src/common/mod.ts +7 -0
  26. package/src/common/ws-message-types.ts +22 -36
  27. package/src/sync-impl/ws-impl.ts +145 -90
  28. package/dist/cf-worker/index.d.ts +0 -3
  29. package/dist/cf-worker/index.d.ts.map +0 -1
  30. package/dist/cf-worker/index.js +0 -33
  31. package/dist/cf-worker/index.js.map +0 -1
  32. package/dist/cf-worker/make-worker.d.ts +0 -6
  33. package/dist/cf-worker/make-worker.d.ts.map +0 -1
  34. package/dist/cf-worker/make-worker.js +0 -31
  35. package/dist/cf-worker/make-worker.js.map +0 -1
  36. package/dist/cf-worker/types.d.ts +0 -2
  37. package/dist/cf-worker/types.d.ts.map +0 -1
  38. package/dist/cf-worker/types.js +0 -2
  39. package/dist/cf-worker/types.js.map +0 -1
  40. package/dist/common/index.d.ts +0 -2
  41. package/dist/common/index.d.ts.map +0 -1
  42. package/dist/common/index.js +0 -2
  43. package/dist/common/index.js.map +0 -1
  44. package/dist/sync-impl/index.d.ts +0 -2
  45. package/dist/sync-impl/index.d.ts.map +0 -1
  46. package/dist/sync-impl/index.js +0 -2
  47. package/dist/sync-impl/index.js.map +0 -1
@@ -1,31 +0,0 @@
1
- export const makeWorker = () => {
2
- return {
3
- fetch: async (request, env, _ctx) => {
4
- const url = new URL(request.url);
5
- const searchParams = url.searchParams;
6
- const roomId = searchParams.get('room');
7
- if (roomId === null) {
8
- return new Response('Room ID is required', { status: 400 });
9
- }
10
- // This example will refer to the same Durable Object instance,
11
- // since the name "foo" is hardcoded.
12
- const id = env.WEBSOCKET_SERVER.idFromName(roomId);
13
- const durableObject = env.WEBSOCKET_SERVER.get(id);
14
- if (url.pathname.endsWith('/websocket')) {
15
- const upgradeHeader = request.headers.get('Upgrade');
16
- if (!upgradeHeader || upgradeHeader !== 'websocket') {
17
- return new Response('Durable Object expected Upgrade: websocket', { status: 426 });
18
- }
19
- return durableObject.fetch(request);
20
- }
21
- return new Response(null, {
22
- status: 400,
23
- statusText: 'Bad Request',
24
- headers: {
25
- 'Content-Type': 'text/plain',
26
- },
27
- });
28
- },
29
- };
30
- };
31
- //# sourceMappingURL=make-worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"make-worker.js","sourceRoot":"","sources":["../../src/cf-worker/make-worker.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,UAAU,GAAG,GAAa,EAAE;IACvC,OAAO;QACL,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;YAClC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YAChC,MAAM,YAAY,GAAG,GAAG,CAAC,YAAY,CAAA;YACrC,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YAEvC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBACpB,OAAO,IAAI,QAAQ,CAAC,qBAAqB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;YAC7D,CAAC;YAED,+DAA+D;YAC/D,qCAAqC;YACrC,MAAM,EAAE,GAAG,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;YAClD,MAAM,aAAa,GAAG,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YAElD,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBACxC,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;gBACpD,IAAI,CAAC,aAAa,IAAI,aAAa,KAAK,WAAW,EAAE,CAAC;oBACpD,OAAO,IAAI,QAAQ,CAAC,4CAA4C,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;gBACpF,CAAC;gBAED,OAAO,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YACrC,CAAC;YAED,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;gBACxB,MAAM,EAAE,GAAG;gBACX,UAAU,EAAE,aAAa;gBACzB,OAAO,EAAE;oBACP,cAAc,EAAE,YAAY;iBAC7B;aACF,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cf-worker/types.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/cf-worker/types.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export * as WSMessage from './ws-message-types.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAA"}
@@ -1,2 +0,0 @@
1
- export * as WSMessage from './ws-message-types.js';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './ws-impl.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync-impl/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './ws-impl.js';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync-impl/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}