@makeswift/runtime 0.26.4-canary.1 → 0.27.0-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.
- package/dist/cjs/api/client.js +1 -10
- package/dist/cjs/api/client.js.map +1 -1
- package/dist/cjs/api-handler/handlers/manifest.js +1 -1
- package/dist/cjs/api-handler/index.js +1 -2
- package/dist/cjs/api-handler/index.js.map +1 -1
- package/dist/cjs/client/index.js +8 -13
- package/dist/cjs/client/index.js.map +1 -1
- package/dist/cjs/next/api-handler/index.js +2 -2
- package/dist/cjs/next/api-handler/index.js.map +1 -1
- package/dist/cjs/next/components/framework-provider/index.js +1 -3
- package/dist/cjs/next/components/framework-provider/index.js.map +1 -1
- package/dist/cjs/next/components/tests/controls/style-control/fixtures.js.map +1 -1
- package/dist/cjs/next/index.js +3 -0
- package/dist/cjs/next/index.js.map +1 -1
- package/dist/cjs/next/runtime.js +38 -0
- package/dist/cjs/next/runtime.js.map +1 -0
- package/dist/cjs/next/tests/test-utils.js +3 -6
- package/dist/cjs/next/tests/test-utils.js.map +1 -1
- package/dist/cjs/react/index.js +0 -3
- package/dist/cjs/react/index.js.map +1 -1
- package/dist/cjs/runtimes/react/components/RuntimeProvider.js +13 -33
- package/dist/cjs/runtimes/react/components/RuntimeProvider.js.map +1 -1
- package/dist/cjs/runtimes/react/components/framework-context.js +1 -2
- package/dist/cjs/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/cjs/runtimes/react/hooks/use-async-effect.js +55 -0
- package/dist/cjs/runtimes/react/hooks/use-async-effect.js.map +1 -0
- package/dist/cjs/runtimes/react/hooks/use-store.js +2 -9
- package/dist/cjs/runtimes/react/hooks/use-store.js.map +1 -1
- package/dist/cjs/runtimes/react/host-api-client.js +2 -25
- package/dist/cjs/runtimes/react/host-api-client.js.map +1 -1
- package/dist/cjs/runtimes/react/index.js +0 -5
- package/dist/cjs/runtimes/react/index.js.map +1 -1
- package/dist/cjs/runtimes/react/react-runtime-core.js +0 -3
- package/dist/cjs/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/cjs/runtimes/react/react-runtime.js +2 -2
- package/dist/cjs/runtimes/react/react-runtime.js.map +1 -1
- package/dist/cjs/runtimes/react/runtime-core.js +42 -3
- package/dist/cjs/runtimes/react/runtime-core.js.map +1 -1
- package/dist/cjs/runtimes/react/testing/react-runtime.js +2 -1
- package/dist/cjs/runtimes/react/testing/react-runtime.js.map +1 -1
- package/dist/cjs/state/middleware/{read-write/makeswift-api-client-sync.js → makeswift-api-client-sync.js} +1 -1
- package/dist/cjs/state/middleware/makeswift-api-client-sync.js.map +1 -0
- package/dist/cjs/state/middleware/read-write/index.js +40 -0
- package/dist/cjs/state/middleware/read-write/index.js.map +1 -0
- package/dist/cjs/state/middleware/{prop-controller-handles.js → read-write/prop-controller-handles.js} +8 -8
- package/dist/cjs/state/middleware/read-write/prop-controller-handles.js.map +1 -0
- package/dist/cjs/state/read-only-state.js +2 -0
- package/dist/cjs/state/read-only-state.js.map +1 -1
- package/dist/cjs/state/read-write-state.js +9 -2
- package/dist/cjs/state/read-write-state.js.map +1 -1
- package/dist/cjs/state/store.js +184 -0
- package/dist/cjs/state/store.js.map +1 -0
- package/dist/cjs/state/unified-state.js +17 -0
- package/dist/cjs/state/unified-state.js.map +1 -0
- package/dist/cjs/unstable-framework-support/index.js.map +1 -1
- package/dist/cjs/{state/mixins/setup-teardown.js → utils/deferred.js} +15 -11
- package/dist/cjs/utils/deferred.js.map +1 -0
- package/dist/esm/api/client.js +1 -10
- package/dist/esm/api/client.js.map +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/api-handler/index.js +1 -2
- package/dist/esm/api-handler/index.js.map +1 -1
- package/dist/esm/client/index.js +8 -13
- package/dist/esm/client/index.js.map +1 -1
- package/dist/esm/next/api-handler/index.js +2 -2
- package/dist/esm/next/api-handler/index.js.map +1 -1
- package/dist/esm/next/components/framework-provider/index.js +1 -3
- package/dist/esm/next/components/framework-provider/index.js.map +1 -1
- package/dist/esm/next/components/tests/controls/style-control/fixtures.js.map +1 -1
- package/dist/esm/next/index.js +2 -0
- package/dist/esm/next/index.js.map +1 -1
- package/dist/esm/next/runtime.js +14 -0
- package/dist/esm/next/runtime.js.map +1 -0
- package/dist/esm/next/tests/test-utils.js +3 -6
- package/dist/esm/next/tests/test-utils.js.map +1 -1
- package/dist/esm/react/index.js +0 -2
- package/dist/esm/react/index.js.map +1 -1
- package/dist/esm/runtimes/react/components/RuntimeProvider.js +14 -24
- package/dist/esm/runtimes/react/components/RuntimeProvider.js.map +1 -1
- package/dist/esm/runtimes/react/components/framework-context.js +1 -2
- package/dist/esm/runtimes/react/components/framework-context.js.map +1 -1
- package/dist/esm/runtimes/react/hooks/use-async-effect.js +31 -0
- package/dist/esm/runtimes/react/hooks/use-async-effect.js.map +1 -0
- package/dist/esm/runtimes/react/hooks/use-store.js +2 -8
- package/dist/esm/runtimes/react/hooks/use-store.js.map +1 -1
- package/dist/esm/runtimes/react/host-api-client.js +2 -24
- package/dist/esm/runtimes/react/host-api-client.js.map +1 -1
- package/dist/esm/runtimes/react/index.js +1 -4
- package/dist/esm/runtimes/react/index.js.map +1 -1
- package/dist/esm/runtimes/react/react-runtime-core.js +0 -3
- package/dist/esm/runtimes/react/react-runtime-core.js.map +1 -1
- package/dist/esm/runtimes/react/react-runtime.js +2 -2
- package/dist/esm/runtimes/react/react-runtime.js.map +1 -1
- package/dist/esm/runtimes/react/runtime-core.js +45 -2
- package/dist/esm/runtimes/react/runtime-core.js.map +1 -1
- package/dist/esm/runtimes/react/testing/react-runtime.js +2 -1
- package/dist/esm/runtimes/react/testing/react-runtime.js.map +1 -1
- package/dist/esm/state/middleware/{read-write/makeswift-api-client-sync.js → makeswift-api-client-sync.js} +1 -1
- package/dist/esm/state/middleware/makeswift-api-client-sync.js.map +1 -0
- package/dist/esm/state/middleware/read-write/index.js +16 -0
- package/dist/esm/state/middleware/read-write/index.js.map +1 -0
- package/dist/esm/state/middleware/{prop-controller-handles.js → read-write/prop-controller-handles.js} +8 -8
- package/dist/esm/state/middleware/read-write/prop-controller-handles.js.map +1 -0
- package/dist/esm/state/read-only-state.js +2 -0
- package/dist/esm/state/read-only-state.js.map +1 -1
- package/dist/esm/state/read-write-state.js +7 -1
- package/dist/esm/state/read-write-state.js.map +1 -1
- package/dist/esm/state/store.js +153 -0
- package/dist/esm/state/store.js.map +1 -0
- package/dist/esm/state/unified-state.js +1 -0
- package/dist/esm/state/unified-state.js.map +1 -0
- package/dist/esm/unstable-framework-support/index.js.map +1 -1
- package/dist/esm/utils/deferred.js +15 -0
- package/dist/esm/utils/deferred.js.map +1 -0
- package/dist/types/api/client.d.ts +1 -4
- package/dist/types/api/client.d.ts.map +1 -1
- package/dist/types/api-handler/handlers/webhook/types.d.ts +4 -4
- package/dist/types/api-handler/index.d.ts +1 -3
- package/dist/types/api-handler/index.d.ts.map +1 -1
- package/dist/types/client/index.d.ts +10 -11
- package/dist/types/client/index.d.ts.map +1 -1
- package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/dist/types/components/hooks/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/dist/types/next/api-handler/index.d.ts +1 -1
- package/dist/types/next/api-handler/index.d.ts.map +1 -1
- package/dist/types/next/components/framework-provider/index.d.ts.map +1 -1
- package/dist/types/next/components/tests/controls/style-control/fixtures.d.ts +1 -1
- package/dist/types/next/components/tests/controls/style-control/fixtures.d.ts.map +1 -1
- package/dist/types/next/index.d.ts +1 -0
- package/dist/types/next/index.d.ts.map +1 -1
- package/dist/types/next/runtime.d.ts +10 -0
- package/dist/types/next/runtime.d.ts.map +1 -0
- package/dist/types/next/tests/test-utils.d.ts.map +1 -1
- package/dist/types/react/index.d.ts +0 -1
- package/dist/types/react/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/RuntimeProvider.d.ts +2 -4
- package/dist/types/runtimes/react/components/RuntimeProvider.d.ts.map +1 -1
- package/dist/types/runtimes/react/components/framework-context.d.ts +0 -2
- package/dist/types/runtimes/react/components/framework-context.d.ts.map +1 -1
- package/dist/types/runtimes/react/hooks/__tests__/use-async-effect.test.d.ts +2 -0
- package/dist/types/runtimes/react/hooks/__tests__/use-async-effect.test.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-async-effect.d.ts +3 -0
- package/dist/types/runtimes/react/hooks/use-async-effect.d.ts.map +1 -0
- package/dist/types/runtimes/react/hooks/use-store.d.ts +1 -26
- package/dist/types/runtimes/react/hooks/use-store.d.ts.map +1 -1
- package/dist/types/runtimes/react/host-api-client.d.ts +0 -5
- package/dist/types/runtimes/react/host-api-client.d.ts.map +1 -1
- package/dist/types/runtimes/react/index.d.ts +1 -2
- package/dist/types/runtimes/react/index.d.ts.map +1 -1
- package/dist/types/runtimes/react/react-runtime-core.d.ts +0 -4
- package/dist/types/runtimes/react/react-runtime-core.d.ts.map +1 -1
- package/dist/types/runtimes/react/react-runtime.d.ts +1 -4
- package/dist/types/runtimes/react/react-runtime.d.ts.map +1 -1
- package/dist/types/runtimes/react/runtime-core.d.ts +20 -3
- package/dist/types/runtimes/react/runtime-core.d.ts.map +1 -1
- package/dist/types/runtimes/react/testing/react-runtime.d.ts.map +1 -1
- package/dist/types/state/__tests__/store.read-write-state.test.d.ts +2 -0
- package/dist/types/state/__tests__/store.read-write-state.test.d.ts.map +1 -0
- package/dist/types/state/__tests__/test-store.d.ts +29 -0
- package/dist/types/state/__tests__/test-store.d.ts.map +1 -0
- package/dist/types/state/middleware/makeswift-api-client-sync.d.ts +5 -0
- package/dist/types/state/middleware/makeswift-api-client-sync.d.ts.map +1 -0
- package/dist/types/state/middleware/read-write/index.d.ts +5 -0
- package/dist/types/state/middleware/read-write/index.d.ts.map +1 -0
- package/dist/types/state/middleware/{prop-controller-handles.d.ts → read-write/prop-controller-handles.d.ts} +1 -1
- package/dist/types/state/middleware/read-write/prop-controller-handles.d.ts.map +1 -0
- package/dist/types/state/read-only-state.d.ts +3 -0
- package/dist/types/state/read-only-state.d.ts.map +1 -1
- package/dist/types/state/read-write-state.d.ts +5 -1
- package/dist/types/state/read-write-state.d.ts.map +1 -1
- package/dist/types/state/{react-page.d.ts → store.d.ts} +25 -6
- package/dist/types/state/store.d.ts.map +1 -0
- package/dist/types/state/unified-state.d.ts +9 -0
- package/dist/types/state/unified-state.d.ts.map +1 -0
- package/dist/types/unstable-framework-support/index.d.ts +1 -0
- package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
- package/dist/types/utils/deferred.d.ts +7 -0
- package/dist/types/utils/deferred.d.ts.map +1 -0
- package/package.json +2 -2
- package/dist/cjs/runtimes/react/components/LiveProvider.js +0 -50
- package/dist/cjs/runtimes/react/components/LiveProvider.js.map +0 -1
- package/dist/cjs/runtimes/react/components/PreviewProvider.js +0 -63
- package/dist/cjs/runtimes/react/components/PreviewProvider.js.map +0 -1
- package/dist/cjs/state/middleware/prop-controller-handles.js.map +0 -1
- package/dist/cjs/state/middleware/read-write/makeswift-api-client-sync.js.map +0 -1
- package/dist/cjs/state/mixins/setup-teardown.js.map +0 -1
- package/dist/cjs/state/react-builder-preview.js +0 -96
- package/dist/cjs/state/react-builder-preview.js.map +0 -1
- package/dist/cjs/state/react-page.js +0 -69
- package/dist/cjs/state/react-page.js.map +0 -1
- package/dist/esm/runtimes/react/components/LiveProvider.js +0 -20
- package/dist/esm/runtimes/react/components/LiveProvider.js.map +0 -1
- package/dist/esm/runtimes/react/components/PreviewProvider.js +0 -33
- package/dist/esm/runtimes/react/components/PreviewProvider.js.map +0 -1
- package/dist/esm/state/middleware/prop-controller-handles.js.map +0 -1
- package/dist/esm/state/middleware/read-write/makeswift-api-client-sync.js.map +0 -1
- package/dist/esm/state/mixins/setup-teardown.js +0 -11
- package/dist/esm/state/mixins/setup-teardown.js.map +0 -1
- package/dist/esm/state/react-builder-preview.js +0 -62
- package/dist/esm/state/react-builder-preview.js.map +0 -1
- package/dist/esm/state/react-page.js +0 -35
- package/dist/esm/state/react-page.js.map +0 -1
- package/dist/types/runtimes/react/components/LiveProvider.d.ts +0 -3
- package/dist/types/runtimes/react/components/LiveProvider.d.ts.map +0 -1
- package/dist/types/runtimes/react/components/PreviewProvider.d.ts +0 -5
- package/dist/types/runtimes/react/components/PreviewProvider.d.ts.map +0 -1
- package/dist/types/state/middleware/prop-controller-handles.d.ts.map +0 -1
- package/dist/types/state/middleware/read-write/makeswift-api-client-sync.d.ts +0 -5
- package/dist/types/state/middleware/read-write/makeswift-api-client-sync.d.ts.map +0 -1
- package/dist/types/state/mixins/setup-teardown.d.ts +0 -7
- package/dist/types/state/mixins/setup-teardown.d.ts.map +0 -1
- package/dist/types/state/react-builder-preview.d.ts +0 -41
- package/dist/types/state/react-builder-preview.d.ts.map +0 -1
- package/dist/types/state/react-page.d.ts.map +0 -1
|
@@ -27,16 +27,13 @@ module.exports = __toCommonJS(test_utils_exports);
|
|
|
27
27
|
var import_server = require("next/server");
|
|
28
28
|
var import_node_mocks_http = require("node-mocks-http");
|
|
29
29
|
var import_api_handler = require("../api-handler");
|
|
30
|
-
var import_react = require("../../react");
|
|
31
|
-
var import_fixtures = require("../../testing/fixtures");
|
|
32
30
|
var import_preview = require("../api-handler/preview");
|
|
31
|
+
var import_testing = require("../testing");
|
|
33
32
|
function createHandler(apiKey, args = {}) {
|
|
34
|
-
const runtime =
|
|
33
|
+
const runtime = (0, import_testing.createReactRuntime)();
|
|
35
34
|
return (0, import_api_handler.MakeswiftApiHandler)(apiKey, {
|
|
36
35
|
...args,
|
|
37
|
-
runtime
|
|
38
|
-
apiOrigin: import_fixtures.TestOrigins.apiOrigin,
|
|
39
|
-
appOrigin: import_fixtures.TestOrigins.appOrigin
|
|
36
|
+
runtime
|
|
40
37
|
});
|
|
41
38
|
}
|
|
42
39
|
const hostUrl = (path) => new URL(path, "https://example.com");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/next/tests/test-utils.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest } from 'next/server'\nimport {\n createRequest,\n createResponse,\n type RequestMethod,\n type MockResponse,\n} from 'node-mocks-http'\n\nimport { MakeswiftApiHandler } from '../api-handler'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/next/tests/test-utils.ts"],"sourcesContent":["import { NextApiRequest, NextApiResponse } from 'next'\nimport { NextRequest } from 'next/server'\nimport {\n createRequest,\n createResponse,\n type RequestMethod,\n type MockResponse,\n} from 'node-mocks-http'\n\nimport { MakeswiftApiHandler } from '../api-handler'\nimport { RewriteRuleMatches } from '../api-handler/preview'\nimport { createReactRuntime } from '../testing'\n\nexport type MakeswiftApiHandlerArgs = Partial<Parameters<typeof MakeswiftApiHandler>[1]>\n\nfunction createHandler(apiKey: string, args: Partial<MakeswiftApiHandlerArgs> = {}) {\n const runtime = createReactRuntime()\n\n return MakeswiftApiHandler(apiKey, {\n ...args,\n runtime,\n })\n}\n\nexport const hostUrl = (path: string) => new URL(path, 'https://example.com')\n\nfunction routeParams(url: URL) {\n // simulate Next.js API route's context params, e.g. /api/makeswift/revalidate -> { 'makeswift': ['revalidate'] }\n const segments = url.pathname.split('/').filter(Boolean).slice(1)\n return { [segments[0]]: segments.slice(1) }\n}\n\nexport type RequestParams = {\n method: RequestMethod\n path: string\n originalPath?: string\n body?: Record<string, unknown>\n headers?: Record<string, string>\n}\n\nfunction createNextApiRequest({\n method,\n path,\n originalPath,\n body,\n headers,\n}: RequestParams): NextApiRequest {\n const url = hostUrl(originalPath ?? path)\n return createRequest<NextApiRequest>({\n method,\n url: url.toString(),\n query: {\n ...routeParams(hostUrl(path)),\n ...Object.fromEntries(url.searchParams.entries()),\n ...(originalPath ? { [RewriteRuleMatches.OriginalPath]: originalPath } : {}),\n },\n body,\n headers,\n })\n}\n\nfunction createNextRequestWithContext({\n method,\n path,\n originalPath,\n body,\n headers,\n}: RequestParams): [NextRequest, { params: Promise<{ [key: string]: string | string[] }> }] {\n const request = new NextRequest(hostUrl(originalPath ?? path), {\n method,\n body: JSON.stringify(body),\n headers,\n })\n\n return [request, { params: Promise.resolve(routeParams(hostUrl(path))) }]\n}\n\nexport function pagesRouterApiRequestFixture(\n args: MakeswiftApiHandlerArgs = {},\n responseMock?: MockResponse<NextApiResponse>,\n) {\n const apiKey = 'pages-router-api-key'\n const handler = createHandler(apiKey, args)\n\n const response = responseMock ?? createResponse<NextApiResponse>()\n const testApiRequest = async (reqParams: RequestParams) => {\n await handler(createNextApiRequest(reqParams), response)\n return {\n statusCode: response.statusCode,\n get jsonBody() {\n return response._getJSONData()\n },\n get textBody() {\n return response._getData()\n },\n headers: {\n getSetCookie() {\n return response._getHeaders()['set-cookie']\n },\n get(key: string) {\n return key.toLowerCase() === 'location'\n ? response._getRedirectUrl() || response._getHeaders()['location']\n : response._getHeaders()[key]\n },\n },\n }\n }\n\n return { testApiRequest, apiKey }\n}\n\nexport function appRouterApiRequestFixture(args: MakeswiftApiHandlerArgs = {}) {\n const apiKey = 'app-router-api-key'\n const handler = createHandler(apiKey, args)\n const testApiRequest = async (reqParams: RequestParams) => {\n const response = await handler(...createNextRequestWithContext(reqParams))\n return {\n statusCode: response?.status,\n get jsonBody() {\n return response?.json()\n },\n get textBody() {\n return response?.text()\n },\n headers: response?.headers ?? new Headers(),\n }\n }\n\n return { testApiRequest, apiKey }\n}\n\nexport const apiRequestFixtures = [\n { fixture: pagesRouterApiRequestFixture, router: 'pages' },\n { fixture: appRouterApiRequestFixture, router: 'app' },\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA4B;AAC5B,6BAKO;AAEP,yBAAoC;AACpC,qBAAmC;AACnC,qBAAmC;AAInC,SAAS,cAAc,QAAgB,OAAyC,CAAC,GAAG;AAClF,QAAM,cAAU,mCAAmB;AAEnC,aAAO,wCAAoB,QAAQ;AAAA,IACjC,GAAG;AAAA,IACH;AAAA,EACF,CAAC;AACH;AAEO,MAAM,UAAU,CAAC,SAAiB,IAAI,IAAI,MAAM,qBAAqB;AAE5E,SAAS,YAAY,KAAU;AAE7B,QAAM,WAAW,IAAI,SAAS,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,MAAM,CAAC;AAChE,SAAO,EAAE,CAAC,SAAS,CAAC,CAAC,GAAG,SAAS,MAAM,CAAC,EAAE;AAC5C;AAUA,SAAS,qBAAqB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAkC;AAChC,QAAM,MAAM,QAAQ,gBAAgB,IAAI;AACxC,aAAO,sCAA8B;AAAA,IACnC;AAAA,IACA,KAAK,IAAI,SAAS;AAAA,IAClB,OAAO;AAAA,MACL,GAAG,YAAY,QAAQ,IAAI,CAAC;AAAA,MAC5B,GAAG,OAAO,YAAY,IAAI,aAAa,QAAQ,CAAC;AAAA,MAChD,GAAI,eAAe,EAAE,CAAC,kCAAmB,YAAY,GAAG,aAAa,IAAI,CAAC;AAAA,IAC5E;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;AAEA,SAAS,6BAA6B;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA4F;AAC1F,QAAM,UAAU,IAAI,0BAAY,QAAQ,gBAAgB,IAAI,GAAG;AAAA,IAC7D;AAAA,IACA,MAAM,KAAK,UAAU,IAAI;AAAA,IACzB;AAAA,EACF,CAAC;AAED,SAAO,CAAC,SAAS,EAAE,QAAQ,QAAQ,QAAQ,YAAY,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC;AAC1E;AAEO,SAAS,6BACd,OAAgC,CAAC,GACjC,cACA;AACA,QAAM,SAAS;AACf,QAAM,UAAU,cAAc,QAAQ,IAAI;AAE1C,QAAM,WAAW,oBAAgB,uCAAgC;AACjE,QAAM,iBAAiB,OAAO,cAA6B;AACzD,UAAM,QAAQ,qBAAqB,SAAS,GAAG,QAAQ;AACvD,WAAO;AAAA,MACL,YAAY,SAAS;AAAA,MACrB,IAAI,WAAW;AACb,eAAO,SAAS,aAAa;AAAA,MAC/B;AAAA,MACA,IAAI,WAAW;AACb,eAAO,SAAS,SAAS;AAAA,MAC3B;AAAA,MACA,SAAS;AAAA,QACP,eAAe;AACb,iBAAO,SAAS,YAAY,EAAE,YAAY;AAAA,QAC5C;AAAA,QACA,IAAI,KAAa;AACf,iBAAO,IAAI,YAAY,MAAM,aACzB,SAAS,gBAAgB,KAAK,SAAS,YAAY,EAAE,UAAU,IAC/D,SAAS,YAAY,EAAE,GAAG;AAAA,QAChC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,gBAAgB,OAAO;AAClC;AAEO,SAAS,2BAA2B,OAAgC,CAAC,GAAG;AAC7E,QAAM,SAAS;AACf,QAAM,UAAU,cAAc,QAAQ,IAAI;AAC1C,QAAM,iBAAiB,OAAO,cAA6B;AACzD,UAAM,WAAW,MAAM,QAAQ,GAAG,6BAA6B,SAAS,CAAC;AACzE,WAAO;AAAA,MACL,YAAY,UAAU;AAAA,MACtB,IAAI,WAAW;AACb,eAAO,UAAU,KAAK;AAAA,MACxB;AAAA,MACA,IAAI,WAAW;AACb,eAAO,UAAU,KAAK;AAAA,MACxB;AAAA,MACA,SAAS,UAAU,WAAW,IAAI,QAAQ;AAAA,IAC5C;AAAA,EACF;AAEA,SAAO,EAAE,gBAAgB,OAAO;AAClC;AAEO,MAAM,qBAAqB;AAAA,EAChC,EAAE,SAAS,8BAA8B,QAAQ,QAAQ;AAAA,EACzD,EAAE,SAAS,4BAA4B,QAAQ,MAAM;AACvD;","names":[]}
|
package/dist/cjs/react/index.js
CHANGED
|
@@ -18,15 +18,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var react_exports = {};
|
|
20
20
|
__export(react_exports, {
|
|
21
|
-
ReactRuntime: () => import_react.ReactRuntime,
|
|
22
21
|
useIsInBuilder: () => import_use_is_in_builder.useIsInBuilder
|
|
23
22
|
});
|
|
24
23
|
module.exports = __toCommonJS(react_exports);
|
|
25
|
-
var import_react = require("../runtimes/react");
|
|
26
24
|
var import_use_is_in_builder = require("../runtimes/react/hooks/use-is-in-builder");
|
|
27
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28
26
|
0 && (module.exports = {
|
|
29
|
-
ReactRuntime,
|
|
30
27
|
useIsInBuilder
|
|
31
28
|
});
|
|
32
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/react/index.ts"],"sourcesContent":["export {
|
|
1
|
+
{"version":3,"sources":["../../../src/react/index.ts"],"sourcesContent":["export { useIsInBuilder } from '../runtimes/react/hooks/use-is-in-builder'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAA+B;","names":[]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
-
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
7
|
var __export = (target, all) => {
|
|
10
8
|
for (var name in all)
|
|
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
}
|
|
19
17
|
return to;
|
|
20
18
|
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
var RuntimeProvider_exports = {};
|
|
31
21
|
__export(RuntimeProvider_exports, {
|
|
@@ -34,39 +24,29 @@ __export(RuntimeProvider_exports, {
|
|
|
34
24
|
module.exports = __toCommonJS(RuntimeProvider_exports);
|
|
35
25
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
26
|
var import_react = require("react");
|
|
37
|
-
var import_client = require("../../../api/client");
|
|
38
27
|
var import_use_react_runtime = require("../hooks/use-react-runtime");
|
|
39
|
-
var
|
|
40
|
-
var import_preview_switcher = require("./preview-switcher/preview-switcher");
|
|
28
|
+
var import_use_async_effect = require("../hooks/use-async-effect");
|
|
41
29
|
var import_use_builder_connection_ping = require("./hooks/use-builder-connection-ping");
|
|
42
|
-
var
|
|
43
|
-
const LiveProvider = (0, import_react.lazy)(() => Promise.resolve().then(() => __toESM(require("./LiveProvider"))));
|
|
44
|
-
const PreviewProvider = (0, import_react.lazy)(() => Promise.resolve().then(() => __toESM(require("./PreviewProvider"))));
|
|
30
|
+
var import_preview_switcher = require("./preview-switcher/preview-switcher");
|
|
45
31
|
function RuntimeProvider({
|
|
46
32
|
children,
|
|
47
33
|
runtime,
|
|
48
|
-
siteVersion,
|
|
49
|
-
appOrigin = "https://app.makeswift.com",
|
|
50
|
-
apiOrigin = "https://api.makeswift.com",
|
|
34
|
+
siteVersion: siteVersionProp,
|
|
51
35
|
locale = void 0
|
|
52
36
|
}) {
|
|
53
|
-
const
|
|
54
|
-
const client = (0, import_react.useMemo)(
|
|
55
|
-
() => new import_client.MakeswiftHostApiClient({
|
|
56
|
-
uri: new URL("graphql", apiOrigin).href,
|
|
57
|
-
locale,
|
|
58
|
-
fetch,
|
|
59
|
-
siteVersion: siteVersion ?? null
|
|
60
|
-
}),
|
|
61
|
-
[apiOrigin, locale, siteVersion, fetch]
|
|
62
|
-
);
|
|
37
|
+
const siteVersion = siteVersionProp ?? null;
|
|
63
38
|
const isPreview = siteVersion != null;
|
|
64
|
-
const
|
|
65
|
-
(0,
|
|
66
|
-
|
|
39
|
+
const isReadOnly = siteVersion == null;
|
|
40
|
+
(0, import_react.useMemo)(
|
|
41
|
+
() => runtime.setIdempotent({ siteVersion, isReadOnly, locale }),
|
|
42
|
+
[runtime, siteVersion, isReadOnly, locale]
|
|
43
|
+
);
|
|
44
|
+
(0, import_use_builder_connection_ping.useBuilderConnectionPing)({ appOrigin: runtime.appOrigin });
|
|
45
|
+
(0, import_use_async_effect.useAsyncEffect)(() => runtime.setupStore({ isReadOnly }), [runtime, isReadOnly]);
|
|
46
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_use_react_runtime.ReactRuntimeContext.Provider, { value: runtime, children: [
|
|
67
47
|
children,
|
|
68
48
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_preview_switcher.PreviewSwitcher, { isPreview })
|
|
69
|
-
] })
|
|
49
|
+
] });
|
|
70
50
|
}
|
|
71
51
|
// Annotate the CommonJS export names for ESM import in node:
|
|
72
52
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/components/RuntimeProvider.tsx"],"sourcesContent":["'use client'\n\nimport { ReactNode, useMemo
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/components/RuntimeProvider.tsx"],"sourcesContent":["'use client'\n\nimport { ReactNode, useMemo } from 'react'\n\nimport { type SiteVersion } from '../../../api/site-version'\n\nimport { ReactRuntimeContext } from '../hooks/use-react-runtime'\nimport { useAsyncEffect } from '../hooks/use-async-effect'\nimport { type ReactRuntimeCore } from '../react-runtime-core'\n\nimport { useBuilderConnectionPing } from './hooks/use-builder-connection-ping'\nimport { PreviewSwitcher } from './preview-switcher/preview-switcher'\n\nexport function RuntimeProvider({\n children,\n runtime,\n siteVersion: siteVersionProp,\n locale = undefined,\n}: {\n children: ReactNode\n runtime: ReactRuntimeCore\n siteVersion: SiteVersion | null | undefined\n locale?: string\n}) {\n const siteVersion = siteVersionProp ?? null\n const isPreview = siteVersion != null\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 // setting idempotent part of the state on render to have parity between server-side and\n // client-side rendering depending on this state; `useMemo` here is purely a performance\n // optimization; prior art for performing idempotent side effects on render:\n // https://github.com/TanStack/query/blob/8f9f183f11df3709a1a38c4efce1452788041f88/packages/react-query/src/HydrationBoundary.tsx#L41\n useMemo(\n () => runtime.setIdempotent({ siteVersion, isReadOnly, locale }),\n [runtime, siteVersion, isReadOnly, locale],\n )\n\n useBuilderConnectionPing({ appOrigin: runtime.appOrigin })\n\n useAsyncEffect(() => runtime.setupStore({ isReadOnly }), [runtime, isReadOnly])\n\n return (\n <ReactRuntimeContext.Provider value={runtime}>\n {children}\n <PreviewSwitcher isPreview={isPreview} />\n </ReactRuntimeContext.Provider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CI;AA1CJ,mBAAmC;AAInC,+BAAoC;AACpC,8BAA+B;AAG/B,yCAAyC;AACzC,8BAAgC;AAEzB,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb,SAAS;AACX,GAKG;AACD,QAAM,cAAc,mBAAmB;AACvC,QAAM,YAAY,eAAe;AAGjC,QAAM,aAAa,eAAe;AAMlC;AAAA,IACE,MAAM,QAAQ,cAAc,EAAE,aAAa,YAAY,OAAO,CAAC;AAAA,IAC/D,CAAC,SAAS,aAAa,YAAY,MAAM;AAAA,EAC3C;AAEA,mEAAyB,EAAE,WAAW,QAAQ,UAAU,CAAC;AAEzD,8CAAe,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC,SAAS,UAAU,CAAC;AAE9E,SACE,6CAAC,6CAAoB,UAApB,EAA6B,OAAO,SAClC;AAAA;AAAA,IACD,4CAAC,2CAAgB,WAAsB;AAAA,KACzC;AAEJ;","names":[]}
|
|
@@ -52,8 +52,7 @@ const FrameworkContext = (0, import_react.createContext)({
|
|
|
52
52
|
Head: DefaultHead,
|
|
53
53
|
HeadSnippet: DefaultHeadSnippet,
|
|
54
54
|
Image: DefaultImage,
|
|
55
|
-
Link: DefaultLink
|
|
56
|
-
fetch: globalThis.fetch
|
|
55
|
+
Link: DefaultLink
|
|
57
56
|
});
|
|
58
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
59
58
|
0 && (module.exports = {
|
|
@@ -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
|
|
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":[]}
|
|
@@ -0,0 +1,55 @@
|
|
|
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_async_effect_exports = {};
|
|
20
|
+
__export(use_async_effect_exports, {
|
|
21
|
+
useAsyncEffect: () => useAsyncEffect
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(use_async_effect_exports);
|
|
24
|
+
var import_react = require("react");
|
|
25
|
+
function useAsyncEffect(effect, deps) {
|
|
26
|
+
(0, import_react.useEffect)(() => {
|
|
27
|
+
let cancelled = false;
|
|
28
|
+
let cleanup = null;
|
|
29
|
+
const runAsyncEffect = async () => {
|
|
30
|
+
try {
|
|
31
|
+
cleanup = await effect();
|
|
32
|
+
if (cancelled) {
|
|
33
|
+
cleanup?.();
|
|
34
|
+
cleanup = null;
|
|
35
|
+
}
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error("Async effect error:", { error, deps });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
runAsyncEffect();
|
|
41
|
+
return () => {
|
|
42
|
+
cancelled = true;
|
|
43
|
+
try {
|
|
44
|
+
cleanup?.();
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error("Async effect cleanup error:", { error, deps });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}, deps);
|
|
50
|
+
}
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
useAsyncEffect
|
|
54
|
+
});
|
|
55
|
+
//# sourceMappingURL=use-async-effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-async-effect.ts"],"sourcesContent":["import { type DependencyList, useEffect } from 'react'\n\nexport function useAsyncEffect(effect: () => Promise<void | (() => void)>, deps: DependencyList) {\n useEffect(() => {\n let cancelled = false\n let cleanup: void | (() => void) | null = null\n\n const runAsyncEffect = async () => {\n try {\n cleanup = await effect()\n\n if (cancelled) {\n cleanup?.()\n cleanup = null\n }\n } catch (error) {\n console.error('Async effect error:', { error, deps })\n }\n }\n\n runAsyncEffect()\n\n return () => {\n cancelled = true\n try {\n cleanup?.()\n } catch (error) {\n console.error('Async effect cleanup error:', { error, deps })\n }\n }\n }, deps)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+C;AAExC,SAAS,eAAe,QAA4C,MAAsB;AAC/F,8BAAU,MAAM;AACd,QAAI,YAAY;AAChB,QAAI,UAAsC;AAE1C,UAAM,iBAAiB,YAAY;AACjC,UAAI;AACF,kBAAU,MAAM,OAAO;AAEvB,YAAI,WAAW;AACb,oBAAU;AACV,oBAAU;AAAA,QACZ;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,MAAM,uBAAuB,EAAE,OAAO,KAAK,CAAC;AAAA,MACtD;AAAA,IACF;AAEA,mBAAe;AAEf,WAAO,MAAM;AACX,kBAAY;AACZ,UAAI;AACF,kBAAU;AAAA,MACZ,SAAS,OAAO;AACd,gBAAQ,MAAM,+BAA+B,EAAE,OAAO,KAAK,CAAC;AAAA,MAC9D;AAAA,IACF;AAAA,EACF,GAAG,IAAI;AACT;","names":[]}
|
|
@@ -19,22 +19,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var use_store_exports = {};
|
|
21
21
|
__export(use_store_exports, {
|
|
22
|
-
StoreContext: () => StoreContext,
|
|
23
22
|
useStore: () => useStore
|
|
24
23
|
});
|
|
25
24
|
module.exports = __toCommonJS(use_store_exports);
|
|
26
|
-
var
|
|
27
|
-
const StoreContext = (0, import_react.createContext)(null);
|
|
25
|
+
var import_use_react_runtime = require("./use-react-runtime");
|
|
28
26
|
function useStore() {
|
|
29
|
-
|
|
30
|
-
if (store == null) {
|
|
31
|
-
throw new Error("`useStore` must be used within a `StoreProvider`");
|
|
32
|
-
}
|
|
33
|
-
return store;
|
|
27
|
+
return (0, import_use_react_runtime.useReactRuntime)().store;
|
|
34
28
|
}
|
|
35
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
30
|
0 && (module.exports = {
|
|
37
|
-
StoreContext,
|
|
38
31
|
useStore
|
|
39
32
|
});
|
|
40
33
|
//# sourceMappingURL=use-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-store.ts"],"sourcesContent":["'use client'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/hooks/use-store.ts"],"sourcesContent":["'use client'\n\nimport { type Store } from '../../../state/store'\nimport { useReactRuntime } from './use-react-runtime'\n\nexport function useStore(): Store {\n return useReactRuntime().store\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,+BAAgC;AAEzB,SAAS,WAAkB;AAChC,aAAO,0CAAgB,EAAE;AAC3B;","names":[]}
|
|
@@ -19,38 +19,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
var host_api_client_exports = {};
|
|
21
21
|
__export(host_api_client_exports, {
|
|
22
|
-
MakeswiftHostApiClientProvider: () => MakeswiftHostApiClientProvider,
|
|
23
22
|
useMakeswiftHostApiClient: () => useMakeswiftHostApiClient
|
|
24
23
|
});
|
|
25
24
|
module.exports = __toCommonJS(host_api_client_exports);
|
|
26
|
-
var
|
|
27
|
-
var import_react = require("react");
|
|
28
|
-
var import_client = require("../../api/client");
|
|
29
|
-
const Context = (0, import_react.createContext)(
|
|
30
|
-
new import_client.MakeswiftHostApiClient({
|
|
31
|
-
uri: "https://api.makeswift.com/graphql",
|
|
32
|
-
fetch: async (url, init) => {
|
|
33
|
-
console.warn(
|
|
34
|
-
"Using fallback `fetch` implementation, resource revalidation may not work as expected.",
|
|
35
|
-
{ url }
|
|
36
|
-
);
|
|
37
|
-
return fetch(url, init);
|
|
38
|
-
},
|
|
39
|
-
siteVersion: null
|
|
40
|
-
})
|
|
41
|
-
);
|
|
25
|
+
var import_use_react_runtime = require("./hooks/use-react-runtime");
|
|
42
26
|
function useMakeswiftHostApiClient() {
|
|
43
|
-
return (0,
|
|
44
|
-
}
|
|
45
|
-
function MakeswiftHostApiClientProvider({
|
|
46
|
-
client,
|
|
47
|
-
children
|
|
48
|
-
}) {
|
|
49
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context.Provider, { value: client, children });
|
|
27
|
+
return (0, import_use_react_runtime.useReactRuntime)().hostApiClient;
|
|
50
28
|
}
|
|
51
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
30
|
0 && (module.exports = {
|
|
53
|
-
MakeswiftHostApiClientProvider,
|
|
54
31
|
useMakeswiftHostApiClient
|
|
55
32
|
});
|
|
56
33
|
//# sourceMappingURL=host-api-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/react/host-api-client.tsx"],"sourcesContent":["'use client'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/host-api-client.tsx"],"sourcesContent":["'use client'\n\nimport { MakeswiftHostApiClient } from '../../api/client'\n\nimport { useReactRuntime } from './hooks/use-react-runtime'\n\nexport function useMakeswiftHostApiClient(): MakeswiftHostApiClient {\n return useReactRuntime().hostApiClient\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,+BAAgC;AAEzB,SAAS,4BAAoD;AAClE,aAAO,0CAAgB,EAAE;AAC3B;","names":[]}
|
|
@@ -20,9 +20,7 @@ var react_exports = {};
|
|
|
20
20
|
__export(react_exports, {
|
|
21
21
|
DocumentRoot: () => import_DocumentRoot.DocumentRoot,
|
|
22
22
|
Element: () => import_Element.Element,
|
|
23
|
-
ReactRuntime: () => import_react_runtime.ReactRuntime,
|
|
24
23
|
RuntimeProvider: () => import_RuntimeProvider.RuntimeProvider,
|
|
25
|
-
StoreContext: () => import_use_store.StoreContext,
|
|
26
24
|
useBreakpoints: () => import_use_breakpoints.useBreakpoints,
|
|
27
25
|
useBuilderEditMode: () => import_use_builder_edit_mode.useBuilderEditMode,
|
|
28
26
|
useDocumentKey: () => import_use_document_context.useDocumentKey,
|
|
@@ -33,7 +31,6 @@ __export(react_exports, {
|
|
|
33
31
|
useStore: () => import_use_store.useStore
|
|
34
32
|
});
|
|
35
33
|
module.exports = __toCommonJS(react_exports);
|
|
36
|
-
var import_react_runtime = require("./react-runtime");
|
|
37
34
|
var import_Element = require("./components/Element");
|
|
38
35
|
var import_DocumentRoot = require("./components/DocumentRoot");
|
|
39
36
|
var import_RuntimeProvider = require("./components/RuntimeProvider");
|
|
@@ -49,9 +46,7 @@ var import_use_store = require("./hooks/use-store");
|
|
|
49
46
|
0 && (module.exports = {
|
|
50
47
|
DocumentRoot,
|
|
51
48
|
Element,
|
|
52
|
-
ReactRuntime,
|
|
53
49
|
RuntimeProvider,
|
|
54
|
-
StoreContext,
|
|
55
50
|
useBreakpoints,
|
|
56
51
|
useBuilderEditMode,
|
|
57
52
|
useDocumentKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/react/index.ts"],"sourcesContent":["export {
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/index.ts"],"sourcesContent":["export { Element } from './components/Element'\nexport { DocumentRoot } from './components/DocumentRoot'\nexport { RuntimeProvider } from './components/RuntimeProvider'\n\nexport { useBreakpoints } from './hooks/use-breakpoints'\nexport { useBuilderEditMode } from './hooks/use-builder-edit-mode'\nexport { useDocumentKey } from './hooks/use-document-context'\nexport { useElementId } from './hooks/use-element-id'\nexport { useIsInBuilder } from './hooks/use-is-in-builder'\nexport { useIsReadOnly } from './hooks/use-is-read-only'\nexport { useSelector } from './hooks/use-selector'\nexport { useStore } from './hooks/use-store'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AACxB,0BAA6B;AAC7B,6BAAgC;AAEhC,6BAA+B;AAC/B,mCAAmC;AACnC,kCAA+B;AAC/B,4BAA6B;AAC7B,+BAA+B;AAC/B,8BAA8B;AAC9B,0BAA4B;AAC5B,uBAAyB;","names":[]}
|
|
@@ -64,9 +64,6 @@ class ReactRuntimeCore extends import_runtime_core.RuntimeCore {
|
|
|
64
64
|
unregisterReactComponent();
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
constructor({ breakpoints } = {}) {
|
|
68
|
-
super({ breakpoints });
|
|
69
|
-
}
|
|
70
67
|
}
|
|
71
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
72
69
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/react/react-runtime-core.ts"],"sourcesContent":["import { ControlDefinition as UnifiedControlDefinition } from '@makeswift/controls'\n\nimport { type LegacyDescriptor, type DescriptorValueType } from '../../prop-controllers/descriptors'\n\nimport { supportsActivity } from './components/activity-with-fallback'\n\nimport {\n registerComponentEffect,\n registerReactComponentEffect,\n} from '../../state/actions/internal/read-only-actions'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/react-runtime-core.ts"],"sourcesContent":["import { ControlDefinition as UnifiedControlDefinition } from '@makeswift/controls'\n\nimport { type LegacyDescriptor, type DescriptorValueType } from '../../prop-controllers/descriptors'\n\nimport { supportsActivity } from './components/activity-with-fallback'\n\nimport {\n registerComponentEffect,\n registerReactComponentEffect,\n} from '../../state/actions/internal/read-only-actions'\n\nimport { ComponentIcon } from '../../state/modules/components-meta'\nimport type { ComponentType } from '../../state/read-only-state'\n\nimport { RuntimeCore } from './runtime-core'\n\nfunction validateComponentType(type: string, component?: ComponentType): void {\n const componentName = component?.name ?? 'Component'\n if (typeof type !== 'string' || type === '') {\n throw new Error(\n `${componentName}: A non-empty string \\`type\\` is required for component registration, got ${type}`,\n )\n }\n}\n\nexport class ReactRuntimeCore extends RuntimeCore {\n registerComponent<\n ControlDef extends UnifiedControlDefinition,\n P extends Record<string, LegacyDescriptor | ControlDef>,\n C extends ComponentType<{ [K in keyof P]: DescriptorValueType<P[K]> }>,\n >(\n component: C,\n {\n type,\n label,\n icon = ComponentIcon.Cube,\n hidden = false,\n description,\n builtinSuspense,\n props,\n }: {\n type: string\n label: string\n icon?: ComponentIcon\n hidden?: boolean\n description?: string\n /**\n * In React <= 19.1, controls the default `<Suspense>` boundary.\n * Ignored in React >= 19.2; components are always wrapped in `<Activity>`.\n * Defaults to `true`.\n */\n builtinSuspense?: boolean\n props?: P\n },\n ): () => void {\n validateComponentType(type, component as unknown as ComponentType)\n\n const unregisterComponent = this.store.dispatch(\n registerComponentEffect(\n type,\n { label, icon, hidden, description, builtinSuspense },\n props ?? {},\n ),\n )\n\n if (supportsActivity() && builtinSuspense !== undefined) {\n console.warn(\n 'builtinSuspense is ignored in React >= 19.2; components are always wrapped in <Activity>.',\n )\n }\n\n const unregisterReactComponent = this.store.dispatch(\n registerReactComponentEffect(type, component as unknown as ComponentType),\n )\n\n return () => {\n unregisterComponent()\n unregisterReactComponent()\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oCAAiC;AAEjC,+BAGO;AAEP,6BAA8B;AAG9B,0BAA4B;AAE5B,SAAS,sBAAsB,MAAc,WAAiC;AAC5E,QAAM,gBAAgB,WAAW,QAAQ;AACzC,MAAI,OAAO,SAAS,YAAY,SAAS,IAAI;AAC3C,UAAM,IAAI;AAAA,MACR,GAAG,aAAa,6EAA6E,IAAI;AAAA,IACnG;AAAA,EACF;AACF;AAEO,MAAM,yBAAyB,gCAAY;AAAA,EAChD,kBAKE,WACA;AAAA,IACE;AAAA,IACA;AAAA,IACA,OAAO,qCAAc;AAAA,IACrB,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAcY;AACZ,0BAAsB,MAAM,SAAqC;AAEjE,UAAM,sBAAsB,KAAK,MAAM;AAAA,UACrC;AAAA,QACE;AAAA,QACA,EAAE,OAAO,MAAM,QAAQ,aAAa,gBAAgB;AAAA,QACpD,SAAS,CAAC;AAAA,MACZ;AAAA,IACF;AAEA,YAAI,gDAAiB,KAAK,oBAAoB,QAAW;AACvD,cAAQ;AAAA,QACN;AAAA,MACF;AAAA,IACF;AAEA,UAAM,2BAA2B,KAAK,MAAM;AAAA,UAC1C,uDAA6B,MAAM,SAAqC;AAAA,IAC1E;AAEA,WAAO,MAAM;AACX,0BAAoB;AACpB,+BAAyB;AAAA,IAC3B;AAAA,EACF;AACF;","names":[]}
|
|
@@ -24,8 +24,8 @@ module.exports = __toCommonJS(react_runtime_exports);
|
|
|
24
24
|
var import_register = require("../../components/builtin/register");
|
|
25
25
|
var import_react_runtime_core = require("./react-runtime-core");
|
|
26
26
|
class ReactRuntime extends import_react_runtime_core.ReactRuntimeCore {
|
|
27
|
-
constructor(
|
|
28
|
-
super(
|
|
27
|
+
constructor(...args) {
|
|
28
|
+
super(...args);
|
|
29
29
|
(0, import_register.registerBuiltinComponents)(this);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/react/react-runtime.ts"],"sourcesContent":["import { registerBuiltinComponents } from '../../components/builtin/register'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/react-runtime.ts"],"sourcesContent":["import { registerBuiltinComponents } from '../../components/builtin/register'\nimport { ReactRuntimeCore } from './react-runtime-core'\n\nexport class ReactRuntime extends ReactRuntimeCore {\n constructor(...args: ConstructorParameters<typeof ReactRuntimeCore>) {\n super(...args)\n registerBuiltinComponents(this)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0C;AAC1C,gCAAiC;AAE1B,MAAM,qBAAqB,2CAAiB;AAAA,EACjD,eAAe,MAAsD;AACnE,UAAM,GAAG,IAAI;AACb,mDAA0B,IAAI;AAAA,EAChC;AACF;","names":[]}
|
|
@@ -21,19 +21,51 @@ __export(runtime_core_exports, {
|
|
|
21
21
|
RuntimeCore: () => RuntimeCore
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(runtime_core_exports);
|
|
24
|
+
var import_client = require("../../api/client");
|
|
24
25
|
var import_breakpoints = require("../../state/modules/breakpoints");
|
|
25
26
|
var import_copy_element_tree = require("../../state/ops/copy-element-tree");
|
|
26
27
|
var import_read_only_state = require("../../state/read-only-state");
|
|
27
|
-
var
|
|
28
|
+
var import_store = require("../../state/store");
|
|
29
|
+
var import_builder = require("../../builder");
|
|
30
|
+
var import_read_only_actions = require("../../state/actions/internal/read-only-actions");
|
|
28
31
|
class RuntimeCore {
|
|
29
32
|
store;
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
hostApiClient;
|
|
34
|
+
appOrigin;
|
|
35
|
+
apiOrigin;
|
|
36
|
+
constructor({
|
|
37
|
+
appOrigin = "https://app.makeswift.com",
|
|
38
|
+
apiOrigin = "https://api.makeswift.com",
|
|
39
|
+
breakpoints,
|
|
40
|
+
fetch
|
|
41
|
+
}) {
|
|
42
|
+
this.appOrigin = validateOrigin(appOrigin, "appOrigin");
|
|
43
|
+
this.apiOrigin = validateOrigin(apiOrigin, "apiOrigin");
|
|
44
|
+
this.hostApiClient = new import_client.MakeswiftHostApiClient({
|
|
45
|
+
uri: new URL("graphql", this.apiOrigin).href,
|
|
46
|
+
fetch
|
|
47
|
+
});
|
|
48
|
+
this.store = (0, import_store.configureStore)({
|
|
32
49
|
name: "Runtime store",
|
|
50
|
+
hostApiClient: this.hostApiClient,
|
|
51
|
+
appOrigin: this.appOrigin,
|
|
33
52
|
preloadedState: null,
|
|
34
53
|
breakpoints: breakpoints ? (0, import_breakpoints.parseBreakpointsInput)(breakpoints) : void 0
|
|
35
54
|
});
|
|
36
55
|
}
|
|
56
|
+
setIdempotent({
|
|
57
|
+
siteVersion,
|
|
58
|
+
isReadOnly,
|
|
59
|
+
locale
|
|
60
|
+
}) {
|
|
61
|
+
this.store.dispatch((0, import_read_only_actions.setSiteVersion)(siteVersion));
|
|
62
|
+
this.store.dispatch((0, import_read_only_actions.setIsReadOnly)(isReadOnly));
|
|
63
|
+
this.store.dispatch(locale != null ? (0, import_builder.setLocale)(new Intl.Locale(locale)) : (0, import_read_only_actions.resetLocaleState)());
|
|
64
|
+
}
|
|
65
|
+
async setupStore({ isReadOnly }) {
|
|
66
|
+
const unloadReadWriteState = await this.store.loadReadWriteState({ isReadOnly });
|
|
67
|
+
return () => unloadReadWriteState();
|
|
68
|
+
}
|
|
37
69
|
copyElementTree(elementTree, replacementContext) {
|
|
38
70
|
return (0, import_copy_element_tree.copyElementTree)(this.store.getState(), elementTree, replacementContext);
|
|
39
71
|
}
|
|
@@ -41,6 +73,13 @@ class RuntimeCore {
|
|
|
41
73
|
return (0, import_read_only_state.getBreakpoints)(this.store.getState());
|
|
42
74
|
}
|
|
43
75
|
}
|
|
76
|
+
function validateOrigin(url, name) {
|
|
77
|
+
try {
|
|
78
|
+
return new URL(url).origin;
|
|
79
|
+
} catch {
|
|
80
|
+
throw new Error(`The Makeswift runtime received an invalid \`${name}\` parameter: "${url}".`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
44
83
|
// Annotate the CommonJS export names for ESM import in node:
|
|
45
84
|
0 && (module.exports = {
|
|
46
85
|
RuntimeCore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/runtimes/react/runtime-core.ts"],"sourcesContent":["import { type SerializableReplacementContext } from '@makeswift/controls'\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 { configureStore, type Store } from '../../state/
|
|
1
|
+
{"version":3,"sources":["../../../../src/runtimes/react/runtime-core.ts"],"sourcesContent":["import { type SerializableReplacementContext } from '@makeswift/controls'\n\nimport { MakeswiftHostApiClient } from '../../api/client'\nimport * as MakeswiftApiClient from '../../state/makeswift-api-client'\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 { configureStore, type Store } from '../../state/store'\nimport { setLocale } from '../../builder'\nimport {\n resetLocaleState,\n setIsReadOnly,\n setSiteVersion,\n} from '../../state/actions/internal/read-only-actions'\n\nexport class RuntimeCore {\n readonly store: Store\n readonly hostApiClient: MakeswiftHostApiClient\n readonly appOrigin: string\n readonly apiOrigin: string\n\n constructor({\n appOrigin = 'https://app.makeswift.com',\n apiOrigin = 'https://api.makeswift.com',\n breakpoints,\n fetch,\n }: {\n appOrigin?: string\n apiOrigin?: string\n breakpoints?: BreakpointsInput\n fetch: MakeswiftApiClient.HttpFetch\n }) {\n this.appOrigin = validateOrigin(appOrigin, 'appOrigin')\n this.apiOrigin = validateOrigin(apiOrigin, 'apiOrigin')\n\n this.hostApiClient = new MakeswiftHostApiClient({\n uri: new URL('graphql', this.apiOrigin).href,\n fetch: fetch,\n })\n\n this.store = configureStore({\n name: 'Runtime store',\n hostApiClient: this.hostApiClient,\n appOrigin: this.appOrigin,\n preloadedState: null,\n breakpoints: breakpoints ? parseBreakpointsInput(breakpoints) : undefined,\n })\n }\n\n setIdempotent({\n siteVersion,\n isReadOnly,\n locale,\n }: {\n siteVersion: SiteVersion | null\n isReadOnly: boolean\n locale: string | undefined\n }): void {\n this.store.dispatch(setSiteVersion(siteVersion))\n this.store.dispatch(setIsReadOnly(isReadOnly))\n this.store.dispatch(locale != null ? setLocale(new Intl.Locale(locale)) : resetLocaleState())\n }\n\n async setupStore({ isReadOnly }: { isReadOnly: boolean }): Promise<() => void> {\n const unloadReadWriteState = await this.store.loadReadWriteState({ isReadOnly })\n return () => unloadReadWriteState()\n }\n\n copyElementTree(\n elementTree: ElementData,\n replacementContext: SerializableReplacementContext,\n ): Element {\n return copyElementTree(this.store.getState(), elementTree, replacementContext)\n }\n\n getBreakpoints(): Breakpoints {\n return getBreakpoints(this.store.getState())\n }\n}\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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAuC;AAIvC,yBAIO;AAEP,+BAAgC;AAEhC,6BAA+D;AAC/D,mBAA2C;AAC3C,qBAA0B;AAC1B,+BAIO;AAEA,MAAM,YAAY;AAAA,EACd;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY;AAAA,IACV,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,EACF,GAKG;AACD,SAAK,YAAY,eAAe,WAAW,WAAW;AACtD,SAAK,YAAY,eAAe,WAAW,WAAW;AAEtD,SAAK,gBAAgB,IAAI,qCAAuB;AAAA,MAC9C,KAAK,IAAI,IAAI,WAAW,KAAK,SAAS,EAAE;AAAA,MACxC;AAAA,IACF,CAAC;AAED,SAAK,YAAQ,6BAAe;AAAA,MAC1B,MAAM;AAAA,MACN,eAAe,KAAK;AAAA,MACpB,WAAW,KAAK;AAAA,MAChB,gBAAgB;AAAA,MAChB,aAAa,kBAAc,0CAAsB,WAAW,IAAI;AAAA,IAClE,CAAC;AAAA,EACH;AAAA,EAEA,cAAc;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAIS;AACP,SAAK,MAAM,aAAS,yCAAe,WAAW,CAAC;AAC/C,SAAK,MAAM,aAAS,wCAAc,UAAU,CAAC;AAC7C,SAAK,MAAM,SAAS,UAAU,WAAO,0BAAU,IAAI,KAAK,OAAO,MAAM,CAAC,QAAI,2CAAiB,CAAC;AAAA,EAC9F;AAAA,EAEA,MAAM,WAAW,EAAE,WAAW,GAAiD;AAC7E,UAAM,uBAAuB,MAAM,KAAK,MAAM,mBAAmB,EAAE,WAAW,CAAC;AAC/E,WAAO,MAAM,qBAAqB;AAAA,EACpC;AAAA,EAEA,gBACE,aACA,oBACS;AACT,eAAO,0CAAgB,KAAK,MAAM,SAAS,GAAG,aAAa,kBAAkB;AAAA,EAC/E;AAAA,EAEA,iBAA8B;AAC5B,eAAO,uCAAe,KAAK,MAAM,SAAS,CAAC;AAAA,EAC7C;AACF;AAEA,SAAS,eAAe,KAAa,MAAsB;AACzD,MAAI;AACF,WAAO,IAAI,IAAI,GAAG,EAAE;AAAA,EACtB,QAAQ;AACN,UAAM,IAAI,MAAM,+CAA+C,IAAI,kBAAkB,GAAG,IAAI;AAAA,EAC9F;AACF;","names":[]}
|
|
@@ -21,9 +21,10 @@ __export(react_runtime_exports, {
|
|
|
21
21
|
createReactRuntime: () => createReactRuntime
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(react_runtime_exports);
|
|
24
|
+
var import_fixtures = require("../../../testing/fixtures");
|
|
24
25
|
var import_react_runtime = require("../react-runtime");
|
|
25
26
|
function createReactRuntime() {
|
|
26
|
-
return new import_react_runtime.ReactRuntime();
|
|
27
|
+
return new import_react_runtime.ReactRuntime({ fetch, ...import_fixtures.TestOrigins });
|
|
27
28
|
}
|
|
28
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
30
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/runtimes/react/testing/react-runtime.tsx"],"sourcesContent":["import { ReactRuntime } from '../react-runtime'\n\nexport function createReactRuntime() {\n return new ReactRuntime()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAA6B;AAEtB,SAAS,qBAAqB;AACnC,SAAO,IAAI,kCAAa;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/runtimes/react/testing/react-runtime.tsx"],"sourcesContent":["import { TestOrigins } from '../../../testing/fixtures'\nimport { ReactRuntime } from '../react-runtime'\n\nexport function createReactRuntime() {\n return new ReactRuntime({ fetch, ...TestOrigins })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA4B;AAC5B,2BAA6B;AAEtB,SAAS,qBAAqB;AACnC,SAAO,IAAI,kCAAa,EAAE,OAAO,GAAG,4BAAY,CAAC;AACnD;","names":[]}
|
|
@@ -21,7 +21,7 @@ __export(makeswift_api_client_sync_exports, {
|
|
|
21
21
|
makeswiftApiClientSyncMiddleware: () => makeswiftApiClientSyncMiddleware
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(makeswift_api_client_sync_exports);
|
|
24
|
-
var import_toolkit2 = require("
|
|
24
|
+
var import_toolkit2 = require("../toolkit");
|
|
25
25
|
function makeswiftApiClientSyncMiddleware(client) {
|
|
26
26
|
return (0, import_toolkit2.actionMiddleware)(() => (next) => {
|
|
27
27
|
return (action) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/middleware/makeswift-api-client-sync.ts"],"sourcesContent":["import { type Middleware } from '@reduxjs/toolkit'\n\nimport { MakeswiftHostApiClient } from '../../api/client'\n\nimport { type Action } from '../actions'\nimport { actionMiddleware } from '../toolkit'\nimport { type State, type Dispatch } from '../unified-state'\n\nexport function makeswiftApiClientSyncMiddleware(\n client: MakeswiftHostApiClient,\n): Middleware<Dispatch, State, Dispatch> {\n return actionMiddleware(() => next => {\n return (action: Action) => {\n client.makeswiftApiClient.dispatch(action)\n\n return next(action)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,IAAAA,kBAAiC;AAG1B,SAAS,iCACd,QACuC;AACvC,aAAO,kCAAiB,MAAM,UAAQ;AACpC,WAAO,CAAC,WAAmB;AACzB,aAAO,mBAAmB,SAAS,MAAM;AAEzC,aAAO,KAAK,MAAM;AAAA,IACpB;AAAA,EACF,CAAC;AACH;","names":["import_toolkit"]}
|
|
@@ -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 read_write_exports = {};
|
|
20
|
+
__export(read_write_exports, {
|
|
21
|
+
createReadWriteMiddleware: () => createReadWriteMiddleware
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(read_write_exports);
|
|
24
|
+
var import_update_element_tree = require("./update-element-tree");
|
|
25
|
+
var import_measure_box_models = require("./measure-box-models");
|
|
26
|
+
var import_builder_api = require("./builder-api");
|
|
27
|
+
var import_prop_controller_handles = require("./prop-controller-handles");
|
|
28
|
+
function createReadWriteMiddleware({ builderProxy }) {
|
|
29
|
+
return [
|
|
30
|
+
(0, import_update_element_tree.updateElementTreeMiddleware)(),
|
|
31
|
+
(0, import_measure_box_models.measureBoxModelsMiddleware)(),
|
|
32
|
+
(0, import_builder_api.builderAPIMiddleware)(builderProxy),
|
|
33
|
+
(0, import_prop_controller_handles.propControllerHandlesMiddleware)()
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
createReadWriteMiddleware
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/state/middleware/read-write/index.ts"],"sourcesContent":["import { type BuilderAPIProxy } from '../../builder-api/proxy'\n\nimport { updateElementTreeMiddleware } from './update-element-tree'\nimport { measureBoxModelsMiddleware } from './measure-box-models'\nimport { builderAPIMiddleware } from './builder-api'\nimport { propControllerHandlesMiddleware } from './prop-controller-handles'\n\nexport function createReadWriteMiddleware({ builderProxy }: { builderProxy: BuilderAPIProxy }) {\n return [\n updateElementTreeMiddleware(),\n measureBoxModelsMiddleware(),\n builderAPIMiddleware(builderProxy),\n propControllerHandlesMiddleware(),\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iCAA4C;AAC5C,gCAA2C;AAC3C,yBAAqC;AACrC,qCAAgD;AAEzC,SAAS,0BAA0B,EAAE,aAAa,GAAsC;AAC7F,SAAO;AAAA,QACL,wDAA4B;AAAA,QAC5B,sDAA2B;AAAA,QAC3B,yCAAqB,YAAY;AAAA,QACjC,gEAAgC;AAAA,EAClC;AACF;","names":[]}
|