@sidekickdb/react 2.0.0 → 3.0.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 (106) hide show
  1. package/README.md +3 -3
  2. package/__example__/standalone.esm.html +3 -3
  3. package/__example__/standalone.umd.html +2 -2
  4. package/__tests__/getUserFromSidekickCookie.test.ts +24 -0
  5. package/dist/commonjs/Cursors.d.ts +2 -2
  6. package/dist/commonjs/Cursors.d.ts.map +1 -1
  7. package/dist/commonjs/Cursors.js.map +1 -1
  8. package/dist/commonjs/SidekickReactWebDatabase.d.ts +7 -0
  9. package/dist/commonjs/SidekickReactWebDatabase.d.ts.map +1 -0
  10. package/dist/commonjs/{InstantReactWebDatabase.js → SidekickReactWebDatabase.js} +3 -3
  11. package/dist/commonjs/SidekickReactWebDatabase.js.map +1 -0
  12. package/dist/commonjs/index.d.ts +4 -4
  13. package/dist/commonjs/index.d.ts.map +1 -1
  14. package/dist/commonjs/index.js +8 -8
  15. package/dist/commonjs/index.js.map +1 -1
  16. package/dist/commonjs/init.d.ts +5 -5
  17. package/dist/commonjs/init.d.ts.map +1 -1
  18. package/dist/commonjs/init.js +5 -5
  19. package/dist/commonjs/init.js.map +1 -1
  20. package/dist/commonjs/next-ssr/SidekickNextDatabase.d.ts +12 -0
  21. package/dist/commonjs/next-ssr/SidekickNextDatabase.d.ts.map +1 -0
  22. package/dist/commonjs/next-ssr/{InstantNextDatabase.js → SidekickNextDatabase.js} +8 -8
  23. package/dist/commonjs/next-ssr/SidekickNextDatabase.js.map +1 -0
  24. package/dist/commonjs/next-ssr/SidekickSuspenseProvider.d.ts +25 -0
  25. package/dist/commonjs/next-ssr/SidekickSuspenseProvider.d.ts.map +1 -0
  26. package/dist/commonjs/next-ssr/{InstantSuspenseProvider.js → SidekickSuspenseProvider.js} +6 -6
  27. package/dist/commonjs/next-ssr/SidekickSuspenseProvider.js.map +1 -0
  28. package/dist/commonjs/next-ssr/getUserFromSidekickCookie.d.ts +10 -0
  29. package/dist/commonjs/next-ssr/getUserFromSidekickCookie.d.ts.map +1 -0
  30. package/dist/commonjs/next-ssr/getUserFromSidekickCookie.js +22 -0
  31. package/dist/commonjs/next-ssr/getUserFromSidekickCookie.js.map +1 -0
  32. package/dist/commonjs/next-ssr/index.d.ts +9 -9
  33. package/dist/commonjs/next-ssr/index.d.ts.map +1 -1
  34. package/dist/commonjs/next-ssr/index.js +14 -14
  35. package/dist/commonjs/next-ssr/index.js.map +1 -1
  36. package/dist/esm/Cursors.d.ts +2 -2
  37. package/dist/esm/Cursors.d.ts.map +1 -1
  38. package/dist/esm/Cursors.js.map +1 -1
  39. package/dist/esm/SidekickReactWebDatabase.d.ts +7 -0
  40. package/dist/esm/SidekickReactWebDatabase.d.ts.map +1 -0
  41. package/dist/esm/SidekickReactWebDatabase.js +6 -0
  42. package/dist/esm/SidekickReactWebDatabase.js.map +1 -0
  43. package/dist/esm/index.d.ts +4 -4
  44. package/dist/esm/index.d.ts.map +1 -1
  45. package/dist/esm/index.js +9 -9
  46. package/dist/esm/index.js.map +1 -1
  47. package/dist/esm/init.d.ts +5 -5
  48. package/dist/esm/init.d.ts.map +1 -1
  49. package/dist/esm/init.js +5 -5
  50. package/dist/esm/init.js.map +1 -1
  51. package/dist/esm/next-ssr/SidekickNextDatabase.d.ts +12 -0
  52. package/dist/esm/next-ssr/SidekickNextDatabase.d.ts.map +1 -0
  53. package/dist/esm/next-ssr/{InstantNextDatabase.js → SidekickNextDatabase.js} +4 -4
  54. package/dist/esm/next-ssr/SidekickNextDatabase.js.map +1 -0
  55. package/dist/esm/next-ssr/SidekickSuspenseProvider.d.ts +25 -0
  56. package/dist/esm/next-ssr/SidekickSuspenseProvider.d.ts.map +1 -0
  57. package/dist/esm/next-ssr/{InstantSuspenseProvider.js → SidekickSuspenseProvider.js} +4 -4
  58. package/dist/esm/next-ssr/SidekickSuspenseProvider.js.map +1 -0
  59. package/dist/esm/next-ssr/getUserFromSidekickCookie.d.ts +10 -0
  60. package/dist/esm/next-ssr/getUserFromSidekickCookie.d.ts.map +1 -0
  61. package/dist/esm/next-ssr/getUserFromSidekickCookie.js +17 -0
  62. package/dist/esm/next-ssr/getUserFromSidekickCookie.js.map +1 -0
  63. package/dist/esm/next-ssr/index.d.ts +9 -9
  64. package/dist/esm/next-ssr/index.d.ts.map +1 -1
  65. package/dist/esm/next-ssr/index.js +9 -9
  66. package/dist/esm/next-ssr/index.js.map +1 -1
  67. package/dist/standalone/index.js +1526 -1626
  68. package/dist/standalone/index.umd.cjs +20 -17
  69. package/package.json +6 -6
  70. package/src/Cursors.tsx +2 -2
  71. package/src/SidekickReactWebDatabase.ts +14 -0
  72. package/src/index.ts +56 -56
  73. package/src/init.ts +16 -12
  74. package/src/next-ssr/{InstantNextDatabase.tsx → SidekickNextDatabase.tsx} +8 -8
  75. package/src/next-ssr/{InstantSuspenseProvider.tsx → SidekickSuspenseProvider.tsx} +17 -17
  76. package/src/next-ssr/{getUserFromInstantCookie.ts → getUserFromSidekickCookie.ts} +5 -5
  77. package/src/next-ssr/index.tsx +17 -17
  78. package/vite.config.ts +1 -1
  79. package/dist/commonjs/InstantReactWebDatabase.d.ts +0 -7
  80. package/dist/commonjs/InstantReactWebDatabase.d.ts.map +0 -1
  81. package/dist/commonjs/InstantReactWebDatabase.js.map +0 -1
  82. package/dist/commonjs/next-ssr/InstantNextDatabase.d.ts +0 -12
  83. package/dist/commonjs/next-ssr/InstantNextDatabase.d.ts.map +0 -1
  84. package/dist/commonjs/next-ssr/InstantNextDatabase.js.map +0 -1
  85. package/dist/commonjs/next-ssr/InstantSuspenseProvider.d.ts +0 -25
  86. package/dist/commonjs/next-ssr/InstantSuspenseProvider.d.ts.map +0 -1
  87. package/dist/commonjs/next-ssr/InstantSuspenseProvider.js.map +0 -1
  88. package/dist/commonjs/next-ssr/getUserFromInstantCookie.d.ts +0 -10
  89. package/dist/commonjs/next-ssr/getUserFromInstantCookie.d.ts.map +0 -1
  90. package/dist/commonjs/next-ssr/getUserFromInstantCookie.js +0 -22
  91. package/dist/commonjs/next-ssr/getUserFromInstantCookie.js.map +0 -1
  92. package/dist/esm/InstantReactWebDatabase.d.ts +0 -7
  93. package/dist/esm/InstantReactWebDatabase.d.ts.map +0 -1
  94. package/dist/esm/InstantReactWebDatabase.js +0 -6
  95. package/dist/esm/InstantReactWebDatabase.js.map +0 -1
  96. package/dist/esm/next-ssr/InstantNextDatabase.d.ts +0 -12
  97. package/dist/esm/next-ssr/InstantNextDatabase.d.ts.map +0 -1
  98. package/dist/esm/next-ssr/InstantNextDatabase.js.map +0 -1
  99. package/dist/esm/next-ssr/InstantSuspenseProvider.d.ts +0 -25
  100. package/dist/esm/next-ssr/InstantSuspenseProvider.d.ts.map +0 -1
  101. package/dist/esm/next-ssr/InstantSuspenseProvider.js.map +0 -1
  102. package/dist/esm/next-ssr/getUserFromInstantCookie.d.ts +0 -10
  103. package/dist/esm/next-ssr/getUserFromInstantCookie.d.ts.map +0 -1
  104. package/dist/esm/next-ssr/getUserFromInstantCookie.js +0 -17
  105. package/dist/esm/next-ssr/getUserFromInstantCookie.js.map +0 -1
  106. package/src/InstantReactWebDatabase.ts +0 -14
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUnverifiedUserFromSidekickCookie = exports.getUserFromSidekickCookie = void 0;
4
+ const headers_js_1 = require("next/headers.js");
5
+ /**
6
+ * @deprecated Please use `getUnverifiedUserFromSidekickCookie` instead
7
+ */
8
+ const getUserFromSidekickCookie = async (appId) => {
9
+ return (0, exports.getUnverifiedUserFromSidekickCookie)(appId);
10
+ };
11
+ exports.getUserFromSidekickCookie = getUserFromSidekickCookie;
12
+ /**
13
+ * Parses a user object from current Next.JS request context's cookies.
14
+ */
15
+ const getUnverifiedUserFromSidekickCookie = async (appId) => {
16
+ const cookieStore = await (0, headers_js_1.cookies)();
17
+ const userJSON = cookieStore.get('sidekick_user_' + appId);
18
+ const user = userJSON ? JSON.parse(decodeURIComponent(userJSON.value)) : null;
19
+ return user;
20
+ };
21
+ exports.getUnverifiedUserFromSidekickCookie = getUnverifiedUserFromSidekickCookie;
22
+ //# sourceMappingURL=getUserFromSidekickCookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getUserFromSidekickCookie.js","sourceRoot":"","sources":["../../../src/next-ssr/getUserFromSidekickCookie.ts"],"names":[],"mappings":";;;AACA,gDAA0C;AAE1C;;GAEG;AACI,MAAM,yBAAyB,GAAG,KAAK,EAC5C,KAAa,EACS,EAAE;IACxB,OAAO,IAAA,2CAAmC,EAAC,KAAK,CAAC,CAAC;AACpD,CAAC,CAAC;AAJW,QAAA,yBAAyB,6BAIpC;AAEF;;GAEG;AACI,MAAM,mCAAmC,GAAG,KAAK,EACtD,KAAa,EACS,EAAE;IACxB,MAAM,WAAW,GAAG,MAAM,IAAA,oBAAO,GAAE,CAAC;IACpC,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9E,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAPW,QAAA,mCAAmC,uCAO9C","sourcesContent":["import { User } from '@sidekickdb/core';\nimport { cookies } from 'next/headers.js';\n\n/**\n * @deprecated Please use `getUnverifiedUserFromSidekickCookie` instead\n */\nexport const getUserFromSidekickCookie = async (\n appId: string,\n): Promise<User | null> => {\n return getUnverifiedUserFromSidekickCookie(appId);\n};\n\n/**\n * Parses a user object from current Next.JS request context's cookies.\n */\nexport const getUnverifiedUserFromSidekickCookie = async (\n appId: string,\n): Promise<User | null> => {\n const cookieStore = await cookies();\n const userJSON = cookieStore.get('sidekick_user_' + appId);\n const user = userJSON ? JSON.parse(decodeURIComponent(userJSON.value)) : null;\n return user;\n};\n"]}
@@ -1,9 +1,9 @@
1
- import { InstantConfig, InstantSchemaDef, InstantUnknownSchema } from '@sidekickdb/core';
2
- import { InstantNextDatabase } from './InstantNextDatabase.tsx';
3
- export { getUnverifiedUserFromInstantCookie, getUserFromInstantCookie, } from './getUserFromInstantCookie.ts';
4
- export { InstantNextDatabase } from './InstantNextDatabase.tsx';
5
- export { InstantSuspenseProvider } from './InstantSuspenseProvider.tsx';
6
- export { createInstantRouteHandler } from '@sidekickdb/core';
1
+ import { SidekickConfig, SidekickSchemaDef, SidekickUnknownSchema } from '@sidekickdb/core';
2
+ import { SidekickNextDatabase } from './SidekickNextDatabase.tsx';
3
+ export { getUnverifiedUserFromSidekickCookie, getUserFromSidekickCookie, } from './getUserFromSidekickCookie.ts';
4
+ export { SidekickNextDatabase } from './SidekickNextDatabase.tsx';
5
+ export { SidekickSuspenseProvider } from './SidekickSuspenseProvider.tsx';
6
+ export { createSidekickRouteHandler } from '@sidekickdb/core';
7
7
  /**
8
8
  *
9
9
  * The first step: init your application!
@@ -18,13 +18,13 @@ export { createInstantRouteHandler } from '@sidekickdb/core';
18
18
  * // You can also provide a schema for type safety and editor autocomplete!
19
19
  *
20
20
  * import { init } from "@sidekickdb/react"
21
- * import schema from ""../instant.schema.ts";
21
+ * import schema from ""../sidekick.schema.ts";
22
22
  *
23
23
  * const db = init({ appId: "my-app-id", apiURI: "https://sidekick.example.com", schema })
24
24
  *
25
25
  * // To learn more: https://sidekickdb.co/docs/modeling-data
26
26
  */
