@makeswift/react-router 0.0.0-snapshot-20250829013357
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/cjs/api-handler.js +61 -0
- package/dist/cjs/api-handler.js.map +1 -0
- package/dist/cjs/client.js +34 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/components/framework-provider/index.js +42 -0
- package/dist/cjs/components/framework-provider/index.js.map +1 -0
- package/dist/cjs/components/framework-provider/link.js +38 -0
- package/dist/cjs/components/framework-provider/link.js.map +1 -0
- package/dist/cjs/index.js +47 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/root-style-registry.js +39 -0
- package/dist/cjs/root-style-registry.js.map +1 -0
- package/dist/cjs/runtime-provider.js +37 -0
- package/dist/cjs/runtime-provider.js.map +1 -0
- package/dist/cjs/server/index.js +35 -0
- package/dist/cjs/server/index.js.map +1 -0
- package/dist/cjs/server/preview.js +67 -0
- package/dist/cjs/server/preview.js.map +1 -0
- package/dist/cjs/server/render.js +95 -0
- package/dist/cjs/server/render.js.map +1 -0
- package/dist/cjs/server/site-version.js +37 -0
- package/dist/cjs/server/site-version.js.map +1 -0
- package/dist/esm/api-handler.js +39 -0
- package/dist/esm/api-handler.js.map +1 -0
- package/dist/esm/client.js +10 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/components/framework-provider/index.js +24 -0
- package/dist/esm/components/framework-provider/index.js.map +1 -0
- package/dist/esm/components/framework-provider/link.js +14 -0
- package/dist/esm/components/framework-provider/link.js.map +1 -0
- package/dist/esm/index.js +21 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/root-style-registry.js +18 -0
- package/dist/esm/root-style-registry.js.map +1 -0
- package/dist/esm/runtime-provider.js +13 -0
- package/dist/esm/runtime-provider.js.map +1 -0
- package/dist/esm/server/index.js +9 -0
- package/dist/esm/server/index.js.map +1 -0
- package/dist/esm/server/preview.js +51 -0
- package/dist/esm/server/preview.js.map +1 -0
- package/dist/esm/server/render.js +75 -0
- package/dist/esm/server/render.js.map +1 -0
- package/dist/esm/server/site-version.js +15 -0
- package/dist/esm/server/site-version.js.map +1 -0
- package/dist/types/api-handler.d.ts +14 -0
- package/dist/types/api-handler.d.ts.map +1 -0
- package/dist/types/client.d.ts +5 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/components/framework-provider/index.d.ts +3 -0
- package/dist/types/components/framework-provider/index.d.ts.map +1 -0
- package/dist/types/components/framework-provider/link.d.ts +2 -0
- package/dist/types/components/framework-provider/link.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/root-style-registry.d.ts +4 -0
- package/dist/types/root-style-registry.d.ts.map +1 -0
- package/dist/types/runtime-provider.d.ts +4 -0
- package/dist/types/runtime-provider.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +4 -0
- package/dist/types/server/index.d.ts.map +1 -0
- package/dist/types/server/preview.d.ts +11 -0
- package/dist/types/server/preview.d.ts.map +1 -0
- package/dist/types/server/render.d.ts +9 -0
- package/dist/types/server/render.d.ts.map +1 -0
- package/dist/types/server/site-version.d.ts +3 -0
- package/dist/types/server/site-version.d.ts.map +1 -0
- package/package.json +66 -0
- package/server/package.json +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Makeswift, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
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 api_handler_exports = {};
|
|
20
|
+
__export(api_handler_exports, {
|
|
21
|
+
createApiHandler: () => createApiHandler
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(api_handler_exports);
|
|
24
|
+
var import_unstable_framework_support = require("@makeswift/runtime/unstable-framework-support");
|
|
25
|
+
var import_client = require("./client");
|
|
26
|
+
var import_preview = require("./server/preview");
|
|
27
|
+
function validateApiRoute(params) {
|
|
28
|
+
const route = decodeURIComponent(params["*"] ?? "");
|
|
29
|
+
if (route.includes("/api/") || route.includes("/makeswift/")) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Unexpected API route '${route}'. Please make sure the Makeswift API handler is invoked from a nested catch-all route named 'api.makeswift.$.ts'`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return `/${route}`;
|
|
35
|
+
}
|
|
36
|
+
async function revalidationHandler(path) {
|
|
37
|
+
if (path != null) {
|
|
38
|
+
} else {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function createApiHandler(apiKey, { apiOrigin, runtime, ...userConfig }) {
|
|
42
|
+
const client = new import_client.Makeswift(apiKey, { apiOrigin, runtime });
|
|
43
|
+
return {
|
|
44
|
+
async loader({ request, params }) {
|
|
45
|
+
const route = validateApiRoute(params);
|
|
46
|
+
const apiHandler = (0, import_unstable_framework_support.createApiHandler)(apiKey, {
|
|
47
|
+
...userConfig,
|
|
48
|
+
runtime,
|
|
49
|
+
client,
|
|
50
|
+
revalidationHandler,
|
|
51
|
+
previewCookieNames: [import_preview.siteVersionCookie.name]
|
|
52
|
+
});
|
|
53
|
+
return await apiHandler(request, route);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
createApiHandler
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=api-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/api-handler.ts"],"sourcesContent":["import {\n type ApiHandlerUserConfig,\n createApiHandler as createMakeswiftApiHandler,\n} from '@makeswift/runtime/unstable-framework-support'\n\nimport { Makeswift as MakeswiftClient } from './client'\nimport { siteVersionCookie } from './server/preview'\n\nfunction validateApiRoute(params: Record<string, string>): string {\n const route = decodeURIComponent(params['*'] ?? '')\n if (route.includes('/api/') || route.includes('/makeswift/')) {\n throw new Error(\n `Unexpected API route '${route}'. Please make sure the Makeswift API handler is invoked from a nested catch-all route named 'api.makeswift.$.ts'`,\n )\n }\n\n return `/${route}`\n}\n\nasync function revalidationHandler(path?: string): Promise<void> {\n if (path != null) {\n // revalidate a specific path\n } else {\n // revalidate the entire site\n }\n}\n\nexport function createApiHandler(\n apiKey: string,\n { apiOrigin, runtime, ...userConfig }: ApiHandlerUserConfig,\n) {\n const client = new MakeswiftClient(apiKey, { apiOrigin, runtime })\n\n return {\n async loader({ request, params }: { request: Request; params: Record<string, string> }) {\n const route = validateApiRoute(params)\n\n const apiHandler = createMakeswiftApiHandler(apiKey, {\n ...userConfig,\n runtime,\n client,\n revalidationHandler,\n previewCookieNames: [siteVersionCookie.name],\n })\n\n return await apiHandler(request, route)\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAGO;AAEP,oBAA6C;AAC7C,qBAAkC;AAElC,SAAS,iBAAiB,QAAwC;AAChE,QAAM,QAAQ,mBAAmB,OAAO,GAAG,KAAK,EAAE;AAClD,MAAI,MAAM,SAAS,OAAO,KAAK,MAAM,SAAS,aAAa,GAAG;AAC5D,UAAM,IAAI;AAAA,MACR,yBAAyB,KAAK;AAAA,IAChC;AAAA,EACF;AAEA,SAAO,IAAI,KAAK;AAClB;AAEA,eAAe,oBAAoB,MAA8B;AAC/D,MAAI,QAAQ,MAAM;AAAA,EAElB,OAAO;AAAA,EAEP;AACF;AAEO,SAAS,iBACd,QACA,EAAE,WAAW,SAAS,GAAG,WAAW,GACpC;AACA,QAAM,SAAS,IAAI,cAAAA,UAAgB,QAAQ,EAAE,WAAW,QAAQ,CAAC;AAEjE,SAAO;AAAA,IACL,MAAM,OAAO,EAAE,SAAS,OAAO,GAAyD;AACtF,YAAM,QAAQ,iBAAiB,MAAM;AAErC,YAAM,iBAAa,kCAAAC,kBAA0B,QAAQ;AAAA,QACnD,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA;AAAA,QACA,oBAAoB,CAAC,iCAAkB,IAAI;AAAA,MAC7C,CAAC;AAED,aAAO,MAAM,WAAW,SAAS,KAAK;AAAA,IACxC;AAAA,EACF;AACF;","names":["MakeswiftClient","createMakeswiftApiHandler"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 client_exports = {};
|
|
20
|
+
__export(client_exports, {
|
|
21
|
+
Makeswift: () => Makeswift
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(client_exports);
|
|
24
|
+
var import_unstable_framework_support = require("@makeswift/runtime/unstable-framework-support");
|
|
25
|
+
class Makeswift extends import_unstable_framework_support.MakeswiftClient {
|
|
26
|
+
fetchOptions(_siteVersion) {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
Makeswift
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client.ts"],"sourcesContent":["import { type SiteVersion, MakeswiftClient } from '@makeswift/runtime/unstable-framework-support'\n\nexport class Makeswift extends MakeswiftClient {\n fetchOptions(_siteVersion: SiteVersion | null): Record<string, unknown> {\n return {}\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAAkD;AAE3C,MAAM,kBAAkB,kDAAgB;AAAA,EAC7C,aAAa,cAA2D;AACtE,WAAO,CAAC;AAAA,EACV;AACF;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 framework_provider_exports = {};
|
|
20
|
+
__export(framework_provider_exports, {
|
|
21
|
+
FrameworkProvider: () => FrameworkProvider
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(framework_provider_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_unstable_framework_support = require("@makeswift/runtime/unstable-framework-support");
|
|
27
|
+
var import_link = require("./link");
|
|
28
|
+
function FrameworkProvider({ children }) {
|
|
29
|
+
const [context] = (0, import_react.useState)({
|
|
30
|
+
Head: import_unstable_framework_support.DefaultHead,
|
|
31
|
+
HeadSnippet: import_unstable_framework_support.DefaultHeadSnippet,
|
|
32
|
+
Image: import_unstable_framework_support.DefaultImage,
|
|
33
|
+
Link: import_link.Link,
|
|
34
|
+
versionedFetch: import_unstable_framework_support.versionedFetch
|
|
35
|
+
});
|
|
36
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_unstable_framework_support.FrameworkContext.Provider, { value: context, children });
|
|
37
|
+
}
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
FrameworkProvider
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/framework-provider/index.tsx"],"sourcesContent":["import { type PropsWithChildren, useState } from 'react'\n\nimport {\n FrameworkContext,\n DefaultHead,\n DefaultHeadSnippet,\n DefaultImage,\n versionedFetch,\n} from '@makeswift/runtime/unstable-framework-support'\n\nimport { Link } from './link'\n\nexport function FrameworkProvider({ children }: PropsWithChildren) {\n const [context] = useState<FrameworkContext>({\n Head: DefaultHead,\n HeadSnippet: DefaultHeadSnippet,\n Image: DefaultImage,\n Link,\n versionedFetch,\n })\n\n return <FrameworkContext.Provider value={context}>{children}</FrameworkContext.Provider>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBS;AArBT,mBAAiD;AAEjD,wCAMO;AAEP,kBAAqB;AAEd,SAAS,kBAAkB,EAAE,SAAS,GAAsB;AACjE,QAAM,CAAC,OAAO,QAAI,uBAA2B;AAAA,IAC3C,MAAM;AAAA,IACN,aAAa;AAAA,IACb,OAAO;AAAA,IACP;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO,4CAAC,mDAAiB,UAAjB,EAA0B,OAAO,SAAU,UAAS;AAC9D;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 link_exports = {};
|
|
20
|
+
__export(link_exports, {
|
|
21
|
+
Link: () => Link
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(link_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_react_router = require("react-router");
|
|
27
|
+
const Link = (0, import_react.forwardRef)(function Link2({ linkType, href, ...props }, ref) {
|
|
28
|
+
const useRRLink = href != null && linkType === "OPEN_PAGE";
|
|
29
|
+
if (useRRLink) {
|
|
30
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router.Link, { ...props, ref, to: href, prefetch: "intent" });
|
|
31
|
+
}
|
|
32
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { ...props, ref, href });
|
|
33
|
+
});
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
Link
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/framework-provider/link.tsx"],"sourcesContent":["import { type ComponentPropsWithoutRef, forwardRef } from 'react'\nimport { Link as RRLink } from 'react-router'\n\nimport { type FrameworkContext } from '@makeswift/runtime/unstable-framework-support'\n\nexport const Link = forwardRef<HTMLAnchorElement>(function Link(\n { linkType, href, ...props }: ComponentPropsWithoutRef<FrameworkContext['Link']>,\n ref,\n) {\n const useRRLink = href != null && linkType === 'OPEN_PAGE'\n if (useRRLink) {\n return <RRLink {...props} ref={ref} to={href} prefetch=\"intent\" />\n }\n\n return <a {...props} ref={ref} href={href} />\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAWW;AAXX,mBAA0D;AAC1D,0BAA+B;AAIxB,MAAM,WAAO,yBAA8B,SAASA,MACzD,EAAE,UAAU,MAAM,GAAG,MAAM,GAC3B,KACA;AACA,QAAM,YAAY,QAAQ,QAAQ,aAAa;AAC/C,MAAI,WAAW;AACb,WAAO,4CAAC,oBAAAC,MAAA,EAAQ,GAAG,OAAO,KAAU,IAAI,MAAM,UAAS,UAAS;AAAA,EAClE;AAEA,SAAO,4CAAC,OAAG,GAAG,OAAO,KAAU,MAAY;AAC7C,CAAC;","names":["Link","RRLink"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
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 src_exports = {};
|
|
20
|
+
__export(src_exports, {
|
|
21
|
+
Makeswift: () => import_client.Makeswift,
|
|
22
|
+
MakeswiftComponent: () => import_unstable_framework_support.MakeswiftComponent,
|
|
23
|
+
Page: () => import_unstable_framework_support.Page,
|
|
24
|
+
ReactRuntime: () => import_unstable_framework_support.ReactRuntime,
|
|
25
|
+
ReactRuntimeProvider: () => import_runtime_provider.RemixRuntimeProvider,
|
|
26
|
+
RootStyleRegistry: () => import_root_style_registry.RemixRootStyleRegistry,
|
|
27
|
+
Slot: () => import_unstable_framework_support.Slot,
|
|
28
|
+
createApiHandler: () => import_api_handler.createApiHandler
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(src_exports);
|
|
31
|
+
var import_unstable_framework_support = require("@makeswift/runtime/unstable-framework-support");
|
|
32
|
+
var import_client = require("./client");
|
|
33
|
+
var import_api_handler = require("./api-handler");
|
|
34
|
+
var import_runtime_provider = require("./runtime-provider");
|
|
35
|
+
var import_root_style_registry = require("./root-style-registry");
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
Makeswift,
|
|
39
|
+
MakeswiftComponent,
|
|
40
|
+
Page,
|
|
41
|
+
ReactRuntime,
|
|
42
|
+
ReactRuntimeProvider,
|
|
43
|
+
RootStyleRegistry,
|
|
44
|
+
Slot,
|
|
45
|
+
createApiHandler
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n type SiteVersion,\n Page,\n MakeswiftComponent,\n Slot,\n ReactRuntime,\n} from '@makeswift/runtime/unstable-framework-support'\n\nexport { Makeswift } from './client'\nexport { createApiHandler } from './api-handler'\nexport { RemixRuntimeProvider as ReactRuntimeProvider } from './runtime-provider'\nexport { RemixRootStyleRegistry as RootStyleRegistry } from './root-style-registry'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAMO;AAEP,oBAA0B;AAC1B,yBAAiC;AACjC,8BAA6D;AAC7D,iCAA4D;","names":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 root_style_registry_exports = {};
|
|
20
|
+
__export(root_style_registry_exports, {
|
|
21
|
+
RemixRootStyleRegistry: () => RemixRootStyleRegistry
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(root_style_registry_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_unstable_framework_support = require("@makeswift/runtime/unstable-framework-support");
|
|
27
|
+
function RemixRootStyleRegistry({
|
|
28
|
+
children,
|
|
29
|
+
cacheKey,
|
|
30
|
+
enableCssReset
|
|
31
|
+
}) {
|
|
32
|
+
const [cache] = (0, import_react.useState)((0, import_unstable_framework_support.createRootStyleCache)({ key: cacheKey }));
|
|
33
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_unstable_framework_support.RootStyleRegistry, { cache, enableCssReset, children });
|
|
34
|
+
}
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
RemixRootStyleRegistry
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=root-style-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/root-style-registry.tsx"],"sourcesContent":["import { type PropsWithChildren, useState } from 'react'\n\nimport {\n createRootStyleCache,\n RootStyleRegistry as ReactRootStyleRegistry,\n type RootStyleProps,\n} from '@makeswift/runtime/unstable-framework-support'\n\nexport function RemixRootStyleRegistry({\n children,\n cacheKey,\n enableCssReset,\n}: PropsWithChildren<RootStyleProps>) {\n const [cache] = useState(createRootStyleCache({ key: cacheKey }))\n\n return (\n <ReactRootStyleRegistry cache={cache} enableCssReset={enableCssReset}>\n {children}\n </ReactRootStyleRegistry>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBI;AAhBJ,mBAAiD;AAEjD,wCAIO;AAEA,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACF,GAAsC;AACpC,QAAM,CAAC,KAAK,QAAI,2BAAS,wDAAqB,EAAE,KAAK,SAAS,CAAC,CAAC;AAEhE,SACE,4CAAC,kCAAAA,mBAAA,EAAuB,OAAc,gBACnC,UACH;AAEJ;","names":["ReactRootStyleRegistry"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 runtime_provider_exports = {};
|
|
20
|
+
__export(runtime_provider_exports, {
|
|
21
|
+
RemixRuntimeProvider: () => RemixRuntimeProvider
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(runtime_provider_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_unstable_framework_support = require("@makeswift/runtime/unstable-framework-support");
|
|
26
|
+
var import_framework_provider = require("./components/framework-provider");
|
|
27
|
+
function RemixRuntimeProvider({
|
|
28
|
+
children,
|
|
29
|
+
...props
|
|
30
|
+
}) {
|
|
31
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_framework_provider.FrameworkProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_unstable_framework_support.RuntimeProvider, { ...props, children }) });
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
RemixRuntimeProvider
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=runtime-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/runtime-provider.tsx"],"sourcesContent":["import { ComponentProps } from 'react'\n\nimport { RuntimeProvider } from '@makeswift/runtime/unstable-framework-support'\n\nimport { FrameworkProvider } from './components/framework-provider'\n\nexport function RemixRuntimeProvider({\n children,\n ...props\n}: ComponentProps<typeof RuntimeProvider>) {\n return (\n <FrameworkProvider>\n <RuntimeProvider {...props}>{children}</RuntimeProvider>\n </FrameworkProvider>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYM;AAVN,wCAAgC;AAEhC,gCAAkC;AAE3B,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA,GAAG;AACL,GAA2C;AACzC,SACE,4CAAC,+CACC,sDAAC,qDAAiB,GAAG,OAAQ,UAAS,GACxC;AAEJ;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 server_exports = {};
|
|
20
|
+
__export(server_exports, {
|
|
21
|
+
getSiteVersion: () => import_site_version.getSiteVersion,
|
|
22
|
+
renderHtml: () => import_render.renderHtml,
|
|
23
|
+
withMakeswift: () => import_preview.withMakeswift
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(server_exports);
|
|
26
|
+
var import_render = require("./render");
|
|
27
|
+
var import_site_version = require("./site-version");
|
|
28
|
+
var import_preview = require("./preview");
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
getSiteVersion,
|
|
32
|
+
renderHtml,
|
|
33
|
+
withMakeswift
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export { renderHtml } from './render'\nexport { getSiteVersion } from './site-version'\nexport { withMakeswift } from './preview'\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,0BAA+B;AAC/B,qBAA8B;","names":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 preview_exports = {};
|
|
20
|
+
__export(preview_exports, {
|
|
21
|
+
siteVersionCookie: () => siteVersionCookie,
|
|
22
|
+
withMakeswift: () => withMakeswift
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(preview_exports);
|
|
25
|
+
var import_react_router = require("react-router");
|
|
26
|
+
var import_unstable_framework_support = require("@makeswift/runtime/unstable-framework-support");
|
|
27
|
+
const siteVersionCookie = (0, import_react_router.createCookie)(import_unstable_framework_support.MAKESWIFT_SITE_VERSION_COOKIE, import_unstable_framework_support.cookieSettingOptions);
|
|
28
|
+
async function requestedSiteVersion({
|
|
29
|
+
searchParams,
|
|
30
|
+
client
|
|
31
|
+
}) {
|
|
32
|
+
const previewToken = searchParams.get(import_unstable_framework_support.SearchParams.PreviewToken);
|
|
33
|
+
if (previewToken == null)
|
|
34
|
+
return null;
|
|
35
|
+
const verifiedToken = await client.readPreviewToken(previewToken);
|
|
36
|
+
if (verifiedToken == null)
|
|
37
|
+
return null;
|
|
38
|
+
const { payload } = verifiedToken;
|
|
39
|
+
return { version: payload.version, token: previewToken };
|
|
40
|
+
}
|
|
41
|
+
function withMakeswift(loader, { client }) {
|
|
42
|
+
return async function withMakeswiftLoader(args) {
|
|
43
|
+
const { origin, pathname, searchParams } = new URL(args.request.url);
|
|
44
|
+
const redirectLive = searchParams.get(import_unstable_framework_support.REDIRECT_SEARCH_PARAM);
|
|
45
|
+
if (redirectLive != null) {
|
|
46
|
+
return (0, import_unstable_framework_support.redirectLiveHandler)(args.request, { previewCookieNames: [siteVersionCookie.name] });
|
|
47
|
+
}
|
|
48
|
+
const siteVersion = await requestedSiteVersion({ searchParams, client });
|
|
49
|
+
if (siteVersion == null)
|
|
50
|
+
return loader(args);
|
|
51
|
+
const serializedSiteVersion = (0, import_unstable_framework_support.serializeSiteVersion)(siteVersion);
|
|
52
|
+
const secondsUntilExpiration = (0, import_unstable_framework_support.secondsUntilSiteVersionExpiration)(siteVersion);
|
|
53
|
+
return (0, import_react_router.redirect)(`${origin}${pathname}`, {
|
|
54
|
+
headers: {
|
|
55
|
+
[import_unstable_framework_support.SET_COOKIE_HEADER]: await siteVersionCookie.serialize(serializedSiteVersion, {
|
|
56
|
+
maxAge: secondsUntilExpiration
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
siteVersionCookie,
|
|
65
|
+
withMakeswift
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/preview.ts"],"sourcesContent":["import { redirect, createCookie } from 'react-router'\n\nimport {\n type SiteVersion,\n MAKESWIFT_SITE_VERSION_COOKIE,\n REDIRECT_SEARCH_PARAM,\n SET_COOKIE_HEADER,\n cookieSettingOptions,\n MakeswiftClient,\n serializeSiteVersion,\n secondsUntilSiteVersionExpiration,\n SearchParams,\n redirectLiveHandler,\n} from '@makeswift/runtime/unstable-framework-support'\n\nexport const siteVersionCookie = createCookie(MAKESWIFT_SITE_VERSION_COOKIE, cookieSettingOptions)\n\nasync function requestedSiteVersion({\n searchParams,\n client,\n}: {\n searchParams: URLSearchParams\n client: MakeswiftClient\n}): Promise<SiteVersion | null> {\n const previewToken = searchParams.get(SearchParams.PreviewToken)\n if (previewToken == null) return null\n\n const verifiedToken = await client.readPreviewToken(previewToken)\n if (verifiedToken == null) return null\n\n const { payload } = verifiedToken\n\n return { version: payload.version, token: previewToken }\n}\n\ntype LoaderArgs = { request: Request }\ntype Loader<T extends LoaderArgs, R> = (args: T) => Promise<Response | R>\n\nexport function withMakeswift<T extends LoaderArgs, R>(\n loader: Loader<T, R>,\n { client }: { client: MakeswiftClient },\n): Loader<T, R> {\n return async function withMakeswiftLoader(args: T): Promise<Response | R> {\n const { origin, pathname, searchParams } = new URL(args.request.url)\n\n const redirectLive = searchParams.get(REDIRECT_SEARCH_PARAM)\n if (redirectLive != null) {\n return redirectLiveHandler(args.request, { previewCookieNames: [siteVersionCookie.name] })\n }\n\n const siteVersion = await requestedSiteVersion({ searchParams, client })\n if (siteVersion == null) return loader(args)\n\n const serializedSiteVersion = serializeSiteVersion(siteVersion)\n const secondsUntilExpiration = secondsUntilSiteVersionExpiration(siteVersion)\n\n return redirect(`${origin}${pathname}`, {\n headers: {\n [SET_COOKIE_HEADER]: await siteVersionCookie.serialize(serializedSiteVersion, {\n maxAge: secondsUntilExpiration,\n }),\n },\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAuC;AAEvC,wCAWO;AAEA,MAAM,wBAAoB,kCAAa,iEAA+B,sDAAoB;AAEjG,eAAe,qBAAqB;AAAA,EAClC;AAAA,EACA;AACF,GAGgC;AAC9B,QAAM,eAAe,aAAa,IAAI,+CAAa,YAAY;AAC/D,MAAI,gBAAgB;AAAM,WAAO;AAEjC,QAAM,gBAAgB,MAAM,OAAO,iBAAiB,YAAY;AAChE,MAAI,iBAAiB;AAAM,WAAO;AAElC,QAAM,EAAE,QAAQ,IAAI;AAEpB,SAAO,EAAE,SAAS,QAAQ,SAAS,OAAO,aAAa;AACzD;AAKO,SAAS,cACd,QACA,EAAE,OAAO,GACK;AACd,SAAO,eAAe,oBAAoB,MAAgC;AACxE,UAAM,EAAE,QAAQ,UAAU,aAAa,IAAI,IAAI,IAAI,KAAK,QAAQ,GAAG;AAEnE,UAAM,eAAe,aAAa,IAAI,uDAAqB;AAC3D,QAAI,gBAAgB,MAAM;AACxB,iBAAO,uDAAoB,KAAK,SAAS,EAAE,oBAAoB,CAAC,kBAAkB,IAAI,EAAE,CAAC;AAAA,IAC3F;AAEA,UAAM,cAAc,MAAM,qBAAqB,EAAE,cAAc,OAAO,CAAC;AACvE,QAAI,eAAe;AAAM,aAAO,OAAO,IAAI;AAE3C,UAAM,4BAAwB,wDAAqB,WAAW;AAC9D,UAAM,6BAAyB,qEAAkC,WAAW;AAE5E,eAAO,8BAAS,GAAG,MAAM,GAAG,QAAQ,IAAI;AAAA,MACtC,SAAS;AAAA,QACP,CAAC,mDAAiB,GAAG,MAAM,kBAAkB,UAAU,uBAAuB;AAAA,UAC5E,QAAQ;AAAA,QACV,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,95 @@
|
|
|
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 render_exports = {};
|
|
20
|
+
__export(render_exports, {
|
|
21
|
+
renderHtml: () => renderHtml
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(render_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_node = require("@react-router/node");
|
|
26
|
+
var import_server = require("react-dom/server");
|
|
27
|
+
var import_node_stream = require("node:stream");
|
|
28
|
+
var import_unstable_framework_support = require("@makeswift/runtime/unstable-framework-support");
|
|
29
|
+
const DEFAULT_TIMEOUT = 1e4;
|
|
30
|
+
function renderHtml(children, {
|
|
31
|
+
timeout,
|
|
32
|
+
cacheKey,
|
|
33
|
+
enableCssReset,
|
|
34
|
+
responseStatusCode,
|
|
35
|
+
responseHeaders
|
|
36
|
+
}) {
|
|
37
|
+
const cache = (0, import_unstable_framework_support.createRootStyleCache)({ key: cacheKey });
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
let didError = false;
|
|
40
|
+
const { pipe, abort } = (0, import_server.renderToPipeableStream)(
|
|
41
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_unstable_framework_support.RootStyleRegistry, { cache, enableCssReset, children }),
|
|
42
|
+
{
|
|
43
|
+
// wait for all Suspense boundaries before streaming for consistent Emotion CSS
|
|
44
|
+
onAllReady() {
|
|
45
|
+
const { classNames, css } = cache.flush();
|
|
46
|
+
const headInjector = createHeadInjectionTransform(
|
|
47
|
+
(0, import_unstable_framework_support.styleTagHtml)({ cacheKey: cache.key, classNames, css })
|
|
48
|
+
);
|
|
49
|
+
const body = new import_node_stream.PassThrough();
|
|
50
|
+
const responseStream = (0, import_node.createReadableStreamFromReadable)(
|
|
51
|
+
classNames.length > 0 ? body.pipe(headInjector) : body
|
|
52
|
+
);
|
|
53
|
+
responseHeaders.set("Content-Type", "text/html; charset=utf-8");
|
|
54
|
+
resolve(
|
|
55
|
+
new Response(responseStream, {
|
|
56
|
+
status: didError ? 500 : responseStatusCode,
|
|
57
|
+
headers: responseHeaders
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
body.write("<!DOCTYPE html>");
|
|
61
|
+
pipe(body);
|
|
62
|
+
},
|
|
63
|
+
onShellError(err) {
|
|
64
|
+
reject(err);
|
|
65
|
+
},
|
|
66
|
+
onError(err) {
|
|
67
|
+
didError = true;
|
|
68
|
+
console.error(err);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
setTimeout(abort, timeout ?? DEFAULT_TIMEOUT);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function createHeadInjectionTransform(snippet) {
|
|
76
|
+
let injected = false;
|
|
77
|
+
return new import_node_stream.Transform({
|
|
78
|
+
transform(chunk, _enc, cb) {
|
|
79
|
+
if (injected)
|
|
80
|
+
return cb(null, chunk);
|
|
81
|
+
const str = chunk.toString();
|
|
82
|
+
const idx = str.indexOf("</head>");
|
|
83
|
+
if (idx === -1)
|
|
84
|
+
return cb(null, chunk);
|
|
85
|
+
injected = true;
|
|
86
|
+
const out = str.slice(0, idx) + snippet + str.slice(idx);
|
|
87
|
+
cb(null, out);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {
|
|
93
|
+
renderHtml
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/render.tsx"],"sourcesContent":["import { type ReactNode } from 'react'\n\nimport { createReadableStreamFromReadable } from '@react-router/node'\nimport { renderToPipeableStream } from 'react-dom/server'\nimport { PassThrough, Transform } from 'node:stream'\n\nimport {\n createRootStyleCache,\n RootStyleRegistry,\n styleTagHtml,\n type RootStyleProps,\n} from '@makeswift/runtime/unstable-framework-support'\n\nconst DEFAULT_TIMEOUT = 10000\n\nexport function renderHtml(\n children: ReactNode,\n {\n timeout,\n cacheKey,\n enableCssReset,\n responseStatusCode,\n responseHeaders,\n }: RootStyleProps & {\n request: Request\n timeout?: number\n responseStatusCode: number\n responseHeaders: Headers\n },\n): Promise<Response> {\n const cache = createRootStyleCache({ key: cacheKey })\n\n return new Promise((resolve, reject) => {\n let didError = false\n\n const { pipe, abort } = renderToPipeableStream(\n <RootStyleRegistry cache={cache} enableCssReset={enableCssReset}>\n {children}\n </RootStyleRegistry>,\n {\n // wait for all Suspense boundaries before streaming for consistent Emotion CSS\n onAllReady() {\n // create a head injection transform with server-side styles\n const { classNames, css } = cache.flush()\n const headInjector = createHeadInjectionTransform(\n styleTagHtml({ cacheKey: cache.key, classNames, css }),\n )\n\n // prepare a pipeable response stream with the head transform\n const body = new PassThrough()\n const responseStream = createReadableStreamFromReadable(\n classNames.length > 0 ? body.pipe(headInjector) : body,\n )\n\n // amend response headers with content type\n responseHeaders.set('Content-Type', 'text/html; charset=utf-8')\n\n // return the stream response\n resolve(\n new Response(responseStream, {\n status: didError ? 500 : responseStatusCode,\n headers: responseHeaders,\n }),\n )\n\n // write the initial HTML doctype and start piping the stream\n body.write('<!DOCTYPE html>')\n pipe(body)\n },\n onShellError(err) {\n reject(err)\n },\n onError(err) {\n didError = true\n console.error(err)\n },\n },\n )\n\n setTimeout(abort, timeout ?? DEFAULT_TIMEOUT)\n })\n}\n\nfunction createHeadInjectionTransform(snippet: string) {\n let injected = false\n return new Transform({\n transform(chunk, _enc, cb) {\n if (injected) return cb(null, chunk)\n\n // inject `snippet` right before the first </head> tag\n const str = chunk.toString()\n const idx = str.indexOf('</head>')\n if (idx === -1) return cb(null, chunk)\n\n injected = true\n const out = str.slice(0, idx) + snippet + str.slice(idx)\n cb(null, out)\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoCM;AAlCN,kBAAiD;AACjD,oBAAuC;AACvC,yBAAuC;AAEvC,wCAKO;AAEP,MAAM,kBAAkB;AAEjB,SAAS,WACd,UACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMmB;AACnB,QAAM,YAAQ,wDAAqB,EAAE,KAAK,SAAS,CAAC;AAEpD,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,QAAI,WAAW;AAEf,UAAM,EAAE,MAAM,MAAM,QAAI;AAAA,MACtB,4CAAC,uDAAkB,OAAc,gBAC9B,UACH;AAAA,MACA;AAAA;AAAA,QAEE,aAAa;AAEX,gBAAM,EAAE,YAAY,IAAI,IAAI,MAAM,MAAM;AACxC,gBAAM,eAAe;AAAA,gBACnB,gDAAa,EAAE,UAAU,MAAM,KAAK,YAAY,IAAI,CAAC;AAAA,UACvD;AAGA,gBAAM,OAAO,IAAI,+BAAY;AAC7B,gBAAM,qBAAiB;AAAA,YACrB,WAAW,SAAS,IAAI,KAAK,KAAK,YAAY,IAAI;AAAA,UACpD;AAGA,0BAAgB,IAAI,gBAAgB,0BAA0B;AAG9D;AAAA,YACE,IAAI,SAAS,gBAAgB;AAAA,cAC3B,QAAQ,WAAW,MAAM;AAAA,cACzB,SAAS;AAAA,YACX,CAAC;AAAA,UACH;AAGA,eAAK,MAAM,iBAAiB;AAC5B,eAAK,IAAI;AAAA,QACX;AAAA,QACA,aAAa,KAAK;AAChB,iBAAO,GAAG;AAAA,QACZ;AAAA,QACA,QAAQ,KAAK;AACX,qBAAW;AACX,kBAAQ,MAAM,GAAG;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AAEA,eAAW,OAAO,WAAW,eAAe;AAAA,EAC9C,CAAC;AACH;AAEA,SAAS,6BAA6B,SAAiB;AACrD,MAAI,WAAW;AACf,SAAO,IAAI,6BAAU;AAAA,IACnB,UAAU,OAAO,MAAM,IAAI;AACzB,UAAI;AAAU,eAAO,GAAG,MAAM,KAAK;AAGnC,YAAM,MAAM,MAAM,SAAS;AAC3B,YAAM,MAAM,IAAI,QAAQ,SAAS;AACjC,UAAI,QAAQ;AAAI,eAAO,GAAG,MAAM,KAAK;AAErC,iBAAW;AACX,YAAM,MAAM,IAAI,MAAM,GAAG,GAAG,IAAI,UAAU,IAAI,MAAM,GAAG;AACvD,SAAG,MAAM,GAAG;AAAA,IACd;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 site_version_exports = {};
|
|
20
|
+
__export(site_version_exports, {
|
|
21
|
+
getSiteVersion: () => getSiteVersion
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(site_version_exports);
|
|
24
|
+
var import_unstable_framework_support = require("@makeswift/runtime/unstable-framework-support");
|
|
25
|
+
var import_preview = require("./preview");
|
|
26
|
+
async function getSiteVersion(request) {
|
|
27
|
+
const cookieHeader = request.headers.get("Cookie");
|
|
28
|
+
const cookieValue = await import_preview.siteVersionCookie.parse(cookieHeader);
|
|
29
|
+
if (cookieValue == null)
|
|
30
|
+
return null;
|
|
31
|
+
return (0, import_unstable_framework_support.deserializeSiteVersion)(cookieValue);
|
|
32
|
+
}
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
getSiteVersion
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=site-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/server/site-version.tsx"],"sourcesContent":["import {\n deserializeSiteVersion,\n type SiteVersion,\n} from '@makeswift/runtime/unstable-framework-support'\nimport { siteVersionCookie } from './preview'\n\nexport async function getSiteVersion(request: Request): Promise<SiteVersion | null> {\n const cookieHeader = request.headers.get('Cookie')\n const cookieValue = await siteVersionCookie.parse(cookieHeader)\n if (cookieValue == null) return null\n\n return deserializeSiteVersion(cookieValue)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAGO;AACP,qBAAkC;AAElC,eAAsB,eAAe,SAA+C;AAClF,QAAM,eAAe,QAAQ,QAAQ,IAAI,QAAQ;AACjD,QAAM,cAAc,MAAM,iCAAkB,MAAM,YAAY;AAC9D,MAAI,eAAe;AAAM,WAAO;AAEhC,aAAO,0DAAuB,WAAW;AAC3C;","names":[]}
|