@rxdrag/website-studio 0.0.3 → 0.0.5

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.
@@ -0,0 +1 @@
1
+ export declare function useAllMaterials(): import("@rxdrag/react-core-pro").IMaterial[];
@@ -8,6 +8,7 @@ export declare abstract class Coder {
8
8
  protected elements: INodeSchema<XData>[];
9
9
  protected imports: Record<string, string[]>;
10
10
  protected typeImports: Record<string, string[]>;
11
+ protected defaultImports: Record<string, string[]>;
11
12
  constructor(comsStore: TemplatesStore, elements: INodeSchema<XData>[]);
12
13
  getUsedMaterials(): IMaterial[];
13
14
  getMaterialsFromElements(elements: INodeSchema<XData>[], usedMaterials: IMaterial[]): void;
@@ -30,6 +31,7 @@ export declare abstract class Coder {
30
31
  [key: string]: INodeSchema | undefined;
31
32
  } | undefined, spaces?: number): string;
32
33
  addImport(componentName: string, packagePath: string): void;
34
+ addDefaultImport(componentName: string, packagePath: string): void;
33
35
  addTypeImport(componentName: string, packagePath: string): void;
34
36
  abstract getFileName(): string;
35
37
  }
@@ -3,9 +3,9 @@ import { ComponentCoder } from "./ComponentCoder";
3
3
  import { IMaterial } from "@rxdrag/react-core-pro";
4
4
  export declare class TemplatesStore {
5
5
  protected components: FrontComponent[];
6
- maretials: Record<string, IMaterial | undefined> | undefined;
6
+ materials: IMaterial[];
7
7
  coders: ComponentCoder[];
8
- constructor(components: FrontComponent[], maretials: Record<string, IMaterial | undefined> | undefined);
8
+ constructor(components: FrontComponent[], materials: IMaterial[]);
9
9
  getComponentCoders(): ComponentCoder[];
10
10
  getComponentCoder(name: string): ComponentCoder | undefined;
11
11
  }
@@ -4,8 +4,8 @@ import { IMaterial } from "@rxdrag/react-core-pro";
4
4
  import { StudioContextProps } from "../../components/StudioRoot";
