@puckeditor/cli 0.24.0-canary.5eddccac → 0.24.0-canary.6e2f8164
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/bin.mjs +55 -3
- package/dist/templates/next/app/puck/[...puckPath]/page.tsx +3 -2
- package/dist/templates/next/app/puck/page.tsx +0 -2
- package/dist/templates/next-ai/app/puck/[...puckPath]/page.tsx +3 -2
- package/dist/templates/next-ai/app/puck/page.tsx +0 -2
- package/dist/templates/vinext/app/puck/[...puckPath]/page.tsx +3 -2
- package/dist/templates/vinext/app/puck/page.tsx +0 -2
- package/dist/templates/vinext-ai/app/puck/[...puckPath]/page.tsx +3 -2
- package/dist/templates/vinext-ai/app/puck/page.tsx +0 -2
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -152,6 +152,19 @@ var findStringProperty = (code, filename, key) => {
|
|
|
152
152
|
});
|
|
153
153
|
return result;
|
|
154
154
|
};
|
|
155
|
+
var hasTrueProperty = (code, filename, key) => {
|
|
156
|
+
const ast = tryParseModule(code, filename);
|
|
157
|
+
let found = false;
|
|
158
|
+
if (ast) {
|
|
159
|
+
walk(ast.program, (node) => {
|
|
160
|
+
if (node.type !== "ObjectProperty" || node.computed) return;
|
|
161
|
+
const name = node.key.type === "Identifier" ? node.key.name : node.key.type === "StringLiteral" ? node.key.value : null;
|
|
162
|
+
if (name === key && node.value.type === "BooleanLiteral")
|
|
163
|
+
found ||= node.value.value;
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return found;
|
|
167
|
+
};
|
|
155
168
|
|
|
156
169
|
// src/detect/package-json.ts
|
|
157
170
|
import path from "path";
|
|
@@ -328,6 +341,18 @@ var findViteConfig = (vfs, root) => firstExisting(
|
|
|
328
341
|
root,
|
|
329
342
|
CONFIG_EXTENSIONS.map((ext) => `vite.config.${ext}`)
|
|
330
343
|
);
|
|
344
|
+
var detectCacheComponents = (vfs, root) => {
|
|
345
|
+
const config = firstExisting(
|
|
346
|
+
vfs,
|
|
347
|
+
root,
|
|
348
|
+
CONFIG_EXTENSIONS.map((ext) => `next.config.${ext}`)
|
|
349
|
+
);
|
|
350
|
+
return config ? hasTrueProperty(
|
|
351
|
+
vfs.readText(path3.join(root, config)) ?? "",
|
|
352
|
+
config,
|
|
353
|
+
"cacheComponents"
|
|
354
|
+
) : false;
|
|
355
|
+
};
|
|
331
356
|
var normalizeDir = (dir) => path3.posix.normalize(dir).replace(/^\.\/?$/, "").replace(/\/+$/, "");
|
|
332
357
|
var dynamicConfig = (file, what) => ({
|
|
333
358
|
status: "unsupported",
|
|
@@ -384,7 +409,8 @@ var detectNext = (vfs, root, range) => {
|
|
|
384
409
|
version,
|
|
385
410
|
major: major2,
|
|
386
411
|
...layout,
|
|
387
|
-
proxyKind: major2 >= 16 ? "proxy" : "middleware"
|
|
412
|
+
proxyKind: major2 >= 16 ? "proxy" : "middleware",
|
|
413
|
+
cacheComponents: detectCacheComponents(vfs, root)
|
|
388
414
|
}
|
|
389
415
|
};
|
|
390
416
|
};
|
|
@@ -406,6 +432,7 @@ var detectVinext = (vfs, root, range) => {
|
|
|
406
432
|
major: majorOf(version) ?? majorOf(range),
|
|
407
433
|
...layout,
|
|
408
434
|
proxyKind: hasMiddleware ? "middleware" : "proxy",
|
|
435
|
+
cacheComponents: false,
|
|
409
436
|
viteConfig: findViteConfig(vfs, root)
|
|
410
437
|
}
|
|
411
438
|
};
|
|
@@ -1672,6 +1699,27 @@ var configImportClause = (shape, local) => {
|
|
|
1672
1699
|
if (shape.named.length === 1) return `{ ${shape.named[0]} as ${local} }`;
|
|
1673
1700
|
return null;
|
|
1674
1701
|
};
|
|
1702
|
+
var INSTANT = `// Cache Components: allow rendering on request, outside <Suspense>
|
|
1703
|
+
export const instant = false;`;
|
|
1704
|
+
var cacheComponentsEdits = (ast, code) => {
|
|
1705
|
+
const dynamic = ast.program.body.find(
|
|
1706
|
+
(s) => s.type === "ExportNamedDeclaration" && s.declaration?.type === "VariableDeclaration" && s.declaration.declarations.some(
|
|
1707
|
+
(d) => d.id.type === "Identifier" && d.id.name === "dynamic"
|
|
1708
|
+
)
|
|
1709
|
+
);
|
|
1710
|
+
if (!dynamic) {
|
|
1711
|
+
return [{ start: code.length, end: code.length, text: `
|
|
1712
|
+
${INSTANT}
|
|
1713
|
+
` }];
|
|
1714
|
+
}
|
|
1715
|
+
return [
|
|
1716
|
+
{
|
|
1717
|
+
start: dynamic.leadingComments?.[0]?.start ?? dynamic.start,
|
|
1718
|
+
end: dynamic.end,
|
|
1719
|
+
text: INSTANT
|
|
1720
|
+
}
|
|
1721
|
+
];
|
|
1722
|
+
};
|
|
1675
1723
|
var TYPE_FALLBACKS = {
|
|
1676
1724
|
UserData: 'import("@puckeditor/core").Data'
|
|
1677
1725
|
};
|
|
@@ -1764,6 +1812,9 @@ var relocateModule = (code, opts) => {
|
|
|
1764
1812
|
});
|
|
1765
1813
|
}
|
|
1766
1814
|
}
|
|
1815
|
+
if (opts.cacheComponents && /(^|\/)page\.[jt]sx?$/.test(opts.to)) {
|
|
1816
|
+
edits.push(...cacheComponentsEdits(ast, code));
|
|
1817
|
+
}
|
|
1767
1818
|
return { ok: true, code: applyEdits(code, edits) };
|
|
1768
1819
|
};
|
|
1769
1820
|
|
|
@@ -1930,7 +1981,8 @@ var nextRelocation = (p, info) => {
|
|
|
1930
1981
|
"lib/get-page": `${lib}/get-page`,
|
|
1931
1982
|
"puck.config": configModuleTarget(p)
|
|
1932
1983
|
},
|
|
1933
|
-
config: configRelocation(p)
|
|
1984
|
+
config: configRelocation(p),
|
|
1985
|
+
cacheComponents: info.cacheComponents
|
|
1934
1986
|
};
|
|
1935
1987
|
};
|
|
1936
1988
|
var conflictingSegments = (p, appDir) => {
|
|
@@ -7931,7 +7983,7 @@ runCli(process.argv.slice(2), {
|
|
|
7931
7983
|
stdout: process.stdout,
|
|
7932
7984
|
stderr: process.stderr,
|
|
7933
7985
|
stdinIsTTY: Boolean(process.stdin.isTTY),
|
|
7934
|
-
cliVersion: "0.24.0-canary.
|
|
7986
|
+
cliVersion: "0.24.0-canary.6e2f8164",
|
|
7935
7987
|
runner: createRunner(env),
|
|
7936
7988
|
fetch: globalThis.fetch,
|
|
7937
7989
|
openUrl,
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import "@puckeditor/core/puck.css";
|
|
15
15
|
import type { Data } from "@puckeditor/core";
|
|
16
16
|
import { Metadata } from "next";
|
|
17
|
+
import { connection } from "next/server";
|
|
17
18
|
import { Client } from "./client";
|
|
18
19
|
import { getPage } from "../../../lib/get-page";
|
|
19
20
|
|
|
@@ -45,11 +46,11 @@ export default async function Page({
|
|
|
45
46
|
}: {
|
|
46
47
|
params: Promise<{ puckPath: string[] }>;
|
|
47
48
|
}) {
|
|
49
|
+
// Load the latest saved data on every request
|
|
50
|
+
await connection();
|
|
48
51
|
const { puckPath = [] } = await params;
|
|
49
52
|
const path = `/${puckPath.join("/")}`;
|
|
50
53
|
const data = getPage(path);
|
|
51
54
|
|
|
52
55
|
return <Client path={path} data={data || EMPTY_PAGE_DATA} />;
|
|
53
56
|
}
|
|
54
|
-
|
|
55
|
-
export const dynamic = "force-dynamic";
|
|
@@ -15,6 +15,7 @@ import "@puckeditor/core/puck.css";
|
|
|
15
15
|
import "@puckeditor/plugin-ai/styles.css";
|
|
16
16
|
import type { Data } from "@puckeditor/core";
|
|
17
17
|
import { Metadata } from "next";
|
|
18
|
+
import { connection } from "next/server";
|
|
18
19
|
import { Client } from "./client";
|
|
19
20
|
import { getPage } from "../../../lib/get-page";
|
|
20
21
|
|
|
@@ -46,6 +47,8 @@ export default async function Page({
|
|
|
46
47
|
}: {
|
|
47
48
|
params: Promise<{ puckPath: string[] }>;
|
|
48
49
|
}) {
|
|
50
|
+
// Load the latest saved data on every request
|
|
51
|
+
await connection();
|
|
49
52
|
const { puckPath = [] } = await params;
|
|
50
53
|
const path = `/${puckPath.join("/")}`;
|
|
51
54
|
|
|
@@ -53,5 +56,3 @@ export default async function Page({
|
|
|
53
56
|
|
|
54
57
|
return <Client path={path} data={data || EMPTY_PAGE_DATA} />;
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
export const dynamic = "force-dynamic";
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import "@puckeditor/core/puck.css";
|
|
15
15
|
import type { Data } from "@puckeditor/core";
|
|
16
16
|
import { Metadata } from "next";
|
|
17
|
+
import { connection } from "next/server";
|
|
17
18
|
import { Client } from "./client";
|
|
18
19
|
import { getPage } from "../../../lib/get-page";
|
|
19
20
|
|
|
@@ -45,11 +46,11 @@ export default async function Page({
|
|
|
45
46
|
}: {
|
|
46
47
|
params: Promise<{ puckPath: string[] }>;
|
|
47
48
|
}) {
|
|
49
|
+
// Load the latest saved data on every request
|
|
50
|
+
await connection();
|
|
48
51
|
const { puckPath = [] } = await params;
|
|
49
52
|
const path = `/${puckPath.join("/")}`;
|
|
50
53
|
const data = getPage(path);
|
|
51
54
|
|
|
52
55
|
return <Client path={path} data={data || EMPTY_PAGE_DATA} />;
|
|
53
56
|
}
|
|
54
|
-
|
|
55
|
-
export const dynamic = "force-dynamic";
|
|
@@ -15,6 +15,7 @@ import "@puckeditor/core/puck.css";
|
|
|
15
15
|
import "@puckeditor/plugin-ai/styles.css";
|
|
16
16
|
import type { Data } from "@puckeditor/core";
|
|
17
17
|
import { Metadata } from "next";
|
|
18
|
+
import { connection } from "next/server";
|
|
18
19
|
import { Client } from "./client";
|
|
19
20
|
import { getPage } from "../../../lib/get-page";
|
|
20
21
|
|
|
@@ -46,6 +47,8 @@ export default async function Page({
|
|
|
46
47
|
}: {
|
|
47
48
|
params: Promise<{ puckPath: string[] }>;
|
|
48
49
|
}) {
|
|
50
|
+
// Load the latest saved data on every request
|
|
51
|
+
await connection();
|
|
49
52
|
const { puckPath = [] } = await params;
|
|
50
53
|
const path = `/${puckPath.join("/")}`;
|
|
51
54
|
|
|
@@ -53,5 +56,3 @@ export default async function Page({
|
|
|
53
56
|
|
|
54
57
|
return <Client path={path} data={data || EMPTY_PAGE_DATA} />;
|
|
55
58
|
}
|
|
56
|
-
|
|
57
|
-
export const dynamic = "force-dynamic";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puckeditor/cli",
|
|
3
|
-
"version": "0.24.0-canary.
|
|
3
|
+
"version": "0.24.0-canary.6e2f8164",
|
|
4
4
|
"description": "Set up Puck and Puck Cloud from the command line. Built for coding agents, friendly for humans.",
|
|
5
5
|
"author": "Chris Villa <chris@puckeditor.com>",
|
|
6
6
|
"repository": {
|