27
- export declare function init<Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema, UseDates extends boolean = false>(config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {
27
+ export declare function init<Schema extends SidekickSchemaDef<any, any, any> = SidekickUnknownSchema, UseDates extends boolean = false>(config: Omit<SidekickConfig<Schema, UseDates>, 'useDateObjects'> & {
28
28
  useDateObjects?: UseDates;
29
- }): InstantNextDatabase<Schema, UseDates>;
29
+ }): SidekickNextDatabase<Schema, UseDates>;
30
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/next-ssr/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EACL,kCAAkC,EAClC,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,IAAI,CAClB,MAAM,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,oBAAoB,EACrE,QAAQ,SAAS,OAAO,GAAG,KAAK,EAIhC,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,GAAG;IAChE,cAAc,CAAC,EAAE,QAAQ,CAAC;CAC3B,GACA,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAIvC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/next-ssr/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EACL,mCAAmC,EACnC,yBAAyB,GAC1B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,IAAI,CAClB,MAAM,SAAS,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,qBAAqB,EACvE,QAAQ,SAAS,OAAO,GAAG,KAAK,EAIhC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,GAAG;IACjE,cAAc,CAAC,EAAE,QAAQ,CAAC;CAC3B,GACA,oBAAoB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAIxC"}
@@ -3,19 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createInstantRouteHandler = exports.InstantSuspenseProvider = exports.InstantNextDatabase = exports.getUserFromInstantCookie = exports.getUnverifiedUserFromInstantCookie = void 0;
6
+ exports.createSidekickRouteHandler = exports.SidekickSuspenseProvider = exports.SidekickNextDatabase = exports.getUserFromSidekickCookie = exports.getUnverifiedUserFromSidekickCookie = void 0;
7
7
  exports.init = init;
8
8
  const version_ts_1 = __importDefault(require("../version.js"));
9
- const InstantNextDatabase_tsx_1 = require("./InstantNextDatabase.js");
10
- var getUserFromInstantCookie_ts_1 = require("./getUserFromInstantCookie.js");
11
- Object.defineProperty(exports, "getUnverifiedUserFromInstantCookie", { enumerable: true, get: function () { return getUserFromInstantCookie_ts_1.getUnverifiedUserFromInstantCookie; } });
12
- Object.defineProperty(exports, "getUserFromInstantCookie", { enumerable: true, get: function () { return getUserFromInstantCookie_ts_1.getUserFromInstantCookie; } });
13
- var InstantNextDatabase_tsx_2 = require("./InstantNextDatabase.js");
14
- Object.defineProperty(exports, "InstantNextDatabase", { enumerable: true, get: function () { return InstantNextDatabase_tsx_2.InstantNextDatabase; } });
15
- var InstantSuspenseProvider_tsx_1 = require("./InstantSuspenseProvider.js");
16
- Object.defineProperty(exports, "InstantSuspenseProvider", { enumerable: true, get: function () { return InstantSuspenseProvider_tsx_1.InstantSuspenseProvider; } });
9
+ const SidekickNextDatabase_tsx_1 = require("./SidekickNextDatabase.js");
10
+ var getUserFromSidekickCookie_ts_1 = require("./getUserFromSidekickCookie.js");
11
+ Object.defineProperty(exports, "getUnverifiedUserFromSidekickCookie", { enumerable: true, get: function () { return getUserFromSidekickCookie_ts_1.getUnverifiedUserFromSidekickCookie; } });
12
+ Object.defineProperty(exports, "getUserFromSidekickCookie", { enumerable: true, get: function () { return getUserFromSidekickCookie_ts_1.getUserFromSidekickCookie; } });
13
+ var SidekickNextDatabase_tsx_2 = require("./SidekickNextDatabase.js");
14
+ Object.defineProperty(exports, "SidekickNextDatabase", { enumerable: true, get: function () { return SidekickNextDatabase_tsx_2.SidekickNextDatabase; } });
15
+ var SidekickSuspenseProvider_tsx_1 = require("./SidekickSuspenseProvider.js");
16
+ Object.defineProperty(exports, "SidekickSuspenseProvider", { enumerable: true, get: function () { return SidekickSuspenseProvider_tsx_1.SidekickSuspenseProvider; } });
17
17
  var core_1 = require("@sidekickdb/core");
18
- Object.defineProperty(exports, "createInstantRouteHandler", { enumerable: true, get: function () { return core_1.createInstantRouteHandler; } });
18
+ Object.defineProperty(exports, "createSidekickRouteHandler", { enumerable: true, get: function () { return core_1.createSidekickRouteHandler; } });
19
19
  /**
20
20
  *
21
21
  * The first step: init your application!
@@ -30,7 +30,7 @@ Object.defineProperty(exports, "createInstantRouteHandler", { enumerable: true,
30
30
  * // You can also provide a schema for type safety and editor autocomplete!
31
31
  *
32
32
  * import { init } from "@sidekickdb/react"
33
- * import schema from ""../instant.schema.ts";
33
+ * import schema from ""../sidekick.schema.ts";
34
34
  *
35
35
  * const db = init({ appId: "my-app-id", apiURI: "https://sidekick.example.com", schema })
36
36
  *
@@ -38,10 +38,10 @@ Object.defineProperty(exports, "createInstantRouteHandler", { enumerable: true,
38
38
  */
