@bendyline/squisq 1.2.2 → 1.4.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/{Doc-BfBhiCNr.d.ts → Doc-BeSeH2iX.d.ts} +141 -33
- package/dist/ImageEditDoc-BTIvw0oq.d.ts +84 -0
- package/dist/__tests__/colorUtils.test.d.ts +2 -0
- package/dist/__tests__/colorUtils.test.d.ts.map +1 -0
- package/dist/__tests__/colorUtils.test.js +94 -0
- package/dist/__tests__/colorUtils.test.js.map +1 -0
- package/dist/__tests__/getLayers.test.js +31 -7
- package/dist/__tests__/getLayers.test.js.map +1 -1
- package/dist/__tests__/iconResolve.test.d.ts +2 -0
- package/dist/__tests__/iconResolve.test.d.ts.map +1 -0
- package/dist/__tests__/iconResolve.test.js +99 -0
- package/dist/__tests__/iconResolve.test.js.map +1 -0
- package/dist/__tests__/imageEditState.test.d.ts +2 -0
- package/dist/__tests__/imageEditState.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditState.test.js +61 -0
- package/dist/__tests__/imageEditState.test.js.map +1 -0
- package/dist/__tests__/imageEditVersions.test.d.ts +2 -0
- package/dist/__tests__/imageEditVersions.test.d.ts.map +1 -0
- package/dist/__tests__/imageEditVersions.test.js +141 -0
- package/dist/__tests__/imageEditVersions.test.js.map +1 -0
- package/dist/__tests__/inferDocumentTitle.test.d.ts +2 -0
- package/dist/__tests__/inferDocumentTitle.test.d.ts.map +1 -0
- package/dist/__tests__/inferDocumentTitle.test.js +42 -0
- package/dist/__tests__/inferDocumentTitle.test.js.map +1 -0
- package/dist/__tests__/jsonForm.chooseControl.test.d.ts +2 -0
- package/dist/__tests__/jsonForm.chooseControl.test.d.ts.map +1 -0
- package/dist/__tests__/jsonForm.chooseControl.test.js +74 -0
- package/dist/__tests__/jsonForm.chooseControl.test.js.map +1 -0
- package/dist/__tests__/jsonForm.evaluateWhen.test.d.ts +2 -0
- package/dist/__tests__/jsonForm.evaluateWhen.test.d.ts.map +1 -0
- package/dist/__tests__/jsonForm.evaluateWhen.test.js +51 -0
- package/dist/__tests__/jsonForm.evaluateWhen.test.js.map +1 -0
- package/dist/__tests__/jsonForm.inferSchema.test.d.ts +2 -0
- package/dist/__tests__/jsonForm.inferSchema.test.d.ts.map +1 -0
- package/dist/__tests__/jsonForm.inferSchema.test.js +23 -0
- package/dist/__tests__/jsonForm.inferSchema.test.js.map +1 -0
- package/dist/__tests__/jsonForm.pointer.test.d.ts +2 -0
- package/dist/__tests__/jsonForm.pointer.test.d.ts.map +1 -0
- package/dist/__tests__/jsonForm.pointer.test.js +94 -0
- package/dist/__tests__/jsonForm.pointer.test.js.map +1 -0
- package/dist/__tests__/markdown.test.js +40 -0
- package/dist/__tests__/markdown.test.js.map +1 -1
- package/dist/__tests__/markdownIcons.test.d.ts +2 -0
- package/dist/__tests__/markdownIcons.test.d.ts.map +1 -0
- package/dist/__tests__/markdownIcons.test.js +93 -0
- package/dist/__tests__/markdownIcons.test.js.map +1 -0
- package/dist/__tests__/markdownToDoc.test.js +15 -4
- package/dist/__tests__/markdownToDoc.test.js.map +1 -1
- package/dist/__tests__/recommendTemplates.test.d.ts +2 -0
- package/dist/__tests__/recommendTemplates.test.d.ts.map +1 -0
- package/dist/__tests__/recommendTemplates.test.js +158 -0
- package/dist/__tests__/recommendTemplates.test.js.map +1 -0
- package/dist/__tests__/scopedContentContainer.test.d.ts +2 -0
- package/dist/__tests__/scopedContentContainer.test.d.ts.map +1 -0
- package/dist/__tests__/scopedContentContainer.test.js +74 -0
- package/dist/__tests__/scopedContentContainer.test.js.map +1 -0
- package/dist/__tests__/slideshowGenerator.test.js +1 -1
- package/dist/__tests__/slideshowGenerator.test.js.map +1 -1
- package/dist/__tests__/surface.test.d.ts +2 -0
- package/dist/__tests__/surface.test.d.ts.map +1 -0
- package/dist/__tests__/surface.test.js +57 -0
- package/dist/__tests__/surface.test.js.map +1 -0
- package/dist/__tests__/templateAnnotationParse.test.d.ts +2 -0
- package/dist/__tests__/templateAnnotationParse.test.d.ts.map +1 -0
- package/dist/__tests__/templateAnnotationParse.test.js +42 -0
- package/dist/__tests__/templateAnnotationParse.test.js.map +1 -0
- package/dist/__tests__/templates.test.js +90 -9
- package/dist/__tests__/templates.test.js.map +1 -1
- package/dist/__tests__/themeCompile.test.d.ts +2 -0
- package/dist/__tests__/themeCompile.test.d.ts.map +1 -0
- package/dist/__tests__/themeCompile.test.js +134 -0
- package/dist/__tests__/themeCompile.test.js.map +1 -0
- package/dist/__tests__/themeValidator.test.d.ts +2 -0
- package/dist/__tests__/themeValidator.test.d.ts.map +1 -0
- package/dist/__tests__/themeValidator.test.js +107 -0
- package/dist/__tests__/themeValidator.test.js.map +1 -0
- package/dist/__tests__/versions.test.d.ts +2 -0
- package/dist/__tests__/versions.test.d.ts.map +1 -0
- package/dist/__tests__/versions.test.js +339 -0
- package/dist/__tests__/versions.test.js.map +1 -0
- package/dist/{chunk-CYQHG27J.js → chunk-2TMAWB4Y.js} +74 -1
- package/dist/chunk-2TMAWB4Y.js.map +1 -0
- package/dist/{chunk-LAZELBON.js → chunk-3K5OG6KI.js} +165 -17
- package/dist/chunk-3K5OG6KI.js.map +1 -0
- package/dist/chunk-57CVQCFX.js +193 -0
- package/dist/chunk-57CVQCFX.js.map +1 -0
- package/dist/{chunk-QM5PKNPW.js → chunk-5WFRKURX.js} +1 -1
- package/dist/chunk-5WFRKURX.js.map +1 -0
- package/dist/chunk-B4EEON3N.js +1317 -0
- package/dist/chunk-B4EEON3N.js.map +1 -0
- package/dist/chunk-DBS6RIFL.js +81 -0
- package/dist/chunk-DBS6RIFL.js.map +1 -0
- package/dist/{chunk-MIBRIRGJ.js → chunk-FR2RBTKO.js} +3 -3
- package/dist/{chunk-MIBRIRGJ.js.map → chunk-FR2RBTKO.js.map} +1 -1
- package/dist/chunk-H3AXU4MJ.js +179 -0
- package/dist/chunk-H3AXU4MJ.js.map +1 -0
- package/dist/chunk-JELIRVDP.js +24 -0
- package/dist/chunk-JELIRVDP.js.map +1 -0
- package/dist/chunk-K32VJONL.js +193 -0
- package/dist/chunk-K32VJONL.js.map +1 -0
- package/dist/{chunk-GAQLMORN.js → chunk-KSWJR66U.js} +248 -44
- package/dist/chunk-KSWJR66U.js.map +1 -0
- package/dist/{chunk-TSG2OSE6.js → chunk-MYIH7FWD.js} +3 -3
- package/dist/chunk-MYIH7FWD.js.map +1 -0
- package/dist/chunk-VLJJHDAC.js +218 -0
- package/dist/chunk-VLJJHDAC.js.map +1 -0
- package/dist/chunk-WMOI7FN3.js +182 -0
- package/dist/chunk-WMOI7FN3.js.map +1 -0
- package/dist/chunk-ZTX4PFFT.js +520 -0
- package/dist/chunk-ZTX4PFFT.js.map +1 -0
- package/dist/doc/audioMapping.d.ts.map +1 -1
- package/dist/doc/audioMapping.js +80 -9
- package/dist/doc/audioMapping.js.map +1 -1
- package/dist/doc/getLayers.d.ts.map +1 -1
- package/dist/doc/getLayers.js +29 -18
- package/dist/doc/getLayers.js.map +1 -1
- package/dist/doc/markdownToDoc.d.ts.map +1 -1
- package/dist/doc/markdownToDoc.js +40 -6
- package/dist/doc/markdownToDoc.js.map +1 -1
- package/dist/doc/templates/featureBlock.d.ts +18 -0
- package/dist/doc/templates/featureBlock.d.ts.map +1 -0
- package/dist/doc/templates/featureBlock.js +180 -0
- package/dist/doc/templates/featureBlock.js.map +1 -0
- package/dist/doc/templates/fullBleedQuote.d.ts +12 -0
- package/dist/doc/templates/fullBleedQuote.d.ts.map +1 -1
- package/dist/doc/templates/fullBleedQuote.js +12 -0
- package/dist/doc/templates/fullBleedQuote.js.map +1 -1
- package/dist/doc/templates/index.d.ts +28 -4
- package/dist/doc/templates/index.d.ts.map +1 -1
- package/dist/doc/templates/index.js +45 -12
- package/dist/doc/templates/index.js.map +1 -1
- package/dist/doc/templates/listBlock.d.ts.map +1 -1
- package/dist/doc/templates/listBlock.js +22 -5
- package/dist/doc/templates/listBlock.js.map +1 -1
- package/dist/doc/templates/statHighlight.d.ts +12 -0
- package/dist/doc/templates/statHighlight.d.ts.map +1 -1
- package/dist/doc/templates/statHighlight.js +12 -0
- package/dist/doc/templates/statHighlight.js.map +1 -1
- package/dist/doc/templates/titleBlock.d.ts +11 -0
- package/dist/doc/templates/titleBlock.d.ts.map +1 -1
- package/dist/doc/templates/titleBlock.js +8 -0
- package/dist/doc/templates/titleBlock.js.map +1 -1
- package/dist/doc/utils/themeUtils.d.ts +4 -4
- package/dist/doc/utils/themeUtils.d.ts.map +1 -1
- package/dist/doc/utils/themeUtils.js +8 -7
- package/dist/doc/utils/themeUtils.js.map +1 -1
- package/dist/generate/slideshowGenerator.js +1 -1
- package/dist/generate/slideshowGenerator.js.map +1 -1
- package/dist/generate/templateMapper.js +2 -2
- package/dist/generate/templateMapper.js.map +1 -1
- package/dist/icons/iconData.d.ts +26 -0
- package/dist/icons/iconData.d.ts.map +1 -0
- package/dist/icons/iconData.js +12 -0
- package/dist/icons/iconData.js.map +1 -0
- package/dist/icons/index.d.ts +12 -0
- package/dist/icons/index.d.ts.map +1 -0
- package/dist/icons/index.js +10 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/icons/resolve.d.ts +61 -0
- package/dist/icons/resolve.d.ts.map +1 -0
- package/dist/icons/resolve.js +130 -0
- package/dist/icons/resolve.js.map +1 -0
- package/dist/imageEdit/ImageEditVersionManager.d.ts +31 -0
- package/dist/imageEdit/ImageEditVersionManager.d.ts.map +1 -0
- package/dist/imageEdit/ImageEditVersionManager.js +39 -0
- package/dist/imageEdit/ImageEditVersionManager.js.map +1 -0
- package/dist/imageEdit/export.d.ts +33 -0
- package/dist/imageEdit/export.d.ts.map +1 -0
- package/dist/imageEdit/export.js +253 -0
- package/dist/imageEdit/export.js.map +1 -0
- package/dist/imageEdit/index.d.ts +14 -0
- package/dist/imageEdit/index.d.ts.map +1 -0
- package/dist/imageEdit/index.js +22 -0
- package/dist/imageEdit/index.js.map +1 -0
- package/dist/imageEdit/persistence.d.ts +15 -0
- package/dist/imageEdit/persistence.d.ts.map +1 -0
- package/dist/imageEdit/persistence.js +49 -0
- package/dist/imageEdit/persistence.js.map +1 -0
- package/dist/imageEdit/state.d.ts +42 -0
- package/dist/imageEdit/state.d.ts.map +1 -0
- package/dist/imageEdit/state.js +98 -0
- package/dist/imageEdit/state.js.map +1 -0
- package/dist/imageEdit/versionPaths.d.ts +27 -0
- package/dist/imageEdit/versionPaths.d.ts.map +1 -0
- package/dist/imageEdit/versionPaths.js +57 -0
- package/dist/imageEdit/versionPaths.js.map +1 -0
- package/dist/imageEdit/versions.d.ts +67 -0
- package/dist/imageEdit/versions.d.ts.map +1 -0
- package/dist/imageEdit/versions.js +161 -0
- package/dist/imageEdit/versions.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/jsonForm/chooseControl.d.ts +20 -0
- package/dist/jsonForm/chooseControl.d.ts.map +1 -0
- package/dist/jsonForm/chooseControl.js +82 -0
- package/dist/jsonForm/chooseControl.js.map +1 -0
- package/dist/jsonForm/evaluateWhen.d.ts +12 -0
- package/dist/jsonForm/evaluateWhen.d.ts.map +1 -0
- package/dist/jsonForm/evaluateWhen.js +65 -0
- package/dist/jsonForm/evaluateWhen.js.map +1 -0
- package/dist/jsonForm/index.d.ts +14 -0
- package/dist/jsonForm/index.d.ts.map +1 -0
- package/dist/jsonForm/index.js +12 -0
- package/dist/jsonForm/index.js.map +1 -0
- package/dist/jsonForm/inferSchema.d.ts +12 -0
- package/dist/jsonForm/inferSchema.d.ts.map +1 -0
- package/dist/jsonForm/inferSchema.js +15 -0
- package/dist/jsonForm/inferSchema.js.map +1 -0
- package/dist/jsonForm/pointer.d.ts +26 -0
- package/dist/jsonForm/pointer.d.ts.map +1 -0
- package/dist/jsonForm/pointer.js +102 -0
- package/dist/jsonForm/pointer.js.map +1 -0
- package/dist/jsonForm/types.d.ts +120 -0
- package/dist/jsonForm/types.d.ts.map +1 -0
- package/dist/jsonForm/types.js +10 -0
- package/dist/jsonForm/types.js.map +1 -0
- package/dist/markdown/convert.d.ts +11 -1
- package/dist/markdown/convert.d.ts.map +1 -1
- package/dist/markdown/convert.js +235 -15
- package/dist/markdown/convert.js.map +1 -1
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.d.ts.map +1 -1
- package/dist/markdown/index.js +1 -1
- package/dist/markdown/index.js.map +1 -1
- package/dist/markdown/types.d.ts +34 -1
- package/dist/markdown/types.d.ts.map +1 -1
- package/dist/markdown/utils.d.ts +40 -0
- package/dist/markdown/utils.d.ts.map +1 -1
- package/dist/markdown/utils.js +155 -0
- package/dist/markdown/utils.js.map +1 -1
- package/dist/recommend/index.d.ts +16 -0
- package/dist/recommend/index.d.ts.map +1 -0
- package/dist/recommend/index.js +15 -0
- package/dist/recommend/index.js.map +1 -0
- package/dist/recommend/templates.d.ts +39 -0
- package/dist/recommend/templates.d.ts.map +1 -0
- package/dist/recommend/templates.js +235 -0
- package/dist/recommend/templates.js.map +1 -0
- package/dist/schemas/BlockTemplates.d.ts +46 -8
- package/dist/schemas/BlockTemplates.d.ts.map +1 -1
- package/dist/schemas/BlockTemplates.js +3 -3
- package/dist/schemas/BlockTemplates.js.map +1 -1
- package/dist/schemas/ImageEditDoc.d.ts +81 -0
- package/dist/schemas/ImageEditDoc.d.ts.map +1 -0
- package/dist/schemas/ImageEditDoc.js +20 -0
- package/dist/schemas/ImageEditDoc.js.map +1 -0
- package/dist/schemas/Theme.d.ts +93 -23
- package/dist/schemas/Theme.d.ts.map +1 -1
- package/dist/schemas/Theme.js +80 -13
- package/dist/schemas/Theme.js.map +1 -1
- package/dist/schemas/colorUtils.d.ts +51 -0
- package/dist/schemas/colorUtils.d.ts.map +1 -0
- package/dist/schemas/colorUtils.js +154 -0
- package/dist/schemas/colorUtils.js.map +1 -0
- package/dist/schemas/fontStacks.d.ts +57 -0
- package/dist/schemas/fontStacks.d.ts.map +1 -0
- package/dist/schemas/fontStacks.js +227 -0
- package/dist/schemas/fontStacks.js.map +1 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +4 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/themeCompile.d.ts +45 -0
- package/dist/schemas/themeCompile.d.ts.map +1 -0
- package/dist/schemas/themeCompile.js +160 -0
- package/dist/schemas/themeCompile.js.map +1 -0
- package/dist/schemas/themeLibrary.d.ts +11 -15
- package/dist/schemas/themeLibrary.d.ts.map +1 -1
- package/dist/schemas/themeLibrary.js +18 -499
- package/dist/schemas/themeLibrary.js.map +1 -1
- package/dist/schemas/themeValidator.d.ts +26 -0
- package/dist/schemas/themeValidator.d.ts.map +1 -0
- package/dist/schemas/themeValidator.js +352 -0
- package/dist/schemas/themeValidator.js.map +1 -0
- package/dist/schemas/themes/bold.json +48 -0
- package/dist/schemas/themes/cinematic.json +54 -0
- package/dist/schemas/themes/documentary.json +49 -0
- package/dist/schemas/themes/gezellig.json +44 -0
- package/dist/schemas/themes/index.d.ts +26 -0
- package/dist/schemas/themes/index.d.ts.map +1 -0
- package/dist/schemas/themes/index.js +49 -0
- package/dist/schemas/themes/index.js.map +1 -0
- package/dist/schemas/themes/magazine.json +44 -0
- package/dist/schemas/themes/minimalist.json +45 -0
- package/dist/schemas/themes/morning-light.json +42 -0
- package/dist/schemas/themes/standard-dark.json +50 -0
- package/dist/schemas/themes/standard.json +42 -0
- package/dist/schemas/themes/tech-dark.json +48 -0
- package/dist/schemas/themes/warm-earth.json +50 -0
- package/dist/storage/ScopedContentContainer.d.ts +44 -0
- package/dist/storage/ScopedContentContainer.d.ts.map +1 -0
- package/dist/storage/ScopedContentContainer.js +94 -0
- package/dist/storage/ScopedContentContainer.js.map +1 -0
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +1 -0
- package/dist/storage/index.js.map +1 -1
- package/dist/story/index.d.ts +53 -13
- package/dist/story/index.js +12 -4
- package/dist/themeLibrary-BHjJ0Qx6.d.ts +40 -0
- package/dist/{types-DYAzisMG.d.ts → types-BdZkdJ3z.d.ts} +35 -2
- package/dist/types-D98li1gV.d.ts +93 -0
- package/dist/versions/DocumentVersionManager.d.ts +31 -0
- package/dist/versions/DocumentVersionManager.d.ts.map +1 -0
- package/dist/versions/DocumentVersionManager.js +33 -0
- package/dist/versions/DocumentVersionManager.js.map +1 -0
- package/dist/versions/index.d.ts +29 -0
- package/dist/versions/index.d.ts.map +1 -0
- package/dist/versions/index.js +28 -0
- package/dist/versions/index.js.map +1 -0
- package/dist/versions/operations.d.ts +44 -0
- package/dist/versions/operations.d.ts.map +1 -0
- package/dist/versions/operations.js +190 -0
- package/dist/versions/operations.js.map +1 -0
- package/dist/versions/paths.d.ts +29 -0
- package/dist/versions/paths.d.ts.map +1 -0
- package/dist/versions/paths.js +66 -0
- package/dist/versions/paths.js.map +1 -0
- package/dist/versions/timestamp.d.ts +22 -0
- package/dist/versions/timestamp.d.ts.map +1 -0
- package/dist/versions/timestamp.js +44 -0
- package/dist/versions/timestamp.js.map +1 -0
- package/dist/versions/types.d.ts +92 -0
- package/dist/versions/types.d.ts.map +1 -0
- package/dist/versions/types.js +11 -0
- package/dist/versions/types.js.map +1 -0
- package/package.json +28 -1
- package/src/__tests__/colorUtils.test.ts +112 -0
- package/src/__tests__/getLayers.test.ts +32 -7
- package/src/__tests__/iconResolve.test.ts +122 -0
- package/src/__tests__/imageEditState.test.ts +74 -0
- package/src/__tests__/imageEditVersions.test.ts +169 -0
- package/src/__tests__/inferDocumentTitle.test.ts +50 -0
- package/src/__tests__/jsonForm.chooseControl.test.ts +86 -0
- package/src/__tests__/jsonForm.evaluateWhen.test.ts +59 -0
- package/src/__tests__/jsonForm.inferSchema.test.ts +25 -0
- package/src/__tests__/jsonForm.pointer.test.ts +103 -0
- package/src/__tests__/markdown.test.ts +44 -0
- package/src/__tests__/markdownIcons.test.ts +104 -0
- package/src/__tests__/markdownToDoc.test.ts +19 -4
- package/src/__tests__/recommendTemplates.test.ts +183 -0
- package/src/__tests__/scopedContentContainer.test.ts +89 -0
- package/src/__tests__/slideshowGenerator.test.ts +1 -1
- package/src/__tests__/surface.test.ts +68 -0
- package/src/__tests__/templateAnnotationParse.test.ts +42 -0
- package/src/__tests__/templates.test.ts +93 -9
- package/src/__tests__/themeCompile.test.ts +156 -0
- package/src/__tests__/themeValidator.test.ts +125 -0
- package/src/__tests__/versions.test.ts +415 -0
- package/src/doc/audioMapping.ts +95 -13
- package/src/doc/getLayers.ts +32 -21
- package/src/doc/markdownToDoc.ts +45 -7
- package/src/doc/templates/featureBlock.ts +202 -0
- package/src/doc/templates/fullBleedQuote.ts +13 -0
- package/src/doc/templates/index.ts +50 -16
- package/src/doc/templates/listBlock.ts +24 -5
- package/src/doc/templates/statHighlight.ts +13 -0
- package/src/doc/templates/titleBlock.ts +9 -0
- package/src/doc/utils/themeUtils.ts +8 -7
- package/src/generate/slideshowGenerator.ts +1 -1
- package/src/generate/templateMapper.ts +2 -2
- package/src/icons/iconData.ts +31 -0
- package/src/icons/index.ts +18 -0
- package/src/icons/resolve.ts +139 -0
- package/src/imageEdit/ImageEditVersionManager.ts +73 -0
- package/src/imageEdit/export.ts +326 -0
- package/src/imageEdit/index.ts +71 -0
- package/src/imageEdit/persistence.ts +62 -0
- package/src/imageEdit/state.ts +112 -0
- package/src/imageEdit/versionPaths.ts +57 -0
- package/src/imageEdit/versions.ts +231 -0
- package/src/index.ts +4 -0
- package/src/jsonForm/chooseControl.ts +88 -0
- package/src/jsonForm/evaluateWhen.ts +59 -0
- package/src/jsonForm/index.ts +22 -0
- package/src/jsonForm/inferSchema.ts +25 -0
- package/src/jsonForm/pointer.ts +109 -0
- package/src/jsonForm/types.ts +167 -0
- package/src/markdown/convert.ts +248 -15
- package/src/markdown/index.ts +4 -0
- package/src/markdown/types.ts +38 -1
- package/src/markdown/utils.ts +159 -0
- package/src/recommend/index.ts +16 -0
- package/src/recommend/templates.ts +273 -0
- package/src/schemas/BlockTemplates.ts +50 -7
- package/src/schemas/ImageEditDoc.ts +95 -0
- package/src/schemas/Theme.ts +152 -23
- package/src/schemas/colorUtils.ts +186 -0
- package/src/schemas/fontStacks.ts +257 -0
- package/src/schemas/index.ts +12 -0
- package/src/schemas/themeCompile.ts +203 -0
- package/src/schemas/themeLibrary.ts +18 -524
- package/src/schemas/themeValidator.ts +388 -0
- package/src/schemas/themes/bold.json +48 -0
- package/src/schemas/themes/cinematic.json +54 -0
- package/src/schemas/themes/documentary.json +49 -0
- package/src/schemas/themes/gezellig.json +44 -0
- package/src/schemas/themes/index.ts +53 -0
- package/src/schemas/themes/magazine.json +44 -0
- package/src/schemas/themes/minimalist.json +45 -0
- package/src/schemas/themes/morning-light.json +42 -0
- package/src/schemas/themes/standard-dark.json +50 -0
- package/src/schemas/themes/standard.json +42 -0
- package/src/schemas/themes/tech-dark.json +48 -0
- package/src/schemas/themes/warm-earth.json +50 -0
- package/src/storage/ScopedContentContainer.ts +113 -0
- package/src/storage/index.ts +1 -0
- package/src/versions/DocumentVersionManager.ts +70 -0
- package/src/versions/index.ts +54 -0
- package/src/versions/operations.ts +230 -0
- package/src/versions/paths.ts +66 -0
- package/src/versions/timestamp.ts +48 -0
- package/src/versions/types.ts +91 -0
- package/dist/chunk-53TZ2UTL.js +0 -470
- package/dist/chunk-53TZ2UTL.js.map +0 -1
- package/dist/chunk-7GF6RDED.js +0 -82
- package/dist/chunk-7GF6RDED.js.map +0 -1
- package/dist/chunk-CYQHG27J.js.map +0 -1
- package/dist/chunk-GAQLMORN.js.map +0 -1
- package/dist/chunk-LAZELBON.js.map +0 -1
- package/dist/chunk-QM5PKNPW.js.map +0 -1
- package/dist/chunk-TSG2OSE6.js.map +0 -1
- package/dist/chunk-XM4WSOHB.js +0 -92
- package/dist/chunk-XM4WSOHB.js.map +0 -1
- package/dist/themeLibrary-IP7EdyRq.d.ts +0 -44
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Font Stacks
|
|
3
|
+
*
|
|
4
|
+
* Curated registry of font families used by built-in themes and offered in
|
|
5
|
+
* the theme customizer. Each stack has a stable `id` (referenced by JSON
|
|
6
|
+
* theme files via `{ stackId }`) and a CSS `family` string that resolves
|
|
7
|
+
* to the actual font when rendered.
|
|
8
|
+
*
|
|
9
|
+
* Themes never carry raw CSS font strings — they reference a `stackId` or
|
|
10
|
+
* specify a `{ custom: { name, fallback } }` form, both of which resolve
|
|
11
|
+
* here at render time.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { FontFamily, FontFamilyKind } from './Theme.js';
|
|
15
|
+
|
|
16
|
+
export interface FontStack {
|
|
17
|
+
/** Stable identifier referenced by Theme JSON. */
|
|
18
|
+
id: string;
|
|
19
|
+
/** Display label for pickers. */
|
|
20
|
+
label: string;
|
|
21
|
+
/** Full CSS font-family string with safe fallbacks. */
|
|
22
|
+
family: string;
|
|
23
|
+
/** Categorical bucket for the picker UI. */
|
|
24
|
+
kind: FontFamilyKind;
|
|
25
|
+
/**
|
|
26
|
+
* Google Fonts family name, when this stack is served by Google Fonts.
|
|
27
|
+
* Used by exports that bundle a `<link>` to fonts.googleapis.com so the
|
|
28
|
+
* face renders correctly even when the host page doesn't preload it.
|
|
29
|
+
* Omit (or set to undefined) for purely system stacks.
|
|
30
|
+
*/
|
|
31
|
+
googleFontFamily?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** All curated stacks, in the order they should appear in pickers. */
|
|
35
|
+
export const AVAILABLE_FONT_STACKS: FontStack[] = [
|
|
36
|
+
// System defaults
|
|
37
|
+
{
|
|
38
|
+
id: 'system-sans',
|
|
39
|
+
label: 'System Sans',
|
|
40
|
+
family: 'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',
|
|
41
|
+
kind: 'sans',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 'system-serif',
|
|
45
|
+
label: 'System Serif',
|
|
46
|
+
family: 'Georgia, "Times New Roman", serif',
|
|
47
|
+
kind: 'serif',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'system-mono',
|
|
51
|
+
label: 'System Mono',
|
|
52
|
+
family: 'Consolas, "Courier New", monospace',
|
|
53
|
+
kind: 'mono',
|
|
54
|
+
},
|
|
55
|
+
// Curated Google Fonts. `googleFontFamily` is the canonical family
|
|
56
|
+
// name Google serves the face under (used by exports that emit a
|
|
57
|
+
// `<link rel="stylesheet" href="https://fonts.googleapis.com/...">`
|
|
58
|
+
// so the face renders even when the host doesn't preload it).
|
|
59
|
+
{
|
|
60
|
+
id: 'inter',
|
|
61
|
+
label: 'Inter',
|
|
62
|
+
family: '"Inter", "Segoe UI", Roboto, sans-serif',
|
|
63
|
+
kind: 'sans',
|
|
64
|
+
googleFontFamily: 'Inter',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 'ibm-plex-sans',
|
|
68
|
+
label: 'IBM Plex Sans',
|
|
69
|
+
family: '"IBM Plex Sans", "Segoe UI", Roboto, sans-serif',
|
|
70
|
+
kind: 'sans',
|
|
71
|
+
googleFontFamily: 'IBM Plex Sans',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: 'roboto',
|
|
75
|
+
label: 'Roboto',
|
|
76
|
+
family: '"Roboto", "Segoe UI", Arial, sans-serif',
|
|
77
|
+
kind: 'sans',
|
|
78
|
+
googleFontFamily: 'Roboto',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id: 'dm-sans',
|
|
82
|
+
label: 'DM Sans',
|
|
83
|
+
family: '"DM Sans", "Segoe UI", Roboto, sans-serif',
|
|
84
|
+
kind: 'sans',
|
|
85
|
+
googleFontFamily: 'DM Sans',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 'oswald',
|
|
89
|
+
label: 'Oswald',
|
|
90
|
+
family: '"Oswald", Impact, "Arial Black", sans-serif',
|
|
91
|
+
kind: 'display',
|
|
92
|
+
googleFontFamily: 'Oswald',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: 'playfair',
|
|
96
|
+
label: 'Playfair Display',
|
|
97
|
+
family: '"Playfair Display", Georgia, serif',
|
|
98
|
+
kind: 'serif',
|
|
99
|
+
googleFontFamily: 'Playfair Display',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: 'source-serif',
|
|
103
|
+
label: 'Source Serif',
|
|
104
|
+
family: '"Source Serif 4", "PT Serif", Georgia, serif',
|
|
105
|
+
kind: 'serif',
|
|
106
|
+
googleFontFamily: 'Source Serif 4',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: 'merriweather',
|
|
110
|
+
label: 'Merriweather',
|
|
111
|
+
family: '"Merriweather", Georgia, serif',
|
|
112
|
+
kind: 'serif',
|
|
113
|
+
googleFontFamily: 'Merriweather',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: 'lora',
|
|
117
|
+
label: 'Lora',
|
|
118
|
+
family: '"Lora", "Merriweather", Georgia, serif',
|
|
119
|
+
kind: 'serif',
|
|
120
|
+
googleFontFamily: 'Lora',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: 'pt-serif',
|
|
124
|
+
label: 'PT Serif',
|
|
125
|
+
family: '"PT Serif", Georgia, serif',
|
|
126
|
+
kind: 'serif',
|
|
127
|
+
googleFontFamily: 'PT Serif',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
id: 'crimson',
|
|
131
|
+
label: 'Crimson Text',
|
|
132
|
+
family: '"Crimson Text", Georgia, serif',
|
|
133
|
+
kind: 'serif',
|
|
134
|
+
googleFontFamily: 'Crimson Text',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: 'cormorant',
|
|
138
|
+
label: 'Cormorant Garamond',
|
|
139
|
+
family: '"Cormorant Garamond", Garamond, Georgia, serif',
|
|
140
|
+
kind: 'serif',
|
|
141
|
+
googleFontFamily: 'Cormorant Garamond',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: 'dm-serif',
|
|
145
|
+
label: 'DM Serif Display',
|
|
146
|
+
family: '"DM Serif Display", Georgia, serif',
|
|
147
|
+
kind: 'display',
|
|
148
|
+
googleFontFamily: 'DM Serif Display',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
id: 'jetbrains-mono',
|
|
152
|
+
label: 'JetBrains Mono',
|
|
153
|
+
family: '"JetBrains Mono", "Fira Code", Consolas, monospace',
|
|
154
|
+
kind: 'mono',
|
|
155
|
+
googleFontFamily: 'JetBrains Mono',
|
|
156
|
+
},
|
|
157
|
+
// Themed system stacks with emoji fallbacks (used by gezellig)
|
|
158
|
+
{
|
|
159
|
+
id: 'system-sans-emoji',
|
|
160
|
+
label: 'System Sans + Emoji',
|
|
161
|
+
family:
|
|
162
|
+
'system-ui, -apple-system, "Segoe UI", Roboto, "OpenMoji Color", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif',
|
|
163
|
+
kind: 'sans',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
id: 'system-serif-emoji',
|
|
167
|
+
label: 'System Serif + Emoji',
|
|
168
|
+
family:
|
|
169
|
+
'Georgia, "Times New Roman", "OpenMoji Color", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", serif',
|
|
170
|
+
kind: 'serif',
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
const STACKS_BY_ID: Record<string, FontStack> = Object.fromEntries(
|
|
175
|
+
AVAILABLE_FONT_STACKS.map((s) => [s.id, s]),
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
/** Look up a stack by id. Returns undefined if not registered. */
|
|
179
|
+
export function getFontStack(id: string): FontStack | undefined {
|
|
180
|
+
return STACKS_BY_ID[id];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Default fallback CSS family per kind, used when a custom font has no fallback specified. */
|
|
184
|
+
const FALLBACK_BY_KIND: Record<FontFamilyKind, string> = {
|
|
185
|
+
sans: 'system-ui, sans-serif',
|
|
186
|
+
serif: 'Georgia, serif',
|
|
187
|
+
mono: 'Consolas, monospace',
|
|
188
|
+
display: 'Impact, Arial, sans-serif',
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Resolve a `FontFamily` reference (or legacy raw string) to a CSS family string.
|
|
193
|
+
* Used by `getThemeFont` at render time. Never returns an empty string —
|
|
194
|
+
* unrecognized stackIds fall back to the requested role's default.
|
|
195
|
+
*/
|
|
196
|
+
export function resolveFontFamily(
|
|
197
|
+
family: FontFamily | string | undefined,
|
|
198
|
+
roleFallback: string,
|
|
199
|
+
): string {
|
|
200
|
+
if (!family) return roleFallback;
|
|
201
|
+
if (typeof family === 'string') return family;
|
|
202
|
+
if ('stackId' in family) {
|
|
203
|
+
const stack = STACKS_BY_ID[family.stackId];
|
|
204
|
+
return stack ? stack.family : roleFallback;
|
|
205
|
+
}
|
|
206
|
+
if ('custom' in family) {
|
|
207
|
+
const { name, fallback } = family.custom;
|
|
208
|
+
const fb =
|
|
209
|
+
fallback === 'system-ui'
|
|
210
|
+
? 'system-ui, sans-serif'
|
|
211
|
+
: fallback === 'serif'
|
|
212
|
+
? 'Georgia, serif'
|
|
213
|
+
: fallback === 'monospace'
|
|
214
|
+
? 'Consolas, monospace'
|
|
215
|
+
: 'system-ui, sans-serif';
|
|
216
|
+
const safeName = name.includes(' ') || name.includes(',') ? `"${name}"` : name;
|
|
217
|
+
return `${safeName}, ${fb}`;
|
|
218
|
+
}
|
|
219
|
+
return roleFallback;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Convenience: quick `{ stackId }` factory for code that constructs themes. */
|
|
223
|
+
export function fontStack(id: string): FontFamily {
|
|
224
|
+
return { stackId: id };
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Build a `https://fonts.googleapis.com/css2?...` URL that loads the
|
|
229
|
+
* subset of supplied `FontFamily` references that are served by Google
|
|
230
|
+
* Fonts. Returns `null` when nothing in the list needs Google hosting
|
|
231
|
+
* (system stacks, custom fonts, or unknown stack ids) — callers can use
|
|
232
|
+
* that to skip emitting a `<link>` entirely.
|
|
233
|
+
*
|
|
234
|
+
* The URL requests regular + bold (400/700) for each family, which is
|
|
235
|
+
* what the templates use. `display=swap` keeps the fallback visible
|
|
236
|
+
* while the web font streams in.
|
|
237
|
+
*/
|
|
238
|
+
export function buildGoogleFontsUrl(families: Array<FontFamily | undefined>): string | null {
|
|
239
|
+
const names = new Set<string>();
|
|
240
|
+
for (const f of families) {
|
|
241
|
+
if (!f || typeof f === 'string') continue;
|
|
242
|
+
if ('stackId' in f) {
|
|
243
|
+
const stack = STACKS_BY_ID[f.stackId];
|
|
244
|
+
if (stack?.googleFontFamily) names.add(stack.googleFontFamily);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (names.size === 0) return null;
|
|
248
|
+
// css2 syntax: ?family=Name+With+Spaces:wght@400;700&family=Other:wght@400;700&display=swap
|
|
249
|
+
const params = Array.from(names)
|
|
250
|
+
.sort()
|
|
251
|
+
.map((name) => `family=${encodeURIComponent(name).replace(/%20/g, '+')}:wght@400;700`)
|
|
252
|
+
.join('&');
|
|
253
|
+
return `https://fonts.googleapis.com/css2?${params}&display=swap`;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** Default fallback families exposed for tools that need them. */
|
|
257
|
+
export const FONT_FALLBACKS = FALLBACK_BY_KIND;
|
package/src/schemas/index.ts
CHANGED
|
@@ -3,6 +3,10 @@ export * from './Doc.js';
|
|
|
3
3
|
export * from './BlockTemplates.js';
|
|
4
4
|
export * from './Theme.js';
|
|
5
5
|
export * from './themeLibrary.js';
|
|
6
|
+
export * from './themeValidator.js';
|
|
7
|
+
export * from './themeCompile.js';
|
|
8
|
+
export * from './fontStacks.js';
|
|
9
|
+
export * from './colorUtils.js';
|
|
6
10
|
export * from './Viewport.js';
|
|
7
11
|
export {
|
|
8
12
|
getLayoutHints,
|
|
@@ -12,3 +16,11 @@ export {
|
|
|
12
16
|
} from './LayoutStrategy.js';
|
|
13
17
|
export type { LayoutHints } from './LayoutStrategy.js';
|
|
14
18
|
export type { MediaProvider, MediaEntry } from './MediaProvider.js';
|
|
19
|
+
export type {
|
|
20
|
+
ImageEditDoc,
|
|
21
|
+
ImageEditLayer,
|
|
22
|
+
ImageEditLayerKind,
|
|
23
|
+
ImageEditCanvas,
|
|
24
|
+
ImageEditMeta,
|
|
25
|
+
EditorLayerMeta,
|
|
26
|
+
} from './ImageEditDoc.js';
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Compilation
|
|
3
|
+
*
|
|
4
|
+
* Turns a partial Theme (typically authored by the customizer panel from
|
|
5
|
+
* a few seed colors and preset choices) into a complete, validated Theme
|
|
6
|
+
* by:
|
|
7
|
+
*
|
|
8
|
+
* 1. Filling unspecified fields from a hardcoded `STARTER_THEME`.
|
|
9
|
+
* 2. Deriving missing color slots from `seedColors` via OKLCh math.
|
|
10
|
+
* 3. Validating the result.
|
|
11
|
+
*
|
|
12
|
+
* Built-in themes ship as fully-specified Theme JSON and skip this step.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type {
|
|
16
|
+
Theme,
|
|
17
|
+
DeepPartial,
|
|
18
|
+
ThemeColorPalette,
|
|
19
|
+
ThemeColorScheme,
|
|
20
|
+
ThemeSeedColors,
|
|
21
|
+
FontFamily,
|
|
22
|
+
} from './Theme.js';
|
|
23
|
+
import { THEME_SCHEMA_VERSION, createTheme } from './Theme.js';
|
|
24
|
+
import { assertTheme } from './themeValidator.js';
|
|
25
|
+
import {
|
|
26
|
+
oklchLighten,
|
|
27
|
+
oklchDarken,
|
|
28
|
+
oklchSetChroma,
|
|
29
|
+
pickContrastingText,
|
|
30
|
+
relativeLuminance,
|
|
31
|
+
} from './colorUtils.js';
|
|
32
|
+
|
|
33
|
+
/** Internal default theme used to fill in fields the customizer doesn't expose. */
|
|
34
|
+
const STARTER_BODY_FONT: FontFamily = { stackId: 'system-sans' };
|
|
35
|
+
const STARTER_TITLE_FONT: FontFamily = { stackId: 'system-serif' };
|
|
36
|
+
const STARTER_MONO_FONT: FontFamily = { stackId: 'system-mono' };
|
|
37
|
+
|
|
38
|
+
const STARTER_COLOR_SCHEMES: Record<string, ThemeColorScheme> = {
|
|
39
|
+
blue: { bg: '#1a365d', text: '#63b3ed', accent: '#90cdf4' },
|
|
40
|
+
green: { bg: '#22543d', text: '#9ae6b4', accent: '#68d391' },
|
|
41
|
+
purple: { bg: '#44337a', text: '#d6bcfa', accent: '#b794f4' },
|
|
42
|
+
red: { bg: '#742a2a', text: '#fc8181', accent: '#feb2b2' },
|
|
43
|
+
orange: { bg: '#744210', text: '#fbd38d', accent: '#f6ad55' },
|
|
44
|
+
teal: { bg: '#234e52', text: '#81e6d9', accent: '#4fd1c5' },
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const STARTER_THEME: Theme = {
|
|
48
|
+
schemaVersion: THEME_SCHEMA_VERSION,
|
|
49
|
+
id: 'custom',
|
|
50
|
+
name: 'Custom Theme',
|
|
51
|
+
description: 'Customizer starter — gets overridden by user choices.',
|
|
52
|
+
colors: {
|
|
53
|
+
primary: '#3182ce',
|
|
54
|
+
secondary: '#4a5568',
|
|
55
|
+
background: '#1a202c',
|
|
56
|
+
backgroundLight: '#2d3748',
|
|
57
|
+
text: '#f7fafc',
|
|
58
|
+
textMuted: '#a0aec0',
|
|
59
|
+
highlight: '#4299e1',
|
|
60
|
+
warning: '#fc8181',
|
|
61
|
+
},
|
|
62
|
+
typography: {
|
|
63
|
+
bodyFont: STARTER_BODY_FONT,
|
|
64
|
+
titleFont: STARTER_TITLE_FONT,
|
|
65
|
+
monoFont: STARTER_MONO_FONT,
|
|
66
|
+
titleWeight: 'bold',
|
|
67
|
+
},
|
|
68
|
+
style: {
|
|
69
|
+
textShadow: true,
|
|
70
|
+
overlayOpacity: 0.45,
|
|
71
|
+
animationSpeed: 1.0,
|
|
72
|
+
borderRadius: 6,
|
|
73
|
+
},
|
|
74
|
+
renderStyle: {
|
|
75
|
+
name: 'standard',
|
|
76
|
+
defaultTextAnimation: 'fadeIn',
|
|
77
|
+
defaultImageAnimation: 'slowZoom',
|
|
78
|
+
ambientMotion: true,
|
|
79
|
+
defaultTransition: { type: 'fade', duration: 0.7 },
|
|
80
|
+
},
|
|
81
|
+
colorSchemes: STARTER_COLOR_SCHEMES,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Derive a full `ThemeColorPalette` from `seedColors`, with any explicit
|
|
86
|
+
* `partialColors` taking precedence over derived values. Background and
|
|
87
|
+
* text are guessed from luminance when the user gave only a primary.
|
|
88
|
+
*/
|
|
89
|
+
export function deriveColorPalette(
|
|
90
|
+
seeds: ThemeSeedColors,
|
|
91
|
+
partialColors: Partial<ThemeColorPalette> = {},
|
|
92
|
+
opts: { contrast?: 'subtle' | 'balanced' | 'high' } = {},
|
|
93
|
+
): ThemeColorPalette {
|
|
94
|
+
const spread = opts.contrast === 'high' ? 0.22 : opts.contrast === 'subtle' ? 0.08 : 0.15;
|
|
95
|
+
|
|
96
|
+
const primary = seeds.primary;
|
|
97
|
+
const secondary = seeds.secondary ?? oklchSetChroma(oklchLighten(primary, 0.05), 0.5);
|
|
98
|
+
const accent = seeds.accent ?? oklchLighten(primary, spread);
|
|
99
|
+
|
|
100
|
+
// Decide light vs dark surface from the explicit background, the seed background,
|
|
101
|
+
// or default to dark.
|
|
102
|
+
const bgSeed = partialColors.background ?? seeds.background;
|
|
103
|
+
let background: string;
|
|
104
|
+
if (bgSeed) {
|
|
105
|
+
background = bgSeed;
|
|
106
|
+
} else {
|
|
107
|
+
// Pick a dark or light background that contrasts with primary
|
|
108
|
+
background = relativeLuminance(primary) > 0.5 ? '#0a0a0a' : '#1a202c';
|
|
109
|
+
}
|
|
110
|
+
const isLightSurface = relativeLuminance(background) > 0.5;
|
|
111
|
+
|
|
112
|
+
const backgroundLight =
|
|
113
|
+
partialColors.backgroundLight ??
|
|
114
|
+
(isLightSurface ? oklchDarken(background, 0.04) : oklchLighten(background, 0.04));
|
|
115
|
+
|
|
116
|
+
const text =
|
|
117
|
+
partialColors.text ?? seeds.text ?? pickContrastingText(background, '#f7fafc', '#1a202c');
|
|
118
|
+
const textMuted =
|
|
119
|
+
partialColors.textMuted ??
|
|
120
|
+
(isLightSurface ? oklchLighten(text, 0.25) : oklchDarken(text, 0.25));
|
|
121
|
+
|
|
122
|
+
const highlight = partialColors.highlight ?? accent;
|
|
123
|
+
const warning = partialColors.warning ?? '#fc8181';
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
primary: partialColors.primary ?? primary,
|
|
127
|
+
secondary: partialColors.secondary ?? secondary,
|
|
128
|
+
background,
|
|
129
|
+
backgroundLight,
|
|
130
|
+
text,
|
|
131
|
+
textMuted,
|
|
132
|
+
highlight,
|
|
133
|
+
warning,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Map a contrast preset to numeric spread used by `deriveColorPalette`. */
|
|
138
|
+
export type ContrastPreset = 'subtle' | 'balanced' | 'high';
|
|
139
|
+
|
|
140
|
+
export interface CompileOptions {
|
|
141
|
+
/** Contrast level for OKLCh derivation (default 'balanced'). */
|
|
142
|
+
contrast?: ContrastPreset;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Compile a partial Theme into a complete one. Fills missing fields from
|
|
147
|
+
* `STARTER_THEME`, derives missing color slots from `seedColors` (when
|
|
148
|
+
* present), and validates the result.
|
|
149
|
+
*/
|
|
150
|
+
export function compileTheme(partial: DeepPartial<Theme>, opts: CompileOptions = {}): Theme {
|
|
151
|
+
// Step 1: deep-merge over the starter
|
|
152
|
+
const merged = createTheme(STARTER_THEME, partial);
|
|
153
|
+
merged.schemaVersion = THEME_SCHEMA_VERSION;
|
|
154
|
+
|
|
155
|
+
// Step 1b: typography fonts are discriminated unions ({stackId} | {custom}),
|
|
156
|
+
// so deep-merge would leave stale keys from the starter when the partial
|
|
157
|
+
// switches form. Replace each font wholesale when explicitly provided.
|
|
158
|
+
const partialTypography = partial.typography;
|
|
159
|
+
if (partialTypography) {
|
|
160
|
+
if (partialTypography.titleFont !== undefined) {
|
|
161
|
+
merged.typography.titleFont = partialTypography.titleFont as FontFamily;
|
|
162
|
+
}
|
|
163
|
+
if (partialTypography.bodyFont !== undefined) {
|
|
164
|
+
merged.typography.bodyFont = partialTypography.bodyFont as FontFamily;
|
|
165
|
+
}
|
|
166
|
+
if (partialTypography.monoFont !== undefined) {
|
|
167
|
+
merged.typography.monoFont = partialTypography.monoFont as FontFamily;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Step 2: derive missing color slots from seeds, if present
|
|
172
|
+
if (merged.seedColors) {
|
|
173
|
+
const partialColors = (partial.colors ?? {}) as Partial<ThemeColorPalette>;
|
|
174
|
+
merged.colors = deriveColorPalette(merged.seedColors, partialColors, {
|
|
175
|
+
contrast: opts.contrast,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Step 3: validate
|
|
180
|
+
return assertTheme(merged, `compiled theme "${merged.id}"`);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Parse a JSON string into a validated Theme. Throws on invalid input.
|
|
185
|
+
*/
|
|
186
|
+
export function parseTheme(json: string): Theme {
|
|
187
|
+
let parsed: unknown;
|
|
188
|
+
try {
|
|
189
|
+
parsed = JSON.parse(json);
|
|
190
|
+
} catch (err) {
|
|
191
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
192
|
+
throw new Error(`Invalid theme JSON: ${msg}`);
|
|
193
|
+
}
|
|
194
|
+
return assertTheme(parsed, 'parsed theme');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Serialize a Theme to a stable, pretty-printed JSON string. Round-trips
|
|
199
|
+
* cleanly through `parseTheme`.
|
|
200
|
+
*/
|
|
201
|
+
export function serializeTheme(theme: Theme): string {
|
|
202
|
+
return JSON.stringify(theme, null, 2);
|
|
203
|
+
}
|