@makeswift/runtime 0.28.8-canary.0 → 0.28.8-canary.2

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 (85) hide show
  1. package/dist/cjs/api/graphql-api-client.js +1 -1
  2. package/dist/cjs/api/makeswift-api-resources-client.js +25 -11
  3. package/dist/cjs/api/makeswift-api-resources-client.js.map +1 -1
  4. package/dist/cjs/api/rest-api-client.js +1 -1
  5. package/dist/cjs/api-handler/handlers/manifest.js +1 -1
  6. package/dist/cjs/client/index.js +1 -1
  7. package/dist/cjs/next/components/framework-provider/app-router/index.js +0 -2
  8. package/dist/cjs/next/components/framework-provider/app-router/index.js.map +1 -1
  9. package/dist/cjs/next/components/framework-provider/index.js +1 -1
  10. package/dist/cjs/next/components/framework-provider/index.js.map +1 -1
  11. package/dist/cjs/runtimes/react/components/ElementData.js +2 -2
  12. package/dist/cjs/runtimes/react/components/ElementData.js.map +1 -1
  13. package/dist/cjs/runtimes/react/components/framework-context.js +18 -12
  14. package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
  15. package/dist/cjs/runtimes/react/components/hooks/use-framework-context.js +1 -5
  16. package/dist/cjs/runtimes/react/components/hooks/use-framework-context.js.map +1 -1
  17. package/dist/cjs/runtimes/react/components/resolve-props.js +43 -0
  18. package/dist/cjs/runtimes/react/components/resolve-props.js.map +1 -0
  19. package/dist/cjs/runtimes/react/hooks/use-control-defs.js +40 -0
  20. package/dist/cjs/runtimes/react/hooks/use-control-defs.js.map +1 -0
  21. package/dist/cjs/runtimes/react/runtime-core.js +13 -0
  22. package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
  23. package/dist/cjs/testing/fixtures/index.js +4 -2
  24. package/dist/cjs/testing/fixtures/index.js.map +1 -1
  25. package/dist/cjs/testing/fixtures/snippet.js +36 -0
  26. package/dist/cjs/testing/fixtures/snippet.js.map +1 -0
  27. package/dist/cjs/unstable-framework-support/index.js +2 -8
  28. package/dist/cjs/unstable-framework-support/index.js.map +1 -1
  29. package/dist/esm/api/graphql-api-client.js +1 -1
  30. package/dist/esm/api/makeswift-api-resources-client.js +15 -11
  31. package/dist/esm/api/makeswift-api-resources-client.js.map +1 -1
  32. package/dist/esm/api/rest-api-client.js +1 -1
  33. package/dist/esm/api-handler/handlers/manifest.js +1 -1
  34. package/dist/esm/client/index.js +1 -1
  35. package/dist/esm/next/components/framework-provider/app-router/index.js +0 -4
  36. package/dist/esm/next/components/framework-provider/app-router/index.js.map +1 -1
  37. package/dist/esm/next/components/framework-provider/index.js +4 -2
  38. package/dist/esm/next/components/framework-provider/index.js.map +1 -1
  39. package/dist/esm/runtimes/react/components/ElementData.js +1 -1
  40. package/dist/esm/runtimes/react/components/ElementData.js.map +1 -1
  41. package/dist/esm/runtimes/react/components/framework-context.js +19 -8
  42. package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
  43. package/dist/esm/runtimes/react/components/hooks/use-framework-context.js +1 -5
  44. package/dist/esm/runtimes/react/components/hooks/use-framework-context.js.map +1 -1
  45. package/dist/esm/runtimes/react/components/resolve-props.js +19 -0
  46. package/dist/esm/runtimes/react/components/resolve-props.js.map +1 -0
  47. package/dist/esm/runtimes/react/hooks/use-control-defs.js +16 -0
  48. package/dist/esm/runtimes/react/hooks/use-control-defs.js.map +1 -0
  49. package/dist/esm/runtimes/react/runtime-core.js +13 -0
  50. package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
  51. package/dist/esm/testing/fixtures/index.js +2 -1
  52. package/dist/esm/testing/fixtures/index.js.map +1 -1
  53. package/dist/esm/testing/fixtures/snippet.js +12 -0
  54. package/dist/esm/testing/fixtures/snippet.js.map +1 -0
  55. package/dist/esm/unstable-framework-support/index.js +2 -8
  56. package/dist/esm/unstable-framework-support/index.js.map +1 -1
  57. package/dist/types/api/makeswift-api-resources-client.d.ts.map +1 -1
  58. package/dist/types/next/components/framework-provider/app-router/index.d.ts +1 -1
  59. package/dist/types/next/components/framework-provider/app-router/index.d.ts.map +1 -1
  60. package/dist/types/next/components/framework-provider/index.d.ts.map +1 -1
  61. package/dist/types/runtimes/react/components/__tests__/framework-context.test.d.ts +3 -0
  62. package/dist/types/runtimes/react/components/__tests__/framework-context.test.d.ts.map +1 -0
  63. package/dist/types/runtimes/react/components/framework-context.d.ts +4 -6
  64. package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
  65. package/dist/types/runtimes/react/components/hooks/use-framework-context.d.ts +1 -2
  66. package/dist/types/runtimes/react/components/hooks/use-framework-context.d.ts.map +1 -1
  67. package/dist/types/runtimes/react/components/resolve-props.d.ts +7 -0
  68. package/dist/types/runtimes/react/components/resolve-props.d.ts.map +1 -0
  69. package/dist/types/runtimes/react/hooks/use-control-defs.d.ts +6 -0
  70. package/dist/types/runtimes/react/hooks/use-control-defs.d.ts.map +1 -0
  71. package/dist/types/runtimes/react/runtime-core.d.ts +4 -2
  72. package/dist/types/runtimes/react/runtime-core.d.ts.map +1 -1
  73. package/dist/types/testing/fixtures/index.d.ts +2 -1
  74. package/dist/types/testing/fixtures/index.d.ts.map +1 -1
  75. package/dist/types/testing/fixtures/snippet.d.ts +6 -0
  76. package/dist/types/testing/fixtures/snippet.d.ts.map +1 -0
  77. package/dist/types/unstable-framework-support/index.d.ts +1 -1
  78. package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
  79. package/package.json +3 -3
  80. package/dist/cjs/runtimes/react/controls.js +0 -59
  81. package/dist/cjs/runtimes/react/controls.js.map +0 -1
  82. package/dist/esm/runtimes/react/controls.js +0 -25
  83. package/dist/esm/runtimes/react/controls.js.map +0 -1
  84. package/dist/types/runtimes/react/controls.d.ts +0 -9
  85. package/dist/types/runtimes/react/controls.d.ts.map +0 -1
