@makeswift/runtime 0.28.1-canary.0 → 0.28.1-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-handler/handlers/manifest.js +1 -1
- package/dist/cjs/api-handler/handlers/webhook/diff-projection.js +62 -0
- package/dist/cjs/api-handler/handlers/webhook/diff-projection.js.map +1 -0
- package/dist/cjs/api-handler/handlers/webhook/site-published.js +2 -2
- package/dist/cjs/api-handler/handlers/webhook/site-published.js.map +1 -1
- package/dist/cjs/api-handler/handlers/webhook/types.js +6 -1
- package/dist/cjs/api-handler/handlers/webhook/types.js.map +1 -1
- package/dist/cjs/api-handler/index.js.map +1 -1
- package/dist/cjs/client/index.js +3 -3
- package/dist/cjs/global.d.js.map +1 -1
- package/dist/cjs/state/builder-api/api.js.map +1 -1
- package/dist/cjs/state/builder-api/navigation-listener.js +31 -11
- package/dist/cjs/state/builder-api/navigation-listener.js.map +1 -1
- package/dist/cjs/unstable-framework-support/index.js.map +1 -1
- package/dist/esm/api-handler/handlers/manifest.js +1 -1
- package/dist/esm/api-handler/handlers/webhook/diff-projection.js +38 -0
- package/dist/esm/api-handler/handlers/webhook/diff-projection.js.map +1 -0
- package/dist/esm/api-handler/handlers/webhook/site-published.js +2 -2
- package/dist/esm/api-handler/handlers/webhook/site-published.js.map +1 -1
- package/dist/esm/api-handler/handlers/webhook/types.js +6 -1
- package/dist/esm/api-handler/handlers/webhook/types.js.map +1 -1
- package/dist/esm/api-handler/index.js.map +1 -1
- package/dist/esm/client/index.js +3 -3
- package/dist/esm/global.d.js.map +1 -1
- package/dist/esm/state/builder-api/navigation-listener.js +31 -11
- package/dist/esm/state/builder-api/navigation-listener.js.map +1 -1
- package/dist/esm/unstable-framework-support/index.js +3 -1
- package/dist/esm/unstable-framework-support/index.js.map +1 -1
- package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts +201 -0
- package/dist/types/api-handler/handlers/webhook/diff-projection.d.ts.map +1 -0
- package/dist/types/api-handler/handlers/webhook/site-published.d.ts +1 -1
- package/dist/types/api-handler/handlers/webhook/site-published.d.ts.map +1 -1
- package/dist/types/api-handler/handlers/webhook/types.d.ts +672 -1
- package/dist/types/api-handler/handlers/webhook/types.d.ts.map +1 -1
- package/dist/types/api-handler/index.d.ts +2 -2
- package/dist/types/api-handler/index.d.ts.map +1 -1
- package/dist/types/state/builder-api/api.d.ts +2 -1
- package/dist/types/state/builder-api/api.d.ts.map +1 -1
- package/dist/types/state/builder-api/navigation-listener.d.ts +2 -5
- package/dist/types/state/builder-api/navigation-listener.d.ts.map +1 -1
- package/dist/types/unstable-framework-support/index.d.ts +1 -1
- package/dist/types/unstable-framework-support/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -28,7 +28,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
28
28
|
return import_request_response.ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
29
29
|
}
|
|
30
30
|
return import_request_response.ApiResponse.json({
|
|
31
|
-
version: "0.28.1-canary.
|
|
31
|
+
version: "0.28.1-canary.2",
|
|
32
32
|
interactionMode: true,
|
|
33
33
|
clientSideNavigation: false,
|
|
34
34
|
elementFromPoint: false,
|
|
@@ -0,0 +1,62 @@
|
|
|
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 diff_projection_exports = {};
|
|
20
|
+
__export(diff_projection_exports, {
|
|
21
|
+
diffProjectionSchema: () => diffProjectionSchema
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(diff_projection_exports);
|
|
24
|
+
var import_zod = require("zod");
|
|
25
|
+
const changeTypeSchema = import_zod.z.enum(["created", "updated", "deleted"]);
|
|
26
|
+
const componentChangeSchema = import_zod.z.object({
|
|
27
|
+
id: import_zod.z.string(),
|
|
28
|
+
locale: import_zod.z.string().nullable(),
|
|
29
|
+
changeType: changeTypeSchema
|
|
30
|
+
});
|
|
31
|
+
const pageChangeSchema = import_zod.z.object({
|
|
32
|
+
pageId: import_zod.z.string().uuid(),
|
|
33
|
+
locale: import_zod.z.string().nullable(),
|
|
34
|
+
changeType: changeTypeSchema,
|
|
35
|
+
pathname: import_zod.z.string(),
|
|
36
|
+
previousPathname: import_zod.z.string().optional()
|
|
37
|
+
});
|
|
38
|
+
const globalElementChangeSchema = import_zod.z.object({
|
|
39
|
+
id: import_zod.z.string().uuid(),
|
|
40
|
+
locale: import_zod.z.string().nullable(),
|
|
41
|
+
changeType: changeTypeSchema
|
|
42
|
+
});
|
|
43
|
+
const swatchChangeSchema = import_zod.z.object({
|
|
44
|
+
id: import_zod.z.string().uuid(),
|
|
45
|
+
changeType: changeTypeSchema
|
|
46
|
+
});
|
|
47
|
+
const typographyChangeSchema = import_zod.z.object({
|
|
48
|
+
id: import_zod.z.string().uuid(),
|
|
49
|
+
changeType: changeTypeSchema
|
|
50
|
+
});
|
|
51
|
+
const diffProjectionSchema = import_zod.z.object({
|
|
52
|
+
components: import_zod.z.array(componentChangeSchema),
|
|
53
|
+
pages: import_zod.z.array(pageChangeSchema),
|
|
54
|
+
globalElements: import_zod.z.array(globalElementChangeSchema),
|
|
55
|
+
swatches: import_zod.z.array(swatchChangeSchema),
|
|
56
|
+
typographies: import_zod.z.array(typographyChangeSchema)
|
|
57
|
+
}).passthrough();
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
diffProjectionSchema
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=diff-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/diff-projection.ts"],"sourcesContent":["import { z } from 'zod'\n\nconst changeTypeSchema = z.enum(['created', 'updated', 'deleted'])\n\n// `locale` is null for the default locale. We'd prefer explicit locale strings\n// (e.g. \"en-US\"), but both server and runtime treat the default locale as null\n// today — changing that requires a broader localization rework.\nconst componentChangeSchema = z.object({\n id: z.string(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n})\n\nconst pageChangeSchema = z.object({\n pageId: z.string().uuid(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n pathname: z.string(),\n previousPathname: z.string().optional(),\n})\n\nconst globalElementChangeSchema = z.object({\n id: z.string().uuid(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n})\n\nconst swatchChangeSchema = z.object({\n id: z.string().uuid(),\n changeType: changeTypeSchema,\n})\n\nconst typographyChangeSchema = z.object({\n id: z.string().uuid(),\n changeType: changeTypeSchema,\n})\n\nexport const diffProjectionSchema = z\n .object({\n components: z.array(componentChangeSchema),\n pages: z.array(pageChangeSchema),\n globalElements: z.array(globalElementChangeSchema),\n swatches: z.array(swatchChangeSchema),\n typographies: z.array(typographyChangeSchema),\n })\n // passthrough() preserves unknown resource types the server may add in the\n // future (e.g. `fonts`), so onPublish consumers can access them without a\n // runtime upgrade.\n .passthrough()\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAElB,MAAM,mBAAmB,aAAE,KAAK,CAAC,WAAW,WAAW,SAAS,CAAC;AAKjE,MAAM,wBAAwB,aAAE,OAAO;AAAA,EACrC,IAAI,aAAE,OAAO;AAAA,EACb,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AACd,CAAC;AAED,MAAM,mBAAmB,aAAE,OAAO;AAAA,EAChC,QAAQ,aAAE,OAAO,EAAE,KAAK;AAAA,EACxB,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AAAA,EACZ,UAAU,aAAE,OAAO;AAAA,EACnB,kBAAkB,aAAE,OAAO,EAAE,SAAS;AACxC,CAAC;AAED,MAAM,4BAA4B,aAAE,OAAO;AAAA,EACzC,IAAI,aAAE,OAAO,EAAE,KAAK;AAAA,EACpB,QAAQ,aAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AACd,CAAC;AAED,MAAM,qBAAqB,aAAE,OAAO;AAAA,EAClC,IAAI,aAAE,OAAO,EAAE,KAAK;AAAA,EACpB,YAAY;AACd,CAAC;AAED,MAAM,yBAAyB,aAAE,OAAO;AAAA,EACtC,IAAI,aAAE,OAAO,EAAE,KAAK;AAAA,EACpB,YAAY;AACd,CAAC;AAEM,MAAM,uBAAuB,aACjC,OAAO;AAAA,EACN,YAAY,aAAE,MAAM,qBAAqB;AAAA,EACzC,OAAO,aAAE,MAAM,gBAAgB;AAAA,EAC/B,gBAAgB,aAAE,MAAM,yBAAyB;AAAA,EACjD,UAAU,aAAE,MAAM,kBAAkB;AAAA,EACpC,cAAc,aAAE,MAAM,sBAAsB;AAC9C,CAAC,EAIA,YAAY;","names":[]}
|
|
@@ -21,10 +21,10 @@ __export(site_published_exports, {
|
|
|
21
21
|
handleSitePublished: () => handleSitePublished
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(site_published_exports);
|
|
24
|
-
async function handleSitePublished(
|
|
24
|
+
async function handleSitePublished(payload, { onPublish, revalidate }) {
|
|
25
25
|
revalidate();
|
|
26
26
|
try {
|
|
27
|
-
await onPublish?.();
|
|
27
|
+
await onPublish?.(payload.data);
|
|
28
28
|
} catch (error) {
|
|
29
29
|
console.error("Unhandled exception in the 'onPublish' callback:", error);
|
|
30
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/site-published.ts"],"sourcesContent":["import {\n type OnPublish,\n type SitePublishedWebhookPayload,\n type WebhookHandlerResult,\n} from './types'\n\ntype SitePublishedParams = {\n onPublish?: OnPublish\n revalidate: () => void\n}\n\nexport async function handleSitePublished(\n
|
|
1
|
+
{"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/site-published.ts"],"sourcesContent":["import {\n type OnPublish,\n type SitePublishedWebhookPayload,\n type WebhookHandlerResult,\n} from './types'\n\ntype SitePublishedParams = {\n onPublish?: OnPublish\n revalidate: () => void\n}\n\nexport async function handleSitePublished(\n payload: SitePublishedWebhookPayload,\n { onPublish, revalidate }: SitePublishedParams,\n): Promise<WebhookHandlerResult> {\n revalidate()\n\n try {\n await onPublish?.(payload.data)\n } catch (error) {\n // log and ignore any error in user-provided onPublish\n console.error(\"Unhandled exception in the 'onPublish' callback:\", error)\n }\n\n return { body: { success: true }, status: 200 }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,eAAsB,oBACpB,SACA,EAAE,WAAW,WAAW,GACO;AAC/B,aAAW;AAEX,MAAI;AACF,UAAM,YAAY,QAAQ,IAAI;AAAA,EAChC,SAAS,OAAO;AAEd,YAAQ,MAAM,oDAAoD,KAAK;AAAA,EACzE;AAEA,SAAO,EAAE,MAAM,EAAE,SAAS,KAAK,GAAG,QAAQ,IAAI;AAChD;","names":[]}
|
|
@@ -23,6 +23,7 @@ __export(types_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(types_exports);
|
|
25
25
|
var import_zod = require("zod");
|
|
26
|
+
var import_diff_projection = require("./diff-projection");
|
|
26
27
|
const WebhookEventType = {
|
|
27
28
|
SITE_PUBLISHED: "site.published"
|
|
28
29
|
};
|
|
@@ -34,7 +35,11 @@ const sitePublishedWebhookPayloadSchema = import_zod.z.object({
|
|
|
34
35
|
from: import_zod.z.string().uuid().nullable(),
|
|
35
36
|
to: import_zod.z.string().uuid()
|
|
36
37
|
}),
|
|
37
|
-
at: import_zod.z.number()
|
|
38
|
+
at: import_zod.z.number(),
|
|
39
|
+
// catch(undefined) ensures a server-side schema change never breaks the
|
|
40
|
+
// webhook handler — if parsing fails, unstable_diff degrades to undefined
|
|
41
|
+
// and the consumer falls back to full revalidation.
|
|
42
|
+
unstable_diff: import_diff_projection.diffProjectionSchema.nullable().optional().catch(void 0)
|
|
38
43
|
})
|
|
39
44
|
});
|
|
40
45
|
const webhookPayloadSchema = sitePublishedWebhookPayloadSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/types.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { type ErrorResponseBody } from '../../request-response'\n\nexport const WebhookEventType = {\n SITE_PUBLISHED: 'site.published',\n} as const\n\nexport const sitePublishedWebhookPayloadSchema = z.object({\n type: z.literal(WebhookEventType.SITE_PUBLISHED),\n data: z.object({\n siteId: z.string().uuid(),\n publish: z.object({\n from: z.string().uuid().nullable(),\n to: z.string().uuid(),\n }),\n at: z.number(),\n }),\n})\n\nexport type SitePublishedWebhookPayload = z.infer<typeof sitePublishedWebhookPayloadSchema>\n\nconst webhookPayloadSchema = sitePublishedWebhookPayloadSchema\n\nexport type WebhookPayloadSchema = z.infer<typeof webhookPayloadSchema>\n\ntype WebhookSuccessBody = { success: true }\n\nexport type WebhookResponseBody = WebhookSuccessBody | ErrorResponseBody\n\nexport type WebhookHandlerResult = {\n body: WebhookResponseBody\n status: 200\n}\n\nexport type OnPublish = () => void | Promise<void>\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/types.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { type ErrorResponseBody } from '../../request-response'\nimport { diffProjectionSchema } from './diff-projection'\n\nexport const WebhookEventType = {\n SITE_PUBLISHED: 'site.published',\n} as const\n\nexport const sitePublishedWebhookPayloadSchema = z.object({\n type: z.literal(WebhookEventType.SITE_PUBLISHED),\n data: z.object({\n siteId: z.string().uuid(),\n publish: z.object({\n from: z.string().uuid().nullable(),\n to: z.string().uuid(),\n }),\n at: z.number(),\n // catch(undefined) ensures a server-side schema change never breaks the\n // webhook handler — if parsing fails, unstable_diff degrades to undefined\n // and the consumer falls back to full revalidation.\n unstable_diff: diffProjectionSchema.nullable().optional().catch(undefined),\n }),\n})\n\nexport type SitePublishedWebhookPayload = z.infer<typeof sitePublishedWebhookPayloadSchema>\n\nexport type SitePublishedWebhookPayloadData = z.infer<\n typeof sitePublishedWebhookPayloadSchema\n>['data']\n\nconst webhookPayloadSchema = sitePublishedWebhookPayloadSchema\n\nexport type WebhookPayloadSchema = z.infer<typeof webhookPayloadSchema>\n\ntype WebhookSuccessBody = { success: true }\n\nexport type WebhookResponseBody = WebhookSuccessBody | ErrorResponseBody\n\nexport type WebhookHandlerResult = {\n body: WebhookResponseBody\n status: 200\n}\n\nexport type OnPublish = (payload: SitePublishedWebhookPayloadData) => void | Promise<void>\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAGlB,6BAAqC;AAE9B,MAAM,mBAAmB;AAAA,EAC9B,gBAAgB;AAClB;AAEO,MAAM,oCAAoC,aAAE,OAAO;AAAA,EACxD,MAAM,aAAE,QAAQ,iBAAiB,cAAc;AAAA,EAC/C,MAAM,aAAE,OAAO;AAAA,IACb,QAAQ,aAAE,OAAO,EAAE,KAAK;AAAA,IACxB,SAAS,aAAE,OAAO;AAAA,MAChB,MAAM,aAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA,MACjC,IAAI,aAAE,OAAO,EAAE,KAAK;AAAA,IACtB,CAAC;AAAA,IACD,IAAI,aAAE,OAAO;AAAA;AAAA;AAAA;AAAA,IAIb,eAAe,4CAAqB,SAAS,EAAE,SAAS,EAAE,MAAM,MAAS;AAAA,EAC3E,CAAC;AACH,CAAC;AAQD,MAAM,uBAAuB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/api-handler/index.ts"],"sourcesContent":["import { Match, match as matchPattern } from 'path-to-regexp'\n\nimport { APIResource } from '../api'\nimport { ApiHandlerHeaders, deserializeSiteVersion } from '../api/site-version'\n\nimport { MakeswiftClient } from '../client'\nimport { type ReactRuntimeCore } from '../runtimes/react/react-runtime-core'\n\nimport { redirectLiveHandler } from './handlers/redirect-live'\nimport { elementTreeHandler } from './handlers/element-tree'\nimport { fontsHandler, type Font, type GetFonts } from './handlers/fonts'\nimport { manifestHandler, type Manifest } from './handlers/manifest'\nimport { mergeTranslatedDataHandler } from './handlers/merge-translated-data'\nimport { revalidateHandler } from './handlers/revalidate'\nimport { translatableDataHandler } from './handlers/translatable-data'\nimport { webhookHandler } from './handlers/webhook'\nimport { type OnPublish } from './handlers/webhook/types'\n\nimport {\n type ApiRequest,\n type ErrorResponseBody,\n ApiResponse,\n searchParams,\n} from './request-response'\n\nimport { applyCorsHeaders } from './cors'\n\nexport type { Manifest, Font }\n\ntype Events = { onPublish: OnPublish }\n\nexport type ApiHandlerUserConfig = {\n runtime: ReactRuntimeCore\n getFonts?: GetFonts\n events?: Events\n}\n\nexport type ApiHandlerInternalConfig = {\n client: MakeswiftClient\n manifest?: Partial<Manifest>\n revalidationHandler: (path?: string) => Promise<void>\n previewCookieNames: string[]\n}\n\ntype ApiHandlerConfig = ApiHandlerUserConfig & ApiHandlerInternalConfig\n\ntype ResponseType =\n | Awaited<\n | ReturnType<typeof redirectLiveHandler>\n | ReturnType<typeof elementTreeHandler>\n | ReturnType<typeof fontsHandler>\n | ReturnType<typeof manifestHandler>\n | ReturnType<typeof mergeTranslatedDataHandler>\n | ReturnType<typeof revalidateHandler>\n | ReturnType<typeof translatableDataHandler>\n | ReturnType<typeof webhookHandler>\n >\n | ApiResponse<APIResource>\n | ApiResponse<ErrorResponseBody>\n | Response\n\ntype ApiHandler = (req: ApiRequest, route: string) => Promise<ResponseType>\n\nexport function createApiHandler(\n apiKey: string,\n {\n runtime,\n getFonts,\n events,\n client,\n manifest,\n revalidationHandler,\n previewCookieNames,\n }: ApiHandlerConfig,\n): ApiHandler {\n if (typeof apiKey !== 'string') {\n throw new Error(\n 'The Makeswift API handler must be passed a valid Makeswift site API key. ' +\n `Received \"${apiKey}\" instead.`,\n )\n }\n\n return async function (req: ApiRequest, route: string): Promise<ResponseType> {\n const res =\n req.method.toUpperCase() !== 'OPTIONS'\n ? await apiRouteHandler(req, route)\n : new Response(null, { status: 204, headers: [['Content-Length', '0']] })\n\n applyCorsHeaders(res.headers, {\n origin: runtime.appOrigin,\n allowedHeaders: ['Content-Type', 'Authorization'],\n })\n\n return res\n }\n\n async function apiRouteHandler(req: ApiRequest, route: string): Promise<ResponseType> {\n const versionHeader = req.headers.get(ApiHandlerHeaders.SiteVersion)\n\n const siteVersion = versionHeader != null ? deserializeSiteVersion(versionHeader) : null\n\n const matches = <T extends object>(pattern: string): Match<T> =>\n matchPattern<T>(pattern, { decode: decodeURIComponent })(route)\n\n if (matches('/redirect-live')) return redirectLiveHandler(req, { previewCookieNames })\n if (matches('/element-tree')) return elementTreeHandler(req, { runtime })\n if (matches('/fonts')) return fontsHandler(req, { getFonts })\n if (matches('/manifest')) return manifestHandler(req, { apiKey, manifest })\n if (matches('/merge-translated-data')) return mergeTranslatedDataHandler(req, { client })\n if (matches('/revalidate')) {\n return revalidateHandler(req, { apiKey, revalidatePath: revalidationHandler })\n }\n\n if (matches('/translatable-data')) return translatableDataHandler(req, { client })\n if (matches('/webhook')) {\n return webhookHandler(req, { apiKey, events, revalidate: revalidationHandler })\n }\n\n const handleResource = <T extends APIResource>(\n resource: T | null,\n ): ApiResponse<APIResource | ErrorResponseBody> => {\n return resource !== null\n ? ApiResponse.json(resource)\n : ApiResponse.json({ message: 'Not Found' }, { status: 404 })\n }\n\n let m\n\n if ((m = matches<{ id: string }>('/swatches/:id'))) {\n return client.getSwatch(m.params.id, siteVersion).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/files/:id'))) {\n return client.getFile(m.params.id).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/typographies/:id'))) {\n return client.getTypography(m.params.id, siteVersion).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/global-elements/:id'))) {\n return client.getGlobalElement(m.params.id, siteVersion).then(handleResource)\n }\n\n if (\n (m = matches<{ globalElementId: string; locale: string }>(\n '/localized-global-elements/:globalElementId/:locale',\n ))\n ) {\n return client\n .getLocalizedGlobalElement(m.params.globalElementId, m.params.locale, siteVersion)\n .then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/page-pathname-slices/:id'))) {\n const localeParam = searchParams(req).get('locale')\n const locale = typeof localeParam === 'string' ? localeParam : undefined\n\n return client.getPagePathnameSlice(m.params.id, siteVersion, { locale }).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/tables/:id'))) {\n return client.getTable(m.params.id).then(handleResource)\n }\n\n return ApiResponse.json({ message: 'Not Found' }, { status: 404 })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA6C;AAG7C,0BAA0D;AAK1D,2BAAoC;AACpC,0BAAmC;AACnC,mBAAuD;AACvD,sBAA+C;AAC/C,mCAA2C;AAC3C,wBAAkC;AAClC,+BAAwC;AACxC,qBAA+B;AAG/B,8BAKO;AAEP,kBAAiC;AAsC1B,SAAS,iBACd,QACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,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,SAAS,EAAE,OAAO,EAAE,EAAE,KAAK,cAAc;AAAA,IACzD;AAEA,WAAO,oCAAY,KAAK,EAAE,SAAS,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACnE;AACF;","names":["matchPattern"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/api-handler/index.ts"],"sourcesContent":["import { Match, match as matchPattern } from 'path-to-regexp'\n\nimport { APIResource } from '../api'\nimport { ApiHandlerHeaders, deserializeSiteVersion } from '../api/site-version'\n\nimport { MakeswiftClient } from '../client'\nimport { type ReactRuntimeCore } from '../runtimes/react/react-runtime-core'\n\nimport { redirectLiveHandler } from './handlers/redirect-live'\nimport { elementTreeHandler } from './handlers/element-tree'\nimport { fontsHandler, type Font, type GetFonts } from './handlers/fonts'\nimport { manifestHandler, type Manifest } from './handlers/manifest'\nimport { mergeTranslatedDataHandler } from './handlers/merge-translated-data'\nimport { revalidateHandler } from './handlers/revalidate'\nimport { translatableDataHandler } from './handlers/translatable-data'\nimport { webhookHandler } from './handlers/webhook'\nimport { type OnPublish, type SitePublishedWebhookPayloadData } from './handlers/webhook/types'\n\nimport {\n type ApiRequest,\n type ErrorResponseBody,\n ApiResponse,\n searchParams,\n} from './request-response'\n\nimport { applyCorsHeaders } from './cors'\n\nexport type { Manifest, Font, SitePublishedWebhookPayloadData }\n\ntype Events = { onPublish: OnPublish }\n\nexport type ApiHandlerUserConfig = {\n runtime: ReactRuntimeCore\n getFonts?: GetFonts\n events?: Events\n}\n\nexport type ApiHandlerInternalConfig = {\n client: MakeswiftClient\n manifest?: Partial<Manifest>\n revalidationHandler: (path?: string) => Promise<void>\n previewCookieNames: string[]\n}\n\ntype ApiHandlerConfig = ApiHandlerUserConfig & ApiHandlerInternalConfig\n\ntype ResponseType =\n | Awaited<\n | ReturnType<typeof redirectLiveHandler>\n | ReturnType<typeof elementTreeHandler>\n | ReturnType<typeof fontsHandler>\n | ReturnType<typeof manifestHandler>\n | ReturnType<typeof mergeTranslatedDataHandler>\n | ReturnType<typeof revalidateHandler>\n | ReturnType<typeof translatableDataHandler>\n | ReturnType<typeof webhookHandler>\n >\n | ApiResponse<APIResource>\n | ApiResponse<ErrorResponseBody>\n | Response\n\ntype ApiHandler = (req: ApiRequest, route: string) => Promise<ResponseType>\n\nexport function createApiHandler(\n apiKey: string,\n {\n runtime,\n getFonts,\n events,\n client,\n manifest,\n revalidationHandler,\n previewCookieNames,\n }: ApiHandlerConfig,\n): ApiHandler {\n if (typeof apiKey !== 'string') {\n throw new Error(\n 'The Makeswift API handler must be passed a valid Makeswift site API key. ' +\n `Received \"${apiKey}\" instead.`,\n )\n }\n\n return async function (req: ApiRequest, route: string): Promise<ResponseType> {\n const res =\n req.method.toUpperCase() !== 'OPTIONS'\n ? await apiRouteHandler(req, route)\n : new Response(null, { status: 204, headers: [['Content-Length', '0']] })\n\n applyCorsHeaders(res.headers, {\n origin: runtime.appOrigin,\n allowedHeaders: ['Content-Type', 'Authorization'],\n })\n\n return res\n }\n\n async function apiRouteHandler(req: ApiRequest, route: string): Promise<ResponseType> {\n const versionHeader = req.headers.get(ApiHandlerHeaders.SiteVersion)\n\n const siteVersion = versionHeader != null ? deserializeSiteVersion(versionHeader) : null\n\n const matches = <T extends object>(pattern: string): Match<T> =>\n matchPattern<T>(pattern, { decode: decodeURIComponent })(route)\n\n if (matches('/redirect-live')) return redirectLiveHandler(req, { previewCookieNames })\n if (matches('/element-tree')) return elementTreeHandler(req, { runtime })\n if (matches('/fonts')) return fontsHandler(req, { getFonts })\n if (matches('/manifest')) return manifestHandler(req, { apiKey, manifest })\n if (matches('/merge-translated-data')) return mergeTranslatedDataHandler(req, { client })\n if (matches('/revalidate')) {\n return revalidateHandler(req, { apiKey, revalidatePath: revalidationHandler })\n }\n\n if (matches('/translatable-data')) return translatableDataHandler(req, { client })\n if (matches('/webhook')) {\n return webhookHandler(req, { apiKey, events, revalidate: revalidationHandler })\n }\n\n const handleResource = <T extends APIResource>(\n resource: T | null,\n ): ApiResponse<APIResource | ErrorResponseBody> => {\n return resource !== null\n ? ApiResponse.json(resource)\n : ApiResponse.json({ message: 'Not Found' }, { status: 404 })\n }\n\n let m\n\n if ((m = matches<{ id: string }>('/swatches/:id'))) {\n return client.getSwatch(m.params.id, siteVersion).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/files/:id'))) {\n return client.getFile(m.params.id).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/typographies/:id'))) {\n return client.getTypography(m.params.id, siteVersion).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/global-elements/:id'))) {\n return client.getGlobalElement(m.params.id, siteVersion).then(handleResource)\n }\n\n if (\n (m = matches<{ globalElementId: string; locale: string }>(\n '/localized-global-elements/:globalElementId/:locale',\n ))\n ) {\n return client\n .getLocalizedGlobalElement(m.params.globalElementId, m.params.locale, siteVersion)\n .then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/page-pathname-slices/:id'))) {\n const localeParam = searchParams(req).get('locale')\n const locale = typeof localeParam === 'string' ? localeParam : undefined\n\n return client.getPagePathnameSlice(m.params.id, siteVersion, { locale }).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/tables/:id'))) {\n return client.getTable(m.params.id).then(handleResource)\n }\n\n return ApiResponse.json({ message: 'Not Found' }, { status: 404 })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA6C;AAG7C,0BAA0D;AAK1D,2BAAoC;AACpC,0BAAmC;AACnC,mBAAuD;AACvD,sBAA+C;AAC/C,mCAA2C;AAC3C,wBAAkC;AAClC,+BAAwC;AACxC,qBAA+B;AAG/B,8BAKO;AAEP,kBAAiC;AAsC1B,SAAS,iBACd,QACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GACY;AACZ,MAAI,OAAO,WAAW,UAAU;AAC9B,UAAM,IAAI;AAAA,MACR,sFACe,MAAM;AAA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,CAAC;AAAA,EACnE;AACF;","names":["matchPattern"]}
|
package/dist/cjs/client/index.js
CHANGED
|
@@ -211,7 +211,7 @@ Received "${apiKey}" instead.`
|
|
|
211
211
|
}
|
|
212
212
|
this.apiKey = apiKey;
|
|
213
213
|
this.graphqlClient = new import_client.GraphQLClient(new URL("graphql", runtime.apiOrigin).href, {
|
|
214
|
-
"makeswift-runtime-version": "0.28.1-canary.
|
|
214
|
+
"makeswift-runtime-version": "0.28.1-canary.2"
|
|
215
215
|
});
|
|
216
216
|
this.runtime = runtime;
|
|
217
217
|
}
|
|
@@ -223,7 +223,7 @@ Received "${apiKey}" instead.`
|
|
|
223
223
|
const requestHeaders = new Headers({
|
|
224
224
|
"x-api-key": this.apiKey,
|
|
225
225
|
"makeswift-site-api-key": this.apiKey,
|
|
226
|
-
"makeswift-runtime-version": "0.28.1-canary.
|
|
226
|
+
"makeswift-runtime-version": "0.28.1-canary.2"
|
|
227
227
|
});
|
|
228
228
|
if (siteVersion?.token) {
|
|
229
229
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -681,7 +681,7 @@ Received "${apiKey}" instead.`
|
|
|
681
681
|
headers: {
|
|
682
682
|
"x-api-key": this.apiKey,
|
|
683
683
|
"makeswift-site-api-key": this.apiKey,
|
|
684
|
-
"makeswift-runtime-version": "0.28.1-canary.
|
|
684
|
+
"makeswift-runtime-version": "0.28.1-canary.2",
|
|
685
685
|
"content-type": "application/json"
|
|
686
686
|
},
|
|
687
687
|
body: JSON.stringify({ token }),
|
package/dist/cjs/global.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/global.d.ts"],"sourcesContent":["import '@emotion/jest'\n\ndeclare global {\n const PACKAGE_VERSION: string\n\n // partial typings for the new Navigation API, see\n // https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API\n interface NavigateEvent extends Event {\n readonly navigationType: 'push' | 'reload' | 'replace' | 'traverse'\n readonly destination: {\n readonly id: string\n readonly index: number\n readonly key: string\n readonly sameDocument: boolean\n readonly url: string\n }\n\n readonly hashChange: boolean\n readonly userInitiated: boolean\n }\n\n interface Navigation {\n addEventListener(type: 'navigate', listener: (event: NavigateEvent) => void): void\n removeEventListener(type: 'navigate', listener: (event: NavigateEvent) => void): void\n }\n\n interface Window {\n navigation?: Navigation\n }\n}\n\nexport {}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAAA,kBAAO;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/global.d.ts"],"sourcesContent":["import '@emotion/jest'\n\ndeclare global {\n const PACKAGE_VERSION: string\n\n // partial typings for the new Navigation API, see\n // https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API\n interface NavigateEvent extends Event {\n readonly navigationType: 'push' | 'reload' | 'replace' | 'traverse'\n readonly destination: {\n readonly id: string\n readonly index: number\n readonly key: string\n readonly sameDocument: boolean\n readonly url: string\n }\n\n readonly hashChange: boolean\n readonly userInitiated: boolean\n }\n\n interface NavigationHistoryEntry {\n readonly id: string\n readonly index: number\n readonly key: string\n readonly sameDocument: boolean\n readonly url: string | null\n }\n\n interface Navigation {\n addEventListener(type: 'navigate', listener: (event: NavigateEvent) => void): void\n removeEventListener(type: 'navigate', listener: (event: NavigateEvent) => void): void\n addEventListener(type: 'navigatesuccess', listener: (event: Event) => void): void\n removeEventListener(type: 'navigatesuccess', listener: (event: Event) => void): void\n\n readonly currentEntry: NavigationHistoryEntry\n }\n\n interface Window {\n navigation?: Navigation\n }\n}\n\nexport {}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;AAAA,kBAAO;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/state/builder-api/api.ts"],"sourcesContent":["export type HostNavigationEvent = {\n url: string | null\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/builder-api/api.ts"],"sourcesContent":["export type HostNavigationEvent = {\n url: string | null\n navigationCompleted?: 'initial-page-load' | 'client-side-navigation'\n // indicates whether the navigation event was captured via the Navigation API or\n // via our polyfill for browsers lacking Navigation API support\n polyfilled?: boolean\n}\n\nexport type BuilderApi = {\n handleHostNavigate(event: HostNavigationEvent): void\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -22,16 +22,17 @@ __export(navigation_listener_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(navigation_listener_exports);
|
|
24
24
|
const CLICK_NAVIGATION_THRESHOLD_MS = 100;
|
|
25
|
-
const
|
|
25
|
+
const CLICK_NAVIGATION_CHECK_INTERVAL_MS = 200;
|
|
26
|
+
const CLICK_NAVIGATION_MAX_CHECKS = 20;
|
|
26
27
|
function setupNavigationListener(callback) {
|
|
27
28
|
let previousLocation = null;
|
|
28
29
|
const handleNavigate = (event) => {
|
|
29
|
-
if (event.url === previousLocation)
|
|
30
|
+
if (!event.navigationCompleted && event.url === previousLocation)
|
|
30
31
|
return;
|
|
31
32
|
callback(event);
|
|
32
33
|
previousLocation = event.url;
|
|
33
34
|
};
|
|
34
|
-
handleNavigate({ url: windowLocation(),
|
|
35
|
+
handleNavigate({ url: windowLocation(), navigationCompleted: "initial-page-load" });
|
|
35
36
|
if (typeof window === "undefined") {
|
|
36
37
|
return () => {
|
|
37
38
|
};
|
|
@@ -39,9 +40,19 @@ function setupNavigationListener(callback) {
|
|
|
39
40
|
const unsubscribes = [];
|
|
40
41
|
if ("navigation" in window && window.navigation) {
|
|
41
42
|
const navigation = window.navigation;
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const navigateHandler = ({ destination }) => handleNavigate({ url: destination.url });
|
|
44
|
+
const navigateSuccessHandler = () => {
|
|
45
|
+
handleNavigate({
|
|
46
|
+
url: navigation.currentEntry.url,
|
|
47
|
+
navigationCompleted: "client-side-navigation"
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
navigation.addEventListener("navigate", navigateHandler);
|
|
51
|
+
navigation.addEventListener("navigatesuccess", navigateSuccessHandler);
|
|
52
|
+
unsubscribes.push(() => navigation.removeEventListener("navigate", navigateHandler));
|
|
53
|
+
unsubscribes.push(
|
|
54
|
+
() => navigation.removeEventListener("navigatesuccess", navigateSuccessHandler)
|
|
55
|
+
);
|
|
45
56
|
return () => {
|
|
46
57
|
unsubscribes.forEach((u) => u());
|
|
47
58
|
};
|
|
@@ -52,10 +63,19 @@ function setupNavigationListener(callback) {
|
|
|
52
63
|
if (!a)
|
|
53
64
|
return;
|
|
54
65
|
lastClickEvent = { href: a.href, timestamp: Date.now() };
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
66
|
+
const pageUrlBeforeClick = windowLocation();
|
|
67
|
+
let navigationCheckCounter = 0;
|
|
68
|
+
const checkIfNavigationOccurred = () => {
|
|
69
|
+
const url = windowLocation();
|
|
70
|
+
if (url !== pageUrlBeforeClick) {
|
|
71
|
+
handleNavigate({ url, polyfilled: true });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (++navigationCheckCounter < CLICK_NAVIGATION_MAX_CHECKS) {
|
|
75
|
+
window.setTimeout(checkIfNavigationOccurred, CLICK_NAVIGATION_CHECK_INTERVAL_MS);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
window.setTimeout(checkIfNavigationOccurred, CLICK_NAVIGATION_CHECK_INTERVAL_MS);
|
|
59
79
|
};
|
|
60
80
|
window.document.addEventListener(
|
|
61
81
|
"click",
|
|
@@ -72,7 +92,7 @@ function setupNavigationListener(callback) {
|
|
|
72
92
|
const msSinceLastClick = Date.now() - lastClickEvent.timestamp;
|
|
73
93
|
handleNavigate({
|
|
74
94
|
url: msSinceLastClick < CLICK_NAVIGATION_THRESHOLD_MS ? lastClickEvent.href ?? null : null,
|
|
75
|
-
|
|
95
|
+
polyfilled: true
|
|
76
96
|
});
|
|
77
97
|
lastClickEvent = null;
|
|
78
98
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/state/builder-api/navigation-listener.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/state/builder-api/navigation-listener.ts"],"sourcesContent":["import { type HostNavigationEvent } from './api'\n\ntype ClickEvent = {\n href: string\n timestamp: number\n}\n\nconst CLICK_NAVIGATION_THRESHOLD_MS = 100\nconst CLICK_NAVIGATION_CHECK_INTERVAL_MS = 200\nconst CLICK_NAVIGATION_MAX_CHECKS = 20\n\nexport function setupNavigationListener(\n callback: (args: HostNavigationEvent) => void,\n): VoidFunction {\n let previousLocation: string | null = null\n\n const handleNavigate = (event: HostNavigationEvent) => {\n if (!event.navigationCompleted && event.url === previousLocation) return\n\n callback(event)\n previousLocation = event.url\n }\n\n // trigger navigation callback on initial page load\n handleNavigate({ url: windowLocation(), navigationCompleted: 'initial-page-load' })\n\n if (typeof window === 'undefined') {\n return () => {}\n }\n\n const unsubscribes: (() => void)[] = []\n\n // check for availability of the Navigation API (baseline feature since January 2026),\n // see https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API\n if ('navigation' in window && window.navigation) {\n const navigation = window.navigation\n\n const navigateHandler = ({ destination }: NavigateEvent) =>\n handleNavigate({ url: destination.url })\n\n const navigateSuccessHandler = () => {\n handleNavigate({\n url: navigation.currentEntry.url,\n navigationCompleted: 'client-side-navigation',\n })\n }\n\n // note that in order to capture destination URLs that might not be Makeswift-enabled,\n // we send a `SiteNavigationEvent` at the start of navigation, but do not track whether\n // the navigation was successful or not (possible future improvement)\n navigation.addEventListener('navigate', navigateHandler)\n navigation.addEventListener('navigatesuccess', navigateSuccessHandler)\n unsubscribes.push(() => navigation.removeEventListener('navigate', navigateHandler))\n unsubscribes.push(() =>\n navigation.removeEventListener('navigatesuccess', navigateSuccessHandler),\n )\n\n return () => {\n unsubscribes.forEach(u => u())\n }\n }\n\n // for browsers lacking Navigation API support, we manually track:\n // - link clicks to capture destination URLs\n // - page unload events to detect cross-page navigation\n //\n // this works well enough to keep this polyfill in place for now, but not nearly as\n // reliably as the Navigation API\n let lastClickEvent: ClickEvent | null = null\n\n const clickHandler = (e: MouseEvent) => {\n const a =\n e.composedPath?.()?.find(n => n instanceof HTMLAnchorElement) ??\n (e.target instanceof Element && e.target.closest?.('a'))\n\n if (!a) return\n\n lastClickEvent = { href: a.href, timestamp: Date.now() }\n\n const pageUrlBeforeClick = windowLocation()\n let navigationCheckCounter = 0\n\n // handle navigation between pages in the host; note that we intentionally are\n // not cancelling the timer on cleanup to ensure we report the navigation\n const checkIfNavigationOccurred = () => {\n const url = windowLocation()\n\n if (url !== pageUrlBeforeClick) {\n // the host navigated to a different page, report the new URL to the builder\n handleNavigate({ url, polyfilled: true })\n return\n }\n\n // we're still on the same page, recheck until the max number of checks is reached\n if (++navigationCheckCounter < CLICK_NAVIGATION_MAX_CHECKS) {\n window.setTimeout(checkIfNavigationOccurred, CLICK_NAVIGATION_CHECK_INTERVAL_MS)\n }\n }\n\n window.setTimeout(checkIfNavigationOccurred, CLICK_NAVIGATION_CHECK_INTERVAL_MS)\n }\n\n window.document.addEventListener(\n 'click',\n clickHandler,\n { capture: true }, // run before bubbling to fortify against `stopPropagation()` calls\n )\n\n unsubscribes.push(() =>\n window.document.removeEventListener('click', clickHandler, { capture: true }),\n )\n\n // handle external navigation\n const unloadHandler = () => {\n if (!lastClickEvent) return\n\n const msSinceLastClick = Date.now() - lastClickEvent.timestamp\n handleNavigate({\n url: msSinceLastClick < CLICK_NAVIGATION_THRESHOLD_MS ? (lastClickEvent.href ?? null) : null,\n polyfilled: true,\n })\n\n lastClickEvent = null\n }\n\n window.addEventListener('beforeunload', unloadHandler)\n unsubscribes.push(() => window.removeEventListener('beforeunload', unloadHandler))\n\n return () => {\n unsubscribes.forEach(u => u())\n }\n}\n\nconst windowLocation = (): string | null =>\n typeof window !== 'undefined' ? window.location.href : null\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,MAAM,gCAAgC;AACtC,MAAM,qCAAqC;A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AAM;AACtC,YAAM,MAAM,eAAe;AAE3B,UAAI,QAAQ,oBAAoB;AAE9B,uBAAe,EAAE,KAAK,YAAY,KAAK,CAAC;AACxC;AAAA,MACF;AAGA,UAAI,EAAE,yBAAyB,6BAA6B;AAC1D,eAAO,WAAW,2BAA2B,kCAAkC;AAAA,MACjF;AAAA,IACF;AAEA,WAAO,WAAW,2BAA2B,kCAAkC;AAAA,EACjF;AAEA,SAAO,SAAS;AAAA,IACd;AAAA,IACA;AAAA,IACA,EAAE,SAAS,KAAK;AAAA;AAAA,EAClB;AAEA,eAAa;AAAA,IAAK,MAChB,OAAO,SAAS,oBAAoB,SAAS,cAAc,EAAE,SAAS,KAAK,CAAC;AAAA,EAC9E;AAGA,QAAM,gBAAgB,MAAM;AAC1B,QAAI,CAAC;AAAgB;AAErB,UAAM,mBAAmB,KAAK,IAAI,IAAI,eAAe;AACrD,mBAAe;AAAA,MACb,KAAK,mBAAmB,gCAAiC,eAAe,QAAQ,OAAQ;AAAA,MACxF,YAAY;AAAA,IACd,CAAC;AAED,qBAAiB;AAAA,EACnB;AAEA,SAAO,iBAAiB,gBAAgB,aAAa;AACrD,eAAa,KAAK,MAAM,OAAO,oBAAoB,gBAAgB,aAAa,CAAC;AAEjF,SAAO,MAAM;AACX,iBAAa,QAAQ,OAAK,EAAE,CAAC;AAAA,EAC/B;AACF;AAEA,MAAM,iBAAiB,MACrB,OAAO,WAAW,cAAc,OAAO,SAAS,OAAO;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/unstable-framework-support/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n serializeSiteVersion,\n deserializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n} from '../api/site-version'\n\nexport {
|
|
1
|
+
{"version":3,"sources":["../../../src/unstable-framework-support/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n serializeSiteVersion,\n deserializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n} from '../api/site-version'\n\nexport {\n type ApiHandlerUserConfig,\n createApiHandler,\n type SitePublishedWebhookPayloadData,\n} from '../api-handler'\nexport { SET_COOKIE_HEADER, cookieSettingOptions } from '../api-handler/cookies'\nexport { REDIRECT_SEARCH_PARAM, redirectLiveHandler } from '../api-handler/handlers/redirect-live'\nexport { toApiRequest, pipeResponseTo } from '../api-handler/node-request-response'\nexport { MAKESWIFT_SITE_VERSION_COOKIE, SearchParams } from '../api-handler/preview'\n\nexport { MakeswiftClient } from '../client'\n\nexport { type BreakpointsInput as Breakpoints } from '../state/modules/breakpoints'\n\nexport {\n FrameworkContext,\n DefaultHead,\n DefaultHeadSnippet,\n DefaultImage,\n} from '../runtimes/react/components/framework-context'\n\nexport { MakeswiftComponent } from '../runtimes/react/components/MakeswiftComponent'\nexport { Page } from '../runtimes/react/components/page'\nexport { RuntimeProvider } from '../runtimes/react/components/RuntimeProvider'\nexport { Slot } from '../runtimes/react/components/Slot'\n\nexport { GoogleFontLink } from '../runtimes/react/components/GoogleFontLink'\nexport { MakeswiftFonts } from '../runtimes/react/components/MakeswiftFonts'\n\nexport {\n createRootStyleCache,\n RootStyleRegistry,\n styleTagHtml,\n StyleTagSSR,\n type RootStyleProps,\n} from '../runtimes/react/root-style-registry'\n\nexport { ReactRuntime } from '../runtimes/react/react-runtime'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAKO;AAEP,yBAIO;AACP,qBAAwD;AACxD,2BAA2D;AAC3D,mCAA6C;AAC7C,qBAA4D;AAE5D,oBAAgC;AAIhC,+BAKO;AAEP,gCAAmC;AACnC,kBAAqB;AACrB,6BAAgC;AAChC,kBAAqB;AAErB,4BAA+B;AAC/B,4BAA+B;AAE/B,iCAMO;AAEP,2BAA6B;","names":[]}
|
|
@@ -8,7 +8,7 @@ async function manifestHandler(req, { apiKey, manifest }) {
|
|
|
8
8
|
return ApiResponse.json({ message: "Unauthorized" }, { status: 401 });
|
|
9
9
|
}
|
|
10
10
|
return ApiResponse.json({
|
|
11
|
-
version: "0.28.1-canary.
|
|
11
|
+
version: "0.28.1-canary.2",
|
|
12
12
|
interactionMode: true,
|
|
13
13
|
clientSideNavigation: false,
|
|
14
14
|
elementFromPoint: false,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const changeTypeSchema = z.enum(["created", "updated", "deleted"]);
|
|
3
|
+
const componentChangeSchema = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
locale: z.string().nullable(),
|
|
6
|
+
changeType: changeTypeSchema
|
|
7
|
+
});
|
|
8
|
+
const pageChangeSchema = z.object({
|
|
9
|
+
pageId: z.string().uuid(),
|
|
10
|
+
locale: z.string().nullable(),
|
|
11
|
+
changeType: changeTypeSchema,
|
|
12
|
+
pathname: z.string(),
|
|
13
|
+
previousPathname: z.string().optional()
|
|
14
|
+
});
|
|
15
|
+
const globalElementChangeSchema = z.object({
|
|
16
|
+
id: z.string().uuid(),
|
|
17
|
+
locale: z.string().nullable(),
|
|
18
|
+
changeType: changeTypeSchema
|
|
19
|
+
});
|
|
20
|
+
const swatchChangeSchema = z.object({
|
|
21
|
+
id: z.string().uuid(),
|
|
22
|
+
changeType: changeTypeSchema
|
|
23
|
+
});
|
|
24
|
+
const typographyChangeSchema = z.object({
|
|
25
|
+
id: z.string().uuid(),
|
|
26
|
+
changeType: changeTypeSchema
|
|
27
|
+
});
|
|
28
|
+
const diffProjectionSchema = z.object({
|
|
29
|
+
components: z.array(componentChangeSchema),
|
|
30
|
+
pages: z.array(pageChangeSchema),
|
|
31
|
+
globalElements: z.array(globalElementChangeSchema),
|
|
32
|
+
swatches: z.array(swatchChangeSchema),
|
|
33
|
+
typographies: z.array(typographyChangeSchema)
|
|
34
|
+
}).passthrough();
|
|
35
|
+
export {
|
|
36
|
+
diffProjectionSchema
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=diff-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/diff-projection.ts"],"sourcesContent":["import { z } from 'zod'\n\nconst changeTypeSchema = z.enum(['created', 'updated', 'deleted'])\n\n// `locale` is null for the default locale. We'd prefer explicit locale strings\n// (e.g. \"en-US\"), but both server and runtime treat the default locale as null\n// today — changing that requires a broader localization rework.\nconst componentChangeSchema = z.object({\n id: z.string(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n})\n\nconst pageChangeSchema = z.object({\n pageId: z.string().uuid(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n pathname: z.string(),\n previousPathname: z.string().optional(),\n})\n\nconst globalElementChangeSchema = z.object({\n id: z.string().uuid(),\n locale: z.string().nullable(),\n changeType: changeTypeSchema,\n})\n\nconst swatchChangeSchema = z.object({\n id: z.string().uuid(),\n changeType: changeTypeSchema,\n})\n\nconst typographyChangeSchema = z.object({\n id: z.string().uuid(),\n changeType: changeTypeSchema,\n})\n\nexport const diffProjectionSchema = z\n .object({\n components: z.array(componentChangeSchema),\n pages: z.array(pageChangeSchema),\n globalElements: z.array(globalElementChangeSchema),\n swatches: z.array(swatchChangeSchema),\n typographies: z.array(typographyChangeSchema),\n })\n // passthrough() preserves unknown resource types the server may add in the\n // future (e.g. `fonts`), so onPublish consumers can access them without a\n // runtime upgrade.\n .passthrough()\n"],"mappings":"AAAA,SAAS,SAAS;AAElB,MAAM,mBAAmB,EAAE,KAAK,CAAC,WAAW,WAAW,SAAS,CAAC;AAKjE,MAAM,wBAAwB,EAAE,OAAO;AAAA,EACrC,IAAI,EAAE,OAAO;AAAA,EACb,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AACd,CAAC;AAED,MAAM,mBAAmB,EAAE,OAAO;AAAA,EAChC,QAAQ,EAAE,OAAO,EAAE,KAAK;AAAA,EACxB,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AAAA,EACZ,UAAU,EAAE,OAAO;AAAA,EACnB,kBAAkB,EAAE,OAAO,EAAE,SAAS;AACxC,CAAC;AAED,MAAM,4BAA4B,EAAE,OAAO;AAAA,EACzC,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,EACpB,QAAQ,EAAE,OAAO,EAAE,SAAS;AAAA,EAC5B,YAAY;AACd,CAAC;AAED,MAAM,qBAAqB,EAAE,OAAO;AAAA,EAClC,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,EACpB,YAAY;AACd,CAAC;AAED,MAAM,yBAAyB,EAAE,OAAO;AAAA,EACtC,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,EACpB,YAAY;AACd,CAAC;AAEM,MAAM,uBAAuB,EACjC,OAAO;AAAA,EACN,YAAY,EAAE,MAAM,qBAAqB;AAAA,EACzC,OAAO,EAAE,MAAM,gBAAgB;AAAA,EAC/B,gBAAgB,EAAE,MAAM,yBAAyB;AAAA,EACjD,UAAU,EAAE,MAAM,kBAAkB;AAAA,EACpC,cAAc,EAAE,MAAM,sBAAsB;AAC9C,CAAC,EAIA,YAAY;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
async function handleSitePublished(
|
|
1
|
+
async function handleSitePublished(payload, { onPublish, revalidate }) {
|
|
2
2
|
revalidate();
|
|
3
3
|
try {
|
|
4
|
-
await onPublish?.();
|
|
4
|
+
await onPublish?.(payload.data);
|
|
5
5
|
} catch (error) {
|
|
6
6
|
console.error("Unhandled exception in the 'onPublish' callback:", error);
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/site-published.ts"],"sourcesContent":["import {\n type OnPublish,\n type SitePublishedWebhookPayload,\n type WebhookHandlerResult,\n} from './types'\n\ntype SitePublishedParams = {\n onPublish?: OnPublish\n revalidate: () => void\n}\n\nexport async function handleSitePublished(\n
|
|
1
|
+
{"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/site-published.ts"],"sourcesContent":["import {\n type OnPublish,\n type SitePublishedWebhookPayload,\n type WebhookHandlerResult,\n} from './types'\n\ntype SitePublishedParams = {\n onPublish?: OnPublish\n revalidate: () => void\n}\n\nexport async function handleSitePublished(\n payload: SitePublishedWebhookPayload,\n { onPublish, revalidate }: SitePublishedParams,\n): Promise<WebhookHandlerResult> {\n revalidate()\n\n try {\n await onPublish?.(payload.data)\n } catch (error) {\n // log and ignore any error in user-provided onPublish\n console.error(\"Unhandled exception in the 'onPublish' callback:\", error)\n }\n\n return { body: { success: true }, status: 200 }\n}\n"],"mappings":"AAWA,eAAsB,oBACpB,SACA,EAAE,WAAW,WAAW,GACO;AAC/B,aAAW;AAEX,MAAI;AACF,UAAM,YAAY,QAAQ,IAAI;AAAA,EAChC,SAAS,OAAO;AAEd,YAAQ,MAAM,oDAAoD,KAAK;AAAA,EACzE;AAEA,SAAO,EAAE,MAAM,EAAE,SAAS,KAAK,GAAG,QAAQ,IAAI;AAChD;","names":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { diffProjectionSchema } from "./diff-projection";
|
|
2
3
|
const WebhookEventType = {
|
|
3
4
|
SITE_PUBLISHED: "site.published"
|
|
4
5
|
};
|
|
@@ -10,7 +11,11 @@ const sitePublishedWebhookPayloadSchema = z.object({
|
|
|
10
11
|
from: z.string().uuid().nullable(),
|
|
11
12
|
to: z.string().uuid()
|
|
12
13
|
}),
|
|
13
|
-
at: z.number()
|
|
14
|
+
at: z.number(),
|
|
15
|
+
// catch(undefined) ensures a server-side schema change never breaks the
|
|
16
|
+
// webhook handler — if parsing fails, unstable_diff degrades to undefined
|
|
17
|
+
// and the consumer falls back to full revalidation.
|
|
18
|
+
unstable_diff: diffProjectionSchema.nullable().optional().catch(void 0)
|
|
14
19
|
})
|
|
15
20
|
});
|
|
16
21
|
const webhookPayloadSchema = sitePublishedWebhookPayloadSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/types.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { type ErrorResponseBody } from '../../request-response'\n\nexport const WebhookEventType = {\n SITE_PUBLISHED: 'site.published',\n} as const\n\nexport const sitePublishedWebhookPayloadSchema = z.object({\n type: z.literal(WebhookEventType.SITE_PUBLISHED),\n data: z.object({\n siteId: z.string().uuid(),\n publish: z.object({\n from: z.string().uuid().nullable(),\n to: z.string().uuid(),\n }),\n at: z.number(),\n }),\n})\n\nexport type SitePublishedWebhookPayload = z.infer<typeof sitePublishedWebhookPayloadSchema>\n\nconst webhookPayloadSchema = sitePublishedWebhookPayloadSchema\n\nexport type WebhookPayloadSchema = z.infer<typeof webhookPayloadSchema>\n\ntype WebhookSuccessBody = { success: true }\n\nexport type WebhookResponseBody = WebhookSuccessBody | ErrorResponseBody\n\nexport type WebhookHandlerResult = {\n body: WebhookResponseBody\n status: 200\n}\n\nexport type OnPublish = () => void | Promise<void>\n"],"mappings":"AAAA,SAAS,SAAS;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/api-handler/handlers/webhook/types.ts"],"sourcesContent":["import { z } from 'zod'\n\nimport { type ErrorResponseBody } from '../../request-response'\nimport { diffProjectionSchema } from './diff-projection'\n\nexport const WebhookEventType = {\n SITE_PUBLISHED: 'site.published',\n} as const\n\nexport const sitePublishedWebhookPayloadSchema = z.object({\n type: z.literal(WebhookEventType.SITE_PUBLISHED),\n data: z.object({\n siteId: z.string().uuid(),\n publish: z.object({\n from: z.string().uuid().nullable(),\n to: z.string().uuid(),\n }),\n at: z.number(),\n // catch(undefined) ensures a server-side schema change never breaks the\n // webhook handler — if parsing fails, unstable_diff degrades to undefined\n // and the consumer falls back to full revalidation.\n unstable_diff: diffProjectionSchema.nullable().optional().catch(undefined),\n }),\n})\n\nexport type SitePublishedWebhookPayload = z.infer<typeof sitePublishedWebhookPayloadSchema>\n\nexport type SitePublishedWebhookPayloadData = z.infer<\n typeof sitePublishedWebhookPayloadSchema\n>['data']\n\nconst webhookPayloadSchema = sitePublishedWebhookPayloadSchema\n\nexport type WebhookPayloadSchema = z.infer<typeof webhookPayloadSchema>\n\ntype WebhookSuccessBody = { success: true }\n\nexport type WebhookResponseBody = WebhookSuccessBody | ErrorResponseBody\n\nexport type WebhookHandlerResult = {\n body: WebhookResponseBody\n status: 200\n}\n\nexport type OnPublish = (payload: SitePublishedWebhookPayloadData) => void | Promise<void>\n"],"mappings":"AAAA,SAAS,SAAS;AAGlB,SAAS,4BAA4B;AAE9B,MAAM,mBAAmB;AAAA,EAC9B,gBAAgB;AAClB;AAEO,MAAM,oCAAoC,EAAE,OAAO;AAAA,EACxD,MAAM,EAAE,QAAQ,iBAAiB,cAAc;AAAA,EAC/C,MAAM,EAAE,OAAO;AAAA,IACb,QAAQ,EAAE,OAAO,EAAE,KAAK;AAAA,IACxB,SAAS,EAAE,OAAO;AAAA,MAChB,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS;AAAA,MACjC,IAAI,EAAE,OAAO,EAAE,KAAK;AAAA,IACtB,CAAC;AAAA,IACD,IAAI,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA,IAIb,eAAe,qBAAqB,SAAS,EAAE,SAAS,EAAE,MAAM,MAAS;AAAA,EAC3E,CAAC;AACH,CAAC;AAQD,MAAM,uBAAuB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/api-handler/index.ts"],"sourcesContent":["import { Match, match as matchPattern } from 'path-to-regexp'\n\nimport { APIResource } from '../api'\nimport { ApiHandlerHeaders, deserializeSiteVersion } from '../api/site-version'\n\nimport { MakeswiftClient } from '../client'\nimport { type ReactRuntimeCore } from '../runtimes/react/react-runtime-core'\n\nimport { redirectLiveHandler } from './handlers/redirect-live'\nimport { elementTreeHandler } from './handlers/element-tree'\nimport { fontsHandler, type Font, type GetFonts } from './handlers/fonts'\nimport { manifestHandler, type Manifest } from './handlers/manifest'\nimport { mergeTranslatedDataHandler } from './handlers/merge-translated-data'\nimport { revalidateHandler } from './handlers/revalidate'\nimport { translatableDataHandler } from './handlers/translatable-data'\nimport { webhookHandler } from './handlers/webhook'\nimport { type OnPublish } from './handlers/webhook/types'\n\nimport {\n type ApiRequest,\n type ErrorResponseBody,\n ApiResponse,\n searchParams,\n} from './request-response'\n\nimport { applyCorsHeaders } from './cors'\n\nexport type { Manifest, Font }\n\ntype Events = { onPublish: OnPublish }\n\nexport type ApiHandlerUserConfig = {\n runtime: ReactRuntimeCore\n getFonts?: GetFonts\n events?: Events\n}\n\nexport type ApiHandlerInternalConfig = {\n client: MakeswiftClient\n manifest?: Partial<Manifest>\n revalidationHandler: (path?: string) => Promise<void>\n previewCookieNames: string[]\n}\n\ntype ApiHandlerConfig = ApiHandlerUserConfig & ApiHandlerInternalConfig\n\ntype ResponseType =\n | Awaited<\n | ReturnType<typeof redirectLiveHandler>\n | ReturnType<typeof elementTreeHandler>\n | ReturnType<typeof fontsHandler>\n | ReturnType<typeof manifestHandler>\n | ReturnType<typeof mergeTranslatedDataHandler>\n | ReturnType<typeof revalidateHandler>\n | ReturnType<typeof translatableDataHandler>\n | ReturnType<typeof webhookHandler>\n >\n | ApiResponse<APIResource>\n | ApiResponse<ErrorResponseBody>\n | Response\n\ntype ApiHandler = (req: ApiRequest, route: string) => Promise<ResponseType>\n\nexport function createApiHandler(\n apiKey: string,\n {\n runtime,\n getFonts,\n events,\n client,\n manifest,\n revalidationHandler,\n previewCookieNames,\n }: ApiHandlerConfig,\n): ApiHandler {\n if (typeof apiKey !== 'string') {\n throw new Error(\n 'The Makeswift API handler must be passed a valid Makeswift site API key. ' +\n `Received \"${apiKey}\" instead.`,\n )\n }\n\n return async function (req: ApiRequest, route: string): Promise<ResponseType> {\n const res =\n req.method.toUpperCase() !== 'OPTIONS'\n ? await apiRouteHandler(req, route)\n : new Response(null, { status: 204, headers: [['Content-Length', '0']] })\n\n applyCorsHeaders(res.headers, {\n origin: runtime.appOrigin,\n allowedHeaders: ['Content-Type', 'Authorization'],\n })\n\n return res\n }\n\n async function apiRouteHandler(req: ApiRequest, route: string): Promise<ResponseType> {\n const versionHeader = req.headers.get(ApiHandlerHeaders.SiteVersion)\n\n const siteVersion = versionHeader != null ? deserializeSiteVersion(versionHeader) : null\n\n const matches = <T extends object>(pattern: string): Match<T> =>\n matchPattern<T>(pattern, { decode: decodeURIComponent })(route)\n\n if (matches('/redirect-live')) return redirectLiveHandler(req, { previewCookieNames })\n if (matches('/element-tree')) return elementTreeHandler(req, { runtime })\n if (matches('/fonts')) return fontsHandler(req, { getFonts })\n if (matches('/manifest')) return manifestHandler(req, { apiKey, manifest })\n if (matches('/merge-translated-data')) return mergeTranslatedDataHandler(req, { client })\n if (matches('/revalidate')) {\n return revalidateHandler(req, { apiKey, revalidatePath: revalidationHandler })\n }\n\n if (matches('/translatable-data')) return translatableDataHandler(req, { client })\n if (matches('/webhook')) {\n return webhookHandler(req, { apiKey, events, revalidate: revalidationHandler })\n }\n\n const handleResource = <T extends APIResource>(\n resource: T | null,\n ): ApiResponse<APIResource | ErrorResponseBody> => {\n return resource !== null\n ? ApiResponse.json(resource)\n : ApiResponse.json({ message: 'Not Found' }, { status: 404 })\n }\n\n let m\n\n if ((m = matches<{ id: string }>('/swatches/:id'))) {\n return client.getSwatch(m.params.id, siteVersion).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/files/:id'))) {\n return client.getFile(m.params.id).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/typographies/:id'))) {\n return client.getTypography(m.params.id, siteVersion).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/global-elements/:id'))) {\n return client.getGlobalElement(m.params.id, siteVersion).then(handleResource)\n }\n\n if (\n (m = matches<{ globalElementId: string; locale: string }>(\n '/localized-global-elements/:globalElementId/:locale',\n ))\n ) {\n return client\n .getLocalizedGlobalElement(m.params.globalElementId, m.params.locale, siteVersion)\n .then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/page-pathname-slices/:id'))) {\n const localeParam = searchParams(req).get('locale')\n const locale = typeof localeParam === 'string' ? localeParam : undefined\n\n return client.getPagePathnameSlice(m.params.id, siteVersion, { locale }).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/tables/:id'))) {\n return client.getTable(m.params.id).then(handleResource)\n }\n\n return ApiResponse.json({ message: 'Not Found' }, { status: 404 })\n }\n}\n"],"mappings":"AAAA,SAAgB,SAAS,oBAAoB;AAG7C,SAAS,mBAAmB,8BAA8B;AAK1D,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,oBAA8C;AACvD,SAAS,uBAAsC;AAC/C,SAAS,kCAAkC;AAC3C,SAAS,yBAAyB;AAClC,SAAS,+BAA+B;AACxC,SAAS,sBAAsB;AAG/B;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB;AAsC1B,SAAS,iBACd,QACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GACY;AACZ,MAAI,OAAO,WAAW,UAAU;AAC9B,UAAM,IAAI;AAAA,MACR,sFACe,MAAM;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,eAAgB,KAAiB,OAAsC;AAC5E,UAAM,MACJ,IAAI,OAAO,YAAY,MAAM,YACzB,MAAM,gBAAgB,KAAK,KAAK,IAChC,IAAI,SAAS,MAAM,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,kBAAkB,GAAG,CAAC,EAAE,CAAC;AAE5E,qBAAiB,IAAI,SAAS;AAAA,MAC5B,QAAQ,QAAQ;AAAA,MAChB,gBAAgB,CAAC,gBAAgB,eAAe;AAAA,IAClD,CAAC;AAED,WAAO;AAAA,EACT;AAEA,iBAAe,gBAAgB,KAAiB,OAAs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Ac;AAAA,IACxD;AAEA,QAAK,IAAI,QAAwB,mBAAmB,GAAI;AACtD,aAAO,OAAO,cAAc,EAAE,OAAO,IAAI,WAAW,EAAE,KAAK,cAAc;AAAA,IAC3E;AAEA,QAAK,IAAI,QAAwB,sBAAsB,GAAI;AACzD,aAAO,OAAO,iBAAiB,EAAE,OAAO,IAAI,WAAW,EAAE,KAAK,cAAc;AAAA,IAC9E;AAEA,QACG,IAAI;AAAA,MACH;AAAA,IACF,GACA;AACA,aAAO,OACJ,0BAA0B,EAAE,OAAO,iBAAiB,EAAE,OAAO,QAAQ,WAAW,EAChF,KAAK,cAAc;AAAA,IACxB;AAEA,QAAK,IAAI,QAAwB,2BAA2B,GAAI;AAC9D,YAAM,cAAc,aAAa,GAAG,EAAE,IAAI,QAAQ;AAClD,YAAM,SAAS,OAAO,gBAAgB,WAAW,cAAc;AAE/D,aAAO,OAAO,qBAAqB,EAAE,OAAO,IAAI,aAAa,EAAE,OAAO,CAAC,EAAE,KAAK,cAAc;AAAA,IAC9F;AAEA,QAAK,IAAI,QAAwB,aAAa,GAAI;AAChD,aAAO,OAAO,SAAS,EAAE,OAAO,EAAE,EAAE,KAAK,cAAc;AAAA,IACzD;AAEA,WAAO,YAAY,KAAK,EAAE,SAAS,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACnE;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/api-handler/index.ts"],"sourcesContent":["import { Match, match as matchPattern } from 'path-to-regexp'\n\nimport { APIResource } from '../api'\nimport { ApiHandlerHeaders, deserializeSiteVersion } from '../api/site-version'\n\nimport { MakeswiftClient } from '../client'\nimport { type ReactRuntimeCore } from '../runtimes/react/react-runtime-core'\n\nimport { redirectLiveHandler } from './handlers/redirect-live'\nimport { elementTreeHandler } from './handlers/element-tree'\nimport { fontsHandler, type Font, type GetFonts } from './handlers/fonts'\nimport { manifestHandler, type Manifest } from './handlers/manifest'\nimport { mergeTranslatedDataHandler } from './handlers/merge-translated-data'\nimport { revalidateHandler } from './handlers/revalidate'\nimport { translatableDataHandler } from './handlers/translatable-data'\nimport { webhookHandler } from './handlers/webhook'\nimport { type OnPublish, type SitePublishedWebhookPayloadData } from './handlers/webhook/types'\n\nimport {\n type ApiRequest,\n type ErrorResponseBody,\n ApiResponse,\n searchParams,\n} from './request-response'\n\nimport { applyCorsHeaders } from './cors'\n\nexport type { Manifest, Font, SitePublishedWebhookPayloadData }\n\ntype Events = { onPublish: OnPublish }\n\nexport type ApiHandlerUserConfig = {\n runtime: ReactRuntimeCore\n getFonts?: GetFonts\n events?: Events\n}\n\nexport type ApiHandlerInternalConfig = {\n client: MakeswiftClient\n manifest?: Partial<Manifest>\n revalidationHandler: (path?: string) => Promise<void>\n previewCookieNames: string[]\n}\n\ntype ApiHandlerConfig = ApiHandlerUserConfig & ApiHandlerInternalConfig\n\ntype ResponseType =\n | Awaited<\n | ReturnType<typeof redirectLiveHandler>\n | ReturnType<typeof elementTreeHandler>\n | ReturnType<typeof fontsHandler>\n | ReturnType<typeof manifestHandler>\n | ReturnType<typeof mergeTranslatedDataHandler>\n | ReturnType<typeof revalidateHandler>\n | ReturnType<typeof translatableDataHandler>\n | ReturnType<typeof webhookHandler>\n >\n | ApiResponse<APIResource>\n | ApiResponse<ErrorResponseBody>\n | Response\n\ntype ApiHandler = (req: ApiRequest, route: string) => Promise<ResponseType>\n\nexport function createApiHandler(\n apiKey: string,\n {\n runtime,\n getFonts,\n events,\n client,\n manifest,\n revalidationHandler,\n previewCookieNames,\n }: ApiHandlerConfig,\n): ApiHandler {\n if (typeof apiKey !== 'string') {\n throw new Error(\n 'The Makeswift API handler must be passed a valid Makeswift site API key. ' +\n `Received \"${apiKey}\" instead.`,\n )\n }\n\n return async function (req: ApiRequest, route: string): Promise<ResponseType> {\n const res =\n req.method.toUpperCase() !== 'OPTIONS'\n ? await apiRouteHandler(req, route)\n : new Response(null, { status: 204, headers: [['Content-Length', '0']] })\n\n applyCorsHeaders(res.headers, {\n origin: runtime.appOrigin,\n allowedHeaders: ['Content-Type', 'Authorization'],\n })\n\n return res\n }\n\n async function apiRouteHandler(req: ApiRequest, route: string): Promise<ResponseType> {\n const versionHeader = req.headers.get(ApiHandlerHeaders.SiteVersion)\n\n const siteVersion = versionHeader != null ? deserializeSiteVersion(versionHeader) : null\n\n const matches = <T extends object>(pattern: string): Match<T> =>\n matchPattern<T>(pattern, { decode: decodeURIComponent })(route)\n\n if (matches('/redirect-live')) return redirectLiveHandler(req, { previewCookieNames })\n if (matches('/element-tree')) return elementTreeHandler(req, { runtime })\n if (matches('/fonts')) return fontsHandler(req, { getFonts })\n if (matches('/manifest')) return manifestHandler(req, { apiKey, manifest })\n if (matches('/merge-translated-data')) return mergeTranslatedDataHandler(req, { client })\n if (matches('/revalidate')) {\n return revalidateHandler(req, { apiKey, revalidatePath: revalidationHandler })\n }\n\n if (matches('/translatable-data')) return translatableDataHandler(req, { client })\n if (matches('/webhook')) {\n return webhookHandler(req, { apiKey, events, revalidate: revalidationHandler })\n }\n\n const handleResource = <T extends APIResource>(\n resource: T | null,\n ): ApiResponse<APIResource | ErrorResponseBody> => {\n return resource !== null\n ? ApiResponse.json(resource)\n : ApiResponse.json({ message: 'Not Found' }, { status: 404 })\n }\n\n let m\n\n if ((m = matches<{ id: string }>('/swatches/:id'))) {\n return client.getSwatch(m.params.id, siteVersion).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/files/:id'))) {\n return client.getFile(m.params.id).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/typographies/:id'))) {\n return client.getTypography(m.params.id, siteVersion).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/global-elements/:id'))) {\n return client.getGlobalElement(m.params.id, siteVersion).then(handleResource)\n }\n\n if (\n (m = matches<{ globalElementId: string; locale: string }>(\n '/localized-global-elements/:globalElementId/:locale',\n ))\n ) {\n return client\n .getLocalizedGlobalElement(m.params.globalElementId, m.params.locale, siteVersion)\n .then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/page-pathname-slices/:id'))) {\n const localeParam = searchParams(req).get('locale')\n const locale = typeof localeParam === 'string' ? localeParam : undefined\n\n return client.getPagePathnameSlice(m.params.id, siteVersion, { locale }).then(handleResource)\n }\n\n if ((m = matches<{ id: string }>('/tables/:id'))) {\n return client.getTable(m.params.id).then(handleResource)\n }\n\n return ApiResponse.json({ message: 'Not Found' }, { status: 404 })\n }\n}\n"],"mappings":"AAAA,SAAgB,SAAS,oBAAoB;AAG7C,SAAS,mBAAmB,8BAA8B;AAK1D,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,oBAA8C;AACvD,SAAS,uBAAsC;AAC/C,SAAS,kCAAkC;AAC3C,SAAS,yBAAyB;AAClC,SAAS,+BAA+B;AACxC,SAAS,sBAAsB;AAG/B;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB;AAsC1B,SAAS,iBACd,QACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GACY;AACZ,MAAI,OAAO,WAAW,UAAU;AAC9B,UAAM,IAAI;AAAA,MACR,sFACe,MAAM;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,eAAgB,KAAiB,OAAsC;AAC5E,UAAM,MACJ,IAAI,OAAO,YAAY,MAAM,YACzB,MAAM,gBAAgB,KAAK,KAAK,IAChC,IAAI,SAAS,MAAM,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,kBAAkB,GAAG,CAAC,EAAE,CAAC;AAE5E,qBAAiB,IAAI,SAAS;AAAA,MAC5B,QAAQ,QAAQ;AAAA,MAChB,gBAAgB,CAAC,gBAAgB,eAAe;AAAA,IAClD,CAAC;AAED,WAAO;AAAA,EACT;AAEA,iBAAe,gBAAgB,KAAiB,OAAsC;AACpF,UAAM,gBAAgB,IAAI,QAAQ,IAAI,kBAAkB,WAAW;AAEnE,UAAM,cAAc,iBAAiB,OAAO,uBAAuB,a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AW,EAAE,KAAK,cAAc;AAAA,IAC3E;AAEA,QAAK,IAAI,QAAwB,sBAAsB,GAAI;AACzD,aAAO,OAAO,iBAAiB,EAAE,OAAO,IAAI,WAAW,EAAE,KAAK,cAAc;AAAA,IAC9E;AAEA,QACG,IAAI;AAAA,MACH;AAAA,IACF,GACA;AACA,aAAO,OACJ,0BAA0B,EAAE,OAAO,iBAAiB,EAAE,OAAO,QAAQ,WAAW,EAChF,KAAK,cAAc;AAAA,IACxB;AAEA,QAAK,IAAI,QAAwB,2BAA2B,GAAI;AAC9D,YAAM,cAAc,aAAa,GAAG,EAAE,IAAI,QAAQ;AAClD,YAAM,SAAS,OAAO,gBAAgB,WAAW,cAAc;AAE/D,aAAO,OAAO,qBAAqB,EAAE,OAAO,IAAI,aAAa,EAAE,OAAO,CAAC,EAAE,KAAK,cAAc;AAAA,IAC9F;AAEA,QAAK,IAAI,QAAwB,aAAa,GAAI;AAChD,aAAO,OAAO,SAAS,EAAE,OAAO,EAAE,EAAE,KAAK,cAAc;AAAA,IACzD;AAEA,WAAO,YAAY,KAAK,EAAE,SAAS,YAAY,GAAG,EAAE,QAAQ,IAAI,CAAC;AAAA,EACnE;AACF;","names":[]}
|
package/dist/esm/client/index.js
CHANGED
|
@@ -195,7 +195,7 @@ Received "${apiKey}" instead.`
|
|
|
195
195
|
}
|
|
196
196
|
this.apiKey = apiKey;
|
|
197
197
|
this.graphqlClient = new GraphQLClient(new URL("graphql", runtime.apiOrigin).href, {
|
|
198
|
-
"makeswift-runtime-version": "0.28.1-canary.
|
|
198
|
+
"makeswift-runtime-version": "0.28.1-canary.2"
|
|
199
199
|
});
|
|
200
200
|
this.runtime = runtime;
|
|
201
201
|
}
|
|
@@ -207,7 +207,7 @@ Received "${apiKey}" instead.`
|
|
|
207
207
|
const requestHeaders = new Headers({
|
|
208
208
|
"x-api-key": this.apiKey,
|
|
209
209
|
"makeswift-site-api-key": this.apiKey,
|
|
210
|
-
"makeswift-runtime-version": "0.28.1-canary.
|
|
210
|
+
"makeswift-runtime-version": "0.28.1-canary.2"
|
|
211
211
|
});
|
|
212
212
|
if (siteVersion?.token) {
|
|
213
213
|
requestUrl.searchParams.set("version", siteVersion.version);
|
|
@@ -665,7 +665,7 @@ Received "${apiKey}" instead.`
|
|
|
665
665
|
headers: {
|
|
666
666
|
"x-api-key": this.apiKey,
|
|
667
667
|
"makeswift-site-api-key": this.apiKey,
|
|
668
|
-
"makeswift-runtime-version": "0.28.1-canary.
|
|
668
|
+
"makeswift-runtime-version": "0.28.1-canary.2",
|
|
669
669
|
"content-type": "application/json"
|
|
670
670
|
},
|
|
671
671
|
body: JSON.stringify({ token }),
|
package/dist/esm/global.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/global.d.ts"],"sourcesContent":["import '@emotion/jest'\n\ndeclare global {\n const PACKAGE_VERSION: string\n\n // partial typings for the new Navigation API, see\n // https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API\n interface NavigateEvent extends Event {\n readonly navigationType: 'push' | 'reload' | 'replace' | 'traverse'\n readonly destination: {\n readonly id: string\n readonly index: number\n readonly key: string\n readonly sameDocument: boolean\n readonly url: string\n }\n\n readonly hashChange: boolean\n readonly userInitiated: boolean\n }\n\n interface Navigation {\n addEventListener(type: 'navigate', listener: (event: NavigateEvent) => void): void\n removeEventListener(type: 'navigate', listener: (event: NavigateEvent) => void): void\n }\n\n interface Window {\n navigation?: Navigation\n }\n}\n\nexport {}\n"],"mappings":"AAAA,OAAO;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/global.d.ts"],"sourcesContent":["import '@emotion/jest'\n\ndeclare global {\n const PACKAGE_VERSION: string\n\n // partial typings for the new Navigation API, see\n // https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API\n interface NavigateEvent extends Event {\n readonly navigationType: 'push' | 'reload' | 'replace' | 'traverse'\n readonly destination: {\n readonly id: string\n readonly index: number\n readonly key: string\n readonly sameDocument: boolean\n readonly url: string\n }\n\n readonly hashChange: boolean\n readonly userInitiated: boolean\n }\n\n interface NavigationHistoryEntry {\n readonly id: string\n readonly index: number\n readonly key: string\n readonly sameDocument: boolean\n readonly url: string | null\n }\n\n interface Navigation {\n addEventListener(type: 'navigate', listener: (event: NavigateEvent) => void): void\n removeEventListener(type: 'navigate', listener: (event: NavigateEvent) => void): void\n addEventListener(type: 'navigatesuccess', listener: (event: Event) => void): void\n removeEventListener(type: 'navigatesuccess', listener: (event: Event) => void): void\n\n readonly currentEntry: NavigationHistoryEntry\n }\n\n interface Window {\n navigation?: Navigation\n }\n}\n\nexport {}\n"],"mappings":"AAAA,OAAO;","names":[]}
|