5
5
  export declare class WebsiteGenerator {
6
6
  protected studioProps: StudioContextProps;
7
- protected materials: Record<string, IMaterial | undefined> | undefined;
8
- constructor(studioProps: StudioContextProps, materials: Record<string, IMaterial | undefined> | undefined);
7
+ protected materials: IMaterial[];
8
+ constructor(studioProps: StudioContextProps, materials: IMaterial[]);
9
9
  getComponents(): import("@rxdrag/rxcms-models").FrontComponent[];
10
10
  getPages(): Page[] | undefined;
11
11
  get404Page(): Page | undefined;
@@ -9,6 +9,6 @@ export declare const APP_PPACKAGES = "#appPackages#";
9
9
  export declare const WEBSITE_ID = "#websiteId#";
10
10
  export declare const LOADER_FUNCTION = "#loader#";
11
11
  export declare const USE_LOADER_DATA = "#useLoaderData#";
12
- export declare const rxcmsModelsVersion = "0.3.35";
13
- export declare const entifyHooksVersion = "0.2.29";
14
- export declare const modelRemixLibVersion = "0.1.46";
12
+ export declare const rxcmsModelsVersion = "0.3.36";
13
+ export declare const entifyHooksVersion = "0.2.30";
14
+ export declare const modelRemixLibVersion = "0.1.47";
package/dist/index.mjs CHANGED
@@ -10,6 +10,8 @@ import React__default, { createContext, useContext, useMemo, memo, Fragment, use
10
10
  import { useFilterMeta, useDesignerEngine, ComponentDesignersRoot, useComponentDesigners, useNode, Designer, useDocument, useDocumentChangedState, useCurrentNode, useGetNode, useChangeNodeMeta, useNodeMeta, useUndo, useRedo, useLanguage, useSetters, useResourceNode, useActiveIdState, useActions, useCurrentTree, useSelectedNodeIds, ComponentTreeWidget, useSelect, DocumentRoot } from "@rxdrag/react-core-pro";
11
11
  import { RXID_ATTR_NAME, TOOLBAR_HEIGHT, CanvasScrollEvent, CanvasResizeEvent, numbToPx, getMaxZIndex, HistoryableActionType, MARGIN_DECORATOR_NAME, LINE_DECORTOR_NAME, LineDecorator, MarginDecorator, IFrameCanvasImpl, KeyboardDriver, DragDropDriver, DragOverDriver, MouseClickDriver, MouseMoveDriver, MouseOverOutDriver, CanvasResizeDriver, CanvasScrollDriver, MouseUpDriver, ContainerImpl } from "@rxdrag/core-pro";
12
12
  import { TextNodeName } from "@rxdrag/schema-pro";
13
+ import { propSetters, Input, Textarea, ImageSelect, TargetSetter, DeviceBreakpoints, DeviceContext } from "@rxdrag/schema-setters";
14
+ import { createSchema as createSchema$1, staticMaterials, attachmentNameResource, XAttachmentIconMaterial, attachmentLinkResource, websiteSettingsContactResource, websiteSettingsAvatarResource, websiteSettingsAddressResource, webisteSettingsEmailResource, webisteSettingsTelResource, webisteSettingsFaxResource, webisteSettingMobileResource, userNameResource, userAvatarResource, userPositionResource, userProfileResource, userEmailResource, userTelResource, userMobileResource, userLinkedInResource, userTwitterResource, userFacebookResource, userInstagramResource, userLinkResource, productCategoryNameResource, productCategoryMediaResource, productCategoryDescriptionResource, productCategoryCreatedAtResource, productCategoryUpdatedAtResource, productCategoryProductsResource, proudctCategoryLinkResource, postCategoryNameResource, postCategoryDescriptionResource, postCategoryCreatedAtResource, postCategoryUpdatedAtResource, postCategoryPostsResource, postCategoryLinkResource, productTitleResource, productShortTitleResource, productCoverResource, productMediasResource, productDescriptionResource, productFeaturesResource, productContentResource, productContent2Resource, productContent3Resource, productPublishedAtResource, productCreatedAtResource, productUpdatedAtResource, productAssociationCategoryResource, productAttachmentsResource, productRelatedResource, productLinkResource, postCoverResource, postAuthorResource, postTitleResource, postDescriptionResource, postContentResource, postPublishedAtResource, postCreatedAtResource, postUpdatedAtResource, postAssociationCategoryResource, postOutlineResource, postLinkResource, productResource, productListResource, postResource, postListResource, productCategoryResource, productCategoryListResource, postCategoryResource, postCategoryListResource, searchListResource, featuredProductsResource, latestPostsResource, XPaginationMaterial, XPaginationPrevButtonMaterial, XPaginationNextButtonMaterial, XPaginationPagesMaterial, XPaginationPageIndexMaterial, XPaginationTotalMaterial, pageTitleResource, XBreadcrumbsMaterial, xHeading1Resource, xHeading2Resource, xHeading3Resource, xHeading4Resource, XParagraphMaterial, XDateMaterial, ImgMaterial, XIconMaterial, XMenuMaterial, XModalMaterial, XModalCloseMaterial, RouteLinkMaterial, XSearchMaterial, XShareMaterial, XToTopMaterial, XAnimationNumberMaterial, XSectionMaterial, XBoxMaterial, xRowName, xColName, XPageOutletMaterial, XTabsMaterial, XTabsNavTitleMaterial, XTabPanelMaterial, XFormMaterial, XFormEmailMaterial, XFormNameMaterial, XFormCompanyMaterial, XFormTelMaterial, XFormMessageMaterial, XSubmitMaterial, AMaterial, creatHtmlMaterial } from "@rxdrag/website-materials";
13
15
  import { ThemeQueryOptions, ThemeFields, WebsiteFrameQueryOptions, WebsiteFrameFields, TemplateQueryOptions, TemplateFields, TemplateCategoryFields, PageQueryOptions, PageFields, PageAssciations, MediaQueryOptions, FrontComponentQueryOptions, FrontComponentFields, ComponentCategoryFields, MediaFields, WebsiteSettingsFields, ProductCategoryAssciations, ProductCategoryFields, ProductFields, PostFields, PostAssciations, UserFields, UserAssciations, ComponentType, FrontComponentEntityName, TemplateEntityName, mediaToInput, templateToInput, TemplateCategoryQueryOptions, frontComponentToInput, ComponentCategoryQueryOptions, ExtendFieldType, PageEntityName, PageType, pageToInput, ComponentCategoryEntityName, componentCategoryToInput, TemplateCategoryEntityName, templateCategoryToInput, MediaType, ProductAssciations, PostCategoryAssciations } from "@rxdrag/rxcms-models";
14
16
  import { GlobalLoading, EntityEditModal, EntitySelectField, EditingPopoverScope, useRemoveRow, useEditRow, EntityListScope, EntityRowScope, useListData, QueryListScope, useNewRow, useIsLoading, NewButton } from "@rxdrag/rxcms-models-ui";
15
17
  import { useOneTheme, useOneWebsiteFrame, useTemplateList, usePageList, useFrontComponentList, useUpsertOnePage, useUpsertOneWebsiteFrame, useUpsertOneTheme, useDeletePageById, useDeleteWebsiteFrameById } from "@rxdrag/rxcms-model-hooks";
@@ -21,9 +23,7 @@ import { isHTMLElement, makeRxId, isStr } from "@rxdrag/shared";
21
23
  import { faker } from "@faker-js/faker";
22
24
  import { XDataType, XDataScope, PRODUCT_COVER, PAGE_BREADCRUMBS, PAGE_TITLE, TriggerType } from "@rxdrag/website-components";
23
25
  import { merge, keys, uniqueId, isObject, isArray, isString, uniqBy } from "lodash-es";
24
- import { Input, Textarea, ImageSelect, TargetSetter, propSetters, DeviceBreakpoints, DeviceContext } from "@rxdrag/schema-setters";
25
26
  import { ColorPicker, StyledTooltip, Modal, ModalContent, ModalHeader, ModalBody, WarningIcon, ModalFooter, SettingsIcon, AddIcon, Drawer, ModalClose, PinIcon, CloseIcon, LeafNode, GroupNode, SearchIcon, TreeView, PredefinedColorPicker, FrameIcon, HomeIcon, RemoveIcon, MenuIcon } from "@rxdrag/rxcms-common";
26
- import { createSchema as createSchema$1, staticMaterials, attachmentNameResource, XAttachmentIconMaterial, attachmentLinkResource, websiteSettingsContactResource, websiteSettingsAvatarResource, websiteSettingsAddressResource, webisteSettingsEmailResource, webisteSettingsTelResource, webisteSettingsFaxResource, webisteSettingMobileResource, userNameResource, userAvatarResource, userPositionResource, userProfileResource, userEmailResource, userTelResource, userMobileResource, userLinkedInResource, userTwitterResource, userFacebookResource, userInstagramResource, userLinkResource, productCategoryNameResource, productCategoryMediaResource, productCategoryDescriptionResource, productCategoryCreatedAtResource, productCategoryUpdatedAtResource, productCategoryProductsResource, proudctCategoryLinkResource, postCategoryNameResource, postCategoryDescriptionResource, postCategoryCreatedAtResource, postCategoryUpdatedAtResource, postCategoryPostsResource, postCategoryLinkResource, productTitleResource, productShortTitleResource, productCoverResource, productMediasResource, productDescriptionResource, productFeaturesResource, productContentResource, productContent2Resource, productContent3Resource, productPublishedAtResource, productCreatedAtResource, productUpdatedAtResource, productAssociationCategoryResource, productAttachmentsResource, productRelatedResource, productLinkResource, postCoverResource, postAuthorResource, postTitleResource, postDescriptionResource, postContentResource, postPublishedAtResource, postCreatedAtResource, postUpdatedAtResource, postAssociationCategoryResource, postOutlineResource, postLinkResource, productResource, productListResource, postResource, postListResource, productCategoryResource, productCategoryListResource, postCategoryResource, postCategoryListResource, searchListResource, featuredProductsResource, latestPostsResource, XPaginationMaterial, XPaginationPrevButtonMaterial, XPaginationNextButtonMaterial, XPaginationPagesMaterial, XPaginationPageIndexMaterial, XPaginationTotalMaterial, pageTitleResource, XBreadcrumbsMaterial, xHeading1Resource, xHeading2Resource, xHeading3Resource, xHeading4Resource, XParagraphMaterial, XDateMaterial, ImgMaterial, XIconMaterial, XMenuMaterial, XModalMaterial, XModalCloseMaterial, RouteLinkMaterial, XSearchMaterial, XShareMaterial, XToTopMaterial, XAnimationNumberMaterial, XSectionMaterial, XBoxMaterial, xRowName, xColName, XPageOutletMaterial, XTabsMaterial, XTabsNavTitleMaterial, XTabPanelMaterial, XFormMaterial, XFormEmailMaterial, XFormNameMaterial, XFormCompanyMaterial, XFormTelMaterial, XFormMessageMaterial, XSubmitMaterial, AMaterial, creatHtmlMaterial } from "@rxdrag/website-materials";
27
27
  import { Icon } from "@iconify/react";
28
28
  import { useUpsertEntityWithIndicator, globalErrorState } from "@rxdrag/rxcms-entify-wrapper";
29
29
  import { InputField, Form, TextareaField } from "@rxdrag/fieldy-nextui";
@@ -1352,6 +1352,27 @@ class ContentEditorImpl {
1352
1352
  const ContentEditor = (engine) => {
1353
1353
  return new ContentEditorImpl(engine);
1354
1354
  };
1355
+ const studioSetters = {
1356
+ ...propSetters,
1357
+ Fragment: React__default.Fragment
1358
+ // TabList,
1359
+ // Tab,
1360
+ // TabPanel,
1361
+ // Stack,
1362
+ // FormControl,
1363
+ // FormLabel: FormLabel,
1364
+ // Autocomplete: Autocomplete,
1365
+ // Input: toControlled(Input, 'value', ''),
1366
+ // Textarea: toControlled(Textarea, 'value', ''),
1367
+ //Select,
1368
+ //Option: Option,
1369
+ //Switch: Switch,
1370
+ //IconPicker,
1371
+ //ToggleButtonGroup,
1372
+ // Button,
1373
+ // IconButton,
1374
+ // SlotSwitch,
1375
+ };
1355
1376
  const StudioContext = createContext({});
1356
1377
  function useStudioContext() {
1357
1378
  return useContext(StudioContext);
@@ -3284,33 +3305,16 @@ function useCustomizedMaterials() {
3284
3305
  }, [components]);
3285
3306
  return materials;
3286
3307
  }
3287
- const studioSetters = {
3288
- ...propSetters,
3289
- Fragment: React__default.Fragment
3290
- // TabList,
3291
- // Tab,
3292
- // TabPanel,
3293
- // Stack,
3294
- // FormControl,
3295
- // FormLabel: FormLabel,
3296
- // Autocomplete: Autocomplete,
3297
- // Input: toControlled(Input, 'value', ''),
3298
- // Textarea: toControlled(Textarea, 'value', ''),
3299
- //Select,
3300
- //Option: Option,
3301
- //Switch: Switch,
3302
- //IconPicker,
3303
- //ToggleButtonGroup,
3304
- // Button,
3305
- // IconButton,
3306
- // SlotSwitch,
3307
- };
3308
- function EditorScope(props) {
3309
- const { children, resources, ...rest } = props;
3308
+ function useAllMaterials() {
3310
3309
  const customMaterials = useCustomizedMaterials();
3311
3310
  const materials = useMemo(() => {
3312
3311
  return staticMaterials.concat(customMaterials || []);
3313
3312
  }, [customMaterials]);
3313
+ return materials;
3314
+ }
3315
+ function EditorScope(props) {
3316
+ const { children, resources, ...rest } = props;
3317
+ const materials = useAllMaterials();
3314
3318
  const plugins = useMemo(() => {
3315
3319
  return [ContentEditor];
3316
3320
  }, []);
@@ -15417,9 +15421,9 @@ const APP_PPACKAGES = "#appPackages#";
15417
15421
  const WEBSITE_ID = "#websiteId#";
15418
15422
  const LOADER_FUNCTION = "#loader#";
15419
15423
  const USE_LOADER_DATA = "#useLoaderData#";
15420
- const rxcmsModelsVersion = "0.3.35";
15421
- const entifyHooksVersion = "0.2.29";
15422
- const modelRemixLibVersion = "0.1.46";
15424
+ const rxcmsModelsVersion = "0.3.36";
15425
+ const entifyHooksVersion = "0.2.30";
15426
+ const modelRemixLibVersion = "0.1.47";
15423
15427
  const envTemplate = {
15424
15428
  name: ".env",
15425
15429
  content: `VITE_SERVER_URL = http://139.129.23.194:4000/graphql
@@ -15853,122 +15857,91 @@ const tailwindCssTemplate = {
15853
15857
  };
15854
15858
  const slugTemplate = {
15855
15859
  name: "$slug.tsx",
15856
- content: `import type { LoaderFunction, MetaFunction } from "@remix-run/node";
15857
- import { useLoaderData } from "@remix-run/react";
15858
- import { EntifyClient } from "@rxdrag/entify-hooks";
15859
- import { MediaFields, Post, PostCategoryFields, PostFields, ProductCategoryFields, ProductFields, Slug, SlugBoolExp, SlugDistinctExp, SlugEntityName, SlugFields, SlugOrderBy, UserFields } from "@rxdrag/rxcms-models";
15860
- import { Datas } from "@rxdrag/website-components";
15861
- import { PostPage } from "~/components/PostPage";
15862
- import { ProductPage } from "~/components/ProductPage";
15863
-
15864
- export const meta: MetaFunction = ({ data }) => {
15865
- const datas = data as Datas | undefined
15866
- const obj = datas?.post || datas?.product;
15867
- return [
15868
- { title: obj?.seoTitle || obj?.title },
15869
- {
15870
- name: "description",
15871
- content: obj?.seoDescription
15872
- },
15873
- ];
15874
- };
15860
+ content: `import { redirect, type LoaderFunction, type LoaderFunctionArgs } from "~/deploy/remix-run-node";
15861
+ import type { WebsiteSettings, WebsiteSettingsBoolExp, WebsiteSettingsOrderBy, WebsiteSettingsDistinctExp, Product, ProductBoolExp, ProductDistinctExp, ProductOrderBy, Post, PostBoolExp, PostDistinctExp, PostOrderBy } from "@rxdrag/rxcms-models";
15862
+ import { WebsiteSettingsQueryOptions, WebsiteSettingsFields, ProductFields, ProductQueryOptions, PostQueryOptions } from "@rxdrag/rxcms-models";
15863
+ import { queryOneEntity } from "@rxdrag/model-remix-lib";
15864
+ import { getEnvVariables } from "~/deploy/get-env";
15875
15865
 
15876
15866
  // 定义 loader 函数
15877
- export const loader: LoaderFunction = async ({ params }) => {
15867
+ export const loader: LoaderFunction = async (args: LoaderFunctionArgs) => {
15868
+ const { params } = args
15878
15869
  const { slug } = params;
15879
- if (!process.env.VITE_SERVER_URL) {
15880
- return { status: 404, error: new Error("VITE_SERVER_URL Not Set") };
15881
- }
15882
- const websiteId = process.env.VITE_WEBSITE_ID;
15883
- if (!process.env.VITE_WEBSITE_ID) {
15884
- return { status: 404, error: new Error("VITE_WEBSITE_ID Not Set") };
15885
- }
15886
15870
 
15887
- const entifyClient = new EntifyClient(process.env.VITE_SERVER_URL);
15888
- const slugObj = await entifyClient.oneEntity<Slug, SlugBoolExp, SlugOrderBy, SlugDistinctExp>(SlugEntityName, {
15889
- queryArgs: {
15890
- where: {
15891
- [SlugFields.websiteId]: {
15892
- "_eq": websiteId
15893
- },
15871
+ if (!slug) {
15872
+ throw new Response(null, { status: 404 });
15873
+ }
15874
+ const envVariables = getEnvVariables(args)
15894
15875
 
15876
+ const webisteSettings = await queryOneEntity<WebsiteSettings, WebsiteSettingsBoolExp, WebsiteSettingsOrderBy, WebsiteSettingsDistinctExp>(
15877
+ new WebsiteSettingsQueryOptions(
15878
+ [
15879
+ WebsiteSettingsFields.id,
15880
+ WebsiteSettingsFields.map301,
15881
+ ],
15882
+ ),
15883
+ envVariables
15884
+ )
15885
+ if (webisteSettings?.map301) {
15886
+ for (const line of webisteSettings.map301?.split('
15887
+ ')) {
15888
+ const [from, to] = line.split(',');
15889
+ if (slug === from) {
15890
+ return redirect(to, 301);
15895
15891
  }
15896
- },
15897
- fields: [
15892
+ }
15893
+ }
15894
+
15895
+ const product = await queryOneEntity<Product, ProductBoolExp, ProductOrderBy, ProductDistinctExp>(
15896
+ new ProductQueryOptions(
15897
+ [
15898
+ ProductFields.id,
15899
+ ProductFields.slug,
15900
+ ],
15898
15901
  {
15899
- [SlugFields.post]: [
15900
- PostFields.id,
15901
- PostFields.title,
15902
- PostFields.seoTitle,
15903
- PostFields.seoKeywords,
15904
- PostFields.seoDescription,
15905
- PostFields.content,
15906
- {
15907
- [PostFields.author]: [
15908
- UserFields.id,
15909
- UserFields.name,
15910
- {
15911
- [UserFields.avatar]: [
15912
- MediaFields.id,
15913
- {
15914
- [MediaFields.file]: [
15915
- 'thumbnail',
15916
- ]
15917
- }
15918
- ]
15919
- }
15920
- ]
15921
- },
15922
- {
15923
- [PostFields.category]: [
15924
- PostCategoryFields.id,
15925
- PostCategoryFields.name,
15926
- PostCategoryFields.description
15927
- ]
15928
- }
15929
- ],
15930
- [SlugFields.product]: [
15931
- ProductFields.id,
15932
- ProductFields.title,
15933
- ProductFields.seoTitle,
15934
- ProductFields.seoKeywords,
15935
- ProductFields.seoDescription,
15936
- ProductFields.content,
15937
- {
15938
- [ProductFields.category]: [
15939
- ProductCategoryFields.id,
15940
- ProductCategoryFields.name,
15941
- ProductCategoryFields.description
15942
- ]
15902
+ where: {
15903
+ slug: {
15904
+ _eq: slug
15943
15905
  }
15944
- ]
15906
+ }
15945
15907
  }
15946
- ],
15947
- });
15948
- return {
15949
- datas: {
15950
- post: slugObj?.post,
15951
- product: slugObj?.product
15952
- }
15953
- };
15954
- };
15908
+ ),
15909
+ envVariables
15910
+ )
15911
+ if (product) {
15912
+ return redirect(\`/product/\${product.slug}\`, 301);
15913
+ }
15955
15914
 
15915
+ const post = await queryOneEntity<Post, PostBoolExp, PostOrderBy, PostDistinctExp>(
15916
+ new PostQueryOptions(
15917
+ [
15918
+ ProductFields.id,
15919
+ ProductFields.slug,
15920
+ ],
15921
+ {
15922
+ where: {
15923
+ slug: {
15924
+ _eq: slug
15925
+ }
15926
+ }
15927
+ }
15928
+ ),
15929
+ envVariables
15930
+ )
15956
15931
 
15957
- export default function SlugPage() {
15958
- const { datas } = useLoaderData<{ datas: Datas | undefined }>();
15959
- if (datas?.post) {
15960
- return <PostPage datas={datas as Datas} />
15961
- } else if (datas?.product) {
15962
- return <ProductPage datas={datas as Datas} />
15932
+ if (post) {
15933
+ return redirect(\`/post/\${post.slug}\`, 301);
15963
15934
  }
15964
- return <>404 can find slug</>
15965
- }
15935
+
15936
+ return redirect("/404", 404);
15937
+ };
15966
15938
  `
15967
15939
  };
15968
15940
  class Coder {
15969
15941
  constructor(comsStore, elements) {
15970
15942
  __publicField(this, "imports", {});
15971
15943
  __publicField(this, "typeImports", {});
15944
+ __publicField(this, "defaultImports", {});
15972
15945
  this.comsStore = comsStore;
15973
15946
  this.elements = elements;
15974
15947
  const customizedComponents = this.getCustomizedComponents();
@@ -15990,13 +15963,16 @@ class Coder {
15990
15963
  getMaterialsFromElements(elements, usedMaterials) {
15991
15964
  var _a2;
15992
15965
  for (const element of elements) {
15993
- const maretial = (_a2 = this.comsStore.maretials) == null ? void 0 : _a2[element.componentName];
15994
- if (maretial) {
15966
+ const maretial = (_a2 = this.comsStore.materials) == null ? void 0 : _a2.find((material) => material.componentName === element.componentName);
15967
+ if (maretial && !usedMaterials.find((material) => material.componentName === maretial.componentName)) {
15995
15968
  usedMaterials.push(maretial);
15996
15969
  }
15997
15970
  if (element.children) {
15998
15971
  this.getMaterialsFromElements(element.children, usedMaterials);
15999
15972
  }
15973
+ if (element.slots) {
15974
+ this.getMaterialsFromElements(Object.values(element.slots).filter(Boolean), usedMaterials);
15975
+ }
16000
15976
  }
16001
15977
  }
16002
15978
  getXDataSchemas() {
@@ -16015,6 +15991,9 @@ class Coder {
16015
15991
  if (element.children) {
16016
15992
  this.getXSchemas(element.children, xSchemas);
16017
15993
  }
15994
+ if (element.slots) {
15995
+ this.getXSchemas(Object.values(element.slots).filter(Boolean), xSchemas);
15996
+ }
16018
15997
  }
16019
15998
  if (element.componentName.startsWith(CUSTOMIZED_COMPONENT_NAME_PREFIX)) {
16020
15999
  const componentCoder = this.comsStore.getComponentCoder((_a2 = element.props) == null ? void 0 : _a2.name);
@@ -16035,12 +16014,16 @@ class Coder {
16035
16014
  components.push((_a2 = element.props) == null ? void 0 : _a2.name);
16036
16015
  }
16037
16016
  this.getCustomzedComponentsFromElements(element.children, components);
16017
+ if (element.slots) {
16018
+ this.getCustomzedComponentsFromElements(Object.values(element.slots).filter(Boolean), components);
16019
+ }
16038
16020
  }
16039
16021
  }
16040
16022
  getImportsCode() {
16023
+ const defaultImportsCode = Object.keys(this.defaultImports).map((key) => `import ${this.defaultImports[key].join(", ")} from "${key}"`).join("\n");
16041
16024
  const importsCode = Object.keys(this.imports).map((key) => `import { ${this.imports[key].join(", ")} } from "${key}"`).join("\n");
16042
16025
  const typeImportsCode = Object.keys(this.typeImports).map((key) => `import type { ${this.typeImports[key].join(", ")} } from "${key}"`).join("\n");
16043
- const codes = [importsCode, typeImportsCode].filter((code) => code);
16026
+ const codes = [defaultImportsCode, importsCode, typeImportsCode].filter((code) => code);
16044
16027
  return codes.join("\n") + "\n";
16045
16028
  }
16046
16029
  getUseLoaderDataCode(spaces = 2) {
@@ -16236,6 +16219,14 @@ ${spacesStr}}`).join("\n" + spacesStr);
16236
16219
  this.imports[packagePath].push(componentName);
16237
16220
  }
16238
16221
  }
16222
+ addDefaultImport(componentName, packagePath) {
16223
+ if (!this.defaultImports[packagePath]) {
16224
+ this.defaultImports[packagePath] = [];
16225
+ }
16226
+ if (!this.defaultImports[packagePath].find((name) => name === componentName)) {
16227
+ this.defaultImports[packagePath].push(componentName);
16228
+ }
16229
+ }
16239
16230
  addTypeImport(componentName, packagePath) {
16240
16231
  if (!this.typeImports[packagePath]) {
16241
16232
  this.typeImports[packagePath] = [];
@@ -16249,9 +16240,7 @@ const rootTemplate = {
16249
16240
  name: "root.tsx",
16250
16241
  content: `import type { LoaderFunctionArgs } from "~/deploy/remix-run-node";
16251
16242
  import { entify } from "@rxdrag/model-remix-lib";
16252
- import type { TDatas } from "@rxdrag/website-components";
16253
- import { useAppInit, toViewModel, XDataScope, HtmlDocument } from "@rxdrag/website-components";
16254
- import { Page404 } from "./components/Page404";
16243
+ import { useAppInit, XDataScope, HtmlDocument } from "@rxdrag/website-components";
16255
16244
  import "./tailwind.css";
16256
16245
  import './frontend.css'
16257
16246
  ${FRAME_IMPORTS}
@@ -16324,7 +16313,7 @@ class FrameCoder extends Coder {
16324
16313
  return `export const loader = async (args: LoaderFunctionArgs) => {
16325
16314
  //为了兼容cloudflare,把环境变量抽离到一个函数
16326
16315
  const envVariables = getEnvVariables(args)
16327
- const productCategories = await entify.queryProductCategories(undefined, envVariables);
16316
+ const productCategories = await entify.queryProductCategories(envVariables);
16328
16317
  const webSiteSettings = await entify.queryWebSiteSettings(envVariables);
16329
16318
  const datas: TDatas = {
16330
16319
  [XDataScope.WebsiteSettings]: webSiteSettings,
@@ -16357,7 +16346,7 @@ class ComponentCoder extends Coder {
16357
16346
  this.comsStore = comsStore;
16358
16347
  this.component = component;
16359
16348
  if (this.component.droppable) {
16360
- this.addImport("React", "react");
16349
+ this.addDefaultImport("React", "react");
16361
16350
  }
16362
16351
  if (this.getXDataSchemas().length) {
16363
16352
  this.addTypeImport("TDatas", "@rxdrag/website-components");
@@ -16426,10 +16415,10 @@ class ComponentCoder extends Coder {
16426
16415
  }
16427
16416
  }
16428
16417
  class TemplatesStore {
16429
- constructor(components, maretials) {
16418
+ constructor(components, materials) {
16430
16419
  __publicField(this, "coders", []);
16431
16420
  this.components = components;
16432
- this.maretials = maretials;
16421
+ this.materials = materials;
16433
16422
  this.coders = this.components.map((component) => new ComponentCoder(this, component));
16434
16423
  }
16435
16424
  getComponentCoders() {
@@ -16844,14 +16833,14 @@ function useExportWebsite() {
16844
16833
  const website = useWebsite();
16845
16834
  const save = useSave();
16846
16835
  const contextValue = useStudioContext();
16847
- const engine = useDesignerEngine();
16836
+ const materials = useAllMaterials();
16848
16837
  const exportWebsite = useCallback(async () => {
16849
16838
  try {
16850
16839
  if (nopClient && website) {
16851
16840
  setExporting(true);
16852
16841
  const generator = new WebsiteGenerator(
16853
16842
  contextValue,
16854
- engine == null ? void 0 : engine.getComponentManager().getAllComponentConfigs()
16843
+ materials
16855
16844
  );
16856
16845
  const zip = await generator.generate();
16857
16846
  const content = await zip.generateAsync({ type: "blob" });
@@ -16863,7 +16852,7 @@ function useExportWebsite() {
16863
16852
  } finally {
16864
16853
  setExporting(false);
16865
16854
  }
16866
- }, [contextValue, engine, nopClient, save, setError, website]);
16855
+ }, [contextValue, materials, nopClient, save, setError, website]);
16867
16856
  return { exportWebsite, exporting };
16868
16857
  }
16869
16858
  const Toolbar = memo(() => {