@makeswift/runtime 0.28.2 → 0.28.3-canary.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.
@@ -28,7 +28,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
28
28
  return import_request_response.ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
29
29
  }
30
30
  return import_request_response.ApiResponse.json({
31
- version: "0.28.2",
31
+ version: "0.28.3-canary.0",
32
32
  interactionMode: true,
33
33
  clientSideNavigation: false,
34
34
  elementFromPoint: false,
@@ -211,7 +211,7 @@ Received "${apiKey}" instead.`
211
211
  }
212
212
  this.apiKey = apiKey;
213
213
  this.graphqlClient = new import_client.GraphQLClient(new URL("graphql", runtime.apiOrigin).href, {
214
- "makeswift-runtime-version": "0.28.2"
214
+ "makeswift-runtime-version": "0.28.3-canary.0"
215
215
  });
216
216
  this.runtime = runtime;
217
217
  }
@@ -223,7 +223,7 @@ Received "${apiKey}" instead.`
223
223
  const requestHeaders = new Headers({
224
224
  "x-api-key": this.apiKey,
225
225
  "makeswift-site-api-key": this.apiKey,
226
- "makeswift-runtime-version": "0.28.2"
226
+ "makeswift-runtime-version": "0.28.3-canary.0"
227
227
  });
228
228
  if (siteVersion?.token) {
229
229
  requestUrl.searchParams.set("version", siteVersion.version);
@@ -681,7 +681,7 @@ Received "${apiKey}" instead.`
681
681
  headers: {
682
682
  "x-api-key": this.apiKey,
683
683
  "makeswift-site-api-key": this.apiKey,
684
- "makeswift-runtime-version": "0.28.2",
684
+ "makeswift-runtime-version": "0.28.3-canary.0",
685
685
  "content-type": "application/json"
686
686
  },
687
687
  body: JSON.stringify({ token }),
@@ -21,10 +21,19 @@ __export(use_is_in_builder_exports, {
21
21
  useIsInBuilder: () => useIsInBuilder
22
22
  });
23
23
  module.exports = __toCommonJS(use_is_in_builder_exports);
24
+ var import_use_store = require("./use-store");
24
25
  var import_read_only_state = require("../../../state/read-only-state");
25
- var import_use_selector = require("./use-selector");
26
+ var import_react = require("react");
27
+ function getServerSnapshot() {
28
+ return false;
29
+ }
26
30
  function useIsInBuilder() {
27
- return (0, import_use_selector.useSelector)((state) => (0, import_read_only_state.getIsInBuilder)(state));
31
+ const store = (0, import_use_store.useStore)();
32
+ return (0, import_react.useSyncExternalStore)(
33
+ store.subscribe,
34
+ () => (0, import_read_only_state.getIsInBuilder)(store.getState()),
35
+ getServerSnapshot
36
+ );
28
37
  }
29
38
  // Annotate the CommonJS export names for ESM import in node:
30
39
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-is-in-builder.ts"],"sourcesContent":["import { getIsInBuilder } from '../../../state/read-only-state'\nimport { useSelector } from './use-selector'\n\nexport function useIsInBuilder(): boolean {\n return useSelector(state => getIsInBuilder(state))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA+B;AAC/B,0BAA4B;AAErB,SAAS,iBAA0B;AACxC,aAAO,iCAAY,eAAS,uCAAe,KAAK,CAAC;AACnD;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-is-in-builder.ts"],"sourcesContent":["import { useStore } from './use-store'\nimport { getIsInBuilder } from '../../../state/read-only-state'\nimport { useSyncExternalStore } from 'react'\n\n/**\n * When multiple React roots share a single store, `isInBuilder` can become\n * `true` before all roots have hydrated. React uses `getServerSnapshot` during\n * client hydration — not just on the server — so if it reads from the live\n * store, it may see `true` while the server HTML was rendered with `false`,\n * causing a hydration mismatch that React may fail to recover from inside\n * nested Suspense boundaries. This can manifest as cases where the correct\n * value of `isInBuilder` is read in the component, but the DOM remains stale.\n *\n * https://react.dev/reference/react/useSyncExternalStore#parameters\n *\n * TODO: For now, we're fixing this by returning a fixed `false` from\n * `getServerSnapshot` to match what the server actually rendered. After\n * hydration, the subscription picks up changes to this value which can only be\n * initiated client-side. We'll need to revisit this problem to reconsider how\n * we holistically handle store state changes across the server/client.\n */\nfunction getServerSnapshot(): boolean {\n return false\n}\n\nexport function useIsInBuilder(): boolean {\n const store = useStore()\n\n return useSyncExternalStore(\n store.subscribe,\n () => getIsInBuilder(store.getState()),\n getServerSnapshot,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAyB;AACzB,6BAA+B;AAC/B,mBAAqC;AAmBrC,SAAS,oBAA6B;AACpC,SAAO;AACT;AAEO,SAAS,iBAA0B;AACxC,QAAM,YAAQ,2BAAS;AAEvB,aAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAM,uCAAe,MAAM,SAAS,CAAC;AAAA,IACrC;AAAA,EACF;AACF;","names":[]}
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
8
8
  return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
9
9
  }
10
10
  return ApiResponse.json({
11
- version: "0.28.2",
11
+ version: "0.28.3-canary.0",
12
12
  interactionMode: true,
13
13
  clientSideNavigation: false,
14
14
  elementFromPoint: false,
@@ -195,7 +195,7 @@ Received "${apiKey}" instead.`
195
195
  }
196
196
  this.apiKey = apiKey;
197
197
  this.graphqlClient = new GraphQLClient(new URL("graphql", runtime.apiOrigin).href, {
198
- "makeswift-runtime-version": "0.28.2"
198
+ "makeswift-runtime-version": "0.28.3-canary.0"
199
199
  });
200
200
  this.runtime = runtime;
201
201
  }
@@ -207,7 +207,7 @@ Received "${apiKey}" instead.`
207
207
  const requestHeaders = new Headers({
208
208
  "x-api-key": this.apiKey,
209
209
  "makeswift-site-api-key": this.apiKey,
210
- "makeswift-runtime-version": "0.28.2"
210
+ "makeswift-runtime-version": "0.28.3-canary.0"
211
211
  });
212
212
  if (siteVersion?.token) {
213
213
  requestUrl.searchParams.set("version", siteVersion.version);
@@ -665,7 +665,7 @@ Received "${apiKey}" instead.`
665
665
  headers: {
666
666
  "x-api-key": this.apiKey,
667
667
  "makeswift-site-api-key": this.apiKey,
668
- "makeswift-runtime-version": "0.28.2",
668
+ "makeswift-runtime-version": "0.28.3-canary.0",
669
669
  "content-type": "application/json"
670
670
  },
671
671
  body: JSON.stringify({ token }),
@@ -1,7 +1,16 @@
1
+ import { useStore } from "./use-store";
1
2
  import { getIsInBuilder } from "../../../state/read-only-state";
2
- import { useSelector } from "./use-selector";
3
+ import { useSyncExternalStore } from "react";
4
+ function getServerSnapshot() {
5
+ return false;
6
+ }
3
7
  function useIsInBuilder() {
4
- return useSelector((state) => getIsInBuilder(state));
8
+ const store = useStore();
9
+ return useSyncExternalStore(
10
+ store.subscribe,
11
+ () => getIsInBuilder(store.getState()),
12
+ getServerSnapshot
13
+ );
5
14
  }
6
15
  export {
7
16
  useIsInBuilder
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-is-in-builder.ts"],"sourcesContent":["import { getIsInBuilder } from '../../../state/read-only-state'\nimport { useSelector } from './use-selector'\n\nexport function useIsInBuilder(): boolean {\n return useSelector(state => getIsInBuilder(state))\n}\n"],"mappings":"AAAA,SAAS,sBAAsB;AAC/B,SAAS,mBAAmB;AAErB,SAAS,iBAA0B;AACxC,SAAO,YAAY,WAAS,eAAe,KAAK,CAAC;AACnD;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-is-in-builder.ts"],"sourcesContent":["import { useStore } from './use-store'\nimport { getIsInBuilder } from '../../../state/read-only-state'\nimport { useSyncExternalStore } from 'react'\n\n/**\n * When multiple React roots share a single store, `isInBuilder` can become\n * `true` before all roots have hydrated. React uses `getServerSnapshot` during\n * client hydration — not just on the server — so if it reads from the live\n * store, it may see `true` while the server HTML was rendered with `false`,\n * causing a hydration mismatch that React may fail to recover from inside\n * nested Suspense boundaries. This can manifest as cases where the correct\n * value of `isInBuilder` is read in the component, but the DOM remains stale.\n *\n * https://react.dev/reference/react/useSyncExternalStore#parameters\n *\n * TODO: For now, we're fixing this by returning a fixed `false` from\n * `getServerSnapshot` to match what the server actually rendered. After\n * hydration, the subscription picks up changes to this value which can only be\n * initiated client-side. We'll need to revisit this problem to reconsider how\n * we holistically handle store state changes across the server/client.\n */\nfunction getServerSnapshot(): boolean {\n return false\n}\n\nexport function useIsInBuilder(): boolean {\n const store = useStore()\n\n return useSyncExternalStore(\n store.subscribe,\n () => getIsInBuilder(store.getState()),\n getServerSnapshot,\n )\n}\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,4BAA4B;AAmBrC,SAAS,oBAA6B;AACpC,SAAO;AACT;AAEO,SAAS,iBAA0B;AACxC,QAAM,QAAQ,SAAS;AAEvB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,eAAe,MAAM,SAAS,CAAC;AAAA,IACrC;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"use-is-in-builder.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-is-in-builder.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,IAAI,OAAO,CAExC"}
1
+ {"version":3,"file":"use-is-in-builder.d.ts","sourceRoot":"","sources":["../../../../../src/runtimes/react/hooks/use-is-in-builder.ts"],"names":[],"mappings":"AAyBA,wBAAgB,cAAc,IAAI,OAAO,CAQxC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makeswift/runtime",
3
- "version": "0.28.2",
3
+ "version": "0.28.3-canary.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "url": "makeswift/makeswift",