39
39
  function init(
40
40
  // Allows config with missing `useDateObjects`, but keeps `UseDates`
41
- // as a non-nullable in the InstantConfig type.
41
+ // as a non-nullable in the SidekickConfig type.
42
42
  config) {
43
- return new InstantNextDatabase_tsx_1.InstantNextDatabase(config, {
44
- '@instantdb/react': version_ts_1.default,
43
+ return new SidekickNextDatabase_tsx_1.SidekickNextDatabase(config, {
44
+ '@sidekickdb/react': version_ts_1.default,
45
45
  });
46
46
  }
47
47
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/next-ssr/index.tsx"],"names":[],"mappings":";;;;;;AAwCA,oBAaC;AA/CD,+DAAoC;AAEpC,sEAAgE;AAEhE,6EAGuC;AAFrC,iJAAA,kCAAkC,OAAA;AAClC,uIAAA,wBAAwB,OAAA;AAG1B,oEAAgE;AAAvD,8HAAA,mBAAmB,OAAA;AAC5B,4EAAwE;AAA/D,sIAAA,uBAAuB,OAAA;AAEhC,yCAA6D;AAApD,iHAAA,yBAAyB,OAAA;AAElC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,IAAI;AAIlB,oEAAoE;AACpE,+CAA+C;AAC/C,MAEC;IAED,OAAO,IAAI,6CAAmB,CAAmB,MAAM,EAAE;QACvD,kBAAkB,EAAE,oBAAO;KAC5B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n InstantConfig,\n InstantSchemaDef,\n InstantUnknownSchema,\n} from '@sidekickdb/core';\n\nimport version from '../version.ts';\n\nimport { InstantNextDatabase } from './InstantNextDatabase.tsx';\n\nexport {\n getUnverifiedUserFromInstantCookie,\n getUserFromInstantCookie,\n} from './getUserFromInstantCookie.ts';\n\nexport { InstantNextDatabase } from './InstantNextDatabase.tsx';\nexport { InstantSuspenseProvider } from './InstantSuspenseProvider.tsx';\n\nexport { createInstantRouteHandler } from '@sidekickdb/core';\n\n/**\n *\n * The first step: init your application!\n *\n * Find your `appId` in your SidekickDB dashboard.\n *\n * @example\n * import { init } from \"@sidekickdb/react\"\n *\n * const db = init({ appId: \"my-app-id\", apiURI: \"https://sidekick.example.com\" })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@sidekickdb/react\"\n * import schema from \"\"../instant.schema.ts\";\n *\n * const db = init({ appId: \"my-app-id\", apiURI: \"https://sidekick.example.com\", schema })\n *\n * // To learn more: https://sidekickdb.co/docs/modeling-data\n */\nexport function init<\n Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema,\n UseDates extends boolean = false,\n>(\n // Allows config with missing `useDateObjects`, but keeps `UseDates`\n // as a non-nullable in the InstantConfig type.\n config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {\n useDateObjects?: UseDates;\n },\n): InstantNextDatabase<Schema, UseDates> {\n return new InstantNextDatabase<Schema, UseDates>(config, {\n '@instantdb/react': version,\n });\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/next-ssr/index.tsx"],"names":[],"mappings":";;;;;;AAwCA,oBAaC;AA/CD,+DAAoC;AAEpC,wEAAkE;AAElE,+EAGwC;AAFtC,mJAAA,mCAAmC,OAAA;AACnC,yIAAA,yBAAyB,OAAA;AAG3B,sEAAkE;AAAzD,gIAAA,oBAAoB,OAAA;AAC7B,8EAA0E;AAAjE,wIAAA,wBAAwB,OAAA;AAEjC,yCAA8D;AAArD,kHAAA,0BAA0B,OAAA;AAEnC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,IAAI;AAIlB,oEAAoE;AACpE,gDAAgD;AAChD,MAEC;IAED,OAAO,IAAI,+CAAoB,CAAmB,MAAM,EAAE;QACxD,mBAAmB,EAAE,oBAAO;KAC7B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n SidekickConfig,\n SidekickSchemaDef,\n SidekickUnknownSchema,\n} from '@sidekickdb/core';\n\nimport version from '../version.ts';\n\nimport { SidekickNextDatabase } from './SidekickNextDatabase.tsx';\n\nexport {\n getUnverifiedUserFromSidekickCookie,\n getUserFromSidekickCookie,\n} from './getUserFromSidekickCookie.ts';\n\nexport { SidekickNextDatabase } from './SidekickNextDatabase.tsx';\nexport { SidekickSuspenseProvider } from './SidekickSuspenseProvider.tsx';\n\nexport { createSidekickRouteHandler } from '@sidekickdb/core';\n\n/**\n *\n * The first step: init your application!\n *\n * Find your `appId` in your SidekickDB dashboard.\n *\n * @example\n * import { init } from \"@sidekickdb/react\"\n *\n * const db = init({ appId: \"my-app-id\", apiURI: \"https://sidekick.example.com\" })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@sidekickdb/react\"\n * import schema from \"\"../sidekick.schema.ts\";\n *\n * const db = init({ appId: \"my-app-id\", apiURI: \"https://sidekick.example.com\", schema })\n *\n * // To learn more: https://sidekickdb.co/docs/modeling-data\n */\nexport function init<\n Schema extends SidekickSchemaDef<any, any, any> = SidekickUnknownSchema,\n UseDates extends boolean = false,\n>(\n // Allows config with missing `useDateObjects`, but keeps `UseDates`\n // as a non-nullable in the SidekickConfig type.\n config: Omit<SidekickConfig<Schema, UseDates>, 'useDateObjects'> & {\n useDateObjects?: UseDates;\n },\n): SidekickNextDatabase<Schema, UseDates> {\n return new SidekickNextDatabase<Schema, UseDates>(config, {\n '@sidekickdb/react': version,\n });\n}\n"]}
@@ -1,9 +1,9 @@
1
1
  import { type ReactNode } from 'react';
2
- import { type InstantReactRoom } from '@sidekickdb/react-common';
2
+ import { type SidekickReactRoom } from '@sidekickdb/react-common';
3
3
  import type { RoomSchemaShape } from '@sidekickdb/core';
4
4
  export declare function Cursors<RoomSchema extends RoomSchemaShape, RoomType extends string & keyof RoomSchema>({ as, spaceId: _spaceId, room, className, style, userCursorColor, children, renderCursor, propagate, zIndex, }: {
5
5
  spaceId?: string;
6
- room: InstantReactRoom<any, RoomSchema, RoomType>;
6
+ room: SidekickReactRoom<any, RoomSchema, RoomType>;
7
7
  style?: React.CSSProperties;
8
8
  userCursorColor?: string;
9
9
  as?: any;
@@ -1 +1 @@
1
- {"version":3,"file":"Cursors.d.ts","sourceRoot":"","sources":["../../src/Cursors.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,wBAAgB,OAAO,CACrB,UAAU,SAAS,eAAe,EAClC,QAAQ,SAAS,MAAM,GAAG,MAAM,UAAU,EAC1C,EACA,EAAU,EACV,OAAO,EAAE,QAAQ,EACjB,IAAI,EACJ,SAAS,EACT,KAAK,EACL,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,MAAM,GACP,EAAE;IACD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAClD,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC;KAC5C,KAAK,SAAS,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,qHAqHA"}
1
+ {"version":3,"file":"Cursors.d.ts","sourceRoot":"","sources":["../../src/Cursors.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,i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GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,MAAM,WAAW,GAAkB;IACjC,QAAQ,EAAE,QAAQ;IAClB,aAAa,EAAE,MAAM;IACrB,UAAU,EAAE,MAAM;CACnB,CAAC;AAEF,MAAM,QAAQ,GAAG,KAAK,CAAC","sourcesContent":["import {\n createElement,\n type ReactNode,\n type MouseEvent,\n type TouchEvent,\n type CSSProperties,\n} from 'react';\nimport { type InstantReactRoom } from '@sidekickdb/react-common';\nimport type { RoomSchemaShape } from '@sidekickdb/core';\n\nexport function Cursors<\n RoomSchema extends RoomSchemaShape,\n RoomType extends string & keyof RoomSchema,\n>({\n as = 'div',\n spaceId: _spaceId,\n room,\n className,\n style,\n userCursorColor,\n children,\n renderCursor,\n propagate,\n zIndex,\n}: {\n spaceId?: string;\n room: InstantReactRoom<any, RoomSchema, RoomType>;\n style?: React.CSSProperties;\n userCursorColor?: string;\n as?: any;\n className?: string;\n children?: ReactNode;\n renderCursor?: (props: {\n color: string;\n presence: RoomSchema[RoomType]['presence'];\n }) => ReactNode;\n propagate?: boolean;\n zIndex?: number;\n}) {\n const spaceId =\n _spaceId || `cursors-space-default--${String(room.type)}-${room.id}`;\n\n const cursorsPresence = room.usePresence({\n keys: [spaceId] as (keyof RoomSchema[RoomType]['presence'])[],\n });\n\n const fullPresence = room._core._reactor.getPresence(room.type, room.id);\n\n function publishCursor(\n rect: DOMRect,\n touch: { clientX: number; clientY: number },\n ) {\n const x = touch.clientX;\n const y = touch.clientY;\n const xPercent = ((x - rect.left) / rect.width) * 100;\n const yPercent = ((y - rect.top) / rect.height) * 100;\n cursorsPresence.publishPresence({\n [spaceId]: {\n x,\n y,\n xPercent,\n yPercent,\n color: userCursorColor,\n },\n } as RoomSchema[RoomType]['presence']);\n }\n\n function onMouseMove(e: MouseEvent) {\n if (!propagate) {\n e.stopPropagation();\n }\n\n const rect = e.currentTarget.getBoundingClientRect();\n publishCursor(rect, e);\n }\n\n function onMouseOut(e: MouseEvent) {\n cursorsPresence.publishPresence({\n [spaceId]: undefined,\n } as RoomSchema[RoomType]['presence']);\n }\n\n function onTouchMove(e: TouchEvent) {\n if (e.touches.length !== 1) {\n return;\n }\n\n const touch = e.touches[0];\n\n if (touch.target instanceof Element) {\n if (!propagate) {\n e.stopPropagation();\n }\n const rect = touch.target.getBoundingClientRect();\n publishCursor(rect, touch);\n }\n }\n\n function onTouchEnd(e: TouchEvent) {\n cursorsPresence.publishPresence({\n [spaceId]: undefined,\n } as RoomSchema[RoomType]['presence']);\n }\n\n return createElement(\n as,\n {\n onMouseMove,\n onMouseOut,\n onTouchMove,\n onTouchEnd,\n className,\n style: {\n position: 'relative',\n ...style,\n },\n },\n [\n children,\n <div\n key={spaceId}\n style={{\n ...absStyles,\n ...inertStyles,\n zIndex: zIndex !== undefined ? zIndex : defaultZ,\n }}\n >\n {Object.entries(cursorsPresence.peers).map(([id, presence]) => {\n const cursor = presence[spaceId];\n if (!cursor) return null;\n\n return (\n <div\n key={id}\n style={{\n ...absStyles,\n transform: `translate(${cursor.xPercent}%, ${cursor.yPercent}%)`,\n transformOrigin: '0 0',\n transition: 'transform 100ms',\n }}\n >\n {renderCursor ? (\n renderCursor({\n color: cursor.color,\n presence: fullPresence?.peers[id],\n })\n ) : (\n <Cursor {...cursor} />\n )}\n </div>\n );\n })}\n </div>,\n ],\n );\n}\n\nfunction Cursor({ color }: { color: string }) {\n const size = 35;\n const fill = color || 'black';\n\n return (\n <svg\n style={{ height: size, width: size }}\n viewBox={`0 0 ${size} ${size}`}\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g\n fill=\"rgba(0,0,0,.2)\"\n transform=\"matrix(1, 0, 0, 1, -11.999999046325684, -8.406899452209473)\"\n >\n <path d=\"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z\" />\n <path d=\"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z\" />\n </g>\n <g\n fill=\"white\"\n transform=\"matrix(1, 0, 0, 1, -11.999999046325684, -8.406899452209473)\"\n >\n <path d=\"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z\" />\n <path d=\"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z\" />\n </g>\n <g\n fill={fill}\n transform=\"matrix(1, 0, 0, 1, -11.999999046325684, -8.406899452209473)\"\n >\n <path d=\"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z\" />\n <path d=\"m13 10.814v11.188l2.969-2.866.428-.139h4.768z\" />\n </g>\n </svg>\n );\n}\n\nconst absStyles: CSSProperties = {\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n right: 0,\n};\n\nconst inertStyles: CSSProperties = {\n overflow: 'hidden',\n pointerEvents: 'none',\n userSelect: 'none',\n};\n\nconst defaultZ = 99999;\n"]}
1
+ {"version":3,"file":"Cursors.js","sourceRoot":"","sources":["../../src/Cursors.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,GAKd,MAAM,OAAO,CAAC;AAIf,MAAM,UAAU,OAAO,CAGrB,EACA,EAAE,GAAG,KAAK,EACV,OAAO,EAAE,QAAQ,EACjB,IAAI,EACJ,SAAS,EACT,KAAK,EACL,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,MAAM,GAeP;IACC,MAAM,OAAO,GACX,QAAQ,IAAI,0BAA0B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;IAEvE,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC;QACvC,IAAI,EAAE,CAAC,OAAO,CAA+C;KAC9D,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAEzE,SAAS,aAAa,CACpB,IAAa,EAC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,CAAC;YACJ,CAAC,CAAC,IA/BG,OAAO,CAgCR;KACP,CACF,CAAC;AACJ,CAAC;AAED,SAAS,MAAM,CAAC,EAAE,KAAK,EAAqB;IAC1C,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,MAAM,IAAI,GAAG,KAAK,IAAI,OAAO,CAAC;IAE9B,OAAO,CACL,eACE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EACpC,OAAO,EAAE,OAAO,IAAI,IAAI,IAAI,EAAE,EAC9B,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,4BAA4B,aAElC,aACE,IAAI,EAAC,gBAAgB,EACrB,SAAS,EAAC,6DAA6D,aAEvE,eAAM,CAAC,EAAC,qDAAqD,GAAG,EAChE,eAAM,CAAC,EAAC,wDAAwD,GAAG,IACjE,EACJ,aACE,IAAI,EAAC,OAAO,EACZ,SAAS,EAAC,6DAA6D,aAEvE,eAAM,CAAC,EAAC,qDAAqD,GAAG,EAChE,eAAM,CAAC,EAAC,wDAAwD,GAAG,IACjE,EACJ,aACE,IAAI,EAAE,IAAI,EACV,SAAS,EAAC,6DAA6D,aAEvE,eAAM,CAAC,EAAC,iDAAiD,GAAG,EAC5D,eAAM,CAAC,EAAC,+CAA+C,GAAG,IACxD,IACA,CACP,CAAC;AACJ,CAAC;AAED,MAAM,SAAS,GAAkB;IAC/B,QAAQ,EAAE,UAAU;IACpB,GAAG,EAAE,CAAC;IACN,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;CACT,CAAC;AAEF,MAAM,WAAW,GAAkB;IACjC,QAAQ,EAAE,QAAQ;IAClB,aAAa,EAAE,MAAM;IACrB,UAAU,EAAE,MAAM;CACnB,CAAC;AAEF,MAAM,QAAQ,GAAG,KAAK,CAAC","sourcesContent":["import {\n createElement,\n type ReactNode,\n type MouseEvent,\n type TouchEvent,\n type CSSProperties,\n} from 'react';\nimport { type SidekickReactRoom } from '@sidekickdb/react-common';\nimport type { RoomSchemaShape } from '@sidekickdb/core';\n\nexport function Cursors<\n RoomSchema extends RoomSchemaShape,\n RoomType extends string & keyof RoomSchema,\n>({\n as = 'div',\n spaceId: _spaceId,\n room,\n className,\n style,\n userCursorColor,\n children,\n renderCursor,\n propagate,\n zIndex,\n}: {\n spaceId?: string;\n room: SidekickReactRoom<any, RoomSchema, RoomType>;\n style?: React.CSSProperties;\n userCursorColor?: string;\n as?: any;\n className?: string;\n children?: ReactNode;\n renderCursor?: (props: {\n color: string;\n presence: RoomSchema[RoomType]['presence'];\n }) => ReactNode;\n propagate?: boolean;\n zIndex?: number;\n}) {\n const spaceId =\n _spaceId || `cursors-space-default--${String(room.type)}-${room.id}`;\n\n const cursorsPresence = room.usePresence({\n keys: [spaceId] as (keyof RoomSchema[RoomType]['presence'])[],\n });\n\n const fullPresence = room._core._reactor.getPresence(room.type, room.id);\n\n function publishCursor(\n rect: DOMRect,\n touch: { clientX: number; clientY: number },\n ) {\n const x = touch.clientX;\n const y = touch.clientY;\n const xPercent = ((x - rect.left) / rect.width) * 100;\n const yPercent = ((y - rect.top) / rect.height) * 100;\n cursorsPresence.publishPresence({\n [spaceId]: {\n x,\n y,\n xPercent,\n yPercent,\n color: userCursorColor,\n },\n } as RoomSchema[RoomType]['presence']);\n }\n\n function onMouseMove(e: MouseEvent) {\n if (!propagate) {\n e.stopPropagation();\n }\n\n const rect = e.currentTarget.getBoundingClientRect();\n publishCursor(rect, e);\n }\n\n function onMouseOut(e: MouseEvent) {\n cursorsPresence.publishPresence({\n [spaceId]: undefined,\n } as RoomSchema[RoomType]['presence']);\n }\n\n function onTouchMove(e: TouchEvent) {\n if (e.touches.length !== 1) {\n return;\n }\n\n const touch = e.touches[0];\n\n if (touch.target instanceof Element) {\n if (!propagate) {\n e.stopPropagation();\n }\n const rect = touch.target.getBoundingClientRect();\n publishCursor(rect, touch);\n }\n }\n\n function onTouchEnd(e: TouchEvent) {\n cursorsPresence.publishPresence({\n [spaceId]: undefined,\n } as RoomSchema[RoomType]['presence']);\n }\n\n return createElement(\n as,\n {\n onMouseMove,\n onMouseOut,\n onTouchMove,\n onTouchEnd,\n className,\n style: {\n position: 'relative',\n ...style,\n },\n },\n [\n children,\n <div\n key={spaceId}\n style={{\n ...absStyles,\n ...inertStyles,\n zIndex: zIndex !== undefined ? zIndex : defaultZ,\n }}\n >\n {Object.entries(cursorsPresence.peers).map(([id, presence]) => {\n const cursor = presence[spaceId];\n if (!cursor) return null;\n\n return (\n <div\n key={id}\n style={{\n ...absStyles,\n transform: `translate(${cursor.xPercent}%, ${cursor.yPercent}%)`,\n transformOrigin: '0 0',\n transition: 'transform 100ms',\n }}\n >\n {renderCursor ? (\n renderCursor({\n color: cursor.color,\n presence: fullPresence?.peers[id],\n })\n ) : (\n <Cursor {...cursor} />\n )}\n </div>\n );\n })}\n </div>,\n ],\n );\n}\n\nfunction Cursor({ color }: { color: string }) {\n const size = 35;\n const fill = color || 'black';\n\n return (\n <svg\n style={{ height: size, width: size }}\n viewBox={`0 0 ${size} ${size}`}\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g\n fill=\"rgba(0,0,0,.2)\"\n transform=\"matrix(1, 0, 0, 1, -11.999999046325684, -8.406899452209473)\"\n >\n <path d=\"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z\" />\n <path d=\"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z\" />\n </g>\n <g\n fill=\"white\"\n transform=\"matrix(1, 0, 0, 1, -11.999999046325684, -8.406899452209473)\"\n >\n <path d=\"m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z\" />\n <path d=\"m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z\" />\n </g>\n <g\n fill={fill}\n transform=\"matrix(1, 0, 0, 1, -11.999999046325684, -8.406899452209473)\"\n >\n <path d=\"m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z\" />\n <path d=\"m13 10.814v11.188l2.969-2.866.428-.139h4.768z\" />\n </g>\n </svg>\n );\n}\n\nconst absStyles: CSSProperties = {\n position: 'absolute',\n top: 0,\n left: 0,\n bottom: 0,\n right: 0,\n};\n\nconst inertStyles: CSSProperties = {\n overflow: 'hidden',\n pointerEvents: 'none',\n userSelect: 'none',\n};\n\nconst defaultZ = 99999;\n"]}
@@ -0,0 +1,7 @@
1
+ import type { SidekickConfig, SidekickSchemaDef } from '@sidekickdb/core';
2
+ import { SidekickReactAbstractDatabase } from '@sidekickdb/react-common';
3
+ import { EventSource } from 'eventsource';
4
+ export default class SidekickReactWebDatabase<Schema extends SidekickSchemaDef<any, any, any>, UseDates extends boolean = false, Config extends SidekickConfig<Schema, UseDates> = SidekickConfig<Schema, UseDates>> extends SidekickReactAbstractDatabase<Schema, UseDates, Config> {
5
+ static EventSourceImpl: typeof EventSource;
6
+ }
7
+ //# sourceMappingURL=SidekickReactWebDatabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidekickReactWebDatabase.d.ts","sourceRoot":"","sources":["../../src/SidekickReactWebDatabase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,wBAAwB,CAC3C,MAAM,SAAS,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC/C,QAAQ,SAAS,OAAO,GAAG,KAAK,EAChC,MAAM,SAAS,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,cAAc,CAC9D,MAAM,EACN,QAAQ,CACT,CACD,SAAQ,6BAA6B,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC;IAC/D,MAAM,CAAC,eAAe,qBAAe;CACtC"}
@@ -0,0 +1,6 @@
1
+ import { SidekickReactAbstractDatabase } from '@sidekickdb/react-common';
2
+ import { EventSource } from 'eventsource';
3
+ export default class SidekickReactWebDatabase extends SidekickReactAbstractDatabase {
4
+ static EventSourceImpl = EventSource;
5
+ }
6
+ //# sourceMappingURL=SidekickReactWebDatabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidekickReactWebDatabase.js","sourceRoot":"","sources":["../../src/SidekickReactWebDatabase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,wBAOnB,SAAQ,6BAAuD;IAC/D,MAAM,CAAC,eAAe,GAAG,WAAW,CAAC","sourcesContent":["import type { SidekickConfig, SidekickSchemaDef } from '@sidekickdb/core';\nimport { SidekickReactAbstractDatabase } from '@sidekickdb/react-common';\nimport { EventSource } from 'eventsource';\n\nexport default class SidekickReactWebDatabase<\n Schema extends SidekickSchemaDef<any, any, any>,\n UseDates extends boolean = false,\n Config extends SidekickConfig<Schema, UseDates> = SidekickConfig<\n Schema,\n UseDates\n >,\n> extends SidekickReactAbstractDatabase<Schema, UseDates, Config> {\n static EventSourceImpl = EventSource;\n}\n"]}
@@ -1,7 +1,7 @@
1
- import { id, tx, lookup, i, InstantAPIError, SyncTableCallbackEventType, setInstantWarningsEnabled, type QueryResponse, type InstantQuery, type InstantQueryResult, type InstantSchema, type InstantObject, type InstantEntity, type InstantSchemaDatabase, type InstantUnknownSchemaDef, type IInstantDatabase, type User, type AuthState, type Query, type Config, type InstaQLParams, type ConnectionStatus, type AppStatusState, type ValidQuery, type PresencePeer, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type InstantConfig, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type ValueTypes, type InstaQLEntity, type InstaQLFields, type InstaQLResult, type InstaQLEntitySubquery, type RoomsOf, type RoomsDef, type PresenceOf, type TopicsOf, type TopicOf, type RoomHandle, type TransactionChunk, type InstantUnknownSchema, type InstantSchemaDef, type BackwardsCompatibleSchema, type InstantRules, type UpdateParams, type LinkParams, type CreateParams, type CheckMagicCodeParams, type CheckMagicCodeResponse, type ExchangeCodeForTokenParams, type SendMagicCodeParams, type SendMagicCodeResponse, type SignInWithIdTokenParams, type VerifyMagicCodeParams, type VerifyResponse, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type CreateReadStreamOpts, type CreateWriteStreamOpts, type SyncTableCallback, type SyncTableCallbackEvent, type SyncTableInitialSyncBatch, type SyncTableInitialSyncComplete, type SyncTableSyncTransaction, type SyncTableLoadFromStorage, type SyncTableSetupError, StoreInterface, createInstantRouteHandler, type InstantRouteHandlerPayloadByType, type InstantRouteHandlerType, type InstantRouteHandlerBody, type StoreInterfaceStoreName, InstantWritableStream, InstantReadableStream, type Logger } from '@sidekickdb/core';
2
- import { InstantReactAbstractDatabase } from '@sidekickdb/react-common';
3
- import InstantReactWebDatabase from './InstantReactWebDatabase.ts';
1
+ import { id, tx, lookup, i, SidekickAPIError, SyncTableCallbackEventType, setSidekickWarningsEnabled, type QueryResponse, type SidekickQuery, type SidekickQueryResult, type SidekickSchema, type SidekickObject, type SidekickEntity, type SidekickSchemaDatabase, type SidekickUnknownSchemaDef, type ISidekickDatabase, type User, type AuthState, type Query, type Config, type SideQLParams, type ConnectionStatus, type AppStatusState, type ValidQuery, type PresencePeer, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type SidekickGraph, type SidekickConfig, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type ValueTypes, type SideQLEntity, type SideQLFields, type SideQLResult, type SideQLEntitySubquery, type RoomsOf, type RoomsDef, type PresenceOf, type TopicsOf, type TopicOf, type RoomHandle, type TransactionChunk, type SidekickUnknownSchema, type SidekickSchemaDef, type BackwardsCompatibleSchema, type SidekickRules, type UpdateParams, type LinkParams, type CreateParams, type CheckMagicCodeParams, type CheckMagicCodeResponse, type ExchangeCodeForTokenParams, type SendMagicCodeParams, type SendMagicCodeResponse, type SignInWithIdTokenParams, type VerifyMagicCodeParams, type VerifyResponse, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type CreateReadStreamOpts, type CreateWriteStreamOpts, type SyncTableCallback, type SyncTableCallbackEvent, type SyncTableInitialSyncBatch, type SyncTableInitialSyncComplete, type SyncTableSyncTransaction, type SyncTableLoadFromStorage, type SyncTableSetupError, StoreInterface, createSidekickRouteHandler, type SidekickRouteHandlerPayloadByType, type SidekickRouteHandlerType, type SidekickRouteHandlerBody, type StoreInterfaceStoreName, SidekickWritableStream, SidekickReadableStream, type Logger } from '@sidekickdb/core';
2
+ import { SidekickReactAbstractDatabase } from '@sidekickdb/react-common';
3
+ import SidekickReactWebDatabase from './SidekickReactWebDatabase.ts';
4
4
  import { init, init_experimental } from './init.ts';
5
5
  import { Cursors } from './Cursors.tsx';
6
- export { id, tx, lookup, init, init_experimental, InstantReactWebDatabase, Cursors, i, InstantAPIError, InstantReactAbstractDatabase, SyncTableCallbackEventType, setInstantWarningsEnabled, type Config, type InstantConfig, type InstantUnknownSchemaDef, type Query, type QueryResponse, type InstantObject, type User, type AuthState, type ConnectionStatus, type AppStatusState, type InstantQuery, type InstantQueryResult, type InstantSchema, type InstantEntity, type InstantSchemaDatabase, type IInstantDatabase, type InstaQLParams, type ValidQuery, type InstaQLFields, type PresencePeer, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type InstantGraph, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type ValueTypes, type InstaQLEntity, type InstaQLResult, type InstaQLEntitySubquery, type RoomsOf, type RoomsDef, type TransactionChunk, type PresenceOf, type TopicsOf, type TopicOf, type RoomHandle, type InstantUnknownSchema, type InstantSchemaDef, type BackwardsCompatibleSchema, type InstantRules, type UpdateParams, type LinkParams, type CreateParams, type CheckMagicCodeParams, type CheckMagicCodeResponse, type ExchangeCodeForTokenParams, type SendMagicCodeParams, type SendMagicCodeResponse, type SignInWithIdTokenParams, type VerifyMagicCodeParams, type VerifyResponse, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type CreateReadStreamOpts, type CreateWriteStreamOpts, type InstantWritableStream, type InstantReadableStream, StoreInterface, type StoreInterfaceStoreName, type SyncTableCallback, type SyncTableCallbackEvent, type SyncTableInitialSyncBatch, type SyncTableInitialSyncComplete, type SyncTableSyncTransaction, type SyncTableLoadFromStorage, type SyncTableSetupError, createInstantRouteHandler, type InstantRouteHandlerPayloadByType, type InstantRouteHandlerType, type InstantRouteHandlerBody, type Logger, };
6
+ export { id, tx, lookup, init, init_experimental, SidekickReactWebDatabase, Cursors, i, SidekickAPIError, SidekickReactAbstractDatabase, SyncTableCallbackEventType, setSidekickWarningsEnabled, type Config, type SidekickConfig, type SidekickUnknownSchemaDef, type Query, type QueryResponse, type SidekickObject, type User, type AuthState, type ConnectionStatus, type AppStatusState, type SidekickQuery, type SidekickQueryResult, type SidekickSchema, type SidekickEntity, type SidekickSchemaDatabase, type ISidekickDatabase, type SideQLParams, type ValidQuery, type SideQLFields, type PresencePeer, type AttrsDefs, type CardinalityKind, type DataAttrDef, type EntitiesDef, type EntitiesWithLinks, type EntityDef, type SidekickGraph, type LinkAttrDef, type LinkDef, type LinksDef, type ResolveAttrs, type ValueTypes, type SideQLEntity, type SideQLResult, type SideQLEntitySubquery, type RoomsOf, type RoomsDef, type TransactionChunk, type PresenceOf, type TopicsOf, type TopicOf, type RoomHandle, type SidekickUnknownSchema, type SidekickSchemaDef, type BackwardsCompatibleSchema, type SidekickRules, type UpdateParams, type LinkParams, type CreateParams, type CheckMagicCodeParams, type CheckMagicCodeResponse, type ExchangeCodeForTokenParams, type SendMagicCodeParams, type SendMagicCodeResponse, type SignInWithIdTokenParams, type VerifyMagicCodeParams, type VerifyResponse, type FileOpts, type UploadFileResponse, type DeleteFileResponse, type CreateReadStreamOpts, type CreateWriteStreamOpts, type SidekickWritableStream, type SidekickReadableStream, StoreInterface, type StoreInterfaceStoreName, type SyncTableCallback, type SyncTableCallbackEvent, type SyncTableInitialSyncBatch, type SyncTableInitialSyncComplete, type SyncTableSyncTransaction, type SyncTableLoadFromStorage, type SyncTableSetupError, createSidekickRouteHandler, type SidekickRouteHandlerPayloadByType, type SidekickRouteHandlerType, type SidekickRouteHandlerBody, type Logger, };
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EACF,EAAE,EACF,MAAM,EACN,CAAC,EAGD,eAAe,EAGf,0BAA0B,EAC1B,yBAAyB,EAGzB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,UAAU,EAGf,KAAK,YAAY,EAGjB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,O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K,wBAAwB,EAC7B,KAAK,wBAAwB,EAG7B,KAAK,MAAM,GACZ,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,23 +1,23 @@
1
1
  import { id, tx, lookup, i,
2
2
  // error
3
- InstantAPIError,
3
+ SidekickAPIError,
4
4
  // sync table enums
5
- SyncTableCallbackEventType, setInstantWarningsEnabled, StoreInterface, createInstantRouteHandler, } from '@sidekickdb/core';
6
- import { InstantReactAbstractDatabase } from '@sidekickdb/react-common';
7
- import InstantReactWebDatabase from "./InstantReactWebDatabase.js";
5
+ SyncTableCallbackEventType, setSidekickWarningsEnabled, StoreInterface, createSidekickRouteHandler, } from '@sidekickdb/core';
6
+ import { SidekickReactAbstractDatabase } from '@sidekickdb/react-common';
7
+ import SidekickReactWebDatabase from "./SidekickReactWebDatabase.js";
8
8
  import { init, init_experimental } from "./init.js";
9
9
  import { Cursors } from "./Cursors.js";
10
- export { id, tx, lookup, init, init_experimental, InstantReactWebDatabase, Cursors, i,
10
+ export { id, tx, lookup, init, init_experimental, SidekickReactWebDatabase, Cursors, i,
11
11
  // error
12
- InstantAPIError,
12
+ SidekickAPIError,
13
13
  // internal
14
- InstantReactAbstractDatabase,
14
+ SidekickReactAbstractDatabase,
15
15
  // sync table enums
16
16
  SyncTableCallbackEventType,
17
17
  // warnings
18
- setInstantWarningsEnabled,
18
+ setSidekickWarningsEnabled,
19
19
  // custom store
20
20
  StoreInterface,
21
21
  // Server helper
22
- createInstantRouteHandler, };
22
+ createSidekickRouteHandler, };
23
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EACF,EAAE,EACF,MAAM,EACN,CAAC;AAED,QAAQ;AACR,eAAe;AAEf,mBAAmB;AACnB,0BAA0B,EAC1B,yBAAyB,EAkFzB,cAAc,EACd,yBAAyB,GAQ1B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAe,CAAC;AAExC,OAAO,EACL,EAAE,EACF,EAAE,EACF,MAAM,EACN,IAAI,EACJ,iBAAiB,EACjB,uBAAuB,EACvB,OAAO,EACP,CAAC;AAED,QAAQ;AACR,eAAe;AAEf,WAAW;AACX,4BAA4B;AAE5B,mBAAmB;AACnB,0BAA0B;AAE1B,WAAW;AACX,yBAAyB;AA4EzB,eAAe;AACf,cAAc;AAYd,gBAAgB;AAChB,yBAAyB,GAO1B,CAAC","sourcesContent":["import {\n id,\n tx,\n lookup,\n i,\n\n // error\n InstantAPIError,\n\n // sync table enums\n SyncTableCallbackEventType,\n setInstantWarningsEnabled,\n\n // types\n type QueryResponse,\n type InstantQuery,\n type InstantQueryResult,\n type InstantSchema,\n type InstantObject,\n type InstantEntity,\n type InstantSchemaDatabase,\n type InstantUnknownSchemaDef,\n type IInstantDatabase,\n type User,\n type AuthState,\n type Query,\n type Config,\n type InstaQLParams,\n type ConnectionStatus,\n type AppStatusState,\n type ValidQuery,\n\n // presence types\n type PresencePeer,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type InstantConfig,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type ValueTypes,\n type InstaQLEntity,\n type InstaQLFields,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type RoomsOf,\n type RoomsDef,\n type PresenceOf,\n type TopicsOf,\n type TopicOf,\n type RoomHandle,\n type TransactionChunk,\n type InstantUnknownSchema,\n type InstantSchemaDef,\n type BackwardsCompatibleSchema,\n type InstantRules,\n type UpdateParams,\n type LinkParams,\n type CreateParams,\n type CheckMagicCodeParams,\n type CheckMagicCodeResponse,\n type ExchangeCodeForTokenParams,\n type SendMagicCodeParams,\n type SendMagicCodeResponse,\n type SignInWithIdTokenParams,\n type VerifyMagicCodeParams,\n type VerifyResponse,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n\n // stream types\n type CreateReadStreamOpts,\n type CreateWriteStreamOpts,\n\n // sync table types\n type SyncTableCallback,\n type SyncTableCallbackEvent,\n type SyncTableInitialSyncBatch,\n type SyncTableInitialSyncComplete,\n type SyncTableSyncTransaction,\n type SyncTableLoadFromStorage,\n type SyncTableSetupError,\n StoreInterface,\n createInstantRouteHandler,\n type InstantRouteHandlerPayloadByType,\n type InstantRouteHandlerType,\n type InstantRouteHandlerBody,\n type StoreInterfaceStoreName,\n InstantWritableStream,\n InstantReadableStream,\n type Logger,\n} from '@sidekickdb/core';\n\nimport { InstantReactAbstractDatabase } from '@sidekickdb/react-common';\nimport InstantReactWebDatabase from './InstantReactWebDatabase.ts';\nimport { init, init_experimental } from './init.ts';\nimport { Cursors } from './Cursors.tsx';\n\nexport {\n id,\n tx,\n lookup,\n init,\n init_experimental,\n InstantReactWebDatabase,\n Cursors,\n i,\n\n // error\n InstantAPIError,\n\n // internal\n InstantReactAbstractDatabase,\n\n // sync table enums\n SyncTableCallbackEventType,\n\n // warnings\n setInstantWarningsEnabled,\n\n // types\n type Config,\n type InstantConfig,\n type InstantUnknownSchemaDef,\n type Query,\n type QueryResponse,\n type InstantObject,\n type User,\n type AuthState,\n type ConnectionStatus,\n type AppStatusState,\n type InstantQuery,\n type InstantQueryResult,\n type InstantSchema,\n type InstantEntity,\n type InstantSchemaDatabase,\n type IInstantDatabase,\n type InstaQLParams,\n type ValidQuery,\n type InstaQLFields,\n\n // presence types\n type PresencePeer,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type InstantGraph,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type ValueTypes,\n type InstaQLEntity,\n type InstaQLResult,\n type InstaQLEntitySubquery,\n type RoomsOf,\n type RoomsDef,\n type TransactionChunk,\n type PresenceOf,\n type TopicsOf,\n type TopicOf,\n type RoomHandle,\n type InstantUnknownSchema,\n type InstantSchemaDef,\n type BackwardsCompatibleSchema,\n type InstantRules,\n type UpdateParams,\n type LinkParams,\n type CreateParams,\n type CheckMagicCodeParams,\n type CheckMagicCodeResponse,\n type ExchangeCodeForTokenParams,\n type SendMagicCodeParams,\n type SendMagicCodeResponse,\n type SignInWithIdTokenParams,\n type VerifyMagicCodeParams,\n type VerifyResponse,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n\n // stream types\n type CreateReadStreamOpts,\n type CreateWriteStreamOpts,\n type InstantWritableStream,\n type InstantReadableStream,\n\n // custom store\n StoreInterface,\n type StoreInterfaceStoreName,\n\n // sync table types\n type SyncTableCallback,\n type SyncTableCallbackEvent,\n type SyncTableInitialSyncBatch,\n type SyncTableInitialSyncComplete,\n type SyncTableSyncTransaction,\n type SyncTableLoadFromStorage,\n type SyncTableSetupError,\n\n // Server helper\n createInstantRouteHandler,\n type InstantRouteHandlerPayloadByType,\n type InstantRouteHandlerType,\n type InstantRouteHandlerBody,\n\n // logger\n type Logger,\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,EACF,EAAE,EACF,MAAM,EACN,CAAC;AAED,QAAQ;AACR,gBAAgB;AAEhB,mBAAmB;AACnB,0BAA0B,EAC1B,0BAA0B,EAkF1B,cAAc,EACd,0BAA0B,GAQ3B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,wBAAwB,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAe,CAAC;AAExC,OAAO,EACL,EAAE,EACF,EAAE,EACF,MAAM,EACN,IAAI,EACJ,iBAAiB,EACjB,wBAAwB,EACxB,OAAO,EACP,CAAC;AAED,QAAQ;AACR,gBAAgB;AAEhB,WAAW;AACX,6BAA6B;AAE7B,mBAAmB;AACnB,0BAA0B;AAE1B,WAAW;AACX,0BAA0B;AA4E1B,eAAe;AACf,cAAc;AAYd,gBAAgB;AAChB,0BAA0B,GAO3B,CAAC","sourcesContent":["import {\n id,\n tx,\n lookup,\n i,\n\n // error\n SidekickAPIError,\n\n // sync table enums\n SyncTableCallbackEventType,\n setSidekickWarningsEnabled,\n\n // types\n type QueryResponse,\n type SidekickQuery,\n type SidekickQueryResult,\n type SidekickSchema,\n type SidekickObject,\n type SidekickEntity,\n type SidekickSchemaDatabase,\n type SidekickUnknownSchemaDef,\n type ISidekickDatabase,\n type User,\n type AuthState,\n type Query,\n type Config,\n type SideQLParams,\n type ConnectionStatus,\n type AppStatusState,\n type ValidQuery,\n\n // presence types\n type PresencePeer,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type SidekickGraph,\n type SidekickConfig,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type ValueTypes,\n type SideQLEntity,\n type SideQLFields,\n type SideQLResult,\n type SideQLEntitySubquery,\n type RoomsOf,\n type RoomsDef,\n type PresenceOf,\n type TopicsOf,\n type TopicOf,\n type RoomHandle,\n type TransactionChunk,\n type SidekickUnknownSchema,\n type SidekickSchemaDef,\n type BackwardsCompatibleSchema,\n type SidekickRules,\n type UpdateParams,\n type LinkParams,\n type CreateParams,\n type CheckMagicCodeParams,\n type CheckMagicCodeResponse,\n type ExchangeCodeForTokenParams,\n type SendMagicCodeParams,\n type SendMagicCodeResponse,\n type SignInWithIdTokenParams,\n type VerifyMagicCodeParams,\n type VerifyResponse,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n\n // stream types\n type CreateReadStreamOpts,\n type CreateWriteStreamOpts,\n\n // sync table types\n type SyncTableCallback,\n type SyncTableCallbackEvent,\n type SyncTableInitialSyncBatch,\n type SyncTableInitialSyncComplete,\n type SyncTableSyncTransaction,\n type SyncTableLoadFromStorage,\n type SyncTableSetupError,\n StoreInterface,\n createSidekickRouteHandler,\n type SidekickRouteHandlerPayloadByType,\n type SidekickRouteHandlerType,\n type SidekickRouteHandlerBody,\n type StoreInterfaceStoreName,\n SidekickWritableStream,\n SidekickReadableStream,\n type Logger,\n} from '@sidekickdb/core';\n\nimport { SidekickReactAbstractDatabase } from '@sidekickdb/react-common';\nimport SidekickReactWebDatabase from './SidekickReactWebDatabase.ts';\nimport { init, init_experimental } from './init.ts';\nimport { Cursors } from './Cursors.tsx';\n\nexport {\n id,\n tx,\n lookup,\n init,\n init_experimental,\n SidekickReactWebDatabase,\n Cursors,\n i,\n\n // error\n SidekickAPIError,\n\n // internal\n SidekickReactAbstractDatabase,\n\n // sync table enums\n SyncTableCallbackEventType,\n\n // warnings\n setSidekickWarningsEnabled,\n\n // types\n type Config,\n type SidekickConfig,\n type SidekickUnknownSchemaDef,\n type Query,\n type QueryResponse,\n type SidekickObject,\n type User,\n type AuthState,\n type ConnectionStatus,\n type AppStatusState,\n type SidekickQuery,\n type SidekickQueryResult,\n type SidekickSchema,\n type SidekickEntity,\n type SidekickSchemaDatabase,\n type ISidekickDatabase,\n type SideQLParams,\n type ValidQuery,\n type SideQLFields,\n\n // presence types\n type PresencePeer,\n\n // schema types\n type AttrsDefs,\n type CardinalityKind,\n type DataAttrDef,\n type EntitiesDef,\n type EntitiesWithLinks,\n type EntityDef,\n type SidekickGraph,\n type LinkAttrDef,\n type LinkDef,\n type LinksDef,\n type ResolveAttrs,\n type ValueTypes,\n type SideQLEntity,\n type SideQLResult,\n type SideQLEntitySubquery,\n type RoomsOf,\n type RoomsDef,\n type TransactionChunk,\n type PresenceOf,\n type TopicsOf,\n type TopicOf,\n type RoomHandle,\n type SidekickUnknownSchema,\n type SidekickSchemaDef,\n type BackwardsCompatibleSchema,\n type SidekickRules,\n type UpdateParams,\n type LinkParams,\n type CreateParams,\n type CheckMagicCodeParams,\n type CheckMagicCodeResponse,\n type ExchangeCodeForTokenParams,\n type SendMagicCodeParams,\n type SendMagicCodeResponse,\n type SignInWithIdTokenParams,\n type VerifyMagicCodeParams,\n type VerifyResponse,\n\n // storage types\n type FileOpts,\n type UploadFileResponse,\n type DeleteFileResponse,\n\n // stream types\n type CreateReadStreamOpts,\n type CreateWriteStreamOpts,\n type SidekickWritableStream,\n type SidekickReadableStream,\n\n // custom store\n StoreInterface,\n type StoreInterfaceStoreName,\n\n // sync table types\n type SyncTableCallback,\n type SyncTableCallbackEvent,\n type SyncTableInitialSyncBatch,\n type SyncTableInitialSyncComplete,\n type SyncTableSyncTransaction,\n type SyncTableLoadFromStorage,\n type SyncTableSetupError,\n\n // Server helper\n createSidekickRouteHandler,\n type SidekickRouteHandlerPayloadByType,\n type SidekickRouteHandlerType,\n type SidekickRouteHandlerBody,\n\n // logger\n type Logger,\n};\n"]}
@@ -1,5 +1,5 @@
1
- import type { InstantConfig, InstantSchemaDef, InstantUnknownSchema } from '@sidekickdb/core';
2
- import InstantReactWebDatabase from './InstantReactWebDatabase.ts';
1
+ import type { SidekickConfig, SidekickSchemaDef, SidekickUnknownSchema } from '@sidekickdb/core';
2
+ import SidekickReactWebDatabase from './SidekickReactWebDatabase.ts';
3
3
  /**
4
4
  *
5
5
  * The first step: init your application!
@@ -14,15 +14,15 @@ import InstantReactWebDatabase from './InstantReactWebDatabase.ts';
14
14
  * // You can also provide a schema for type safety and editor autocomplete!
15
15
  *
16
16
  * import { init } from "@sidekickdb/react"
17
- * import schema from ""../instant.schema.ts";
17
+ * import schema from ""../sidekick.schema.ts";
18
18
  *
19
19
  * const db = init({ appId: "my-app-id", apiURI: "https://sidekick.example.com", schema })
20
20
  *
21
21
  * // To learn more: https://sidekickdb.co/docs/modeling-data
22
22
  */
23
- export declare function init<Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema, UseDates extends boolean = false>(config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {
23
+ export declare function init<Schema extends SidekickSchemaDef<any, any, any> = SidekickUnknownSchema, UseDates extends boolean = false>(config: Omit<SidekickConfig<Schema, UseDates>, 'useDateObjects'> & {
24
24
  useDateObjects?: UseDates;
25
- }): InstantReactWebDatabase<Schema, UseDates, InstantConfig<Schema, UseDates>>;
25
+ }): SidekickReactWebDatabase<Schema, UseDates, SidekickConfig<Schema, UseDates>>;
26
26
  /**
27
27
  * @deprecated
28
28
  * `init_experimental` is deprecated. You can replace it with `init`.
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AAGnE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,IAAI,CAClB,MAAM,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,oBAAoB,EACrE,QAAQ,SAAS,OAAO,GAAG,KAAK,EAIhC,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,GAAG;IAChE,cAAc,CAAC,EAAE,QAAQ,CAAC;CAC3B,GACA,uBAAuB,CAAC,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAY5E;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,aAAO,CAAC"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,wBAAwB,MAAM,+BAA+B,CAAC;AAGrE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,IAAI,CAClB,MAAM,SAAS,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,qBAAqB,EACvE,QAAQ,SAAS,OAAO,GAAG,KAAK,EAIhC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,GAAG;IACjE,cAAc,CAAC,EAAE,QAAQ,CAAC;CAC3B,GACA,wBAAwB,CACzB,MAAM,EACN,QAAQ,EACR,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CACjC,CAYA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,aAAO,CAAC"}
package/dist/esm/init.js CHANGED
@@ -1,4 +1,4 @@
1
- import InstantReactWebDatabase from "./InstantReactWebDatabase.js";
1
+ import SidekickReactWebDatabase from "./SidekickReactWebDatabase.js";
2
2
  import version from "./version.js";
3
3
  /**
4
4
  *
@@ -14,7 +14,7 @@ import version from "./version.js";
14
14
  * // You can also provide a schema for type safety and editor autocomplete!
15
15
  *
16
16
  * import { init } from "@sidekickdb/react"
17
- * import schema from ""../instant.schema.ts";
17
+ * import schema from ""../sidekick.schema.ts";
18
18
  *
19
19
  * const db = init({ appId: "my-app-id", apiURI: "https://sidekick.example.com", schema })
20
20
  *
@@ -22,14 +22,14 @@ import version from "./version.js";
22
22
  */
23
23
  export function init(
24
24
  // Allows config with missing `useDateObjects`, but keeps `UseDates`
25
- // as a non-nullable in the InstantConfig type.
25
+ // as a non-nullable in the SidekickConfig type.
26
26
  config) {
27
27
  const configStrict = {
28
28
  ...config,
29
29
  useDateObjects: (config.useDateObjects ?? false),
30
30
  };
31
- return new InstantReactWebDatabase(configStrict, {
32
- '@instantdb/react': version,
31
+ return new SidekickReactWebDatabase(configStrict, {
32
+ '@sidekickdb/react': version,
33
33
  });
34
34
  }
35
35
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAMA,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AACnE,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,IAAI;AAIlB,oEAAoE;AACpE,+CAA+C;AAC/C,MAEC;IAED,MAAM,YAAY,GAAG;QACnB,GAAG,MAAM;QACT,cAAc,EAAE,CAAC,MAAM,CAAC,cAAc,IAAI,KAAK,CAAa;KAC7D,CAAC;IACF,OAAO,IAAI,uBAAuB,CAIhC,YAAY,EAAE;QACd,kBAAkB,EAAE,OAAO;KAC5B,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC","sourcesContent":["import type {\n InstantConfig,\n InstantSchemaDef,\n InstantUnknownSchema,\n} from '@sidekickdb/core';\n\nimport InstantReactWebDatabase from './InstantReactWebDatabase.ts';\nimport version from './version.ts';\n\n/**\n *\n * The first step: init your application!\n *\n * Find your `appId` in your SidekickDB dashboard.\n *\n * @example\n * import { init } from \"@sidekickdb/react\"\n *\n * const db = init({ appId: \"my-app-id\", apiURI: \"https://sidekick.example.com\" })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@sidekickdb/react\"\n * import schema from \"\"../instant.schema.ts\";\n *\n * const db = init({ appId: \"my-app-id\", apiURI: \"https://sidekick.example.com\", schema })\n *\n * // To learn more: https://sidekickdb.co/docs/modeling-data\n */\nexport function init<\n Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema,\n UseDates extends boolean = false,\n>(\n // Allows config with missing `useDateObjects`, but keeps `UseDates`\n // as a non-nullable in the InstantConfig type.\n config: Omit<InstantConfig<Schema, UseDates>, 'useDateObjects'> & {\n useDateObjects?: UseDates;\n },\n): InstantReactWebDatabase<Schema, UseDates, InstantConfig<Schema, UseDates>> {\n const configStrict = {\n ...config,\n useDateObjects: (config.useDateObjects ?? false) as UseDates,\n };\n return new InstantReactWebDatabase<\n Schema,\n UseDates,\n InstantConfig<Schema, UseDates>\n >(configStrict, {\n '@instantdb/react': version,\n });\n}\n\n/**\n * @deprecated\n * `init_experimental` is deprecated. You can replace it with `init`.\n *\n * @example\n *\n * // Before\n * import { init_experimental } from \"@sidekickdb/react\"\n * const db = init_experimental({ ... });\n *\n * // After\n * import { init } from \"@sidekickdb/react\"\n * const db = init({ ... });\n */\nexport const init_experimental = init;\n"]}
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/init.ts"],"names":[],"mappings":"AAMA,OAAO,wBAAwB,MAAM,+BAA+B,CAAC;AACrE,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,IAAI;AAIlB,oEAAoE;AACpE,gDAAgD;AAChD,MAEC;IAMD,MAAM,YAAY,GAAG;QACnB,GAAG,MAAM;QACT,cAAc,EAAE,CAAC,MAAM,CAAC,cAAc,IAAI,KAAK,CAAa;KAC7D,CAAC;IACF,OAAO,IAAI,wBAAwB,CAIjC,YAAY,EAAE;QACd,mBAAmB,EAAE,OAAO;KAC7B,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC","sourcesContent":["import type {\n SidekickConfig,\n SidekickSchemaDef,\n SidekickUnknownSchema,\n} from '@sidekickdb/core';\n\nimport SidekickReactWebDatabase from './SidekickReactWebDatabase.ts';\nimport version from './version.ts';\n\n/**\n *\n * The first step: init your application!\n *\n * Find your `appId` in your SidekickDB dashboard.\n *\n * @example\n * import { init } from \"@sidekickdb/react\"\n *\n * const db = init({ appId: \"my-app-id\", apiURI: \"https://sidekick.example.com\" })\n *\n * // You can also provide a schema for type safety and editor autocomplete!\n *\n * import { init } from \"@sidekickdb/react\"\n * import schema from \"\"../sidekick.schema.ts\";\n *\n * const db = init({ appId: \"my-app-id\", apiURI: \"https://sidekick.example.com\", schema })\n *\n * // To learn more: https://sidekickdb.co/docs/modeling-data\n */\nexport function init<\n Schema extends SidekickSchemaDef<any, any, any> = SidekickUnknownSchema,\n UseDates extends boolean = false,\n>(\n // Allows config with missing `useDateObjects`, but keeps `UseDates`\n // as a non-nullable in the SidekickConfig type.\n config: Omit<SidekickConfig<Schema, UseDates>, 'useDateObjects'> & {\n useDateObjects?: UseDates;\n },\n): SidekickReactWebDatabase<\n Schema,\n UseDates,\n SidekickConfig<Schema, UseDates>\n> {\n const configStrict = {\n ...config,\n useDateObjects: (config.useDateObjects ?? false) as UseDates,\n };\n return new SidekickReactWebDatabase<\n Schema,\n UseDates,\n SidekickConfig<Schema, UseDates>\n >(configStrict, {\n '@sidekickdb/react': version,\n });\n}\n\n/**\n * @deprecated\n * `init_experimental` is deprecated. You can replace it with `init`.\n *\n * @example\n *\n * // Before\n * import { init_experimental } from \"@sidekickdb/react\"\n * const db = init_experimental({ ... });\n *\n * // After\n * import { init } from \"@sidekickdb/react\"\n * const db = init({ ... });\n */\nexport const init_experimental = init;\n"]}
@@ -0,0 +1,12 @@
1
+ import { AuthState, SidekickSchemaDef, SideQLResponse, PageInfoResponse, RuleParams, ValidQuery } from '@sidekickdb/core';
2
+ import SidekickReactWebDatabase from '../SidekickReactWebDatabase.ts';
3
+ export declare class SidekickNextDatabase<Schema extends SidekickSchemaDef<any, any, any>, UseDates extends boolean> extends SidekickReactWebDatabase<Schema, UseDates> {
4
+ useSuspenseQuery: <Q extends ValidQuery<Q, Schema>>(q: Q, opts?: {
5
+ ruleParams: RuleParams;
6
+ }) => {
7
+ data: SideQLResponse<Schema, Q, NonNullable<UseDates>>;
8
+ pageInfo?: PageInfoResponse<Q>;
9
+ };
10
+ useAuth: () => AuthState;
11
+ }
12
+ //# sourceMappingURL=SidekickNextDatabase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidekickNextDatabase.d.ts","sourceRoot":"","sources":["../../../src/next-ssr/SidekickNextDatabase.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,UAAU,EACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,wBAAwB,MAAM,gCAAgC,CAAC;AAItE,qBAAa,oBAAoB,CAC/B,MAAM,SAAS,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC/C,QAAQ,SAAS,OAAO,CACxB,SAAQ,wBAAwB,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC3C,gBAAgB,GAAI,CAAC,SAAS,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,EACxD,GAAG,CAAC,EACJ,OAAO;QACL,UAAU,EAAE,UAAU,CAAC;KACxB,KACA;QACD,IAAI,EAAE,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;QACvD,QAAQ,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;KAChC,CAQC;IAEF,OAAO,QAAO,SAAS,CAoBrB;CACH"}
@@ -1,7 +1,7 @@
1
- import InstantReactWebDatabase from "../InstantReactWebDatabase.js";
1
+ import SidekickReactWebDatabase from "../SidekickReactWebDatabase.js";
2
2
  import { useContext } from 'react';
3
- import { SuspsenseQueryContext } from "./InstantSuspenseProvider.js";
4
- export class InstantNextDatabase extends InstantReactWebDatabase {
3
+ import { SuspsenseQueryContext } from "./SidekickSuspenseProvider.js";
4
+ export class SidekickNextDatabase extends SidekickReactWebDatabase {
5
5
  useSuspenseQuery = (q, opts) => {
6
6
  const ctx = useContext(SuspsenseQueryContext);
7
7
  if (!ctx) {
@@ -29,4 +29,4 @@ export class InstantNextDatabase extends InstantReactWebDatabase {
29
29
  return realAuthResult;
30
30
  };
31
31
  }
32
- //# sourceMappingURL=InstantNextDatabase.js.map
32
+ //# sourceMappingURL=SidekickNextDatabase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidekickNextDatabase.js","sourceRoot":"","sources":["../../../src/next-ssr/SidekickNextDatabase.tsx"],"names":[],"mappings":"AAQA,OAAO,wBAAwB,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAAgC,CAAC;AAEvE,MAAM,OAAO,oBAGX,SAAQ,wBAA0C;IAC3C,gBAAgB,GAAG,CACxB,CAAI,EACJ,IAEC,EAID,EAAE;QACF,MAAM,GAAG,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;QAC9C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAQ,CAAC;IAC9C,CAAC,CAAC;IAEF,OAAO,GAAG,GAAc,EAAE;QACxB,MAAM,GAAG,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;QAC9C,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,cAAc,CAAC;QACxB,CAAC;QAED,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;QACxB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,cAAc,CAAC;QACxB,CAAC;QACD,IAAI,cAAc,CAAC,SAAS,EAAE,CAAC;YAC7B,OAAO;gBACL,KAAK,EAAE,SAAS;gBAChB,SAAS,EAAE,KAAK;gBAChB,IAAI,EAAE,OAAO,IAAI,SAAS,EAAE,qCAAqC;aAClE,CAAC;QACJ,CAAC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;CACH","sourcesContent":["import {\n AuthState,\n SidekickSchemaDef,\n SideQLResponse,\n PageInfoResponse,\n RuleParams,\n ValidQuery,\n} from '@sidekickdb/core';\nimport SidekickReactWebDatabase from '../SidekickReactWebDatabase.ts';\nimport { useContext } from 'react';\nimport { SuspsenseQueryContext } from './SidekickSuspenseProvider.tsx';\n\nexport class SidekickNextDatabase<\n Schema extends SidekickSchemaDef<any, any, any>,\n UseDates extends boolean,\n> extends SidekickReactWebDatabase<Schema, UseDates> {\n public useSuspenseQuery = <Q extends ValidQuery<Q, Schema>>(\n q: Q,\n opts?: {\n ruleParams: RuleParams;\n },\n ): {\n data: SideQLResponse<Schema, Q, NonNullable<UseDates>>;\n pageInfo?: PageInfoResponse<Q>;\n } => {\n const ctx = useContext(SuspsenseQueryContext);\n if (!ctx) {\n throw new Error(\n 'useSuspenseQuery must be used within a SuspenseQueryProvider',\n );\n }\n return ctx.useSuspenseQuery(q, opts) as any;\n };\n\n useAuth = (): AuthState => {\n const ctx = useContext(SuspsenseQueryContext);\n const realAuthResult = this._useAuth();\n if (!ctx) {\n return realAuthResult;\n }\n\n const { ssrUser } = ctx;\n if (ssrUser === undefined) {\n return realAuthResult;\n }\n if (realAuthResult.isLoading) {\n return {\n error: undefined,\n isLoading: false,\n user: ssrUser ?? undefined, // null -> undefined for the response\n };\n }\n\n return realAuthResult;\n };\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import { SidekickSchemaDef, SideQLResponse, PageInfoResponse, RuleParams, User, ValidQuery } from '@sidekickdb/core';
2
+ import SidekickReactWebDatabase from '../SidekickReactWebDatabase.ts';
3
+ type SidekickSuspenseProviderProps<Schema extends SidekickSchemaDef<any, any, any>> = {
4
+ nonce?: string;
5
+ children: React.ReactNode;
6
+ db: SidekickReactWebDatabase<Schema, any>;
7
+ user?: User | null;
8
+ };
9
+ type SuspenseQueryContextValue = {
10
+ useSuspenseQuery: (query: any, opts?: SuspenseQueryOpts) => any;
11
+ ssrUser: User | null | undefined;
12
+ };
13
+ export declare const SuspsenseQueryContext: import("react").Context<SuspenseQueryContextValue | null>;
14
+ export declare const createUseSuspenseQuery: <Schema extends SidekickSchemaDef<any, any, any>, UseDates extends boolean>(_db: SidekickReactWebDatabase<Schema, UseDates>) => (<Q extends ValidQuery<Q, Schema>>(q: Q, opts?: {
15
+ ruleParams: RuleParams;
16
+ }) => {
17
+ data: SideQLResponse<Schema, Q, NonNullable<UseDates>>;
18
+ pageInfo?: PageInfoResponse<Q>;
19
+ });
20
+ type SuspenseQueryOpts = {
21
+ ruleParams: RuleParams;
22
+ };
23
+ export declare const SidekickSuspenseProvider: (props: SidekickSuspenseProviderProps<any>) => import("react/jsx-runtime").JSX.Element;
24
+ export {};
25
+ //# sourceMappingURL=SidekickSuspenseProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidekickSuspenseProvider.d.ts","sourceRoot":"","sources":["../../../src/next-ssr/SidekickSuspenseProvider.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,IAAI,EACJ,UAAU,EACX,MAAM,kBAAkB,CAAC;AAC1B,OAAO,wBAAwB,MAAM,gCAAgC,CAAC;AAmBtE,KAAK,6BAA6B,CAChC,MAAM,SAAS,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAC7C;IACF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,EAAE,EAAE,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1C,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,CAAC;AAIF,KAAK,yBAAyB,GAAG;IAC/B,gBAAgB,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,iBAAiB,KAAK,GAAG,CAAC;IAChE,OAAO,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,qBAAqB,2DACqB,CAAC;AAGxD,eAAO,MAAM,sBAAsB,GACjC,MAAM,SAAS,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAC/C,QAAQ,SAAS,OAAO,EAExB,KAAK,wBAAwB,CAAC,MAAM,EAAE,QAAQ,CAAC,KAC9C,CAAC,CAAC,CAAC,SAAS,UAAU,CAAC,CAAC,EAAE,MAAM,CAAC,EAClC,CAAC,EAAE,CAAC,EACJ,IAAI,CAAC,EAAE;IACL,UAAU,EAAE,UAAU,CAAC;CACxB,KACE;IACH,IAAI,EAAE,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvD,QAAQ,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;CAChC,CAUA,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAqJF,eAAO,MAAM,wBAAwB,GACnC,OAAO,6BAA6B,CAAC,GAAG,CAAC,4CA4D1C,CAAC"}
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- // InstantSuspenseProvider can only be used in a client context so this prevents errors from trying to use it in a server component.
3
+ // SidekickSuspenseProvider can only be used in a client context so this prevents errors from trying to use it in a server component.
4
4
  import { FrameworkClient, } from '@sidekickdb/core';
5
5
  import { createHydrationStreamProvider, isServer, } from "./HydrationStreamProvider.js";
6
6
  import { createContext, useCallback, useContext, useMemo, useRef, useState, useEffect, } from 'react';
@@ -123,9 +123,9 @@ function createFrameworkClient(db, user) {
123
123
  db.core._reactor.setFrameworkClient(client);
124
124
  return client;
125
125
  }
126
- export const InstantSuspenseProvider = (props) => {
126
+ export const SidekickSuspenseProvider = (props) => {
127
127
  if (!props.db) {
128
- throw new Error('Must provide db to InstantSuspenseProvider');
128
+ throw new Error('Must provide db to SidekickSuspenseProvider');
129
129
  }
130
130
  const db = props.db;
131
131
  const [trackedKeys] = useState(() => new Set());
@@ -160,4 +160,4 @@ export const InstantSuspenseProvider = (props) => {
160
160
  });
161
161
  }, children: props.children }) }));
162
162
  };
163
- //# sourceMappingURL=InstantSuspenseProvider.js.map
163
+ //# sourceMappingURL=SidekickSuspenseProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SidekickSuspenseProvider.js","sourceRoot":"","sources":["../../../src/next-ssr/SidekickSuspenseProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,qIAAqI;AAErI,OAAO,EACL,eAAe,GAQhB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,6BAA6B,EAC7B,QAAQ,GACT,MAAM,8BAA+B,CAAC;AACvC,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,OAAO,EACP,MAAM,EACN,QAAQ,EACR,SAAS,GACV,MAAM,OAAO,CAAC;AACf,OAAO,EAEL,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAWlC,MAAM,MAAM,GAAG,6BAA6B,EAAO,CAAC;AAOpD,MAAM,CAAC,MAAM,qBAAqB,GAChC,aAAa,CAAmC,IAAI,CAAC,CAAC;AAExD,mCAAmC;AACnC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAIpC,GAA+C,EAS9C,EAAE;IACH,OAAO,CAAkC,CAAM,EAAE,IAAS,EAAE,EAAE;QAC5D,MAAM,GAAG,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;QAC9C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAQ,CAAC;IAC9C,CAAC,CAAC;AACJ,CAAC,CAAC;AAMF,SAAS,0BAA0B,C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,CAAC,IAAI,CAAC,CAAC,CAAC;IAEnC,OAAO,CACL,KAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YACjD,KAAC,MAAM,CAAC,QAAQ,IACd,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,OAAO,EAAE,GAAG,EAAE;gBACZ,MAAM,MAAM,GAAuC,EAAE,CAAC;gBACtD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,SAAS,CAAC,OAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;oBAClE,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;wBACvD,MAAM,CAAC,IAAI,CAAC;4BACV,QAAQ,EAAE,GAAG;4BACb,KAAK,EAAE,KAAK,CAAC,IAAI;yBAClB,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;gBAED,WAAW,CAAC,KAAK,EAAE,CAAC;gBACpB,OAAO,MAAM,CAAC;YAChB,CAAC,EACD,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE;gBACrB,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;oBACxB,SAAS,CAAC,OAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;gBACjE,CAAC,CAAC,CAAC;YACL,CAAC,YAEA,KAAK,CAAC,QAAQ,GACC,GACa,CAClC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["'use client';\n// SidekickSuspenseProvider can only be used in a client context so this prevents errors from trying to use it in a server component.\n\nimport {\n FrameworkClient,\n SidekickConfig,\n SidekickSchemaDef,\n SideQLResponse,\n PageInfoResponse,\n RuleParams,\n User,\n ValidQuery,\n} from '@sidekickdb/core';\nimport SidekickReactWebDatabase from '../SidekickReactWebDatabase.ts';\nimport {\n createHydrationStreamProvider,\n isServer,\n} from './HydrationStreamProvider.tsx';\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n useEffect,\n} from 'react';\nimport {\n SidekickReactAbstractDatabase,\n useQueryInternal,\n} from '@sidekickdb/react-common';\n\ntype SidekickSuspenseProviderProps<\n Schema extends SidekickSchemaDef<any, any, any>,\n> = {\n nonce?: string;\n children: React.ReactNode;\n db: SidekickReactWebDatabase<Schema, any>;\n user?: User | null;\n};\n\nconst stream = createHydrationStreamProvider<any>();\n\ntype SuspenseQueryContextValue = {\n useSuspenseQuery: (query: any, opts?: SuspenseQueryOpts) => any;\n ssrUser: User | null | undefined;\n};\n\nexport const SuspsenseQueryContext =\n createContext<SuspenseQueryContextValue | null>(null);\n\n// Creates a typed useSuspense hook\nexport const createUseSuspenseQuery = <\n Schema extends SidekickSchemaDef<any, any, any>,\n UseDates extends boolean,\n>(\n _db: SidekickReactWebDatabase<Schema, UseDates>,\n): (<Q extends ValidQuery<Q, Schema>>(\n q: Q,\n opts?: {\n ruleParams: RuleParams;\n },\n) => {\n data: SideQLResponse<Schema, Q, NonNullable<UseDates>>;\n pageInfo?: PageInfoResponse<Q>;\n}) => {\n return <Q extends ValidQuery<Q, Schema>>(q: any, opts: any) => {\n const ctx = useContext(SuspsenseQueryContext);\n if (!ctx) {\n throw new Error(\n 'useSuspenseQuery must be used within a SuspenseQueryProvider',\n );\n }\n return ctx.useSuspenseQuery(q, opts) as any;\n };\n};\n\ntype SuspenseQueryOpts = {\n ruleParams: RuleParams;\n};\n\nfunction makeUseSuspenseQueryServer(client: FrameworkClient) {\n return function useSuspenseQueryServer(query: any, opts: SuspenseQueryOpts) {\n let entry = client.getExistingResultForQuery(query, opts);\n\n if (!entry) {\n entry = client.query(query, opts);\n }\n\n if (entry.status === 'pending') {\n throw entry.promise;\n }\n\n if (entry.status === 'error') {\n throw entry.error;\n }\n\n if (entry.status === 'success') {\n switch (entry.type) {\n case 'session': {\n return entry.data;\n }\n case 'http': {\n const data = entry.data;\n const result = client.completeIsomorphic(\n query,\n data.triples,\n data.attrs,\n data.pageInfo,\n );\n\n return result;\n }\n }\n }\n };\n}\n\nfunction makeUseSuspenseQueryClient(\n db: SidekickReactAbstractDatabase<any, any>,\n client: FrameworkClient,\n) {\n function getEntry(query: any, opts: SuspenseQueryOpts, allowFetch: boolean) {\n const entry = client.getExistingResultForQuery(query, opts);\n\n if (entry?.status === 'pending') {\n throw entry.promise;\n }\n\n if (entry?.status === 'error') {\n throw entry.error;\n }\n\n if (entry?.status === 'success') {\n switch (entry.type) {\n case 'session': {\n return entry.data;\n }\n case 'http': {\n const data = entry.data;\n const result = client.completeIsomorphic(\n query,\n data.triples,\n data.attrs,\n data.pageInfo,\n );\n\n return result;\n }\n }\n }\n\n if (allowFetch) {\n const promise = client.queryClient(query, opts);\n throw promise;\n }\n }\n\n return function useSuspenseQueryClient(query: any, opts: SuspenseQueryOpts) {\n const useQueryResult = useQueryInternal(\n db.core,\n query,\n opts,\n // Returns the server result for useSyncExternalStore\n () => {\n try {\n const res = getEntry(query, opts, false);\n return res;\n } catch (throwable) {\n return { error: throwable };\n }\n },\n );\n\n const hasData = !!useQueryResult.state.data;\n const queryHash = useQueryResult.queryHash;\n\n useEffect(() => {\n if (hasData) {\n // We have a newer result, so remove the cached SSR or suspended\n // result from the framework client cache\n client.removeCachedQueryResult(queryHash);\n }\n }, [hasData, queryHash]);\n\n if (useQueryResult.state.data) {\n return {\n data: useQueryResult.state.data,\n pageInfo: useQueryResult.state.pageInfo,\n };\n }\n\n if (useQueryResult.state.error) {\n throw useQueryResult.state.error;\n }\n\n return getEntry(query, opts, true);\n };\n}\n\nfunction createFrameworkClient(\n db: SidekickReactAbstractDatabase<any, any>,\n user: User | null | undefined,\n) {\n if (isServer) {\n if (user && !user.refresh_token) {\n throw new Error(\n 'User must have a refresh_token field. Recieved: ' +\n JSON.stringify(user, null, 2),\n );\n }\n return new FrameworkClient({\n token: user?.refresh_token,\n db: db.core,\n });\n }\n\n // On the client, make sure we only have a single framework\n // in case our suspense provider gets unmounted\n const existing = db.core._reactor._frameworkClient;\n if (existing) {\n return existing;\n }\n const client = new FrameworkClient({ db: db.core });\n db.core._reactor.setFrameworkClient(client);\n return client;\n}\n\nexport const SidekickSuspenseProvider = (\n props: SidekickSuspenseProviderProps<any>,\n) => {\n if (!props.db) {\n throw new Error('Must provide db to SidekickSuspenseProvider');\n }\n\n const db = props.db;\n\n const [trackedKeys] = useState(() => new Set<string>());\n\n const clientRef = useRef<FrameworkClient>(\n createFrameworkClient(props.db, props.user),\n );\n\n if (isServer) {\n clientRef.current.subscribe((result) => {\n const { queryHash } = result;\n trackedKeys.add(queryHash);\n });\n }\n\n const useSuspenseQuery = useCallback(\n isServer\n ? makeUseSuspenseQueryServer(clientRef.current)\n : makeUseSuspenseQueryClient(db, clientRef.current),\n [],\n );\n\n const contextValue = useMemo(() => {\n return { useSuspenseQuery, ssrUser: props.user };\n }, [useSuspenseQuery, props.user]);\n\n return (\n <SuspsenseQueryContext.Provider value={contextValue}>\n <stream.Provider\n nonce={props.nonce}\n onFlush={() => {\n const toSend: { queryKey: string; value: any }[] = [];\n for (const [key, value] of clientRef.current!.resultMap.entries()) {\n if (trackedKeys.has(key) && value.status === 'success') {\n toSend.push({\n queryKey: key,\n value: value.data,\n });\n }\n }\n\n trackedKeys.clear();\n return toSend;\n }}\n onEntries={(entries) => {\n entries.forEach((entry) => {\n clientRef.current!.addQueryResult(entry.queryKey, entry.value);\n });\n }}\n >\n {props.children}\n </stream.Provider>\n </SuspsenseQueryContext.Provider>\n );\n};\n"]}