@akairos/typeset-studio 0.2.0 → 0.2.1

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.
@@ -6696,331 +6696,357 @@ function applyTemplateImages(currentImages, templateImages) {
6696
6696
 
6697
6697
  // src/server/routes/templates.ts
6698
6698
  import { existsSync as existsSync3, mkdirSync, readdirSync as readdirSync2, readFileSync as readFileSync2, unlinkSync, writeFileSync } from "fs";
6699
- import { join as join3 } from "path";
6700
- var TEMPLATES_DIR = join3(process.cwd(), "data", "templates");
6699
+ import { dirname, join as join3, resolve as resolve2 } from "path";
6700
+ import { fileURLToPath } from "url";
6701
+ var __dirname = "/Users/aatrox/.oh-my-zzhub/core/typeset-studio/src/server/routes";
6702
+ function resolveDataDir() {
6703
+ if (process.env.TYPESET_DATA_DIR) {
6704
+ return process.env.TYPESET_DATA_DIR;
6705
+ }
6706
+ const currentDir = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
6707
+ const candidateLib = resolve2(currentDir, "../../data");
6708
+ if (existsSync3(candidateLib))
6709
+ return candidateLib;
6710
+ const candidateSrc = resolve2(currentDir, "../../../data");
6711
+ if (existsSync3(candidateSrc))
6712
+ return candidateSrc;
6713
+ const candidateCwd = resolve2(process.cwd(), "data");
6714
+ if (existsSync3(candidateCwd))
6715
+ return candidateCwd;
6716
+ return candidateLib;
6717
+ }
6718
+ var TEMPLATES_DIR = join3(resolveDataDir(), "templates");
6701
6719
  function ensureTemplatesDir() {
6702
6720
  if (!existsSync3(TEMPLATES_DIR)) {
6703
- mkdirSync(TEMPLATES_DIR, { recursive: true });
6721
+ try {
6722
+ mkdirSync(TEMPLATES_DIR, { recursive: true });
6723
+ } catch {}
6704
6724
  }
6705
6725
  seedDefaultTemplates();
6706
6726
  }
6707
- function seedDefaultTemplates() {
6708
- const presets = [
6709
- {
6710
- ...getDefaultConfig("wechat-cover-2.35"),
6711
- id: "tpl_wechat_cover_minimal",
6712
- name: "微信纯净大图封面 (2.35:1)",
6713
- slot: "article_cover",
6714
- algorithm: {
6715
- ...getDefaultConfig("wechat-cover-2.35").algorithm,
6716
- baseFontSize: 58,
6717
- scaleRatio: 1.4,
6718
- verticalAlign: "center",
6719
- textAlign: "center"
6720
- },
6721
- theme: {
6722
- bgColor: "#09090b",
6723
- textColor: "#ffffff",
6724
- headingColor: "#ffffff",
6725
- accentColor: "#10b981",
6726
- quoteColor: "#71717a",
6727
- captionColor: "#71717a",
6728
- watermarkColor: "#3f3f46",
6729
- cardBg: "#18181b"
6730
- },
6731
- typography: {
6732
- headingFont: "PingFang SC",
6733
- bodyFont: "Songti SC"
6734
- },
6735
- footerText: "",
6736
- watermarkText: "",
6737
- chrome: {
6738
- showHeader: false,
6739
- showWatermark: false,
6740
- showPageNumber: false,
6741
- showFooter: false,
6742
- showFooterDivider: false,
6743
- showFooterText: false,
6744
- showFillRatio: false
6745
- },
6746
- images: [
6747
- {
6748
- id: "tpl_img_cover_bg",
6749
- src: "https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=1200&auto=format&fit=crop&q=80",
6750
- alt: "封面装饰图",
6751
- isAbsolute: true,
6752
- x: 1350,
6753
- y: 120,
6754
- width: 880,
6755
- height: 760,
6756
- zIndex: 5,
6757
- rotate: 0,
6758
- opacity: 0.95,
6759
- borderRadius: 24,
6760
- layoutPreset: "custom"
6761
- }
6762
- ]
6727
+ var BUILTIN_PRESETS = [
6728
+ {
6729
+ ...getDefaultConfig("wechat-cover-2.35"),
6730
+ id: "tpl_wechat_cover_minimal",
6731
+ name: "微信纯净大图封面 (2.35:1)",
6732
+ slot: "article_cover",
6733
+ algorithm: {
6734
+ ...getDefaultConfig("wechat-cover-2.35").algorithm,
6735
+ baseFontSize: 58,
6736
+ scaleRatio: 1.4,
6737
+ verticalAlign: "center",
6738
+ textAlign: "center"
6763
6739
  },
6764
- {
6765
- ...getDefaultConfig("wechat-cover-2.35"),
6766
- id: "tpl_wechat_cover_editorial",
6767
- name: "微信杂志标封面 (2.35:1)",
6768
- slot: "article_cover",
6769
- algorithm: {
6770
- ...getDefaultConfig("wechat-cover-2.35").algorithm,
6771
- baseFontSize: 54,
6772
- scaleRatio: 1.35,
6773
- verticalAlign: "center",
6774
- textAlign: "left"
6775
- },
6776
- theme: {
6777
- bgColor: "#ffffff",
6778
- textColor: "#111827",
6779
- headingColor: "#000000",
6780
- accentColor: "#059669",
6781
- quoteColor: "#4b5563",
6782
- captionColor: "#6b7280",
6783
- watermarkColor: "#9ca3af",
6784
- cardBg: "#f3f4f6"
6785
- },
6786
- typography: {
6787
- headingFont: "PingFang SC",
6788
- bodyFont: "Songti SC"
6789
- },
6790
- footerText: "",
6791
- watermarkText: "SPECIAL EDITION · 专栏特辑",
6792
- chrome: {
6793
- showHeader: true,
6794
- showWatermark: true,
6795
- showPageNumber: false,
6796
- showFooter: false,
6797
- showFooterDivider: false,
6798
- showFooterText: false,
6799
- showFillRatio: false
6800
- },
6801
- images: [
6802
- {
6803
- id: "tpl_img_editorial_card",
6804
- src: "https://images.unsplash.com/photo-1600585154340-be6161a56a0c?w=1200&auto=format&fit=crop&q=80",
6805
- alt: "杂志插图",
6806
- isAbsolute: true,
6807
- x: 1400,
6808
- y: 140,
6809
- width: 820,
6810
- height: 720,
6811
- zIndex: 15,
6812
- rotate: -2,
6813
- opacity: 1,
6814
- borderRadius: 20,
6815
- layoutPreset: "custom"
6816
- }
6817
- ]
6740
+ theme: {
6741
+ bgColor: "#09090b",
6742
+ textColor: "#ffffff",
6743
+ headingColor: "#ffffff",
6744
+ accentColor: "#10b981",
6745
+ quoteColor: "#71717a",
6746
+ captionColor: "#71717a",
6747
+ watermarkColor: "#3f3f46",
6748
+ cardBg: "#18181b"
6818
6749
  },
6819
- {
6820
- ...getDefaultConfig("longform-3-4"),
6821
- id: "tpl_newspic_poster_cover",
6822
- name: "贴图封面海报 (3:4)",
6823
- slot: "newspic_cover",
6824
- algorithm: {
6825
- ...getDefaultConfig("longform-3-4").algorithm,
6826
- baseFontSize: 56,
6827
- scaleRatio: 1.35,
6828
- verticalAlign: "center",
6829
- textAlign: "center"
6830
- },
6831
- theme: {
6832
- bgColor: "#121212",
6833
- textColor: "#ffffff",
6834
- headingColor: "#ffffff",
6835
- accentColor: "#f59e0b",
6836
- quoteColor: "#a3a3a3",
6837
- captionColor: "#737373",
6838
- watermarkColor: "#525252",
6839
- cardBg: "#1c1c1c"
6840
- },
6841
- typography: {
6842
- headingFont: "PingFang SC",
6843
- bodyFont: "Songti SC"
6844
- },
6845
- footerText: "Typeset Studio · 贴图精选",
6846
- watermarkText: "FEATURED NEWSPIC",
6847
- chrome: {
6848
- showHeader: true,
6849
- showWatermark: true,
6850
- showPageNumber: false,
6851
- showFooter: true,
6852
- showFooterDivider: false,
6853
- showFooterText: true,
6854
- showFillRatio: false
6855
- },
6856
- images: [
6857
- {
6858
- id: "tpl_img_poster_bg",
6859
- src: "https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=1200&auto=format&fit=crop&q=80",
6860
- alt: "海报主图",
6861
- isAbsolute: true,
6862
- x: 100,
6863
- y: 780,
6864
- width: 1000,
6865
- height: 650,
6866
- zIndex: 10,
6867
- rotate: 0,
6868
- opacity: 1,
6869
- borderRadius: 20,
6870
- layoutPreset: "custom"
6871
- }
6872
- ]
6750
+ typography: {
6751
+ headingFont: "PingFang SC",
6752
+ bodyFont: "Songti SC"
6873
6753
  },
6874
- {
6875
- ...getDefaultConfig("longform-3-4"),
6876
- id: "tpl_longform_paper_sage",
6877
- name: "纸白典雅长图文 (3:4)",
6878
- slot: "newspic_content",
6879
- theme: {
6880
- bgColor: "#fbfcfb",
6881
- textColor: "#1c1917",
6882
- headingColor: "#0c0a09",
6883
- accentColor: "#047857",
6884
- quoteColor: "#44403c",
6885
- captionColor: "#78716c",
6886
- watermarkColor: "#a8a29e",
6887
- cardBg: "#ffffff"
6888
- },
6889
- typography: {
6890
- headingFont: "Songti SC",
6891
- bodyFont: "Songti SC"
6892
- },
6893
- footerText: "Typeset Studio · 纯算法空间排版",
6894
- watermarkText: "@ANTIGRAVITY",
6895
- chrome: {
6896
- showHeader: true,
6897
- showWatermark: true,
6898
- showPageNumber: true,
6899
- showFooter: true,
6900
- showFooterDivider: true,
6901
- showFooterText: true,
6902
- showFillRatio: false
6903
- }
6754
+ footerText: "",
6755
+ watermarkText: "",
6756
+ chrome: {
6757
+ showHeader: false,
6758
+ showWatermark: false,
6759
+ showPageNumber: false,
6760
+ showFooter: false,
6761
+ showFooterDivider: false,
6762
+ showFooterText: false,
6763
+ showFillRatio: false
6904
6764
  },
6905
- {
6906
- ...getDefaultConfig("square-1-1"),
6907
- id: "tpl_square_quote_card",
6908
- name: "金句留白方卡 (1:1)",
6909
- algorithm: {
6910
- ...getDefaultConfig("square-1-1").algorithm,
6911
- baseFontSize: 50,
6912
- scaleRatio: 1.3,
6913
- verticalAlign: "center",
6914
- textAlign: "center"
6915
- },
6916
- theme: {
6917
- bgColor: "#18181b",
6918
- textColor: "#fafafa",
6919
- headingColor: "#ffffff",
6920
- accentColor: "#f59e0b",
6921
- quoteColor: "#d4d4d8",
6922
- captionColor: "#a1a1aa",
6923
- watermarkColor: "#71717a",
6924
- cardBg: "#27272a"
6925
- },
6926
- typography: {
6927
- headingFont: "PingFang SC",
6928
- bodyFont: "Kaiti SC"
6929
- },
6930
- footerText: "",
6931
- watermarkText: "",
6932
- chrome: {
6933
- showHeader: false,
6934
- showWatermark: false,
6935
- showPageNumber: false,
6936
- showFooter: false,
6937
- showFooterDivider: false,
6938
- showFooterText: false,
6939
- showFillRatio: false
6765
+ images: [
6766
+ {
6767
+ id: "tpl_img_cover_bg",
6768
+ src: "https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=1200&auto=format&fit=crop&q=80",
6769
+ alt: "封面装饰图",
6770
+ isAbsolute: true,
6771
+ x: 1350,
6772
+ y: 120,
6773
+ width: 880,
6774
+ height: 760,
6775
+ zIndex: 5,
6776
+ rotate: 0,
6777
+ opacity: 0.95,
6778
+ borderRadius: 24,
6779
+ layoutPreset: "custom"
6940
6780
  }
6781
+ ]
6782
+ },
6783
+ {
6784
+ ...getDefaultConfig("wechat-cover-2.35"),
6785
+ id: "tpl_wechat_cover_editorial",
6786
+ name: "微信杂志标封面 (2.35:1)",
6787
+ slot: "article_cover",
6788
+ algorithm: {
6789
+ ...getDefaultConfig("wechat-cover-2.35").algorithm,
6790
+ baseFontSize: 54,
6791
+ scaleRatio: 1.35,
6792
+ verticalAlign: "center",
6793
+ textAlign: "left"
6941
6794
  },
6942
- {
6943
- ...getDefaultConfig("wide-16-9"),
6944
- id: "tpl_wide_tech_banner",
6945
- name: "极简技术宽屏 (16:9)",
6946
- algorithm: {
6947
- ...getDefaultConfig("wide-16-9").algorithm,
6948
- baseFontSize: 46,
6949
- scaleRatio: 1.3,
6950
- verticalAlign: "center",
6951
- textAlign: "left"
6952
- },
6953
- theme: {
6954
- bgColor: "#09090b",
6955
- textColor: "#f4f4f5",
6956
- headingColor: "#ffffff",
6957
- accentColor: "#3b82f6",
6958
- quoteColor: "#a1a1aa",
6959
- captionColor: "#71717a",
6960
- watermarkColor: "#52525b",
6961
- cardBg: "#18181b"
6962
- },
6963
- typography: {
6964
- headingFont: "PingFang SC",
6965
- bodyFont: "SourceHanSansSC, sans-serif"
6966
- },
6967
- footerText: "TECH ENGINEERING INSIGHTS",
6968
- watermarkText: "DEV // ARCHITECTURE",
6969
- chrome: {
6970
- showHeader: true,
6971
- showWatermark: true,
6972
- showPageNumber: false,
6973
- showFooter: true,
6974
- showFooterDivider: false,
6975
- showFooterText: true,
6976
- showFillRatio: false
6795
+ theme: {
6796
+ bgColor: "#ffffff",
6797
+ textColor: "#111827",
6798
+ headingColor: "#000000",
6799
+ accentColor: "#059669",
6800
+ quoteColor: "#4b5563",
6801
+ captionColor: "#6b7280",
6802
+ watermarkColor: "#9ca3af",
6803
+ cardBg: "#f3f4f6"
6804
+ },
6805
+ typography: {
6806
+ headingFont: "PingFang SC",
6807
+ bodyFont: "Songti SC"
6808
+ },
6809
+ footerText: "",
6810
+ watermarkText: "SPECIAL EDITION · 专栏特辑",
6811
+ chrome: {
6812
+ showHeader: true,
6813
+ showWatermark: true,
6814
+ showPageNumber: false,
6815
+ showFooter: false,
6816
+ showFooterDivider: false,
6817
+ showFooterText: false,
6818
+ showFillRatio: false
6819
+ },
6820
+ images: [
6821
+ {
6822
+ id: "tpl_img_editorial_card",
6823
+ src: "https://images.unsplash.com/photo-1600585154340-be6161a56a0c?w=1200&auto=format&fit=crop&q=80",
6824
+ alt: "杂志插图",
6825
+ isAbsolute: true,
6826
+ x: 1400,
6827
+ y: 140,
6828
+ width: 820,
6829
+ height: 720,
6830
+ zIndex: 15,
6831
+ rotate: -2,
6832
+ opacity: 1,
6833
+ borderRadius: 20,
6834
+ layoutPreset: "custom"
6977
6835
  }
6836
+ ]
6837
+ },
6838
+ {
6839
+ ...getDefaultConfig("longform-3-4"),
6840
+ id: "tpl_newspic_poster_cover",
6841
+ name: "贴图封面海报 (3:4)",
6842
+ slot: "newspic_cover",
6843
+ algorithm: {
6844
+ ...getDefaultConfig("longform-3-4").algorithm,
6845
+ baseFontSize: 56,
6846
+ scaleRatio: 1.35,
6847
+ verticalAlign: "center",
6848
+ textAlign: "center"
6978
6849
  },
6979
- {
6980
- ...getDefaultConfig("longform-3-4"),
6981
- id: "tpl_longform_vintage_news",
6982
- name: "复古报刊多图 (3:4)",
6983
- slot: "newspic_content",
6984
- algorithm: {
6985
- ...getDefaultConfig("longform-3-4").algorithm,
6986
- baseFontSize: 38,
6987
- scaleRatio: 1.25,
6988
- verticalAlign: "top",
6989
- textAlign: "left"
6990
- },
6991
- theme: {
6992
- bgColor: "#f7f4ee",
6993
- textColor: "#262320",
6994
- headingColor: "#141210",
6995
- accentColor: "#991b1b",
6996
- quoteColor: "#57534e",
6997
- captionColor: "#78716c",
6998
- watermarkColor: "#a8a29e",
6999
- cardBg: "#eee9df"
7000
- },
7001
- typography: {
7002
- headingFont: "SourceHanSerifSC, serif",
7003
- bodyFont: "SourceHanSerifSC, serif"
7004
- },
7005
- footerText: "WEEKLY REPORT · 观察与沉淀",
7006
- watermarkText: "VOL. 42 // THE CHRONICLE",
7007
- chrome: {
7008
- showHeader: true,
7009
- showWatermark: true,
7010
- showPageNumber: true,
7011
- showFooter: true,
7012
- showFooterDivider: true,
7013
- showFooterText: true,
7014
- showFillRatio: false
6850
+ theme: {
6851
+ bgColor: "#121212",
6852
+ textColor: "#ffffff",
6853
+ headingColor: "#ffffff",
6854
+ accentColor: "#f59e0b",
6855
+ quoteColor: "#a3a3a3",
6856
+ captionColor: "#737373",
6857
+ watermarkColor: "#525252",
6858
+ cardBg: "#1c1c1c"
6859
+ },
6860
+ typography: {
6861
+ headingFont: "PingFang SC",
6862
+ bodyFont: "Songti SC"
6863
+ },
6864
+ footerText: "Typeset Studio · 贴图精选",
6865
+ watermarkText: "FEATURED NEWSPIC",
6866
+ chrome: {
6867
+ showHeader: true,
6868
+ showWatermark: true,
6869
+ showPageNumber: false,
6870
+ showFooter: true,
6871
+ showFooterDivider: false,
6872
+ showFooterText: true,
6873
+ showFillRatio: false
6874
+ },
6875
+ images: [
6876
+ {
6877
+ id: "tpl_img_poster_bg",
6878
+ src: "https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=1200&auto=format&fit=crop&q=80",
6879
+ alt: "海报主图",
6880
+ isAbsolute: true,
6881
+ x: 100,
6882
+ y: 780,
6883
+ width: 1000,
6884
+ height: 650,
6885
+ zIndex: 10,
6886
+ rotate: 0,
6887
+ opacity: 1,
6888
+ borderRadius: 20,
6889
+ layoutPreset: "custom"
7015
6890
  }
6891
+ ]
6892
+ },
6893
+ {
6894
+ ...getDefaultConfig("longform-3-4"),
6895
+ id: "tpl_longform_paper_sage",
6896
+ name: "纸白典雅长图文 (3:4)",
6897
+ slot: "newspic_content",
6898
+ theme: {
6899
+ bgColor: "#fbfcfb",
6900
+ textColor: "#1c1917",
6901
+ headingColor: "#0c0a09",
6902
+ accentColor: "#047857",
6903
+ quoteColor: "#44403c",
6904
+ captionColor: "#78716c",
6905
+ watermarkColor: "#a8a29e",
6906
+ cardBg: "#ffffff"
6907
+ },
6908
+ typography: {
6909
+ headingFont: "Songti SC",
6910
+ bodyFont: "Songti SC"
6911
+ },
6912
+ footerText: "Typeset Studio · 纯算法空间排版",
6913
+ watermarkText: "@ANTIGRAVITY",
6914
+ chrome: {
6915
+ showHeader: true,
6916
+ showWatermark: true,
6917
+ showPageNumber: true,
6918
+ showFooter: true,
6919
+ showFooterDivider: true,
6920
+ showFooterText: true,
6921
+ showFillRatio: false
7016
6922
  }
7017
- ];
7018
- for (const preset of presets) {
6923
+ },
6924
+ {
6925
+ ...getDefaultConfig("square-1-1"),
6926
+ id: "tpl_square_quote_card",
6927
+ name: "金句留白方卡 (1:1)",
6928
+ algorithm: {
6929
+ ...getDefaultConfig("square-1-1").algorithm,
6930
+ baseFontSize: 50,
6931
+ scaleRatio: 1.3,
6932
+ verticalAlign: "center",
6933
+ textAlign: "center"
6934
+ },
6935
+ theme: {
6936
+ bgColor: "#18181b",
6937
+ textColor: "#fafafa",
6938
+ headingColor: "#ffffff",
6939
+ accentColor: "#f59e0b",
6940
+ quoteColor: "#d4d4d8",
6941
+ captionColor: "#a1a1aa",
6942
+ watermarkColor: "#71717a",
6943
+ cardBg: "#27272a"
6944
+ },
6945
+ typography: {
6946
+ headingFont: "PingFang SC",
6947
+ bodyFont: "Kaiti SC"
6948
+ },
6949
+ footerText: "",
6950
+ watermarkText: "",
6951
+ chrome: {
6952
+ showHeader: false,
6953
+ showWatermark: false,
6954
+ showPageNumber: false,
6955
+ showFooter: false,
6956
+ showFooterDivider: false,
6957
+ showFooterText: false,
6958
+ showFillRatio: false
6959
+ }
6960
+ },
6961
+ {
6962
+ ...getDefaultConfig("wide-16-9"),
6963
+ id: "tpl_wide_tech_banner",
6964
+ name: "极简技术宽屏 (16:9)",
6965
+ algorithm: {
6966
+ ...getDefaultConfig("wide-16-9").algorithm,
6967
+ baseFontSize: 46,
6968
+ scaleRatio: 1.3,
6969
+ verticalAlign: "center",
6970
+ textAlign: "left"
6971
+ },
6972
+ theme: {
6973
+ bgColor: "#09090b",
6974
+ textColor: "#f4f4f5",
6975
+ headingColor: "#ffffff",
6976
+ accentColor: "#3b82f6",
6977
+ quoteColor: "#a1a1aa",
6978
+ captionColor: "#71717a",
6979
+ watermarkColor: "#52525b",
6980
+ cardBg: "#18181b"
6981
+ },
6982
+ typography: {
6983
+ headingFont: "PingFang SC",
6984
+ bodyFont: "SourceHanSansSC, sans-serif"
6985
+ },
6986
+ footerText: "TECH ENGINEERING INSIGHTS",
6987
+ watermarkText: "DEV // ARCHITECTURE",
6988
+ chrome: {
6989
+ showHeader: true,
6990
+ showWatermark: true,
6991
+ showPageNumber: false,
6992
+ showFooter: true,
6993
+ showFooterDivider: false,
6994
+ showFooterText: true,
6995
+ showFillRatio: false
6996
+ }
6997
+ },
6998
+ {
6999
+ ...getDefaultConfig("longform-3-4"),
7000
+ id: "tpl_longform_vintage_news",
7001
+ name: "复古报刊多图 (3:4)",
7002
+ slot: "newspic_content",
7003
+ algorithm: {
7004
+ ...getDefaultConfig("longform-3-4").algorithm,
7005
+ baseFontSize: 38,
7006
+ scaleRatio: 1.25,
7007
+ verticalAlign: "top",
7008
+ textAlign: "left"
7009
+ },
7010
+ theme: {
7011
+ bgColor: "#f7f4ee",
7012
+ textColor: "#262320",
7013
+ headingColor: "#141210",
7014
+ accentColor: "#991b1b",
7015
+ quoteColor: "#57534e",
7016
+ captionColor: "#78716c",
7017
+ watermarkColor: "#a8a29e",
7018
+ cardBg: "#eee9df"
7019
+ },
7020
+ typography: {
7021
+ headingFont: "SourceHanSerifSC, serif",
7022
+ bodyFont: "SourceHanSerifSC, serif"
7023
+ },
7024
+ footerText: "WEEKLY REPORT · 观察与沉淀",
7025
+ watermarkText: "VOL. 42 // THE CHRONICLE",
7026
+ chrome: {
7027
+ showHeader: true,
7028
+ showWatermark: true,
7029
+ showPageNumber: true,
7030
+ showFooter: true,
7031
+ showFooterDivider: true,
7032
+ showFooterText: true,
7033
+ showFillRatio: false
7034
+ }
7035
+ }
7036
+ ];
7037
+ function seedDefaultTemplates() {
7038
+ if (!existsSync3(TEMPLATES_DIR))
7039
+ return;
7040
+ for (const preset of BUILTIN_PRESETS) {
7019
7041
  const filePath = join3(TEMPLATES_DIR, `${preset.id}.json`);
7020
- writeFileSync(filePath, JSON.stringify(preset, null, 2), "utf-8");
7042
+ if (!existsSync3(filePath)) {
7043
+ try {
7044
+ writeFileSync(filePath, JSON.stringify(preset, null, 2), "utf-8");
7045
+ } catch {}
7046
+ }
7021
7047
  }
7022
7048
  }
7023
- var DEFAULT_SETTINGS_PATH = join3(process.cwd(), "data", "default-template.json");
7049
+ var DEFAULT_SETTINGS_PATH = join3(resolveDataDir(), "default-template.json");
7024
7050
  var BUILTIN_SLOT_DEFAULTS = {
7025
7051
  article_cover: "tpl_wechat_cover_minimal",
7026
7052
  newspic_cover: "tpl_newspic_poster_cover",
@@ -7090,7 +7116,15 @@ function setDefaultTemplateId(id) {
7090
7116
  writeFileSync(DEFAULT_SETTINGS_PATH, JSON.stringify(current, null, 2), "utf-8");
7091
7117
  }
7092
7118
  function findTemplateByKeyOrName(key) {
7093
- ensureTemplatesDir();
7119
+ const lowerKey = key.trim().toLowerCase();
7120
+ const builtin = BUILTIN_PRESETS.find((p) => p.id?.toLowerCase() === lowerKey || p.name.toLowerCase() === lowerKey);
7121
+ if (builtin)
7122
+ return builtin;
7123
+ const builtinPartial = BUILTIN_PRESETS.find((p) => p.name.toLowerCase().includes(lowerKey));
7124
+ if (builtinPartial)
7125
+ return builtinPartial;
7126
+ if (!existsSync3(TEMPLATES_DIR))
7127
+ return null;
7094
7128
  const directPath = join3(TEMPLATES_DIR, `${key}.json`);
7095
7129
  if (existsSync3(directPath)) {
7096
7130
  try {
@@ -7098,7 +7132,6 @@ function findTemplateByKeyOrName(key) {
7098
7132
  } catch {}
7099
7133
  }
7100
7134
  const files = readdirSync2(TEMPLATES_DIR).filter((f) => f.endsWith(".json"));
7101
- const lowerKey = key.trim().toLowerCase();
7102
7135
  for (const file of files) {
7103
7136
  try {
7104
7137
  const content = readFileSync2(join3(TEMPLATES_DIR, file), "utf-8");
@@ -7445,7 +7478,7 @@ async function renderRemoteBatch(studioUrl, body, outputDir, filenamePrefix, rou
7445
7478
  }
7446
7479
  var typesetStudioAdapter = {
7447
7480
  name: "typeset-studio",
7448
- version: "0.2.0",
7481
+ version: "0.2.1",
7449
7482
  async doctor() {
7450
7483
  const checks = [];
7451
7484
  if (REMOTE_STUDIO_URL) {