@makeswift/runtime 0.28.2-canary.1 → 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.
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/client/index.js +3 -3
- package/dist/cjs/runtimes/react/hooks/use-is-in-builder.js +11 -2
- package/dist/cjs/runtimes/react/hooks/use-is-in-builder.js.map +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/client/index.js +3 -3
- package/dist/esm/runtimes/react/hooks/use-is-in-builder.js +11 -2
- package/dist/esm/runtimes/react/hooks/use-is-in-builder.js.map +1 -1
- package/dist/types/runtimes/react/hooks/use-is-in-builder.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -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.
|
|
31
|
+
version: "0.28.3-canary.0",
|
|
32
32
|
interactionMode: true,
|
|
33
33
|
clientSideNavigation: false,
|
|
34
34
|
elementFromPoint: false,
|
package/dist/cjs/client/index.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
function getServerSnapshot() {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
26
30
|
function useIsInBuilder() {
|
|
27
|
-
|
|
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 {
|
|
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.
|
|
11
|
+
version: "0.28.3-canary.0",
|
|
12
12
|
interactionMode: true,
|
|
13
13
|
clientSideNavigation: false,
|
|
14
14
|
elementFromPoint: false,
|
package/dist/esm/client/index.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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 {
|
|
3
|
+
import { useSyncExternalStore } from "react";
|
|
4
|
+
function getServerSnapshot() {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
3
7
|
function useIsInBuilder() {
|
|
4
|
-
|
|
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 {
|
|
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":"
|
|
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"}
|