@sudajs/cli 0.14.0 → 0.15.0
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/index.js
CHANGED
|
@@ -580,85 +580,105 @@ export const { createRoot, hydrateRoot, version } = ReactDOMClient;
|
|
|
580
580
|
}
|
|
581
581
|
};
|
|
582
582
|
}
|
|
583
|
-
function
|
|
583
|
+
function createRejectEditorRuntimeDependencyPlugin() {
|
|
584
584
|
return {
|
|
585
|
-
name: "suda-
|
|
585
|
+
name: "suda-reject-editor-runtime-dependency",
|
|
586
586
|
setup(build) {
|
|
587
|
-
build.onResolve({ filter: /^@puckeditor\/core
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
contents: `
|
|
594
|
-
const PuckCore = globalThis.__SUDA_PUCK_CORE__;
|
|
595
|
-
if (!PuckCore) {
|
|
596
|
-
throw new Error("Missing host Puck core runtime (__SUDA_PUCK_CORE__).");
|
|
597
|
-
}
|
|
598
|
-
export default PuckCore;
|
|
599
|
-
export const {
|
|
600
|
-
Action,
|
|
601
|
-
ActionBar,
|
|
602
|
-
AutoField,
|
|
603
|
-
Button,
|
|
604
|
-
Drawer,
|
|
605
|
-
DropZone,
|
|
606
|
-
FieldLabel,
|
|
607
|
-
Group,
|
|
608
|
-
IconButton,
|
|
609
|
-
Label,
|
|
610
|
-
Puck,
|
|
611
|
-
Render,
|
|
612
|
-
RichTextMenu,
|
|
613
|
-
Separator,
|
|
614
|
-
blocksPlugin,
|
|
615
|
-
createUsePuck,
|
|
616
|
-
fieldsPlugin,
|
|
617
|
-
legacySideBarPlugin,
|
|
618
|
-
migrate,
|
|
619
|
-
outlinePlugin,
|
|
620
|
-
overrideKeys,
|
|
621
|
-
registerOverlayPortal,
|
|
622
|
-
renderContext,
|
|
623
|
-
resolveAllData,
|
|
624
|
-
setDeep,
|
|
625
|
-
transformProps,
|
|
626
|
-
useGetPuck,
|
|
627
|
-
usePuck,
|
|
628
|
-
walkTree,
|
|
629
|
-
} = PuckCore;
|
|
630
|
-
`
|
|
587
|
+
build.onResolve({ filter: /^@puckeditor\/(?:core|plugin-ai)(?:\/.*)?$/ }, (args) => ({
|
|
588
|
+
errors: [
|
|
589
|
+
{
|
|
590
|
+
text: `${args.path} is an editor dependency and cannot be imported by the public theme client runtime.`
|
|
591
|
+
}
|
|
592
|
+
]
|
|
631
593
|
}));
|
|
632
594
|
}
|
|
633
595
|
};
|
|
634
596
|
}
|
|
635
|
-
function
|
|
597
|
+
function createHostThemeRuntimeShimPlugin() {
|
|
636
598
|
return {
|
|
637
|
-
name: "suda-theme-
|
|
599
|
+
name: "suda-host-theme-runtime-shim",
|
|
638
600
|
setup(build) {
|
|
639
|
-
const themeRequire = createRequire(path2.join(root, "package.json"));
|
|
640
|
-
const runtimeEntry = themeRequire.resolve("@sudajs/theme-engine/runtime");
|
|
641
601
|
build.onResolve({ filter: /^@sudajs\/theme-engine\/runtime$/ }, () => ({
|
|
642
|
-
path:
|
|
602
|
+
path: "theme-runtime-host-shim",
|
|
603
|
+
namespace: "suda-shim"
|
|
604
|
+
}));
|
|
605
|
+
build.onLoad({ filter: /^theme-runtime-host-shim$/, namespace: "suda-shim" }, () => ({
|
|
606
|
+
loader: "js",
|
|
607
|
+
contents: `
|
|
608
|
+
const ThemeRuntime = globalThis.__SUDA_THEME_RUNTIME__;
|
|
609
|
+
if (!ThemeRuntime) {
|
|
610
|
+
throw new Error("Missing host theme runtime (__SUDA_THEME_RUNTIME__).");
|
|
611
|
+
}
|
|
612
|
+
export const {
|
|
613
|
+
SudaLucideIcon,
|
|
614
|
+
isSudaLucideIconName,
|
|
615
|
+
normalizeSudaLucideIconName,
|
|
616
|
+
colorSchemeField,
|
|
617
|
+
createColorSchemeDefault,
|
|
618
|
+
createThemeCssVariables,
|
|
619
|
+
designSystemField,
|
|
620
|
+
resolveColorSchemeTokens,
|
|
621
|
+
SUDA_COLOR_TOKEN_KEYS,
|
|
622
|
+
createThemeDesignCssVariables,
|
|
623
|
+
createThemeDesignDefault,
|
|
624
|
+
resolveThemeDesignTokens,
|
|
625
|
+
SUDA_CUSTOM_DESIGN_PRESET_ID,
|
|
626
|
+
SUDA_DESIGN_COLOR_KEYS,
|
|
627
|
+
SUDA_DESIGN_RADIUS_KEYS,
|
|
628
|
+
compileSudaBlockSlots,
|
|
629
|
+
isSudaLocalBlockComponent,
|
|
630
|
+
SUDA_LOCAL_BLOCK_CATEGORY,
|
|
631
|
+
SUDA_LOCAL_BLOCK_TYPE_PREFIX,
|
|
632
|
+
cmsPaginationUrl,
|
|
633
|
+
getIcpRecord,
|
|
634
|
+
getCmsContent,
|
|
635
|
+
getContactForm,
|
|
636
|
+
getPostResource,
|
|
637
|
+
getWhiteLabel,
|
|
638
|
+
resolveAsset,
|
|
639
|
+
postResourceKey,
|
|
640
|
+
getPageSlot,
|
|
641
|
+
THEME_PAGE_SLOT,
|
|
642
|
+
createThemeAsset,
|
|
643
|
+
createThemeAssetPath,
|
|
644
|
+
createThemeAssetResolver,
|
|
645
|
+
resolveThemeClientRuntimeUrl,
|
|
646
|
+
resolveThemeRuntimeUrl,
|
|
647
|
+
resolveAssetPath,
|
|
648
|
+
THEME_CLIENT_RUNTIME_ARTIFACT,
|
|
649
|
+
clearThemeLocale,
|
|
650
|
+
createThemeTranslate,
|
|
651
|
+
installThemeLocale,
|
|
652
|
+
clearThemePreviewLocale,
|
|
653
|
+
createThemePreviewTranslate,
|
|
654
|
+
installThemePreviewLocale,
|
|
655
|
+
} = ThemeRuntime;
|
|
656
|
+
`
|
|
643
657
|
}));
|
|
644
658
|
}
|
|
645
659
|
};
|
|
646
660
|
}
|
|
647
|
-
function
|
|
661
|
+
function createHostThemeIconsShimPlugin() {
|
|
648
662
|
return {
|
|
649
|
-
name: "suda-theme-
|
|
663
|
+
name: "suda-host-theme-icons-shim",
|
|
650
664
|
setup(build) {
|
|
651
|
-
const themeRequire = createRequire(path2.join(root, "package.json"));
|
|
652
|
-
const themeEngineEntry = themeRequire.resolve("@sudajs/theme-engine");
|
|
653
|
-
const entryDir = path2.dirname(themeEngineEntry);
|
|
654
|
-
const packageRoot2 = path2.basename(entryDir) === "dist" || path2.basename(entryDir) === "src" ? path2.dirname(entryDir) : entryDir;
|
|
655
|
-
const sourceEntry = path2.join(packageRoot2, "src", "icons", "lucide-icon.hydrate.client.tsx");
|
|
656
665
|
build.onResolve({ filter: /^@sudajs\/theme-engine\/icons$/ }, () => {
|
|
657
|
-
|
|
658
|
-
return { path: sourceEntry };
|
|
659
|
-
}
|
|
660
|
-
return { path: themeRequire.resolve("@sudajs/theme-engine/icons") };
|
|
666
|
+
return { path: "theme-icons-host-shim", namespace: "suda-shim" };
|
|
661
667
|
});
|
|
668
|
+
build.onLoad({ filter: /^theme-icons-host-shim$/, namespace: "suda-shim" }, () => ({
|
|
669
|
+
loader: "js",
|
|
670
|
+
contents: `
|
|
671
|
+
const ThemeIcons = globalThis.__SUDA_THEME_ICONS__;
|
|
672
|
+
if (!ThemeIcons) {
|
|
673
|
+
throw new Error("Missing host theme icon runtime (__SUDA_THEME_ICONS__).");
|
|
674
|
+
}
|
|
675
|
+
export const {
|
|
676
|
+
SudaLucideIcon,
|
|
677
|
+
isSudaLucideIconName,
|
|
678
|
+
normalizeSudaLucideIconName,
|
|
679
|
+
} = ThemeIcons;
|
|
680
|
+
`
|
|
681
|
+
}));
|
|
662
682
|
}
|
|
663
683
|
};
|
|
664
684
|
}
|
|
@@ -779,9 +799,9 @@ ${issues}`);
|
|
|
779
799
|
if (module.manifest.entry !== "index.js") {
|
|
780
800
|
throw new Error('manifest.entry must be artifact-local: "index.js".');
|
|
781
801
|
}
|
|
782
|
-
if (
|
|
802
|
+
if ("clientEntry" in module.manifest) {
|
|
783
803
|
throw new Error(
|
|
784
|
-
|
|
804
|
+
"manifest.clientEntry is no longer supported. The CLI owns the runtime.client.js artifact."
|
|
785
805
|
);
|
|
786
806
|
}
|
|
787
807
|
assertRecord(module.pageConfig?.components, "pageConfig.components");
|
|
@@ -1001,18 +1021,6 @@ async function loadThemeVite(root) {
|
|
|
1001
1021
|
}
|
|
1002
1022
|
return await import(pathToFileURL(viteEntry).href);
|
|
1003
1023
|
}
|
|
1004
|
-
async function findClientEntry(root) {
|
|
1005
|
-
const candidates = [
|
|
1006
|
-
path2.join(root, "src", "runtime.client.tsx"),
|
|
1007
|
-
path2.join(root, "src", "runtime.client.ts")
|
|
1008
|
-
];
|
|
1009
|
-
for (const candidate of candidates) {
|
|
1010
|
-
if (await pathExists(candidate)) {
|
|
1011
|
-
return candidate;
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
throw new Error(`Missing runtime entry. Add src/runtime.client.ts(x) in ${root}.`);
|
|
1015
|
-
}
|
|
1016
1024
|
async function findServerEntry(root) {
|
|
1017
1025
|
const candidates = [path2.join(root, "src", "index.tsx"), path2.join(root, "src", "index.ts")];
|
|
1018
1026
|
for (const candidate of candidates) {
|
|
@@ -1113,38 +1121,74 @@ async function copyThemeLocales(root) {
|
|
|
1113
1121
|
await copyDirectory(sourceLocales, path2.join(root, "dist", "locales"));
|
|
1114
1122
|
}
|
|
1115
1123
|
async function buildClientRuntime(root, minify) {
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1118
|
-
|
|
1124
|
+
const legacyEntries = [
|
|
1125
|
+
path2.join(root, "src", "runtime.client.ts"),
|
|
1126
|
+
path2.join(root, "src", "runtime.client.tsx")
|
|
1127
|
+
];
|
|
1128
|
+
if (legacyEntries.some((entry) => existsSync(entry))) {
|
|
1129
|
+
throw new Error(
|
|
1130
|
+
"Theme-authored src/runtime.client.ts(x) is no longer supported. Move optional browser setup to src/client.ts as clientHooks; the CLI owns runtime.client.js."
|
|
1131
|
+
);
|
|
1119
1132
|
}
|
|
1120
1133
|
const packageJson = JSON.parse(await readFile(path2.join(root, "package.json"), "utf8"));
|
|
1121
1134
|
const themeVersion = typeof packageJson.version === "string" ? packageJson.version : "0.0.0";
|
|
1135
|
+
const clientHooksPath = path2.join(root, "src", "client.ts");
|
|
1136
|
+
const generatedEntry = path2.join(root, ".suda-build", "runtime.client.ts");
|
|
1137
|
+
const clientHooksImport = await pathExists(clientHooksPath) ? 'import { clientHooks } from "../src/client.js";' : "const clientHooks = {};";
|
|
1138
|
+
await mkdir(path2.dirname(generatedEntry), { recursive: true });
|
|
1139
|
+
await writeFile(
|
|
1140
|
+
generatedEntry,
|
|
1141
|
+
[
|
|
1142
|
+
'"use client";',
|
|
1143
|
+
'import type { ThemeClientHooks, ThemeClientRuntime, ThemeRenderModule } from "@sudajs/theme-engine/runtime";',
|
|
1144
|
+
'import * as themeConfig from "../src/config.js";',
|
|
1145
|
+
clientHooksImport,
|
|
1146
|
+
"const theme: ThemeRenderModule = {",
|
|
1147
|
+
" pageConfig: themeConfig.pageConfig,",
|
|
1148
|
+
" layoutConfig: themeConfig.layoutConfig,",
|
|
1149
|
+
"};",
|
|
1150
|
+
'if ("rendering" in themeConfig && themeConfig.rendering !== undefined) {',
|
|
1151
|
+
" theme.rendering = themeConfig.rendering;",
|
|
1152
|
+
"}",
|
|
1153
|
+
"const hooks: ThemeClientHooks = clientHooks;",
|
|
1154
|
+
"const runtime: ThemeClientRuntime = { theme };",
|
|
1155
|
+
"if (hooks.initialize !== undefined) {",
|
|
1156
|
+
" runtime.initialize = hooks.initialize;",
|
|
1157
|
+
"}",
|
|
1158
|
+
"export default runtime;",
|
|
1159
|
+
""
|
|
1160
|
+
].join("\n"),
|
|
1161
|
+
"utf8"
|
|
1162
|
+
);
|
|
1122
1163
|
await mkdir(path2.join(root, "dist"), { recursive: true });
|
|
1123
1164
|
const hostReactShimPlugin = createHostReactShimPlugin();
|
|
1124
|
-
const
|
|
1125
|
-
const
|
|
1126
|
-
const
|
|
1165
|
+
const rejectEditorRuntimeDependencyPlugin = createRejectEditorRuntimeDependencyPlugin();
|
|
1166
|
+
const hostThemeRuntimeShimPlugin = createHostThemeRuntimeShimPlugin();
|
|
1167
|
+
const hostThemeIconsShimPlugin = createHostThemeIconsShimPlugin();
|
|
1127
1168
|
const themeDependencyResolverPlugin = createThemeDependencyResolverPlugin(root);
|
|
1128
1169
|
await build({
|
|
1129
1170
|
bundle: true,
|
|
1130
|
-
entryPoints:
|
|
1171
|
+
entryPoints: { "runtime.client": generatedEntry },
|
|
1131
1172
|
external: ["react", "react/*", "react-dom", "react-dom/*"],
|
|
1132
1173
|
format: "esm",
|
|
1133
1174
|
jsx: "automatic",
|
|
1175
|
+
logOverride: { "import-is-undefined": "silent" },
|
|
1134
1176
|
minify,
|
|
1135
|
-
|
|
1177
|
+
outdir: path2.join(root, "dist"),
|
|
1136
1178
|
platform: "browser",
|
|
1137
1179
|
define: {
|
|
1138
1180
|
__SUDA_THEME_VERSION__: JSON.stringify(themeVersion)
|
|
1139
1181
|
},
|
|
1140
1182
|
plugins: [
|
|
1141
1183
|
hostReactShimPlugin,
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1184
|
+
rejectEditorRuntimeDependencyPlugin,
|
|
1185
|
+
hostThemeRuntimeShimPlugin,
|
|
1186
|
+
hostThemeIconsShimPlugin,
|
|
1145
1187
|
themeDependencyResolverPlugin
|
|
1146
1188
|
],
|
|
1147
1189
|
sourcemap: false,
|
|
1190
|
+
splitting: true,
|
|
1191
|
+
chunkNames: "chunks/[name]-[hash]",
|
|
1148
1192
|
target: "es2022",
|
|
1149
1193
|
treeShaking: true
|
|
1150
1194
|
});
|