@@ -27,7 +27,7 @@ class MakeswiftGraphQLApiClient {
27
27
  graphqlClient;
28
28
  constructor({ endpoint }) {
29
29
  this.graphqlClient = new import_client.GraphQLClient(endpoint, {
30
- "makeswift-runtime-version": "0.28.8-canary.0"
30
+ "makeswift-runtime-version": "0.28.8-canary.2"
31
31
  });
32
32
  }
33
33
  async createTableRecord(tableId, columns) {
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var makeswift_api_resources_client_exports = {};
20
30
  __export(makeswift_api_resources_client_exports, {
@@ -23,8 +33,6 @@ __export(makeswift_api_resources_client_exports, {
23
33
  module.exports = __toCommonJS(makeswift_api_resources_client_exports);
24
34
  var import_client_store = require("../state/api-client/client-store");
25
35
  var import_api_resources_client = require("./api-resources-client");
26
- var import_graphql_api_client = require("./graphql-api-client");
27
- var import_rest_api_client = require("./rest-api-client");
28
36
  class MakeswiftApiResourcesClient extends import_api_resources_client.ApiResourcesClient {
29
37
  restApiClient;
30
38
  graphQlClient;
@@ -38,29 +46,35 @@ class MakeswiftApiResourcesClient extends import_api_resources_client.ApiResourc
38
46
  super({
39
47
  store: (0, import_client_store.configureClientStore)({ preloadedState })
40
48
  });
41
- this.restApiClient = new import_rest_api_client.MakeswiftRestAPIClient({ fetch, apiKey, apiOrigin });
42
- this.graphQlClient = new import_graphql_api_client.MakeswiftGraphQLApiClient({ endpoint: graphqlApiEndpoint });
49
+ this.restApiClient = (async () => {
50
+ const { MakeswiftRestAPIClient } = await Promise.resolve().then(() => __toESM(require("./rest-api-client")));
51
+ return new MakeswiftRestAPIClient({ fetch, apiKey, apiOrigin });
52
+ })();
53
+ this.graphQlClient = (async () => {
54
+ const { MakeswiftGraphQLApiClient } = await Promise.resolve().then(() => __toESM(require("./graphql-api-client")));
55
+ return new MakeswiftGraphQLApiClient({ endpoint: graphqlApiEndpoint });
56
+ })();
43
57
  }
44
58
  async fetchSwatchImpl(id, version) {
45
- return this.restApiClient.getSwatch(id, version);
59
+ return (await this.restApiClient).getSwatch(id, version);
46
60
  }
47
61
  async fetchFileImpl(id, _version) {
48
- return this.graphQlClient.getFile(id);
62
+ return (await this.graphQlClient).getFile(id);
49
63
  }
50
64
  async fetchTypographyImpl(id, version) {
51
- return this.restApiClient.getTypography(id, version);
65
+ return (await this.restApiClient).getTypography(id, version);
52
66
  }
53
67
  async fetchGlobalElementImpl(id, version) {
54
- return this.restApiClient.getGlobalElement(id, version);
68
+ return (await this.restApiClient).getGlobalElement(id, version);
55
69
  }
56
70
  async fetchLocalizedGlobalElementImpl(id, version, locale) {
57
- return this.restApiClient.getLocalizedGlobalElement(id, locale, version);
71
+ return (await this.restApiClient).getLocalizedGlobalElement(id, locale, version);
58
72
  }
59
73
  async fetchPagePathnameSliceImpl(id, version, locale) {
60
- return this.restApiClient.getPagePathnameSlice(id, version, { locale });
74
+ return (await this.restApiClient).getPagePathnameSlice(id, version, { locale });
61
75
  }
62
76
  async fetchTableImpl(id, _version) {
63
- return this.graphQlClient.getTable(id);
77
+ return (await this.graphQlClient).getTable(id);
64
78
  }
65
79
  }
66
80
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/api/makeswift-api-resources-client.ts"],"sourcesContent":["import { type State as ApiClientState } from '../state/api-client/state'\nimport { configureClientStore } from '../state/api-client/client-store'\n\nimport {\n type File,\n type GlobalElement,\n type LocalizedGlobalElement,\n type PagePathnameSlice,\n type Swatch,\n type Table,\n type Typography,\n type HttpFetch,\n} from './types'\n\nimport { ApiResourcesClient } from './api-resources-client'\nimport { MakeswiftGraphQLApiClient } from './graphql-api-client'\nimport { MakeswiftRestAPIClient } from './rest-api-client'\nimport { type SiteVersion } from './site-version'\n\n/**\n * Server-side implementation that makes direct authenticated requests to the Makeswift API.\n * Requires an API key.\n *\n * For client-side usage, see `HostApiResourcesClient`, which goes through the host via\n * `/api/makeswift/...` endpoints.\n */\nexport class MakeswiftApiResourcesClient extends ApiResourcesClient {\n private restApiClient: MakeswiftRestAPIClient\n private graphQlClient: MakeswiftGraphQLApiClient\n\n constructor({\n fetch,\n apiKey,\n apiOrigin,\n graphqlApiEndpoint,\n preloadedState,\n }: {\n fetch: HttpFetch\n apiKey: string\n apiOrigin: string\n graphqlApiEndpoint: string\n preloadedState: Partial<ApiClientState>\n }) {\n super({\n store: configureClientStore({ preloadedState }),\n })\n\n this.restApiClient = new MakeswiftRestAPIClient({ fetch, apiKey, apiOrigin })\n this.graphQlClient = new MakeswiftGraphQLApiClient({ endpoint: graphqlApiEndpoint })\n }\n\n protected async fetchSwatchImpl(id: string, version: SiteVersion | null): Promise<Swatch | null> {\n return this.restApiClient.getSwatch(id, version)\n }\n\n protected async fetchFileImpl(id: string, _version: SiteVersion | null): Promise<File | null> {\n // files are unversioned\n return this.graphQlClient.getFile(id)\n }\n\n protected async fetchTypographyImpl(\n id: string,\n version: SiteVersion | null,\n ): Promise<Typography | null> {\n return this.restApiClient.getTypography(id, version)\n }\n\n protected async fetchGlobalElementImpl(\n id: string,\n version: SiteVersion | null,\n ): Promise<GlobalElement | null> {\n return this.restApiClient.getGlobalElement(id, version)\n }\n\n protected async fetchLocalizedGlobalElementImpl(\n id: string,\n version: SiteVersion | null,\n locale: string,\n ): Promise<LocalizedGlobalElement | null> {\n return this.restApiClient.getLocalizedGlobalElement(id, locale, version)\n }\n\n protected async fetchPagePathnameSliceImpl(\n id: string,\n version: SiteVersion | null,\n locale: string | null | undefined,\n ): Promise<PagePathnameSlice | null> {\n return this.restApiClient.getPagePathnameSlice(id, version, { locale })\n }\n\n protected async fetchTableImpl(id: string, _version: SiteVersion | null): Promise<Table | null> {\n // tables are unversioned\n return this.graphQlClient.getTable(id)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAqC;AAarC,kCAAmC;AACnC,gCAA0C;AAC1C,6BAAuC;AAUhC,MAAM,oCAAoC,+CAAmB;AAAA,EAC1D;AAAA,EACA;AAAA,EAER,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAMG;AACD,UAAM;AAAA,MACJ,WAAO,0CAAqB,EAAE,eAAe,CAAC;AAAA,IAChD,CAAC;AAED,SAAK,gBAAgB,IAAI,8CAAuB,EAAE,OAAO,QAAQ,UAAU,CAAC;AAC5E,SAAK,gBAAgB,IAAI,oDAA0B,EAAE,UAAU,mBAAmB,CAAC;AAAA,EACrF;AAAA,EAEA,MAAgB,gBAAgB,IAAY,SAAqD;AAC/F,WAAO,KAAK,cAAc,UAAU,IAAI,OAAO;AAAA,EACjD;AAAA,EAEA,MAAgB,cAAc,IAAY,UAAoD;AAE5F,WAAO,KAAK,cAAc,QAAQ,EAAE;AAAA,EACtC;AAAA,EAEA,MAAgB,oBACd,IACA,SAC4B;AAC5B,WAAO,KAAK,cAAc,cAAc,IAAI,OAAO;AAAA,EACrD;AAAA,EAEA,MAAgB,uBACd,IACA,SAC+B;AAC/B,WAAO,KAAK,cAAc,iBAAiB,IAAI,OAAO;AAAA,EACxD;AAAA,EAEA,MAAgB,gCACd,IACA,SACA,QACwC;AACxC,WAAO,KAAK,cAAc,0BAA0B,IAAI,QAAQ,OAAO;AAAA,EACzE;AAAA,EAEA,MAAgB,2BACd,IACA,SACA,QACmC;AACnC,WAAO,KAAK,cAAc,qBAAqB,IAAI,SAAS,EAAE,OAAO,CAAC;AAAA,EACxE;AAAA,EAEA,MAAgB,eAAe,IAAY,UAAqD;AAE9F,WAAO,KAAK,cAAc,SAAS,EAAE;AAAA,EACvC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/api/makeswift-api-resources-client.ts"],"sourcesContent":["import { type State as ApiClientState } from '../state/api-client/state'\nimport { configureClientStore } from '../state/api-client/client-store'\n\nimport {\n type File,\n type GlobalElement,\n type LocalizedGlobalElement,\n type PagePathnameSlice,\n type Swatch,\n type Table,\n type Typography,\n type HttpFetch,\n} from './types'\n\nimport { ApiResourcesClient } from './api-resources-client'\nimport { type SiteVersion } from './site-version'\n\n// see the comment in `MakeswiftApiResourcesClient` constructor below\nimport { type MakeswiftGraphQLApiClient } from './graphql-api-client'\nimport { type MakeswiftRestAPIClient } from './rest-api-client'\n\n/**\n * Server-side implementation that makes direct authenticated requests to the Makeswift API.\n * Requires an API key.\n *\n * For client-side usage, see `HostApiResourcesClient`, which goes through the host via\n * `/api/makeswift/...` endpoints.\n */\nexport class MakeswiftApiResourcesClient extends ApiResourcesClient {\n private restApiClient: Promise<MakeswiftRestAPIClient>\n private graphQlClient: Promise<MakeswiftGraphQLApiClient>\n\n constructor({\n fetch,\n apiKey,\n apiOrigin,\n graphqlApiEndpoint,\n preloadedState,\n }: {\n fetch: HttpFetch\n apiKey: string\n apiOrigin: string\n graphqlApiEndpoint: string\n preloadedState: Partial<ApiClientState>\n }) {\n super({\n store: configureClientStore({ preloadedState }),\n })\n\n // `MakeswiftApiResourcesClient` is used by the runtime and therefore will be imported\n // on the client; lazy import server-side REST/GraphQL clients to avoid unnecessarily\n // pulling their code into a client bundle.\n //\n // (we can't easily lazy-load `MakeswiftApiResourcesClient` itself, at it will make its\n // construction async, but because it shares most of its implementation with\n // `HostApiResourcesClient`, the overhead of this module on its own is negligible)\n this.restApiClient = (async () => {\n const { MakeswiftRestAPIClient } = await import('./rest-api-client')\n return new MakeswiftRestAPIClient({ fetch, apiKey, apiOrigin })\n })()\n\n this.graphQlClient = (async () => {\n const { MakeswiftGraphQLApiClient } = await import('./graphql-api-client')\n return new MakeswiftGraphQLApiClient({ endpoint: graphqlApiEndpoint })\n })()\n }\n\n protected async fetchSwatchImpl(id: string, version: SiteVersion | null): Promise<Swatch | null> {\n return (await this.restApiClient).getSwatch(id, version)\n }\n\n protected async fetchFileImpl(id: string, _version: SiteVersion | null): Promise<File | null> {\n // files are unversioned\n return (await this.graphQlClient).getFile(id)\n }\n\n protected async fetchTypographyImpl(\n id: string,\n version: SiteVersion | null,\n ): Promise<Typography | null> {\n return (await this.restApiClient).getTypography(id, version)\n }\n\n protected async fetchGlobalElementImpl(\n id: string,\n version: SiteVersion | null,\n ): Promise<GlobalElement | null> {\n return (await this.restApiClient).getGlobalElement(id, version)\n }\n\n protected async fetchLocalizedGlobalElementImpl(\n id: string,\n version: SiteVersion | null,\n locale: string,\n ): Promise<LocalizedGlobalElement | null> {\n return (await this.restApiClient).getLocalizedGlobalElement(id, locale, version)\n }\n\n protected async fetchPagePathnameSliceImpl(\n id: string,\n version: SiteVersion | null,\n locale: string | null | undefined,\n ): Promise<PagePathnameSlice | null> {\n return (await this.restApiClient).getPagePathnameSlice(id, version, { locale })\n }\n\n protected async fetchTableImpl(id: string, _version: SiteVersion | null): Promise<Table | null> {\n // tables are unversioned\n return (await this.graphQlClient).getTable(id)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAqC;AAarC,kCAAmC;AAc5B,MAAM,oCAAoC,+CAAmB;AAAA,EAC1D;AAAA,EACA;AAAA,EAER,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAMG;AACD,UAAM;AAAA,MACJ,WAAO,0CAAqB,EAAE,eAAe,CAAC;AAAA,IAChD,CAAC;AASD,SAAK,iBAAiB,YAAY;AAChC,YAAM,EAAE,uBAAuB,IAAI,MAAM,6CAAO,mBAAmB;AACnE,aAAO,IAAI,uBAAuB,EAAE,OAAO,QAAQ,UAAU,CAAC;AAAA,IAChE,GAAG;AAEH,SAAK,iBAAiB,YAAY;AAChC,YAAM,EAAE,0BAA0B,IAAI,MAAM,6CAAO,sBAAsB;AACzE,aAAO,IAAI,0BAA0B,EAAE,UAAU,mBAAmB,CAAC;AAAA,IACvE,GAAG;AAAA,EACL;AAAA,EAEA,MAAgB,gBAAgB,IAAY,SAAqD;AAC/F,YAAQ,MAAM,KAAK,eAAe,UAAU,IAAI,OAAO;AAAA,EACzD;AAAA,EAEA,MAAgB,cAAc,IAAY,UAAoD;AAE5F,YAAQ,MAAM,KAAK,eAAe,QAAQ,EAAE;AAAA,EAC9C;AAAA,EAEA,MAAgB,oBACd,IACA,SAC4B;AAC5B,YAAQ,MAAM,KAAK,eAAe,cAAc,IAAI,OAAO;AAAA,EAC7D;AAAA,EAEA,MAAgB,uBACd,IACA,SAC+B;AAC/B,YAAQ,MAAM,KAAK,eAAe,iBAAiB,IAAI,OAAO;AAAA,EAChE;AAAA,EAEA,MAAgB,gCACd,IACA,SACA,QACwC;AACxC,YAAQ,MAAM,KAAK,eAAe,0BAA0B,IAAI,QAAQ,OAAO;AAAA,EACjF;AAAA,EAEA,MAAgB,2BACd,IACA,SACA,QACmC;AACnC,YAAQ,MAAM,KAAK,eAAe,qBAAqB,IAAI,SAAS,EAAE,OAAO,CAAC;AAAA,EAChF;AAAA,EAEA,MAAgB,eAAe,IAAY,UAAqD;AAE9F,YAAQ,MAAM,KAAK,eAAe,SAAS,EAAE;AAAA,EAC/C;AACF;","names":[]}
@@ -147,7 +147,7 @@ class MakeswiftRestAPIClient {
147
147
  const requestHeaders = new Headers({
148
148
  "x-api-key": this.apiKey,
149
149
  "makeswift-site-api-key": this.apiKey,
150
- "makeswift-runtime-version": "0.28.8-canary.0"
150
+ "makeswift-runtime-version": "0.28.8-canary.2"
151
151
  });
152
152
  if (siteVersion?.token) {
153
153
  requestUrl.searchParams.set("version", siteVersion.version);
@@ -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.8-canary.0",
31
+ version: "0.28.8-canary.2",
32
32
  interactionMode: true,
33
33
  clientSideNavigation: false,
34
34
  elementFromPoint: false,
@@ -689,7 +689,7 @@ Received "${apiKey}" instead.`
689
689
  headers: {
690
690
  "x-api-key": this.apiKey,
691
691
  "makeswift-site-api-key": this.apiKey,
692
- "makeswift-runtime-version": "0.28.8-canary.0",
692
+ "makeswift-runtime-version": "0.28.8-canary.2",
693
693
  "content-type": "application/json"
694
694
  },
695
695
  body: JSON.stringify({ token }),
@@ -21,12 +21,10 @@ __export(app_router_exports, {
21
21
  context: () => context
22
22
  });
23
23
  module.exports = __toCommonJS(app_router_exports);
24
- var import_framework_context = require("../../../../runtimes/react/components/framework-context");
25
24
  var import_HeadSnippet = require("./HeadSnippet");
26
25
  const context = {
27
26
  // The App Router uses built-in React Canary releases, which include all stable
28
27
  // React 19 features, so we can simply use our default head implementation
29
- Head: import_framework_context.DefaultHead,
30
28
  HeadSnippet: import_HeadSnippet.HeadSnippet
31
29
  };
32
30
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/next/components/framework-provider/app-router/index.ts"],"sourcesContent":["import {\n type FrameworkContext,\n DefaultHead,\n} from '../../../../runtimes/react/components/framework-context'\n\nimport { HeadSnippet } from './HeadSnippet'\n\nexport const context: Pick<FrameworkContext, 'Head' | 'HeadSnippet'> = {\n // The App Router uses built-in React Canary releases, which include all stable\n // React 19 features, so we can simply use our default head implementation\n Head: DefaultHead,\n HeadSnippet,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAGO;AAEP,yBAA4B;AAErB,MAAM,UAA0D;AAAA;AAAA;AAAA,EAGrE,MAAM;AAAA,EACN;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../../../src/next/components/framework-provider/app-router/index.ts"],"sourcesContent":["import { type FrameworkContext } from '../../../../runtimes/react/components/framework-context'\n\nimport { HeadSnippet } from './HeadSnippet'\n\nexport const context: Pick<FrameworkContext, 'HeadSnippet'> = {\n // The App Router uses built-in React Canary releases, which include all stable\n // React 19 features, so we can simply use our default head implementation\n HeadSnippet,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAA4B;AAErB,MAAM,UAAiD;AAAA;AAAA;AAAA,EAG5D;AACF;","names":[]}
@@ -53,7 +53,7 @@ function FrameworkProvider({
53
53
  }),
54
54
  [isPagesRouter]
55
55
  );
56
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framework_context.FrameworkContext.Provider, { value: context, children });
56
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framework_context.FrameworkContextProvider, { value: context, children });
57
57
  }
58
58
  // Annotate the CommonJS export names for ESM import in node:
59
59
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/next/components/framework-provider/index.tsx"],"sourcesContent":["'use client'\n\nimport { type PropsWithChildren, useMemo } from 'react'\nimport NextImage from 'next/image'\n\nimport { useIsPagesRouter } from '../../hooks/use-is-pages-router'\nimport { FrameworkContext } from '../../../runtimes/react/components/framework-context'\n\nimport { context as appRouterContext } from './app-router'\nimport { context as pagesRouterContext } from './pages-router'\nimport { Link } from './link'\n\nexport function FrameworkProvider({\n children,\n forcePagesRouter,\n}: PropsWithChildren<{ forcePagesRouter?: boolean }>) {\n const isPagesRouter = useIsPagesRouter() || forcePagesRouter\n const context = useMemo<FrameworkContext>(\n () => ({\n ...(isPagesRouter ? pagesRouterContext : appRouterContext),\n Image: NextImage,\n Link,\n }),\n [isPagesRouter],\n )\n\n return <FrameworkContext.Provider value={context}>{children}</FrameworkContext.Provider>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BS;AAxBT,mBAAgD;AAChD,mBAAsB;AAEtB,iCAAiC;AACjC,+BAAiC;AAEjC,wBAA4C;AAC5C,0BAA8C;AAC9C,kBAAqB;AAEd,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAAsD;AACpD,QAAM,oBAAgB,6CAAiB,KAAK;AAC5C,QAAM,cAAU;AAAA,IACd,OAAO;AAAA,MACL,GAAI,gBAAgB,oBAAAA,UAAqB,kBAAAC;AAAA,MACzC,OAAO,aAAAC;AAAA,MACP;AAAA,IACF;AAAA,IACA,CAAC,aAAa;AAAA,EAChB;AAEA,SAAO,4CAAC,0CAAiB,UAAjB,EAA0B,OAAO,SAAU,UAAS;AAC9D;","names":["pagesRouterContext","appRouterContext","NextImage"]}
1
+ {"version":3,"sources":["../../../../../src/next/components/framework-provider/index.tsx"],"sourcesContent":["'use client'\n\nimport { type PropsWithChildren, useMemo } from 'react'\nimport NextImage from 'next/image'\n\nimport { useIsPagesRouter } from '../../hooks/use-is-pages-router'\nimport {\n type FrameworkContext,\n FrameworkContextProvider,\n} from '../../../runtimes/react/components/framework-context'\n\nimport { context as appRouterContext } from './app-router'\nimport { context as pagesRouterContext } from './pages-router'\nimport { Link } from './link'\n\nexport function FrameworkProvider({\n children,\n forcePagesRouter,\n}: PropsWithChildren<{ forcePagesRouter?: boolean }>) {\n const isPagesRouter = useIsPagesRouter() || forcePagesRouter\n const context = useMemo<Partial<FrameworkContext>>(\n () => ({\n ...(isPagesRouter ? pagesRouterContext : appRouterContext),\n Image: NextImage,\n Link,\n }),\n [isPagesRouter],\n )\n\n return <FrameworkContextProvider value={context}>{children}</FrameworkContextProvider>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BS;AA3BT,mBAAgD;AAChD,mBAAsB;AAEtB,iCAAiC;AACjC,+BAGO;AAEP,wBAA4C;AAC5C,0BAA8C;AAC9C,kBAAqB;AAEd,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAAsD;AACpD,QAAM,oBAAgB,6CAAiB,KAAK;AAC5C,QAAM,cAAU;AAAA,IACd,OAAO;AAAA,MACL,GAAI,gBAAgB,oBAAAA,UAAqB,kBAAAC;AAAA,MACzC,OAAO,aAAAC;AAAA,MACP;AAAA,IACF;AAAA,IACA,CAAC,aAAa;AAAA,EAChB;AAEA,SAAO,4CAAC,qDAAyB,OAAO,SAAU,UAAS;AAC7D;","names":["pagesRouterContext","appRouterContext","NextImage"]}
@@ -28,7 +28,7 @@ var import_use_builtin_suspense = require("../hooks/use-builtin-suspense");
28
28
  var import_use_component = require("../hooks/use-component");
29
29
  var import_can_accept_ref = require("../utils/can-accept-ref");
30
30
  var import_FallbackComponent = require("../../../components/shared/FallbackComponent");
31
- var import_controls = require("../controls");
31
+ var import_resolve_props = require("./resolve-props");
32
32
  var import_activity_with_fallback = require("./activity-with-fallback");
33
33
  const ElementData = (0, import_react2.memo)(
34
34
  (0, import_react2.forwardRef)(function ElementData2({ elementData }, ref) {
@@ -39,7 +39,7 @@ const ElementData = (0, import_react2.memo)(
39
39
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_FallbackComponent.FallbackComponent, { ref, text: "Component not found" });
40
40
  }
41
41
  const forwardRef2 = (0, import_can_accept_ref.canAcceptRef)(Component);
42
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_activity_with_fallback.ActivityOrFallback, { suspenseFallback: builtinSuspense, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_controls.ResolveProps, { element: elementData, children: (props) => forwardRef2 ? /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key, ref }) : /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key }) }) });
42
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_activity_with_fallback.ActivityOrFallback, { suspenseFallback: builtinSuspense, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_resolve_props.ResolveProps, { element: elementData, children: (props) => forwardRef2 ? /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key, ref }) : /* @__PURE__ */ (0, import_react.createElement)(Component, { ...props, key: elementData.key }) }) });
43
43
  })
44
44
  );
45
45
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"sourcesContent":["import { Ref, forwardRef, memo, ReactNode } from 'react'\n\nimport { ElementData as ReactPageElementData } from '../../../state/read-only-state'\nimport { useBuiltinSuspense } from '../hooks/use-builtin-suspense'\nimport { useComponent } from '../hooks/use-component'\nimport { canAcceptRef } from '../utils/can-accept-ref'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { ResolveProps } from '../controls'\nimport { ActivityOrFallback } from './activity-with-fallback'\n\ntype ElementDataProps = {\n elementData: ReactPageElementData\n}\n\nexport const ElementData = memo(\n forwardRef(function ElementData({ elementData }: ElementDataProps, ref: Ref<unknown>): ReactNode {\n const Component = useComponent(elementData.type)\n const builtinSuspense = useBuiltinSuspense(elementData.type)\n\n if (Component == null) {\n console.warn(`Unknown component '${elementData.type}'`, { elementData })\n return <FallbackComponent ref={ref as Ref<HTMLDivElement>} text=\"Component not found\" />\n }\n\n const forwardRef = canAcceptRef(Component)\n\n return (\n <ActivityOrFallback suspenseFallback={builtinSuspense}>\n <ResolveProps element={elementData}>\n {props =>\n forwardRef ? (\n <Component {...props} key={elementData.key} ref={ref} />\n ) : (\n <Component {...props} key={elementData.key} />\n )\n }\n </ResolveProps>\n </ActivityOrFallback>\n )\n }),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBa;AAUC;AA/Bd,IAAAA,gBAAiD;AAGjD,kCAAmC;AACnC,2BAA6B;AAC7B,4BAA6B;AAC7B,+BAAkC;AAClC,sBAA6B;AAC7B,oCAAmC;AAM5B,MAAM,kBAAc;AAAA,MACzB,0BAAW,SAASC,aAAY,EAAE,YAAY,GAAqB,KAA8B;AAC/F,UAAM,gBAAY,mCAAa,YAAY,IAAI;AAC/C,UAAM,sBAAkB,gDAAmB,YAAY,IAAI;AAE3D,QAAI,aAAa,MAAM;AACrB,cAAQ,KAAK,sBAAsB,YAAY,IAAI,KAAK,EAAE,YAAY,CAAC;AACvE,aAAO,4CAAC,8CAAkB,KAAiC,MAAK,uBAAsB;AAAA,IACxF;AAEA,UAAMC,kBAAa,oCAAa,SAAS;AAEzC,WACE,4CAAC,oDAAmB,kBAAkB,iBACpC,sDAAC,gCAAa,SAAS,aACpB,qBACCA,cACE,gDAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,KAAU,IAEtD,gDAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,GAGlD,GACF;AAAA,EAEJ,CAAC;AACH;","names":["import_react","ElementData","forwardRef"]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/ElementData.tsx"],"sourcesContent":["import { Ref, forwardRef, memo, ReactNode } from 'react'\n\nimport { ElementData as ReactPageElementData } from '../../../state/read-only-state'\nimport { useBuiltinSuspense } from '../hooks/use-builtin-suspense'\nimport { useComponent } from '../hooks/use-component'\nimport { canAcceptRef } from '../utils/can-accept-ref'\nimport { FallbackComponent } from '../../../components/shared/FallbackComponent'\nimport { ResolveProps } from './resolve-props'\nimport { ActivityOrFallback } from './activity-with-fallback'\n\ntype ElementDataProps = {\n elementData: ReactPageElementData\n}\n\nexport const ElementData = memo(\n forwardRef(function ElementData({ elementData }: ElementDataProps, ref: Ref<unknown>): ReactNode {\n const Component = useComponent(elementData.type)\n const builtinSuspense = useBuiltinSuspense(elementData.type)\n\n if (Component == null) {\n console.warn(`Unknown component '${elementData.type}'`, { elementData })\n return <FallbackComponent ref={ref as Ref<HTMLDivElement>} text=\"Component not found\" />\n }\n\n const forwardRef = canAcceptRef(Component)\n\n return (\n <ActivityOrFallback suspenseFallback={builtinSuspense}>\n <ResolveProps element={elementData}>\n {props =>\n forwardRef ? (\n <Component {...props} key={elementData.key} ref={ref} />\n ) : (\n <Component {...props} key={elementData.key} />\n )\n }\n </ResolveProps>\n </ActivityOrFallback>\n )\n }),\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBa;AAUC;AA/Bd,IAAAA,gBAAiD;AAGjD,kCAAmC;AACnC,2BAA6B;AAC7B,4BAA6B;AAC7B,+BAAkC;AAClC,2BAA6B;AAC7B,oCAAmC;AAM5B,MAAM,kBAAc;AAAA,MACzB,0BAAW,SAASC,aAAY,EAAE,YAAY,GAAqB,KAA8B;AAC/F,UAAM,gBAAY,mCAAa,YAAY,IAAI;AAC/C,UAAM,sBAAkB,gDAAmB,YAAY,IAAI;AAE3D,QAAI,aAAa,MAAM;AACrB,cAAQ,KAAK,sBAAsB,YAAY,IAAI,KAAK,EAAE,YAAY,CAAC;AACvE,aAAO,4CAAC,8CAAkB,KAAiC,MAAK,uBAAsB;AAAA,IACxF;AAEA,UAAMC,kBAAa,oCAAa,SAAS;AAEzC,WACE,4CAAC,oDAAmB,kBAAkB,iBACpC,sDAAC,qCAAa,SAAS,aACpB,qBACCA,cACE,gDAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,KAAU,IAEtD,gDAAC,aAAW,GAAG,OAAO,KAAK,YAAY,KAAK,GAGlD,GACF;AAAA,EAEJ,CAAC;AACH;","names":["import_react","ElementData","forwardRef"]}
@@ -18,11 +18,8 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var framework_context_exports = {};
20
20
  __export(framework_context_exports, {
21
- DefaultHead: () => DefaultHead,
22
- DefaultHeadSnippet: () => DefaultHeadSnippet,
23
- DefaultImage: () => DefaultImage,
24
- DefaultLink: () => DefaultLink,
25
- FrameworkContext: () => FrameworkContext
21
+ FrameworkContextProvider: () => FrameworkContextProvider,
22
+ useFrameworkContext: () => useFrameworkContext
26
23
  });
27
24
  module.exports = __toCommonJS(framework_context_exports);
28
25
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -48,18 +45,27 @@ const DefaultImage = ({ priority, fill, style, ...props }) => /* @__PURE__ */ (0
48
45
  const DefaultLink = (0, import_react.forwardRef)(
49
46
  ({ linkType, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { ...props, ref })
50
47
  );
51
- const FrameworkContext = (0, import_react.createContext)({
48
+ const FrameworkContext = (0, import_react.createContext)({});
49
+ const FrameworkContextProvider = ({
50
+ value,
51
+ children
52
+ }) => {
53
+ const parentContext = (0, import_react.useContext)(FrameworkContext);
54
+ const mergedContext = (0, import_react.useMemo)(() => ({ ...parentContext, ...value }), [parentContext, value]);
55
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FrameworkContext.Provider, { value: mergedContext, children });
56
+ };
57
+ const defaultContext = {
52
58
  Head: DefaultHead,
53
59
  HeadSnippet: DefaultHeadSnippet,
54
60
  Image: DefaultImage,
55
61
  Link: DefaultLink
56
- });
62
+ };
63
+ function useFrameworkContext() {
64
+ return { ...defaultContext, ...(0, import_react.useContext)(FrameworkContext) };
65
+ }
57
66
  // Annotate the CommonJS export names for ESM import in node:
58
67
  0 && (module.exports = {
59
- DefaultHead,
60
- DefaultHeadSnippet,
61
- DefaultImage,
62
- DefaultLink,
63
- FrameworkContext
68
+ FrameworkContextProvider,
69
+ useFrameworkContext
64
70
  });
65
71
  //# sourceMappingURL=framework-context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/runtimes/react/components/framework-context.tsx"],"sourcesContent":["import {\n createContext,\n type ReactNode,\n type PropsWithChildren,\n type CSSProperties,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n type ForwardRefExoticComponent,\n type RefAttributes,\n forwardRef,\n} from 'react'\n\nimport { type LinkData } from '@makeswift/prop-controllers'\n\nimport { type Snippet } from '../../../client'\n\nimport { BaseHeadSnippet } from './page/HeadSnippet'\n\ntype HeadComponent = (props: { children: ReactNode }) => ReactNode\ntype HeadSnippet = (props: { snippet: Snippet }) => ReactNode\ntype ImageComponent = (props: {\n src: string\n alt: string\n sizes?: string\n width?: number\n height?: number\n priority?: boolean\n fill?: boolean\n style?: CSSProperties\n}) => ReactNode\n\ntype LinkProps = Omit<ComponentPropsWithoutRef<'a'>, 'onClick'> & {\n linkType?: LinkData['type']\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => unknown\n}\n\ntype LinkComponent = ForwardRefExoticComponent<RefAttributes<HTMLAnchorElement> & LinkProps>\n\nexport type FrameworkContext = {\n Head: HeadComponent\n HeadSnippet: HeadSnippet\n Image: ImageComponent\n Link: LinkComponent\n}\n\n// React 19 automatically hoists metadata tags to the <head>\nexport const DefaultHead = ({ children }: PropsWithChildren) => <>{children}</>\n\nexport const DefaultHeadSnippet = BaseHeadSnippet\n\nexport const DefaultImage: ImageComponent = ({ priority, fill, style, ...props }) => (\n <img\n {...props}\n style={{\n ...(fill\n ? {\n height: '100%',\n width: '100%',\n objectFit: 'cover',\n }\n : {}),\n ...style,\n }}\n loading={priority ? 'eager' : 'lazy'}\n />\n)\n\nexport const DefaultLink: LinkComponent = forwardRef<HTMLAnchorElement, LinkProps>(\n ({ linkType, ...props }, ref) => <a {...props} ref={ref} />,\n)\n\nexport const FrameworkContext = createContext<FrameworkContext>({\n Head: DefaultHead,\n HeadSnippet: DefaultHeadSnippet,\n Image: DefaultImage,\n Link: DefaultLink,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA8CgE;AA9ChE,mBAUO;AAMP,yBAAgC;AA8BzB,MAAM,cAAc,CAAC,EAAE,SAAS,MAAyB,2EAAG,UAAS;AAErE,MAAM,qBAAqB;AAE3B,MAAM,eAA+B,CAAC,EAAE,UAAU,MAAM,OAAO,GAAG,MAAM,MAC7E;AAAA,EAAC;AAAA;AAAA,IACE,GAAG;AAAA,IACJ,OAAO;AAAA,MACL,GAAI,OACA;AAAA,QACE,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,WAAW;AAAA,MACb,IACA,CAAC;AAAA,MACL,GAAG;AAAA,IACL;AAAA,IACA,SAAS,WAAW,UAAU;AAAA;AAChC;AAGK,MAAM,kBAA6B;AAAA,EACxC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,4CAAC,OAAG,GAAG,OAAO,KAAU;AAC3D;AAEO,MAAM,uBAAmB,4BAAgC;AAAA,EAC9D,MAAM;AAAA,EACN,aAAa;AAAA,EACb,OAAO;AAAA,EACP,MAAM;AACR,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/framework-context.tsx"],"sourcesContent":["import {\n type ReactNode,\n type PropsWithChildren,\n type CSSProperties,\n type ComponentPropsWithoutRef,\n type MouseEvent,\n type ForwardRefExoticComponent,\n type RefAttributes,\n forwardRef,\n createContext,\n useContext,\n useMemo,\n} from 'react'\n\nimport { type LinkData } from '@makeswift/prop-controllers'\n\nimport { type Snippet } from '../../../client'\n\nimport { BaseHeadSnippet } from './page/HeadSnippet'\n\ntype HeadComponent = (props: { children: ReactNode }) => ReactNode\ntype HeadSnippet = (props: { snippet: Snippet }) => ReactNode\ntype ImageComponent = (props: {\n src: string\n alt: string\n sizes?: string\n width?: number\n height?: number\n priority?: boolean\n fill?: boolean\n style?: CSSProperties\n}) => ReactNode\n\ntype LinkProps = Omit<ComponentPropsWithoutRef<'a'>, 'onClick'> & {\n linkType?: LinkData['type']\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => unknown\n}\n\ntype LinkComponent = ForwardRefExoticComponent<RefAttributes<HTMLAnchorElement> & LinkProps>\n\nexport type FrameworkContext = {\n Head: HeadComponent\n HeadSnippet: HeadSnippet\n Image: ImageComponent\n Link: LinkComponent\n}\n\n// React 19 automatically hoists metadata tags to the <head>\nconst DefaultHead = ({ children }: PropsWithChildren) => <>{children}</>\n\nconst DefaultHeadSnippet = BaseHeadSnippet\n\nconst DefaultImage: ImageComponent = ({ priority, fill, style, ...props }) => (\n <img\n {...props}\n style={{\n ...(fill\n ? {\n height: '100%',\n width: '100%',\n objectFit: 'cover',\n }\n : {}),\n ...style,\n }}\n loading={priority ? 'eager' : 'lazy'}\n />\n)\n\nconst DefaultLink: LinkComponent = forwardRef<HTMLAnchorElement, LinkProps>(\n ({ linkType, ...props }, ref) => <a {...props} ref={ref} />,\n)\n\nconst FrameworkContext = createContext<Partial<FrameworkContext>>({})\n\nexport const FrameworkContextProvider = ({\n value,\n children,\n}: PropsWithChildren<{ value: Partial<FrameworkContext> }>) => {\n const parentContext = useContext(FrameworkContext)\n const mergedContext = useMemo(() => ({ ...parentContext, ...value }), [parentContext, value])\n\n return <FrameworkContext.Provider value={mergedContext}>{children}</FrameworkContext.Provider>\n}\n\nconst defaultContext: FrameworkContext = {\n Head: DefaultHead,\n HeadSnippet: DefaultHeadSnippet,\n Image: DefaultImage,\n Link: DefaultLink,\n}\n\nexport function useFrameworkContext(): FrameworkContext {\n return { ...defaultContext, ...useContext(FrameworkContext) }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgDyD;AAhDzD,mBAYO;AAMP,yBAAgC;AA8BhC,MAAM,cAAc,CAAC,EAAE,SAAS,MAAyB,2EAAG,UAAS;AAErE,MAAM,qBAAqB;AAE3B,MAAM,eAA+B,CAAC,EAAE,UAAU,MAAM,OAAO,GAAG,MAAM,MACtE;AAAA,EAAC;AAAA;AAAA,IACE,GAAG;AAAA,IACJ,OAAO;AAAA,MACL,GAAI,OACA;AAAA,QACE,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,WAAW;AAAA,MACb,IACA,CAAC;AAAA,MACL,GAAG;AAAA,IACL;AAAA,IACA,SAAS,WAAW,UAAU;AAAA;AAChC;AAGF,MAAM,kBAA6B;AAAA,EACjC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,4CAAC,OAAG,GAAG,OAAO,KAAU;AAC3D;AAEA,MAAM,uBAAmB,4BAAyC,CAAC,CAAC;AAE7D,MAAM,2BAA2B,CAAC;AAAA,EACvC;AAAA,EACA;AACF,MAA+D;AAC7D,QAAM,oBAAgB,yBAAW,gBAAgB;AACjD,QAAM,oBAAgB,sBAAQ,OAAO,EAAE,GAAG,eAAe,GAAG,MAAM,IAAI,CAAC,eAAe,KAAK,CAAC;AAE5F,SAAO,4CAAC,iBAAiB,UAAjB,EAA0B,OAAO,eAAgB,UAAS;AACpE;AAEA,MAAM,iBAAmC;AAAA,EACvC,MAAM;AAAA,EACN,aAAa;AAAA,EACb,OAAO;AAAA,EACP,MAAM;AACR;AAEO,SAAS,sBAAwC;AACtD,SAAO,EAAE,GAAG,gBAAgB,OAAG,yBAAW,gBAAgB,EAAE;AAC9D;","names":[]}
@@ -18,14 +18,10 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var use_framework_context_exports = {};
20
20
  __export(use_framework_context_exports, {
21
- useFrameworkContext: () => useFrameworkContext
21
+ useFrameworkContext: () => import_framework_context.useFrameworkContext
22
22
  });
23
23
  module.exports = __toCommonJS(use_framework_context_exports);
24
- var import_react = require("react");
25
24
  var import_framework_context = require("../framework-context");
26
- function useFrameworkContext() {
27
- return (0, import_react.useContext)(import_framework_context.FrameworkContext);
28
- }
29
25
  // Annotate the CommonJS export names for ESM import in node:
30
26
  0 && (module.exports = {
31
27
  useFrameworkContext
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../src/runtimes/react/components/hooks/use-framework-context.tsx"],"sourcesContent":["import { useContext } from 'react'\n\nimport { FrameworkContext } from '../framework-context'\n\nexport function useFrameworkContext() {\n return useContext(FrameworkContext)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAE3B,+BAAiC;AAE1B,SAAS,sBAAsB;AACpC,aAAO,yBAAW,yCAAgB;AACpC;","names":[]}
1
+ {"version":3,"sources":["../../../../../../src/runtimes/react/components/hooks/use-framework-context.tsx"],"sourcesContent":["export { useFrameworkContext } from '../framework-context'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAoC;","names":[]}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var resolve_props_exports = {};
20
+ __export(resolve_props_exports, {
21
+ ResolveProps: () => ResolveProps
22
+ });
23
+ module.exports = __toCommonJS(resolve_props_exports);
24
+ var import_use_control_defs = require("../hooks/use-control-defs");
25
+ var import_use_resolved_props = require("../hooks/use-resolved-props");
26
+ var import_legacy_controls = require("../legacy-controls");
27
+ function ResolveProps({
28
+ element,
29
+ children: renderComponent
30
+ }) {
31
+ const [legacyDescriptors, definitions] = (0, import_use_control_defs.useControlDefs)({ elementType: element.type });
32
+ const resolvedProps = (0, import_use_resolved_props.useResolvedProps)(definitions, element.props, element.key);
33
+ const renderFn = Object.entries(legacyDescriptors).reduceRight(
34
+ (renderFn2, [propName, descriptor]) => (props) => (0, import_legacy_controls.resolveLegacyDescriptorProp)(descriptor, propName, element.props[propName], props, renderFn2),
35
+ renderComponent
36
+ );
37
+ return renderFn(resolvedProps);
38
+ }
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ ResolveProps
42
+ });
43
+ //# sourceMappingURL=resolve-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/components/resolve-props.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { type ElementData } from '../../../state/read-only-state'\n\nimport { useControlDefs } from '../hooks/use-control-defs'\nimport { useResolvedProps } from '../hooks/use-resolved-props'\n\nimport { resolveLegacyDescriptorProp } from '../legacy-controls'\n\nexport function ResolveProps({\n element,\n children: renderComponent,\n}: {\n element: ElementData\n children: (props: Record<string, unknown>) => ReactNode\n}): ReactNode {\n const [legacyDescriptors, definitions] = useControlDefs({ elementType: element.type })\n\n const resolvedProps = useResolvedProps(definitions, element.props, element.key)\n\n const renderFn = Object.entries(legacyDescriptors).reduceRight(\n (renderFn, [propName, descriptor]) =>\n props =>\n resolveLegacyDescriptorProp(descriptor, propName, element.props[propName], props, renderFn),\n renderComponent,\n )\n\n return renderFn(resolvedProps)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,8BAA+B;AAC/B,gCAAiC;AAEjC,6BAA4C;AAErC,SAAS,aAAa;AAAA,EAC3B;AAAA,EACA,UAAU;AACZ,GAGc;AACZ,QAAM,CAAC,mBAAmB,WAAW,QAAI,wCAAe,EAAE,aAAa,QAAQ,KAAK,CAAC;AAErF,QAAM,oBAAgB,4CAAiB,aAAa,QAAQ,OAAO,QAAQ,GAAG;AAE9E,QAAM,WAAW,OAAO,QAAQ,iBAAiB,EAAE;AAAA,IACjD,CAACA,WAAU,CAAC,UAAU,UAAU,MAC9B,eACE,oDAA4B,YAAY,UAAU,QAAQ,MAAM,QAAQ,GAAG,OAAOA,SAAQ;AAAA,IAC9F;AAAA,EACF;AAEA,SAAO,SAAS,aAAa;AAC/B;","names":["renderFn"]}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var use_control_defs_exports = {};
20
+ __export(use_control_defs_exports, {
21
+ useControlDefs: () => useControlDefs
22
+ });
23
+ module.exports = __toCommonJS(use_control_defs_exports);
24
+ var import_react = require("react");
25
+ var import_partition = require("../../../utils/partition");
26
+ var import_read_only_state = require("../../../state/read-only-state");
27
+ var import_descriptors = require("../../../prop-controllers/descriptors");
28
+ var import_use_store = require("./use-store");
29
+ function useControlDefs({
30
+ elementType
31
+ }) {
32
+ const store = (0, import_use_store.useStore)();
33
+ const all = (0, import_read_only_state.getComponentPropControllerDescriptors)(store.getState(), elementType) ?? {};
34
+ return (0, import_react.useRef)((0, import_partition.partitionRecord)(all, import_descriptors.isLegacyDescriptor)).current;
35
+ }
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ useControlDefs
39
+ });
40
+ //# sourceMappingURL=use-control-defs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-control-defs.ts"],"sourcesContent":["import { useRef } from 'react'\n\nimport { ControlDefinition } from '@makeswift/controls'\n\nimport { partitionRecord } from '../../../utils/partition'\n\nimport { getComponentPropControllerDescriptors } from '../../../state/read-only-state'\nimport { type LegacyDescriptor, isLegacyDescriptor } from '../../../prop-controllers/descriptors'\n\nimport { useStore } from './use-store'\n\nexport function useControlDefs({\n elementType,\n}: {\n elementType: string\n}): readonly [Record<string, LegacyDescriptor>, Record<string, ControlDefinition>] {\n const store = useStore()\n const all = getComponentPropControllerDescriptors(store.getState(), elementType) ?? {}\n return useRef(partitionRecord(all, isLegacyDescriptor)).current\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuB;AAIvB,uBAAgC;AAEhC,6BAAsD;AACtD,yBAA0D;AAE1D,uBAAyB;AAElB,SAAS,eAAe;AAAA,EAC7B;AACF,GAEmF;AACjF,QAAM,YAAQ,2BAAS;AACvB,QAAM,UAAM,8DAAsC,MAAM,SAAS,GAAG,WAAW,KAAK,CAAC;AACrF,aAAO,yBAAO,kCAAgB,KAAK,qCAAkB,CAAC,EAAE;AAC1D;","names":[]}
@@ -22,6 +22,7 @@ __export(runtime_core_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(runtime_core_exports);
24
24
  var import_host_api_resources_client = require("../../api/host-api-resources-client");
25
+ var import_makeswift_api_resources_client = require("../../api/makeswift-api-resources-client");
25
26
  var import_breakpoints = require("../../state/modules/breakpoints");
26
27
  var import_copy_element_tree = require("../../state/ops/copy-element-tree");
27
28
  var import_read_only_state = require("../../state/read-only-state");
@@ -41,6 +42,7 @@ class RuntimeCore {
41
42
  // requested site version, which should be the only site version for which the store is requested
42
43
  ttlCheck: import_ref_counted_map.RefCountedMap.TTLCheck.ON_RETAIN | import_ref_counted_map.RefCountedMap.TTLCheck.ON_RELEASE
43
44
  });
45
+ apiKey;
44
46
  protoStore;
45
47
  appOrigin;
46
48
  apiOrigin;
@@ -49,12 +51,14 @@ class RuntimeCore {
49
51
  constructor({
50
52
  appOrigin = "https://app.makeswift.com",
51
53
  apiOrigin = "https://api.makeswift.com",
54
+ apiKey,
52
55
  breakpoints,
53
56
  requestKey,
54
57
  fetch
55
58
  }) {
56
59
  this.appOrigin = validateOrigin(appOrigin, "appOrigin");
57
60
  this.apiOrigin = validateOrigin(apiOrigin, "apiOrigin");
61
+ this.apiKey = apiKey;
58
62
  this.requestKey = requestKey;
59
63
  this.fetch = fetch;
60
64
  this.protoStore = (0, import_store.configureProtoStore)({
@@ -107,6 +111,15 @@ class RuntimeCore {
107
111
  return new URL("graphql", this.apiOrigin).href;
108
112
  }
109
113
  createApiResourcesClient(preloadedState) {
114
+ if ((0, import_is_server.isServer)() && this.apiKey) {
115
+ return new import_makeswift_api_resources_client.MakeswiftApiResourcesClient({
116
+ fetch: this.fetch,
117
+ apiKey: this.apiKey,
118
+ apiOrigin: this.apiOrigin,
119
+ graphqlApiEndpoint: this.graphqlApiEndpoint,
120
+ preloadedState
121
+ });
122
+ }
110
123
  return new import_host_api_resources_client.HostApiResourcesClient({
111
124
  fetch: this.fetch,
112
125
  preloadedState
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/runtimes/react/runtime-core.ts"],"sourcesContent":["import { type SerializableReplacementContext } from '@makeswift/controls'\n\nimport { HostApiResourcesClient } from '../../api/host-api-resources-client'\nimport { type HttpFetch } from '../../api/types'\nimport { type SiteVersion } from '../../api/site-version'\n\nimport {\n Breakpoints,\n BreakpointsInput,\n parseBreakpointsInput,\n} from '../../state/modules/breakpoints'\n\nimport { copyElementTree } from '../../state/ops/copy-element-tree'\n\nimport { getBreakpoints, type Element, type ElementData } from '../../state/read-only-state'\nimport {\n configureProtoStore,\n configureReadWriteStore,\n type ProtoStore,\n type Store,\n} from '../../state/store'\n\nimport { RefCountedMap } from '../../utils/ref-counted-map'\nimport { isServer } from '../../utils/is-server'\n\nexport type StoreKey = {\n siteVersion: SiteVersion | null\n locale: string | undefined\n}\n\nconst VERSION_TAG_LIVE = 'ref:live'\n\nexport class RuntimeCore {\n // The unowned entry TTL affects performance, not correctness. The TTL controls how long an unretained store stays\n // in the map. If an entry expires and is removed from the map before React commits, the store remains retained\n // via `<StoreContext.Provider>`. The only impact is that future lookups will create a new store instance instead of\n // reusing the existing one, reducing cache efficiency.\n private readonly activeStores = new RefCountedMap<string | null, Store>({\n unownedEntryTtlMs: 1000,\n // Checking on retain/release is sufficient on the client, and we don't need to check on get on the server\n // as the only scenario in which we add the store to the map is when the runtime is already bound to the\n // requested site version, which should be the only site version for which the store is requested\n ttlCheck: RefCountedMap.TTLCheck.ON_RETAIN | RefCountedMap.TTLCheck.ON_RELEASE,\n })\n\n readonly protoStore: ProtoStore\n readonly appOrigin: string\n readonly apiOrigin: string\n readonly requestKey: StoreKey | undefined\n readonly fetch: HttpFetch\n\n constructor({\n appOrigin = 'https://app.makeswift.com',\n apiOrigin = 'https://api.makeswift.com',\n breakpoints,\n requestKey,\n fetch,\n }: {\n appOrigin?: string\n apiOrigin?: string\n breakpoints?: BreakpointsInput\n requestKey?: StoreKey\n fetch: HttpFetch\n }) {\n this.appOrigin = validateOrigin(appOrigin, 'appOrigin')\n this.apiOrigin = validateOrigin(apiOrigin, 'apiOrigin')\n this.requestKey = requestKey\n this.fetch = fetch\n\n this.protoStore = configureProtoStore({\n name: 'Runtime proto-store',\n breakpoints: breakpoints ? parseBreakpointsInput(breakpoints) : undefined,\n })\n }\n\n getOrCreateStore({ siteVersion, locale }: StoreKey): Store {\n const key = storeCacheKey({ siteVersion, locale })\n\n const createStore = () => {\n // API resources client includes an in-memory cache of the site's resources and thus also has to be versioned\n const apiResourcesClient = this.createApiResourcesClient({ siteVersion, locale })\n\n // TODO: we need to decouple editability from the site version; specifically, previewing\n // a draft version of the site should not lead to switching to the read-write state\n const isReadOnly = siteVersion == null\n\n return configureReadWriteStore({\n name: `Runtime read-write store (site version: ${key})`,\n appOrigin: this.appOrigin,\n apiResourcesClient,\n preloadedState: { ...this.protoStore.getState(), siteVersion, isReadOnly, locale },\n })\n }\n\n // On the server, stores are ephemeral by default so SSR does not retain them in a long-lived runtime.\n // The exception is a runtime that is already bound to the requested site version & locale, where we\n // can safely reuse the store across multiple root regions and benefit from the host API client's\n // in-memory cache.\n //\n // On the client, stores are reference-counted by site version so multiple root regions can share a store\n // instance, which preserves the pre-v0.17 per-site-version store behavior without requiring a separate\n // runtime per root.\n const usePersistentStore = this.shouldUsePersistentStore(key)\n return usePersistentStore ? this.activeStores.getOrCreate(key, createStore) : createStore()\n }\n\n retainStore({ siteVersion, locale }: StoreKey, store: Store): void {\n const key = storeCacheKey({ siteVersion, locale })\n\n if (!this.shouldUsePersistentStore(key)) {\n console.error('RuntimeCore: attempt to retain an ephemeral store', { key })\n return\n }\n\n if (this.activeStores.retain(key, store)) {\n store.startBreakpointWatch()\n }\n }\n\n releaseStore({ siteVersion, locale }: StoreKey, store: Store): void {\n const key = storeCacheKey({ siteVersion, locale })\n\n if (!this.shouldUsePersistentStore(key)) {\n console.error('RuntimeCore: attempt to release an ephemeral store', { key })\n return\n }\n\n if (this.activeStores.release(key, store)) {\n store.stopBreakpointWatch()\n }\n }\n\n copyElementTree(\n elementTree: ElementData,\n replacementContext: SerializableReplacementContext,\n ): Element {\n return copyElementTree(this.protoStore.getState(), elementTree, replacementContext)\n }\n\n getBreakpoints(): Breakpoints {\n return getBreakpoints(this.protoStore.getState())\n }\n\n get graphqlApiEndpoint(): string {\n return new URL('graphql', this.apiOrigin).href\n }\n\n private createApiResourcesClient(preloadedState: {\n siteVersion: SiteVersion | null\n locale: string | undefined\n }) {\n return new HostApiResourcesClient({\n fetch: this.fetch,\n preloadedState,\n })\n }\n\n private shouldUsePersistentStore(key: string): boolean {\n // don't persist stores on the server unless the runtime instance is bound to a request\n // and the requested store matches the request's site version and locale\n return !isServer() || (this.requestKey !== undefined && storeCacheKey(this.requestKey) === key)\n }\n}\n\nconst storeCacheKey = ({ siteVersion, locale }: StoreKey): string =>\n `${siteVersionTag(siteVersion)}/${locale ?? 'default'}`\n\nconst siteVersionTag = (siteVersion: SiteVersion | null): string =>\n siteVersion?.version ?? VERSION_TAG_LIVE\n\nfunction validateOrigin(url: string, name: string): string {\n try {\n return new URL(url).origin\n } catch {\n throw new Error(`The Makeswift runtime received an invalid \\`${name}\\` parameter: \"${url}\".`)\n }\n}\n"],"mappings":"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","names":[]}
1
+ {"version":3,"sources":["../../../../src/runtimes/react/runtime-core.ts"],"sourcesContent":["import { type SerializableReplacementContext } from '@makeswift/controls'\n\nimport { ApiResourcesClient } from '../../api/api-resources-client'\nimport { HostApiResourcesClient } from '../../api/host-api-resources-client'\nimport { MakeswiftApiResourcesClient } from '../../api/makeswift-api-resources-client'\nimport { type HttpFetch } from '../../api/types'\nimport { type SiteVersion } from '../../api/site-version'\n\nimport {\n type Breakpoints,\n type BreakpointsInput,\n parseBreakpointsInput,\n} from '../../state/modules/breakpoints'\n\nimport { copyElementTree } from '../../state/ops/copy-element-tree'\n\nimport { getBreakpoints, type Element, type ElementData } from '../../state/read-only-state'\nimport {\n configureProtoStore,\n configureReadWriteStore,\n type ProtoStore,\n type Store,\n} from '../../state/store'\n\nimport { RefCountedMap } from '../../utils/ref-counted-map'\nimport { isServer } from '../../utils/is-server'\n\nexport type StoreKey = {\n siteVersion: SiteVersion | null\n locale: string | undefined\n}\n\nconst VERSION_TAG_LIVE = 'ref:live'\n\nexport class RuntimeCore {\n // The unowned entry TTL affects performance, not correctness. The TTL controls how long an unretained store stays\n // in the map. If an entry expires and is removed from the map before React commits, the store remains retained\n // via `<StoreContext.Provider>`. The only impact is that future lookups will create a new store instance instead of\n // reusing the existing one, reducing cache efficiency.\n private readonly activeStores = new RefCountedMap<string | null, Store>({\n unownedEntryTtlMs: 1000,\n // Checking on retain/release is sufficient on the client, and we don't need to check on get on the server\n // as the only scenario in which we add the store to the map is when the runtime is already bound to the\n // requested site version, which should be the only site version for which the store is requested\n ttlCheck: RefCountedMap.TTLCheck.ON_RETAIN | RefCountedMap.TTLCheck.ON_RELEASE,\n })\n\n private readonly apiKey: string | undefined\n\n readonly protoStore: ProtoStore\n readonly appOrigin: string\n readonly apiOrigin: string\n readonly requestKey: StoreKey | undefined\n readonly fetch: HttpFetch\n\n constructor({\n appOrigin = 'https://app.makeswift.com',\n apiOrigin = 'https://api.makeswift.com',\n apiKey,\n breakpoints,\n requestKey,\n fetch,\n }: {\n appOrigin?: string\n apiOrigin?: string\n apiKey?: string\n breakpoints?: BreakpointsInput\n requestKey?: StoreKey\n fetch: HttpFetch\n }) {\n this.appOrigin = validateOrigin(appOrigin, 'appOrigin')\n this.apiOrigin = validateOrigin(apiOrigin, 'apiOrigin')\n this.apiKey = apiKey\n this.requestKey = requestKey\n this.fetch = fetch\n\n this.protoStore = configureProtoStore({\n name: 'Runtime proto-store',\n breakpoints: breakpoints ? parseBreakpointsInput(breakpoints) : undefined,\n })\n }\n\n getOrCreateStore({ siteVersion, locale }: StoreKey): Store {\n const key = storeCacheKey({ siteVersion, locale })\n\n const createStore = () => {\n // API resources client includes an in-memory cache of the site's resources and thus also has to be versioned\n const apiResourcesClient = this.createApiResourcesClient({ siteVersion, locale })\n\n // TODO: we need to decouple editability from the site version; specifically, previewing\n // a draft version of the site should not lead to switching to the read-write state\n const isReadOnly = siteVersion == null\n\n return configureReadWriteStore({\n name: `Runtime read-write store (site version: ${key})`,\n appOrigin: this.appOrigin,\n apiResourcesClient,\n preloadedState: { ...this.protoStore.getState(), siteVersion, isReadOnly, locale },\n })\n }\n\n // On the server, stores are ephemeral by default so SSR does not retain them in a long-lived runtime.\n // The exception is a runtime that is already bound to the requested site version & locale, where we\n // can safely reuse the store across multiple root regions and benefit from the host API client's\n // in-memory cache.\n //\n // On the client, stores are reference-counted by site version so multiple root regions can share a store\n // instance, which preserves the pre-v0.17 per-site-version store behavior without requiring a separate\n // runtime per root.\n const usePersistentStore = this.shouldUsePersistentStore(key)\n return usePersistentStore ? this.activeStores.getOrCreate(key, createStore) : createStore()\n }\n\n retainStore({ siteVersion, locale }: StoreKey, store: Store): void {\n const key = storeCacheKey({ siteVersion, locale })\n\n if (!this.shouldUsePersistentStore(key)) {\n console.error('RuntimeCore: attempt to retain an ephemeral store', { key })\n return\n }\n\n if (this.activeStores.retain(key, store)) {\n store.startBreakpointWatch()\n }\n }\n\n releaseStore({ siteVersion, locale }: StoreKey, store: Store): void {\n const key = storeCacheKey({ siteVersion, locale })\n\n if (!this.shouldUsePersistentStore(key)) {\n console.error('RuntimeCore: attempt to release an ephemeral store', { key })\n return\n }\n\n if (this.activeStores.release(key, store)) {\n store.stopBreakpointWatch()\n }\n }\n\n copyElementTree(\n elementTree: ElementData,\n replacementContext: SerializableReplacementContext,\n ): Element {\n return copyElementTree(this.protoStore.getState(), elementTree, replacementContext)\n }\n\n getBreakpoints(): Breakpoints {\n return getBreakpoints(this.protoStore.getState())\n }\n\n get graphqlApiEndpoint(): string {\n return new URL('graphql', this.apiOrigin).href\n }\n\n private createApiResourcesClient(preloadedState: {\n siteVersion: SiteVersion | null\n locale: string | undefined\n }): ApiResourcesClient {\n if (isServer() && this.apiKey) {\n return new MakeswiftApiResourcesClient({\n fetch: this.fetch,\n apiKey: this.apiKey,\n apiOrigin: this.apiOrigin,\n graphqlApiEndpoint: this.graphqlApiEndpoint,\n preloadedState,\n })\n }\n\n return new HostApiResourcesClient({\n fetch: this.fetch,\n preloadedState,\n })\n }\n\n private shouldUsePersistentStore(key: string): boolean {\n // don't persist stores on the server unless the runtime instance is bound to a request\n // and the requested store matches the request's site version and locale\n return !isServer() || (this.requestKey !== undefined && storeCacheKey(this.requestKey) === key)\n }\n}\n\nconst storeCacheKey = ({ siteVersion, locale }: StoreKey): string =>\n `${siteVersionTag(siteVersion)}/${locale ?? 'default'}`\n\nconst siteVersionTag = (siteVersion: SiteVersion | null): string =>\n siteVersion?.version ?? VERSION_TAG_LIVE\n\nfunction validateOrigin(url: string, name: string): string {\n try {\n return new URL(url).origin\n } catch {\n throw new Error(`The Makeswift runtime received an invalid \\`${name}\\` parameter: \"${url}\".`)\n }\n}\n"],"mappings":"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","names":[]}
@@ -16,12 +16,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  var fixtures_exports = {};
17
17
  module.exports = __toCommonJS(fixtures_exports);
18
18
  __reExport(fixtures_exports, require("./origins"), module.exports);
19
- __reExport(fixtures_exports, require("./site-version"), module.exports);
20
19
  __reExport(fixtures_exports, require("./resources"), module.exports);
20
+ __reExport(fixtures_exports, require("./site-version"), module.exports);
21
+ __reExport(fixtures_exports, require("./snippet"), module.exports);
21
22
  // Annotate the CommonJS export names for ESM import in node:
22
23
  0 && (module.exports = {
23
24
  ...require("./origins"),
25
+ ...require("./resources"),
24
26
  ...require("./site-version"),
25
- ...require("./resources")
27
+ ...require("./snippet")
26
28
  });
27
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/testing/fixtures/index.ts"],"sourcesContent":["export * from './origins'\nexport * from './site-version'\nexport * from './resources'\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,sBAAd;AACA,6BAAc,2BADd;AAEA,6BAAc,wBAFd;","names":[]}
1
+ {"version":3,"sources":["../../../../src/testing/fixtures/index.ts"],"sourcesContent":["export * from './origins'\nexport * from './resources'\nexport * from './site-version'\nexport * from './snippet'\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,sBAAd;AACA,6BAAc,wBADd;AAEA,6BAAc,2BAFd;AAGA,6BAAc,sBAHd;","names":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var snippet_exports = {};
20
+ __export(snippet_exports, {
21
+ createSnippet: () => createSnippet
22
+ });
23
+ module.exports = __toCommonJS(snippet_exports);
24
+ const createSnippet = ({ id, code }) => ({
25
+ id,
26
+ code,
27
+ location: "HEAD",
28
+ liveEnabled: true,
29
+ builderEnabled: true,
30
+ cleanup: null
31
+ });
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ createSnippet
35
+ });
36
+ //# sourceMappingURL=snippet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/testing/fixtures/snippet.ts"],"sourcesContent":["import { type Snippet } from '../../client/page-snapshot'\n\nexport const createSnippet = ({ id, code }: { id: string; code: string }): Snippet => ({\n id,\n code,\n location: 'HEAD',\n liveEnabled: true,\n builderEnabled: true,\n cleanup: null,\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,gBAAgB,CAAC,EAAE,IAAI,KAAK,OAA8C;AAAA,EACrF;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,SAAS;AACX;","names":[]}
@@ -18,11 +18,8 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var unstable_framework_support_exports = {};
20
20
  __export(unstable_framework_support_exports, {
21
- DefaultHead: () => import_framework_context.DefaultHead,
22
- DefaultHeadSnippet: () => import_framework_context.DefaultHeadSnippet,
23
- DefaultImage: () => import_framework_context.DefaultImage,
24
21
  DefaultRootStyleRegistry: () => import_root_style_registry.DefaultRootStyleRegistry,
25
- FrameworkContext: () => import_framework_context.FrameworkContext,
22
+ FrameworkContextProvider: () => import_framework_context.FrameworkContextProvider,
26
23
  GoogleFontLink: () => import_GoogleFontLink.GoogleFontLink,
27
24
  MAKESWIFT_SITE_VERSION_COOKIE: () => import_preview.MAKESWIFT_SITE_VERSION_COOKIE,
28
25
  MakeswiftClient: () => import_client.MakeswiftClient,
@@ -67,11 +64,8 @@ var import_root_style_registry = require("../runtimes/react/root-style-registry"
67
64
  var import_react_runtime = require("../runtimes/react/react-runtime");
68
65
  // Annotate the CommonJS export names for ESM import in node:
69
66
  0 && (module.exports = {
70
- DefaultHead,
71
- DefaultHeadSnippet,
72
- DefaultImage,
73
67
  DefaultRootStyleRegistry,
74
- FrameworkContext,
68
+ FrameworkContextProvider,
75
69
  GoogleFontLink,
76
70
  MAKESWIFT_SITE_VERSION_COOKIE,
77
71
  MakeswiftClient,