@livestore/sync-cf 0.3.0-dev.11 → 0.3.0-dev.3

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 (50) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/cf-worker/durable-object.d.ts +34 -27
  3. package/dist/cf-worker/durable-object.d.ts.map +1 -1
  4. package/dist/cf-worker/durable-object.js +129 -150
  5. package/dist/cf-worker/durable-object.js.map +1 -1
  6. package/dist/cf-worker/index.d.ts +6 -1
  7. package/dist/cf-worker/index.d.ts.map +1 -1
  8. package/dist/cf-worker/index.js +64 -30
  9. package/dist/cf-worker/index.js.map +1 -1
  10. package/dist/common/ws-message-types.d.ts +207 -54
  11. package/dist/common/ws-message-types.d.ts.map +1 -1
  12. package/dist/common/ws-message-types.js +3 -3
  13. package/dist/common/ws-message-types.js.map +1 -1
  14. package/dist/sync-impl/ws-impl.d.ts +12 -3
  15. package/dist/sync-impl/ws-impl.d.ts.map +1 -1
  16. package/dist/sync-impl/ws-impl.js +4 -5
  17. package/dist/sync-impl/ws-impl.js.map +1 -1
  18. package/package.json +13 -15
  19. package/src/cf-worker/durable-object.ts +161 -215
  20. package/src/cf-worker/index.ts +84 -0
  21. package/src/common/ws-message-types.ts +3 -3
  22. package/src/sync-impl/ws-impl.ts +16 -8
  23. package/dist/cf-worker/make-worker.d.ts +0 -6
  24. package/dist/cf-worker/make-worker.d.ts.map +0 -1
  25. package/dist/cf-worker/make-worker.js +0 -31
  26. package/dist/cf-worker/make-worker.js.map +0 -1
  27. package/dist/cf-worker/mod.d.ts +0 -3
  28. package/dist/cf-worker/mod.d.ts.map +0 -1
  29. package/dist/cf-worker/mod.js +0 -3
  30. package/dist/cf-worker/mod.js.map +0 -1
  31. package/dist/cf-worker/types.d.ts +0 -2
  32. package/dist/cf-worker/types.d.ts.map +0 -1
  33. package/dist/cf-worker/types.js +0 -2
  34. package/dist/cf-worker/types.js.map +0 -1
  35. package/dist/cf-worker/worker.d.ts +0 -6
  36. package/dist/cf-worker/worker.d.ts.map +0 -1
  37. package/dist/cf-worker/worker.js +0 -29
  38. package/dist/cf-worker/worker.js.map +0 -1
  39. package/dist/common/mod.d.ts +0 -2
  40. package/dist/common/mod.d.ts.map +0 -1
  41. package/dist/common/mod.js +0 -2
  42. package/dist/common/mod.js.map +0 -1
  43. package/dist/sync-impl/mod.d.ts +0 -2
  44. package/dist/sync-impl/mod.d.ts.map +0 -1
  45. package/dist/sync-impl/mod.js +0 -2
  46. package/dist/sync-impl/mod.js.map +0 -1
  47. package/src/cf-worker/mod.ts +0 -2
  48. package/src/cf-worker/worker.ts +0 -39
  49. /package/src/common/{mod.ts → index.ts} +0 -0
  50. /package/src/sync-impl/{mod.ts → index.ts} +0 -0
@@ -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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worker.js';
3
- //# sourceMappingURL=mod.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/cf-worker/mod.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './durable-object.js';
2
- export * from './worker.js';
3
- //# sourceMappingURL=mod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/cf-worker/mod.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,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,6 +0,0 @@
1
- import type { Env } from './durable-object.js';
2
- export type CFWorker = {
3
- fetch: (request: Request, env: Env, ctx: ExecutionContext) => Promise<Response>;
4
- };
5
- export declare const makeWorker: () => CFWorker;
6
- //# sourceMappingURL=worker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/cf-worker/worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AAE9C,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,gBAAgB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;CAChF,CAAA;AAED,eAAO,MAAM,UAAU,QAAO,QAgC7B,CAAA"}
@@ -1,29 +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 storeId = searchParams.get('storeId');
7
- if (storeId === null) {
8
- return new Response('storeId search param is required', { status: 400 });
9
- }
10
- const id = env.WEBSOCKET_SERVER.idFromName(storeId);
11
- const durableObject = env.WEBSOCKET_SERVER.get(id);
12
- if (url.pathname.endsWith('/websocket')) {
13
- const upgradeHeader = request.headers.get('Upgrade');
14
- if (!upgradeHeader || upgradeHeader !== 'websocket') {
15
- return new Response('Durable Object expected Upgrade: websocket', { status: 426 });
16
- }
17
- return durableObject.fetch(request);
18
- }
19
- return new Response(null, {
20
- status: 400,
21
- statusText: 'Bad Request',
22
- headers: {
23
- 'Content-Type': 'text/plain',
24
- },
25
- });
26
- },
27
- };
28
- };
29
- //# sourceMappingURL=worker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/cf-worker/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,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YAE3C,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;gBACrB,OAAO,IAAI,QAAQ,CAAC,kCAAkC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;YAC1E,CAAC;YAED,MAAM,EAAE,GAAG,GAAG,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;YACnD,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 * as WSMessage from './ws-message-types.js';
2
- //# sourceMappingURL=mod.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/common/mod.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=mod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/common/mod.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './ws-impl.js';
2
- //# sourceMappingURL=mod.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/sync-impl/mod.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './ws-impl.js';
2
- //# sourceMappingURL=mod.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/sync-impl/mod.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './durable-object.js'
2
- export * from './worker.js'
@@ -1,39 +0,0 @@
1
- import type { Env } from './durable-object.js'
2
-
3
- export type CFWorker = {
4
- fetch: (request: Request, env: Env, ctx: ExecutionContext) => Promise<Response>
5
- }
6
-
7
- export const makeWorker = (): CFWorker => {
8
- return {
9
- fetch: async (request, env, _ctx) => {
10
- const url = new URL(request.url)
11
- const searchParams = url.searchParams
12
- const storeId = searchParams.get('storeId')
13
-
14
- if (storeId === null) {
15
- return new Response('storeId search param is required', { status: 400 })
16
- }
17
-
18
- const id = env.WEBSOCKET_SERVER.idFromName(storeId)
19
- const durableObject = env.WEBSOCKET_SERVER.get(id)
20
-
21
- if (url.pathname.endsWith('/websocket')) {
22
- const upgradeHeader = request.headers.get('Upgrade')
23
- if (!upgradeHeader || upgradeHeader !== 'websocket') {
24
- return new Response('Durable Object expected Upgrade: websocket', { status: 426 })
25
- }
26
-
27
- return durableObject.fetch(request)
28
- }
29
-
30
- return new Response(null, {
31
- status: 400,
32
- statusText: 'Bad Request',
33
- headers: {
34
- 'Content-Type': 'text/plain',
35
- },
36
- })
37
- },
38
- }
39
- }
File without changes
File without changes